OSDN Git Service

fb2be33d96a35861444c5799a1fb4fa627c9213f
[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  GNAT is maintained by Ada Core Technologies Inc (http://www.gnat.com).    o
12 @c                                                                            o
13 @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
14
15 @setfilename gnat_rm.info
16
17 @copying
18 Copyright @copyright{} 1995-2008, Free Software Foundation, Inc.
19
20 Permission is granted to copy, distribute and/or modify this document
21 under the terms of the GNU Free Documentation License, Version 1.3 or
22 any later version published by the Free Software Foundation; with no
23 Invariant Sections, with the Front-Cover Texts being ``GNAT Reference
24 Manual'', and with no Back-Cover Texts.  A copy of the license is
25 included in the section entitled ``GNU Free Documentation License''.
26 @end copying
27
28 @set EDITION GNAT
29 @set DEFAULTLANGUAGEVERSION Ada 2005
30 @set NONDEFAULTLANGUAGEVERSION Ada 95
31
32 @settitle GNAT Reference Manual
33
34 @setchapternewpage odd
35 @syncodeindex fn cp
36
37 @include gcc-common.texi
38
39 @dircategory GNU Ada tools
40 @direntry
41 * GNAT Reference Manual: (gnat_rm).  Reference Manual for GNU Ada tools.
42 @end direntry
43
44 @titlepage
45 @title GNAT Reference Manual
46 @subtitle GNAT, The GNU Ada Compiler
47 @versionsubtitle
48 @author AdaCore
49 @page
50 @vskip 0pt plus 1filll
51
52 @insertcopying
53
54 @end titlepage
55
56 @ifnottex
57 @node Top, About This Guide, (dir), (dir)
58 @top GNAT Reference Manual
59
60 @noindent
61 GNAT Reference Manual
62
63 @noindent
64 GNAT, The GNU Ada Compiler@*
65 GCC version @value{version-GCC}@*
66
67 @noindent
68 AdaCore
69
70 @menu
71 * About This Guide::
72 * Implementation Defined Pragmas::
73 * Implementation Defined Attributes::
74 * Implementation Advice::
75 * Implementation Defined Characteristics::
76 * Intrinsic Subprograms::
77 * Representation Clauses and Pragmas::
78 * Standard Library Routines::
79 * The Implementation of Standard I/O::
80 * The GNAT Library::
81 * Interfacing to Other Languages::
82 * Specialized Needs Annexes::
83 * Implementation of Specific Ada Features::
84 * Implementation of Ada 2012 Features::
85 * Obsolescent Features::
86 * GNU Free Documentation License::
87 * Index::
88
89  --- The Detailed Node Listing ---
90
91 About This Guide
92
93 * What This Reference Manual Contains::
94 * Related Information::
95
96 Implementation Defined Pragmas
97
98 * Pragma Abort_Defer::
99 * Pragma Ada_83::
100 * Pragma Ada_95::
101 * Pragma Ada_05::
102 * Pragma Ada_2005::
103 * Pragma Ada_12::
104 * Pragma Ada_2012::
105 * Pragma Annotate::
106 * Pragma Assert::
107 * Pragma Assertion_Policy::
108 * Pragma Assume_No_Invalid_Values::
109 * Pragma Ast_Entry::
110 * Pragma C_Pass_By_Copy::
111 * Pragma Check::
112 * Pragma Check_Name::
113 * Pragma Check_Policy::
114 * Pragma Comment::
115 * Pragma Common_Object::
116 * Pragma Compile_Time_Error::
117 * Pragma Compile_Time_Warning::
118 * Pragma Compiler_Unit::
119 * Pragma Complete_Representation::
120 * Pragma Complex_Representation::
121 * Pragma Component_Alignment::
122 * Pragma Convention_Identifier::
123 * Pragma CPP_Class::
124 * Pragma CPP_Constructor::
125 * Pragma CPP_Virtual::
126 * Pragma CPP_Vtable::
127 * Pragma Debug::
128 * Pragma Debug_Policy::
129 * Pragma Detect_Blocking::
130 * Pragma Elaboration_Checks::
131 * Pragma Eliminate::
132 * Pragma Export_Exception::
133 * Pragma Export_Function::
134 * Pragma Export_Object::
135 * Pragma Export_Procedure::
136 * Pragma Export_Value::
137 * Pragma Export_Valued_Procedure::
138 * Pragma Extend_System::
139 * Pragma Extensions_Allowed::
140 * Pragma External::
141 * Pragma External_Name_Casing::
142 * Pragma Fast_Math::
143 * Pragma Favor_Top_Level::
144 * Pragma Finalize_Storage_Only::
145 * Pragma Float_Representation::
146 * Pragma Ident::
147 * Pragma Implemented::
148 * Pragma Implicit_Packing::
149 * Pragma Import_Exception::
150 * Pragma Import_Function::
151 * Pragma Import_Object::
152 * Pragma Import_Procedure::
153 * Pragma Import_Valued_Procedure::
154 * Pragma Initialize_Scalars::
155 * Pragma Inline_Always::
156 * Pragma Inline_Generic::
157 * Pragma Interface::
158 * Pragma Interface_Name::
159 * Pragma Interrupt_Handler::
160 * Pragma Interrupt_State::
161 * Pragma Invariant::
162 * Pragma Keep_Names::
163 * Pragma License::
164 * Pragma Link_With::
165 * Pragma Linker_Alias::
166 * Pragma Linker_Constructor::
167 * Pragma Linker_Destructor::
168 * Pragma Linker_Section::
169 * Pragma Long_Float::
170 * Pragma Machine_Attribute::
171 * Pragma Main::
172 * Pragma Main_Storage::
173 * Pragma No_Body::
174 * Pragma No_Return::
175 * Pragma No_Strict_Aliasing ::
176 * Pragma Normalize_Scalars::
177 * Pragma Obsolescent::
178 * Pragma Optimize_Alignment::
179 * Pragma Ordered::
180 * Pragma Passive::
181 * Pragma Persistent_BSS::
182 * Pragma Polling::
183 * Pragma Postcondition::
184 * Pragma Precondition::
185 * Pragma Profile (Ravenscar)::
186 * Pragma Profile (Restricted)::
187 * Pragma Psect_Object::
188 * Pragma Pure_Function::
189 * Pragma Restriction_Warnings::
190 * Pragma Shared::
191 * Pragma Short_Circuit_And_Or::
192 * Pragma Short_Descriptors::
193 * Pragma Source_File_Name::
194 * Pragma Source_File_Name_Project::
195 * Pragma Source_Reference::
196 * Pragma Static_Elaboration_Desired::
197 * Pragma Stream_Convert::
198 * Pragma Style_Checks::
199 * Pragma Subtitle::
200 * Pragma Suppress::
201 * Pragma Suppress_All::
202 * Pragma Suppress_Exception_Locations::
203 * Pragma Suppress_Initialization::
204 * Pragma Task_Info::
205 * Pragma Task_Name::
206 * Pragma Task_Storage::
207 * Pragma Test_Case::
208 * Pragma Thread_Local_Storage::
209 * Pragma Time_Slice::
210 * Pragma Title::
211 * Pragma Unchecked_Union::
212 * Pragma Unimplemented_Unit::
213 * Pragma Universal_Aliasing ::
214 * Pragma Universal_Data::
215 * Pragma Unmodified::
216 * Pragma Unreferenced::
217 * Pragma Unreferenced_Objects::
218 * Pragma Unreserve_All_Interrupts::
219 * Pragma Unsuppress::
220 * Pragma Use_VADS_Size::
221 * Pragma Validity_Checks::
222 * Pragma Volatile::
223 * Pragma Warnings::
224 * Pragma Weak_External::
225 * Pragma Wide_Character_Encoding::
226
227 Implementation Defined Attributes
228
229 * Abort_Signal::
230 * Address_Size::
231 * Asm_Input::
232 * Asm_Output::
233 * AST_Entry::
234 * Bit::
235 * Bit_Position::
236 * Compiler_Version::
237 * Code_Address::
238 * Default_Bit_Order::
239 * Descriptor_Size::
240 * Elaborated::
241 * Elab_Body::
242 * Elab_Spec::
243 * Elab_Subp_Body::
244 * Emax::
245 * Enabled::
246 * Enum_Rep::
247 * Enum_Val::
248 * Epsilon::
249 * Fixed_Value::
250 * Has_Access_Values::
251 * Has_Discriminants::
252 * Img::
253 * Integer_Value::
254 * Invalid_Value::
255 * Large::
256 * Machine_Size::
257 * Mantissa::
258 * Max_Interrupt_Priority::
259 * Max_Priority::
260 * Maximum_Alignment::
261 * Mechanism_Code::
262 * Null_Parameter::
263 * Object_Size::
264 * Old::
265 * Passed_By_Reference::
266 * Pool_Address::
267 * Range_Length::
268 * Result::
269 * Safe_Emax::
270 * Safe_Large::
271 * Small::
272 * Storage_Unit::
273 * Stub_Type::
274 * System_Allocator_Alignment::
275 * Target_Name::
276 * Tick::
277 * To_Address::
278 * Type_Class::
279 * UET_Address::
280 * Unconstrained_Array::
281 * Universal_Literal_String::
282 * Unrestricted_Access::
283 * VADS_Size::
284 * Value_Size::
285 * Wchar_T_Size::
286 * Word_Size::
287
288 The Implementation of Standard I/O
289
290 * Standard I/O Packages::
291 * FORM Strings::
292 * Direct_IO::
293 * Sequential_IO::
294 * Text_IO::
295 * Wide_Text_IO::
296 * Wide_Wide_Text_IO::
297 * Stream_IO::
298 * Text Translation::
299 * Shared Files::
300 * Filenames encoding::
301 * Open Modes::
302 * Operations on C Streams::
303 * Interfacing to C Streams::
304
305 The GNAT Library
306
307 * Ada.Characters.Latin_9 (a-chlat9.ads)::
308 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
309 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
310 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
311 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
312 * Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)::
313 * Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)::
314 * Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)::
315 * Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)::
316 * Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)::
317 * Ada.Containers.Formal_Vectors (a-cofove.ads)::
318 * Ada.Command_Line.Environment (a-colien.ads)::
319 * Ada.Command_Line.Remove (a-colire.ads)::
320 * Ada.Command_Line.Response_File (a-clrefi.ads)::
321 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
322 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
323 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
324 * Ada.Exceptions.Traceback (a-exctra.ads)::
325 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
326 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
327 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
328 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
329 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
330 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
331 * Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)::
332 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
333 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
334 * Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)::
335 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
336 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
337 * Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)::
338 * GNAT.Altivec (g-altive.ads)::
339 * GNAT.Altivec.Conversions (g-altcon.ads)::
340 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
341 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
342 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
343 * GNAT.Array_Split (g-arrspl.ads)::
344 * GNAT.AWK (g-awk.ads)::
345 * GNAT.Bounded_Buffers (g-boubuf.ads)::
346 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
347 * GNAT.Bubble_Sort (g-bubsor.ads)::
348 * GNAT.Bubble_Sort_A (g-busora.ads)::
349 * GNAT.Bubble_Sort_G (g-busorg.ads)::
350 * GNAT.Byte_Order_Mark (g-byorma.ads)::
351 * GNAT.Byte_Swapping (g-bytswa.ads)::
352 * GNAT.Calendar (g-calend.ads)::
353 * GNAT.Calendar.Time_IO (g-catiio.ads)::
354 * GNAT.Case_Util (g-casuti.ads)::
355 * GNAT.CGI (g-cgi.ads)::
356 * GNAT.CGI.Cookie (g-cgicoo.ads)::
357 * GNAT.CGI.Debug (g-cgideb.ads)::
358 * GNAT.Command_Line (g-comlin.ads)::
359 * GNAT.Compiler_Version (g-comver.ads)::
360 * GNAT.Ctrl_C (g-ctrl_c.ads)::
361 * GNAT.CRC32 (g-crc32.ads)::
362 * GNAT.Current_Exception (g-curexc.ads)::
363 * GNAT.Debug_Pools (g-debpoo.ads)::
364 * GNAT.Debug_Utilities (g-debuti.ads)::
365 * GNAT.Decode_String (g-decstr.ads)::
366 * GNAT.Decode_UTF8_String (g-deutst.ads)::
367 * GNAT.Directory_Operations (g-dirope.ads)::
368 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
369 * GNAT.Dynamic_HTables (g-dynhta.ads)::
370 * GNAT.Dynamic_Tables (g-dyntab.ads)::
371 * GNAT.Encode_String (g-encstr.ads)::
372 * GNAT.Encode_UTF8_String (g-enutst.ads)::
373 * GNAT.Exception_Actions (g-excact.ads)::
374 * GNAT.Exception_Traces (g-exctra.ads)::
375 * GNAT.Exceptions (g-except.ads)::
376 * GNAT.Expect (g-expect.ads)::
377 * GNAT.Expect.TTY (g-exptty.ads)::
378 * GNAT.Float_Control (g-flocon.ads)::
379 * GNAT.Heap_Sort (g-heasor.ads)::
380 * GNAT.Heap_Sort_A (g-hesora.ads)::
381 * GNAT.Heap_Sort_G (g-hesorg.ads)::
382 * GNAT.HTable (g-htable.ads)::
383 * GNAT.IO (g-io.ads)::
384 * GNAT.IO_Aux (g-io_aux.ads)::
385 * GNAT.Lock_Files (g-locfil.ads)::
386 * GNAT.MBBS_Discrete_Random (g-mbdira.ads)::
387 * GNAT.MBBS_Float_Random (g-mbflra.ads)::
388 * GNAT.MD5 (g-md5.ads)::
389 * GNAT.Memory_Dump (g-memdum.ads)::
390 * GNAT.Most_Recent_Exception (g-moreex.ads)::
391 * GNAT.OS_Lib (g-os_lib.ads)::
392 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
393 * GNAT.Random_Numbers (g-rannum.ads)::
394 * GNAT.Regexp (g-regexp.ads)::
395 * GNAT.Registry (g-regist.ads)::
396 * GNAT.Regpat (g-regpat.ads)::
397 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
398 * GNAT.Semaphores (g-semaph.ads)::
399 * GNAT.Serial_Communications (g-sercom.ads)::
400 * GNAT.SHA1 (g-sha1.ads)::
401 * GNAT.SHA224 (g-sha224.ads)::
402 * GNAT.SHA256 (g-sha256.ads)::
403 * GNAT.SHA384 (g-sha384.ads)::
404 * GNAT.SHA512 (g-sha512.ads)::
405 * GNAT.Signals (g-signal.ads)::
406 * GNAT.Sockets (g-socket.ads)::
407 * GNAT.Source_Info (g-souinf.ads)::
408 * GNAT.Spelling_Checker (g-speche.ads)::
409 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
410 * GNAT.Spitbol.Patterns (g-spipat.ads)::
411 * GNAT.Spitbol (g-spitbo.ads)::
412 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
413 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
414 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
415 * GNAT.SSE (g-sse.ads)::
416 * GNAT.SSE.Vector_Types (g-ssvety.ads)::
417 * GNAT.Strings (g-string.ads)::
418 * GNAT.String_Split (g-strspl.ads)::
419 * GNAT.Table (g-table.ads)::
420 * GNAT.Task_Lock (g-tasloc.ads)::
421 * GNAT.Threads (g-thread.ads)::
422 * GNAT.Time_Stamp (g-timsta.ads)::
423 * GNAT.Traceback (g-traceb.ads)::
424 * GNAT.Traceback.Symbolic (g-trasym.ads)::
425 * GNAT.UTF_32 (g-utf_32.ads)::
426 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
427 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
428 * GNAT.Wide_String_Split (g-wistsp.ads)::
429 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
430 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
431 * Interfaces.C.Extensions (i-cexten.ads)::
432 * Interfaces.C.Streams (i-cstrea.ads)::
433 * Interfaces.CPP (i-cpp.ads)::
434 * Interfaces.Packed_Decimal (i-pacdec.ads)::
435 * Interfaces.VxWorks (i-vxwork.ads)::
436 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
437 * System.Address_Image (s-addima.ads)::
438 * System.Assertions (s-assert.ads)::
439 * System.Memory (s-memory.ads)::
440 * System.Partition_Interface (s-parint.ads)::
441 * System.Pool_Global (s-pooglo.ads)::
442 * System.Pool_Local (s-pooloc.ads)::
443 * System.Restrictions (s-restri.ads)::
444 * System.Rident (s-rident.ads)::
445 * System.Strings.Stream_Ops (s-ststop.ads)::
446 * System.Task_Info (s-tasinf.ads)::
447 * System.Wch_Cnv (s-wchcnv.ads)::
448 * System.Wch_Con (s-wchcon.ads)::
449
450 Text_IO
451
452 * Text_IO Stream Pointer Positioning::
453 * Text_IO Reading and Writing Non-Regular Files::
454 * Get_Immediate::
455 * Treating Text_IO Files as Streams::
456 * Text_IO Extensions::
457 * Text_IO Facilities for Unbounded Strings::
458
459 Wide_Text_IO
460
461 * Wide_Text_IO Stream Pointer Positioning::
462 * Wide_Text_IO Reading and Writing Non-Regular Files::
463
464 Wide_Wide_Text_IO
465
466 * Wide_Wide_Text_IO Stream Pointer Positioning::
467 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
468
469 Interfacing to Other Languages
470
471 * Interfacing to C::
472 * Interfacing to C++::
473 * Interfacing to COBOL::
474 * Interfacing to Fortran::
475 * Interfacing to non-GNAT Ada code::
476
477 Specialized Needs Annexes
478
479 Implementation of Specific Ada Features
480 * Machine Code Insertions::
481 * GNAT Implementation of Tasking::
482 * GNAT Implementation of Shared Passive Packages::
483 * Code Generation for Array Aggregates::
484 * The Size of Discriminated Records with Default Discriminants::
485 * Strict Conformance to the Ada Reference Manual::
486
487 Implementation of Ada 2012 Features
488
489 Obsolescent Features
490
491 GNU Free Documentation License
492
493 Index
494 @end menu
495
496 @end ifnottex
497
498 @node About This Guide
499 @unnumbered About This Guide
500
501 @noindent
502 This manual contains useful information in writing programs using the
503 @value{EDITION} compiler.  It includes information on implementation dependent
504 characteristics of @value{EDITION}, including all the information required by
505 Annex M of the Ada language standard.
506
507 @value{EDITION} implements Ada 95 and Ada 2005, and it may also be invoked in
508 Ada 83 compatibility mode.
509 By default, @value{EDITION} assumes @value{DEFAULTLANGUAGEVERSION},
510 but you can override with a compiler switch
511 to explicitly specify the language version.
512 (Please refer to @ref{Compiling Different Versions of Ada,,, gnat_ugn,
513 @value{EDITION} User's Guide}, for details on these switches.)
514 Throughout this manual, references to ``Ada'' without a year suffix
515 apply to both the Ada 95 and Ada 2005 versions of the language.
516
517 Ada is designed to be highly portable.
518 In general, a program will have the same effect even when compiled by
519 different compilers on different platforms.
520 However, since Ada is designed to be used in a
521 wide variety of applications, it also contains a number of system
522 dependent features to be used in interfacing to the external world.
523 @cindex Implementation-dependent features
524 @cindex Portability
525
526 Note: Any program that makes use of implementation-dependent features
527 may be non-portable.  You should follow good programming practice and
528 isolate and clearly document any sections of your program that make use
529 of these features in a non-portable manner.
530
531 @ifset PROEDITION
532 For ease of exposition, ``@value{EDITION}'' will be referred to simply as
533 ``GNAT'' in the remainder of this document.
534 @end ifset
535
536 @menu
537 * What This Reference Manual Contains::
538 * Conventions::
539 * Related Information::
540 @end menu
541
542 @node What This Reference Manual Contains
543 @unnumberedsec What This Reference Manual Contains
544
545 @noindent
546 This reference manual contains the following chapters:
547
548 @itemize @bullet
549 @item
550 @ref{Implementation Defined Pragmas}, lists GNAT implementation-dependent
551 pragmas, which can be used to extend and enhance the functionality of the
552 compiler.
553
554 @item
555 @ref{Implementation Defined Attributes}, lists GNAT
556 implementation-dependent attributes which can be used to extend and
557 enhance the functionality of the compiler.
558
559 @item
560 @ref{Implementation Advice}, provides information on generally
561 desirable behavior which are not requirements that all compilers must
562 follow since it cannot be provided on all systems, or which may be
563 undesirable on some systems.
564
565 @item
566 @ref{Implementation Defined Characteristics}, provides a guide to
567 minimizing implementation dependent features.
568
569 @item
570 @ref{Intrinsic Subprograms}, describes the intrinsic subprograms
571 implemented by GNAT, and how they can be imported into user
572 application programs.
573
574 @item
575 @ref{Representation Clauses and Pragmas}, describes in detail the
576 way that GNAT represents data, and in particular the exact set
577 of representation clauses and pragmas that is accepted.
578
579 @item
580 @ref{Standard Library Routines}, provides a listing of packages and a
581 brief description of the functionality that is provided by Ada's
582 extensive set of standard library routines as implemented by GNAT@.
583
584 @item
585 @ref{The Implementation of Standard I/O}, details how the GNAT
586 implementation of the input-output facilities.
587
588 @item
589 @ref{The GNAT Library}, is a catalog of packages that complement
590 the Ada predefined library.
591
592 @item
593 @ref{Interfacing to Other Languages}, describes how programs
594 written in Ada using GNAT can be interfaced to other programming
595 languages.
596
597 @ref{Specialized Needs Annexes}, describes the GNAT implementation of all
598 of the specialized needs annexes.
599
600 @item
601 @ref{Implementation of Specific Ada Features}, discusses issues related
602 to GNAT's implementation of machine code insertions, tasking, and several
603 other features.
604
605 @item
606 @ref{Implementation of Ada 2012 Features}, describes the status of the
607 GNAT implementation of the Ada 2012 language standard.
608
609 @item
610 @ref{Obsolescent Features} documents implementation dependent features,
611 including pragmas and attributes, which are considered obsolescent, since
612 there are other preferred ways of achieving the same results. These
613 obsolescent forms are retained for backwards compatibility.
614
615 @end itemize
616
617 @cindex Ada 95 Language Reference Manual
618 @cindex Ada 2005 Language Reference Manual
619 @noindent
620 This reference manual assumes a basic familiarity with the Ada 95 language, as
621 described in the International Standard ANSI/ISO/IEC-8652:1995,
622 January 1995.
623 It does not require knowledge of the new features introduced by Ada 2005,
624 (officially known as ISO/IEC 8652:1995 with Technical Corrigendum 1
625 and Amendment 1).
626 Both reference manuals are included in the GNAT documentation
627 package.
628
629 @node Conventions
630 @unnumberedsec Conventions
631 @cindex Conventions, typographical
632 @cindex Typographical conventions
633
634 @noindent
635 Following are examples of the typographical and graphic conventions used
636 in this guide:
637
638 @itemize @bullet
639 @item
640 @code{Functions}, @code{utility program names}, @code{standard names},
641 and @code{classes}.
642
643 @item
644 @code{Option flags}
645
646 @item
647 @file{File names}, @samp{button names}, and @samp{field names}.
648
649 @item
650 @code{Variables}, @env{environment variables}, and @var{metasyntactic
651 variables}.
652
653 @item
654 @emph{Emphasis}.
655
656 @item
657 [optional information or parameters]
658
659 @item
660 Examples are described by text
661 @smallexample
662 and then shown this way.
663 @end smallexample
664 @end itemize
665
666 @noindent
667 Commands that are entered by the user are preceded in this manual by the
668 characters @samp{$ } (dollar sign followed by space).  If your system uses this
669 sequence as a prompt, then the commands will appear exactly as you see them
670 in the manual.  If your system uses some other prompt, then the command will
671 appear with the @samp{$} replaced by whatever prompt character you are using.
672
673 @node Related Information
674 @unnumberedsec Related Information
675 @noindent
676 See the following documents for further information on GNAT:
677
678 @itemize @bullet
679 @item
680 @xref{Top, @value{EDITION} User's Guide, About This Guide, gnat_ugn,
681 @value{EDITION} User's Guide}, which provides information on how to use the
682 GNAT compiler system.
683
684 @item
685 @cite{Ada 95 Reference Manual}, which contains all reference
686 material for the Ada 95 programming language.
687
688 @item
689 @cite{Ada 95 Annotated Reference Manual}, which is an annotated version
690 of the Ada 95 standard.  The annotations describe
691 detailed aspects of the design decision, and in particular contain useful
692 sections on Ada 83 compatibility.
693
694 @item
695 @cite{Ada 2005 Reference Manual}, which contains all reference
696 material for the Ada 2005 programming language.
697
698 @item
699 @cite{Ada 2005 Annotated Reference Manual}, which is an annotated version
700 of the Ada 2005 standard.  The annotations describe
701 detailed aspects of the design decision, and in particular contain useful
702 sections on Ada 83 and Ada 95 compatibility.
703
704 @item
705 @cite{DEC Ada, Technical Overview and Comparison on DIGITAL Platforms},
706 which contains specific information on compatibility between GNAT and
707 DEC Ada 83 systems.
708
709 @item
710 @cite{DEC Ada, Language Reference Manual, part number AA-PYZAB-TK} which
711 describes in detail the pragmas and attributes provided by the DEC Ada 83
712 compiler system.
713
714 @end itemize
715
716 @node Implementation Defined Pragmas
717 @chapter Implementation Defined Pragmas
718
719 @noindent
720 Ada defines a set of pragmas that can be used to supply additional
721 information to the compiler.  These language defined pragmas are
722 implemented in GNAT and work as described in the Ada Reference Manual.
723
724 In addition, Ada allows implementations to define additional pragmas
725 whose meaning is defined by the implementation.  GNAT provides a number
726 of these implementation-defined pragmas, which can be used to extend
727 and enhance the functionality of the compiler.  This section of the GNAT
728 Reference Manual describes these additional pragmas.
729
730 Note that any program using these pragmas might not be portable to other
731 compilers (although GNAT implements this set of pragmas on all
732 platforms).  Therefore if portability to other compilers is an important
733 consideration, the use of these pragmas should be minimized.
734
735 @menu
736 * Pragma Abort_Defer::
737 * Pragma Ada_83::
738 * Pragma Ada_95::
739 * Pragma Ada_05::
740 * Pragma Ada_2005::
741 * Pragma Ada_12::
742 * Pragma Ada_2012::
743 * Pragma Annotate::
744 * Pragma Assert::
745 * Pragma Assertion_Policy::
746 * Pragma Assume_No_Invalid_Values::
747 * Pragma Ast_Entry::
748 * Pragma C_Pass_By_Copy::
749 * Pragma Check::
750 * Pragma Check_Name::
751 * Pragma Check_Policy::
752 * Pragma Comment::
753 * Pragma Common_Object::
754 * Pragma Compile_Time_Error::
755 * Pragma Compile_Time_Warning::
756 * Pragma Compiler_Unit::
757 * Pragma Complete_Representation::
758 * Pragma Complex_Representation::
759 * Pragma Component_Alignment::
760 * Pragma Convention_Identifier::
761 * Pragma CPP_Class::
762 * Pragma CPP_Constructor::
763 * Pragma CPP_Virtual::
764 * Pragma CPP_Vtable::
765 * Pragma Debug::
766 * Pragma Debug_Policy::
767 * Pragma Detect_Blocking::
768 * Pragma Elaboration_Checks::
769 * Pragma Eliminate::
770 * Pragma Export_Exception::
771 * Pragma Export_Function::
772 * Pragma Export_Object::
773 * Pragma Export_Procedure::
774 * Pragma Export_Value::
775 * Pragma Export_Valued_Procedure::
776 * Pragma Extend_System::
777 * Pragma Extensions_Allowed::
778 * Pragma External::
779 * Pragma External_Name_Casing::
780 * Pragma Fast_Math::
781 * Pragma Favor_Top_Level::
782 * Pragma Finalize_Storage_Only::
783 * Pragma Float_Representation::
784 * Pragma Ident::
785 * Pragma Implemented::
786 * Pragma Implicit_Packing::
787 * Pragma Import_Exception::
788 * Pragma Import_Function::
789 * Pragma Import_Object::
790 * Pragma Import_Procedure::
791 * Pragma Import_Valued_Procedure::
792 * Pragma Initialize_Scalars::
793 * Pragma Inline_Always::
794 * Pragma Inline_Generic::
795 * Pragma Interface::
796 * Pragma Interface_Name::
797 * Pragma Interrupt_Handler::
798 * Pragma Interrupt_State::
799 * Pragma Invariant::
800 * Pragma Keep_Names::
801 * Pragma License::
802 * Pragma Link_With::
803 * Pragma Linker_Alias::
804 * Pragma Linker_Constructor::
805 * Pragma Linker_Destructor::
806 * Pragma Linker_Section::
807 * Pragma Long_Float::
808 * Pragma Machine_Attribute::
809 * Pragma Main::
810 * Pragma Main_Storage::
811 * Pragma No_Body::
812 * Pragma No_Return::
813 * Pragma No_Strict_Aliasing::
814 * Pragma Normalize_Scalars::
815 * Pragma Obsolescent::
816 * Pragma Optimize_Alignment::
817 * Pragma Ordered::
818 * Pragma Passive::
819 * Pragma Persistent_BSS::
820 * Pragma Polling::
821 * Pragma Postcondition::
822 * Pragma Precondition::
823 * Pragma Profile (Ravenscar)::
824 * Pragma Profile (Restricted)::
825 * Pragma Psect_Object::
826 * Pragma Pure_Function::
827 * Pragma Restriction_Warnings::
828 * Pragma Shared::
829 * Pragma Short_Circuit_And_Or::
830 * Pragma Short_Descriptors::
831 * Pragma Source_File_Name::
832 * Pragma Source_File_Name_Project::
833 * Pragma Source_Reference::
834 * Pragma Static_Elaboration_Desired::
835 * Pragma Stream_Convert::
836 * Pragma Style_Checks::
837 * Pragma Subtitle::
838 * Pragma Suppress::
839 * Pragma Suppress_All::
840 * Pragma Suppress_Exception_Locations::
841 * Pragma Suppress_Initialization::
842 * Pragma Task_Info::
843 * Pragma Task_Name::
844 * Pragma Task_Storage::
845 * Pragma Test_Case::
846 * Pragma Thread_Local_Storage::
847 * Pragma Time_Slice::
848 * Pragma Title::
849 * Pragma Unchecked_Union::
850 * Pragma Unimplemented_Unit::
851 * Pragma Universal_Aliasing ::
852 * Pragma Universal_Data::
853 * Pragma Unmodified::
854 * Pragma Unreferenced::
855 * Pragma Unreferenced_Objects::
856 * Pragma Unreserve_All_Interrupts::
857 * Pragma Unsuppress::
858 * Pragma Use_VADS_Size::
859 * Pragma Validity_Checks::
860 * Pragma Volatile::
861 * Pragma Warnings::
862 * Pragma Weak_External::
863 * Pragma Wide_Character_Encoding::
864 @end menu
865
866 @node Pragma Abort_Defer
867 @unnumberedsec Pragma Abort_Defer
868 @findex Abort_Defer
869 @cindex Deferring aborts
870 @noindent
871 Syntax:
872 @smallexample
873 pragma Abort_Defer;
874 @end smallexample
875
876 @noindent
877 This pragma must appear at the start of the statement sequence of a
878 handled sequence of statements (right after the @code{begin}).  It has
879 the effect of deferring aborts for the sequence of statements (but not
880 for the declarations or handlers, if any, associated with this statement
881 sequence).
882
883 @node Pragma Ada_83
884 @unnumberedsec Pragma Ada_83
885 @findex Ada_83
886 @noindent
887 Syntax:
888 @smallexample @c ada
889 pragma Ada_83;
890 @end smallexample
891
892 @noindent
893 A configuration pragma that establishes Ada 83 mode for the unit to
894 which it applies, regardless of the mode set by the command line
895 switches.  In Ada 83 mode, GNAT attempts to be as compatible with
896 the syntax and semantics of Ada 83, as defined in the original Ada
897 83 Reference Manual as possible.  In particular, the keywords added by Ada 95
898 and Ada 2005 are not recognized, optional package bodies are allowed,
899 and generics may name types with unknown discriminants without using
900 the @code{(<>)} notation.  In addition, some but not all of the additional
901 restrictions of Ada 83 are enforced.
902
903 Ada 83 mode is intended for two purposes.  Firstly, it allows existing
904 Ada 83 code to be compiled and adapted to GNAT with less effort.
905 Secondly, it aids in keeping code backwards compatible with Ada 83.
906 However, there is no guarantee that code that is processed correctly
907 by GNAT in Ada 83 mode will in fact compile and execute with an Ada
908 83 compiler, since GNAT does not enforce all the additional checks
909 required by Ada 83.
910
911 @node Pragma Ada_95
912 @unnumberedsec Pragma Ada_95
913 @findex Ada_95
914 @noindent
915 Syntax:
916 @smallexample @c ada
917 pragma Ada_95;
918 @end smallexample
919
920 @noindent
921 A configuration pragma that establishes Ada 95 mode for the unit to which
922 it applies, regardless of the mode set by the command line switches.
923 This mode is set automatically for the @code{Ada} and @code{System}
924 packages and their children, so you need not specify it in these
925 contexts.  This pragma is useful when writing a reusable component that
926 itself uses Ada 95 features, but which is intended to be usable from
927 either Ada 83 or Ada 95 programs.
928
929 @node Pragma Ada_05
930 @unnumberedsec Pragma Ada_05
931 @findex Ada_05
932 @noindent
933 Syntax:
934 @smallexample @c ada
935 pragma Ada_05;
936 @end smallexample
937
938 @noindent
939 A configuration pragma that establishes Ada 2005 mode for the unit to which
940 it applies, regardless of the mode set by the command line switches.
941 This pragma is useful when writing a reusable component that
942 itself uses Ada 2005 features, but which is intended to be usable from
943 either Ada 83 or Ada 95 programs.
944
945 @node Pragma Ada_2005
946 @unnumberedsec Pragma Ada_2005
947 @findex Ada_2005
948 @noindent
949 Syntax:
950 @smallexample @c ada
951 pragma Ada_2005;
952 @end smallexample
953
954 @noindent
955 This configuration pragma is a synonym for pragma Ada_05 and has the
956 same syntax and effect.
957
958 @node Pragma Ada_12
959 @unnumberedsec Pragma Ada_12
960 @findex Ada_12
961 @noindent
962 Syntax:
963 @smallexample @c ada
964 pragma Ada_12;
965 @end smallexample
966
967 @noindent
968 A configuration pragma that establishes Ada 2012 mode for the unit to which
969 it applies, regardless of the mode set by the command line switches.
970 This mode is set automatically for the @code{Ada} and @code{System}
971 packages and their children, so you need not specify it in these
972 contexts.  This pragma is useful when writing a reusable component that
973 itself uses Ada 2012 features, but which is intended to be usable from
974 Ada 83, Ada 95, or Ada 2005 programs.
975
976 @node Pragma Ada_2012
977 @unnumberedsec Pragma Ada_2012
978 @findex Ada_2005
979 @noindent
980 Syntax:
981 @smallexample @c ada
982 pragma Ada_2012;
983 @end smallexample
984
985 @noindent
986 This configuration pragma is a synonym for pragma Ada_12 and has the
987 same syntax and effect.
988
989 @node Pragma Annotate
990 @unnumberedsec Pragma Annotate
991 @findex Annotate
992 @noindent
993 Syntax:
994 @smallexample @c ada
995 pragma Annotate (IDENTIFIER [,IDENTIFIER @{, ARG@}]);
996
997 ARG ::= NAME | EXPRESSION
998 @end smallexample
999
1000 @noindent
1001 This pragma is used to annotate programs.  @var{identifier} identifies
1002 the type of annotation.  GNAT verifies that it is an identifier, but does
1003 not otherwise analyze it. The second optional identifier is also left
1004 unanalyzed, and by convention is used to control the action of the tool to
1005 which the annotation is addressed.  The remaining @var{arg} arguments
1006 can be either string literals or more generally expressions.
1007 String literals are assumed to be either of type
1008 @code{Standard.String} or else @code{Wide_String} or @code{Wide_Wide_String}
1009 depending on the character literals they contain.
1010 All other kinds of arguments are analyzed as expressions, and must be
1011 unambiguous.
1012
1013 The analyzed pragma is retained in the tree, but not otherwise processed
1014 by any part of the GNAT compiler, except to generate corresponding note
1015 lines in the generated ALI file. For the format of these note lines, see
1016 the compiler source file lib-writ.ads. This pragma is intended for use by
1017 external tools, including ASIS@. The use of pragma Annotate does not
1018 affect the compilation process in any way. This pragma may be used as
1019 a configuration pragma.
1020
1021 @node Pragma Assert
1022 @unnumberedsec Pragma Assert
1023 @findex Assert
1024 @noindent
1025 Syntax:
1026 @smallexample @c ada
1027 pragma Assert (
1028   boolean_EXPRESSION
1029   [, string_EXPRESSION]);
1030 @end smallexample
1031
1032 @noindent
1033 The effect of this pragma depends on whether the corresponding command
1034 line switch is set to activate assertions.  The pragma expands into code
1035 equivalent to the following:
1036
1037 @smallexample @c ada
1038 if assertions-enabled then
1039    if not boolean_EXPRESSION then
1040       System.Assertions.Raise_Assert_Failure
1041         (string_EXPRESSION);
1042    end if;
1043 end if;
1044 @end smallexample
1045
1046 @noindent
1047 The string argument, if given, is the message that will be associated
1048 with the exception occurrence if the exception is raised.  If no second
1049 argument is given, the default message is @samp{@var{file}:@var{nnn}},
1050 where @var{file} is the name of the source file containing the assert,
1051 and @var{nnn} is the line number of the assert.  A pragma is not a
1052 statement, so if a statement sequence contains nothing but a pragma
1053 assert, then a null statement is required in addition, as in:
1054
1055 @smallexample @c ada
1056 @dots{}
1057 if J > 3 then
1058    pragma Assert (K > 3, "Bad value for K");
1059    null;
1060 end if;
1061 @end smallexample
1062
1063 @noindent
1064 Note that, as with the @code{if} statement to which it is equivalent, the
1065 type of the expression is either @code{Standard.Boolean}, or any type derived
1066 from this standard type.
1067
1068 If assertions are disabled (switch @option{-gnata} not used), then there
1069 is no run-time effect (and in particular, any side effects from the
1070 expression will not occur at run time).  (The expression is still
1071 analyzed at compile time, and may cause types to be frozen if they are
1072 mentioned here for the first time).
1073
1074 If assertions are enabled, then the given expression is tested, and if
1075 it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
1076 which results in the raising of @code{Assert_Failure} with the given message.
1077
1078 You should generally avoid side effects in the expression arguments of
1079 this pragma, because these side effects will turn on and off with the
1080 setting of the assertions mode, resulting in assertions that have an
1081 effect on the program.  However, the expressions are analyzed for
1082 semantic correctness whether or not assertions are enabled, so turning
1083 assertions on and off cannot affect the legality of a program.
1084
1085 Note that the implementation defined policy @code{DISABLE}, given in a
1086 pragma Assertion_Policy, can be used to suppress this semantic analysis.
1087
1088 Note: this is a standard language-defined pragma in versions
1089 of Ada from 2005 on. In GNAT, it is implemented in all versions
1090 of Ada, and the DISABLE policy is an implementation-defined
1091 addition.
1092
1093
1094 @node Pragma Assertion_Policy
1095 @unnumberedsec Pragma Assertion_Policy
1096 @findex Debug_Policy
1097 @noindent
1098 Syntax:
1099
1100 @smallexample @c ada
1101 pragma Assertion_Policy (CHECK | DISABLE | IGNORE);
1102 @end smallexample
1103
1104 @noindent
1105 If the argument is @code{CHECK}, then pragma @code{Assert} is enabled.
1106 If the argument is @code{IGNORE}, then pragma @code{Assert} is ignored.
1107 This pragma overrides the effect of the @option{-gnata} switch on the
1108 command line.
1109
1110 The implementation defined policy @code{DISABLE} is like
1111 @code{IGNORE} except that it completely disables semantic
1112 checking of the argument to @code{pragma Assert}. This may
1113 be useful when the pragma argument references subprograms
1114 in a with'ed package which is replaced by a dummy package
1115 for the final build.
1116
1117 Note: this is a standard language-defined pragma in versions
1118 of Ada from 2005 on. In GNAT, it is implemented in all versions
1119 of Ada, and the DISABLE policy is an implementation-defined
1120 addition.
1121
1122 @node Pragma Assume_No_Invalid_Values
1123 @unnumberedsec Pragma Assume_No_Invalid_Values
1124 @findex Assume_No_Invalid_Values
1125 @cindex Invalid representations
1126 @cindex Invalid values
1127 @noindent
1128 Syntax:
1129 @smallexample @c ada
1130 pragma Assume_No_Invalid_Values (On | Off);
1131 @end smallexample
1132
1133 @noindent
1134 This is a configuration pragma that controls the assumptions made by the
1135 compiler about the occurrence of invalid representations (invalid values)
1136 in the code.
1137
1138 The default behavior (corresponding to an Off argument for this pragma), is
1139 to assume that values may in general be invalid unless the compiler can
1140 prove they are valid. Consider the following example:
1141
1142 @smallexample @c ada
1143 V1 : Integer range 1 .. 10;
1144 V2 : Integer range 11 .. 20;
1145 ...
1146 for J in V2 .. V1 loop
1147    ...
1148 end loop;
1149 @end smallexample
1150
1151 @noindent
1152 if V1 and V2 have valid values, then the loop is known at compile
1153 time not to execute since the lower bound must be greater than the
1154 upper bound. However in default mode, no such assumption is made,
1155 and the loop may execute. If @code{Assume_No_Invalid_Values (On)}
1156 is given, the compiler will assume that any occurrence of a variable
1157 other than in an explicit @code{'Valid} test always has a valid
1158 value, and the loop above will be optimized away.
1159
1160 The use of @code{Assume_No_Invalid_Values (On)} is appropriate if
1161 you know your code is free of uninitialized variables and other
1162 possible sources of invalid representations, and may result in
1163 more efficient code. A program that accesses an invalid representation
1164 with this pragma in effect is erroneous, so no guarantees can be made
1165 about its behavior.
1166
1167 It is peculiar though permissible to use this pragma in conjunction
1168 with validity checking (-gnatVa). In such cases, accessing invalid
1169 values will generally give an exception, though formally the program
1170 is erroneous so there are no guarantees that this will always be the
1171 case, and it is recommended that these two options not be used together.
1172
1173 @node Pragma Ast_Entry
1174 @unnumberedsec Pragma Ast_Entry
1175 @cindex OpenVMS
1176 @findex Ast_Entry
1177 @noindent
1178 Syntax:
1179 @smallexample @c ada
1180 pragma AST_Entry (entry_IDENTIFIER);
1181 @end smallexample
1182
1183 @noindent
1184 This pragma is implemented only in the OpenVMS implementation of GNAT@.  The
1185 argument is the simple name of a single entry; at most one @code{AST_Entry}
1186 pragma is allowed for any given entry.  This pragma must be used in
1187 conjunction with the @code{AST_Entry} attribute, and is only allowed after
1188 the entry declaration and in the same task type specification or single task
1189 as the entry to which it applies.  This pragma specifies that the given entry
1190 may be used to handle an OpenVMS asynchronous system trap (@code{AST})
1191 resulting from an OpenVMS system service call.  The pragma does not affect
1192 normal use of the entry.  For further details on this pragma, see the
1193 DEC Ada Language Reference Manual, section 9.12a.
1194
1195 @node Pragma C_Pass_By_Copy
1196 @unnumberedsec Pragma C_Pass_By_Copy
1197 @cindex Passing by copy
1198 @findex C_Pass_By_Copy
1199 @noindent
1200 Syntax:
1201 @smallexample @c ada
1202 pragma C_Pass_By_Copy
1203   ([Max_Size =>] static_integer_EXPRESSION);
1204 @end smallexample
1205
1206 @noindent
1207 Normally the default mechanism for passing C convention records to C
1208 convention subprograms is to pass them by reference, as suggested by RM
1209 B.3(69).  Use the configuration pragma @code{C_Pass_By_Copy} to change
1210 this default, by requiring that record formal parameters be passed by
1211 copy if all of the following conditions are met:
1212
1213 @itemize @bullet
1214 @item
1215 The size of the record type does not exceed the value specified for
1216 @code{Max_Size}.
1217 @item
1218 The record type has @code{Convention C}.
1219 @item
1220 The formal parameter has this record type, and the subprogram has a
1221 foreign (non-Ada) convention.
1222 @end itemize
1223
1224 @noindent
1225 If these conditions are met the argument is passed by copy, i.e.@: in a
1226 manner consistent with what C expects if the corresponding formal in the
1227 C prototype is a struct (rather than a pointer to a struct).
1228
1229 You can also pass records by copy by specifying the convention
1230 @code{C_Pass_By_Copy} for the record type, or by using the extended
1231 @code{Import} and @code{Export} pragmas, which allow specification of
1232 passing mechanisms on a parameter by parameter basis.
1233
1234 @node Pragma Check
1235 @unnumberedsec Pragma Check
1236 @cindex Assertions
1237 @cindex Named assertions
1238 @findex Check
1239 @noindent
1240 Syntax:
1241 @smallexample @c ada
1242 pragma Check (
1243      [Name    =>] Identifier,
1244      [Check   =>] Boolean_EXPRESSION
1245   [, [Message =>] string_EXPRESSION] );
1246 @end smallexample
1247
1248 @noindent
1249 This pragma is similar to the predefined pragma @code{Assert} except that an
1250 extra identifier argument is present. In conjunction with pragma
1251 @code{Check_Policy}, this can be used to define groups of assertions that can
1252 be independently controlled. The identifier @code{Assertion} is special, it
1253 refers to the normal set of pragma @code{Assert} statements. The identifiers
1254 @code{Precondition} and @code{Postcondition} correspond to the pragmas of these
1255 names, so these three names would normally not be used directly in a pragma
1256 @code{Check}.
1257
1258 Checks introduced by this pragma are normally deactivated by default. They can
1259 be activated either by the command line option @option{-gnata}, which turns on
1260 all checks, or individually controlled using pragma @code{Check_Policy}.
1261
1262 @node Pragma Check_Name
1263 @unnumberedsec Pragma Check_Name
1264 @cindex Defining check names
1265 @cindex Check names, defining
1266 @findex Check_Name
1267 @noindent
1268 Syntax:
1269 @smallexample @c ada
1270 pragma Check_Name (check_name_IDENTIFIER);
1271 @end smallexample
1272
1273 @noindent
1274 This is a configuration pragma that defines a new implementation
1275 defined check name (unless IDENTIFIER matches one of the predefined
1276 check names, in which case the pragma has no effect). Check names
1277 are global to a partition, so if two or more configuration pragmas
1278 are present in a partition mentioning the same name, only one new
1279 check name is introduced.
1280
1281 An implementation defined check name introduced with this pragma may
1282 be used in only three contexts: @code{pragma Suppress},
1283 @code{pragma Unsuppress},
1284 and as the prefix of a @code{Check_Name'Enabled} attribute reference. For
1285 any of these three cases, the check name must be visible. A check
1286 name is visible if it is in the configuration pragmas applying to
1287 the current unit, or if it appears at the start of any unit that
1288 is part of the dependency set of the current unit (e.g., units that
1289 are mentioned in @code{with} clauses).
1290
1291 @node Pragma Check_Policy
1292 @unnumberedsec Pragma Check_Policy
1293 @cindex Controlling assertions
1294 @cindex Assertions, control
1295 @cindex Check pragma control
1296 @cindex Named assertions
1297 @findex Check
1298 @noindent
1299 Syntax:
1300 @smallexample @c ada
1301 pragma Check_Policy
1302  ([Name   =>] Identifier,
1303   [Policy =>] POLICY_IDENTIFIER);
1304
1305 POLICY_IDENTIFIER ::= ON | OFF | CHECK | DISABLE | IGNORE
1306 @end smallexample
1307
1308 @noindent
1309 This pragma is similar to the predefined pragma @code{Assertion_Policy},
1310 except that it controls sets of named assertions introduced using the
1311 @code{Check} pragmas. It can be used as a configuration pragma or (unlike
1312 @code{Assertion_Policy}) can be used within a declarative part, in which case
1313 it controls the status to the end of the corresponding construct (in a manner
1314 identical to pragma @code{Suppress)}.
1315
1316 The identifier given as the first argument corresponds to a name used in
1317 associated @code{Check} pragmas. For example, if the pragma:
1318
1319 @smallexample @c ada
1320 pragma Check_Policy (Critical_Error, OFF);
1321 @end smallexample
1322
1323 @noindent
1324 is given, then subsequent @code{Check} pragmas whose first argument is also
1325 @code{Critical_Error} will be disabled. The special identifier @code{Assertion}
1326 controls the behavior of normal @code{Assert} pragmas (thus a pragma
1327 @code{Check_Policy} with this identifier is similar to the normal
1328 @code{Assertion_Policy} pragma except that it can appear within a
1329 declarative part).
1330
1331 The special identifiers @code{Precondition} and @code{Postcondition} control
1332 the status of preconditions and postconditions. If a @code{Precondition} pragma
1333 is encountered, it is ignored if turned off by a @code{Check_Policy} specifying
1334 that @code{Precondition} checks are @code{Off} or @code{Ignored}. Similarly use
1335 of the name @code{Postcondition} controls whether @code{Postcondition} pragmas
1336 are recognized.
1337
1338 The check policy is @code{OFF} to turn off corresponding checks, and @code{ON}
1339 to turn on corresponding checks. The default for a set of checks for which no
1340 @code{Check_Policy} is given is @code{OFF} unless the compiler switch
1341 @option{-gnata} is given, which turns on all checks by default.
1342
1343 The check policy settings @code{CHECK} and @code{IGNORE} are also recognized
1344 as synonyms for @code{ON} and @code{OFF}. These synonyms are provided for
1345 compatibility with the standard @code{Assertion_Policy} pragma.
1346
1347 The implementation defined policy @code{DISABLE} is like
1348 @code{OFF} except that it completely disables semantic
1349 checking of the argument to the corresponding class of
1350 pragmas. This may be useful when the pragma arguments reference
1351 subprograms in a with'ed package which is replaced by a dummy package
1352 for the final build.
1353
1354 @node Pragma Comment
1355 @unnumberedsec Pragma Comment
1356 @findex Comment
1357 @noindent
1358 Syntax:
1359
1360 @smallexample @c ada
1361 pragma Comment (static_string_EXPRESSION);
1362 @end smallexample
1363
1364 @noindent
1365 This is almost identical in effect to pragma @code{Ident}.  It allows the
1366 placement of a comment into the object file and hence into the
1367 executable file if the operating system permits such usage.  The
1368 difference is that @code{Comment}, unlike @code{Ident}, has
1369 no limitations on placement of the pragma (it can be placed
1370 anywhere in the main source unit), and if more than one pragma
1371 is used, all comments are retained.
1372
1373 @node Pragma Common_Object
1374 @unnumberedsec Pragma Common_Object
1375 @findex Common_Object
1376 @noindent
1377 Syntax:
1378
1379 @smallexample @c ada
1380 pragma Common_Object (
1381      [Internal =>] LOCAL_NAME
1382   [, [External =>] EXTERNAL_SYMBOL]
1383   [, [Size     =>] EXTERNAL_SYMBOL] );
1384
1385 EXTERNAL_SYMBOL ::=
1386   IDENTIFIER
1387 | static_string_EXPRESSION
1388 @end smallexample
1389
1390 @noindent
1391 This pragma enables the shared use of variables stored in overlaid
1392 linker areas corresponding to the use of @code{COMMON}
1393 in Fortran.  The single
1394 object @var{LOCAL_NAME} is assigned to the area designated by
1395 the @var{External} argument.
1396 You may define a record to correspond to a series
1397 of fields.  The @var{Size} argument
1398 is syntax checked in GNAT, but otherwise ignored.
1399
1400 @code{Common_Object} is not supported on all platforms.  If no
1401 support is available, then the code generator will issue a message
1402 indicating that the necessary attribute for implementation of this
1403 pragma is not available.
1404
1405 @node Pragma Compile_Time_Error
1406 @unnumberedsec Pragma Compile_Time_Error
1407 @findex Compile_Time_Error
1408 @noindent
1409 Syntax:
1410
1411 @smallexample @c ada
1412 pragma Compile_Time_Error
1413          (boolean_EXPRESSION, static_string_EXPRESSION);
1414 @end smallexample
1415
1416 @noindent
1417 This pragma can be used to generate additional compile time
1418 error messages. It
1419 is particularly useful in generics, where errors can be issued for
1420 specific problematic instantiations. The first parameter is a boolean
1421 expression. The pragma is effective only if the value of this expression
1422 is known at compile time, and has the value True. The set of expressions
1423 whose values are known at compile time includes all static boolean
1424 expressions, and also other values which the compiler can determine
1425 at compile time (e.g., the size of a record type set by an explicit
1426 size representation clause, or the value of a variable which was
1427 initialized to a constant and is known not to have been modified).
1428 If these conditions are met, an error message is generated using
1429 the value given as the second argument. This string value may contain
1430 embedded ASCII.LF characters to break the message into multiple lines.
1431
1432 @node Pragma Compile_Time_Warning
1433 @unnumberedsec Pragma Compile_Time_Warning
1434 @findex Compile_Time_Warning
1435 @noindent
1436 Syntax:
1437
1438 @smallexample @c ada
1439 pragma Compile_Time_Warning
1440          (boolean_EXPRESSION, static_string_EXPRESSION);
1441 @end smallexample
1442
1443 @noindent
1444 Same as pragma Compile_Time_Error, except a warning is issued instead
1445 of an error message. Note that if this pragma is used in a package that
1446 is with'ed by a client, the client will get the warning even though it
1447 is issued by a with'ed package (normally warnings in with'ed units are
1448 suppressed, but this is a special exception to that rule).
1449
1450 One typical use is within a generic where compile time known characteristics
1451 of formal parameters are tested, and warnings given appropriately. Another use
1452 with a first parameter of True is to warn a client about use of a package,
1453 for example that it is not fully implemented.
1454
1455 @node Pragma Compiler_Unit
1456 @unnumberedsec Pragma Compiler_Unit
1457 @findex Compiler_Unit
1458 @noindent
1459 Syntax:
1460
1461 @smallexample @c ada
1462 pragma Compiler_Unit;
1463 @end smallexample
1464
1465 @noindent
1466 This pragma is intended only for internal use in the GNAT run-time library.
1467 It indicates that the unit is used as part of the compiler build. The effect
1468 is to disallow constructs (raise with message, conditional expressions etc)
1469 that would cause trouble when bootstrapping using an older version of GNAT.
1470 For the exact list of restrictions, see the compiler sources and references
1471 to Is_Compiler_Unit.
1472
1473 @node Pragma Complete_Representation
1474 @unnumberedsec Pragma Complete_Representation
1475 @findex Complete_Representation
1476 @noindent
1477 Syntax:
1478
1479 @smallexample @c ada
1480 pragma Complete_Representation;
1481 @end smallexample
1482
1483 @noindent
1484 This pragma must appear immediately within a record representation
1485 clause. Typical placements are before the first component clause
1486 or after the last component clause. The effect is to give an error
1487 message if any component is missing a component clause. This pragma
1488 may be used to ensure that a record representation clause is
1489 complete, and that this invariant is maintained if fields are
1490 added to the record in the future.
1491
1492 @node Pragma Complex_Representation
1493 @unnumberedsec Pragma Complex_Representation
1494 @findex Complex_Representation
1495 @noindent
1496 Syntax:
1497
1498 @smallexample @c ada
1499 pragma Complex_Representation
1500         ([Entity =>] LOCAL_NAME);
1501 @end smallexample
1502
1503 @noindent
1504 The @var{Entity} argument must be the name of a record type which has
1505 two fields of the same floating-point type.  The effect of this pragma is
1506 to force gcc to use the special internal complex representation form for
1507 this record, which may be more efficient.  Note that this may result in
1508 the code for this type not conforming to standard ABI (application
1509 binary interface) requirements for the handling of record types.  For
1510 example, in some environments, there is a requirement for passing
1511 records by pointer, and the use of this pragma may result in passing
1512 this type in floating-point registers.
1513
1514 @node Pragma Component_Alignment
1515 @unnumberedsec Pragma Component_Alignment
1516 @cindex Alignments of components
1517 @findex Component_Alignment
1518 @noindent
1519 Syntax:
1520
1521 @smallexample @c ada
1522 pragma Component_Alignment (
1523      [Form =>] ALIGNMENT_CHOICE
1524   [, [Name =>] type_LOCAL_NAME]);
1525
1526 ALIGNMENT_CHOICE ::=
1527   Component_Size
1528 | Component_Size_4
1529 | Storage_Unit
1530 | Default
1531 @end smallexample
1532
1533 @noindent
1534 Specifies the alignment of components in array or record types.
1535 The meaning of the @var{Form} argument is as follows:
1536
1537 @table @code
1538 @findex Component_Size
1539 @item Component_Size
1540 Aligns scalar components and subcomponents of the array or record type
1541 on boundaries appropriate to their inherent size (naturally
1542 aligned).  For example, 1-byte components are aligned on byte boundaries,
1543 2-byte integer components are aligned on 2-byte boundaries, 4-byte
1544 integer components are aligned on 4-byte boundaries and so on.  These
1545 alignment rules correspond to the normal rules for C compilers on all
1546 machines except the VAX@.
1547
1548 @findex Component_Size_4
1549 @item Component_Size_4
1550 Naturally aligns components with a size of four or fewer
1551 bytes.  Components that are larger than 4 bytes are placed on the next
1552 4-byte boundary.
1553
1554 @findex Storage_Unit
1555 @item Storage_Unit
1556 Specifies that array or record components are byte aligned, i.e.@:
1557 aligned on boundaries determined by the value of the constant
1558 @code{System.Storage_Unit}.
1559
1560 @cindex OpenVMS
1561 @item Default
1562 Specifies that array or record components are aligned on default
1563 boundaries, appropriate to the underlying hardware or operating system or
1564 both.  For OpenVMS VAX systems, the @code{Default} choice is the same as
1565 the @code{Storage_Unit} choice (byte alignment).  For all other systems,
1566 the @code{Default} choice is the same as @code{Component_Size} (natural
1567 alignment).
1568 @end table
1569
1570 @noindent
1571 If the @code{Name} parameter is present, @var{type_LOCAL_NAME} must
1572 refer to a local record or array type, and the specified alignment
1573 choice applies to the specified type.  The use of
1574 @code{Component_Alignment} together with a pragma @code{Pack} causes the
1575 @code{Component_Alignment} pragma to be ignored.  The use of
1576 @code{Component_Alignment} together with a record representation clause
1577 is only effective for fields not specified by the representation clause.
1578
1579 If the @code{Name} parameter is absent, the pragma can be used as either
1580 a configuration pragma, in which case it applies to one or more units in
1581 accordance with the normal rules for configuration pragmas, or it can be
1582 used within a declarative part, in which case it applies to types that
1583 are declared within this declarative part, or within any nested scope
1584 within this declarative part.  In either case it specifies the alignment
1585 to be applied to any record or array type which has otherwise standard
1586 representation.
1587
1588 If the alignment for a record or array type is not specified (using
1589 pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
1590 clause), the GNAT uses the default alignment as described previously.
1591
1592 @node Pragma Convention_Identifier
1593 @unnumberedsec Pragma Convention_Identifier
1594 @findex Convention_Identifier
1595 @cindex Conventions, synonyms
1596 @noindent
1597 Syntax:
1598
1599 @smallexample @c ada
1600 pragma Convention_Identifier (
1601          [Name =>]       IDENTIFIER,
1602          [Convention =>] convention_IDENTIFIER);
1603 @end smallexample
1604
1605 @noindent
1606 This pragma provides a mechanism for supplying synonyms for existing
1607 convention identifiers. The @code{Name} identifier can subsequently
1608 be used as a synonym for the given convention in other pragmas (including
1609 for example pragma @code{Import} or another @code{Convention_Identifier}
1610 pragma). As an example of the use of this, suppose you had legacy code
1611 which used Fortran77 as the identifier for Fortran. Then the pragma:
1612
1613 @smallexample @c ada
1614 pragma Convention_Identifier (Fortran77, Fortran);
1615 @end smallexample
1616
1617 @noindent
1618 would allow the use of the convention identifier @code{Fortran77} in
1619 subsequent code, avoiding the need to modify the sources. As another
1620 example, you could use this to parameterize convention requirements
1621 according to systems. Suppose you needed to use @code{Stdcall} on
1622 windows systems, and @code{C} on some other system, then you could
1623 define a convention identifier @code{Library} and use a single
1624 @code{Convention_Identifier} pragma to specify which convention
1625 would be used system-wide.
1626
1627 @node Pragma CPP_Class
1628 @unnumberedsec Pragma CPP_Class
1629 @findex CPP_Class
1630 @cindex Interfacing with C++
1631 @noindent
1632 Syntax:
1633
1634 @smallexample @c ada
1635 pragma CPP_Class ([Entity =>] LOCAL_NAME);
1636 @end smallexample
1637
1638 @noindent
1639 The argument denotes an entity in the current declarative region that is
1640 declared as a record type. It indicates that the type corresponds to an
1641 externally declared C++ class type, and is to be laid out the same way
1642 that C++ would lay out the type. If the C++ class has virtual primitives
1643 then the record must be declared as a tagged record type.
1644
1645 Types for which @code{CPP_Class} is specified do not have assignment or
1646 equality operators defined (such operations can be imported or declared
1647 as subprograms as required). Initialization is allowed only by constructor
1648 functions (see pragma @code{CPP_Constructor}). Such types are implicitly
1649 limited if not explicitly declared as limited or derived from a limited
1650 type, and an error is issued in that case.
1651
1652 Pragma @code{CPP_Class} is intended primarily for automatic generation
1653 using an automatic binding generator tool.
1654 See @ref{Interfacing to C++} for related information.
1655
1656 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
1657 for backward compatibility but its functionality is available
1658 using pragma @code{Import} with @code{Convention} = @code{CPP}.
1659
1660 @node Pragma CPP_Constructor
1661 @unnumberedsec Pragma CPP_Constructor
1662 @cindex Interfacing with C++
1663 @findex CPP_Constructor
1664 @noindent
1665 Syntax:
1666
1667 @smallexample @c ada
1668 pragma CPP_Constructor ([Entity =>] LOCAL_NAME
1669   [, [External_Name =>] static_string_EXPRESSION ]
1670   [, [Link_Name     =>] static_string_EXPRESSION ]);
1671 @end smallexample
1672
1673 @noindent
1674 This pragma identifies an imported function (imported in the usual way
1675 with pragma @code{Import}) as corresponding to a C++ constructor. If
1676 @code{External_Name} and @code{Link_Name} are not specified then the
1677 @code{Entity} argument is a name that must have been previously mentioned
1678 in a pragma @code{Import} with @code{Convention} = @code{CPP}. Such name
1679 must be of one of the following forms:
1680
1681 @itemize @bullet
1682 @item
1683 @code{function @var{Fname} return @var{T}}
1684
1685 @itemize @bullet
1686 @item
1687 @code{function @var{Fname} return @var{T}'Class}
1688
1689 @item
1690 @code{function @var{Fname} (@dots{}) return @var{T}}
1691 @end itemize
1692
1693 @item
1694 @code{function @var{Fname} (@dots{}) return @var{T}'Class}
1695 @end itemize
1696
1697 @noindent
1698 where @var{T} is a limited record type imported from C++ with pragma
1699 @code{Import} and @code{Convention} = @code{CPP}.
1700
1701 The first two forms import the default constructor, used when an object
1702 of type @var{T} is created on the Ada side with no explicit constructor.
1703 The latter two forms cover all the non-default constructors of the type.
1704 See the GNAT users guide for details.
1705
1706 If no constructors are imported, it is impossible to create any objects
1707 on the Ada side and the type is implicitly declared abstract.
1708
1709 Pragma @code{CPP_Constructor} is intended primarily for automatic generation
1710 using an automatic binding generator tool.
1711 See @ref{Interfacing to C++} for more related information.
1712
1713 Note: The use of functions returning class-wide types for constructors is
1714 currently obsolete. They are supported for backward compatibility. The
1715 use of functions returning the type T leave the Ada sources more clear
1716 because the imported C++ constructors always return an object of type T;
1717 that is, they never return an object whose type is a descendant of type T.
1718
1719 @node Pragma CPP_Virtual
1720 @unnumberedsec Pragma CPP_Virtual
1721 @cindex Interfacing to C++
1722 @findex CPP_Virtual
1723 @noindent
1724 This pragma is now obsolete has has no effect because GNAT generates
1725 the same object layout than the G++ compiler.
1726
1727 See @ref{Interfacing to C++} for related information.
1728
1729 @node Pragma CPP_Vtable
1730 @unnumberedsec Pragma CPP_Vtable
1731 @cindex Interfacing with C++
1732 @findex CPP_Vtable
1733 @noindent
1734 This pragma is now obsolete has has no effect because GNAT generates
1735 the same object layout than the G++ compiler.
1736
1737 See @ref{Interfacing to C++} for related information.
1738
1739 @node Pragma Debug
1740 @unnumberedsec Pragma Debug
1741 @findex Debug
1742 @noindent
1743 Syntax:
1744
1745 @smallexample @c ada
1746 pragma Debug ([CONDITION, ]PROCEDURE_CALL_WITHOUT_SEMICOLON);
1747
1748 PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
1749   PROCEDURE_NAME
1750 | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
1751 @end smallexample
1752
1753 @noindent
1754 The procedure call argument has the syntactic form of an expression, meeting
1755 the syntactic requirements for pragmas.
1756
1757 If debug pragmas are not enabled or if the condition is present and evaluates
1758 to False, this pragma has no effect. If debug pragmas are enabled, the
1759 semantics of the pragma is exactly equivalent to the procedure call statement
1760 corresponding to the argument with a terminating semicolon. Pragmas are
1761 permitted in sequences of declarations, so you can use pragma @code{Debug} to
1762 intersperse calls to debug procedures in the middle of declarations. Debug
1763 pragmas can be enabled either by use of the command line switch @option{-gnata}
1764 or by use of the configuration pragma @code{Debug_Policy}.
1765
1766 @node Pragma Debug_Policy
1767 @unnumberedsec Pragma Debug_Policy
1768 @findex Debug_Policy
1769 @noindent
1770 Syntax:
1771
1772 @smallexample @c ada
1773 pragma Debug_Policy (CHECK | DISABLE | IGNORE);
1774 @end smallexample
1775
1776 @noindent
1777 If the argument is @code{CHECK}, then pragma @code{DEBUG} is enabled.
1778 If the argument is @code{IGNORE}, then pragma @code{DEBUG} is ignored.
1779 This pragma overrides the effect of the @option{-gnata} switch on the
1780 command line.
1781
1782 The implementation defined policy @code{DISABLE} is like
1783 @code{IGNORE} except that it completely disables semantic
1784 checking of the argument to @code{pragma Debug}. This may
1785 be useful when the pragma argument references subprograms
1786 in a with'ed package which is replaced by a dummy package
1787 for the final build.
1788
1789 @node Pragma Detect_Blocking
1790 @unnumberedsec Pragma Detect_Blocking
1791 @findex Detect_Blocking
1792 @noindent
1793 Syntax:
1794
1795 @smallexample @c ada
1796 pragma Detect_Blocking;
1797 @end smallexample
1798
1799 @noindent
1800 This is a configuration pragma that forces the detection of potentially
1801 blocking operations within a protected operation, and to raise Program_Error
1802 if that happens.
1803
1804 @node Pragma Elaboration_Checks
1805 @unnumberedsec Pragma Elaboration_Checks
1806 @cindex Elaboration control
1807 @findex Elaboration_Checks
1808 @noindent
1809 Syntax:
1810
1811 @smallexample @c ada
1812 pragma Elaboration_Checks (Dynamic | Static);
1813 @end smallexample
1814
1815 @noindent
1816 This is a configuration pragma that provides control over the
1817 elaboration model used by the compilation affected by the
1818 pragma.  If the parameter is @code{Dynamic},
1819 then the dynamic elaboration
1820 model described in the Ada Reference Manual is used, as though
1821 the @option{-gnatE} switch had been specified on the command
1822 line.  If the parameter is @code{Static}, then the default GNAT static
1823 model is used.  This configuration pragma overrides the setting
1824 of the command line.  For full details on the elaboration models
1825 used by the GNAT compiler, see @ref{Elaboration Order Handling in GNAT,,,
1826 gnat_ugn, @value{EDITION} User's Guide}.
1827
1828 @node Pragma Eliminate
1829 @unnumberedsec Pragma Eliminate
1830 @cindex Elimination of unused subprograms
1831 @findex Eliminate
1832 @noindent
1833 Syntax:
1834
1835 @smallexample @c ada
1836 pragma Eliminate ([Entity          =>] DEFINING_DESIGNATOR,
1837                   [Source_Location =>] STRING_LITERAL);
1838 @end smallexample
1839
1840 @noindent
1841 The string literal given for the source location is a string which
1842 specifies the line number of the occurrence of the entity, using
1843 the syntax for SOURCE_TRACE given below:
1844
1845 @smallexample @c ada
1846  SOURCE_TRACE     ::= SOURCE_REFERENCE [LBRACKET SOURCE_TRACE RBRACKET]
1847
1848  LBRACKET         ::= [
1849  RBRACKET         ::= ]
1850
1851  SOURCE_REFERENCE ::= FILE_NAME : LINE_NUMBER
1852
1853  LINE_NUMBER      ::= DIGIT @{DIGIT@}
1854 @end smallexample
1855
1856 @noindent
1857 Spaces around the colon in a @code{Source_Reference} are optional.
1858
1859 The @code{DEFINING_DESIGNATOR} matches the defining designator used in an
1860 explicit subprogram declaration, where the @code{entity} name in this
1861 designator appears on the source line specified by the source location.
1862
1863 The source trace that is given as the @code{Source_Location} shall obey the
1864 following rules. The @code{FILE_NAME} is the short name (with no directory
1865 information) of an Ada source file, given using exactly the required syntax
1866 for the underlying file system (e.g. case is important if the underlying
1867 operating system is case sensitive). @code{LINE_NUMBER} gives the line
1868 number of the occurrence of the @code{entity}
1869 as a decimal literal without an exponent or point. If an @code{entity} is not
1870 declared in a generic instantiation (this includes generic subprogram
1871 instances), the source trace includes only one source reference. If an entity
1872 is declared inside a generic instantiation, its source trace (when parsing
1873 from left to right) starts with the source location of the declaration of the
1874 entity in the generic unit and ends with the source location of the
1875 instantiation (it is given in square brackets). This approach is recursively
1876 used in case of nested instantiations: the rightmost (nested most deeply in
1877 square brackets) element of the source trace is the location of the outermost
1878 instantiation, the next to left element is the location of the next (first
1879 nested) instantiation in the code of the corresponding generic unit, and so
1880 on, and the leftmost element (that is out of any square brackets) is the
1881 location of the declaration of the entity to eliminate in a generic unit.
1882
1883 Note that the @code{Source_Location} argument specifies which of a set of
1884 similarly named entities is being eliminated, dealing both with overloading,
1885 and also appearence of the same entity name in different scopes.
1886
1887 This pragma indicates that the given entity is not used in the program to be
1888 compiled and built. The effect of the pragma is to allow the compiler to
1889 eliminate the code or data associated with the named entity. Any reference to
1890 an eliminated entity causes a compile-time or link-time error.
1891
1892 The intention of pragma @code{Eliminate} is to allow a program to be compiled
1893 in a system-independent manner, with unused entities eliminated, without
1894 needing to modify the source text. Normally the required set of
1895 @code{Eliminate} pragmas is constructed automatically using the gnatelim tool.
1896
1897 Any source file change that removes, splits, or
1898 adds lines may make the set of Eliminate pragmas invalid because their
1899 @code{Source_Location} argument values may get out of date.
1900
1901 Pragma @code{Eliminate} may be used where the referenced entity is a dispatching
1902 operation. In this case all the subprograms to which the given operation can
1903 dispatch are considered to be unused (are never called as a result of a direct
1904 or a dispatching call).
1905
1906 @node Pragma Export_Exception
1907 @unnumberedsec Pragma Export_Exception
1908 @cindex OpenVMS
1909 @findex Export_Exception
1910 @noindent
1911 Syntax:
1912
1913 @smallexample @c ada
1914 pragma Export_Exception (
1915      [Internal =>] LOCAL_NAME
1916   [, [External =>] EXTERNAL_SYMBOL]
1917   [, [Form     =>] Ada | VMS]
1918   [, [Code     =>] static_integer_EXPRESSION]);
1919
1920 EXTERNAL_SYMBOL ::=
1921   IDENTIFIER
1922 | static_string_EXPRESSION
1923 @end smallexample
1924
1925 @noindent
1926 This pragma is implemented only in the OpenVMS implementation of GNAT@.  It
1927 causes the specified exception to be propagated outside of the Ada program,
1928 so that it can be handled by programs written in other OpenVMS languages.
1929 This pragma establishes an external name for an Ada exception and makes the
1930 name available to the OpenVMS Linker as a global symbol.  For further details
1931 on this pragma, see the
1932 DEC Ada Language Reference Manual, section 13.9a3.2.
1933
1934 @node Pragma Export_Function
1935 @unnumberedsec Pragma Export_Function
1936 @cindex Argument passing mechanisms
1937 @findex Export_Function
1938
1939 @noindent
1940 Syntax:
1941
1942 @smallexample @c ada
1943 pragma Export_Function (
1944      [Internal         =>] LOCAL_NAME
1945   [, [External         =>] EXTERNAL_SYMBOL]
1946   [, [Parameter_Types  =>] PARAMETER_TYPES]
1947   [, [Result_Type      =>] result_SUBTYPE_MARK]
1948   [, [Mechanism        =>] MECHANISM]
1949   [, [Result_Mechanism =>] MECHANISM_NAME]);
1950
1951 EXTERNAL_SYMBOL ::=
1952   IDENTIFIER
1953 | static_string_EXPRESSION
1954 | ""
1955
1956 PARAMETER_TYPES ::=
1957   null
1958 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1959
1960 TYPE_DESIGNATOR ::=
1961   subtype_NAME
1962 | subtype_Name ' Access
1963
1964 MECHANISM ::=
1965   MECHANISM_NAME
1966 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1967
1968 MECHANISM_ASSOCIATION ::=
1969   [formal_parameter_NAME =>] MECHANISM_NAME
1970
1971 MECHANISM_NAME ::=
1972   Value
1973 | Reference
1974 | Descriptor [([Class =>] CLASS_NAME)]
1975 | Short_Descriptor [([Class =>] CLASS_NAME)]
1976
1977 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
1978 @end smallexample
1979
1980 @noindent
1981 Use this pragma to make a function externally callable and optionally
1982 provide information on mechanisms to be used for passing parameter and
1983 result values.  We recommend, for the purposes of improving portability,
1984 this pragma always be used in conjunction with a separate pragma
1985 @code{Export}, which must precede the pragma @code{Export_Function}.
1986 GNAT does not require a separate pragma @code{Export}, but if none is
1987 present, @code{Convention Ada} is assumed, which is usually
1988 not what is wanted, so it is usually appropriate to use this
1989 pragma in conjunction with a @code{Export} or @code{Convention}
1990 pragma that specifies the desired foreign convention.
1991 Pragma @code{Export_Function}
1992 (and @code{Export}, if present) must appear in the same declarative
1993 region as the function to which they apply.
1994
1995 @var{internal_name} must uniquely designate the function to which the
1996 pragma applies.  If more than one function name exists of this name in
1997 the declarative part you must use the @code{Parameter_Types} and
1998 @code{Result_Type} parameters is mandatory to achieve the required
1999 unique designation.  @var{subtype_mark}s in these parameters must
2000 exactly match the subtypes in the corresponding function specification,
2001 using positional notation to match parameters with subtype marks.
2002 The form with an @code{'Access} attribute can be used to match an
2003 anonymous access parameter.
2004
2005 @cindex OpenVMS
2006 @cindex Passing by descriptor
2007 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2008 The default behavior for Export_Function is to accept either 64bit or
2009 32bit descriptors unless short_descriptor is specified, then only 32bit
2010 descriptors are accepted.
2011
2012 @cindex Suppressing external name
2013 Special treatment is given if the EXTERNAL is an explicit null
2014 string or a static string expressions that evaluates to the null
2015 string. In this case, no external name is generated. This form
2016 still allows the specification of parameter mechanisms.
2017
2018 @node Pragma Export_Object
2019 @unnumberedsec Pragma Export_Object
2020 @findex Export_Object
2021 @noindent
2022 Syntax:
2023
2024 @smallexample @c ada
2025 pragma Export_Object
2026       [Internal =>] LOCAL_NAME
2027    [, [External =>] EXTERNAL_SYMBOL]
2028    [, [Size     =>] EXTERNAL_SYMBOL]
2029
2030 EXTERNAL_SYMBOL ::=
2031   IDENTIFIER
2032 | static_string_EXPRESSION
2033 @end smallexample
2034
2035 @noindent
2036 This pragma designates an object as exported, and apart from the
2037 extended rules for external symbols, is identical in effect to the use of
2038 the normal @code{Export} pragma applied to an object.  You may use a
2039 separate Export pragma (and you probably should from the point of view
2040 of portability), but it is not required.  @var{Size} is syntax checked,
2041 but otherwise ignored by GNAT@.
2042
2043 @node Pragma Export_Procedure
2044 @unnumberedsec Pragma Export_Procedure
2045 @findex Export_Procedure
2046 @noindent
2047 Syntax:
2048
2049 @smallexample @c ada
2050 pragma Export_Procedure (
2051      [Internal        =>] LOCAL_NAME
2052   [, [External        =>] EXTERNAL_SYMBOL]
2053   [, [Parameter_Types =>] PARAMETER_TYPES]
2054   [, [Mechanism       =>] MECHANISM]);
2055
2056 EXTERNAL_SYMBOL ::=
2057   IDENTIFIER
2058 | static_string_EXPRESSION
2059 | ""
2060
2061 PARAMETER_TYPES ::=
2062   null
2063 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2064
2065 TYPE_DESIGNATOR ::=
2066   subtype_NAME
2067 | subtype_Name ' Access
2068
2069 MECHANISM ::=
2070   MECHANISM_NAME
2071 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2072
2073 MECHANISM_ASSOCIATION ::=
2074   [formal_parameter_NAME =>] MECHANISM_NAME
2075
2076 MECHANISM_NAME ::=
2077   Value
2078 | Reference
2079 | Descriptor [([Class =>] CLASS_NAME)]
2080 | Short_Descriptor [([Class =>] CLASS_NAME)]
2081
2082 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2083 @end smallexample
2084
2085 @noindent
2086 This pragma is identical to @code{Export_Function} except that it
2087 applies to a procedure rather than a function and the parameters
2088 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2089 GNAT does not require a separate pragma @code{Export}, but if none is
2090 present, @code{Convention Ada} is assumed, which is usually
2091 not what is wanted, so it is usually appropriate to use this
2092 pragma in conjunction with a @code{Export} or @code{Convention}
2093 pragma that specifies the desired foreign convention.
2094
2095 @cindex OpenVMS
2096 @cindex Passing by descriptor
2097 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2098 The default behavior for Export_Procedure is to accept either 64bit or
2099 32bit descriptors unless short_descriptor is specified, then only 32bit
2100 descriptors are accepted.
2101
2102 @cindex Suppressing external name
2103 Special treatment is given if the EXTERNAL is an explicit null
2104 string or a static string expressions that evaluates to the null
2105 string. In this case, no external name is generated. This form
2106 still allows the specification of parameter mechanisms.
2107
2108 @node Pragma Export_Value
2109 @unnumberedsec Pragma Export_Value
2110 @findex Export_Value
2111 @noindent
2112 Syntax:
2113
2114 @smallexample @c ada
2115 pragma Export_Value (
2116   [Value     =>] static_integer_EXPRESSION,
2117   [Link_Name =>] static_string_EXPRESSION);
2118 @end smallexample
2119
2120 @noindent
2121 This pragma serves to export a static integer value for external use.
2122 The first argument specifies the value to be exported. The Link_Name
2123 argument specifies the symbolic name to be associated with the integer
2124 value. This pragma is useful for defining a named static value in Ada
2125 that can be referenced in assembly language units to be linked with
2126 the application. This pragma is currently supported only for the
2127 AAMP target and is ignored for other targets.
2128
2129 @node Pragma Export_Valued_Procedure
2130 @unnumberedsec Pragma Export_Valued_Procedure
2131 @findex Export_Valued_Procedure
2132 @noindent
2133 Syntax:
2134
2135 @smallexample @c ada
2136 pragma Export_Valued_Procedure (
2137      [Internal        =>] LOCAL_NAME
2138   [, [External        =>] EXTERNAL_SYMBOL]
2139   [, [Parameter_Types =>] PARAMETER_TYPES]
2140   [, [Mechanism       =>] MECHANISM]);
2141
2142 EXTERNAL_SYMBOL ::=
2143   IDENTIFIER
2144 | static_string_EXPRESSION
2145 | ""
2146
2147 PARAMETER_TYPES ::=
2148   null
2149 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2150
2151 TYPE_DESIGNATOR ::=
2152   subtype_NAME
2153 | subtype_Name ' Access
2154
2155 MECHANISM ::=
2156   MECHANISM_NAME
2157 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2158
2159 MECHANISM_ASSOCIATION ::=
2160   [formal_parameter_NAME =>] MECHANISM_NAME
2161
2162 MECHANISM_NAME ::=
2163   Value
2164 | Reference
2165 | Descriptor [([Class =>] CLASS_NAME)]
2166 | Short_Descriptor [([Class =>] CLASS_NAME)]
2167
2168 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2169 @end smallexample
2170
2171 @noindent
2172 This pragma is identical to @code{Export_Procedure} except that the
2173 first parameter of @var{LOCAL_NAME}, which must be present, must be of
2174 mode @code{OUT}, and externally the subprogram is treated as a function
2175 with this parameter as the result of the function.  GNAT provides for
2176 this capability to allow the use of @code{OUT} and @code{IN OUT}
2177 parameters in interfacing to external functions (which are not permitted
2178 in Ada functions).
2179 GNAT does not require a separate pragma @code{Export}, but if none is
2180 present, @code{Convention Ada} is assumed, which is almost certainly
2181 not what is wanted since the whole point of this pragma is to interface
2182 with foreign language functions, so it is usually appropriate to use this
2183 pragma in conjunction with a @code{Export} or @code{Convention}
2184 pragma that specifies the desired foreign convention.
2185
2186 @cindex OpenVMS
2187 @cindex Passing by descriptor
2188 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2189 The default behavior for Export_Valued_Procedure is to accept either 64bit or
2190 32bit descriptors unless short_descriptor is specified, then only 32bit
2191 descriptors are accepted.
2192
2193 @cindex Suppressing external name
2194 Special treatment is given if the EXTERNAL is an explicit null
2195 string or a static string expressions that evaluates to the null
2196 string. In this case, no external name is generated. This form
2197 still allows the specification of parameter mechanisms.
2198
2199 @node Pragma Extend_System
2200 @unnumberedsec Pragma Extend_System
2201 @cindex @code{system}, extending
2202 @cindex Dec Ada 83
2203 @findex Extend_System
2204 @noindent
2205 Syntax:
2206
2207 @smallexample @c ada
2208 pragma Extend_System ([Name =>] IDENTIFIER);
2209 @end smallexample
2210
2211 @noindent
2212 This pragma is used to provide backwards compatibility with other
2213 implementations that extend the facilities of package @code{System}.  In
2214 GNAT, @code{System} contains only the definitions that are present in
2215 the Ada RM@.  However, other implementations, notably the DEC Ada 83
2216 implementation, provide many extensions to package @code{System}.
2217
2218 For each such implementation accommodated by this pragma, GNAT provides a
2219 package @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83
2220 implementation, which provides the required additional definitions.  You
2221 can use this package in two ways.  You can @code{with} it in the normal
2222 way and access entities either by selection or using a @code{use}
2223 clause.  In this case no special processing is required.
2224
2225 However, if existing code contains references such as
2226 @code{System.@var{xxx}} where @var{xxx} is an entity in the extended
2227 definitions provided in package @code{System}, you may use this pragma
2228 to extend visibility in @code{System} in a non-standard way that
2229 provides greater compatibility with the existing code.  Pragma
2230 @code{Extend_System} is a configuration pragma whose single argument is
2231 the name of the package containing the extended definition
2232 (e.g.@: @code{Aux_DEC} for the DEC Ada case).  A unit compiled under
2233 control of this pragma will be processed using special visibility
2234 processing that looks in package @code{System.Aux_@var{xxx}} where
2235 @code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
2236 package @code{System}, but not found in package @code{System}.
2237
2238 You can use this pragma either to access a predefined @code{System}
2239 extension supplied with the compiler, for example @code{Aux_DEC} or
2240 you can construct your own extension unit following the above
2241 definition.  Note that such a package is a child of @code{System}
2242 and thus is considered part of the implementation.  To compile
2243 it you will have to use the appropriate switch for compiling
2244 system units.
2245 @xref{Top, @value{EDITION} User's Guide, About This Guide, gnat_ugn, @value{EDITION} User's Guide},
2246 for details.
2247
2248 @node Pragma Extensions_Allowed
2249 @unnumberedsec Pragma Extensions_Allowed
2250 @cindex Ada Extensions
2251 @cindex GNAT Extensions
2252 @findex Extensions_Allowed
2253 @noindent
2254 Syntax:
2255
2256 @smallexample @c ada
2257 pragma Extensions_Allowed (On | Off);
2258 @end smallexample
2259
2260 @noindent
2261 This configuration pragma enables or disables the implementation
2262 extension mode (the use of Off as a parameter cancels the effect
2263 of the @option{-gnatX} command switch).
2264
2265 In extension mode, the latest version of the Ada language is
2266 implemented (currently Ada 2012), and in addition a small number
2267 of GNAT specific extensions are recognized as follows:
2268
2269 @table @asis
2270 @item Constrained attribute for generic objects
2271 The @code{Constrained} attribute is permitted for objects of
2272 generic types. The result indicates if the corresponding actual
2273 is constrained.
2274
2275 @end table
2276
2277 @node Pragma External
2278 @unnumberedsec Pragma External
2279 @findex External
2280 @noindent
2281 Syntax:
2282
2283 @smallexample @c ada
2284 pragma External (
2285   [   Convention    =>] convention_IDENTIFIER,
2286   [   Entity        =>] LOCAL_NAME
2287   [, [External_Name =>] static_string_EXPRESSION ]
2288   [, [Link_Name     =>] static_string_EXPRESSION ]);
2289 @end smallexample
2290
2291 @noindent
2292 This pragma is identical in syntax and semantics to pragma
2293 @code{Export} as defined in the Ada Reference Manual.  It is
2294 provided for compatibility with some Ada 83 compilers that
2295 used this pragma for exactly the same purposes as pragma
2296 @code{Export} before the latter was standardized.
2297
2298 @node Pragma External_Name_Casing
2299 @unnumberedsec Pragma External_Name_Casing
2300 @cindex Dec Ada 83 casing compatibility
2301 @cindex External Names, casing
2302 @cindex Casing of External names
2303 @findex External_Name_Casing
2304 @noindent
2305 Syntax:
2306
2307 @smallexample @c ada
2308 pragma External_Name_Casing (
2309   Uppercase | Lowercase
2310   [, Uppercase | Lowercase | As_Is]);
2311 @end smallexample
2312
2313 @noindent
2314 This pragma provides control over the casing of external names associated
2315 with Import and Export pragmas.  There are two cases to consider:
2316
2317 @table @asis
2318 @item Implicit external names
2319 Implicit external names are derived from identifiers.  The most common case
2320 arises when a standard Ada Import or Export pragma is used with only two
2321 arguments, as in:
2322
2323 @smallexample @c ada
2324    pragma Import (C, C_Routine);
2325 @end smallexample
2326
2327 @noindent
2328 Since Ada is a case-insensitive language, the spelling of the identifier in
2329 the Ada source program does not provide any information on the desired
2330 casing of the external name, and so a convention is needed.  In GNAT the
2331 default treatment is that such names are converted to all lower case
2332 letters.  This corresponds to the normal C style in many environments.
2333 The first argument of pragma @code{External_Name_Casing} can be used to
2334 control this treatment.  If @code{Uppercase} is specified, then the name
2335 will be forced to all uppercase letters.  If @code{Lowercase} is specified,
2336 then the normal default of all lower case letters will be used.
2337
2338 This same implicit treatment is also used in the case of extended DEC Ada 83
2339 compatible Import and Export pragmas where an external name is explicitly
2340 specified using an identifier rather than a string.
2341
2342 @item Explicit external names
2343 Explicit external names are given as string literals.  The most common case
2344 arises when a standard Ada Import or Export pragma is used with three
2345 arguments, as in:
2346
2347 @smallexample @c ada
2348 pragma Import (C, C_Routine, "C_routine");
2349 @end smallexample
2350
2351 @noindent
2352 In this case, the string literal normally provides the exact casing required
2353 for the external name.  The second argument of pragma
2354 @code{External_Name_Casing} may be used to modify this behavior.
2355 If @code{Uppercase} is specified, then the name
2356 will be forced to all uppercase letters.  If @code{Lowercase} is specified,
2357 then the name will be forced to all lowercase letters.  A specification of
2358 @code{As_Is} provides the normal default behavior in which the casing is
2359 taken from the string provided.
2360 @end table
2361
2362 @noindent
2363 This pragma may appear anywhere that a pragma is valid.  In particular, it
2364 can be used as a configuration pragma in the @file{gnat.adc} file, in which
2365 case it applies to all subsequent compilations, or it can be used as a program
2366 unit pragma, in which case it only applies to the current unit, or it can
2367 be used more locally to control individual Import/Export pragmas.
2368
2369 It is primarily intended for use with OpenVMS systems, where many
2370 compilers convert all symbols to upper case by default.  For interfacing to
2371 such compilers (e.g.@: the DEC C compiler), it may be convenient to use
2372 the pragma:
2373
2374 @smallexample @c ada
2375 pragma External_Name_Casing (Uppercase, Uppercase);
2376 @end smallexample
2377
2378 @noindent
2379 to enforce the upper casing of all external symbols.
2380
2381 @node Pragma Fast_Math
2382 @unnumberedsec Pragma Fast_Math
2383 @findex Fast_Math
2384 @noindent
2385 Syntax:
2386
2387 @smallexample @c ada
2388 pragma Fast_Math;
2389 @end smallexample
2390
2391 @noindent
2392 This is a configuration pragma which activates a mode in which speed is
2393 considered more important for floating-point operations than absolutely
2394 accurate adherence to the requirements of the standard. Currently the
2395 following operations are affected:
2396
2397 @table @asis
2398 @item Complex Multiplication
2399 The normal simple formula for complex multiplication can result in intermediate
2400 overflows for numbers near the end of the range. The Ada standard requires that
2401 this situation be detected and corrected by scaling, but in Fast_Math mode such
2402 cases will simply result in overflow. Note that to take advantage of this you
2403 must instantiate your own version of @code{Ada.Numerics.Generic_Complex_Types}
2404 under control of the pragma, rather than use the preinstantiated versions.
2405 @end table
2406
2407 @node Pragma Favor_Top_Level
2408 @unnumberedsec Pragma Favor_Top_Level
2409 @findex Favor_Top_Level
2410 @noindent
2411 Syntax:
2412
2413 @smallexample @c ada
2414 pragma Favor_Top_Level (type_NAME);
2415 @end smallexample
2416
2417 @noindent
2418 The named type must be an access-to-subprogram type. This pragma is an
2419 efficiency hint to the compiler, regarding the use of 'Access or
2420 'Unrestricted_Access on nested (non-library-level) subprograms. The
2421 pragma means that nested subprograms are not used with this type, or
2422 are rare, so that the generated code should be efficient in the
2423 top-level case. When this pragma is used, dynamically generated
2424 trampolines may be used on some targets for nested subprograms.
2425 See also the No_Implicit_Dynamic_Code restriction.
2426
2427 @node Pragma Finalize_Storage_Only
2428 @unnumberedsec Pragma Finalize_Storage_Only
2429 @findex Finalize_Storage_Only
2430 @noindent
2431 Syntax:
2432
2433 @smallexample @c ada
2434 pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
2435 @end smallexample
2436
2437 @noindent
2438 This pragma allows the compiler not to emit a Finalize call for objects
2439 defined at the library level.  This is mostly useful for types where
2440 finalization is only used to deal with storage reclamation since in most
2441 environments it is not necessary to reclaim memory just before terminating
2442 execution, hence the name.
2443
2444 @node Pragma Float_Representation
2445 @unnumberedsec Pragma Float_Representation
2446 @cindex OpenVMS
2447 @findex Float_Representation
2448 @noindent
2449 Syntax:
2450
2451 @smallexample @c ada
2452 pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
2453
2454 FLOAT_REP ::= VAX_Float | IEEE_Float
2455 @end smallexample
2456
2457 @noindent
2458 In the one argument form, this pragma is a configuration pragma which
2459 allows control over the internal representation chosen for the predefined
2460 floating point types declared in the packages @code{Standard} and
2461 @code{System}. On all systems other than OpenVMS, the argument must
2462 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2463 argument may be @code{VAX_Float} to specify the use of the VAX float
2464 format for the floating-point types in Standard. This requires that
2465 the standard runtime libraries be recompiled.
2466
2467 The two argument form specifies the representation to be used for
2468 the specified floating-point type. On all systems other than OpenVMS,
2469 the argument must
2470 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2471 argument may be @code{VAX_Float} to specify the use of the VAX float
2472 format, as follows:
2473
2474 @itemize @bullet
2475 @item
2476 For digits values up to 6, F float format will be used.
2477 @item
2478 For digits values from 7 to 9, D float format will be used.
2479 @item
2480 For digits values from 10 to 15, G float format will be used.
2481 @item
2482 Digits values above 15 are not allowed.
2483 @end itemize
2484
2485 @node Pragma Ident
2486 @unnumberedsec Pragma Ident
2487 @findex Ident
2488 @noindent
2489 Syntax:
2490
2491 @smallexample @c ada
2492 pragma Ident (static_string_EXPRESSION);
2493 @end smallexample
2494
2495 @noindent
2496 This pragma provides a string identification in the generated object file,
2497 if the system supports the concept of this kind of identification string.
2498 This pragma is allowed only in the outermost declarative part or
2499 declarative items of a compilation unit. If more than one @code{Ident}
2500 pragma is given, only the last one processed is effective.
2501 @cindex OpenVMS
2502 On OpenVMS systems, the effect of the pragma is identical to the effect of
2503 the DEC Ada 83 pragma of the same name. Note that in DEC Ada 83, the
2504 maximum allowed length is 31 characters, so if it is important to
2505 maintain compatibility with this compiler, you should obey this length
2506 limit.
2507
2508 @node Pragma Implemented
2509 @unnumberedsec Pragma Implemented
2510 @findex Implemented
2511 @noindent
2512 Syntax:
2513
2514 @smallexample @c ada
2515 pragma Implemented (procedure_LOCAL_NAME, implementation_kind);
2516
2517 implementation_kind ::= By_Entry | By_Protected_Procedure | By_Any
2518 @end smallexample
2519
2520 @noindent
2521 This is an Ada 2012 representation pragma which applies to protected, task
2522 and synchronized interface primitives. The use of pragma Implemented provides
2523 a way to impose a static requirement on the overriding operation by adhering
2524 to one of the three implementation kids: entry, protected procedure or any of
2525 the above.
2526
2527 @smallexample @c ada
2528 type Synch_Iface is synchronized interface;
2529 procedure Prim_Op (Obj : in out Iface) is abstract;
2530 pragma Implemented (Prim_Op, By_Protected_Procedure);
2531
2532 protected type Prot_1 is new Synch_Iface with
2533    procedure Prim_Op;  --  Legal
2534 end Prot_1;
2535
2536 protected type Prot_2 is new Synch_Iface with
2537    entry Prim_Op;      --  Illegal
2538 end Prot_2;
2539
2540 task type Task_Typ is new Synch_Iface with
2541    entry Prim_Op;      --  Illegal
2542 end Task_Typ;
2543 @end smallexample
2544
2545 @noindent
2546 When applied to the procedure_or_entry_NAME of a requeue statement, pragma
2547 Implemented determines the runtime behavior of the requeue. Implementation kind
2548 By_Entry guarantees that the action of requeueing will proceed from an entry to
2549 another entry. Implementation kind By_Protected_Procedure transforms the
2550 requeue into a dispatching call, thus eliminating the chance of blocking. Kind
2551 By_Any shares the behavior of By_Entry and By_Protected_Procedure depending on
2552 the target's overriding subprogram kind.
2553
2554 @node Pragma Implicit_Packing
2555 @unnumberedsec Pragma Implicit_Packing
2556 @findex Implicit_Packing
2557 @noindent
2558 Syntax:
2559
2560 @smallexample @c ada
2561 pragma Implicit_Packing;
2562 @end smallexample
2563
2564 @noindent
2565 This is a configuration pragma that requests implicit packing for packed
2566 arrays for which a size clause is given but no explicit pragma Pack or
2567 specification of Component_Size is present. It also applies to records
2568 where no record representation clause is present. Consider this example:
2569
2570 @smallexample @c ada
2571 type R is array (0 .. 7) of Boolean;
2572 for R'Size use 8;
2573 @end smallexample
2574
2575 @noindent
2576 In accordance with the recommendation in the RM (RM 13.3(53)), a Size clause
2577 does not change the layout of a composite object. So the Size clause in the
2578 above example is normally rejected, since the default layout of the array uses
2579 8-bit components, and thus the array requires a minimum of 64 bits.
2580
2581 If this declaration is compiled in a region of code covered by an occurrence
2582 of the configuration pragma Implicit_Packing, then the Size clause in this
2583 and similar examples will cause implicit packing and thus be accepted. For
2584 this implicit packing to occur, the type in question must be an array of small
2585 components whose size is known at compile time, and the Size clause must
2586 specify the exact size that corresponds to the length of the array multiplied
2587 by the size in bits of the component type.
2588 @cindex Array packing
2589
2590 Similarly, the following example shows the use in the record case
2591
2592 @smallexample @c ada
2593 type r is record
2594    a, b, c, d, e, f, g, h : boolean;
2595    chr                    : character;
2596 end record;
2597 for r'size use 16;
2598 @end smallexample
2599
2600 @noindent
2601 Without a pragma Pack, each Boolean field requires 8 bits, so the
2602 minimum size is 72 bits, but with a pragma Pack, 16 bits would be
2603 sufficient. The use of pragma Implicit_Packing allows this record
2604 declaration to compile without an explicit pragma Pack.
2605 @node Pragma Import_Exception
2606 @unnumberedsec Pragma Import_Exception
2607 @cindex OpenVMS
2608 @findex Import_Exception
2609 @noindent
2610 Syntax:
2611
2612 @smallexample @c ada
2613 pragma Import_Exception (
2614      [Internal =>] LOCAL_NAME
2615   [, [External =>] EXTERNAL_SYMBOL]
2616   [, [Form     =>] Ada | VMS]
2617   [, [Code     =>] static_integer_EXPRESSION]);
2618
2619 EXTERNAL_SYMBOL ::=
2620   IDENTIFIER
2621 | static_string_EXPRESSION
2622 @end smallexample
2623
2624 @noindent
2625 This pragma is implemented only in the OpenVMS implementation of GNAT@.
2626 It allows OpenVMS conditions (for example, from OpenVMS system services or
2627 other OpenVMS languages) to be propagated to Ada programs as Ada exceptions.
2628 The pragma specifies that the exception associated with an exception
2629 declaration in an Ada program be defined externally (in non-Ada code).
2630 For further details on this pragma, see the
2631 DEC Ada Language Reference Manual, section 13.9a.3.1.
2632
2633 @node Pragma Import_Function
2634 @unnumberedsec Pragma Import_Function
2635 @findex Import_Function
2636 @noindent
2637 Syntax:
2638
2639 @smallexample @c ada
2640 pragma Import_Function (
2641      [Internal                 =>] LOCAL_NAME,
2642   [, [External                 =>] EXTERNAL_SYMBOL]
2643   [, [Parameter_Types          =>] PARAMETER_TYPES]
2644   [, [Result_Type              =>] SUBTYPE_MARK]
2645   [, [Mechanism                =>] MECHANISM]
2646   [, [Result_Mechanism         =>] MECHANISM_NAME]
2647   [, [First_Optional_Parameter =>] IDENTIFIER]);
2648
2649 EXTERNAL_SYMBOL ::=
2650   IDENTIFIER
2651 | static_string_EXPRESSION
2652
2653 PARAMETER_TYPES ::=
2654   null
2655 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2656
2657 TYPE_DESIGNATOR ::=
2658   subtype_NAME
2659 | subtype_Name ' Access
2660
2661 MECHANISM ::=
2662   MECHANISM_NAME
2663 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2664
2665 MECHANISM_ASSOCIATION ::=
2666   [formal_parameter_NAME =>] MECHANISM_NAME
2667
2668 MECHANISM_NAME ::=
2669   Value
2670 | Reference
2671 | Descriptor [([Class =>] CLASS_NAME)]
2672 | Short_Descriptor [([Class =>] CLASS_NAME)]
2673
2674 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2675 @end smallexample
2676
2677 @noindent
2678 This pragma is used in conjunction with a pragma @code{Import} to
2679 specify additional information for an imported function.  The pragma
2680 @code{Import} (or equivalent pragma @code{Interface}) must precede the
2681 @code{Import_Function} pragma and both must appear in the same
2682 declarative part as the function specification.
2683
2684 The @var{Internal} argument must uniquely designate
2685 the function to which the
2686 pragma applies.  If more than one function name exists of this name in
2687 the declarative part you must use the @code{Parameter_Types} and
2688 @var{Result_Type} parameters to achieve the required unique
2689 designation.  Subtype marks in these parameters must exactly match the
2690 subtypes in the corresponding function specification, using positional
2691 notation to match parameters with subtype marks.
2692 The form with an @code{'Access} attribute can be used to match an
2693 anonymous access parameter.
2694
2695 You may optionally use the @var{Mechanism} and @var{Result_Mechanism}
2696 parameters to specify passing mechanisms for the
2697 parameters and result.  If you specify a single mechanism name, it
2698 applies to all parameters.  Otherwise you may specify a mechanism on a
2699 parameter by parameter basis using either positional or named
2700 notation.  If the mechanism is not specified, the default mechanism
2701 is used.
2702
2703 @cindex OpenVMS
2704 @cindex Passing by descriptor
2705 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2706 The default behavior for Import_Function is to pass a 64bit descriptor
2707 unless short_descriptor is specified, then a 32bit descriptor is passed.
2708
2709 @code{First_Optional_Parameter} applies only to OpenVMS ports of GNAT@.
2710 It specifies that the designated parameter and all following parameters
2711 are optional, meaning that they are not passed at the generated code
2712 level (this is distinct from the notion of optional parameters in Ada
2713 where the parameters are passed anyway with the designated optional
2714 parameters).  All optional parameters must be of mode @code{IN} and have
2715 default parameter values that are either known at compile time
2716 expressions, or uses of the @code{'Null_Parameter} attribute.
2717
2718 @node Pragma Import_Object
2719 @unnumberedsec Pragma Import_Object
2720 @findex Import_Object
2721 @noindent
2722 Syntax:
2723
2724 @smallexample @c ada
2725 pragma Import_Object
2726      [Internal =>] LOCAL_NAME
2727   [, [External =>] EXTERNAL_SYMBOL]
2728   [, [Size     =>] EXTERNAL_SYMBOL]);
2729
2730 EXTERNAL_SYMBOL ::=
2731   IDENTIFIER
2732 | static_string_EXPRESSION
2733 @end smallexample
2734
2735 @noindent
2736 This pragma designates an object as imported, and apart from the
2737 extended rules for external symbols, is identical in effect to the use of
2738 the normal @code{Import} pragma applied to an object.  Unlike the
2739 subprogram case, you need not use a separate @code{Import} pragma,
2740 although you may do so (and probably should do so from a portability
2741 point of view).  @var{size} is syntax checked, but otherwise ignored by
2742 GNAT@.
2743
2744 @node Pragma Import_Procedure
2745 @unnumberedsec Pragma Import_Procedure
2746 @findex Import_Procedure
2747 @noindent
2748 Syntax:
2749
2750 @smallexample @c ada
2751 pragma Import_Procedure (
2752      [Internal                 =>] LOCAL_NAME
2753   [, [External                 =>] EXTERNAL_SYMBOL]
2754   [, [Parameter_Types          =>] PARAMETER_TYPES]
2755   [, [Mechanism                =>] MECHANISM]
2756   [, [First_Optional_Parameter =>] IDENTIFIER]);
2757
2758 EXTERNAL_SYMBOL ::=
2759   IDENTIFIER
2760 | static_string_EXPRESSION
2761
2762 PARAMETER_TYPES ::=
2763   null
2764 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2765
2766 TYPE_DESIGNATOR ::=
2767   subtype_NAME
2768 | subtype_Name ' Access
2769
2770 MECHANISM ::=
2771   MECHANISM_NAME
2772 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2773
2774 MECHANISM_ASSOCIATION ::=
2775   [formal_parameter_NAME =>] MECHANISM_NAME
2776
2777 MECHANISM_NAME ::=
2778   Value
2779 | Reference
2780 | Descriptor [([Class =>] CLASS_NAME)]
2781 | Short_Descriptor [([Class =>] CLASS_NAME)]
2782
2783 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2784 @end smallexample
2785
2786 @noindent
2787 This pragma is identical to @code{Import_Function} except that it
2788 applies to a procedure rather than a function and the parameters
2789 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2790
2791 @node Pragma Import_Valued_Procedure
2792 @unnumberedsec Pragma Import_Valued_Procedure
2793 @findex Import_Valued_Procedure
2794 @noindent
2795 Syntax:
2796
2797 @smallexample @c ada
2798 pragma Import_Valued_Procedure (
2799      [Internal                 =>] LOCAL_NAME
2800   [, [External                 =>] EXTERNAL_SYMBOL]
2801   [, [Parameter_Types          =>] PARAMETER_TYPES]
2802   [, [Mechanism                =>] MECHANISM]
2803   [, [First_Optional_Parameter =>] IDENTIFIER]);
2804
2805 EXTERNAL_SYMBOL ::=
2806   IDENTIFIER
2807 | static_string_EXPRESSION
2808
2809 PARAMETER_TYPES ::=
2810   null
2811 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2812
2813 TYPE_DESIGNATOR ::=
2814   subtype_NAME
2815 | subtype_Name ' Access
2816
2817 MECHANISM ::=
2818   MECHANISM_NAME
2819 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2820
2821 MECHANISM_ASSOCIATION ::=
2822   [formal_parameter_NAME =>] MECHANISM_NAME
2823
2824 MECHANISM_NAME ::=
2825   Value
2826 | Reference
2827 | Descriptor [([Class =>] CLASS_NAME)]
2828 | Short_Descriptor [([Class =>] CLASS_NAME)]
2829
2830 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2831 @end smallexample
2832
2833 @noindent
2834 This pragma is identical to @code{Import_Procedure} except that the
2835 first parameter of @var{LOCAL_NAME}, which must be present, must be of
2836 mode @code{OUT}, and externally the subprogram is treated as a function
2837 with this parameter as the result of the function.  The purpose of this
2838 capability is to allow the use of @code{OUT} and @code{IN OUT}
2839 parameters in interfacing to external functions (which are not permitted
2840 in Ada functions).  You may optionally use the @code{Mechanism}
2841 parameters to specify passing mechanisms for the parameters.
2842 If you specify a single mechanism name, it applies to all parameters.
2843 Otherwise you may specify a mechanism on a parameter by parameter
2844 basis using either positional or named notation.  If the mechanism is not
2845 specified, the default mechanism is used.
2846
2847 Note that it is important to use this pragma in conjunction with a separate
2848 pragma Import that specifies the desired convention, since otherwise the
2849 default convention is Ada, which is almost certainly not what is required.
2850
2851 @node Pragma Initialize_Scalars
2852 @unnumberedsec Pragma Initialize_Scalars
2853 @findex Initialize_Scalars
2854 @cindex debugging with Initialize_Scalars
2855 @noindent
2856 Syntax:
2857
2858 @smallexample @c ada
2859 pragma Initialize_Scalars;
2860 @end smallexample
2861
2862 @noindent
2863 This pragma is similar to @code{Normalize_Scalars} conceptually but has
2864 two important differences.  First, there is no requirement for the pragma
2865 to be used uniformly in all units of a partition, in particular, it is fine
2866 to use this just for some or all of the application units of a partition,
2867 without needing to recompile the run-time library.
2868
2869 In the case where some units are compiled with the pragma, and some without,
2870 then a declaration of a variable where the type is defined in package
2871 Standard or is locally declared will always be subject to initialization,
2872 as will any declaration of a scalar variable.  For composite variables,
2873 whether the variable is initialized may also depend on whether the package
2874 in which the type of the variable is declared is compiled with the pragma.
2875
2876 The other important difference is that you can control the value used
2877 for initializing scalar objects.  At bind time, you can select several
2878 options for initialization. You can
2879 initialize with invalid values (similar to Normalize_Scalars, though for
2880 Initialize_Scalars it is not always possible to determine the invalid
2881 values in complex cases like signed component fields with non-standard
2882 sizes). You can also initialize with high or
2883 low values, or with a specified bit pattern.  See the users guide for binder
2884 options for specifying these cases.
2885
2886 This means that you can compile a program, and then without having to
2887 recompile the program, you can run it with different values being used
2888 for initializing otherwise uninitialized values, to test if your program
2889 behavior depends on the choice.  Of course the behavior should not change,
2890 and if it does, then most likely you have an erroneous reference to an
2891 uninitialized value.
2892
2893 It is even possible to change the value at execution time eliminating even
2894 the need to rebind with a different switch using an environment variable.
2895 See the GNAT users guide for details.
2896
2897 Note that pragma @code{Initialize_Scalars} is particularly useful in
2898 conjunction with the enhanced validity checking that is now provided
2899 in GNAT, which checks for invalid values under more conditions.
2900 Using this feature (see description of the @option{-gnatV} flag in the
2901 users guide) in conjunction with pragma @code{Initialize_Scalars}
2902 provides a powerful new tool to assist in the detection of problems
2903 caused by uninitialized variables.
2904
2905 Note: the use of @code{Initialize_Scalars} has a fairly extensive
2906 effect on the generated code. This may cause your code to be
2907 substantially larger. It may also cause an increase in the amount
2908 of stack required, so it is probably a good idea to turn on stack
2909 checking (see description of stack checking in the GNAT users guide)
2910 when using this pragma.
2911
2912 @node Pragma Inline_Always
2913 @unnumberedsec Pragma Inline_Always
2914 @findex Inline_Always
2915 @noindent
2916 Syntax:
2917
2918 @smallexample @c ada
2919 pragma Inline_Always (NAME [, NAME]);
2920 @end smallexample
2921
2922 @noindent
2923 Similar to pragma @code{Inline} except that inlining is not subject to
2924 the use of option @option{-gnatn} and the inlining happens regardless of
2925 whether this option is used.
2926
2927 @node Pragma Inline_Generic
2928 @unnumberedsec Pragma Inline_Generic
2929 @findex Inline_Generic
2930 @noindent
2931 Syntax:
2932
2933 @smallexample @c ada
2934 pragma Inline_Generic (generic_package_NAME);
2935 @end smallexample
2936
2937 @noindent
2938 This is implemented for compatibility with DEC Ada 83 and is recognized,
2939 but otherwise ignored, by GNAT@.  All generic instantiations are inlined
2940 by default when using GNAT@.
2941
2942 @node Pragma Interface
2943 @unnumberedsec Pragma Interface
2944 @findex Interface
2945 @noindent
2946 Syntax:
2947
2948 @smallexample @c ada
2949 pragma Interface (
2950      [Convention    =>] convention_identifier,
2951      [Entity        =>] local_NAME
2952   [, [External_Name =>] static_string_expression]
2953   [, [Link_Name     =>] static_string_expression]);
2954 @end smallexample
2955
2956 @noindent
2957 This pragma is identical in syntax and semantics to
2958 the standard Ada pragma @code{Import}.  It is provided for compatibility
2959 with Ada 83.  The definition is upwards compatible both with pragma
2960 @code{Interface} as defined in the Ada 83 Reference Manual, and also
2961 with some extended implementations of this pragma in certain Ada 83
2962 implementations.  The only difference between pragma @code{Interface}
2963 and pragma @code{Import} is that there is special circuitry to allow
2964 both pragmas to appear for the same subprogram entity (normally it
2965 is illegal to have multiple @code{Import} pragmas. This is useful in
2966 maintaining Ada 83/Ada 95 compatibility and is compatible with other
2967 Ada 83 compilers.
2968
2969 @node Pragma Interface_Name
2970 @unnumberedsec Pragma Interface_Name
2971 @findex Interface_Name
2972 @noindent
2973 Syntax:
2974
2975 @smallexample @c ada
2976 pragma Interface_Name (
2977      [Entity        =>] LOCAL_NAME
2978   [, [External_Name =>] static_string_EXPRESSION]
2979   [, [Link_Name     =>] static_string_EXPRESSION]);
2980 @end smallexample
2981
2982 @noindent
2983 This pragma provides an alternative way of specifying the interface name
2984 for an interfaced subprogram, and is provided for compatibility with Ada
2985 83 compilers that use the pragma for this purpose.  You must provide at
2986 least one of @var{External_Name} or @var{Link_Name}.
2987
2988 @node Pragma Interrupt_Handler
2989 @unnumberedsec Pragma Interrupt_Handler
2990 @findex Interrupt_Handler
2991 @noindent
2992 Syntax:
2993
2994 @smallexample @c ada
2995 pragma Interrupt_Handler (procedure_LOCAL_NAME);
2996 @end smallexample
2997
2998 @noindent
2999 This program unit pragma is supported for parameterless protected procedures
3000 as described in Annex C of the Ada Reference Manual. On the AAMP target
3001 the pragma can also be specified for nonprotected parameterless procedures
3002 that are declared at the library level (which includes procedures
3003 declared at the top level of a library package). In the case of AAMP,
3004 when this pragma is applied to a nonprotected procedure, the instruction
3005 @code{IERET} is generated for returns from the procedure, enabling
3006 maskable interrupts, in place of the normal return instruction.
3007
3008 @node Pragma Interrupt_State
3009 @unnumberedsec Pragma Interrupt_State
3010 @findex Interrupt_State
3011 @noindent
3012 Syntax:
3013
3014 @smallexample @c ada
3015 pragma Interrupt_State
3016  ([Name  =>] value,
3017   [State =>] SYSTEM | RUNTIME | USER);
3018 @end smallexample
3019
3020 @noindent
3021 Normally certain interrupts are reserved to the implementation.  Any attempt
3022 to attach an interrupt causes Program_Error to be raised, as described in
3023 RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
3024 many systems for an @kbd{Ctrl-C} interrupt.  Normally this interrupt is
3025 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
3026 interrupt execution.  Additionally, signals such as @code{SIGSEGV},
3027 @code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
3028 Ada exceptions, or used to implement run-time functions such as the
3029 @code{abort} statement and stack overflow checking.
3030
3031 Pragma @code{Interrupt_State} provides a general mechanism for overriding
3032 such uses of interrupts.  It subsumes the functionality of pragma
3033 @code{Unreserve_All_Interrupts}.  Pragma @code{Interrupt_State} is not
3034 available on Windows or VMS.  On all other platforms than VxWorks,
3035 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
3036 and may be used to mark interrupts required by the board support package
3037 as reserved.
3038
3039 Interrupts can be in one of three states:
3040 @itemize @bullet
3041 @item System
3042
3043 The interrupt is reserved (no Ada handler can be installed), and the
3044 Ada run-time may not install a handler. As a result you are guaranteed
3045 standard system default action if this interrupt is raised.
3046
3047 @item Runtime
3048
3049 The interrupt is reserved (no Ada handler can be installed). The run time
3050 is allowed to install a handler for internal control purposes, but is
3051 not required to do so.
3052
3053 @item User
3054
3055 The interrupt is unreserved.  The user may install a handler to provide
3056 some other action.
3057 @end itemize
3058
3059 @noindent
3060 These states are the allowed values of the @code{State} parameter of the
3061 pragma.  The @code{Name} parameter is a value of the type
3062 @code{Ada.Interrupts.Interrupt_ID}.  Typically, it is a name declared in
3063 @code{Ada.Interrupts.Names}.
3064
3065 This is a configuration pragma, and the binder will check that there
3066 are no inconsistencies between different units in a partition in how a
3067 given interrupt is specified. It may appear anywhere a pragma is legal.
3068
3069 The effect is to move the interrupt to the specified state.
3070
3071 By declaring interrupts to be SYSTEM, you guarantee the standard system
3072 action, such as a core dump.
3073
3074 By declaring interrupts to be USER, you guarantee that you can install
3075 a handler.
3076
3077 Note that certain signals on many operating systems cannot be caught and
3078 handled by applications.  In such cases, the pragma is ignored.  See the
3079 operating system documentation, or the value of the array @code{Reserved}
3080 declared in the spec of package @code{System.OS_Interface}.
3081
3082 Overriding the default state of signals used by the Ada runtime may interfere
3083 with an application's runtime behavior in the cases of the synchronous signals,
3084 and in the case of the signal used to implement the @code{abort} statement.
3085
3086 @node Pragma Invariant
3087 @unnumberedsec Pragma Invariant
3088 @findex Invariant
3089 @noindent
3090 Syntax:
3091
3092 @smallexample @c ada
3093 pragma Invariant
3094   ([Entity =>]    private_type_LOCAL_NAME,
3095    [Check  =>]    EXPRESSION
3096    [,[Message =>] String_Expression]);
3097 @end smallexample
3098
3099 @noindent
3100 This pragma provides exactly the same capabilities as the Invariant aspect
3101 defined in AI05-0146-1, and in the Ada 2012 Reference Manual. The Invariant
3102 aspect is fully implemented in Ada 2012 mode, but since it requires the use
3103 of the aspect syntax, which is not available exception in 2012 mode, it is
3104 not possible to use the Invariant aspect in earlier versions of Ada. However
3105 the Invariant pragma may be used in any version of Ada.
3106
3107 The pragma must appear within the visible part of the package specification,
3108 after the type to which its Entity argument appears. As with the Invariant
3109 aspect, the Check expression is not analyzed until the end of the visible
3110 part of the package, so it may contain forward references. The Message
3111 argument, if present, provides the exception message used if the invariant
3112 is violated. If no Message parameter is provided, a default message that
3113 identifies the line on which the pragma appears is used.
3114
3115 It is permissible to have multiple Invariants for the same type entity, in
3116 which case they are and'ed together. It is permissible to use this pragma
3117 in Ada 2012 mode, but you cannot have both an invariant aspect and an
3118 invariant pragma for the same entity.
3119
3120 For further details on the use of this pragma, see the Ada 2012 documentation
3121 of the Invariant aspect.
3122
3123 @node Pragma Keep_Names
3124 @unnumberedsec Pragma Keep_Names
3125 @findex Keep_Names
3126 @noindent
3127 Syntax:
3128
3129 @smallexample @c ada
3130 pragma Keep_Names ([On =>] enumeration_first_subtype_LOCAL_NAME);
3131 @end smallexample
3132
3133 @noindent
3134 The @var{LOCAL_NAME} argument
3135 must refer to an enumeration first subtype
3136 in the current declarative part. The effect is to retain the enumeration
3137 literal names for use by @code{Image} and @code{Value} even if a global
3138 @code{Discard_Names} pragma applies. This is useful when you want to
3139 generally suppress enumeration literal names and for example you therefore
3140 use a @code{Discard_Names} pragma in the @file{gnat.adc} file, but you
3141 want to retain the names for specific enumeration types.
3142
3143 @node Pragma License
3144 @unnumberedsec Pragma License
3145 @findex License
3146 @cindex License checking
3147 @noindent
3148 Syntax:
3149
3150 @smallexample @c ada
3151 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
3152 @end smallexample
3153
3154 @noindent
3155 This pragma is provided to allow automated checking for appropriate license
3156 conditions with respect to the standard and modified GPL@.  A pragma
3157 @code{License}, which is a configuration pragma that typically appears at
3158 the start of a source file or in a separate @file{gnat.adc} file, specifies
3159 the licensing conditions of a unit as follows:
3160
3161 @itemize @bullet
3162 @item Unrestricted
3163 This is used for a unit that can be freely used with no license restrictions.
3164 Examples of such units are public domain units, and units from the Ada
3165 Reference Manual.
3166
3167 @item GPL
3168 This is used for a unit that is licensed under the unmodified GPL, and which
3169 therefore cannot be @code{with}'ed by a restricted unit.
3170
3171 @item Modified_GPL
3172 This is used for a unit licensed under the GNAT modified GPL that includes
3173 a special exception paragraph that specifically permits the inclusion of
3174 the unit in programs without requiring the entire program to be released
3175 under the GPL@.
3176
3177 @item Restricted
3178 This is used for a unit that is restricted in that it is not permitted to
3179 depend on units that are licensed under the GPL@.  Typical examples are
3180 proprietary code that is to be released under more restrictive license
3181 conditions.  Note that restricted units are permitted to @code{with} units
3182 which are licensed under the modified GPL (this is the whole point of the
3183 modified GPL).
3184
3185 @end itemize
3186
3187 @noindent
3188 Normally a unit with no @code{License} pragma is considered to have an
3189 unknown license, and no checking is done.  However, standard GNAT headers
3190 are recognized, and license information is derived from them as follows.
3191
3192 @itemize @bullet
3193
3194 A GNAT license header starts with a line containing 78 hyphens.  The following
3195 comment text is searched for the appearance of any of the following strings.
3196
3197 If the string ``GNU General Public License'' is found, then the unit is assumed
3198 to have GPL license, unless the string ``As a special exception'' follows, in
3199 which case the license is assumed to be modified GPL@.
3200
3201 If one of the strings
3202 ``This specification is adapted from the Ada Semantic Interface'' or
3203 ``This specification is derived from the Ada Reference Manual'' is found
3204 then the unit is assumed to be unrestricted.
3205 @end itemize
3206
3207 @noindent
3208 These default actions means that a program with a restricted license pragma
3209 will automatically get warnings if a GPL unit is inappropriately
3210 @code{with}'ed.  For example, the program:
3211
3212 @smallexample @c ada
3213 with Sem_Ch3;
3214 with GNAT.Sockets;
3215 procedure Secret_Stuff is
3216   @dots{}
3217 end Secret_Stuff
3218 @end smallexample
3219
3220 @noindent
3221 if compiled with pragma @code{License} (@code{Restricted}) in a
3222 @file{gnat.adc} file will generate the warning:
3223
3224 @smallexample
3225 1.  with Sem_Ch3;
3226         |
3227    >>> license of withed unit "Sem_Ch3" is incompatible
3228
3229 2.  with GNAT.Sockets;
3230 3.  procedure Secret_Stuff is
3231 @end smallexample
3232
3233 @noindent
3234 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
3235 compiler and is licensed under the
3236 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
3237 run time, and is therefore licensed under the modified GPL@.
3238
3239 @node Pragma Link_With
3240 @unnumberedsec Pragma Link_With
3241 @findex Link_With
3242 @noindent
3243 Syntax:
3244
3245 @smallexample @c ada
3246 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
3247 @end smallexample
3248
3249 @noindent
3250 This pragma is provided for compatibility with certain Ada 83 compilers.
3251 It has exactly the same effect as pragma @code{Linker_Options} except
3252 that spaces occurring within one of the string expressions are treated
3253 as separators. For example, in the following case:
3254
3255 @smallexample @c ada
3256 pragma Link_With ("-labc -ldef");
3257 @end smallexample
3258
3259 @noindent
3260 results in passing the strings @code{-labc} and @code{-ldef} as two
3261 separate arguments to the linker. In addition pragma Link_With allows
3262 multiple arguments, with the same effect as successive pragmas.
3263
3264 @node Pragma Linker_Alias
3265 @unnumberedsec Pragma Linker_Alias
3266 @findex Linker_Alias
3267 @noindent
3268 Syntax:
3269
3270 @smallexample @c ada
3271 pragma Linker_Alias (
3272   [Entity =>] LOCAL_NAME,
3273   [Target =>] static_string_EXPRESSION);
3274 @end smallexample
3275
3276 @noindent
3277 @var{LOCAL_NAME} must refer to an object that is declared at the library
3278 level. This pragma establishes the given entity as a linker alias for the
3279 given target. It is equivalent to @code{__attribute__((alias))} in GNU C
3280 and causes @var{LOCAL_NAME} to be emitted as an alias for the symbol
3281 @var{static_string_EXPRESSION} in the object file, that is to say no space
3282 is reserved for @var{LOCAL_NAME} by the assembler and it will be resolved
3283 to the same address as @var{static_string_EXPRESSION} by the linker.
3284
3285 The actual linker name for the target must be used (e.g.@: the fully
3286 encoded name with qualification in Ada, or the mangled name in C++),
3287 or it must be declared using the C convention with @code{pragma Import}
3288 or @code{pragma Export}.
3289
3290 Not all target machines support this pragma. On some of them it is accepted
3291 only if @code{pragma Weak_External} has been applied to @var{LOCAL_NAME}.
3292
3293 @smallexample @c ada
3294 --  Example of the use of pragma Linker_Alias
3295
3296 package p is
3297   i : Integer := 1;
3298   pragma Export (C, i);
3299
3300   new_name_for_i : Integer;
3301   pragma Linker_Alias (new_name_for_i, "i");
3302 end p;
3303 @end smallexample
3304
3305 @node Pragma Linker_Constructor
3306 @unnumberedsec Pragma Linker_Constructor
3307 @findex Linker_Constructor
3308 @noindent
3309 Syntax:
3310
3311 @smallexample @c ada
3312 pragma Linker_Constructor (procedure_LOCAL_NAME);
3313 @end smallexample
3314
3315 @noindent
3316 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
3317 is declared at the library level. A procedure to which this pragma is
3318 applied will be treated as an initialization routine by the linker.
3319 It is equivalent to @code{__attribute__((constructor))} in GNU C and
3320 causes @var{procedure_LOCAL_NAME} to be invoked before the entry point
3321 of the executable is called (or immediately after the shared library is
3322 loaded if the procedure is linked in a shared library), in particular
3323 before the Ada run-time environment is set up.
3324
3325 Because of these specific contexts, the set of operations such a procedure
3326 can perform is very limited and the type of objects it can manipulate is
3327 essentially restricted to the elementary types. In particular, it must only
3328 contain code to which pragma Restrictions (No_Elaboration_Code) applies.
3329
3330 This pragma is used by GNAT to implement auto-initialization of shared Stand
3331 Alone Libraries, which provides a related capability without the restrictions
3332 listed above. Where possible, the use of Stand Alone Libraries is preferable
3333 to the use of this pragma.
3334
3335 @node Pragma Linker_Destructor
3336 @unnumberedsec Pragma Linker_Destructor
3337 @findex Linker_Destructor
3338 @noindent
3339 Syntax:
3340
3341 @smallexample @c ada
3342 pragma Linker_Destructor (procedure_LOCAL_NAME);
3343 @end smallexample
3344
3345 @noindent
3346 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
3347 is declared at the library level. A procedure to which this pragma is
3348 applied will be treated as a finalization routine by the linker.
3349 It is equivalent to @code{__attribute__((destructor))} in GNU C and
3350 causes @var{procedure_LOCAL_NAME} to be invoked after the entry point
3351 of the executable has exited (or immediately before the shared library
3352 is unloaded if the procedure is linked in a shared library), in particular
3353 after the Ada run-time environment is shut down.
3354
3355 See @code{pragma Linker_Constructor} for the set of restrictions that apply
3356 because of these specific contexts.
3357
3358 @node Pragma Linker_Section
3359 @unnumberedsec Pragma Linker_Section
3360 @findex Linker_Section
3361 @noindent
3362 Syntax:
3363
3364 @smallexample @c ada
3365 pragma Linker_Section (
3366   [Entity  =>] LOCAL_NAME,
3367   [Section =>] static_string_EXPRESSION);
3368 @end smallexample
3369
3370 @noindent
3371 @var{LOCAL_NAME} must refer to an object that is declared at the library
3372 level. This pragma specifies the name of the linker section for the given
3373 entity. It is equivalent to @code{__attribute__((section))} in GNU C and
3374 causes @var{LOCAL_NAME} to be placed in the @var{static_string_EXPRESSION}
3375 section of the executable (assuming the linker doesn't rename the section).
3376
3377 The compiler normally places library-level objects in standard sections
3378 depending on their type: procedures and functions generally go in the
3379 @code{.text} section, initialized variables in the @code{.data} section
3380 and uninitialized variables in the @code{.bss} section.
3381
3382 Other, special sections may exist on given target machines to map special
3383 hardware, for example I/O ports or flash memory. This pragma is a means to
3384 defer the final layout of the executable to the linker, thus fully working
3385 at the symbolic level with the compiler.
3386
3387 Some file formats do not support arbitrary sections so not all target
3388 machines support this pragma. The use of this pragma may cause a program
3389 execution to be erroneous if it is used to place an entity into an
3390 inappropriate section (e.g.@: a modified variable into the @code{.text}
3391 section). See also @code{pragma Persistent_BSS}.
3392
3393 @smallexample @c ada
3394 --  Example of the use of pragma Linker_Section
3395
3396 package IO_Card is
3397   Port_A : Integer;
3398   pragma Volatile (Port_A);
3399   pragma Linker_Section (Port_A, ".bss.port_a");
3400
3401   Port_B : Integer;
3402   pragma Volatile (Port_B);
3403   pragma Linker_Section (Port_B, ".bss.port_b");
3404 end IO_Card;
3405 @end smallexample
3406
3407 @node Pragma Long_Float
3408 @unnumberedsec Pragma Long_Float
3409 @cindex OpenVMS
3410 @findex Long_Float
3411 @noindent
3412 Syntax:
3413
3414 @smallexample @c ada
3415 pragma Long_Float (FLOAT_FORMAT);
3416
3417 FLOAT_FORMAT ::= D_Float | G_Float
3418 @end smallexample
3419
3420 @noindent
3421 This pragma is implemented only in the OpenVMS implementation of GNAT@.
3422 It allows control over the internal representation chosen for the predefined
3423 type @code{Long_Float} and for floating point type representations with
3424 @code{digits} specified in the range 7 through 15.
3425 For further details on this pragma, see the
3426 @cite{DEC Ada Language Reference Manual}, section 3.5.7b.  Note that to use
3427 this pragma, the standard runtime libraries must be recompiled.
3428
3429 @node Pragma Machine_Attribute
3430 @unnumberedsec Pragma Machine_Attribute
3431 @findex Machine_Attribute
3432 @noindent
3433 Syntax:
3434
3435 @smallexample @c ada
3436 pragma Machine_Attribute (
3437      [Entity         =>] LOCAL_NAME,
3438      [Attribute_Name =>] static_string_EXPRESSION
3439   [, [Info           =>] static_EXPRESSION] );
3440 @end smallexample
3441
3442 @noindent
3443 Machine-dependent attributes can be specified for types and/or
3444 declarations.  This pragma is semantically equivalent to
3445 @code{__attribute__((@var{attribute_name}))} (if @var{info} is not
3446 specified) or @code{__attribute__((@var{attribute_name}(@var{info})))}
3447 in GNU C, where @code{@var{attribute_name}} is recognized by the
3448 compiler middle-end or the @code{TARGET_ATTRIBUTE_TABLE} machine
3449 specific macro.  A string literal for the optional parameter @var{info}
3450 is transformed into an identifier, which may make this pragma unusable
3451 for some attributes.  @xref{Target Attributes,, Defining target-specific
3452 uses of @code{__attribute__}, gccint, GNU Compiler Collection (GCC)
3453 Internals}, further information.
3454
3455 @node Pragma Main
3456 @unnumberedsec Pragma Main
3457 @cindex OpenVMS
3458 @findex Main
3459 @noindent
3460 Syntax:
3461
3462 @smallexample @c ada
3463 pragma Main
3464  (MAIN_OPTION [, MAIN_OPTION]);
3465
3466 MAIN_OPTION ::=
3467   [Stack_Size              =>] static_integer_EXPRESSION
3468 | [Task_Stack_Size_Default =>] static_integer_EXPRESSION
3469 | [Time_Slicing_Enabled    =>] static_boolean_EXPRESSION
3470 @end smallexample
3471
3472 @noindent
3473 This pragma is provided for compatibility with OpenVMS VAX Systems.  It has
3474 no effect in GNAT, other than being syntax checked.
3475
3476 @node Pragma Main_Storage
3477 @unnumberedsec Pragma Main_Storage
3478 @cindex OpenVMS
3479 @findex Main_Storage
3480 @noindent
3481 Syntax:
3482
3483 @smallexample @c ada
3484 pragma Main_Storage
3485   (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
3486
3487 MAIN_STORAGE_OPTION ::=
3488   [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
3489 | [TOP_GUARD       =>] static_SIMPLE_EXPRESSION
3490 @end smallexample
3491
3492 @noindent
3493 This pragma is provided for compatibility with OpenVMS VAX Systems.  It has
3494 no effect in GNAT, other than being syntax checked.  Note that the pragma
3495 also has no effect in DEC Ada 83 for OpenVMS Alpha Systems.
3496
3497 @node Pragma No_Body
3498 @unnumberedsec Pragma No_Body
3499 @findex No_Body
3500 @noindent
3501 Syntax:
3502
3503 @smallexample @c ada
3504 pragma No_Body;
3505 @end smallexample
3506
3507 @noindent
3508 There are a number of cases in which a package spec does not require a body,
3509 and in fact a body is not permitted. GNAT will not permit the spec to be
3510 compiled if there is a body around. The pragma No_Body allows you to provide
3511 a body file, even in a case where no body is allowed. The body file must
3512 contain only comments and a single No_Body pragma. This is recognized by
3513 the compiler as indicating that no body is logically present.
3514
3515 This is particularly useful during maintenance when a package is modified in
3516 such a way that a body needed before is no longer needed. The provision of a
3517 dummy body with a No_Body pragma ensures that there is no interference from
3518 earlier versions of the package body.
3519
3520 @node Pragma No_Return
3521 @unnumberedsec Pragma No_Return
3522 @findex No_Return
3523 @noindent
3524 Syntax:
3525
3526 @smallexample @c ada
3527 pragma No_Return (procedure_LOCAL_NAME @{, procedure_LOCAL_NAME@});
3528 @end smallexample
3529
3530 @noindent
3531 Each @var{procedure_LOCAL_NAME} argument must refer to one or more procedure
3532 declarations in the current declarative part.  A procedure to which this
3533 pragma is applied may not contain any explicit @code{return} statements.
3534 In addition, if the procedure contains any implicit returns from falling
3535 off the end of a statement sequence, then execution of that implicit
3536 return will cause Program_Error to be raised.
3537
3538 One use of this pragma is to identify procedures whose only purpose is to raise
3539 an exception. Another use of this pragma is to suppress incorrect warnings
3540 about missing returns in functions, where the last statement of a function
3541 statement sequence is a call to such a procedure.
3542
3543 Note that in Ada 2005 mode, this pragma is part of the language, and is
3544 identical in effect to the pragma as implemented in Ada 95 mode.
3545
3546 @node Pragma No_Strict_Aliasing
3547 @unnumberedsec Pragma No_Strict_Aliasing
3548 @findex No_Strict_Aliasing
3549 @noindent
3550 Syntax:
3551
3552 @smallexample @c ada
3553 pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
3554 @end smallexample
3555
3556 @noindent
3557 @var{type_LOCAL_NAME} must refer to an access type
3558 declaration in the current declarative part.  The effect is to inhibit
3559 strict aliasing optimization for the given type.  The form with no
3560 arguments is a configuration pragma which applies to all access types
3561 declared in units to which the pragma applies. For a detailed
3562 description of the strict aliasing optimization, and the situations
3563 in which it must be suppressed, see @ref{Optimization and Strict
3564 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
3565
3566 This pragma currently has no effects on access to unconstrained array types.
3567
3568 @node Pragma Normalize_Scalars
3569 @unnumberedsec Pragma Normalize_Scalars
3570 @findex Normalize_Scalars
3571 @noindent
3572 Syntax:
3573
3574 @smallexample @c ada
3575 pragma Normalize_Scalars;
3576 @end smallexample
3577
3578 @noindent
3579 This is a language defined pragma which is fully implemented in GNAT@.  The
3580 effect is to cause all scalar objects that are not otherwise initialized
3581 to be initialized.  The initial values are implementation dependent and
3582 are as follows:
3583
3584 @table @code
3585 @item Standard.Character
3586 @noindent
3587 Objects whose root type is Standard.Character are initialized to
3588 Character'Last unless the subtype range excludes NUL (in which case
3589 NUL is used). This choice will always generate an invalid value if
3590 one exists.
3591
3592 @item Standard.Wide_Character
3593 @noindent
3594 Objects whose root type is Standard.Wide_Character are initialized to
3595 Wide_Character'Last unless the subtype range excludes NUL (in which case
3596 NUL is used). This choice will always generate an invalid value if
3597 one exists.
3598
3599 @item Standard.Wide_Wide_Character
3600 @noindent
3601 Objects whose root type is Standard.Wide_Wide_Character are initialized to
3602 the invalid value 16#FFFF_FFFF# unless the subtype range excludes NUL (in
3603 which case NUL is used). This choice will always generate an invalid value if
3604 one exists.
3605
3606 @item Integer types
3607 @noindent
3608 Objects of an integer type are treated differently depending on whether
3609 negative values are present in the subtype. If no negative values are
3610 present, then all one bits is used as the initial value except in the
3611 special case where zero is excluded from the subtype, in which case
3612 all zero bits are used. This choice will always generate an invalid
3613 value if one exists.
3614
3615 For subtypes with negative values present, the largest negative number
3616 is used, except in the unusual case where this largest negative number
3617 is in the subtype, and the largest positive number is not, in which case
3618 the largest positive value is used. This choice will always generate
3619 an invalid value if one exists.
3620
3621 @item Floating-Point Types
3622 Objects of all floating-point types are initialized to all 1-bits. For
3623 standard IEEE format, this corresponds to a NaN (not a number) which is
3624 indeed an invalid value.
3625
3626 @item Fixed-Point Types
3627 Objects of all fixed-point types are treated as described above for integers,
3628 with the rules applying to the underlying integer value used to represent
3629 the fixed-point value.
3630
3631 @item Modular types
3632 Objects of a modular type are initialized to all one bits, except in
3633 the special case where zero is excluded from the subtype, in which
3634 case all zero bits are used. This choice will always generate an
3635 invalid value if one exists.
3636
3637 @item Enumeration types
3638 Objects of an enumeration type are initialized to all one-bits, i.e.@: to
3639 the value @code{2 ** typ'Size - 1} unless the subtype excludes the literal
3640 whose Pos value is zero, in which case a code of zero is used. This choice
3641 will always generate an invalid value if one exists.
3642
3643 @end table
3644
3645 @node Pragma Obsolescent
3646 @unnumberedsec Pragma Obsolescent
3647 @findex Obsolescent
3648 @noindent
3649 Syntax:
3650
3651 @smallexample @c ada
3652 pragma Obsolescent;
3653
3654 pragma Obsolescent (
3655   [Message =>] static_string_EXPRESSION
3656 [,[Version =>] Ada_05]]);
3657
3658 pragma Obsolescent (
3659   [Entity  =>] NAME
3660 [,[Message =>] static_string_EXPRESSION
3661 [,[Version =>] Ada_05]] );
3662 @end smallexample
3663
3664 @noindent
3665 This pragma can occur immediately following a declaration of an entity,
3666 including the case of a record component. If no Entity argument is present,
3667 then this declaration is the one to which the pragma applies. If an Entity
3668 parameter is present, it must either match the name of the entity in this
3669 declaration, or alternatively, the pragma can immediately follow an enumeration
3670 type declaration, where the Entity argument names one of the enumeration
3671 literals.
3672
3673 This pragma is used to indicate that the named entity
3674 is considered obsolescent and should not be used. Typically this is
3675 used when an API must be modified by eventually removing or modifying
3676 existing subprograms or other entities. The pragma can be used at an
3677 intermediate stage when the entity is still present, but will be
3678 removed later.
3679
3680 The effect of this pragma is to output a warning message on a reference to
3681 an entity thus marked that the subprogram is obsolescent if the appropriate
3682 warning option in the compiler is activated. If the Message parameter is
3683 present, then a second warning message is given containing this text. In
3684 addition, a reference to the entity is considered to be a violation of pragma
3685 Restrictions (No_Obsolescent_Features).
3686
3687 This pragma can also be used as a program unit pragma for a package,
3688 in which case the entity name is the name of the package, and the
3689 pragma indicates that the entire package is considered
3690 obsolescent. In this case a client @code{with}'ing such a package
3691 violates the restriction, and the @code{with} statement is
3692 flagged with warnings if the warning option is set.
3693
3694 If the Version parameter is present (which must be exactly
3695 the identifier Ada_05, no other argument is allowed), then the
3696 indication of obsolescence applies only when compiling in Ada 2005
3697 mode. This is primarily intended for dealing with the situations
3698 in the predefined library where subprograms or packages
3699 have become defined as obsolescent in Ada 2005
3700 (e.g.@: in Ada.Characters.Handling), but may be used anywhere.
3701
3702 The following examples show typical uses of this pragma:
3703
3704 @smallexample @c ada
3705 package p is
3706    pragma Obsolescent (p, Message => "use pp instead of p");
3707 end p;
3708
3709 package q is
3710    procedure q2;
3711    pragma Obsolescent ("use q2new instead");
3712
3713    type R is new integer;
3714    pragma Obsolescent
3715      (Entity  => R,
3716       Message => "use RR in Ada 2005",
3717       Version => Ada_05);
3718
3719    type M is record
3720       F1 : Integer;
3721       F2 : Integer;
3722       pragma Obsolescent;
3723       F3 : Integer;
3724    end record;
3725
3726    type E is (a, bc, 'd', quack);
3727    pragma Obsolescent (Entity => bc)
3728    pragma Obsolescent (Entity => 'd')
3729
3730    function "+"
3731      (a, b : character) return character;
3732    pragma Obsolescent (Entity => "+");
3733 end;
3734 @end smallexample
3735
3736 @noindent
3737 Note that, as for all pragmas, if you use a pragma argument identifier,
3738 then all subsequent parameters must also use a pragma argument identifier.
3739 So if you specify "Entity =>" for the Entity argument, and a Message
3740 argument is present, it must be preceded by "Message =>".
3741
3742 @node Pragma Optimize_Alignment
3743 @unnumberedsec Pragma Optimize_Alignment
3744 @findex Optimize_Alignment
3745 @cindex Alignment, default settings
3746 @noindent
3747 Syntax:
3748
3749 @smallexample @c ada
3750 pragma Optimize_Alignment (TIME | SPACE | OFF);
3751 @end smallexample
3752
3753 @noindent
3754 This is a configuration pragma which affects the choice of default alignments
3755 for types where no alignment is explicitly specified. There is a time/space
3756 trade-off in the selection of these values. Large alignments result in more
3757 efficient code, at the expense of larger data space, since sizes have to be
3758 increased to match these alignments. Smaller alignments save space, but the
3759 access code is slower. The normal choice of default alignments (which is what
3760 you get if you do not use this pragma, or if you use an argument of OFF),
3761 tries to balance these two requirements.
3762
3763 Specifying SPACE causes smaller default alignments to be chosen in two cases.
3764 First any packed record is given an alignment of 1. Second, if a size is given
3765 for the type, then the alignment is chosen to avoid increasing this size. For
3766 example, consider:
3767
3768 @smallexample @c ada
3769    type R is record
3770       X : Integer;
3771       Y : Character;
3772    end record;
3773
3774    for R'Size use 5*8;
3775 @end smallexample
3776
3777 @noindent
3778 In the default mode, this type gets an alignment of 4, so that access to the
3779 Integer field X are efficient. But this means that objects of the type end up
3780 with a size of 8 bytes. This is a valid choice, since sizes of objects are
3781 allowed to be bigger than the size of the type, but it can waste space if for
3782 example fields of type R appear in an enclosing record. If the above type is
3783 compiled in @code{Optimize_Alignment (Space)} mode, the alignment is set to 1.
3784
3785 Specifying TIME causes larger default alignments to be chosen in the case of
3786 small types with sizes that are not a power of 2. For example, consider:
3787
3788 @smallexample @c ada
3789    type R is record
3790       A : Character;
3791       B : Character;
3792       C : Boolean;
3793    end record;
3794
3795    pragma Pack (R);
3796    for R'Size use 17;
3797 @end smallexample
3798
3799 @noindent
3800 The default alignment for this record is normally 1, but if this type is
3801 compiled in @code{Optimize_Alignment (Time)} mode, then the alignment is set
3802 to 4, which wastes space for objects of the type, since they are now 4 bytes
3803 long, but results in more efficient access when the whole record is referenced.
3804
3805 As noted above, this is a configuration pragma, and there is a requirement
3806 that all units in a partition be compiled with a consistent setting of the
3807 optimization setting. This would normally be achieved by use of a configuration
3808 pragma file containing the appropriate setting. The exception to this rule is
3809 that units with an explicit configuration pragma in the same file as the source
3810 unit are excluded from the consistency check, as are all predefined units. The
3811 latter are compiled by default in pragma Optimize_Alignment (Off) mode if no
3812 pragma appears at the start of the file.
3813
3814 @node Pragma Ordered
3815 @unnumberedsec Pragma Ordered
3816 @findex Ordered
3817 @findex pragma @code{Ordered}
3818 @noindent
3819 Syntax:
3820
3821 @smallexample @c ada
3822 pragma Ordered (enumeration_first_subtype_LOCAL_NAME);
3823 @end smallexample
3824
3825 @noindent
3826 Most enumeration types are from a conceptual point of view unordered.
3827 For example, consider:
3828
3829 @smallexample @c ada
3830 type Color is (Red, Blue, Green, Yellow);
3831 @end smallexample
3832
3833 @noindent
3834 By Ada semantics @code{Blue > Red} and @code{Green > Blue},
3835 but really these relations make no sense; the enumeration type merely
3836 specifies a set of possible colors, and the order is unimportant.
3837
3838 For unordered enumeration types, it is generally a good idea if
3839 clients avoid comparisons (other than equality or inequality) and
3840 explicit ranges. (A @emph{client} is a unit where the type is referenced,
3841 other than the unit where the type is declared, its body, and its subunits.)
3842 For example, if code buried in some client says:
3843
3844 @smallexample @c ada
3845 if Current_Color < Yellow then ...
3846 if Current_Color in Blue .. Green then ...
3847 @end smallexample
3848
3849 @noindent
3850 then the client code is relying on the order, which is undesirable.
3851 It makes the code hard to read and creates maintenance difficulties if
3852 entries have to be added to the enumeration type. Instead,
3853 the code in the client should list the possibilities, or an
3854 appropriate subtype should be declared in the unit that declares
3855 the original enumeration type. E.g., the following subtype could
3856 be declared along with the type @code{Color}:
3857
3858 @smallexample @c ada
3859 subtype RBG is Color range Red .. Green;
3860 @end smallexample
3861
3862 @noindent
3863 and then the client could write:
3864
3865 @smallexample @c ada
3866 if Current_Color in RBG then ...
3867 if Current_Color = Blue or Current_Color = Green then ...
3868 @end smallexample
3869
3870 @noindent
3871 However, some enumeration types are legitimately ordered from a conceptual
3872 point of view. For example, if you declare:
3873
3874 @smallexample @c ada
3875 type Day is (Mon, Tue, Wed, Thu, Fri, Sat, Sun);
3876 @end smallexample
3877
3878 @noindent
3879 then the ordering imposed by the language is reasonable, and
3880 clients can depend on it, writing for example:
3881
3882 @smallexample @c ada
3883 if D in Mon .. Fri then ...
3884 if D < Wed then ...
3885 @end smallexample
3886
3887 @noindent
3888 The pragma @option{Ordered} is provided to mark enumeration types that
3889 are conceptually ordered, alerting the reader that clients may depend
3890 on the ordering. GNAT provides a pragma to mark enumerations as ordered
3891 rather than one to mark them as unordered, since in our experience,
3892 the great majority of enumeration types are conceptually unordered.
3893
3894 The types @code{Boolean}, @code{Character}, @code{Wide_Character},
3895 and @code{Wide_Wide_Character}
3896 are considered to be ordered types, so each is declared with a
3897 pragma @code{Ordered} in package @code{Standard}.
3898
3899 Normally pragma @code{Ordered} serves only as documentation and a guide for
3900 coding standards, but GNAT provides a warning switch @option{-gnatw.u} that
3901 requests warnings for inappropriate uses (comparisons and explicit
3902 subranges) for unordered types. If this switch is used, then any
3903 enumeration type not marked with pragma @code{Ordered} will be considered
3904 as unordered, and will generate warnings for inappropriate uses.
3905
3906 For additional information please refer to the description of the
3907 @option{-gnatw.u} switch in the @value{EDITION} User's Guide.
3908
3909 @node Pragma Passive
3910 @unnumberedsec Pragma Passive
3911 @findex Passive
3912 @noindent
3913 Syntax:
3914
3915 @smallexample @c ada
3916 pragma Passive [(Semaphore | No)];
3917 @end smallexample
3918
3919 @noindent
3920 Syntax checked, but otherwise ignored by GNAT@.  This is recognized for
3921 compatibility with DEC Ada 83 implementations, where it is used within a
3922 task definition to request that a task be made passive.  If the argument
3923 @code{Semaphore} is present, or the argument is omitted, then DEC Ada 83
3924 treats the pragma as an assertion that the containing task is passive
3925 and that optimization of context switch with this task is permitted and
3926 desired.  If the argument @code{No} is present, the task must not be
3927 optimized.  GNAT does not attempt to optimize any tasks in this manner
3928 (since protected objects are available in place of passive tasks).
3929
3930 @node Pragma Persistent_BSS
3931 @unnumberedsec Pragma Persistent_BSS
3932 @findex Persistent_BSS
3933 @noindent
3934 Syntax:
3935
3936 @smallexample @c ada
3937 pragma Persistent_BSS [(LOCAL_NAME)]
3938 @end smallexample
3939
3940 @noindent
3941 This pragma allows selected objects to be placed in the @code{.persistent_bss}
3942 section. On some targets the linker and loader provide for special
3943 treatment of this section, allowing a program to be reloaded without
3944 affecting the contents of this data (hence the name persistent).
3945
3946 There are two forms of usage. If an argument is given, it must be the
3947 local name of a library level object, with no explicit initialization
3948 and whose type is potentially persistent. If no argument is given, then
3949 the pragma is a configuration pragma, and applies to all library level
3950 objects with no explicit initialization of potentially persistent types.
3951
3952 A potentially persistent type is a scalar type, or a non-tagged,
3953 non-discriminated record, all of whose components have no explicit
3954 initialization and are themselves of a potentially persistent type,
3955 or an array, all of whose constraints are static, and whose component
3956 type is potentially persistent.
3957
3958 If this pragma is used on a target where this feature is not supported,
3959 then the pragma will be ignored. See also @code{pragma Linker_Section}.
3960
3961 @node Pragma Polling
3962 @unnumberedsec Pragma Polling
3963 @findex Polling
3964 @noindent
3965 Syntax:
3966
3967 @smallexample @c ada
3968 pragma Polling (ON | OFF);
3969 @end smallexample
3970
3971 @noindent
3972 This pragma controls the generation of polling code.  This is normally off.
3973 If @code{pragma Polling (ON)} is used then periodic calls are generated to
3974 the routine @code{Ada.Exceptions.Poll}.  This routine is a separate unit in the
3975 runtime library, and can be found in file @file{a-excpol.adb}.
3976
3977 Pragma @code{Polling} can appear as a configuration pragma (for example it
3978 can be placed in the @file{gnat.adc} file) to enable polling globally, or it
3979 can be used in the statement or declaration sequence to control polling
3980 more locally.
3981
3982 A call to the polling routine is generated at the start of every loop and
3983 at the start of every subprogram call.  This guarantees that the @code{Poll}
3984 routine is called frequently, and places an upper bound (determined by
3985 the complexity of the code) on the period between two @code{Poll} calls.
3986
3987 The primary purpose of the polling interface is to enable asynchronous
3988 aborts on targets that cannot otherwise support it (for example Windows
3989 NT), but it may be used for any other purpose requiring periodic polling.
3990 The standard version is null, and can be replaced by a user program.  This
3991 will require re-compilation of the @code{Ada.Exceptions} package that can
3992 be found in files @file{a-except.ads} and @file{a-except.adb}.
3993
3994 A standard alternative unit (in file @file{4wexcpol.adb} in the standard GNAT
3995 distribution) is used to enable the asynchronous abort capability on
3996 targets that do not normally support the capability.  The version of
3997 @code{Poll} in this file makes a call to the appropriate runtime routine
3998 to test for an abort condition.
3999
4000 Note that polling can also be enabled by use of the @option{-gnatP} switch.
4001 @xref{Switches for gcc,,, gnat_ugn, @value{EDITION} User's Guide}, for
4002 details.
4003
4004 @node Pragma Postcondition
4005 @unnumberedsec Pragma Postcondition
4006 @cindex Postconditions
4007 @cindex Checks, postconditions
4008 @findex Postconditions
4009 @noindent
4010 Syntax:
4011
4012 @smallexample @c ada
4013 pragma Postcondition (
4014    [Check   =>] Boolean_Expression
4015  [,[Message =>] String_Expression]);
4016 @end smallexample
4017
4018 @noindent
4019 The @code{Postcondition} pragma allows specification of automatic
4020 postcondition checks for subprograms. These checks are similar to
4021 assertions, but are automatically inserted just prior to the return
4022 statements of the subprogram with which they are associated (including
4023 implicit returns at the end of procedure bodies and associated
4024 exception handlers).
4025
4026 In addition, the boolean expression which is the condition which
4027 must be true may contain references to function'Result in the case
4028 of a function to refer to the returned value.
4029
4030 @code{Postcondition} pragmas may appear either immediately following the
4031 (separate) declaration of a subprogram, or at the start of the
4032 declarations of a subprogram body. Only other pragmas may intervene
4033 (that is appear between the subprogram declaration and its
4034 postconditions, or appear before the postcondition in the
4035 declaration sequence in a subprogram body). In the case of a
4036 postcondition appearing after a subprogram declaration, the
4037 formal arguments of the subprogram are visible, and can be
4038 referenced in the postcondition expressions.
4039
4040 The postconditions are collected and automatically tested just
4041 before any return (implicit or explicit) in the subprogram body.
4042 A postcondition is only recognized if postconditions are active
4043 at the time the pragma is encountered. The compiler switch @option{gnata}
4044 turns on all postconditions by default, and pragma @code{Check_Policy}
4045 with an identifier of @code{Postcondition} can also be used to
4046 control whether postconditions are active.
4047
4048 The general approach is that postconditions are placed in the spec
4049 if they represent functional aspects which make sense to the client.
4050 For example we might have:
4051
4052 @smallexample @c ada
4053    function Direction return Integer;
4054    pragma Postcondition
4055     (Direction'Result = +1
4056        or else
4057      Direction'Result = -1);
4058 @end smallexample
4059
4060 @noindent
4061 which serves to document that the result must be +1 or -1, and
4062 will test that this is the case at run time if postcondition
4063 checking is active.
4064
4065 Postconditions within the subprogram body can be used to
4066 check that some internal aspect of the implementation,
4067 not visible to the client, is operating as expected.
4068 For instance if a square root routine keeps an internal
4069 counter of the number of times it is called, then we
4070 might have the following postcondition:
4071
4072 @smallexample @c ada
4073    Sqrt_Calls : Natural := 0;
4074
4075    function Sqrt (Arg : Float) return Float is
4076      pragma Postcondition
4077        (Sqrt_Calls = Sqrt_Calls'Old + 1);
4078      ...
4079    end Sqrt
4080 @end smallexample
4081
4082 @noindent
4083 As this example, shows, the use of the @code{Old} attribute
4084 is often useful in postconditions to refer to the state on
4085 entry to the subprogram.
4086
4087 Note that postconditions are only checked on normal returns
4088 from the subprogram. If an abnormal return results from
4089 raising an exception, then the postconditions are not checked.
4090
4091 If a postcondition fails, then the exception
4092 @code{System.Assertions.Assert_Failure} is raised. If
4093 a message argument was supplied, then the given string
4094 will be used as the exception message. If no message
4095 argument was supplied, then the default message has
4096 the form "Postcondition failed at file:line". The
4097 exception is raised in the context of the subprogram
4098 body, so it is possible to catch postcondition failures
4099 within the subprogram body itself.
4100
4101 Within a package spec, normal visibility rules
4102 in Ada would prevent forward references within a
4103 postcondition pragma to functions defined later in
4104 the same package. This would introduce undesirable
4105 ordering constraints. To avoid this problem, all
4106 postcondition pragmas are analyzed at the end of
4107 the package spec, allowing forward references.
4108
4109 The following example shows that this even allows
4110 mutually recursive postconditions as in:
4111
4112 @smallexample @c ada
4113 package Parity_Functions is
4114    function Odd  (X : Natural) return Boolean;
4115    pragma Postcondition
4116      (Odd'Result =
4117         (x = 1
4118           or else
4119         (x /= 0 and then Even (X - 1))));
4120
4121    function Even (X : Natural) return Boolean;
4122    pragma Postcondition
4123      (Even'Result =
4124         (x = 0
4125           or else
4126         (x /= 1 and then Odd (X - 1))));
4127
4128 end Parity_Functions;
4129 @end smallexample
4130
4131 @noindent
4132 There are no restrictions on the complexity or form of
4133 conditions used within @code{Postcondition} pragmas.
4134 The following example shows that it is even possible
4135 to verify performance behavior.
4136
4137 @smallexample @c ada
4138 package Sort is
4139
4140    Performance : constant Float;
4141    --  Performance constant set by implementation
4142    --  to match target architecture behavior.
4143
4144    procedure Treesort (Arg : String);
4145    --  Sorts characters of argument using N*logN sort
4146    pragma Postcondition
4147      (Float (Clock - Clock'Old) <=
4148         Float (Arg'Length) *
4149         log (Float (Arg'Length)) *
4150         Performance);
4151 end Sort;
4152 @end smallexample
4153
4154 @noindent
4155 Note: postcondition pragmas associated with subprograms that are
4156 marked as Inline_Always, or those marked as Inline with front-end
4157 inlining (-gnatN option set) are accepted and legality-checked
4158 by the compiler, but are ignored at run-time even if postcondition
4159 checking is enabled.
4160
4161 @node Pragma Precondition
4162 @unnumberedsec Pragma Precondition
4163 @cindex Preconditions
4164 @cindex Checks, preconditions
4165 @findex Preconditions
4166 @noindent
4167 Syntax:
4168
4169 @smallexample @c ada
4170 pragma Precondition (
4171    [Check   =>] Boolean_Expression
4172  [,[Message =>] String_Expression]);
4173 @end smallexample
4174
4175 @noindent
4176 The @code{Precondition} pragma is similar to @code{Postcondition}
4177 except that the corresponding checks take place immediately upon
4178 entry to the subprogram, and if a precondition fails, the exception
4179 is raised in the context of the caller, and the attribute 'Result
4180 cannot be used within the precondition expression.
4181
4182 Otherwise, the placement and visibility rules are identical to those
4183 described for postconditions. The following is an example of use
4184 within a package spec:
4185
4186 @smallexample @c ada
4187 package Math_Functions is
4188    ...
4189    function Sqrt (Arg : Float) return Float;
4190    pragma Precondition (Arg >= 0.0)
4191    ...
4192 end Math_Functions;
4193 @end smallexample
4194
4195 @noindent
4196 @code{Precondition} pragmas may appear either immediately following the
4197 (separate) declaration of a subprogram, or at the start of the
4198 declarations of a subprogram body. Only other pragmas may intervene
4199 (that is appear between the subprogram declaration and its
4200 postconditions, or appear before the postcondition in the
4201 declaration sequence in a subprogram body).
4202
4203 Note: postcondition pragmas associated with subprograms that are
4204 marked as Inline_Always, or those marked as Inline with front-end
4205 inlining (-gnatN option set) are accepted and legality-checked
4206 by the compiler, but are ignored at run-time even if postcondition
4207 checking is enabled.
4208
4209 @node Pragma Profile (Ravenscar)
4210 @unnumberedsec Pragma Profile (Ravenscar)
4211 @findex Ravenscar
4212 @noindent
4213 Syntax:
4214
4215 @smallexample @c ada
4216 pragma Profile (Ravenscar);
4217 @end smallexample
4218
4219 @noindent
4220 A configuration pragma that establishes the following set of configuration
4221 pragmas:
4222
4223 @table @code
4224 @item Task_Dispatching_Policy (FIFO_Within_Priorities)
4225 [RM D.2.2] Tasks are dispatched following a preemptive
4226 priority-ordered scheduling policy.
4227
4228 @item Locking_Policy (Ceiling_Locking)
4229 [RM D.3] While tasks and interrupts execute a protected action, they inherit
4230 the ceiling priority of the corresponding protected object.
4231 @c
4232 @c @item Detect_Blocking
4233 @c This pragma forces the detection of potentially blocking operations within a
4234 @c protected operation, and to raise Program_Error if that happens.
4235 @end table
4236 @noindent
4237
4238 plus the following set of restrictions:
4239
4240 @table @code
4241 @item Max_Entry_Queue_Length => 1
4242 Defines the maximum number of calls that are queued on a (protected) entry.
4243 Note that this restrictions is checked at run time. Violation of this
4244 restriction results in the raising of Program_Error exception at the point of
4245 the call. For the Profile (Ravenscar) the value of Max_Entry_Queue_Length is
4246 always 1 and hence no task can be queued on a protected entry.
4247
4248 @item Max_Protected_Entries => 1
4249 [RM D.7] Specifies the maximum number of entries per protected type. The
4250 bounds of every entry family of a protected unit shall be static, or shall be
4251 defined by a discriminant of a subtype whose corresponding bound is static.
4252 For the Profile (Ravenscar) the value of Max_Protected_Entries is always 1.
4253
4254 @item Max_Task_Entries => 0
4255 [RM D.7] Specifies the maximum number of entries
4256 per task.  The bounds of every entry family
4257 of a task unit shall be static, or shall be
4258 defined by a discriminant of a subtype whose
4259 corresponding bound is static.  A value of zero
4260 indicates that no rendezvous are possible.  For
4261 the Profile (Ravenscar), the value of Max_Task_Entries is always
4262 0 (zero).
4263
4264 @item No_Abort_Statements
4265 [RM D.7] There are no abort_statements, and there are
4266 no calls to Task_Identification.Abort_Task.
4267
4268 @item No_Dynamic_Attachment
4269 There is no call to any of the operations defined in package Ada.Interrupts
4270 (Is_Reserved, Is_Attached, Current_Handler, Attach_Handler, Exchange_Handler,
4271 Detach_Handler, and Reference).
4272
4273 @item No_Dynamic_Priorities
4274 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
4275
4276 @item No_Implicit_Heap_Allocations
4277 [RM D.7] No constructs are allowed to cause implicit heap allocation.
4278
4279 @item No_Local_Protected_Objects
4280 Protected objects and access types that designate
4281 such objects shall be declared only at library level.
4282
4283 @item No_Local_Timing_Events
4284 [RM D.7] All objects of type Ada.Timing_Events.Timing_Event are
4285 declared at the library level.
4286
4287 @item No_Protected_Type_Allocators
4288 There are no allocators for protected types or
4289 types containing protected subcomponents.
4290
4291 @item No_Relative_Delay
4292 There are no delay_relative statements.
4293
4294 @item No_Requeue_Statements
4295 Requeue statements are not allowed.
4296
4297 @item No_Select_Statements
4298 There are no select_statements.
4299
4300 @item No_Specific_Termination_Handlers
4301 [RM D.7] There are no calls to Ada.Task_Termination.Set_Specific_Handler
4302 or to Ada.Task_Termination.Specific_Handler.
4303
4304 @item No_Task_Allocators
4305 [RM D.7] There are no allocators for task types
4306 or types containing task subcomponents.
4307
4308 @item No_Task_Hierarchy
4309 [RM D.7] All (non-environment) tasks depend
4310 directly on the environment task of the partition.
4311
4312 @item No_Task_Termination
4313 Tasks which terminate are erroneous.
4314
4315 @item Simple_Barriers
4316 Entry barrier condition expressions shall be either static
4317 boolean expressions or boolean objects which are declared in
4318 the protected type which contains the entry.
4319 @end table
4320 @noindent
4321
4322 The Ravenscar profile also includes the following restrictions that specify
4323 that there are no semantic dependences on the corresponding predefined
4324 packages:
4325
4326 @table @code
4327 @item No_Dependence => Ada.Asynchronous_Task_Control
4328 @item No_Dependence => Ada.Calendar
4329 @item No_Dependence => Ada.Execution_Time.Group_Budget
4330 @item No_Dependence => Ada.Execution_Time.Timers
4331 @item No_Dependence => Ada.Task_Attributes
4332 @item No_Dependence => System.Multiprocessors.Dispatching_Domains
4333 @end table
4334
4335 @noindent
4336
4337 This set of configuration pragmas and restrictions correspond to the
4338 definition of the ``Ravenscar Profile'' for limited tasking, devised and
4339 published by the @cite{International Real-Time Ada Workshop}, 1997,
4340 and whose most recent description is available at
4341 @url{http://www-users.cs.york.ac.uk/~burns/ravenscar.ps}.
4342
4343 The original definition of the profile was revised at subsequent IRTAW
4344 meetings. It has been included in the ISO
4345 @cite{Guide for the Use of the Ada Programming Language in High
4346 Integrity Systems}, and has been approved by ISO/IEC/SC22/WG9 for inclusion in
4347 the next revision of the standard. The formal definition given by
4348 the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
4349 AI-305) available at
4350 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00249.txt} and
4351 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00305.txt}.
4352
4353 The above set is a superset of the restrictions provided by pragma
4354 @code{Profile (Restricted)}, it includes six additional restrictions
4355 (@code{Simple_Barriers}, @code{No_Select_Statements},
4356 @code{No_Calendar}, @code{No_Implicit_Heap_Allocations},
4357 @code{No_Relative_Delay} and @code{No_Task_Termination}).  This means
4358 that pragma @code{Profile (Ravenscar)}, like the pragma
4359 @code{Profile (Restricted)},
4360 automatically causes the use of a simplified,
4361 more efficient version of the tasking run-time system.
4362
4363 @node Pragma Profile (Restricted)
4364 @unnumberedsec Pragma Profile (Restricted)
4365 @findex Restricted Run Time
4366 @noindent
4367 Syntax:
4368
4369 @smallexample @c ada
4370 pragma Profile (Restricted);
4371 @end smallexample
4372
4373 @noindent
4374 A configuration pragma that establishes the following set of restrictions:
4375
4376 @itemize @bullet
4377 @item No_Abort_Statements
4378 @item No_Entry_Queue
4379 @item No_Task_Hierarchy
4380 @item No_Task_Allocators
4381 @item No_Dynamic_Priorities
4382 @item No_Terminate_Alternatives
4383 @item No_Dynamic_Attachment
4384 @item No_Protected_Type_Allocators
4385 @item No_Local_Protected_Objects
4386 @item No_Requeue_Statements
4387 @item No_Task_Attributes_Package
4388 @item Max_Asynchronous_Select_Nesting =  0
4389 @item Max_Task_Entries =  0
4390 @item Max_Protected_Entries = 1
4391 @item Max_Select_Alternatives = 0
4392 @end itemize
4393
4394 @noindent
4395 This set of restrictions causes the automatic selection of a simplified
4396 version of the run time that provides improved performance for the
4397 limited set of tasking functionality permitted by this set of restrictions.
4398
4399 @node Pragma Psect_Object
4400 @unnumberedsec Pragma Psect_Object
4401 @findex Psect_Object
4402 @noindent
4403 Syntax:
4404
4405 @smallexample @c ada
4406 pragma Psect_Object (
4407      [Internal =>] LOCAL_NAME,
4408   [, [External =>] EXTERNAL_SYMBOL]
4409   [, [Size     =>] EXTERNAL_SYMBOL]);
4410
4411 EXTERNAL_SYMBOL ::=
4412   IDENTIFIER
4413 | static_string_EXPRESSION
4414 @end smallexample
4415
4416 @noindent
4417 This pragma is identical in effect to pragma @code{Common_Object}.
4418
4419 @node Pragma Pure_Function
4420 @unnumberedsec Pragma Pure_Function
4421 @findex Pure_Function
4422 @noindent
4423 Syntax:
4424
4425 @smallexample @c ada
4426 pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
4427 @end smallexample
4428
4429 @noindent
4430 This pragma appears in the same declarative part as a function
4431 declaration (or a set of function declarations if more than one
4432 overloaded declaration exists, in which case the pragma applies
4433 to all entities).  It specifies that the function @code{Entity} is
4434 to be considered pure for the purposes of code generation.  This means
4435 that the compiler can assume that there are no side effects, and
4436 in particular that two calls with identical arguments produce the
4437 same result.  It also means that the function can be used in an
4438 address clause.
4439
4440 Note that, quite deliberately, there are no static checks to try
4441 to ensure that this promise is met, so @code{Pure_Function} can be used
4442 with functions that are conceptually pure, even if they do modify
4443 global variables.  For example, a square root function that is
4444 instrumented to count the number of times it is called is still
4445 conceptually pure, and can still be optimized, even though it
4446 modifies a global variable (the count).  Memo functions are another
4447 example (where a table of previous calls is kept and consulted to
4448 avoid re-computation).
4449
4450 Note also that the normal rules excluding optimization of subprograms
4451 in pure units (when parameter types are descended from System.Address,
4452 or when the full view of a parameter type is limited), do not apply
4453 for the Pure_Function case. If you explicitly specify Pure_Function,
4454 the compiler may optimize away calls with identical arguments, and
4455 if that results in unexpected behavior, the proper action is not to
4456 use the pragma for subprograms that are not (conceptually) pure.
4457
4458 @findex Pure
4459 Note: Most functions in a @code{Pure} package are automatically pure, and
4460 there is no need to use pragma @code{Pure_Function} for such functions.  One
4461 exception is any function that has at least one formal of type
4462 @code{System.Address} or a type derived from it.  Such functions are not
4463 considered pure by default, since the compiler assumes that the
4464 @code{Address} parameter may be functioning as a pointer and that the
4465 referenced data may change even if the address value does not.
4466 Similarly, imported functions are not considered to be pure by default,
4467 since there is no way of checking that they are in fact pure.  The use
4468 of pragma @code{Pure_Function} for such a function will override these default
4469 assumption, and cause the compiler to treat a designated subprogram as pure
4470 in these cases.
4471
4472 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
4473 applies to the underlying renamed function.  This can be used to
4474 disambiguate cases of overloading where some but not all functions
4475 in a set of overloaded functions are to be designated as pure.
4476
4477 If pragma @code{Pure_Function} is applied to a library level function, the
4478 function is also considered pure from an optimization point of view, but the
4479 unit is not a Pure unit in the categorization sense. So for example, a function
4480 thus marked is free to @code{with} non-pure units.
4481
4482 @node Pragma Restriction_Warnings
4483 @unnumberedsec Pragma Restriction_Warnings
4484 @findex Restriction_Warnings
4485 @noindent
4486 Syntax:
4487
4488 @smallexample @c ada
4489 pragma Restriction_Warnings
4490   (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
4491 @end smallexample
4492
4493 @noindent
4494 This pragma allows a series of restriction identifiers to be
4495 specified (the list of allowed identifiers is the same as for
4496 pragma @code{Restrictions}). For each of these identifiers
4497 the compiler checks for violations of the restriction, but
4498 generates a warning message rather than an error message
4499 if the restriction is violated.
4500
4501 @node Pragma Shared
4502 @unnumberedsec Pragma Shared
4503 @findex Shared
4504
4505 @noindent
4506 This pragma is provided for compatibility with Ada 83. The syntax and
4507 semantics are identical to pragma Atomic.
4508
4509 @node Pragma Short_Circuit_And_Or
4510 @unnumberedsec Pragma Short_Circuit_And_Or
4511 @findex Short_Circuit_And_Or
4512
4513 @noindent
4514 This configuration pragma causes any occurrence of the AND operator applied to
4515 operands of type Standard.Boolean to be short-circuited (i.e. the AND operator
4516 is treated as if it were AND THEN). Or is similarly treated as OR ELSE. This
4517 may be useful in the context of certification protocols requiring the use of
4518 short-circuited logical operators. If this configuration pragma occurs locally
4519 within the file being compiled, it applies only to the file being compiled.
4520 There is no requirement that all units in a partition use this option.
4521
4522 @node Pragma Short_Descriptors
4523 @unnumberedsec Pragma Short_Descriptors
4524 @findex Short_Descriptors
4525 @noindent
4526 Syntax:
4527
4528 @smallexample @c ada
4529 pragma Short_Descriptors
4530 @end smallexample
4531
4532 @noindent
4533 In VMS versions of the compiler, this configuration pragma causes all
4534 occurrences of the mechanism types Descriptor[_xxx] to be treated as
4535 Short_Descriptor[_xxx]. This is helpful in porting legacy applications from a
4536 32-bit environment to a 64-bit environment. This pragma is ignored for non-VMS
4537 versions.
4538
4539 @node Pragma Source_File_Name
4540 @unnumberedsec Pragma Source_File_Name
4541 @findex Source_File_Name
4542 @noindent
4543 Syntax:
4544
4545 @smallexample @c ada
4546 pragma Source_File_Name (
4547   [Unit_Name   =>] unit_NAME,
4548   Spec_File_Name =>  STRING_LITERAL,
4549   [Index => INTEGER_LITERAL]);
4550
4551 pragma Source_File_Name (
4552   [Unit_Name   =>] unit_NAME,
4553   Body_File_Name =>  STRING_LITERAL,
4554   [Index => INTEGER_LITERAL]);
4555 @end smallexample
4556
4557 @noindent
4558 Use this to override the normal naming convention.  It is a configuration
4559 pragma, and so has the usual applicability of configuration pragmas
4560 (i.e.@: it applies to either an entire partition, or to all units in a
4561 compilation, or to a single unit, depending on how it is used.
4562 @var{unit_name} is mapped to @var{file_name_literal}.  The identifier for
4563 the second argument is required, and indicates whether this is the file
4564 name for the spec or for the body.
4565
4566 The optional Index argument should be used when a file contains multiple
4567 units, and when you do not want to use @code{gnatchop} to separate then
4568 into multiple files (which is the recommended procedure to limit the
4569 number of recompilations that are needed when some sources change).
4570 For instance, if the source file @file{source.ada} contains
4571
4572 @smallexample @c ada
4573 package B is
4574 ...
4575 end B;
4576
4577 with B;
4578 procedure A is
4579 begin
4580    ..
4581 end A;
4582 @end smallexample
4583
4584 you could use the following configuration pragmas:
4585
4586 @smallexample @c ada
4587 pragma Source_File_Name
4588   (B, Spec_File_Name => "source.ada", Index => 1);
4589 pragma Source_File_Name
4590   (A, Body_File_Name => "source.ada", Index => 2);
4591 @end smallexample
4592
4593 Note that the @code{gnatname} utility can also be used to generate those
4594 configuration pragmas.
4595
4596 Another form of the @code{Source_File_Name} pragma allows
4597 the specification of patterns defining alternative file naming schemes
4598 to apply to all files.
4599
4600 @smallexample @c ada
4601 pragma Source_File_Name
4602   (  [Spec_File_Name  =>] STRING_LITERAL
4603    [,[Casing          =>] CASING_SPEC]
4604    [,[Dot_Replacement =>] STRING_LITERAL]);
4605
4606 pragma Source_File_Name
4607   (  [Body_File_Name  =>] STRING_LITERAL
4608    [,[Casing          =>] CASING_SPEC]
4609    [,[Dot_Replacement =>] STRING_LITERAL]);
4610
4611 pragma Source_File_Name
4612   (  [Subunit_File_Name =>] STRING_LITERAL
4613    [,[Casing            =>] CASING_SPEC]
4614    [,[Dot_Replacement   =>] STRING_LITERAL]);
4615
4616 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
4617 @end smallexample
4618
4619 @noindent
4620 The first argument is a pattern that contains a single asterisk indicating
4621 the point at which the unit name is to be inserted in the pattern string
4622 to form the file name.  The second argument is optional.  If present it
4623 specifies the casing of the unit name in the resulting file name string.
4624 The default is lower case.  Finally the third argument allows for systematic
4625 replacement of any dots in the unit name by the specified string literal.
4626
4627 Note that Source_File_Name pragmas should not be used if you are using
4628 project files. The reason for this rule is that the project manager is not
4629 aware of these pragmas, and so other tools that use the projet file would not
4630 be aware of the intended naming conventions. If you are using project files,
4631 file naming is controlled by Source_File_Name_Project pragmas, which are
4632 usually supplied automatically by the project manager. A pragma
4633 Source_File_Name cannot appear after a @ref{Pragma Source_File_Name_Project}.
4634
4635 For more details on the use of the @code{Source_File_Name} pragma,
4636 @xref{Using Other File Names,,, gnat_ugn, @value{EDITION} User's Guide},
4637 and @ref{Alternative File Naming Schemes,,, gnat_ugn, @value{EDITION}
4638 User's Guide}.
4639
4640 @node Pragma Source_File_Name_Project
4641 @unnumberedsec Pragma Source_File_Name_Project
4642 @findex Source_File_Name_Project
4643 @noindent
4644
4645 This pragma has the same syntax and semantics as pragma Source_File_Name.
4646 It is only allowed as a stand alone configuration pragma.
4647 It cannot appear after a @ref{Pragma Source_File_Name}, and
4648 most importantly, once pragma Source_File_Name_Project appears,
4649 no further Source_File_Name pragmas are allowed.
4650
4651 The intention is that Source_File_Name_Project pragmas are always
4652 generated by the Project Manager in a manner consistent with the naming
4653 specified in a project file, and when naming is controlled in this manner,
4654 it is not permissible to attempt to modify this naming scheme using
4655 Source_File_Name or Source_File_Name_Project pragmas (which would not be
4656 known to the project manager).
4657
4658 @node Pragma Source_Reference
4659 @unnumberedsec Pragma Source_Reference
4660 @findex Source_Reference
4661 @noindent
4662 Syntax:
4663
4664 @smallexample @c ada
4665 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
4666 @end smallexample
4667
4668 @noindent
4669 This pragma must appear as the first line of a source file.
4670 @var{integer_literal} is the logical line number of the line following
4671 the pragma line (for use in error messages and debugging
4672 information).  @var{string_literal} is a static string constant that
4673 specifies the file name to be used in error messages and debugging
4674 information.  This is most notably used for the output of @code{gnatchop}
4675 with the @option{-r} switch, to make sure that the original unchopped
4676 source file is the one referred to.
4677
4678 The second argument must be a string literal, it cannot be a static
4679 string expression other than a string literal.  This is because its value
4680 is needed for error messages issued by all phases of the compiler.
4681
4682 @node Pragma Static_Elaboration_Desired
4683 @unnumberedsec Pragma Static_Elaboration_Desired
4684 @findex Static_Elaboration_Desired
4685 @noindent
4686 Syntax:
4687
4688 @smallexample @c ada
4689 pragma Static_Elaboration_Desired;
4690 @end smallexample
4691
4692 @noindent
4693 This pragma is used to indicate that the compiler should attempt to initialize
4694 statically the objects declared in the library unit to which the pragma applies,
4695 when these objects are initialized (explicitly or implicitly) by an aggregate.
4696 In the absence of this pragma, aggregates in object declarations are expanded
4697 into assignments and loops, even when the aggregate components are static
4698 constants. When the aggregate is present the compiler builds a static expression
4699 that requires no run-time code, so that the initialized object can be placed in
4700 read-only data space. If the components are not static, or the aggregate has
4701 more that 100 components, the compiler emits a warning that the pragma cannot
4702 be obeyed. (See also the restriction No_Implicit_Loops, which supports static
4703 construction of larger aggregates with static components that include an others
4704 choice.)
4705
4706 @node Pragma Stream_Convert
4707 @unnumberedsec Pragma Stream_Convert
4708 @findex Stream_Convert
4709 @noindent
4710 Syntax:
4711
4712 @smallexample @c ada
4713 pragma Stream_Convert (
4714   [Entity =>] type_LOCAL_NAME,
4715   [Read   =>] function_NAME,
4716   [Write  =>] function_NAME);
4717 @end smallexample
4718
4719 @noindent
4720 This pragma provides an efficient way of providing stream functions for
4721 types defined in packages.  Not only is it simpler to use than declaring
4722 the necessary functions with attribute representation clauses, but more
4723 significantly, it allows the declaration to made in such a way that the
4724 stream packages are not loaded unless they are needed.  The use of
4725 the Stream_Convert pragma adds no overhead at all, unless the stream
4726 attributes are actually used on the designated type.
4727
4728 The first argument specifies the type for which stream functions are
4729 provided.  The second parameter provides a function used to read values
4730 of this type.  It must name a function whose argument type may be any
4731 subtype, and whose returned type must be the type given as the first
4732 argument to the pragma.
4733
4734 The meaning of the @var{Read}
4735 parameter is that if a stream attribute directly
4736 or indirectly specifies reading of the type given as the first parameter,
4737 then a value of the type given as the argument to the Read function is
4738 read from the stream, and then the Read function is used to convert this
4739 to the required target type.
4740
4741 Similarly the @var{Write} parameter specifies how to treat write attributes
4742 that directly or indirectly apply to the type given as the first parameter.
4743 It must have an input parameter of the type specified by the first parameter,
4744 and the return type must be the same as the input type of the Read function.
4745 The effect is to first call the Write function to convert to the given stream
4746 type, and then write the result type to the stream.
4747
4748 The Read and Write functions must not be overloaded subprograms.  If necessary
4749 renamings can be supplied to meet this requirement.
4750 The usage of this attribute is best illustrated by a simple example, taken
4751 from the GNAT implementation of package Ada.Strings.Unbounded:
4752
4753 @smallexample @c ada
4754 function To_Unbounded (S : String)
4755            return Unbounded_String
4756   renames To_Unbounded_String;
4757
4758 pragma Stream_Convert
4759   (Unbounded_String, To_Unbounded, To_String);
4760 @end smallexample
4761
4762 @noindent
4763 The specifications of the referenced functions, as given in the Ada
4764 Reference Manual are:
4765
4766 @smallexample @c ada
4767 function To_Unbounded_String (Source : String)
4768   return Unbounded_String;
4769
4770 function To_String (Source : Unbounded_String)
4771   return String;
4772 @end smallexample
4773
4774 @noindent
4775 The effect is that if the value of an unbounded string is written to a stream,
4776 then the representation of the item in the stream is in the same format that
4777 would be used for @code{Standard.String'Output}, and this same representation
4778 is expected when a value of this type is read from the stream. Note that the
4779 value written always includes the bounds, even for Unbounded_String'Write,
4780 since Unbounded_String is not an array type.
4781
4782 @node Pragma Style_Checks
4783 @unnumberedsec Pragma Style_Checks
4784 @findex Style_Checks
4785 @noindent
4786 Syntax:
4787
4788 @smallexample @c ada
4789 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
4790                      On | Off [, LOCAL_NAME]);
4791 @end smallexample
4792
4793 @noindent
4794 This pragma is used in conjunction with compiler switches to control the
4795 built in style checking provided by GNAT@.  The compiler switches, if set,
4796 provide an initial setting for the switches, and this pragma may be used
4797 to modify these settings, or the settings may be provided entirely by
4798 the use of the pragma.  This pragma can be used anywhere that a pragma
4799 is legal, including use as a configuration pragma (including use in
4800 the @file{gnat.adc} file).
4801
4802 The form with a string literal specifies which style options are to be
4803 activated.  These are additive, so they apply in addition to any previously
4804 set style check options.  The codes for the options are the same as those
4805 used in the @option{-gnaty} switch to @command{gcc} or @command{gnatmake}.
4806 For example the following two methods can be used to enable
4807 layout checking:
4808
4809 @itemize @bullet
4810 @item
4811 @smallexample @c ada
4812 pragma Style_Checks ("l");
4813 @end smallexample
4814
4815 @item
4816 @smallexample
4817 gcc -c -gnatyl @dots{}
4818 @end smallexample
4819 @end itemize
4820
4821 @noindent
4822 The form ALL_CHECKS activates all standard checks (its use is equivalent
4823 to the use of the @code{gnaty} switch with no options.  @xref{Top,
4824 @value{EDITION} User's Guide, About This Guide, gnat_ugn,
4825 @value{EDITION} User's Guide}, for details.)
4826
4827 Note: the behavior is slightly different in GNAT mode (@option{-gnatg} used).
4828 In this case, ALL_CHECKS implies the standard set of GNAT mode style check
4829 options (i.e. equivalent to -gnatyg).
4830
4831 The forms with @code{Off} and @code{On}
4832 can be used to temporarily disable style checks
4833 as shown in the following example:
4834
4835 @smallexample @c ada
4836 @iftex
4837 @leftskip=0cm
4838 @end iftex
4839 pragma Style_Checks ("k"); -- requires keywords in lower case
4840 pragma Style_Checks (Off); -- turn off style checks
4841 NULL;                      -- this will not generate an error message
4842 pragma Style_Checks (On);  -- turn style checks back on
4843 NULL;                      -- this will generate an error message
4844 @end smallexample
4845
4846 @noindent
4847 Finally the two argument form is allowed only if the first argument is
4848 @code{On} or @code{Off}.  The effect is to turn of semantic style checks
4849 for the specified entity, as shown in the following example:
4850
4851 @smallexample @c ada
4852 @iftex
4853 @leftskip=0cm
4854 @end iftex
4855 pragma Style_Checks ("r"); -- require consistency of identifier casing
4856 Arg : Integer;
4857 Rf1 : Integer := ARG;      -- incorrect, wrong case
4858 pragma Style_Checks (Off, Arg);
4859 Rf2 : Integer := ARG;      -- OK, no error
4860 @end smallexample
4861
4862 @node Pragma Subtitle
4863 @unnumberedsec Pragma Subtitle
4864 @findex Subtitle
4865 @noindent
4866 Syntax:
4867
4868 @smallexample @c ada
4869 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
4870 @end smallexample
4871
4872 @noindent
4873 This pragma is recognized for compatibility with other Ada compilers
4874 but is ignored by GNAT@.
4875
4876 @node Pragma Suppress
4877 @unnumberedsec Pragma Suppress
4878 @findex Suppress
4879 @noindent
4880 Syntax:
4881
4882 @smallexample @c ada
4883 pragma Suppress (Identifier [, [On =>] Name]);
4884 @end smallexample
4885
4886 @noindent
4887 This is a standard pragma, and supports all the check names required in
4888 the RM. It is included here because GNAT recognizes one additional check
4889 name: @code{Alignment_Check} which can be used to suppress alignment checks
4890 on addresses used in address clauses. Such checks can also be suppressed
4891 by suppressing range checks, but the specific use of @code{Alignment_Check}
4892 allows suppression of alignment checks without suppressing other range checks.
4893
4894 Note that pragma Suppress gives the compiler permission to omit
4895 checks, but does not require the compiler to omit checks. The compiler
4896 will generate checks if they are essentially free, even when they are
4897 suppressed. In particular, if the compiler can prove that a certain
4898 check will necessarily fail, it will generate code to do an
4899 unconditional ``raise'', even if checks are suppressed. The compiler
4900 warns in this case.
4901
4902 Of course, run-time checks are omitted whenever the compiler can prove
4903 that they will not fail, whether or not checks are suppressed.
4904
4905 @node Pragma Suppress_All
4906 @unnumberedsec Pragma Suppress_All
4907 @findex Suppress_All
4908 @noindent
4909 Syntax:
4910
4911 @smallexample @c ada
4912 pragma Suppress_All;
4913 @end smallexample
4914
4915 @noindent
4916 This pragma can appear anywhere within a unit.
4917 The effect is to apply @code{Suppress (All_Checks)} to the unit
4918 in which it appears.  This pragma is implemented for compatibility with DEC
4919 Ada 83 usage where it appears at the end of a unit, and for compatibility
4920 with Rational Ada, where it appears as a program unit pragma.
4921 The use of the standard Ada pragma @code{Suppress (All_Checks)}
4922 as a normal configuration pragma is the preferred usage in GNAT@.
4923
4924 @node Pragma Suppress_Exception_Locations
4925 @unnumberedsec Pragma Suppress_Exception_Locations
4926 @findex Suppress_Exception_Locations
4927 @noindent
4928 Syntax:
4929
4930 @smallexample @c ada
4931 pragma Suppress_Exception_Locations;
4932 @end smallexample
4933
4934 @noindent
4935 In normal mode, a raise statement for an exception by default generates
4936 an exception message giving the file name and line number for the location
4937 of the raise. This is useful for debugging and logging purposes, but this
4938 entails extra space for the strings for the messages. The configuration
4939 pragma @code{Suppress_Exception_Locations} can be used to suppress the
4940 generation of these strings, with the result that space is saved, but the
4941 exception message for such raises is null. This configuration pragma may
4942 appear in a global configuration pragma file, or in a specific unit as
4943 usual. It is not required that this pragma be used consistently within
4944 a partition, so it is fine to have some units within a partition compiled
4945 with this pragma and others compiled in normal mode without it.
4946
4947 @node Pragma Suppress_Initialization
4948 @unnumberedsec Pragma Suppress_Initialization
4949 @findex Suppress_Initialization
4950 @cindex Suppressing initialization
4951 @cindex Initialization, suppression of
4952 @noindent
4953 Syntax:
4954
4955 @smallexample @c ada
4956 pragma Suppress_Initialization ([Entity =>] subtype_Name);
4957 @end smallexample
4958
4959 @noindent
4960 Here subtype_Name is the name introduced by a type declaration
4961 or subtype declaration.
4962 This pragma suppresses any implicit or explicit initialization
4963 for all variables of the given type or subtype,
4964 including initialization resulting from the use of pragmas
4965 Normalize_Scalars or Initialize_Scalars.
4966
4967 This is considered a representation item, so it cannot be given after
4968 the type is frozen. It applies to all subsequent object declarations,
4969 and also any allocator that creates objects of the type.
4970
4971 If the pragma is given for the first subtype, then it is considered
4972 to apply to the base type and all its subtypes. If the pragma is given
4973 for other than a first subtype, then it applies only to the given subtype.
4974 The pragma may not be given after the type is frozen.
4975
4976 @node Pragma Task_Info
4977 @unnumberedsec Pragma Task_Info
4978 @findex Task_Info
4979 @noindent
4980 Syntax
4981
4982 @smallexample @c ada
4983 pragma Task_Info (EXPRESSION);
4984 @end smallexample
4985
4986 @noindent
4987 This pragma appears within a task definition (like pragma
4988 @code{Priority}) and applies to the task in which it appears.  The
4989 argument must be of type @code{System.Task_Info.Task_Info_Type}.
4990 The @code{Task_Info} pragma provides system dependent control over
4991 aspects of tasking implementation, for example, the ability to map
4992 tasks to specific processors.  For details on the facilities available
4993 for the version of GNAT that you are using, see the documentation
4994 in the spec of package System.Task_Info in the runtime
4995 library.
4996
4997 @node Pragma Task_Name
4998 @unnumberedsec Pragma Task_Name
4999 @findex Task_Name
5000 @noindent
5001 Syntax
5002
5003 @smallexample @c ada
5004 pragma Task_Name (string_EXPRESSION);
5005 @end smallexample
5006
5007 @noindent
5008 This pragma appears within a task definition (like pragma
5009 @code{Priority}) and applies to the task in which it appears.  The
5010 argument must be of type String, and provides a name to be used for
5011 the task instance when the task is created.  Note that this expression
5012 is not required to be static, and in particular, it can contain
5013 references to task discriminants.  This facility can be used to
5014 provide different names for different tasks as they are created,
5015 as illustrated in the example below.
5016
5017 The task name is recorded internally in the run-time structures
5018 and is accessible to tools like the debugger.  In addition the
5019 routine @code{Ada.Task_Identification.Image} will return this
5020 string, with a unique task address appended.
5021
5022 @smallexample @c ada
5023 --  Example of the use of pragma Task_Name
5024
5025 with Ada.Task_Identification;
5026 use Ada.Task_Identification;
5027 with Text_IO; use Text_IO;
5028 procedure t3 is
5029
5030    type Astring is access String;
5031
5032    task type Task_Typ (Name : access String) is
5033       pragma Task_Name (Name.all);
5034    end Task_Typ;
5035
5036    task body Task_Typ is
5037       Nam : constant String := Image (Current_Task);
5038    begin
5039       Put_Line ("-->" & Nam (1 .. 14) & "<--");
5040    end Task_Typ;
5041
5042    type Ptr_Task is access Task_Typ;
5043    Task_Var : Ptr_Task;
5044
5045 begin
5046    Task_Var :=
5047      new Task_Typ (new String'("This is task 1"));
5048    Task_Var :=
5049      new Task_Typ (new String'("This is task 2"));
5050 end;
5051 @end smallexample
5052
5053 @node Pragma Task_Storage
5054 @unnumberedsec Pragma Task_Storage
5055 @findex Task_Storage
5056 Syntax:
5057
5058 @smallexample @c ada
5059 pragma Task_Storage (
5060   [Task_Type =>] LOCAL_NAME,
5061   [Top_Guard =>] static_integer_EXPRESSION);
5062 @end smallexample
5063
5064 @noindent
5065 This pragma specifies the length of the guard area for tasks.  The guard
5066 area is an additional storage area allocated to a task.  A value of zero
5067 means that either no guard area is created or a minimal guard area is
5068 created, depending on the target.  This pragma can appear anywhere a
5069 @code{Storage_Size} attribute definition clause is allowed for a task
5070 type.
5071
5072 @node Pragma Test_Case
5073 @unnumberedsec Pragma Test_Case
5074 @cindex Test cases
5075 @findex Test_Case
5076 @noindent
5077 Syntax:
5078
5079 @smallexample @c ada
5080 pragma Test_Case (
5081    [Name     =>] static_string_Expression
5082   ,[Mode     =>] (Nominal | Robustness)
5083  [, Requires =>  Boolean_Expression]
5084  [, Ensures  =>  Boolean_Expression]);
5085 @end smallexample
5086
5087 @noindent
5088 The @code{Test_Case} pragma allows defining fine-grain specifications
5089 for use by testing and verification tools. The compiler checks its
5090 validity but the presence of pragma @code{Test_Case} does not lead to
5091 any modification of the code generated by the compiler.
5092
5093 @code{Test_Case} pragmas may only appear immediately following the
5094 (separate) declaration of a subprogram in a package declaration, inside
5095 a package spec unit. Only other pragmas may intervene (that is appear
5096 between the subprogram declaration and a test case).
5097
5098 The compiler checks that boolean expressions given in @code{Requires} and
5099 @code{Ensures} are valid, where the rules for @code{Requires} are the
5100 same as the rule for an expression in @code{Precondition} and the rules
5101 for @code{Ensures} are the same as the rule for an expression in
5102 @code{Postcondition}. In particular, attributes @code{'Old} and
5103 @code{'Result} can only be used within the @code{Ensures}
5104 expression. The following is an example of use within a package spec:
5105
5106 @smallexample @c ada
5107 package Math_Functions is
5108    ...
5109    function Sqrt (Arg : Float) return Float;
5110    pragma Test_Case (Name     => "Test 1",
5111                      Mode     => Nominal,
5112                      Requires => Arg < 100,
5113                      Ensures  => Sqrt'Result < 10);
5114    ...
5115 end Math_Functions;
5116 @end smallexample
5117
5118 @noindent
5119 The meaning of a test case is that, if the associated subprogram is
5120 executed in a context where @code{Requires} holds, then @code{Ensures}
5121 should hold when the subprogram returns. Mode @code{Nominal} indicates
5122 that the input context should satisfy the precondition of the
5123 subprogram, and the output context should then satisfy its
5124 postcondition. More @code{Robustness} indicates that the pre- and
5125 postcondition of the subprogram should be ignored for this test case.
5126
5127 @node Pragma Thread_Local_Storage
5128 @unnumberedsec Pragma Thread_Local_Storage
5129 @findex Thread_Local_Storage
5130 @cindex Task specific storage
5131 @cindex TLS (Thread Local Storage)
5132 Syntax:
5133
5134 @smallexample @c ada
5135 pragma Thread_Local_Storage ([Entity =>] LOCAL_NAME);
5136 @end smallexample
5137
5138 @noindent
5139 This pragma specifies that the specified entity, which must be
5140 a variable declared in a library level package, is to be marked as
5141 "Thread Local Storage" (@code{TLS}). On systems supporting this (which
5142 include Solaris, GNU/Linux and VxWorks 6), this causes each thread
5143 (and hence each Ada task) to see a distinct copy of the variable.
5144
5145 The variable may not have default initialization, and if there is
5146 an explicit initialization, it must be either @code{null} for an
5147 access variable, or a static expression for a scalar variable.
5148 This provides a low level mechanism similar to that provided by
5149 the @code{Ada.Task_Attributes} package, but much more efficient
5150 and is also useful in writing interface code that will interact
5151 with foreign threads.
5152
5153 If this pragma is used on a system where @code{TLS} is not supported,
5154 then an error message will be generated and the program will be rejected.
5155
5156 @node Pragma Time_Slice
5157 @unnumberedsec Pragma Time_Slice
5158 @findex Time_Slice
5159 @noindent
5160 Syntax:
5161
5162 @smallexample @c ada
5163 pragma Time_Slice (static_duration_EXPRESSION);
5164 @end smallexample
5165
5166 @noindent
5167 For implementations of GNAT on operating systems where it is possible
5168 to supply a time slice value, this pragma may be used for this purpose.
5169 It is ignored if it is used in a system that does not allow this control,
5170 or if it appears in other than the main program unit.
5171 @cindex OpenVMS
5172 Note that the effect of this pragma is identical to the effect of the
5173 DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
5174
5175 @node Pragma Title
5176 @unnumberedsec Pragma Title
5177 @findex Title
5178 @noindent
5179 Syntax:
5180
5181 @smallexample @c ada
5182 pragma Title (TITLING_OPTION [, TITLING OPTION]);
5183
5184 TITLING_OPTION ::=
5185   [Title    =>] STRING_LITERAL,
5186 | [Subtitle =>] STRING_LITERAL
5187 @end smallexample
5188
5189 @noindent
5190 Syntax checked but otherwise ignored by GNAT@.  This is a listing control
5191 pragma used in DEC Ada 83 implementations to provide a title and/or
5192 subtitle for the program listing.  The program listing generated by GNAT
5193 does not have titles or subtitles.
5194
5195 Unlike other pragmas, the full flexibility of named notation is allowed
5196 for this pragma, i.e.@: the parameters may be given in any order if named
5197 notation is used, and named and positional notation can be mixed
5198 following the normal rules for procedure calls in Ada.
5199
5200 @node Pragma Unchecked_Union
5201 @unnumberedsec Pragma Unchecked_Union
5202 @cindex Unions in C
5203 @findex Unchecked_Union
5204 @noindent
5205 Syntax:
5206
5207 @smallexample @c ada
5208 pragma Unchecked_Union (first_subtype_LOCAL_NAME);
5209 @end smallexample
5210
5211 @noindent
5212 This pragma is used to specify a representation of a record type that is
5213 equivalent to a C union. It was introduced as a GNAT implementation defined
5214 pragma in the GNAT Ada 95 mode. Ada 2005 includes an extended version of this
5215 pragma, making it language defined, and GNAT fully implements this extended
5216 version in all language modes (Ada 83, Ada 95, and Ada 2005). For full
5217 details, consult the Ada 2005 Reference Manual, section B.3.3.
5218
5219 @node Pragma Unimplemented_Unit
5220 @unnumberedsec Pragma Unimplemented_Unit
5221 @findex Unimplemented_Unit
5222 @noindent
5223 Syntax:
5224
5225 @smallexample @c ada
5226 pragma Unimplemented_Unit;
5227 @end smallexample
5228
5229 @noindent
5230 If this pragma occurs in a unit that is processed by the compiler, GNAT
5231 aborts with the message @samp{@var{xxx} not implemented}, where
5232 @var{xxx} is the name of the current compilation unit.  This pragma is
5233 intended to allow the compiler to handle unimplemented library units in
5234 a clean manner.
5235
5236 The abort only happens if code is being generated.  Thus you can use
5237 specs of unimplemented packages in syntax or semantic checking mode.
5238
5239 @node Pragma Universal_Aliasing
5240 @unnumberedsec Pragma Universal_Aliasing
5241 @findex Universal_Aliasing
5242 @noindent
5243 Syntax:
5244
5245 @smallexample @c ada
5246 pragma Universal_Aliasing [([Entity =>] type_LOCAL_NAME)];
5247 @end smallexample
5248
5249 @noindent
5250 @var{type_LOCAL_NAME} must refer to a type declaration in the current
5251 declarative part.  The effect is to inhibit strict type-based aliasing
5252 optimization for the given type.  In other words, the effect is as though
5253 access types designating this type were subject to pragma No_Strict_Aliasing.
5254 For a detailed description of the strict aliasing optimization, and the
5255 situations in which it must be suppressed, @xref{Optimization and Strict
5256 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
5257
5258 @node Pragma Universal_Data
5259 @unnumberedsec Pragma Universal_Data
5260 @findex Universal_Data
5261 @noindent
5262 Syntax:
5263
5264 @smallexample @c ada
5265 pragma Universal_Data [(library_unit_Name)];
5266 @end smallexample
5267
5268 @noindent
5269 This pragma is supported only for the AAMP target and is ignored for
5270 other targets. The pragma specifies that all library-level objects
5271 (Counter 0 data) associated with the library unit are to be accessed
5272 and updated using universal addressing (24-bit addresses for AAMP5)
5273 rather than the default of 16-bit Data Environment (DENV) addressing.
5274 Use of this pragma will generally result in less efficient code for
5275 references to global data associated with the library unit, but
5276 allows such data to be located anywhere in memory. This pragma is
5277 a library unit pragma, but can also be used as a configuration pragma
5278 (including use in the @file{gnat.adc} file). The functionality
5279 of this pragma is also available by applying the -univ switch on the
5280 compilations of units where universal addressing of the data is desired.
5281
5282 @node Pragma Unmodified
5283 @unnumberedsec Pragma Unmodified
5284 @findex Unmodified
5285 @cindex Warnings, unmodified
5286 @noindent
5287 Syntax:
5288
5289 @smallexample @c ada
5290 pragma Unmodified (LOCAL_NAME @{, LOCAL_NAME@});
5291 @end smallexample
5292
5293 @noindent
5294 This pragma signals that the assignable entities (variables,
5295 @code{out} parameters, @code{in out} parameters) whose names are listed are
5296 deliberately not assigned in the current source unit. This
5297 suppresses warnings about the
5298 entities being referenced but not assigned, and in addition a warning will be
5299 generated if one of these entities is in fact assigned in the
5300 same unit as the pragma (or in the corresponding body, or one
5301 of its subunits).
5302
5303 This is particularly useful for clearly signaling that a particular
5304 parameter is not modified, even though the spec suggests that it might
5305 be.
5306
5307 @node Pragma Unreferenced
5308 @unnumberedsec Pragma Unreferenced
5309 @findex Unreferenced
5310 @cindex Warnings, unreferenced
5311 @noindent
5312 Syntax:
5313
5314 @smallexample @c ada
5315 pragma Unreferenced (LOCAL_NAME @{, LOCAL_NAME@});
5316 pragma Unreferenced (library_unit_NAME @{, library_unit_NAME@});
5317 @end smallexample
5318
5319 @noindent
5320 This pragma signals that the entities whose names are listed are
5321 deliberately not referenced in the current source unit. This
5322 suppresses warnings about the
5323 entities being unreferenced, and in addition a warning will be
5324 generated if one of these entities is in fact subsequently referenced in the
5325 same unit as the pragma (or in the corresponding body, or one
5326 of its subunits).
5327
5328 This is particularly useful for clearly signaling that a particular
5329 parameter is not referenced in some particular subprogram implementation
5330 and that this is deliberate. It can also be useful in the case of
5331 objects declared only for their initialization or finalization side
5332 effects.
5333
5334 If @code{LOCAL_NAME} identifies more than one matching homonym in the
5335 current scope, then the entity most recently declared is the one to which
5336 the pragma applies. Note that in the case of accept formals, the pragma
5337 Unreferenced may appear immediately after the keyword @code{do} which
5338 allows the indication of whether or not accept formals are referenced
5339 or not to be given individually for each accept statement.
5340
5341 The left hand side of an assignment does not count as a reference for the
5342 purpose of this pragma. Thus it is fine to assign to an entity for which
5343 pragma Unreferenced is given.
5344
5345 Note that if a warning is desired for all calls to a given subprogram,
5346 regardless of whether they occur in the same unit as the subprogram
5347 declaration, then this pragma should not be used (calls from another
5348 unit would not be flagged); pragma Obsolescent can be used instead
5349 for this purpose, see @xref{Pragma Obsolescent}.
5350
5351 The second form of pragma @code{Unreferenced} is used within a context
5352 clause. In this case the arguments must be unit names of units previously
5353 mentioned in @code{with} clauses (similar to the usage of pragma
5354 @code{Elaborate_All}. The effect is to suppress warnings about unreferenced
5355 units and unreferenced entities within these units.
5356
5357 @node Pragma Unreferenced_Objects
5358 @unnumberedsec Pragma Unreferenced_Objects
5359 @findex Unreferenced_Objects
5360 @cindex Warnings, unreferenced
5361 @noindent
5362 Syntax:
5363
5364 @smallexample @c ada
5365 pragma Unreferenced_Objects (local_subtype_NAME @{, local_subtype_NAME@});
5366 @end smallexample
5367
5368 @noindent
5369 This pragma signals that for the types or subtypes whose names are
5370 listed, objects which are declared with one of these types or subtypes may
5371 not be referenced, and if no references appear, no warnings are given.
5372
5373 This is particularly useful for objects which are declared solely for their
5374 initialization and finalization effect. Such variables are sometimes referred
5375 to as RAII variables (Resource Acquisition Is Initialization). Using this
5376 pragma on the relevant type (most typically a limited controlled type), the
5377 compiler will automatically suppress unwanted warnings about these variables
5378 not being referenced.
5379
5380 @node Pragma Unreserve_All_Interrupts
5381 @unnumberedsec Pragma Unreserve_All_Interrupts
5382 @findex Unreserve_All_Interrupts
5383 @noindent
5384 Syntax:
5385
5386 @smallexample @c ada
5387 pragma Unreserve_All_Interrupts;
5388 @end smallexample
5389
5390 @noindent
5391 Normally certain interrupts are reserved to the implementation.  Any attempt
5392 to attach an interrupt causes Program_Error to be raised, as described in
5393 RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
5394 many systems for a @kbd{Ctrl-C} interrupt.  Normally this interrupt is
5395 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
5396 interrupt execution.
5397
5398 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
5399 a program, then all such interrupts are unreserved.  This allows the
5400 program to handle these interrupts, but disables their standard
5401 functions.  For example, if this pragma is used, then pressing
5402 @kbd{Ctrl-C} will not automatically interrupt execution.  However,
5403 a program can then handle the @code{SIGINT} interrupt as it chooses.
5404
5405 For a full list of the interrupts handled in a specific implementation,
5406 see the source code for the spec of @code{Ada.Interrupts.Names} in
5407 file @file{a-intnam.ads}.  This is a target dependent file that contains the
5408 list of interrupts recognized for a given target.  The documentation in
5409 this file also specifies what interrupts are affected by the use of
5410 the @code{Unreserve_All_Interrupts} pragma.
5411
5412 For a more general facility for controlling what interrupts can be
5413 handled, see pragma @code{Interrupt_State}, which subsumes the functionality
5414 of the @code{Unreserve_All_Interrupts} pragma.
5415
5416 @node Pragma Unsuppress
5417 @unnumberedsec Pragma Unsuppress
5418 @findex Unsuppress
5419 @noindent
5420 Syntax:
5421
5422 @smallexample @c ada
5423 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
5424 @end smallexample
5425
5426 @noindent
5427 This pragma undoes the effect of a previous pragma @code{Suppress}.  If
5428 there is no corresponding pragma @code{Suppress} in effect, it has no
5429 effect.  The range of the effect is the same as for pragma
5430 @code{Suppress}.  The meaning of the arguments is identical to that used
5431 in pragma @code{Suppress}.
5432
5433 One important application is to ensure that checks are on in cases where
5434 code depends on the checks for its correct functioning, so that the code
5435 will compile correctly even if the compiler switches are set to suppress
5436 checks.
5437
5438 @node Pragma Use_VADS_Size
5439 @unnumberedsec Pragma Use_VADS_Size
5440 @cindex @code{Size}, VADS compatibility
5441 @findex Use_VADS_Size
5442 @noindent
5443 Syntax:
5444
5445 @smallexample @c ada
5446 pragma Use_VADS_Size;
5447 @end smallexample
5448
5449 @noindent
5450 This is a configuration pragma.  In a unit to which it applies, any use
5451 of the 'Size attribute is automatically interpreted as a use of the
5452 'VADS_Size attribute.  Note that this may result in incorrect semantic
5453 processing of valid Ada 95 or Ada 2005 programs.  This is intended to aid in
5454 the handling of existing code which depends on the interpretation of Size
5455 as implemented in the VADS compiler.  See description of the VADS_Size
5456 attribute for further details.
5457
5458 @node Pragma Validity_Checks
5459 @unnumberedsec Pragma Validity_Checks
5460 @findex Validity_Checks
5461 @noindent
5462 Syntax:
5463
5464 @smallexample @c ada
5465 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
5466 @end smallexample
5467
5468 @noindent
5469 This pragma is used in conjunction with compiler switches to control the
5470 built-in validity checking provided by GNAT@.  The compiler switches, if set
5471 provide an initial setting for the switches, and this pragma may be used
5472 to modify these settings, or the settings may be provided entirely by
5473 the use of the pragma.  This pragma can be used anywhere that a pragma
5474 is legal, including use as a configuration pragma (including use in
5475 the @file{gnat.adc} file).
5476
5477 The form with a string literal specifies which validity options are to be
5478 activated.  The validity checks are first set to include only the default
5479 reference manual settings, and then a string of letters in the string
5480 specifies the exact set of options required.  The form of this string
5481 is exactly as described for the @option{-gnatVx} compiler switch (see the
5482 GNAT users guide for details).  For example the following two methods
5483 can be used to enable validity checking for mode @code{in} and
5484 @code{in out} subprogram parameters:
5485
5486 @itemize @bullet
5487 @item
5488 @smallexample @c ada
5489 pragma Validity_Checks ("im");
5490 @end smallexample
5491
5492 @item
5493 @smallexample
5494 gcc -c -gnatVim @dots{}
5495 @end smallexample
5496 @end itemize
5497
5498 @noindent
5499 The form ALL_CHECKS activates all standard checks (its use is equivalent
5500 to the use of the @code{gnatva} switch.
5501
5502 The forms with @code{Off} and @code{On}
5503 can be used to temporarily disable validity checks
5504 as shown in the following example:
5505
5506 @smallexample @c ada
5507 @iftex
5508 @leftskip=0cm
5509 @end iftex
5510 pragma Validity_Checks ("c"); -- validity checks for copies
5511 pragma Validity_Checks (Off); -- turn off validity checks
5512 A := B;                       -- B will not be validity checked
5513 pragma Validity_Checks (On);  -- turn validity checks back on
5514 A := C;                       -- C will be validity checked
5515 @end smallexample
5516
5517 @node Pragma Volatile
5518 @unnumberedsec Pragma Volatile
5519 @findex Volatile
5520 @noindent
5521 Syntax:
5522
5523 @smallexample @c ada
5524 pragma Volatile (LOCAL_NAME);
5525 @end smallexample
5526
5527 @noindent
5528 This pragma is defined by the Ada Reference Manual, and the GNAT
5529 implementation is fully conformant with this definition.  The reason it
5530 is mentioned in this section is that a pragma of the same name was supplied
5531 in some Ada 83 compilers, including DEC Ada 83.  The Ada 95 / Ada 2005
5532 implementation of pragma Volatile is upwards compatible with the
5533 implementation in DEC Ada 83.
5534
5535 @node Pragma Warnings
5536 @unnumberedsec Pragma Warnings
5537 @findex Warnings
5538 @noindent
5539 Syntax:
5540
5541 @smallexample @c ada
5542 pragma Warnings (On | Off);
5543 pragma Warnings (On | Off, LOCAL_NAME);
5544 pragma Warnings (static_string_EXPRESSION);
5545 pragma Warnings (On | Off, static_string_EXPRESSION);
5546 @end smallexample
5547
5548 @noindent
5549 Normally warnings are enabled, with the output being controlled by
5550 the command line switch.  Warnings (@code{Off}) turns off generation of
5551 warnings until a Warnings (@code{On}) is encountered or the end of the
5552 current unit.  If generation of warnings is turned off using this
5553 pragma, then no warning messages are output, regardless of the
5554 setting of the command line switches.
5555
5556 The form with a single argument may be used as a configuration pragma.
5557
5558 If the @var{LOCAL_NAME} parameter is present, warnings are suppressed for
5559 the specified entity.  This suppression is effective from the point where
5560 it occurs till the end of the extended scope of the variable (similar to
5561 the scope of @code{Suppress}).
5562
5563 The form with a single static_string_EXPRESSION argument provides more precise
5564 control over which warnings are active. The string is a list of letters
5565 specifying which warnings are to be activated and which deactivated. The
5566 code for these letters is the same as the string used in the command
5567 line switch controlling warnings. For a brief summary, use the gnatmake
5568 command with no arguments, which will generate usage information containing
5569 the list of warnings switches supported. For
5570 full details see @ref{Warning Message Control,,, gnat_ugn, @value{EDITION}
5571 User's Guide}.
5572
5573 @noindent
5574 The specified warnings will be in effect until the end of the program
5575 or another pragma Warnings is encountered. The effect of the pragma is
5576 cumulative. Initially the set of warnings is the standard default set
5577 as possibly modified by compiler switches. Then each pragma Warning
5578 modifies this set of warnings as specified. This form of the pragma may
5579 also be used as a configuration pragma.
5580
5581 The fourth form, with an @code{On|Off} parameter and a string, is used to
5582 control individual messages, based on their text. The string argument
5583 is a pattern that is used to match against the text of individual
5584 warning messages (not including the initial "warning: " tag).
5585
5586 The pattern may contain asterisks, which match zero or more characters in
5587 the message. For example, you can use
5588 @code{pragma Warnings (Off, "*bits of*unused")} to suppress the warning
5589 message @code{warning: 960 bits of "a" unused}. No other regular
5590 expression notations are permitted. All characters other than asterisk in
5591 these three specific cases are treated as literal characters in the match.
5592
5593 There are two ways to use the pragma in this form. The OFF form can be used as a
5594 configuration pragma. The effect is to suppress all warnings (if any)
5595 that match the pattern string throughout the compilation.
5596
5597 The second usage is to suppress a warning locally, and in this case, two
5598 pragmas must appear in sequence:
5599
5600 @smallexample @c ada
5601 pragma Warnings (Off, Pattern);
5602 @dots{} code where given warning is to be suppressed
5603 pragma Warnings (On, Pattern);
5604 @end smallexample
5605
5606 @noindent
5607 In this usage, the pattern string must match in the Off and On pragmas,
5608 and at least one matching warning must be suppressed.
5609
5610 Note: to write a string that will match any warning, use the string
5611 @code{"***"}. It will not work to use a single asterisk or two asterisks
5612 since this looks like an operator name. This form with three asterisks
5613 is similar in effect to specifying @code{pragma Warnings (Off)} except that a
5614 matching @code{pragma Warnings (On, "***")} will be required. This can be
5615 helpful in avoiding forgetting to turn warnings back on.
5616
5617 Note: the debug flag -gnatd.i (@code{/NOWARNINGS_PRAGMAS} in VMS) can be
5618 used to cause the compiler to entirely ignore all WARNINGS pragmas. This can
5619 be useful in checking whether obsolete pragmas in existing programs are hiding
5620 real problems.
5621
5622 Note: pragma Warnings does not affect the processing of style messages. See
5623 separate entry for pragma Style_Checks for control of style messages.
5624
5625 @node Pragma Weak_External
5626 @unnumberedsec Pragma Weak_External
5627 @findex Weak_External
5628 @noindent
5629 Syntax:
5630
5631 @smallexample @c ada
5632 pragma Weak_External ([Entity =>] LOCAL_NAME);
5633 @end smallexample
5634
5635 @noindent
5636 @var{LOCAL_NAME} must refer to an object that is declared at the library
5637 level. This pragma specifies that the given entity should be marked as a
5638 weak symbol for the linker. It is equivalent to @code{__attribute__((weak))}
5639 in GNU C and causes @var{LOCAL_NAME} to be emitted as a weak symbol instead
5640 of a regular symbol, that is to say a symbol that does not have to be
5641 resolved by the linker if used in conjunction with a pragma Import.
5642
5643 When a weak symbol is not resolved by the linker, its address is set to
5644 zero. This is useful in writing interfaces to external modules that may
5645 or may not be linked in the final executable, for example depending on
5646 configuration settings.
5647
5648 If a program references at run time an entity to which this pragma has been
5649 applied, and the corresponding symbol was not resolved at link time, then
5650 the execution of the program is erroneous. It is not erroneous to take the
5651 Address of such an entity, for example to guard potential references,
5652 as shown in the example below.
5653
5654 Some file formats do not support weak symbols so not all target machines
5655 support this pragma.
5656
5657 @smallexample @c ada
5658 --  Example of the use of pragma Weak_External
5659
5660 package External_Module is
5661   key : Integer;
5662   pragma Import (C, key);
5663   pragma Weak_External (key);
5664   function Present return boolean;
5665 end External_Module;
5666
5667 with System; use System;
5668 package body External_Module is
5669   function Present return boolean is
5670   begin
5671     return key'Address /= System.Null_Address;
5672   end Present;
5673 end External_Module;
5674 @end smallexample
5675
5676 @node Pragma Wide_Character_Encoding
5677 @unnumberedsec Pragma Wide_Character_Encoding
5678 @findex Wide_Character_Encoding
5679 @noindent
5680 Syntax:
5681
5682 @smallexample @c ada
5683 pragma Wide_Character_Encoding (IDENTIFIER | CHARACTER_LITERAL);
5684 @end smallexample
5685
5686 @noindent
5687 This pragma specifies the wide character encoding to be used in program
5688 source text appearing subsequently. It is a configuration pragma, but may
5689 also be used at any point that a pragma is allowed, and it is permissible
5690 to have more than one such pragma in a file, allowing multiple encodings
5691 to appear within the same file.
5692
5693 The argument can be an identifier or a character literal. In the identifier
5694 case, it is one of @code{HEX}, @code{UPPER}, @code{SHIFT_JIS},
5695 @code{EUC}, @code{UTF8}, or @code{BRACKETS}. In the character literal
5696 case it is correspondingly one of the characters @samp{h}, @samp{u},
5697 @samp{s}, @samp{e}, @samp{8}, or @samp{b}.
5698
5699 Note that when the pragma is used within a file, it affects only the
5700 encoding within that file, and does not affect withed units, specs,
5701 or subunits.
5702
5703 @node Implementation Defined Attributes
5704 @chapter Implementation Defined Attributes
5705 Ada defines (throughout the Ada reference manual,
5706 summarized in Annex K),
5707 a set of attributes that provide useful additional functionality in all
5708 areas of the language.  These language defined attributes are implemented
5709 in GNAT and work as described in the Ada Reference Manual.
5710
5711 In addition, Ada allows implementations to define additional
5712 attributes whose meaning is defined by the implementation.  GNAT provides
5713 a number of these implementation-dependent attributes which can be used
5714 to extend and enhance the functionality of the compiler.  This section of
5715 the GNAT reference manual describes these additional attributes.
5716
5717 Note that any program using these attributes may not be portable to
5718 other compilers (although GNAT implements this set of attributes on all
5719 platforms).  Therefore if portability to other compilers is an important
5720 consideration, you should minimize the use of these attributes.
5721
5722 @menu
5723 * Abort_Signal::
5724 * Address_Size::
5725 * Asm_Input::
5726 * Asm_Output::
5727 * AST_Entry::
5728 * Bit::
5729 * Bit_Position::
5730 * Compiler_Version::
5731 * Code_Address::
5732 * Default_Bit_Order::
5733 * Descriptor_Size::
5734 * Elaborated::
5735 * Elab_Body::
5736 * Elab_Spec::
5737 * Elab_Subp_Body::
5738 * Emax::
5739 * Enabled::
5740 * Enum_Rep::
5741 * Enum_Val::
5742 * Epsilon::
5743 * Fixed_Value::
5744 * Has_Access_Values::
5745 * Has_Discriminants::
5746 * Img::
5747 * Integer_Value::
5748 * Invalid_Value::
5749 * Large::
5750 * Machine_Size::
5751 * Mantissa::
5752 * Max_Interrupt_Priority::
5753 * Max_Priority::
5754 * Maximum_Alignment::
5755 * Mechanism_Code::
5756 * Null_Parameter::
5757 * Object_Size::
5758 * Old::
5759 * Passed_By_Reference::
5760 * Pool_Address::
5761 * Range_Length::
5762 * Ref::
5763 * Result::
5764 * Safe_Emax::
5765 * Safe_Large::
5766 * Small::
5767 * Storage_Unit::
5768 * Stub_Type::
5769 * System_Allocator_Alignment::
5770 * Target_Name::
5771 * Tick::
5772 * To_Address::
5773 * Type_Class::
5774 * UET_Address::
5775 * Unconstrained_Array::
5776 * Universal_Literal_String::
5777 * Unrestricted_Access::
5778 * VADS_Size::
5779 * Value_Size::
5780 * Wchar_T_Size::
5781 * Word_Size::
5782 @end menu
5783
5784 @node Abort_Signal
5785 @unnumberedsec Abort_Signal
5786 @findex Abort_Signal
5787 @noindent
5788 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
5789 prefix) provides the entity for the special exception used to signal
5790 task abort or asynchronous transfer of control.  Normally this attribute
5791 should only be used in the tasking runtime (it is highly peculiar, and
5792 completely outside the normal semantics of Ada, for a user program to
5793 intercept the abort exception).
5794
5795 @node Address_Size
5796 @unnumberedsec Address_Size
5797 @cindex Size of @code{Address}
5798 @findex Address_Size
5799 @noindent
5800 @code{Standard'Address_Size} (@code{Standard} is the only allowed
5801 prefix) is a static constant giving the number of bits in an
5802 @code{Address}. It is the same value as System.Address'Size,
5803 but has the advantage of being static, while a direct
5804 reference to System.Address'Size is non-static because Address
5805 is a private type.
5806
5807 @node Asm_Input
5808 @unnumberedsec Asm_Input
5809 @findex Asm_Input
5810 @noindent
5811 The @code{Asm_Input} attribute denotes a function that takes two
5812 parameters.  The first is a string, the second is an expression of the
5813 type designated by the prefix.  The first (string) argument is required
5814 to be a static expression, and is the constraint for the parameter,
5815 (e.g.@: what kind of register is required).  The second argument is the
5816 value to be used as the input argument.  The possible values for the
5817 constant are the same as those used in the RTL, and are dependent on
5818 the configuration file used to built the GCC back end.
5819 @ref{Machine Code Insertions}
5820
5821 @node Asm_Output
5822 @unnumberedsec Asm_Output
5823 @findex Asm_Output
5824 @noindent
5825 The @code{Asm_Output} attribute denotes a function that takes two
5826 parameters.  The first is a string, the second is the name of a variable
5827 of the type designated by the attribute prefix.  The first (string)
5828 argument is required to be a static expression and designates the
5829 constraint for the parameter (e.g.@: what kind of register is
5830 required).  The second argument is the variable to be updated with the
5831 result.  The possible values for constraint are the same as those used in
5832 the RTL, and are dependent on the configuration file used to build the
5833 GCC back end.  If there are no output operands, then this argument may
5834 either be omitted, or explicitly given as @code{No_Output_Operands}.
5835 @ref{Machine Code Insertions}
5836
5837 @node AST_Entry
5838 @unnumberedsec AST_Entry
5839 @cindex OpenVMS
5840 @findex AST_Entry
5841 @noindent
5842 This attribute is implemented only in OpenVMS versions of GNAT@.  Applied to
5843 the name of an entry, it yields a value of the predefined type AST_Handler
5844 (declared in the predefined package System, as extended by the use of
5845 pragma @code{Extend_System (Aux_DEC)}).  This value enables the given entry to
5846 be called when an AST occurs.  For further details, refer to the @cite{DEC Ada
5847 Language Reference Manual}, section 9.12a.
5848
5849 @node Bit
5850 @unnumberedsec Bit
5851 @findex Bit
5852 @code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
5853 offset within the storage unit (byte) that contains the first bit of
5854 storage allocated for the object.  The value of this attribute is of the
5855 type @code{Universal_Integer}, and is always a non-negative number not
5856 exceeding the value of @code{System.Storage_Unit}.
5857
5858 For an object that is a variable or a constant allocated in a register,
5859 the value is zero.  (The use of this attribute does not force the
5860 allocation of a variable to memory).
5861
5862 For an object that is a formal parameter, this attribute applies
5863 to either the matching actual parameter or to a copy of the
5864 matching actual parameter.
5865
5866 For an access object the value is zero.  Note that
5867 @code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
5868 designated object.  Similarly for a record component
5869 @code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
5870 @code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
5871 are subject to index checks.
5872
5873 This attribute is designed to be compatible with the DEC Ada 83 definition
5874 and implementation of the @code{Bit} attribute.
5875
5876 @node Bit_Position
5877 @unnumberedsec Bit_Position
5878 @findex Bit_Position
5879 @noindent
5880 @code{@var{R.C}'Bit_Position}, where @var{R} is a record object and C is one
5881 of the fields of the record type, yields the bit
5882 offset within the record contains the first bit of
5883 storage allocated for the object.  The value of this attribute is of the
5884 type @code{Universal_Integer}.  The value depends only on the field
5885 @var{C} and is independent of the alignment of
5886 the containing record @var{R}.
5887
5888 @node Compiler_Version
5889 @unnumberedsec Compiler_Version
5890 @findex Compiler_Version
5891 @noindent
5892 @code{Standard'Compiler_Version} (@code{Standard} is the only allowed
5893 prefix) yields a static string identifying the version of the compiler
5894 being used to compile the unit containing the attribute reference. A
5895 typical result would be something like "@value{EDITION} @i{version} (20090221)".
5896
5897 @node Code_Address
5898 @unnumberedsec Code_Address
5899 @findex Code_Address
5900 @cindex Subprogram address
5901 @cindex Address of subprogram code
5902 @noindent
5903 The @code{'Address}
5904 attribute may be applied to subprograms in Ada 95 and Ada 2005, but the
5905 intended effect seems to be to provide
5906 an address value which can be used to call the subprogram by means of
5907 an address clause as in the following example:
5908
5909 @smallexample @c ada
5910 procedure K is @dots{}
5911
5912 procedure L;
5913 for L'Address use K'Address;
5914 pragma Import (Ada, L);
5915 @end smallexample
5916
5917 @noindent
5918 A call to @code{L} is then expected to result in a call to @code{K}@.
5919 In Ada 83, where there were no access-to-subprogram values, this was
5920 a common work-around for getting the effect of an indirect call.
5921 GNAT implements the above use of @code{Address} and the technique
5922 illustrated by the example code works correctly.
5923
5924 However, for some purposes, it is useful to have the address of the start
5925 of the generated code for the subprogram.  On some architectures, this is
5926 not necessarily the same as the @code{Address} value described above.
5927 For example, the @code{Address} value may reference a subprogram
5928 descriptor rather than the subprogram itself.
5929
5930 The @code{'Code_Address} attribute, which can only be applied to
5931 subprogram entities, always returns the address of the start of the
5932 generated code of the specified subprogram, which may or may not be
5933 the same value as is returned by the corresponding @code{'Address}
5934 attribute.
5935
5936 @node Default_Bit_Order
5937 @unnumberedsec Default_Bit_Order
5938 @cindex Big endian
5939 @cindex Little endian
5940 @findex Default_Bit_Order
5941 @noindent
5942 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
5943 permissible prefix), provides the value @code{System.Default_Bit_Order}
5944 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
5945 @code{Low_Order_First}).  This is used to construct the definition of
5946 @code{Default_Bit_Order} in package @code{System}.
5947
5948 @node Descriptor_Size
5949 @unnumberedsec Descriptor_Size
5950 @cindex Descriptor
5951 @cindex Dope vector
5952 @findex Descriptor_Size
5953 @noindent
5954 Non-static attribute @code{Descriptor_Size} returns the size in bits of the
5955 descriptor allocated for a type.  The result is non-zero only for unconstrained
5956 array types and the returned value is of type universal integer.  In GNAT, an
5957 array descriptor contains bounds information and is located immediately before
5958 the first element of the array.
5959
5960 @smallexample @c ada
5961 type Unconstr_Array is array (Positive range <>) of Boolean;
5962 Put_Line ("Descriptor size = " & Unconstr_Array'Descriptor_Size'Img);
5963 @end smallexample
5964
5965 @noindent
5966 The attribute takes into account any additional padding due to type alignment.
5967 In the example above, the descriptor contains two values of type
5968 @code{Positive} representing the low and high bound.  Since @code{Positive} has
5969 a size of 31 bits and an alignment of 4, the descriptor size is @code{2 *
5970 Positive'Size + 2} or 64 bits.
5971
5972 @node Elaborated
5973 @unnumberedsec Elaborated
5974 @findex Elaborated
5975 @noindent
5976 The prefix of the @code{'Elaborated} attribute must be a unit name.  The
5977 value is a Boolean which indicates whether or not the given unit has been
5978 elaborated.  This attribute is primarily intended for internal use by the
5979 generated code for dynamic elaboration checking, but it can also be used
5980 in user programs.  The value will always be True once elaboration of all
5981 units has been completed.  An exception is for units which need no
5982 elaboration, the value is always False for such units.
5983
5984 @node Elab_Body
5985 @unnumberedsec Elab_Body
5986 @findex Elab_Body
5987 @noindent
5988 This attribute can only be applied to a program unit name.  It returns
5989 the entity for the corresponding elaboration procedure for elaborating
5990 the body of the referenced unit.  This is used in the main generated
5991 elaboration procedure by the binder and is not normally used in any
5992 other context.  However, there may be specialized situations in which it
5993 is useful to be able to call this elaboration procedure from Ada code,
5994 e.g.@: if it is necessary to do selective re-elaboration to fix some
5995 error.
5996
5997 @node Elab_Spec
5998 @unnumberedsec Elab_Spec
5999 @findex Elab_Spec
6000 @noindent
6001 This attribute can only be applied to a program unit name.  It returns
6002 the entity for the corresponding elaboration procedure for elaborating
6003 the spec of the referenced unit.  This is used in the main
6004 generated elaboration procedure by the binder and is not normally used
6005 in any other context.  However, there may be specialized situations in
6006 which it is useful to be able to call this elaboration procedure from
6007 Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
6008 some error.
6009
6010 @node Elab_Subp_Body
6011 @unnumberedsec Elab_Subp_Body
6012 @findex Elab_Subp_Body
6013 @noindent
6014 This attribute can only be applied to a library level subprogram
6015 name and is only allowed in CodePeer mode. It returns the entity
6016 for the corresponding elaboration procedure for elaborating the body
6017 of the referenced subprogram unit. This is used in the main generated
6018 elaboration procedure by the binder in CodePeer mode only and is unrecognized
6019 otherwise.
6020
6021 @node Emax
6022 @unnumberedsec Emax
6023 @cindex Ada 83 attributes
6024 @findex Emax
6025 @noindent
6026 The @code{Emax} attribute is provided for compatibility with Ada 83.  See
6027 the Ada 83 reference manual for an exact description of the semantics of
6028 this attribute.
6029
6030 @node Enabled
6031 @unnumberedsec Enabled
6032 @findex Enabled
6033 @noindent
6034 The @code{Enabled} attribute allows an application program to check at compile
6035 time to see if the designated check is currently enabled. The prefix is a
6036 simple identifier, referencing any predefined check name (other than
6037 @code{All_Checks}) or a check name introduced by pragma Check_Name. If
6038 no argument is given for the attribute, the check is for the general state
6039 of the check, if an argument is given, then it is an entity name, and the
6040 check indicates whether an @code{Suppress} or @code{Unsuppress} has been
6041 given naming the entity (if not, then the argument is ignored).
6042
6043 Note that instantiations inherit the check status at the point of the
6044 instantiation, so a useful idiom is to have a library package that
6045 introduces a check name with @code{pragma Check_Name}, and then contains
6046 generic packages or subprograms which use the @code{Enabled} attribute
6047 to see if the check is enabled. A user of this package can then issue
6048 a @code{pragma Suppress} or @code{pragma Unsuppress} before instantiating
6049 the package or subprogram, controlling whether the check will be present.
6050
6051 @node Enum_Rep
6052 @unnumberedsec Enum_Rep
6053 @cindex Representation of enums
6054 @findex Enum_Rep
6055 @noindent
6056 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
6057 function with the following spec:
6058
6059 @smallexample @c ada
6060 function @var{S}'Enum_Rep (Arg : @var{S}'Base)
6061   return @i{Universal_Integer};
6062 @end smallexample
6063
6064 @noindent
6065 It is also allowable to apply @code{Enum_Rep} directly to an object of an
6066 enumeration type or to a non-overloaded enumeration
6067 literal.  In this case @code{@var{S}'Enum_Rep} is equivalent to
6068 @code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
6069 enumeration literal or object.
6070
6071 The function returns the representation value for the given enumeration
6072 value.  This will be equal to value of the @code{Pos} attribute in the
6073 absence of an enumeration representation clause.  This is a static
6074 attribute (i.e.@: the result is static if the argument is static).
6075
6076 @code{@var{S}'Enum_Rep} can also be used with integer types and objects,
6077 in which case it simply returns the integer value.  The reason for this
6078 is to allow it to be used for @code{(<>)} discrete formal arguments in
6079 a generic unit that can be instantiated with either enumeration types
6080 or integer types.  Note that if @code{Enum_Rep} is used on a modular
6081 type whose upper bound exceeds the upper bound of the largest signed
6082 integer type, and the argument is a variable, so that the universal
6083 integer calculation is done at run time, then the call to @code{Enum_Rep}
6084 may raise @code{Constraint_Error}.
6085
6086 @node Enum_Val
6087 @unnumberedsec Enum_Val
6088 @cindex Representation of enums
6089 @findex Enum_Val
6090 @noindent
6091 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Val} denotes a
6092 function with the following spec:
6093
6094 @smallexample @c ada
6095 function @var{S}'Enum_Val (Arg : @i{Universal_Integer)
6096   return @var{S}'Base};
6097 @end smallexample
6098
6099 @noindent
6100 The function returns the enumeration value whose representation matches the
6101 argument, or raises Constraint_Error if no enumeration literal of the type
6102 has the matching value.
6103 This will be equal to value of the @code{Val} attribute in the
6104 absence of an enumeration representation clause.  This is a static
6105 attribute (i.e.@: the result is static if the argument is static).
6106
6107 @node Epsilon
6108 @unnumberedsec Epsilon
6109 @cindex Ada 83 attributes
6110 @findex Epsilon
6111 @noindent
6112 The @code{Epsilon} attribute is provided for compatibility with Ada 83.  See
6113 the Ada 83 reference manual for an exact description of the semantics of
6114 this attribute.
6115
6116 @node Fixed_Value
6117 @unnumberedsec Fixed_Value
6118 @findex Fixed_Value
6119 @noindent
6120 For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
6121 function with the following specification:
6122
6123 @smallexample @c ada
6124 function @var{S}'Fixed_Value (Arg : @i{Universal_Integer})
6125   return @var{S};
6126 @end smallexample
6127
6128 @noindent
6129 The value returned is the fixed-point value @var{V} such that
6130
6131 @smallexample @c ada
6132 @var{V} = Arg * @var{S}'Small
6133 @end smallexample
6134
6135 @noindent
6136 The effect is thus similar to first converting the argument to the
6137 integer type used to represent @var{S}, and then doing an unchecked
6138 conversion to the fixed-point type.  The difference is
6139 that there are full range checks, to ensure that the result is in range.
6140 This attribute is primarily intended for use in implementation of the
6141 input-output functions for fixed-point values.
6142
6143 @node Has_Access_Values
6144 @unnumberedsec Has_Access_Values
6145 @cindex Access values, testing for
6146 @findex Has_Access_Values
6147 @noindent
6148 The prefix of the @code{Has_Access_Values} attribute is a type.  The result
6149 is a Boolean value which is True if the is an access type, or is a composite
6150 type with a component (at any nesting depth) that is an access type, and is
6151 False otherwise.
6152 The intended use of this attribute is in conjunction with generic
6153 definitions.  If the attribute is applied to a generic private type, it
6154 indicates whether or not the corresponding actual type has access values.
6155
6156 @node Has_Discriminants
6157 @unnumberedsec Has_Discriminants
6158 @cindex Discriminants, testing for
6159 @findex Has_Discriminants
6160 @noindent
6161 The prefix of the @code{Has_Discriminants} attribute is a type.  The result
6162 is a Boolean value which is True if the type has discriminants, and False
6163 otherwise.  The intended use of this attribute is in conjunction with generic
6164 definitions.  If the attribute is applied to a generic private type, it
6165 indicates whether or not the corresponding actual type has discriminants.
6166
6167 @node Img
6168 @unnumberedsec Img
6169 @findex Img
6170 @noindent
6171 The @code{Img} attribute differs from @code{Image} in that it may be
6172 applied to objects as well as types, in which case it gives the
6173 @code{Image} for the subtype of the object.  This is convenient for
6174 debugging:
6175
6176 @smallexample @c ada
6177 Put_Line ("X = " & X'Img);
6178 @end smallexample
6179
6180 @noindent
6181 has the same meaning as the more verbose:
6182
6183 @smallexample @c ada
6184 Put_Line ("X = " & @var{T}'Image (X));
6185 @end smallexample
6186
6187 @noindent
6188 where @var{T} is the (sub)type of the object @code{X}.
6189
6190 @node Integer_Value
6191 @unnumberedsec Integer_Value
6192 @findex Integer_Value
6193 @noindent
6194 For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
6195 function with the following spec:
6196
6197 @smallexample @c ada
6198 function @var{S}'Integer_Value (Arg : @i{Universal_Fixed})
6199   return @var{S};
6200 @end smallexample
6201
6202 @noindent
6203 The value returned is the integer value @var{V}, such that
6204
6205 @smallexample @c ada
6206 Arg = @var{V} * @var{T}'Small
6207 @end smallexample
6208
6209 @noindent
6210 where @var{T} is the type of @code{Arg}.
6211 The effect is thus similar to first doing an unchecked conversion from
6212 the fixed-point type to its corresponding implementation type, and then
6213 converting the result to the target integer type.  The difference is
6214 that there are full range checks, to ensure that the result is in range.
6215 This attribute is primarily intended for use in implementation of the
6216 standard input-output functions for fixed-point values.
6217
6218 @node Invalid_Value
6219 @unnumberedsec Invalid_Value
6220 @findex Invalid_Value
6221 @noindent
6222 For every scalar type S, S'Invalid_Value returns an undefined value of the
6223 type. If possible this value is an invalid representation for the type. The
6224 value returned is identical to the value used to initialize an otherwise
6225 uninitialized value of the type if pragma Initialize_Scalars is used,
6226 including the ability to modify the value with the binder -Sxx flag and
6227 relevant environment variables at run time.
6228
6229 @node Large
6230 @unnumberedsec Large
6231 @cindex Ada 83 attributes
6232 @findex Large
6233 @noindent
6234 The @code{Large} attribute is provided for compatibility with Ada 83.  See
6235 the Ada 83 reference manual for an exact description of the semantics of
6236 this attribute.
6237
6238 @node Machine_Size
6239 @unnumberedsec Machine_Size
6240 @findex Machine_Size
6241 @noindent
6242 This attribute is identical to the @code{Object_Size} attribute.  It is
6243 provided for compatibility with the DEC Ada 83 attribute of this name.
6244
6245 @node Mantissa
6246 @unnumberedsec Mantissa
6247 @cindex Ada 83 attributes
6248 @findex Mantissa
6249 @noindent
6250 The @code{Mantissa} attribute is provided for compatibility with Ada 83.  See
6251 the Ada 83 reference manual for an exact description of the semantics of
6252 this attribute.
6253
6254 @node Max_Interrupt_Priority
6255 @unnumberedsec Max_Interrupt_Priority
6256 @cindex Interrupt priority, maximum
6257 @findex Max_Interrupt_Priority
6258 @noindent
6259 @code{Standard'Max_Interrupt_Priority} (@code{Standard} is the only
6260 permissible prefix), provides the same value as
6261 @code{System.Max_Interrupt_Priority}.
6262
6263 @node Max_Priority
6264 @unnumberedsec Max_Priority
6265 @cindex Priority, maximum
6266 @findex Max_Priority
6267 @noindent
6268 @code{Standard'Max_Priority} (@code{Standard} is the only permissible
6269 prefix) provides the same value as @code{System.Max_Priority}.
6270
6271 @node Maximum_Alignment
6272 @unnumberedsec Maximum_Alignment
6273 @cindex Alignment, maximum
6274 @findex Maximum_Alignment
6275 @noindent
6276 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
6277 permissible prefix) provides the maximum useful alignment value for the
6278 target.  This is a static value that can be used to specify the alignment
6279 for an object, guaranteeing that it is properly aligned in all
6280 cases.
6281
6282 @node Mechanism_Code
6283 @unnumberedsec Mechanism_Code
6284 @cindex Return values, passing mechanism
6285 @cindex Parameters, passing mechanism
6286 @findex Mechanism_Code
6287 @noindent
6288 @code{@var{function}'Mechanism_Code} yields an integer code for the
6289 mechanism used for the result of function, and
6290 @code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
6291 used for formal parameter number @var{n} (a static integer value with 1
6292 meaning the first parameter) of @var{subprogram}.  The code returned is:
6293
6294 @table @asis
6295 @item 1
6296 by copy (value)
6297 @item 2
6298 by reference
6299 @item 3
6300 by descriptor (default descriptor class)
6301 @item 4
6302 by descriptor (UBS: unaligned bit string)
6303 @item 5
6304 by descriptor (UBSB: aligned bit string with arbitrary bounds)
6305 @item 6
6306 by descriptor (UBA: unaligned bit array)
6307 @item 7
6308 by descriptor (S: string, also scalar access type parameter)
6309 @item 8
6310 by descriptor (SB: string with arbitrary bounds)
6311 @item 9
6312 by descriptor (A: contiguous array)
6313 @item 10
6314 by descriptor (NCA: non-contiguous array)
6315 @end table
6316
6317 @noindent
6318 Values from 3 through 10 are only relevant to Digital OpenVMS implementations.
6319 @cindex OpenVMS
6320
6321 @node Null_Parameter
6322 @unnumberedsec Null_Parameter
6323 @cindex Zero address, passing
6324 @findex Null_Parameter
6325 @noindent
6326 A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
6327 type or subtype @var{T} allocated at machine address zero.  The attribute
6328 is allowed only as the default expression of a formal parameter, or as
6329 an actual expression of a subprogram call.  In either case, the
6330 subprogram must be imported.
6331
6332 The identity of the object is represented by the address zero in the
6333 argument list, independent of the passing mechanism (explicit or
6334 default).
6335
6336 This capability is needed to specify that a zero address should be
6337 passed for a record or other composite object passed by reference.
6338 There is no way of indicating this without the @code{Null_Parameter}
6339 attribute.
6340
6341 @node Object_Size
6342 @unnumberedsec Object_Size
6343 @cindex Size, used for objects
6344 @findex Object_Size
6345 @noindent
6346 The size of an object is not necessarily the same as the size of the type
6347 of an object.  This is because by default object sizes are increased to be
6348 a multiple of the alignment of the object.  For example,
6349 @code{Natural'Size} is
6350 31, but by default objects of type @code{Natural} will have a size of 32 bits.
6351 Similarly, a record containing an integer and a character:
6352
6353 @smallexample @c ada
6354 type Rec is record
6355    I : Integer;
6356    C : Character;
6357 end record;
6358 @end smallexample
6359
6360 @noindent
6361 will have a size of 40 (that is @code{Rec'Size} will be 40).  The
6362 alignment will be 4, because of the
6363 integer field, and so the default size of record objects for this type
6364 will be 64 (8 bytes).
6365
6366 @node Old
6367 @unnumberedsec Old
6368 @cindex Capturing Old values
6369 @cindex Postconditions
6370 @noindent
6371 The attribute Prefix'Old can be used within a
6372 subprogram body or within a precondition or
6373 postcondition pragma. The effect is to
6374 refer to the value of the prefix on entry. So for
6375 example if you have an argument of a record type X called Arg1,
6376 you can refer to Arg1.Field'Old which yields the value of
6377 Arg1.Field on entry. The implementation simply involves generating
6378 an object declaration which captures the value on entry.
6379 The prefix must denote an object of a nonlimited type (since limited types
6380 cannot be copied to capture their values) and it must not reference a local
6381 variable (since local variables do not exist at subprogram entry time). Note
6382 that the variable introduced by a quantified expression is a local variable.
6383 The following example shows the use of 'Old to implement
6384 a test of a postcondition:
6385
6386 @smallexample @c ada
6387 with Old_Pkg;
6388 procedure Old is
6389 begin
6390    Old_Pkg.Incr;
6391 end Old;
6392
6393 package Old_Pkg is
6394    procedure Incr;
6395 end Old_Pkg;
6396
6397 package body Old_Pkg is
6398    Count : Natural := 0;
6399
6400    procedure Incr is
6401    begin
6402       ... code manipulating the value of Count
6403
6404       pragma Assert (Count = Count'Old + 1);
6405    end Incr;
6406 end Old_Pkg;
6407 @end smallexample
6408
6409 @noindent
6410 Note that it is allowed to apply 'Old to a constant entity, but this will
6411 result in a warning, since the old and new values will always be the same.
6412
6413 @node Passed_By_Reference
6414 @unnumberedsec Passed_By_Reference
6415 @cindex Parameters, when passed by reference
6416 @findex Passed_By_Reference
6417 @noindent
6418 @code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
6419 a value of type @code{Boolean} value that is @code{True} if the type is
6420 normally passed by reference and @code{False} if the type is normally
6421 passed by copy in calls.  For scalar types, the result is always @code{False}
6422 and is static.  For non-scalar types, the result is non-static.
6423
6424 @node Pool_Address
6425 @unnumberedsec Pool_Address
6426 @cindex Parameters, when passed by reference
6427 @findex Pool_Address
6428 @noindent
6429 @code{@var{X}'Pool_Address} for any object @var{X} returns the address
6430 of X within its storage pool. This is the same as
6431 @code{@var{X}'Address}, except that for an unconstrained array whose
6432 bounds are allocated just before the first component,
6433 @code{@var{X}'Pool_Address} returns the address of those bounds,
6434 whereas @code{@var{X}'Address} returns the address of the first
6435 component.
6436
6437 Here, we are interpreting ``storage pool'' broadly to mean ``wherever
6438 the object is allocated'', which could be a user-defined storage pool,
6439 the global heap, on the stack, or in a static memory area. For an
6440 object created by @code{new}, @code{@var{Ptr.all}'Pool_Address} is
6441 what is passed to @code{Allocate} and returned from @code{Deallocate}.
6442
6443 @node Range_Length
6444 @unnumberedsec Range_Length
6445 @findex Range_Length
6446 @noindent
6447 @code{@var{type}'Range_Length} for any discrete type @var{type} yields
6448 the number of values represented by the subtype (zero for a null
6449 range).  The result is static for static subtypes.  @code{Range_Length}
6450 applied to the index subtype of a one dimensional array always gives the
6451 same result as @code{Range} applied to the array itself.
6452
6453 @node Ref
6454 @unnumberedsec Ref
6455 @findex Ref
6456 @noindent
6457 The @code{System.Address'Ref}
6458 (@code{System.Address} is the only permissible prefix)
6459 denotes a function identical to
6460 @code{System.Storage_Elements.To_Address} except that
6461 it is a static attribute.  See @ref{To_Address} for more details.
6462
6463 @node Result
6464 @unnumberedsec Result
6465 @findex Result
6466 @noindent
6467 @code{@var{function}'Result} can only be used with in a Postcondition pragma
6468 for a function. The prefix must be the name of the corresponding function. This
6469 is used to refer to the result of the function in the postcondition expression.
6470 For a further discussion of the use of this attribute and examples of its use,
6471 see the description of pragma Postcondition.
6472
6473 @node Safe_Emax
6474 @unnumberedsec Safe_Emax
6475 @cindex Ada 83 attributes
6476 @findex Safe_Emax
6477 @noindent
6478 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83.  See
6479 the Ada 83 reference manual for an exact description of the semantics of
6480 this attribute.
6481
6482 @node Safe_Large
6483 @unnumberedsec Safe_Large
6484 @cindex Ada 83 attributes
6485 @findex Safe_Large
6486 @noindent
6487 The @code{Safe_Large} attribute is provided for compatibility with Ada 83.  See
6488 the Ada 83 reference manual for an exact description of the semantics of
6489 this attribute.
6490
6491 @node Small
6492 @unnumberedsec Small
6493 @cindex Ada 83 attributes
6494 @findex Small
6495 @noindent
6496 The @code{Small} attribute is defined in Ada 95 (and Ada 2005) only for
6497 fixed-point types.
6498 GNAT also allows this attribute to be applied to floating-point types
6499 for compatibility with Ada 83.  See
6500 the Ada 83 reference manual for an exact description of the semantics of
6501 this attribute when applied to floating-point types.
6502
6503 @node Storage_Unit
6504 @unnumberedsec Storage_Unit
6505 @findex Storage_Unit
6506 @noindent
6507 @code{Standard'Storage_Unit} (@code{Standard} is the only permissible
6508 prefix) provides the same value as @code{System.Storage_Unit}.
6509
6510 @node Stub_Type
6511 @unnumberedsec Stub_Type
6512 @findex Stub_Type
6513 @noindent
6514 The GNAT implementation of remote access-to-classwide types is
6515 organized as described in AARM section E.4 (20.t): a value of an RACW type
6516 (designating a remote object) is represented as a normal access
6517 value, pointing to a "stub" object which in turn contains the
6518 necessary information to contact the designated remote object. A
6519 call on any dispatching operation of such a stub object does the
6520 remote call, if necessary, using the information in the stub object
6521 to locate the target partition, etc.
6522
6523 For a prefix @code{T} that denotes a remote access-to-classwide type,
6524 @code{T'Stub_Type} denotes the type of the corresponding stub objects.
6525
6526 By construction, the layout of @code{T'Stub_Type} is identical to that of
6527 type @code{RACW_Stub_Type} declared in the internal implementation-defined
6528 unit @code{System.Partition_Interface}. Use of this attribute will create
6529 an implicit dependency on this unit.
6530
6531 @node System_Allocator_Alignment
6532 @unnumberedsec System_Allocator_Alignment
6533 @cindex Alignment, allocator
6534 @findex System_Allocator_Alignment
6535 @noindent
6536 @code{Standard'System_Allocator_Alignment} (@code{Standard} is the only
6537 permissible prefix) provides the observable guaranted to be honored by
6538 the system allocator (malloc). This is a static value that can be used
6539 in user storage pools based on malloc either to reject allocation
6540 with alignment too large or to enable a realignment circuitry if the
6541 alignment request is larger than this value.
6542
6543 @node Target_Name
6544 @unnumberedsec Target_Name
6545 @findex Target_Name
6546 @noindent
6547 @code{Standard'Target_Name} (@code{Standard} is the only permissible
6548 prefix) provides a static string value that identifies the target
6549 for the current compilation. For GCC implementations, this is the
6550 standard gcc target name without the terminating slash (for
6551 example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
6552
6553 @node Tick
6554 @unnumberedsec Tick
6555 @findex Tick
6556 @noindent
6557 @code{Standard'Tick} (@code{Standard} is the only permissible prefix)
6558 provides the same value as @code{System.Tick},
6559
6560 @node To_Address
6561 @unnumberedsec To_Address
6562 @findex To_Address
6563 @noindent
6564 The @code{System'To_Address}
6565 (@code{System} is the only permissible prefix)
6566 denotes a function identical to
6567 @code{System.Storage_Elements.To_Address} except that
6568 it is a static attribute.  This means that if its argument is
6569 a static expression, then the result of the attribute is a
6570 static expression.  The result is that such an expression can be
6571 used in contexts (e.g.@: preelaborable packages) which require a
6572 static expression and where the function call could not be used
6573 (since the function call is always non-static, even if its
6574 argument is static).
6575
6576 @node Type_Class
6577 @unnumberedsec Type_Class
6578 @findex Type_Class
6579 @noindent
6580 @code{@var{type}'Type_Class} for any type or subtype @var{type} yields
6581 the value of the type class for the full type of @var{type}.  If
6582 @var{type} is a generic formal type, the value is the value for the
6583 corresponding actual subtype.  The value of this attribute is of type
6584 @code{System.Aux_DEC.Type_Class}, which has the following definition:
6585
6586 @smallexample @c ada
6587   type Type_Class is
6588     (Type_Class_Enumeration,
6589      Type_Class_Integer,
6590      Type_Class_Fixed_Point,
6591      Type_Class_Floating_Point,
6592      Type_Class_Array,
6593      Type_Class_Record,
6594      Type_Class_Access,
6595      Type_Class_Task,
6596      Type_Class_Address);
6597 @end smallexample
6598
6599 @noindent
6600 Protected types yield the value @code{Type_Class_Task}, which thus
6601 applies to all concurrent types.  This attribute is designed to
6602 be compatible with the DEC Ada 83 attribute of the same name.
6603
6604 @node UET_Address
6605 @unnumberedsec UET_Address
6606 @findex UET_Address
6607 @noindent
6608 The @code{UET_Address} attribute can only be used for a prefix which
6609 denotes a library package.  It yields the address of the unit exception
6610 table when zero cost exception handling is used.  This attribute is
6611 intended only for use within the GNAT implementation.  See the unit
6612 @code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb}
6613 for details on how this attribute is used in the implementation.
6614
6615 @node Unconstrained_Array
6616 @unnumberedsec Unconstrained_Array
6617 @findex Unconstrained_Array
6618 @noindent
6619 The @code{Unconstrained_Array} attribute can be used with a prefix that
6620 denotes any type or subtype. It is a static attribute that yields
6621 @code{True} if the prefix designates an unconstrained array,
6622 and @code{False} otherwise. In a generic instance, the result is
6623 still static, and yields the result of applying this test to the
6624 generic actual.
6625
6626 @node Universal_Literal_String
6627 @unnumberedsec Universal_Literal_String
6628 @cindex Named numbers, representation of
6629 @findex Universal_Literal_String
6630 @noindent
6631 The prefix of @code{Universal_Literal_String} must be a named
6632 number.  The static result is the string consisting of the characters of
6633 the number as defined in the original source.  This allows the user
6634 program to access the actual text of named numbers without intermediate
6635 conversions and without the need to enclose the strings in quotes (which
6636 would preclude their use as numbers).
6637
6638 For example, the following program prints the first 50 digits of pi:
6639
6640 @smallexample @c ada
6641 with Text_IO; use Text_IO;
6642 with Ada.Numerics;
6643 procedure Pi is
6644 begin
6645    Put (Ada.Numerics.Pi'Universal_Literal_String);
6646 end;
6647 @end smallexample
6648
6649 @node Unrestricted_Access
6650 @unnumberedsec Unrestricted_Access
6651 @cindex @code{Access}, unrestricted
6652 @findex Unrestricted_Access
6653 @noindent
6654 The @code{Unrestricted_Access} attribute is similar to @code{Access}
6655 except that all accessibility and aliased view checks are omitted.  This
6656 is a user-beware attribute.  It is similar to
6657 @code{Address}, for which it is a desirable replacement where the value
6658 desired is an access type.  In other words, its effect is identical to
6659 first applying the @code{Address} attribute and then doing an unchecked
6660 conversion to a desired access type.  In GNAT, but not necessarily in
6661 other implementations, the use of static chains for inner level
6662 subprograms means that @code{Unrestricted_Access} applied to a
6663 subprogram yields a value that can be called as long as the subprogram
6664 is in scope (normal Ada accessibility rules restrict this usage).
6665
6666 It is possible to use @code{Unrestricted_Access} for any type, but care
6667 must be exercised if it is used to create pointers to unconstrained
6668 objects. In this case, the resulting pointer has the same scope as the
6669 context of the attribute, and may not be returned to some enclosing
6670 scope. For instance, a function cannot use @code{Unrestricted_Access}
6671 to create a unconstrained pointer and then return that value to the
6672 caller.
6673
6674 @node VADS_Size
6675 @unnumberedsec VADS_Size
6676 @cindex @code{Size}, VADS compatibility
6677 @findex VADS_Size
6678 @noindent
6679 The @code{'VADS_Size} attribute is intended to make it easier to port
6680 legacy code which relies on the semantics of @code{'Size} as implemented
6681 by the VADS Ada 83 compiler.  GNAT makes a best effort at duplicating the
6682 same semantic interpretation.  In particular, @code{'VADS_Size} applied
6683 to a predefined or other primitive type with no Size clause yields the
6684 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
6685 typical machines).  In addition @code{'VADS_Size} applied to an object
6686 gives the result that would be obtained by applying the attribute to
6687 the corresponding type.
6688
6689 @node Value_Size
6690 @unnumberedsec Value_Size
6691 @cindex @code{Size}, setting for not-first subtype
6692 @findex Value_Size
6693 @code{@var{type}'Value_Size} is the number of bits required to represent
6694 a value of the given subtype.  It is the same as @code{@var{type}'Size},
6695 but, unlike @code{Size}, may be set for non-first subtypes.
6696
6697 @node Wchar_T_Size
6698 @unnumberedsec Wchar_T_Size
6699 @findex Wchar_T_Size
6700 @code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
6701 prefix) provides the size in bits of the C @code{wchar_t} type
6702 primarily for constructing the definition of this type in
6703 package @code{Interfaces.C}.
6704
6705 @node Word_Size
6706 @unnumberedsec Word_Size
6707 @findex Word_Size
6708 @code{Standard'Word_Size} (@code{Standard} is the only permissible
6709 prefix) provides the value @code{System.Word_Size}.
6710
6711 @c ------------------------
6712 @node Implementation Advice
6713 @chapter Implementation Advice
6714 @noindent
6715 The main text of the Ada Reference Manual describes the required
6716 behavior of all Ada compilers, and the GNAT compiler conforms to
6717 these requirements.
6718
6719 In addition, there are sections throughout the Ada Reference Manual headed
6720 by the phrase ``Implementation advice''.  These sections are not normative,
6721 i.e., they do not specify requirements that all compilers must
6722 follow.  Rather they provide advice on generally desirable behavior.  You
6723 may wonder why they are not requirements.  The most typical answer is
6724 that they describe behavior that seems generally desirable, but cannot
6725 be provided on all systems, or which may be undesirable on some systems.
6726
6727 As far as practical, GNAT follows the implementation advice sections in
6728 the Ada Reference Manual.  This chapter contains a table giving the
6729 reference manual section number, paragraph number and several keywords
6730 for each advice.  Each entry consists of the text of the advice followed
6731 by the GNAT interpretation of this advice.  Most often, this simply says
6732 ``followed'', which means that GNAT follows the advice.  However, in a
6733 number of cases, GNAT deliberately deviates from this advice, in which
6734 case the text describes what GNAT does and why.
6735
6736 @cindex Error detection
6737 @unnumberedsec 1.1.3(20): Error Detection
6738 @sp 1
6739 @cartouche
6740 If an implementation detects the use of an unsupported Specialized Needs
6741 Annex feature at run time, it should raise @code{Program_Error} if
6742 feasible.
6743 @end cartouche
6744 Not relevant.  All specialized needs annex features are either supported,
6745 or diagnosed at compile time.
6746
6747 @cindex Child Units
6748 @unnumberedsec 1.1.3(31): Child Units
6749 @sp 1
6750 @cartouche
6751 If an implementation wishes to provide implementation-defined
6752 extensions to the functionality of a language-defined library unit, it
6753 should normally do so by adding children to the library unit.
6754 @end cartouche
6755 Followed.
6756
6757 @cindex Bounded errors
6758 @unnumberedsec 1.1.5(12): Bounded Errors
6759 @sp 1
6760 @cartouche
6761 If an implementation detects a bounded error or erroneous
6762 execution, it should raise @code{Program_Error}.
6763 @end cartouche
6764 Followed in all cases in which the implementation detects a bounded
6765 error or erroneous execution.  Not all such situations are detected at
6766 runtime.
6767
6768 @cindex Pragmas
6769 @unnumberedsec 2.8(16): Pragmas
6770 @sp 1
6771 @cartouche
6772 Normally, implementation-defined pragmas should have no semantic effect
6773 for error-free programs; that is, if the implementation-defined pragmas
6774 are removed from a working program, the program should still be legal,
6775 and should still have the same semantics.
6776 @end cartouche
6777 The following implementation defined pragmas are exceptions to this
6778 rule:
6779
6780 @table @code
6781 @item Abort_Defer
6782 Affects semantics
6783 @item Ada_83
6784 Affects legality
6785 @item Assert
6786 Affects semantics
6787 @item CPP_Class
6788 Affects semantics
6789 @item CPP_Constructor
6790 Affects semantics
6791 @item Debug
6792 Affects semantics
6793 @item Interface_Name
6794 Affects semantics
6795 @item Machine_Attribute
6796 Affects semantics
6797 @item Unimplemented_Unit
6798 Affects legality
6799 @item Unchecked_Union
6800 Affects semantics
6801 @end table
6802
6803 @noindent
6804 In each of the above cases, it is essential to the purpose of the pragma
6805 that this advice not be followed.  For details see the separate section
6806 on implementation defined pragmas.
6807
6808 @unnumberedsec 2.8(17-19): Pragmas
6809 @sp 1
6810 @cartouche
6811 Normally, an implementation should not define pragmas that can
6812 make an illegal program legal, except as follows:
6813 @end cartouche
6814 @sp 1
6815 @cartouche
6816 A pragma used to complete a declaration, such as a pragma @code{Import};
6817 @end cartouche
6818 @sp 1
6819 @cartouche
6820 A pragma used to configure the environment by adding, removing, or
6821 replacing @code{library_items}.
6822 @end cartouche
6823 See response to paragraph 16 of this same section.
6824
6825 @cindex Character Sets
6826 @cindex Alternative Character Sets
6827 @unnumberedsec 3.5.2(5): Alternative Character Sets
6828 @sp 1
6829 @cartouche
6830 If an implementation supports a mode with alternative interpretations
6831 for @code{Character} and @code{Wide_Character}, the set of graphic
6832 characters of @code{Character} should nevertheless remain a proper
6833 subset of the set of graphic characters of @code{Wide_Character}.  Any
6834 character set ``localizations'' should be reflected in the results of
6835 the subprograms defined in the language-defined package
6836 @code{Characters.Handling} (see A.3) available in such a mode.  In a mode with
6837 an alternative interpretation of @code{Character}, the implementation should
6838 also support a corresponding change in what is a legal
6839 @code{identifier_letter}.
6840 @end cartouche
6841 Not all wide character modes follow this advice, in particular the JIS
6842 and IEC modes reflect standard usage in Japan, and in these encoding,
6843 the upper half of the Latin-1 set is not part of the wide-character
6844 subset, since the most significant bit is used for wide character
6845 encoding.  However, this only applies to the external forms.  Internally
6846 there is no such restriction.
6847
6848 @cindex Integer types
6849 @unnumberedsec 3.5.4(28): Integer Types
6850
6851 @sp 1
6852 @cartouche
6853 An implementation should support @code{Long_Integer} in addition to
6854 @code{Integer} if the target machine supports 32-bit (or longer)
6855 arithmetic.  No other named integer subtypes are recommended for package
6856 @code{Standard}.  Instead, appropriate named integer subtypes should be
6857 provided in the library package @code{Interfaces} (see B.2).
6858 @end cartouche
6859 @code{Long_Integer} is supported.  Other standard integer types are supported
6860 so this advice is not fully followed.  These types
6861 are supported for convenient interface to C, and so that all hardware
6862 types of the machine are easily available.
6863 @unnumberedsec 3.5.4(29): Integer Types
6864
6865 @sp 1
6866 @cartouche
6867 An implementation for a two's complement machine should support
6868 modular types with a binary modulus up to @code{System.Max_Int*2+2}.  An
6869 implementation should support a non-binary modules up to @code{Integer'Last}.
6870 @end cartouche
6871 Followed.
6872
6873 @cindex Enumeration values
6874 @unnumberedsec 3.5.5(8): Enumeration Values
6875 @sp 1
6876 @cartouche
6877 For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
6878 subtype, if the value of the operand does not correspond to the internal
6879 code for any enumeration literal of its type (perhaps due to an
6880 un-initialized variable), then the implementation should raise
6881 @code{Program_Error}.  This is particularly important for enumeration
6882 types with noncontiguous internal codes specified by an
6883 enumeration_representation_clause.
6884 @end cartouche
6885 Followed.
6886
6887 @cindex Float types
6888 @unnumberedsec 3.5.7(17): Float Types
6889 @sp 1
6890 @cartouche
6891 An implementation should support @code{Long_Float} in addition to
6892 @code{Float} if the target machine supports 11 or more digits of
6893 precision.  No other named floating point subtypes are recommended for
6894 package @code{Standard}.  Instead, appropriate named floating point subtypes
6895 should be provided in the library package @code{Interfaces} (see B.2).
6896 @end cartouche
6897 @code{Short_Float} and @code{Long_Long_Float} are also provided.  The
6898 former provides improved compatibility with other implementations
6899 supporting this type.  The latter corresponds to the highest precision
6900 floating-point type supported by the hardware.  On most machines, this
6901 will be the same as @code{Long_Float}, but on some machines, it will
6902 correspond to the IEEE extended form.  The notable case is all ia32
6903 (x86) implementations, where @code{Long_Long_Float} corresponds to
6904 the 80-bit extended precision format supported in hardware on this
6905 processor.  Note that the 128-bit format on SPARC is not supported,
6906 since this is a software rather than a hardware format.
6907
6908 @cindex Multidimensional arrays
6909 @cindex Arrays, multidimensional
6910 @unnumberedsec 3.6.2(11): Multidimensional Arrays
6911 @sp 1
6912 @cartouche
6913 An implementation should normally represent multidimensional arrays in
6914 row-major order, consistent with the notation used for multidimensional
6915 array aggregates (see 4.3.3).  However, if a pragma @code{Convention}
6916 (@code{Fortran}, @dots{}) applies to a multidimensional array type, then
6917 column-major order should be used instead (see B.5, ``Interfacing with
6918 Fortran'').
6919 @end cartouche
6920 Followed.
6921
6922 @findex Duration'Small
6923 @unnumberedsec 9.6(30-31): Duration'Small
6924 @sp 1
6925 @cartouche
6926 Whenever possible in an implementation, the value of @code{Duration'Small}
6927 should be no greater than 100 microseconds.
6928 @end cartouche
6929 Followed.  (@code{Duration'Small} = 10**(@minus{}9)).
6930
6931 @sp 1
6932 @cartouche
6933 The time base for @code{delay_relative_statements} should be monotonic;
6934 it need not be the same time base as used for @code{Calendar.Clock}.
6935 @end cartouche
6936 Followed.
6937
6938 @unnumberedsec 10.2.1(12): Consistent Representation
6939 @sp 1
6940 @cartouche
6941 In an implementation, a type declared in a pre-elaborated package should
6942 have the same representation in every elaboration of a given version of
6943 the package, whether the elaborations occur in distinct executions of
6944 the same program, or in executions of distinct programs or partitions
6945 that include the given version.
6946 @end cartouche
6947 Followed, except in the case of tagged types.  Tagged types involve
6948 implicit pointers to a local copy of a dispatch table, and these pointers
6949 have representations which thus depend on a particular elaboration of the
6950 package.  It is not easy to see how it would be possible to follow this
6951 advice without severely impacting efficiency of execution.
6952
6953 @cindex Exception information
6954 @unnumberedsec 11.4.1(19): Exception Information
6955 @sp 1
6956 @cartouche
6957 @code{Exception_Message} by default and @code{Exception_Information}
6958 should produce information useful for
6959 debugging.  @code{Exception_Message} should be short, about one
6960 line.  @code{Exception_Information} can be long.  @code{Exception_Message}
6961 should not include the
6962 @code{Exception_Name}.  @code{Exception_Information} should include both
6963 the @code{Exception_Name} and the @code{Exception_Message}.
6964 @end cartouche
6965 Followed.  For each exception that doesn't have a specified
6966 @code{Exception_Message}, the compiler generates one containing the location
6967 of the raise statement.  This location has the form ``file:line'', where
6968 file is the short file name (without path information) and line is the line
6969 number in the file.  Note that in the case of the Zero Cost Exception
6970 mechanism, these messages become redundant with the Exception_Information that
6971 contains a full backtrace of the calling sequence, so they are disabled.
6972 To disable explicitly the generation of the source location message, use the
6973 Pragma @code{Discard_Names}.
6974
6975 @cindex Suppression of checks
6976 @cindex Checks, suppression of
6977 @unnumberedsec 11.5(28): Suppression of Checks
6978 @sp 1
6979 @cartouche
6980 The implementation should minimize the code executed for checks that
6981 have been suppressed.
6982 @end cartouche
6983 Followed.
6984
6985 @cindex Representation clauses
6986 @unnumberedsec 13.1 (21-24): Representation Clauses
6987 @sp 1
6988 @cartouche
6989 The recommended level of support for all representation items is
6990 qualified as follows:
6991 @end cartouche
6992 @sp 1
6993 @cartouche
6994 An implementation need not support representation items containing
6995 non-static expressions, except that an implementation should support a
6996 representation item for a given entity if each non-static expression in
6997 the representation item is a name that statically denotes a constant
6998 declared before the entity.
6999 @end cartouche
7000 Followed.  In fact, GNAT goes beyond the recommended level of support
7001 by allowing nonstatic expressions in some representation clauses even
7002 without the need to declare constants initialized with the values of
7003 such expressions.
7004 For example:
7005
7006 @smallexample @c ada
7007   X : Integer;
7008   Y : Float;
7009   for Y'Address use X'Address;>>
7010 @end smallexample
7011
7012 @sp 1
7013 @cartouche
7014 An implementation need not support a specification for the @code{Size}
7015 for a given composite subtype, nor the size or storage place for an
7016 object (including a component) of a given composite subtype, unless the
7017 constraints on the subtype and its composite subcomponents (if any) are
7018 all static constraints.
7019 @end cartouche
7020 Followed.  Size Clauses are not permitted on non-static components, as
7021 described above.
7022
7023 @sp 1
7024 @cartouche
7025 An aliased component, or a component whose type is by-reference, should
7026 always be allocated at an addressable location.
7027 @end cartouche
7028 Followed.
7029
7030 @cindex Packed types
7031 @unnumberedsec 13.2(6-8): Packed Types
7032 @sp 1
7033 @cartouche
7034 If a type is packed, then the implementation should try to minimize
7035 storage allocated to objects of the type, possibly at the expense of
7036 speed of accessing components, subject to reasonable complexity in
7037 addressing calculations.
7038 @end cartouche
7039 @sp 1
7040 @cartouche
7041 The recommended level of support pragma @code{Pack} is:
7042
7043 For a packed record type, the components should be packed as tightly as
7044 possible subject to the Sizes of the component subtypes, and subject to
7045 any @code{record_representation_clause} that applies to the type; the
7046 implementation may, but need not, reorder components or cross aligned
7047 word boundaries to improve the packing.  A component whose @code{Size} is
7048 greater than the word size may be allocated an integral number of words.
7049 @end cartouche
7050 Followed.  Tight packing of arrays is supported for all component sizes
7051 up to 64-bits. If the array component size is 1 (that is to say, if
7052 the component is a boolean type or an enumeration type with two values)
7053 then values of the type are implicitly initialized to zero. This
7054 happens both for objects of the packed type, and for objects that have a
7055 subcomponent of the packed type.
7056
7057 @sp 1
7058 @cartouche
7059 An implementation should support Address clauses for imported
7060 subprograms.
7061 @end cartouche
7062 Followed.
7063 @cindex @code{Address} clauses
7064 @unnumberedsec 13.3(14-19): Address Clauses
7065
7066 @sp 1
7067 @cartouche
7068 For an array @var{X}, @code{@var{X}'Address} should point at the first
7069 component of the array, and not at the array bounds.
7070 @end cartouche
7071 Followed.
7072
7073 @sp 1
7074 @cartouche
7075 The recommended level of support for the @code{Address} attribute is:
7076
7077 @code{@var{X}'Address} should produce a useful result if @var{X} is an
7078 object that is aliased or of a by-reference type, or is an entity whose
7079 @code{Address} has been specified.
7080 @end cartouche
7081 Followed.  A valid address will be produced even if none of those
7082 conditions have been met.  If necessary, the object is forced into
7083 memory to ensure the address is valid.
7084
7085 @sp 1
7086 @cartouche
7087 An implementation should support @code{Address} clauses for imported
7088 subprograms.
7089 @end cartouche
7090 Followed.
7091
7092 @sp 1
7093 @cartouche
7094 Objects (including subcomponents) that are aliased or of a by-reference
7095 type should be allocated on storage element boundaries.
7096 @end cartouche
7097 Followed.
7098
7099 @sp 1
7100 @cartouche
7101 If the @code{Address} of an object is specified, or it is imported or exported,
7102 then the implementation should not perform optimizations based on
7103 assumptions of no aliases.
7104 @end cartouche
7105 Followed.
7106
7107 @cindex @code{Alignment} clauses
7108 @unnumberedsec 13.3(29-35): Alignment Clauses
7109 @sp 1
7110 @cartouche
7111 The recommended level of support for the @code{Alignment} attribute for
7112 subtypes is:
7113
7114 An implementation should support specified Alignments that are factors
7115 and multiples of the number of storage elements per word, subject to the
7116 following:
7117 @end cartouche
7118 Followed.
7119
7120 @sp 1
7121 @cartouche
7122 An implementation need not support specified @code{Alignment}s for
7123 combinations of @code{Size}s and @code{Alignment}s that cannot be easily
7124 loaded and stored by available machine instructions.
7125 @end cartouche
7126 Followed.
7127
7128 @sp 1
7129 @cartouche
7130 An implementation need not support specified @code{Alignment}s that are
7131 greater than the maximum @code{Alignment} the implementation ever returns by
7132 default.
7133 @end cartouche
7134 Followed.
7135
7136 @sp 1
7137 @cartouche
7138 The recommended level of support for the @code{Alignment} attribute for
7139 objects is:
7140
7141 Same as above, for subtypes, but in addition:
7142 @end cartouche
7143 Followed.
7144
7145 @sp 1
7146 @cartouche
7147 For stand-alone library-level objects of statically constrained
7148 subtypes, the implementation should support all @code{Alignment}s
7149 supported by the target linker.  For example, page alignment is likely to
7150 be supported for such objects, but not for subtypes.
7151 @end cartouche
7152 Followed.
7153
7154 @cindex @code{Size} clauses
7155 @unnumberedsec 13.3(42-43): Size Clauses
7156 @sp 1
7157 @cartouche
7158 The recommended level of support for the @code{Size} attribute of
7159 objects is:
7160
7161 A @code{Size} clause should be supported for an object if the specified
7162 @code{Size} is at least as large as its subtype's @code{Size}, and
7163 corresponds to a size in storage elements that is a multiple of the
7164 object's @code{Alignment} (if the @code{Alignment} is nonzero).
7165 @end cartouche
7166 Followed.
7167
7168 @unnumberedsec 13.3(50-56): Size Clauses
7169 @sp 1
7170 @cartouche
7171 If the @code{Size} of a subtype is specified, and allows for efficient
7172 independent addressability (see 9.10) on the target architecture, then
7173 the @code{Size} of the following objects of the subtype should equal the
7174 @code{Size} of the subtype:
7175
7176 Aliased objects (including components).
7177 @end cartouche
7178 Followed.
7179
7180 @sp 1
7181 @cartouche
7182 @code{Size} clause on a composite subtype should not affect the
7183 internal layout of components.
7184 @end cartouche
7185 Followed. But note that this can be overridden by use of the implementation
7186 pragma Implicit_Packing in the case of packed arrays.
7187
7188 @sp 1
7189 @cartouche
7190 The recommended level of support for the @code{Size} attribute of subtypes is:
7191 @end cartouche
7192 @sp 1
7193 @cartouche
7194 The @code{Size} (if not specified) of a static discrete or fixed point
7195 subtype should be the number of bits needed to represent each value
7196 belonging to the subtype using an unbiased representation, leaving space
7197 for a sign bit only if the subtype contains negative values.  If such a
7198 subtype is a first subtype, then an implementation should support a
7199 specified @code{Size} for it that reflects this representation.
7200 @end cartouche
7201 Followed.
7202
7203 @sp 1
7204 @cartouche
7205 For a subtype implemented with levels of indirection, the @code{Size}
7206 should include the size of the pointers, but not the size of what they
7207 point at.
7208 @end cartouche
7209 Followed.
7210
7211 @cindex @code{Component_Size} clauses
7212 @unnumberedsec 13.3(71-73): Component Size Clauses
7213 @sp 1
7214 @cartouche
7215 The recommended level of support for the @code{Component_Size}
7216 attribute is:
7217 @end cartouche
7218 @sp 1
7219 @cartouche
7220 An implementation need not support specified @code{Component_Sizes} that are
7221 less than the @code{Size} of the component subtype.
7222 @end cartouche
7223 Followed.
7224
7225 @sp 1
7226 @cartouche
7227 An implementation should support specified @code{Component_Size}s that
7228 are factors and multiples of the word size.  For such
7229 @code{Component_Size}s, the array should contain no gaps between
7230 components.  For other @code{Component_Size}s (if supported), the array
7231 should contain no gaps between components when packing is also
7232 specified; the implementation should forbid this combination in cases
7233 where it cannot support a no-gaps representation.
7234 @end cartouche
7235 Followed.
7236
7237 @cindex Enumeration representation clauses
7238 @cindex Representation clauses, enumeration
7239 @unnumberedsec 13.4(9-10): Enumeration Representation Clauses
7240 @sp 1
7241 @cartouche
7242 The recommended level of support for enumeration representation clauses
7243 is:
7244
7245 An implementation need not support enumeration representation clauses
7246 for boolean types, but should at minimum support the internal codes in
7247 the range @code{System.Min_Int.System.Max_Int}.
7248 @end cartouche
7249 Followed.
7250
7251 @cindex Record representation clauses
7252 @cindex Representation clauses, records
7253 @unnumberedsec 13.5.1(17-22): Record Representation Clauses
7254 @sp 1
7255 @cartouche
7256 The recommended level of support for
7257 @*@code{record_representation_clauses} is:
7258
7259 An implementation should support storage places that can be extracted
7260 with a load, mask, shift sequence of machine code, and set with a load,
7261 shift, mask, store sequence, given the available machine instructions
7262 and run-time model.
7263 @end cartouche
7264 Followed.
7265
7266 @sp 1
7267 @cartouche
7268 A storage place should be supported if its size is equal to the
7269 @code{Size} of the component subtype, and it starts and ends on a
7270 boundary that obeys the @code{Alignment} of the component subtype.
7271 @end cartouche
7272 Followed.
7273
7274 @sp 1
7275 @cartouche
7276 If the default bit ordering applies to the declaration of a given type,
7277 then for a component whose subtype's @code{Size} is less than the word
7278 size, any storage place that does not cross an aligned word boundary
7279 should be supported.
7280 @end cartouche
7281 Followed.
7282
7283 @sp 1
7284 @cartouche
7285 An implementation may reserve a storage place for the tag field of a
7286 tagged type, and disallow other components from overlapping that place.
7287 @end cartouche
7288 Followed.  The storage place for the tag field is the beginning of the tagged
7289 record, and its size is Address'Size.  GNAT will reject an explicit component
7290 clause for the tag field.
7291
7292 @sp 1
7293 @cartouche
7294 An implementation need not support a @code{component_clause} for a
7295 component of an extension part if the storage place is not after the
7296 storage places of all components of the parent type, whether or not
7297 those storage places had been specified.
7298 @end cartouche
7299 Followed.  The above advice on record representation clauses is followed,
7300 and all mentioned features are implemented.
7301
7302 @cindex Storage place attributes
7303 @unnumberedsec 13.5.2(5): Storage Place Attributes
7304 @sp 1
7305 @cartouche
7306 If a component is represented using some form of pointer (such as an
7307 offset) to the actual data of the component, and this data is contiguous
7308 with the rest of the object, then the storage place attributes should
7309 reflect the place of the actual data, not the pointer.  If a component is
7310 allocated discontinuously from the rest of the object, then a warning
7311 should be generated upon reference to one of its storage place
7312 attributes.
7313 @end cartouche
7314 Followed.  There are no such components in GNAT@.
7315
7316 @cindex Bit ordering
7317 @unnumberedsec 13.5.3(7-8): Bit Ordering
7318 @sp 1
7319 @cartouche
7320 The recommended level of support for the non-default bit ordering is:
7321 @end cartouche
7322 @sp 1
7323 @cartouche
7324 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
7325 should support the non-default bit ordering in addition to the default
7326 bit ordering.
7327 @end cartouche
7328 Followed.  Word size does not equal storage size in this implementation.
7329 Thus non-default bit ordering is not supported.
7330
7331 @cindex @code{Address}, as private type
7332 @unnumberedsec 13.7(37): Address as Private
7333 @sp 1
7334 @cartouche
7335 @code{Address} should be of a private type.
7336 @end cartouche
7337 Followed.
7338
7339 @cindex Operations, on @code{Address}
7340 @cindex @code{Address}, operations of
7341 @unnumberedsec 13.7.1(16): Address Operations
7342 @sp 1
7343 @cartouche
7344 Operations in @code{System} and its children should reflect the target
7345 environment semantics as closely as is reasonable.  For example, on most
7346 machines, it makes sense for address arithmetic to ``wrap around''.
7347 Operations that do not make sense should raise @code{Program_Error}.
7348 @end cartouche
7349 Followed.  Address arithmetic is modular arithmetic that wraps around.  No
7350 operation raises @code{Program_Error}, since all operations make sense.
7351
7352 @cindex Unchecked conversion
7353 @unnumberedsec 13.9(14-17): Unchecked Conversion
7354 @sp 1
7355 @cartouche
7356 The @code{Size} of an array object should not include its bounds; hence,
7357 the bounds should not be part of the converted data.
7358 @end cartouche
7359 Followed.
7360
7361 @sp 1
7362 @cartouche
7363 The implementation should not generate unnecessary run-time checks to
7364 ensure that the representation of @var{S} is a representation of the
7365 target type.  It should take advantage of the permission to return by
7366 reference when possible.  Restrictions on unchecked conversions should be
7367 avoided unless required by the target environment.
7368 @end cartouche
7369 Followed.  There are no restrictions on unchecked conversion.  A warning is
7370 generated if the source and target types do not have the same size since
7371 the semantics in this case may be target dependent.
7372
7373 @sp 1
7374 @cartouche
7375 The recommended level of support for unchecked conversions is:
7376 @end cartouche
7377 @sp 1
7378 @cartouche
7379 Unchecked conversions should be supported and should be reversible in
7380 the cases where this clause defines the result.  To enable meaningful use
7381 of unchecked conversion, a contiguous representation should be used for
7382 elementary subtypes, for statically constrained array subtypes whose
7383 component subtype is one of the subtypes described in this paragraph,
7384 and for record subtypes without discriminants whose component subtypes
7385 are described in this paragraph.
7386 @end cartouche
7387 Followed.
7388
7389 @cindex Heap usage, implicit
7390 @unnumberedsec 13.11(23-25): Implicit Heap Usage
7391 @sp 1
7392 @cartouche
7393 An implementation should document any cases in which it dynamically
7394 allocates heap storage for a purpose other than the evaluation of an
7395 allocator.
7396 @end cartouche
7397 Followed, the only other points at which heap storage is dynamically
7398 allocated are as follows:
7399
7400 @itemize @bullet
7401 @item
7402 At initial elaboration time, to allocate dynamically sized global
7403 objects.
7404
7405 @item
7406 To allocate space for a task when a task is created.
7407
7408 @item
7409 To extend the secondary stack dynamically when needed.  The secondary
7410 stack is used for returning variable length results.
7411 @end itemize
7412
7413 @sp 1
7414 @cartouche
7415 A default (implementation-provided) storage pool for an
7416 access-to-constant type should not have overhead to support deallocation of
7417 individual objects.
7418 @end cartouche
7419 Followed.
7420
7421 @sp 1
7422 @cartouche
7423 A storage pool for an anonymous access type should be created at the
7424 point of an allocator for the type, and be reclaimed when the designated
7425 object becomes inaccessible.
7426 @end cartouche
7427 Followed.
7428
7429 @cindex Unchecked deallocation
7430 @unnumberedsec 13.11.2(17): Unchecked De-allocation
7431 @sp 1
7432 @cartouche
7433 For a standard storage pool, @code{Free} should actually reclaim the
7434 storage.
7435 @end cartouche
7436 Followed.
7437
7438 @cindex Stream oriented attributes
7439 @unnumberedsec 13.13.2(17): Stream Oriented Attributes
7440 @sp 1
7441 @cartouche
7442 If a stream element is the same size as a storage element, then the
7443 normal in-memory representation should be used by @code{Read} and
7444 @code{Write} for scalar objects.  Otherwise, @code{Read} and @code{Write}
7445 should use the smallest number of stream elements needed to represent
7446 all values in the base range of the scalar type.
7447 @end cartouche
7448
7449 Followed.  By default, GNAT uses the interpretation suggested by AI-195,
7450 which specifies using the size of the first subtype.
7451 However, such an implementation is based on direct binary
7452 representations and is therefore target- and endianness-dependent.
7453 To address this issue, GNAT also supplies an alternate implementation
7454 of the stream attributes @code{Read} and @code{Write},
7455 which uses the target-independent XDR standard representation
7456 for scalar types.
7457 @cindex XDR representation
7458 @cindex @code{Read} attribute
7459 @cindex @code{Write} attribute
7460 @cindex Stream oriented attributes
7461 The XDR implementation is provided as an alternative body of the
7462 @code{System.Stream_Attributes} package, in the file
7463 @file{s-stratt-xdr.adb} in the GNAT library.
7464 There is no @file{s-stratt-xdr.ads} file.
7465 In order to install the XDR implementation, do the following:
7466 @enumerate
7467 @item Replace the default implementation of the
7468 @code{System.Stream_Attributes} package with the XDR implementation.
7469 For example on a Unix platform issue the commands:
7470 @smallexample
7471 $ mv s-stratt.adb s-stratt-default.adb
7472 $ mv s-stratt-xdr.adb s-stratt.adb
7473 @end smallexample
7474
7475 @item
7476 Rebuild the GNAT run-time library as documented in
7477 @ref{GNAT and Libraries,,, gnat_ugn, @value{EDITION} User's Guide}.
7478 @end enumerate
7479
7480 @unnumberedsec A.1(52): Names of Predefined Numeric Types
7481 @sp 1
7482 @cartouche
7483 If an implementation provides additional named predefined integer types,
7484 then the names should end with @samp{Integer} as in
7485 @samp{Long_Integer}.  If an implementation provides additional named
7486 predefined floating point types, then the names should end with
7487 @samp{Float} as in @samp{Long_Float}.
7488 @end cartouche
7489 Followed.
7490
7491 @findex Ada.Characters.Handling
7492 @unnumberedsec A.3.2(49): @code{Ada.Characters.Handling}
7493 @sp 1
7494 @cartouche
7495 If an implementation provides a localized definition of @code{Character}
7496 or @code{Wide_Character}, then the effects of the subprograms in
7497 @code{Characters.Handling} should reflect the localizations.  See also
7498 3.5.2.
7499 @end cartouche
7500 Followed.  GNAT provides no such localized definitions.
7501
7502 @cindex Bounded-length strings
7503 @unnumberedsec A.4.4(106): Bounded-Length String Handling
7504 @sp 1
7505 @cartouche
7506 Bounded string objects should not be implemented by implicit pointers
7507 and dynamic allocation.
7508 @end cartouche
7509 Followed.  No implicit pointers or dynamic allocation are used.
7510
7511 @cindex Random number generation
7512 @unnumberedsec A.5.2(46-47): Random Number Generation
7513 @sp 1
7514 @cartouche
7515 Any storage associated with an object of type @code{Generator} should be
7516 reclaimed on exit from the scope of the object.
7517 @end cartouche
7518 Followed.
7519
7520 @sp 1
7521 @cartouche
7522 If the generator period is sufficiently long in relation to the number
7523 of distinct initiator values, then each possible value of
7524 @code{Initiator} passed to @code{Reset} should initiate a sequence of
7525 random numbers that does not, in a practical sense, overlap the sequence
7526 initiated by any other value.  If this is not possible, then the mapping
7527 between initiator values and generator states should be a rapidly
7528 varying function of the initiator value.
7529 @end cartouche
7530 Followed.  The generator period is sufficiently long for the first
7531 condition here to hold true.
7532
7533 @findex Get_Immediate
7534 @unnumberedsec A.10.7(23): @code{Get_Immediate}
7535 @sp 1
7536 @cartouche
7537 The @code{Get_Immediate} procedures should be implemented with
7538 unbuffered input.  For a device such as a keyboard, input should be
7539 @dfn{available} if a key has already been typed, whereas for a disk
7540 file, input should always be available except at end of file.  For a file
7541 associated with a keyboard-like device, any line-editing features of the
7542 underlying operating system should be disabled during the execution of
7543 @code{Get_Immediate}.
7544 @end cartouche
7545 Followed on all targets except VxWorks. For VxWorks, there is no way to
7546 provide this functionality that does not result in the input buffer being
7547 flushed before the @code{Get_Immediate} call. A special unit
7548 @code{Interfaces.Vxworks.IO} is provided that contains routines to enable
7549 this functionality.
7550
7551 @findex Export
7552 @unnumberedsec B.1(39-41): Pragma @code{Export}
7553 @sp 1
7554 @cartouche
7555 If an implementation supports pragma @code{Export} to a given language,
7556 then it should also allow the main subprogram to be written in that
7557 language.  It should support some mechanism for invoking the elaboration
7558 of the Ada library units included in the system, and for invoking the
7559 finalization of the environment task.  On typical systems, the
7560 recommended mechanism is to provide two subprograms whose link names are
7561 @code{adainit} and @code{adafinal}.  @code{adainit} should contain the
7562 elaboration code for library units.  @code{adafinal} should contain the
7563 finalization code.  These subprograms should have no effect the second
7564 and subsequent time they are called.
7565 @end cartouche
7566 Followed.
7567
7568 @sp 1
7569 @cartouche
7570 Automatic elaboration of pre-elaborated packages should be
7571 provided when pragma @code{Export} is supported.
7572 @end cartouche
7573 Followed when the main program is in Ada.  If the main program is in a
7574 foreign language, then
7575 @code{adainit} must be called to elaborate pre-elaborated
7576 packages.
7577
7578 @sp 1
7579 @cartouche
7580 For each supported convention @var{L} other than @code{Intrinsic}, an
7581 implementation should support @code{Import} and @code{Export} pragmas
7582 for objects of @var{L}-compatible types and for subprograms, and pragma
7583 @code{Convention} for @var{L}-eligible types and for subprograms,
7584 presuming the other language has corresponding features.  Pragma
7585 @code{Convention} need not be supported for scalar types.
7586 @end cartouche
7587 Followed.
7588
7589 @cindex Package @code{Interfaces}
7590 @findex Interfaces
7591 @unnumberedsec B.2(12-13): Package @code{Interfaces}
7592 @sp 1
7593 @cartouche
7594 For each implementation-defined convention identifier, there should be a
7595 child package of package Interfaces with the corresponding name.  This
7596 package should contain any declarations that would be useful for
7597 interfacing to the language (implementation) represented by the
7598 convention.  Any declarations useful for interfacing to any language on
7599 the given hardware architecture should be provided directly in
7600 @code{Interfaces}.
7601 @end cartouche
7602 Followed. An additional package not defined
7603 in the Ada Reference Manual is @code{Interfaces.CPP}, used
7604 for interfacing to C++.
7605
7606 @sp 1
7607 @cartouche
7608 An implementation supporting an interface to C, COBOL, or Fortran should
7609 provide the corresponding package or packages described in the following
7610 clauses.
7611 @end cartouche
7612 Followed.  GNAT provides all the packages described in this section.
7613
7614 @cindex C, interfacing with
7615 @unnumberedsec B.3(63-71): Interfacing with C
7616 @sp 1
7617 @cartouche
7618 An implementation should support the following interface correspondences
7619 between Ada and C@.
7620 @end cartouche
7621 Followed.
7622
7623 @sp 1
7624 @cartouche
7625 An Ada procedure corresponds to a void-returning C function.
7626 @end cartouche
7627 Followed.
7628
7629 @sp 1
7630 @cartouche
7631 An Ada function corresponds to a non-void C function.
7632 @end cartouche
7633 Followed.
7634
7635 @sp 1
7636 @cartouche
7637 An Ada @code{in} scalar parameter is passed as a scalar argument to a C
7638 function.
7639 @end cartouche
7640 Followed.
7641
7642 @sp 1
7643 @cartouche
7644 An Ada @code{in} parameter of an access-to-object type with designated
7645 type @var{T} is passed as a @code{@var{t}*} argument to a C function,
7646 where @var{t} is the C type corresponding to the Ada type @var{T}.
7647 @end cartouche
7648 Followed.
7649
7650 @sp 1
7651 @cartouche
7652 An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
7653 parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
7654 argument to a C function, where @var{t} is the C type corresponding to
7655 the Ada type @var{T}.  In the case of an elementary @code{out} or
7656 @code{in out} parameter, a pointer to a temporary copy is used to
7657 preserve by-copy semantics.
7658 @end cartouche
7659 Followed.
7660
7661 @sp 1
7662 @cartouche
7663 An Ada parameter of a record type @var{T}, of any mode, is passed as a
7664 @code{@var{t}*} argument to a C function, where @var{t} is the C
7665 structure corresponding to the Ada type @var{T}.
7666 @end cartouche
7667 Followed.  This convention may be overridden by the use of the C_Pass_By_Copy
7668 pragma, or Convention, or by explicitly specifying the mechanism for a given
7669 call using an extended import or export pragma.
7670
7671 @sp 1
7672 @cartouche
7673 An Ada parameter of an array type with component type @var{T}, of any
7674 mode, is passed as a @code{@var{t}*} argument to a C function, where
7675 @var{t} is the C type corresponding to the Ada type @var{T}.
7676 @end cartouche
7677 Followed.
7678
7679 @sp 1
7680 @cartouche
7681 An Ada parameter of an access-to-subprogram type is passed as a pointer
7682 to a C function whose prototype corresponds to the designated
7683 subprogram's specification.
7684 @end cartouche
7685 Followed.
7686
7687 @cindex COBOL, interfacing with
7688 @unnumberedsec B.4(95-98): Interfacing with COBOL
7689 @sp 1
7690 @cartouche
7691 An Ada implementation should support the following interface
7692 correspondences between Ada and COBOL@.
7693 @end cartouche
7694 Followed.
7695
7696 @sp 1
7697 @cartouche
7698 An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of
7699 the COBOL type corresponding to @var{T}.
7700 @end cartouche
7701 Followed.
7702
7703 @sp 1
7704 @cartouche
7705 An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of
7706 the corresponding COBOL type.
7707 @end cartouche
7708 Followed.
7709
7710 @sp 1
7711 @cartouche
7712 Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the
7713 COBOL type corresponding to the Ada parameter type; for scalars, a local
7714 copy is used if necessary to ensure by-copy semantics.
7715 @end cartouche
7716 Followed.
7717
7718 @cindex Fortran, interfacing with
7719 @unnumberedsec B.5(22-26): Interfacing with Fortran
7720 @sp 1
7721 @cartouche
7722 An Ada implementation should support the following interface
7723 correspondences between Ada and Fortran:
7724 @end cartouche
7725 Followed.
7726
7727 @sp 1
7728 @cartouche
7729 An Ada procedure corresponds to a Fortran subroutine.
7730 @end cartouche
7731 Followed.
7732
7733 @sp 1
7734 @cartouche
7735 An Ada function corresponds to a Fortran function.
7736 @end cartouche
7737 Followed.
7738
7739 @sp 1
7740 @cartouche
7741 An Ada parameter of an elementary, array, or record type @var{T} is
7742 passed as a @var{T} argument to a Fortran procedure, where @var{T} is
7743 the Fortran type corresponding to the Ada type @var{T}, and where the
7744 INTENT attribute of the corresponding dummy argument matches the Ada
7745 formal parameter mode; the Fortran implementation's parameter passing
7746 conventions are used.  For elementary types, a local copy is used if
7747 necessary to ensure by-copy semantics.
7748 @end cartouche
7749 Followed.
7750
7751 @sp 1
7752 @cartouche
7753 An Ada parameter of an access-to-subprogram type is passed as a
7754 reference to a Fortran procedure whose interface corresponds to the
7755 designated subprogram's specification.
7756 @end cartouche
7757 Followed.
7758
7759 @cindex Machine operations
7760 @unnumberedsec C.1(3-5): Access to Machine Operations
7761 @sp 1
7762 @cartouche
7763 The machine code or intrinsic support should allow access to all
7764 operations normally available to assembly language programmers for the
7765 target environment, including privileged instructions, if any.
7766 @end cartouche
7767 Followed.
7768
7769 @sp 1
7770 @cartouche
7771 The interfacing pragmas (see Annex B) should support interface to
7772 assembler; the default assembler should be associated with the
7773 convention identifier @code{Assembler}.
7774 @end cartouche
7775 Followed.
7776
7777 @sp 1
7778 @cartouche
7779 If an entity is exported to assembly language, then the implementation
7780 should allocate it at an addressable location, and should ensure that it
7781 is retained by the linking process, even if not otherwise referenced
7782 from the Ada code.  The implementation should assume that any call to a
7783 machine code or assembler subprogram is allowed to read or update every
7784 object that is specified as exported.
7785 @end cartouche
7786 Followed.
7787
7788 @unnumberedsec C.1(10-16): Access to Machine Operations
7789 @sp 1
7790 @cartouche
7791 The implementation should ensure that little or no overhead is
7792 associated with calling intrinsic and machine-code subprograms.
7793 @end cartouche
7794 Followed for both intrinsics and machine-code subprograms.
7795
7796 @sp 1
7797 @cartouche
7798 It is recommended that intrinsic subprograms be provided for convenient
7799 access to any machine operations that provide special capabilities or
7800 efficiency and that are not otherwise available through the language
7801 constructs.
7802 @end cartouche
7803 Followed.  A full set of machine operation intrinsic subprograms is provided.
7804
7805 @sp 1
7806 @cartouche
7807 Atomic read-modify-write operations---e.g.@:, test and set, compare and
7808 swap, decrement and test, enqueue/dequeue.
7809 @end cartouche
7810 Followed on any target supporting such operations.
7811
7812 @sp 1
7813 @cartouche
7814 Standard numeric functions---e.g.@:, sin, log.
7815 @end cartouche
7816 Followed on any target supporting such operations.
7817
7818 @sp 1
7819 @cartouche
7820 String manipulation operations---e.g.@:, translate and test.
7821 @end cartouche
7822 Followed on any target supporting such operations.
7823
7824 @sp 1
7825 @cartouche
7826 Vector operations---e.g.@:, compare vector against thresholds.
7827 @end cartouche
7828 Followed on any target supporting such operations.
7829
7830 @sp 1
7831 @cartouche
7832 Direct operations on I/O ports.
7833 @end cartouche
7834 Followed on any target supporting such operations.
7835
7836 @cindex Interrupt support
7837 @unnumberedsec C.3(28): Interrupt Support
7838 @sp 1
7839 @cartouche
7840 If the @code{Ceiling_Locking} policy is not in effect, the
7841 implementation should provide means for the application to specify which
7842 interrupts are to be blocked during protected actions, if the underlying
7843 system allows for a finer-grain control of interrupt blocking.
7844 @end cartouche
7845 Followed.  The underlying system does not allow for finer-grain control
7846 of interrupt blocking.
7847
7848 @cindex Protected procedure handlers
7849 @unnumberedsec C.3.1(20-21): Protected Procedure Handlers
7850 @sp 1
7851 @cartouche
7852 Whenever possible, the implementation should allow interrupt handlers to
7853 be called directly by the hardware.
7854 @end cartouche
7855 @c SGI info:
7856 @ignore
7857 This is never possible under IRIX, so this is followed by default.
7858 @end ignore
7859 Followed on any target where the underlying operating system permits
7860 such direct calls.
7861
7862 @sp 1
7863 @cartouche
7864 Whenever practical, violations of any
7865 implementation-defined restrictions should be detected before run time.
7866 @end cartouche
7867 Followed.  Compile time warnings are given when possible.
7868
7869 @cindex Package @code{Interrupts}
7870 @findex Interrupts
7871 @unnumberedsec C.3.2(25): Package @code{Interrupts}
7872
7873 @sp 1
7874 @cartouche
7875 If implementation-defined forms of interrupt handler procedures are
7876 supported, such as protected procedures with parameters, then for each
7877 such form of a handler, a type analogous to @code{Parameterless_Handler}
7878 should be specified in a child package of @code{Interrupts}, with the
7879 same operations as in the predefined package Interrupts.
7880 @end cartouche
7881 Followed.
7882
7883 @cindex Pre-elaboration requirements
7884 @unnumberedsec C.4(14): Pre-elaboration Requirements
7885 @sp 1
7886 @cartouche
7887 It is recommended that pre-elaborated packages be implemented in such a
7888 way that there should be little or no code executed at run time for the
7889 elaboration of entities not already covered by the Implementation
7890 Requirements.
7891 @end cartouche
7892 Followed.  Executable code is generated in some cases, e.g.@: loops
7893 to initialize large arrays.
7894
7895 @unnumberedsec C.5(8): Pragma @code{Discard_Names}
7896 @sp 1
7897 @cartouche
7898 If the pragma applies to an entity, then the implementation should
7899 reduce the amount of storage used for storing names associated with that
7900 entity.
7901 @end cartouche
7902 Followed.
7903
7904 @cindex Package @code{Task_Attributes}
7905 @findex Task_Attributes
7906 @unnumberedsec C.7.2(30): The Package Task_Attributes
7907 @sp 1
7908 @cartouche
7909 Some implementations are targeted to domains in which memory use at run
7910 time must be completely deterministic.  For such implementations, it is
7911 recommended that the storage for task attributes will be pre-allocated
7912 statically and not from the heap.  This can be accomplished by either
7913 placing restrictions on the number and the size of the task's
7914 attributes, or by using the pre-allocated storage for the first @var{N}
7915 attribute objects, and the heap for the others.  In the latter case,
7916 @var{N} should be documented.
7917 @end cartouche
7918 Not followed.  This implementation is not targeted to such a domain.
7919
7920 @cindex Locking Policies
7921 @unnumberedsec D.3(17): Locking Policies
7922
7923 @sp 1
7924 @cartouche
7925 The implementation should use names that end with @samp{_Locking} for
7926 locking policies defined by the implementation.
7927 @end cartouche
7928 Followed.  Two implementation-defined locking policies are defined,
7929 whose names (@code{Inheritance_Locking} and
7930 @code{Concurrent_Readers_Locking}) follow this suggestion.
7931
7932 @cindex Entry queuing policies
7933 @unnumberedsec D.4(16): Entry Queuing Policies
7934 @sp 1
7935 @cartouche
7936 Names that end with @samp{_Queuing} should be used
7937 for all implementation-defined queuing policies.
7938 @end cartouche
7939 Followed.  No such implementation-defined queuing policies exist.
7940
7941 @cindex Preemptive abort
7942 @unnumberedsec D.6(9-10): Preemptive Abort
7943 @sp 1
7944 @cartouche
7945 Even though the @code{abort_statement} is included in the list of
7946 potentially blocking operations (see 9.5.1), it is recommended that this
7947 statement be implemented in a way that never requires the task executing
7948 the @code{abort_statement} to block.
7949 @end cartouche
7950 Followed.
7951
7952 @sp 1
7953 @cartouche
7954 On a multi-processor, the delay associated with aborting a task on
7955 another processor should be bounded; the implementation should use
7956 periodic polling, if necessary, to achieve this.
7957 @end cartouche
7958 Followed.
7959
7960 @cindex Tasking restrictions
7961 @unnumberedsec D.7(21): Tasking Restrictions
7962 @sp 1
7963 @cartouche
7964 When feasible, the implementation should take advantage of the specified
7965 restrictions to produce a more efficient implementation.
7966 @end cartouche
7967 GNAT currently takes advantage of these restrictions by providing an optimized
7968 run time when the Ravenscar profile and the GNAT restricted run time set
7969 of restrictions are specified.  See pragma @code{Profile (Ravenscar)} and
7970 pragma @code{Profile (Restricted)} for more details.
7971
7972 @cindex Time, monotonic
7973 @unnumberedsec D.8(47-49): Monotonic Time
7974 @sp 1
7975 @cartouche
7976 When appropriate, implementations should provide configuration
7977 mechanisms to change the value of @code{Tick}.
7978 @end cartouche
7979 Such configuration mechanisms are not appropriate to this implementation
7980 and are thus not supported.
7981
7982 @sp 1
7983 @cartouche
7984 It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
7985 be implemented as transformations of the same time base.
7986 @end cartouche
7987 Followed.
7988
7989 @sp 1
7990 @cartouche
7991 It is recommended that the @dfn{best} time base which exists in
7992 the underlying system be available to the application through
7993 @code{Clock}.  @dfn{Best} may mean highest accuracy or largest range.
7994 @end cartouche
7995 Followed.
7996
7997 @cindex Partition communication subsystem
7998 @cindex PCS
7999 @unnumberedsec E.5(28-29): Partition Communication Subsystem
8000 @sp 1
8001 @cartouche
8002 Whenever possible, the PCS on the called partition should allow for
8003 multiple tasks to call the RPC-receiver with different messages and
8004 should allow them to block until the corresponding subprogram body
8005 returns.
8006 @end cartouche
8007 Followed by GLADE, a separately supplied PCS that can be used with
8008 GNAT.
8009
8010 @sp 1
8011 @cartouche
8012 The @code{Write} operation on a stream of type @code{Params_Stream_Type}
8013 should raise @code{Storage_Error} if it runs out of space trying to
8014 write the @code{Item} into the stream.
8015 @end cartouche
8016 Followed by GLADE, a separately supplied PCS that can be used with
8017 GNAT@.
8018
8019 @cindex COBOL support
8020 @unnumberedsec F(7): COBOL Support
8021 @sp 1
8022 @cartouche
8023 If COBOL (respectively, C) is widely supported in the target
8024 environment, implementations supporting the Information Systems Annex
8025 should provide the child package @code{Interfaces.COBOL} (respectively,
8026 @code{Interfaces.C}) specified in Annex B and should support a
8027 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
8028 pragmas (see Annex B), thus allowing Ada programs to interface with
8029 programs written in that language.
8030 @end cartouche
8031 Followed.
8032
8033 @cindex Decimal radix support
8034 @unnumberedsec F.1(2): Decimal Radix Support
8035 @sp 1
8036 @cartouche
8037 Packed decimal should be used as the internal representation for objects
8038 of subtype @var{S} when @var{S}'Machine_Radix = 10.
8039 @end cartouche
8040 Not followed.  GNAT ignores @var{S}'Machine_Radix and always uses binary
8041 representations.
8042
8043 @cindex Numerics
8044 @unnumberedsec G: Numerics
8045 @sp 2
8046 @cartouche
8047 If Fortran (respectively, C) is widely supported in the target
8048 environment, implementations supporting the Numerics Annex
8049 should provide the child package @code{Interfaces.Fortran} (respectively,
8050 @code{Interfaces.C}) specified in Annex B and should support a
8051 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
8052 pragmas (see Annex B), thus allowing Ada programs to interface with
8053 programs written in that language.
8054 @end cartouche
8055 Followed.
8056
8057 @cindex Complex types
8058 @unnumberedsec G.1.1(56-58): Complex Types
8059 @sp 2
8060 @cartouche
8061 Because the usual mathematical meaning of multiplication of a complex
8062 operand and a real operand is that of the scaling of both components of
8063 the former by the latter, an implementation should not perform this
8064 operation by first promoting the real operand to complex type and then
8065 performing a full complex multiplication.  In systems that, in the
8066 future, support an Ada binding to IEC 559:1989, the latter technique
8067 will not generate the required result when one of the components of the
8068 complex operand is infinite.  (Explicit multiplication of the infinite
8069 component by the zero component obtained during promotion yields a NaN
8070 that propagates into the final result.) Analogous advice applies in the
8071 case of multiplication of a complex operand and a pure-imaginary
8072 operand, and in the case of division of a complex operand by a real or
8073 pure-imaginary operand.
8074 @end cartouche
8075 Not followed.
8076
8077 @sp 1
8078 @cartouche
8079 Similarly, because the usual mathematical meaning of addition of a
8080 complex operand and a real operand is that the imaginary operand remains
8081 unchanged, an implementation should not perform this operation by first
8082 promoting the real operand to complex type and then performing a full
8083 complex addition.  In implementations in which the @code{Signed_Zeros}
8084 attribute of the component type is @code{True} (and which therefore
8085 conform to IEC 559:1989 in regard to the handling of the sign of zero in
8086 predefined arithmetic operations), the latter technique will not
8087 generate the required result when the imaginary component of the complex
8088 operand is a negatively signed zero.  (Explicit addition of the negative
8089 zero to the zero obtained during promotion yields a positive zero.)
8090 Analogous advice applies in the case of addition of a complex operand
8091 and a pure-imaginary operand, and in the case of subtraction of a
8092 complex operand and a real or pure-imaginary operand.
8093 @end cartouche
8094 Not followed.
8095
8096 @sp 1
8097 @cartouche
8098 Implementations in which @code{Real'Signed_Zeros} is @code{True} should
8099 attempt to provide a rational treatment of the signs of zero results and
8100 result components.  As one example, the result of the @code{Argument}
8101 function should have the sign of the imaginary component of the
8102 parameter @code{X} when the point represented by that parameter lies on
8103 the positive real axis; as another, the sign of the imaginary component
8104 of the @code{Compose_From_Polar} function should be the same as
8105 (respectively, the opposite of) that of the @code{Argument} parameter when that
8106 parameter has a value of zero and the @code{Modulus} parameter has a
8107 nonnegative (respectively, negative) value.
8108 @end cartouche
8109 Followed.
8110
8111 @cindex Complex elementary functions
8112 @unnumberedsec G.1.2(49): Complex Elementary Functions
8113 @sp 1
8114 @cartouche
8115 Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
8116 @code{True} should attempt to provide a rational treatment of the signs
8117 of zero results and result components.  For example, many of the complex
8118 elementary functions have components that are odd functions of one of
8119 the parameter components; in these cases, the result component should
8120 have the sign of the parameter component at the origin.  Other complex
8121 elementary functions have zero components whose sign is opposite that of
8122 a parameter component at the origin, or is always positive or always
8123 negative.
8124 @end cartouche
8125 Followed.
8126
8127 @cindex Accuracy requirements
8128 @unnumberedsec G.2.4(19): Accuracy Requirements
8129 @sp 1
8130 @cartouche
8131 The versions of the forward trigonometric functions without a
8132 @code{Cycle} parameter should not be implemented by calling the
8133 corresponding version with a @code{Cycle} parameter of
8134 @code{2.0*Numerics.Pi}, since this will not provide the required
8135 accuracy in some portions of the domain.  For the same reason, the
8136 version of @code{Log} without a @code{Base} parameter should not be
8137 implemented by calling the corresponding version with a @code{Base}
8138 parameter of @code{Numerics.e}.
8139 @end cartouche
8140 Followed.
8141
8142 @cindex Complex arithmetic accuracy
8143 @cindex Accuracy, complex arithmetic
8144 @unnumberedsec G.2.6(15): Complex Arithmetic Accuracy
8145
8146 @sp 1
8147 @cartouche
8148 The version of the @code{Compose_From_Polar} function without a
8149 @code{Cycle} parameter should not be implemented by calling the
8150 corresponding version with a @code{Cycle} parameter of
8151 @code{2.0*Numerics.Pi}, since this will not provide the required
8152 accuracy in some portions of the domain.
8153 @end cartouche
8154 Followed.
8155
8156 @c -----------------------------------------
8157 @node Implementation Defined Characteristics
8158 @chapter Implementation Defined Characteristics
8159
8160 @noindent
8161 In addition to the implementation dependent pragmas and attributes, and the
8162 implementation advice, there are a number of other Ada features that are
8163 potentially implementation dependent and are designated as
8164 implementation-defined. These are mentioned throughout the Ada Reference
8165 Manual, and are summarized in Annex M@.
8166
8167 A requirement for conforming Ada compilers is that they provide
8168 documentation describing how the implementation deals with each of these
8169 issues.  In this chapter, you will find each point in Annex M listed
8170 followed by a description in italic font of how GNAT
8171 @c SGI info:
8172 @ignore
8173 in the ProDev Ada
8174 implementation on IRIX 5.3 operating system or greater
8175 @end ignore
8176 handles the implementation dependence.
8177
8178 You can use this chapter as a guide to minimizing implementation
8179 dependent features in your programs if portability to other compilers
8180 and other operating systems is an important consideration.  The numbers
8181 in each section below correspond to the paragraph number in the Ada
8182 Reference Manual.
8183
8184 @sp 1
8185 @cartouche
8186 @noindent
8187 @strong{2}.  Whether or not each recommendation given in Implementation
8188 Advice is followed.  See 1.1.2(37).
8189 @end cartouche
8190 @noindent
8191 @xref{Implementation Advice}.
8192
8193 @sp 1
8194 @cartouche
8195 @noindent
8196 @strong{3}.  Capacity limitations of the implementation.  See 1.1.3(3).
8197 @end cartouche
8198 @noindent
8199 The complexity of programs that can be processed is limited only by the
8200 total amount of available virtual memory, and disk space for the
8201 generated object files.
8202
8203 @sp 1
8204 @cartouche
8205 @noindent
8206 @strong{4}.  Variations from the standard that are impractical to avoid
8207 given the implementation's execution environment.  See 1.1.3(6).
8208 @end cartouche
8209 @noindent
8210 There are no variations from the standard.
8211
8212 @sp 1
8213 @cartouche
8214 @noindent
8215 @strong{5}.  Which @code{code_statement}s cause external
8216 interactions.  See 1.1.3(10).
8217 @end cartouche
8218 @noindent
8219 Any @code{code_statement} can potentially cause external interactions.
8220
8221 @sp 1
8222 @cartouche
8223 @noindent
8224 @strong{6}.  The coded representation for the text of an Ada
8225 program.  See 2.1(4).
8226 @end cartouche
8227 @noindent
8228 See separate section on source representation.
8229
8230 @sp 1
8231 @cartouche
8232 @noindent
8233 @strong{7}.  The control functions allowed in comments.  See 2.1(14).
8234 @end cartouche
8235 @noindent
8236 See separate section on source representation.
8237
8238 @sp 1
8239 @cartouche
8240 @noindent
8241 @strong{8}.  The representation for an end of line.  See 2.2(2).
8242 @end cartouche
8243 @noindent
8244 See separate section on source representation.
8245
8246 @sp 1
8247 @cartouche
8248 @noindent
8249 @strong{9}.  Maximum supported line length and lexical element
8250 length.  See 2.2(15).
8251 @end cartouche
8252 @noindent
8253 The maximum line length is 255 characters and the maximum length of a
8254 lexical element is also 255 characters.
8255
8256 @sp 1
8257 @cartouche
8258 @noindent
8259 @strong{10}.  Implementation defined pragmas.  See 2.8(14).
8260 @end cartouche
8261 @noindent
8262
8263 @xref{Implementation Defined Pragmas}.
8264
8265 @sp 1
8266 @cartouche
8267 @noindent
8268 @strong{11}.  Effect of pragma @code{Optimize}.  See 2.8(27).
8269 @end cartouche
8270 @noindent
8271 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
8272 parameter, checks that the optimization flag is set, and aborts if it is
8273 not.
8274
8275 @sp 1
8276 @cartouche
8277 @noindent
8278 @strong{12}.  The sequence of characters of the value returned by
8279 @code{@var{S}'Image} when some of the graphic characters of
8280 @code{@var{S}'Wide_Image} are not defined in @code{Character}.  See
8281 3.5(37).
8282 @end cartouche
8283 @noindent
8284 The sequence of characters is as defined by the wide character encoding
8285 method used for the source.  See section on source representation for
8286 further details.
8287
8288 @sp 1
8289 @cartouche
8290 @noindent
8291 @strong{13}.  The predefined integer types declared in
8292 @code{Standard}.  See 3.5.4(25).
8293 @end cartouche
8294 @noindent
8295 @table @code
8296 @item Short_Short_Integer
8297 8 bit signed
8298 @item Short_Integer
8299 (Short) 16 bit signed
8300 @item Integer
8301 32 bit signed
8302 @item Long_Integer
8303 64 bit signed (on most 64 bit targets, depending on the C definition of long).
8304 32 bit signed (all other targets)
8305 @item Long_Long_Integer
8306 64 bit signed
8307 @end table
8308
8309 @sp 1
8310 @cartouche
8311 @noindent
8312 @strong{14}.  Any nonstandard integer types and the operators defined
8313 for them.  See 3.5.4(26).
8314 @end cartouche
8315 @noindent
8316 There are no nonstandard integer types.
8317
8318 @sp 1
8319 @cartouche
8320 @noindent
8321 @strong{15}.  Any nonstandard real types and the operators defined for
8322 them.  See 3.5.6(8).
8323 @end cartouche
8324 @noindent
8325 There are no nonstandard real types.
8326
8327 @sp 1
8328 @cartouche
8329 @noindent
8330 @strong{16}.  What combinations of requested decimal precision and range
8331 are supported for floating point types.  See 3.5.7(7).
8332 @end cartouche
8333 @noindent
8334 The precision and range is as defined by the IEEE standard.
8335
8336 @sp 1
8337 @cartouche
8338 @noindent
8339 @strong{17}.  The predefined floating point types declared in
8340 @code{Standard}.  See 3.5.7(16).
8341 @end cartouche
8342 @noindent
8343 @table @code
8344 @item Short_Float
8345 32 bit IEEE short
8346 @item Float
8347 (Short) 32 bit IEEE short
8348 @item Long_Float
8349 64 bit IEEE long
8350 @item Long_Long_Float
8351 64 bit IEEE long (80 bit IEEE long on x86 processors)
8352 @end table
8353
8354 @sp 1
8355 @cartouche
8356 @noindent
8357 @strong{18}.  The small of an ordinary fixed point type.  See 3.5.9(8).
8358 @end cartouche
8359 @noindent
8360 @code{Fine_Delta} is 2**(@minus{}63)
8361
8362 @sp 1
8363 @cartouche
8364 @noindent
8365 @strong{19}.  What combinations of small, range, and digits are
8366 supported for fixed point types.  See 3.5.9(10).
8367 @end cartouche
8368 @noindent
8369 Any combinations are permitted that do not result in a small less than
8370 @code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
8371 If the mantissa is larger than 53 bits on machines where Long_Long_Float
8372 is 64 bits (true of all architectures except ia32), then the output from
8373 Text_IO is accurate to only 53 bits, rather than the full mantissa.  This
8374 is because floating-point conversions are used to convert fixed point.
8375
8376 @sp 1
8377 @cartouche
8378 @noindent
8379 @strong{20}.  The result of @code{Tags.Expanded_Name} for types declared
8380 within an unnamed @code{block_statement}.  See 3.9(10).
8381 @end cartouche
8382 @noindent
8383 Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
8384 decimal integer are allocated.
8385
8386 @sp 1
8387 @cartouche
8388 @noindent
8389 @strong{21}.  Implementation-defined attributes.  See 4.1.4(12).
8390 @end cartouche
8391 @noindent
8392 @xref{Implementation Defined Attributes}.
8393
8394 @sp 1
8395 @cartouche
8396 @noindent
8397 @strong{22}.  Any implementation-defined time types.  See 9.6(6).
8398 @end cartouche
8399 @noindent
8400 There are no implementation-defined time types.
8401
8402 @sp 1
8403 @cartouche
8404 @noindent
8405 @strong{23}.  The time base associated with relative delays.
8406 @end cartouche
8407 @noindent
8408 See 9.6(20).  The time base used is that provided by the C library
8409 function @code{gettimeofday}.
8410
8411 @sp 1
8412 @cartouche
8413 @noindent
8414 @strong{24}.  The time base of the type @code{Calendar.Time}.  See
8415 9.6(23).
8416 @end cartouche
8417 @noindent
8418 The time base used is that provided by the C library function
8419 @code{gettimeofday}.
8420
8421 @sp 1
8422 @cartouche
8423 @noindent
8424 @strong{25}.  The time zone used for package @code{Calendar}
8425 operations.  See 9.6(24).
8426 @end cartouche
8427 @noindent
8428 The time zone used by package @code{Calendar} is the current system time zone
8429 setting for local time, as accessed by the C library function
8430 @code{localtime}.
8431
8432 @sp 1
8433 @cartouche
8434 @noindent
8435 @strong{26}.  Any limit on @code{delay_until_statements} of
8436 @code{select_statements}.  See 9.6(29).
8437 @end cartouche
8438 @noindent
8439 There are no such limits.
8440
8441 @sp 1
8442 @cartouche
8443 @noindent
8444 @strong{27}.  Whether or not two non-overlapping parts of a composite
8445 object are independently addressable, in the case where packing, record
8446 layout, or @code{Component_Size} is specified for the object.  See
8447 9.10(1).
8448 @end cartouche
8449 @noindent
8450 Separate components are independently addressable if they do not share
8451 overlapping storage units.
8452
8453 @sp 1
8454 @cartouche
8455 @noindent
8456 @strong{28}.  The representation for a compilation.  See 10.1(2).
8457 @end cartouche
8458 @noindent
8459 A compilation is represented by a sequence of files presented to the
8460 compiler in a single invocation of the @command{gcc} command.
8461
8462 @sp 1
8463 @cartouche
8464 @noindent
8465 @strong{29}.  Any restrictions on compilations that contain multiple
8466 compilation_units.  See 10.1(4).
8467 @end cartouche
8468 @noindent
8469 No single file can contain more than one compilation unit, but any
8470 sequence of files can be presented to the compiler as a single
8471 compilation.
8472
8473 @sp 1
8474 @cartouche
8475 @noindent
8476 @strong{30}.  The mechanisms for creating an environment and for adding
8477 and replacing compilation units.  See 10.1.4(3).
8478 @end cartouche
8479 @noindent
8480 See separate section on compilation model.
8481
8482 @sp 1
8483 @cartouche
8484 @noindent
8485 @strong{31}.  The manner of explicitly assigning library units to a
8486 partition.  See 10.2(2).
8487 @end cartouche
8488 @noindent
8489 If a unit contains an Ada main program, then the Ada units for the partition
8490 are determined by recursive application of the rules in the Ada Reference
8491 Manual section 10.2(2-6).  In other words, the Ada units will be those that
8492 are needed by the main program, and then this definition of need is applied
8493 recursively to those units, and the partition contains the transitive
8494 closure determined by this relationship.  In short, all the necessary units
8495 are included, with no need to explicitly specify the list.  If additional
8496 units are required, e.g.@: by foreign language units, then all units must be
8497 mentioned in the context clause of one of the needed Ada units.
8498
8499 If the partition contains no main program, or if the main program is in
8500 a language other than Ada, then GNAT
8501 provides the binder options @option{-z} and @option{-n} respectively, and in
8502 this case a list of units can be explicitly supplied to the binder for
8503 inclusion in the partition (all units needed by these units will also
8504 be included automatically).  For full details on the use of these
8505 options, refer to @ref{The GNAT Make Program gnatmake,,, gnat_ugn,
8506 @value{EDITION} User's Guide}.
8507
8508 @sp 1
8509 @cartouche
8510 @noindent
8511 @strong{32}.  The implementation-defined means, if any, of specifying
8512 which compilation units are needed by a given compilation unit.  See
8513 10.2(2).
8514 @end cartouche
8515 @noindent
8516 The units needed by a given compilation unit are as defined in
8517 the Ada Reference Manual section 10.2(2-6).  There are no
8518 implementation-defined pragmas or other implementation-defined
8519 means for specifying needed units.
8520
8521 @sp 1
8522 @cartouche
8523 @noindent
8524 @strong{33}.  The manner of designating the main subprogram of a
8525 partition.  See 10.2(7).
8526 @end cartouche
8527 @noindent
8528 The main program is designated by providing the name of the
8529 corresponding @file{ALI} file as the input parameter to the binder.
8530
8531 @sp 1
8532 @cartouche
8533 @noindent
8534 @strong{34}.  The order of elaboration of @code{library_items}.  See
8535 10.2(18).
8536 @end cartouche
8537 @noindent
8538 The first constraint on ordering is that it meets the requirements of
8539 Chapter 10 of the Ada Reference Manual.  This still leaves some
8540 implementation dependent choices, which are resolved by first
8541 elaborating bodies as early as possible (i.e., in preference to specs
8542 where there is a choice), and second by evaluating the immediate with
8543 clauses of a unit to determine the probably best choice, and
8544 third by elaborating in alphabetical order of unit names
8545 where a choice still remains.
8546
8547 @sp 1
8548 @cartouche
8549 @noindent
8550 @strong{35}.  Parameter passing and function return for the main
8551 subprogram.  See 10.2(21).
8552 @end cartouche
8553 @noindent
8554 The main program has no parameters.  It may be a procedure, or a function
8555 returning an integer type.  In the latter case, the returned integer
8556 value is the return code of the program (overriding any value that
8557 may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
8558
8559 @sp 1
8560 @cartouche
8561 @noindent
8562 @strong{36}.  The mechanisms for building and running partitions.  See
8563 10.2(24).
8564 @end cartouche
8565 @noindent
8566 GNAT itself supports programs with only a single partition.  The GNATDIST
8567 tool provided with the GLADE package (which also includes an implementation
8568 of the PCS) provides a completely flexible method for building and running
8569 programs consisting of multiple partitions.  See the separate GLADE manual
8570 for details.
8571
8572 @sp 1
8573 @cartouche
8574 @noindent
8575 @strong{37}.  The details of program execution, including program
8576 termination.  See 10.2(25).
8577 @end cartouche
8578 @noindent
8579 See separate section on compilation model.
8580
8581 @sp 1
8582 @cartouche
8583 @noindent
8584 @strong{38}.  The semantics of any non-active partitions supported by the
8585 implementation.  See 10.2(28).
8586 @end cartouche
8587 @noindent
8588 Passive partitions are supported on targets where shared memory is
8589 provided by the operating system.  See the GLADE reference manual for
8590 further details.
8591
8592 @sp 1
8593 @cartouche
8594 @noindent
8595 @strong{39}.  The information returned by @code{Exception_Message}.  See
8596 11.4.1(10).
8597 @end cartouche
8598 @noindent
8599 Exception message returns the null string unless a specific message has
8600 been passed by the program.
8601
8602 @sp 1
8603 @cartouche
8604 @noindent
8605 @strong{40}.  The result of @code{Exceptions.Exception_Name} for types
8606 declared within an unnamed @code{block_statement}.  See 11.4.1(12).
8607 @end cartouche
8608 @noindent
8609 Blocks have implementation defined names of the form @code{B@var{nnn}}
8610 where @var{nnn} is an integer.
8611
8612 @sp 1
8613 @cartouche
8614 @noindent
8615 @strong{41}.  The information returned by
8616 @code{Exception_Information}.  See 11.4.1(13).
8617 @end cartouche
8618 @noindent
8619 @code{Exception_Information} returns a string in the following format:
8620
8621 @smallexample
8622 @emph{Exception_Name:} nnnnn
8623 @emph{Message:} mmmmm
8624 @emph{PID:} ppp
8625 @emph{Call stack traceback locations:}
8626 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
8627 @end smallexample
8628
8629 @noindent
8630 where
8631
8632 @itemize @bullet
8633 @item
8634 @code{nnnn} is the fully qualified name of the exception in all upper
8635 case letters. This line is always present.
8636
8637 @item
8638 @code{mmmm} is the message (this line present only if message is non-null)
8639
8640 @item
8641 @code{ppp} is the Process Id value as a decimal integer (this line is
8642 present only if the Process Id is nonzero). Currently we are
8643 not making use of this field.
8644
8645 @item
8646 The Call stack traceback locations line and the following values
8647 are present only if at least one traceback location was recorded.
8648 The values are given in C style format, with lower case letters
8649 for a-f, and only as many digits present as are necessary.
8650 @end itemize
8651
8652 @noindent
8653 The line terminator sequence at the end of each line, including
8654 the last line is a single @code{LF} character (@code{16#0A#}).
8655
8656 @sp 1
8657 @cartouche
8658 @noindent
8659 @strong{42}.  Implementation-defined check names.  See 11.5(27).
8660 @end cartouche
8661 @noindent
8662 The implementation defined check name Alignment_Check controls checking of
8663 address clause values for proper alignment (that is, the address supplied
8664 must be consistent with the alignment of the type).
8665
8666 In addition, a user program can add implementation-defined check names
8667 by means of the pragma Check_Name.
8668
8669 @sp 1
8670 @cartouche
8671 @noindent
8672 @strong{43}.  The interpretation of each aspect of representation.  See
8673 13.1(20).
8674 @end cartouche
8675 @noindent
8676 See separate section on data representations.
8677
8678 @sp 1
8679 @cartouche
8680 @noindent
8681 @strong{44}.  Any restrictions placed upon representation items.  See
8682 13.1(20).
8683 @end cartouche
8684 @noindent
8685 See separate section on data representations.
8686
8687 @sp 1
8688 @cartouche
8689 @noindent
8690 @strong{45}.  The meaning of @code{Size} for indefinite subtypes.  See
8691 13.3(48).
8692 @end cartouche
8693 @noindent
8694 Size for an indefinite subtype is the maximum possible size, except that
8695 for the case of a subprogram parameter, the size of the parameter object
8696 is the actual size.
8697
8698 @sp 1
8699 @cartouche
8700 @noindent
8701 @strong{46}.  The default external representation for a type tag.  See
8702 13.3(75).
8703 @end cartouche
8704 @noindent
8705 The default external representation for a type tag is the fully expanded
8706 name of the type in upper case letters.
8707
8708 @sp 1
8709 @cartouche
8710 @noindent
8711 @strong{47}.  What determines whether a compilation unit is the same in
8712 two different partitions.  See 13.3(76).
8713 @end cartouche
8714 @noindent
8715 A compilation unit is the same in two different partitions if and only
8716 if it derives from the same source file.
8717
8718 @sp 1
8719 @cartouche
8720 @noindent
8721 @strong{48}.  Implementation-defined components.  See 13.5.1(15).
8722 @end cartouche
8723 @noindent
8724 The only implementation defined component is the tag for a tagged type,
8725 which contains a pointer to the dispatching table.
8726
8727 @sp 1
8728 @cartouche
8729 @noindent
8730 @strong{49}.  If @code{Word_Size} = @code{Storage_Unit}, the default bit
8731 ordering.  See 13.5.3(5).
8732 @end cartouche
8733 @noindent
8734 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
8735 implementation, so no non-default bit ordering is supported.  The default
8736 bit ordering corresponds to the natural endianness of the target architecture.
8737
8738 @sp 1
8739 @cartouche
8740 @noindent
8741 @strong{50}.  The contents of the visible part of package @code{System}
8742 and its language-defined children.  See 13.7(2).
8743 @end cartouche
8744 @noindent
8745 See the definition of these packages in files @file{system.ads} and
8746 @file{s-stoele.ads}.
8747
8748 @sp 1
8749 @cartouche
8750 @noindent
8751 @strong{51}.  The contents of the visible part of package
8752 @code{System.Machine_Code}, and the meaning of
8753 @code{code_statements}.  See 13.8(7).
8754 @end cartouche
8755 @noindent
8756 See the definition and documentation in file @file{s-maccod.ads}.
8757
8758 @sp 1
8759 @cartouche
8760 @noindent
8761 @strong{52}.  The effect of unchecked conversion.  See 13.9(11).
8762 @end cartouche
8763 @noindent
8764 Unchecked conversion between types of the same size
8765 results in an uninterpreted transmission of the bits from one type
8766 to the other.  If the types are of unequal sizes, then in the case of
8767 discrete types, a shorter source is first zero or sign extended as
8768 necessary, and a shorter target is simply truncated on the left.
8769 For all non-discrete types, the source is first copied if necessary
8770 to ensure that the alignment requirements of the target are met, then
8771 a pointer is constructed to the source value, and the result is obtained
8772 by dereferencing this pointer after converting it to be a pointer to the
8773 target type. Unchecked conversions where the target subtype is an
8774 unconstrained array are not permitted. If the target alignment is
8775 greater than the source alignment, then a copy of the result is
8776 made with appropriate alignment
8777
8778 @sp 1
8779 @cartouche
8780 @noindent
8781 @strong{53}. The semantics of operations on invalid representations.
8782 See 13.9.2(10-11).
8783 @end cartouche
8784 @noindent
8785 For assignments and other operations where the use of invalid values cannot
8786 result in erroneous behavior, the compiler ignores the possibility of invalid
8787 values. An exception is raised at the point where an invalid value would
8788 result in erroneous behavior. For example executing:
8789
8790 @smallexample @c ada
8791 procedure invalidvals is
8792    X : Integer := -1;
8793    Y : Natural range 1 .. 10;
8794    for Y'Address use X'Address;
8795    Z : Natural range 1 .. 10;
8796    A : array (Natural range 1 .. 10) of Integer;
8797 begin
8798    Z := Y;     -- no exception
8799    A (Z) := 3; -- exception raised;
8800 end;
8801 @end smallexample
8802
8803 @noindent
8804 As indicated, an exception is raised on the array assignment, but not
8805 on the simple assignment of the invalid negative value from Y to Z.
8806
8807 @sp 1
8808 @cartouche
8809 @noindent
8810 @strong{53}.  The manner of choosing a storage pool for an access type
8811 when @code{Storage_Pool} is not specified for the type.  See 13.11(17).
8812 @end cartouche
8813 @noindent
8814 There are 3 different standard pools used by the compiler when
8815 @code{Storage_Pool} is not specified depending whether the type is local
8816 to a subprogram or defined at the library level and whether
8817 @code{Storage_Size}is specified or not.  See documentation in the runtime
8818 library units @code{System.Pool_Global}, @code{System.Pool_Size} and
8819 @code{System.Pool_Local} in files @file{s-poosiz.ads},
8820 @file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
8821 default pools used.
8822
8823 @sp 1
8824 @cartouche
8825 @noindent
8826 @strong{54}.  Whether or not the implementation provides user-accessible
8827 names for the standard pool type(s).  See 13.11(17).
8828 @end cartouche
8829 @noindent
8830
8831 See documentation in the sources of the run time mentioned in paragraph
8832 @strong{53} .  All these pools are accessible by means of @code{with}'ing
8833 these units.
8834
8835 @sp 1
8836 @cartouche
8837 @noindent
8838 @strong{55}.  The meaning of @code{Storage_Size}.  See 13.11(18).
8839 @end cartouche
8840 @noindent
8841 @code{Storage_Size} is measured in storage units, and refers to the
8842 total space available for an access type collection, or to the primary
8843 stack space for a task.
8844
8845 @sp 1
8846 @cartouche
8847 @noindent
8848 @strong{56}.  Implementation-defined aspects of storage pools.  See
8849 13.11(22).
8850 @end cartouche
8851 @noindent
8852 See documentation in the sources of the run time mentioned in paragraph
8853 @strong{53} for details on GNAT-defined aspects of storage pools.
8854
8855 @sp 1
8856 @cartouche
8857 @noindent
8858 @strong{57}.  The set of restrictions allowed in a pragma
8859 @code{Restrictions}.  See 13.12(7).
8860 @end cartouche
8861 @noindent
8862 All RM defined Restriction identifiers are implemented.  The following
8863 additional restriction identifiers are provided.  There are two separate
8864 lists of implementation dependent restriction identifiers.  The first
8865 set requires consistency throughout a partition (in other words, if the
8866 restriction identifier is used for any compilation unit in the partition,
8867 then all compilation units in the partition must obey the restriction.
8868
8869 @table @code
8870
8871 @item Simple_Barriers
8872 @findex Simple_Barriers
8873 This restriction ensures at compile time that barriers in entry declarations
8874 for protected types are restricted to either static boolean expressions or
8875 references to simple boolean variables defined in the private part of the
8876 protected type.  No other form of entry barriers is permitted.  This is one
8877 of the restrictions of the Ravenscar profile for limited tasking (see also
8878 pragma @code{Profile (Ravenscar)}).
8879
8880 @item Max_Entry_Queue_Length => Expr
8881 @findex Max_Entry_Queue_Length
8882 This restriction is a declaration that any protected entry compiled in
8883 the scope of the restriction has at most the specified number of
8884 tasks waiting on the entry
8885 at any one time, and so no queue is required.  This restriction is not
8886 checked at compile time.  A program execution is erroneous if an attempt
8887 is made to queue more than the specified number of tasks on such an entry.
8888
8889 @item No_Calendar
8890 @findex No_Calendar
8891 This restriction ensures at compile time that there is no implicit or
8892 explicit dependence on the package @code{Ada.Calendar}.
8893
8894 @item No_Default_Initialization
8895 @findex No_Default_Initialization
8896
8897 This restriction prohibits any instance of default initialization of variables.
8898 The binder implements a consistency rule which prevents any unit compiled
8899 without the restriction from with'ing a unit with the restriction (this allows
8900 the generation of initialization procedures to be skipped, since you can be
8901 sure that no call is ever generated to an initialization procedure in a unit
8902 with the restriction active). If used in conjunction with Initialize_Scalars or
8903 Normalize_Scalars, the effect is to prohibit all cases of variables declared
8904 without a specific initializer (including the case of OUT scalar parameters).
8905
8906 @item No_Direct_Boolean_Operators
8907 @findex No_Direct_Boolean_Operators
8908 This restriction ensures that no logical (and/or/xor) are used on
8909 operands of type Boolean (or any type derived
8910 from Boolean). This is intended for use in safety critical programs
8911 where the certification protocol requires the use of short-circuit
8912 (and then, or else) forms for all composite boolean operations.
8913
8914 @item No_Dispatching_Calls
8915 @findex No_Dispatching_Calls
8916 This restriction ensures at compile time that the code generated by the
8917 compiler involves no dispatching calls. The use of this restriction allows the
8918 safe use of record extensions, classwide membership tests and other classwide
8919 features not involving implicit dispatching. This restriction ensures that
8920 the code contains no indirect calls through a dispatching mechanism. Note that
8921 this includes internally-generated calls created by the compiler, for example
8922 in the implementation of class-wide objects assignments. The
8923 membership test is allowed in the presence of this restriction, because its
8924 implementation requires no dispatching.
8925 This restriction is comparable to the official Ada restriction
8926 @code{No_Dispatch} except that it is a bit less restrictive in that it allows
8927 all classwide constructs that do not imply dispatching.
8928 The following example indicates constructs that violate this restriction.
8929
8930 @smallexample
8931 package Pkg is
8932   type T is tagged record
8933     Data : Natural;
8934   end record;
8935   procedure P (X : T);
8936
8937   type DT is new T with record
8938     More_Data : Natural;
8939   end record;
8940   procedure Q (X : DT);
8941 end Pkg;
8942
8943 with Pkg; use Pkg;
8944 procedure Example is
8945   procedure Test (O : T'Class) is
8946     N : Natural  := O'Size;--  Error: Dispatching call
8947     C : T'Class := O;      --  Error: implicit Dispatching Call
8948   begin
8949     if O in DT'Class then  --  OK   : Membership test
8950        Q (DT (O));         --  OK   : Type conversion plus direct call
8951     else
8952        P (O);              --  Error: Dispatching call
8953     end if;
8954   end Test;
8955
8956   Obj : DT;
8957 begin
8958   P (Obj);                 --  OK   : Direct call
8959   P (T (Obj));             --  OK   : Type conversion plus direct call
8960   P (T'Class (Obj));       --  Error: Dispatching call
8961
8962   Test (Obj);              --  OK   : Type conversion
8963
8964   if Obj in T'Class then   --  OK   : Membership test
8965      null;
8966   end if;
8967 end Example;
8968 @end smallexample
8969
8970 @item No_Dynamic_Attachment
8971 @findex No_Dynamic_Attachment
8972 This restriction ensures that there is no call to any of the operations
8973 defined in package Ada.Interrupts.
8974
8975 @item No_Enumeration_Maps
8976 @findex No_Enumeration_Maps
8977 This restriction ensures at compile time that no operations requiring
8978 enumeration maps are used (that is Image and Value attributes applied
8979 to enumeration types).
8980
8981 @item No_Entry_Calls_In_Elaboration_Code
8982 @findex No_Entry_Calls_In_Elaboration_Code
8983 This restriction ensures at compile time that no task or protected entry
8984 calls are made during elaboration code.  As a result of the use of this
8985 restriction, the compiler can assume that no code past an accept statement
8986 in a task can be executed at elaboration time.
8987
8988 @item No_Exception_Handlers
8989 @findex No_Exception_Handlers
8990 This restriction ensures at compile time that there are no explicit
8991 exception handlers. It also indicates that no exception propagation will
8992 be provided. In this mode, exceptions may be raised but will result in
8993 an immediate call to the last chance handler, a routine that the user
8994 must define with the following profile:
8995
8996 @smallexample @c ada
8997 procedure Last_Chance_Handler
8998   (Source_Location : System.Address; Line : Integer);
8999 pragma Export (C, Last_Chance_Handler,
9000                "__gnat_last_chance_handler");
9001 @end smallexample
9002
9003 The parameter is a C null-terminated string representing a message to be
9004 associated with the exception (typically the source location of the raise
9005 statement generated by the compiler). The Line parameter when nonzero
9006 represents the line number in the source program where the raise occurs.
9007
9008 @item No_Exception_Propagation
9009 @findex No_Exception_Propagation
9010 This restriction guarantees that exceptions are never propagated to an outer
9011 subprogram scope). The only case in which an exception may be raised is when
9012 the handler is statically in the same subprogram, so that the effect of a raise
9013 is essentially like a goto statement. Any other raise statement (implicit or
9014 explicit) will be considered unhandled. Exception handlers are allowed, but may
9015 not contain an exception occurrence identifier (exception choice). In addition
9016 use of the package GNAT.Current_Exception is not permitted, and reraise
9017 statements (raise with no operand) are not permitted.
9018
9019 @item No_Exception_Registration
9020 @findex No_Exception_Registration
9021 This restriction ensures at compile time that no stream operations for
9022 types Exception_Id or Exception_Occurrence are used. This also makes it
9023 impossible to pass exceptions to or from a partition with this restriction
9024 in a distributed environment. If this exception is active, then the generated
9025 code is simplified by omitting the otherwise-required global registration
9026 of exceptions when they are declared.
9027
9028 @item No_Finalization
9029 @findex No_Finalization
9030 This restriction disables the language features described in chapter 7.6 of the
9031 Ada 2005 RM as well as all form of code generation performed by the compiler to
9032 support these features. The following types are no longer considered controlled
9033 when this restriction is in effect:
9034 @itemize @bullet
9035 @item
9036 @code{Ada.Finalization.Controlled}
9037 @item
9038 @code{Ada.Finalization.Limited_Controlled}
9039 @item
9040 Derivations from @code{Controlled} or @code{Limited_Controlled}
9041 @item
9042 Class-wide types
9043 @item
9044 Protected types
9045 @item
9046 Task types
9047 @item
9048 Array and record types with controlled components
9049 @end itemize
9050 The compiler no longer generates code to initialize, finalize or adjust an
9051 object or a nested component, either declared on the stack or on the heap. The
9052 deallocation of a controlled object no longer finalizes its contents.
9053
9054 @item No_Implicit_Aliasing
9055 @findex No_Implicit_Aliasing
9056
9057 This restriction, which is not required to be partition-wide consistent,
9058 requires an explicit aliased keyword for an object to which 'Access,
9059 'Unchecked_Access, or 'Address is applied, and forbids entirely the use of
9060 the 'Unrestricted_Access attribute for objects. Note: the reason that
9061 Unrestricted_Access is forbidden is that it would require the prefix
9062 to be aliased, and in such cases, it can always be replaced by
9063 the standard attribute Unchecked_Access which is preferable.
9064
9065 @item No_Implicit_Conditionals
9066 @findex No_Implicit_Conditionals
9067 This restriction ensures that the generated code does not contain any
9068 implicit conditionals, either by modifying the generated code where possible,
9069 or by rejecting any construct that would otherwise generate an implicit
9070 conditional. Note that this check does not include run time constraint
9071 checks, which on some targets may generate implicit conditionals as
9072 well. To control the latter, constraint checks can be suppressed in the
9073 normal manner. Constructs generating implicit conditionals include comparisons
9074 of composite objects and the Max/Min attributes.
9075
9076 @item No_Implicit_Dynamic_Code
9077 @findex No_Implicit_Dynamic_Code
9078 @cindex trampoline
9079 This restriction prevents the compiler from building ``trampolines''.
9080 This is a structure that is built on the stack and contains dynamic
9081 code to be executed at run time. On some targets, a trampoline is
9082 built for the following features: @code{Access},
9083 @code{Unrestricted_Access}, or @code{Address} of a nested subprogram;
9084 nested task bodies; primitive operations of nested tagged types.
9085 Trampolines do not work on machines that prevent execution of stack
9086 data. For example, on windows systems, enabling DEP (data execution
9087 protection) will cause trampolines to raise an exception.
9088 Trampolines are also quite slow at run time.
9089
9090 On many targets, trampolines have been largely eliminated. Look at the
9091 version of system.ads for your target --- if it has
9092 Always_Compatible_Rep equal to False, then trampolines are largely
9093 eliminated. In particular, a trampoline is built for the following
9094 features: @code{Address} of a nested subprogram;
9095 @code{Access} or @code{Unrestricted_Access} of a nested subprogram,
9096 but only if pragma Favor_Top_Level applies, or the access type has a
9097 foreign-language convention; primitive operations of nested tagged
9098 types.
9099
9100 @item No_Implicit_Loops
9101 @findex No_Implicit_Loops
9102 This restriction ensures that the generated code does not contain any
9103 implicit @code{for} loops, either by modifying
9104 the generated code where possible,
9105 or by rejecting any construct that would otherwise generate an implicit
9106 @code{for} loop. If this restriction is active, it is possible to build
9107 large array aggregates with all static components without generating an
9108 intermediate temporary, and without generating a loop to initialize individual
9109 components. Otherwise, a loop is created for arrays larger than about 5000
9110 scalar components.
9111
9112 @item No_Initialize_Scalars
9113 @findex No_Initialize_Scalars
9114 This restriction ensures that no unit in the partition is compiled with
9115 pragma Initialize_Scalars. This allows the generation of more efficient
9116 code, and in particular eliminates dummy null initialization routines that
9117 are otherwise generated for some record and array types.
9118
9119 @item No_Local_Protected_Objects
9120 @findex No_Local_Protected_Objects
9121 This restriction ensures at compile time that protected objects are
9122 only declared at the library level.
9123
9124 @item No_Protected_Type_Allocators
9125 @findex No_Protected_Type_Allocators
9126 This restriction ensures at compile time that there are no allocator
9127 expressions that attempt to allocate protected objects.
9128
9129 @item No_Relative_Delay
9130 @findex No_Relative_Delay
9131 This restriction ensures at compile time that there are no delay relative
9132 statements and prevents expressions such as @code{delay 1.23;} from appearing
9133 in source code.
9134
9135 @item No_Requeue_Statements
9136 @findex No_Requeue_Statements
9137 This restriction ensures at compile time that no requeue statements are
9138 permitted and prevents keyword @code{requeue} from being used in source code.
9139
9140 @item No_Secondary_Stack
9141 @findex No_Secondary_Stack
9142 This restriction ensures at compile time that the generated code does not
9143 contain any reference to the secondary stack.  The secondary stack is used
9144 to implement functions returning unconstrained objects (arrays or records)
9145 on some targets.
9146
9147 @item No_Select_Statements
9148 @findex No_Select_Statements
9149 This restriction ensures at compile time no select statements of any kind
9150 are permitted, that is the keyword @code{select} may not appear.
9151 This is one of the restrictions of the Ravenscar
9152 profile for limited tasking (see also pragma @code{Profile (Ravenscar)}).
9153
9154 @item No_Standard_Storage_Pools
9155 @findex No_Standard_Storage_Pools
9156 This restriction ensures at compile time that no access types
9157 use the standard default storage pool.  Any access type declared must
9158 have an explicit Storage_Pool attribute defined specifying a
9159 user-defined storage pool.
9160
9161 @item No_Stream_Optimizations
9162 @findex No_Stream_Optimizations
9163 This restriction affects the performance of stream operations on types
9164 @code{String}, @code{Wide_String} and @code{Wide_Wide_String}. By default, the
9165 compiler uses block reads and writes when manipulating @code{String} objects
9166 due to their supperior performance. When this restriction is in effect, the
9167 compiler performs all IO operations on a per-character basis.
9168
9169 @item No_Streams
9170 @findex No_Streams
9171 This restriction ensures at compile/bind time that there are no
9172 stream objects created and no use of stream attributes.
9173 This restriction does not forbid dependences on the package
9174 @code{Ada.Streams}. So it is permissible to with
9175 @code{Ada.Streams} (or another package that does so itself)
9176 as long as no actual stream objects are created and no
9177 stream attributes are used.
9178
9179 Note that the use of restriction allows optimization of tagged types,
9180 since they do not need to worry about dispatching stream operations.
9181 To take maximum advantage of this space-saving optimization, any
9182 unit declaring a tagged type should be compiled with the restriction,
9183 though this is not required.
9184
9185 @item No_Task_Attributes_Package
9186 @findex No_Task_Attributes_Package
9187 This restriction ensures at compile time that there are no implicit or
9188 explicit dependencies on the package @code{Ada.Task_Attributes}.
9189
9190 @item No_Task_Termination
9191 @findex No_Task_Termination
9192 This restriction ensures at compile time that no terminate alternatives
9193 appear in any task body.
9194
9195 @item No_Tasking
9196 @findex No_Tasking
9197 This restriction prevents the declaration of tasks or task types throughout
9198 the partition.  It is similar in effect to the use of @code{Max_Tasks => 0}
9199 except that violations are caught at compile time and cause an error message
9200 to be output either by the compiler or binder.
9201
9202 @item Static_Priorities
9203 @findex Static_Priorities
9204 This restriction ensures at compile time that all priority expressions
9205 are static, and that there are no dependencies on the package
9206 @code{Ada.Dynamic_Priorities}.
9207
9208 @item Static_Storage_Size
9209 @findex Static_Storage_Size
9210 This restriction ensures at compile time that any expression appearing
9211 in a Storage_Size pragma or attribute definition clause is static.
9212
9213 @end table
9214
9215 @noindent
9216 The second set of implementation dependent restriction identifiers
9217 does not require partition-wide consistency.
9218 The restriction may be enforced for a single
9219 compilation unit without any effect on any of the
9220 other compilation units in the partition.
9221
9222 @table @code
9223
9224 @item No_Elaboration_Code
9225 @findex No_Elaboration_Code
9226 This restriction ensures at compile time that no elaboration code is
9227 generated.  Note that this is not the same condition as is enforced
9228 by pragma @code{Preelaborate}.  There are cases in which pragma
9229 @code{Preelaborate} still permits code to be generated (e.g.@: code
9230 to initialize a large array to all zeroes), and there are cases of units
9231 which do not meet the requirements for pragma @code{Preelaborate},
9232 but for which no elaboration code is generated.  Generally, it is
9233 the case that preelaborable units will meet the restrictions, with
9234 the exception of large aggregates initialized with an others_clause,
9235 and exception declarations (which generate calls to a run-time
9236 registry procedure).  This restriction is enforced on
9237 a unit by unit basis, it need not be obeyed consistently
9238 throughout a partition.
9239
9240 In the case of aggregates with others, if the aggregate has a dynamic
9241 size, there is no way to eliminate the elaboration code (such dynamic
9242 bounds would be incompatible with @code{Preelaborate} in any case). If
9243 the bounds are static, then use of this restriction actually modifies
9244 the code choice of the compiler to avoid generating a loop, and instead
9245 generate the aggregate statically if possible, no matter how many times
9246 the data for the others clause must be repeatedly generated.
9247
9248 It is not possible to precisely document
9249 the constructs which are compatible with this restriction, since,
9250 unlike most other restrictions, this is not a restriction on the
9251 source code, but a restriction on the generated object code. For
9252 example, if the source contains a declaration:
9253
9254 @smallexample
9255    Val : constant Integer := X;
9256 @end smallexample
9257
9258 @noindent
9259 where X is not a static constant, it may be possible, depending
9260 on complex optimization circuitry, for the compiler to figure
9261 out the value of X at compile time, in which case this initialization
9262 can be done by the loader, and requires no initialization code. It
9263 is not possible to document the precise conditions under which the
9264 optimizer can figure this out.
9265
9266 Note that this the implementation of this restriction requires full
9267 code generation. If it is used in conjunction with "semantics only"
9268 checking, then some cases of violations may be missed.
9269
9270 @item No_Entry_Queue
9271 @findex No_Entry_Queue
9272 This restriction is a declaration that any protected entry compiled in
9273 the scope of the restriction has at most one task waiting on the entry
9274 at any one time, and so no queue is required.  This restriction is not
9275 checked at compile time.  A program execution is erroneous if an attempt
9276 is made to queue a second task on such an entry.
9277
9278 @item No_Implementation_Attributes
9279 @findex No_Implementation_Attributes
9280 This restriction checks at compile time that no GNAT-defined attributes
9281 are present.  With this restriction, the only attributes that can be used
9282 are those defined in the Ada Reference Manual.
9283
9284 @item No_Implementation_Pragmas
9285 @findex No_Implementation_Pragmas
9286 This restriction checks at compile time that no GNAT-defined pragmas
9287 are present.  With this restriction, the only pragmas that can be used
9288 are those defined in the Ada Reference Manual.
9289
9290 @item No_Implementation_Restrictions
9291 @findex No_Implementation_Restrictions
9292 This restriction checks at compile time that no GNAT-defined restriction
9293 identifiers (other than @code{No_Implementation_Restrictions} itself)
9294 are present.  With this restriction, the only other restriction identifiers
9295 that can be used are those defined in the Ada Reference Manual.
9296
9297 @item No_Wide_Characters
9298 @findex No_Wide_Characters
9299 This restriction ensures at compile time that no uses of the types
9300 @code{Wide_Character} or @code{Wide_String} or corresponding wide
9301 wide types
9302 appear, and that no wide or wide wide string or character literals
9303 appear in the program (that is literals representing characters not in
9304 type @code{Character}.
9305
9306 @item SPARK
9307 @findex SPARK
9308 This restriction checks at compile time that some constructs forbidden in
9309 SPARK are not present. The SPARK version used as a reference is the same as
9310 the Ada mode for the unit, so a unit compiled in Ada 95 mode with SPARK
9311 restrictions will be checked for constructs forbidden in SPARK 95.
9312 Error messages related to SPARK restriction have the form:
9313
9314 @smallexample
9315 violation of restriction "Spark" at <file>
9316  <error message>
9317 @end smallexample
9318
9319 This is not a replacement for the semantic checks performed by the
9320 SPARK Examiner tool, as the compiler only deals currently with code,
9321 not at all with SPARK annotations and does not guarantee catching all
9322 cases of constructs forbidden by SPARK.
9323
9324 Thus it may well be the case that code which
9325 passes the compiler in SPARK mode is rejected by the SPARK Examiner,
9326 e.g. due to the different visibility rules of the Examiner based on
9327 SPARK @code{inherit} annotations.
9328
9329 This restriction can be useful in providing an initial filter for
9330 code developed using SPARK, or in examining legacy code to see how far
9331 it is from meeting SPARK restrictions.
9332
9333 @end table
9334
9335 @sp 1
9336 @cartouche
9337 @noindent
9338 @strong{58}.  The consequences of violating limitations on
9339 @code{Restrictions} pragmas.  See 13.12(9).
9340 @end cartouche
9341 @noindent
9342 Restrictions that can be checked at compile time result in illegalities
9343 if violated.  Currently there are no other consequences of violating
9344 restrictions.
9345
9346 @sp 1
9347 @cartouche
9348 @noindent
9349 @strong{59}.  The representation used by the @code{Read} and
9350 @code{Write} attributes of elementary types in terms of stream
9351 elements.  See 13.13.2(9).
9352 @end cartouche
9353 @noindent
9354 The representation is the in-memory representation of the base type of
9355 the type, using the number of bits corresponding to the
9356 @code{@var{type}'Size} value, and the natural ordering of the machine.
9357
9358 @sp 1
9359 @cartouche
9360 @noindent
9361 @strong{60}.  The names and characteristics of the numeric subtypes
9362 declared in the visible part of package @code{Standard}.  See A.1(3).
9363 @end cartouche
9364 @noindent
9365 See items describing the integer and floating-point types supported.
9366
9367 @sp 1
9368 @cartouche
9369 @noindent
9370 @strong{61}.  The accuracy actually achieved by the elementary
9371 functions.  See A.5.1(1).
9372 @end cartouche
9373 @noindent
9374 The elementary functions correspond to the functions available in the C
9375 library.  Only fast math mode is implemented.
9376
9377 @sp 1
9378 @cartouche
9379 @noindent
9380 @strong{62}.  The sign of a zero result from some of the operators or
9381 functions in @code{Numerics.Generic_Elementary_Functions}, when
9382 @code{Float_Type'Signed_Zeros} is @code{True}.  See A.5.1(46).
9383 @end cartouche
9384 @noindent
9385 The sign of zeroes follows the requirements of the IEEE 754 standard on
9386 floating-point.
9387
9388 @sp 1
9389 @cartouche
9390 @noindent
9391 @strong{63}.  The value of
9392 @code{Numerics.Float_Random.Max_Image_Width}.  See A.5.2(27).
9393 @end cartouche
9394 @noindent
9395 Maximum image width is 6864, see library file @file{s-rannum.ads}.
9396
9397 @sp 1
9398 @cartouche
9399 @noindent
9400 @strong{64}.  The value of
9401 @code{Numerics.Discrete_Random.Max_Image_Width}.  See A.5.2(27).
9402 @end cartouche
9403 @noindent
9404 Maximum image width is 6864, see library file @file{s-rannum.ads}.
9405
9406 @sp 1
9407 @cartouche
9408 @noindent
9409 @strong{65}.  The algorithms for random number generation.  See
9410 A.5.2(32).
9411 @end cartouche
9412 @noindent
9413 The algorithm is the Mersenne Twister, as documented in the source file
9414 @file{s-rannum.adb}. This version of the algorithm has a period of
9415 2**19937-1.
9416
9417 @sp 1
9418 @cartouche
9419 @noindent
9420 @strong{66}.  The string representation of a random number generator's
9421 state.  See A.5.2(38).
9422 @end cartouche
9423 @noindent
9424 The value returned by the Image function is the concatenation of
9425 the fixed-width decimal representations of the 624 32-bit integers
9426 of the state vector.
9427
9428 @sp 1
9429 @cartouche
9430 @noindent
9431 @strong{67}.  The minimum time interval between calls to the
9432 time-dependent Reset procedure that are guaranteed to initiate different
9433 random number sequences.  See A.5.2(45).
9434 @end cartouche
9435 @noindent
9436 The minimum period between reset calls to guarantee distinct series of
9437 random numbers is one microsecond.
9438
9439 @sp 1
9440 @cartouche
9441 @noindent
9442 @strong{68}.  The values of the @code{Model_Mantissa},
9443 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
9444 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
9445 Annex is not supported.  See A.5.3(72).
9446 @end cartouche
9447 @noindent
9448 Run the compiler with @option{-gnatS} to produce a listing of package
9449 @code{Standard}, has the values of all numeric attributes.
9450
9451 @sp 1
9452 @cartouche
9453 @noindent
9454 @strong{69}.  Any implementation-defined characteristics of the
9455 input-output packages.  See A.7(14).
9456 @end cartouche
9457 @noindent
9458 There are no special implementation defined characteristics for these
9459 packages.
9460
9461 @sp 1
9462 @cartouche
9463 @noindent
9464 @strong{70}.  The value of @code{Buffer_Size} in @code{Storage_IO}.  See
9465 A.9(10).
9466 @end cartouche
9467 @noindent
9468 All type representations are contiguous, and the @code{Buffer_Size} is
9469 the value of @code{@var{type}'Size} rounded up to the next storage unit
9470 boundary.
9471
9472 @sp 1
9473 @cartouche
9474 @noindent
9475 @strong{71}.  External files for standard input, standard output, and
9476 standard error See A.10(5).
9477 @end cartouche
9478 @noindent
9479 These files are mapped onto the files provided by the C streams
9480 libraries.  See source file @file{i-cstrea.ads} for further details.
9481
9482 @sp 1
9483 @cartouche
9484 @noindent
9485 @strong{72}.  The accuracy of the value produced by @code{Put}.  See
9486 A.10.9(36).
9487 @end cartouche
9488 @noindent
9489 If more digits are requested in the output than are represented by the
9490 precision of the value, zeroes are output in the corresponding least
9491 significant digit positions.
9492
9493 @sp 1
9494 @cartouche
9495 @noindent
9496 @strong{73}.  The meaning of @code{Argument_Count}, @code{Argument}, and
9497 @code{Command_Name}.  See A.15(1).
9498 @end cartouche
9499 @noindent
9500 These are mapped onto the @code{argv} and @code{argc} parameters of the
9501 main program in the natural manner.
9502
9503 @sp 1
9504 @cartouche
9505 @noindent
9506 @strong{74}.  The interpretation of the @code{Form} parameter in procedure
9507 @code{Create_Directory}.  See A.16(56).
9508 @end cartouche
9509 @noindent
9510 The @code{Form} parameter is not used.
9511
9512 @sp 1
9513 @cartouche
9514 @noindent
9515 @strong{75}.  The interpretation of the @code{Form} parameter in procedure
9516 @code{Create_Path}.  See A.16(60).
9517 @end cartouche
9518 @noindent
9519 The @code{Form} parameter is not used.
9520
9521 @sp 1
9522 @cartouche
9523 @noindent
9524 @strong{76}.  The interpretation of the @code{Form} parameter in procedure
9525 @code{Copy_File}.  See A.16(68).
9526 @end cartouche
9527 @noindent
9528 The @code{Form} parameter is case-insensitive.
9529
9530 Two fields are recognized in the @code{Form} parameter:
9531
9532 @table @code
9533
9534 @item preserve=<value>
9535
9536 @item mode=<value>
9537
9538 @end table
9539
9540 @noindent
9541 <value> starts immediately after the character '=' and ends with the
9542 character immediately preceding the next comma (',') or with the last
9543 character of the parameter.
9544
9545 The only possible values for preserve= are:
9546
9547 @table @code
9548
9549 @item no_attributes
9550 Do not try to preserve any file attributes. This is the default if no
9551 preserve= is found in Form.
9552
9553 @item all_attributes
9554 Try to preserve all file attributes (timestamps, access rights).
9555
9556 @item timestamps
9557 Preserve the timestamp of the copied file, but not the other file attributes.
9558
9559 @end table
9560
9561 @noindent
9562 The only possible values for mode= are:
9563
9564 @table @code
9565
9566 @item copy
9567 Only do the copy if the destination file does not already exist. If it already
9568 exists, Copy_File fails.
9569
9570 @item overwrite
9571 Copy the file in all cases. Overwrite an already existing destination file.
9572
9573 @item append
9574 Append the original file to the destination file. If the destination file does
9575 not exist, the destination file is a copy of the source file. When mode=append,
9576 the field preserve=, if it exists, is not taken into account.
9577
9578 @end table
9579
9580 @noindent
9581 If the Form parameter includes one or both of the fields and the value or
9582 values are incorrect, Copy_file fails with Use_Error.
9583
9584 Examples of correct Forms:
9585
9586 @smallexample
9587 Form => "preserve=no_attributes,mode=overwrite" (the default)
9588 Form => "mode=append"
9589 Form => "mode=copy, preserve=all_attributes"
9590 @end smallexample
9591
9592 @noindent
9593 Examples of incorrect Forms
9594
9595 @smallexample
9596 Form => "preserve=junk"
9597 Form => "mode=internal, preserve=timestamps"
9598 @end smallexample
9599
9600 @sp 1
9601 @cartouche
9602 @noindent
9603 @strong{77}.  Implementation-defined convention names.  See B.1(11).
9604 @end cartouche
9605 @noindent
9606 The following convention names are supported
9607
9608 @table @code
9609 @item  Ada
9610 Ada
9611 @item Ada_Pass_By_Copy
9612 Allowed for any types except by-reference types such as limited
9613 records. Compatible with convention Ada, but causes any parameters
9614 with this convention to be passed by copy.
9615 @item Ada_Pass_By_Reference
9616 Allowed for any types except by-copy types such as scalars.
9617 Compatible with convention Ada, but causes any parameters
9618 with this convention to be passed by reference.
9619 @item Assembler
9620 Assembly language
9621 @item Asm
9622 Synonym for Assembler
9623 @item Assembly
9624 Synonym for Assembler
9625 @item C
9626 C
9627 @item C_Pass_By_Copy
9628 Allowed only for record types, like C, but also notes that record
9629 is to be passed by copy rather than reference.
9630 @item COBOL
9631 COBOL
9632 @item C_Plus_Plus (or CPP)
9633 C++
9634 @item Default
9635 Treated the same as C
9636 @item External
9637 Treated the same as C
9638 @item Fortran
9639 Fortran
9640 @item Intrinsic
9641 For support of pragma @code{Import} with convention Intrinsic, see
9642 separate section on Intrinsic Subprograms.
9643 @item Stdcall
9644 Stdcall (used for Windows implementations only).  This convention correspond
9645 to the WINAPI (previously called Pascal convention) C/C++ convention under
9646 Windows.  A routine with this convention cleans the stack before
9647 exit. This pragma cannot be applied to a dispatching call.
9648 @item DLL
9649 Synonym for Stdcall
9650 @item Win32
9651 Synonym for Stdcall
9652 @item Stubbed
9653 Stubbed is a special convention used to indicate that the body of the
9654 subprogram will be entirely ignored.  Any call to the subprogram
9655 is converted into a raise of the @code{Program_Error} exception.  If a
9656 pragma @code{Import} specifies convention @code{stubbed} then no body need
9657 be present at all.  This convention is useful during development for the
9658 inclusion of subprograms whose body has not yet been written.
9659
9660 @end table
9661 @noindent
9662 In addition, all otherwise unrecognized convention names are also
9663 treated as being synonymous with convention C@.  In all implementations
9664 except for VMS, use of such other names results in a warning.  In VMS
9665 implementations, these names are accepted silently.
9666
9667 @sp 1
9668 @cartouche
9669 @noindent
9670 @strong{78}.  The meaning of link names.  See B.1(36).
9671 @end cartouche
9672 @noindent
9673 Link names are the actual names used by the linker.
9674
9675 @sp 1
9676 @cartouche
9677 @noindent
9678 @strong{79}.  The manner of choosing link names when neither the link
9679 name nor the address of an imported or exported entity is specified.  See
9680 B.1(36).
9681 @end cartouche
9682 @noindent
9683 The default linker name is that which would be assigned by the relevant
9684 external language, interpreting the Ada name as being in all lower case
9685 letters.
9686
9687 @sp 1
9688 @cartouche
9689 @noindent
9690 @strong{80}.  The effect of pragma @code{Linker_Options}.  See B.1(37).
9691 @end cartouche
9692 @noindent
9693 The string passed to @code{Linker_Options} is presented uninterpreted as
9694 an argument to the link command, unless it contains ASCII.NUL characters.
9695 NUL characters if they appear act as argument separators, so for example
9696
9697 @smallexample @c ada
9698 pragma Linker_Options ("-labc" & ASCII.NUL & "-ldef");
9699 @end smallexample
9700
9701 @noindent
9702 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
9703 linker. The order of linker options is preserved for a given unit. The final
9704 list of options passed to the linker is in reverse order of the elaboration
9705 order. For example, linker options for a body always appear before the options
9706 from the corresponding package spec.
9707
9708 @sp 1
9709 @cartouche
9710 @noindent
9711 @strong{81}.  The contents of the visible part of package
9712 @code{Interfaces} and its language-defined descendants.  See B.2(1).
9713 @end cartouche
9714 @noindent
9715 See files with prefix @file{i-} in the distributed library.
9716
9717 @sp 1
9718 @cartouche
9719 @noindent
9720 @strong{82}.  Implementation-defined children of package
9721 @code{Interfaces}.  The contents of the visible part of package
9722 @code{Interfaces}.  See B.2(11).
9723 @end cartouche
9724 @noindent
9725 See files with prefix @file{i-} in the distributed library.
9726
9727 @sp 1
9728 @cartouche
9729 @noindent
9730 @strong{83}.  The types @code{Floating}, @code{Long_Floating},
9731 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
9732 @code{COBOL_Character}; and the initialization of the variables
9733 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
9734 @code{Interfaces.COBOL}.  See B.4(50).
9735 @end cartouche
9736 @noindent
9737 @table @code
9738 @item Floating
9739 Float
9740 @item Long_Floating
9741 (Floating) Long_Float
9742 @item Binary
9743 Integer
9744 @item Long_Binary
9745 Long_Long_Integer
9746 @item Decimal_Element
9747 Character
9748 @item COBOL_Character
9749 Character
9750 @end table
9751
9752 @noindent
9753 For initialization, see the file @file{i-cobol.ads} in the distributed library.
9754
9755 @sp 1
9756 @cartouche
9757 @noindent
9758 @strong{84}.  Support for access to machine instructions.  See C.1(1).
9759 @end cartouche
9760 @noindent
9761 See documentation in file @file{s-maccod.ads} in the distributed library.
9762
9763 @sp 1
9764 @cartouche
9765 @noindent
9766 @strong{85}.  Implementation-defined aspects of access to machine
9767 operations.  See C.1(9).
9768 @end cartouche
9769 @noindent
9770 See documentation in file @file{s-maccod.ads} in the distributed library.
9771
9772 @sp 1
9773 @cartouche
9774 @noindent
9775 @strong{86}.  Implementation-defined aspects of interrupts.  See C.3(2).
9776 @end cartouche
9777 @noindent
9778 Interrupts are mapped to signals or conditions as appropriate.  See
9779 definition of unit
9780 @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
9781 on the interrupts supported on a particular target.
9782
9783 @sp 1
9784 @cartouche
9785 @noindent
9786 @strong{87}.  Implementation-defined aspects of pre-elaboration.  See
9787 C.4(13).
9788 @end cartouche
9789 @noindent
9790 GNAT does not permit a partition to be restarted without reloading,
9791 except under control of the debugger.
9792
9793 @sp 1
9794 @cartouche
9795 @noindent
9796 @strong{88}.  The semantics of pragma @code{Discard_Names}.  See C.5(7).
9797 @end cartouche
9798 @noindent
9799 Pragma @code{Discard_Names} causes names of enumeration literals to
9800 be suppressed.  In the presence of this pragma, the Image attribute
9801 provides the image of the Pos of the literal, and Value accepts
9802 Pos values.
9803
9804 @sp 1
9805 @cartouche
9806 @noindent
9807 @strong{89}.  The result of the @code{Task_Identification.Image}
9808 attribute.  See C.7.1(7).
9809 @end cartouche
9810 @noindent
9811 The result of this attribute is a string that identifies
9812 the object or component that denotes a given task. If a variable @code{Var}
9813 has a task type, the image for this task will have the form @code{Var_@var{XXXXXXXX}},
9814 where the suffix
9815 is the hexadecimal representation of the virtual address of the corresponding
9816 task control block. If the variable is an array of tasks, the image of each
9817 task will have the form of an indexed component indicating the position of a
9818 given task in the array, e.g.@: @code{Group(5)_@var{XXXXXXX}}. If the task is a
9819 component of a record, the image of the task will have the form of a selected
9820 component. These rules are fully recursive, so that the image of a task that
9821 is a subcomponent of a composite object corresponds to the expression that
9822 designates this task.
9823 @noindent
9824 If a task is created by an allocator, its image depends on the context. If the
9825 allocator is part of an object declaration, the rules described above are used
9826 to construct its image, and this image is not affected by subsequent
9827 assignments. If the allocator appears within an expression, the image
9828 includes only the name of the task type.
9829 @noindent
9830 If the configuration pragma Discard_Names is present, or if the restriction
9831 No_Implicit_Heap_Allocation is in effect,  the image reduces to
9832 the numeric suffix, that is to say the hexadecimal representation of the
9833 virtual address of the control block of the task.
9834 @sp 1
9835 @cartouche
9836 @noindent
9837 @strong{90}.  The value of @code{Current_Task} when in a protected entry
9838 or interrupt handler.  See C.7.1(17).
9839 @end cartouche
9840 @noindent
9841 Protected entries or interrupt handlers can be executed by any
9842 convenient thread, so the value of @code{Current_Task} is undefined.
9843
9844 @sp 1
9845 @cartouche
9846 @noindent
9847 @strong{91}.  The effect of calling @code{Current_Task} from an entry
9848 body or interrupt handler.  See C.7.1(19).
9849 @end cartouche
9850 @noindent
9851 The effect of calling @code{Current_Task} from an entry body or
9852 interrupt handler is to return the identification of the task currently
9853 executing the code.
9854
9855 @sp 1
9856 @cartouche
9857 @noindent
9858 @strong{92}.  Implementation-defined aspects of
9859 @code{Task_Attributes}.  See C.7.2(19).
9860 @end cartouche
9861 @noindent
9862 There are no implementation-defined aspects of @code{Task_Attributes}.
9863
9864 @sp 1
9865 @cartouche
9866 @noindent
9867 @strong{93}.  Values of all @code{Metrics}.  See D(2).
9868 @end cartouche
9869 @noindent
9870 The metrics information for GNAT depends on the performance of the
9871 underlying operating system.  The sources of the run-time for tasking
9872 implementation, together with the output from @option{-gnatG} can be
9873 used to determine the exact sequence of operating systems calls made
9874 to implement various tasking constructs.  Together with appropriate
9875 information on the performance of the underlying operating system,
9876 on the exact target in use, this information can be used to determine
9877 the required metrics.
9878
9879 @sp 1
9880 @cartouche
9881 @noindent
9882 @strong{94}.  The declarations of @code{Any_Priority} and
9883 @code{Priority}.  See D.1(11).
9884 @end cartouche
9885 @noindent
9886 See declarations in file @file{system.ads}.
9887
9888 @sp 1
9889 @cartouche
9890 @noindent
9891 @strong{95}.  Implementation-defined execution resources.  See D.1(15).
9892 @end cartouche
9893 @noindent
9894 There are no implementation-defined execution resources.
9895
9896 @sp 1
9897 @cartouche
9898 @noindent
9899 @strong{96}.  Whether, on a multiprocessor, a task that is waiting for
9900 access to a protected object keeps its processor busy.  See D.2.1(3).
9901 @end cartouche
9902 @noindent
9903 On a multi-processor, a task that is waiting for access to a protected
9904 object does not keep its processor busy.
9905
9906 @sp 1
9907 @cartouche
9908 @noindent
9909 @strong{97}.  The affect of implementation defined execution resources
9910 on task dispatching.  See D.2.1(9).
9911 @end cartouche
9912 @noindent
9913 @c SGI info
9914 @ignore
9915 Tasks map to IRIX threads, and the dispatching policy is as defined by
9916 the IRIX implementation of threads.
9917 @end ignore
9918 Tasks map to threads in the threads package used by GNAT@.  Where possible
9919 and appropriate, these threads correspond to native threads of the
9920 underlying operating system.
9921
9922 @sp 1
9923 @cartouche
9924 @noindent
9925 @strong{98}.  Implementation-defined @code{policy_identifiers} allowed
9926 in a pragma @code{Task_Dispatching_Policy}.  See D.2.2(3).
9927 @end cartouche
9928 @noindent
9929 There are no implementation-defined policy-identifiers allowed in this
9930 pragma.
9931
9932 @sp 1
9933 @cartouche
9934 @noindent
9935 @strong{99}.  Implementation-defined aspects of priority inversion.  See
9936 D.2.2(16).
9937 @end cartouche
9938 @noindent
9939 Execution of a task cannot be preempted by the implementation processing
9940 of delay expirations for lower priority tasks.
9941
9942 @sp 1
9943 @cartouche
9944 @noindent
9945 @strong{100}.  Implementation defined task dispatching.  See D.2.2(18).
9946 @end cartouche
9947 @noindent
9948 @c SGI info:
9949 @ignore
9950 Tasks map to IRIX threads, and the dispatching policy is as defined by
9951 the IRIX implementation of threads.
9952 @end ignore
9953 The policy is the same as that of the underlying threads implementation.
9954
9955 @sp 1
9956 @cartouche
9957 @noindent
9958 @strong{101}.  Implementation-defined @code{policy_identifiers} allowed
9959 in a pragma @code{Locking_Policy}.  See D.3(4).
9960 @end cartouche
9961 @noindent
9962 The two implementation defined policies permitted in GNAT are
9963 @code{Inheritance_Locking} and  @code{Conccurent_Readers_Locking}.  On
9964 targets that support the @code{Inheritance_Locking} policy, locking is
9965 implemented by inheritance, i.e.@: the task owning the lock operates
9966 at a priority equal to the highest priority of any task currently
9967 requesting the lock.  On targets that support the
9968 @code{Conccurent_Readers_Locking} policy, locking is implemented with a
9969 read/write lock allowing multiple propected object functions to enter
9970 concurrently.
9971
9972 @sp 1
9973 @cartouche
9974 @noindent
9975 @strong{102}.  Default ceiling priorities.  See D.3(10).
9976 @end cartouche
9977 @noindent
9978 The ceiling priority of protected objects of the type
9979 @code{System.Interrupt_Priority'Last} as described in the Ada
9980 Reference Manual D.3(10),
9981
9982 @sp 1
9983 @cartouche
9984 @noindent
9985 @strong{103}.  The ceiling of any protected object used internally by
9986 the implementation.  See D.3(16).
9987 @end cartouche
9988 @noindent
9989 The ceiling priority of internal protected objects is
9990 @code{System.Priority'Last}.
9991
9992 @sp 1
9993 @cartouche
9994 @noindent
9995 @strong{104}.  Implementation-defined queuing policies.  See D.4(1).
9996 @end cartouche
9997 @noindent
9998 There are no implementation-defined queuing policies.
9999
10000 @sp 1
10001 @cartouche
10002 @noindent
10003 @strong{105}.  On a multiprocessor, any conditions that cause the
10004 completion of an aborted construct to be delayed later than what is
10005 specified for a single processor.  See D.6(3).
10006 @end cartouche
10007 @noindent
10008 The semantics for abort on a multi-processor is the same as on a single
10009 processor, there are no further delays.
10010
10011 @sp 1
10012 @cartouche
10013 @noindent
10014 @strong{106}.  Any operations that implicitly require heap storage
10015 allocation.  See D.7(8).
10016 @end cartouche
10017 @noindent
10018 The only operation that implicitly requires heap storage allocation is
10019 task creation.
10020
10021 @sp 1
10022 @cartouche
10023 @noindent
10024 @strong{107}.  Implementation-defined aspects of pragma
10025 @code{Restrictions}.  See D.7(20).
10026 @end cartouche
10027 @noindent
10028 There are no such implementation-defined aspects.
10029
10030 @sp 1
10031 @cartouche
10032 @noindent
10033 @strong{108}.  Implementation-defined aspects of package
10034 @code{Real_Time}.  See D.8(17).
10035 @end cartouche
10036 @noindent
10037 There are no implementation defined aspects of package @code{Real_Time}.
10038
10039 @sp 1
10040 @cartouche
10041 @noindent
10042 @strong{109}.  Implementation-defined aspects of
10043 @code{delay_statements}.  See D.9(8).
10044 @end cartouche
10045 @noindent
10046 Any difference greater than one microsecond will cause the task to be
10047 delayed (see D.9(7)).
10048
10049 @sp 1
10050 @cartouche
10051 @noindent
10052 @strong{110}.  The upper bound on the duration of interrupt blocking
10053 caused by the implementation.  See D.12(5).
10054 @end cartouche
10055 @noindent
10056 The upper bound is determined by the underlying operating system.  In
10057 no cases is it more than 10 milliseconds.
10058
10059 @sp 1
10060 @cartouche
10061 @noindent
10062 @strong{111}.  The means for creating and executing distributed
10063 programs.  See E(5).
10064 @end cartouche
10065 @noindent
10066 The GLADE package provides a utility GNATDIST for creating and executing
10067 distributed programs.  See the GLADE reference manual for further details.
10068
10069 @sp 1
10070 @cartouche
10071 @noindent
10072 @strong{112}.  Any events that can result in a partition becoming
10073 inaccessible.  See E.1(7).
10074 @end cartouche
10075 @noindent
10076 See the GLADE reference manual for full details on such events.
10077
10078 @sp 1
10079 @cartouche
10080 @noindent
10081 @strong{113}.  The scheduling policies, treatment of priorities, and
10082 management of shared resources between partitions in certain cases.  See
10083 E.1(11).
10084 @end cartouche
10085 @noindent
10086 See the GLADE reference manual for full details on these aspects of
10087 multi-partition execution.
10088
10089 @sp 1
10090 @cartouche
10091 @noindent
10092 @strong{114}.  Events that cause the version of a compilation unit to
10093 change.  See E.3(5).
10094 @end cartouche
10095 @noindent
10096 Editing the source file of a compilation unit, or the source files of
10097 any units on which it is dependent in a significant way cause the version
10098 to change.  No other actions cause the version number to change.  All changes
10099 are significant except those which affect only layout, capitalization or
10100 comments.
10101
10102 @sp 1
10103 @cartouche
10104 @noindent
10105 @strong{115}.  Whether the execution of the remote subprogram is
10106 immediately aborted as a result of cancellation.  See E.4(13).
10107 @end cartouche
10108 @noindent
10109 See the GLADE reference manual for details on the effect of abort in
10110 a distributed application.
10111
10112 @sp 1
10113 @cartouche
10114 @noindent
10115 @strong{116}.  Implementation-defined aspects of the PCS@.  See E.5(25).
10116 @end cartouche
10117 @noindent
10118 See the GLADE reference manual for a full description of all implementation
10119 defined aspects of the PCS@.
10120
10121 @sp 1
10122 @cartouche
10123 @noindent
10124 @strong{117}.  Implementation-defined interfaces in the PCS@.  See
10125 E.5(26).
10126 @end cartouche
10127 @noindent
10128 See the GLADE reference manual for a full description of all
10129 implementation defined interfaces.
10130
10131 @sp 1
10132 @cartouche
10133 @noindent
10134 @strong{118}.  The values of named numbers in the package
10135 @code{Decimal}.  See F.2(7).
10136 @end cartouche
10137 @noindent
10138 @table @code
10139 @item Max_Scale
10140 +18
10141 @item Min_Scale
10142 -18
10143 @item Min_Delta
10144 1.0E-18
10145 @item Max_Delta
10146 1.0E+18
10147 @item Max_Decimal_Digits
10148 18
10149 @end table
10150
10151 @sp 1
10152 @cartouche
10153 @noindent
10154 @strong{119}.  The value of @code{Max_Picture_Length} in the package
10155 @code{Text_IO.Editing}.  See F.3.3(16).
10156 @end cartouche
10157 @noindent
10158 64
10159
10160 @sp 1
10161 @cartouche
10162 @noindent
10163 @strong{120}.  The value of @code{Max_Picture_Length} in the package
10164 @code{Wide_Text_IO.Editing}.  See F.3.4(5).
10165 @end cartouche
10166 @noindent
10167 64
10168
10169 @sp 1
10170 @cartouche
10171 @noindent
10172 @strong{121}.  The accuracy actually achieved by the complex elementary
10173 functions and by other complex arithmetic operations.  See G.1(1).
10174 @end cartouche
10175 @noindent
10176 Standard library functions are used for the complex arithmetic
10177 operations.  Only fast math mode is currently supported.
10178
10179 @sp 1
10180 @cartouche
10181 @noindent
10182 @strong{122}.  The sign of a zero result (or a component thereof) from
10183 any operator or function in @code{Numerics.Generic_Complex_Types}, when
10184 @code{Real'Signed_Zeros} is True.  See G.1.1(53).
10185 @end cartouche
10186 @noindent
10187 The signs of zero values are as recommended by the relevant
10188 implementation advice.
10189
10190 @sp 1
10191 @cartouche
10192 @noindent
10193 @strong{123}.  The sign of a zero result (or a component thereof) from
10194 any operator or function in
10195 @code{Numerics.Generic_Complex_Elementary_Functions}, when
10196 @code{Real'Signed_Zeros} is @code{True}.  See G.1.2(45).
10197 @end cartouche
10198 @noindent
10199 The signs of zero values are as recommended by the relevant
10200 implementation advice.
10201
10202 @sp 1
10203 @cartouche
10204 @noindent
10205 @strong{124}.  Whether the strict mode or the relaxed mode is the
10206 default.  See G.2(2).
10207 @end cartouche
10208 @noindent
10209 The strict mode is the default.  There is no separate relaxed mode.  GNAT
10210 provides a highly efficient implementation of strict mode.
10211
10212 @sp 1
10213 @cartouche
10214 @noindent
10215 @strong{125}.  The result interval in certain cases of fixed-to-float
10216 conversion.  See G.2.1(10).
10217 @end cartouche
10218 @noindent
10219 For cases where the result interval is implementation dependent, the
10220 accuracy is that provided by performing all operations in 64-bit IEEE
10221 floating-point format.
10222
10223 @sp 1
10224 @cartouche
10225 @noindent
10226 @strong{126}.  The result of a floating point arithmetic operation in
10227 overflow situations, when the @code{Machine_Overflows} attribute of the
10228 result type is @code{False}.  See G.2.1(13).
10229 @end cartouche
10230 @noindent
10231 Infinite and NaN values are produced as dictated by the IEEE
10232 floating-point standard.
10233
10234 Note that on machines that are not fully compliant with the IEEE
10235 floating-point standard, such as Alpha, the @option{-mieee} compiler flag
10236 must be used for achieving IEEE conforming behavior (although at the cost
10237 of a significant performance penalty), so infinite and NaN values are
10238 properly generated.
10239
10240 @sp 1
10241 @cartouche
10242 @noindent
10243 @strong{127}.  The result interval for division (or exponentiation by a
10244 negative exponent), when the floating point hardware implements division
10245 as multiplication by a reciprocal.  See G.2.1(16).
10246 @end cartouche
10247 @noindent
10248 Not relevant, division is IEEE exact.
10249
10250 @sp 1
10251 @cartouche
10252 @noindent
10253 @strong{128}.  The definition of close result set, which determines the
10254 accuracy of certain fixed point multiplications and divisions.  See
10255 G.2.3(5).
10256 @end cartouche
10257 @noindent
10258 Operations in the close result set are performed using IEEE long format
10259 floating-point arithmetic.  The input operands are converted to
10260 floating-point, the operation is done in floating-point, and the result
10261 is converted to the target type.
10262
10263 @sp 1
10264 @cartouche
10265 @noindent
10266 @strong{129}.  Conditions on a @code{universal_real} operand of a fixed
10267 point multiplication or division for which the result shall be in the
10268 perfect result set.  See G.2.3(22).
10269 @end cartouche
10270 @noindent
10271 The result is only defined to be in the perfect result set if the result
10272 can be computed by a single scaling operation involving a scale factor
10273 representable in 64-bits.
10274
10275 @sp 1
10276 @cartouche
10277 @noindent
10278 @strong{130}.  The result of a fixed point arithmetic operation in
10279 overflow situations, when the @code{Machine_Overflows} attribute of the
10280 result type is @code{False}.  See G.2.3(27).
10281 @end cartouche
10282 @noindent
10283 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
10284 types.
10285
10286 @sp 1
10287 @cartouche
10288 @noindent
10289 @strong{131}.  The result of an elementary function reference in
10290 overflow situations, when the @code{Machine_Overflows} attribute of the
10291 result type is @code{False}.  See G.2.4(4).
10292 @end cartouche
10293 @noindent
10294 IEEE infinite and Nan values are produced as appropriate.
10295
10296 @sp 1
10297 @cartouche
10298 @noindent
10299 @strong{132}.  The value of the angle threshold, within which certain
10300 elementary functions, complex arithmetic operations, and complex
10301 elementary functions yield results conforming to a maximum relative
10302 error bound.  See G.2.4(10).
10303 @end cartouche
10304 @noindent
10305 Information on this subject is not yet available.
10306
10307 @sp 1
10308 @cartouche
10309 @noindent
10310 @strong{133}.  The accuracy of certain elementary functions for
10311 parameters beyond the angle threshold.  See G.2.4(10).
10312 @end cartouche
10313 @noindent
10314 Information on this subject is not yet available.
10315
10316 @sp 1
10317 @cartouche
10318 @noindent
10319 @strong{134}.  The result of a complex arithmetic operation or complex
10320 elementary function reference in overflow situations, when the
10321 @code{Machine_Overflows} attribute of the corresponding real type is
10322 @code{False}.  See G.2.6(5).
10323 @end cartouche
10324 @noindent
10325 IEEE infinite and Nan values are produced as appropriate.
10326
10327 @sp 1
10328 @cartouche
10329 @noindent
10330 @strong{135}.  The accuracy of certain complex arithmetic operations and
10331 certain complex elementary functions for parameters (or components
10332 thereof) beyond the angle threshold.  See G.2.6(8).
10333 @end cartouche
10334 @noindent
10335 Information on those subjects is not yet available.
10336
10337 @sp 1
10338 @cartouche
10339 @noindent
10340 @strong{136}.  Information regarding bounded errors and erroneous
10341 execution.  See H.2(1).
10342 @end cartouche
10343 @noindent
10344 Information on this subject is not yet available.
10345
10346 @sp 1
10347 @cartouche
10348 @noindent
10349 @strong{137}.  Implementation-defined aspects of pragma
10350 @code{Inspection_Point}.  See H.3.2(8).
10351 @end cartouche
10352 @noindent
10353 Pragma @code{Inspection_Point} ensures that the variable is live and can
10354 be examined by the debugger at the inspection point.
10355
10356 @sp 1
10357 @cartouche
10358 @noindent
10359 @strong{138}.  Implementation-defined aspects of pragma
10360 @code{Restrictions}.  See H.4(25).
10361 @end cartouche
10362 @noindent
10363 There are no implementation-defined aspects of pragma @code{Restrictions}.  The
10364 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
10365 generated code.  Checks must suppressed by use of pragma @code{Suppress}.
10366
10367 @sp 1
10368 @cartouche
10369 @noindent
10370 @strong{139}.  Any restrictions on pragma @code{Restrictions}.  See
10371 H.4(27).
10372 @end cartouche
10373 @noindent
10374 There are no restrictions on pragma @code{Restrictions}.
10375
10376 @node Intrinsic Subprograms
10377 @chapter Intrinsic Subprograms
10378 @cindex Intrinsic Subprograms
10379
10380 @menu
10381 * Intrinsic Operators::
10382 * Enclosing_Entity::
10383 * Exception_Information::
10384 * Exception_Message::
10385 * Exception_Name::
10386 * File::
10387 * Line::
10388 * Shifts and Rotates::
10389 * Source_Location::
10390 @end menu
10391
10392 @noindent
10393 GNAT allows a user application program to write the declaration:
10394
10395 @smallexample @c ada
10396    pragma Import (Intrinsic, name);
10397 @end smallexample
10398
10399 @noindent
10400 providing that the name corresponds to one of the implemented intrinsic
10401 subprograms in GNAT, and that the parameter profile of the referenced
10402 subprogram meets the requirements.  This chapter describes the set of
10403 implemented intrinsic subprograms, and the requirements on parameter profiles.
10404 Note that no body is supplied; as with other uses of pragma Import, the
10405 body is supplied elsewhere (in this case by the compiler itself).  Note
10406 that any use of this feature is potentially non-portable, since the
10407 Ada standard does not require Ada compilers to implement this feature.
10408
10409 @node Intrinsic Operators
10410 @section Intrinsic Operators
10411 @cindex Intrinsic operator
10412
10413 @noindent
10414 All the predefined numeric operators in package Standard
10415 in @code{pragma Import (Intrinsic,..)}
10416 declarations.  In the binary operator case, the operands must have the same
10417 size.  The operand or operands must also be appropriate for
10418 the operator.  For example, for addition, the operands must
10419 both be floating-point or both be fixed-point, and the
10420 right operand for @code{"**"} must have a root type of
10421 @code{Standard.Integer'Base}.
10422 You can use an intrinsic operator declaration as in the following example:
10423
10424 @smallexample @c ada
10425    type Int1 is new Integer;
10426    type Int2 is new Integer;
10427
10428    function "+" (X1 : Int1; X2 : Int2) return Int1;
10429    function "+" (X1 : Int1; X2 : Int2) return Int2;
10430    pragma Import (Intrinsic, "+");
10431 @end smallexample
10432
10433 @noindent
10434 This declaration would permit ``mixed mode'' arithmetic on items
10435 of the differing types @code{Int1} and @code{Int2}.
10436 It is also possible to specify such operators for private types, if the
10437 full views are appropriate arithmetic types.
10438
10439 @node Enclosing_Entity
10440 @section Enclosing_Entity
10441 @cindex Enclosing_Entity
10442 @noindent
10443 This intrinsic subprogram is used in the implementation of the
10444 library routine @code{GNAT.Source_Info}.  The only useful use of the
10445 intrinsic import in this case is the one in this unit, so an
10446 application program should simply call the function
10447 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
10448 the current subprogram, package, task, entry, or protected subprogram.
10449
10450 @node Exception_Information
10451 @section Exception_Information
10452 @cindex Exception_Information'
10453 @noindent
10454 This intrinsic subprogram is used in the implementation of the
10455 library routine @code{GNAT.Current_Exception}.  The only useful
10456 use of the intrinsic import in this case is the one in this unit,
10457 so an application program should simply call the function
10458 @code{GNAT.Current_Exception.Exception_Information} to obtain
10459 the exception information associated with the current exception.
10460
10461 @node Exception_Message
10462 @section Exception_Message
10463 @cindex Exception_Message
10464 @noindent
10465 This intrinsic subprogram is used in the implementation of the
10466 library routine @code{GNAT.Current_Exception}.  The only useful
10467 use of the intrinsic import in this case is the one in this unit,
10468 so an application program should simply call the function
10469 @code{GNAT.Current_Exception.Exception_Message} to obtain
10470 the message associated with the current exception.
10471
10472 @node Exception_Name
10473 @section Exception_Name
10474 @cindex Exception_Name
10475 @noindent
10476 This intrinsic subprogram is used in the implementation of the
10477 library routine @code{GNAT.Current_Exception}.  The only useful
10478 use of the intrinsic import in this case is the one in this unit,
10479 so an application program should simply call the function
10480 @code{GNAT.Current_Exception.Exception_Name} to obtain
10481 the name of the current exception.
10482
10483 @node File
10484 @section File
10485 @cindex File
10486 @noindent
10487 This intrinsic subprogram is used in the implementation of the
10488 library routine @code{GNAT.Source_Info}.  The only useful use of the
10489 intrinsic import in this case is the one in this unit, so an
10490 application program should simply call the function
10491 @code{GNAT.Source_Info.File} to obtain the name of the current
10492 file.
10493
10494 @node Line
10495 @section Line
10496 @cindex Line
10497 @noindent
10498 This intrinsic subprogram is used in the implementation of the
10499 library routine @code{GNAT.Source_Info}.  The only useful use of the
10500 intrinsic import in this case is the one in this unit, so an
10501 application program should simply call the function
10502 @code{GNAT.Source_Info.Line} to obtain the number of the current
10503 source line.
10504
10505 @node Shifts and Rotates
10506 @section Shifts and Rotates
10507 @cindex Shift_Left
10508 @cindex Shift_Right
10509 @cindex Shift_Right_Arithmetic
10510 @cindex Rotate_Left
10511 @cindex Rotate_Right
10512 @noindent
10513 In standard Ada, the shift and rotate functions are available only
10514 for the predefined modular types in package @code{Interfaces}.  However, in
10515 GNAT it is possible to define these functions for any integer
10516 type (signed or modular), as in this example:
10517
10518 @smallexample @c ada
10519    function Shift_Left
10520      (Value  : T;
10521       Amount : Natural)
10522       return   T;
10523 @end smallexample
10524
10525 @noindent
10526 The function name must be one of
10527 Shift_Left, Shift_Right, Shift_Right_Arithmetic, Rotate_Left, or
10528 Rotate_Right. T must be an integer type. T'Size must be
10529 8, 16, 32 or 64 bits; if T is modular, the modulus
10530 must be 2**8, 2**16, 2**32 or 2**64.
10531 The result type must be the same as the type of @code{Value}.
10532 The shift amount must be Natural.
10533 The formal parameter names can be anything.
10534
10535 @node Source_Location
10536 @section Source_Location
10537 @cindex Source_Location
10538 @noindent
10539 This intrinsic subprogram is used in the implementation of the
10540 library routine @code{GNAT.Source_Info}.  The only useful use of the
10541 intrinsic import in this case is the one in this unit, so an
10542 application program should simply call the function
10543 @code{GNAT.Source_Info.Source_Location} to obtain the current
10544 source file location.
10545
10546 @node Representation Clauses and Pragmas
10547 @chapter Representation Clauses and Pragmas
10548 @cindex Representation Clauses
10549
10550 @menu
10551 * Alignment Clauses::
10552 * Size Clauses::
10553 * Storage_Size Clauses::
10554 * Size of Variant Record Objects::
10555 * Biased Representation ::
10556 * Value_Size and Object_Size Clauses::
10557 * Component_Size Clauses::
10558 * Bit_Order Clauses::
10559 * Effect of Bit_Order on Byte Ordering::
10560 * Pragma Pack for Arrays::
10561 * Pragma Pack for Records::
10562 * Record Representation Clauses::
10563 * Enumeration Clauses::
10564 * Address Clauses::
10565 * Effect of Convention on Representation::
10566 * Determining the Representations chosen by GNAT::
10567 @end menu
10568
10569 @noindent
10570 @cindex Representation Clause
10571 @cindex Representation Pragma
10572 @cindex Pragma, representation
10573 This section describes the representation clauses accepted by GNAT, and
10574 their effect on the representation of corresponding data objects.
10575
10576 GNAT fully implements Annex C (Systems Programming).  This means that all
10577 the implementation advice sections in chapter 13 are fully implemented.
10578 However, these sections only require a minimal level of support for
10579 representation clauses.  GNAT provides much more extensive capabilities,
10580 and this section describes the additional capabilities provided.
10581
10582 @node Alignment Clauses
10583 @section Alignment Clauses
10584 @cindex Alignment Clause
10585
10586 @noindent
10587 GNAT requires that all alignment clauses specify a power of 2, and all
10588 default alignments are always a power of 2.  The default alignment
10589 values are as follows:
10590
10591 @itemize @bullet
10592 @item @emph{Primitive Types}.
10593 For primitive types, the alignment is the minimum of the actual size of
10594 objects of the type divided by @code{Storage_Unit},
10595 and the maximum alignment supported by the target.
10596 (This maximum alignment is given by the GNAT-specific attribute
10597 @code{Standard'Maximum_Alignment}; see @ref{Maximum_Alignment}.)
10598 @cindex @code{Maximum_Alignment} attribute
10599 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
10600 default alignment will be 8 on any target that supports alignments
10601 this large, but on some targets, the maximum alignment may be smaller
10602 than 8, in which case objects of type @code{Long_Float} will be maximally
10603 aligned.
10604
10605 @item @emph{Arrays}.
10606 For arrays, the alignment is equal to the alignment of the component type
10607 for the normal case where no packing or component size is given.  If the
10608 array is packed, and the packing is effective (see separate section on
10609 packed arrays), then the alignment will be one for long packed arrays,
10610 or arrays whose length is not known at compile time.  For short packed
10611 arrays, which are handled internally as modular types, the alignment
10612 will be as described for primitive types, e.g.@: a packed array of length
10613 31 bits will have an object size of four bytes, and an alignment of 4.
10614
10615 @item @emph{Records}.
10616 For the normal non-packed case, the alignment of a record is equal to
10617 the maximum alignment of any of its components.  For tagged records, this
10618 includes the implicit access type used for the tag.  If a pragma @code{Pack}
10619 is used and all components are packable (see separate section on pragma
10620 @code{Pack}), then the resulting alignment is 1, unless the layout of the
10621 record makes it profitable to increase it.
10622
10623 A special case is when:
10624 @itemize @bullet
10625 @item
10626 the size of the record is given explicitly, or a
10627 full record representation clause is given, and
10628 @item
10629 the size of the record is 2, 4, or 8 bytes.
10630 @end itemize
10631 @noindent
10632 In this case, an alignment is chosen to match the
10633 size of the record. For example, if we have:
10634
10635 @smallexample @c ada
10636    type Small is record
10637       A, B : Character;
10638    end record;
10639    for Small'Size use 16;
10640 @end smallexample
10641
10642 @noindent
10643 then the default alignment of the record type @code{Small} is 2, not 1. This
10644 leads to more efficient code when the record is treated as a unit, and also
10645 allows the type to specified as @code{Atomic} on architectures requiring
10646 strict alignment.
10647
10648 @end itemize
10649
10650 @noindent
10651 An alignment clause may specify a larger alignment than the default value
10652 up to some maximum value dependent on the target (obtainable by using the
10653 attribute reference @code{Standard'Maximum_Alignment}). It may also specify
10654 a smaller alignment than the default value for enumeration, integer and
10655 fixed point types, as well as for record types, for example
10656
10657 @smallexample @c ada
10658   type V is record
10659      A : Integer;
10660   end record;
10661
10662   for V'alignment use 1;
10663 @end smallexample
10664
10665 @noindent
10666 @cindex Alignment, default
10667 The default alignment for the type @code{V} is 4, as a result of the
10668 Integer field in the record, but it is permissible, as shown, to
10669 override the default alignment of the record with a smaller value.
10670
10671 @node Size Clauses
10672 @section Size Clauses
10673 @cindex Size Clause
10674
10675 @noindent
10676 The default size for a type @code{T} is obtainable through the
10677 language-defined attribute @code{T'Size} and also through the
10678 equivalent GNAT-defined attribute @code{T'Value_Size}.
10679 For objects of type @code{T}, GNAT will generally increase the type size
10680 so that the object size (obtainable through the GNAT-defined attribute
10681 @code{T'Object_Size})
10682 is a multiple of @code{T'Alignment * Storage_Unit}.
10683 For example
10684
10685 @smallexample @c ada
10686    type Smallint is range 1 .. 6;
10687
10688    type Rec is record
10689       Y1 : integer;
10690       Y2 : boolean;
10691    end record;
10692 @end smallexample
10693
10694 @noindent
10695 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
10696 as specified by the RM rules,
10697 but objects of this type will have a size of 8
10698 (@code{Smallint'Object_Size} = 8),
10699 since objects by default occupy an integral number
10700 of storage units.  On some targets, notably older
10701 versions of the Digital Alpha, the size of stand
10702 alone objects of this type may be 32, reflecting
10703 the inability of the hardware to do byte load/stores.
10704
10705 Similarly, the size of type @code{Rec} is 40 bits
10706 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
10707 the alignment is 4, so objects of this type will have
10708 their size increased to 64 bits so that it is a multiple
10709 of the alignment (in bits).  This decision is
10710 in accordance with the specific Implementation Advice in RM 13.3(43):
10711
10712 @quotation
10713 A @code{Size} clause should be supported for an object if the specified
10714 @code{Size} is at least as large as its subtype's @code{Size}, and corresponds
10715 to a size in storage elements that is a multiple of the object's
10716 @code{Alignment} (if the @code{Alignment} is nonzero).
10717 @end quotation
10718
10719 @noindent
10720 An explicit size clause may be used to override the default size by
10721 increasing it.  For example, if we have:
10722
10723 @smallexample @c ada
10724    type My_Boolean is new Boolean;
10725    for My_Boolean'Size use 32;
10726 @end smallexample
10727
10728 @noindent
10729 then values of this type will always be 32 bits long.  In the case of
10730 discrete types, the size can be increased up to 64 bits, with the effect
10731 that the entire specified field is used to hold the value, sign- or
10732 zero-extended as appropriate.  If more than 64 bits is specified, then
10733 padding space is allocated after the value, and a warning is issued that
10734 there are unused bits.
10735
10736 Similarly the size of records and arrays may be increased, and the effect
10737 is to add padding bits after the value.  This also causes a warning message
10738 to be generated.
10739
10740 The largest Size value permitted in GNAT is 2**31@minus{}1.  Since this is a
10741 Size in bits, this corresponds to an object of size 256 megabytes (minus
10742 one).  This limitation is true on all targets.  The reason for this
10743 limitation is that it improves the quality of the code in many cases
10744 if it is known that a Size value can be accommodated in an object of
10745 type Integer.
10746
10747 @node Storage_Size Clauses
10748 @section Storage_Size Clauses
10749 @cindex Storage_Size Clause
10750
10751 @noindent
10752 For tasks, the @code{Storage_Size} clause specifies the amount of space
10753 to be allocated for the task stack.  This cannot be extended, and if the
10754 stack is exhausted, then @code{Storage_Error} will be raised (if stack
10755 checking is enabled).  Use a @code{Storage_Size} attribute definition clause,
10756 or a @code{Storage_Size} pragma in the task definition to set the
10757 appropriate required size.  A useful technique is to include in every
10758 task definition a pragma of the form:
10759
10760 @smallexample @c ada
10761    pragma Storage_Size (Default_Stack_Size);
10762 @end smallexample
10763
10764 @noindent
10765 Then @code{Default_Stack_Size} can be defined in a global package, and
10766 modified as required. Any tasks requiring stack sizes different from the
10767 default can have an appropriate alternative reference in the pragma.
10768
10769 You can also use the @option{-d} binder switch to modify the default stack
10770 size.
10771
10772 For access types, the @code{Storage_Size} clause specifies the maximum
10773 space available for allocation of objects of the type.  If this space is
10774 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
10775 In the case where the access type is declared local to a subprogram, the
10776 use of a @code{Storage_Size} clause triggers automatic use of a special
10777 predefined storage pool (@code{System.Pool_Size}) that ensures that all
10778 space for the pool is automatically reclaimed on exit from the scope in
10779 which the type is declared.
10780
10781 A special case recognized by the compiler is the specification of a
10782 @code{Storage_Size} of zero for an access type.  This means that no
10783 items can be allocated from the pool, and this is recognized at compile
10784 time, and all the overhead normally associated with maintaining a fixed
10785 size storage pool is eliminated.  Consider the following example:
10786
10787 @smallexample @c ada
10788    procedure p is
10789       type R is array (Natural) of Character;
10790       type P is access all R;
10791       for P'Storage_Size use 0;
10792       --  Above access type intended only for interfacing purposes
10793
10794       y : P;
10795
10796       procedure g (m : P);
10797       pragma Import (C, g);
10798
10799       --  @dots{}
10800
10801    begin
10802       --  @dots{}
10803       y := new R;
10804    end;
10805 @end smallexample
10806
10807 @noindent
10808 As indicated in this example, these dummy storage pools are often useful in
10809 connection with interfacing where no object will ever be allocated.  If you
10810 compile the above example, you get the warning:
10811
10812 @smallexample
10813    p.adb:16:09: warning: allocation from empty storage pool
10814    p.adb:16:09: warning: Storage_Error will be raised at run time
10815 @end smallexample
10816
10817 @noindent
10818 Of course in practice, there will not be any explicit allocators in the
10819 case of such an access declaration.
10820
10821 @node Size of Variant Record Objects
10822 @section Size of Variant Record Objects
10823 @cindex Size, variant record objects
10824 @cindex Variant record objects, size
10825
10826 @noindent
10827 In the case of variant record objects, there is a question whether Size gives
10828 information about a particular variant, or the maximum size required
10829 for any variant.  Consider the following program
10830
10831 @smallexample @c ada
10832 with Text_IO; use Text_IO;
10833 procedure q is
10834    type R1 (A : Boolean := False) is record
10835      case A is
10836        when True  => X : Character;
10837        when False => null;
10838      end case;
10839    end record;
10840
10841    V1 : R1 (False);
10842    V2 : R1;
10843
10844 begin
10845    Put_Line (Integer'Image (V1'Size));
10846    Put_Line (Integer'Image (V2'Size));
10847 end q;
10848 @end smallexample
10849
10850 @noindent
10851 Here we are dealing with a variant record, where the True variant
10852 requires 16 bits, and the False variant requires 8 bits.
10853 In the above example, both V1 and V2 contain the False variant,
10854 which is only 8 bits long.  However, the result of running the
10855 program is:
10856
10857 @smallexample
10858 8
10859 16
10860 @end smallexample
10861
10862 @noindent
10863 The reason for the difference here is that the discriminant value of
10864 V1 is fixed, and will always be False.  It is not possible to assign
10865 a True variant value to V1, therefore 8 bits is sufficient.  On the
10866 other hand, in the case of V2, the initial discriminant value is
10867 False (from the default), but it is possible to assign a True
10868 variant value to V2, therefore 16 bits must be allocated for V2
10869 in the general case, even fewer bits may be needed at any particular
10870 point during the program execution.
10871
10872 As can be seen from the output of this program, the @code{'Size}
10873 attribute applied to such an object in GNAT gives the actual allocated
10874 size of the variable, which is the largest size of any of the variants.
10875 The Ada Reference Manual is not completely clear on what choice should
10876 be made here, but the GNAT behavior seems most consistent with the
10877 language in the RM@.
10878
10879 In some cases, it may be desirable to obtain the size of the current
10880 variant, rather than the size of the largest variant.  This can be
10881 achieved in GNAT by making use of the fact that in the case of a
10882 subprogram parameter, GNAT does indeed return the size of the current
10883 variant (because a subprogram has no way of knowing how much space
10884 is actually allocated for the actual).
10885
10886 Consider the following modified version of the above program:
10887
10888 @smallexample @c ada
10889 with Text_IO; use Text_IO;
10890 procedure q is
10891    type R1 (A : Boolean := False) is record
10892      case A is
10893        when True  => X : Character;
10894        when False => null;
10895      end case;
10896    end record;
10897
10898    V2 : R1;
10899
10900    function Size (V : R1) return Integer is
10901    begin
10902       return V'Size;
10903    end Size;
10904
10905 begin
10906    Put_Line (Integer'Image (V2'Size));
10907    Put_Line (Integer'IMage (Size (V2)));
10908    V2 := (True, 'x');
10909    Put_Line (Integer'Image (V2'Size));
10910    Put_Line (Integer'IMage (Size (V2)));
10911 end q;
10912 @end smallexample
10913
10914 @noindent
10915 The output from this program is
10916
10917 @smallexample
10918 16
10919 8
10920 16
10921 16
10922 @end smallexample
10923
10924 @noindent
10925 Here we see that while the @code{'Size} attribute always returns
10926 the maximum size, regardless of the current variant value, the
10927 @code{Size} function does indeed return the size of the current
10928 variant value.
10929
10930 @node Biased Representation
10931 @section Biased Representation
10932 @cindex Size for biased representation
10933 @cindex Biased representation
10934
10935 @noindent
10936 In the case of scalars with a range starting at other than zero, it is
10937 possible in some cases to specify a size smaller than the default minimum
10938 value, and in such cases, GNAT uses an unsigned biased representation,
10939 in which zero is used to represent the lower bound, and successive values
10940 represent successive values of the type.
10941
10942 For example, suppose we have the declaration:
10943
10944 @smallexample @c ada
10945    type Small is range -7 .. -4;
10946    for Small'Size use 2;
10947 @end smallexample
10948
10949 @noindent
10950 Although the default size of type @code{Small} is 4, the @code{Size}
10951 clause is accepted by GNAT and results in the following representation
10952 scheme:
10953
10954 @smallexample
10955   -7 is represented as 2#00#
10956   -6 is represented as 2#01#
10957   -5 is represented as 2#10#
10958   -4 is represented as 2#11#
10959 @end smallexample
10960
10961 @noindent
10962 Biased representation is only used if the specified @code{Size} clause
10963 cannot be accepted in any other manner.  These reduced sizes that force
10964 biased representation can be used for all discrete types except for
10965 enumeration types for which a representation clause is given.
10966
10967 @node Value_Size and Object_Size Clauses
10968 @section Value_Size and Object_Size Clauses
10969 @findex Value_Size
10970 @findex Object_Size
10971 @cindex Size, of objects
10972
10973 @noindent
10974 In Ada 95 and Ada 2005, @code{T'Size} for a type @code{T} is the minimum
10975 number of bits required to hold values of type @code{T}.
10976 Although this interpretation was allowed in Ada 83, it was not required,
10977 and this requirement in practice can cause some significant difficulties.
10978 For example, in most Ada 83 compilers, @code{Natural'Size} was 32.
10979 However, in Ada 95 and Ada 2005,
10980 @code{Natural'Size} is
10981 typically 31.  This means that code may change in behavior when moving
10982 from Ada 83 to Ada 95 or Ada 2005.  For example, consider:
10983
10984 @smallexample @c ada
10985    type Rec is record;
10986       A : Natural;
10987       B : Natural;
10988    end record;
10989
10990    for Rec use record
10991       at 0  range 0 .. Natural'Size - 1;
10992       at 0  range Natural'Size .. 2 * Natural'Size - 1;
10993    end record;
10994 @end smallexample
10995
10996 @noindent
10997 In the above code, since the typical size of @code{Natural} objects
10998 is 32 bits and @code{Natural'Size} is 31, the above code can cause
10999 unexpected inefficient packing in Ada 95 and Ada 2005, and in general
11000 there are cases where the fact that the object size can exceed the
11001 size of the type causes surprises.
11002
11003 To help get around this problem GNAT provides two implementation
11004 defined attributes, @code{Value_Size} and @code{Object_Size}.  When
11005 applied to a type, these attributes yield the size of the type
11006 (corresponding to the RM defined size attribute), and the size of
11007 objects of the type respectively.
11008
11009 The @code{Object_Size} is used for determining the default size of
11010 objects and components.  This size value can be referred to using the
11011 @code{Object_Size} attribute.  The phrase ``is used'' here means that it is
11012 the basis of the determination of the size.  The backend is free to
11013 pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
11014 character might be stored in 32 bits on a machine with no efficient
11015 byte access instructions such as the Alpha.
11016
11017 The default rules for the value of @code{Object_Size} for
11018 discrete types are as follows:
11019
11020 @itemize @bullet
11021 @item
11022 The @code{Object_Size} for base subtypes reflect the natural hardware
11023 size in bits (run the compiler with @option{-gnatS} to find those values
11024 for numeric types). Enumeration types and fixed-point base subtypes have
11025 8, 16, 32 or 64 bits for this size, depending on the range of values
11026 to be stored.
11027
11028 @item
11029 The @code{Object_Size} of a subtype is the same as the
11030 @code{Object_Size} of
11031 the type from which it is obtained.
11032
11033 @item
11034 The @code{Object_Size} of a derived base type is copied from the parent
11035 base type, and the @code{Object_Size} of a derived first subtype is copied
11036 from the parent first subtype.
11037 @end itemize
11038
11039 @noindent
11040 The @code{Value_Size} attribute
11041 is the (minimum) number of bits required to store a value
11042 of the type.
11043 This value is used to determine how tightly to pack
11044 records or arrays with components of this type, and also affects
11045 the semantics of unchecked conversion (unchecked conversions where
11046 the @code{Value_Size} values differ generate a warning, and are potentially
11047 target dependent).
11048
11049 The default rules for the value of @code{Value_Size} are as follows:
11050
11051 @itemize @bullet
11052 @item
11053 The @code{Value_Size} for a base subtype is the minimum number of bits
11054 required to store all values of the type (including the sign bit
11055 only if negative values are possible).
11056
11057 @item
11058 If a subtype statically matches the first subtype of a given type, then it has
11059 by default the same @code{Value_Size} as the first subtype.  This is a
11060 consequence of RM 13.1(14) (``if two subtypes statically match,
11061 then their subtype-specific aspects are the same''.)
11062
11063 @item
11064 All other subtypes have a @code{Value_Size} corresponding to the minimum
11065 number of bits required to store all values of the subtype.  For
11066 dynamic bounds, it is assumed that the value can range down or up
11067 to the corresponding bound of the ancestor
11068 @end itemize
11069
11070 @noindent
11071 The RM defined attribute @code{Size} corresponds to the
11072 @code{Value_Size} attribute.
11073
11074 The @code{Size} attribute may be defined for a first-named subtype.  This sets
11075 the @code{Value_Size} of
11076 the first-named subtype to the given value, and the
11077 @code{Object_Size} of this first-named subtype to the given value padded up
11078 to an appropriate boundary.  It is a consequence of the default rules
11079 above that this @code{Object_Size} will apply to all further subtypes.  On the
11080 other hand, @code{Value_Size} is affected only for the first subtype, any
11081 dynamic subtypes obtained from it directly, and any statically matching
11082 subtypes.  The @code{Value_Size} of any other static subtypes is not affected.
11083
11084 @code{Value_Size} and
11085 @code{Object_Size} may be explicitly set for any subtype using
11086 an attribute definition clause.  Note that the use of these attributes
11087 can cause the RM 13.1(14) rule to be violated.  If two access types
11088 reference aliased objects whose subtypes have differing @code{Object_Size}
11089 values as a result of explicit attribute definition clauses, then it
11090 is erroneous to convert from one access subtype to the other.
11091
11092 At the implementation level, Esize stores the Object_Size and the
11093 RM_Size field stores the @code{Value_Size} (and hence the value of the
11094 @code{Size} attribute,
11095 which, as noted above, is equivalent to @code{Value_Size}).
11096
11097 To get a feel for the difference, consider the following examples (note
11098 that in each case the base is @code{Short_Short_Integer} with a size of 8):
11099
11100 @smallexample
11101                                        Object_Size     Value_Size
11102
11103 type x1 is range 0 .. 5;                    8               3
11104
11105 type x2 is range 0 .. 5;
11106 for x2'size use 12;                        16              12
11107
11108 subtype x3 is x2 range 0 .. 3;             16               2
11109
11110 subtype x4 is x2'base range 0 .. 10;        8               4
11111
11112 subtype x5 is x2 range 0 .. dynamic;       16               3*
11113
11114 subtype x6 is x2'base range 0 .. dynamic;   8               3*
11115
11116 @end smallexample
11117
11118 @noindent
11119 Note: the entries marked ``3*'' are not actually specified by the Ada
11120 Reference Manual, but it seems in the spirit of the RM rules to allocate
11121 the minimum number of bits (here 3, given the range for @code{x2})
11122 known to be large enough to hold the given range of values.
11123
11124 So far, so good, but GNAT has to obey the RM rules, so the question is
11125 under what conditions must the RM @code{Size} be used.
11126 The following is a list
11127 of the occasions on which the RM @code{Size} must be used:
11128
11129 @itemize @bullet
11130 @item
11131 Component size for packed arrays or records
11132
11133 @item
11134 Value of the attribute @code{Size} for a type
11135
11136 @item
11137 Warning about sizes not matching for unchecked conversion
11138 @end itemize
11139
11140 @noindent
11141 For record types, the @code{Object_Size} is always a multiple of the
11142 alignment of the type (this is true for all types). In some cases the
11143 @code{Value_Size} can be smaller. Consider:
11144
11145 @smallexample
11146    type R is record
11147      X : Integer;
11148      Y : Character;
11149    end record;
11150 @end smallexample
11151
11152 @noindent
11153 On a typical 32-bit architecture, the X component will be four bytes, and
11154 require four-byte alignment, and the Y component will be one byte. In this
11155 case @code{R'Value_Size} will be 40 (bits) since this is the minimum size
11156 required to store a value of this type, and for example, it is permissible
11157 to have a component of type R in an outer array whose component size is
11158 specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits),
11159 since it must be rounded up so that this value is a multiple of the
11160 alignment (4 bytes = 32 bits).
11161
11162 @noindent
11163 For all other types, the @code{Object_Size}
11164 and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
11165 Only @code{Size} may be specified for such types.
11166
11167 @node Component_Size Clauses
11168 @section Component_Size Clauses
11169 @cindex Component_Size Clause
11170
11171 @noindent
11172 Normally, the value specified in a component size clause must be consistent
11173 with the subtype of the array component with regard to size and alignment.
11174 In other words, the value specified must be at least equal to the size
11175 of this subtype, and must be a multiple of the alignment value.
11176
11177 In addition, component size clauses are allowed which cause the array
11178 to be packed, by specifying a smaller value.  A first case is for
11179 component size values in the range 1 through 63.  The value specified
11180 must not be smaller than the Size of the subtype.  GNAT will accurately
11181 honor all packing requests in this range.  For example, if we have:
11182
11183 @smallexample @c ada
11184 type r is array (1 .. 8) of Natural;
11185 for r'Component_Size use 31;
11186 @end smallexample
11187
11188 @noindent
11189 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
11190 Of course access to the components of such an array is considerably
11191 less efficient than if the natural component size of 32 is used.
11192 A second case is when the subtype of the component is a record type
11193 padded because of its default alignment.  For example, if we have:
11194
11195 @smallexample @c ada
11196 type r is record
11197   i : Integer;
11198   j : Integer;
11199   b : Boolean;
11200 end record;
11201
11202 type a is array (1 .. 8) of r;
11203 for a'Component_Size use 72;
11204 @end smallexample
11205
11206 @noindent
11207 then the resulting array has a length of 72 bytes, instead of 96 bytes
11208 if the alignment of the record (4) was obeyed.
11209
11210 Note that there is no point in giving both a component size clause
11211 and a pragma Pack for the same array type. if such duplicate
11212 clauses are given, the pragma Pack will be ignored.
11213
11214 @node Bit_Order Clauses
11215 @section Bit_Order Clauses
11216 @cindex Bit_Order Clause
11217 @cindex bit ordering
11218 @cindex ordering, of bits
11219
11220 @noindent
11221 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
11222 attribute.  The specification may either correspond to the default bit
11223 order for the target, in which case the specification has no effect and
11224 places no additional restrictions, or it may be for the non-standard
11225 setting (that is the opposite of the default).
11226
11227 In the case where the non-standard value is specified, the effect is
11228 to renumber bits within each byte, but the ordering of bytes is not
11229 affected.  There are certain
11230 restrictions placed on component clauses as follows:
11231
11232 @itemize @bullet
11233
11234 @item Components fitting within a single storage unit.
11235 @noindent
11236 These are unrestricted, and the effect is merely to renumber bits.  For
11237 example if we are on a little-endian machine with @code{Low_Order_First}
11238 being the default, then the following two declarations have exactly
11239 the same effect:
11240
11241 @smallexample @c ada
11242    type R1 is record
11243       A : Boolean;
11244       B : Integer range 1 .. 120;
11245    end record;
11246
11247    for R1 use record
11248       A at 0 range 0 .. 0;
11249       B at 0 range 1 .. 7;
11250    end record;
11251
11252    type R2 is record
11253       A : Boolean;
11254       B : Integer range 1 .. 120;
11255    end record;
11256
11257    for R2'Bit_Order use High_Order_First;
11258
11259    for R2 use record
11260       A at 0 range 7 .. 7;
11261       B at 0 range 0 .. 6;
11262    end record;
11263 @end smallexample
11264
11265 @noindent
11266 The useful application here is to write the second declaration with the
11267 @code{Bit_Order} attribute definition clause, and know that it will be treated
11268 the same, regardless of whether the target is little-endian or big-endian.
11269
11270 @item Components occupying an integral number of bytes.
11271 @noindent
11272 These are components that exactly fit in two or more bytes.  Such component
11273 declarations are allowed, but have no effect, since it is important to realize
11274 that the @code{Bit_Order} specification does not affect the ordering of bytes.
11275 In particular, the following attempt at getting an endian-independent integer
11276 does not work:
11277
11278 @smallexample @c ada
11279    type R2 is record
11280       A : Integer;
11281    end record;
11282
11283    for R2'Bit_Order use High_Order_First;
11284
11285    for R2 use record
11286       A at 0 range 0 .. 31;
11287    end record;
11288 @end smallexample
11289
11290 @noindent
11291 This declaration will result in a little-endian integer on a
11292 little-endian machine, and a big-endian integer on a big-endian machine.
11293 If byte flipping is required for interoperability between big- and
11294 little-endian machines, this must be explicitly programmed.  This capability
11295 is not provided by @code{Bit_Order}.
11296
11297 @item Components that are positioned across byte boundaries
11298 @noindent
11299 but do not occupy an integral number of bytes.  Given that bytes are not
11300 reordered, such fields would occupy a non-contiguous sequence of bits
11301 in memory, requiring non-trivial code to reassemble.  They are for this
11302 reason not permitted, and any component clause specifying such a layout
11303 will be flagged as illegal by GNAT@.
11304
11305 @end itemize
11306
11307 @noindent
11308 Since the misconception that Bit_Order automatically deals with all
11309 endian-related incompatibilities is a common one, the specification of
11310 a component field that is an integral number of bytes will always
11311 generate a warning.  This warning may be suppressed using @code{pragma
11312 Warnings (Off)} if desired.  The following section contains additional
11313 details regarding the issue of byte ordering.
11314
11315 @node Effect of Bit_Order on Byte Ordering
11316 @section Effect of Bit_Order on Byte Ordering
11317 @cindex byte ordering
11318 @cindex ordering, of bytes
11319
11320 @noindent
11321 In this section we will review the effect of the @code{Bit_Order} attribute
11322 definition clause on byte ordering.  Briefly, it has no effect at all, but
11323 a detailed example will be helpful.  Before giving this
11324 example, let us review the precise
11325 definition of the effect of defining @code{Bit_Order}.  The effect of a
11326 non-standard bit order is described in section 15.5.3 of the Ada
11327 Reference Manual:
11328
11329 @quotation
11330 2   A bit ordering is a method of interpreting the meaning of
11331 the storage place attributes.
11332 @end quotation
11333
11334 @noindent
11335 To understand the precise definition of storage place attributes in
11336 this context, we visit section 13.5.1 of the manual:
11337
11338 @quotation
11339 13   A record_representation_clause (without the mod_clause)
11340 specifies the layout.  The storage place attributes (see 13.5.2)
11341 are taken from the values of the position, first_bit, and last_bit
11342 expressions after normalizing those values so that first_bit is
11343 less than Storage_Unit.
11344 @end quotation
11345
11346 @noindent
11347 The critical point here is that storage places are taken from
11348 the values after normalization, not before.  So the @code{Bit_Order}
11349 interpretation applies to normalized values.  The interpretation
11350 is described in the later part of the 15.5.3 paragraph:
11351
11352 @quotation
11353 2   A bit ordering is a method of interpreting the meaning of
11354 the storage place attributes.  High_Order_First (known in the
11355 vernacular as ``big endian'') means that the first bit of a
11356 storage element (bit 0) is the most significant bit (interpreting
11357 the sequence of bits that represent a component as an unsigned
11358 integer value).  Low_Order_First (known in the vernacular as
11359 ``little endian'') means the opposite: the first bit is the
11360 least significant.
11361 @end quotation
11362
11363 @noindent
11364 Note that the numbering is with respect to the bits of a storage
11365 unit.  In other words, the specification affects only the numbering
11366 of bits within a single storage unit.
11367
11368 We can make the effect clearer by giving an example.
11369
11370 Suppose that we have an external device which presents two bytes, the first
11371 byte presented, which is the first (low addressed byte) of the two byte
11372 record is called Master, and the second byte is called Slave.
11373
11374 The left most (most significant bit is called Control for each byte, and
11375 the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
11376 (least significant) bit.
11377
11378 On a big-endian machine, we can write the following representation clause
11379
11380 @smallexample @c ada
11381    type Data is record
11382       Master_Control : Bit;
11383       Master_V1      : Bit;
11384       Master_V2      : Bit;
11385       Master_V3      : Bit;
11386       Master_V4      : Bit;
11387       Master_V5      : Bit;
11388       Master_V6      : Bit;
11389       Master_V7      : Bit;
11390       Slave_Control  : Bit;
11391       Slave_V1       : Bit;
11392       Slave_V2       : Bit;
11393       Slave_V3       : Bit;
11394       Slave_V4       : Bit;
11395       Slave_V5       : Bit;
11396       Slave_V6       : Bit;
11397       Slave_V7       : Bit;
11398    end record;
11399
11400    for Data use record
11401       Master_Control at 0 range 0 .. 0;
11402       Master_V1      at 0 range 1 .. 1;
11403       Master_V2      at 0 range 2 .. 2;
11404       Master_V3      at 0 range 3 .. 3;
11405       Master_V4      at 0 range 4 .. 4;
11406       Master_V5      at 0 range 5 .. 5;
11407       Master_V6      at 0 range 6 .. 6;
11408       Master_V7      at 0 range 7 .. 7;
11409       Slave_Control  at 1 range 0 .. 0;
11410       Slave_V1       at 1 range 1 .. 1;
11411       Slave_V2       at 1 range 2 .. 2;
11412       Slave_V3       at 1 range 3 .. 3;
11413       Slave_V4       at 1 range 4 .. 4;
11414       Slave_V5       at 1 range 5 .. 5;
11415       Slave_V6       at 1 range 6 .. 6;
11416       Slave_V7       at 1 range 7 .. 7;
11417    end record;
11418 @end smallexample
11419
11420 @noindent
11421 Now if we move this to a little endian machine, then the bit ordering within
11422 the byte is backwards, so we have to rewrite the record rep clause as:
11423
11424 @smallexample @c ada
11425    for Data use record
11426       Master_Control at 0 range 7 .. 7;
11427       Master_V1      at 0 range 6 .. 6;
11428       Master_V2      at 0 range 5 .. 5;
11429       Master_V3      at 0 range 4 .. 4;
11430       Master_V4      at 0 range 3 .. 3;
11431       Master_V5      at 0 range 2 .. 2;
11432       Master_V6      at 0 range 1 .. 1;
11433       Master_V7      at 0 range 0 .. 0;
11434       Slave_Control  at 1 range 7 .. 7;
11435       Slave_V1       at 1 range 6 .. 6;
11436       Slave_V2       at 1 range 5 .. 5;
11437       Slave_V3       at 1 range 4 .. 4;
11438       Slave_V4       at 1 range 3 .. 3;
11439       Slave_V5       at 1 range 2 .. 2;
11440       Slave_V6       at 1 range 1 .. 1;
11441       Slave_V7       at 1 range 0 .. 0;
11442    end record;
11443 @end smallexample
11444
11445 @noindent
11446 It is a nuisance to have to rewrite the clause, especially if
11447 the code has to be maintained on both machines.  However,
11448 this is a case that we can handle with the
11449 @code{Bit_Order} attribute if it is implemented.
11450 Note that the implementation is not required on byte addressed
11451 machines, but it is indeed implemented in GNAT.
11452 This means that we can simply use the
11453 first record clause, together with the declaration
11454
11455 @smallexample @c ada
11456    for Data'Bit_Order use High_Order_First;
11457 @end smallexample
11458
11459 @noindent
11460 and the effect is what is desired, namely the layout is exactly the same,
11461 independent of whether the code is compiled on a big-endian or little-endian
11462 machine.
11463
11464 The important point to understand is that byte ordering is not affected.
11465 A @code{Bit_Order} attribute definition never affects which byte a field
11466 ends up in, only where it ends up in that byte.
11467 To make this clear, let us rewrite the record rep clause of the previous
11468 example as:
11469
11470 @smallexample @c ada
11471    for Data'Bit_Order use High_Order_First;
11472    for Data use record
11473       Master_Control at 0 range  0 .. 0;
11474       Master_V1      at 0 range  1 .. 1;
11475       Master_V2      at 0 range  2 .. 2;
11476       Master_V3      at 0 range  3 .. 3;
11477       Master_V4      at 0 range  4 .. 4;
11478       Master_V5      at 0 range  5 .. 5;
11479       Master_V6      at 0 range  6 .. 6;
11480       Master_V7      at 0 range  7 .. 7;
11481       Slave_Control  at 0 range  8 .. 8;
11482       Slave_V1       at 0 range  9 .. 9;
11483       Slave_V2       at 0 range 10 .. 10;
11484       Slave_V3       at 0 range 11 .. 11;
11485       Slave_V4       at 0 range 12 .. 12;
11486       Slave_V5       at 0 range 13 .. 13;
11487       Slave_V6       at 0 range 14 .. 14;
11488       Slave_V7       at 0 range 15 .. 15;
11489    end record;
11490 @end smallexample
11491
11492 @noindent
11493 This is exactly equivalent to saying (a repeat of the first example):
11494
11495 @smallexample @c ada
11496    for Data'Bit_Order use High_Order_First;
11497    for Data use record
11498       Master_Control at 0 range 0 .. 0;
11499       Master_V1      at 0 range 1 .. 1;
11500       Master_V2      at 0 range 2 .. 2;
11501       Master_V3      at 0 range 3 .. 3;
11502       Master_V4      at 0 range 4 .. 4;
11503       Master_V5      at 0 range 5 .. 5;
11504       Master_V6      at 0 range 6 .. 6;
11505       Master_V7      at 0 range 7 .. 7;
11506       Slave_Control  at 1 range 0 .. 0;
11507       Slave_V1       at 1 range 1 .. 1;
11508       Slave_V2       at 1 range 2 .. 2;
11509       Slave_V3       at 1 range 3 .. 3;
11510       Slave_V4       at 1 range 4 .. 4;
11511       Slave_V5       at 1 range 5 .. 5;
11512       Slave_V6       at 1 range 6 .. 6;
11513       Slave_V7       at 1 range 7 .. 7;
11514    end record;
11515 @end smallexample
11516
11517 @noindent
11518 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
11519 field.  The storage place attributes are obtained by normalizing the
11520 values given so that the @code{First_Bit} value is less than 8.  After
11521 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
11522 we specified in the other case.
11523
11524 Now one might expect that the @code{Bit_Order} attribute might affect
11525 bit numbering within the entire record component (two bytes in this
11526 case, thus affecting which byte fields end up in), but that is not
11527 the way this feature is defined, it only affects numbering of bits,
11528 not which byte they end up in.
11529
11530 Consequently it never makes sense to specify a starting bit number
11531 greater than 7 (for a byte addressable field) if an attribute
11532 definition for @code{Bit_Order} has been given, and indeed it
11533 may be actively confusing to specify such a value, so the compiler
11534 generates a warning for such usage.
11535
11536 If you do need to control byte ordering then appropriate conditional
11537 values must be used.  If in our example, the slave byte came first on
11538 some machines we might write:
11539
11540 @smallexample @c ada
11541    Master_Byte_First constant Boolean := @dots{};
11542
11543    Master_Byte : constant Natural :=
11544                    1 - Boolean'Pos (Master_Byte_First);
11545    Slave_Byte  : constant Natural :=
11546                    Boolean'Pos (Master_Byte_First);
11547
11548    for Data'Bit_Order use High_Order_First;
11549    for Data use record
11550       Master_Control at Master_Byte range 0 .. 0;
11551       Master_V1      at Master_Byte range 1 .. 1;
11552       Master_V2      at Master_Byte range 2 .. 2;
11553       Master_V3      at Master_Byte range 3 .. 3;
11554       Master_V4      at Master_Byte range 4 .. 4;
11555       Master_V5      at Master_Byte range 5 .. 5;
11556       Master_V6      at Master_Byte range 6 .. 6;
11557       Master_V7      at Master_Byte range 7 .. 7;
11558       Slave_Control  at Slave_Byte  range 0 .. 0;
11559       Slave_V1       at Slave_Byte  range 1 .. 1;
11560       Slave_V2       at Slave_Byte  range 2 .. 2;
11561       Slave_V3       at Slave_Byte  range 3 .. 3;
11562       Slave_V4       at Slave_Byte  range 4 .. 4;
11563       Slave_V5       at Slave_Byte  range 5 .. 5;
11564       Slave_V6       at Slave_Byte  range 6 .. 6;
11565       Slave_V7       at Slave_Byte  range 7 .. 7;
11566    end record;
11567 @end smallexample
11568
11569 @noindent
11570 Now to switch between machines, all that is necessary is
11571 to set the boolean constant @code{Master_Byte_First} in
11572 an appropriate manner.
11573
11574 @node Pragma Pack for Arrays
11575 @section Pragma Pack for Arrays
11576 @cindex Pragma Pack (for arrays)
11577
11578 @noindent
11579 Pragma @code{Pack} applied to an array has no effect unless the component type
11580 is packable.  For a component type to be packable, it must be one of the
11581 following cases:
11582
11583 @itemize @bullet
11584 @item
11585 Any scalar type
11586 @item
11587 Any type whose size is specified with a size clause
11588 @item
11589 Any packed array type with a static size
11590 @item
11591 Any record type padded because of its default alignment
11592 @end itemize
11593
11594 @noindent
11595 For all these cases, if the component subtype size is in the range
11596 1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
11597 component size were specified giving the component subtype size.
11598 For example if we have:
11599
11600 @smallexample @c ada
11601    type r is range 0 .. 17;
11602
11603    type ar is array (1 .. 8) of r;
11604    pragma Pack (ar);
11605 @end smallexample
11606
11607 @noindent
11608 Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
11609 and the size of the array @code{ar} will be exactly 40 bits.
11610
11611 Note that in some cases this rather fierce approach to packing can produce
11612 unexpected effects.  For example, in Ada 95 and Ada 2005,
11613 subtype @code{Natural} typically has a size of 31, meaning that if you
11614 pack an array of @code{Natural}, you get 31-bit
11615 close packing, which saves a few bits, but results in far less efficient
11616 access.  Since many other Ada compilers will ignore such a packing request,
11617 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
11618 might not be what is intended.  You can easily remove this warning by
11619 using an explicit @code{Component_Size} setting instead, which never generates
11620 a warning, since the intention of the programmer is clear in this case.
11621
11622 GNAT treats packed arrays in one of two ways.  If the size of the array is
11623 known at compile time and is less than 64 bits, then internally the array
11624 is represented as a single modular type, of exactly the appropriate number
11625 of bits.  If the length is greater than 63 bits, or is not known at compile
11626 time, then the packed array is represented as an array of bytes, and the
11627 length is always a multiple of 8 bits.
11628
11629 Note that to represent a packed array as a modular type, the alignment must
11630 be suitable for the modular type involved. For example, on typical machines
11631 a 32-bit packed array will be represented by a 32-bit modular integer with
11632 an alignment of four bytes. If you explicitly override the default alignment
11633 with an alignment clause that is too small, the modular representation
11634 cannot be used. For example, consider the following set of declarations:
11635
11636 @smallexample @c ada
11637    type R is range 1 .. 3;
11638    type S is array (1 .. 31) of R;
11639    for S'Component_Size use 2;
11640    for S'Size use 62;
11641    for S'Alignment use 1;
11642 @end smallexample
11643
11644 @noindent
11645 If the alignment clause were not present, then a 62-bit modular
11646 representation would be chosen (typically with an alignment of 4 or 8
11647 bytes depending on the target). But the default alignment is overridden
11648 with the explicit alignment clause. This means that the modular
11649 representation cannot be used, and instead the array of bytes
11650 representation must be used, meaning that the length must be a multiple
11651 of 8. Thus the above set of declarations will result in a diagnostic
11652 rejecting the size clause and noting that the minimum size allowed is 64.
11653
11654 @cindex Pragma Pack (for type Natural)
11655 @cindex Pragma Pack warning
11656
11657 One special case that is worth noting occurs when the base type of the
11658 component size is 8/16/32 and the subtype is one bit less. Notably this
11659 occurs with subtype @code{Natural}. Consider:
11660
11661 @smallexample @c ada
11662    type Arr is array (1 .. 32) of Natural;
11663    pragma Pack (Arr);
11664 @end smallexample
11665
11666 @noindent
11667 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
11668 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
11669 Ada 83 compilers did not attempt 31 bit packing.
11670
11671 In Ada 95 and Ada 2005, @code{Natural'Size} is required to be 31. Furthermore,
11672 GNAT really does pack 31-bit subtype to 31 bits. This may result in a
11673 substantial unintended performance penalty when porting legacy Ada 83 code.
11674 To help prevent this, GNAT generates a warning in such cases. If you really
11675 want 31 bit packing in a case like this, you can set the component size
11676 explicitly:
11677
11678 @smallexample @c ada
11679    type Arr is array (1 .. 32) of Natural;
11680    for Arr'Component_Size use 31;
11681 @end smallexample
11682
11683 @noindent
11684 Here 31-bit packing is achieved as required, and no warning is generated,
11685 since in this case the programmer intention is clear.
11686
11687 @node Pragma Pack for Records
11688 @section Pragma Pack for Records
11689 @cindex Pragma Pack (for records)
11690
11691 @noindent
11692 Pragma @code{Pack} applied to a record will pack the components to reduce
11693 wasted space from alignment gaps and by reducing the amount of space
11694 taken by components.  We distinguish between @emph{packable} components and
11695 @emph{non-packable} components.
11696 Components of the following types are considered packable:
11697 @itemize @bullet
11698 @item
11699 All primitive types are packable.
11700
11701 @item
11702 Small packed arrays, whose size does not exceed 64 bits, and where the
11703 size is statically known at compile time, are represented internally
11704 as modular integers, and so they are also packable.
11705
11706 @end itemize
11707
11708 @noindent
11709 All packable components occupy the exact number of bits corresponding to
11710 their @code{Size} value, and are packed with no padding bits, i.e.@: they
11711 can start on an arbitrary bit boundary.
11712
11713 All other types are non-packable, they occupy an integral number of
11714 storage units, and
11715 are placed at a boundary corresponding to their alignment requirements.
11716
11717 For example, consider the record
11718
11719 @smallexample @c ada
11720    type Rb1 is array (1 .. 13) of Boolean;
11721    pragma Pack (rb1);
11722
11723    type Rb2 is array (1 .. 65) of Boolean;
11724    pragma Pack (rb2);
11725
11726    type x2 is record
11727       l1 : Boolean;
11728       l2 : Duration;
11729       l3 : Float;
11730       l4 : Boolean;
11731       l5 : Rb1;
11732       l6 : Rb2;
11733    end record;
11734    pragma Pack (x2);
11735 @end smallexample
11736
11737 @noindent
11738 The representation for the record x2 is as follows:
11739
11740 @smallexample @c ada
11741 for x2'Size use 224;
11742 for x2 use record
11743    l1 at  0 range  0 .. 0;
11744    l2 at  0 range  1 .. 64;
11745    l3 at 12 range  0 .. 31;
11746    l4 at 16 range  0 .. 0;
11747    l5 at 16 range  1 .. 13;
11748    l6 at 18 range  0 .. 71;
11749 end record;
11750 @end smallexample
11751
11752 @noindent
11753 Studying this example, we see that the packable fields @code{l1}
11754 and @code{l2} are
11755 of length equal to their sizes, and placed at specific bit boundaries (and
11756 not byte boundaries) to
11757 eliminate padding.  But @code{l3} is of a non-packable float type, so
11758 it is on the next appropriate alignment boundary.
11759
11760 The next two fields are fully packable, so @code{l4} and @code{l5} are
11761 minimally packed with no gaps.  However, type @code{Rb2} is a packed
11762 array that is longer than 64 bits, so it is itself non-packable.  Thus
11763 the @code{l6} field is aligned to the next byte boundary, and takes an
11764 integral number of bytes, i.e.@: 72 bits.
11765
11766 @node Record Representation Clauses
11767 @section Record Representation Clauses
11768 @cindex Record Representation Clause
11769
11770 @noindent
11771 Record representation clauses may be given for all record types, including
11772 types obtained by record extension.  Component clauses are allowed for any
11773 static component.  The restrictions on component clauses depend on the type
11774 of the component.
11775
11776 @cindex Component Clause
11777 For all components of an elementary type, the only restriction on component
11778 clauses is that the size must be at least the 'Size value of the type
11779 (actually the Value_Size).  There are no restrictions due to alignment,
11780 and such components may freely cross storage boundaries.
11781
11782 Packed arrays with a size up to and including 64 bits are represented
11783 internally using a modular type with the appropriate number of bits, and
11784 thus the same lack of restriction applies.  For example, if you declare:
11785
11786 @smallexample @c ada
11787    type R is array (1 .. 49) of Boolean;
11788    pragma Pack (R);
11789    for R'Size use 49;
11790 @end smallexample
11791
11792 @noindent
11793 then a component clause for a component of type R may start on any
11794 specified bit boundary, and may specify a value of 49 bits or greater.
11795
11796 For packed bit arrays that are longer than 64 bits, there are two
11797 cases. If the component size is a power of 2 (1,2,4,8,16,32 bits),
11798 including the important case of single bits or boolean values, then
11799 there are no limitations on placement of such components, and they
11800 may start and end at arbitrary bit boundaries.
11801
11802 If the component size is not a power of 2 (e.g.@: 3 or 5), then
11803 an array of this type longer than 64 bits must always be placed on
11804 on a storage unit (byte) boundary and occupy an integral number
11805 of storage units (bytes). Any component clause that does not
11806 meet this requirement will be rejected.
11807
11808 Any aliased component, or component of an aliased type, must
11809 have its normal alignment and size. A component clause that
11810 does not meet this requirement will be rejected.
11811
11812 The tag field of a tagged type always occupies an address sized field at
11813 the start of the record.  No component clause may attempt to overlay this
11814 tag. When a tagged type appears as a component, the tag field must have
11815 proper alignment
11816
11817 In the case of a record extension T1, of a type T, no component clause applied
11818 to the type T1 can specify a storage location that would overlap the first
11819 T'Size bytes of the record.
11820
11821 For all other component types, including non-bit-packed arrays,
11822 the component can be placed at an arbitrary bit boundary,
11823 so for example, the following is permitted:
11824
11825 @smallexample @c ada
11826    type R is array (1 .. 10) of Boolean;
11827    for R'Size use 80;
11828
11829    type Q is record
11830       G, H : Boolean;
11831       L, M : R;
11832    end record;
11833
11834    for Q use record
11835       G at 0 range  0 ..   0;
11836       H at 0 range  1 ..   1;
11837       L at 0 range  2 ..  81;
11838       R at 0 range 82 .. 161;
11839    end record;
11840 @end smallexample
11841
11842 @noindent
11843 Note: the above rules apply to recent releases of GNAT 5.
11844 In GNAT 3, there are more severe restrictions on larger components.
11845 For non-primitive types, including packed arrays with a size greater than
11846 64 bits, component clauses must respect the alignment requirement of the
11847 type, in particular, always starting on a byte boundary, and the length
11848 must be a multiple of the storage unit.
11849
11850 @node Enumeration Clauses
11851 @section Enumeration Clauses
11852
11853 The only restriction on enumeration clauses is that the range of values
11854 must be representable.  For the signed case, if one or more of the
11855 representation values are negative, all values must be in the range:
11856
11857 @smallexample @c ada
11858    System.Min_Int .. System.Max_Int
11859 @end smallexample
11860
11861 @noindent
11862 For the unsigned case, where all values are nonnegative, the values must
11863 be in the range:
11864
11865 @smallexample @c ada
11866    0 .. System.Max_Binary_Modulus;
11867 @end smallexample
11868
11869 @noindent
11870 A @emph{confirming} representation clause is one in which the values range
11871 from 0 in sequence, i.e.@: a clause that confirms the default representation
11872 for an enumeration type.
11873 Such a confirming representation
11874 is permitted by these rules, and is specially recognized by the compiler so
11875 that no extra overhead results from the use of such a clause.
11876
11877 If an array has an index type which is an enumeration type to which an
11878 enumeration clause has been applied, then the array is stored in a compact
11879 manner.  Consider the declarations:
11880
11881 @smallexample @c ada
11882    type r is (A, B, C);
11883    for r use (A => 1, B => 5, C => 10);
11884    type t is array (r) of Character;
11885 @end smallexample
11886
11887 @noindent
11888 The array type t corresponds to a vector with exactly three elements and
11889 has a default size equal to @code{3*Character'Size}.  This ensures efficient
11890 use of space, but means that accesses to elements of the array will incur
11891 the overhead of converting representation values to the corresponding
11892 positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
11893
11894 @node Address Clauses
11895 @section Address Clauses
11896 @cindex Address Clause
11897
11898 The reference manual allows a general restriction on representation clauses,
11899 as found in RM 13.1(22):
11900
11901 @quotation
11902 An implementation need not support representation
11903 items containing nonstatic expressions, except that
11904 an implementation should support a representation item
11905 for a given entity if each nonstatic expression in the
11906 representation item is a name that statically denotes
11907 a constant declared before the entity.
11908 @end quotation
11909
11910 @noindent
11911 In practice this is applicable only to address clauses, since this is the
11912 only case in which a non-static expression is permitted by the syntax.  As
11913 the AARM notes in sections 13.1 (22.a-22.h):
11914
11915 @display
11916   22.a   Reason: This is to avoid the following sort of thing:
11917
11918   22.b        X : Integer := F(@dots{});
11919               Y : Address := G(@dots{});
11920               for X'Address use Y;
11921
11922   22.c   In the above, we have to evaluate the
11923          initialization expression for X before we
11924          know where to put the result.  This seems
11925          like an unreasonable implementation burden.
11926
11927   22.d   The above code should instead be written
11928          like this:
11929
11930   22.e        Y : constant Address := G(@dots{});
11931               X : Integer := F(@dots{});
11932               for X'Address use Y;
11933
11934   22.f   This allows the expression ``Y'' to be safely
11935          evaluated before X is created.
11936
11937   22.g   The constant could be a formal parameter of mode in.
11938
11939   22.h   An implementation can support other nonstatic
11940          expressions if it wants to.  Expressions of type
11941          Address are hardly ever static, but their value
11942          might be known at compile time anyway in many
11943          cases.
11944 @end display
11945
11946 @noindent
11947 GNAT does indeed permit many additional cases of non-static expressions.  In
11948 particular, if the type involved is elementary there are no restrictions
11949 (since in this case, holding a temporary copy of the initialization value,
11950 if one is present, is inexpensive).  In addition, if there is no implicit or
11951 explicit initialization, then there are no restrictions.  GNAT will reject
11952 only the case where all three of these conditions hold:
11953
11954 @itemize @bullet
11955
11956 @item
11957 The type of the item is non-elementary (e.g.@: a record or array).
11958
11959 @item
11960 There is explicit or implicit initialization required for the object.
11961 Note that access values are always implicitly initialized.
11962
11963 @item
11964 The address value is non-static.  Here GNAT is more permissive than the
11965 RM, and allows the address value to be the address of a previously declared
11966 stand-alone variable, as long as it does not itself have an address clause.
11967
11968 @smallexample @c ada
11969            Anchor  : Some_Initialized_Type;
11970            Overlay : Some_Initialized_Type;
11971            for Overlay'Address use Anchor'Address;
11972 @end smallexample
11973
11974 @noindent
11975 However, the prefix of the address clause cannot be an array component, or
11976 a component of a discriminated record.
11977
11978 @end itemize
11979
11980 @noindent
11981 As noted above in section 22.h, address values are typically non-static.  In
11982 particular the To_Address function, even if applied to a literal value, is
11983 a non-static function call.  To avoid this minor annoyance, GNAT provides
11984 the implementation defined attribute 'To_Address.  The following two
11985 expressions have identical values:
11986
11987 @findex Attribute
11988 @findex To_Address
11989 @smallexample @c ada
11990    To_Address (16#1234_0000#)
11991    System'To_Address (16#1234_0000#);
11992 @end smallexample
11993
11994 @noindent
11995 except that the second form is considered to be a static expression, and
11996 thus when used as an address clause value is always permitted.
11997
11998 @noindent
11999 Additionally, GNAT treats as static an address clause that is an
12000 unchecked_conversion of a static integer value.  This simplifies the porting
12001 of legacy code, and provides a portable equivalent to the GNAT attribute
12002 @code{To_Address}.
12003
12004 Another issue with address clauses is the interaction with alignment
12005 requirements.  When an address clause is given for an object, the address
12006 value must be consistent with the alignment of the object (which is usually
12007 the same as the alignment of the type of the object).  If an address clause
12008 is given that specifies an inappropriately aligned address value, then the
12009 program execution is erroneous.
12010
12011 Since this source of erroneous behavior can have unfortunate effects, GNAT
12012 checks (at compile time if possible, generating a warning, or at execution
12013 time with a run-time check) that the alignment is appropriate.  If the
12014 run-time check fails, then @code{Program_Error} is raised.  This run-time
12015 check is suppressed if range checks are suppressed, or if the special GNAT
12016 check Alignment_Check is suppressed, or if
12017 @code{pragma Restrictions (No_Elaboration_Code)} is in effect.
12018
12019 Finally, GNAT does not permit overlaying of objects of controlled types or
12020 composite types containing a controlled component. In most cases, the compiler
12021 can detect an attempt at such overlays and will generate a warning at compile
12022 time and a Program_Error exception at run time.
12023
12024 @findex Export
12025 An address clause cannot be given for an exported object.  More
12026 understandably the real restriction is that objects with an address
12027 clause cannot be exported.  This is because such variables are not
12028 defined by the Ada program, so there is no external object to export.
12029
12030 @findex Import
12031 It is permissible to give an address clause and a pragma Import for the
12032 same object.  In this case, the variable is not really defined by the
12033 Ada program, so there is no external symbol to be linked.  The link name
12034 and the external name are ignored in this case.  The reason that we allow this
12035 combination is that it provides a useful idiom to avoid unwanted
12036 initializations on objects with address clauses.
12037
12038 When an address clause is given for an object that has implicit or
12039 explicit initialization, then by default initialization takes place.  This
12040 means that the effect of the object declaration is to overwrite the
12041 memory at the specified address.  This is almost always not what the
12042 programmer wants, so GNAT will output a warning:
12043
12044 @smallexample
12045   with System;
12046   package G is
12047      type R is record
12048         M : Integer := 0;
12049      end record;
12050
12051      Ext : R;
12052      for Ext'Address use System'To_Address (16#1234_1234#);
12053          |
12054   >>> warning: implicit initialization of "Ext" may
12055       modify overlaid storage
12056   >>> warning: use pragma Import for "Ext" to suppress
12057       initialization (RM B(24))
12058
12059   end G;
12060 @end smallexample
12061
12062 @noindent
12063 As indicated by the warning message, the solution is to use a (dummy) pragma
12064 Import to suppress this initialization.  The pragma tell the compiler that the
12065 object is declared and initialized elsewhere.  The following package compiles
12066 without warnings (and the initialization is suppressed):
12067
12068 @smallexample @c ada
12069    with System;
12070    package G is
12071       type R is record
12072          M : Integer := 0;
12073       end record;
12074
12075       Ext : R;
12076       for Ext'Address use System'To_Address (16#1234_1234#);
12077       pragma Import (Ada, Ext);
12078    end G;
12079 @end smallexample
12080
12081 @noindent
12082 A final issue with address clauses involves their use for overlaying
12083 variables, as in the following example:
12084 @cindex Overlaying of objects
12085
12086 @smallexample @c ada
12087   A : Integer;
12088   B : Integer;
12089   for B'Address use A'Address;
12090 @end smallexample
12091
12092 @noindent
12093 or alternatively, using the form recommended by the RM:
12094
12095 @smallexample @c ada
12096   A    : Integer;
12097   Addr : constant Address := A'Address;
12098   B    : Integer;
12099   for B'Address use Addr;
12100 @end smallexample
12101
12102 @noindent
12103 In both of these cases, @code{A}
12104 and @code{B} become aliased to one another via the
12105 address clause. This use of address clauses to overlay
12106 variables, achieving an effect similar to unchecked
12107 conversion was erroneous in Ada 83, but in Ada 95 and Ada 2005
12108 the effect is implementation defined. Furthermore, the
12109 Ada RM specifically recommends that in a situation
12110 like this, @code{B} should be subject to the following
12111 implementation advice (RM 13.3(19)):
12112
12113 @quotation
12114 19  If the Address of an object is specified, or it is imported
12115     or exported, then the implementation should not perform
12116     optimizations based on assumptions of no aliases.
12117 @end quotation
12118
12119 @noindent
12120 GNAT follows this recommendation, and goes further by also applying
12121 this recommendation to the overlaid variable (@code{A}
12122 in the above example) in this case. This means that the overlay
12123 works "as expected", in that a modification to one of the variables
12124 will affect the value of the other.
12125
12126 @node Effect of Convention on Representation
12127 @section Effect of Convention on Representation
12128 @cindex Convention, effect on representation
12129
12130 @noindent
12131 Normally the specification of a foreign language convention for a type or
12132 an object has no effect on the chosen representation.  In particular, the
12133 representation chosen for data in GNAT generally meets the standard system
12134 conventions, and for example records are laid out in a manner that is
12135 consistent with C@.  This means that specifying convention C (for example)
12136 has no effect.
12137
12138 There are four exceptions to this general rule:
12139
12140 @itemize @bullet
12141
12142 @item Convention Fortran and array subtypes
12143 If pragma Convention Fortran is specified for an array subtype, then in
12144 accordance with the implementation advice in section 3.6.2(11) of the
12145 Ada Reference Manual, the array will be stored in a Fortran-compatible
12146 column-major manner, instead of the normal default row-major order.
12147
12148 @item Convention C and enumeration types
12149 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
12150 to accommodate all values of the type.  For example, for the enumeration
12151 type declared by:
12152
12153 @smallexample @c ada
12154    type Color is (Red, Green, Blue);
12155 @end smallexample
12156
12157 @noindent
12158 8 bits is sufficient to store all values of the type, so by default, objects
12159 of type @code{Color} will be represented using 8 bits.  However, normal C
12160 convention is to use 32 bits for all enum values in C, since enum values
12161 are essentially of type int.  If pragma @code{Convention C} is specified for an
12162 Ada enumeration type, then the size is modified as necessary (usually to
12163 32 bits) to be consistent with the C convention for enum values.
12164
12165 Note that this treatment applies only to types. If Convention C is given for
12166 an enumeration object, where the enumeration type is not Convention C, then
12167 Object_Size bits are allocated. For example, for a normal enumeration type,
12168 with less than 256 elements, only 8 bits will be allocated for the object.
12169 Since this may be a surprise in terms of what C expects, GNAT will issue a
12170 warning in this situation. The warning can be suppressed by giving an explicit
12171 size clause specifying the desired size.
12172
12173 @item Convention C/Fortran and Boolean types
12174 In C, the usual convention for boolean values, that is values used for
12175 conditions, is that zero represents false, and nonzero values represent
12176 true.  In Ada, the normal convention is that two specific values, typically
12177 0/1, are used to represent false/true respectively.
12178
12179 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
12180 value represents true).
12181
12182 To accommodate the Fortran and C conventions, if a pragma Convention specifies
12183 C or Fortran convention for a derived Boolean, as in the following example:
12184
12185 @smallexample @c ada
12186    type C_Switch is new Boolean;
12187    pragma Convention (C, C_Switch);
12188 @end smallexample
12189
12190 @noindent
12191 then the GNAT generated code will treat any nonzero value as true.  For truth
12192 values generated by GNAT, the conventional value 1 will be used for True, but
12193 when one of these values is read, any nonzero value is treated as True.
12194
12195 @item Access types on OpenVMS
12196 For 64-bit OpenVMS systems, access types (other than those for unconstrained
12197 arrays) are 64-bits long. An exception to this rule is for the case of
12198 C-convention access types where there is no explicit size clause present (or
12199 inherited for derived types). In this case, GNAT chooses to make these
12200 pointers 32-bits, which provides an easier path for migration of 32-bit legacy
12201 code. size clause specifying 64-bits must be used to obtain a 64-bit pointer.
12202
12203 @end itemize
12204
12205 @node Determining the Representations chosen by GNAT
12206 @section Determining the Representations chosen by GNAT
12207 @cindex Representation, determination of
12208 @cindex @option{-gnatR} switch
12209
12210 @noindent
12211 Although the descriptions in this section are intended to be complete, it is
12212 often easier to simply experiment to see what GNAT accepts and what the
12213 effect is on the layout of types and objects.
12214
12215 As required by the Ada RM, if a representation clause is not accepted, then
12216 it must be rejected as illegal by the compiler.  However, when a
12217 representation clause or pragma is accepted, there can still be questions
12218 of what the compiler actually does.  For example, if a partial record
12219 representation clause specifies the location of some components and not
12220 others, then where are the non-specified components placed? Or if pragma
12221 @code{Pack} is used on a record, then exactly where are the resulting
12222 fields placed? The section on pragma @code{Pack} in this chapter can be
12223 used to answer the second question, but it is often easier to just see
12224 what the compiler does.
12225
12226 For this purpose, GNAT provides the option @option{-gnatR}.  If you compile
12227 with this option, then the compiler will output information on the actual
12228 representations chosen, in a format similar to source representation
12229 clauses.  For example, if we compile the package:
12230
12231 @smallexample @c ada
12232 package q is
12233    type r (x : boolean) is tagged record
12234       case x is
12235          when True => S : String (1 .. 100);
12236          when False => null;
12237       end case;
12238    end record;
12239
12240    type r2 is new r (false) with record
12241       y2 : integer;
12242    end record;
12243
12244    for r2 use record
12245       y2 at 16 range 0 .. 31;
12246    end record;
12247
12248    type x is record
12249       y : character;
12250    end record;
12251
12252    type x1 is array (1 .. 10) of x;
12253    for x1'component_size use 11;
12254
12255    type ia is access integer;
12256
12257    type Rb1 is array (1 .. 13) of Boolean;
12258    pragma Pack (rb1);
12259
12260    type Rb2 is array (1 .. 65) of Boolean;
12261    pragma Pack (rb2);
12262
12263    type x2 is record
12264       l1 : Boolean;
12265       l2 : Duration;
12266       l3 : Float;
12267       l4 : Boolean;
12268       l5 : Rb1;
12269       l6 : Rb2;
12270    end record;
12271    pragma Pack (x2);
12272 end q;
12273 @end smallexample
12274
12275 @noindent
12276 using the switch @option{-gnatR} we obtain the following output:
12277
12278 @smallexample
12279 Representation information for unit q
12280 -------------------------------------
12281
12282 for r'Size use ??;
12283 for r'Alignment use 4;
12284 for r use record
12285    x    at 4 range  0 .. 7;
12286    _tag at 0 range  0 .. 31;
12287    s    at 5 range  0 .. 799;
12288 end record;
12289
12290 for r2'Size use 160;
12291 for r2'Alignment use 4;
12292 for r2 use record
12293    x       at  4 range  0 .. 7;
12294    _tag    at  0 range  0 .. 31;
12295    _parent at  0 range  0 .. 63;
12296    y2      at 16 range  0 .. 31;
12297 end record;
12298
12299 for x'Size use 8;
12300 for x'Alignment use 1;
12301 for x use record
12302    y at 0 range  0 .. 7;
12303 end record;
12304
12305 for x1'Size use 112;
12306 for x1'Alignment use 1;
12307 for x1'Component_Size use 11;
12308
12309 for rb1'Size use 13;
12310 for rb1'Alignment use 2;
12311 for rb1'Component_Size use 1;
12312
12313 for rb2'Size use 72;
12314 for rb2'Alignment use 1;
12315 for rb2'Component_Size use 1;
12316
12317 for x2'Size use 224;
12318 for x2'Alignment use 4;
12319 for x2 use record
12320    l1 at  0 range  0 .. 0;
12321    l2 at  0 range  1 .. 64;
12322    l3 at 12 range  0 .. 31;
12323    l4 at 16 range  0 .. 0;
12324    l5 at 16 range  1 .. 13;
12325    l6 at 18 range  0 .. 71;
12326 end record;
12327 @end smallexample
12328
12329 @noindent
12330 The Size values are actually the Object_Size, i.e.@: the default size that
12331 will be allocated for objects of the type.
12332 The ?? size for type r indicates that we have a variant record, and the
12333 actual size of objects will depend on the discriminant value.
12334
12335 The Alignment values show the actual alignment chosen by the compiler
12336 for each record or array type.
12337
12338 The record representation clause for type r shows where all fields
12339 are placed, including the compiler generated tag field (whose location
12340 cannot be controlled by the programmer).
12341
12342 The record representation clause for the type extension r2 shows all the
12343 fields present, including the parent field, which is a copy of the fields
12344 of the parent type of r2, i.e.@: r1.
12345
12346 The component size and size clauses for types rb1 and rb2 show
12347 the exact effect of pragma @code{Pack} on these arrays, and the record
12348 representation clause for type x2 shows how pragma @code{Pack} affects
12349 this record type.
12350
12351 In some cases, it may be useful to cut and paste the representation clauses
12352 generated by the compiler into the original source to fix and guarantee
12353 the actual representation to be used.
12354
12355 @node Standard Library Routines
12356 @chapter Standard Library Routines
12357
12358 @noindent
12359 The Ada Reference Manual contains in Annex A a full description of an
12360 extensive set of standard library routines that can be used in any Ada
12361 program, and which must be provided by all Ada compilers.  They are
12362 analogous to the standard C library used by C programs.
12363
12364 GNAT implements all of the facilities described in annex A, and for most
12365 purposes the description in the Ada Reference Manual, or appropriate Ada
12366 text book, will be sufficient for making use of these facilities.
12367
12368 In the case of the input-output facilities,
12369 @xref{The Implementation of Standard I/O},
12370 gives details on exactly how GNAT interfaces to the
12371 file system.  For the remaining packages, the Ada Reference Manual
12372 should be sufficient.  The following is a list of the packages included,
12373 together with a brief description of the functionality that is provided.
12374
12375 For completeness, references are included to other predefined library
12376 routines defined in other sections of the Ada Reference Manual (these are
12377 cross-indexed from Annex A).
12378
12379 @table @code
12380 @item Ada (A.2)
12381 This is a parent package for all the standard library packages.  It is
12382 usually included implicitly in your program, and itself contains no
12383 useful data or routines.
12384
12385 @item Ada.Calendar (9.6)
12386 @code{Calendar} provides time of day access, and routines for
12387 manipulating times and durations.
12388
12389 @item Ada.Characters (A.3.1)
12390 This is a dummy parent package that contains no useful entities
12391
12392 @item Ada.Characters.Handling (A.3.2)
12393 This package provides some basic character handling capabilities,
12394 including classification functions for classes of characters (e.g.@: test
12395 for letters, or digits).
12396
12397 @item Ada.Characters.Latin_1 (A.3.3)
12398 This package includes a complete set of definitions of the characters
12399 that appear in type CHARACTER@.  It is useful for writing programs that
12400 will run in international environments.  For example, if you want an
12401 upper case E with an acute accent in a string, it is often better to use
12402 the definition of @code{UC_E_Acute} in this package.  Then your program
12403 will print in an understandable manner even if your environment does not
12404 support these extended characters.
12405
12406 @item Ada.Command_Line (A.15)
12407 This package provides access to the command line parameters and the name
12408 of the current program (analogous to the use of @code{argc} and @code{argv}
12409 in C), and also allows the exit status for the program to be set in a
12410 system-independent manner.
12411
12412 @item Ada.Decimal (F.2)
12413 This package provides constants describing the range of decimal numbers
12414 implemented, and also a decimal divide routine (analogous to the COBOL
12415 verb DIVIDE @dots{} GIVING @dots{} REMAINDER @dots{})
12416
12417 @item Ada.Direct_IO (A.8.4)
12418 This package provides input-output using a model of a set of records of
12419 fixed-length, containing an arbitrary definite Ada type, indexed by an
12420 integer record number.
12421
12422 @item Ada.Dynamic_Priorities (D.5)
12423 This package allows the priorities of a task to be adjusted dynamically
12424 as the task is running.
12425
12426 @item Ada.Exceptions (11.4.1)
12427 This package provides additional information on exceptions, and also
12428 contains facilities for treating exceptions as data objects, and raising
12429 exceptions with associated messages.
12430
12431 @item Ada.Finalization (7.6)
12432 This package contains the declarations and subprograms to support the
12433 use of controlled types, providing for automatic initialization and
12434 finalization (analogous to the constructors and destructors of C++)
12435
12436 @item Ada.Interrupts (C.3.2)
12437 This package provides facilities for interfacing to interrupts, which
12438 includes the set of signals or conditions that can be raised and
12439 recognized as interrupts.
12440
12441 @item Ada.Interrupts.Names (C.3.2)
12442 This package provides the set of interrupt names (actually signal
12443 or condition names) that can be handled by GNAT@.
12444
12445 @item Ada.IO_Exceptions (A.13)
12446 This package defines the set of exceptions that can be raised by use of
12447 the standard IO packages.
12448
12449 @item Ada.Numerics
12450 This package contains some standard constants and exceptions used
12451 throughout the numerics packages.  Note that the constants pi and e are
12452 defined here, and it is better to use these definitions than rolling
12453 your own.
12454
12455 @item Ada.Numerics.Complex_Elementary_Functions
12456 Provides the implementation of standard elementary functions (such as
12457 log and trigonometric functions) operating on complex numbers using the
12458 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
12459 created by the package @code{Numerics.Complex_Types}.
12460
12461 @item Ada.Numerics.Complex_Types
12462 This is a predefined instantiation of
12463 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
12464 build the type @code{Complex} and @code{Imaginary}.
12465
12466 @item Ada.Numerics.Discrete_Random
12467 This generic package provides a random number generator suitable for generating
12468 uniformly distributed values of a specified discrete subtype.
12469
12470 @item Ada.Numerics.Float_Random
12471 This package provides a random number generator suitable for generating
12472 uniformly distributed floating point values in the unit interval.
12473
12474 @item Ada.Numerics.Generic_Complex_Elementary_Functions
12475 This is a generic version of the package that provides the
12476 implementation of standard elementary functions (such as log and
12477 trigonometric functions) for an arbitrary complex type.
12478
12479 The following predefined instantiations of this package are provided:
12480
12481 @table @code
12482 @item Short_Float
12483 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
12484 @item Float
12485 @code{Ada.Numerics.Complex_Elementary_Functions}
12486 @item Long_Float
12487 @code{Ada.Numerics.Long_Complex_Elementary_Functions}
12488 @end table
12489
12490 @item Ada.Numerics.Generic_Complex_Types
12491 This is a generic package that allows the creation of complex types,
12492 with associated complex arithmetic operations.
12493
12494 The following predefined instantiations of this package exist
12495 @table @code
12496 @item Short_Float
12497 @code{Ada.Numerics.Short_Complex_Complex_Types}
12498 @item Float
12499 @code{Ada.Numerics.Complex_Complex_Types}
12500 @item Long_Float
12501 @code{Ada.Numerics.Long_Complex_Complex_Types}
12502 @end table
12503
12504 @item Ada.Numerics.Generic_Elementary_Functions
12505 This is a generic package that provides the implementation of standard
12506 elementary functions (such as log an trigonometric functions) for an
12507 arbitrary float type.
12508
12509 The following predefined instantiations of this package exist
12510
12511 @table @code
12512 @item Short_Float
12513 @code{Ada.Numerics.Short_Elementary_Functions}
12514 @item Float
12515 @code{Ada.Numerics.Elementary_Functions}
12516 @item Long_Float
12517 @code{Ada.Numerics.Long_Elementary_Functions}
12518 @end table
12519
12520 @item Ada.Real_Time (D.8)
12521 This package provides facilities similar to those of @code{Calendar}, but
12522 operating with a finer clock suitable for real time control. Note that
12523 annex D requires that there be no backward clock jumps, and GNAT generally
12524 guarantees this behavior, but of course if the external clock on which
12525 the GNAT runtime depends is deliberately reset by some external event,
12526 then such a backward jump may occur.
12527
12528 @item Ada.Sequential_IO (A.8.1)
12529 This package provides input-output facilities for sequential files,
12530 which can contain a sequence of values of a single type, which can be
12531 any Ada type, including indefinite (unconstrained) types.
12532
12533 @item Ada.Storage_IO (A.9)
12534 This package provides a facility for mapping arbitrary Ada types to and
12535 from a storage buffer.  It is primarily intended for the creation of new
12536 IO packages.
12537
12538 @item Ada.Streams (13.13.1)
12539 This is a generic package that provides the basic support for the
12540 concept of streams as used by the stream attributes (@code{Input},
12541 @code{Output}, @code{Read} and @code{Write}).
12542
12543 @item Ada.Streams.Stream_IO (A.12.1)
12544 This package is a specialization of the type @code{Streams} defined in
12545 package @code{Streams} together with a set of operations providing
12546 Stream_IO capability.  The Stream_IO model permits both random and
12547 sequential access to a file which can contain an arbitrary set of values
12548 of one or more Ada types.
12549
12550 @item Ada.Strings (A.4.1)
12551 This package provides some basic constants used by the string handling
12552 packages.
12553
12554 @item Ada.Strings.Bounded (A.4.4)
12555 This package provides facilities for handling variable length
12556 strings.  The bounded model requires a maximum length.  It is thus
12557 somewhat more limited than the unbounded model, but avoids the use of
12558 dynamic allocation or finalization.
12559
12560 @item Ada.Strings.Fixed (A.4.3)
12561 This package provides facilities for handling fixed length strings.
12562
12563 @item Ada.Strings.Maps (A.4.2)
12564 This package provides facilities for handling character mappings and
12565 arbitrarily defined subsets of characters.  For instance it is useful in
12566 defining specialized translation tables.
12567
12568 @item Ada.Strings.Maps.Constants (A.4.6)
12569 This package provides a standard set of predefined mappings and
12570 predefined character sets.  For example, the standard upper to lower case
12571 conversion table is found in this package.  Note that upper to lower case
12572 conversion is non-trivial if you want to take the entire set of
12573 characters, including extended characters like E with an acute accent,
12574 into account.  You should use the mappings in this package (rather than
12575 adding 32 yourself) to do case mappings.
12576
12577 @item Ada.Strings.Unbounded (A.4.5)
12578 This package provides facilities for handling variable length
12579 strings.  The unbounded model allows arbitrary length strings, but
12580 requires the use of dynamic allocation and finalization.
12581
12582 @item Ada.Strings.Wide_Bounded (A.4.7)
12583 @itemx Ada.Strings.Wide_Fixed (A.4.7)
12584 @itemx Ada.Strings.Wide_Maps (A.4.7)
12585 @itemx Ada.Strings.Wide_Maps.Constants (A.4.7)
12586 @itemx Ada.Strings.Wide_Unbounded (A.4.7)
12587 These packages provide analogous capabilities to the corresponding
12588 packages without @samp{Wide_} in the name, but operate with the types
12589 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
12590 and @code{Character}.
12591
12592 @item Ada.Strings.Wide_Wide_Bounded (A.4.7)
12593 @itemx Ada.Strings.Wide_Wide_Fixed (A.4.7)
12594 @itemx Ada.Strings.Wide_Wide_Maps (A.4.7)
12595 @itemx Ada.Strings.Wide_Wide_Maps.Constants (A.4.7)
12596 @itemx Ada.Strings.Wide_Wide_Unbounded (A.4.7)
12597 These packages provide analogous capabilities to the corresponding
12598 packages without @samp{Wide_} in the name, but operate with the types
12599 @code{Wide_Wide_String} and @code{Wide_Wide_Character} instead
12600 of @code{String} and @code{Character}.
12601
12602 @item Ada.Synchronous_Task_Control (D.10)
12603 This package provides some standard facilities for controlling task
12604 communication in a synchronous manner.
12605
12606 @item Ada.Tags
12607 This package contains definitions for manipulation of the tags of tagged
12608 values.
12609
12610 @item Ada.Task_Attributes
12611 This package provides the capability of associating arbitrary
12612 task-specific data with separate tasks.
12613
12614 @item Ada.Text_IO
12615 This package provides basic text input-output capabilities for
12616 character, string and numeric data.  The subpackages of this
12617 package are listed next.
12618
12619 @item Ada.Text_IO.Decimal_IO
12620 Provides input-output facilities for decimal fixed-point types
12621
12622 @item Ada.Text_IO.Enumeration_IO
12623 Provides input-output facilities for enumeration types.
12624
12625 @item Ada.Text_IO.Fixed_IO
12626 Provides input-output facilities for ordinary fixed-point types.
12627
12628 @item Ada.Text_IO.Float_IO
12629 Provides input-output facilities for float types.  The following
12630 predefined instantiations of this generic package are available:
12631
12632 @table @code
12633 @item Short_Float
12634 @code{Short_Float_Text_IO}
12635 @item Float
12636 @code{Float_Text_IO}
12637 @item Long_Float
12638 @code{Long_Float_Text_IO}
12639 @end table
12640
12641 @item Ada.Text_IO.Integer_IO
12642 Provides input-output facilities for integer types.  The following
12643 predefined instantiations of this generic package are available:
12644
12645 @table @code
12646 @item Short_Short_Integer
12647 @code{Ada.Short_Short_Integer_Text_IO}
12648 @item Short_Integer
12649 @code{Ada.Short_Integer_Text_IO}
12650 @item Integer
12651 @code{Ada.Integer_Text_IO}
12652 @item Long_Integer
12653 @code{Ada.Long_Integer_Text_IO}
12654 @item Long_Long_Integer
12655 @code{Ada.Long_Long_Integer_Text_IO}
12656 @end table
12657
12658 @item Ada.Text_IO.Modular_IO
12659 Provides input-output facilities for modular (unsigned) types
12660
12661 @item Ada.Text_IO.Complex_IO (G.1.3)
12662 This package provides basic text input-output capabilities for complex
12663 data.
12664
12665 @item Ada.Text_IO.Editing (F.3.3)
12666 This package contains routines for edited output, analogous to the use
12667 of pictures in COBOL@.  The picture formats used by this package are a
12668 close copy of the facility in COBOL@.
12669
12670 @item Ada.Text_IO.Text_Streams (A.12.2)
12671 This package provides a facility that allows Text_IO files to be treated
12672 as streams, so that the stream attributes can be used for writing
12673 arbitrary data, including binary data, to Text_IO files.
12674
12675 @item Ada.Unchecked_Conversion (13.9)
12676 This generic package allows arbitrary conversion from one type to
12677 another of the same size, providing for breaking the type safety in
12678 special circumstances.
12679
12680 If the types have the same Size (more accurately the same Value_Size),
12681 then the effect is simply to transfer the bits from the source to the
12682 target type without any modification.  This usage is well defined, and
12683 for simple types whose representation is typically the same across
12684 all implementations, gives a portable method of performing such
12685 conversions.
12686
12687 If the types do not have the same size, then the result is implementation
12688 defined, and thus may be non-portable.  The following describes how GNAT
12689 handles such unchecked conversion cases.
12690
12691 If the types are of different sizes, and are both discrete types, then
12692 the effect is of a normal type conversion without any constraint checking.
12693 In particular if the result type has a larger size, the result will be
12694 zero or sign extended.  If the result type has a smaller size, the result
12695 will be truncated by ignoring high order bits.
12696
12697 If the types are of different sizes, and are not both discrete types,
12698 then the conversion works as though pointers were created to the source
12699 and target, and the pointer value is converted.  The effect is that bits
12700 are copied from successive low order storage units and bits of the source
12701 up to the length of the target type.
12702
12703 A warning is issued if the lengths differ, since the effect in this
12704 case is implementation dependent, and the above behavior may not match
12705 that of some other compiler.
12706
12707 A pointer to one type may be converted to a pointer to another type using
12708 unchecked conversion.  The only case in which the effect is undefined is
12709 when one or both pointers are pointers to unconstrained array types.  In
12710 this case, the bounds information may get incorrectly transferred, and in
12711 particular, GNAT uses double size pointers for such types, and it is
12712 meaningless to convert between such pointer types.  GNAT will issue a
12713 warning if the alignment of the target designated type is more strict
12714 than the alignment of the source designated type (since the result may
12715 be unaligned in this case).
12716
12717 A pointer other than a pointer to an unconstrained array type may be
12718 converted to and from System.Address.  Such usage is common in Ada 83
12719 programs, but note that Ada.Address_To_Access_Conversions is the
12720 preferred method of performing such conversions in Ada 95 and Ada 2005.
12721 Neither
12722 unchecked conversion nor Ada.Address_To_Access_Conversions should be
12723 used in conjunction with pointers to unconstrained objects, since
12724 the bounds information cannot be handled correctly in this case.
12725
12726 @item Ada.Unchecked_Deallocation (13.11.2)
12727 This generic package allows explicit freeing of storage previously
12728 allocated by use of an allocator.
12729
12730 @item Ada.Wide_Text_IO (A.11)
12731 This package is similar to @code{Ada.Text_IO}, except that the external
12732 file supports wide character representations, and the internal types are
12733 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
12734 and @code{String}.  It contains generic subpackages listed next.
12735
12736 @item Ada.Wide_Text_IO.Decimal_IO
12737 Provides input-output facilities for decimal fixed-point types
12738
12739 @item Ada.Wide_Text_IO.Enumeration_IO
12740 Provides input-output facilities for enumeration types.
12741
12742 @item Ada.Wide_Text_IO.Fixed_IO
12743 Provides input-output facilities for ordinary fixed-point types.
12744
12745 @item Ada.Wide_Text_IO.Float_IO
12746 Provides input-output facilities for float types.  The following
12747 predefined instantiations of this generic package are available:
12748
12749 @table @code
12750 @item Short_Float
12751 @code{Short_Float_Wide_Text_IO}
12752 @item Float
12753 @code{Float_Wide_Text_IO}
12754 @item Long_Float
12755 @code{Long_Float_Wide_Text_IO}
12756 @end table
12757
12758 @item Ada.Wide_Text_IO.Integer_IO
12759 Provides input-output facilities for integer types.  The following
12760 predefined instantiations of this generic package are available:
12761
12762 @table @code
12763 @item Short_Short_Integer
12764 @code{Ada.Short_Short_Integer_Wide_Text_IO}
12765 @item Short_Integer
12766 @code{Ada.Short_Integer_Wide_Text_IO}
12767 @item Integer
12768 @code{Ada.Integer_Wide_Text_IO}
12769 @item Long_Integer
12770 @code{Ada.Long_Integer_Wide_Text_IO}
12771 @item Long_Long_Integer
12772 @code{Ada.Long_Long_Integer_Wide_Text_IO}
12773 @end table
12774
12775 @item Ada.Wide_Text_IO.Modular_IO
12776 Provides input-output facilities for modular (unsigned) types
12777
12778 @item Ada.Wide_Text_IO.Complex_IO (G.1.3)
12779 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
12780 external file supports wide character representations.
12781
12782 @item Ada.Wide_Text_IO.Editing (F.3.4)
12783 This package is similar to @code{Ada.Text_IO.Editing}, except that the
12784 types are @code{Wide_Character} and @code{Wide_String} instead of
12785 @code{Character} and @code{String}.
12786
12787 @item Ada.Wide_Text_IO.Streams (A.12.3)
12788 This package is similar to @code{Ada.Text_IO.Streams}, except that the
12789 types are @code{Wide_Character} and @code{Wide_String} instead of
12790 @code{Character} and @code{String}.
12791
12792 @item Ada.Wide_Wide_Text_IO (A.11)
12793 This package is similar to @code{Ada.Text_IO}, except that the external
12794 file supports wide character representations, and the internal types are
12795 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
12796 and @code{String}.  It contains generic subpackages listed next.
12797
12798 @item Ada.Wide_Wide_Text_IO.Decimal_IO
12799 Provides input-output facilities for decimal fixed-point types
12800
12801 @item Ada.Wide_Wide_Text_IO.Enumeration_IO
12802 Provides input-output facilities for enumeration types.
12803
12804 @item Ada.Wide_Wide_Text_IO.Fixed_IO
12805 Provides input-output facilities for ordinary fixed-point types.
12806
12807 @item Ada.Wide_Wide_Text_IO.Float_IO
12808 Provides input-output facilities for float types.  The following
12809 predefined instantiations of this generic package are available:
12810
12811 @table @code
12812 @item Short_Float
12813 @code{Short_Float_Wide_Wide_Text_IO}
12814 @item Float
12815 @code{Float_Wide_Wide_Text_IO}
12816 @item Long_Float
12817 @code{Long_Float_Wide_Wide_Text_IO}
12818 @end table
12819
12820 @item Ada.Wide_Wide_Text_IO.Integer_IO
12821 Provides input-output facilities for integer types.  The following
12822 predefined instantiations of this generic package are available:
12823
12824 @table @code
12825 @item Short_Short_Integer
12826 @code{Ada.Short_Short_Integer_Wide_Wide_Text_IO}
12827 @item Short_Integer
12828 @code{Ada.Short_Integer_Wide_Wide_Text_IO}
12829 @item Integer
12830 @code{Ada.Integer_Wide_Wide_Text_IO}
12831 @item Long_Integer
12832 @code{Ada.Long_Integer_Wide_Wide_Text_IO}
12833 @item Long_Long_Integer
12834 @code{Ada.Long_Long_Integer_Wide_Wide_Text_IO}
12835 @end table
12836
12837 @item Ada.Wide_Wide_Text_IO.Modular_IO
12838 Provides input-output facilities for modular (unsigned) types
12839
12840 @item Ada.Wide_Wide_Text_IO.Complex_IO (G.1.3)
12841 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
12842 external file supports wide character representations.
12843
12844 @item Ada.Wide_Wide_Text_IO.Editing (F.3.4)
12845 This package is similar to @code{Ada.Text_IO.Editing}, except that the
12846 types are @code{Wide_Character} and @code{Wide_String} instead of
12847 @code{Character} and @code{String}.
12848
12849 @item Ada.Wide_Wide_Text_IO.Streams (A.12.3)
12850 This package is similar to @code{Ada.Text_IO.Streams}, except that the
12851 types are @code{Wide_Character} and @code{Wide_String} instead of
12852 @code{Character} and @code{String}.
12853 @end table
12854
12855 @node The Implementation of Standard I/O
12856 @chapter The Implementation of Standard I/O
12857
12858 @noindent
12859 GNAT implements all the required input-output facilities described in
12860 A.6 through A.14.  These sections of the Ada Reference Manual describe the
12861 required behavior of these packages from the Ada point of view, and if
12862 you are writing a portable Ada program that does not need to know the
12863 exact manner in which Ada maps to the outside world when it comes to
12864 reading or writing external files, then you do not need to read this
12865 chapter.  As long as your files are all regular files (not pipes or
12866 devices), and as long as you write and read the files only from Ada, the
12867 description in the Ada Reference Manual is sufficient.
12868
12869 However, if you want to do input-output to pipes or other devices, such
12870 as the keyboard or screen, or if the files you are dealing with are
12871 either generated by some other language, or to be read by some other
12872 language, then you need to know more about the details of how the GNAT
12873 implementation of these input-output facilities behaves.
12874
12875 In this chapter we give a detailed description of exactly how GNAT
12876 interfaces to the file system.  As always, the sources of the system are
12877 available to you for answering questions at an even more detailed level,
12878 but for most purposes the information in this chapter will suffice.
12879
12880 Another reason that you may need to know more about how input-output is
12881 implemented arises when you have a program written in mixed languages
12882 where, for example, files are shared between the C and Ada sections of
12883 the same program.  GNAT provides some additional facilities, in the form
12884 of additional child library packages, that facilitate this sharing, and
12885 these additional facilities are also described in this chapter.
12886
12887 @menu
12888 * Standard I/O Packages::
12889 * FORM Strings::
12890 * Direct_IO::
12891 * Sequential_IO::
12892 * Text_IO::
12893 * Wide_Text_IO::
12894 * Wide_Wide_Text_IO::
12895 * Stream_IO::
12896 * Text Translation::
12897 * Shared Files::
12898 * Filenames encoding::
12899 * Open Modes::
12900 * Operations on C Streams::
12901 * Interfacing to C Streams::
12902 @end menu
12903
12904 @node Standard I/O Packages
12905 @section Standard I/O Packages
12906
12907 @noindent
12908 The Standard I/O packages described in Annex A for
12909
12910 @itemize @bullet
12911 @item
12912 Ada.Text_IO
12913 @item
12914 Ada.Text_IO.Complex_IO
12915 @item
12916 Ada.Text_IO.Text_Streams
12917 @item
12918 Ada.Wide_Text_IO
12919 @item
12920 Ada.Wide_Text_IO.Complex_IO
12921 @item
12922 Ada.Wide_Text_IO.Text_Streams
12923 @item
12924 Ada.Wide_Wide_Text_IO
12925 @item
12926 Ada.Wide_Wide_Text_IO.Complex_IO
12927 @item
12928 Ada.Wide_Wide_Text_IO.Text_Streams
12929 @item
12930 Ada.Stream_IO
12931 @item
12932 Ada.Sequential_IO
12933 @item
12934 Ada.Direct_IO
12935 @end itemize
12936
12937 @noindent
12938 are implemented using the C
12939 library streams facility; where
12940
12941 @itemize @bullet
12942 @item
12943 All files are opened using @code{fopen}.
12944 @item
12945 All input/output operations use @code{fread}/@code{fwrite}.
12946 @end itemize
12947
12948 @noindent
12949 There is no internal buffering of any kind at the Ada library level. The only
12950 buffering is that provided at the system level in the implementation of the
12951 library routines that support streams. This facilitates shared use of these
12952 streams by mixed language programs. Note though that system level buffering is
12953 explicitly enabled at elaboration of the standard I/O packages and that can
12954 have an impact on mixed language programs, in particular those using I/O before
12955 calling the Ada elaboration routine (e.g.@: adainit). It is recommended to call
12956 the Ada elaboration routine before performing any I/O or when impractical,
12957 flush the common I/O streams and in particular Standard_Output before
12958 elaborating the Ada code.
12959
12960 @node FORM Strings
12961 @section FORM Strings
12962
12963 @noindent
12964 The format of a FORM string in GNAT is:
12965
12966 @smallexample
12967 "keyword=value,keyword=value,@dots{},keyword=value"
12968 @end smallexample
12969
12970 @noindent
12971 where letters may be in upper or lower case, and there are no spaces
12972 between values.  The order of the entries is not important.  Currently
12973 the following keywords defined.
12974
12975 @smallexample
12976 TEXT_TRANSLATION=[YES|NO]
12977 SHARED=[YES|NO]
12978 WCEM=[n|h|u|s|e|8|b]
12979 ENCODING=[UTF8|8BITS]
12980 @end smallexample
12981
12982 @noindent
12983 The use of these parameters is described later in this section.
12984
12985 @node Direct_IO
12986 @section Direct_IO
12987
12988 @noindent
12989 Direct_IO can only be instantiated for definite types.  This is a
12990 restriction of the Ada language, which means that the records are fixed
12991 length (the length being determined by @code{@var{type}'Size}, rounded
12992 up to the next storage unit boundary if necessary).
12993
12994 The records of a Direct_IO file are simply written to the file in index
12995 sequence, with the first record starting at offset zero, and subsequent
12996 records following.  There is no control information of any kind.  For
12997 example, if 32-bit integers are being written, each record takes
12998 4-bytes, so the record at index @var{K} starts at offset
12999 (@var{K}@minus{}1)*4.
13000
13001 There is no limit on the size of Direct_IO files, they are expanded as
13002 necessary to accommodate whatever records are written to the file.
13003
13004 @node Sequential_IO
13005 @section Sequential_IO
13006
13007 @noindent
13008 Sequential_IO may be instantiated with either a definite (constrained)
13009 or indefinite (unconstrained) type.
13010
13011 For the definite type case, the elements written to the file are simply
13012 the memory images of the data values with no control information of any
13013 kind.  The resulting file should be read using the same type, no validity
13014 checking is performed on input.
13015
13016 For the indefinite type case, the elements written consist of two
13017 parts.  First is the size of the data item, written as the memory image
13018 of a @code{Interfaces.C.size_t} value, followed by the memory image of
13019 the data value.  The resulting file can only be read using the same
13020 (unconstrained) type.  Normal assignment checks are performed on these
13021 read operations, and if these checks fail, @code{Data_Error} is
13022 raised.  In particular, in the array case, the lengths must match, and in
13023 the variant record case, if the variable for a particular read operation
13024 is constrained, the discriminants must match.
13025
13026 Note that it is not possible to use Sequential_IO to write variable
13027 length array items, and then read the data back into different length
13028 arrays.  For example, the following will raise @code{Data_Error}:
13029
13030 @smallexample @c ada
13031  package IO is new Sequential_IO (String);
13032  F : IO.File_Type;
13033  S : String (1..4);
13034  @dots{}
13035  IO.Create (F)
13036  IO.Write (F, "hello!")
13037  IO.Reset (F, Mode=>In_File);
13038  IO.Read (F, S);
13039  Put_Line (S);
13040
13041 @end smallexample
13042
13043 @noindent
13044 On some Ada implementations, this will print @code{hell}, but the program is
13045 clearly incorrect, since there is only one element in the file, and that
13046 element is the string @code{hello!}.
13047
13048 In Ada 95 and Ada 2005, this kind of behavior can be legitimately achieved
13049 using Stream_IO, and this is the preferred mechanism.  In particular, the
13050 above program fragment rewritten to use Stream_IO will work correctly.
13051
13052 @node Text_IO
13053 @section Text_IO
13054
13055 @noindent
13056 Text_IO files consist of a stream of characters containing the following
13057 special control characters:
13058
13059 @smallexample
13060 LF (line feed, 16#0A#) Line Mark
13061 FF (form feed, 16#0C#) Page Mark
13062 @end smallexample
13063
13064 @noindent
13065 A canonical Text_IO file is defined as one in which the following
13066 conditions are met:
13067
13068 @itemize @bullet
13069 @item
13070 The character @code{LF} is used only as a line mark, i.e.@: to mark the end
13071 of the line.
13072
13073 @item
13074 The character @code{FF} is used only as a page mark, i.e.@: to mark the
13075 end of a page and consequently can appear only immediately following a
13076 @code{LF} (line mark) character.
13077
13078 @item
13079 The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
13080 (line mark, page mark).  In the former case, the page mark is implicitly
13081 assumed to be present.
13082 @end itemize
13083
13084 @noindent
13085 A file written using Text_IO will be in canonical form provided that no
13086 explicit @code{LF} or @code{FF} characters are written using @code{Put}
13087 or @code{Put_Line}.  There will be no @code{FF} character at the end of
13088 the file unless an explicit @code{New_Page} operation was performed
13089 before closing the file.
13090
13091 A canonical Text_IO file that is a regular file (i.e., not a device or a
13092 pipe) can be read using any of the routines in Text_IO@.  The
13093 semantics in this case will be exactly as defined in the Ada Reference
13094 Manual, and all the routines in Text_IO are fully implemented.
13095
13096 A text file that does not meet the requirements for a canonical Text_IO
13097 file has one of the following:
13098
13099 @itemize @bullet
13100 @item
13101 The file contains @code{FF} characters not immediately following a
13102 @code{LF} character.
13103
13104 @item
13105 The file contains @code{LF} or @code{FF} characters written by
13106 @code{Put} or @code{Put_Line}, which are not logically considered to be
13107 line marks or page marks.
13108
13109 @item
13110 The file ends in a character other than @code{LF} or @code{FF},
13111 i.e.@: there is no explicit line mark or page mark at the end of the file.
13112 @end itemize
13113
13114 @noindent
13115 Text_IO can be used to read such non-standard text files but subprograms
13116 to do with line or page numbers do not have defined meanings.  In
13117 particular, a @code{FF} character that does not follow a @code{LF}
13118 character may or may not be treated as a page mark from the point of
13119 view of page and line numbering.  Every @code{LF} character is considered
13120 to end a line, and there is an implied @code{LF} character at the end of
13121 the file.
13122
13123 @menu
13124 * Text_IO Stream Pointer Positioning::
13125 * Text_IO Reading and Writing Non-Regular Files::
13126 * Get_Immediate::
13127 * Treating Text_IO Files as Streams::
13128 * Text_IO Extensions::
13129 * Text_IO Facilities for Unbounded Strings::
13130 @end menu
13131
13132 @node Text_IO Stream Pointer Positioning
13133 @subsection Stream Pointer Positioning
13134
13135 @noindent
13136 @code{Ada.Text_IO} has a definition of current position for a file that
13137 is being read.  No internal buffering occurs in Text_IO, and usually the
13138 physical position in the stream used to implement the file corresponds
13139 to this logical position defined by Text_IO@.  There are two exceptions:
13140
13141 @itemize @bullet
13142 @item
13143 After a call to @code{End_Of_Page} that returns @code{True}, the stream
13144 is positioned past the @code{LF} (line mark) that precedes the page
13145 mark.  Text_IO maintains an internal flag so that subsequent read
13146 operations properly handle the logical position which is unchanged by
13147 the @code{End_Of_Page} call.
13148
13149 @item
13150 After a call to @code{End_Of_File} that returns @code{True}, if the
13151 Text_IO file was positioned before the line mark at the end of file
13152 before the call, then the logical position is unchanged, but the stream
13153 is physically positioned right at the end of file (past the line mark,
13154 and past a possible page mark following the line mark.  Again Text_IO
13155 maintains internal flags so that subsequent read operations properly
13156 handle the logical position.
13157 @end itemize
13158
13159 @noindent
13160 These discrepancies have no effect on the observable behavior of
13161 Text_IO, but if a single Ada stream is shared between a C program and
13162 Ada program, or shared (using @samp{shared=yes} in the form string)
13163 between two Ada files, then the difference may be observable in some
13164 situations.
13165
13166 @node Text_IO Reading and Writing Non-Regular Files
13167 @subsection Reading and Writing Non-Regular Files
13168
13169 @noindent
13170 A non-regular file is a device (such as a keyboard), or a pipe.  Text_IO
13171 can be used for reading and writing.  Writing is not affected and the
13172 sequence of characters output is identical to the normal file case, but
13173 for reading, the behavior of Text_IO is modified to avoid undesirable
13174 look-ahead as follows:
13175
13176 An input file that is not a regular file is considered to have no page
13177 marks.  Any @code{Ascii.FF} characters (the character normally used for a
13178 page mark) appearing in the file are considered to be data
13179 characters.  In particular:
13180
13181 @itemize @bullet
13182 @item
13183 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
13184 following a line mark.  If a page mark appears, it will be treated as a
13185 data character.
13186
13187 @item
13188 This avoids the need to wait for an extra character to be typed or
13189 entered from the pipe to complete one of these operations.
13190
13191 @item
13192 @code{End_Of_Page} always returns @code{False}
13193
13194 @item
13195 @code{End_Of_File} will return @code{False} if there is a page mark at
13196 the end of the file.
13197 @end itemize
13198
13199 @noindent
13200 Output to non-regular files is the same as for regular files.  Page marks
13201 may be written to non-regular files using @code{New_Page}, but as noted
13202 above they will not be treated as page marks on input if the output is
13203 piped to another Ada program.
13204
13205 Another important discrepancy when reading non-regular files is that the end
13206 of file indication is not ``sticky''.  If an end of file is entered, e.g.@: by
13207 pressing the @key{EOT} key,
13208 then end of file
13209 is signaled once (i.e.@: the test @code{End_Of_File}
13210 will yield @code{True}, or a read will
13211 raise @code{End_Error}), but then reading can resume
13212 to read data past that end of
13213 file indication, until another end of file indication is entered.
13214
13215 @node Get_Immediate
13216 @subsection Get_Immediate
13217 @cindex Get_Immediate
13218
13219 @noindent
13220 Get_Immediate returns the next character (including control characters)
13221 from the input file.  In particular, Get_Immediate will return LF or FF
13222 characters used as line marks or page marks.  Such operations leave the
13223 file positioned past the control character, and it is thus not treated
13224 as having its normal function.  This means that page, line and column
13225 counts after this kind of Get_Immediate call are set as though the mark
13226 did not occur.  In the case where a Get_Immediate leaves the file
13227 positioned between the line mark and page mark (which is not normally
13228 possible), it is undefined whether the FF character will be treated as a
13229 page mark.
13230
13231 @node Treating Text_IO Files as Streams
13232 @subsection Treating Text_IO Files as Streams
13233 @cindex Stream files
13234
13235 @noindent
13236 The package @code{Text_IO.Streams} allows a Text_IO file to be treated
13237 as a stream.  Data written to a Text_IO file in this stream mode is
13238 binary data.  If this binary data contains bytes 16#0A# (@code{LF}) or
13239 16#0C# (@code{FF}), the resulting file may have non-standard
13240 format.  Similarly if read operations are used to read from a Text_IO
13241 file treated as a stream, then @code{LF} and @code{FF} characters may be
13242 skipped and the effect is similar to that described above for
13243 @code{Get_Immediate}.
13244
13245 @node Text_IO Extensions
13246 @subsection Text_IO Extensions
13247 @cindex Text_IO extensions
13248
13249 @noindent
13250 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
13251 to the standard @code{Text_IO} package:
13252
13253 @itemize @bullet
13254 @item function File_Exists (Name : String) return Boolean;
13255 Determines if a file of the given name exists.
13256
13257 @item function Get_Line return String;
13258 Reads a string from the standard input file.  The value returned is exactly
13259 the length of the line that was read.
13260
13261 @item function Get_Line (File : Ada.Text_IO.File_Type) return String;
13262 Similar, except that the parameter File specifies the file from which
13263 the string is to be read.
13264
13265 @end itemize
13266
13267 @node Text_IO Facilities for Unbounded Strings
13268 @subsection Text_IO Facilities for Unbounded Strings
13269 @cindex Text_IO for unbounded strings
13270 @cindex Unbounded_String, Text_IO operations
13271
13272 @noindent
13273 The package @code{Ada.Strings.Unbounded.Text_IO}
13274 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
13275 subprograms useful for Text_IO operations on unbounded strings:
13276
13277 @itemize @bullet
13278
13279 @item function Get_Line (File : File_Type) return Unbounded_String;
13280 Reads a line from the specified file
13281 and returns the result as an unbounded string.
13282
13283 @item procedure Put (File : File_Type; U : Unbounded_String);
13284 Writes the value of the given unbounded string to the specified file
13285 Similar to the effect of
13286 @code{Put (To_String (U))} except that an extra copy is avoided.
13287
13288 @item procedure Put_Line (File : File_Type; U : Unbounded_String);
13289 Writes the value of the given unbounded string to the specified file,
13290 followed by a @code{New_Line}.
13291 Similar to the effect of @code{Put_Line (To_String (U))} except
13292 that an extra copy is avoided.
13293 @end itemize
13294
13295 @noindent
13296 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
13297 and is optional.  If the parameter is omitted, then the standard input or
13298 output file is referenced as appropriate.
13299
13300 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
13301 files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended
13302 @code{Wide_Text_IO} functionality for unbounded wide strings.
13303
13304 The package @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} in library
13305 files @file{a-szuzti.ads} and @file{a-szuzti.adb} provides similar extended
13306 @code{Wide_Wide_Text_IO} functionality for unbounded wide wide strings.
13307
13308 @node Wide_Text_IO
13309 @section Wide_Text_IO
13310
13311 @noindent
13312 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
13313 both input and output files may contain special sequences that represent
13314 wide character values.  The encoding scheme for a given file may be
13315 specified using a FORM parameter:
13316
13317 @smallexample
13318 WCEM=@var{x}
13319 @end smallexample
13320
13321 @noindent
13322 as part of the FORM string (WCEM = wide character encoding method),
13323 where @var{x} is one of the following characters
13324
13325 @table @samp
13326 @item h
13327 Hex ESC encoding
13328 @item u
13329 Upper half encoding
13330 @item s
13331 Shift-JIS encoding
13332 @item e
13333 EUC Encoding
13334 @item 8
13335 UTF-8 encoding
13336 @item b
13337 Brackets encoding
13338 @end table
13339
13340 @noindent
13341 The encoding methods match those that
13342 can be used in a source
13343 program, but there is no requirement that the encoding method used for
13344 the source program be the same as the encoding method used for files,
13345 and different files may use different encoding methods.
13346
13347 The default encoding method for the standard files, and for opened files
13348 for which no WCEM parameter is given in the FORM string matches the
13349 wide character encoding specified for the main program (the default
13350 being brackets encoding if no coding method was specified with -gnatW).
13351
13352 @table @asis
13353 @item Hex Coding
13354 In this encoding, a wide character is represented by a five character
13355 sequence:
13356
13357 @smallexample
13358 ESC a b c d
13359 @end smallexample
13360
13361 @noindent
13362 where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
13363 characters (using upper case letters) of the wide character code.  For
13364 example, ESC A345 is used to represent the wide character with code
13365 16#A345#.  This scheme is compatible with use of the full
13366 @code{Wide_Character} set.
13367
13368 @item Upper Half Coding
13369 The wide character with encoding 16#abcd#, where the upper bit is on
13370 (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
13371 16#cd#.  The second byte may never be a format control character, but is
13372 not required to be in the upper half.  This method can be also used for
13373 shift-JIS or EUC where the internal coding matches the external coding.
13374
13375 @item Shift JIS Coding
13376 A wide character is represented by a two character sequence 16#ab# and
13377 16#cd#, with the restrictions described for upper half encoding as
13378 described above.  The internal character code is the corresponding JIS
13379 character according to the standard algorithm for Shift-JIS
13380 conversion.  Only characters defined in the JIS code set table can be
13381 used with this encoding method.
13382
13383 @item EUC Coding
13384 A wide character is represented by a two character sequence 16#ab# and
13385 16#cd#, with both characters being in the upper half.  The internal
13386 character code is the corresponding JIS character according to the EUC
13387 encoding algorithm.  Only characters defined in the JIS code set table
13388 can be used with this encoding method.
13389
13390 @item UTF-8 Coding
13391 A wide character is represented using
13392 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
13393 10646-1/Am.2.  Depending on the character value, the representation
13394 is a one, two, or three byte sequence:
13395
13396 @smallexample
13397 16#0000#-16#007f#: 2#0xxxxxxx#
13398 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
13399 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
13400 @end smallexample
13401
13402 @noindent
13403 where the @var{xxx} bits correspond to the left-padded bits of the
13404 16-bit character value.  Note that all lower half ASCII characters
13405 are represented as ASCII bytes and all upper half characters and
13406 other wide characters are represented as sequences of upper-half
13407 (The full UTF-8 scheme allows for encoding 31-bit characters as
13408 6-byte sequences, but in this implementation, all UTF-8 sequences
13409 of four or more bytes length will raise a Constraint_Error, as
13410 will all invalid UTF-8 sequences.)
13411
13412 @item Brackets Coding
13413 In this encoding, a wide character is represented by the following eight
13414 character sequence:
13415
13416 @smallexample
13417 [ " a b c d " ]
13418 @end smallexample
13419
13420 @noindent
13421 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
13422 characters (using uppercase letters) of the wide character code.  For
13423 example, @code{["A345"]} is used to represent the wide character with code
13424 @code{16#A345#}.
13425 This scheme is compatible with use of the full Wide_Character set.
13426 On input, brackets coding can also be used for upper half characters,
13427 e.g.@: @code{["C1"]} for lower case a.  However, on output, brackets notation
13428 is only used for wide characters with a code greater than @code{16#FF#}.
13429
13430 Note that brackets coding is not normally used in the context of
13431 Wide_Text_IO or Wide_Wide_Text_IO, since it is really just designed as
13432 a portable way of encoding source files. In the context of Wide_Text_IO
13433 or Wide_Wide_Text_IO, it can only be used if the file does not contain
13434 any instance of the left bracket character other than to encode wide
13435 character values using the brackets encoding method. In practice it is
13436 expected that some standard wide character encoding method such
13437 as UTF-8 will be used for text input output.
13438
13439 If brackets notation is used, then any occurrence of a left bracket
13440 in the input file which is not the start of a valid wide character
13441 sequence will cause Constraint_Error to be raised. It is possible to
13442 encode a left bracket as ["5B"] and Wide_Text_IO and Wide_Wide_Text_IO
13443 input will interpret this as a left bracket.
13444
13445 However, when a left bracket is output, it will be output as a left bracket
13446 and not as ["5B"]. We make this decision because for normal use of
13447 Wide_Text_IO for outputting messages, it is unpleasant to clobber left
13448 brackets. For example, if we write:
13449
13450 @smallexample
13451    Put_Line ("Start of output [first run]");
13452 @end smallexample
13453
13454 @noindent
13455 we really do not want to have the left bracket in this message clobbered so
13456 that the output reads:
13457
13458 @smallexample
13459    Start of output ["5B"]first run]
13460 @end smallexample
13461
13462 @noindent
13463 In practice brackets encoding is reasonably useful for normal Put_Line use
13464 since we won't get confused between left brackets and wide character
13465 sequences in the output. But for input, or when files are written out
13466 and read back in, it really makes better sense to use one of the standard
13467 encoding methods such as UTF-8.
13468
13469 @end table
13470
13471 @noindent
13472 For the coding schemes other than UTF-8, Hex, or Brackets encoding,
13473 not all wide character
13474 values can be represented.  An attempt to output a character that cannot
13475 be represented using the encoding scheme for the file causes
13476 Constraint_Error to be raised.  An invalid wide character sequence on
13477 input also causes Constraint_Error to be raised.
13478
13479 @menu
13480 * Wide_Text_IO Stream Pointer Positioning::
13481 * Wide_Text_IO Reading and Writing Non-Regular Files::
13482 @end menu
13483
13484 @node Wide_Text_IO Stream Pointer Positioning
13485 @subsection Stream Pointer Positioning
13486
13487 @noindent
13488 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
13489 of stream pointer positioning (@pxref{Text_IO}).  There is one additional
13490 case:
13491
13492 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
13493 normal lower ASCII set (i.e.@: a character in the range:
13494
13495 @smallexample @c ada
13496 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
13497 @end smallexample
13498
13499 @noindent
13500 then although the logical position of the file pointer is unchanged by
13501 the @code{Look_Ahead} call, the stream is physically positioned past the
13502 wide character sequence.  Again this is to avoid the need for buffering
13503 or backup, and all @code{Wide_Text_IO} routines check the internal
13504 indication that this situation has occurred so that this is not visible
13505 to a normal program using @code{Wide_Text_IO}.  However, this discrepancy
13506 can be observed if the wide text file shares a stream with another file.
13507
13508 @node Wide_Text_IO Reading and Writing Non-Regular Files
13509 @subsection Reading and Writing Non-Regular Files
13510
13511 @noindent
13512 As in the case of Text_IO, when a non-regular file is read, it is
13513 assumed that the file contains no page marks (any form characters are
13514 treated as data characters), and @code{End_Of_Page} always returns
13515 @code{False}.  Similarly, the end of file indication is not sticky, so
13516 it is possible to read beyond an end of file.
13517
13518 @node Wide_Wide_Text_IO
13519 @section Wide_Wide_Text_IO
13520
13521 @noindent
13522 @code{Wide_Wide_Text_IO} is similar in most respects to Text_IO, except that
13523 both input and output files may contain special sequences that represent
13524 wide wide character values.  The encoding scheme for a given file may be
13525 specified using a FORM parameter:
13526
13527 @smallexample
13528 WCEM=@var{x}
13529 @end smallexample
13530
13531 @noindent
13532 as part of the FORM string (WCEM = wide character encoding method),
13533 where @var{x} is one of the following characters
13534
13535 @table @samp
13536 @item h
13537 Hex ESC encoding
13538 @item u
13539 Upper half encoding
13540 @item s
13541 Shift-JIS encoding
13542 @item e
13543 EUC Encoding
13544 @item 8
13545 UTF-8 encoding
13546 @item b
13547 Brackets encoding
13548 @end table
13549
13550 @noindent
13551 The encoding methods match those that
13552 can be used in a source
13553 program, but there is no requirement that the encoding method used for
13554 the source program be the same as the encoding method used for files,
13555 and different files may use different encoding methods.
13556
13557 The default encoding method for the standard files, and for opened files
13558 for which no WCEM parameter is given in the FORM string matches the
13559 wide character encoding specified for the main program (the default
13560 being brackets encoding if no coding method was specified with -gnatW).
13561
13562 @table @asis
13563
13564 @item UTF-8 Coding
13565 A wide character is represented using
13566 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
13567 10646-1/Am.2.  Depending on the character value, the representation
13568 is a one, two, three, or four byte sequence:
13569
13570 @smallexample
13571 16#000000#-16#00007f#: 2#0xxxxxxx#
13572 16#000080#-16#0007ff#: 2#110xxxxx# 2#10xxxxxx#
13573 16#000800#-16#00ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
13574 16#010000#-16#10ffff#: 2#11110xxx# 2#10xxxxxx# 2#10xxxxxx# 2#10xxxxxx#
13575 @end smallexample
13576
13577 @noindent
13578 where the @var{xxx} bits correspond to the left-padded bits of the
13579 21-bit character value.  Note that all lower half ASCII characters
13580 are represented as ASCII bytes and all upper half characters and
13581 other wide characters are represented as sequences of upper-half
13582 characters.
13583
13584 @item Brackets Coding
13585 In this encoding, a wide wide character is represented by the following eight
13586 character sequence if is in wide character range
13587
13588 @smallexample
13589 [ " a b c d " ]
13590 @end smallexample
13591
13592 and by the following ten character sequence if not
13593
13594 @smallexample
13595 [ " a b c d e f " ]
13596 @end smallexample
13597
13598 @noindent
13599 where @code{a}, @code{b}, @code{c}, @code{d}, @code{e}, and @code{f}
13600 are the four or six hexadecimal
13601 characters (using uppercase letters) of the wide wide character code.  For
13602 example, @code{["01A345"]} is used to represent the wide wide character
13603 with code @code{16#01A345#}.
13604
13605 This scheme is compatible with use of the full Wide_Wide_Character set.
13606 On input, brackets coding can also be used for upper half characters,
13607 e.g.@: @code{["C1"]} for lower case a.  However, on output, brackets notation
13608 is only used for wide characters with a code greater than @code{16#FF#}.
13609
13610 @end table
13611
13612 @noindent
13613 If is also possible to use the other Wide_Character encoding methods,
13614 such as Shift-JIS, but the other schemes cannot support the full range
13615 of wide wide characters.
13616 An attempt to output a character that cannot
13617 be represented using the encoding scheme for the file causes
13618 Constraint_Error to be raised.  An invalid wide character sequence on
13619 input also causes Constraint_Error to be raised.
13620
13621 @menu
13622 * Wide_Wide_Text_IO Stream Pointer Positioning::
13623 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
13624 @end menu
13625
13626 @node Wide_Wide_Text_IO Stream Pointer Positioning
13627 @subsection Stream Pointer Positioning
13628
13629 @noindent
13630 @code{Ada.Wide_Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
13631 of stream pointer positioning (@pxref{Text_IO}).  There is one additional
13632 case:
13633
13634 If @code{Ada.Wide_Wide_Text_IO.Look_Ahead} reads a character outside the
13635 normal lower ASCII set (i.e.@: a character in the range:
13636
13637 @smallexample @c ada
13638 Wide_Wide_Character'Val (16#0080#) .. Wide_Wide_Character'Val (16#10FFFF#)
13639 @end smallexample
13640
13641 @noindent
13642 then although the logical position of the file pointer is unchanged by
13643 the @code{Look_Ahead} call, the stream is physically positioned past the
13644 wide character sequence.  Again this is to avoid the need for buffering
13645 or backup, and all @code{Wide_Wide_Text_IO} routines check the internal
13646 indication that this situation has occurred so that this is not visible
13647 to a normal program using @code{Wide_Wide_Text_IO}.  However, this discrepancy
13648 can be observed if the wide text file shares a stream with another file.
13649
13650 @node Wide_Wide_Text_IO Reading and Writing Non-Regular Files
13651 @subsection Reading and Writing Non-Regular Files
13652
13653 @noindent
13654 As in the case of Text_IO, when a non-regular file is read, it is
13655 assumed that the file contains no page marks (any form characters are
13656 treated as data characters), and @code{End_Of_Page} always returns
13657 @code{False}.  Similarly, the end of file indication is not sticky, so
13658 it is possible to read beyond an end of file.
13659
13660 @node Stream_IO
13661 @section Stream_IO
13662
13663 @noindent
13664 A stream file is a sequence of bytes, where individual elements are
13665 written to the file as described in the Ada Reference Manual.  The type
13666 @code{Stream_Element} is simply a byte.  There are two ways to read or
13667 write a stream file.
13668
13669 @itemize @bullet
13670 @item
13671 The operations @code{Read} and @code{Write} directly read or write a
13672 sequence of stream elements with no control information.
13673
13674 @item
13675 The stream attributes applied to a stream file transfer data in the
13676 manner described for stream attributes.
13677 @end itemize
13678
13679 @node Text Translation
13680 @section Text Translation
13681
13682 @noindent
13683 @samp{Text_Translation=@var{xxx}} may be used as the Form parameter
13684 passed to Text_IO.Create and Text_IO.Open:
13685 @samp{Text_Translation=@var{Yes}} is the default, which means to
13686 translate LF to/from CR/LF on Windows systems.
13687 @samp{Text_Translation=@var{No}} disables this translation; i.e. it
13688 uses binary mode. For output files, @samp{Text_Translation=@var{No}}
13689 may be used to create Unix-style files on
13690 Windows. @samp{Text_Translation=@var{xxx}} has no effect on Unix
13691 systems.
13692
13693 @node Shared Files
13694 @section Shared Files
13695
13696 @noindent
13697 Section A.14 of the Ada Reference Manual allows implementations to
13698 provide a wide variety of behavior if an attempt is made to access the
13699 same external file with two or more internal files.
13700
13701 To provide a full range of functionality, while at the same time
13702 minimizing the problems of portability caused by this implementation
13703 dependence, GNAT handles file sharing as follows:
13704
13705 @itemize @bullet
13706 @item
13707 In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
13708 to open two or more files with the same full name is considered an error
13709 and is not supported.  The exception @code{Use_Error} will be
13710 raised.  Note that a file that is not explicitly closed by the program
13711 remains open until the program terminates.
13712
13713 @item
13714 If the form parameter @samp{shared=no} appears in the form string, the
13715 file can be opened or created with its own separate stream identifier,
13716 regardless of whether other files sharing the same external file are
13717 opened.  The exact effect depends on how the C stream routines handle
13718 multiple accesses to the same external files using separate streams.
13719
13720 @item
13721 If the form parameter @samp{shared=yes} appears in the form string for
13722 each of two or more files opened using the same full name, the same
13723 stream is shared between these files, and the semantics are as described
13724 in Ada Reference Manual, Section A.14.
13725 @end itemize
13726
13727 @noindent
13728 When a program that opens multiple files with the same name is ported
13729 from another Ada compiler to GNAT, the effect will be that
13730 @code{Use_Error} is raised.
13731
13732 The documentation of the original compiler and the documentation of the
13733 program should then be examined to determine if file sharing was
13734 expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
13735 and @code{Create} calls as required.
13736
13737 When a program is ported from GNAT to some other Ada compiler, no
13738 special attention is required unless the @samp{shared=@var{xxx}} form
13739 parameter is used in the program.  In this case, you must examine the
13740 documentation of the new compiler to see if it supports the required
13741 file sharing semantics, and form strings modified appropriately.  Of
13742 course it may be the case that the program cannot be ported if the
13743 target compiler does not support the required functionality.  The best
13744 approach in writing portable code is to avoid file sharing (and hence
13745 the use of the @samp{shared=@var{xxx}} parameter in the form string)
13746 completely.
13747
13748 One common use of file sharing in Ada 83 is the use of instantiations of
13749 Sequential_IO on the same file with different types, to achieve
13750 heterogeneous input-output.  Although this approach will work in GNAT if
13751 @samp{shared=yes} is specified, it is preferable in Ada to use Stream_IO
13752 for this purpose (using the stream attributes)
13753
13754 @node Filenames encoding
13755 @section Filenames encoding
13756
13757 @noindent
13758 An encoding form parameter can be used to specify the filename
13759 encoding @samp{encoding=@var{xxx}}.
13760
13761 @itemize @bullet
13762 @item
13763 If the form parameter @samp{encoding=utf8} appears in the form string, the
13764 filename must be encoded in UTF-8.
13765
13766 @item
13767 If the form parameter @samp{encoding=8bits} appears in the form
13768 string, the filename must be a standard 8bits string.
13769 @end itemize
13770
13771 In the absence of a @samp{encoding=@var{xxx}} form parameter, the
13772 encoding is controlled by the @samp{GNAT_CODE_PAGE} environment
13773 variable. And if not set @samp{utf8} is assumed.
13774
13775 @table @samp
13776 @item CP_ACP
13777 The current system Windows ANSI code page.
13778 @item CP_UTF8
13779 UTF-8 encoding
13780 @end table
13781
13782 This encoding form parameter is only supported on the Windows
13783 platform. On the other Operating Systems the run-time is supporting
13784 UTF-8 natively.
13785
13786 @node Open Modes
13787 @section Open Modes
13788
13789 @noindent
13790 @code{Open} and @code{Create} calls result in a call to @code{fopen}
13791 using the mode shown in the following table:
13792
13793 @sp 2
13794 @center @code{Open} and @code{Create} Call Modes
13795 @smallexample
13796                                @b{OPEN }           @b{CREATE}
13797 Append_File                    "r+"             "w+"
13798 In_File                        "r"              "w+"
13799 Out_File (Direct_IO)           "r+"             "w"
13800 Out_File (all other cases)     "w"              "w"
13801 Inout_File                     "r+"             "w+"
13802 @end smallexample
13803
13804 @noindent
13805 If text file translation is required, then either @samp{b} or @samp{t}
13806 is added to the mode, depending on the setting of Text.  Text file
13807 translation refers to the mapping of CR/LF sequences in an external file
13808 to LF characters internally.  This mapping only occurs in DOS and
13809 DOS-like systems, and is not relevant to other systems.
13810
13811 A special case occurs with Stream_IO@.  As shown in the above table, the
13812 file is initially opened in @samp{r} or @samp{w} mode for the
13813 @code{In_File} and @code{Out_File} cases.  If a @code{Set_Mode} operation
13814 subsequently requires switching from reading to writing or vice-versa,
13815 then the file is reopened in @samp{r+} mode to permit the required operation.
13816
13817 @node Operations on C Streams
13818 @section Operations on C Streams
13819 The package @code{Interfaces.C_Streams} provides an Ada program with direct
13820 access to the C library functions for operations on C streams:
13821
13822 @smallexample @c adanocomment
13823 package Interfaces.C_Streams is
13824   -- Note: the reason we do not use the types that are in
13825   -- Interfaces.C is that we want to avoid dragging in the
13826   -- code in this unit if possible.
13827   subtype chars is System.Address;
13828   -- Pointer to null-terminated array of characters
13829   subtype FILEs is System.Address;
13830   -- Corresponds to the C type FILE*
13831   subtype voids is System.Address;
13832   -- Corresponds to the C type void*
13833   subtype int is Integer;
13834   subtype long is Long_Integer;
13835   -- Note: the above types are subtypes deliberately, and it
13836   -- is part of this spec that the above correspondences are
13837   -- guaranteed.  This means that it is legitimate to, for
13838   -- example, use Integer instead of int.  We provide these
13839   -- synonyms for clarity, but in some cases it may be
13840   -- convenient to use the underlying types (for example to
13841   -- avoid an unnecessary dependency of a spec on the spec
13842   -- of this unit).
13843   type size_t is mod 2 ** Standard'Address_Size;
13844   NULL_Stream : constant FILEs;
13845   -- Value returned (NULL in C) to indicate an
13846   -- fdopen/fopen/tmpfile error
13847   ----------------------------------
13848   -- Constants Defined in stdio.h --
13849   ----------------------------------
13850   EOF : constant int;
13851   -- Used by a number of routines to indicate error or
13852   -- end of file
13853   IOFBF : constant int;
13854   IOLBF : constant int;
13855   IONBF : constant int;
13856   -- Used to indicate buffering mode for setvbuf call
13857   SEEK_CUR : constant int;
13858   SEEK_END : constant int;
13859   SEEK_SET : constant int;
13860   -- Used to indicate origin for fseek call
13861   function stdin return FILEs;
13862   function stdout return FILEs;
13863   function stderr return FILEs;
13864   -- Streams associated with standard files
13865   --------------------------
13866   -- Standard C functions --
13867   --------------------------
13868   -- The functions selected below are ones that are
13869   -- available in UNIX (but not necessarily in ANSI C).
13870   -- These are very thin interfaces
13871   -- which copy exactly the C headers.  For more
13872   -- documentation on these functions, see the Microsoft C
13873   -- "Run-Time Library Reference" (Microsoft Press, 1990,
13874   -- ISBN 1-55615-225-6), which includes useful information
13875   -- on system compatibility.
13876   procedure clearerr (stream : FILEs);
13877   function fclose (stream : FILEs) return int;
13878   function fdopen (handle : int; mode : chars) return FILEs;
13879   function feof (stream : FILEs) return int;
13880   function ferror (stream : FILEs) return int;
13881   function fflush (stream : FILEs) return int;
13882   function fgetc (stream : FILEs) return int;
13883   function fgets (strng : chars; n : int; stream : FILEs)
13884       return chars;
13885   function fileno (stream : FILEs) return int;
13886   function fopen (filename : chars; Mode : chars)
13887       return FILEs;
13888   -- Note: to maintain target independence, use
13889   -- text_translation_required, a boolean variable defined in
13890   -- a-sysdep.c to deal with the target dependent text
13891   -- translation requirement.  If this variable is set,
13892   -- then  b/t should be appended to the standard mode
13893   -- argument to set the text translation mode off or on
13894   -- as required.
13895   function fputc (C : int; stream : FILEs) return int;
13896   function fputs (Strng : chars; Stream : FILEs) return int;
13897   function fread
13898      (buffer : voids;
13899       size : size_t;
13900       count : size_t;
13901       stream : FILEs)
13902       return size_t;
13903   function freopen
13904      (filename : chars;
13905       mode : chars;
13906       stream : FILEs)
13907       return FILEs;
13908   function fseek
13909      (stream : FILEs;
13910       offset : long;
13911       origin : int)
13912       return int;
13913   function ftell (stream : FILEs) return long;
13914   function fwrite
13915      (buffer : voids;
13916       size : size_t;
13917       count : size_t;
13918       stream : FILEs)
13919       return size_t;
13920   function isatty (handle : int) return int;
13921   procedure mktemp (template : chars);
13922   -- The return value (which is just a pointer to template)
13923   -- is discarded
13924   procedure rewind (stream : FILEs);
13925   function rmtmp return int;
13926   function setvbuf
13927      (stream : FILEs;
13928       buffer : chars;
13929       mode : int;
13930       size : size_t)
13931       return int;
13932
13933   function tmpfile return FILEs;
13934   function ungetc (c : int; stream : FILEs) return int;
13935   function unlink (filename : chars) return int;
13936   ---------------------
13937   -- Extra functions --
13938   ---------------------
13939   -- These functions supply slightly thicker bindings than
13940   -- those above.  They are derived from functions in the
13941   -- C Run-Time Library, but may do a bit more work than
13942   -- just directly calling one of the Library functions.
13943   function is_regular_file (handle : int) return int;
13944   -- Tests if given handle is for a regular file (result 1)
13945   -- or for a non-regular file (pipe or device, result 0).
13946   ---------------------------------
13947   -- Control of Text/Binary Mode --
13948   ---------------------------------
13949   -- If text_translation_required is true, then the following
13950   -- functions may be used to dynamically switch a file from
13951   -- binary to text mode or vice versa.  These functions have
13952   -- no effect if text_translation_required is false (i.e.@: in
13953   -- normal UNIX mode).  Use fileno to get a stream handle.
13954   procedure set_binary_mode (handle : int);
13955   procedure set_text_mode (handle : int);
13956   ----------------------------
13957   -- Full Path Name support --
13958   ----------------------------
13959   procedure full_name (nam : chars; buffer : chars);
13960   -- Given a NUL terminated string representing a file
13961   -- name, returns in buffer a NUL terminated string
13962   -- representing the full path name for the file name.
13963   -- On systems where it is relevant the   drive is also
13964   -- part of the full path name.  It is the responsibility
13965   -- of the caller to pass an actual parameter for buffer
13966   -- that is big enough for any full path name.  Use
13967   -- max_path_len given below as the size of buffer.
13968   max_path_len : integer;
13969   -- Maximum length of an allowable full path name on the
13970   -- system, including a terminating NUL character.
13971 end Interfaces.C_Streams;
13972 @end smallexample
13973
13974 @node Interfacing to C Streams
13975 @section Interfacing to C Streams
13976
13977 @noindent
13978 The packages in this section permit interfacing Ada files to C Stream
13979 operations.
13980
13981 @smallexample @c ada
13982  with Interfaces.C_Streams;
13983  package Ada.Sequential_IO.C_Streams is
13984     function C_Stream (F : File_Type)
13985        return Interfaces.C_Streams.FILEs;
13986     procedure Open
13987       (File : in out File_Type;
13988        Mode : in File_Mode;
13989        C_Stream : in Interfaces.C_Streams.FILEs;
13990        Form : in String := "");
13991  end Ada.Sequential_IO.C_Streams;
13992
13993   with Interfaces.C_Streams;
13994   package Ada.Direct_IO.C_Streams is
13995      function C_Stream (F : File_Type)
13996         return Interfaces.C_Streams.FILEs;
13997      procedure Open
13998        (File : in out File_Type;
13999         Mode : in File_Mode;
14000         C_Stream : in Interfaces.C_Streams.FILEs;
14001         Form : in String := "");
14002   end Ada.Direct_IO.C_Streams;
14003
14004   with Interfaces.C_Streams;
14005   package Ada.Text_IO.C_Streams is
14006      function C_Stream (F : File_Type)
14007         return Interfaces.C_Streams.FILEs;
14008      procedure Open
14009        (File : in out File_Type;
14010         Mode : in File_Mode;
14011         C_Stream : in Interfaces.C_Streams.FILEs;
14012         Form : in String := "");
14013   end Ada.Text_IO.C_Streams;
14014
14015   with Interfaces.C_Streams;
14016   package Ada.Wide_Text_IO.C_Streams is
14017      function C_Stream (F : File_Type)
14018         return Interfaces.C_Streams.FILEs;
14019      procedure Open
14020        (File : in out File_Type;
14021         Mode : in File_Mode;
14022         C_Stream : in Interfaces.C_Streams.FILEs;
14023         Form : in String := "");
14024  end Ada.Wide_Text_IO.C_Streams;
14025
14026   with Interfaces.C_Streams;
14027   package Ada.Wide_Wide_Text_IO.C_Streams is
14028      function C_Stream (F : File_Type)
14029         return Interfaces.C_Streams.FILEs;
14030      procedure Open
14031        (File : in out File_Type;
14032         Mode : in File_Mode;
14033         C_Stream : in Interfaces.C_Streams.FILEs;
14034         Form : in String := "");
14035  end Ada.Wide_Wide_Text_IO.C_Streams;
14036
14037  with Interfaces.C_Streams;
14038  package Ada.Stream_IO.C_Streams is
14039     function C_Stream (F : File_Type)
14040        return Interfaces.C_Streams.FILEs;
14041     procedure Open
14042       (File : in out File_Type;
14043        Mode : in File_Mode;
14044        C_Stream : in Interfaces.C_Streams.FILEs;
14045        Form : in String := "");
14046  end Ada.Stream_IO.C_Streams;
14047 @end smallexample
14048
14049 @noindent
14050 In each of these six packages, the @code{C_Stream} function obtains the
14051 @code{FILE} pointer from a currently opened Ada file.  It is then
14052 possible to use the @code{Interfaces.C_Streams} package to operate on
14053 this stream, or the stream can be passed to a C program which can
14054 operate on it directly.  Of course the program is responsible for
14055 ensuring that only appropriate sequences of operations are executed.
14056
14057 One particular use of relevance to an Ada program is that the
14058 @code{setvbuf} function can be used to control the buffering of the
14059 stream used by an Ada file.  In the absence of such a call the standard
14060 default buffering is used.
14061
14062 The @code{Open} procedures in these packages open a file giving an
14063 existing C Stream instead of a file name.  Typically this stream is
14064 imported from a C program, allowing an Ada file to operate on an
14065 existing C file.
14066
14067 @node The GNAT Library
14068 @chapter The GNAT Library
14069
14070 @noindent
14071 The GNAT library contains a number of general and special purpose packages.
14072 It represents functionality that the GNAT developers have found useful, and
14073 which is made available to GNAT users.  The packages described here are fully
14074 supported, and upwards compatibility will be maintained in future releases,
14075 so you can use these facilities with the confidence that the same functionality
14076 will be available in future releases.
14077
14078 The chapter here simply gives a brief summary of the facilities available.
14079 The full documentation is found in the spec file for the package.  The full
14080 sources of these library packages, including both spec and body, are provided
14081 with all GNAT releases.  For example, to find out the full specifications of
14082 the SPITBOL pattern matching capability, including a full tutorial and
14083 extensive examples, look in the @file{g-spipat.ads} file in the library.
14084
14085 For each entry here, the package name (as it would appear in a @code{with}
14086 clause) is given, followed by the name of the corresponding spec file in
14087 parentheses.  The packages are children in four hierarchies, @code{Ada},
14088 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
14089 GNAT-specific hierarchy.
14090
14091 Note that an application program should only use packages in one of these
14092 four hierarchies if the package is defined in the Ada Reference Manual,
14093 or is listed in this section of the GNAT Programmers Reference Manual.
14094 All other units should be considered internal implementation units and
14095 should not be directly @code{with}'ed by application code.  The use of
14096 a @code{with} statement that references one of these internal implementation
14097 units makes an application potentially dependent on changes in versions
14098 of GNAT, and will generate a warning message.
14099
14100 @menu
14101 * Ada.Characters.Latin_9 (a-chlat9.ads)::
14102 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
14103 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
14104 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
14105 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
14106 * Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)::
14107 * Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)::
14108 * Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)::
14109 * Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)::
14110 * Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)::
14111 * Ada.Containers.Formal_Vectors (a-cofove.ads)::
14112 * Ada.Command_Line.Environment (a-colien.ads)::
14113 * Ada.Command_Line.Remove (a-colire.ads)::
14114 * Ada.Command_Line.Response_File (a-clrefi.ads)::
14115 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
14116 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
14117 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
14118 * Ada.Exceptions.Traceback (a-exctra.ads)::
14119 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
14120 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
14121 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
14122 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
14123 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
14124 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
14125 * Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)::
14126 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
14127 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
14128 * Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)::
14129 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
14130 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
14131 * Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)::
14132 * GNAT.Altivec (g-altive.ads)::
14133 * GNAT.Altivec.Conversions (g-altcon.ads)::
14134 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
14135 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
14136 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
14137 * GNAT.Array_Split (g-arrspl.ads)::
14138 * GNAT.AWK (g-awk.ads)::
14139 * GNAT.Bounded_Buffers (g-boubuf.ads)::
14140 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
14141 * GNAT.Bubble_Sort (g-bubsor.ads)::
14142 * GNAT.Bubble_Sort_A (g-busora.ads)::
14143 * GNAT.Bubble_Sort_G (g-busorg.ads)::
14144 * GNAT.Byte_Order_Mark (g-byorma.ads)::
14145 * GNAT.Byte_Swapping (g-bytswa.ads)::
14146 * GNAT.Calendar (g-calend.ads)::
14147 * GNAT.Calendar.Time_IO (g-catiio.ads)::
14148 * GNAT.Case_Util (g-casuti.ads)::
14149 * GNAT.CGI (g-cgi.ads)::
14150 * GNAT.CGI.Cookie (g-cgicoo.ads)::
14151 * GNAT.CGI.Debug (g-cgideb.ads)::
14152 * GNAT.Command_Line (g-comlin.ads)::
14153 * GNAT.Compiler_Version (g-comver.ads)::
14154 * GNAT.Ctrl_C (g-ctrl_c.ads)::
14155 * GNAT.CRC32 (g-crc32.ads)::
14156 * GNAT.Current_Exception (g-curexc.ads)::
14157 * GNAT.Debug_Pools (g-debpoo.ads)::
14158 * GNAT.Debug_Utilities (g-debuti.ads)::
14159 * GNAT.Decode_String (g-decstr.ads)::
14160 * GNAT.Decode_UTF8_String (g-deutst.ads)::
14161 * GNAT.Directory_Operations (g-dirope.ads)::
14162 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
14163 * GNAT.Dynamic_HTables (g-dynhta.ads)::
14164 * GNAT.Dynamic_Tables (g-dyntab.ads)::
14165 * GNAT.Encode_String (g-encstr.ads)::
14166 * GNAT.Encode_UTF8_String (g-enutst.ads)::
14167 * GNAT.Exception_Actions (g-excact.ads)::
14168 * GNAT.Exception_Traces (g-exctra.ads)::
14169 * GNAT.Exceptions (g-except.ads)::
14170 * GNAT.Expect (g-expect.ads)::
14171 * GNAT.Expect.TTY (g-exptty.ads)::
14172 * GNAT.Float_Control (g-flocon.ads)::
14173 * GNAT.Heap_Sort (g-heasor.ads)::
14174 * GNAT.Heap_Sort_A (g-hesora.ads)::
14175 * GNAT.Heap_Sort_G (g-hesorg.ads)::
14176 * GNAT.HTable (g-htable.ads)::
14177 * GNAT.IO (g-io.ads)::
14178 * GNAT.IO_Aux (g-io_aux.ads)::
14179 * GNAT.Lock_Files (g-locfil.ads)::
14180 * GNAT.MBBS_Discrete_Random (g-mbdira.ads)::
14181 * GNAT.MBBS_Float_Random (g-mbflra.ads)::
14182 * GNAT.MD5 (g-md5.ads)::
14183 * GNAT.Memory_Dump (g-memdum.ads)::
14184 * GNAT.Most_Recent_Exception (g-moreex.ads)::
14185 * GNAT.OS_Lib (g-os_lib.ads)::
14186 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
14187 * GNAT.Random_Numbers (g-rannum.ads)::
14188 * GNAT.Regexp (g-regexp.ads)::
14189 * GNAT.Registry (g-regist.ads)::
14190 * GNAT.Regpat (g-regpat.ads)::
14191 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
14192 * GNAT.Semaphores (g-semaph.ads)::
14193 * GNAT.Serial_Communications (g-sercom.ads)::
14194 * GNAT.SHA1 (g-sha1.ads)::
14195 * GNAT.SHA224 (g-sha224.ads)::
14196 * GNAT.SHA256 (g-sha256.ads)::
14197 * GNAT.SHA384 (g-sha384.ads)::
14198 * GNAT.SHA512 (g-sha512.ads)::
14199 * GNAT.Signals (g-signal.ads)::
14200 * GNAT.Sockets (g-socket.ads)::
14201 * GNAT.Source_Info (g-souinf.ads)::
14202 * GNAT.Spelling_Checker (g-speche.ads)::
14203 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
14204 * GNAT.Spitbol.Patterns (g-spipat.ads)::
14205 * GNAT.Spitbol (g-spitbo.ads)::
14206 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
14207 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
14208 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
14209 * GNAT.SSE (g-sse.ads)::
14210 * GNAT.SSE.Vector_Types (g-ssvety.ads)::
14211 * GNAT.Strings (g-string.ads)::
14212 * GNAT.String_Split (g-strspl.ads)::
14213 * GNAT.Table (g-table.ads)::
14214 * GNAT.Task_Lock (g-tasloc.ads)::
14215 * GNAT.Threads (g-thread.ads)::
14216 * GNAT.Time_Stamp (g-timsta.ads)::
14217 * GNAT.Traceback (g-traceb.ads)::
14218 * GNAT.Traceback.Symbolic (g-trasym.ads)::
14219 * GNAT.UTF_32 (g-utf_32.ads)::
14220 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
14221 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
14222 * GNAT.Wide_String_Split (g-wistsp.ads)::
14223 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
14224 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
14225 * Interfaces.C.Extensions (i-cexten.ads)::
14226 * Interfaces.C.Streams (i-cstrea.ads)::
14227 * Interfaces.CPP (i-cpp.ads)::
14228 * Interfaces.Packed_Decimal (i-pacdec.ads)::
14229 * Interfaces.VxWorks (i-vxwork.ads)::
14230 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
14231 * System.Address_Image (s-addima.ads)::
14232 * System.Assertions (s-assert.ads)::
14233 * System.Memory (s-memory.ads)::
14234 * System.Partition_Interface (s-parint.ads)::
14235 * System.Pool_Global (s-pooglo.ads)::
14236 * System.Pool_Local (s-pooloc.ads)::
14237 * System.Restrictions (s-restri.ads)::
14238 * System.Rident (s-rident.ads)::
14239 * System.Strings.Stream_Ops (s-ststop.ads)::
14240 * System.Task_Info (s-tasinf.ads)::
14241 * System.Wch_Cnv (s-wchcnv.ads)::
14242 * System.Wch_Con (s-wchcon.ads)::
14243 @end menu
14244
14245 @node Ada.Characters.Latin_9 (a-chlat9.ads)
14246 @section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
14247 @cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
14248 @cindex Latin_9 constants for Character
14249
14250 @noindent
14251 This child of @code{Ada.Characters}
14252 provides a set of definitions corresponding to those in the
14253 RM-defined package @code{Ada.Characters.Latin_1} but with the
14254 few modifications required for @code{Latin-9}
14255 The provision of such a package
14256 is specifically authorized by the Ada Reference Manual
14257 (RM A.3.3(27)).
14258
14259 @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
14260 @section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
14261 @cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
14262 @cindex Latin_1 constants for Wide_Character
14263
14264 @noindent
14265 This child of @code{Ada.Characters}
14266 provides a set of definitions corresponding to those in the
14267 RM-defined package @code{Ada.Characters.Latin_1} but with the
14268 types of the constants being @code{Wide_Character}
14269 instead of @code{Character}.  The provision of such a package
14270 is specifically authorized by the Ada Reference Manual
14271 (RM A.3.3(27)).
14272
14273 @node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
14274 @section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
14275 @cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
14276 @cindex Latin_9 constants for Wide_Character
14277
14278 @noindent
14279 This child of @code{Ada.Characters}
14280 provides a set of definitions corresponding to those in the
14281 GNAT defined package @code{Ada.Characters.Latin_9} but with the
14282 types of the constants being @code{Wide_Character}
14283 instead of @code{Character}.  The provision of such a package
14284 is specifically authorized by the Ada Reference Manual
14285 (RM A.3.3(27)).
14286
14287 @node Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)
14288 @section @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
14289 @cindex @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
14290 @cindex Latin_1 constants for Wide_Wide_Character
14291
14292 @noindent
14293 This child of @code{Ada.Characters}
14294 provides a set of definitions corresponding to those in the
14295 RM-defined package @code{Ada.Characters.Latin_1} but with the
14296 types of the constants being @code{Wide_Wide_Character}
14297 instead of @code{Character}.  The provision of such a package
14298 is specifically authorized by the Ada Reference Manual
14299 (RM A.3.3(27)).
14300
14301 @node Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)
14302 @section @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
14303 @cindex @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
14304 @cindex Latin_9 constants for Wide_Wide_Character
14305
14306 @noindent
14307 This child of @code{Ada.Characters}
14308 provides a set of definitions corresponding to those in the
14309 GNAT defined package @code{Ada.Characters.Latin_9} but with the
14310 types of the constants being @code{Wide_Wide_Character}
14311 instead of @code{Character}.  The provision of such a package
14312 is specifically authorized by the Ada Reference Manual
14313 (RM A.3.3(27)).
14314
14315 @node Ada.Containers.Formal_Doubly_Linked_Lists (a-cfdlli.ads)
14316 @section @code{Ada.Containers.Formal_Doubly_Linked_Lists} (@file{a-cfdlli.ads})
14317 @cindex @code{Ada.Containers.Formal_Doubly_Linked_Lists} (@file{a-cfdlli.ads})
14318 @cindex Formal container for doubly linked lists
14319
14320 @noindent
14321 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
14322 container for doubly linked lists, meant to facilitate formal verification of
14323 code using such containers.
14324
14325 @node Ada.Containers.Formal_Hashed_Maps (a-cfhama.ads)
14326 @section @code{Ada.Containers.Formal_Hashed_Maps} (@file{a-cfhama.ads})
14327 @cindex @code{Ada.Containers.Formal_Hashed_Maps} (@file{a-cfhama.ads})
14328 @cindex Formal container for hashed maps
14329
14330 @noindent
14331 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
14332 container for hashed maps, meant to facilitate formal verification of
14333 code using such containers.
14334
14335 @node Ada.Containers.Formal_Hashed_Sets (a-cfhase.ads)
14336 @section @code{Ada.Containers.Formal_Hashed_Sets} (@file{a-cfhase.ads})
14337 @cindex @code{Ada.Containers.Formal_Hashed_Sets} (@file{a-cfhase.ads})
14338 @cindex Formal container for hashed sets
14339
14340 @noindent
14341 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
14342 container for hashed sets, meant to facilitate formal verification of
14343 code using such containers.
14344
14345 @node Ada.Containers.Formal_Ordered_Maps (a-cforma.ads)
14346 @section @code{Ada.Containers.Formal_Ordered_Maps} (@file{a-cforma.ads})
14347 @cindex @code{Ada.Containers.Formal_Ordered_Maps} (@file{a-cforma.ads})
14348 @cindex Formal container for ordered maps
14349
14350 @noindent
14351 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
14352 container for ordered maps, meant to facilitate formal verification of
14353 code using such containers.
14354
14355 @node Ada.Containers.Formal_Ordered_Sets (a-cforse.ads)
14356 @section @code{Ada.Containers.Formal_Ordered_Sets} (@file{a-cforse.ads})
14357 @cindex @code{Ada.Containers.Formal_Ordered_Sets} (@file{a-cforse.ads})
14358 @cindex Formal container for ordered sets
14359
14360 @noindent
14361 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
14362 container for ordered sets, meant to facilitate formal verification of
14363 code using such containers.
14364
14365 @node Ada.Containers.Formal_Vectors (a-cofove.ads)
14366 @section @code{Ada.Containers.Formal_Vectors} (@file{a-cofove.ads})
14367 @cindex @code{Ada.Containers.Formal_Vectors} (@file{a-cofove.ads})
14368 @cindex Formal container for vectors
14369
14370 @noindent
14371 This child of @code{Ada.Containers} defines a modified version of the Ada 2005
14372 container for vectors, meant to facilitate formal verification of
14373 code using such containers.
14374
14375 @node Ada.Command_Line.Environment (a-colien.ads)
14376 @section @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
14377 @cindex @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
14378 @cindex Environment entries
14379
14380 @noindent
14381 This child of @code{Ada.Command_Line}
14382 provides a mechanism for obtaining environment values on systems
14383 where this concept makes sense.
14384
14385 @node Ada.Command_Line.Remove (a-colire.ads)
14386 @section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
14387 @cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
14388 @cindex Removing command line arguments
14389 @cindex Command line, argument removal
14390
14391 @noindent
14392 This child of @code{Ada.Command_Line}
14393 provides a mechanism for logically removing
14394 arguments from the argument list.  Once removed, an argument is not visible
14395 to further calls on the subprograms in @code{Ada.Command_Line} will not
14396 see the removed argument.
14397
14398 @node Ada.Command_Line.Response_File (a-clrefi.ads)
14399 @section @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
14400 @cindex @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
14401 @cindex Response file for command line
14402 @cindex Command line, response file
14403 @cindex Command line, handling long command lines
14404
14405 @noindent
14406 This child of @code{Ada.Command_Line} provides a mechanism facilities for
14407 getting command line arguments from a text file, called a "response file".
14408 Using a response file allow passing a set of arguments to an executable longer
14409 than the maximum allowed by the system on the command line.
14410
14411 @node Ada.Direct_IO.C_Streams (a-diocst.ads)
14412 @section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
14413 @cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
14414 @cindex C Streams, Interfacing with Direct_IO
14415
14416 @noindent
14417 This package provides subprograms that allow interfacing between
14418 C streams and @code{Direct_IO}.  The stream identifier can be
14419 extracted from a file opened on the Ada side, and an Ada file
14420 can be constructed from a stream opened on the C side.
14421
14422 @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
14423 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
14424 @cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
14425 @cindex Null_Occurrence, testing for
14426
14427 @noindent
14428 This child subprogram provides a way of testing for the null
14429 exception occurrence (@code{Null_Occurrence}) without raising
14430 an exception.
14431
14432 @node Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)
14433 @section @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
14434 @cindex @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
14435 @cindex Null_Occurrence, testing for
14436
14437 @noindent
14438 This child subprogram is used for handling otherwise unhandled
14439 exceptions (hence the name last chance), and perform clean ups before
14440 terminating the program. Note that this subprogram never returns.
14441
14442 @node Ada.Exceptions.Traceback (a-exctra.ads)
14443 @section @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
14444 @cindex @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
14445 @cindex Traceback for Exception Occurrence
14446
14447 @noindent
14448 This child package provides the subprogram (@code{Tracebacks}) to
14449 give a traceback array of addresses based on an exception
14450 occurrence.
14451
14452 @node Ada.Sequential_IO.C_Streams (a-siocst.ads)
14453 @section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
14454 @cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
14455 @cindex C Streams, Interfacing with Sequential_IO
14456
14457 @noindent
14458 This package provides subprograms that allow interfacing between
14459 C streams and @code{Sequential_IO}.  The stream identifier can be
14460 extracted from a file opened on the Ada side, and an Ada file
14461 can be constructed from a stream opened on the C side.
14462
14463 @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
14464 @section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
14465 @cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
14466 @cindex C Streams, Interfacing with Stream_IO
14467
14468 @noindent
14469 This package provides subprograms that allow interfacing between
14470 C streams and @code{Stream_IO}.  The stream identifier can be
14471 extracted from a file opened on the Ada side, and an Ada file
14472 can be constructed from a stream opened on the C side.
14473
14474 @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
14475 @section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
14476 @cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
14477 @cindex @code{Unbounded_String}, IO support
14478 @cindex @code{Text_IO}, extensions for unbounded strings
14479
14480 @noindent
14481 This package provides subprograms for Text_IO for unbounded
14482 strings, avoiding the necessity for an intermediate operation
14483 with ordinary strings.
14484
14485 @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
14486 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
14487 @cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
14488 @cindex @code{Unbounded_Wide_String}, IO support
14489 @cindex @code{Text_IO}, extensions for unbounded wide strings
14490
14491 @noindent
14492 This package provides subprograms for Text_IO for unbounded
14493 wide strings, avoiding the necessity for an intermediate operation
14494 with ordinary wide strings.
14495
14496 @node Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)
14497 @section @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
14498 @cindex @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
14499 @cindex @code{Unbounded_Wide_Wide_String}, IO support
14500 @cindex @code{Text_IO}, extensions for unbounded wide wide strings
14501
14502 @noindent
14503 This package provides subprograms for Text_IO for unbounded
14504 wide wide strings, avoiding the necessity for an intermediate operation
14505 with ordinary wide wide strings.
14506
14507 @node Ada.Text_IO.C_Streams (a-tiocst.ads)
14508 @section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
14509 @cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
14510 @cindex C Streams, Interfacing with @code{Text_IO}
14511
14512 @noindent
14513 This package provides subprograms that allow interfacing between
14514 C streams and @code{Text_IO}.  The stream identifier can be
14515 extracted from a file opened on the Ada side, and an Ada file
14516 can be constructed from a stream opened on the C side.
14517
14518 @node Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)
14519 @section @code{Ada.Text_IO.Reset_Standard_Files} (@file{a-tirsfi.ads})
14520 @cindex @code{Ada.Text_IO.Reset_Standard_Files} (@file{a-tirsfi.ads})
14521 @cindex @code{Text_IO} resetting standard files
14522
14523 @noindent
14524 This procedure is used to reset the status of the standard files used
14525 by Ada.Text_IO.  This is useful in a situation (such as a restart in an
14526 embedded application) where the status of the files may change during
14527 execution (for example a standard input file may be redefined to be
14528 interactive).
14529
14530 @node Ada.Wide_Characters.Unicode (a-wichun.ads)
14531 @section @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
14532 @cindex @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
14533 @cindex Unicode categorization, Wide_Character
14534
14535 @noindent
14536 This package provides subprograms that allow categorization of
14537 Wide_Character values according to Unicode categories.
14538
14539 @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
14540 @section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
14541 @cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
14542 @cindex C Streams, Interfacing with @code{Wide_Text_IO}
14543
14544 @noindent
14545 This package provides subprograms that allow interfacing between
14546 C streams and @code{Wide_Text_IO}.  The stream identifier can be
14547 extracted from a file opened on the Ada side, and an Ada file
14548 can be constructed from a stream opened on the C side.
14549
14550 @node Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)
14551 @section @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@file{a-wrstfi.ads})
14552 @cindex @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@file{a-wrstfi.ads})
14553 @cindex @code{Wide_Text_IO} resetting standard files
14554
14555 @noindent
14556 This procedure is used to reset the status of the standard files used
14557 by Ada.Wide_Text_IO.  This is useful in a situation (such as a restart in an
14558 embedded application) where the status of the files may change during
14559 execution (for example a standard input file may be redefined to be
14560 interactive).
14561
14562 @node Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)
14563 @section @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
14564 @cindex @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
14565 @cindex Unicode categorization, Wide_Wide_Character
14566
14567 @noindent
14568 This package provides subprograms that allow categorization of
14569 Wide_Wide_Character values according to Unicode categories.
14570
14571 @node Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)
14572 @section @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
14573 @cindex @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
14574 @cindex C Streams, Interfacing with @code{Wide_Wide_Text_IO}
14575
14576 @noindent
14577 This package provides subprograms that allow interfacing between
14578 C streams and @code{Wide_Wide_Text_IO}.  The stream identifier can be
14579 extracted from a file opened on the Ada side, and an Ada file
14580 can be constructed from a stream opened on the C side.
14581
14582 @node Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)
14583 @section @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@file{a-zrstfi.ads})
14584 @cindex @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@file{a-zrstfi.ads})
14585 @cindex @code{Wide_Wide_Text_IO} resetting standard files
14586
14587 @noindent
14588 This procedure is used to reset the status of the standard files used
14589 by Ada.Wide_Wide_Text_IO. This is useful in a situation (such as a
14590 restart in an embedded application) where the status of the files may
14591 change during execution (for example a standard input file may be
14592 redefined to be interactive).
14593
14594 @node GNAT.Altivec (g-altive.ads)
14595 @section @code{GNAT.Altivec} (@file{g-altive.ads})
14596 @cindex @code{GNAT.Altivec} (@file{g-altive.ads})
14597 @cindex AltiVec
14598
14599 @noindent
14600 This is the root package of the GNAT AltiVec binding. It provides
14601 definitions of constants and types common to all the versions of the
14602 binding.
14603
14604 @node GNAT.Altivec.Conversions (g-altcon.ads)
14605 @section @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
14606 @cindex @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
14607 @cindex AltiVec
14608
14609 @noindent
14610 This package provides the Vector/View conversion routines.
14611
14612 @node GNAT.Altivec.Vector_Operations (g-alveop.ads)
14613 @section @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
14614 @cindex @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
14615 @cindex AltiVec
14616
14617 @noindent
14618 This package exposes the Ada interface to the AltiVec operations on
14619 vector objects. A soft emulation is included by default in the GNAT
14620 library. The hard binding is provided as a separate package. This unit
14621 is common to both bindings.
14622
14623 @node GNAT.Altivec.Vector_Types (g-alvety.ads)
14624 @section @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
14625 @cindex @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
14626 @cindex AltiVec
14627
14628 @noindent
14629 This package exposes the various vector types part of the Ada binding
14630 to AltiVec facilities.
14631
14632 @node GNAT.Altivec.Vector_Views (g-alvevi.ads)
14633 @section @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
14634 @cindex @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
14635 @cindex AltiVec
14636
14637 @noindent
14638 This package provides public 'View' data types from/to which private
14639 vector representations can be converted via
14640 GNAT.Altivec.Conversions. This allows convenient access to individual
14641 vector elements and provides a simple way to initialize vector
14642 objects.
14643
14644 @node GNAT.Array_Split (g-arrspl.ads)
14645 @section @code{GNAT.Array_Split} (@file{g-arrspl.ads})
14646 @cindex @code{GNAT.Array_Split} (@file{g-arrspl.ads})
14647 @cindex Array splitter
14648
14649 @noindent
14650 Useful array-manipulation routines: given a set of separators, split
14651 an array wherever the separators appear, and provide direct access
14652 to the resulting slices.
14653
14654 @node GNAT.AWK (g-awk.ads)
14655 @section @code{GNAT.AWK} (@file{g-awk.ads})
14656 @cindex @code{GNAT.AWK} (@file{g-awk.ads})
14657 @cindex Parsing
14658 @cindex AWK
14659
14660 @noindent
14661 Provides AWK-like parsing functions, with an easy interface for parsing one
14662 or more files containing formatted data.  The file is viewed as a database
14663 where each record is a line and a field is a data element in this line.
14664
14665 @node GNAT.Bounded_Buffers (g-boubuf.ads)
14666 @section @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
14667 @cindex @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
14668 @cindex Parsing
14669 @cindex Bounded Buffers
14670
14671 @noindent
14672 Provides a concurrent generic bounded buffer abstraction.  Instances are
14673 useful directly or as parts of the implementations of other abstractions,
14674 such as mailboxes.
14675
14676 @node GNAT.Bounded_Mailboxes (g-boumai.ads)
14677 @section @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
14678 @cindex @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
14679 @cindex Parsing
14680 @cindex Mailboxes
14681
14682 @noindent
14683 Provides a thread-safe asynchronous intertask mailbox communication facility.
14684
14685 @node GNAT.Bubble_Sort (g-bubsor.ads)
14686 @section @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
14687 @cindex @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
14688 @cindex Sorting
14689 @cindex Bubble sort
14690
14691 @noindent
14692 Provides a general implementation of bubble sort usable for sorting arbitrary
14693 data items.  Exchange and comparison procedures are provided by passing
14694 access-to-procedure values.
14695
14696 @node GNAT.Bubble_Sort_A (g-busora.ads)
14697 @section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
14698 @cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
14699 @cindex Sorting
14700 @cindex Bubble sort
14701
14702 @noindent
14703 Provides a general implementation of bubble sort usable for sorting arbitrary
14704 data items.  Move and comparison procedures are provided by passing
14705 access-to-procedure values. This is an older version, retained for
14706 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
14707
14708 @node GNAT.Bubble_Sort_G (g-busorg.ads)
14709 @section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
14710 @cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
14711 @cindex Sorting
14712 @cindex Bubble sort
14713
14714 @noindent
14715 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
14716 are provided as generic parameters, this improves efficiency, especially
14717 if the procedures can be inlined, at the expense of duplicating code for
14718 multiple instantiations.
14719
14720 @node GNAT.Byte_Order_Mark (g-byorma.ads)
14721 @section @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
14722 @cindex @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
14723 @cindex UTF-8 representation
14724 @cindex Wide characte representations
14725
14726 @noindent
14727 Provides a routine which given a string, reads the start of the string to
14728 see whether it is one of the standard byte order marks (BOM's) which signal
14729 the encoding of the string. The routine includes detection of special XML
14730 sequences for various UCS input formats.
14731
14732 @node GNAT.Byte_Swapping (g-bytswa.ads)
14733 @section @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
14734 @cindex @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
14735 @cindex Byte swapping
14736 @cindex Endian
14737
14738 @noindent
14739 General routines for swapping the bytes in 2-, 4-, and 8-byte quantities.
14740 Machine-specific implementations are available in some cases.
14741
14742 @node GNAT.Calendar (g-calend.ads)
14743 @section @code{GNAT.Calendar} (@file{g-calend.ads})
14744 @cindex @code{GNAT.Calendar} (@file{g-calend.ads})
14745 @cindex @code{Calendar}
14746
14747 @noindent
14748 Extends the facilities provided by @code{Ada.Calendar} to include handling
14749 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
14750 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
14751 C @code{timeval} format.
14752
14753 @node GNAT.Calendar.Time_IO (g-catiio.ads)
14754 @section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
14755 @cindex @code{Calendar}
14756 @cindex Time
14757 @cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
14758
14759 @node GNAT.CRC32 (g-crc32.ads)
14760 @section @code{GNAT.CRC32} (@file{g-crc32.ads})
14761 @cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
14762 @cindex CRC32
14763 @cindex Cyclic Redundancy Check
14764
14765 @noindent
14766 This package implements the CRC-32 algorithm.  For a full description
14767 of this algorithm see
14768 ``Computation of Cyclic Redundancy Checks via Table Look-Up'',
14769 @cite{Communications of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013,
14770 Aug.@: 1988.  Sarwate, D.V@.
14771
14772 @node GNAT.Case_Util (g-casuti.ads)
14773 @section @code{GNAT.Case_Util} (@file{g-casuti.ads})
14774 @cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
14775 @cindex Casing utilities
14776 @cindex Character handling (@code{GNAT.Case_Util})
14777
14778 @noindent
14779 A set of simple routines for handling upper and lower casing of strings
14780 without the overhead of the full casing tables
14781 in @code{Ada.Characters.Handling}.
14782
14783 @node GNAT.CGI (g-cgi.ads)
14784 @section @code{GNAT.CGI} (@file{g-cgi.ads})
14785 @cindex @code{GNAT.CGI} (@file{g-cgi.ads})
14786 @cindex CGI (Common Gateway Interface)
14787
14788 @noindent
14789 This is a package for interfacing a GNAT program with a Web server via the
14790 Common Gateway Interface (CGI)@.  Basically this package parses the CGI
14791 parameters, which are a set of key/value pairs sent by the Web server.  It
14792 builds a table whose index is the key and provides some services to deal
14793 with this table.
14794
14795 @node GNAT.CGI.Cookie (g-cgicoo.ads)
14796 @section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
14797 @cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
14798 @cindex CGI (Common Gateway Interface) cookie support
14799 @cindex Cookie support in CGI
14800
14801 @noindent
14802 This is a package to interface a GNAT program with a Web server via the
14803 Common Gateway Interface (CGI).  It exports services to deal with Web
14804 cookies (piece of information kept in the Web client software).
14805
14806 @node GNAT.CGI.Debug (g-cgideb.ads)
14807 @section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
14808 @cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
14809 @cindex CGI (Common Gateway Interface) debugging
14810
14811 @noindent
14812 This is a package to help debugging CGI (Common Gateway Interface)
14813 programs written in Ada.
14814
14815 @node GNAT.Command_Line (g-comlin.ads)
14816 @section @code{GNAT.Command_Line} (@file{g-comlin.ads})
14817 @cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
14818 @cindex Command line
14819
14820 @noindent
14821 Provides a high level interface to @code{Ada.Command_Line} facilities,
14822 including the ability to scan for named switches with optional parameters
14823 and expand file names using wild card notations.
14824
14825 @node GNAT.Compiler_Version (g-comver.ads)
14826 @section @code{GNAT.Compiler_Version} (@file{g-comver.ads})
14827 @cindex @code{GNAT.Compiler_Version} (@file{g-comver.ads})
14828 @cindex Compiler Version
14829 @cindex Version, of compiler
14830
14831 @noindent
14832 Provides a routine for obtaining the version of the compiler used to
14833 compile the program. More accurately this is the version of the binder
14834 used to bind the program (this will normally be the same as the version
14835 of the compiler if a consistent tool set is used to compile all units
14836 of a partition).
14837
14838 @node GNAT.Ctrl_C (g-ctrl_c.ads)
14839 @section @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
14840 @cindex @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
14841 @cindex Interrupt
14842
14843 @noindent
14844 Provides a simple interface to handle Ctrl-C keyboard events.
14845
14846 @node GNAT.Current_Exception (g-curexc.ads)
14847 @section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
14848 @cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
14849 @cindex Current exception
14850 @cindex Exception retrieval
14851
14852 @noindent
14853 Provides access to information on the current exception that has been raised
14854 without the need for using the Ada 95 / Ada 2005 exception choice parameter
14855 specification syntax.
14856 This is particularly useful in simulating typical facilities for
14857 obtaining information about exceptions provided by Ada 83 compilers.
14858
14859 @node GNAT.Debug_Pools (g-debpoo.ads)
14860 @section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
14861 @cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
14862 @cindex Debugging
14863 @cindex Debug pools
14864 @cindex Memory corruption debugging
14865
14866 @noindent
14867 Provide a debugging storage pools that helps tracking memory corruption
14868 problems.  @xref{The GNAT Debug Pool Facility,,, gnat_ugn,
14869 @value{EDITION} User's Guide}.
14870
14871 @node GNAT.Debug_Utilities (g-debuti.ads)
14872 @section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
14873 @cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
14874 @cindex Debugging
14875
14876 @noindent
14877 Provides a few useful utilities for debugging purposes, including conversion
14878 to and from string images of address values. Supports both C and Ada formats
14879 for hexadecimal literals.
14880
14881 @node GNAT.Decode_String (g-decstr.ads)
14882 @section @code{GNAT.Decode_String} (@file{g-decstr.ads})
14883 @cindex @code{GNAT.Decode_String} (@file{g-decstr.ads})
14884 @cindex Decoding strings
14885 @cindex String decoding
14886 @cindex Wide character encoding
14887 @cindex UTF-8
14888 @cindex Unicode
14889
14890 @noindent
14891 A generic package providing routines for decoding wide character and wide wide
14892 character strings encoded as sequences of 8-bit characters using a specified
14893 encoding method. Includes validation routines, and also routines for stepping
14894 to next or previous encoded character in an encoded string.
14895 Useful in conjunction with Unicode character coding. Note there is a
14896 preinstantiation for UTF-8. See next entry.
14897
14898 @node GNAT.Decode_UTF8_String (g-deutst.ads)
14899 @section @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
14900 @cindex @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
14901 @cindex Decoding strings
14902 @cindex Decoding UTF-8 strings
14903 @cindex UTF-8 string decoding
14904 @cindex Wide character decoding
14905 @cindex UTF-8
14906 @cindex Unicode
14907
14908 @noindent
14909 A preinstantiation of GNAT.Decode_Strings for UTF-8 encoding.
14910
14911 @node GNAT.Directory_Operations (g-dirope.ads)
14912 @section @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
14913 @cindex @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
14914 @cindex Directory operations
14915
14916 @noindent
14917 Provides a set of routines for manipulating directories, including changing
14918 the current directory, making new directories, and scanning the files in a
14919 directory.
14920
14921 @node GNAT.Directory_Operations.Iteration (g-diopit.ads)
14922 @section @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
14923 @cindex @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
14924 @cindex Directory operations iteration
14925
14926 @noindent
14927 A child unit of GNAT.Directory_Operations providing additional operations
14928 for iterating through directories.
14929
14930 @node GNAT.Dynamic_HTables (g-dynhta.ads)
14931 @section @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
14932 @cindex @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
14933 @cindex Hash tables
14934
14935 @noindent
14936 A generic implementation of hash tables that can be used to hash arbitrary
14937 data.  Provided in two forms, a simple form with built in hash functions,
14938 and a more complex form in which the hash function is supplied.
14939
14940 @noindent
14941 This package provides a facility similar to that of @code{GNAT.HTable},
14942 except that this package declares a type that can be used to define
14943 dynamic instances of the hash table, while an instantiation of
14944 @code{GNAT.HTable} creates a single instance of the hash table.
14945
14946 @node GNAT.Dynamic_Tables (g-dyntab.ads)
14947 @section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
14948 @cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
14949 @cindex Table implementation
14950 @cindex Arrays, extendable
14951
14952 @noindent
14953 A generic package providing a single dimension array abstraction where the
14954 length of the array can be dynamically modified.
14955
14956 @noindent
14957 This package provides a facility similar to that of @code{GNAT.Table},
14958 except that this package declares a type that can be used to define
14959 dynamic instances of the table, while an instantiation of
14960 @code{GNAT.Table} creates a single instance of the table type.
14961
14962 @node GNAT.Encode_String (g-encstr.ads)
14963 @section @code{GNAT.Encode_String} (@file{g-encstr.ads})
14964 @cindex @code{GNAT.Encode_String} (@file{g-encstr.ads})
14965 @cindex Encoding strings
14966 @cindex String encoding
14967 @cindex Wide character encoding
14968 @cindex UTF-8
14969 @cindex Unicode
14970
14971 @noindent
14972 A generic package providing routines for encoding wide character and wide
14973 wide character strings as sequences of 8-bit characters using a specified
14974 encoding method. Useful in conjunction with Unicode character coding.
14975 Note there is a preinstantiation for UTF-8. See next entry.
14976
14977 @node GNAT.Encode_UTF8_String (g-enutst.ads)
14978 @section @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
14979 @cindex @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
14980 @cindex Encoding strings
14981 @cindex Encoding UTF-8 strings
14982 @cindex UTF-8 string encoding
14983 @cindex Wide character encoding
14984 @cindex UTF-8
14985 @cindex Unicode
14986
14987 @noindent
14988 A preinstantiation of GNAT.Encode_Strings for UTF-8 encoding.
14989
14990 @node GNAT.Exception_Actions (g-excact.ads)
14991 @section @code{GNAT.Exception_Actions} (@file{g-excact.ads})
14992 @cindex @code{GNAT.Exception_Actions} (@file{g-excact.ads})
14993 @cindex Exception actions
14994
14995 @noindent
14996 Provides callbacks when an exception is raised. Callbacks can be registered
14997 for specific exceptions, or when any exception is raised. This
14998 can be used for instance to force a core dump to ease debugging.
14999
15000 @node GNAT.Exception_Traces (g-exctra.ads)
15001 @section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
15002 @cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
15003 @cindex Exception traces
15004 @cindex Debugging
15005
15006 @noindent
15007 Provides an interface allowing to control automatic output upon exception
15008 occurrences.
15009
15010 @node GNAT.Exceptions (g-except.ads)
15011 @section @code{GNAT.Exceptions} (@file{g-expect.ads})
15012 @cindex @code{GNAT.Exceptions} (@file{g-expect.ads})
15013 @cindex Exceptions, Pure
15014 @cindex Pure packages, exceptions
15015
15016 @noindent
15017 Normally it is not possible to raise an exception with
15018 a message from a subprogram in a pure package, since the
15019 necessary types and subprograms are in @code{Ada.Exceptions}
15020 which is not a pure unit. @code{GNAT.Exceptions} provides a
15021 facility for getting around this limitation for a few
15022 predefined exceptions, and for example allow raising
15023 @code{Constraint_Error} with a message from a pure subprogram.
15024
15025 @node GNAT.Expect (g-expect.ads)
15026 @section @code{GNAT.Expect} (@file{g-expect.ads})
15027 @cindex @code{GNAT.Expect} (@file{g-expect.ads})
15028
15029 @noindent
15030 Provides a set of subprograms similar to what is available
15031 with the standard Tcl Expect tool.
15032 It allows you to easily spawn and communicate with an external process.
15033 You can send commands or inputs to the process, and compare the output
15034 with some expected regular expression. Currently @code{GNAT.Expect}
15035 is implemented on all native GNAT ports except for OpenVMS@.
15036 It is not implemented for cross ports, and in particular is not
15037 implemented for VxWorks or LynxOS@.
15038
15039 @node GNAT.Expect.TTY (g-exptty.ads)
15040 @section @code{GNAT.Expect.TTY} (@file{g-exptty.ads})
15041 @cindex @code{GNAT.Expect.TTY} (@file{g-exptty.ads})
15042
15043 @noindent
15044 As GNAT.Expect but using pseudo-terminal.
15045 Currently @code{GNAT.Expect.TTY} is implemented on all native GNAT
15046 ports except for OpenVMS@. It is not implemented for cross ports, and
15047 in particular is not implemented for VxWorks or LynxOS@.
15048
15049 @node GNAT.Float_Control (g-flocon.ads)
15050 @section @code{GNAT.Float_Control} (@file{g-flocon.ads})
15051 @cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
15052 @cindex Floating-Point Processor
15053
15054 @noindent
15055 Provides an interface for resetting the floating-point processor into the
15056 mode required for correct semantic operation in Ada.  Some third party
15057 library calls may cause this mode to be modified, and the Reset procedure
15058 in this package can be used to reestablish the required mode.
15059
15060 @node GNAT.Heap_Sort (g-heasor.ads)
15061 @section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
15062 @cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
15063 @cindex Sorting
15064
15065 @noindent
15066 Provides a general implementation of heap sort usable for sorting arbitrary
15067 data items. Exchange and comparison procedures are provided by passing
15068 access-to-procedure values.  The algorithm used is a modified heap sort
15069 that performs approximately N*log(N) comparisons in the worst case.
15070
15071 @node GNAT.Heap_Sort_A (g-hesora.ads)
15072 @section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
15073 @cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
15074 @cindex Sorting
15075
15076 @noindent
15077 Provides a general implementation of heap sort usable for sorting arbitrary
15078 data items. Move and comparison procedures are provided by passing
15079 access-to-procedure values.  The algorithm used is a modified heap sort
15080 that performs approximately N*log(N) comparisons in the worst case.
15081 This differs from @code{GNAT.Heap_Sort} in having a less convenient
15082 interface, but may be slightly more efficient.
15083
15084 @node GNAT.Heap_Sort_G (g-hesorg.ads)
15085 @section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
15086 @cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
15087 @cindex Sorting
15088
15089 @noindent
15090 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
15091 are provided as generic parameters, this improves efficiency, especially
15092 if the procedures can be inlined, at the expense of duplicating code for
15093 multiple instantiations.
15094
15095 @node GNAT.HTable (g-htable.ads)
15096 @section @code{GNAT.HTable} (@file{g-htable.ads})
15097 @cindex @code{GNAT.HTable} (@file{g-htable.ads})
15098 @cindex Hash tables
15099
15100 @noindent
15101 A generic implementation of hash tables that can be used to hash arbitrary
15102 data.  Provides two approaches, one a simple static approach, and the other
15103 allowing arbitrary dynamic hash tables.
15104
15105 @node GNAT.IO (g-io.ads)
15106 @section @code{GNAT.IO} (@file{g-io.ads})
15107 @cindex @code{GNAT.IO} (@file{g-io.ads})
15108 @cindex Simple I/O
15109 @cindex Input/Output facilities
15110
15111 @noindent
15112 A simple preelaborable input-output package that provides a subset of
15113 simple Text_IO functions for reading characters and strings from
15114 Standard_Input, and writing characters, strings and integers to either
15115 Standard_Output or Standard_Error.
15116
15117 @node GNAT.IO_Aux (g-io_aux.ads)
15118 @section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
15119 @cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
15120 @cindex Text_IO
15121 @cindex Input/Output facilities
15122
15123 Provides some auxiliary functions for use with Text_IO, including a test
15124 for whether a file exists, and functions for reading a line of text.
15125
15126 @node GNAT.Lock_Files (g-locfil.ads)
15127 @section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
15128 @cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
15129 @cindex File locking
15130 @cindex Locking using files
15131
15132 @noindent
15133 Provides a general interface for using files as locks.  Can be used for
15134 providing program level synchronization.
15135
15136 @node GNAT.MBBS_Discrete_Random (g-mbdira.ads)
15137 @section @code{GNAT.MBBS_Discrete_Random} (@file{g-mbdira.ads})
15138 @cindex @code{GNAT.MBBS_Discrete_Random} (@file{g-mbdira.ads})
15139 @cindex Random number generation
15140
15141 @noindent
15142 The original implementation of @code{Ada.Numerics.Discrete_Random}.  Uses
15143 a modified version of the Blum-Blum-Shub generator.
15144
15145 @node GNAT.MBBS_Float_Random (g-mbflra.ads)
15146 @section @code{GNAT.MBBS_Float_Random} (@file{g-mbflra.ads})
15147 @cindex @code{GNAT.MBBS_Float_Random} (@file{g-mbflra.ads})
15148 @cindex Random number generation
15149
15150 @noindent
15151 The original implementation of @code{Ada.Numerics.Float_Random}.  Uses
15152 a modified version of the Blum-Blum-Shub generator.
15153
15154 @node GNAT.MD5 (g-md5.ads)
15155 @section @code{GNAT.MD5} (@file{g-md5.ads})
15156 @cindex @code{GNAT.MD5} (@file{g-md5.ads})
15157 @cindex Message Digest MD5
15158
15159 @noindent
15160 Implements the MD5 Message-Digest Algorithm as described in RFC 1321.
15161
15162 @node GNAT.Memory_Dump (g-memdum.ads)
15163 @section @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
15164 @cindex @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
15165 @cindex Dump Memory
15166
15167 @noindent
15168 Provides a convenient routine for dumping raw memory to either the
15169 standard output or standard error files. Uses GNAT.IO for actual
15170 output.
15171
15172 @node GNAT.Most_Recent_Exception (g-moreex.ads)
15173 @section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
15174 @cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
15175 @cindex Exception, obtaining most recent
15176
15177 @noindent
15178 Provides access to the most recently raised exception.  Can be used for
15179 various logging purposes, including duplicating functionality of some
15180 Ada 83 implementation dependent extensions.
15181
15182 @node GNAT.OS_Lib (g-os_lib.ads)
15183 @section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
15184 @cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
15185 @cindex Operating System interface
15186 @cindex Spawn capability
15187
15188 @noindent
15189 Provides a range of target independent operating system interface functions,
15190 including time/date management, file operations, subprocess management,
15191 including a portable spawn procedure, and access to environment variables
15192 and error return codes.
15193
15194 @node GNAT.Perfect_Hash_Generators (g-pehage.ads)
15195 @section @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
15196 @cindex @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
15197 @cindex Hash functions
15198
15199 @noindent
15200 Provides a generator of static minimal perfect hash functions. No
15201 collisions occur and each item can be retrieved from the table in one
15202 probe (perfect property). The hash table size corresponds to the exact
15203 size of the key set and no larger (minimal property). The key set has to
15204 be know in advance (static property). The hash functions are also order
15205 preserving. If w2 is inserted after w1 in the generator, their
15206 hashcode are in the same order. These hashing functions are very
15207 convenient for use with realtime applications.
15208
15209 @node GNAT.Random_Numbers (g-rannum.ads)
15210 @section @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
15211 @cindex @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
15212 @cindex Random number generation
15213
15214 @noindent
15215 Provides random number capabilities which extend those available in the
15216 standard Ada library and are more convenient to use.
15217
15218 @node GNAT.Regexp (g-regexp.ads)
15219 @section @code{GNAT.Regexp} (@file{g-regexp.ads})
15220 @cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
15221 @cindex Regular expressions
15222 @cindex Pattern matching
15223
15224 @noindent
15225 A simple implementation of regular expressions, using a subset of regular
15226 expression syntax copied from familiar Unix style utilities.  This is the
15227 simples of the three pattern matching packages provided, and is particularly
15228 suitable for ``file globbing'' applications.
15229
15230 @node GNAT.Registry (g-regist.ads)
15231 @section @code{GNAT.Registry} (@file{g-regist.ads})
15232 @cindex @code{GNAT.Registry} (@file{g-regist.ads})
15233 @cindex Windows Registry
15234
15235 @noindent
15236 This is a high level binding to the Windows registry.  It is possible to
15237 do simple things like reading a key value, creating a new key.  For full
15238 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
15239 package provided with the Win32Ada binding
15240
15241 @node GNAT.Regpat (g-regpat.ads)
15242 @section @code{GNAT.Regpat} (@file{g-regpat.ads})
15243 @cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
15244 @cindex Regular expressions
15245 @cindex Pattern matching
15246
15247 @noindent
15248 A complete implementation of Unix-style regular expression matching, copied
15249 from the original V7 style regular expression library written in C by
15250 Henry Spencer (and binary compatible with this C library).
15251
15252 @node GNAT.Secondary_Stack_Info (g-sestin.ads)
15253 @section @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
15254 @cindex @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
15255 @cindex Secondary Stack Info
15256
15257 @noindent
15258 Provide the capability to query the high water mark of the current task's
15259 secondary stack.
15260
15261 @node GNAT.Semaphores (g-semaph.ads)
15262 @section @code{GNAT.Semaphores} (@file{g-semaph.ads})
15263 @cindex @code{GNAT.Semaphores} (@file{g-semaph.ads})
15264 @cindex Semaphores
15265
15266 @noindent
15267 Provides classic counting and binary semaphores using protected types.
15268
15269 @node GNAT.Serial_Communications (g-sercom.ads)
15270 @section @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
15271 @cindex @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
15272 @cindex Serial_Communications
15273
15274 @noindent
15275 Provides a simple interface to send and receive data over a serial
15276 port. This is only supported on GNU/Linux and Windows.
15277
15278 @node GNAT.SHA1 (g-sha1.ads)
15279 @section @code{GNAT.SHA1} (@file{g-sha1.ads})
15280 @cindex @code{GNAT.SHA1} (@file{g-sha1.ads})
15281 @cindex Secure Hash Algorithm SHA-1
15282
15283 @noindent
15284 Implements the SHA-1 Secure Hash Algorithm as described in FIPS PUB 180-3
15285 and RFC 3174.
15286
15287 @node GNAT.SHA224 (g-sha224.ads)
15288 @section @code{GNAT.SHA224} (@file{g-sha224.ads})
15289 @cindex @code{GNAT.SHA224} (@file{g-sha224.ads})
15290 @cindex Secure Hash Algorithm SHA-224
15291
15292 @noindent
15293 Implements the SHA-224 Secure Hash Algorithm as described in FIPS PUB 180-3.
15294
15295 @node GNAT.SHA256 (g-sha256.ads)
15296 @section @code{GNAT.SHA256} (@file{g-sha256.ads})
15297 @cindex @code{GNAT.SHA256} (@file{g-sha256.ads})
15298 @cindex Secure Hash Algorithm SHA-256
15299
15300 @noindent
15301 Implements the SHA-256 Secure Hash Algorithm as described in FIPS PUB 180-3.
15302
15303 @node GNAT.SHA384 (g-sha384.ads)
15304 @section @code{GNAT.SHA384} (@file{g-sha384.ads})
15305 @cindex @code{GNAT.SHA384} (@file{g-sha384.ads})
15306 @cindex Secure Hash Algorithm SHA-384
15307
15308 @noindent
15309 Implements the SHA-384 Secure Hash Algorithm as described in FIPS PUB 180-3.
15310
15311 @node GNAT.SHA512 (g-sha512.ads)
15312 @section @code{GNAT.SHA512} (@file{g-sha512.ads})
15313 @cindex @code{GNAT.SHA512} (@file{g-sha512.ads})
15314 @cindex Secure Hash Algorithm SHA-512
15315
15316 @noindent
15317 Implements the SHA-512 Secure Hash Algorithm as described in FIPS PUB 180-3.
15318
15319 @node GNAT.Signals (g-signal.ads)
15320 @section @code{GNAT.Signals} (@file{g-signal.ads})
15321 @cindex @code{GNAT.Signals} (@file{g-signal.ads})
15322 @cindex Signals
15323
15324 @noindent
15325 Provides the ability to manipulate the blocked status of signals on supported
15326 targets.
15327
15328 @node GNAT.Sockets (g-socket.ads)
15329 @section @code{GNAT.Sockets} (@file{g-socket.ads})
15330 @cindex @code{GNAT.Sockets} (@file{g-socket.ads})
15331 @cindex Sockets
15332
15333 @noindent
15334 A high level and portable interface to develop sockets based applications.
15335 This package is based on the sockets thin binding found in
15336 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
15337 on all native GNAT ports except for OpenVMS@.  It is not implemented
15338 for the LynxOS@ cross port.
15339
15340 @node GNAT.Source_Info (g-souinf.ads)
15341 @section @code{GNAT.Source_Info} (@file{g-souinf.ads})
15342 @cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
15343 @cindex Source Information
15344
15345 @noindent
15346 Provides subprograms that give access to source code information known at
15347 compile time, such as the current file name and line number.
15348
15349 @node GNAT.Spelling_Checker (g-speche.ads)
15350 @section @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
15351 @cindex @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
15352 @cindex Spell checking
15353
15354 @noindent
15355 Provides a function for determining whether one string is a plausible
15356 near misspelling of another string.
15357
15358 @node GNAT.Spelling_Checker_Generic (g-spchge.ads)
15359 @section @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
15360 @cindex @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
15361 @cindex Spell checking
15362
15363 @noindent
15364 Provides a generic function that can be instantiated with a string type for
15365 determining whether one string is a plausible near misspelling of another
15366 string.
15367
15368 @node GNAT.Spitbol.Patterns (g-spipat.ads)
15369 @section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
15370 @cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
15371 @cindex SPITBOL pattern matching
15372 @cindex Pattern matching
15373
15374 @noindent
15375 A complete implementation of SNOBOL4 style pattern matching.  This is the
15376 most elaborate of the pattern matching packages provided.  It fully duplicates
15377 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
15378 efficient algorithm developed by Robert Dewar for the SPITBOL system.
15379
15380 @node GNAT.Spitbol (g-spitbo.ads)
15381 @section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
15382 @cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
15383 @cindex SPITBOL interface
15384
15385 @noindent
15386 The top level package of the collection of SPITBOL-style functionality, this
15387 package provides basic SNOBOL4 string manipulation functions, such as
15388 Pad, Reverse, Trim, Substr capability, as well as a generic table function
15389 useful for constructing arbitrary mappings from strings in the style of
15390 the SNOBOL4 TABLE function.
15391
15392 @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
15393 @section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
15394 @cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
15395 @cindex Sets of strings
15396 @cindex SPITBOL Tables
15397
15398 @noindent
15399 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
15400 for type @code{Standard.Boolean}, giving an implementation of sets of
15401 string values.
15402
15403 @node GNAT.Spitbol.Table_Integer (g-sptain.ads)
15404 @section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
15405 @cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
15406 @cindex Integer maps
15407 @cindex Maps
15408 @cindex SPITBOL Tables
15409
15410 @noindent
15411 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
15412 for type @code{Standard.Integer}, giving an implementation of maps
15413 from string to integer values.
15414
15415 @node GNAT.Spitbol.Table_VString (g-sptavs.ads)
15416 @section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
15417 @cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
15418 @cindex String maps
15419 @cindex Maps
15420 @cindex SPITBOL Tables
15421
15422 @noindent
15423 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
15424 a variable length string type, giving an implementation of general
15425 maps from strings to strings.
15426
15427 @node GNAT.SSE (g-sse.ads)
15428 @section @code{GNAT.SSE} (@file{g-sse.ads})
15429 @cindex @code{GNAT.SSE} (@file{g-sse.ads})
15430
15431 @noindent
15432 Root of a set of units aimed at offering Ada bindings to a subset of
15433 the Intel(r) Streaming SIMD Extensions with GNAT on the x86 family of
15434 targets.  It exposes vector component types together with a general
15435 introduction to the binding contents and use.
15436
15437 @node GNAT.SSE.Vector_Types (g-ssvety.ads)
15438 @section @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
15439 @cindex @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
15440
15441 @noindent
15442 SSE vector types for use with SSE related intrinsics.
15443
15444 @node GNAT.Strings (g-string.ads)
15445 @section @code{GNAT.Strings} (@file{g-string.ads})
15446 @cindex @code{GNAT.Strings} (@file{g-string.ads})
15447
15448 @noindent
15449 Common String access types and related subprograms. Basically it
15450 defines a string access and an array of string access types.
15451
15452 @node GNAT.String_Split (g-strspl.ads)
15453 @section @code{GNAT.String_Split} (@file{g-strspl.ads})
15454 @cindex @code{GNAT.String_Split} (@file{g-strspl.ads})
15455 @cindex String splitter
15456
15457 @noindent
15458 Useful string manipulation routines: given a set of separators, split
15459 a string wherever the separators appear, and provide direct access
15460 to the resulting slices. This package is instantiated from
15461 @code{GNAT.Array_Split}.
15462
15463 @node GNAT.Table (g-table.ads)
15464 @section @code{GNAT.Table} (@file{g-table.ads})
15465 @cindex @code{GNAT.Table} (@file{g-table.ads})
15466 @cindex Table implementation
15467 @cindex Arrays, extendable
15468
15469 @noindent
15470 A generic package providing a single dimension array abstraction where the
15471 length of the array can be dynamically modified.
15472
15473 @noindent
15474 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
15475 except that this package declares a single instance of the table type,
15476 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
15477 used to define dynamic instances of the table.
15478
15479 @node GNAT.Task_Lock (g-tasloc.ads)
15480 @section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
15481 @cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
15482 @cindex Task synchronization
15483 @cindex Task locking
15484 @cindex Locking
15485
15486 @noindent
15487 A very simple facility for locking and unlocking sections of code using a
15488 single global task lock.  Appropriate for use in situations where contention
15489 between tasks is very rarely expected.
15490
15491 @node GNAT.Time_Stamp (g-timsta.ads)
15492 @section @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
15493 @cindex @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
15494 @cindex Time stamp
15495 @cindex Current time
15496
15497 @noindent
15498 Provides a simple function that returns a string YYYY-MM-DD HH:MM:SS.SS that
15499 represents the current date and time in ISO 8601 format. This is a very simple
15500 routine with minimal code and there are no dependencies on any other unit.
15501
15502 @node GNAT.Threads (g-thread.ads)
15503 @section @code{GNAT.Threads} (@file{g-thread.ads})
15504 @cindex @code{GNAT.Threads} (@file{g-thread.ads})
15505 @cindex Foreign threads
15506 @cindex Threads, foreign
15507
15508 @noindent
15509 Provides facilities for dealing with foreign threads which need to be known
15510 by the GNAT run-time system. Consult the documentation of this package for
15511 further details if your program has threads that are created by a non-Ada
15512 environment which then accesses Ada code.
15513
15514 @node GNAT.Traceback (g-traceb.ads)
15515 @section @code{GNAT.Traceback} (@file{g-traceb.ads})
15516 @cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
15517 @cindex Trace back facilities
15518
15519 @noindent
15520 Provides a facility for obtaining non-symbolic traceback information, useful
15521 in various debugging situations.
15522
15523 @node GNAT.Traceback.Symbolic (g-trasym.ads)
15524 @section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
15525 @cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
15526 @cindex Trace back facilities
15527
15528 @node GNAT.UTF_32 (g-utf_32.ads)
15529 @section @code{GNAT.UTF_32} (@file{g-table.ads})
15530 @cindex @code{GNAT.UTF_32} (@file{g-table.ads})
15531 @cindex Wide character codes
15532
15533 @noindent
15534 This is a package intended to be used in conjunction with the
15535 @code{Wide_Character} type in Ada 95 and the
15536 @code{Wide_Wide_Character} type in Ada 2005 (available
15537 in @code{GNAT} in Ada 2005 mode). This package contains
15538 Unicode categorization routines, as well as lexical
15539 categorization routines corresponding to the Ada 2005
15540 lexical rules for identifiers and strings, and also a
15541 lower case to upper case fold routine corresponding to
15542 the Ada 2005 rules for identifier equivalence.
15543
15544 @node GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)
15545 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
15546 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
15547 @cindex Spell checking
15548
15549 @noindent
15550 Provides a function for determining whether one wide wide string is a plausible
15551 near misspelling of another wide wide string, where the strings are represented
15552 using the UTF_32_String type defined in System.Wch_Cnv.
15553
15554 @node GNAT.Wide_Spelling_Checker (g-wispch.ads)
15555 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
15556 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
15557 @cindex Spell checking
15558
15559 @noindent
15560 Provides a function for determining whether one wide string is a plausible
15561 near misspelling of another wide string.
15562
15563 @node GNAT.Wide_String_Split (g-wistsp.ads)
15564 @section @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
15565 @cindex @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
15566 @cindex Wide_String splitter
15567
15568 @noindent
15569 Useful wide string manipulation routines: given a set of separators, split
15570 a wide string wherever the separators appear, and provide direct access
15571 to the resulting slices. This package is instantiated from
15572 @code{GNAT.Array_Split}.
15573
15574 @node GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)
15575 @section @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
15576 @cindex @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
15577 @cindex Spell checking
15578
15579 @noindent
15580 Provides a function for determining whether one wide wide string is a plausible
15581 near misspelling of another wide wide string.
15582
15583 @node GNAT.Wide_Wide_String_Split (g-zistsp.ads)
15584 @section @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
15585 @cindex @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
15586 @cindex Wide_Wide_String splitter
15587
15588 @noindent
15589 Useful wide wide string manipulation routines: given a set of separators, split
15590 a wide wide string wherever the separators appear, and provide direct access
15591 to the resulting slices. This package is instantiated from
15592 @code{GNAT.Array_Split}.
15593
15594 @node Interfaces.C.Extensions (i-cexten.ads)
15595 @section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
15596 @cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
15597
15598 @noindent
15599 This package contains additional C-related definitions, intended
15600 for use with either manually or automatically generated bindings
15601 to C libraries.
15602
15603 @node Interfaces.C.Streams (i-cstrea.ads)
15604 @section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
15605 @cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
15606 @cindex  C streams, interfacing
15607
15608 @noindent
15609 This package is a binding for the most commonly used operations
15610 on C streams.
15611
15612 @node Interfaces.CPP (i-cpp.ads)
15613 @section @code{Interfaces.CPP} (@file{i-cpp.ads})
15614 @cindex @code{Interfaces.CPP} (@file{i-cpp.ads})
15615 @cindex  C++ interfacing
15616 @cindex  Interfacing, to C++
15617
15618 @noindent
15619 This package provides facilities for use in interfacing to C++.  It
15620 is primarily intended to be used in connection with automated tools
15621 for the generation of C++ interfaces.
15622
15623 @node Interfaces.Packed_Decimal (i-pacdec.ads)
15624 @section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
15625 @cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
15626 @cindex  IBM Packed Format
15627 @cindex  Packed Decimal
15628
15629 @noindent
15630 This package provides a set of routines for conversions to and
15631 from a packed decimal format compatible with that used on IBM
15632 mainframes.
15633
15634 @node Interfaces.VxWorks (i-vxwork.ads)
15635 @section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
15636 @cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
15637 @cindex Interfacing to VxWorks
15638 @cindex VxWorks, interfacing
15639
15640 @noindent
15641 This package provides a limited binding to the VxWorks API.
15642 In particular, it interfaces with the
15643 VxWorks hardware interrupt facilities.
15644
15645 @node Interfaces.VxWorks.IO (i-vxwoio.ads)
15646 @section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
15647 @cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
15648 @cindex Interfacing to VxWorks' I/O
15649 @cindex VxWorks, I/O interfacing
15650 @cindex VxWorks, Get_Immediate
15651 @cindex Get_Immediate, VxWorks
15652
15653 @noindent
15654 This package provides a binding to the ioctl (IO/Control)
15655 function of VxWorks, defining a set of option values and
15656 function codes. A particular use of this package is
15657 to enable the use of Get_Immediate under VxWorks.
15658
15659 @node System.Address_Image (s-addima.ads)
15660 @section @code{System.Address_Image} (@file{s-addima.ads})
15661 @cindex @code{System.Address_Image} (@file{s-addima.ads})
15662 @cindex Address image
15663 @cindex Image, of an address
15664
15665 @noindent
15666 This function provides a useful debugging
15667 function that gives an (implementation dependent)
15668 string which identifies an address.
15669
15670 @node System.Assertions (s-assert.ads)
15671 @section @code{System.Assertions} (@file{s-assert.ads})
15672 @cindex @code{System.Assertions} (@file{s-assert.ads})
15673 @cindex Assertions
15674 @cindex Assert_Failure, exception
15675
15676 @noindent
15677 This package provides the declaration of the exception raised
15678 by an run-time assertion failure, as well as the routine that
15679 is used internally to raise this assertion.
15680
15681 @node System.Memory (s-memory.ads)
15682 @section @code{System.Memory} (@file{s-memory.ads})
15683 @cindex @code{System.Memory} (@file{s-memory.ads})
15684 @cindex Memory allocation
15685
15686 @noindent
15687 This package provides the interface to the low level routines used
15688 by the generated code for allocation and freeing storage for the
15689 default storage pool (analogous to the C routines malloc and free.
15690 It also provides a reallocation interface analogous to the C routine
15691 realloc. The body of this unit may be modified to provide alternative
15692 allocation mechanisms for the default pool, and in addition, direct
15693 calls to this unit may be made for low level allocation uses (for
15694 example see the body of @code{GNAT.Tables}).
15695
15696 @node System.Partition_Interface (s-parint.ads)
15697 @section @code{System.Partition_Interface} (@file{s-parint.ads})
15698 @cindex @code{System.Partition_Interface} (@file{s-parint.ads})
15699 @cindex Partition interfacing functions
15700
15701 @noindent
15702 This package provides facilities for partition interfacing.  It
15703 is used primarily in a distribution context when using Annex E
15704 with @code{GLADE}.
15705
15706 @node System.Pool_Global (s-pooglo.ads)
15707 @section @code{System.Pool_Global} (@file{s-pooglo.ads})
15708 @cindex @code{System.Pool_Global} (@file{s-pooglo.ads})
15709 @cindex Storage pool, global
15710 @cindex Global storage pool
15711
15712 @noindent
15713 This package provides a storage pool that is equivalent to the default
15714 storage pool used for access types for which no pool is specifically
15715 declared. It uses malloc/free to allocate/free and does not attempt to
15716 do any automatic reclamation.
15717
15718 @node System.Pool_Local (s-pooloc.ads)
15719 @section @code{System.Pool_Local} (@file{s-pooloc.ads})
15720 @cindex @code{System.Pool_Local} (@file{s-pooloc.ads})
15721 @cindex Storage pool, local
15722 @cindex Local storage pool
15723
15724 @noindent
15725 This package provides a storage pool that is intended for use with locally
15726 defined access types. It uses malloc/free for allocate/free, and maintains
15727 a list of allocated blocks, so that all storage allocated for the pool can
15728 be freed automatically when the pool is finalized.
15729
15730 @node System.Restrictions (s-restri.ads)
15731 @section @code{System.Restrictions} (@file{s-restri.ads})
15732 @cindex @code{System.Restrictions} (@file{s-restri.ads})
15733 @cindex Run-time restrictions access
15734
15735 @noindent
15736 This package provides facilities for accessing at run time
15737 the status of restrictions specified at compile time for
15738 the partition. Information is available both with regard
15739 to actual restrictions specified, and with regard to
15740 compiler determined information on which restrictions
15741 are violated by one or more packages in the partition.
15742
15743 @node System.Rident (s-rident.ads)
15744 @section @code{System.Rident} (@file{s-rident.ads})
15745 @cindex @code{System.Rident} (@file{s-rident.ads})
15746 @cindex Restrictions definitions
15747
15748 @noindent
15749 This package provides definitions of the restrictions
15750 identifiers supported by GNAT, and also the format of
15751 the restrictions provided in package System.Restrictions.
15752 It is not normally necessary to @code{with} this generic package
15753 since the necessary instantiation is included in
15754 package System.Restrictions.
15755
15756 @node System.Strings.Stream_Ops (s-ststop.ads)
15757 @section @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
15758 @cindex @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
15759 @cindex Stream operations
15760 @cindex String stream operations
15761
15762 @noindent
15763 This package provides a set of stream subprograms for standard string types.
15764 It is intended primarily to support implicit use of such subprograms when
15765 stream attributes are applied to string types, but the subprograms in this
15766 package can be used directly by application programs.
15767
15768 @node System.Task_Info (s-tasinf.ads)
15769 @section @code{System.Task_Info} (@file{s-tasinf.ads})
15770 @cindex @code{System.Task_Info} (@file{s-tasinf.ads})
15771 @cindex Task_Info pragma
15772
15773 @noindent
15774 This package provides target dependent functionality that is used
15775 to support the @code{Task_Info} pragma
15776
15777 @node System.Wch_Cnv (s-wchcnv.ads)
15778 @section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
15779 @cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
15780 @cindex Wide Character, Representation
15781 @cindex Wide String, Conversion
15782 @cindex Representation of wide characters
15783
15784 @noindent
15785 This package provides routines for converting between
15786 wide and wide wide characters and a representation as a value of type
15787 @code{Standard.String}, using a specified wide character
15788 encoding method.  It uses definitions in
15789 package @code{System.Wch_Con}.
15790
15791 @node System.Wch_Con (s-wchcon.ads)
15792 @section @code{System.Wch_Con} (@file{s-wchcon.ads})
15793 @cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
15794
15795 @noindent
15796 This package provides definitions and descriptions of
15797 the various methods used for encoding wide characters
15798 in ordinary strings.  These definitions are used by
15799 the package @code{System.Wch_Cnv}.
15800
15801 @node Interfacing to Other Languages
15802 @chapter Interfacing to Other Languages
15803 @noindent
15804 The facilities in annex B of the Ada Reference Manual are fully
15805 implemented in GNAT, and in addition, a full interface to C++ is
15806 provided.
15807
15808 @menu
15809 * Interfacing to C::
15810 * Interfacing to C++::
15811 * Interfacing to COBOL::
15812 * Interfacing to Fortran::
15813 * Interfacing to non-GNAT Ada code::
15814 @end menu
15815
15816 @node Interfacing to C
15817 @section Interfacing to C
15818
15819 @noindent
15820 Interfacing to C with GNAT can use one of two approaches:
15821
15822 @itemize @bullet
15823 @item
15824 The types in the package @code{Interfaces.C} may be used.
15825 @item
15826 Standard Ada types may be used directly.  This may be less portable to
15827 other compilers, but will work on all GNAT compilers, which guarantee
15828 correspondence between the C and Ada types.
15829 @end itemize
15830
15831 @noindent
15832 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
15833 effect, since this is the default.  The following table shows the
15834 correspondence between Ada scalar types and the corresponding C types.
15835
15836 @table @code
15837 @item Integer
15838 @code{int}
15839 @item Short_Integer
15840 @code{short}
15841 @item Short_Short_Integer
15842 @code{signed char}
15843 @item Long_Integer
15844 @code{long}
15845 @item Long_Long_Integer
15846 @code{long long}
15847 @item Short_Float
15848 @code{float}
15849 @item Float
15850 @code{float}
15851 @item Long_Float
15852 @code{double}
15853 @item Long_Long_Float
15854 This is the longest floating-point type supported by the hardware.
15855 @end table
15856
15857 @noindent
15858 Additionally, there are the following general correspondences between Ada
15859 and C types:
15860 @itemize @bullet
15861 @item
15862 Ada enumeration types map to C enumeration types directly if pragma
15863 @code{Convention C} is specified, which causes them to have int
15864 length.  Without pragma @code{Convention C}, Ada enumeration types map to
15865 8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short},
15866 @code{int}, respectively) depending on the number of values passed.
15867 This is the only case in which pragma @code{Convention C} affects the
15868 representation of an Ada type.
15869
15870 @item
15871 Ada access types map to C pointers, except for the case of pointers to
15872 unconstrained types in Ada, which have no direct C equivalent.
15873
15874 @item
15875 Ada arrays map directly to C arrays.
15876
15877 @item
15878 Ada records map directly to C structures.
15879
15880 @item
15881 Packed Ada records map to C structures where all members are bit fields
15882 of the length corresponding to the @code{@var{type}'Size} value in Ada.
15883 @end itemize
15884
15885 @node Interfacing to C++
15886 @section Interfacing to C++
15887
15888 @noindent
15889 The interface to C++ makes use of the following pragmas, which are
15890 primarily intended to be constructed automatically using a binding generator
15891 tool, although it is possible to construct them by hand.  No suitable binding
15892 generator tool is supplied with GNAT though.
15893
15894 Using these pragmas it is possible to achieve complete
15895 inter-operability between Ada tagged types and C++ class definitions.
15896 See @ref{Implementation Defined Pragmas}, for more details.
15897
15898 @table @code
15899 @item pragma CPP_Class ([Entity =>] @var{LOCAL_NAME})
15900 The argument denotes an entity in the current declarative region that is
15901 declared as a tagged or untagged record type. It indicates that the type
15902 corresponds to an externally declared C++ class type, and is to be laid
15903 out the same way that C++ would lay out the type.
15904
15905 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
15906 for backward compatibility but its functionality is available
15907 using pragma @code{Import} with @code{Convention} = @code{CPP}.
15908
15909 @item pragma CPP_Constructor ([Entity =>] @var{LOCAL_NAME})
15910 This pragma identifies an imported function (imported in the usual way
15911 with pragma @code{Import}) as corresponding to a C++ constructor.
15912 @end table
15913
15914 @node Interfacing to COBOL
15915 @section Interfacing to COBOL
15916
15917 @noindent
15918 Interfacing to COBOL is achieved as described in section B.4 of
15919 the Ada Reference Manual.
15920
15921 @node Interfacing to Fortran
15922 @section Interfacing to Fortran
15923
15924 @noindent
15925 Interfacing to Fortran is achieved as described in section B.5 of the
15926 Ada Reference Manual.  The pragma @code{Convention Fortran}, applied to a
15927 multi-dimensional array causes the array to be stored in column-major
15928 order as required for convenient interface to Fortran.
15929
15930 @node Interfacing to non-GNAT Ada code
15931 @section Interfacing to non-GNAT Ada code
15932
15933 It is possible to specify the convention @code{Ada} in a pragma
15934 @code{Import} or pragma @code{Export}.  However this refers to
15935 the calling conventions used by GNAT, which may or may not be
15936 similar enough to those used by some other Ada 83 / Ada 95 / Ada 2005
15937 compiler to allow interoperation.
15938
15939 If arguments types are kept simple, and if the foreign compiler generally
15940 follows system calling conventions, then it may be possible to integrate
15941 files compiled by other Ada compilers, provided that the elaboration
15942 issues are adequately addressed (for example by eliminating the
15943 need for any load time elaboration).
15944
15945 In particular, GNAT running on VMS is designed to
15946 be highly compatible with the DEC Ada 83 compiler, so this is one
15947 case in which it is possible to import foreign units of this type,
15948 provided that the data items passed are restricted to simple scalar
15949 values or simple record types without variants, or simple array
15950 types with fixed bounds.
15951
15952 @node Specialized Needs Annexes
15953 @chapter Specialized Needs Annexes
15954
15955 @noindent
15956 Ada 95 and Ada 2005 define a number of Specialized Needs Annexes, which are not
15957 required in all implementations.  However, as described in this chapter,
15958 GNAT implements all of these annexes:
15959
15960 @table @asis
15961 @item Systems Programming (Annex C)
15962 The Systems Programming Annex is fully implemented.
15963
15964 @item Real-Time Systems (Annex D)
15965 The Real-Time Systems Annex is fully implemented.
15966
15967 @item Distributed Systems (Annex E)
15968 Stub generation is fully implemented in the GNAT compiler.  In addition,
15969 a complete compatible PCS is available as part of the GLADE system,
15970 a separate product.  When the two
15971 products are used in conjunction, this annex is fully implemented.
15972
15973 @item Information Systems (Annex F)
15974 The Information Systems annex is fully implemented.
15975
15976 @item Numerics (Annex G)
15977 The Numerics Annex is fully implemented.
15978
15979 @item Safety and Security / High-Integrity Systems (Annex H)
15980 The Safety and Security Annex (termed the High-Integrity Systems Annex
15981 in Ada 2005) is fully implemented.
15982 @end table
15983
15984 @node Implementation of Specific Ada Features
15985 @chapter Implementation of Specific Ada Features
15986
15987 @noindent
15988 This chapter describes the GNAT implementation of several Ada language
15989 facilities.
15990
15991 @menu
15992 * Machine Code Insertions::
15993 * GNAT Implementation of Tasking::
15994 * GNAT Implementation of Shared Passive Packages::
15995 * Code Generation for Array Aggregates::
15996 * The Size of Discriminated Records with Default Discriminants::
15997 * Strict Conformance to the Ada Reference Manual::
15998 @end menu
15999
16000 @node Machine Code Insertions
16001 @section Machine Code Insertions
16002 @cindex Machine Code insertions
16003
16004 @noindent
16005 Package @code{Machine_Code} provides machine code support as described
16006 in the Ada Reference Manual in two separate forms:
16007 @itemize @bullet
16008 @item
16009 Machine code statements, consisting of qualified expressions that
16010 fit the requirements of RM section 13.8.
16011 @item
16012 An intrinsic callable procedure, providing an alternative mechanism of
16013 including machine instructions in a subprogram.
16014 @end itemize
16015
16016 @noindent
16017 The two features are similar, and both are closely related to the mechanism
16018 provided by the asm instruction in the GNU C compiler.  Full understanding
16019 and use of the facilities in this package requires understanding the asm
16020 instruction, see @ref{Extended Asm,, Assembler Instructions with C Expression
16021 Operands, gcc, Using the GNU Compiler Collection (GCC)}.
16022
16023 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
16024 semantic restrictions and effects as described below.  Both are provided so
16025 that the procedure call can be used as a statement, and the function call
16026 can be used to form a code_statement.
16027
16028 The first example given in the GCC documentation is the C @code{asm}
16029 instruction:
16030 @smallexample
16031    asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
16032 @end smallexample
16033
16034 @noindent
16035 The equivalent can be written for GNAT as:
16036
16037 @smallexample @c ada
16038 Asm ("fsinx %1 %0",
16039      My_Float'Asm_Output ("=f", result),
16040      My_Float'Asm_Input  ("f",  angle));
16041 @end smallexample
16042
16043 @noindent
16044 The first argument to @code{Asm} is the assembler template, and is
16045 identical to what is used in GNU C@.  This string must be a static
16046 expression.  The second argument is the output operand list.  It is
16047 either a single @code{Asm_Output} attribute reference, or a list of such
16048 references enclosed in parentheses (technically an array aggregate of
16049 such references).
16050
16051 The @code{Asm_Output} attribute denotes a function that takes two
16052 parameters.  The first is a string, the second is the name of a variable
16053 of the type designated by the attribute prefix.  The first (string)
16054 argument is required to be a static expression and designates the
16055 constraint for the parameter (e.g.@: what kind of register is
16056 required).  The second argument is the variable to be updated with the
16057 result.  The possible values for constraint are the same as those used in
16058 the RTL, and are dependent on the configuration file used to build the
16059 GCC back end.  If there are no output operands, then this argument may
16060 either be omitted, or explicitly given as @code{No_Output_Operands}.
16061
16062 The second argument of @code{@var{my_float}'Asm_Output} functions as
16063 though it were an @code{out} parameter, which is a little curious, but
16064 all names have the form of expressions, so there is no syntactic
16065 irregularity, even though normally functions would not be permitted
16066 @code{out} parameters.  The third argument is the list of input
16067 operands.  It is either a single @code{Asm_Input} attribute reference, or
16068 a list of such references enclosed in parentheses (technically an array
16069 aggregate of such references).
16070
16071 The @code{Asm_Input} attribute denotes a function that takes two
16072 parameters.  The first is a string, the second is an expression of the
16073 type designated by the prefix.  The first (string) argument is required
16074 to be a static expression, and is the constraint for the parameter,
16075 (e.g.@: what kind of register is required).  The second argument is the
16076 value to be used as the input argument.  The possible values for the
16077 constant are the same as those used in the RTL, and are dependent on
16078 the configuration file used to built the GCC back end.
16079
16080 If there are no input operands, this argument may either be omitted, or
16081 explicitly given as @code{No_Input_Operands}.  The fourth argument, not
16082 present in the above example, is a list of register names, called the
16083 @dfn{clobber} argument.  This argument, if given, must be a static string
16084 expression, and is a space or comma separated list of names of registers
16085 that must be considered destroyed as a result of the @code{Asm} call.  If
16086 this argument is the null string (the default value), then the code
16087 generator assumes that no additional registers are destroyed.
16088
16089 The fifth argument, not present in the above example, called the
16090 @dfn{volatile} argument, is by default @code{False}.  It can be set to
16091 the literal value @code{True} to indicate to the code generator that all
16092 optimizations with respect to the instruction specified should be
16093 suppressed, and that in particular, for an instruction that has outputs,
16094 the instruction will still be generated, even if none of the outputs are
16095 used.  @xref{Extended Asm,, Assembler Instructions with C Expression Operands,
16096 gcc, Using the GNU Compiler Collection (GCC)}, for the full description.
16097 Generally it is strongly advisable to use Volatile for any ASM statement
16098 that is missing either input or output operands, or when two or more ASM
16099 statements appear in sequence, to avoid unwanted optimizations. A warning
16100 is generated if this advice is not followed.
16101
16102 The @code{Asm} subprograms may be used in two ways.  First the procedure
16103 forms can be used anywhere a procedure call would be valid, and
16104 correspond to what the RM calls ``intrinsic'' routines.  Such calls can
16105 be used to intersperse machine instructions with other Ada statements.
16106 Second, the function forms, which return a dummy value of the limited
16107 private type @code{Asm_Insn}, can be used in code statements, and indeed
16108 this is the only context where such calls are allowed.  Code statements
16109 appear as aggregates of the form:
16110
16111 @smallexample @c ada
16112 Asm_Insn'(Asm (@dots{}));
16113 Asm_Insn'(Asm_Volatile (@dots{}));
16114 @end smallexample
16115
16116 @noindent
16117 In accordance with RM rules, such code statements are allowed only
16118 within subprograms whose entire body consists of such statements.  It is
16119 not permissible to intermix such statements with other Ada statements.
16120
16121 Typically the form using intrinsic procedure calls is more convenient
16122 and more flexible.  The code statement form is provided to meet the RM
16123 suggestion that such a facility should be made available.  The following
16124 is the exact syntax of the call to @code{Asm}. As usual, if named notation
16125 is used, the arguments may be given in arbitrary order, following the
16126 normal rules for use of positional and named arguments)
16127
16128 @smallexample
16129 ASM_CALL ::= Asm (
16130                  [Template =>] static_string_EXPRESSION
16131                [,[Outputs  =>] OUTPUT_OPERAND_LIST      ]
16132                [,[Inputs   =>] INPUT_OPERAND_LIST       ]
16133                [,[Clobber  =>] static_string_EXPRESSION ]
16134                [,[Volatile =>] static_boolean_EXPRESSION] )
16135
16136 OUTPUT_OPERAND_LIST ::=
16137   [PREFIX.]No_Output_Operands
16138 | OUTPUT_OPERAND_ATTRIBUTE
16139 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
16140
16141 OUTPUT_OPERAND_ATTRIBUTE ::=
16142   SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
16143
16144 INPUT_OPERAND_LIST ::=
16145   [PREFIX.]No_Input_Operands
16146 | INPUT_OPERAND_ATTRIBUTE
16147 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
16148
16149 INPUT_OPERAND_ATTRIBUTE ::=
16150   SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
16151 @end smallexample
16152
16153 @noindent
16154 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
16155 are declared in the package @code{Machine_Code} and must be referenced
16156 according to normal visibility rules. In particular if there is no
16157 @code{use} clause for this package, then appropriate package name
16158 qualification is required.
16159
16160 @node GNAT Implementation of Tasking
16161 @section GNAT Implementation of Tasking
16162
16163 @noindent
16164 This chapter outlines the basic GNAT approach to tasking (in particular,
16165 a multi-layered library for portability) and discusses issues related
16166 to compliance with the Real-Time Systems Annex.
16167
16168 @menu
16169 * Mapping Ada Tasks onto the Underlying Kernel Threads::
16170 * Ensuring Compliance with the Real-Time Annex::
16171 @end menu
16172
16173 @node Mapping Ada Tasks onto the Underlying Kernel Threads
16174 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
16175
16176 @noindent
16177 GNAT's run-time support comprises two layers:
16178
16179 @itemize @bullet
16180 @item GNARL (GNAT Run-time Layer)
16181 @item GNULL (GNAT Low-level Library)
16182 @end itemize
16183
16184 @noindent
16185 In GNAT, Ada's tasking services rely on a platform and OS independent
16186 layer known as GNARL@.  This code is responsible for implementing the
16187 correct semantics of Ada's task creation, rendezvous, protected
16188 operations etc.
16189
16190 GNARL decomposes Ada's tasking semantics into simpler lower level
16191 operations such as create a thread, set the priority of a thread,
16192 yield, create a lock, lock/unlock, etc.  The spec for these low-level
16193 operations constitutes GNULLI, the GNULL Interface.  This interface is
16194 directly inspired from the POSIX real-time API@.
16195
16196 If the underlying executive or OS implements the POSIX standard
16197 faithfully, the GNULL Interface maps as is to the services offered by
16198 the underlying kernel.  Otherwise, some target dependent glue code maps
16199 the services offered by the underlying kernel to the semantics expected
16200 by GNARL@.
16201
16202 Whatever the underlying OS (VxWorks, UNIX, Windows, etc.) the
16203 key point is that each Ada task is mapped on a thread in the underlying
16204 kernel.  For example, in the case of VxWorks, one Ada task = one VxWorks task.
16205
16206 In addition Ada task priorities map onto the underlying thread priorities.
16207 Mapping Ada tasks onto the underlying kernel threads has several advantages:
16208
16209 @itemize @bullet
16210 @item
16211 The underlying scheduler is used to schedule the Ada tasks.  This
16212 makes Ada tasks as efficient as kernel threads from a scheduling
16213 standpoint.
16214
16215 @item
16216 Interaction with code written in C containing threads is eased
16217 since at the lowest level Ada tasks and C threads map onto the same
16218 underlying kernel concept.
16219
16220 @item
16221 When an Ada task is blocked during I/O the remaining Ada tasks are
16222 able to proceed.
16223
16224 @item
16225 On multiprocessor systems Ada tasks can execute in parallel.
16226 @end itemize
16227
16228 @noindent
16229 Some threads libraries offer a mechanism to fork a new process, with the
16230 child process duplicating the threads from the parent.
16231 GNAT does not
16232 support this functionality when the parent contains more than one task.
16233 @cindex Forking a new process
16234
16235 @node Ensuring Compliance with the Real-Time Annex
16236 @subsection Ensuring Compliance with the Real-Time Annex
16237 @cindex Real-Time Systems Annex compliance
16238
16239 @noindent
16240 Although mapping Ada tasks onto
16241 the underlying threads has significant advantages, it does create some
16242 complications when it comes to respecting the scheduling semantics
16243 specified in the real-time annex (Annex D).
16244
16245 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
16246 scheduling policy states:
16247
16248 @quotation
16249 @emph{When the active priority of a ready task that is not running
16250 changes, or the setting of its base priority takes effect, the
16251 task is removed from the ready queue for its old active priority
16252 and is added at the tail of the ready queue for its new active
16253 priority, except in the case where the active priority is lowered
16254 due to the loss of inherited priority, in which case the task is
16255 added at the head of the ready queue for its new active priority.}
16256 @end quotation
16257
16258 @noindent
16259 While most kernels do put tasks at the end of the priority queue when
16260 a task changes its priority, (which respects the main
16261 FIFO_Within_Priorities requirement), almost none keep a thread at the
16262 beginning of its priority queue when its priority drops from the loss
16263 of inherited priority.
16264
16265 As a result most vendors have provided incomplete Annex D implementations.
16266
16267 The GNAT run-time, has a nice cooperative solution to this problem
16268 which ensures that accurate FIFO_Within_Priorities semantics are
16269 respected.
16270
16271 The principle is as follows.  When an Ada task T is about to start
16272 running, it checks whether some other Ada task R with the same
16273 priority as T has been suspended due to the loss of priority
16274 inheritance.  If this is the case, T yields and is placed at the end of
16275 its priority queue.  When R arrives at the front of the queue it
16276 executes.
16277
16278 Note that this simple scheme preserves the relative order of the tasks
16279 that were ready to execute in the priority queue where R has been
16280 placed at the end.
16281
16282 @node GNAT Implementation of Shared Passive Packages
16283 @section GNAT Implementation of Shared Passive Packages
16284 @cindex Shared passive packages
16285
16286 @noindent
16287 GNAT fully implements the pragma @code{Shared_Passive} for
16288 @cindex pragma @code{Shared_Passive}
16289 the purpose of designating shared passive packages.
16290 This allows the use of passive partitions in the
16291 context described in the Ada Reference Manual; i.e., for communication
16292 between separate partitions of a distributed application using the
16293 features in Annex E.
16294 @cindex Annex E
16295 @cindex Distribution Systems Annex
16296
16297 However, the implementation approach used by GNAT provides for more
16298 extensive usage as follows:
16299
16300 @table @emph
16301 @item Communication between separate programs
16302
16303 This allows separate programs to access the data in passive
16304 partitions, using protected objects for synchronization where
16305 needed. The only requirement is that the two programs have a
16306 common shared file system. It is even possible for programs
16307 running on different machines with different architectures
16308 (e.g.@: different endianness) to communicate via the data in
16309 a passive partition.
16310
16311 @item Persistence between program runs
16312
16313 The data in a passive package can persist from one run of a
16314 program to another, so that a later program sees the final
16315 values stored by a previous run of the same program.
16316
16317 @end table
16318
16319 @noindent
16320 The implementation approach used is to store the data in files. A
16321 separate stream file is created for each object in the package, and
16322 an access to an object causes the corresponding file to be read or
16323 written.
16324
16325 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
16326 @cindex @code{SHARED_MEMORY_DIRECTORY} environment variable
16327 set to the directory to be used for these files.
16328 The files in this directory
16329 have names that correspond to their fully qualified names. For
16330 example, if we have the package
16331
16332 @smallexample @c ada
16333 package X is
16334   pragma Shared_Passive (X);
16335   Y : Integer;
16336   Z : Float;
16337 end X;
16338 @end smallexample
16339
16340 @noindent
16341 and the environment variable is set to @code{/stemp/}, then the files created
16342 will have the names:
16343
16344 @smallexample
16345 /stemp/x.y
16346 /stemp/x.z
16347 @end smallexample
16348
16349 @noindent
16350 These files are created when a value is initially written to the object, and
16351 the files are retained until manually deleted. This provides the persistence
16352 semantics. If no file exists, it means that no partition has assigned a value
16353 to the variable; in this case the initial value declared in the package
16354 will be used. This model ensures that there are no issues in synchronizing
16355 the elaboration process, since elaboration of passive packages elaborates the
16356 initial values, but does not create the files.
16357
16358 The files are written using normal @code{Stream_IO} access.
16359 If you want to be able
16360 to communicate between programs or partitions running on different
16361 architectures, then you should use the XDR versions of the stream attribute
16362 routines, since these are architecture independent.
16363
16364 If active synchronization is required for access to the variables in the
16365 shared passive package, then as described in the Ada Reference Manual, the
16366 package may contain protected objects used for this purpose. In this case
16367 a lock file (whose name is @file{___lock} (three underscores)
16368 is created in the shared memory directory.
16369 @cindex @file{___lock} file (for shared passive packages)
16370 This is used to provide the required locking
16371 semantics for proper protected object synchronization.
16372
16373 As of January 2003, GNAT supports shared passive packages on all platforms
16374 except for OpenVMS.
16375
16376 @node Code Generation for Array Aggregates
16377 @section Code Generation for Array Aggregates
16378
16379 @menu
16380 * Static constant aggregates with static bounds::
16381 * Constant aggregates with unconstrained nominal types::
16382 * Aggregates with static bounds::
16383 * Aggregates with non-static bounds::
16384 * Aggregates in assignment statements::
16385 @end menu
16386
16387 @noindent
16388 Aggregates have a rich syntax and allow the user to specify the values of
16389 complex data structures by means of a single construct.  As a result, the
16390 code generated for aggregates can be quite complex and involve loops, case
16391 statements and multiple assignments.  In the simplest cases, however, the
16392 compiler will recognize aggregates whose components and constraints are
16393 fully static, and in those cases the compiler will generate little or no
16394 executable code.  The following is an outline of the code that GNAT generates
16395 for various aggregate constructs.  For further details, you will find it
16396 useful to examine the output produced by the -gnatG flag to see the expanded
16397 source that is input to the code generator.  You may also want to examine
16398 the assembly code generated at various levels of optimization.
16399
16400 The code generated for aggregates depends on the context, the component values,
16401 and the type.  In the context of an object declaration the code generated is
16402 generally simpler than in the case of an assignment.  As a general rule, static
16403 component values and static subtypes also lead to simpler code.
16404
16405 @node Static constant aggregates with static bounds
16406 @subsection Static constant aggregates with static bounds
16407
16408 @noindent
16409 For the declarations:
16410 @smallexample @c ada
16411     type One_Dim is array (1..10) of integer;
16412     ar0 : constant One_Dim := (1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
16413 @end smallexample
16414
16415 @noindent
16416 GNAT generates no executable code: the constant ar0 is placed in static memory.
16417 The same is true for constant aggregates with named associations:
16418
16419 @smallexample @c ada
16420     Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1 => 1, 5 .. 10 => 0);
16421     Cr3 : constant One_Dim := (others => 7777);
16422 @end smallexample
16423
16424 @noindent
16425 The same is true for multidimensional constant arrays such as:
16426
16427 @smallexample @c ada
16428     type two_dim is array (1..3, 1..3) of integer;
16429     Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
16430 @end smallexample
16431
16432 @noindent
16433 The same is true for arrays of one-dimensional arrays: the following are
16434 static:
16435
16436 @smallexample @c ada
16437 type ar1b  is array (1..3) of boolean;
16438 type ar_ar is array (1..3) of ar1b;
16439 None  : constant ar1b := (others => false);     --  fully static
16440 None2 : constant ar_ar := (1..3 => None);       --  fully static
16441 @end smallexample
16442
16443 @noindent
16444 However, for multidimensional aggregates with named associations, GNAT will
16445 generate assignments and loops, even if all associations are static.  The
16446 following two declarations generate a loop for the first dimension, and
16447 individual component assignments for the second dimension:
16448
16449 @smallexample @c ada
16450 Zero1: constant two_dim := (1..3 => (1..3 => 0));
16451 Zero2: constant two_dim := (others => (others => 0));
16452 @end smallexample
16453
16454 @node Constant aggregates with unconstrained nominal types
16455 @subsection Constant aggregates with unconstrained nominal types
16456
16457 @noindent
16458 In such cases the aggregate itself establishes the subtype, so that
16459 associations with @code{others} cannot be used.  GNAT determines the
16460 bounds for the actual subtype of the aggregate, and allocates the
16461 aggregate statically as well.  No code is generated for the following:
16462
16463 @smallexample @c ada
16464     type One_Unc is array (natural range <>) of integer;
16465     Cr_Unc : constant One_Unc := (12,24,36);
16466 @end smallexample
16467
16468 @node Aggregates with static bounds
16469 @subsection Aggregates with static bounds
16470
16471 @noindent
16472 In all previous examples the aggregate was the initial (and immutable) value
16473 of a constant.  If the aggregate initializes a variable, then code is generated
16474 for it as a combination of individual assignments and loops over the target
16475 object.  The declarations
16476
16477 @smallexample @c ada
16478        Cr_Var1 : One_Dim := (2, 5, 7, 11, 0, 0, 0, 0, 0, 0);
16479        Cr_Var2 : One_Dim := (others > -1);
16480 @end smallexample
16481
16482 @noindent
16483 generate the equivalent of
16484
16485 @smallexample @c ada
16486        Cr_Var1 (1) := 2;
16487        Cr_Var1 (2) := 3;
16488        Cr_Var1 (3) := 5;
16489        Cr_Var1 (4) := 11;
16490
16491        for I in Cr_Var2'range loop
16492           Cr_Var2 (I) := -1;
16493        end loop;
16494 @end smallexample
16495
16496 @node Aggregates with non-static bounds
16497 @subsection Aggregates with non-static bounds
16498
16499 @noindent
16500 If the bounds of the aggregate are not statically compatible with the bounds
16501 of the nominal subtype  of the target, then constraint checks have to be
16502 generated on the bounds.  For a multidimensional array, constraint checks may
16503 have to be applied to sub-arrays individually, if they do not have statically
16504 compatible subtypes.
16505
16506 @node Aggregates in assignment statements
16507 @subsection Aggregates in assignment statements
16508
16509 @noindent
16510 In general, aggregate assignment requires the construction of a temporary,
16511 and a copy from the temporary to the target of the assignment.  This is because
16512 it is not always possible to convert the assignment into a series of individual
16513 component assignments.  For example, consider the simple case:
16514
16515 @smallexample @c ada
16516         A := (A(2), A(1));
16517 @end smallexample
16518
16519 @noindent
16520 This cannot be converted into:
16521
16522 @smallexample @c ada
16523         A(1) := A(2);
16524         A(2) := A(1);
16525 @end smallexample
16526
16527 @noindent
16528 So the aggregate has to be built first in a separate location, and then
16529 copied into the target.  GNAT recognizes simple cases where this intermediate
16530 step is not required, and the assignments can be performed in place, directly
16531 into the target.  The following sufficient criteria are applied:
16532
16533 @itemize @bullet
16534 @item
16535 The bounds of the aggregate are static, and the associations are static.
16536 @item
16537 The components of the aggregate are static constants, names of
16538 simple variables that are not renamings, or expressions not involving
16539 indexed components whose operands obey these rules.
16540 @end itemize
16541
16542 @noindent
16543 If any of these conditions are violated, the aggregate will be built in
16544 a temporary (created either by the front-end or the code generator) and then
16545 that temporary will be copied onto the target.
16546
16547 @node The Size of Discriminated Records with Default Discriminants
16548 @section The Size of Discriminated Records with Default Discriminants
16549
16550 @noindent
16551 If a discriminated type @code{T} has discriminants with default values, it is
16552 possible to declare an object of this type without providing an explicit
16553 constraint:
16554
16555 @smallexample @c ada
16556 @group
16557 type Size is range 1..100;
16558
16559 type Rec (D : Size := 15) is record
16560    Name : String (1..D);
16561 end T;
16562
16563 Word : Rec;
16564 @end group
16565 @end smallexample
16566
16567 @noindent
16568 Such an object is said to be @emph{unconstrained}.
16569 The discriminant of the object
16570 can be modified by a full assignment to the object, as long as it preserves the
16571 relation between the value of the discriminant, and the value of the components
16572 that depend on it:
16573
16574 @smallexample @c ada
16575 @group
16576 Word := (3, "yes");
16577
16578 Word := (5, "maybe");
16579
16580 Word := (5, "no"); -- raises Constraint_Error
16581 @end group
16582 @end smallexample
16583
16584 @noindent
16585 In order to support this behavior efficiently, an unconstrained object is
16586 given the maximum size that any value of the type requires. In the case
16587 above, @code{Word} has storage for the discriminant and for
16588 a @code{String} of length 100.
16589 It is important to note that unconstrained objects do not require dynamic
16590 allocation. It would be an improper implementation to place on the heap those
16591 components whose size depends on discriminants. (This improper implementation
16592 was used by some Ada83 compilers, where the @code{Name} component above
16593 would have
16594 been stored as a pointer to a dynamic string). Following the principle that
16595 dynamic storage management should never be introduced implicitly,
16596 an Ada compiler should reserve the full size for an unconstrained declared
16597 object, and place it on the stack.
16598
16599 This maximum size approach
16600 has been a source of surprise to some users, who expect the default
16601 values of the discriminants to determine the size reserved for an
16602 unconstrained object: ``If the default is 15, why should the object occupy
16603 a larger size?''
16604 The answer, of course, is that the discriminant may be later modified,
16605 and its full range of values must be taken into account. This is why the
16606 declaration:
16607
16608 @smallexample
16609 @group
16610 type Rec (D : Positive := 15) is record
16611    Name : String (1..D);
16612 end record;
16613
16614 Too_Large : Rec;
16615 @end group
16616 @end smallexample
16617
16618 @noindent
16619 is flagged by the compiler with a warning:
16620 an attempt to create @code{Too_Large} will raise @code{Storage_Error},
16621 because the required size includes @code{Positive'Last}
16622 bytes. As the first example indicates, the proper approach is to declare an
16623 index type of ``reasonable'' range so that unconstrained objects are not too
16624 large.
16625
16626 One final wrinkle: if the object is declared to be @code{aliased}, or if it is
16627 created in the heap by means of an allocator, then it is @emph{not}
16628 unconstrained:
16629 it is constrained by the default values of the discriminants, and those values
16630 cannot be modified by full assignment. This is because in the presence of
16631 aliasing all views of the object (which may be manipulated by different tasks,
16632 say) must be consistent, so it is imperative that the object, once created,
16633 remain invariant.
16634
16635 @node Strict Conformance to the Ada Reference Manual
16636 @section Strict Conformance to the Ada Reference Manual
16637
16638 @noindent
16639 The dynamic semantics defined by the Ada Reference Manual impose a set of
16640 run-time checks to be generated. By default, the GNAT compiler will insert many
16641 run-time checks into the compiled code, including most of those required by the
16642 Ada Reference Manual. However, there are three checks that are not enabled
16643 in the default mode for efficiency reasons: arithmetic overflow checking for
16644 integer operations (including division by zero), checks for access before
16645 elaboration on subprogram calls, and stack overflow checking (most operating
16646 systems do not perform this check by default).
16647
16648 Strict conformance to the Ada Reference Manual can be achieved by adding
16649 three compiler options for overflow checking for integer operations
16650 (@option{-gnato}), dynamic checks for access-before-elaboration on subprogram
16651 calls and generic instantiations (@option{-gnatE}), and stack overflow
16652 checking (@option{-fstack-check}).
16653
16654 Note that the result of a floating point arithmetic operation in overflow and
16655 invalid situations, when the @code{Machine_Overflows} attribute of the result
16656 type is @code{False}, is to generate IEEE NaN and infinite values. This is the
16657 case for machines compliant with the IEEE floating-point standard, but on
16658 machines that are not fully compliant with this standard, such as Alpha, the
16659 @option{-mieee} compiler flag must be used for achieving IEEE confirming
16660 behavior (although at the cost of a significant performance penalty), so
16661 infinite and NaN values are properly generated.
16662
16663
16664 @node Implementation of Ada 2012 Features
16665 @chapter Implementation of Ada 2012 Features
16666 @cindex Ada 2012 implementation status
16667
16668 This chapter contains a complete list of Ada 2012 features that have been
16669 implemented as of GNAT version 6.4. Generally, these features are only
16670 available if the @option{-gnat12} (Ada 2012 features enabled) flag is set
16671 @cindex @option{-gnat12} option
16672 or if the configuration pragma @code{Ada_2012} is used.
16673 @cindex pragma @code{Ada_2012}
16674 @cindex configuration pragma @code{Ada_2012}
16675 @cindex @code{Ada_2012} configuration pragma
16676 However, new pragmas, attributes, and restrictions are
16677 unconditionally available, since the Ada 95 standard allows the addition of
16678 new pragmas, attributes, and restrictions (there are exceptions, which are
16679 documented in the individual descriptions), and also certain packages
16680 were made available in earlier versions of Ada.
16681
16682 An ISO date (YYYY-MM-DD) appears in parentheses on the description line.
16683 This date shows the implementation date of the feature. Any wavefront
16684 subsequent to this date will contain the indicated feature, as will any
16685 subsequent releases. A date of 0000-00-00 means that GNAT has always
16686 implemented the feature, or implemented it as soon as it appeared as a
16687 binding interpretation.
16688
16689 Each feature corresponds to an Ada Issue (``AI'') approved by the Ada
16690 standardization group (ISO/IEC JTC1/SC22/WG9) for inclusion in Ada 2012.
16691 The features are ordered based on the relevant sections of the Ada
16692 Reference Manual (``RM'').  When a given AI relates to multiple points
16693 in the RM, the earliest is used.
16694
16695 A complete description of the AIs may be found in
16696 @url{www.ada-auth.org/ai05-summary.html}.
16697
16698 @itemize @bullet
16699
16700 @item
16701 @emph{AI-0176 Quantified expressions (2010-09-29)}
16702 @cindex AI-0176 (Ada 2012 feature)
16703
16704 @noindent
16705   Both universally and existentially quantified expressions are implemented.
16706   They use the new syntax for iterators proposed in AI05-139-2, as well as
16707   the standard Ada loop syntax.
16708
16709 @noindent
16710   RM References:  1.01.04 (12)   2.09 (2/2)   4.04 (7)   4.05.09 (0)
16711
16712 @item
16713 @emph{AI-0079 Allow @i{other_format} characters in source (2010-07-10)}
16714 @cindex AI-0079 (Ada 2012 feature)
16715
16716 @noindent
16717   Wide characters in the unicode category @i{other_format} are now allowed in
16718   source programs between tokens, but not within a token such as an identifier.
16719
16720 @noindent
16721   RM References:  2.01 (4/2)   2.02 (7)
16722
16723 @item
16724 @emph{AI-0091 Do not allow @i{other_format} in identifiers (0000-00-00)}
16725 @cindex AI-0091 (Ada 2012 feature)
16726
16727 @noindent
16728   Wide characters in the unicode category @i{other_format} are not permitted
16729   within  an identifier, since this can be a security problem. The error
16730   message for this case has been improved to be more specific, but GNAT has
16731   never allowed such characters to appear in identifiers.
16732
16733 @noindent
16734   RM References:  2.03 (3.1/2)   2.03 (4/2)   2.03 (5/2)   2.03 (5.1/2)   2.03 (5.2/2)   2.03 (5.3/2)   2.09 (2/2)
16735
16736 @item
16737 @emph{AI-0100 Placement of pragmas  (2010-07-01)}
16738 @cindex AI-0100 (Ada 2012 feature)
16739
16740 @noindent
16741   This AI is an earlier version of AI-163. It simplifies the rules
16742   for legal placement of pragmas. In the case of lists that allow pragmas, if
16743   the list may have no elements, then the list may consist solely of pragmas.
16744
16745 @noindent
16746   RM References:  2.08 (7)
16747
16748 @item
16749 @emph{AI-0163 Pragmas in place of null (2010-07-01)}
16750 @cindex AI-0163 (Ada 2012 feature)
16751
16752 @noindent
16753   A statement sequence may be composed entirely of pragmas. It is no longer
16754   necessary to add a dummy @code{null} statement to make the sequence legal.
16755
16756 @noindent
16757   RM References:  2.08 (7)   2.08 (16)
16758
16759
16760 @item
16761 @emph{AI-0080 ``View of'' not needed if clear from context (0000-00-00)}
16762 @cindex AI-0080 (Ada 2012 feature)
16763
16764 @noindent
16765   This is an editorial change only, described as non-testable in the AI.
16766
16767 @noindent
16768   RM References:  3.01 (7)
16769
16770
16771 @item
16772 @emph{AI-0183 Aspect specifications (2010-08-16)}
16773 @cindex AI-0183 (Ada 2012 feature)
16774
16775 @noindent
16776   Aspect specifications have been fully implemented except for pre and post-
16777   conditions, and type invariants, which have their own separate AI's. All
16778   forms of declarations listed in the AI are supported. The following is a
16779   list of the aspects supported (with GNAT implementation aspects marked)
16780
16781 @multitable {@code{Preelaborable_Initialization}} {--GNAT}
16782 @item @code{Ada_2005} @tab                      -- GNAT
16783 @item @code{Ada_2012} @tab                      -- GNAT
16784 @item @code{Address} @tab
16785 @item @code{Alignment} @tab
16786 @item @code{Atomic} @tab
16787 @item @code{Atomic_Components} @tab
16788 @item @code{Bit_Order} @tab
16789 @item @code{Component_Size} @tab
16790 @item @code{Discard_Names} @tab
16791 @item @code{External_Tag} @tab
16792 @item @code{Favor_Top_Level} @tab               -- GNAT
16793 @item @code{Inline} @tab
16794 @item @code{Inline_Always} @tab                 -- GNAT
16795 @item @code{Invariant} @tab
16796 @item @code{Machine_Radix} @tab
16797 @item @code{No_Return} @tab
16798 @item @code{Object_Size} @tab                   -- GNAT
16799 @item @code{Pack} @tab
16800 @item @code{Persistent_BSS} @tab                -- GNAT
16801 @item @code{Post} @tab
16802 @item @code{Pre} @tab
16803 @item @code{Predicate} @tab
16804 @item @code{Preelaborable_Initialization} @tab
16805 @item @code{Pure_Function} @tab                 -- GNAT
16806 @item @code{Shared} @tab                        -- GNAT
16807 @item @code{Size} @tab
16808 @item @code{Storage_Pool} @tab
16809 @item @code{Storage_Size} @tab
16810 @item @code{Stream_Size} @tab
16811 @item @code{Suppress} @tab
16812 @item @code{Suppress_Debug_Info} @tab           -- GNAT
16813 @item @code{Test_Case} @tab                     -- GNAT
16814 @item @code{Unchecked_Union} @tab
16815 @item @code{Universal_Aliasing} @tab            -- GNAT
16816 @item @code{Unmodified} @tab                    -- GNAT
16817 @item @code{Unreferenced} @tab                  -- GNAT
16818 @item @code{Unreferenced_Objects} @tab          -- GNAT
16819 @item @code{Unsuppress} @tab
16820 @item @code{Value_Size} @tab                    -- GNAT
16821 @item @code{Volatile} @tab
16822 @item @code{Volatile_Components}
16823 @item @code{Warnings} @tab                      -- GNAT
16824 @end multitable
16825
16826 @noindent
16827   Note that for aspects with an expression, e.g. @code{Size}, the expression is
16828   treated like a default expression (visibility is analyzed at the point of
16829   occurrence of the aspect, but evaluation of the expression occurs at the
16830   freeze point of the entity involved.
16831
16832 @noindent
16833   RM References:  3.02.01 (3)   3.02.02 (2)   3.03.01 (2/2)   3.08 (6)
16834   3.09.03 (1.1/2)   6.01 (2/2)   6.07 (2/2)   9.05.02 (2/2)   7.01 (3)   7.03
16835   (2)   7.03 (3)   9.01 (2/2)   9.01 (3/2)   9.04 (2/2)   9.04 (3/2)
16836   9.05.02 (2/2)   11.01 (2)   12.01 (3)   12.03 (2/2)   12.04 (2/2)   12.05 (2)
16837   12.06 (2.1/2)   12.06 (2.2/2)   12.07 (2)   13.01 (0.1/2)   13.03 (5/1)
16838   13.03.01 (0)
16839
16840
16841 @item
16842 @emph{AI-0128 Inequality is a primitive operation (0000-00-00)}
16843 @cindex AI-0128 (Ada 2012 feature)
16844
16845 @noindent
16846   If an equality operator ("=") is declared for a type, then the implicitly
16847   declared inequality operator ("/=") is a primitive operation of the type.
16848   This is the only reasonable interpretation, and is the one always implemented
16849   by GNAT, but the RM was not entirely clear in making this point.
16850
16851 @noindent
16852   RM References:  3.02.03 (6)   6.06 (6)
16853
16854 @item
16855 @emph{AI-0003 Qualified expressions as names (2010-07-11)}
16856 @cindex AI-0003 (Ada 2012 feature)
16857
16858 @noindent
16859    In Ada 2012, a qualified expression is considered to be syntactically a name,
16860    meaning that constructs such as @code{A'(F(X)).B} are now legal. This is
16861    useful in disambiguating some cases of overloading.
16862
16863 @noindent
16864   RM References:  3.03 (11)   3.03 (21)   4.01 (2)   4.04 (7)   4.07 (3)
16865   5.04 (7)
16866
16867 @item
16868 @emph{AI-0120 Constant instance of protected object (0000-00-00)}
16869 @cindex AI-0120 (Ada 2012 feature)
16870
16871 @noindent
16872   This is an RM editorial change only. The section that lists objects that are
16873   constant failed to include the current instance of a protected object
16874   within a protected function. This has always been treated as a constant
16875   in GNAT.
16876
16877 @noindent
16878   RM References:  3.03 (21)
16879
16880 @item
16881 @emph{AI-0008 General access to constrained objects (0000-00-00)}
16882 @cindex AI-0008 (Ada 2012 feature)
16883
16884 @noindent
16885   The wording in the RM implied that if you have a general access to a
16886   constrained object, it could be used to modify the discriminants. This was
16887   obviously not intended. @code{Constraint_Error} should be raised, and GNAT
16888   has always done so in this situation.
16889
16890 @noindent
16891   RM References:  3.03 (23)   3.10.02 (26/2)   4.01 (9)   6.04.01 (17)   8.05.01 (5/2)
16892
16893
16894 @item
16895 @emph{AI-0093 Additional rules use immutably limited (0000-00-00)}
16896 @cindex AI-0093 (Ada 2012 feature)
16897
16898 @noindent
16899   This is an editorial change only, to make more widespread use of the Ada 2012
16900   ``immutably limited''.
16901
16902 @noindent
16903   RM References:  3.03 (23.4/3)
16904
16905
16906
16907 @item
16908 @emph{AI-0096 Deriving from formal private types (2010-07-20)}
16909 @cindex AI-0096 (Ada 2012 feature)
16910
16911 @noindent
16912   In general it is illegal for a type derived from a formal limited type to be
16913   nonlimited.  This AI makes an exception to this rule: derivation is legal
16914   if it appears in the private part of the generic, and the formal type is not
16915   tagged. If the type is tagged, the legality check must be applied to the
16916   private part of the package.
16917
16918 @noindent
16919   RM References:  3.04 (5.1/2)   6.02 (7)
16920
16921
16922 @item
16923 @emph{AI-0181 Soft hyphen is a non-graphic character (2010-07-23)}
16924 @cindex AI-0181 (Ada 2012 feature)
16925
16926 @noindent
16927   From Ada 2005 on, soft hyphen is considered a non-graphic character, which
16928   means that it has a special name (@code{SOFT_HYPHEN}) in conjunction with the
16929   @code{Image} and @code{Value} attributes for the character types. Strictly
16930   speaking this is an inconsistency with Ada 95, but in practice the use of
16931   these attributes is so obscure that it will not cause problems.
16932
16933 @noindent
16934   RM References:  3.05.02 (2/2)   A.01 (35/2)   A.03.03 (21)
16935
16936
16937 @item
16938 @emph{AI-0182 Additional forms for @code{Character'Value} (0000-00-00)}
16939 @cindex AI-0182 (Ada 2012 feature)
16940
16941 @noindent
16942   This AI allows @code{Character'Value} to accept the string @code{'?'} where
16943   @code{?} is any character including non-graphic control characters. GNAT has
16944   always accepted such strings. It also allows strings such as
16945   @code{HEX_00000041} to be accepted, but GNAT does not take advantage of this
16946   permission and raises @code{Constraint_Error}, as is certainly still
16947   permitted.
16948
16949 @noindent
16950   RM References:  3.05 (56/2)
16951
16952
16953 @item
16954 @emph{AI-0214 Defaulted discriminants for limited tagged (2010-10-01)}
16955 @cindex AI-0214 (Ada 2012 feature)
16956
16957 @noindent
16958   Ada 2012 relaxes the restriction that forbids discriminants of tagged types
16959   to have default expressions by allowing them when the type is limited. It
16960   is often useful to define a default value for a discriminant even though
16961   it can't be changed by assignment.
16962
16963 @noindent
16964   RM References:  3.07 (9.1/2)   3.07.02 (3)
16965
16966
16967 @item
16968 @emph{AI-0102 Some implicit conversions are illegal (0000-00-00)}
16969 @cindex AI-0102 (Ada 2012 feature)
16970
16971 @noindent
16972   It is illegal to assign an anonymous access constant to an anonymous access
16973   variable. The RM did not have a clear rule to prevent this, but GNAT has
16974   always generated an error for this usage.
16975
16976 @noindent
16977   RM References:  3.07 (16)   3.07.01 (9)   6.04.01 (6)   8.06 (27/2)
16978
16979
16980 @item
16981 @emph{AI-0158 Generalizing membership tests (2010-09-16)}
16982 @cindex AI-0158 (Ada 2012 feature)
16983
16984 @noindent
16985   This AI extends the syntax of membership tests to simplify complex conditions
16986   that can be expressed as membership in a subset of values of any type. It
16987   introduces syntax for a list of expressions that may be used in loop contexts
16988   as well.
16989
16990 @noindent
16991   RM References:  3.08.01 (5)   4.04 (3)   4.05.02 (3)   4.05.02 (5)   4.05.02 (27)
16992
16993
16994 @item
16995 @emph{AI-0173 Testing if tags represent abstract types (2010-07-03)}
16996 @cindex AI-0173 (Ada 2012 feature)
16997
16998 @noindent
16999   The function @code{Ada.Tags.Type_Is_Abstract} returns @code{True} if invoked
17000   with the tag of an abstract type, and @code{False} otherwise.
17001
17002 @noindent
17003   RM References:  3.09 (7.4/2)   3.09 (12.4/2)
17004
17005
17006
17007 @item
17008 @emph{AI-0076 function with controlling result (0000-00-00)}
17009 @cindex AI-0076 (Ada 2012 feature)
17010
17011 @noindent
17012   This is an editorial change only. The RM defines calls with controlling
17013   results, but uses the term ``function with controlling result'' without an
17014   explicit definition.
17015
17016 @noindent
17017   RM References:  3.09.02 (2/2)
17018
17019
17020 @item
17021 @emph{AI-0126 Dispatching with no declared operation (0000-00-00)}
17022 @cindex AI-0126 (Ada 2012 feature)
17023
17024 @noindent
17025   This AI clarifies dispatching rules, and simply confirms that dispatching
17026   executes the operation of the parent type when there is no explicitly or
17027   implicitly declared operation for the descendant type. This has always been
17028   the case in all versions of GNAT.
17029
17030 @noindent
17031   RM References:  3.09.02 (20/2)   3.09.02 (20.1/2)   3.09.02 (20.2/2)
17032
17033
17034 @item
17035 @emph{AI-0097 Treatment of abstract null extension (2010-07-19)}
17036 @cindex AI-0097 (Ada 2012 feature)
17037
17038 @noindent
17039   The RM as written implied that in some cases it was possible to create an
17040   object of an abstract type, by having an abstract extension inherit a non-
17041   abstract constructor from its parent type. This mistake has been corrected
17042   in GNAT and in the RM, and this construct is now illegal.
17043
17044 @noindent
17045   RM References:  3.09.03 (4/2)
17046
17047
17048 @item
17049 @emph{AI-0203 Extended return cannot be abstract (0000-00-00)}
17050 @cindex AI-0203 (Ada 2012 feature)
17051
17052 @noindent
17053   A return_subtype_indication cannot denote an abstract subtype. GNAT has never
17054   permitted such usage.
17055
17056 @noindent
17057   RM References:  3.09.03 (8/3)
17058
17059
17060 @item
17061 @emph{AI-0198 Inheriting abstract operators  (0000-00-00)}
17062 @cindex AI-0198 (Ada 2012 feature)
17063
17064 @noindent
17065   This AI resolves a conflict between two rules involving inherited abstract
17066   operations and predefined operators. If a derived numeric type inherits
17067   an abstract operator, it overrides the predefined one. This interpretation
17068   was always the one implemented in GNAT.
17069
17070 @noindent
17071   RM References:  3.09.03 (4/3)
17072
17073 @item
17074 @emph{AI-0073 Functions returning abstract types (2010-07-10)}
17075 @cindex AI-0073 (Ada 2012 feature)
17076
17077 @noindent
17078   This AI covers a number of issues regarding returning abstract types. In
17079   particular generic functions cannot have abstract result types or access
17080   result types designated an abstract type. There are some other cases which
17081   are detailed in the AI. Note that this binding interpretation has not been
17082   retrofitted to operate before Ada 2012 mode, since it caused a significant
17083   number of regressions.
17084
17085 @noindent
17086   RM References:  3.09.03 (8)   3.09.03 (10)   6.05 (8/2)
17087
17088
17089 @item
17090 @emph{AI-0070 Elaboration of interface types (0000-00-00)}
17091 @cindex AI-0070 (Ada 2012 feature)
17092
17093 @noindent
17094   This is an editorial change only, there are no testable consequences short of
17095   checking for the absence of generated code for an interface declaration.
17096
17097 @noindent
17098   RM References:  3.09.04 (18/2)
17099
17100
17101 @item
17102 @emph{AI-0208 Characteristics of incomplete views (0000-00-00)}
17103 @cindex AI-0208 (Ada 2012 feature)
17104
17105 @noindent
17106   The wording in the Ada 2005 RM concerning characteristics of incomplete views
17107   was incorrect and implied that some programs intended to be legal were now
17108   illegal. GNAT had never considered such programs illegal, so it has always
17109   implemented the intent of this AI.
17110
17111 @noindent
17112   RM References:  3.10.01 (2.4/2)   3.10.01 (2.6/2)
17113
17114
17115 @item
17116 @emph{AI-0162 Incomplete type completed by partial view (2010-09-15)}
17117 @cindex AI-0162 (Ada 2012 feature)
17118
17119 @noindent
17120   Incomplete types are made more useful by allowing them to be completed by
17121   private types and private extensions.
17122
17123 @noindent
17124   RM References:  3.10.01 (2.5/2)   3.10.01 (2.6/2)   3.10.01 (3)   3.10.01 (4/2)
17125
17126
17127
17128 @item
17129 @emph{AI-0098 Anonymous subprogram access restrictions (0000-00-00)}
17130 @cindex AI-0098 (Ada 2012 feature)
17131
17132 @noindent
17133   An unintentional omission in the RM implied some inconsistent restrictions on
17134   the use of anonymous access to subprogram values. These restrictions were not
17135   intentional, and have never been enforced by GNAT.
17136
17137 @noindent
17138   RM References:  3.10.01 (6)   3.10.01 (9.2/2)
17139
17140
17141 @item
17142 @emph{AI-0199 Aggregate with anonymous access components (2010-07-14)}
17143 @cindex AI-0199 (Ada 2012 feature)
17144
17145 @noindent
17146   A choice list in a record aggregate can include several components of
17147   (distinct) anonymous access types as long as they have matching designated
17148   subtypes.
17149
17150 @noindent
17151   RM References:  4.03.01 (16)
17152
17153
17154 @item
17155 @emph{AI-0220 Needed components for aggregates (0000-00-00)}
17156 @cindex AI-0220 (Ada 2012 feature)
17157
17158 @noindent
17159   This AI addresses a wording problem in the RM that appears to permit some
17160   complex cases of aggregates with non-static discriminants. GNAT has always
17161   implemented the intended semantics.
17162
17163 @noindent
17164   RM References:  4.03.01 (17)
17165
17166 @item
17167 @emph{AI-0147 Conditional expressions (2009-03-29)}
17168 @cindex AI-0147 (Ada 2012 feature)
17169
17170 @noindent
17171   Conditional expressions are permitted. The form of such an expression is:
17172
17173 @smallexample
17174     (@b{if} @i{expr} @b{then} @i{expr} @{@b{elsif} @i{expr} @b{then} @i{expr}@} [@b{else} @i{expr}])
17175 @end smallexample
17176
17177   The parentheses can be omitted in contexts where parentheses are present
17178   anyway, such as subprogram arguments and pragma arguments. If the @b{else}
17179   clause is omitted, @b{else True} is assumed;
17180   thus @code{(@b{if} A @b{then} B)} is a way to conveniently represent
17181   @emph{(A implies B)} in standard logic.
17182
17183 @noindent
17184   RM References:  4.03.03 (15)   4.04 (1)   4.04 (7)   4.05.07 (0)   4.07 (2)
17185   4.07 (3)   4.09 (12)   4.09 (33)   5.03 (3)   5.03 (4)   7.05 (2.1/2)
17186
17187
17188 @item
17189 @emph{AI-0037 Out-of-range box associations in aggregate (0000-00-00)}
17190 @cindex AI-0037 (Ada 2012 feature)
17191
17192 @noindent
17193   This AI confirms that an association of the form @code{Indx => <>} in an
17194   array aggregate must raise @code{Constraint_Error} if @code{Indx}
17195   is out of range. The RM specified a range check on other associations, but
17196   not when the value of the association was defaulted. GNAT has always inserted
17197   a constraint check on the index value.
17198
17199 @noindent
17200   RM References:  4.03.03 (29)
17201
17202
17203 @item
17204 @emph{AI-0123 Composability of equality (2010-04-13)}
17205 @cindex AI-0123 (Ada 2012 feature)
17206
17207 @noindent
17208   Equality of untagged record composes, so that the predefined equality for a
17209   composite type that includes a component of some untagged record type
17210   @code{R} uses the equality operation of @code{R} (which may be user-defined
17211   or predefined). This makes the behavior of untagged records identical to that
17212   of tagged types in this respect.
17213
17214   This change is an incompatibility with previous versions of Ada, but it
17215   corrects a non-uniformity that was often a source of confusion. Analysis of
17216   a large number of industrial programs indicates that in those rare cases
17217   where a composite type had an untagged record component with a user-defined
17218   equality, either there was no use of the composite equality, or else the code
17219   expected the same composability as for tagged types, and thus had a bug that
17220   would be fixed by this change.
17221
17222 @noindent
17223   RM References:  4.05.02 (9.7/2)   4.05.02 (14)   4.05.02 (15)   4.05.02 (24)
17224   8.05.04 (8)
17225
17226
17227 @item
17228 @emph{AI-0088 The value of exponentiation (0000-00-00)}
17229 @cindex AI-0088 (Ada 2012 feature)
17230
17231 @noindent
17232   This AI clarifies the equivalence rule given for the dynamic semantics of
17233   exponentiation: the value of the operation can be obtained by repeated
17234   multiplication, but the operation can be implemented otherwise (for example
17235   using the familiar divide-by-two-and-square algorithm, even if this is less
17236   accurate), and does not imply repeated reads of a volatile base.
17237
17238 @noindent
17239   RM References:  4.05.06 (11)
17240
17241 @item
17242 @emph{AI-0188 Case expressions (2010-01-09)}
17243 @cindex AI-0188 (Ada 2012 feature)
17244
17245 @noindent
17246   Case expressions are permitted. This allows use of constructs such as:
17247 @smallexample
17248   X := (@b{case} Y @b{is when} 1 => 2, @b{when} 2 => 3, @b{when others} => 31)
17249 @end smallexample
17250
17251 @noindent
17252   RM References:  4.05.07 (0)   4.05.08 (0)   4.09 (12)   4.09 (33)
17253
17254 @item
17255 @emph{AI-0104 Null exclusion and uninitialized allocator (2010-07-15)}
17256 @cindex AI-0104 (Ada 2012 feature)
17257
17258 @noindent
17259   The assignment @code{Ptr := @b{new not null} Some_Ptr;} will raise
17260   @code{Constraint_Error} because the default value of the allocated object is
17261   @b{null}. This useless construct is illegal in Ada 2012.
17262
17263 @noindent
17264   RM References:  4.08 (2)
17265
17266 @item
17267 @emph{AI-0157 Allocation/Deallocation from empty pool (2010-07-11)}
17268 @cindex AI-0157 (Ada 2012 feature)
17269
17270 @noindent
17271   Allocation and Deallocation from an empty storage pool (i.e. allocation or
17272   deallocation of a pointer for which a static storage size clause of zero
17273   has been given) is now illegal and is detected as such. GNAT
17274   previously gave a warning but not an error.
17275
17276 @noindent
17277   RM References:  4.08 (5.3/2)   13.11.02 (4)   13.11.02 (17)
17278
17279 @item
17280 @emph{AI-0179 Statement not required after label (2010-04-10)}
17281 @cindex AI-0179 (Ada 2012 feature)
17282
17283 @noindent
17284   It is not necessary to have a statement following a label, so a label
17285   can appear at the end of a statement sequence without the need for putting a
17286   null statement afterwards, but it is not allowable to have only labels and
17287   no real statements in a statement sequence.
17288
17289 @noindent
17290   RM References:  5.01 (2)
17291
17292
17293 @item
17294 @emph{AI-139-2 Syntactic sugar for iterators (2010-09-29)}
17295 @cindex AI-139-2 (Ada 2012 feature)
17296
17297 @noindent
17298   The new syntax for iterating over arrays and containers is now implemented.
17299   Iteration over containers is for now limited to read-only iterators. Only
17300   default iterators are supported, with the syntax:  @code{@b{for} Elem @b{of} C}.
17301
17302 @noindent
17303   RM References:  5.05
17304
17305 @item
17306 @emph{AI-0134 Profiles must match for full conformance (0000-00-00)}
17307 @cindex AI-0134 (Ada 2012 feature)
17308
17309 @noindent
17310   For full conformance, the profiles of anonymous-access-to-subprogram
17311   parameters must match. GNAT has always enforced this rule.
17312
17313 @noindent
17314   RM References:  6.03.01 (18)
17315
17316 @item
17317 @emph{AI-0207 Mode conformance and access constant (0000-00-00)}
17318 @cindex AI-0207 (Ada 2012 feature)
17319
17320 @noindent
17321   This AI confirms that access_to_constant indication must match for mode
17322   conformance. This was implemented in GNAT when the qualifier was originally
17323   introduced in Ada 2005.
17324
17325 @noindent
17326   RM References:  6.03.01 (16/2)
17327
17328
17329 @item
17330 @emph{AI-0046 Null exclusion match for full conformance (2010-07-17)}
17331 @cindex AI-0046 (Ada 2012 feature)
17332
17333 @noindent
17334   For full conformance, in the case of access parameters, the null exclusion
17335   must match (either both or neither must have @code{@b{not null}}).
17336
17337 @noindent
17338   RM References:  6.03.02 (18)
17339
17340
17341 @item
17342 @emph{AI-0118 The association of parameter associations (0000-00-00)}
17343 @cindex AI-0118 (Ada 2012 feature)
17344
17345 @noindent
17346   This AI clarifies the rules for named associations in subprogram calls and
17347   generic instantiations. The rules have been in place since Ada 83.
17348
17349 @noindent
17350   RM References:  6.04.01 (2)   12.03 (9)
17351
17352
17353 @item
17354 @emph{AI-0196 Null exclusion tests for out parameters (0000-00-00)}
17355 @cindex AI-0196 (Ada 2012 feature)
17356
17357 @noindent
17358   Null exclusion checks are not made for @code{@b{out}} parameters when
17359   evaluating the actual parameters. GNAT has never generated these checks.
17360
17361 @noindent
17362   RM References:  6.04.01 (13)
17363
17364 @item
17365 @emph{AI-0015 Constant return objects (0000-00-00)}
17366 @cindex AI-0015 (Ada 2012 feature)
17367
17368 @noindent
17369   The return object declared in an @i{extended_return_statement} may be
17370   declared constant. This was always intended, and GNAT has always allowed it.
17371
17372 @noindent
17373   RM References:  6.05 (2.1/2)   3.03 (10/2)   3.03 (21)   6.05 (5/2)
17374   6.05 (5.7/2)
17375
17376
17377 @item
17378 @emph{AI-0032 Extended return for class-wide functions (0000-00-00)}
17379 @cindex AI-0032 (Ada 2012 feature)
17380
17381 @noindent
17382   If a function returns a class-wide type, the object of an extended return
17383   statement can be declared with a specific type that is covered by the class-
17384   wide type. This has been implemented in GNAT since the introduction of
17385   extended returns. Note AI-0103 complements this AI by imposing matching
17386   rules for constrained return types.
17387
17388 @noindent
17389   RM References:  6.05 (5.2/2)   6.05 (5.3/2)   6.05 (5.6/2)   6.05 (5.8/2)
17390   6.05 (8/2)
17391
17392 @item
17393 @emph{AI-0103 Static matching for extended return (2010-07-23)}
17394 @cindex AI-0103 (Ada 2012 feature)
17395
17396 @noindent
17397   If the return subtype of a function is an elementary type or a constrained
17398   type, the subtype indication in an extended return statement must match
17399   statically this return subtype.
17400
17401 @noindent
17402   RM References:  6.05 (5.2/2)
17403
17404
17405 @item
17406 @emph{AI-0058 Abnormal completion of an extended return (0000-00-00)}
17407 @cindex AI-0058 (Ada 2012 feature)
17408
17409 @noindent
17410   The RM had some incorrect wording implying wrong treatment of abnormal
17411   completion in an extended return. GNAT has always implemented the intended
17412   correct semantics as described by this AI.
17413
17414 @noindent
17415   RM References:  6.05 (22/2)
17416
17417
17418 @item
17419 @emph{AI-0050 Raising Constraint_Error early for function call (0000-00-00)}
17420 @cindex AI-0050 (Ada 2012 feature)
17421
17422 @noindent
17423   The implementation permissions for raising @code{Constraint_Error} early on a function call when it was clear an exception would be raised were over-permissive and allowed mishandling of discriminants in some cases. GNAT did
17424   not take advantage of these incorrect permissions in any case.
17425
17426 @noindent
17427   RM References:  6.05 (24/2)
17428
17429
17430 @item
17431 @emph{AI-0125 Nonoverridable operations of an ancestor (2010-09-28)}
17432 @cindex AI-0125 (Ada 2012 feature)
17433
17434 @noindent
17435   In Ada 2012, the declaration of a primitive operation of a type extension
17436   or private extension can also override an inherited primitive that is not
17437   visible at the point of this declaration.
17438
17439 @noindent
17440   RM References:  7.03.01 (6)   8.03 (23)   8.03.01 (5/2)   8.03.01 (6/2)
17441
17442 @item
17443 @emph{AI-0062 Null exclusions and deferred constants (0000-00-00)}
17444 @cindex AI-0062 (Ada 2012 feature)
17445
17446 @noindent
17447   A full constant may have a null exclusion even if its associated deferred
17448   constant does not. GNAT has always allowed this.
17449
17450 @noindent
17451   RM References:  7.04 (6/2)   7.04 (7.1/2)
17452
17453
17454 @item
17455 @emph{AI-0178 Incomplete views are limited (0000-00-00)}
17456 @cindex AI-0178 (Ada 2012 feature)
17457
17458 @noindent
17459   This AI clarifies the role of incomplete views and plugs an omission in the
17460   RM. GNAT always correctly restricted the use of incomplete views and types.
17461
17462 @noindent
17463   RM References:  7.05 (3/2)   7.05 (6/2)
17464
17465 @item
17466 @emph{AI-0087 Actual for formal nonlimited derived type (2010-07-15)}
17467 @cindex AI-0087 (Ada 2012 feature)
17468
17469 @noindent
17470   The actual for a formal nonlimited derived type cannot be limited. In
17471   particular, a formal derived type that extends a limited interface but which
17472   is not explicitly limited cannot be instantiated with a limited type.
17473
17474 @noindent
17475   RM References:  7.05 (5/2)   12.05.01 (5.1/2)
17476
17477 @item
17478 @emph{AI-0099 Tag determines whether finalization needed (0000-00-00)}
17479 @cindex AI-0099 (Ada 2012 feature)
17480
17481 @noindent
17482   This AI clarifies that ``needs finalization'' is part of dynamic semantics,
17483   and therefore depends on the run-time characteristics of an object (i.e. its
17484   tag) and not on its nominal type. As the AI indicates: ``we do not expect
17485   this to affect any implementation''.
17486
17487 @noindent
17488   RM References:  7.06.01 (6)   7.06.01 (7)   7.06.01 (8)   7.06.01 (9/2)
17489
17490
17491
17492 @item
17493 @emph{AI-0064 Redundant finalization rule (0000-00-00)}
17494 @cindex AI-0064 (Ada 2012 feature)
17495
17496 @noindent
17497   This is an editorial change only. The intended behavior is already checked
17498   by an existing ACATS test, which GNAT has always executed correctly.
17499
17500 @noindent
17501   RM References:  7.06.01 (17.1/1)
17502
17503 @item
17504 @emph{AI-0026 Missing rules for Unchecked_Union (2010-07-07)}
17505 @cindex AI-0026 (Ada 2012 feature)
17506
17507 @noindent
17508   Record representation clauses concerning Unchecked_Union types cannot mention
17509   the discriminant of the type. The type of a component declared in the variant
17510   part of an Unchecked_Union cannot be controlled, have controlled components,
17511   nor have protected or task parts. If an Unchecked_Union type is declared
17512   within the body of a generic unit or its descendants, then the type of a
17513   component declared in the variant part cannot be a formal private type or a
17514   formal private extension declared within the same generic unit.
17515
17516 @noindent
17517   RM References:  7.06 (9.4/2)   B.03.03 (9/2)   B.03.03 (10/2)
17518
17519
17520 @item
17521 @emph{AI-0205 Extended return declares visible name (0000-00-00)}
17522 @cindex AI-0205 (Ada 2012 feature)
17523
17524 @noindent
17525   This AI corrects a simple omission in the RM. Return objects have always
17526   been visible within an extended return statement.
17527
17528 @noindent
17529   RM References:  8.03 (17)
17530
17531
17532 @item
17533 @emph{AI-0042 Overriding versus implemented-by (0000-00-00)}
17534 @cindex AI-0042 (Ada 2012 feature)
17535
17536 @noindent
17537   This AI fixes a wording gap in the RM. An operation of a synchronized
17538   interface can be implemented by a protected or task entry, but the abstract
17539   operation is not being overridden in the usual sense, and it must be stated
17540   separately that this implementation is legal. This has always been the case
17541   in GNAT.
17542
17543 @noindent
17544   RM References:  9.01 (9.2/2)   9.04 (11.1/2)
17545
17546 @item
17547 @emph{AI-0030 Requeue on synchronized interfaces (2010-07-19)}
17548 @cindex AI-0030 (Ada 2012 feature)
17549
17550 @noindent
17551   Requeue is permitted to a protected, synchronized or task interface primitive
17552   providing it is known that the overriding operation is an entry. Otherwise
17553   the requeue statement has the same effect as a procedure call. Use of pragma
17554   @code{Implemented} provides a way to impose a static requirement on the
17555   overriding operation by adhering to one of the implementation kinds: entry,
17556   protected procedure or any of the above.
17557
17558 @noindent
17559   RM References:  9.05 (9)   9.05.04 (2)   9.05.04 (3)   9.05.04 (5)
17560   9.05.04 (6)   9.05.04 (7)   9.05.04 (12)
17561
17562
17563 @item
17564 @emph{AI-0201 Independence of atomic object components (2010-07-22)}
17565 @cindex AI-0201 (Ada 2012 feature)
17566
17567 @noindent
17568   If an Atomic object has a pragma @code{Pack} or a @code{Component_Size}
17569   attribute, then individual components may not be addressable by independent
17570   tasks. However, if the representation clause has no effect (is confirming),
17571   then independence is not compromised. Furthermore, in GNAT, specification of
17572   other appropriately addressable component sizes (e.g. 16 for 8-bit
17573   characters) also preserves independence. GNAT now gives very clear warnings
17574   both for the declaration of such a type, and for any assignment to its components.
17575
17576 @noindent
17577   RM References:  9.10 (1/3)   C.06 (22/2)   C.06 (23/2)
17578
17579 @item
17580 @emph{AI-0009 Pragma Independent[_Components] (2010-07-23)}
17581 @cindex AI-0009 (Ada 2012 feature)
17582
17583 @noindent
17584   This AI introduces the new pragmas @code{Independent} and
17585   @code{Independent_Components},
17586   which control guaranteeing independence of access to objects and components.
17587   The AI also requires independence not unaffected by confirming rep clauses.
17588
17589 @noindent
17590   RM References:  9.10 (1)   13.01 (15/1)   13.02 (9)   13.03 (13)   C.06 (2)
17591   C.06 (4)   C.06 (6)   C.06 (9)   C.06 (13)   C.06 (14)
17592
17593
17594 @item
17595 @emph{AI-0072 Task signalling using 'Terminated (0000-00-00)}
17596 @cindex AI-0072 (Ada 2012 feature)
17597
17598 @noindent
17599   This AI clarifies that task signalling for reading @code{'Terminated} only
17600   occurs if the result is True. GNAT semantics has always been consistent with
17601   this notion of task signalling.
17602
17603 @noindent
17604   RM References:  9.10 (6.1/1)
17605
17606 @item
17607 @emph{AI-0108 Limited incomplete view and discriminants (0000-00-00)}
17608 @cindex AI-0108 (Ada 2012 feature)
17609
17610 @noindent
17611   This AI confirms that an incomplete type from a limited view does not have
17612   discriminants. This has always been the case in GNAT.
17613
17614 @noindent
17615   RM References:  10.01.01 (12.3/2)
17616
17617 @item
17618 @emph{AI-0129 Limited views and incomplete types (0000-00-00)}
17619 @cindex AI-0129 (Ada 2012 feature)
17620
17621 @noindent
17622   This AI clarifies the description of limited views: a limited view of a
17623   package includes only one view of a type that has an incomplete declaration
17624   and a full declaration (there is no possible ambiguity in a client package).
17625   This AI also fixes an omission: a nested package in the private part has no
17626   limited view. GNAT always implemented this correctly.
17627
17628 @noindent
17629   RM References:  10.01.01 (12.2/2)   10.01.01 (12.3/2)
17630
17631
17632
17633 @item
17634 @emph{AI-0077 Limited withs and scope of declarations (0000-00-00)}
17635 @cindex AI-0077 (Ada 2012 feature)
17636
17637 @noindent
17638   This AI clarifies that a declaration does not include a context clause,
17639   and confirms that it is illegal to have a context in which both a limited
17640   and a nonlimited view of a package are accessible. Such double visibility
17641   was always rejected by GNAT.
17642
17643 @noindent
17644   RM References:  10.01.02 (12/2)   10.01.02 (21/2)   10.01.02 (22/2)
17645
17646 @item
17647 @emph{AI-0122 Private with and children of generics (0000-00-00)}
17648 @cindex AI-0122 (Ada 2012 feature)
17649
17650 @noindent
17651   This AI clarifies the visibility of private children of generic units within
17652   instantiations of a parent. GNAT has always handled this correctly.
17653
17654 @noindent
17655   RM References:  10.01.02 (12/2)
17656
17657
17658
17659 @item
17660 @emph{AI-0040 Limited with clauses on descendant (0000-00-00)}
17661 @cindex AI-0040 (Ada 2012 feature)
17662
17663 @noindent
17664   This AI confirms that a limited with clause in a child unit cannot name
17665   an ancestor of the unit. This has always been checked in GNAT.
17666
17667 @noindent
17668   RM References:  10.01.02 (20/2)
17669
17670 @item
17671 @emph{AI-0132 Placement of library unit pragmas (0000-00-00)}
17672 @cindex AI-0132 (Ada 2012 feature)
17673
17674 @noindent
17675   This AI fills a gap in the description of library unit pragmas. The pragma
17676   clearly must apply to a library unit, even if it does not carry the name
17677   of the enclosing unit. GNAT has always enforced the required check.
17678
17679 @noindent
17680   RM References:  10.01.05 (7)
17681
17682
17683 @item
17684 @emph{AI-0034 Categorization of limited views (0000-00-00)}
17685 @cindex AI-0034 (Ada 2012 feature)
17686
17687 @noindent
17688   The RM makes certain limited with clauses illegal because of categorization
17689   considerations, when the corresponding normal with would be legal. This is
17690   not intended, and GNAT has always implemented the recommended behavior.
17691
17692 @noindent
17693   RM References:  10.02.01 (11/1)   10.02.01 (17/2)
17694
17695
17696 @item
17697 @emph{AI-0035 Inconsistencies with Pure units (0000-00-00)}
17698 @cindex AI-0035 (Ada 2012 feature)
17699
17700 @noindent
17701   This AI remedies some inconsistencies in the legality rules for Pure units.
17702   Derived access types are legal in a pure unit (on the assumption that the
17703   rule for a zero storage pool size has been enforced on the ancestor type).
17704   The rules are enforced in generic instances and in subunits. GNAT has always
17705   implemented the recommended behavior.
17706
17707 @noindent
17708   RM References:  10.02.01 (15.1/2)   10.02.01 (15.4/2)   10.02.01 (15.5/2)   10.02.01 (17/2)
17709
17710
17711 @item
17712 @emph{AI-0219 Pure permissions and limited parameters (2010-05-25)}
17713 @cindex AI-0219 (Ada 2012 feature)
17714
17715 @noindent
17716   This AI refines the rules for the cases with limited parameters which do not
17717   allow the implementations to omit ``redundant''. GNAT now properly conforms
17718   to the requirements of this binding interpretation.
17719
17720 @noindent
17721   RM References:  10.02.01 (18/2)
17722
17723 @item
17724 @emph{AI-0043 Rules about raising exceptions (0000-00-00)}
17725 @cindex AI-0043 (Ada 2012 feature)
17726
17727 @noindent
17728   This AI covers various omissions in the RM regarding the raising of
17729   exceptions. GNAT has always implemented the intended semantics.
17730
17731 @noindent
17732   RM References:  11.04.01 (10.1/2)   11 (2)
17733
17734
17735 @item
17736 @emph{AI-0200 Mismatches in formal package declarations (0000-00-00)}
17737 @cindex AI-0200 (Ada 2012 feature)
17738
17739 @noindent
17740   This AI plugs a gap in the RM which appeared to allow some obviously intended
17741   illegal instantiations. GNAT has never allowed these instantiations.
17742
17743 @noindent
17744   RM References:  12.07 (16)
17745
17746
17747 @item
17748 @emph{AI-0112 Detection of duplicate pragmas (2010-07-24)}
17749 @cindex AI-0112 (Ada 2012 feature)
17750
17751 @noindent
17752   This AI concerns giving names to various representation aspects, but the
17753   practical effect is simply to make the use of duplicate
17754   @code{Atomic}[@code{_Components}],
17755   @code{Volatile}[@code{_Components}] and
17756   @code{Independent}[@code{_Components}] pragmas illegal, and GNAT
17757   now performs this required check.
17758
17759 @noindent
17760   RM References:  13.01 (8)
17761
17762 @item
17763 @emph{AI-0106 No representation pragmas on generic formals (0000-00-00)}
17764 @cindex AI-0106 (Ada 2012 feature)
17765
17766 @noindent
17767   The RM appeared to allow representation pragmas on generic formal parameters,
17768   but this was not intended, and GNAT has never permitted this usage.
17769
17770 @noindent
17771   RM References:  13.01 (9.1/1)
17772
17773
17774 @item
17775 @emph{AI-0012 Pack/Component_Size for aliased/atomic (2010-07-15)}
17776 @cindex AI-0012 (Ada 2012 feature)
17777
17778 @noindent
17779   It is now illegal to give an inappropriate component size or a pragma
17780   @code{Pack} that attempts to change the component size in the case of atomic
17781   or aliased components. Previously GNAT ignored such an attempt with a
17782   warning.
17783
17784 @noindent
17785   RM References:  13.02 (6.1/2)   13.02 (7)   C.06 (10)   C.06 (11)   C.06 (21)
17786
17787
17788 @item
17789 @emph{AI-0039 Stream attributes cannot be dynamic (0000-00-00)}
17790 @cindex AI-0039 (Ada 2012 feature)
17791
17792 @noindent
17793   The RM permitted the use of dynamic expressions (such as @code{ptr.@b{all})}
17794   for stream attributes, but these were never useful and are now illegal. GNAT
17795   has always regarded such expressions as illegal.
17796
17797 @noindent
17798   RM References:  13.03 (4)   13.03 (6)   13.13.02 (38/2)
17799
17800
17801 @item
17802 @emph{AI-0095 Address of intrinsic subprograms (0000-00-00)}
17803 @cindex AI-0095 (Ada 2012 feature)
17804
17805 @noindent
17806   The prefix of @code{'Address} cannot statically denote a subprogram with
17807   convention @code{Intrinsic}. The use of the @code{Address} attribute raises
17808   @code{Program_Error} if the prefix denotes a subprogram with convention
17809   @code{Intrinsic}.
17810
17811 @noindent
17812   RM References:  13.03 (11/1)
17813
17814
17815 @item
17816 @emph{AI-0116 Alignment of class-wide objects (0000-00-00)}
17817 @cindex AI-0116 (Ada 2012 feature)
17818
17819 @noindent
17820   This AI requires that the alignment of a class-wide object be no greater
17821   than the alignment of any type in the class. GNAT has always followed this
17822   recommendation.
17823
17824 @noindent
17825   RM References:  13.03 (29)   13.11 (16)
17826
17827
17828 @item
17829 @emph{AI-0146 Type invariants (2009-09-21)}
17830 @cindex AI-0146 (Ada 2012 feature)
17831
17832 @noindent
17833   Type invariants may be specified for private types using the aspect notation.
17834   Aspect @code{Invariant} may be specified for any private type,
17835   @code{Invariant'Class} can
17836   only be specified for tagged types, and is inherited by any descendent of the
17837   tagged types. The invariant is a boolean expression that is tested for being
17838   true in the following situations: conversions to the private type, object
17839   declarations for the private type that are default initialized, and
17840   [@b{in}] @b{out}
17841   parameters and returned result on return from any primitive operation for
17842   the type that is visible to a client.
17843
17844 @noindent
17845   RM References:  13.03.03 (00)
17846
17847 @item
17848 @emph{AI-0078 Relax Unchecked_Conversion alignment rules (0000-00-00)}
17849 @cindex AI-0078 (Ada 2012 feature)
17850
17851 @noindent
17852   In Ada 2012, compilers are required to support unchecked conversion where the
17853   target alignment is a multiple of the source alignment. GNAT always supported
17854   this case (and indeed all cases of differing alignments, doing copies where
17855   required if the alignment was reduced).
17856
17857 @noindent
17858   RM References:  13.09 (7)
17859
17860
17861 @item
17862 @emph{AI-0195 Invalid value handling is implementation defined (2010-07-03)}
17863 @cindex AI-0195 (Ada 2012 feature)
17864
17865 @noindent
17866   The handling of invalid values is now designated to be implementation
17867   defined. This is a documentation change only, requiring Annex M in the GNAT
17868   Reference Manual to document this handling.
17869   In GNAT, checks for invalid values are made
17870   only when necessary to avoid erroneous behavior. Operations like assignments
17871   which cannot cause erroneous behavior ignore the possibility of invalid
17872   values and do not do a check. The date given above applies only to the
17873   documentation change, this behavior has always been implemented by GNAT.
17874
17875 @noindent
17876   RM References:  13.09.01 (10)
17877
17878 @item
17879 @emph{AI-0193 Alignment of allocators (2010-09-16)}
17880 @cindex AI-0193 (Ada 2012 feature)
17881
17882 @noindent
17883   This AI introduces a new attribute @code{Max_Alignment_For_Allocation},
17884   analogous to @code{Max_Size_In_Storage_Elements}, but for alignment instead
17885   of size.
17886
17887 @noindent
17888   RM References:  13.11 (16)   13.11 (21)   13.11.01 (0)   13.11.01 (1)
17889   13.11.01 (2)   13.11.01 (3)
17890
17891
17892 @item
17893 @emph{AI-0177 Parameterized expressions (2010-07-10)}
17894 @cindex AI-0177 (Ada 2012 feature)
17895
17896 @noindent
17897   The new Ada 2012 notion of parameterized expressions is implemented. The form
17898   is:
17899 @smallexample
17900   @i{function specification} @b{is} (@i{expression})
17901 @end smallexample
17902
17903 @noindent
17904   This is exactly equivalent to the
17905   corresponding function body that returns the expression, but it can appear
17906   in a package spec. Note that the expression must be parenthesized.
17907
17908 @noindent
17909   RM References:  13.11.01 (3/2)
17910
17911 @item
17912 @emph{AI-0033 Attach/Interrupt_Handler in generic (2010-07-24)}
17913 @cindex AI-0033 (Ada 2012 feature)
17914
17915 @noindent
17916   Neither of these two pragmas may appear within a generic template, because
17917   the generic might be instantiated at other than the library level.
17918
17919 @noindent
17920   RM References:  13.11.02 (16)   C.03.01 (7/2)   C.03.01 (8/2)
17921
17922
17923 @item
17924 @emph{AI-0161 Restriction No_Default_Stream_Attributes (2010-09-11)}
17925 @cindex AI-0161 (Ada 2012 feature)
17926
17927 @noindent
17928   A new restriction @code{No_Default_Stream_Attributes} prevents the use of any
17929   of the default stream attributes for elementary types. If this restriction is
17930   in force, then it is necessary to provide explicit subprograms for any
17931   stream attributes used.
17932
17933 @noindent
17934   RM References:  13.12.01 (4/2)   13.13.02 (40/2)   13.13.02 (52/2)
17935
17936 @item
17937 @emph{AI-0194 Value of Stream_Size attribute (0000-00-00)}
17938 @cindex AI-0194 (Ada 2012 feature)
17939
17940 @noindent
17941   The @code{Stream_Size} attribute returns the default number of bits in the
17942   stream representation of the given type.
17943   This value is not affected by the presence
17944   of stream subprogram attributes for the type. GNAT has always implemented
17945   this interpretation.
17946
17947 @noindent
17948   RM References:  13.13.02 (1.2/2)
17949
17950 @item
17951 @emph{AI-0109 Redundant check in S'Class'Input (0000-00-00)}
17952 @cindex AI-0109 (Ada 2012 feature)
17953
17954 @noindent
17955   This AI is an editorial change only. It removes the need for a tag check
17956   that can never fail.
17957
17958 @noindent
17959   RM References:  13.13.02 (34/2)
17960
17961 @item
17962 @emph{AI-0007 Stream read and private scalar types (0000-00-00)}
17963 @cindex AI-0007 (Ada 2012 feature)
17964
17965 @noindent
17966   The RM as written appeared to limit the possibilities of declaring read
17967   attribute procedures for private scalar types. This limitation was not
17968   intended, and has never been enforced by GNAT.
17969
17970 @noindent
17971   RM References:  13.13.02 (50/2)   13.13.02 (51/2)
17972
17973
17974 @item
17975 @emph{AI-0065 Remote access types and external streaming (0000-00-00)}
17976 @cindex AI-0065 (Ada 2012 feature)
17977
17978 @noindent
17979   This AI clarifies the fact that all remote access types support external
17980   streaming. This fixes an obvious oversight in the definition of the
17981   language, and GNAT always implemented the intended correct rules.
17982
17983 @noindent
17984   RM References:  13.13.02 (52/2)
17985
17986 @item
17987 @emph{AI-0019 Freezing of primitives for tagged types (0000-00-00)}
17988 @cindex AI-0019 (Ada 2012 feature)
17989
17990 @noindent
17991   The RM suggests that primitive subprograms of a specific tagged type are
17992   frozen when the tagged type is frozen. This would be an incompatible change
17993   and is not intended. GNAT has never attempted this kind of freezing and its
17994   behavior is consistent with the recommendation of this AI.
17995
17996 @noindent
17997   RM References:  13.14 (2)   13.14 (3/1)   13.14 (8.1/1)   13.14 (10)   13.14 (14)   13.14 (15.1/2)
17998
17999 @item
18000 @emph{AI-0017 Freezing and incomplete types (0000-00-00)}
18001 @cindex AI-0017 (Ada 2012 feature)
18002
18003 @noindent
18004   So-called ``Taft-amendment types'' (i.e., types that are completed in package
18005   bodies) are not frozen by the occurrence of bodies in the
18006   enclosing declarative part. GNAT always implemented this properly.
18007
18008 @noindent
18009   RM References:  13.14 (3/1)
18010
18011
18012 @item
18013 @emph{AI-0060 Extended definition of remote access types (0000-00-00)}
18014 @cindex AI-0060 (Ada 2012 feature)
18015
18016 @noindent
18017   This AI extends the definition of remote access types to include access
18018   to limited, synchronized, protected or task class-wide interface types.
18019   GNAT already implemented this extension.
18020
18021 @noindent
18022   RM References:  A (4)   E.02.02 (9/1)   E.02.02 (9.2/1)   E.02.02 (14/2)   E.02.02 (18)
18023
18024 @item
18025 @emph{AI-0114 Classification of letters (0000-00-00)}
18026 @cindex AI-0114 (Ada 2012 feature)
18027
18028 @noindent
18029   The code points 170 (@code{FEMININE ORDINAL INDICATOR}),
18030   181 (@code{MICRO SIGN}), and
18031   186 (@code{MASCULINE ORDINAL INDICATOR}) are technically considered
18032   lower case letters by Unicode.
18033   However, they are not allowed in identifiers, and they
18034   return @code{False} to @code{Ada.Characters.Handling.Is_Letter/Is_Lower}.
18035   This behavior is consistent with that defined in Ada 95.
18036
18037 @noindent
18038   RM References:  A.03.02 (59)   A.04.06 (7)
18039
18040
18041 @item
18042 @emph{AI-0185 Ada.Wide_[Wide_]Characters.Handling (2010-07-06)}
18043 @cindex AI-0185 (Ada 2012 feature)
18044
18045 @noindent
18046   Two new packages @code{Ada.Wide_[Wide_]Characters.Handling} provide
18047   classification functions for @code{Wide_Character} and
18048   @code{Wide_Wide_Character}, as well as providing
18049   case folding routines for @code{Wide_[Wide_]Character} and
18050   @code{Wide_[Wide_]String}.
18051
18052 @noindent
18053   RM References:  A.03.05 (0)   A.03.06 (0)
18054
18055
18056 @item
18057 @emph{AI-0031 Add From parameter to Find_Token (2010-07-25)}
18058 @cindex AI-0031 (Ada 2012 feature)
18059
18060 @noindent
18061   A new version of @code{Find_Token} is added to all relevant string packages,
18062   with an extra parameter @code{From}. Instead of starting at the first
18063   character of the string, the search for a matching Token starts at the
18064   character indexed by the value of @code{From}.
18065   These procedures are available in all versions of Ada
18066   but if used in versions earlier than Ada 2012 they will generate a warning
18067   that an Ada 2012 subprogram is being used.
18068
18069 @noindent
18070   RM References:  A.04.03 (16)   A.04.03 (67)   A.04.03 (68/1)   A.04.04 (51)
18071   A.04.05 (46)
18072
18073
18074 @item
18075 @emph{AI-0056 Index on null string returns zero (0000-00-00)}
18076 @cindex AI-0056 (Ada 2012 feature)
18077
18078 @noindent
18079   The wording in the Ada 2005 RM implied an incompatible handling of the
18080   @code{Index} functions, resulting in raising an exception instead of
18081   returning zero in some situations.
18082   This was not intended and has been corrected.
18083   GNAT always returned zero, and is thus consistent with this AI.
18084
18085 @noindent
18086   RM References:  A.04.03 (56.2/2)   A.04.03 (58.5/2)
18087
18088
18089 @item
18090 @emph{AI-0137 String encoding package (2010-03-25)}
18091 @cindex AI-0137 (Ada 2012 feature)
18092
18093 @noindent
18094   The packages @code{Ada.Strings.UTF_Encoding}, together with its child
18095   packages, @code{Conversions}, @code{Strings}, @code{Wide_Strings},
18096   and @code{Wide_Wide_Strings} have been
18097   implemented. These packages (whose documentation can be found in the spec
18098   files @file{a-stuten.ads}, @file{a-suenco.ads}, @file{a-suenst.ads},
18099   @file{a-suewst.ads}, @file{a-suezst.ads}) allow encoding and decoding of
18100   @code{String}, @code{Wide_String}, and @code{Wide_Wide_String}
18101   values using UTF coding schemes (including UTF-8, UTF-16LE, UTF-16BE, and
18102   UTF-16), as well as conversions between the different UTF encodings. With
18103   the exception of @code{Wide_Wide_Strings}, these packages are available in
18104   Ada 95 and Ada 2005 mode as well as Ada 2012 mode.
18105   The @code{Wide_Wide_Strings package}
18106   is available in Ada 2005 mode as well as Ada 2012 mode (but not in Ada 95
18107   mode since it uses @code{Wide_Wide_Character}).
18108
18109 @noindent
18110   RM References:  A.04.11
18111
18112 @item
18113 @emph{AI-0038 Minor errors in Text_IO (0000-00-00)}
18114 @cindex AI-0038 (Ada 2012 feature)
18115
18116 @noindent
18117   These are minor errors in the description on three points. The intent on
18118   all these points has always been clear, and GNAT has always implemented the
18119   correct intended semantics.
18120
18121 @noindent
18122   RM References:  A.10.05 (37)   A.10.07 (8/1)   A.10.07 (10)   A.10.07 (12)   A.10.08 (10)   A.10.08 (24)
18123
18124 @item
18125 @emph{AI-0044 Restrictions on container instantiations (0000-00-00)}
18126 @cindex AI-0044 (Ada 2012 feature)
18127
18128 @noindent
18129   This AI places restrictions on allowed instantiations of generic containers.
18130   These restrictions are not checked by the compiler, so there is nothing to
18131   change in the implementation. This affects only the RM documentation.
18132
18133 @noindent
18134   RM References:  A.18 (4/2)   A.18.02 (231/2)   A.18.03 (145/2)   A.18.06 (56/2)   A.18.08 (66/2)   A.18.09 (79/2)   A.18.26 (5/2)   A.18.26 (9/2)
18135
18136 @item
18137 @emph{AI-0127 Adding Locale Capabilities (2010-09-29)}
18138 @cindex AI-0127 (Ada 2012 feature)
18139
18140 @noindent
18141   This package provides an interface for identifying the current locale.
18142
18143 @noindent
18144   RM References:  A.19    A.19.01    A.19.02    A.19.03    A.19.05    A.19.06
18145   A.19.07    A.19.08    A.19.09    A.19.10    A.19.11    A.19.12    A.19.13
18146
18147
18148
18149 @item
18150 @emph{AI-0002 Export C with unconstrained arrays (0000-00-00)}
18151 @cindex AI-0002 (Ada 2012 feature)
18152
18153 @noindent
18154   The compiler is not required to support exporting an Ada subprogram with
18155   convention C if there are parameters or a return type of an unconstrained
18156   array type (such as @code{String}). GNAT allows such declarations but
18157   generates warnings. It is possible, but complicated, to write the
18158   corresponding C code and certainly such code would be specific to GNAT and
18159   non-portable.
18160
18161 @noindent
18162   RM References:  B.01 (17)   B.03 (62)   B.03 (71.1/2)
18163
18164
18165 @item
18166 @emph{AI-0216 No_Task_Hierarchy forbids local tasks (0000-00-00)}
18167 @cindex AI05-0216 (Ada 2012 feature)
18168
18169 @noindent
18170   It is clearly the intention that @code{No_Task_Hierarchy} is intended to
18171   forbid tasks declared locally within subprograms, or functions returning task
18172   objects, and that is the implementation that GNAT has always provided.
18173   However the language in the RM was not sufficiently clear on this point.
18174   Thus this is a documentation change in the RM only.
18175
18176 @noindent
18177   RM References:  D.07 (3/3)
18178
18179 @item
18180 @emph{AI-0211 No_Relative_Delays forbids Set_Handler use (2010-07-09)}
18181 @cindex AI-0211 (Ada 2012 feature)
18182
18183 @noindent
18184   The restriction @code{No_Relative_Delays} forbids any calls to the subprogram
18185   @code{Ada.Real_Time.Timing_Events.Set_Handler}.
18186
18187 @noindent
18188   RM References:  D.07 (5)   D.07 (10/2)   D.07 (10.4/2)   D.07 (10.7/2)
18189
18190 @item
18191 @emph{AI-0190 pragma Default_Storage_Pool (2010-09-15)}
18192 @cindex AI-0190 (Ada 2012 feature)
18193
18194 @noindent
18195   This AI introduces a new pragma @code{Default_Storage_Pool}, which can be
18196   used to control storage pools globally.
18197   In particular, you can force every access
18198   type that is used for allocation (@b{new}) to have an explicit storage pool,
18199   or you can declare a pool globally to be used for all access types that lack
18200   an explicit one.
18201
18202 @noindent
18203   RM References:  D.07 (8)
18204
18205 @item
18206 @emph{AI-0189 No_Allocators_After_Elaboration (2010-01-23)}
18207 @cindex AI-0189 (Ada 2012 feature)
18208
18209 @noindent
18210   This AI introduces a new restriction @code{No_Allocators_After_Elaboration},
18211   which says that no dynamic allocation will occur once elaboration is
18212   completed.
18213   In general this requires a run-time check, which is not required, and which
18214   GNAT does not attempt. But the static cases of allocators in a task body or
18215   in the body of the main program are detected and flagged at compile or bind
18216   time.
18217
18218 @noindent
18219   RM References:  D.07 (19.1/2)   H.04 (23.3/2)
18220
18221 @item
18222 @emph{AI-0171 Pragma CPU and Ravenscar Profile (2010-09-24)}
18223 @cindex AI-0171 (Ada 2012 feature)
18224
18225 @noindent
18226   A new package @code{System.Multiprocessors} is added, together with the
18227   definition of pragma @code{CPU} for controlling task affinity. A new no
18228   dependence restriction, on @code{System.Multiprocessors.Dispatching_Domains},
18229   is added to the Ravenscar profile.
18230
18231 @noindent
18232   RM References:  D.13.01 (4/2)   D.16
18233
18234
18235 @item
18236 @emph{AI-0210 Correct Timing_Events metric (0000-00-00)}
18237 @cindex AI-0210 (Ada 2012 feature)
18238
18239 @noindent
18240   This is a documentation only issue regarding wording of metric requirements,
18241   that does not affect the implementation of the compiler.
18242
18243 @noindent
18244   RM References:  D.15 (24/2)
18245
18246
18247 @item
18248 @emph{AI-0206 Remote types packages and preelaborate (2010-07-24)}
18249 @cindex AI-0206 (Ada 2012 feature)
18250
18251 @noindent
18252   Remote types packages are now allowed to depend on preelaborated packages.
18253   This was formerly considered illegal.
18254
18255 @noindent
18256   RM References:  E.02.02 (6)
18257
18258
18259
18260 @item
18261 @emph{AI-0152 Restriction No_Anonymous_Allocators (2010-09-08)}
18262 @cindex AI-0152 (Ada 2012 feature)
18263
18264 @noindent
18265   Restriction @code{No_Anonymous_Allocators} prevents the use of allocators
18266   where the type of the returned value is an anonymous access type.
18267
18268 @noindent
18269   RM References:  H.04 (8/1)
18270 @end itemize
18271
18272
18273 @node Obsolescent Features
18274 @chapter Obsolescent Features
18275
18276 @noindent
18277 This chapter describes features that are provided by GNAT, but are
18278 considered obsolescent since there are preferred ways of achieving
18279 the same effect. These features are provided solely for historical
18280 compatibility purposes.
18281
18282 @menu
18283 * pragma No_Run_Time::
18284 * pragma Ravenscar::
18285 * pragma Restricted_Run_Time::
18286 @end menu
18287
18288 @node pragma No_Run_Time
18289 @section pragma No_Run_Time
18290
18291 The pragma @code{No_Run_Time} is used to achieve an affect similar
18292 to the use of the "Zero Foot Print" configurable run time, but without
18293 requiring a specially configured run time. The result of using this
18294 pragma, which must be used for all units in a partition, is to restrict
18295 the use of any language features requiring run-time support code. The
18296 preferred usage is to use an appropriately configured run-time that
18297 includes just those features that are to be made accessible.
18298
18299 @node pragma Ravenscar
18300 @section pragma Ravenscar
18301
18302 The pragma @code{Ravenscar} has exactly the same effect as pragma
18303 @code{Profile (Ravenscar)}. The latter usage is preferred since it
18304 is part of the new Ada 2005 standard.
18305
18306 @node pragma Restricted_Run_Time
18307 @section pragma Restricted_Run_Time
18308
18309 The pragma @code{Restricted_Run_Time} has exactly the same effect as
18310 pragma @code{Profile (Restricted)}. The latter usage is
18311 preferred since the Ada 2005 pragma @code{Profile} is intended for
18312 this kind of implementation dependent addition.
18313
18314 @include fdl.texi
18315 @c GNU Free Documentation License
18316
18317 @node Index,,GNU Free Documentation License, Top
18318 @unnumbered Index
18319
18320 @printindex cp
18321
18322 @contents
18323
18324 @bye