OSDN Git Service

Fix PR c++/42260 and ensure PR c++/45383 is fixed
[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 Assume_No_Invalid_Values::
108 * Pragma Ast_Entry::
109 * Pragma C_Pass_By_Copy::
110 * Pragma Check::
111 * Pragma Check_Name::
112 * Pragma Check_Policy::
113 * Pragma Comment::
114 * Pragma Common_Object::
115 * Pragma Compile_Time_Error::
116 * Pragma Compile_Time_Warning::
117 * Pragma Compiler_Unit::
118 * Pragma Complete_Representation::
119 * Pragma Complex_Representation::
120 * Pragma Component_Alignment::
121 * Pragma Convention_Identifier::
122 * Pragma CPP_Class::
123 * Pragma CPP_Constructor::
124 * Pragma CPP_Virtual::
125 * Pragma CPP_Vtable::
126 * Pragma Debug::
127 * Pragma Debug_Policy::
128 * Pragma Detect_Blocking::
129 * Pragma Elaboration_Checks::
130 * Pragma Eliminate::
131 * Pragma Export_Exception::
132 * Pragma Export_Function::
133 * Pragma Export_Object::
134 * Pragma Export_Procedure::
135 * Pragma Export_Value::
136 * Pragma Export_Valued_Procedure::
137 * Pragma Extend_System::
138 * Pragma Extensions_Allowed::
139 * Pragma External::
140 * Pragma External_Name_Casing::
141 * Pragma Fast_Math::
142 * Pragma Favor_Top_Level::
143 * Pragma Finalize_Storage_Only::
144 * Pragma Float_Representation::
145 * Pragma Ident::
146 * Pragma Implemented::
147 * Pragma Implicit_Packing::
148 * Pragma Import_Exception::
149 * Pragma Import_Function::
150 * Pragma Import_Object::
151 * Pragma Import_Procedure::
152 * Pragma Import_Valued_Procedure::
153 * Pragma Initialize_Scalars::
154 * Pragma Inline_Always::
155 * Pragma Inline_Generic::
156 * Pragma Interface::
157 * Pragma Interface_Name::
158 * Pragma Interrupt_Handler::
159 * Pragma Interrupt_State::
160 * Pragma Invariant::
161 * Pragma Keep_Names::
162 * Pragma License::
163 * Pragma Link_With::
164 * Pragma Linker_Alias::
165 * Pragma Linker_Constructor::
166 * Pragma Linker_Destructor::
167 * Pragma Linker_Section::
168 * Pragma Long_Float::
169 * Pragma Machine_Attribute::
170 * Pragma Main::
171 * Pragma Main_Storage::
172 * Pragma No_Body::
173 * Pragma No_Return::
174 * Pragma No_Strict_Aliasing ::
175 * Pragma Normalize_Scalars::
176 * Pragma Obsolescent::
177 * Pragma Optimize_Alignment::
178 * Pragma Ordered::
179 * Pragma Passive::
180 * Pragma Persistent_BSS::
181 * Pragma Polling::
182 * Pragma Postcondition::
183 * Pragma Precondition::
184 * Pragma Profile (Ravenscar)::
185 * Pragma Profile (Restricted)::
186 * Pragma Psect_Object::
187 * Pragma Pure_Function::
188 * Pragma Restriction_Warnings::
189 * Pragma Shared::
190 * Pragma Short_Circuit_And_Or::
191 * Pragma Short_Descriptors::
192 * Pragma Source_File_Name::
193 * Pragma Source_File_Name_Project::
194 * Pragma Source_Reference::
195 * Pragma Stream_Convert::
196 * Pragma Style_Checks::
197 * Pragma Subtitle::
198 * Pragma Suppress::
199 * Pragma Suppress_All::
200 * Pragma Suppress_Exception_Locations::
201 * Pragma Suppress_Initialization::
202 * Pragma Task_Info::
203 * Pragma Task_Name::
204 * Pragma Task_Storage::
205 * Pragma Thread_Local_Storage::
206 * Pragma Time_Slice::
207 * Pragma Title::
208 * Pragma Unchecked_Union::
209 * Pragma Unimplemented_Unit::
210 * Pragma Universal_Aliasing ::
211 * Pragma Universal_Data::
212 * Pragma Unmodified::
213 * Pragma Unreferenced::
214 * Pragma Unreferenced_Objects::
215 * Pragma Unreserve_All_Interrupts::
216 * Pragma Unsuppress::
217 * Pragma Use_VADS_Size::
218 * Pragma Validity_Checks::
219 * Pragma Volatile::
220 * Pragma Warnings::
221 * Pragma Weak_External::
222 * Pragma Wide_Character_Encoding::
223
224 Implementation Defined Attributes
225
226 * Abort_Signal::
227 * Address_Size::
228 * Asm_Input::
229 * Asm_Output::
230 * AST_Entry::
231 * Bit::
232 * Bit_Position::
233 * Compiler_Version::
234 * Code_Address::
235 * Default_Bit_Order::
236 * Elaborated::
237 * Elab_Body::
238 * Elab_Spec::
239 * Emax::
240 * Enabled::
241 * Enum_Rep::
242 * Enum_Val::
243 * Epsilon::
244 * Fixed_Value::
245 * Has_Access_Values::
246 * Has_Discriminants::
247 * Img::
248 * Integer_Value::
249 * Invalid_Value::
250 * Large::
251 * Machine_Size::
252 * Mantissa::
253 * Max_Interrupt_Priority::
254 * Max_Priority::
255 * Maximum_Alignment::
256 * Mechanism_Code::
257 * Null_Parameter::
258 * Object_Size::
259 * Old::
260 * Passed_By_Reference::
261 * Pool_Address::
262 * Range_Length::
263 * Result::
264 * Safe_Emax::
265 * Safe_Large::
266 * Small::
267 * Storage_Unit::
268 * Stub_Type::
269 * Target_Name::
270 * Tick::
271 * To_Address::
272 * Type_Class::
273 * UET_Address::
274 * Unconstrained_Array::
275 * Universal_Literal_String::
276 * Unrestricted_Access::
277 * VADS_Size::
278 * Value_Size::
279 * Wchar_T_Size::
280 * Word_Size::
281
282 The Implementation of Standard I/O
283
284 * Standard I/O Packages::
285 * FORM Strings::
286 * Direct_IO::
287 * Sequential_IO::
288 * Text_IO::
289 * Wide_Text_IO::
290 * Wide_Wide_Text_IO::
291 * Stream_IO::
292 * Text Translation::
293 * Shared Files::
294 * Filenames encoding::
295 * Open Modes::
296 * Operations on C Streams::
297 * Interfacing to C Streams::
298
299 The GNAT Library
300
301 * Ada.Characters.Latin_9 (a-chlat9.ads)::
302 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
303 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
304 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
305 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
306 * Ada.Command_Line.Environment (a-colien.ads)::
307 * Ada.Command_Line.Remove (a-colire.ads)::
308 * Ada.Command_Line.Response_File (a-clrefi.ads)::
309 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
310 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
311 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
312 * Ada.Exceptions.Traceback (a-exctra.ads)::
313 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
314 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
315 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
316 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
317 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
318 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
319 * Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)::
320 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
321 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
322 * Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)::
323 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
324 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
325 * Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)::
326 * GNAT.Altivec (g-altive.ads)::
327 * GNAT.Altivec.Conversions (g-altcon.ads)::
328 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
329 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
330 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
331 * GNAT.Array_Split (g-arrspl.ads)::
332 * GNAT.AWK (g-awk.ads)::
333 * GNAT.Bounded_Buffers (g-boubuf.ads)::
334 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
335 * GNAT.Bubble_Sort (g-bubsor.ads)::
336 * GNAT.Bubble_Sort_A (g-busora.ads)::
337 * GNAT.Bubble_Sort_G (g-busorg.ads)::
338 * GNAT.Byte_Order_Mark (g-byorma.ads)::
339 * GNAT.Byte_Swapping (g-bytswa.ads)::
340 * GNAT.Calendar (g-calend.ads)::
341 * GNAT.Calendar.Time_IO (g-catiio.ads)::
342 * GNAT.Case_Util (g-casuti.ads)::
343 * GNAT.CGI (g-cgi.ads)::
344 * GNAT.CGI.Cookie (g-cgicoo.ads)::
345 * GNAT.CGI.Debug (g-cgideb.ads)::
346 * GNAT.Command_Line (g-comlin.ads)::
347 * GNAT.Compiler_Version (g-comver.ads)::
348 * GNAT.Ctrl_C (g-ctrl_c.ads)::
349 * GNAT.CRC32 (g-crc32.ads)::
350 * GNAT.Current_Exception (g-curexc.ads)::
351 * GNAT.Debug_Pools (g-debpoo.ads)::
352 * GNAT.Debug_Utilities (g-debuti.ads)::
353 * GNAT.Decode_String (g-decstr.ads)::
354 * GNAT.Decode_UTF8_String (g-deutst.ads)::
355 * GNAT.Directory_Operations (g-dirope.ads)::
356 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
357 * GNAT.Dynamic_HTables (g-dynhta.ads)::
358 * GNAT.Dynamic_Tables (g-dyntab.ads)::
359 * GNAT.Encode_String (g-encstr.ads)::
360 * GNAT.Encode_UTF8_String (g-enutst.ads)::
361 * GNAT.Exception_Actions (g-excact.ads)::
362 * GNAT.Exception_Traces (g-exctra.ads)::
363 * GNAT.Exceptions (g-except.ads)::
364 * GNAT.Expect (g-expect.ads)::
365 * GNAT.Float_Control (g-flocon.ads)::
366 * GNAT.Heap_Sort (g-heasor.ads)::
367 * GNAT.Heap_Sort_A (g-hesora.ads)::
368 * GNAT.Heap_Sort_G (g-hesorg.ads)::
369 * GNAT.HTable (g-htable.ads)::
370 * GNAT.IO (g-io.ads)::
371 * GNAT.IO_Aux (g-io_aux.ads)::
372 * GNAT.Lock_Files (g-locfil.ads)::
373 * GNAT.MBBS_Discrete_Random (g-mbdira.ads)::
374 * GNAT.MBBS_Float_Random (g-mbflra.ads)::
375 * GNAT.MD5 (g-md5.ads)::
376 * GNAT.Memory_Dump (g-memdum.ads)::
377 * GNAT.Most_Recent_Exception (g-moreex.ads)::
378 * GNAT.OS_Lib (g-os_lib.ads)::
379 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
380 * GNAT.Random_Numbers (g-rannum.ads)::
381 * GNAT.Regexp (g-regexp.ads)::
382 * GNAT.Registry (g-regist.ads)::
383 * GNAT.Regpat (g-regpat.ads)::
384 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
385 * GNAT.Semaphores (g-semaph.ads)::
386 * GNAT.Serial_Communications (g-sercom.ads)::
387 * GNAT.SHA1 (g-sha1.ads)::
388 * GNAT.SHA224 (g-sha224.ads)::
389 * GNAT.SHA256 (g-sha256.ads)::
390 * GNAT.SHA384 (g-sha384.ads)::
391 * GNAT.SHA512 (g-sha512.ads)::
392 * GNAT.Signals (g-signal.ads)::
393 * GNAT.Sockets (g-socket.ads)::
394 * GNAT.Source_Info (g-souinf.ads)::
395 * GNAT.Spelling_Checker (g-speche.ads)::
396 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
397 * GNAT.Spitbol.Patterns (g-spipat.ads)::
398 * GNAT.Spitbol (g-spitbo.ads)::
399 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
400 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
401 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
402 * GNAT.SSE (g-sse.ads)::
403 * GNAT.SSE.Vector_Types (g-ssvety.ads)::
404 * GNAT.Strings (g-string.ads)::
405 * GNAT.String_Split (g-strspl.ads)::
406 * GNAT.Table (g-table.ads)::
407 * GNAT.Task_Lock (g-tasloc.ads)::
408 * GNAT.Threads (g-thread.ads)::
409 * GNAT.Time_Stamp (g-timsta.ads)::
410 * GNAT.Traceback (g-traceb.ads)::
411 * GNAT.Traceback.Symbolic (g-trasym.ads)::
412 * GNAT.UTF_32 (g-utf_32.ads)::
413 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
414 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
415 * GNAT.Wide_String_Split (g-wistsp.ads)::
416 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
417 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
418 * Interfaces.C.Extensions (i-cexten.ads)::
419 * Interfaces.C.Streams (i-cstrea.ads)::
420 * Interfaces.CPP (i-cpp.ads)::
421 * Interfaces.Packed_Decimal (i-pacdec.ads)::
422 * Interfaces.VxWorks (i-vxwork.ads)::
423 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
424 * System.Address_Image (s-addima.ads)::
425 * System.Assertions (s-assert.ads)::
426 * System.Memory (s-memory.ads)::
427 * System.Partition_Interface (s-parint.ads)::
428 * System.Pool_Global (s-pooglo.ads)::
429 * System.Pool_Local (s-pooloc.ads)::
430 * System.Restrictions (s-restri.ads)::
431 * System.Rident (s-rident.ads)::
432 * System.Strings.Stream_Ops (s-ststop.ads)::
433 * System.Task_Info (s-tasinf.ads)::
434 * System.Wch_Cnv (s-wchcnv.ads)::
435 * System.Wch_Con (s-wchcon.ads)::
436
437 Text_IO
438
439 * Text_IO Stream Pointer Positioning::
440 * Text_IO Reading and Writing Non-Regular Files::
441 * Get_Immediate::
442 * Treating Text_IO Files as Streams::
443 * Text_IO Extensions::
444 * Text_IO Facilities for Unbounded Strings::
445
446 Wide_Text_IO
447
448 * Wide_Text_IO Stream Pointer Positioning::
449 * Wide_Text_IO Reading and Writing Non-Regular Files::
450
451 Wide_Wide_Text_IO
452
453 * Wide_Wide_Text_IO Stream Pointer Positioning::
454 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
455
456 Interfacing to Other Languages
457
458 * Interfacing to C::
459 * Interfacing to C++::
460 * Interfacing to COBOL::
461 * Interfacing to Fortran::
462 * Interfacing to non-GNAT Ada code::
463
464 Specialized Needs Annexes
465
466 Implementation of Specific Ada Features
467 * Machine Code Insertions::
468 * GNAT Implementation of Tasking::
469 * GNAT Implementation of Shared Passive Packages::
470 * Code Generation for Array Aggregates::
471 * The Size of Discriminated Records with Default Discriminants::
472 * Strict Conformance to the Ada Reference Manual::
473
474 Implementation of Ada 2012 Features
475
476 Obsolescent Features
477
478 GNU Free Documentation License
479
480 Index
481 @end menu
482
483 @end ifnottex
484
485 @node About This Guide
486 @unnumbered About This Guide
487
488 @noindent
489 This manual contains useful information in writing programs using the
490 @value{EDITION} compiler.  It includes information on implementation dependent
491 characteristics of @value{EDITION}, including all the information required by
492 Annex M of the Ada language standard.
493
494 @value{EDITION} implements Ada 95 and Ada 2005, and it may also be invoked in
495 Ada 83 compatibility mode.
496 By default, @value{EDITION} assumes @value{DEFAULTLANGUAGEVERSION},
497 but you can override with a compiler switch
498 to explicitly specify the language version.
499 (Please refer to @ref{Compiling Different Versions of Ada,,, gnat_ugn,
500 @value{EDITION} User's Guide}, for details on these switches.)
501 Throughout this manual, references to ``Ada'' without a year suffix
502 apply to both the Ada 95 and Ada 2005 versions of the language.
503
504 Ada is designed to be highly portable.
505 In general, a program will have the same effect even when compiled by
506 different compilers on different platforms.
507 However, since Ada is designed to be used in a
508 wide variety of applications, it also contains a number of system
509 dependent features to be used in interfacing to the external world.
510 @cindex Implementation-dependent features
511 @cindex Portability
512
513 Note: Any program that makes use of implementation-dependent features
514 may be non-portable.  You should follow good programming practice and
515 isolate and clearly document any sections of your program that make use
516 of these features in a non-portable manner.
517
518 @ifset PROEDITION
519 For ease of exposition, ``GNAT Pro'' will be referred to simply as
520 ``GNAT'' in the remainder of this document.
521 @end ifset
522
523 @menu
524 * What This Reference Manual Contains::
525 * Conventions::
526 * Related Information::
527 @end menu
528
529 @node What This Reference Manual Contains
530 @unnumberedsec What This Reference Manual Contains
531
532 @noindent
533 This reference manual contains the following chapters:
534
535 @itemize @bullet
536 @item
537 @ref{Implementation Defined Pragmas}, lists GNAT implementation-dependent
538 pragmas, which can be used to extend and enhance the functionality of the
539 compiler.
540
541 @item
542 @ref{Implementation Defined Attributes}, lists GNAT
543 implementation-dependent attributes which can be used to extend and
544 enhance the functionality of the compiler.
545
546 @item
547 @ref{Implementation Advice}, provides information on generally
548 desirable behavior which are not requirements that all compilers must
549 follow since it cannot be provided on all systems, or which may be
550 undesirable on some systems.
551
552 @item
553 @ref{Implementation Defined Characteristics}, provides a guide to
554 minimizing implementation dependent features.
555
556 @item
557 @ref{Intrinsic Subprograms}, describes the intrinsic subprograms
558 implemented by GNAT, and how they can be imported into user
559 application programs.
560
561 @item
562 @ref{Representation Clauses and Pragmas}, describes in detail the
563 way that GNAT represents data, and in particular the exact set
564 of representation clauses and pragmas that is accepted.
565
566 @item
567 @ref{Standard Library Routines}, provides a listing of packages and a
568 brief description of the functionality that is provided by Ada's
569 extensive set of standard library routines as implemented by GNAT@.
570
571 @item
572 @ref{The Implementation of Standard I/O}, details how the GNAT
573 implementation of the input-output facilities.
574
575 @item
576 @ref{The GNAT Library}, is a catalog of packages that complement
577 the Ada predefined library.
578
579 @item
580 @ref{Interfacing to Other Languages}, describes how programs
581 written in Ada using GNAT can be interfaced to other programming
582 languages.
583
584 @ref{Specialized Needs Annexes}, describes the GNAT implementation of all
585 of the specialized needs annexes.
586
587 @item
588 @ref{Implementation of Specific Ada Features}, discusses issues related
589 to GNAT's implementation of machine code insertions, tasking, and several
590 other features.
591
592 @item
593 @ref{Implementation of Ada 2012 Features}, describes the status of the
594 GNAT implementation of the Ada 2012 language standard.
595
596 @item
597 @ref{Obsolescent Features} documents implementation dependent features,
598 including pragmas and attributes, which are considered obsolescent, since
599 there are other preferred ways of achieving the same results. These
600 obsolescent forms are retained for backwards compatibility.
601
602 @end itemize
603
604 @cindex Ada 95 Language Reference Manual
605 @cindex Ada 2005 Language Reference Manual
606 @noindent
607 This reference manual assumes a basic familiarity with the Ada 95 language, as
608 described in the International Standard ANSI/ISO/IEC-8652:1995,
609 January 1995.
610 It does not require knowledge of the new features introduced by Ada 2005,
611 (officially known as ISO/IEC 8652:1995 with Technical Corrigendum 1
612 and Amendment 1).
613 Both reference manuals are included in the GNAT documentation
614 package.
615
616 @node Conventions
617 @unnumberedsec Conventions
618 @cindex Conventions, typographical
619 @cindex Typographical conventions
620
621 @noindent
622 Following are examples of the typographical and graphic conventions used
623 in this guide:
624
625 @itemize @bullet
626 @item
627 @code{Functions}, @code{utility program names}, @code{standard names},
628 and @code{classes}.
629
630 @item
631 @code{Option flags}
632
633 @item
634 @file{File names}, @samp{button names}, and @samp{field names}.
635
636 @item
637 @code{Variables}, @env{environment variables}, and @var{metasyntactic
638 variables}.
639
640 @item
641 @emph{Emphasis}.
642
643 @item
644 [optional information or parameters]
645
646 @item
647 Examples are described by text
648 @smallexample
649 and then shown this way.
650 @end smallexample
651 @end itemize
652
653 @noindent
654 Commands that are entered by the user are preceded in this manual by the
655 characters @samp{$ } (dollar sign followed by space).  If your system uses this
656 sequence as a prompt, then the commands will appear exactly as you see them
657 in the manual.  If your system uses some other prompt, then the command will
658 appear with the @samp{$} replaced by whatever prompt character you are using.
659
660 @node Related Information
661 @unnumberedsec Related Information
662 @noindent
663 See the following documents for further information on GNAT:
664
665 @itemize @bullet
666 @item
667 @xref{Top, @value{EDITION} User's Guide, About This Guide, gnat_ugn,
668 @value{EDITION} User's Guide}, which provides information on how to use the
669 GNAT compiler system.
670
671 @item
672 @cite{Ada 95 Reference Manual}, which contains all reference
673 material for the Ada 95 programming language.
674
675 @item
676 @cite{Ada 95 Annotated Reference Manual}, which is an annotated version
677 of the Ada 95 standard.  The annotations describe
678 detailed aspects of the design decision, and in particular contain useful
679 sections on Ada 83 compatibility.
680
681 @item
682 @cite{Ada 2005 Reference Manual}, which contains all reference
683 material for the Ada 2005 programming language.
684
685 @item
686 @cite{Ada 2005 Annotated Reference Manual}, which is an annotated version
687 of the Ada 2005 standard.  The annotations describe
688 detailed aspects of the design decision, and in particular contain useful
689 sections on Ada 83 and Ada 95 compatibility.
690
691 @item
692 @cite{DEC Ada, Technical Overview and Comparison on DIGITAL Platforms},
693 which contains specific information on compatibility between GNAT and
694 DEC Ada 83 systems.
695
696 @item
697 @cite{DEC Ada, Language Reference Manual, part number AA-PYZAB-TK} which
698 describes in detail the pragmas and attributes provided by the DEC Ada 83
699 compiler system.
700
701 @end itemize
702
703 @node Implementation Defined Pragmas
704 @chapter Implementation Defined Pragmas
705
706 @noindent
707 Ada defines a set of pragmas that can be used to supply additional
708 information to the compiler.  These language defined pragmas are
709 implemented in GNAT and work as described in the Ada Reference Manual.
710
711 In addition, Ada allows implementations to define additional pragmas
712 whose meaning is defined by the implementation.  GNAT provides a number
713 of these implementation-defined pragmas, which can be used to extend
714 and enhance the functionality of the compiler.  This section of the GNAT
715 Reference Manual describes these additional pragmas.
716
717 Note that any program using these pragmas might not be portable to other
718 compilers (although GNAT implements this set of pragmas on all
719 platforms).  Therefore if portability to other compilers is an important
720 consideration, the use of these pragmas should be minimized.
721
722 @menu
723 * Pragma Abort_Defer::
724 * Pragma Ada_83::
725 * Pragma Ada_95::
726 * Pragma Ada_05::
727 * Pragma Ada_2005::
728 * Pragma Ada_12::
729 * Pragma Ada_2012::
730 * Pragma Annotate::
731 * Pragma Assert::
732 * Pragma Assume_No_Invalid_Values::
733 * Pragma Ast_Entry::
734 * Pragma C_Pass_By_Copy::
735 * Pragma Check::
736 * Pragma Check_Name::
737 * Pragma Check_Policy::
738 * Pragma Comment::
739 * Pragma Common_Object::
740 * Pragma Compile_Time_Error::
741 * Pragma Compile_Time_Warning::
742 * Pragma Compiler_Unit::
743 * Pragma Complete_Representation::
744 * Pragma Complex_Representation::
745 * Pragma Component_Alignment::
746 * Pragma Convention_Identifier::
747 * Pragma CPP_Class::
748 * Pragma CPP_Constructor::
749 * Pragma CPP_Virtual::
750 * Pragma CPP_Vtable::
751 * Pragma Debug::
752 * Pragma Debug_Policy::
753 * Pragma Detect_Blocking::
754 * Pragma Elaboration_Checks::
755 * Pragma Eliminate::
756 * Pragma Export_Exception::
757 * Pragma Export_Function::
758 * Pragma Export_Object::
759 * Pragma Export_Procedure::
760 * Pragma Export_Value::
761 * Pragma Export_Valued_Procedure::
762 * Pragma Extend_System::
763 * Pragma Extensions_Allowed::
764 * Pragma External::
765 * Pragma External_Name_Casing::
766 * Pragma Fast_Math::
767 * Pragma Favor_Top_Level::
768 * Pragma Finalize_Storage_Only::
769 * Pragma Float_Representation::
770 * Pragma Ident::
771 * Pragma Implemented::
772 * Pragma Implicit_Packing::
773 * Pragma Import_Exception::
774 * Pragma Import_Function::
775 * Pragma Import_Object::
776 * Pragma Import_Procedure::
777 * Pragma Import_Valued_Procedure::
778 * Pragma Initialize_Scalars::
779 * Pragma Inline_Always::
780 * Pragma Inline_Generic::
781 * Pragma Interface::
782 * Pragma Interface_Name::
783 * Pragma Interrupt_Handler::
784 * Pragma Interrupt_State::
785 * Pragma Invariant::
786 * Pragma Keep_Names::
787 * Pragma License::
788 * Pragma Link_With::
789 * Pragma Linker_Alias::
790 * Pragma Linker_Constructor::
791 * Pragma Linker_Destructor::
792 * Pragma Linker_Section::
793 * Pragma Long_Float::
794 * Pragma Machine_Attribute::
795 * Pragma Main::
796 * Pragma Main_Storage::
797 * Pragma No_Body::
798 * Pragma No_Return::
799 * Pragma No_Strict_Aliasing::
800 * Pragma Normalize_Scalars::
801 * Pragma Obsolescent::
802 * Pragma Optimize_Alignment::
803 * Pragma Ordered::
804 * Pragma Passive::
805 * Pragma Persistent_BSS::
806 * Pragma Polling::
807 * Pragma Postcondition::
808 * Pragma Precondition::
809 * Pragma Profile (Ravenscar)::
810 * Pragma Profile (Restricted)::
811 * Pragma Psect_Object::
812 * Pragma Pure_Function::
813 * Pragma Restriction_Warnings::
814 * Pragma Shared::
815 * Pragma Short_Circuit_And_Or::
816 * Pragma Short_Descriptors::
817 * Pragma Source_File_Name::
818 * Pragma Source_File_Name_Project::
819 * Pragma Source_Reference::
820 * Pragma Stream_Convert::
821 * Pragma Style_Checks::
822 * Pragma Subtitle::
823 * Pragma Suppress::
824 * Pragma Suppress_All::
825 * Pragma Suppress_Exception_Locations::
826 * Pragma Suppress_Initialization::
827 * Pragma Task_Info::
828 * Pragma Task_Name::
829 * Pragma Task_Storage::
830 * Pragma Thread_Local_Storage::
831 * Pragma Time_Slice::
832 * Pragma Title::
833 * Pragma Unchecked_Union::
834 * Pragma Unimplemented_Unit::
835 * Pragma Universal_Aliasing ::
836 * Pragma Universal_Data::
837 * Pragma Unmodified::
838 * Pragma Unreferenced::
839 * Pragma Unreferenced_Objects::
840 * Pragma Unreserve_All_Interrupts::
841 * Pragma Unsuppress::
842 * Pragma Use_VADS_Size::
843 * Pragma Validity_Checks::
844 * Pragma Volatile::
845 * Pragma Warnings::
846 * Pragma Weak_External::
847 * Pragma Wide_Character_Encoding::
848 @end menu
849
850 @node Pragma Abort_Defer
851 @unnumberedsec Pragma Abort_Defer
852 @findex Abort_Defer
853 @cindex Deferring aborts
854 @noindent
855 Syntax:
856 @smallexample
857 pragma Abort_Defer;
858 @end smallexample
859
860 @noindent
861 This pragma must appear at the start of the statement sequence of a
862 handled sequence of statements (right after the @code{begin}).  It has
863 the effect of deferring aborts for the sequence of statements (but not
864 for the declarations or handlers, if any, associated with this statement
865 sequence).
866
867 @node Pragma Ada_83
868 @unnumberedsec Pragma Ada_83
869 @findex Ada_83
870 @noindent
871 Syntax:
872 @smallexample @c ada
873 pragma Ada_83;
874 @end smallexample
875
876 @noindent
877 A configuration pragma that establishes Ada 83 mode for the unit to
878 which it applies, regardless of the mode set by the command line
879 switches.  In Ada 83 mode, GNAT attempts to be as compatible with
880 the syntax and semantics of Ada 83, as defined in the original Ada
881 83 Reference Manual as possible.  In particular, the keywords added by Ada 95
882 and Ada 2005 are not recognized, optional package bodies are allowed,
883 and generics may name types with unknown discriminants without using
884 the @code{(<>)} notation.  In addition, some but not all of the additional
885 restrictions of Ada 83 are enforced.
886
887 Ada 83 mode is intended for two purposes.  Firstly, it allows existing
888 Ada 83 code to be compiled and adapted to GNAT with less effort.
889 Secondly, it aids in keeping code backwards compatible with Ada 83.
890 However, there is no guarantee that code that is processed correctly
891 by GNAT in Ada 83 mode will in fact compile and execute with an Ada
892 83 compiler, since GNAT does not enforce all the additional checks
893 required by Ada 83.
894
895 @node Pragma Ada_95
896 @unnumberedsec Pragma Ada_95
897 @findex Ada_95
898 @noindent
899 Syntax:
900 @smallexample @c ada
901 pragma Ada_95;
902 @end smallexample
903
904 @noindent
905 A configuration pragma that establishes Ada 95 mode for the unit to which
906 it applies, regardless of the mode set by the command line switches.
907 This mode is set automatically for the @code{Ada} and @code{System}
908 packages and their children, so you need not specify it in these
909 contexts.  This pragma is useful when writing a reusable component that
910 itself uses Ada 95 features, but which is intended to be usable from
911 either Ada 83 or Ada 95 programs.
912
913 @node Pragma Ada_05
914 @unnumberedsec Pragma Ada_05
915 @findex Ada_05
916 @noindent
917 Syntax:
918 @smallexample @c ada
919 pragma Ada_05;
920 @end smallexample
921
922 @noindent
923 A configuration pragma that establishes Ada 2005 mode for the unit to which
924 it applies, regardless of the mode set by the command line switches.
925 This pragma is useful when writing a reusable component that
926 itself uses Ada 2005 features, but which is intended to be usable from
927 either Ada 83 or Ada 95 programs.
928
929 @node Pragma Ada_2005
930 @unnumberedsec Pragma Ada_2005
931 @findex Ada_2005
932 @noindent
933 Syntax:
934 @smallexample @c ada
935 pragma Ada_2005;
936 @end smallexample
937
938 @noindent
939 This configuration pragma is a synonym for pragma Ada_05 and has the
940 same syntax and effect.
941
942 @node Pragma Ada_12
943 @unnumberedsec Pragma Ada_12
944 @findex Ada_12
945 @noindent
946 Syntax:
947 @smallexample @c ada
948 pragma Ada_12;
949 @end smallexample
950
951 @noindent
952 A configuration pragma that establishes Ada 2012 mode for the unit to which
953 it applies, regardless of the mode set by the command line switches.
954 This mode is set automatically for the @code{Ada} and @code{System}
955 packages and their children, so you need not specify it in these
956 contexts.  This pragma is useful when writing a reusable component that
957 itself uses Ada 2012 features, but which is intended to be usable from
958 Ada 83, Ada 95, or Ada 2005 programs.
959
960 @node Pragma Ada_2012
961 @unnumberedsec Pragma Ada_2012
962 @findex Ada_2005
963 @noindent
964 Syntax:
965 @smallexample @c ada
966 pragma Ada_2012;
967 @end smallexample
968
969 @noindent
970 This configuration pragma is a synonym for pragma Ada_12 and has the
971 same syntax and effect.
972
973 @node Pragma Annotate
974 @unnumberedsec Pragma Annotate
975 @findex Annotate
976 @noindent
977 Syntax:
978 @smallexample @c ada
979 pragma Annotate (IDENTIFIER [,IDENTIFIER] @{, ARG@});
980
981 ARG ::= NAME | EXPRESSION
982 @end smallexample
983
984 @noindent
985 This pragma is used to annotate programs.  @var{identifier} identifies
986 the type of annotation.  GNAT verifies that it is an identifier, but does
987 not otherwise analyze it. The second optional identifier is also left
988 unanalyzed, and by convention is used to control the action of the tool to
989 which the annotation is addressed.  The remaining @var{arg} arguments
990 can be either string literals or more generally expressions.
991 String literals are assumed to be either of type
992 @code{Standard.String} or else @code{Wide_String} or @code{Wide_Wide_String}
993 depending on the character literals they contain.
994 All other kinds of arguments are analyzed as expressions, and must be
995 unambiguous.
996
997 The analyzed pragma is retained in the tree, but not otherwise processed
998 by any part of the GNAT compiler.  This pragma is intended for use by
999 external tools, including ASIS@.
1000
1001 @node Pragma Assert
1002 @unnumberedsec Pragma Assert
1003 @findex Assert
1004 @noindent
1005 Syntax:
1006 @smallexample @c ada
1007 pragma Assert (
1008   boolean_EXPRESSION
1009   [, string_EXPRESSION]);
1010 @end smallexample
1011
1012 @noindent
1013 The effect of this pragma depends on whether the corresponding command
1014 line switch is set to activate assertions.  The pragma expands into code
1015 equivalent to the following:
1016
1017 @smallexample @c ada
1018 if assertions-enabled then
1019    if not boolean_EXPRESSION then
1020       System.Assertions.Raise_Assert_Failure
1021         (string_EXPRESSION);
1022    end if;
1023 end if;
1024 @end smallexample
1025
1026 @noindent
1027 The string argument, if given, is the message that will be associated
1028 with the exception occurrence if the exception is raised.  If no second
1029 argument is given, the default message is @samp{@var{file}:@var{nnn}},
1030 where @var{file} is the name of the source file containing the assert,
1031 and @var{nnn} is the line number of the assert.  A pragma is not a
1032 statement, so if a statement sequence contains nothing but a pragma
1033 assert, then a null statement is required in addition, as in:
1034
1035 @smallexample @c ada
1036 @dots{}
1037 if J > 3 then
1038    pragma Assert (K > 3, "Bad value for K");
1039    null;
1040 end if;
1041 @end smallexample
1042
1043 @noindent
1044 Note that, as with the @code{if} statement to which it is equivalent, the
1045 type of the expression is either @code{Standard.Boolean}, or any type derived
1046 from this standard type.
1047
1048 If assertions are disabled (switch @option{-gnata} not used), then there
1049 is no run-time effect (and in particular, any side effects from the
1050 expression will not occur at run time).  (The expression is still
1051 analyzed at compile time, and may cause types to be frozen if they are
1052 mentioned here for the first time).
1053
1054 If assertions are enabled, then the given expression is tested, and if
1055 it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
1056 which results in the raising of @code{Assert_Failure} with the given message.
1057
1058 You should generally avoid side effects in the expression arguments of
1059 this pragma, because these side effects will turn on and off with the
1060 setting of the assertions mode, resulting in assertions that have an
1061 effect on the program.  However, the expressions are analyzed for
1062 semantic correctness whether or not assertions are enabled, so turning
1063 assertions on and off cannot affect the legality of a program.
1064
1065 @node Pragma Assume_No_Invalid_Values
1066 @unnumberedsec Pragma Assume_No_Invalid_Values
1067 @findex Assume_No_Invalid_Values
1068 @cindex Invalid representations
1069 @cindex Invalid values
1070 @noindent
1071 Syntax:
1072 @smallexample @c ada
1073 pragma Assume_No_Invalid_Values (On | Off);
1074 @end smallexample
1075
1076 @noindent
1077 This is a configuration pragma that controls the assumptions made by the
1078 compiler about the occurrence of invalid representations (invalid values)
1079 in the code.
1080
1081 The default behavior (corresponding to an Off argument for this pragma), is
1082 to assume that values may in general be invalid unless the compiler can
1083 prove they are valid. Consider the following example:
1084
1085 @smallexample @c ada
1086 V1 : Integer range 1 .. 10;
1087 V2 : Integer range 11 .. 20;
1088 ...
1089 for J in V2 .. V1 loop
1090    ...
1091 end loop;
1092 @end smallexample
1093
1094 @noindent
1095 if V1 and V2 have valid values, then the loop is known at compile
1096 time not to execute since the lower bound must be greater than the
1097 upper bound. However in default mode, no such assumption is made,
1098 and the loop may execute. If @code{Assume_No_Invalid_Values (On)}
1099 is given, the compiler will assume that any occurrence of a variable
1100 other than in an explicit @code{'Valid} test always has a valid
1101 value, and the loop above will be optimized away.
1102
1103 The use of @code{Assume_No_Invalid_Values (On)} is appropriate if
1104 you know your code is free of uninitialized variables and other
1105 possible sources of invalid representations, and may result in
1106 more efficient code. A program that accesses an invalid representation
1107 with this pragma in effect is erroneous, so no guarantees can be made
1108 about its behavior.
1109
1110 It is peculiar though permissible to use this pragma in conjunction
1111 with validity checking (-gnatVa). In such cases, accessing invalid
1112 values will generally give an exception, though formally the program
1113 is erroneous so there are no guarantees that this will always be the
1114 case, and it is recommended that these two options not be used together.
1115
1116 @node Pragma Ast_Entry
1117 @unnumberedsec Pragma Ast_Entry
1118 @cindex OpenVMS
1119 @findex Ast_Entry
1120 @noindent
1121 Syntax:
1122 @smallexample @c ada
1123 pragma AST_Entry (entry_IDENTIFIER);
1124 @end smallexample
1125
1126 @noindent
1127 This pragma is implemented only in the OpenVMS implementation of GNAT@.  The
1128 argument is the simple name of a single entry; at most one @code{AST_Entry}
1129 pragma is allowed for any given entry.  This pragma must be used in
1130 conjunction with the @code{AST_Entry} attribute, and is only allowed after
1131 the entry declaration and in the same task type specification or single task
1132 as the entry to which it applies.  This pragma specifies that the given entry
1133 may be used to handle an OpenVMS asynchronous system trap (@code{AST})
1134 resulting from an OpenVMS system service call.  The pragma does not affect
1135 normal use of the entry.  For further details on this pragma, see the
1136 DEC Ada Language Reference Manual, section 9.12a.
1137
1138 @node Pragma C_Pass_By_Copy
1139 @unnumberedsec Pragma C_Pass_By_Copy
1140 @cindex Passing by copy
1141 @findex C_Pass_By_Copy
1142 @noindent
1143 Syntax:
1144 @smallexample @c ada
1145 pragma C_Pass_By_Copy
1146   ([Max_Size =>] static_integer_EXPRESSION);
1147 @end smallexample
1148
1149 @noindent
1150 Normally the default mechanism for passing C convention records to C
1151 convention subprograms is to pass them by reference, as suggested by RM
1152 B.3(69).  Use the configuration pragma @code{C_Pass_By_Copy} to change
1153 this default, by requiring that record formal parameters be passed by
1154 copy if all of the following conditions are met:
1155
1156 @itemize @bullet
1157 @item
1158 The size of the record type does not exceed the value specified for
1159 @code{Max_Size}.
1160 @item
1161 The record type has @code{Convention C}.
1162 @item
1163 The formal parameter has this record type, and the subprogram has a
1164 foreign (non-Ada) convention.
1165 @end itemize
1166
1167 @noindent
1168 If these conditions are met the argument is passed by copy, i.e.@: in a
1169 manner consistent with what C expects if the corresponding formal in the
1170 C prototype is a struct (rather than a pointer to a struct).
1171
1172 You can also pass records by copy by specifying the convention
1173 @code{C_Pass_By_Copy} for the record type, or by using the extended
1174 @code{Import} and @code{Export} pragmas, which allow specification of
1175 passing mechanisms on a parameter by parameter basis.
1176
1177 @node Pragma Check
1178 @unnumberedsec Pragma Check
1179 @cindex Assertions
1180 @cindex Named assertions
1181 @findex Check
1182 @noindent
1183 Syntax:
1184 @smallexample @c ada
1185 pragma Check (
1186      [Name    =>] Identifier,
1187      [Check   =>] Boolean_EXPRESSION
1188   [, [Message =>] string_EXPRESSION] );
1189 @end smallexample
1190
1191 @noindent
1192 This pragma is similar to the predefined pragma @code{Assert} except that an
1193 extra identifier argument is present. In conjunction with pragma
1194 @code{Check_Policy}, this can be used to define groups of assertions that can
1195 be independently controlled. The identifier @code{Assertion} is special, it
1196 refers to the normal set of pragma @code{Assert} statements. The identifiers
1197 @code{Precondition} and @code{Postcondition} correspond to the pragmas of these
1198 names, so these three names would normally not be used directly in a pragma
1199 @code{Check}.
1200
1201 Checks introduced by this pragma are normally deactivated by default. They can
1202 be activated either by the command line option @option{-gnata}, which turns on
1203 all checks, or individually controlled using pragma @code{Check_Policy}.
1204
1205 @node Pragma Check_Name
1206 @unnumberedsec Pragma Check_Name
1207 @cindex Defining check names
1208 @cindex Check names, defining
1209 @findex Check_Name
1210 @noindent
1211 Syntax:
1212 @smallexample @c ada
1213 pragma Check_Name (check_name_IDENTIFIER);
1214 @end smallexample
1215
1216 @noindent
1217 This is a configuration pragma that defines a new implementation
1218 defined check name (unless IDENTIFIER matches one of the predefined
1219 check names, in which case the pragma has no effect). Check names
1220 are global to a partition, so if two or more configuration pragmas
1221 are present in a partition mentioning the same name, only one new
1222 check name is introduced.
1223
1224 An implementation defined check name introduced with this pragma may
1225 be used in only three contexts: @code{pragma Suppress},
1226 @code{pragma Unsuppress},
1227 and as the prefix of a @code{Check_Name'Enabled} attribute reference. For
1228 any of these three cases, the check name must be visible. A check
1229 name is visible if it is in the configuration pragmas applying to
1230 the current unit, or if it appears at the start of any unit that
1231 is part of the dependency set of the current unit (e.g., units that
1232 are mentioned in @code{with} clauses).
1233
1234 @node Pragma Check_Policy
1235 @unnumberedsec Pragma Check_Policy
1236 @cindex Controlling assertions
1237 @cindex Assertions, control
1238 @cindex Check pragma control
1239 @cindex Named assertions
1240 @findex Check
1241 @noindent
1242 Syntax:
1243 @smallexample @c ada
1244 pragma Check_Policy
1245  ([Name   =>] Identifier,
1246   [Policy =>] POLICY_IDENTIFIER);
1247
1248 POLICY_IDENTIFIER ::= On | Off | Check | Ignore
1249 @end smallexample
1250
1251 @noindent
1252 This pragma is similar to the predefined pragma @code{Assertion_Policy},
1253 except that it controls sets of named assertions introduced using the
1254 @code{Check} pragmas. It can be used as a configuration pragma or (unlike
1255 @code{Assertion_Policy}) can be used within a declarative part, in which case
1256 it controls the status to the end of the corresponding construct (in a manner
1257 identical to pragma @code{Suppress)}.
1258
1259 The identifier given as the first argument corresponds to a name used in
1260 associated @code{Check} pragmas. For example, if the pragma:
1261
1262 @smallexample @c ada
1263 pragma Check_Policy (Critical_Error, Off);
1264 @end smallexample
1265
1266 @noindent
1267 is given, then subsequent @code{Check} pragmas whose first argument is also
1268 @code{Critical_Error} will be disabled. The special identifier @code{Assertion}
1269 controls the behavior of normal @code{Assert} pragmas (thus a pragma
1270 @code{Check_Policy} with this identifier is similar to the normal
1271 @code{Assertion_Policy} pragma except that it can appear within a
1272 declarative part).
1273
1274 The special identifiers @code{Precondition} and @code{Postcondition} control
1275 the status of preconditions and postconditions. If a @code{Precondition} pragma
1276 is encountered, it is ignored if turned off by a @code{Check_Policy} specifying
1277 that @code{Precondition} checks are @code{Off} or @code{Ignored}. Similarly use
1278 of the name @code{Postcondition} controls whether @code{Postcondition} pragmas
1279 are recognized.
1280
1281 The check policy is @code{Off} to turn off corresponding checks, and @code{On}
1282 to turn on corresponding checks. The default for a set of checks for which no
1283 @code{Check_Policy} is given is @code{Off} unless the compiler switch
1284 @option{-gnata} is given, which turns on all checks by default.
1285
1286 The check policy settings @code{Check} and @code{Ignore} are also recognized
1287 as synonyms for @code{On} and @code{Off}. These synonyms are provided for
1288 compatibility with the standard @code{Assertion_Policy} pragma.
1289
1290 @node Pragma Comment
1291 @unnumberedsec Pragma Comment
1292 @findex Comment
1293 @noindent
1294 Syntax:
1295
1296 @smallexample @c ada
1297 pragma Comment (static_string_EXPRESSION);
1298 @end smallexample
1299
1300 @noindent
1301 This is almost identical in effect to pragma @code{Ident}.  It allows the
1302 placement of a comment into the object file and hence into the
1303 executable file if the operating system permits such usage.  The
1304 difference is that @code{Comment}, unlike @code{Ident}, has
1305 no limitations on placement of the pragma (it can be placed
1306 anywhere in the main source unit), and if more than one pragma
1307 is used, all comments are retained.
1308
1309 @node Pragma Common_Object
1310 @unnumberedsec Pragma Common_Object
1311 @findex Common_Object
1312 @noindent
1313 Syntax:
1314
1315 @smallexample @c ada
1316 pragma Common_Object (
1317      [Internal =>] LOCAL_NAME
1318   [, [External =>] EXTERNAL_SYMBOL]
1319   [, [Size     =>] EXTERNAL_SYMBOL] );
1320
1321 EXTERNAL_SYMBOL ::=
1322   IDENTIFIER
1323 | static_string_EXPRESSION
1324 @end smallexample
1325
1326 @noindent
1327 This pragma enables the shared use of variables stored in overlaid
1328 linker areas corresponding to the use of @code{COMMON}
1329 in Fortran.  The single
1330 object @var{LOCAL_NAME} is assigned to the area designated by
1331 the @var{External} argument.
1332 You may define a record to correspond to a series
1333 of fields.  The @var{Size} argument
1334 is syntax checked in GNAT, but otherwise ignored.
1335
1336 @code{Common_Object} is not supported on all platforms.  If no
1337 support is available, then the code generator will issue a message
1338 indicating that the necessary attribute for implementation of this
1339 pragma is not available.
1340
1341 @node Pragma Compile_Time_Error
1342 @unnumberedsec Pragma Compile_Time_Error
1343 @findex Compile_Time_Error
1344 @noindent
1345 Syntax:
1346
1347 @smallexample @c ada
1348 pragma Compile_Time_Error
1349          (boolean_EXPRESSION, static_string_EXPRESSION);
1350 @end smallexample
1351
1352 @noindent
1353 This pragma can be used to generate additional compile time
1354 error messages. It
1355 is particularly useful in generics, where errors can be issued for
1356 specific problematic instantiations. The first parameter is a boolean
1357 expression. The pragma is effective only if the value of this expression
1358 is known at compile time, and has the value True. The set of expressions
1359 whose values are known at compile time includes all static boolean
1360 expressions, and also other values which the compiler can determine
1361 at compile time (e.g., the size of a record type set by an explicit
1362 size representation clause, or the value of a variable which was
1363 initialized to a constant and is known not to have been modified).
1364 If these conditions are met, an error message is generated using
1365 the value given as the second argument. This string value may contain
1366 embedded ASCII.LF characters to break the message into multiple lines.
1367
1368 @node Pragma Compile_Time_Warning
1369 @unnumberedsec Pragma Compile_Time_Warning
1370 @findex Compile_Time_Warning
1371 @noindent
1372 Syntax:
1373
1374 @smallexample @c ada
1375 pragma Compile_Time_Warning
1376          (boolean_EXPRESSION, static_string_EXPRESSION);
1377 @end smallexample
1378
1379 @noindent
1380 Same as pragma Compile_Time_Error, except a warning is issued instead
1381 of an error message. Note that if this pragma is used in a package that
1382 is with'ed by a client, the client will get the warning even though it
1383 is issued by a with'ed package (normally warnings in with'ed units are
1384 suppressed, but this is a special exception to that rule).
1385
1386 One typical use is within a generic where compile time known characteristics
1387 of formal parameters are tested, and warnings given appropriately. Another use
1388 with a first parameter of True is to warn a client about use of a package,
1389 for example that it is not fully implemented.
1390
1391 @node Pragma Compiler_Unit
1392 @unnumberedsec Pragma Compiler_Unit
1393 @findex Compiler_Unit
1394 @noindent
1395 Syntax:
1396
1397 @smallexample @c ada
1398 pragma Compiler_Unit;
1399 @end smallexample
1400
1401 @noindent
1402 This pragma is intended only for internal use in the GNAT run-time library.
1403 It indicates that the unit is used as part of the compiler build. The effect
1404 is to disallow constructs (raise with message, conditional expressions etc)
1405 that would cause trouble when bootstrapping using an older version of GNAT.
1406 For the exact list of restrictions, see the compiler sources and references
1407 to Is_Compiler_Unit.
1408
1409 @node Pragma Complete_Representation
1410 @unnumberedsec Pragma Complete_Representation
1411 @findex Complete_Representation
1412 @noindent
1413 Syntax:
1414
1415 @smallexample @c ada
1416 pragma Complete_Representation;
1417 @end smallexample
1418
1419 @noindent
1420 This pragma must appear immediately within a record representation
1421 clause. Typical placements are before the first component clause
1422 or after the last component clause. The effect is to give an error
1423 message if any component is missing a component clause. This pragma
1424 may be used to ensure that a record representation clause is
1425 complete, and that this invariant is maintained if fields are
1426 added to the record in the future.
1427
1428 @node Pragma Complex_Representation
1429 @unnumberedsec Pragma Complex_Representation
1430 @findex Complex_Representation
1431 @noindent
1432 Syntax:
1433
1434 @smallexample @c ada
1435 pragma Complex_Representation
1436         ([Entity =>] LOCAL_NAME);
1437 @end smallexample
1438
1439 @noindent
1440 The @var{Entity} argument must be the name of a record type which has
1441 two fields of the same floating-point type.  The effect of this pragma is
1442 to force gcc to use the special internal complex representation form for
1443 this record, which may be more efficient.  Note that this may result in
1444 the code for this type not conforming to standard ABI (application
1445 binary interface) requirements for the handling of record types.  For
1446 example, in some environments, there is a requirement for passing
1447 records by pointer, and the use of this pragma may result in passing
1448 this type in floating-point registers.
1449
1450 @node Pragma Component_Alignment
1451 @unnumberedsec Pragma Component_Alignment
1452 @cindex Alignments of components
1453 @findex Component_Alignment
1454 @noindent
1455 Syntax:
1456
1457 @smallexample @c ada
1458 pragma Component_Alignment (
1459      [Form =>] ALIGNMENT_CHOICE
1460   [, [Name =>] type_LOCAL_NAME]);
1461
1462 ALIGNMENT_CHOICE ::=
1463   Component_Size
1464 | Component_Size_4
1465 | Storage_Unit
1466 | Default
1467 @end smallexample
1468
1469 @noindent
1470 Specifies the alignment of components in array or record types.
1471 The meaning of the @var{Form} argument is as follows:
1472
1473 @table @code
1474 @findex Component_Size
1475 @item Component_Size
1476 Aligns scalar components and subcomponents of the array or record type
1477 on boundaries appropriate to their inherent size (naturally
1478 aligned).  For example, 1-byte components are aligned on byte boundaries,
1479 2-byte integer components are aligned on 2-byte boundaries, 4-byte
1480 integer components are aligned on 4-byte boundaries and so on.  These
1481 alignment rules correspond to the normal rules for C compilers on all
1482 machines except the VAX@.
1483
1484 @findex Component_Size_4
1485 @item Component_Size_4
1486 Naturally aligns components with a size of four or fewer
1487 bytes.  Components that are larger than 4 bytes are placed on the next
1488 4-byte boundary.
1489
1490 @findex Storage_Unit
1491 @item Storage_Unit
1492 Specifies that array or record components are byte aligned, i.e.@:
1493 aligned on boundaries determined by the value of the constant
1494 @code{System.Storage_Unit}.
1495
1496 @cindex OpenVMS
1497 @item Default
1498 Specifies that array or record components are aligned on default
1499 boundaries, appropriate to the underlying hardware or operating system or
1500 both.  For OpenVMS VAX systems, the @code{Default} choice is the same as
1501 the @code{Storage_Unit} choice (byte alignment).  For all other systems,
1502 the @code{Default} choice is the same as @code{Component_Size} (natural
1503 alignment).
1504 @end table
1505
1506 @noindent
1507 If the @code{Name} parameter is present, @var{type_LOCAL_NAME} must
1508 refer to a local record or array type, and the specified alignment
1509 choice applies to the specified type.  The use of
1510 @code{Component_Alignment} together with a pragma @code{Pack} causes the
1511 @code{Component_Alignment} pragma to be ignored.  The use of
1512 @code{Component_Alignment} together with a record representation clause
1513 is only effective for fields not specified by the representation clause.
1514
1515 If the @code{Name} parameter is absent, the pragma can be used as either
1516 a configuration pragma, in which case it applies to one or more units in
1517 accordance with the normal rules for configuration pragmas, or it can be
1518 used within a declarative part, in which case it applies to types that
1519 are declared within this declarative part, or within any nested scope
1520 within this declarative part.  In either case it specifies the alignment
1521 to be applied to any record or array type which has otherwise standard
1522 representation.
1523
1524 If the alignment for a record or array type is not specified (using
1525 pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
1526 clause), the GNAT uses the default alignment as described previously.
1527
1528 @node Pragma Convention_Identifier
1529 @unnumberedsec Pragma Convention_Identifier
1530 @findex Convention_Identifier
1531 @cindex Conventions, synonyms
1532 @noindent
1533 Syntax:
1534
1535 @smallexample @c ada
1536 pragma Convention_Identifier (
1537          [Name =>]       IDENTIFIER,
1538          [Convention =>] convention_IDENTIFIER);
1539 @end smallexample
1540
1541 @noindent
1542 This pragma provides a mechanism for supplying synonyms for existing
1543 convention identifiers. The @code{Name} identifier can subsequently
1544 be used as a synonym for the given convention in other pragmas (including
1545 for example pragma @code{Import} or another @code{Convention_Identifier}
1546 pragma). As an example of the use of this, suppose you had legacy code
1547 which used Fortran77 as the identifier for Fortran. Then the pragma:
1548
1549 @smallexample @c ada
1550 pragma Convention_Identifier (Fortran77, Fortran);
1551 @end smallexample
1552
1553 @noindent
1554 would allow the use of the convention identifier @code{Fortran77} in
1555 subsequent code, avoiding the need to modify the sources. As another
1556 example, you could use this to parameterize convention requirements
1557 according to systems. Suppose you needed to use @code{Stdcall} on
1558 windows systems, and @code{C} on some other system, then you could
1559 define a convention identifier @code{Library} and use a single
1560 @code{Convention_Identifier} pragma to specify which convention
1561 would be used system-wide.
1562
1563 @node Pragma CPP_Class
1564 @unnumberedsec Pragma CPP_Class
1565 @findex CPP_Class
1566 @cindex Interfacing with C++
1567 @noindent
1568 Syntax:
1569
1570 @smallexample @c ada
1571 pragma CPP_Class ([Entity =>] LOCAL_NAME);
1572 @end smallexample
1573
1574 @noindent
1575 The argument denotes an entity in the current declarative region that is
1576 declared as a record type. It indicates that the type corresponds to an
1577 externally declared C++ class type, and is to be laid out the same way
1578 that C++ would lay out the type. If the C++ class has virtual primitives
1579 then the record must be declared as a tagged record type.
1580
1581 Types for which @code{CPP_Class} is specified do not have assignment or
1582 equality operators defined (such operations can be imported or declared
1583 as subprograms as required). Initialization is allowed only by constructor
1584 functions (see pragma @code{CPP_Constructor}). Such types are implicitly
1585 limited if not explicitly declared as limited or derived from a limited
1586 type, and an error is issued in that case.
1587
1588 Pragma @code{CPP_Class} is intended primarily for automatic generation
1589 using an automatic binding generator tool.
1590 See @ref{Interfacing to C++} for related information.
1591
1592 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
1593 for backward compatibility but its functionality is available
1594 using pragma @code{Import} with @code{Convention} = @code{CPP}.
1595
1596 @node Pragma CPP_Constructor
1597 @unnumberedsec Pragma CPP_Constructor
1598 @cindex Interfacing with C++
1599 @findex CPP_Constructor
1600 @noindent
1601 Syntax:
1602
1603 @smallexample @c ada
1604 pragma CPP_Constructor ([Entity =>] LOCAL_NAME
1605   [, [External_Name =>] static_string_EXPRESSION ]
1606   [, [Link_Name     =>] static_string_EXPRESSION ]);
1607 @end smallexample
1608
1609 @noindent
1610 This pragma identifies an imported function (imported in the usual way
1611 with pragma @code{Import}) as corresponding to a C++ constructor. If
1612 @code{External_Name} and @code{Link_Name} are not specified then the
1613 @code{Entity} argument is a name that must have been previously mentioned
1614 in a pragma @code{Import} with @code{Convention} = @code{CPP}. Such name
1615 must be of one of the following forms:
1616
1617 @itemize @bullet
1618 @item
1619 @code{function @var{Fname} return @var{T}}
1620
1621 @itemize @bullet
1622 @item
1623 @code{function @var{Fname} return @var{T}'Class}
1624
1625 @item
1626 @code{function @var{Fname} (@dots{}) return @var{T}}
1627 @end itemize
1628
1629 @item
1630 @code{function @var{Fname} (@dots{}) return @var{T}'Class}
1631 @end itemize
1632
1633 @noindent
1634 where @var{T} is a limited record type imported from C++ with pragma
1635 @code{Import} and @code{Convention} = @code{CPP}.
1636
1637 The first two forms import the default constructor, used when an object
1638 of type @var{T} is created on the Ada side with no explicit constructor.
1639 The latter two forms cover all the non-default constructors of the type.
1640 See the GNAT users guide for details.
1641
1642 If no constructors are imported, it is impossible to create any objects
1643 on the Ada side and the type is implicitly declared abstract.
1644
1645 Pragma @code{CPP_Constructor} is intended primarily for automatic generation
1646 using an automatic binding generator tool.
1647 See @ref{Interfacing to C++} for more related information.
1648
1649 Note: The use of functions returning class-wide types for constructors is
1650 currently obsolete. They are supported for backward compatibility. The
1651 use of functions returning the type T leave the Ada sources more clear
1652 because the imported C++ constructors always return an object of type T;
1653 that is, they never return an object whose type is a descendant of type T.
1654
1655 @node Pragma CPP_Virtual
1656 @unnumberedsec Pragma CPP_Virtual
1657 @cindex Interfacing to C++
1658 @findex CPP_Virtual
1659 @noindent
1660 This pragma is now obsolete has has no effect because GNAT generates
1661 the same object layout than the G++ compiler.
1662
1663 See @ref{Interfacing to C++} for related information.
1664
1665 @node Pragma CPP_Vtable
1666 @unnumberedsec Pragma CPP_Vtable
1667 @cindex Interfacing with C++
1668 @findex CPP_Vtable
1669 @noindent
1670 This pragma is now obsolete has has no effect because GNAT generates
1671 the same object layout than the G++ compiler.
1672
1673 See @ref{Interfacing to C++} for related information.
1674
1675 @node Pragma Debug
1676 @unnumberedsec Pragma Debug
1677 @findex Debug
1678 @noindent
1679 Syntax:
1680
1681 @smallexample @c ada
1682 pragma Debug ([CONDITION, ]PROCEDURE_CALL_WITHOUT_SEMICOLON);
1683
1684 PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
1685   PROCEDURE_NAME
1686 | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
1687 @end smallexample
1688
1689 @noindent
1690 The procedure call argument has the syntactic form of an expression, meeting
1691 the syntactic requirements for pragmas.
1692
1693 If debug pragmas are not enabled or if the condition is present and evaluates
1694 to False, this pragma has no effect. If debug pragmas are enabled, the
1695 semantics of the pragma is exactly equivalent to the procedure call statement
1696 corresponding to the argument with a terminating semicolon. Pragmas are
1697 permitted in sequences of declarations, so you can use pragma @code{Debug} to
1698 intersperse calls to debug procedures in the middle of declarations. Debug
1699 pragmas can be enabled either by use of the command line switch @option{-gnata}
1700 or by use of the configuration pragma @code{Debug_Policy}.
1701
1702 @node Pragma Debug_Policy
1703 @unnumberedsec Pragma Debug_Policy
1704 @findex Debug_Policy
1705 @noindent
1706 Syntax:
1707
1708 @smallexample @c ada
1709 pragma Debug_Policy (CHECK | IGNORE);
1710 @end smallexample
1711
1712 @noindent
1713 If the argument is @code{CHECK}, then pragma @code{DEBUG} is enabled.
1714 If the argument is @code{IGNORE}, then pragma @code{DEBUG} is ignored.
1715 This pragma overrides the effect of the @option{-gnata} switch on the
1716 command line.
1717
1718 @node Pragma Detect_Blocking
1719 @unnumberedsec Pragma Detect_Blocking
1720 @findex Detect_Blocking
1721 @noindent
1722 Syntax:
1723
1724 @smallexample @c ada
1725 pragma Detect_Blocking;
1726 @end smallexample
1727
1728 @noindent
1729 This is a configuration pragma that forces the detection of potentially
1730 blocking operations within a protected operation, and to raise Program_Error
1731 if that happens.
1732
1733 @node Pragma Elaboration_Checks
1734 @unnumberedsec Pragma Elaboration_Checks
1735 @cindex Elaboration control
1736 @findex Elaboration_Checks
1737 @noindent
1738 Syntax:
1739
1740 @smallexample @c ada
1741 pragma Elaboration_Checks (Dynamic | Static);
1742 @end smallexample
1743
1744 @noindent
1745 This is a configuration pragma that provides control over the
1746 elaboration model used by the compilation affected by the
1747 pragma.  If the parameter is @code{Dynamic},
1748 then the dynamic elaboration
1749 model described in the Ada Reference Manual is used, as though
1750 the @option{-gnatE} switch had been specified on the command
1751 line.  If the parameter is @code{Static}, then the default GNAT static
1752 model is used.  This configuration pragma overrides the setting
1753 of the command line.  For full details on the elaboration models
1754 used by the GNAT compiler, see @ref{Elaboration Order Handling in GNAT,,,
1755 gnat_ugn, @value{EDITION} User's Guide}.
1756
1757 @node Pragma Eliminate
1758 @unnumberedsec Pragma Eliminate
1759 @cindex Elimination of unused subprograms
1760 @findex Eliminate
1761 @noindent
1762 Syntax:
1763
1764 @smallexample @c ada
1765 pragma Eliminate (UNIT_NAME, ENTITY, Source_Location => SOURCE_TRACE)
1766
1767 UNIT_NAME        ::= IDENTIFIER |
1768                      SELECTED_COMPONENT,
1769
1770 ENTITY           ::= IDENTIFIER |
1771                      SELECTED_COMPONENT,
1772
1773 SOURCE_TRACE     ::= SOURCE_REFERENCE |
1774                      SOURCE_REFERENCE LBRACKET SOURCE_TRACE RBRACKET
1775
1776 LBRACKET         ::= [
1777 RBRACKET         ::= ]
1778
1779 SOURCE_REFERENCE ::= FILE_NAME : LINE_NUMBER
1780
1781 FILE_NAME        ::= STRING_LITERAL
1782 LINE_NUMBER      ::= INTEGER_LITERAL
1783 @end smallexample
1784
1785 @noindent
1786 This pragma indicates that the given entity is not used in the program
1787 to be compiled and built. The entity must be an explicitly declared
1788 subprogram; this includes generic subprogram instances and
1789 subprograms declared in generic package instances. @code{Unit_Name}
1790 must be the name of the compilation unit in which the entity is declared.
1791
1792 The @code{Source_Location} argument is used to resolve overloading
1793 in case more then one callable entity with the same name is declared
1794 in the given compilation unit. Each file name must be the short name of the
1795 source file (with no directory information).
1796 If an entity is not declared in
1797 a generic instantiation (this includes generic subprogram instances),
1798 the source trace includes only one source
1799 reference. If an entity is declared inside a generic instantiation,
1800 its source trace starts from the source location in the instantiation and
1801 ends with the source location of the declaration of the corresponding
1802 entity in the generic
1803 unit. This approach is recursively used in case of nested instantiations:
1804 the leftmost element of the
1805 source trace is the location of the outermost instantiation, the next
1806 element is the location of the next (first nested) instantiation in the
1807 code of the corresponding generic unit, and so on.
1808
1809 The effect of the pragma is to allow the compiler to eliminate
1810 the code or data associated with the named entity.  Any reference to
1811 an eliminated entity outside the compilation unit where it is defined
1812 causes a compile-time or link-time error.
1813
1814 The intention of pragma @code{Eliminate} is to allow a program to be compiled
1815 in a system-independent manner, with unused entities eliminated, without
1816 needing to modify the source text.  Normally the required set
1817 of @code{Eliminate} pragmas is constructed automatically using the gnatelim
1818 tool. Elimination of unused entities local to a compilation unit is
1819 automatic, without requiring the use of pragma @code{Eliminate}.
1820
1821 Any source file change that removes, splits, or
1822 adds lines may make the set of Eliminate pragmas invalid because their
1823 @code{Source_Location} argument values may get out of date.
1824
1825 Pragma Eliminate may be used where the referenced entity is a
1826 dispatching operation. In this case all the subprograms to which the
1827 given operation can dispatch are considered to be unused (are never called
1828 as a result of a direct or a dispatching call).
1829
1830 @node Pragma Export_Exception
1831 @unnumberedsec Pragma Export_Exception
1832 @cindex OpenVMS
1833 @findex Export_Exception
1834 @noindent
1835 Syntax:
1836
1837 @smallexample @c ada
1838 pragma Export_Exception (
1839      [Internal =>] LOCAL_NAME
1840   [, [External =>] EXTERNAL_SYMBOL]
1841   [, [Form     =>] Ada | VMS]
1842   [, [Code     =>] static_integer_EXPRESSION]);
1843
1844 EXTERNAL_SYMBOL ::=
1845   IDENTIFIER
1846 | static_string_EXPRESSION
1847 @end smallexample
1848
1849 @noindent
1850 This pragma is implemented only in the OpenVMS implementation of GNAT@.  It
1851 causes the specified exception to be propagated outside of the Ada program,
1852 so that it can be handled by programs written in other OpenVMS languages.
1853 This pragma establishes an external name for an Ada exception and makes the
1854 name available to the OpenVMS Linker as a global symbol.  For further details
1855 on this pragma, see the
1856 DEC Ada Language Reference Manual, section 13.9a3.2.
1857
1858 @node Pragma Export_Function
1859 @unnumberedsec Pragma Export_Function
1860 @cindex Argument passing mechanisms
1861 @findex Export_Function
1862
1863 @noindent
1864 Syntax:
1865
1866 @smallexample @c ada
1867 pragma Export_Function (
1868      [Internal         =>] LOCAL_NAME
1869   [, [External         =>] EXTERNAL_SYMBOL]
1870   [, [Parameter_Types  =>] PARAMETER_TYPES]
1871   [, [Result_Type      =>] result_SUBTYPE_MARK]
1872   [, [Mechanism        =>] MECHANISM]
1873   [, [Result_Mechanism =>] MECHANISM_NAME]);
1874
1875 EXTERNAL_SYMBOL ::=
1876   IDENTIFIER
1877 | static_string_EXPRESSION
1878 | ""
1879
1880 PARAMETER_TYPES ::=
1881   null
1882 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1883
1884 TYPE_DESIGNATOR ::=
1885   subtype_NAME
1886 | subtype_Name ' Access
1887
1888 MECHANISM ::=
1889   MECHANISM_NAME
1890 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1891
1892 MECHANISM_ASSOCIATION ::=
1893   [formal_parameter_NAME =>] MECHANISM_NAME
1894
1895 MECHANISM_NAME ::=
1896   Value
1897 | Reference
1898 | Descriptor [([Class =>] CLASS_NAME)]
1899 | Short_Descriptor [([Class =>] CLASS_NAME)]
1900
1901 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
1902 @end smallexample
1903
1904 @noindent
1905 Use this pragma to make a function externally callable and optionally
1906 provide information on mechanisms to be used for passing parameter and
1907 result values.  We recommend, for the purposes of improving portability,
1908 this pragma always be used in conjunction with a separate pragma
1909 @code{Export}, which must precede the pragma @code{Export_Function}.
1910 GNAT does not require a separate pragma @code{Export}, but if none is
1911 present, @code{Convention Ada} is assumed, which is usually
1912 not what is wanted, so it is usually appropriate to use this
1913 pragma in conjunction with a @code{Export} or @code{Convention}
1914 pragma that specifies the desired foreign convention.
1915 Pragma @code{Export_Function}
1916 (and @code{Export}, if present) must appear in the same declarative
1917 region as the function to which they apply.
1918
1919 @var{internal_name} must uniquely designate the function to which the
1920 pragma applies.  If more than one function name exists of this name in
1921 the declarative part you must use the @code{Parameter_Types} and
1922 @code{Result_Type} parameters is mandatory to achieve the required
1923 unique designation.  @var{subtype_mark}s in these parameters must
1924 exactly match the subtypes in the corresponding function specification,
1925 using positional notation to match parameters with subtype marks.
1926 The form with an @code{'Access} attribute can be used to match an
1927 anonymous access parameter.
1928
1929 @cindex OpenVMS
1930 @cindex Passing by descriptor
1931 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
1932 The default behavior for Export_Function is to accept either 64bit or
1933 32bit descriptors unless short_descriptor is specified, then only 32bit
1934 descriptors are accepted.
1935
1936 @cindex Suppressing external name
1937 Special treatment is given if the EXTERNAL is an explicit null
1938 string or a static string expressions that evaluates to the null
1939 string. In this case, no external name is generated. This form
1940 still allows the specification of parameter mechanisms.
1941
1942 @node Pragma Export_Object
1943 @unnumberedsec Pragma Export_Object
1944 @findex Export_Object
1945 @noindent
1946 Syntax:
1947
1948 @smallexample @c ada
1949 pragma Export_Object
1950       [Internal =>] LOCAL_NAME
1951    [, [External =>] EXTERNAL_SYMBOL]
1952    [, [Size     =>] EXTERNAL_SYMBOL]
1953
1954 EXTERNAL_SYMBOL ::=
1955   IDENTIFIER
1956 | static_string_EXPRESSION
1957 @end smallexample
1958
1959 @noindent
1960 This pragma designates an object as exported, and apart from the
1961 extended rules for external symbols, is identical in effect to the use of
1962 the normal @code{Export} pragma applied to an object.  You may use a
1963 separate Export pragma (and you probably should from the point of view
1964 of portability), but it is not required.  @var{Size} is syntax checked,
1965 but otherwise ignored by GNAT@.
1966
1967 @node Pragma Export_Procedure
1968 @unnumberedsec Pragma Export_Procedure
1969 @findex Export_Procedure
1970 @noindent
1971 Syntax:
1972
1973 @smallexample @c ada
1974 pragma Export_Procedure (
1975      [Internal        =>] LOCAL_NAME
1976   [, [External        =>] EXTERNAL_SYMBOL]
1977   [, [Parameter_Types =>] PARAMETER_TYPES]
1978   [, [Mechanism       =>] MECHANISM]);
1979
1980 EXTERNAL_SYMBOL ::=
1981   IDENTIFIER
1982 | static_string_EXPRESSION
1983 | ""
1984
1985 PARAMETER_TYPES ::=
1986   null
1987 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1988
1989 TYPE_DESIGNATOR ::=
1990   subtype_NAME
1991 | subtype_Name ' Access
1992
1993 MECHANISM ::=
1994   MECHANISM_NAME
1995 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1996
1997 MECHANISM_ASSOCIATION ::=
1998   [formal_parameter_NAME =>] MECHANISM_NAME
1999
2000 MECHANISM_NAME ::=
2001   Value
2002 | Reference
2003 | Descriptor [([Class =>] CLASS_NAME)]
2004 | Short_Descriptor [([Class =>] CLASS_NAME)]
2005
2006 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2007 @end smallexample
2008
2009 @noindent
2010 This pragma is identical to @code{Export_Function} except that it
2011 applies to a procedure rather than a function and the parameters
2012 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2013 GNAT does not require a separate pragma @code{Export}, but if none is
2014 present, @code{Convention Ada} is assumed, which is usually
2015 not what is wanted, so it is usually appropriate to use this
2016 pragma in conjunction with a @code{Export} or @code{Convention}
2017 pragma that specifies the desired foreign convention.
2018
2019 @cindex OpenVMS
2020 @cindex Passing by descriptor
2021 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2022 The default behavior for Export_Procedure is to accept either 64bit or
2023 32bit descriptors unless short_descriptor is specified, then only 32bit
2024 descriptors are accepted.
2025
2026 @cindex Suppressing external name
2027 Special treatment is given if the EXTERNAL is an explicit null
2028 string or a static string expressions that evaluates to the null
2029 string. In this case, no external name is generated. This form
2030 still allows the specification of parameter mechanisms.
2031
2032 @node Pragma Export_Value
2033 @unnumberedsec Pragma Export_Value
2034 @findex Export_Value
2035 @noindent
2036 Syntax:
2037
2038 @smallexample @c ada
2039 pragma Export_Value (
2040   [Value     =>] static_integer_EXPRESSION,
2041   [Link_Name =>] static_string_EXPRESSION);
2042 @end smallexample
2043
2044 @noindent
2045 This pragma serves to export a static integer value for external use.
2046 The first argument specifies the value to be exported. The Link_Name
2047 argument specifies the symbolic name to be associated with the integer
2048 value. This pragma is useful for defining a named static value in Ada
2049 that can be referenced in assembly language units to be linked with
2050 the application. This pragma is currently supported only for the
2051 AAMP target and is ignored for other targets.
2052
2053 @node Pragma Export_Valued_Procedure
2054 @unnumberedsec Pragma Export_Valued_Procedure
2055 @findex Export_Valued_Procedure
2056 @noindent
2057 Syntax:
2058
2059 @smallexample @c ada
2060 pragma Export_Valued_Procedure (
2061      [Internal        =>] LOCAL_NAME
2062   [, [External        =>] EXTERNAL_SYMBOL]
2063   [, [Parameter_Types =>] PARAMETER_TYPES]
2064   [, [Mechanism       =>] MECHANISM]);
2065
2066 EXTERNAL_SYMBOL ::=
2067   IDENTIFIER
2068 | static_string_EXPRESSION
2069 | ""
2070
2071 PARAMETER_TYPES ::=
2072   null
2073 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2074
2075 TYPE_DESIGNATOR ::=
2076   subtype_NAME
2077 | subtype_Name ' Access
2078
2079 MECHANISM ::=
2080   MECHANISM_NAME
2081 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2082
2083 MECHANISM_ASSOCIATION ::=
2084   [formal_parameter_NAME =>] MECHANISM_NAME
2085
2086 MECHANISM_NAME ::=
2087   Value
2088 | Reference
2089 | Descriptor [([Class =>] CLASS_NAME)]
2090 | Short_Descriptor [([Class =>] CLASS_NAME)]
2091
2092 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2093 @end smallexample
2094
2095 @noindent
2096 This pragma is identical to @code{Export_Procedure} except that the
2097 first parameter of @var{LOCAL_NAME}, which must be present, must be of
2098 mode @code{OUT}, and externally the subprogram is treated as a function
2099 with this parameter as the result of the function.  GNAT provides for
2100 this capability to allow the use of @code{OUT} and @code{IN OUT}
2101 parameters in interfacing to external functions (which are not permitted
2102 in Ada functions).
2103 GNAT does not require a separate pragma @code{Export}, but if none is
2104 present, @code{Convention Ada} is assumed, which is almost certainly
2105 not what is wanted since the whole point of this pragma is to interface
2106 with foreign language functions, so it is usually appropriate to use this
2107 pragma in conjunction with a @code{Export} or @code{Convention}
2108 pragma that specifies the desired foreign convention.
2109
2110 @cindex OpenVMS
2111 @cindex Passing by descriptor
2112 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2113 The default behavior for Export_Valued_Procedure is to accept either 64bit or
2114 32bit descriptors unless short_descriptor is specified, then only 32bit
2115 descriptors are accepted.
2116
2117 @cindex Suppressing external name
2118 Special treatment is given if the EXTERNAL is an explicit null
2119 string or a static string expressions that evaluates to the null
2120 string. In this case, no external name is generated. This form
2121 still allows the specification of parameter mechanisms.
2122
2123 @node Pragma Extend_System
2124 @unnumberedsec Pragma Extend_System
2125 @cindex @code{system}, extending
2126 @cindex Dec Ada 83
2127 @findex Extend_System
2128 @noindent
2129 Syntax:
2130
2131 @smallexample @c ada
2132 pragma Extend_System ([Name =>] IDENTIFIER);
2133 @end smallexample
2134
2135 @noindent
2136 This pragma is used to provide backwards compatibility with other
2137 implementations that extend the facilities of package @code{System}.  In
2138 GNAT, @code{System} contains only the definitions that are present in
2139 the Ada RM@.  However, other implementations, notably the DEC Ada 83
2140 implementation, provide many extensions to package @code{System}.
2141
2142 For each such implementation accommodated by this pragma, GNAT provides a
2143 package @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83
2144 implementation, which provides the required additional definitions.  You
2145 can use this package in two ways.  You can @code{with} it in the normal
2146 way and access entities either by selection or using a @code{use}
2147 clause.  In this case no special processing is required.
2148
2149 However, if existing code contains references such as
2150 @code{System.@var{xxx}} where @var{xxx} is an entity in the extended
2151 definitions provided in package @code{System}, you may use this pragma
2152 to extend visibility in @code{System} in a non-standard way that
2153 provides greater compatibility with the existing code.  Pragma
2154 @code{Extend_System} is a configuration pragma whose single argument is
2155 the name of the package containing the extended definition
2156 (e.g.@: @code{Aux_DEC} for the DEC Ada case).  A unit compiled under
2157 control of this pragma will be processed using special visibility
2158 processing that looks in package @code{System.Aux_@var{xxx}} where
2159 @code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
2160 package @code{System}, but not found in package @code{System}.
2161
2162 You can use this pragma either to access a predefined @code{System}
2163 extension supplied with the compiler, for example @code{Aux_DEC} or
2164 you can construct your own extension unit following the above
2165 definition.  Note that such a package is a child of @code{System}
2166 and thus is considered part of the implementation.  To compile
2167 it you will have to use the appropriate switch for compiling
2168 system units.
2169 @xref{Top, @value{EDITION} User's Guide, About This Guide, gnat_ugn, @value{EDITION} User's Guide},
2170 for details.
2171
2172 @node Pragma Extensions_Allowed
2173 @unnumberedsec Pragma Extensions_Allowed
2174 @cindex Ada Extensions
2175 @cindex GNAT Extensions
2176 @findex Extensions_Allowed
2177 @noindent
2178 Syntax:
2179
2180 @smallexample @c ada
2181 pragma Extensions_Allowed (On | Off);
2182 @end smallexample
2183
2184 @noindent
2185 This configuration pragma enables or disables the implementation
2186 extension mode (the use of Off as a parameter cancels the effect
2187 of the @option{-gnatX} command switch).
2188
2189 In extension mode, the latest version of the Ada language is
2190 implemented (currently Ada 2012), and in addition a small number
2191 of GNAT specific extensions are recognized as follows:
2192
2193 @table @asis
2194 @item Constrained attribute for generic objects
2195 The @code{Constrained} attribute is permitted for objects of
2196 generic types. The result indicates if the corresponding actual
2197 is constrained.
2198
2199 @end table
2200
2201 @node Pragma External
2202 @unnumberedsec Pragma External
2203 @findex External
2204 @noindent
2205 Syntax:
2206
2207 @smallexample @c ada
2208 pragma External (
2209   [   Convention    =>] convention_IDENTIFIER,
2210   [   Entity        =>] LOCAL_NAME
2211   [, [External_Name =>] static_string_EXPRESSION ]
2212   [, [Link_Name     =>] static_string_EXPRESSION ]);
2213 @end smallexample
2214
2215 @noindent
2216 This pragma is identical in syntax and semantics to pragma
2217 @code{Export} as defined in the Ada Reference Manual.  It is
2218 provided for compatibility with some Ada 83 compilers that
2219 used this pragma for exactly the same purposes as pragma
2220 @code{Export} before the latter was standardized.
2221
2222 @node Pragma External_Name_Casing
2223 @unnumberedsec Pragma External_Name_Casing
2224 @cindex Dec Ada 83 casing compatibility
2225 @cindex External Names, casing
2226 @cindex Casing of External names
2227 @findex External_Name_Casing
2228 @noindent
2229 Syntax:
2230
2231 @smallexample @c ada
2232 pragma External_Name_Casing (
2233   Uppercase | Lowercase
2234   [, Uppercase | Lowercase | As_Is]);
2235 @end smallexample
2236
2237 @noindent
2238 This pragma provides control over the casing of external names associated
2239 with Import and Export pragmas.  There are two cases to consider:
2240
2241 @table @asis
2242 @item Implicit external names
2243 Implicit external names are derived from identifiers.  The most common case
2244 arises when a standard Ada Import or Export pragma is used with only two
2245 arguments, as in:
2246
2247 @smallexample @c ada
2248    pragma Import (C, C_Routine);
2249 @end smallexample
2250
2251 @noindent
2252 Since Ada is a case-insensitive language, the spelling of the identifier in
2253 the Ada source program does not provide any information on the desired
2254 casing of the external name, and so a convention is needed.  In GNAT the
2255 default treatment is that such names are converted to all lower case
2256 letters.  This corresponds to the normal C style in many environments.
2257 The first argument of pragma @code{External_Name_Casing} can be used to
2258 control this treatment.  If @code{Uppercase} is specified, then the name
2259 will be forced to all uppercase letters.  If @code{Lowercase} is specified,
2260 then the normal default of all lower case letters will be used.
2261
2262 This same implicit treatment is also used in the case of extended DEC Ada 83
2263 compatible Import and Export pragmas where an external name is explicitly
2264 specified using an identifier rather than a string.
2265
2266 @item Explicit external names
2267 Explicit external names are given as string literals.  The most common case
2268 arises when a standard Ada Import or Export pragma is used with three
2269 arguments, as in:
2270
2271 @smallexample @c ada
2272 pragma Import (C, C_Routine, "C_routine");
2273 @end smallexample
2274
2275 @noindent
2276 In this case, the string literal normally provides the exact casing required
2277 for the external name.  The second argument of pragma
2278 @code{External_Name_Casing} may be used to modify this behavior.
2279 If @code{Uppercase} is specified, then the name
2280 will be forced to all uppercase letters.  If @code{Lowercase} is specified,
2281 then the name will be forced to all lowercase letters.  A specification of
2282 @code{As_Is} provides the normal default behavior in which the casing is
2283 taken from the string provided.
2284 @end table
2285
2286 @noindent
2287 This pragma may appear anywhere that a pragma is valid.  In particular, it
2288 can be used as a configuration pragma in the @file{gnat.adc} file, in which
2289 case it applies to all subsequent compilations, or it can be used as a program
2290 unit pragma, in which case it only applies to the current unit, or it can
2291 be used more locally to control individual Import/Export pragmas.
2292
2293 It is primarily intended for use with OpenVMS systems, where many
2294 compilers convert all symbols to upper case by default.  For interfacing to
2295 such compilers (e.g.@: the DEC C compiler), it may be convenient to use
2296 the pragma:
2297
2298 @smallexample @c ada
2299 pragma External_Name_Casing (Uppercase, Uppercase);
2300 @end smallexample
2301
2302 @noindent
2303 to enforce the upper casing of all external symbols.
2304
2305 @node Pragma Fast_Math
2306 @unnumberedsec Pragma Fast_Math
2307 @findex Fast_Math
2308 @noindent
2309 Syntax:
2310
2311 @smallexample @c ada
2312 pragma Fast_Math;
2313 @end smallexample
2314
2315 @noindent
2316 This is a configuration pragma which activates a mode in which speed is
2317 considered more important for floating-point operations than absolutely
2318 accurate adherence to the requirements of the standard. Currently the
2319 following operations are affected:
2320
2321 @table @asis
2322 @item Complex Multiplication
2323 The normal simple formula for complex multiplication can result in intermediate
2324 overflows for numbers near the end of the range. The Ada standard requires that
2325 this situation be detected and corrected by scaling, but in Fast_Math mode such
2326 cases will simply result in overflow. Note that to take advantage of this you
2327 must instantiate your own version of @code{Ada.Numerics.Generic_Complex_Types}
2328 under control of the pragma, rather than use the preinstantiated versions.
2329 @end table
2330
2331 @node Pragma Favor_Top_Level
2332 @unnumberedsec Pragma Favor_Top_Level
2333 @findex Favor_Top_Level
2334 @noindent
2335 Syntax:
2336
2337 @smallexample @c ada
2338 pragma Favor_Top_Level (type_NAME);
2339 @end smallexample
2340
2341 @noindent
2342 The named type must be an access-to-subprogram type. This pragma is an
2343 efficiency hint to the compiler, regarding the use of 'Access or
2344 'Unrestricted_Access on nested (non-library-level) subprograms. The
2345 pragma means that nested subprograms are not used with this type, or
2346 are rare, so that the generated code should be efficient in the
2347 top-level case. When this pragma is used, dynamically generated
2348 trampolines may be used on some targets for nested subprograms.
2349 See also the No_Implicit_Dynamic_Code restriction.
2350
2351 @node Pragma Finalize_Storage_Only
2352 @unnumberedsec Pragma Finalize_Storage_Only
2353 @findex Finalize_Storage_Only
2354 @noindent
2355 Syntax:
2356
2357 @smallexample @c ada
2358 pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
2359 @end smallexample
2360
2361 @noindent
2362 This pragma allows the compiler not to emit a Finalize call for objects
2363 defined at the library level.  This is mostly useful for types where
2364 finalization is only used to deal with storage reclamation since in most
2365 environments it is not necessary to reclaim memory just before terminating
2366 execution, hence the name.
2367
2368 @node Pragma Float_Representation
2369 @unnumberedsec Pragma Float_Representation
2370 @cindex OpenVMS
2371 @findex Float_Representation
2372 @noindent
2373 Syntax:
2374
2375 @smallexample @c ada
2376 pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
2377
2378 FLOAT_REP ::= VAX_Float | IEEE_Float
2379 @end smallexample
2380
2381 @noindent
2382 In the one argument form, this pragma is a configuration pragma which
2383 allows control over the internal representation chosen for the predefined
2384 floating point types declared in the packages @code{Standard} and
2385 @code{System}. On all systems other than OpenVMS, the argument must
2386 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2387 argument may be @code{VAX_Float} to specify the use of the VAX float
2388 format for the floating-point types in Standard. This requires that
2389 the standard runtime libraries be recompiled.
2390
2391 The two argument form specifies the representation to be used for
2392 the specified floating-point type. On all systems other than OpenVMS,
2393 the argument must
2394 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2395 argument may be @code{VAX_Float} to specify the use of the VAX float
2396 format, as follows:
2397
2398 @itemize @bullet
2399 @item
2400 For digits values up to 6, F float format will be used.
2401 @item
2402 For digits values from 7 to 9, D float format will be used.
2403 @item
2404 For digits values from 10 to 15, G float format will be used.
2405 @item
2406 Digits values above 15 are not allowed.
2407 @end itemize
2408
2409 @node Pragma Ident
2410 @unnumberedsec Pragma Ident
2411 @findex Ident
2412 @noindent
2413 Syntax:
2414
2415 @smallexample @c ada
2416 pragma Ident (static_string_EXPRESSION);
2417 @end smallexample
2418
2419 @noindent
2420 This pragma provides a string identification in the generated object file,
2421 if the system supports the concept of this kind of identification string.
2422 This pragma is allowed only in the outermost declarative part or
2423 declarative items of a compilation unit. If more than one @code{Ident}
2424 pragma is given, only the last one processed is effective.
2425 @cindex OpenVMS
2426 On OpenVMS systems, the effect of the pragma is identical to the effect of
2427 the DEC Ada 83 pragma of the same name. Note that in DEC Ada 83, the
2428 maximum allowed length is 31 characters, so if it is important to
2429 maintain compatibility with this compiler, you should obey this length
2430 limit.
2431
2432 @node Pragma Implemented
2433 @unnumberedsec Pragma Implemented
2434 @findex Implemented
2435 @noindent
2436 Syntax:
2437
2438 @smallexample @c ada
2439 pragma Implemented (procedure_LOCAL_NAME, implementation_kind);
2440
2441 implementation_kind ::= By_Entry | By_Protected_Procedure | By_Any
2442 @end smallexample
2443
2444 @noindent
2445 This is an Ada 2012 representation pragma which applies to protected, task
2446 and synchronized interface primitives. The use of pragma Implemented provides
2447 a way to impose a static requirement on the overriding opreration by adhering
2448 to one of the three implementation kids: entry, protected procedure or any of
2449 the above.
2450
2451 @smallexample @c ada
2452 type Synch_Iface is synchronized interface;
2453 procedure Prim_Op (Obj : in out Iface) is abstract;
2454 pragma Implemented (Prim_Op, By_Protected_Procedure);
2455
2456 protected type Prot_1 is new Synch_Iface with
2457    procedure Prim_Op;  --  Legal
2458 end Prot_1;
2459
2460 protected type Prot_2 is new Synch_Iface with
2461    entry Prim_Op;      --  Illegal
2462 end Prot_2;
2463
2464 task type Task_Typ is new Synch_Iface with
2465    entry Prim_Op;      --  Illegal
2466 end Task_Typ;
2467 @end smallexample
2468
2469 @noindent
2470 When applied to the procedure_or_entry_NAME of a requeue statement, pragma
2471 Implemented determines the runtime behavior of the requeue. Implementation kind
2472 By_Entry guarantees that the action of requeueing will procede from an entry to
2473 another entry. Implementation kind By_Protected_Procedure transforms the
2474 requeue into a dispatching call, thus eliminating the chance of blocking. Kind
2475 By_Any shares the behavior of By_Entry and By_Protected_Procedure depending on
2476 the target's overriding subprogram kind.
2477
2478 @node Pragma Implicit_Packing
2479 @unnumberedsec Pragma Implicit_Packing
2480 @findex Implicit_Packing
2481 @noindent
2482 Syntax:
2483
2484 @smallexample @c ada
2485 pragma Implicit_Packing;
2486 @end smallexample
2487
2488 @noindent
2489 This is a configuration pragma that requests implicit packing for packed
2490 arrays for which a size clause is given but no explicit pragma Pack or
2491 specification of Component_Size is present. It also applies to records
2492 where no record representation clause is present. Consider this example:
2493
2494 @smallexample @c ada
2495 type R is array (0 .. 7) of Boolean;
2496 for R'Size use 8;
2497 @end smallexample
2498
2499 @noindent
2500 In accordance with the recommendation in the RM (RM 13.3(53)), a Size clause
2501 does not change the layout of a composite object. So the Size clause in the
2502 above example is normally rejected, since the default layout of the array uses
2503 8-bit components, and thus the array requires a minimum of 64 bits.
2504
2505 If this declaration is compiled in a region of code covered by an occurrence
2506 of the configuration pragma Implicit_Packing, then the Size clause in this
2507 and similar examples will cause implicit packing and thus be accepted. For
2508 this implicit packing to occur, the type in question must be an array of small
2509 components whose size is known at compile time, and the Size clause must
2510 specify the exact size that corresponds to the length of the array multiplied
2511 by the size in bits of the component type.
2512 @cindex Array packing
2513
2514 Similarly, the following example shows the use in the record case
2515
2516 @smallexample @c ada
2517 type r is record
2518    a, b, c, d, e, f, g, h : boolean;
2519    chr                    : character;
2520 end record;
2521 for r'size use 16;
2522 @end smallexample
2523
2524 @noindent
2525 Without a pragma Pack, each Boolean field requires 8 bits, so the
2526 minimum size is 72 bits, but with a pragma Pack, 16 bits would be
2527 sufficient. The use of pragma Implciit_Packing allows this record
2528 declaration to compile without an explicit pragma Pack.
2529 @node Pragma Import_Exception
2530 @unnumberedsec Pragma Import_Exception
2531 @cindex OpenVMS
2532 @findex Import_Exception
2533 @noindent
2534 Syntax:
2535
2536 @smallexample @c ada
2537 pragma Import_Exception (
2538      [Internal =>] LOCAL_NAME
2539   [, [External =>] EXTERNAL_SYMBOL]
2540   [, [Form     =>] Ada | VMS]
2541   [, [Code     =>] static_integer_EXPRESSION]);
2542
2543 EXTERNAL_SYMBOL ::=
2544   IDENTIFIER
2545 | static_string_EXPRESSION
2546 @end smallexample
2547
2548 @noindent
2549 This pragma is implemented only in the OpenVMS implementation of GNAT@.
2550 It allows OpenVMS conditions (for example, from OpenVMS system services or
2551 other OpenVMS languages) to be propagated to Ada programs as Ada exceptions.
2552 The pragma specifies that the exception associated with an exception
2553 declaration in an Ada program be defined externally (in non-Ada code).
2554 For further details on this pragma, see the
2555 DEC Ada Language Reference Manual, section 13.9a.3.1.
2556
2557 @node Pragma Import_Function
2558 @unnumberedsec Pragma Import_Function
2559 @findex Import_Function
2560 @noindent
2561 Syntax:
2562
2563 @smallexample @c ada
2564 pragma Import_Function (
2565      [Internal                 =>] LOCAL_NAME,
2566   [, [External                 =>] EXTERNAL_SYMBOL]
2567   [, [Parameter_Types          =>] PARAMETER_TYPES]
2568   [, [Result_Type              =>] SUBTYPE_MARK]
2569   [, [Mechanism                =>] MECHANISM]
2570   [, [Result_Mechanism         =>] MECHANISM_NAME]
2571   [, [First_Optional_Parameter =>] IDENTIFIER]);
2572
2573 EXTERNAL_SYMBOL ::=
2574   IDENTIFIER
2575 | static_string_EXPRESSION
2576
2577 PARAMETER_TYPES ::=
2578   null
2579 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2580
2581 TYPE_DESIGNATOR ::=
2582   subtype_NAME
2583 | subtype_Name ' Access
2584
2585 MECHANISM ::=
2586   MECHANISM_NAME
2587 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2588
2589 MECHANISM_ASSOCIATION ::=
2590   [formal_parameter_NAME =>] MECHANISM_NAME
2591
2592 MECHANISM_NAME ::=
2593   Value
2594 | Reference
2595 | Descriptor [([Class =>] CLASS_NAME)]
2596 | Short_Descriptor [([Class =>] CLASS_NAME)]
2597
2598 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2599 @end smallexample
2600
2601 @noindent
2602 This pragma is used in conjunction with a pragma @code{Import} to
2603 specify additional information for an imported function.  The pragma
2604 @code{Import} (or equivalent pragma @code{Interface}) must precede the
2605 @code{Import_Function} pragma and both must appear in the same
2606 declarative part as the function specification.
2607
2608 The @var{Internal} argument must uniquely designate
2609 the function to which the
2610 pragma applies.  If more than one function name exists of this name in
2611 the declarative part you must use the @code{Parameter_Types} and
2612 @var{Result_Type} parameters to achieve the required unique
2613 designation.  Subtype marks in these parameters must exactly match the
2614 subtypes in the corresponding function specification, using positional
2615 notation to match parameters with subtype marks.
2616 The form with an @code{'Access} attribute can be used to match an
2617 anonymous access parameter.
2618
2619 You may optionally use the @var{Mechanism} and @var{Result_Mechanism}
2620 parameters to specify passing mechanisms for the
2621 parameters and result.  If you specify a single mechanism name, it
2622 applies to all parameters.  Otherwise you may specify a mechanism on a
2623 parameter by parameter basis using either positional or named
2624 notation.  If the mechanism is not specified, the default mechanism
2625 is used.
2626
2627 @cindex OpenVMS
2628 @cindex Passing by descriptor
2629 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2630 The default behavior for Import_Function is to pass a 64bit descriptor
2631 unless short_descriptor is specified, then a 32bit descriptor is passed.
2632
2633 @code{First_Optional_Parameter} applies only to OpenVMS ports of GNAT@.
2634 It specifies that the designated parameter and all following parameters
2635 are optional, meaning that they are not passed at the generated code
2636 level (this is distinct from the notion of optional parameters in Ada
2637 where the parameters are passed anyway with the designated optional
2638 parameters).  All optional parameters must be of mode @code{IN} and have
2639 default parameter values that are either known at compile time
2640 expressions, or uses of the @code{'Null_Parameter} attribute.
2641
2642 @node Pragma Import_Object
2643 @unnumberedsec Pragma Import_Object
2644 @findex Import_Object
2645 @noindent
2646 Syntax:
2647
2648 @smallexample @c ada
2649 pragma Import_Object
2650      [Internal =>] LOCAL_NAME
2651   [, [External =>] EXTERNAL_SYMBOL]
2652   [, [Size     =>] EXTERNAL_SYMBOL]);
2653
2654 EXTERNAL_SYMBOL ::=
2655   IDENTIFIER
2656 | static_string_EXPRESSION
2657 @end smallexample
2658
2659 @noindent
2660 This pragma designates an object as imported, and apart from the
2661 extended rules for external symbols, is identical in effect to the use of
2662 the normal @code{Import} pragma applied to an object.  Unlike the
2663 subprogram case, you need not use a separate @code{Import} pragma,
2664 although you may do so (and probably should do so from a portability
2665 point of view).  @var{size} is syntax checked, but otherwise ignored by
2666 GNAT@.
2667
2668 @node Pragma Import_Procedure
2669 @unnumberedsec Pragma Import_Procedure
2670 @findex Import_Procedure
2671 @noindent
2672 Syntax:
2673
2674 @smallexample @c ada
2675 pragma Import_Procedure (
2676      [Internal                 =>] LOCAL_NAME
2677   [, [External                 =>] EXTERNAL_SYMBOL]
2678   [, [Parameter_Types          =>] PARAMETER_TYPES]
2679   [, [Mechanism                =>] MECHANISM]
2680   [, [First_Optional_Parameter =>] IDENTIFIER]);
2681
2682 EXTERNAL_SYMBOL ::=
2683   IDENTIFIER
2684 | static_string_EXPRESSION
2685
2686 PARAMETER_TYPES ::=
2687   null
2688 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2689
2690 TYPE_DESIGNATOR ::=
2691   subtype_NAME
2692 | subtype_Name ' Access
2693
2694 MECHANISM ::=
2695   MECHANISM_NAME
2696 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2697
2698 MECHANISM_ASSOCIATION ::=
2699   [formal_parameter_NAME =>] MECHANISM_NAME
2700
2701 MECHANISM_NAME ::=
2702   Value
2703 | Reference
2704 | Descriptor [([Class =>] CLASS_NAME)]
2705 | Short_Descriptor [([Class =>] CLASS_NAME)]
2706
2707 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2708 @end smallexample
2709
2710 @noindent
2711 This pragma is identical to @code{Import_Function} except that it
2712 applies to a procedure rather than a function and the parameters
2713 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2714
2715 @node Pragma Import_Valued_Procedure
2716 @unnumberedsec Pragma Import_Valued_Procedure
2717 @findex Import_Valued_Procedure
2718 @noindent
2719 Syntax:
2720
2721 @smallexample @c ada
2722 pragma Import_Valued_Procedure (
2723      [Internal                 =>] LOCAL_NAME
2724   [, [External                 =>] EXTERNAL_SYMBOL]
2725   [, [Parameter_Types          =>] PARAMETER_TYPES]
2726   [, [Mechanism                =>] MECHANISM]
2727   [, [First_Optional_Parameter =>] IDENTIFIER]);
2728
2729 EXTERNAL_SYMBOL ::=
2730   IDENTIFIER
2731 | static_string_EXPRESSION
2732
2733 PARAMETER_TYPES ::=
2734   null
2735 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2736
2737 TYPE_DESIGNATOR ::=
2738   subtype_NAME
2739 | subtype_Name ' Access
2740
2741 MECHANISM ::=
2742   MECHANISM_NAME
2743 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2744
2745 MECHANISM_ASSOCIATION ::=
2746   [formal_parameter_NAME =>] MECHANISM_NAME
2747
2748 MECHANISM_NAME ::=
2749   Value
2750 | Reference
2751 | Descriptor [([Class =>] CLASS_NAME)]
2752 | Short_Descriptor [([Class =>] CLASS_NAME)]
2753
2754 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2755 @end smallexample
2756
2757 @noindent
2758 This pragma is identical to @code{Import_Procedure} except that the
2759 first parameter of @var{LOCAL_NAME}, which must be present, must be of
2760 mode @code{OUT}, and externally the subprogram is treated as a function
2761 with this parameter as the result of the function.  The purpose of this
2762 capability is to allow the use of @code{OUT} and @code{IN OUT}
2763 parameters in interfacing to external functions (which are not permitted
2764 in Ada functions).  You may optionally use the @code{Mechanism}
2765 parameters to specify passing mechanisms for the parameters.
2766 If you specify a single mechanism name, it applies to all parameters.
2767 Otherwise you may specify a mechanism on a parameter by parameter
2768 basis using either positional or named notation.  If the mechanism is not
2769 specified, the default mechanism is used.
2770
2771 Note that it is important to use this pragma in conjunction with a separate
2772 pragma Import that specifies the desired convention, since otherwise the
2773 default convention is Ada, which is almost certainly not what is required.
2774
2775 @node Pragma Initialize_Scalars
2776 @unnumberedsec Pragma Initialize_Scalars
2777 @findex Initialize_Scalars
2778 @cindex debugging with Initialize_Scalars
2779 @noindent
2780 Syntax:
2781
2782 @smallexample @c ada
2783 pragma Initialize_Scalars;
2784 @end smallexample
2785
2786 @noindent
2787 This pragma is similar to @code{Normalize_Scalars} conceptually but has
2788 two important differences.  First, there is no requirement for the pragma
2789 to be used uniformly in all units of a partition, in particular, it is fine
2790 to use this just for some or all of the application units of a partition,
2791 without needing to recompile the run-time library.
2792
2793 In the case where some units are compiled with the pragma, and some without,
2794 then a declaration of a variable where the type is defined in package
2795 Standard or is locally declared will always be subject to initialization,
2796 as will any declaration of a scalar variable.  For composite variables,
2797 whether the variable is initialized may also depend on whether the package
2798 in which the type of the variable is declared is compiled with the pragma.
2799
2800 The other important difference is that you can control the value used
2801 for initializing scalar objects.  At bind time, you can select several
2802 options for initialization. You can
2803 initialize with invalid values (similar to Normalize_Scalars, though for
2804 Initialize_Scalars it is not always possible to determine the invalid
2805 values in complex cases like signed component fields with non-standard
2806 sizes). You can also initialize with high or
2807 low values, or with a specified bit pattern.  See the users guide for binder
2808 options for specifying these cases.
2809
2810 This means that you can compile a program, and then without having to
2811 recompile the program, you can run it with different values being used
2812 for initializing otherwise uninitialized values, to test if your program
2813 behavior depends on the choice.  Of course the behavior should not change,
2814 and if it does, then most likely you have an erroneous reference to an
2815 uninitialized value.
2816
2817 It is even possible to change the value at execution time eliminating even
2818 the need to rebind with a different switch using an environment variable.
2819 See the GNAT users guide for details.
2820
2821 Note that pragma @code{Initialize_Scalars} is particularly useful in
2822 conjunction with the enhanced validity checking that is now provided
2823 in GNAT, which checks for invalid values under more conditions.
2824 Using this feature (see description of the @option{-gnatV} flag in the
2825 users guide) in conjunction with pragma @code{Initialize_Scalars}
2826 provides a powerful new tool to assist in the detection of problems
2827 caused by uninitialized variables.
2828
2829 Note: the use of @code{Initialize_Scalars} has a fairly extensive
2830 effect on the generated code. This may cause your code to be
2831 substantially larger. It may also cause an increase in the amount
2832 of stack required, so it is probably a good idea to turn on stack
2833 checking (see description of stack checking in the GNAT users guide)
2834 when using this pragma.
2835
2836 @node Pragma Inline_Always
2837 @unnumberedsec Pragma Inline_Always
2838 @findex Inline_Always
2839 @noindent
2840 Syntax:
2841
2842 @smallexample @c ada
2843 pragma Inline_Always (NAME [, NAME]);
2844 @end smallexample
2845
2846 @noindent
2847 Similar to pragma @code{Inline} except that inlining is not subject to
2848 the use of option @option{-gnatn} and the inlining happens regardless of
2849 whether this option is used.
2850
2851 @node Pragma Inline_Generic
2852 @unnumberedsec Pragma Inline_Generic
2853 @findex Inline_Generic
2854 @noindent
2855 Syntax:
2856
2857 @smallexample @c ada
2858 pragma Inline_Generic (generic_package_NAME);
2859 @end smallexample
2860
2861 @noindent
2862 This is implemented for compatibility with DEC Ada 83 and is recognized,
2863 but otherwise ignored, by GNAT@.  All generic instantiations are inlined
2864 by default when using GNAT@.
2865
2866 @node Pragma Interface
2867 @unnumberedsec Pragma Interface
2868 @findex Interface
2869 @noindent
2870 Syntax:
2871
2872 @smallexample @c ada
2873 pragma Interface (
2874      [Convention    =>] convention_identifier,
2875      [Entity        =>] local_NAME
2876   [, [External_Name =>] static_string_expression]
2877   [, [Link_Name     =>] static_string_expression]);
2878 @end smallexample
2879
2880 @noindent
2881 This pragma is identical in syntax and semantics to
2882 the standard Ada pragma @code{Import}.  It is provided for compatibility
2883 with Ada 83.  The definition is upwards compatible both with pragma
2884 @code{Interface} as defined in the Ada 83 Reference Manual, and also
2885 with some extended implementations of this pragma in certain Ada 83
2886 implementations.  The only difference between pragma @code{Interface}
2887 and pragma @code{Import} is that there is special circuitry to allow
2888 both pragmas to appear for the same subprogram entity (normally it
2889 is illegal to have multiple @code{Import} pragmas. This is useful in
2890 maintaining Ada 83/Ada 95 compatibility and is compatible with other
2891 Ada 83 compilers.
2892
2893 @node Pragma Interface_Name
2894 @unnumberedsec Pragma Interface_Name
2895 @findex Interface_Name
2896 @noindent
2897 Syntax:
2898
2899 @smallexample @c ada
2900 pragma Interface_Name (
2901      [Entity        =>] LOCAL_NAME
2902   [, [External_Name =>] static_string_EXPRESSION]
2903   [, [Link_Name     =>] static_string_EXPRESSION]);
2904 @end smallexample
2905
2906 @noindent
2907 This pragma provides an alternative way of specifying the interface name
2908 for an interfaced subprogram, and is provided for compatibility with Ada
2909 83 compilers that use the pragma for this purpose.  You must provide at
2910 least one of @var{External_Name} or @var{Link_Name}.
2911
2912 @node Pragma Interrupt_Handler
2913 @unnumberedsec Pragma Interrupt_Handler
2914 @findex Interrupt_Handler
2915 @noindent
2916 Syntax:
2917
2918 @smallexample @c ada
2919 pragma Interrupt_Handler (procedure_LOCAL_NAME);
2920 @end smallexample
2921
2922 @noindent
2923 This program unit pragma is supported for parameterless protected procedures
2924 as described in Annex C of the Ada Reference Manual. On the AAMP target
2925 the pragma can also be specified for nonprotected parameterless procedures
2926 that are declared at the library level (which includes procedures
2927 declared at the top level of a library package). In the case of AAMP,
2928 when this pragma is applied to a nonprotected procedure, the instruction
2929 @code{IERET} is generated for returns from the procedure, enabling
2930 maskable interrupts, in place of the normal return instruction.
2931
2932 @node Pragma Interrupt_State
2933 @unnumberedsec Pragma Interrupt_State
2934 @findex Interrupt_State
2935 @noindent
2936 Syntax:
2937
2938 @smallexample @c ada
2939 pragma Interrupt_State
2940  ([Name  =>] value,
2941   [State =>] SYSTEM | RUNTIME | USER);
2942 @end smallexample
2943
2944 @noindent
2945 Normally certain interrupts are reserved to the implementation.  Any attempt
2946 to attach an interrupt causes Program_Error to be raised, as described in
2947 RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
2948 many systems for an @kbd{Ctrl-C} interrupt.  Normally this interrupt is
2949 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
2950 interrupt execution.  Additionally, signals such as @code{SIGSEGV},
2951 @code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
2952 Ada exceptions, or used to implement run-time functions such as the
2953 @code{abort} statement and stack overflow checking.
2954
2955 Pragma @code{Interrupt_State} provides a general mechanism for overriding
2956 such uses of interrupts.  It subsumes the functionality of pragma
2957 @code{Unreserve_All_Interrupts}.  Pragma @code{Interrupt_State} is not
2958 available on Windows or VMS.  On all other platforms than VxWorks,
2959 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
2960 and may be used to mark interrupts required by the board support package
2961 as reserved.
2962
2963 Interrupts can be in one of three states:
2964 @itemize @bullet
2965 @item System
2966
2967 The interrupt is reserved (no Ada handler can be installed), and the
2968 Ada run-time may not install a handler. As a result you are guaranteed
2969 standard system default action if this interrupt is raised.
2970
2971 @item Runtime
2972
2973 The interrupt is reserved (no Ada handler can be installed). The run time
2974 is allowed to install a handler for internal control purposes, but is
2975 not required to do so.
2976
2977 @item User
2978
2979 The interrupt is unreserved.  The user may install a handler to provide
2980 some other action.
2981 @end itemize
2982
2983 @noindent
2984 These states are the allowed values of the @code{State} parameter of the
2985 pragma.  The @code{Name} parameter is a value of the type
2986 @code{Ada.Interrupts.Interrupt_ID}.  Typically, it is a name declared in
2987 @code{Ada.Interrupts.Names}.
2988
2989 This is a configuration pragma, and the binder will check that there
2990 are no inconsistencies between different units in a partition in how a
2991 given interrupt is specified. It may appear anywhere a pragma is legal.
2992
2993 The effect is to move the interrupt to the specified state.
2994
2995 By declaring interrupts to be SYSTEM, you guarantee the standard system
2996 action, such as a core dump.
2997
2998 By declaring interrupts to be USER, you guarantee that you can install
2999 a handler.
3000
3001 Note that certain signals on many operating systems cannot be caught and
3002 handled by applications.  In such cases, the pragma is ignored.  See the
3003 operating system documentation, or the value of the array @code{Reserved}
3004 declared in the spec of package @code{System.OS_Interface}.
3005
3006 Overriding the default state of signals used by the Ada runtime may interfere
3007 with an application's runtime behavior in the cases of the synchronous signals,
3008 and in the case of the signal used to implement the @code{abort} statement.
3009
3010 @node Pragma Invariant
3011 @unnumberedsec Pragma Invariant
3012 @findex Invariant
3013 @noindent
3014 Syntax:
3015
3016 @smallexample @c ada
3017 pragma Invariant
3018   ([Entity =>]    private_type_LOCAL_NAME,
3019    [Check  =>]    EXPRESSION
3020    [,[Message =>] String_Expression]);
3021 @end smallexample
3022
3023 @noindent
3024 This pragma provides exactly the same capabilities as the Invariant aspect
3025 defined in AI05-0146-1, and in the Ada 2012 Reference Manual. The Invariant
3026 aspect is fully implemented in Ada 2012 mode, but since it requires the use
3027 of the aspect syntax, which is not available exception in 2012 mode, it is
3028 not possible to use the Invariant aspect in earlier versions of Ada. However
3029 the Invariant pragma may be used in any version of Ada.
3030
3031 The pragma must appear within the visible part of the package specification,
3032 after the type to which its Entity argument appears. As with the Invariant
3033 aspect, the Check expression is not analyzed until the end of the visible
3034 part of the package, so it may contain forward references. The Message
3035 argument, if present, provides the exception message used if the invariant
3036 is violated. If no Message parameter is provided, a default message that
3037 identifies the line on which the pragma appears is used.
3038
3039 It is permissible to have multiple Invariants for the same type entity, in
3040 which case they are and'ed together. It is permissible to use this pragma
3041 in Ada 2012 mode, but you cannot have both an invariant aspect and an
3042 invariant pragma for the same entity.
3043
3044 For further details on the use of this pragma, see the Ada 2012 documentation
3045 of the Invariant aspect.
3046
3047 @node Pragma Keep_Names
3048 @unnumberedsec Pragma Keep_Names
3049 @findex Keep_Names
3050 @noindent
3051 Syntax:
3052
3053 @smallexample @c ada
3054 pragma Keep_Names ([On =>] enumeration_first_subtype_LOCAL_NAME);
3055 @end smallexample
3056
3057 @noindent
3058 The @var{LOCAL_NAME} argument
3059 must refer to an enumeration first subtype
3060 in the current declarative part. The effect is to retain the enumeration
3061 literal names for use by @code{Image} and @code{Value} even if a global
3062 @code{Discard_Names} pragma applies. This is useful when you want to
3063 generally suppress enumeration literal names and for example you therefore
3064 use a @code{Discard_Names} pragma in the @file{gnat.adc} file, but you
3065 want to retain the names for specific enumeration types.
3066
3067 @node Pragma License
3068 @unnumberedsec Pragma License
3069 @findex License
3070 @cindex License checking
3071 @noindent
3072 Syntax:
3073
3074 @smallexample @c ada
3075 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
3076 @end smallexample
3077
3078 @noindent
3079 This pragma is provided to allow automated checking for appropriate license
3080 conditions with respect to the standard and modified GPL@.  A pragma
3081 @code{License}, which is a configuration pragma that typically appears at
3082 the start of a source file or in a separate @file{gnat.adc} file, specifies
3083 the licensing conditions of a unit as follows:
3084
3085 @itemize @bullet
3086 @item Unrestricted
3087 This is used for a unit that can be freely used with no license restrictions.
3088 Examples of such units are public domain units, and units from the Ada
3089 Reference Manual.
3090
3091 @item GPL
3092 This is used for a unit that is licensed under the unmodified GPL, and which
3093 therefore cannot be @code{with}'ed by a restricted unit.
3094
3095 @item Modified_GPL
3096 This is used for a unit licensed under the GNAT modified GPL that includes
3097 a special exception paragraph that specifically permits the inclusion of
3098 the unit in programs without requiring the entire program to be released
3099 under the GPL@.
3100
3101 @item Restricted
3102 This is used for a unit that is restricted in that it is not permitted to
3103 depend on units that are licensed under the GPL@.  Typical examples are
3104 proprietary code that is to be released under more restrictive license
3105 conditions.  Note that restricted units are permitted to @code{with} units
3106 which are licensed under the modified GPL (this is the whole point of the
3107 modified GPL).
3108
3109 @end itemize
3110
3111 @noindent
3112 Normally a unit with no @code{License} pragma is considered to have an
3113 unknown license, and no checking is done.  However, standard GNAT headers
3114 are recognized, and license information is derived from them as follows.
3115
3116 @itemize @bullet
3117
3118 A GNAT license header starts with a line containing 78 hyphens.  The following
3119 comment text is searched for the appearance of any of the following strings.
3120
3121 If the string ``GNU General Public License'' is found, then the unit is assumed
3122 to have GPL license, unless the string ``As a special exception'' follows, in
3123 which case the license is assumed to be modified GPL@.
3124
3125 If one of the strings
3126 ``This specification is adapted from the Ada Semantic Interface'' or
3127 ``This specification is derived from the Ada Reference Manual'' is found
3128 then the unit is assumed to be unrestricted.
3129 @end itemize
3130
3131 @noindent
3132 These default actions means that a program with a restricted license pragma
3133 will automatically get warnings if a GPL unit is inappropriately
3134 @code{with}'ed.  For example, the program:
3135
3136 @smallexample @c ada
3137 with Sem_Ch3;
3138 with GNAT.Sockets;
3139 procedure Secret_Stuff is
3140   @dots{}
3141 end Secret_Stuff
3142 @end smallexample
3143
3144 @noindent
3145 if compiled with pragma @code{License} (@code{Restricted}) in a
3146 @file{gnat.adc} file will generate the warning:
3147
3148 @smallexample
3149 1.  with Sem_Ch3;
3150         |
3151    >>> license of withed unit "Sem_Ch3" is incompatible
3152
3153 2.  with GNAT.Sockets;
3154 3.  procedure Secret_Stuff is
3155 @end smallexample
3156
3157 @noindent
3158 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
3159 compiler and is licensed under the
3160 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
3161 run time, and is therefore licensed under the modified GPL@.
3162
3163 @node Pragma Link_With
3164 @unnumberedsec Pragma Link_With
3165 @findex Link_With
3166 @noindent
3167 Syntax:
3168
3169 @smallexample @c ada
3170 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
3171 @end smallexample
3172
3173 @noindent
3174 This pragma is provided for compatibility with certain Ada 83 compilers.
3175 It has exactly the same effect as pragma @code{Linker_Options} except
3176 that spaces occurring within one of the string expressions are treated
3177 as separators. For example, in the following case:
3178
3179 @smallexample @c ada
3180 pragma Link_With ("-labc -ldef");
3181 @end smallexample
3182
3183 @noindent
3184 results in passing the strings @code{-labc} and @code{-ldef} as two
3185 separate arguments to the linker. In addition pragma Link_With allows
3186 multiple arguments, with the same effect as successive pragmas.
3187
3188 @node Pragma Linker_Alias
3189 @unnumberedsec Pragma Linker_Alias
3190 @findex Linker_Alias
3191 @noindent
3192 Syntax:
3193
3194 @smallexample @c ada
3195 pragma Linker_Alias (
3196   [Entity =>] LOCAL_NAME,
3197   [Target =>] static_string_EXPRESSION);
3198 @end smallexample
3199
3200 @noindent
3201 @var{LOCAL_NAME} must refer to an object that is declared at the library
3202 level. This pragma establishes the given entity as a linker alias for the
3203 given target. It is equivalent to @code{__attribute__((alias))} in GNU C
3204 and causes @var{LOCAL_NAME} to be emitted as an alias for the symbol
3205 @var{static_string_EXPRESSION} in the object file, that is to say no space
3206 is reserved for @var{LOCAL_NAME} by the assembler and it will be resolved
3207 to the same address as @var{static_string_EXPRESSION} by the linker.
3208
3209 The actual linker name for the target must be used (e.g.@: the fully
3210 encoded name with qualification in Ada, or the mangled name in C++),
3211 or it must be declared using the C convention with @code{pragma Import}
3212 or @code{pragma Export}.
3213
3214 Not all target machines support this pragma. On some of them it is accepted
3215 only if @code{pragma Weak_External} has been applied to @var{LOCAL_NAME}.
3216
3217 @smallexample @c ada
3218 --  Example of the use of pragma Linker_Alias
3219
3220 package p is
3221   i : Integer := 1;
3222   pragma Export (C, i);
3223
3224   new_name_for_i : Integer;
3225   pragma Linker_Alias (new_name_for_i, "i");
3226 end p;
3227 @end smallexample
3228
3229 @node Pragma Linker_Constructor
3230 @unnumberedsec Pragma Linker_Constructor
3231 @findex Linker_Constructor
3232 @noindent
3233 Syntax:
3234
3235 @smallexample @c ada
3236 pragma Linker_Constructor (procedure_LOCAL_NAME);
3237 @end smallexample
3238
3239 @noindent
3240 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
3241 is declared at the library level. A procedure to which this pragma is
3242 applied will be treated as an initialization routine by the linker.
3243 It is equivalent to @code{__attribute__((constructor))} in GNU C and
3244 causes @var{procedure_LOCAL_NAME} to be invoked before the entry point
3245 of the executable is called (or immediately after the shared library is
3246 loaded if the procedure is linked in a shared library), in particular
3247 before the Ada run-time environment is set up.
3248
3249 Because of these specific contexts, the set of operations such a procedure
3250 can perform is very limited and the type of objects it can manipulate is
3251 essentially restricted to the elementary types. In particular, it must only
3252 contain code to which pragma Restrictions (No_Elaboration_Code) applies.
3253
3254 This pragma is used by GNAT to implement auto-initialization of shared Stand
3255 Alone Libraries, which provides a related capability without the restrictions
3256 listed above. Where possible, the use of Stand Alone Libraries is preferable
3257 to the use of this pragma.
3258
3259 @node Pragma Linker_Destructor
3260 @unnumberedsec Pragma Linker_Destructor
3261 @findex Linker_Destructor
3262 @noindent
3263 Syntax:
3264
3265 @smallexample @c ada
3266 pragma Linker_Destructor (procedure_LOCAL_NAME);
3267 @end smallexample
3268
3269 @noindent
3270 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
3271 is declared at the library level. A procedure to which this pragma is
3272 applied will be treated as a finalization routine by the linker.
3273 It is equivalent to @code{__attribute__((destructor))} in GNU C and
3274 causes @var{procedure_LOCAL_NAME} to be invoked after the entry point
3275 of the executable has exited (or immediately before the shared library
3276 is unloaded if the procedure is linked in a shared library), in particular
3277 after the Ada run-time environment is shut down.
3278
3279 See @code{pragma Linker_Constructor} for the set of restrictions that apply
3280 because of these specific contexts.
3281
3282 @node Pragma Linker_Section
3283 @unnumberedsec Pragma Linker_Section
3284 @findex Linker_Section
3285 @noindent
3286 Syntax:
3287
3288 @smallexample @c ada
3289 pragma Linker_Section (
3290   [Entity  =>] LOCAL_NAME,
3291   [Section =>] static_string_EXPRESSION);
3292 @end smallexample
3293
3294 @noindent
3295 @var{LOCAL_NAME} must refer to an object that is declared at the library
3296 level. This pragma specifies the name of the linker section for the given
3297 entity. It is equivalent to @code{__attribute__((section))} in GNU C and
3298 causes @var{LOCAL_NAME} to be placed in the @var{static_string_EXPRESSION}
3299 section of the executable (assuming the linker doesn't rename the section).
3300
3301 The compiler normally places library-level objects in standard sections
3302 depending on their type: procedures and functions generally go in the
3303 @code{.text} section, initialized variables in the @code{.data} section
3304 and uninitialized variables in the @code{.bss} section.
3305
3306 Other, special sections may exist on given target machines to map special
3307 hardware, for example I/O ports or flash memory. This pragma is a means to
3308 defer the final layout of the executable to the linker, thus fully working
3309 at the symbolic level with the compiler.
3310
3311 Some file formats do not support arbitrary sections so not all target
3312 machines support this pragma. The use of this pragma may cause a program
3313 execution to be erroneous if it is used to place an entity into an
3314 inappropriate section (e.g.@: a modified variable into the @code{.text}
3315 section). See also @code{pragma Persistent_BSS}.
3316
3317 @smallexample @c ada
3318 --  Example of the use of pragma Linker_Section
3319
3320 package IO_Card is
3321   Port_A : Integer;
3322   pragma Volatile (Port_A);
3323   pragma Linker_Section (Port_A, ".bss.port_a");
3324
3325   Port_B : Integer;
3326   pragma Volatile (Port_B);
3327   pragma Linker_Section (Port_B, ".bss.port_b");
3328 end IO_Card;
3329 @end smallexample
3330
3331 @node Pragma Long_Float
3332 @unnumberedsec Pragma Long_Float
3333 @cindex OpenVMS
3334 @findex Long_Float
3335 @noindent
3336 Syntax:
3337
3338 @smallexample @c ada
3339 pragma Long_Float (FLOAT_FORMAT);
3340
3341 FLOAT_FORMAT ::= D_Float | G_Float
3342 @end smallexample
3343
3344 @noindent
3345 This pragma is implemented only in the OpenVMS implementation of GNAT@.
3346 It allows control over the internal representation chosen for the predefined
3347 type @code{Long_Float} and for floating point type representations with
3348 @code{digits} specified in the range 7 through 15.
3349 For further details on this pragma, see the
3350 @cite{DEC Ada Language Reference Manual}, section 3.5.7b.  Note that to use
3351 this pragma, the standard runtime libraries must be recompiled.
3352
3353 @node Pragma Machine_Attribute
3354 @unnumberedsec Pragma Machine_Attribute
3355 @findex Machine_Attribute
3356 @noindent
3357 Syntax:
3358
3359 @smallexample @c ada
3360 pragma Machine_Attribute (
3361      [Entity         =>] LOCAL_NAME,
3362      [Attribute_Name =>] static_string_EXPRESSION
3363   [, [Info           =>] static_EXPRESSION] );
3364 @end smallexample
3365
3366 @noindent
3367 Machine-dependent attributes can be specified for types and/or
3368 declarations.  This pragma is semantically equivalent to
3369 @code{__attribute__((@var{attribute_name}))} (if @var{info} is not
3370 specified) or @code{__attribute__((@var{attribute_name}(@var{info})))}
3371 in GNU C, where @code{@var{attribute_name}} is recognized by the
3372 compiler middle-end or the @code{TARGET_ATTRIBUTE_TABLE} machine
3373 specific macro.  A string literal for the optional parameter @var{info}
3374 is transformed into an identifier, which may make this pragma unusable
3375 for some attributes.  @xref{Target Attributes,, Defining target-specific
3376 uses of @code{__attribute__}, gccint, GNU Compiler Collection (GCC)
3377 Internals}, further information.
3378
3379 @node Pragma Main
3380 @unnumberedsec Pragma Main
3381 @cindex OpenVMS
3382 @findex Main
3383 @noindent
3384 Syntax:
3385
3386 @smallexample @c ada
3387 pragma Main
3388  (MAIN_OPTION [, MAIN_OPTION]);
3389
3390 MAIN_OPTION ::=
3391   [Stack_Size              =>] static_integer_EXPRESSION
3392 | [Task_Stack_Size_Default =>] static_integer_EXPRESSION
3393 | [Time_Slicing_Enabled    =>] static_boolean_EXPRESSION
3394 @end smallexample
3395
3396 @noindent
3397 This pragma is provided for compatibility with OpenVMS VAX Systems.  It has
3398 no effect in GNAT, other than being syntax checked.
3399
3400 @node Pragma Main_Storage
3401 @unnumberedsec Pragma Main_Storage
3402 @cindex OpenVMS
3403 @findex Main_Storage
3404 @noindent
3405 Syntax:
3406
3407 @smallexample @c ada
3408 pragma Main_Storage
3409   (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
3410
3411 MAIN_STORAGE_OPTION ::=
3412   [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
3413 | [TOP_GUARD       =>] static_SIMPLE_EXPRESSION
3414 @end smallexample
3415
3416 @noindent
3417 This pragma is provided for compatibility with OpenVMS VAX Systems.  It has
3418 no effect in GNAT, other than being syntax checked.  Note that the pragma
3419 also has no effect in DEC Ada 83 for OpenVMS Alpha Systems.
3420
3421 @node Pragma No_Body
3422 @unnumberedsec Pragma No_Body
3423 @findex No_Body
3424 @noindent
3425 Syntax:
3426
3427 @smallexample @c ada
3428 pragma No_Body;
3429 @end smallexample
3430
3431 @noindent
3432 There are a number of cases in which a package spec does not require a body,
3433 and in fact a body is not permitted. GNAT will not permit the spec to be
3434 compiled if there is a body around. The pragma No_Body allows you to provide
3435 a body file, even in a case where no body is allowed. The body file must
3436 contain only comments and a single No_Body pragma. This is recognized by
3437 the compiler as indicating that no body is logically present.
3438
3439 This is particularly useful during maintenance when a package is modified in
3440 such a way that a body needed before is no longer needed. The provision of a
3441 dummy body with a No_Body pragma ensures that there is no interference from
3442 earlier versions of the package body.
3443
3444 @node Pragma No_Return
3445 @unnumberedsec Pragma No_Return
3446 @findex No_Return
3447 @noindent
3448 Syntax:
3449
3450 @smallexample @c ada
3451 pragma No_Return (procedure_LOCAL_NAME @{, procedure_LOCAL_NAME@});
3452 @end smallexample
3453
3454 @noindent
3455 Each @var{procedure_LOCAL_NAME} argument must refer to one or more procedure
3456 declarations in the current declarative part.  A procedure to which this
3457 pragma is applied may not contain any explicit @code{return} statements.
3458 In addition, if the procedure contains any implicit returns from falling
3459 off the end of a statement sequence, then execution of that implicit
3460 return will cause Program_Error to be raised.
3461
3462 One use of this pragma is to identify procedures whose only purpose is to raise
3463 an exception. Another use of this pragma is to suppress incorrect warnings
3464 about missing returns in functions, where the last statement of a function
3465 statement sequence is a call to such a procedure.
3466
3467 Note that in Ada 2005 mode, this pragma is part of the language, and is
3468 identical in effect to the pragma as implemented in Ada 95 mode.
3469
3470 @node Pragma No_Strict_Aliasing
3471 @unnumberedsec Pragma No_Strict_Aliasing
3472 @findex No_Strict_Aliasing
3473 @noindent
3474 Syntax:
3475
3476 @smallexample @c ada
3477 pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
3478 @end smallexample
3479
3480 @noindent
3481 @var{type_LOCAL_NAME} must refer to an access type
3482 declaration in the current declarative part.  The effect is to inhibit
3483 strict aliasing optimization for the given type.  The form with no
3484 arguments is a configuration pragma which applies to all access types
3485 declared in units to which the pragma applies. For a detailed
3486 description of the strict aliasing optimization, and the situations
3487 in which it must be suppressed, see @ref{Optimization and Strict
3488 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
3489
3490 @node Pragma Normalize_Scalars
3491 @unnumberedsec Pragma Normalize_Scalars
3492 @findex Normalize_Scalars
3493 @noindent
3494 Syntax:
3495
3496 @smallexample @c ada
3497 pragma Normalize_Scalars;
3498 @end smallexample
3499
3500 @noindent
3501 This is a language defined pragma which is fully implemented in GNAT@.  The
3502 effect is to cause all scalar objects that are not otherwise initialized
3503 to be initialized.  The initial values are implementation dependent and
3504 are as follows:
3505
3506 @table @code
3507 @item Standard.Character
3508 @noindent
3509 Objects whose root type is Standard.Character are initialized to
3510 Character'Last unless the subtype range excludes NUL (in which case
3511 NUL is used). This choice will always generate an invalid value if
3512 one exists.
3513
3514 @item Standard.Wide_Character
3515 @noindent
3516 Objects whose root type is Standard.Wide_Character are initialized to
3517 Wide_Character'Last unless the subtype range excludes NUL (in which case
3518 NUL is used). This choice will always generate an invalid value if
3519 one exists.
3520
3521 @item Standard.Wide_Wide_Character
3522 @noindent
3523 Objects whose root type is Standard.Wide_Wide_Character are initialized to
3524 the invalid value 16#FFFF_FFFF# unless the subtype range excludes NUL (in
3525 which case NUL is used). This choice will always generate an invalid value if
3526 one exists.
3527
3528 @item Integer types
3529 @noindent
3530 Objects of an integer type are treated differently depending on whether
3531 negative values are present in the subtype. If no negative values are
3532 present, then all one bits is used as the initial value except in the
3533 special case where zero is excluded from the subtype, in which case
3534 all zero bits are used. This choice will always generate an invalid
3535 value if one exists.
3536
3537 For subtypes with negative values present, the largest negative number
3538 is used, except in the unusual case where this largest negative number
3539 is in the subtype, and the largest positive number is not, in which case
3540 the largest positive value is used. This choice will always generate
3541 an invalid value if one exists.
3542
3543 @item Floating-Point Types
3544 Objects of all floating-point types are initialized to all 1-bits. For
3545 standard IEEE format, this corresponds to a NaN (not a number) which is
3546 indeed an invalid value.
3547
3548 @item Fixed-Point Types
3549 Objects of all fixed-point types are treated as described above for integers,
3550 with the rules applying to the underlying integer value used to represent
3551 the fixed-point value.
3552
3553 @item Modular types
3554 Objects of a modular type are initialized to all one bits, except in
3555 the special case where zero is excluded from the subtype, in which
3556 case all zero bits are used. This choice will always generate an
3557 invalid value if one exists.
3558
3559 @item Enumeration types
3560 Objects of an enumeration type are initialized to all one-bits, i.e.@: to
3561 the value @code{2 ** typ'Size - 1} unless the subtype excludes the literal
3562 whose Pos value is zero, in which case a code of zero is used. This choice
3563 will always generate an invalid value if one exists.
3564
3565 @end table
3566
3567 @node Pragma Obsolescent
3568 @unnumberedsec Pragma Obsolescent
3569 @findex Obsolescent
3570 @noindent
3571 Syntax:
3572
3573 @smallexample @c ada
3574 pragma Obsolescent;
3575
3576 pragma Obsolescent (
3577   [Message =>] static_string_EXPRESSION
3578 [,[Version =>] Ada_05]]);
3579
3580 pragma Obsolescent (
3581   [Entity  =>] NAME
3582 [,[Message =>] static_string_EXPRESSION
3583 [,[Version =>] Ada_05]] );
3584 @end smallexample
3585
3586 @noindent
3587 This pragma can occur immediately following a declaration of an entity,
3588 including the case of a record component. If no Entity argument is present,
3589 then this declaration is the one to which the pragma applies. If an Entity
3590 parameter is present, it must either match the name of the entity in this
3591 declaration, or alternatively, the pragma can immediately follow an enumeration
3592 type declaration, where the Entity argument names one of the enumeration
3593 literals.
3594
3595 This pragma is used to indicate that the named entity
3596 is considered obsolescent and should not be used. Typically this is
3597 used when an API must be modified by eventually removing or modifying
3598 existing subprograms or other entities. The pragma can be used at an
3599 intermediate stage when the entity is still present, but will be
3600 removed later.
3601
3602 The effect of this pragma is to output a warning message on a reference to
3603 an entity thus marked that the subprogram is obsolescent if the appropriate
3604 warning option in the compiler is activated. If the Message parameter is
3605 present, then a second warning message is given containing this text. In
3606 addition, a reference to the eneity is considered to be a violation of pragma
3607 Restrictions (No_Obsolescent_Features).
3608
3609 This pragma can also be used as a program unit pragma for a package,
3610 in which case the entity name is the name of the package, and the
3611 pragma indicates that the entire package is considered
3612 obsolescent. In this case a client @code{with}'ing such a package
3613 violates the restriction, and the @code{with} statement is
3614 flagged with warnings if the warning option is set.
3615
3616 If the Version parameter is present (which must be exactly
3617 the identifier Ada_05, no other argument is allowed), then the
3618 indication of obsolescence applies only when compiling in Ada 2005
3619 mode. This is primarily intended for dealing with the situations
3620 in the predefined library where subprograms or packages
3621 have become defined as obsolescent in Ada 2005
3622 (e.g.@: in Ada.Characters.Handling), but may be used anywhere.
3623
3624 The following examples show typical uses of this pragma:
3625
3626 @smallexample @c ada
3627 package p is
3628    pragma Obsolescent (p, Message => "use pp instead of p");
3629 end p;
3630
3631 package q is
3632    procedure q2;
3633    pragma Obsolescent ("use q2new instead");
3634
3635    type R is new integer;
3636    pragma Obsolescent
3637      (Entity  => R,
3638       Message => "use RR in Ada 2005",
3639       Version => Ada_05);
3640
3641    type M is record
3642       F1 : Integer;
3643       F2 : Integer;
3644       pragma Obsolescent;
3645       F3 : Integer;
3646    end record;
3647
3648    type E is (a, bc, 'd', quack);
3649    pragma Obsolescent (Entity => bc)
3650    pragma Obsolescent (Entity => 'd')
3651
3652    function "+"
3653      (a, b : character) return character;
3654    pragma Obsolescent (Entity => "+");
3655 end;
3656 @end smallexample
3657
3658 @noindent
3659 Note that, as for all pragmas, if you use a pragma argument identifier,
3660 then all subsequent parameters must also use a pragma argument identifier.
3661 So if you specify "Entity =>" for the Entity argument, and a Message
3662 argument is present, it must be preceded by "Message =>".
3663
3664 @node Pragma Optimize_Alignment
3665 @unnumberedsec Pragma Optimize_Alignment
3666 @findex Optimize_Alignment
3667 @cindex Alignment, default settings
3668 @noindent
3669 Syntax:
3670
3671 @smallexample @c ada
3672 pragma Optimize_Alignment (TIME | SPACE | OFF);
3673 @end smallexample
3674
3675 @noindent
3676 This is a configuration pragma which affects the choice of default alignments
3677 for types where no alignment is explicitly specified. There is a time/space
3678 trade-off in the selection of these values. Large alignments result in more
3679 efficient code, at the expense of larger data space, since sizes have to be
3680 increased to match these alignments. Smaller alignments save space, but the
3681 access code is slower. The normal choice of default alignments (which is what
3682 you get if you do not use this pragma, or if you use an argument of OFF),
3683 tries to balance these two requirements.
3684
3685 Specifying SPACE causes smaller default alignments to be chosen in two cases.
3686 First any packed record is given an alignment of 1. Second, if a size is given
3687 for the type, then the alignment is chosen to avoid increasing this size. For
3688 example, consider:
3689
3690 @smallexample @c ada
3691    type R is record
3692       X : Integer;
3693       Y : Character;
3694    end record;
3695
3696    for R'Size use 5*8;
3697 @end smallexample
3698
3699 @noindent
3700 In the default mode, this type gets an alignment of 4, so that access to the
3701 Integer field X are efficient. But this means that objects of the type end up
3702 with a size of 8 bytes. This is a valid choice, since sizes of objects are
3703 allowed to be bigger than the size of the type, but it can waste space if for
3704 example fields of type R appear in an enclosing record. If the above type is
3705 compiled in @code{Optimize_Alignment (Space)} mode, the alignment is set to 1.
3706
3707 Specifying TIME causes larger default alignments to be chosen in the case of
3708 small types with sizes that are not a power of 2. For example, consider:
3709
3710 @smallexample @c ada
3711    type R is record
3712       A : Character;
3713       B : Character;
3714       C : Boolean;
3715    end record;
3716
3717    pragma Pack (R);
3718    for R'Size use 17;
3719 @end smallexample
3720
3721 @noindent
3722 The default alignment for this record is normally 1, but if this type is
3723 compiled in @code{Optimize_Alignment (Time)} mode, then the alignment is set
3724 to 4, which wastes space for objects of the type, since they are now 4 bytes
3725 long, but results in more efficient access when the whole record is referenced.
3726
3727 As noted above, this is a configuration pragma, and there is a requirement
3728 that all units in a partition be compiled with a consistent setting of the
3729 optimization setting. This would normally be achieved by use of a configuration
3730 pragma file containing the appropriate setting. The exception to this rule is
3731 that units with an explicit configuration pragma in the same file as the source
3732 unit are excluded from the consistency check, as are all predefined units. The
3733 latter are compiled by default in pragma Optimize_Alignment (Off) mode if no
3734 pragma appears at the start of the file.
3735
3736 @node Pragma Ordered
3737 @unnumberedsec Pragma Ordered
3738 @findex Ordered
3739 @findex pragma @code{Ordered}
3740 @noindent
3741 Syntax:
3742
3743 @smallexample @c ada
3744 pragma Ordered (enumeration_first_subtype_LOCAL_NAME);
3745 @end smallexample
3746
3747 @noindent
3748 Most enumeration types are from a conceptual point of view unordered.
3749 For example, consider:
3750
3751 @smallexample @c ada
3752 type Color is (Red, Blue, Green, Yellow);
3753 @end smallexample
3754
3755 @noindent
3756 By Ada semantics @code{Blue > Red} and @code{Green > Blue},
3757 but really these relations make no sense; the enumeration type merely
3758 specifies a set of possible colors, and the order is unimportant.
3759
3760 For unordered enumeration types, it is generally a good idea if
3761 clients avoid comparisons (other than equality or inequality) and
3762 explicit ranges. (A @emph{client} is a unit where the type is referenced,
3763 other than the unit where the type is declared, its body, and its subunits.)
3764 For example, if code buried in some client says:
3765
3766 @smallexample @c ada
3767 if Current_Color < Yellow then ...
3768 if Current_Color in Blue .. Green then ...
3769 @end smallexample
3770
3771 @noindent
3772 then the client code is relying on the order, which is undesirable.
3773 It makes the code hard to read and creates maintenance difficulties if
3774 entries have to be added to the enumeration type. Instead,
3775 the code in the client should list the possibilities, or an
3776 appropriate subtype should be declared in the unit that declares
3777 the original enumeration type. E.g., the following subtype could
3778 be declared along with the type @code{Color}:
3779
3780 @smallexample @c ada
3781 subtype RBG is Color range Red .. Green;
3782 @end smallexample
3783
3784 @noindent
3785 and then the client could write:
3786
3787 @smallexample @c ada
3788 if Current_Color in RBG then ...
3789 if Current_Color = Blue or Current_Color = Green then ...
3790 @end smallexample
3791
3792 @noindent
3793 However, some enumeration types are legitimately ordered from a conceptual
3794 point of view. For example, if you declare:
3795
3796 @smallexample @c ada
3797 type Day is (Mon, Tue, Wed, Thu, Fri, Sat, Sun);
3798 @end smallexample
3799
3800 @noindent
3801 then the ordering imposed by the language is reasonable, and
3802 clients can depend on it, writing for example:
3803
3804 @smallexample @c ada
3805 if D in Mon .. Fri then ...
3806 if D < Wed then ...
3807 @end smallexample
3808
3809 @noindent
3810 The pragma @option{Ordered} is provided to mark enumeration types that
3811 are conceptually ordered, alerting the reader that clients may depend
3812 on the ordering. GNAT provides a pragma to mark enumerations as ordered
3813 rather than one to mark them as unordered, since in our experience,
3814 the great majority of enumeration types are conceptually unordered.
3815
3816 The types @code{Boolean}, @code{Character}, @code{Wide_Character},
3817 and @code{Wide_Wide_Character}
3818 are considered to be ordered types, so each is declared with a
3819 pragma @code{Ordered} in package @code{Standard}.
3820
3821 Normally pragma @code{Ordered} serves only as documentation and a guide for
3822 coding standards, but GNAT provides a warning switch @option{-gnatw.u} that
3823 requests warnings for inappropriate uses (comparisons and explicit
3824 subranges) for unordered types. If this switch is used, then any
3825 enumeration type not marked with pragma @code{Ordered} will be considered
3826 as unordered, and will generate warnings for inappropriate uses.
3827
3828 For additional information please refer to the description of the
3829 @option{-gnatw.u} switch in the @value{EDITION} User's Guide.
3830
3831 @node Pragma Passive
3832 @unnumberedsec Pragma Passive
3833 @findex Passive
3834 @noindent
3835 Syntax:
3836
3837 @smallexample @c ada
3838 pragma Passive [(Semaphore | No)];
3839 @end smallexample
3840
3841 @noindent
3842 Syntax checked, but otherwise ignored by GNAT@.  This is recognized for
3843 compatibility with DEC Ada 83 implementations, where it is used within a
3844 task definition to request that a task be made passive.  If the argument
3845 @code{Semaphore} is present, or the argument is omitted, then DEC Ada 83
3846 treats the pragma as an assertion that the containing task is passive
3847 and that optimization of context switch with this task is permitted and
3848 desired.  If the argument @code{No} is present, the task must not be
3849 optimized.  GNAT does not attempt to optimize any tasks in this manner
3850 (since protected objects are available in place of passive tasks).
3851
3852 @node Pragma Persistent_BSS
3853 @unnumberedsec Pragma Persistent_BSS
3854 @findex Persistent_BSS
3855 @noindent
3856 Syntax:
3857
3858 @smallexample @c ada
3859 pragma Persistent_BSS [(LOCAL_NAME)]
3860 @end smallexample
3861
3862 @noindent
3863 This pragma allows selected objects to be placed in the @code{.persistent_bss}
3864 section. On some targets the linker and loader provide for special
3865 treatment of this section, allowing a program to be reloaded without
3866 affecting the contents of this data (hence the name persistent).
3867
3868 There are two forms of usage. If an argument is given, it must be the
3869 local name of a library level object, with no explicit initialization
3870 and whose type is potentially persistent. If no argument is given, then
3871 the pragma is a configuration pragma, and applies to all library level
3872 objects with no explicit initialization of potentially persistent types.
3873
3874 A potentially persistent type is a scalar type, or a non-tagged,
3875 non-discriminated record, all of whose components have no explicit
3876 initialization and are themselves of a potentially persistent type,
3877 or an array, all of whose constraints are static, and whose component
3878 type is potentially persistent.
3879
3880 If this pragma is used on a target where this feature is not supported,
3881 then the pragma will be ignored. See also @code{pragma Linker_Section}.
3882
3883 @node Pragma Polling
3884 @unnumberedsec Pragma Polling
3885 @findex Polling
3886 @noindent
3887 Syntax:
3888
3889 @smallexample @c ada
3890 pragma Polling (ON | OFF);
3891 @end smallexample
3892
3893 @noindent
3894 This pragma controls the generation of polling code.  This is normally off.
3895 If @code{pragma Polling (ON)} is used then periodic calls are generated to
3896 the routine @code{Ada.Exceptions.Poll}.  This routine is a separate unit in the
3897 runtime library, and can be found in file @file{a-excpol.adb}.
3898
3899 Pragma @code{Polling} can appear as a configuration pragma (for example it
3900 can be placed in the @file{gnat.adc} file) to enable polling globally, or it
3901 can be used in the statement or declaration sequence to control polling
3902 more locally.
3903
3904 A call to the polling routine is generated at the start of every loop and
3905 at the start of every subprogram call.  This guarantees that the @code{Poll}
3906 routine is called frequently, and places an upper bound (determined by
3907 the complexity of the code) on the period between two @code{Poll} calls.
3908
3909 The primary purpose of the polling interface is to enable asynchronous
3910 aborts on targets that cannot otherwise support it (for example Windows
3911 NT), but it may be used for any other purpose requiring periodic polling.
3912 The standard version is null, and can be replaced by a user program.  This
3913 will require re-compilation of the @code{Ada.Exceptions} package that can
3914 be found in files @file{a-except.ads} and @file{a-except.adb}.
3915
3916 A standard alternative unit (in file @file{4wexcpol.adb} in the standard GNAT
3917 distribution) is used to enable the asynchronous abort capability on
3918 targets that do not normally support the capability.  The version of
3919 @code{Poll} in this file makes a call to the appropriate runtime routine
3920 to test for an abort condition.
3921
3922 Note that polling can also be enabled by use of the @option{-gnatP} switch.
3923 @xref{Switches for gcc,,, gnat_ugn, @value{EDITION} User's Guide}, for
3924 details.
3925
3926 @node Pragma Postcondition
3927 @unnumberedsec Pragma Postcondition
3928 @cindex Postconditions
3929 @cindex Checks, postconditions
3930 @findex Postconditions
3931 @noindent
3932 Syntax:
3933
3934 @smallexample @c ada
3935 pragma Postcondition (
3936    [Check   =>] Boolean_Expression
3937  [,[Message =>] String_Expression]);
3938 @end smallexample
3939
3940 @noindent
3941 The @code{Postcondition} pragma allows specification of automatic
3942 postcondition checks for subprograms. These checks are similar to
3943 assertions, but are automatically inserted just prior to the return
3944 statements of the subprogram with which they are associated (including
3945 implicit returns at the end of procedure bodies and associated
3946 exception handlers).
3947
3948 In addition, the boolean expression which is the condition which
3949 must be true may contain references to function'Result in the case
3950 of a function to refer to the returned value.
3951
3952 @code{Postcondition} pragmas may appear either immediate following the
3953 (separate) declaration of a subprogram, or at the start of the
3954 declarations of a subprogram body. Only other pragmas may intervene
3955 (that is appear between the subprogram declaration and its
3956 postconditions, or appear before the postcondition in the
3957 declaration sequence in a subprogram body). In the case of a
3958 postcondition appearing after a subprogram declaration, the
3959 formal arguments of the subprogram are visible, and can be
3960 referenced in the postcondition expressions.
3961
3962 The postconditions are collected and automatically tested just
3963 before any return (implicit or explicit) in the subprogram body.
3964 A postcondition is only recognized if postconditions are active
3965 at the time the pragma is encountered. The compiler switch @option{gnata}
3966 turns on all postconditions by default, and pragma @code{Check_Policy}
3967 with an identifier of @code{Postcondition} can also be used to
3968 control whether postconditions are active.
3969
3970 The general approach is that postconditions are placed in the spec
3971 if they represent functional aspects which make sense to the client.
3972 For example we might have:
3973
3974 @smallexample @c ada
3975    function Direction return Integer;
3976    pragma Postcondition
3977     (Direction'Result = +1
3978        or else
3979      Direction'Result = -1);
3980 @end smallexample
3981
3982 @noindent
3983 which serves to document that the result must be +1 or -1, and
3984 will test that this is the case at run time if postcondition
3985 checking is active.
3986
3987 Postconditions within the subprogram body can be used to
3988 check that some internal aspect of the implementation,
3989 not visible to the client, is operating as expected.
3990 For instance if a square root routine keeps an internal
3991 counter of the number of times it is called, then we
3992 might have the following postcondition:
3993
3994 @smallexample @c ada
3995    Sqrt_Calls : Natural := 0;
3996
3997    function Sqrt (Arg : Float) return Float is
3998      pragma Postcondition
3999        (Sqrt_Calls = Sqrt_Calls'Old + 1);
4000      ...
4001    end Sqrt
4002 @end smallexample
4003
4004 @noindent
4005 As this example, shows, the use of the @code{Old} attribute
4006 is often useful in postconditions to refer to the state on
4007 entry to the subprogram.
4008
4009 Note that postconditions are only checked on normal returns
4010 from the subprogram. If an abnormal return results from
4011 raising an exception, then the postconditions are not checked.
4012
4013 If a postcondition fails, then the exception
4014 @code{System.Assertions.Assert_Failure} is raised. If
4015 a message argument was supplied, then the given string
4016 will be used as the exception message. If no message
4017 argument was supplied, then the default message has
4018 the form "Postcondition failed at file:line". The
4019 exception is raised in the context of the subprogram
4020 body, so it is possible to catch postcondition failures
4021 within the subprogram body itself.
4022
4023 Within a package spec, normal visibility rules
4024 in Ada would prevent forward references within a
4025 postcondition pragma to functions defined later in
4026 the same package. This would introduce undesirable
4027 ordering constraints. To avoid this problem, all
4028 postcondition pragmas are analyzed at the end of
4029 the package spec, allowing forward references.
4030
4031 The following example shows that this even allows
4032 mutually recursive postconditions as in:
4033
4034 @smallexample @c ada
4035 package Parity_Functions is
4036    function Odd  (X : Natural) return Boolean;
4037    pragma Postcondition
4038      (Odd'Result =
4039         (x = 1
4040           or else
4041         (x /= 0 and then Even (X - 1))));
4042
4043    function Even (X : Natural) return Boolean;
4044    pragma Postcondition
4045      (Even'Result =
4046         (x = 0
4047           or else
4048         (x /= 1 and then Odd (X - 1))));
4049
4050 end Parity_Functions;
4051 @end smallexample
4052
4053 @noindent
4054 There are no restrictions on the complexity or form of
4055 conditions used within @code{Postcondition} pragmas.
4056 The following example shows that it is even possible
4057 to verify performance behavior.
4058
4059 @smallexample @c ada
4060 package Sort is
4061
4062    Performance : constant Float;
4063    --  Performance constant set by implementation
4064    --  to match target architecture behavior.
4065
4066    procedure Treesort (Arg : String);
4067    --  Sorts characters of argument using N*logN sort
4068    pragma Postcondition
4069      (Float (Clock - Clock'Old) <=
4070         Float (Arg'Length) *
4071         log (Float (Arg'Length)) *
4072         Performance);
4073 end Sort;
4074 @end smallexample
4075
4076 @noindent
4077 Note: postcondition pragmas associated with subprograms that are
4078 marked as Inline_Always, or those marked as Inline with front-end
4079 inlining (-gnatN option set) are accepted and legality-checked
4080 by the compiler, but are ignored at run-time even if postcondition
4081 checking is enabled.
4082
4083 @node Pragma Precondition
4084 @unnumberedsec Pragma Precondition
4085 @cindex Preconditions
4086 @cindex Checks, preconditions
4087 @findex Preconditions
4088 @noindent
4089 Syntax:
4090
4091 @smallexample @c ada
4092 pragma Precondition (
4093    [Check   =>] Boolean_Expression
4094  [,[Message =>] String_Expression]);
4095 @end smallexample
4096
4097 @noindent
4098 The @code{Precondition} pragma is similar to @code{Postcondition}
4099 except that the corresponding checks take place immediately upon
4100 entry to the subprogram, and if a precondition fails, the exception
4101 is raised in the context of the caller, and the attribute 'Result
4102 cannot be used within the precondition expression.
4103
4104 Otherwise, the placement and visibility rules are identical to those
4105 described for postconditions. The following is an example of use
4106 within a package spec:
4107
4108 @smallexample @c ada
4109 package Math_Functions is
4110    ...
4111    function Sqrt (Arg : Float) return Float;
4112    pragma Precondition (Arg >= 0.0)
4113    ...
4114 end Math_Functions;
4115 @end smallexample
4116
4117 @noindent
4118 @code{Precondition} pragmas may appear either immediate following the
4119 (separate) declaration of a subprogram, or at the start of the
4120 declarations of a subprogram body. Only other pragmas may intervene
4121 (that is appear between the subprogram declaration and its
4122 postconditions, or appear before the postcondition in the
4123 declaration sequence in a subprogram body).
4124
4125 Note: postcondition pragmas associated with subprograms that are
4126 marked as Inline_Always, or those marked as Inline with front-end
4127 inlining (-gnatN option set) are accepted and legality-checked
4128 by the compiler, but are ignored at run-time even if postcondition
4129 checking is enabled.
4130
4131 @node Pragma Profile (Ravenscar)
4132 @unnumberedsec Pragma Profile (Ravenscar)
4133 @findex Ravenscar
4134 @noindent
4135 Syntax:
4136
4137 @smallexample @c ada
4138 pragma Profile (Ravenscar);
4139 @end smallexample
4140
4141 @noindent
4142 A configuration pragma that establishes the following set of configuration
4143 pragmas:
4144
4145 @table @code
4146 @item Task_Dispatching_Policy (FIFO_Within_Priorities)
4147 [RM D.2.2] Tasks are dispatched following a preemptive
4148 priority-ordered scheduling policy.
4149
4150 @item Locking_Policy (Ceiling_Locking)
4151 [RM D.3] While tasks and interrupts execute a protected action, they inherit
4152 the ceiling priority of the corresponding protected object.
4153 @c
4154 @c @item Detect_Blocking
4155 @c This pragma forces the detection of potentially blocking operations within a
4156 @c protected operation, and to raise Program_Error if that happens.
4157 @end table
4158 @noindent
4159
4160 plus the following set of restrictions:
4161
4162 @table @code
4163 @item Max_Entry_Queue_Length = 1
4164 Defines the maximum number of calls that are queued on a (protected) entry.
4165 Note that this restrictions is checked at run time. Violation of this
4166 restriction results in the raising of Program_Error exception at the point of
4167 the call. For the Profile (Ravenscar) the value of Max_Entry_Queue_Length is
4168 always 1 and hence no task can be queued on a protected entry.
4169
4170 @item Max_Protected_Entries = 1
4171 [RM D.7] Specifies the maximum number of entries per protected type. The
4172 bounds of every entry family of a protected unit shall be static, or shall be
4173 defined by a discriminant of a subtype whose corresponding bound is static.
4174 For the Profile (Ravenscar) the value of Max_Protected_Entries is always 1.
4175
4176 @item Max_Task_Entries = 0
4177 [RM D.7] Specifies the maximum number of entries
4178 per task.  The bounds of every entry family
4179 of a task unit shall be static, or shall be
4180 defined by a discriminant of a subtype whose
4181 corresponding bound is static.  A value of zero
4182 indicates that no rendezvous are possible.  For
4183 the Profile (Ravenscar), the value of Max_Task_Entries is always
4184 0 (zero).
4185
4186 @item No_Abort_Statements
4187 [RM D.7] There are no abort_statements, and there are
4188 no calls to Task_Identification.Abort_Task.
4189
4190 @item No_Asynchronous_Control
4191 There are no semantic dependences on the package
4192 Asynchronous_Task_Control.
4193
4194 @item No_Calendar
4195 There are no semantic dependencies on the package Ada.Calendar.
4196
4197 @item No_Dynamic_Attachment
4198 There is no call to any of the operations defined in package Ada.Interrupts
4199 (Is_Reserved, Is_Attached, Current_Handler, Attach_Handler, Exchange_Handler,
4200 Detach_Handler, and Reference).
4201
4202 @item No_Dynamic_Priorities
4203 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
4204
4205 @item No_Implicit_Heap_Allocations
4206 [RM D.7] No constructs are allowed to cause implicit heap allocation.
4207
4208 @item No_Local_Protected_Objects
4209 Protected objects and access types that designate
4210 such objects shall be declared only at library level.
4211
4212 @item No_Local_Timing_Events
4213 [RM D.7] All objects of type Ada.Timing_Events.Timing_Event are
4214 declared at the library level.
4215
4216 @item No_Protected_Type_Allocators
4217 There are no allocators for protected types or
4218 types containing protected subcomponents.
4219
4220 @item No_Relative_Delay
4221 There are no delay_relative statements.
4222
4223 @item No_Requeue_Statements
4224 Requeue statements are not allowed.
4225
4226 @item No_Select_Statements
4227 There are no select_statements.
4228
4229 @item No_Specific_Termination_Handlers
4230 [RM D.7] There are no calls to Ada.Task_Termination.Set_Specific_Handler
4231 or to Ada.Task_Termination.Specific_Handler.
4232
4233 @item No_Task_Allocators
4234 [RM D.7] There are no allocators for task types
4235 or types containing task subcomponents.
4236
4237 @item No_Task_Attributes_Package
4238 There are no semantic dependencies on the Ada.Task_Attributes package.
4239
4240 @item No_Task_Hierarchy
4241 [RM D.7] All (non-environment) tasks depend
4242 directly on the environment task of the partition.
4243
4244 @item No_Task_Termination
4245 Tasks which terminate are erroneous.
4246
4247 @item No_Unchecked_Conversion
4248 There are no semantic dependencies on the Ada.Unchecked_Conversion package.
4249
4250 @item No_Unchecked_Deallocation
4251 There are no semantic dependencies on the Ada.Unchecked_Deallocation package.
4252
4253 @item Simple_Barriers
4254 Entry barrier condition expressions shall be either static
4255 boolean expressions or boolean objects which are declared in
4256 the protected type which contains the entry.
4257 @end table
4258
4259 @noindent
4260 This set of configuration pragmas and restrictions correspond to the
4261 definition of the ``Ravenscar Profile'' for limited tasking, devised and
4262 published by the @cite{International Real-Time Ada Workshop}, 1997,
4263 and whose most recent description is available at
4264 @url{http://www-users.cs.york.ac.uk/~burns/ravenscar.ps}.
4265
4266 The original definition of the profile was revised at subsequent IRTAW
4267 meetings. It has been included in the ISO
4268 @cite{Guide for the Use of the Ada Programming Language in High
4269 Integrity Systems}, and has been approved by ISO/IEC/SC22/WG9 for inclusion in
4270 the next revision of the standard. The formal definition given by
4271 the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
4272 AI-305) available at
4273 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00249.TXT} and
4274 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00305.TXT}
4275 respectively.
4276
4277 The above set is a superset of the restrictions provided by pragma
4278 @code{Profile (Restricted)}, it includes six additional restrictions
4279 (@code{Simple_Barriers}, @code{No_Select_Statements},
4280 @code{No_Calendar}, @code{No_Implicit_Heap_Allocations},
4281 @code{No_Relative_Delay} and @code{No_Task_Termination}).  This means
4282 that pragma @code{Profile (Ravenscar)}, like the pragma
4283 @code{Profile (Restricted)},
4284 automatically causes the use of a simplified,
4285 more efficient version of the tasking run-time system.
4286
4287 @node Pragma Profile (Restricted)
4288 @unnumberedsec Pragma Profile (Restricted)
4289 @findex Restricted Run Time
4290 @noindent
4291 Syntax:
4292
4293 @smallexample @c ada
4294 pragma Profile (Restricted);
4295 @end smallexample
4296
4297 @noindent
4298 A configuration pragma that establishes the following set of restrictions:
4299
4300 @itemize @bullet
4301 @item No_Abort_Statements
4302 @item No_Entry_Queue
4303 @item No_Task_Hierarchy
4304 @item No_Task_Allocators
4305 @item No_Dynamic_Priorities
4306 @item No_Terminate_Alternatives
4307 @item No_Dynamic_Attachment
4308 @item No_Protected_Type_Allocators
4309 @item No_Local_Protected_Objects
4310 @item No_Requeue_Statements
4311 @item No_Task_Attributes_Package
4312 @item Max_Asynchronous_Select_Nesting =  0
4313 @item Max_Task_Entries =  0
4314 @item Max_Protected_Entries = 1
4315 @item Max_Select_Alternatives = 0
4316 @end itemize
4317
4318 @noindent
4319 This set of restrictions causes the automatic selection of a simplified
4320 version of the run time that provides improved performance for the
4321 limited set of tasking functionality permitted by this set of restrictions.
4322
4323 @node Pragma Psect_Object
4324 @unnumberedsec Pragma Psect_Object
4325 @findex Psect_Object
4326 @noindent
4327 Syntax:
4328
4329 @smallexample @c ada
4330 pragma Psect_Object (
4331      [Internal =>] LOCAL_NAME,
4332   [, [External =>] EXTERNAL_SYMBOL]
4333   [, [Size     =>] EXTERNAL_SYMBOL]);
4334
4335 EXTERNAL_SYMBOL ::=
4336   IDENTIFIER
4337 | static_string_EXPRESSION
4338 @end smallexample
4339
4340 @noindent
4341 This pragma is identical in effect to pragma @code{Common_Object}.
4342
4343 @node Pragma Pure_Function
4344 @unnumberedsec Pragma Pure_Function
4345 @findex Pure_Function
4346 @noindent
4347 Syntax:
4348
4349 @smallexample @c ada
4350 pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
4351 @end smallexample
4352
4353 @noindent
4354 This pragma appears in the same declarative part as a function
4355 declaration (or a set of function declarations if more than one
4356 overloaded declaration exists, in which case the pragma applies
4357 to all entities).  It specifies that the function @code{Entity} is
4358 to be considered pure for the purposes of code generation.  This means
4359 that the compiler can assume that there are no side effects, and
4360 in particular that two calls with identical arguments produce the
4361 same result.  It also means that the function can be used in an
4362 address clause.
4363
4364 Note that, quite deliberately, there are no static checks to try
4365 to ensure that this promise is met, so @code{Pure_Function} can be used
4366 with functions that are conceptually pure, even if they do modify
4367 global variables.  For example, a square root function that is
4368 instrumented to count the number of times it is called is still
4369 conceptually pure, and can still be optimized, even though it
4370 modifies a global variable (the count).  Memo functions are another
4371 example (where a table of previous calls is kept and consulted to
4372 avoid re-computation).
4373
4374 Note also that the normal rules excluding optimization of subprograms
4375 in pure units (when parameter types are descended from System.Address,
4376 or when the full view of a parameter type is limited), do not apply
4377 for the Pure_Function case. If you explicitly specify Pure_Function,
4378 the compiler may optimize away calls with identical arguments, and
4379 if that results in unexpected behavior, the proper action is not to
4380 use the pragma for subprograms that are not (conceptually) pure.
4381
4382 @findex Pure
4383 Note: Most functions in a @code{Pure} package are automatically pure, and
4384 there is no need to use pragma @code{Pure_Function} for such functions.  One
4385 exception is any function that has at least one formal of type
4386 @code{System.Address} or a type derived from it.  Such functions are not
4387 considered pure by default, since the compiler assumes that the
4388 @code{Address} parameter may be functioning as a pointer and that the
4389 referenced data may change even if the address value does not.
4390 Similarly, imported functions are not considered to be pure by default,
4391 since there is no way of checking that they are in fact pure.  The use
4392 of pragma @code{Pure_Function} for such a function will override these default
4393 assumption, and cause the compiler to treat a designated subprogram as pure
4394 in these cases.
4395
4396 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
4397 applies to the underlying renamed function.  This can be used to
4398 disambiguate cases of overloading where some but not all functions
4399 in a set of overloaded functions are to be designated as pure.
4400
4401 If pragma @code{Pure_Function} is applied to a library level function, the
4402 function is also considered pure from an optimization point of view, but the
4403 unit is not a Pure unit in the categorization sense. So for example, a function
4404 thus marked is free to @code{with} non-pure units.
4405
4406 @node Pragma Restriction_Warnings
4407 @unnumberedsec Pragma Restriction_Warnings
4408 @findex Restriction_Warnings
4409 @noindent
4410 Syntax:
4411
4412 @smallexample @c ada
4413 pragma Restriction_Warnings
4414   (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
4415 @end smallexample
4416
4417 @noindent
4418 This pragma allows a series of restriction identifiers to be
4419 specified (the list of allowed identifiers is the same as for
4420 pragma @code{Restrictions}). For each of these identifiers
4421 the compiler checks for violations of the restriction, but
4422 generates a warning message rather than an error message
4423 if the restriction is violated.
4424
4425 @node Pragma Shared
4426 @unnumberedsec Pragma Shared
4427 @findex Shared
4428
4429 @noindent
4430 This pragma is provided for compatibility with Ada 83. The syntax and
4431 semantics are identical to pragma Atomic.
4432
4433 @node Pragma Short_Circuit_And_Or
4434 @unnumberedsec Pragma Short_Circuit_And_Or
4435 @findex Short_Circuit_And_Or
4436
4437 @noindent
4438 This configuration pragma causes any occurrence of the AND operator applied to
4439 operands of type Standard.Boolean to be short-circuited (i.e. the AND operator
4440 is treated as if it were AND THEN). Or is similarly treated as OR ELSE. This
4441 may be useful in the context of certification protocols requiring the use of
4442 short-circuited logical operators. If this configuration pragma occurs locally
4443 within the file being compiled, it applies only to the file being compiled.
4444 There is no requirement that all units in a partition use this option.
4445
4446 @node Pragma Short_Descriptors
4447 @unnumberedsec Pragma Short_Descriptors
4448 @findex Short_Descriptors
4449 @noindent
4450 Syntax:
4451
4452 @smallexample @c ada
4453 pragma Short_Descriptors
4454 @end smallexample
4455
4456 @noindent
4457 In VMS versions of the compiler, this configuration pragma causes all
4458 occurrences of the mechanism types Descriptor[_xxx] to be treated as
4459 Short_Descriptor[_xxx]. This is helpful in porting legacy applications from a
4460 32-bit environment to a 64-bit environment. This pragma is ignored for non-VMS
4461 versions.
4462
4463 @node Pragma Source_File_Name
4464 @unnumberedsec Pragma Source_File_Name
4465 @findex Source_File_Name
4466 @noindent
4467 Syntax:
4468
4469 @smallexample @c ada
4470 pragma Source_File_Name (
4471   [Unit_Name   =>] unit_NAME,
4472   Spec_File_Name =>  STRING_LITERAL,
4473   [Index => INTEGER_LITERAL]);
4474
4475 pragma Source_File_Name (
4476   [Unit_Name   =>] unit_NAME,
4477   Body_File_Name =>  STRING_LITERAL,
4478   [Index => INTEGER_LITERAL]);
4479 @end smallexample
4480
4481 @noindent
4482 Use this to override the normal naming convention.  It is a configuration
4483 pragma, and so has the usual applicability of configuration pragmas
4484 (i.e.@: it applies to either an entire partition, or to all units in a
4485 compilation, or to a single unit, depending on how it is used.
4486 @var{unit_name} is mapped to @var{file_name_literal}.  The identifier for
4487 the second argument is required, and indicates whether this is the file
4488 name for the spec or for the body.
4489
4490 The optional Index argument should be used when a file contains multiple
4491 units, and when you do not want to use @code{gnatchop} to separate then
4492 into multiple files (which is the recommended procedure to limit the
4493 number of recompilations that are needed when some sources change).
4494 For instance, if the source file @file{source.ada} contains
4495
4496 @smallexample @c ada
4497 package B is
4498 ...
4499 end B;
4500
4501 with B;
4502 procedure A is
4503 begin
4504    ..
4505 end A;
4506 @end smallexample
4507
4508 you could use the following configuration pragmas:
4509
4510 @smallexample @c ada
4511 pragma Source_File_Name
4512   (B, Spec_File_Name => "source.ada", Index => 1);
4513 pragma Source_File_Name
4514   (A, Body_File_Name => "source.ada", Index => 2);
4515 @end smallexample
4516
4517 Note that the @code{gnatname} utility can also be used to generate those
4518 configuration pragmas.
4519
4520 Another form of the @code{Source_File_Name} pragma allows
4521 the specification of patterns defining alternative file naming schemes
4522 to apply to all files.
4523
4524 @smallexample @c ada
4525 pragma Source_File_Name
4526   (  [Spec_File_Name  =>] STRING_LITERAL
4527    [,[Casing          =>] CASING_SPEC]
4528    [,[Dot_Replacement =>] STRING_LITERAL]);
4529
4530 pragma Source_File_Name
4531   (  [Body_File_Name  =>] STRING_LITERAL
4532    [,[Casing          =>] CASING_SPEC]
4533    [,[Dot_Replacement =>] STRING_LITERAL]);
4534
4535 pragma Source_File_Name
4536   (  [Subunit_File_Name =>] STRING_LITERAL
4537    [,[Casing            =>] CASING_SPEC]
4538    [,[Dot_Replacement   =>] STRING_LITERAL]);
4539
4540 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
4541 @end smallexample
4542
4543 @noindent
4544 The first argument is a pattern that contains a single asterisk indicating
4545 the point at which the unit name is to be inserted in the pattern string
4546 to form the file name.  The second argument is optional.  If present it
4547 specifies the casing of the unit name in the resulting file name string.
4548 The default is lower case.  Finally the third argument allows for systematic
4549 replacement of any dots in the unit name by the specified string literal.
4550
4551 A pragma Source_File_Name cannot appear after a
4552 @ref{Pragma Source_File_Name_Project}.
4553
4554 For more details on the use of the @code{Source_File_Name} pragma,
4555 @xref{Using Other File Names,,, gnat_ugn, @value{EDITION} User's Guide},
4556 and @ref{Alternative File Naming Schemes,,, gnat_ugn, @value{EDITION}
4557 User's Guide}.
4558
4559 @node Pragma Source_File_Name_Project
4560 @unnumberedsec Pragma Source_File_Name_Project
4561 @findex Source_File_Name_Project
4562 @noindent
4563
4564 This pragma has the same syntax and semantics as pragma Source_File_Name.
4565 It is only allowed as a stand alone configuration pragma.
4566 It cannot appear after a @ref{Pragma Source_File_Name}, and
4567 most importantly, once pragma Source_File_Name_Project appears,
4568 no further Source_File_Name pragmas are allowed.
4569
4570 The intention is that Source_File_Name_Project pragmas are always
4571 generated by the Project Manager in a manner consistent with the naming
4572 specified in a project file, and when naming is controlled in this manner,
4573 it is not permissible to attempt to modify this naming scheme using
4574 Source_File_Name pragmas (which would not be known to the project manager).
4575
4576 @node Pragma Source_Reference
4577 @unnumberedsec Pragma Source_Reference
4578 @findex Source_Reference
4579 @noindent
4580 Syntax:
4581
4582 @smallexample @c ada
4583 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
4584 @end smallexample
4585
4586 @noindent
4587 This pragma must appear as the first line of a source file.
4588 @var{integer_literal} is the logical line number of the line following
4589 the pragma line (for use in error messages and debugging
4590 information).  @var{string_literal} is a static string constant that
4591 specifies the file name to be used in error messages and debugging
4592 information.  This is most notably used for the output of @code{gnatchop}
4593 with the @option{-r} switch, to make sure that the original unchopped
4594 source file is the one referred to.
4595
4596 The second argument must be a string literal, it cannot be a static
4597 string expression other than a string literal.  This is because its value
4598 is needed for error messages issued by all phases of the compiler.
4599
4600 @node Pragma Stream_Convert
4601 @unnumberedsec Pragma Stream_Convert
4602 @findex Stream_Convert
4603 @noindent
4604 Syntax:
4605
4606 @smallexample @c ada
4607 pragma Stream_Convert (
4608   [Entity =>] type_LOCAL_NAME,
4609   [Read   =>] function_NAME,
4610   [Write  =>] function_NAME);
4611 @end smallexample
4612
4613 @noindent
4614 This pragma provides an efficient way of providing stream functions for
4615 types defined in packages.  Not only is it simpler to use than declaring
4616 the necessary functions with attribute representation clauses, but more
4617 significantly, it allows the declaration to made in such a way that the
4618 stream packages are not loaded unless they are needed.  The use of
4619 the Stream_Convert pragma adds no overhead at all, unless the stream
4620 attributes are actually used on the designated type.
4621
4622 The first argument specifies the type for which stream functions are
4623 provided.  The second parameter provides a function used to read values
4624 of this type.  It must name a function whose argument type may be any
4625 subtype, and whose returned type must be the type given as the first
4626 argument to the pragma.
4627
4628 The meaning of the @var{Read}
4629 parameter is that if a stream attribute directly
4630 or indirectly specifies reading of the type given as the first parameter,
4631 then a value of the type given as the argument to the Read function is
4632 read from the stream, and then the Read function is used to convert this
4633 to the required target type.
4634
4635 Similarly the @var{Write} parameter specifies how to treat write attributes
4636 that directly or indirectly apply to the type given as the first parameter.
4637 It must have an input parameter of the type specified by the first parameter,
4638 and the return type must be the same as the input type of the Read function.
4639 The effect is to first call the Write function to convert to the given stream
4640 type, and then write the result type to the stream.
4641
4642 The Read and Write functions must not be overloaded subprograms.  If necessary
4643 renamings can be supplied to meet this requirement.
4644 The usage of this attribute is best illustrated by a simple example, taken
4645 from the GNAT implementation of package Ada.Strings.Unbounded:
4646
4647 @smallexample @c ada
4648 function To_Unbounded (S : String)
4649            return Unbounded_String
4650   renames To_Unbounded_String;
4651
4652 pragma Stream_Convert
4653   (Unbounded_String, To_Unbounded, To_String);
4654 @end smallexample
4655
4656 @noindent
4657 The specifications of the referenced functions, as given in the Ada
4658 Reference Manual are:
4659
4660 @smallexample @c ada
4661 function To_Unbounded_String (Source : String)
4662   return Unbounded_String;
4663
4664 function To_String (Source : Unbounded_String)
4665   return String;
4666 @end smallexample
4667
4668 @noindent
4669 The effect is that if the value of an unbounded string is written to a stream,
4670 then the representation of the item in the stream is in the same format that
4671 would be used for @code{Standard.String'Output}, and this same representation
4672 is expected when a value of this type is read from the stream. Note that the
4673 value written always includes the bounds, even for Unbounded_String'Write,
4674 since Unbounded_String is not an array type.
4675
4676 @node Pragma Style_Checks
4677 @unnumberedsec Pragma Style_Checks
4678 @findex Style_Checks
4679 @noindent
4680 Syntax:
4681
4682 @smallexample @c ada
4683 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
4684                      On | Off [, LOCAL_NAME]);
4685 @end smallexample
4686
4687 @noindent
4688 This pragma is used in conjunction with compiler switches to control the
4689 built in style checking provided by GNAT@.  The compiler switches, if set,
4690 provide an initial setting for the switches, and this pragma may be used
4691 to modify these settings, or the settings may be provided entirely by
4692 the use of the pragma.  This pragma can be used anywhere that a pragma
4693 is legal, including use as a configuration pragma (including use in
4694 the @file{gnat.adc} file).
4695
4696 The form with a string literal specifies which style options are to be
4697 activated.  These are additive, so they apply in addition to any previously
4698 set style check options.  The codes for the options are the same as those
4699 used in the @option{-gnaty} switch to @command{gcc} or @command{gnatmake}.
4700 For example the following two methods can be used to enable
4701 layout checking:
4702
4703 @itemize @bullet
4704 @item
4705 @smallexample @c ada
4706 pragma Style_Checks ("l");
4707 @end smallexample
4708
4709 @item
4710 @smallexample
4711 gcc -c -gnatyl @dots{}
4712 @end smallexample
4713 @end itemize
4714
4715 @noindent
4716 The form ALL_CHECKS activates all standard checks (its use is equivalent
4717 to the use of the @code{gnaty} switch with no options.  @xref{Top,
4718 @value{EDITION} User's Guide, About This Guide, gnat_ugn,
4719 @value{EDITION} User's Guide}, for details.)
4720
4721 Note: the behavior is slightly different in GNAT mode (@option{-gnatg} used).
4722 In this case, ALL_CHECKS implies the standard set of GNAT mode style check
4723 options (i.e. equivalent to -gnatyg).
4724
4725 The forms with @code{Off} and @code{On}
4726 can be used to temporarily disable style checks
4727 as shown in the following example:
4728
4729 @smallexample @c ada
4730 @iftex
4731 @leftskip=0cm
4732 @end iftex
4733 pragma Style_Checks ("k"); -- requires keywords in lower case
4734 pragma Style_Checks (Off); -- turn off style checks
4735 NULL;                      -- this will not generate an error message
4736 pragma Style_Checks (On);  -- turn style checks back on
4737 NULL;                      -- this will generate an error message
4738 @end smallexample
4739
4740 @noindent
4741 Finally the two argument form is allowed only if the first argument is
4742 @code{On} or @code{Off}.  The effect is to turn of semantic style checks
4743 for the specified entity, as shown in the following example:
4744
4745 @smallexample @c ada
4746 @iftex
4747 @leftskip=0cm
4748 @end iftex
4749 pragma Style_Checks ("r"); -- require consistency of identifier casing
4750 Arg : Integer;
4751 Rf1 : Integer := ARG;      -- incorrect, wrong case
4752 pragma Style_Checks (Off, Arg);
4753 Rf2 : Integer := ARG;      -- OK, no error
4754 @end smallexample
4755
4756 @node Pragma Subtitle
4757 @unnumberedsec Pragma Subtitle
4758 @findex Subtitle
4759 @noindent
4760 Syntax:
4761
4762 @smallexample @c ada
4763 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
4764 @end smallexample
4765
4766 @noindent
4767 This pragma is recognized for compatibility with other Ada compilers
4768 but is ignored by GNAT@.
4769
4770 @node Pragma Suppress
4771 @unnumberedsec Pragma Suppress
4772 @findex Suppress
4773 @noindent
4774 Syntax:
4775
4776 @smallexample @c ada
4777 pragma Suppress (Identifier [, [On =>] Name]);
4778 @end smallexample
4779
4780 @noindent
4781 This is a standard pragma, and supports all the check names required in
4782 the RM. It is included here because GNAT recognizes one additional check
4783 name: @code{Alignment_Check} which can be used to suppress alignment checks
4784 on addresses used in address clauses. Such checks can also be suppressed
4785 by suppressing range checks, but the specific use of @code{Alignment_Check}
4786 allows suppression of alignment checks without suppressing other range checks.
4787
4788 Note that pragma Suppress gives the compiler permission to omit
4789 checks, but does not require the compiler to omit checks. The compiler
4790 will generate checks if they are essentially free, even when they are
4791 suppressed. In particular, if the compiler can prove that a certain
4792 check will necessarily fail, it will generate code to do an
4793 unconditional ``raise'', even if checks are suppressed. The compiler
4794 warns in this case.
4795
4796 Of course, run-time checks are omitted whenever the compiler can prove
4797 that they will not fail, whether or not checks are suppressed.
4798
4799 @node Pragma Suppress_All
4800 @unnumberedsec Pragma Suppress_All
4801 @findex Suppress_All
4802 @noindent
4803 Syntax:
4804
4805 @smallexample @c ada
4806 pragma Suppress_All;
4807 @end smallexample
4808
4809 @noindent
4810 This pragma can appear anywhere within a unit.
4811 The effect is to apply @code{Suppress (All_Checks)} to the unit
4812 in which it appears.  This pragma is implemented for compatibility with DEC
4813 Ada 83 usage where it appears at the end of a unit, and for compatibility
4814 with Rational Ada, where it appears as a program unit pragma.
4815 The use of the standard Ada pragma @code{Suppress (All_Checks)}
4816 as a normal configuration pragma is the preferred usage in GNAT@.
4817
4818 @node Pragma Suppress_Exception_Locations
4819 @unnumberedsec Pragma Suppress_Exception_Locations
4820 @findex Suppress_Exception_Locations
4821 @noindent
4822 Syntax:
4823
4824 @smallexample @c ada
4825 pragma Suppress_Exception_Locations;
4826 @end smallexample
4827
4828 @noindent
4829 In normal mode, a raise statement for an exception by default generates
4830 an exception message giving the file name and line number for the location
4831 of the raise. This is useful for debugging and logging purposes, but this
4832 entails extra space for the strings for the messages. The configuration
4833 pragma @code{Suppress_Exception_Locations} can be used to suppress the
4834 generation of these strings, with the result that space is saved, but the
4835 exception message for such raises is null. This configuration pragma may
4836 appear in a global configuration pragma file, or in a specific unit as
4837 usual. It is not required that this pragma be used consistently within
4838 a partition, so it is fine to have some units within a partition compiled
4839 with this pragma and others compiled in normal mode without it.
4840
4841 @node Pragma Suppress_Initialization
4842 @unnumberedsec Pragma Suppress_Initialization
4843 @findex Suppress_Initialization
4844 @cindex Suppressing initialization
4845 @cindex Initialization, suppression of
4846 @noindent
4847 Syntax:
4848
4849 @smallexample @c ada
4850 pragma Suppress_Initialization ([Entity =>] type_Name);
4851 @end smallexample
4852
4853 @noindent
4854 This pragma suppresses any implicit or explicit initialization
4855 associated with the given type name for all variables of this type.
4856
4857 @node Pragma Task_Info
4858 @unnumberedsec Pragma Task_Info
4859 @findex Task_Info
4860 @noindent
4861 Syntax
4862
4863 @smallexample @c ada
4864 pragma Task_Info (EXPRESSION);
4865 @end smallexample
4866
4867 @noindent
4868 This pragma appears within a task definition (like pragma
4869 @code{Priority}) and applies to the task in which it appears.  The
4870 argument must be of type @code{System.Task_Info.Task_Info_Type}.
4871 The @code{Task_Info} pragma provides system dependent control over
4872 aspects of tasking implementation, for example, the ability to map
4873 tasks to specific processors.  For details on the facilities available
4874 for the version of GNAT that you are using, see the documentation
4875 in the spec of package System.Task_Info in the runtime
4876 library.
4877
4878 @node Pragma Task_Name
4879 @unnumberedsec Pragma Task_Name
4880 @findex Task_Name
4881 @noindent
4882 Syntax
4883
4884 @smallexample @c ada
4885 pragma Task_Name (string_EXPRESSION);
4886 @end smallexample
4887
4888 @noindent
4889 This pragma appears within a task definition (like pragma
4890 @code{Priority}) and applies to the task in which it appears.  The
4891 argument must be of type String, and provides a name to be used for
4892 the task instance when the task is created.  Note that this expression
4893 is not required to be static, and in particular, it can contain
4894 references to task discriminants.  This facility can be used to
4895 provide different names for different tasks as they are created,
4896 as illustrated in the example below.
4897
4898 The task name is recorded internally in the run-time structures
4899 and is accessible to tools like the debugger.  In addition the
4900 routine @code{Ada.Task_Identification.Image} will return this
4901 string, with a unique task address appended.
4902
4903 @smallexample @c ada
4904 --  Example of the use of pragma Task_Name
4905
4906 with Ada.Task_Identification;
4907 use Ada.Task_Identification;
4908 with Text_IO; use Text_IO;
4909 procedure t3 is
4910
4911    type Astring is access String;
4912
4913    task type Task_Typ (Name : access String) is
4914       pragma Task_Name (Name.all);
4915    end Task_Typ;
4916
4917    task body Task_Typ is
4918       Nam : constant String := Image (Current_Task);
4919    begin
4920       Put_Line ("-->" & Nam (1 .. 14) & "<--");
4921    end Task_Typ;
4922
4923    type Ptr_Task is access Task_Typ;
4924    Task_Var : Ptr_Task;
4925
4926 begin
4927    Task_Var :=
4928      new Task_Typ (new String'("This is task 1"));
4929    Task_Var :=
4930      new Task_Typ (new String'("This is task 2"));
4931 end;
4932 @end smallexample
4933
4934 @node Pragma Task_Storage
4935 @unnumberedsec Pragma Task_Storage
4936 @findex Task_Storage
4937 Syntax:
4938
4939 @smallexample @c ada
4940 pragma Task_Storage (
4941   [Task_Type =>] LOCAL_NAME,
4942   [Top_Guard =>] static_integer_EXPRESSION);
4943 @end smallexample
4944
4945 @noindent
4946 This pragma specifies the length of the guard area for tasks.  The guard
4947 area is an additional storage area allocated to a task.  A value of zero
4948 means that either no guard area is created or a minimal guard area is
4949 created, depending on the target.  This pragma can appear anywhere a
4950 @code{Storage_Size} attribute definition clause is allowed for a task
4951 type.
4952
4953 @node Pragma Thread_Local_Storage
4954 @unnumberedsec Pragma Thread_Local_Storage
4955 @findex Thread_Local_Storage
4956 @cindex Task specific storage
4957 @cindex TLS (Thread Local Storage)
4958 Syntax:
4959
4960 @smallexample @c ada
4961 pragma Thread_Local_Storage ([Entity =>] LOCAL_NAME);
4962 @end smallexample
4963
4964 @noindent
4965 This pragma specifies that the specified entity, which must be
4966 a variable declared in a library level package, is to be marked as
4967 "Thread Local Storage" (@code{TLS}). On systems supporting this (which
4968 include Solaris, GNU/Linux and VxWorks 6), this causes each thread
4969 (and hence each Ada task) to see a distinct copy of the variable.
4970
4971 The variable may not have default initialization, and if there is
4972 an explicit initialization, it must be either @code{null} for an
4973 access variable, or a static expression for a scalar variable.
4974 This provides a low level mechanism similar to that provided by
4975 the @code{Ada.Task_Attributes} package, but much more efficient
4976 and is also useful in writing interface code that will interact
4977 with foreign threads.
4978
4979 If this pragma is used on a system where @code{TLS} is not supported,
4980 then an error message will be generated and the program will be rejected.
4981
4982 @node Pragma Time_Slice
4983 @unnumberedsec Pragma Time_Slice
4984 @findex Time_Slice
4985 @noindent
4986 Syntax:
4987
4988 @smallexample @c ada
4989 pragma Time_Slice (static_duration_EXPRESSION);
4990 @end smallexample
4991
4992 @noindent
4993 For implementations of GNAT on operating systems where it is possible
4994 to supply a time slice value, this pragma may be used for this purpose.
4995 It is ignored if it is used in a system that does not allow this control,
4996 or if it appears in other than the main program unit.
4997 @cindex OpenVMS
4998 Note that the effect of this pragma is identical to the effect of the
4999 DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
5000
5001 @node Pragma Title
5002 @unnumberedsec Pragma Title
5003 @findex Title
5004 @noindent
5005 Syntax:
5006
5007 @smallexample @c ada
5008 pragma Title (TITLING_OPTION [, TITLING OPTION]);
5009
5010 TITLING_OPTION ::=
5011   [Title    =>] STRING_LITERAL,
5012 | [Subtitle =>] STRING_LITERAL
5013 @end smallexample
5014
5015 @noindent
5016 Syntax checked but otherwise ignored by GNAT@.  This is a listing control
5017 pragma used in DEC Ada 83 implementations to provide a title and/or
5018 subtitle for the program listing.  The program listing generated by GNAT
5019 does not have titles or subtitles.
5020
5021 Unlike other pragmas, the full flexibility of named notation is allowed
5022 for this pragma, i.e.@: the parameters may be given in any order if named
5023 notation is used, and named and positional notation can be mixed
5024 following the normal rules for procedure calls in Ada.
5025
5026 @node Pragma Unchecked_Union
5027 @unnumberedsec Pragma Unchecked_Union
5028 @cindex Unions in C
5029 @findex Unchecked_Union
5030 @noindent
5031 Syntax:
5032
5033 @smallexample @c ada
5034 pragma Unchecked_Union (first_subtype_LOCAL_NAME);
5035 @end smallexample
5036
5037 @noindent
5038 This pragma is used to specify a representation of a record type that is
5039 equivalent to a C union. It was introduced as a GNAT implementation defined
5040 pragma in the GNAT Ada 95 mode. Ada 2005 includes an extended version of this
5041 pragma, making it language defined, and GNAT fully implements this extended
5042 version in all language modes (Ada 83, Ada 95, and Ada 2005). For full
5043 details, consult the Ada 2005 Reference Manual, section B.3.3.
5044
5045 @node Pragma Unimplemented_Unit
5046 @unnumberedsec Pragma Unimplemented_Unit
5047 @findex Unimplemented_Unit
5048 @noindent
5049 Syntax:
5050
5051 @smallexample @c ada
5052 pragma Unimplemented_Unit;
5053 @end smallexample
5054
5055 @noindent
5056 If this pragma occurs in a unit that is processed by the compiler, GNAT
5057 aborts with the message @samp{@var{xxx} not implemented}, where
5058 @var{xxx} is the name of the current compilation unit.  This pragma is
5059 intended to allow the compiler to handle unimplemented library units in
5060 a clean manner.
5061
5062 The abort only happens if code is being generated.  Thus you can use
5063 specs of unimplemented packages in syntax or semantic checking mode.
5064
5065 @node Pragma Universal_Aliasing
5066 @unnumberedsec Pragma Universal_Aliasing
5067 @findex Universal_Aliasing
5068 @noindent
5069 Syntax:
5070
5071 @smallexample @c ada
5072 pragma Universal_Aliasing [([Entity =>] type_LOCAL_NAME)];
5073 @end smallexample
5074
5075 @noindent
5076 @var{type_LOCAL_NAME} must refer to a type declaration in the current
5077 declarative part.  The effect is to inhibit strict type-based aliasing
5078 optimization for the given type.  In other words, the effect is as though
5079 access types designating this type were subject to pragma No_Strict_Aliasing.
5080 For a detailed description of the strict aliasing optimization, and the
5081 situations in which it must be suppressed, @xref{Optimization and Strict
5082 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
5083
5084 @node Pragma Universal_Data
5085 @unnumberedsec Pragma Universal_Data
5086 @findex Universal_Data
5087 @noindent
5088 Syntax:
5089
5090 @smallexample @c ada
5091 pragma Universal_Data [(library_unit_Name)];
5092 @end smallexample
5093
5094 @noindent
5095 This pragma is supported only for the AAMP target and is ignored for
5096 other targets. The pragma specifies that all library-level objects
5097 (Counter 0 data) associated with the library unit are to be accessed
5098 and updated using universal addressing (24-bit addresses for AAMP5)
5099 rather than the default of 16-bit Data Environment (DENV) addressing.
5100 Use of this pragma will generally result in less efficient code for
5101 references to global data associated with the library unit, but
5102 allows such data to be located anywhere in memory. This pragma is
5103 a library unit pragma, but can also be used as a configuration pragma
5104 (including use in the @file{gnat.adc} file). The functionality
5105 of this pragma is also available by applying the -univ switch on the
5106 compilations of units where universal addressing of the data is desired.
5107
5108 @node Pragma Unmodified
5109 @unnumberedsec Pragma Unmodified
5110 @findex Unmodified
5111 @cindex Warnings, unmodified
5112 @noindent
5113 Syntax:
5114
5115 @smallexample @c ada
5116 pragma Unmodified (LOCAL_NAME @{, LOCAL_NAME@});
5117 @end smallexample
5118
5119 @noindent
5120 This pragma signals that the assignable entities (variables,
5121 @code{out} parameters, @code{in out} parameters) whose names are listed are
5122 deliberately not assigned in the current source unit. This
5123 suppresses warnings about the
5124 entities being referenced but not assigned, and in addition a warning will be
5125 generated if one of these entities is in fact assigned in the
5126 same unit as the pragma (or in the corresponding body, or one
5127 of its subunits).
5128
5129 This is particularly useful for clearly signaling that a particular
5130 parameter is not modified, even though the spec suggests that it might
5131 be.
5132
5133 @node Pragma Unreferenced
5134 @unnumberedsec Pragma Unreferenced
5135 @findex Unreferenced
5136 @cindex Warnings, unreferenced
5137 @noindent
5138 Syntax:
5139
5140 @smallexample @c ada
5141 pragma Unreferenced (LOCAL_NAME @{, LOCAL_NAME@});
5142 pragma Unreferenced (library_unit_NAME @{, library_unit_NAME@});
5143 @end smallexample
5144
5145 @noindent
5146 This pragma signals that the entities whose names are listed are
5147 deliberately not referenced in the current source unit. This
5148 suppresses warnings about the
5149 entities being unreferenced, and in addition a warning will be
5150 generated if one of these entities is in fact referenced in the
5151 same unit as the pragma (or in the corresponding body, or one
5152 of its subunits).
5153
5154 This is particularly useful for clearly signaling that a particular
5155 parameter is not referenced in some particular subprogram implementation
5156 and that this is deliberate. It can also be useful in the case of
5157 objects declared only for their initialization or finalization side
5158 effects.
5159
5160 If @code{LOCAL_NAME} identifies more than one matching homonym in the
5161 current scope, then the entity most recently declared is the one to which
5162 the pragma applies. Note that in the case of accept formals, the pragma
5163 Unreferenced may appear immediately after the keyword @code{do} which
5164 allows the indication of whether or not accept formals are referenced
5165 or not to be given individually for each accept statement.
5166
5167 The left hand side of an assignment does not count as a reference for the
5168 purpose of this pragma. Thus it is fine to assign to an entity for which
5169 pragma Unreferenced is given.
5170
5171 Note that if a warning is desired for all calls to a given subprogram,
5172 regardless of whether they occur in the same unit as the subprogram
5173 declaration, then this pragma should not be used (calls from another
5174 unit would not be flagged); pragma Obsolescent can be used instead
5175 for this purpose, see @xref{Pragma Obsolescent}.
5176
5177 The second form of pragma @code{Unreferenced} is used within a context
5178 clause. In this case the arguments must be unit names of units previously
5179 mentioned in @code{with} clauses (similar to the usage of pragma
5180 @code{Elaborate_All}. The effect is to suppress warnings about unreferenced
5181 units and unreferenced entities within these units.
5182
5183 @node Pragma Unreferenced_Objects
5184 @unnumberedsec Pragma Unreferenced_Objects
5185 @findex Unreferenced_Objects
5186 @cindex Warnings, unreferenced
5187 @noindent
5188 Syntax:
5189
5190 @smallexample @c ada
5191 pragma Unreferenced_Objects (local_subtype_NAME @{, local_subtype_NAME@});
5192 @end smallexample
5193
5194 @noindent
5195 This pragma signals that for the types or subtypes whose names are
5196 listed, objects which are declared with one of these types or subtypes may
5197 not be referenced, and if no references appear, no warnings are given.
5198
5199 This is particularly useful for objects which are declared solely for their
5200 initialization and finalization effect. Such variables are sometimes referred
5201 to as RAII variables (Resource Acquisition Is Initialization). Using this
5202 pragma on the relevant type (most typically a limited controlled type), the
5203 compiler will automatically suppress unwanted warnings about these variables
5204 not being referenced.
5205
5206 @node Pragma Unreserve_All_Interrupts
5207 @unnumberedsec Pragma Unreserve_All_Interrupts
5208 @findex Unreserve_All_Interrupts
5209 @noindent
5210 Syntax:
5211
5212 @smallexample @c ada
5213 pragma Unreserve_All_Interrupts;
5214 @end smallexample
5215
5216 @noindent
5217 Normally certain interrupts are reserved to the implementation.  Any attempt
5218 to attach an interrupt causes Program_Error to be raised, as described in
5219 RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
5220 many systems for a @kbd{Ctrl-C} interrupt.  Normally this interrupt is
5221 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
5222 interrupt execution.
5223
5224 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
5225 a program, then all such interrupts are unreserved.  This allows the
5226 program to handle these interrupts, but disables their standard
5227 functions.  For example, if this pragma is used, then pressing
5228 @kbd{Ctrl-C} will not automatically interrupt execution.  However,
5229 a program can then handle the @code{SIGINT} interrupt as it chooses.
5230
5231 For a full list of the interrupts handled in a specific implementation,
5232 see the source code for the spec of @code{Ada.Interrupts.Names} in
5233 file @file{a-intnam.ads}.  This is a target dependent file that contains the
5234 list of interrupts recognized for a given target.  The documentation in
5235 this file also specifies what interrupts are affected by the use of
5236 the @code{Unreserve_All_Interrupts} pragma.
5237
5238 For a more general facility for controlling what interrupts can be
5239 handled, see pragma @code{Interrupt_State}, which subsumes the functionality
5240 of the @code{Unreserve_All_Interrupts} pragma.
5241
5242 @node Pragma Unsuppress
5243 @unnumberedsec Pragma Unsuppress
5244 @findex Unsuppress
5245 @noindent
5246 Syntax:
5247
5248 @smallexample @c ada
5249 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
5250 @end smallexample
5251
5252 @noindent
5253 This pragma undoes the effect of a previous pragma @code{Suppress}.  If
5254 there is no corresponding pragma @code{Suppress} in effect, it has no
5255 effect.  The range of the effect is the same as for pragma
5256 @code{Suppress}.  The meaning of the arguments is identical to that used
5257 in pragma @code{Suppress}.
5258
5259 One important application is to ensure that checks are on in cases where
5260 code depends on the checks for its correct functioning, so that the code
5261 will compile correctly even if the compiler switches are set to suppress
5262 checks.
5263
5264 @node Pragma Use_VADS_Size
5265 @unnumberedsec Pragma Use_VADS_Size
5266 @cindex @code{Size}, VADS compatibility
5267 @findex Use_VADS_Size
5268 @noindent
5269 Syntax:
5270
5271 @smallexample @c ada
5272 pragma Use_VADS_Size;
5273 @end smallexample
5274
5275 @noindent
5276 This is a configuration pragma.  In a unit to which it applies, any use
5277 of the 'Size attribute is automatically interpreted as a use of the
5278 'VADS_Size attribute.  Note that this may result in incorrect semantic
5279 processing of valid Ada 95 or Ada 2005 programs.  This is intended to aid in
5280 the handling of existing code which depends on the interpretation of Size
5281 as implemented in the VADS compiler.  See description of the VADS_Size
5282 attribute for further details.
5283
5284 @node Pragma Validity_Checks
5285 @unnumberedsec Pragma Validity_Checks
5286 @findex Validity_Checks
5287 @noindent
5288 Syntax:
5289
5290 @smallexample @c ada
5291 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
5292 @end smallexample
5293
5294 @noindent
5295 This pragma is used in conjunction with compiler switches to control the
5296 built-in validity checking provided by GNAT@.  The compiler switches, if set
5297 provide an initial setting for the switches, and this pragma may be used
5298 to modify these settings, or the settings may be provided entirely by
5299 the use of the pragma.  This pragma can be used anywhere that a pragma
5300 is legal, including use as a configuration pragma (including use in
5301 the @file{gnat.adc} file).
5302
5303 The form with a string literal specifies which validity options are to be
5304 activated.  The validity checks are first set to include only the default
5305 reference manual settings, and then a string of letters in the string
5306 specifies the exact set of options required.  The form of this string
5307 is exactly as described for the @option{-gnatVx} compiler switch (see the
5308 GNAT users guide for details).  For example the following two methods
5309 can be used to enable validity checking for mode @code{in} and
5310 @code{in out} subprogram parameters:
5311
5312 @itemize @bullet
5313 @item
5314 @smallexample @c ada
5315 pragma Validity_Checks ("im");
5316 @end smallexample
5317
5318 @item
5319 @smallexample
5320 gcc -c -gnatVim @dots{}
5321 @end smallexample
5322 @end itemize
5323
5324 @noindent
5325 The form ALL_CHECKS activates all standard checks (its use is equivalent
5326 to the use of the @code{gnatva} switch.
5327
5328 The forms with @code{Off} and @code{On}
5329 can be used to temporarily disable validity checks
5330 as shown in the following example:
5331
5332 @smallexample @c ada
5333 @iftex
5334 @leftskip=0cm
5335 @end iftex
5336 pragma Validity_Checks ("c"); -- validity checks for copies
5337 pragma Validity_Checks (Off); -- turn off validity checks
5338 A := B;                       -- B will not be validity checked
5339 pragma Validity_Checks (On);  -- turn validity checks back on
5340 A := C;                       -- C will be validity checked
5341 @end smallexample
5342
5343 @node Pragma Volatile
5344 @unnumberedsec Pragma Volatile
5345 @findex Volatile
5346 @noindent
5347 Syntax:
5348
5349 @smallexample @c ada
5350 pragma Volatile (LOCAL_NAME);
5351 @end smallexample
5352
5353 @noindent
5354 This pragma is defined by the Ada Reference Manual, and the GNAT
5355 implementation is fully conformant with this definition.  The reason it
5356 is mentioned in this section is that a pragma of the same name was supplied
5357 in some Ada 83 compilers, including DEC Ada 83.  The Ada 95 / Ada 2005
5358 implementation of pragma Volatile is upwards compatible with the
5359 implementation in DEC Ada 83.
5360
5361 @node Pragma Warnings
5362 @unnumberedsec Pragma Warnings
5363 @findex Warnings
5364 @noindent
5365 Syntax:
5366
5367 @smallexample @c ada
5368 pragma Warnings (On | Off);
5369 pragma Warnings (On | Off, LOCAL_NAME);
5370 pragma Warnings (static_string_EXPRESSION);
5371 pragma Warnings (On | Off, static_string_EXPRESSION);
5372 @end smallexample
5373
5374 @noindent
5375 Normally warnings are enabled, with the output being controlled by
5376 the command line switch.  Warnings (@code{Off}) turns off generation of
5377 warnings until a Warnings (@code{On}) is encountered or the end of the
5378 current unit.  If generation of warnings is turned off using this
5379 pragma, then no warning messages are output, regardless of the
5380 setting of the command line switches.
5381
5382 The form with a single argument may be used as a configuration pragma.
5383
5384 If the @var{LOCAL_NAME} parameter is present, warnings are suppressed for
5385 the specified entity.  This suppression is effective from the point where
5386 it occurs till the end of the extended scope of the variable (similar to
5387 the scope of @code{Suppress}).
5388
5389 The form with a single static_string_EXPRESSION argument provides more precise
5390 control over which warnings are active. The string is a list of letters
5391 specifying which warnings are to be activated and which deactivated. The
5392 code for these letters is the same as the string used in the command
5393 line switch controlling warnings. For a brief summary, use the gnatmake
5394 command with no arguments, which will generate usage information containing
5395 the list of warnings switches supported. For
5396 full details see @ref{Warning Message Control,,, gnat_ugn, @value{EDITION}
5397 User's Guide}.
5398
5399 @noindent
5400 The specified warnings will be in effect until the end of the program
5401 or another pragma Warnings is encountered. The effect of the pragma is
5402 cumulative. Initially the set of warnings is the standard default set
5403 as possibly modified by compiler switches. Then each pragma Warning
5404 modifies this set of warnings as specified. This form of the pragma may
5405 also be used as a configuration pragma.
5406
5407 The fourth form, with an On|Off parameter and a string, is used to
5408 control individual messages, based on their text. The string argument
5409 is a pattern that is used to match against the text of individual
5410 warning messages (not including the initial "warning: " tag).
5411
5412 The pattern may contain asterisks, which match zero or more characters in
5413 the message. For example, you can use
5414 @code{pragma Warnings (Off, "*bits of*unused")} to suppress the warning
5415 message @code{warning: 960 bits of "a" unused}. No other regular
5416 expression notations are permitted. All characters other than asterisk in
5417 these three specific cases are treated as literal characters in the match.
5418
5419 There are two ways to use this pragma. The OFF form can be used as a
5420 configuration pragma. The effect is to suppress all warnings (if any)
5421 that match the pattern string throughout the compilation.
5422
5423 The second usage is to suppress a warning locally, and in this case, two
5424 pragmas must appear in sequence:
5425
5426 @smallexample @c ada
5427 pragma Warnings (Off, Pattern);
5428 @dots{} code where given warning is to be suppressed
5429 pragma Warnings (On, Pattern);
5430 @end smallexample
5431
5432 @noindent
5433 In this usage, the pattern string must match in the Off and On pragmas,
5434 and at least one matching warning must be suppressed.
5435
5436 Note: the debug flag -gnatd.i (@code{/NOWARNINGS_PRAGMAS} in VMS) can be
5437 used to cause the compiler to entirely ignore all WARNINGS pragmas. This can
5438 be useful in checking whether obsolete pragmas in existing programs are hiding
5439 real problems.
5440
5441 Note: pragma Warnings does not affect the processing of style messages. See
5442 separate entry for pragma Style_Checks for control of style messages.
5443
5444 @node Pragma Weak_External
5445 @unnumberedsec Pragma Weak_External
5446 @findex Weak_External
5447 @noindent
5448 Syntax:
5449
5450 @smallexample @c ada
5451 pragma Weak_External ([Entity =>] LOCAL_NAME);
5452 @end smallexample
5453
5454 @noindent
5455 @var{LOCAL_NAME} must refer to an object that is declared at the library
5456 level. This pragma specifies that the given entity should be marked as a
5457 weak symbol for the linker. It is equivalent to @code{__attribute__((weak))}
5458 in GNU C and causes @var{LOCAL_NAME} to be emitted as a weak symbol instead
5459 of a regular symbol, that is to say a symbol that does not have to be
5460 resolved by the linker if used in conjunction with a pragma Import.
5461
5462 When a weak symbol is not resolved by the linker, its address is set to
5463 zero. This is useful in writing interfaces to external modules that may
5464 or may not be linked in the final executable, for example depending on
5465 configuration settings.
5466
5467 If a program references at run time an entity to which this pragma has been
5468 applied, and the corresponding symbol was not resolved at link time, then
5469 the execution of the program is erroneous. It is not erroneous to take the
5470 Address of such an entity, for example to guard potential references,
5471 as shown in the example below.
5472
5473 Some file formats do not support weak symbols so not all target machines
5474 support this pragma.
5475
5476 @smallexample @c ada
5477 --  Example of the use of pragma Weak_External
5478
5479 package External_Module is
5480   key : Integer;
5481   pragma Import (C, key);
5482   pragma Weak_External (key);
5483   function Present return boolean;
5484 end External_Module;
5485
5486 with System; use System;
5487 package body External_Module is
5488   function Present return boolean is
5489   begin
5490     return key'Address /= System.Null_Address;
5491   end Present;
5492 end External_Module;
5493 @end smallexample
5494
5495 @node Pragma Wide_Character_Encoding
5496 @unnumberedsec Pragma Wide_Character_Encoding
5497 @findex Wide_Character_Encoding
5498 @noindent
5499 Syntax:
5500
5501 @smallexample @c ada
5502 pragma Wide_Character_Encoding (IDENTIFIER | CHARACTER_LITERAL);
5503 @end smallexample
5504
5505 @noindent
5506 This pragma specifies the wide character encoding to be used in program
5507 source text appearing subsequently. It is a configuration pragma, but may
5508 also be used at any point that a pragma is allowed, and it is permissible
5509 to have more than one such pragma in a file, allowing multiple encodings
5510 to appear within the same file.
5511
5512 The argument can be an identifier or a character literal. In the identifier
5513 case, it is one of @code{HEX}, @code{UPPER}, @code{SHIFT_JIS},
5514 @code{EUC}, @code{UTF8}, or @code{BRACKETS}. In the character literal
5515 case it is correspondingly one of the characters @samp{h}, @samp{u},
5516 @samp{s}, @samp{e}, @samp{8}, or @samp{b}.
5517
5518 Note that when the pragma is used within a file, it affects only the
5519 encoding within that file, and does not affect withed units, specs,
5520 or subunits.
5521
5522 @node Implementation Defined Attributes
5523 @chapter Implementation Defined Attributes
5524 Ada defines (throughout the Ada reference manual,
5525 summarized in Annex K),
5526 a set of attributes that provide useful additional functionality in all
5527 areas of the language.  These language defined attributes are implemented
5528 in GNAT and work as described in the Ada Reference Manual.
5529
5530 In addition, Ada allows implementations to define additional
5531 attributes whose meaning is defined by the implementation.  GNAT provides
5532 a number of these implementation-dependent attributes which can be used
5533 to extend and enhance the functionality of the compiler.  This section of
5534 the GNAT reference manual describes these additional attributes.
5535
5536 Note that any program using these attributes may not be portable to
5537 other compilers (although GNAT implements this set of attributes on all
5538 platforms).  Therefore if portability to other compilers is an important
5539 consideration, you should minimize the use of these attributes.
5540
5541 @menu
5542 * Abort_Signal::
5543 * Address_Size::
5544 * Asm_Input::
5545 * Asm_Output::
5546 * AST_Entry::
5547 * Bit::
5548 * Bit_Position::
5549 * Compiler_Version::
5550 * Code_Address::
5551 * Default_Bit_Order::
5552 * Elaborated::
5553 * Elab_Body::
5554 * Elab_Spec::
5555 * Emax::
5556 * Enabled::
5557 * Enum_Rep::
5558 * Enum_Val::
5559 * Epsilon::
5560 * Fixed_Value::
5561 * Has_Access_Values::
5562 * Has_Discriminants::
5563 * Img::
5564 * Integer_Value::
5565 * Invalid_Value::
5566 * Large::
5567 * Machine_Size::
5568 * Mantissa::
5569 * Max_Interrupt_Priority::
5570 * Max_Priority::
5571 * Maximum_Alignment::
5572 * Mechanism_Code::
5573 * Null_Parameter::
5574 * Object_Size::
5575 * Old::
5576 * Passed_By_Reference::
5577 * Pool_Address::
5578 * Range_Length::
5579 * Ref::
5580 * Result::
5581 * Safe_Emax::
5582 * Safe_Large::
5583 * Small::
5584 * Storage_Unit::
5585 * Stub_Type::
5586 * Target_Name::
5587 * Tick::
5588 * To_Address::
5589 * Type_Class::
5590 * UET_Address::
5591 * Unconstrained_Array::
5592 * Universal_Literal_String::
5593 * Unrestricted_Access::
5594 * VADS_Size::
5595 * Value_Size::
5596 * Wchar_T_Size::
5597 * Word_Size::
5598 @end menu
5599
5600 @node Abort_Signal
5601 @unnumberedsec Abort_Signal
5602 @findex Abort_Signal
5603 @noindent
5604 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
5605 prefix) provides the entity for the special exception used to signal
5606 task abort or asynchronous transfer of control.  Normally this attribute
5607 should only be used in the tasking runtime (it is highly peculiar, and
5608 completely outside the normal semantics of Ada, for a user program to
5609 intercept the abort exception).
5610
5611 @node Address_Size
5612 @unnumberedsec Address_Size
5613 @cindex Size of @code{Address}
5614 @findex Address_Size
5615 @noindent
5616 @code{Standard'Address_Size} (@code{Standard} is the only allowed
5617 prefix) is a static constant giving the number of bits in an
5618 @code{Address}. It is the same value as System.Address'Size,
5619 but has the advantage of being static, while a direct
5620 reference to System.Address'Size is non-static because Address
5621 is a private type.
5622
5623 @node Asm_Input
5624 @unnumberedsec Asm_Input
5625 @findex Asm_Input
5626 @noindent
5627 The @code{Asm_Input} attribute denotes a function that takes two
5628 parameters.  The first is a string, the second is an expression of the
5629 type designated by the prefix.  The first (string) argument is required
5630 to be a static expression, and is the constraint for the parameter,
5631 (e.g.@: what kind of register is required).  The second argument is the
5632 value to be used as the input argument.  The possible values for the
5633 constant are the same as those used in the RTL, and are dependent on
5634 the configuration file used to built the GCC back end.
5635 @ref{Machine Code Insertions}
5636
5637 @node Asm_Output
5638 @unnumberedsec Asm_Output
5639 @findex Asm_Output
5640 @noindent
5641 The @code{Asm_Output} attribute denotes a function that takes two
5642 parameters.  The first is a string, the second is the name of a variable
5643 of the type designated by the attribute prefix.  The first (string)
5644 argument is required to be a static expression and designates the
5645 constraint for the parameter (e.g.@: what kind of register is
5646 required).  The second argument is the variable to be updated with the
5647 result.  The possible values for constraint are the same as those used in
5648 the RTL, and are dependent on the configuration file used to build the
5649 GCC back end.  If there are no output operands, then this argument may
5650 either be omitted, or explicitly given as @code{No_Output_Operands}.
5651 @ref{Machine Code Insertions}
5652
5653 @node AST_Entry
5654 @unnumberedsec AST_Entry
5655 @cindex OpenVMS
5656 @findex AST_Entry
5657 @noindent
5658 This attribute is implemented only in OpenVMS versions of GNAT@.  Applied to
5659 the name of an entry, it yields a value of the predefined type AST_Handler
5660 (declared in the predefined package System, as extended by the use of
5661 pragma @code{Extend_System (Aux_DEC)}).  This value enables the given entry to
5662 be called when an AST occurs.  For further details, refer to the @cite{DEC Ada
5663 Language Reference Manual}, section 9.12a.
5664
5665 @node Bit
5666 @unnumberedsec Bit
5667 @findex Bit
5668 @code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
5669 offset within the storage unit (byte) that contains the first bit of
5670 storage allocated for the object.  The value of this attribute is of the
5671 type @code{Universal_Integer}, and is always a non-negative number not
5672 exceeding the value of @code{System.Storage_Unit}.
5673
5674 For an object that is a variable or a constant allocated in a register,
5675 the value is zero.  (The use of this attribute does not force the
5676 allocation of a variable to memory).
5677
5678 For an object that is a formal parameter, this attribute applies
5679 to either the matching actual parameter or to a copy of the
5680 matching actual parameter.
5681
5682 For an access object the value is zero.  Note that
5683 @code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
5684 designated object.  Similarly for a record component
5685 @code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
5686 @code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
5687 are subject to index checks.
5688
5689 This attribute is designed to be compatible with the DEC Ada 83 definition
5690 and implementation of the @code{Bit} attribute.
5691
5692 @node Bit_Position
5693 @unnumberedsec Bit_Position
5694 @findex Bit_Position
5695 @noindent
5696 @code{@var{R.C}'Bit_Position}, where @var{R} is a record object and C is one
5697 of the fields of the record type, yields the bit
5698 offset within the record contains the first bit of
5699 storage allocated for the object.  The value of this attribute is of the
5700 type @code{Universal_Integer}.  The value depends only on the field
5701 @var{C} and is independent of the alignment of
5702 the containing record @var{R}.
5703
5704 @node Compiler_Version
5705 @unnumberedsec Compiler_Version
5706 @findex Compiler_Version
5707 @noindent
5708 @code{Standard'Compiler_Version} (@code{Standard} is the only allowed
5709 prefix) yields a static string identifying the version of the compiler
5710 being used to compile the unit containing the attribute reference. A
5711 typical result would be something like "GNAT Pro 6.3.0w (20090221)".
5712
5713 @node Code_Address
5714 @unnumberedsec Code_Address
5715 @findex Code_Address
5716 @cindex Subprogram address
5717 @cindex Address of subprogram code
5718 @noindent
5719 The @code{'Address}
5720 attribute may be applied to subprograms in Ada 95 and Ada 2005, but the
5721 intended effect seems to be to provide
5722 an address value which can be used to call the subprogram by means of
5723 an address clause as in the following example:
5724
5725 @smallexample @c ada
5726 procedure K is @dots{}
5727
5728 procedure L;
5729 for L'Address use K'Address;
5730 pragma Import (Ada, L);
5731 @end smallexample
5732
5733 @noindent
5734 A call to @code{L} is then expected to result in a call to @code{K}@.
5735 In Ada 83, where there were no access-to-subprogram values, this was
5736 a common work-around for getting the effect of an indirect call.
5737 GNAT implements the above use of @code{Address} and the technique
5738 illustrated by the example code works correctly.
5739
5740 However, for some purposes, it is useful to have the address of the start
5741 of the generated code for the subprogram.  On some architectures, this is
5742 not necessarily the same as the @code{Address} value described above.
5743 For example, the @code{Address} value may reference a subprogram
5744 descriptor rather than the subprogram itself.
5745
5746 The @code{'Code_Address} attribute, which can only be applied to
5747 subprogram entities, always returns the address of the start of the
5748 generated code of the specified subprogram, which may or may not be
5749 the same value as is returned by the corresponding @code{'Address}
5750 attribute.
5751
5752 @node Default_Bit_Order
5753 @unnumberedsec Default_Bit_Order
5754 @cindex Big endian
5755 @cindex Little endian
5756 @findex Default_Bit_Order
5757 @noindent
5758 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
5759 permissible prefix), provides the value @code{System.Default_Bit_Order}
5760 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
5761 @code{Low_Order_First}).  This is used to construct the definition of
5762 @code{Default_Bit_Order} in package @code{System}.
5763
5764 @node Elaborated
5765 @unnumberedsec Elaborated
5766 @findex Elaborated
5767 @noindent
5768 The prefix of the @code{'Elaborated} attribute must be a unit name.  The
5769 value is a Boolean which indicates whether or not the given unit has been
5770 elaborated.  This attribute is primarily intended for internal use by the
5771 generated code for dynamic elaboration checking, but it can also be used
5772 in user programs.  The value will always be True once elaboration of all
5773 units has been completed.  An exception is for units which need no
5774 elaboration, the value is always False for such units.
5775
5776 @node Elab_Body
5777 @unnumberedsec Elab_Body
5778 @findex Elab_Body
5779 @noindent
5780 This attribute can only be applied to a program unit name.  It returns
5781 the entity for the corresponding elaboration procedure for elaborating
5782 the body of the referenced unit.  This is used in the main generated
5783 elaboration procedure by the binder and is not normally used in any
5784 other context.  However, there may be specialized situations in which it
5785 is useful to be able to call this elaboration procedure from Ada code,
5786 e.g.@: if it is necessary to do selective re-elaboration to fix some
5787 error.
5788
5789 @node Elab_Spec
5790 @unnumberedsec Elab_Spec
5791 @findex Elab_Spec
5792 @noindent
5793 This attribute can only be applied to a program unit name.  It returns
5794 the entity for the corresponding elaboration procedure for elaborating
5795 the spec of the referenced unit.  This is used in the main
5796 generated elaboration procedure by the binder and is not normally used
5797 in any other context.  However, there may be specialized situations in
5798 which it is useful to be able to call this elaboration procedure from
5799 Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
5800 some error.
5801
5802 @node Emax
5803 @unnumberedsec Emax
5804 @cindex Ada 83 attributes
5805 @findex Emax
5806 @noindent
5807 The @code{Emax} attribute is provided for compatibility with Ada 83.  See
5808 the Ada 83 reference manual for an exact description of the semantics of
5809 this attribute.
5810
5811 @node Enabled
5812 @unnumberedsec Enabled
5813 @findex Enabled
5814 @noindent
5815 The @code{Enabled} attribute allows an application program to check at compile
5816 time to see if the designated check is currently enabled. The prefix is a
5817 simple identifier, referencing any predefined check name (other than
5818 @code{All_Checks}) or a check name introduced by pragma Check_Name. If
5819 no argument is given for the attribute, the check is for the general state
5820 of the check, if an argument is given, then it is an entity name, and the
5821 check indicates whether an @code{Suppress} or @code{Unsuppress} has been
5822 given naming the entity (if not, then the argument is ignored).
5823
5824 Note that instantiations inherit the check status at the point of the
5825 instantiation, so a useful idiom is to have a library package that
5826 introduces a check name with @code{pragma Check_Name}, and then contains
5827 generic packages or subprograms which use the @code{Enabled} attribute
5828 to see if the check is enabled. A user of this package can then issue
5829 a @code{pragma Suppress} or @code{pragma Unsuppress} before instantiating
5830 the package or subprogram, controlling whether the check will be present.
5831
5832 @node Enum_Rep
5833 @unnumberedsec Enum_Rep
5834 @cindex Representation of enums
5835 @findex Enum_Rep
5836 @noindent
5837 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
5838 function with the following spec:
5839
5840 @smallexample @c ada
5841 function @var{S}'Enum_Rep (Arg : @var{S}'Base)
5842   return @i{Universal_Integer};
5843 @end smallexample
5844
5845 @noindent
5846 It is also allowable to apply @code{Enum_Rep} directly to an object of an
5847 enumeration type or to a non-overloaded enumeration
5848 literal.  In this case @code{@var{S}'Enum_Rep} is equivalent to
5849 @code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
5850 enumeration literal or object.
5851
5852 The function returns the representation value for the given enumeration
5853 value.  This will be equal to value of the @code{Pos} attribute in the
5854 absence of an enumeration representation clause.  This is a static
5855 attribute (i.e.@: the result is static if the argument is static).
5856
5857 @code{@var{S}'Enum_Rep} can also be used with integer types and objects,
5858 in which case it simply returns the integer value.  The reason for this
5859 is to allow it to be used for @code{(<>)} discrete formal arguments in
5860 a generic unit that can be instantiated with either enumeration types
5861 or integer types.  Note that if @code{Enum_Rep} is used on a modular
5862 type whose upper bound exceeds the upper bound of the largest signed
5863 integer type, and the argument is a variable, so that the universal
5864 integer calculation is done at run time, then the call to @code{Enum_Rep}
5865 may raise @code{Constraint_Error}.
5866
5867 @node Enum_Val
5868 @unnumberedsec Enum_Val
5869 @cindex Representation of enums
5870 @findex Enum_Val
5871 @noindent
5872 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Val} denotes a
5873 function with the following spec:
5874
5875 @smallexample @c ada
5876 function @var{S}'Enum_Val (Arg : @i{Universal_Integer)
5877   return @var{S}'Base};
5878 @end smallexample
5879
5880 @noindent
5881 The function returns the enumeration value whose representation matches the
5882 argument, or raises Constraint_Error if no enumeration literal of the type
5883 has the matching value.
5884 This will be equal to value of the @code{Val} attribute in the
5885 absence of an enumeration representation clause.  This is a static
5886 attribute (i.e.@: the result is static if the argument is static).
5887
5888 @node Epsilon
5889 @unnumberedsec Epsilon
5890 @cindex Ada 83 attributes
5891 @findex Epsilon
5892 @noindent
5893 The @code{Epsilon} attribute is provided for compatibility with Ada 83.  See
5894 the Ada 83 reference manual for an exact description of the semantics of
5895 this attribute.
5896
5897 @node Fixed_Value
5898 @unnumberedsec Fixed_Value
5899 @findex Fixed_Value
5900 @noindent
5901 For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
5902 function with the following specification:
5903
5904 @smallexample @c ada
5905 function @var{S}'Fixed_Value (Arg : @i{Universal_Integer})
5906   return @var{S};
5907 @end smallexample
5908
5909 @noindent
5910 The value returned is the fixed-point value @var{V} such that
5911
5912 @smallexample @c ada
5913 @var{V} = Arg * @var{S}'Small
5914 @end smallexample
5915
5916 @noindent
5917 The effect is thus similar to first converting the argument to the
5918 integer type used to represent @var{S}, and then doing an unchecked
5919 conversion to the fixed-point type.  The difference is
5920 that there are full range checks, to ensure that the result is in range.
5921 This attribute is primarily intended for use in implementation of the
5922 input-output functions for fixed-point values.
5923
5924 @node Has_Access_Values
5925 @unnumberedsec Has_Access_Values
5926 @cindex Access values, testing for
5927 @findex Has_Access_Values
5928 @noindent
5929 The prefix of the @code{Has_Access_Values} attribute is a type.  The result
5930 is a Boolean value which is True if the is an access type, or is a composite
5931 type with a component (at any nesting depth) that is an access type, and is
5932 False otherwise.
5933 The intended use of this attribute is in conjunction with generic
5934 definitions.  If the attribute is applied to a generic private type, it
5935 indicates whether or not the corresponding actual type has access values.
5936
5937 @node Has_Discriminants
5938 @unnumberedsec Has_Discriminants
5939 @cindex Discriminants, testing for
5940 @findex Has_Discriminants
5941 @noindent
5942 The prefix of the @code{Has_Discriminants} attribute is a type.  The result
5943 is a Boolean value which is True if the type has discriminants, and False
5944 otherwise.  The intended use of this attribute is in conjunction with generic
5945 definitions.  If the attribute is applied to a generic private type, it
5946 indicates whether or not the corresponding actual type has discriminants.
5947
5948 @node Img
5949 @unnumberedsec Img
5950 @findex Img
5951 @noindent
5952 The @code{Img} attribute differs from @code{Image} in that it may be
5953 applied to objects as well as types, in which case it gives the
5954 @code{Image} for the subtype of the object.  This is convenient for
5955 debugging:
5956
5957 @smallexample @c ada
5958 Put_Line ("X = " & X'Img);
5959 @end smallexample
5960
5961 @noindent
5962 has the same meaning as the more verbose:
5963
5964 @smallexample @c ada
5965 Put_Line ("X = " & @var{T}'Image (X));
5966 @end smallexample
5967
5968 @noindent
5969 where @var{T} is the (sub)type of the object @code{X}.
5970
5971 @node Integer_Value
5972 @unnumberedsec Integer_Value
5973 @findex Integer_Value
5974 @noindent
5975 For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
5976 function with the following spec:
5977
5978 @smallexample @c ada
5979 function @var{S}'Integer_Value (Arg : @i{Universal_Fixed})
5980   return @var{S};
5981 @end smallexample
5982
5983 @noindent
5984 The value returned is the integer value @var{V}, such that
5985
5986 @smallexample @c ada
5987 Arg = @var{V} * @var{T}'Small
5988 @end smallexample
5989
5990 @noindent
5991 where @var{T} is the type of @code{Arg}.
5992 The effect is thus similar to first doing an unchecked conversion from
5993 the fixed-point type to its corresponding implementation type, and then
5994 converting the result to the target integer type.  The difference is
5995 that there are full range checks, to ensure that the result is in range.
5996 This attribute is primarily intended for use in implementation of the
5997 standard input-output functions for fixed-point values.
5998
5999 @node Invalid_Value
6000 @unnumberedsec Invalid_Value
6001 @findex Invalid_Value
6002 @noindent
6003 For every scalar type S, S'Invalid_Value returns an undefined value of the
6004 type. If possible this value is an invalid representation for the type. The
6005 value returned is identical to the value used to initialize an otherwise
6006 uninitialized value of the type if pragma Initialize_Scalars is used,
6007 including the ability to modify the value with the binder -Sxx flag and
6008 relevant environment variables at run time.
6009
6010 @node Large
6011 @unnumberedsec Large
6012 @cindex Ada 83 attributes
6013 @findex Large
6014 @noindent
6015 The @code{Large} attribute is provided for compatibility with Ada 83.  See
6016 the Ada 83 reference manual for an exact description of the semantics of
6017 this attribute.
6018
6019 @node Machine_Size
6020 @unnumberedsec Machine_Size
6021 @findex Machine_Size
6022 @noindent
6023 This attribute is identical to the @code{Object_Size} attribute.  It is
6024 provided for compatibility with the DEC Ada 83 attribute of this name.
6025
6026 @node Mantissa
6027 @unnumberedsec Mantissa
6028 @cindex Ada 83 attributes
6029 @findex Mantissa
6030 @noindent
6031 The @code{Mantissa} attribute is provided for compatibility with Ada 83.  See
6032 the Ada 83 reference manual for an exact description of the semantics of
6033 this attribute.
6034
6035 @node Max_Interrupt_Priority
6036 @unnumberedsec Max_Interrupt_Priority
6037 @cindex Interrupt priority, maximum
6038 @findex Max_Interrupt_Priority
6039 @noindent
6040 @code{Standard'Max_Interrupt_Priority} (@code{Standard} is the only
6041 permissible prefix), provides the same value as
6042 @code{System.Max_Interrupt_Priority}.
6043
6044 @node Max_Priority
6045 @unnumberedsec Max_Priority
6046 @cindex Priority, maximum
6047 @findex Max_Priority
6048 @noindent
6049 @code{Standard'Max_Priority} (@code{Standard} is the only permissible
6050 prefix) provides the same value as @code{System.Max_Priority}.
6051
6052 @node Maximum_Alignment
6053 @unnumberedsec Maximum_Alignment
6054 @cindex Alignment, maximum
6055 @findex Maximum_Alignment
6056 @noindent
6057 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
6058 permissible prefix) provides the maximum useful alignment value for the
6059 target.  This is a static value that can be used to specify the alignment
6060 for an object, guaranteeing that it is properly aligned in all
6061 cases.
6062
6063 @node Mechanism_Code
6064 @unnumberedsec Mechanism_Code
6065 @cindex Return values, passing mechanism
6066 @cindex Parameters, passing mechanism
6067 @findex Mechanism_Code
6068 @noindent
6069 @code{@var{function}'Mechanism_Code} yields an integer code for the
6070 mechanism used for the result of function, and
6071 @code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
6072 used for formal parameter number @var{n} (a static integer value with 1
6073 meaning the first parameter) of @var{subprogram}.  The code returned is:
6074
6075 @table @asis
6076 @item 1
6077 by copy (value)
6078 @item 2
6079 by reference
6080 @item 3
6081 by descriptor (default descriptor class)
6082 @item 4
6083 by descriptor (UBS: unaligned bit string)
6084 @item 5
6085 by descriptor (UBSB: aligned bit string with arbitrary bounds)
6086 @item 6
6087 by descriptor (UBA: unaligned bit array)
6088 @item 7
6089 by descriptor (S: string, also scalar access type parameter)
6090 @item 8
6091 by descriptor (SB: string with arbitrary bounds)
6092 @item 9
6093 by descriptor (A: contiguous array)
6094 @item 10
6095 by descriptor (NCA: non-contiguous array)
6096 @end table
6097
6098 @noindent
6099 Values from 3 through 10 are only relevant to Digital OpenVMS implementations.
6100 @cindex OpenVMS
6101
6102 @node Null_Parameter
6103 @unnumberedsec Null_Parameter
6104 @cindex Zero address, passing
6105 @findex Null_Parameter
6106 @noindent
6107 A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
6108 type or subtype @var{T} allocated at machine address zero.  The attribute
6109 is allowed only as the default expression of a formal parameter, or as
6110 an actual expression of a subprogram call.  In either case, the
6111 subprogram must be imported.
6112
6113 The identity of the object is represented by the address zero in the
6114 argument list, independent of the passing mechanism (explicit or
6115 default).
6116
6117 This capability is needed to specify that a zero address should be
6118 passed for a record or other composite object passed by reference.
6119 There is no way of indicating this without the @code{Null_Parameter}
6120 attribute.
6121
6122 @node Object_Size
6123 @unnumberedsec Object_Size
6124 @cindex Size, used for objects
6125 @findex Object_Size
6126 @noindent
6127 The size of an object is not necessarily the same as the size of the type
6128 of an object.  This is because by default object sizes are increased to be
6129 a multiple of the alignment of the object.  For example,
6130 @code{Natural'Size} is
6131 31, but by default objects of type @code{Natural} will have a size of 32 bits.
6132 Similarly, a record containing an integer and a character:
6133
6134 @smallexample @c ada
6135 type Rec is record
6136    I : Integer;
6137    C : Character;
6138 end record;
6139 @end smallexample
6140
6141 @noindent
6142 will have a size of 40 (that is @code{Rec'Size} will be 40).  The
6143 alignment will be 4, because of the
6144 integer field, and so the default size of record objects for this type
6145 will be 64 (8 bytes).
6146
6147 @node Old
6148 @unnumberedsec Old
6149 @cindex Capturing Old values
6150 @cindex Postconditions
6151 @noindent
6152 The attribute Prefix'Old can be used within a
6153 subprogram body or within a precondition or
6154 postcondition pragma. The effect is to
6155 refer to the value of the prefix on entry. So for
6156 example if you have an argument of a record type X called Arg1,
6157 you can refer to Arg1.Field'Old which yields the value of
6158 Arg1.Field on entry. The implementation simply involves generating
6159 an object declaration which captures the value on entry. Any
6160 prefix is allowed except one of a limited type (since limited
6161 types cannot be copied to capture their values) or an expression
6162 which references a local variable
6163 (since local variables do not exist at subprogram entry time).
6164
6165 The following example shows the use of 'Old to implement
6166 a test of a postcondition:
6167
6168 @smallexample @c ada
6169 with Old_Pkg;
6170 procedure Old is
6171 begin
6172    Old_Pkg.Incr;
6173 end Old;
6174
6175 package Old_Pkg is
6176    procedure Incr;
6177 end Old_Pkg;
6178
6179 package body Old_Pkg is
6180    Count : Natural := 0;
6181
6182    procedure Incr is
6183    begin
6184       ... code manipulating the value of Count
6185
6186       pragma Assert (Count = Count'Old + 1);
6187    end Incr;
6188 end Old_Pkg;
6189 @end smallexample
6190
6191 @noindent
6192 Note that it is allowed to apply 'Old to a constant entity, but this will
6193 result in a warning, since the old and new values will always be the same.
6194
6195 @node Passed_By_Reference
6196 @unnumberedsec Passed_By_Reference
6197 @cindex Parameters, when passed by reference
6198 @findex Passed_By_Reference
6199 @noindent
6200 @code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
6201 a value of type @code{Boolean} value that is @code{True} if the type is
6202 normally passed by reference and @code{False} if the type is normally
6203 passed by copy in calls.  For scalar types, the result is always @code{False}
6204 and is static.  For non-scalar types, the result is non-static.
6205
6206 @node Pool_Address
6207 @unnumberedsec Pool_Address
6208 @cindex Parameters, when passed by reference
6209 @findex Pool_Address
6210 @noindent
6211 @code{@var{X}'Pool_Address} for any object @var{X} returns the address
6212 of X within its storage pool. This is the same as
6213 @code{@var{X}'Address}, except that for an unconstrained array whose
6214 bounds are allocated just before the first component,
6215 @code{@var{X}'Pool_Address} returns the address of those bounds,
6216 whereas @code{@var{X}'Address} returns the address of the first
6217 component.
6218
6219 Here, we are interpreting ``storage pool'' broadly to mean ``wherever
6220 the object is allocated'', which could be a user-defined storage pool,
6221 the global heap, on the stack, or in a static memory area. For an
6222 object created by @code{new}, @code{@var{Ptr.all}'Pool_Address} is
6223 what is passed to @code{Allocate} and returned from @code{Deallocate}.
6224
6225 @node Range_Length
6226 @unnumberedsec Range_Length
6227 @findex Range_Length
6228 @noindent
6229 @code{@var{type}'Range_Length} for any discrete type @var{type} yields
6230 the number of values represented by the subtype (zero for a null
6231 range).  The result is static for static subtypes.  @code{Range_Length}
6232 applied to the index subtype of a one dimensional array always gives the
6233 same result as @code{Range} applied to the array itself.
6234
6235 @node Ref
6236 @unnumberedsec Ref
6237 @findex Ref
6238 @noindent
6239 The @code{System.Address'Ref}
6240 (@code{System.Address} is the only permissible prefix)
6241 denotes a function identical to
6242 @code{System.Storage_Elements.To_Address} except that
6243 it is a static attribute.  See @ref{To_Address} for more details.
6244
6245 @node Result
6246 @unnumberedsec Result
6247 @findex Result
6248 @noindent
6249 @code{@var{function}'Result} can only be used with in a Postcondition pragma
6250 for a function. The prefix must be the name of the corresponding function. This
6251 is used to refer to the result of the function in the postcondition expression.
6252 For a further discussion of the use of this attribute and examples of its use,
6253 see the description of pragma Postcondition.
6254
6255 @node Safe_Emax
6256 @unnumberedsec Safe_Emax
6257 @cindex Ada 83 attributes
6258 @findex Safe_Emax
6259 @noindent
6260 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83.  See
6261 the Ada 83 reference manual for an exact description of the semantics of
6262 this attribute.
6263
6264 @node Safe_Large
6265 @unnumberedsec Safe_Large
6266 @cindex Ada 83 attributes
6267 @findex Safe_Large
6268 @noindent
6269 The @code{Safe_Large} attribute is provided for compatibility with Ada 83.  See
6270 the Ada 83 reference manual for an exact description of the semantics of
6271 this attribute.
6272
6273 @node Small
6274 @unnumberedsec Small
6275 @cindex Ada 83 attributes
6276 @findex Small
6277 @noindent
6278 The @code{Small} attribute is defined in Ada 95 (and Ada 2005) only for
6279 fixed-point types.
6280 GNAT also allows this attribute to be applied to floating-point types
6281 for compatibility with Ada 83.  See
6282 the Ada 83 reference manual for an exact description of the semantics of
6283 this attribute when applied to floating-point types.
6284
6285 @node Storage_Unit
6286 @unnumberedsec Storage_Unit
6287 @findex Storage_Unit
6288 @noindent
6289 @code{Standard'Storage_Unit} (@code{Standard} is the only permissible
6290 prefix) provides the same value as @code{System.Storage_Unit}.
6291
6292 @node Stub_Type
6293 @unnumberedsec Stub_Type
6294 @findex Stub_Type
6295 @noindent
6296 The GNAT implementation of remote access-to-classwide types is
6297 organized as described in AARM section E.4 (20.t): a value of an RACW type
6298 (designating a remote object) is represented as a normal access
6299 value, pointing to a "stub" object which in turn contains the
6300 necessary information to contact the designated remote object. A
6301 call on any dispatching operation of such a stub object does the
6302 remote call, if necessary, using the information in the stub object
6303 to locate the target partition, etc.
6304
6305 For a prefix @code{T} that denotes a remote access-to-classwide type,
6306 @code{T'Stub_Type} denotes the type of the corresponding stub objects.
6307
6308 By construction, the layout of @code{T'Stub_Type} is identical to that of
6309 type @code{RACW_Stub_Type} declared in the internal implementation-defined
6310 unit @code{System.Partition_Interface}. Use of this attribute will create
6311 an implicit dependency on this unit.
6312
6313 @node Target_Name
6314 @unnumberedsec Target_Name
6315 @findex Target_Name
6316 @noindent
6317 @code{Standard'Target_Name} (@code{Standard} is the only permissible
6318 prefix) provides a static string value that identifies the target
6319 for the current compilation. For GCC implementations, this is the
6320 standard gcc target name without the terminating slash (for
6321 example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
6322
6323 @node Tick
6324 @unnumberedsec Tick
6325 @findex Tick
6326 @noindent
6327 @code{Standard'Tick} (@code{Standard} is the only permissible prefix)
6328 provides the same value as @code{System.Tick},
6329
6330 @node To_Address
6331 @unnumberedsec To_Address
6332 @findex To_Address
6333 @noindent
6334 The @code{System'To_Address}
6335 (@code{System} is the only permissible prefix)
6336 denotes a function identical to
6337 @code{System.Storage_Elements.To_Address} except that
6338 it is a static attribute.  This means that if its argument is
6339 a static expression, then the result of the attribute is a
6340 static expression.  The result is that such an expression can be
6341 used in contexts (e.g.@: preelaborable packages) which require a
6342 static expression and where the function call could not be used
6343 (since the function call is always non-static, even if its
6344 argument is static).
6345
6346 @node Type_Class
6347 @unnumberedsec Type_Class
6348 @findex Type_Class
6349 @noindent
6350 @code{@var{type}'Type_Class} for any type or subtype @var{type} yields
6351 the value of the type class for the full type of @var{type}.  If
6352 @var{type} is a generic formal type, the value is the value for the
6353 corresponding actual subtype.  The value of this attribute is of type
6354 @code{System.Aux_DEC.Type_Class}, which has the following definition:
6355
6356 @smallexample @c ada
6357   type Type_Class is
6358     (Type_Class_Enumeration,
6359      Type_Class_Integer,
6360      Type_Class_Fixed_Point,
6361      Type_Class_Floating_Point,
6362      Type_Class_Array,
6363      Type_Class_Record,
6364      Type_Class_Access,
6365      Type_Class_Task,
6366      Type_Class_Address);
6367 @end smallexample
6368
6369 @noindent
6370 Protected types yield the value @code{Type_Class_Task}, which thus
6371 applies to all concurrent types.  This attribute is designed to
6372 be compatible with the DEC Ada 83 attribute of the same name.
6373
6374 @node UET_Address
6375 @unnumberedsec UET_Address
6376 @findex UET_Address
6377 @noindent
6378 The @code{UET_Address} attribute can only be used for a prefix which
6379 denotes a library package.  It yields the address of the unit exception
6380 table when zero cost exception handling is used.  This attribute is
6381 intended only for use within the GNAT implementation.  See the unit
6382 @code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb}
6383 for details on how this attribute is used in the implementation.
6384
6385 @node Unconstrained_Array
6386 @unnumberedsec Unconstrained_Array
6387 @findex Unconstrained_Array
6388 @noindent
6389 The @code{Unconstrained_Array} attribute can be used with a prefix that
6390 denotes any type or subtype. It is a static attribute that yields
6391 @code{True} if the prefix designates an unconstrained array,
6392 and @code{False} otherwise. In a generic instance, the result is
6393 still static, and yields the result of applying this test to the
6394 generic actual.
6395
6396 @node Universal_Literal_String
6397 @unnumberedsec Universal_Literal_String
6398 @cindex Named numbers, representation of
6399 @findex Universal_Literal_String
6400 @noindent
6401 The prefix of @code{Universal_Literal_String} must be a named
6402 number.  The static result is the string consisting of the characters of
6403 the number as defined in the original source.  This allows the user
6404 program to access the actual text of named numbers without intermediate
6405 conversions and without the need to enclose the strings in quotes (which
6406 would preclude their use as numbers).
6407
6408 For example, the following program prints the first 50 digits of pi:
6409
6410 @smallexample @c ada
6411 with Text_IO; use Text_IO;
6412 with Ada.Numerics;
6413 procedure Pi is
6414 begin
6415    Put (Ada.Numerics.Pi'Universal_Literal_String);
6416 end;
6417 @end smallexample
6418
6419 @node Unrestricted_Access
6420 @unnumberedsec Unrestricted_Access
6421 @cindex @code{Access}, unrestricted
6422 @findex Unrestricted_Access
6423 @noindent
6424 The @code{Unrestricted_Access} attribute is similar to @code{Access}
6425 except that all accessibility and aliased view checks are omitted.  This
6426 is a user-beware attribute.  It is similar to
6427 @code{Address}, for which it is a desirable replacement where the value
6428 desired is an access type.  In other words, its effect is identical to
6429 first applying the @code{Address} attribute and then doing an unchecked
6430 conversion to a desired access type.  In GNAT, but not necessarily in
6431 other implementations, the use of static chains for inner level
6432 subprograms means that @code{Unrestricted_Access} applied to a
6433 subprogram yields a value that can be called as long as the subprogram
6434 is in scope (normal Ada accessibility rules restrict this usage).
6435
6436 It is possible to use @code{Unrestricted_Access} for any type, but care
6437 must be exercised if it is used to create pointers to unconstrained
6438 objects. In this case, the resulting pointer has the same scope as the
6439 context of the attribute, and may not be returned to some enclosing
6440 scope. For instance, a function cannot use @code{Unrestricted_Access}
6441 to create a unconstrained pointer and then return that value to the
6442 caller.
6443
6444 @node VADS_Size
6445 @unnumberedsec VADS_Size
6446 @cindex @code{Size}, VADS compatibility
6447 @findex VADS_Size
6448 @noindent
6449 The @code{'VADS_Size} attribute is intended to make it easier to port
6450 legacy code which relies on the semantics of @code{'Size} as implemented
6451 by the VADS Ada 83 compiler.  GNAT makes a best effort at duplicating the
6452 same semantic interpretation.  In particular, @code{'VADS_Size} applied
6453 to a predefined or other primitive type with no Size clause yields the
6454 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
6455 typical machines).  In addition @code{'VADS_Size} applied to an object
6456 gives the result that would be obtained by applying the attribute to
6457 the corresponding type.
6458
6459 @node Value_Size
6460 @unnumberedsec Value_Size
6461 @cindex @code{Size}, setting for not-first subtype
6462 @findex Value_Size
6463 @code{@var{type}'Value_Size} is the number of bits required to represent
6464 a value of the given subtype.  It is the same as @code{@var{type}'Size},
6465 but, unlike @code{Size}, may be set for non-first subtypes.
6466
6467 @node Wchar_T_Size
6468 @unnumberedsec Wchar_T_Size
6469 @findex Wchar_T_Size
6470 @code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
6471 prefix) provides the size in bits of the C @code{wchar_t} type
6472 primarily for constructing the definition of this type in
6473 package @code{Interfaces.C}.
6474
6475 @node Word_Size
6476 @unnumberedsec Word_Size
6477 @findex Word_Size
6478 @code{Standard'Word_Size} (@code{Standard} is the only permissible
6479 prefix) provides the value @code{System.Word_Size}.
6480
6481 @c ------------------------
6482 @node Implementation Advice
6483 @chapter Implementation Advice
6484 @noindent
6485 The main text of the Ada Reference Manual describes the required
6486 behavior of all Ada compilers, and the GNAT compiler conforms to
6487 these requirements.
6488
6489 In addition, there are sections throughout the Ada Reference Manual headed
6490 by the phrase ``Implementation advice''.  These sections are not normative,
6491 i.e., they do not specify requirements that all compilers must
6492 follow.  Rather they provide advice on generally desirable behavior.  You
6493 may wonder why they are not requirements.  The most typical answer is
6494 that they describe behavior that seems generally desirable, but cannot
6495 be provided on all systems, or which may be undesirable on some systems.
6496
6497 As far as practical, GNAT follows the implementation advice sections in
6498 the Ada Reference Manual.  This chapter contains a table giving the
6499 reference manual section number, paragraph number and several keywords
6500 for each advice.  Each entry consists of the text of the advice followed
6501 by the GNAT interpretation of this advice.  Most often, this simply says
6502 ``followed'', which means that GNAT follows the advice.  However, in a
6503 number of cases, GNAT deliberately deviates from this advice, in which
6504 case the text describes what GNAT does and why.
6505
6506 @cindex Error detection
6507 @unnumberedsec 1.1.3(20): Error Detection
6508 @sp 1
6509 @cartouche
6510 If an implementation detects the use of an unsupported Specialized Needs
6511 Annex feature at run time, it should raise @code{Program_Error} if
6512 feasible.
6513 @end cartouche
6514 Not relevant.  All specialized needs annex features are either supported,
6515 or diagnosed at compile time.
6516
6517 @cindex Child Units
6518 @unnumberedsec 1.1.3(31): Child Units
6519 @sp 1
6520 @cartouche
6521 If an implementation wishes to provide implementation-defined
6522 extensions to the functionality of a language-defined library unit, it
6523 should normally do so by adding children to the library unit.
6524 @end cartouche
6525 Followed.
6526
6527 @cindex Bounded errors
6528 @unnumberedsec 1.1.5(12): Bounded Errors
6529 @sp 1
6530 @cartouche
6531 If an implementation detects a bounded error or erroneous
6532 execution, it should raise @code{Program_Error}.
6533 @end cartouche
6534 Followed in all cases in which the implementation detects a bounded
6535 error or erroneous execution.  Not all such situations are detected at
6536 runtime.
6537
6538 @cindex Pragmas
6539 @unnumberedsec 2.8(16): Pragmas
6540 @sp 1
6541 @cartouche
6542 Normally, implementation-defined pragmas should have no semantic effect
6543 for error-free programs; that is, if the implementation-defined pragmas
6544 are removed from a working program, the program should still be legal,
6545 and should still have the same semantics.
6546 @end cartouche
6547 The following implementation defined pragmas are exceptions to this
6548 rule:
6549
6550 @table @code
6551 @item Abort_Defer
6552 Affects semantics
6553 @item Ada_83
6554 Affects legality
6555 @item Assert
6556 Affects semantics
6557 @item CPP_Class
6558 Affects semantics
6559 @item CPP_Constructor
6560 Affects semantics
6561 @item Debug
6562 Affects semantics
6563 @item Interface_Name
6564 Affects semantics
6565 @item Machine_Attribute
6566 Affects semantics
6567 @item Unimplemented_Unit
6568 Affects legality
6569 @item Unchecked_Union
6570 Affects semantics
6571 @end table
6572
6573 @noindent
6574 In each of the above cases, it is essential to the purpose of the pragma
6575 that this advice not be followed.  For details see the separate section
6576 on implementation defined pragmas.
6577
6578 @unnumberedsec 2.8(17-19): Pragmas
6579 @sp 1
6580 @cartouche
6581 Normally, an implementation should not define pragmas that can
6582 make an illegal program legal, except as follows:
6583 @end cartouche
6584 @sp 1
6585 @cartouche
6586 A pragma used to complete a declaration, such as a pragma @code{Import};
6587 @end cartouche
6588 @sp 1
6589 @cartouche
6590 A pragma used to configure the environment by adding, removing, or
6591 replacing @code{library_items}.
6592 @end cartouche
6593 See response to paragraph 16 of this same section.
6594
6595 @cindex Character Sets
6596 @cindex Alternative Character Sets
6597 @unnumberedsec 3.5.2(5): Alternative Character Sets
6598 @sp 1
6599 @cartouche
6600 If an implementation supports a mode with alternative interpretations
6601 for @code{Character} and @code{Wide_Character}, the set of graphic
6602 characters of @code{Character} should nevertheless remain a proper
6603 subset of the set of graphic characters of @code{Wide_Character}.  Any
6604 character set ``localizations'' should be reflected in the results of
6605 the subprograms defined in the language-defined package
6606 @code{Characters.Handling} (see A.3) available in such a mode.  In a mode with
6607 an alternative interpretation of @code{Character}, the implementation should
6608 also support a corresponding change in what is a legal
6609 @code{identifier_letter}.
6610 @end cartouche
6611 Not all wide character modes follow this advice, in particular the JIS
6612 and IEC modes reflect standard usage in Japan, and in these encoding,
6613 the upper half of the Latin-1 set is not part of the wide-character
6614 subset, since the most significant bit is used for wide character
6615 encoding.  However, this only applies to the external forms.  Internally
6616 there is no such restriction.
6617
6618 @cindex Integer types
6619 @unnumberedsec 3.5.4(28): Integer Types
6620
6621 @sp 1
6622 @cartouche
6623 An implementation should support @code{Long_Integer} in addition to
6624 @code{Integer} if the target machine supports 32-bit (or longer)
6625 arithmetic.  No other named integer subtypes are recommended for package
6626 @code{Standard}.  Instead, appropriate named integer subtypes should be
6627 provided in the library package @code{Interfaces} (see B.2).
6628 @end cartouche
6629 @code{Long_Integer} is supported.  Other standard integer types are supported
6630 so this advice is not fully followed.  These types
6631 are supported for convenient interface to C, and so that all hardware
6632 types of the machine are easily available.
6633 @unnumberedsec 3.5.4(29): Integer Types
6634
6635 @sp 1
6636 @cartouche
6637 An implementation for a two's complement machine should support
6638 modular types with a binary modulus up to @code{System.Max_Int*2+2}.  An
6639 implementation should support a non-binary modules up to @code{Integer'Last}.
6640 @end cartouche
6641 Followed.
6642
6643 @cindex Enumeration values
6644 @unnumberedsec 3.5.5(8): Enumeration Values
6645 @sp 1
6646 @cartouche
6647 For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
6648 subtype, if the value of the operand does not correspond to the internal
6649 code for any enumeration literal of its type (perhaps due to an
6650 un-initialized variable), then the implementation should raise
6651 @code{Program_Error}.  This is particularly important for enumeration
6652 types with noncontiguous internal codes specified by an
6653 enumeration_representation_clause.
6654 @end cartouche
6655 Followed.
6656
6657 @cindex Float types
6658 @unnumberedsec 3.5.7(17): Float Types
6659 @sp 1
6660 @cartouche
6661 An implementation should support @code{Long_Float} in addition to
6662 @code{Float} if the target machine supports 11 or more digits of
6663 precision.  No other named floating point subtypes are recommended for
6664 package @code{Standard}.  Instead, appropriate named floating point subtypes
6665 should be provided in the library package @code{Interfaces} (see B.2).
6666 @end cartouche
6667 @code{Short_Float} and @code{Long_Long_Float} are also provided.  The
6668 former provides improved compatibility with other implementations
6669 supporting this type.  The latter corresponds to the highest precision
6670 floating-point type supported by the hardware.  On most machines, this
6671 will be the same as @code{Long_Float}, but on some machines, it will
6672 correspond to the IEEE extended form.  The notable case is all ia32
6673 (x86) implementations, where @code{Long_Long_Float} corresponds to
6674 the 80-bit extended precision format supported in hardware on this
6675 processor.  Note that the 128-bit format on SPARC is not supported,
6676 since this is a software rather than a hardware format.
6677
6678 @cindex Multidimensional arrays
6679 @cindex Arrays, multidimensional
6680 @unnumberedsec 3.6.2(11): Multidimensional Arrays
6681 @sp 1
6682 @cartouche
6683 An implementation should normally represent multidimensional arrays in
6684 row-major order, consistent with the notation used for multidimensional
6685 array aggregates (see 4.3.3).  However, if a pragma @code{Convention}
6686 (@code{Fortran}, @dots{}) applies to a multidimensional array type, then
6687 column-major order should be used instead (see B.5, ``Interfacing with
6688 Fortran'').
6689 @end cartouche
6690 Followed.
6691
6692 @findex Duration'Small
6693 @unnumberedsec 9.6(30-31): Duration'Small
6694 @sp 1
6695 @cartouche
6696 Whenever possible in an implementation, the value of @code{Duration'Small}
6697 should be no greater than 100 microseconds.
6698 @end cartouche
6699 Followed.  (@code{Duration'Small} = 10**(@minus{}9)).
6700
6701 @sp 1
6702 @cartouche
6703 The time base for @code{delay_relative_statements} should be monotonic;
6704 it need not be the same time base as used for @code{Calendar.Clock}.
6705 @end cartouche
6706 Followed.
6707
6708 @unnumberedsec 10.2.1(12): Consistent Representation
6709 @sp 1
6710 @cartouche
6711 In an implementation, a type declared in a pre-elaborated package should
6712 have the same representation in every elaboration of a given version of
6713 the package, whether the elaborations occur in distinct executions of
6714 the same program, or in executions of distinct programs or partitions
6715 that include the given version.
6716 @end cartouche
6717 Followed, except in the case of tagged types.  Tagged types involve
6718 implicit pointers to a local copy of a dispatch table, and these pointers
6719 have representations which thus depend on a particular elaboration of the
6720 package.  It is not easy to see how it would be possible to follow this
6721 advice without severely impacting efficiency of execution.
6722
6723 @cindex Exception information
6724 @unnumberedsec 11.4.1(19): Exception Information
6725 @sp 1
6726 @cartouche
6727 @code{Exception_Message} by default and @code{Exception_Information}
6728 should produce information useful for
6729 debugging.  @code{Exception_Message} should be short, about one
6730 line.  @code{Exception_Information} can be long.  @code{Exception_Message}
6731 should not include the
6732 @code{Exception_Name}.  @code{Exception_Information} should include both
6733 the @code{Exception_Name} and the @code{Exception_Message}.
6734 @end cartouche
6735 Followed.  For each exception that doesn't have a specified
6736 @code{Exception_Message}, the compiler generates one containing the location
6737 of the raise statement.  This location has the form ``file:line'', where
6738 file is the short file name (without path information) and line is the line
6739 number in the file.  Note that in the case of the Zero Cost Exception
6740 mechanism, these messages become redundant with the Exception_Information that
6741 contains a full backtrace of the calling sequence, so they are disabled.
6742 To disable explicitly the generation of the source location message, use the
6743 Pragma @code{Discard_Names}.
6744
6745 @cindex Suppression of checks
6746 @cindex Checks, suppression of
6747 @unnumberedsec 11.5(28): Suppression of Checks
6748 @sp 1
6749 @cartouche
6750 The implementation should minimize the code executed for checks that
6751 have been suppressed.
6752 @end cartouche
6753 Followed.
6754
6755 @cindex Representation clauses
6756 @unnumberedsec 13.1 (21-24): Representation Clauses
6757 @sp 1
6758 @cartouche
6759 The recommended level of support for all representation items is
6760 qualified as follows:
6761 @end cartouche
6762 @sp 1
6763 @cartouche
6764 An implementation need not support representation items containing
6765 non-static expressions, except that an implementation should support a
6766 representation item for a given entity if each non-static expression in
6767 the representation item is a name that statically denotes a constant
6768 declared before the entity.
6769 @end cartouche
6770 Followed.  In fact, GNAT goes beyond the recommended level of support
6771 by allowing nonstatic expressions in some representation clauses even
6772 without the need to declare constants initialized with the values of
6773 such expressions.
6774 For example:
6775
6776 @smallexample @c ada
6777   X : Integer;
6778   Y : Float;
6779   for Y'Address use X'Address;>>
6780 @end smallexample
6781
6782 @sp 1
6783 @cartouche
6784 An implementation need not support a specification for the @code{Size}
6785 for a given composite subtype, nor the size or storage place for an
6786 object (including a component) of a given composite subtype, unless the
6787 constraints on the subtype and its composite subcomponents (if any) are
6788 all static constraints.
6789 @end cartouche
6790 Followed.  Size Clauses are not permitted on non-static components, as
6791 described above.
6792
6793 @sp 1
6794 @cartouche
6795 An aliased component, or a component whose type is by-reference, should
6796 always be allocated at an addressable location.
6797 @end cartouche
6798 Followed.
6799
6800 @cindex Packed types
6801 @unnumberedsec 13.2(6-8): Packed Types
6802 @sp 1
6803 @cartouche
6804 If a type is packed, then the implementation should try to minimize
6805 storage allocated to objects of the type, possibly at the expense of
6806 speed of accessing components, subject to reasonable complexity in
6807 addressing calculations.
6808 @end cartouche
6809 @sp 1
6810 @cartouche
6811 The recommended level of support pragma @code{Pack} is:
6812
6813 For a packed record type, the components should be packed as tightly as
6814 possible subject to the Sizes of the component subtypes, and subject to
6815 any @code{record_representation_clause} that applies to the type; the
6816 implementation may, but need not, reorder components or cross aligned
6817 word boundaries to improve the packing.  A component whose @code{Size} is
6818 greater than the word size may be allocated an integral number of words.
6819 @end cartouche
6820 Followed.  Tight packing of arrays is supported for all component sizes
6821 up to 64-bits. If the array component size is 1 (that is to say, if
6822 the component is a boolean type or an enumeration type with two values)
6823 then values of the type are implicitly initialized to zero. This
6824 happens both for objects of the packed type, and for objects that have a
6825 subcomponent of the packed type.
6826
6827 @sp 1
6828 @cartouche
6829 An implementation should support Address clauses for imported
6830 subprograms.
6831 @end cartouche
6832 Followed.
6833 @cindex @code{Address} clauses
6834 @unnumberedsec 13.3(14-19): Address Clauses
6835
6836 @sp 1
6837 @cartouche
6838 For an array @var{X}, @code{@var{X}'Address} should point at the first
6839 component of the array, and not at the array bounds.
6840 @end cartouche
6841 Followed.
6842
6843 @sp 1
6844 @cartouche
6845 The recommended level of support for the @code{Address} attribute is:
6846
6847 @code{@var{X}'Address} should produce a useful result if @var{X} is an
6848 object that is aliased or of a by-reference type, or is an entity whose
6849 @code{Address} has been specified.
6850 @end cartouche
6851 Followed.  A valid address will be produced even if none of those
6852 conditions have been met.  If necessary, the object is forced into
6853 memory to ensure the address is valid.
6854
6855 @sp 1
6856 @cartouche
6857 An implementation should support @code{Address} clauses for imported
6858 subprograms.
6859 @end cartouche
6860 Followed.
6861
6862 @sp 1
6863 @cartouche
6864 Objects (including subcomponents) that are aliased or of a by-reference
6865 type should be allocated on storage element boundaries.
6866 @end cartouche
6867 Followed.
6868
6869 @sp 1
6870 @cartouche
6871 If the @code{Address} of an object is specified, or it is imported or exported,
6872 then the implementation should not perform optimizations based on
6873 assumptions of no aliases.
6874 @end cartouche
6875 Followed.
6876
6877 @cindex @code{Alignment} clauses
6878 @unnumberedsec 13.3(29-35): Alignment Clauses
6879 @sp 1
6880 @cartouche
6881 The recommended level of support for the @code{Alignment} attribute for
6882 subtypes is:
6883
6884 An implementation should support specified Alignments that are factors
6885 and multiples of the number of storage elements per word, subject to the
6886 following:
6887 @end cartouche
6888 Followed.
6889
6890 @sp 1
6891 @cartouche
6892 An implementation need not support specified @code{Alignment}s for
6893 combinations of @code{Size}s and @code{Alignment}s that cannot be easily
6894 loaded and stored by available machine instructions.
6895 @end cartouche
6896 Followed.
6897
6898 @sp 1
6899 @cartouche
6900 An implementation need not support specified @code{Alignment}s that are
6901 greater than the maximum @code{Alignment} the implementation ever returns by
6902 default.
6903 @end cartouche
6904 Followed.
6905
6906 @sp 1
6907 @cartouche
6908 The recommended level of support for the @code{Alignment} attribute for
6909 objects is:
6910
6911 Same as above, for subtypes, but in addition:
6912 @end cartouche
6913 Followed.
6914
6915 @sp 1
6916 @cartouche
6917 For stand-alone library-level objects of statically constrained
6918 subtypes, the implementation should support all @code{Alignment}s
6919 supported by the target linker.  For example, page alignment is likely to
6920 be supported for such objects, but not for subtypes.
6921 @end cartouche
6922 Followed.
6923
6924 @cindex @code{Size} clauses
6925 @unnumberedsec 13.3(42-43): Size Clauses
6926 @sp 1
6927 @cartouche
6928 The recommended level of support for the @code{Size} attribute of
6929 objects is:
6930
6931 A @code{Size} clause should be supported for an object if the specified
6932 @code{Size} is at least as large as its subtype's @code{Size}, and
6933 corresponds to a size in storage elements that is a multiple of the
6934 object's @code{Alignment} (if the @code{Alignment} is nonzero).
6935 @end cartouche
6936 Followed.
6937
6938 @unnumberedsec 13.3(50-56): Size Clauses
6939 @sp 1
6940 @cartouche
6941 If the @code{Size} of a subtype is specified, and allows for efficient
6942 independent addressability (see 9.10) on the target architecture, then
6943 the @code{Size} of the following objects of the subtype should equal the
6944 @code{Size} of the subtype:
6945
6946 Aliased objects (including components).
6947 @end cartouche
6948 Followed.
6949
6950 @sp 1
6951 @cartouche
6952 @code{Size} clause on a composite subtype should not affect the
6953 internal layout of components.
6954 @end cartouche
6955 Followed. But note that this can be overridden by use of the implementation
6956 pragma Implicit_Packing in the case of packed arrays.
6957
6958 @sp 1
6959 @cartouche
6960 The recommended level of support for the @code{Size} attribute of subtypes is:
6961 @end cartouche
6962 @sp 1
6963 @cartouche
6964 The @code{Size} (if not specified) of a static discrete or fixed point
6965 subtype should be the number of bits needed to represent each value
6966 belonging to the subtype using an unbiased representation, leaving space
6967 for a sign bit only if the subtype contains negative values.  If such a
6968 subtype is a first subtype, then an implementation should support a
6969 specified @code{Size} for it that reflects this representation.
6970 @end cartouche
6971 Followed.
6972
6973 @sp 1
6974 @cartouche
6975 For a subtype implemented with levels of indirection, the @code{Size}
6976 should include the size of the pointers, but not the size of what they
6977 point at.
6978 @end cartouche
6979 Followed.
6980
6981 @cindex @code{Component_Size} clauses
6982 @unnumberedsec 13.3(71-73): Component Size Clauses
6983 @sp 1
6984 @cartouche
6985 The recommended level of support for the @code{Component_Size}
6986 attribute is:
6987 @end cartouche
6988 @sp 1
6989 @cartouche
6990 An implementation need not support specified @code{Component_Sizes} that are
6991 less than the @code{Size} of the component subtype.
6992 @end cartouche
6993 Followed.
6994
6995 @sp 1
6996 @cartouche
6997 An implementation should support specified @code{Component_Size}s that
6998 are factors and multiples of the word size.  For such
6999 @code{Component_Size}s, the array should contain no gaps between
7000 components.  For other @code{Component_Size}s (if supported), the array
7001 should contain no gaps between components when packing is also
7002 specified; the implementation should forbid this combination in cases
7003 where it cannot support a no-gaps representation.
7004 @end cartouche
7005 Followed.
7006
7007 @cindex Enumeration representation clauses
7008 @cindex Representation clauses, enumeration
7009 @unnumberedsec 13.4(9-10): Enumeration Representation Clauses
7010 @sp 1
7011 @cartouche
7012 The recommended level of support for enumeration representation clauses
7013 is:
7014
7015 An implementation need not support enumeration representation clauses
7016 for boolean types, but should at minimum support the internal codes in
7017 the range @code{System.Min_Int.System.Max_Int}.
7018 @end cartouche
7019 Followed.
7020
7021 @cindex Record representation clauses
7022 @cindex Representation clauses, records
7023 @unnumberedsec 13.5.1(17-22): Record Representation Clauses
7024 @sp 1
7025 @cartouche
7026 The recommended level of support for
7027 @*@code{record_representation_clauses} is:
7028
7029 An implementation should support storage places that can be extracted
7030 with a load, mask, shift sequence of machine code, and set with a load,
7031 shift, mask, store sequence, given the available machine instructions
7032 and run-time model.
7033 @end cartouche
7034 Followed.
7035
7036 @sp 1
7037 @cartouche
7038 A storage place should be supported if its size is equal to the
7039 @code{Size} of the component subtype, and it starts and ends on a
7040 boundary that obeys the @code{Alignment} of the component subtype.
7041 @end cartouche
7042 Followed.
7043
7044 @sp 1
7045 @cartouche
7046 If the default bit ordering applies to the declaration of a given type,
7047 then for a component whose subtype's @code{Size} is less than the word
7048 size, any storage place that does not cross an aligned word boundary
7049 should be supported.
7050 @end cartouche
7051 Followed.
7052
7053 @sp 1
7054 @cartouche
7055 An implementation may reserve a storage place for the tag field of a
7056 tagged type, and disallow other components from overlapping that place.
7057 @end cartouche
7058 Followed.  The storage place for the tag field is the beginning of the tagged
7059 record, and its size is Address'Size.  GNAT will reject an explicit component
7060 clause for the tag field.
7061
7062 @sp 1
7063 @cartouche
7064 An implementation need not support a @code{component_clause} for a
7065 component of an extension part if the storage place is not after the
7066 storage places of all components of the parent type, whether or not
7067 those storage places had been specified.
7068 @end cartouche
7069 Followed.  The above advice on record representation clauses is followed,
7070 and all mentioned features are implemented.
7071
7072 @cindex Storage place attributes
7073 @unnumberedsec 13.5.2(5): Storage Place Attributes
7074 @sp 1
7075 @cartouche
7076 If a component is represented using some form of pointer (such as an
7077 offset) to the actual data of the component, and this data is contiguous
7078 with the rest of the object, then the storage place attributes should
7079 reflect the place of the actual data, not the pointer.  If a component is
7080 allocated discontinuously from the rest of the object, then a warning
7081 should be generated upon reference to one of its storage place
7082 attributes.
7083 @end cartouche
7084 Followed.  There are no such components in GNAT@.
7085
7086 @cindex Bit ordering
7087 @unnumberedsec 13.5.3(7-8): Bit Ordering
7088 @sp 1
7089 @cartouche
7090 The recommended level of support for the non-default bit ordering is:
7091 @end cartouche
7092 @sp 1
7093 @cartouche
7094 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
7095 should support the non-default bit ordering in addition to the default
7096 bit ordering.
7097 @end cartouche
7098 Followed.  Word size does not equal storage size in this implementation.
7099 Thus non-default bit ordering is not supported.
7100
7101 @cindex @code{Address}, as private type
7102 @unnumberedsec 13.7(37): Address as Private
7103 @sp 1
7104 @cartouche
7105 @code{Address} should be of a private type.
7106 @end cartouche
7107 Followed.
7108
7109 @cindex Operations, on @code{Address}
7110 @cindex @code{Address}, operations of
7111 @unnumberedsec 13.7.1(16): Address Operations
7112 @sp 1
7113 @cartouche
7114 Operations in @code{System} and its children should reflect the target
7115 environment semantics as closely as is reasonable.  For example, on most
7116 machines, it makes sense for address arithmetic to ``wrap around''.
7117 Operations that do not make sense should raise @code{Program_Error}.
7118 @end cartouche
7119 Followed.  Address arithmetic is modular arithmetic that wraps around.  No
7120 operation raises @code{Program_Error}, since all operations make sense.
7121
7122 @cindex Unchecked conversion
7123 @unnumberedsec 13.9(14-17): Unchecked Conversion
7124 @sp 1
7125 @cartouche
7126 The @code{Size} of an array object should not include its bounds; hence,
7127 the bounds should not be part of the converted data.
7128 @end cartouche
7129 Followed.
7130
7131 @sp 1
7132 @cartouche
7133 The implementation should not generate unnecessary run-time checks to
7134 ensure that the representation of @var{S} is a representation of the
7135 target type.  It should take advantage of the permission to return by
7136 reference when possible.  Restrictions on unchecked conversions should be
7137 avoided unless required by the target environment.
7138 @end cartouche
7139 Followed.  There are no restrictions on unchecked conversion.  A warning is
7140 generated if the source and target types do not have the same size since
7141 the semantics in this case may be target dependent.
7142
7143 @sp 1
7144 @cartouche
7145 The recommended level of support for unchecked conversions is:
7146 @end cartouche
7147 @sp 1
7148 @cartouche
7149 Unchecked conversions should be supported and should be reversible in
7150 the cases where this clause defines the result.  To enable meaningful use
7151 of unchecked conversion, a contiguous representation should be used for
7152 elementary subtypes, for statically constrained array subtypes whose
7153 component subtype is one of the subtypes described in this paragraph,
7154 and for record subtypes without discriminants whose component subtypes
7155 are described in this paragraph.
7156 @end cartouche
7157 Followed.
7158
7159 @cindex Heap usage, implicit
7160 @unnumberedsec 13.11(23-25): Implicit Heap Usage
7161 @sp 1
7162 @cartouche
7163 An implementation should document any cases in which it dynamically
7164 allocates heap storage for a purpose other than the evaluation of an
7165 allocator.
7166 @end cartouche
7167 Followed, the only other points at which heap storage is dynamically
7168 allocated are as follows:
7169
7170 @itemize @bullet
7171 @item
7172 At initial elaboration time, to allocate dynamically sized global
7173 objects.
7174
7175 @item
7176 To allocate space for a task when a task is created.
7177
7178 @item
7179 To extend the secondary stack dynamically when needed.  The secondary
7180 stack is used for returning variable length results.
7181 @end itemize
7182
7183 @sp 1
7184 @cartouche
7185 A default (implementation-provided) storage pool for an
7186 access-to-constant type should not have overhead to support deallocation of
7187 individual objects.
7188 @end cartouche
7189 Followed.
7190
7191 @sp 1
7192 @cartouche
7193 A storage pool for an anonymous access type should be created at the
7194 point of an allocator for the type, and be reclaimed when the designated
7195 object becomes inaccessible.
7196 @end cartouche
7197 Followed.
7198
7199 @cindex Unchecked deallocation
7200 @unnumberedsec 13.11.2(17): Unchecked De-allocation
7201 @sp 1
7202 @cartouche
7203 For a standard storage pool, @code{Free} should actually reclaim the
7204 storage.
7205 @end cartouche
7206 Followed.
7207
7208 @cindex Stream oriented attributes
7209 @unnumberedsec 13.13.2(17): Stream Oriented Attributes
7210 @sp 1
7211 @cartouche
7212 If a stream element is the same size as a storage element, then the
7213 normal in-memory representation should be used by @code{Read} and
7214 @code{Write} for scalar objects.  Otherwise, @code{Read} and @code{Write}
7215 should use the smallest number of stream elements needed to represent
7216 all values in the base range of the scalar type.
7217 @end cartouche
7218
7219 Followed.  By default, GNAT uses the interpretation suggested by AI-195,
7220 which specifies using the size of the first subtype.
7221 However, such an implementation is based on direct binary
7222 representations and is therefore target- and endianness-dependent.
7223 To address this issue, GNAT also supplies an alternate implementation
7224 of the stream attributes @code{Read} and @code{Write},
7225 which uses the target-independent XDR standard representation
7226 for scalar types.
7227 @cindex XDR representation
7228 @cindex @code{Read} attribute
7229 @cindex @code{Write} attribute
7230 @cindex Stream oriented attributes
7231 The XDR implementation is provided as an alternative body of the
7232 @code{System.Stream_Attributes} package, in the file
7233 @file{s-stratt-xdr.adb} in the GNAT library.
7234 There is no @file{s-stratt-xdr.ads} file.
7235 In order to install the XDR implementation, do the following:
7236 @enumerate
7237 @item Replace the default implementation of the
7238 @code{System.Stream_Attributes} package with the XDR implementation.
7239 For example on a Unix platform issue the commands:
7240 @smallexample
7241 $ mv s-stratt.adb s-stratt-default.adb
7242 $ mv s-stratt-xdr.adb s-stratt.adb
7243 @end smallexample
7244
7245 @item
7246 Rebuild the GNAT run-time library as documented in
7247 @ref{GNAT and Libraries,,, gnat_ugn, @value{EDITION} User's Guide}.
7248 @end enumerate
7249
7250 @unnumberedsec A.1(52): Names of Predefined Numeric Types
7251 @sp 1
7252 @cartouche
7253 If an implementation provides additional named predefined integer types,
7254 then the names should end with @samp{Integer} as in
7255 @samp{Long_Integer}.  If an implementation provides additional named
7256 predefined floating point types, then the names should end with
7257 @samp{Float} as in @samp{Long_Float}.
7258 @end cartouche
7259 Followed.
7260
7261 @findex Ada.Characters.Handling
7262 @unnumberedsec A.3.2(49): @code{Ada.Characters.Handling}
7263 @sp 1
7264 @cartouche
7265 If an implementation provides a localized definition of @code{Character}
7266 or @code{Wide_Character}, then the effects of the subprograms in
7267 @code{Characters.Handling} should reflect the localizations.  See also
7268 3.5.2.
7269 @end cartouche
7270 Followed.  GNAT provides no such localized definitions.
7271
7272 @cindex Bounded-length strings
7273 @unnumberedsec A.4.4(106): Bounded-Length String Handling
7274 @sp 1
7275 @cartouche
7276 Bounded string objects should not be implemented by implicit pointers
7277 and dynamic allocation.
7278 @end cartouche
7279 Followed.  No implicit pointers or dynamic allocation are used.
7280
7281 @cindex Random number generation
7282 @unnumberedsec A.5.2(46-47): Random Number Generation
7283 @sp 1
7284 @cartouche
7285 Any storage associated with an object of type @code{Generator} should be
7286 reclaimed on exit from the scope of the object.
7287 @end cartouche
7288 Followed.
7289
7290 @sp 1
7291 @cartouche
7292 If the generator period is sufficiently long in relation to the number
7293 of distinct initiator values, then each possible value of
7294 @code{Initiator} passed to @code{Reset} should initiate a sequence of
7295 random numbers that does not, in a practical sense, overlap the sequence
7296 initiated by any other value.  If this is not possible, then the mapping
7297 between initiator values and generator states should be a rapidly
7298 varying function of the initiator value.
7299 @end cartouche
7300 Followed.  The generator period is sufficiently long for the first
7301 condition here to hold true.
7302
7303 @findex Get_Immediate
7304 @unnumberedsec A.10.7(23): @code{Get_Immediate}
7305 @sp 1
7306 @cartouche
7307 The @code{Get_Immediate} procedures should be implemented with
7308 unbuffered input.  For a device such as a keyboard, input should be
7309 @dfn{available} if a key has already been typed, whereas for a disk
7310 file, input should always be available except at end of file.  For a file
7311 associated with a keyboard-like device, any line-editing features of the
7312 underlying operating system should be disabled during the execution of
7313 @code{Get_Immediate}.
7314 @end cartouche
7315 Followed on all targets except VxWorks. For VxWorks, there is no way to
7316 provide this functionality that does not result in the input buffer being
7317 flushed before the @code{Get_Immediate} call. A special unit
7318 @code{Interfaces.Vxworks.IO} is provided that contains routines to enable
7319 this functionality.
7320
7321 @findex Export
7322 @unnumberedsec B.1(39-41): Pragma @code{Export}
7323 @sp 1
7324 @cartouche
7325 If an implementation supports pragma @code{Export} to a given language,
7326 then it should also allow the main subprogram to be written in that
7327 language.  It should support some mechanism for invoking the elaboration
7328 of the Ada library units included in the system, and for invoking the
7329 finalization of the environment task.  On typical systems, the
7330 recommended mechanism is to provide two subprograms whose link names are
7331 @code{adainit} and @code{adafinal}.  @code{adainit} should contain the
7332 elaboration code for library units.  @code{adafinal} should contain the
7333 finalization code.  These subprograms should have no effect the second
7334 and subsequent time they are called.
7335 @end cartouche
7336 Followed.
7337
7338 @sp 1
7339 @cartouche
7340 Automatic elaboration of pre-elaborated packages should be
7341 provided when pragma @code{Export} is supported.
7342 @end cartouche
7343 Followed when the main program is in Ada.  If the main program is in a
7344 foreign language, then
7345 @code{adainit} must be called to elaborate pre-elaborated
7346 packages.
7347
7348 @sp 1
7349 @cartouche
7350 For each supported convention @var{L} other than @code{Intrinsic}, an
7351 implementation should support @code{Import} and @code{Export} pragmas
7352 for objects of @var{L}-compatible types and for subprograms, and pragma
7353 @code{Convention} for @var{L}-eligible types and for subprograms,
7354 presuming the other language has corresponding features.  Pragma
7355 @code{Convention} need not be supported for scalar types.
7356 @end cartouche
7357 Followed.
7358
7359 @cindex Package @code{Interfaces}
7360 @findex Interfaces
7361 @unnumberedsec B.2(12-13): Package @code{Interfaces}
7362 @sp 1
7363 @cartouche
7364 For each implementation-defined convention identifier, there should be a
7365 child package of package Interfaces with the corresponding name.  This
7366 package should contain any declarations that would be useful for
7367 interfacing to the language (implementation) represented by the
7368 convention.  Any declarations useful for interfacing to any language on
7369 the given hardware architecture should be provided directly in
7370 @code{Interfaces}.
7371 @end cartouche
7372 Followed. An additional package not defined
7373 in the Ada Reference Manual is @code{Interfaces.CPP}, used
7374 for interfacing to C++.
7375
7376 @sp 1
7377 @cartouche
7378 An implementation supporting an interface to C, COBOL, or Fortran should
7379 provide the corresponding package or packages described in the following
7380 clauses.
7381 @end cartouche
7382 Followed.  GNAT provides all the packages described in this section.
7383
7384 @cindex C, interfacing with
7385 @unnumberedsec B.3(63-71): Interfacing with C
7386 @sp 1
7387 @cartouche
7388 An implementation should support the following interface correspondences
7389 between Ada and C@.
7390 @end cartouche
7391 Followed.
7392
7393 @sp 1
7394 @cartouche
7395 An Ada procedure corresponds to a void-returning C function.
7396 @end cartouche
7397 Followed.
7398
7399 @sp 1
7400 @cartouche
7401 An Ada function corresponds to a non-void C function.
7402 @end cartouche
7403 Followed.
7404
7405 @sp 1
7406 @cartouche
7407 An Ada @code{in} scalar parameter is passed as a scalar argument to a C
7408 function.
7409 @end cartouche
7410 Followed.
7411
7412 @sp 1
7413 @cartouche
7414 An Ada @code{in} parameter of an access-to-object type with designated
7415 type @var{T} is passed as a @code{@var{t}*} argument to a C function,
7416 where @var{t} is the C type corresponding to the Ada type @var{T}.
7417 @end cartouche
7418 Followed.
7419
7420 @sp 1
7421 @cartouche
7422 An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
7423 parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
7424 argument to a C function, where @var{t} is the C type corresponding to
7425 the Ada type @var{T}.  In the case of an elementary @code{out} or
7426 @code{in out} parameter, a pointer to a temporary copy is used to
7427 preserve by-copy semantics.
7428 @end cartouche
7429 Followed.
7430
7431 @sp 1
7432 @cartouche
7433 An Ada parameter of a record type @var{T}, of any mode, is passed as a
7434 @code{@var{t}*} argument to a C function, where @var{t} is the C
7435 structure corresponding to the Ada type @var{T}.
7436 @end cartouche
7437 Followed.  This convention may be overridden by the use of the C_Pass_By_Copy
7438 pragma, or Convention, or by explicitly specifying the mechanism for a given
7439 call using an extended import or export pragma.
7440
7441 @sp 1
7442 @cartouche
7443 An Ada parameter of an array type with component type @var{T}, of any
7444 mode, is passed as a @code{@var{t}*} argument to a C function, where
7445 @var{t} is the C type corresponding to the Ada type @var{T}.
7446 @end cartouche
7447 Followed.
7448
7449 @sp 1
7450 @cartouche
7451 An Ada parameter of an access-to-subprogram type is passed as a pointer
7452 to a C function whose prototype corresponds to the designated
7453 subprogram's specification.
7454 @end cartouche
7455 Followed.
7456
7457 @cindex COBOL, interfacing with
7458 @unnumberedsec B.4(95-98): Interfacing with COBOL
7459 @sp 1
7460 @cartouche
7461 An Ada implementation should support the following interface
7462 correspondences between Ada and COBOL@.
7463 @end cartouche
7464 Followed.
7465
7466 @sp 1
7467 @cartouche
7468 An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of
7469 the COBOL type corresponding to @var{T}.
7470 @end cartouche
7471 Followed.
7472
7473 @sp 1
7474 @cartouche
7475 An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of
7476 the corresponding COBOL type.
7477 @end cartouche
7478 Followed.
7479
7480 @sp 1
7481 @cartouche
7482 Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the
7483 COBOL type corresponding to the Ada parameter type; for scalars, a local
7484 copy is used if necessary to ensure by-copy semantics.
7485 @end cartouche
7486 Followed.
7487
7488 @cindex Fortran, interfacing with
7489 @unnumberedsec B.5(22-26): Interfacing with Fortran
7490 @sp 1
7491 @cartouche
7492 An Ada implementation should support the following interface
7493 correspondences between Ada and Fortran:
7494 @end cartouche
7495 Followed.
7496
7497 @sp 1
7498 @cartouche
7499 An Ada procedure corresponds to a Fortran subroutine.
7500 @end cartouche
7501 Followed.
7502
7503 @sp 1
7504 @cartouche
7505 An Ada function corresponds to a Fortran function.
7506 @end cartouche
7507 Followed.
7508
7509 @sp 1
7510 @cartouche
7511 An Ada parameter of an elementary, array, or record type @var{T} is
7512 passed as a @var{T} argument to a Fortran procedure, where @var{T} is
7513 the Fortran type corresponding to the Ada type @var{T}, and where the
7514 INTENT attribute of the corresponding dummy argument matches the Ada
7515 formal parameter mode; the Fortran implementation's parameter passing
7516 conventions are used.  For elementary types, a local copy is used if
7517 necessary to ensure by-copy semantics.
7518 @end cartouche
7519 Followed.
7520
7521 @sp 1
7522 @cartouche
7523 An Ada parameter of an access-to-subprogram type is passed as a
7524 reference to a Fortran procedure whose interface corresponds to the
7525 designated subprogram's specification.
7526 @end cartouche
7527 Followed.
7528
7529 @cindex Machine operations
7530 @unnumberedsec C.1(3-5): Access to Machine Operations
7531 @sp 1
7532 @cartouche
7533 The machine code or intrinsic support should allow access to all
7534 operations normally available to assembly language programmers for the
7535 target environment, including privileged instructions, if any.
7536 @end cartouche
7537 Followed.
7538
7539 @sp 1
7540 @cartouche
7541 The interfacing pragmas (see Annex B) should support interface to
7542 assembler; the default assembler should be associated with the
7543 convention identifier @code{Assembler}.
7544 @end cartouche
7545 Followed.
7546
7547 @sp 1
7548 @cartouche
7549 If an entity is exported to assembly language, then the implementation
7550 should allocate it at an addressable location, and should ensure that it
7551 is retained by the linking process, even if not otherwise referenced
7552 from the Ada code.  The implementation should assume that any call to a
7553 machine code or assembler subprogram is allowed to read or update every
7554 object that is specified as exported.
7555 @end cartouche
7556 Followed.
7557
7558 @unnumberedsec C.1(10-16): Access to Machine Operations
7559 @sp 1
7560 @cartouche
7561 The implementation should ensure that little or no overhead is
7562 associated with calling intrinsic and machine-code subprograms.
7563 @end cartouche
7564 Followed for both intrinsics and machine-code subprograms.
7565
7566 @sp 1
7567 @cartouche
7568 It is recommended that intrinsic subprograms be provided for convenient
7569 access to any machine operations that provide special capabilities or
7570 efficiency and that are not otherwise available through the language
7571 constructs.
7572 @end cartouche
7573 Followed.  A full set of machine operation intrinsic subprograms is provided.
7574
7575 @sp 1
7576 @cartouche
7577 Atomic read-modify-write operations---e.g.@:, test and set, compare and
7578 swap, decrement and test, enqueue/dequeue.
7579 @end cartouche
7580 Followed on any target supporting such operations.
7581
7582 @sp 1
7583 @cartouche
7584 Standard numeric functions---e.g.@:, sin, log.
7585 @end cartouche
7586 Followed on any target supporting such operations.
7587
7588 @sp 1
7589 @cartouche
7590 String manipulation operations---e.g.@:, translate and test.
7591 @end cartouche
7592 Followed on any target supporting such operations.
7593
7594 @sp 1
7595 @cartouche
7596 Vector operations---e.g.@:, compare vector against thresholds.
7597 @end cartouche
7598 Followed on any target supporting such operations.
7599
7600 @sp 1
7601 @cartouche
7602 Direct operations on I/O ports.
7603 @end cartouche
7604 Followed on any target supporting such operations.
7605
7606 @cindex Interrupt support
7607 @unnumberedsec C.3(28): Interrupt Support
7608 @sp 1
7609 @cartouche
7610 If the @code{Ceiling_Locking} policy is not in effect, the
7611 implementation should provide means for the application to specify which
7612 interrupts are to be blocked during protected actions, if the underlying
7613 system allows for a finer-grain control of interrupt blocking.
7614 @end cartouche
7615 Followed.  The underlying system does not allow for finer-grain control
7616 of interrupt blocking.
7617
7618 @cindex Protected procedure handlers
7619 @unnumberedsec C.3.1(20-21): Protected Procedure Handlers
7620 @sp 1
7621 @cartouche
7622 Whenever possible, the implementation should allow interrupt handlers to
7623 be called directly by the hardware.
7624 @end cartouche
7625 @c SGI info:
7626 @ignore
7627 This is never possible under IRIX, so this is followed by default.
7628 @end ignore
7629 Followed on any target where the underlying operating system permits
7630 such direct calls.
7631
7632 @sp 1
7633 @cartouche
7634 Whenever practical, violations of any
7635 implementation-defined restrictions should be detected before run time.
7636 @end cartouche
7637 Followed.  Compile time warnings are given when possible.
7638
7639 @cindex Package @code{Interrupts}
7640 @findex Interrupts
7641 @unnumberedsec C.3.2(25): Package @code{Interrupts}
7642
7643 @sp 1
7644 @cartouche
7645 If implementation-defined forms of interrupt handler procedures are
7646 supported, such as protected procedures with parameters, then for each
7647 such form of a handler, a type analogous to @code{Parameterless_Handler}
7648 should be specified in a child package of @code{Interrupts}, with the
7649 same operations as in the predefined package Interrupts.
7650 @end cartouche
7651 Followed.
7652
7653 @cindex Pre-elaboration requirements
7654 @unnumberedsec C.4(14): Pre-elaboration Requirements
7655 @sp 1
7656 @cartouche
7657 It is recommended that pre-elaborated packages be implemented in such a
7658 way that there should be little or no code executed at run time for the
7659 elaboration of entities not already covered by the Implementation
7660 Requirements.
7661 @end cartouche
7662 Followed.  Executable code is generated in some cases, e.g.@: loops
7663 to initialize large arrays.
7664
7665 @unnumberedsec C.5(8): Pragma @code{Discard_Names}
7666
7667 @sp 1
7668 @cartouche
7669 If the pragma applies to an entity, then the implementation should
7670 reduce the amount of storage used for storing names associated with that
7671 entity.
7672 @end cartouche
7673 Followed.
7674
7675 @cindex Package @code{Task_Attributes}
7676 @findex Task_Attributes
7677 @unnumberedsec C.7.2(30): The Package Task_Attributes
7678 @sp 1
7679 @cartouche
7680 Some implementations are targeted to domains in which memory use at run
7681 time must be completely deterministic.  For such implementations, it is
7682 recommended that the storage for task attributes will be pre-allocated
7683 statically and not from the heap.  This can be accomplished by either
7684 placing restrictions on the number and the size of the task's
7685 attributes, or by using the pre-allocated storage for the first @var{N}
7686 attribute objects, and the heap for the others.  In the latter case,
7687 @var{N} should be documented.
7688 @end cartouche
7689 Not followed.  This implementation is not targeted to such a domain.
7690
7691 @cindex Locking Policies
7692 @unnumberedsec D.3(17): Locking Policies
7693
7694 @sp 1
7695 @cartouche
7696 The implementation should use names that end with @samp{_Locking} for
7697 locking policies defined by the implementation.
7698 @end cartouche
7699 Followed.  A single implementation-defined locking policy is defined,
7700 whose name (@code{Inheritance_Locking}) follows this suggestion.
7701
7702 @cindex Entry queuing policies
7703 @unnumberedsec D.4(16): Entry Queuing Policies
7704 @sp 1
7705 @cartouche
7706 Names that end with @samp{_Queuing} should be used
7707 for all implementation-defined queuing policies.
7708 @end cartouche
7709 Followed.  No such implementation-defined queuing policies exist.
7710
7711 @cindex Preemptive abort
7712 @unnumberedsec D.6(9-10): Preemptive Abort
7713 @sp 1
7714 @cartouche
7715 Even though the @code{abort_statement} is included in the list of
7716 potentially blocking operations (see 9.5.1), it is recommended that this
7717 statement be implemented in a way that never requires the task executing
7718 the @code{abort_statement} to block.
7719 @end cartouche
7720 Followed.
7721
7722 @sp 1
7723 @cartouche
7724 On a multi-processor, the delay associated with aborting a task on
7725 another processor should be bounded; the implementation should use
7726 periodic polling, if necessary, to achieve this.
7727 @end cartouche
7728 Followed.
7729
7730 @cindex Tasking restrictions
7731 @unnumberedsec D.7(21): Tasking Restrictions
7732 @sp 1
7733 @cartouche
7734 When feasible, the implementation should take advantage of the specified
7735 restrictions to produce a more efficient implementation.
7736 @end cartouche
7737 GNAT currently takes advantage of these restrictions by providing an optimized
7738 run time when the Ravenscar profile and the GNAT restricted run time set
7739 of restrictions are specified.  See pragma @code{Profile (Ravenscar)} and
7740 pragma @code{Profile (Restricted)} for more details.
7741
7742 @cindex Time, monotonic
7743 @unnumberedsec D.8(47-49): Monotonic Time
7744 @sp 1
7745 @cartouche
7746 When appropriate, implementations should provide configuration
7747 mechanisms to change the value of @code{Tick}.
7748 @end cartouche
7749 Such configuration mechanisms are not appropriate to this implementation
7750 and are thus not supported.
7751
7752 @sp 1
7753 @cartouche
7754 It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
7755 be implemented as transformations of the same time base.
7756 @end cartouche
7757 Followed.
7758
7759 @sp 1
7760 @cartouche
7761 It is recommended that the @dfn{best} time base which exists in
7762 the underlying system be available to the application through
7763 @code{Clock}.  @dfn{Best} may mean highest accuracy or largest range.
7764 @end cartouche
7765 Followed.
7766
7767 @cindex Partition communication subsystem
7768 @cindex PCS
7769 @unnumberedsec E.5(28-29): Partition Communication Subsystem
7770 @sp 1
7771 @cartouche
7772 Whenever possible, the PCS on the called partition should allow for
7773 multiple tasks to call the RPC-receiver with different messages and
7774 should allow them to block until the corresponding subprogram body
7775 returns.
7776 @end cartouche
7777 Followed by GLADE, a separately supplied PCS that can be used with
7778 GNAT.
7779
7780 @sp 1
7781 @cartouche
7782 The @code{Write} operation on a stream of type @code{Params_Stream_Type}
7783 should raise @code{Storage_Error} if it runs out of space trying to
7784 write the @code{Item} into the stream.
7785 @end cartouche
7786 Followed by GLADE, a separately supplied PCS that can be used with
7787 GNAT@.
7788
7789 @cindex COBOL support
7790 @unnumberedsec F(7): COBOL Support
7791 @sp 1
7792 @cartouche
7793 If COBOL (respectively, C) is widely supported in the target
7794 environment, implementations supporting the Information Systems Annex
7795 should provide the child package @code{Interfaces.COBOL} (respectively,
7796 @code{Interfaces.C}) specified in Annex B and should support a
7797 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
7798 pragmas (see Annex B), thus allowing Ada programs to interface with
7799 programs written in that language.
7800 @end cartouche
7801 Followed.
7802
7803 @cindex Decimal radix support
7804 @unnumberedsec F.1(2): Decimal Radix Support
7805 @sp 1
7806 @cartouche
7807 Packed decimal should be used as the internal representation for objects
7808 of subtype @var{S} when @var{S}'Machine_Radix = 10.
7809 @end cartouche
7810 Not followed.  GNAT ignores @var{S}'Machine_Radix and always uses binary
7811 representations.
7812
7813 @cindex Numerics
7814 @unnumberedsec G: Numerics
7815 @sp 2
7816 @cartouche
7817 If Fortran (respectively, C) is widely supported in the target
7818 environment, implementations supporting the Numerics Annex
7819 should provide the child package @code{Interfaces.Fortran} (respectively,
7820 @code{Interfaces.C}) specified in Annex B and should support a
7821 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
7822 pragmas (see Annex B), thus allowing Ada programs to interface with
7823 programs written in that language.
7824 @end cartouche
7825 Followed.
7826
7827 @cindex Complex types
7828 @unnumberedsec G.1.1(56-58): Complex Types
7829 @sp 2
7830 @cartouche
7831 Because the usual mathematical meaning of multiplication of a complex
7832 operand and a real operand is that of the scaling of both components of
7833 the former by the latter, an implementation should not perform this
7834 operation by first promoting the real operand to complex type and then
7835 performing a full complex multiplication.  In systems that, in the
7836 future, support an Ada binding to IEC 559:1989, the latter technique
7837 will not generate the required result when one of the components of the
7838 complex operand is infinite.  (Explicit multiplication of the infinite
7839 component by the zero component obtained during promotion yields a NaN
7840 that propagates into the final result.) Analogous advice applies in the
7841 case of multiplication of a complex operand and a pure-imaginary
7842 operand, and in the case of division of a complex operand by a real or
7843 pure-imaginary operand.
7844 @end cartouche
7845 Not followed.
7846
7847 @sp 1
7848 @cartouche
7849 Similarly, because the usual mathematical meaning of addition of a
7850 complex operand and a real operand is that the imaginary operand remains
7851 unchanged, an implementation should not perform this operation by first
7852 promoting the real operand to complex type and then performing a full
7853 complex addition.  In implementations in which the @code{Signed_Zeros}
7854 attribute of the component type is @code{True} (and which therefore
7855 conform to IEC 559:1989 in regard to the handling of the sign of zero in
7856 predefined arithmetic operations), the latter technique will not
7857 generate the required result when the imaginary component of the complex
7858 operand is a negatively signed zero.  (Explicit addition of the negative
7859 zero to the zero obtained during promotion yields a positive zero.)
7860 Analogous advice applies in the case of addition of a complex operand
7861 and a pure-imaginary operand, and in the case of subtraction of a
7862 complex operand and a real or pure-imaginary operand.
7863 @end cartouche
7864 Not followed.
7865
7866 @sp 1
7867 @cartouche
7868 Implementations in which @code{Real'Signed_Zeros} is @code{True} should
7869 attempt to provide a rational treatment of the signs of zero results and
7870 result components.  As one example, the result of the @code{Argument}
7871 function should have the sign of the imaginary component of the
7872 parameter @code{X} when the point represented by that parameter lies on
7873 the positive real axis; as another, the sign of the imaginary component
7874 of the @code{Compose_From_Polar} function should be the same as
7875 (respectively, the opposite of) that of the @code{Argument} parameter when that
7876 parameter has a value of zero and the @code{Modulus} parameter has a
7877 nonnegative (respectively, negative) value.
7878 @end cartouche
7879 Followed.
7880
7881 @cindex Complex elementary functions
7882 @unnumberedsec G.1.2(49): Complex Elementary Functions
7883 @sp 1
7884 @cartouche
7885 Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
7886 @code{True} should attempt to provide a rational treatment of the signs
7887 of zero results and result components.  For example, many of the complex
7888 elementary functions have components that are odd functions of one of
7889 the parameter components; in these cases, the result component should
7890 have the sign of the parameter component at the origin.  Other complex
7891 elementary functions have zero components whose sign is opposite that of
7892 a parameter component at the origin, or is always positive or always
7893 negative.
7894 @end cartouche
7895 Followed.
7896
7897 @cindex Accuracy requirements
7898 @unnumberedsec G.2.4(19): Accuracy Requirements
7899 @sp 1
7900 @cartouche
7901 The versions of the forward trigonometric functions without a
7902 @code{Cycle} parameter should not be implemented by calling the
7903 corresponding version with a @code{Cycle} parameter of
7904 @code{2.0*Numerics.Pi}, since this will not provide the required
7905 accuracy in some portions of the domain.  For the same reason, the
7906 version of @code{Log} without a @code{Base} parameter should not be
7907 implemented by calling the corresponding version with a @code{Base}
7908 parameter of @code{Numerics.e}.
7909 @end cartouche
7910 Followed.
7911
7912 @cindex Complex arithmetic accuracy
7913 @cindex Accuracy, complex arithmetic
7914 @unnumberedsec G.2.6(15): Complex Arithmetic Accuracy
7915
7916 @sp 1
7917 @cartouche
7918 The version of the @code{Compose_From_Polar} function without a
7919 @code{Cycle} parameter should not be implemented by calling the
7920 corresponding version with a @code{Cycle} parameter of
7921 @code{2.0*Numerics.Pi}, since this will not provide the required
7922 accuracy in some portions of the domain.
7923 @end cartouche
7924 Followed.
7925
7926 @c -----------------------------------------
7927 @node Implementation Defined Characteristics
7928 @chapter Implementation Defined Characteristics
7929
7930 @noindent
7931 In addition to the implementation dependent pragmas and attributes, and the
7932 implementation advice, there are a number of other Ada features that are
7933 potentially implementation dependent and are designated as
7934 implementation-defined. These are mentioned throughout the Ada Reference
7935 Manual, and are summarized in Annex M@.
7936
7937 A requirement for conforming Ada compilers is that they provide
7938 documentation describing how the implementation deals with each of these
7939 issues.  In this chapter, you will find each point in Annex M listed
7940 followed by a description in italic font of how GNAT
7941 @c SGI info:
7942 @ignore
7943 in the ProDev Ada
7944 implementation on IRIX 5.3 operating system or greater
7945 @end ignore
7946 handles the implementation dependence.
7947
7948 You can use this chapter as a guide to minimizing implementation
7949 dependent features in your programs if portability to other compilers
7950 and other operating systems is an important consideration.  The numbers
7951 in each section below correspond to the paragraph number in the Ada
7952 Reference Manual.
7953
7954 @sp 1
7955 @cartouche
7956 @noindent
7957 @strong{2}.  Whether or not each recommendation given in Implementation
7958 Advice is followed.  See 1.1.2(37).
7959 @end cartouche
7960 @noindent
7961 @xref{Implementation Advice}.
7962
7963 @sp 1
7964 @cartouche
7965 @noindent
7966 @strong{3}.  Capacity limitations of the implementation.  See 1.1.3(3).
7967 @end cartouche
7968 @noindent
7969 The complexity of programs that can be processed is limited only by the
7970 total amount of available virtual memory, and disk space for the
7971 generated object files.
7972
7973 @sp 1
7974 @cartouche
7975 @noindent
7976 @strong{4}.  Variations from the standard that are impractical to avoid
7977 given the implementation's execution environment.  See 1.1.3(6).
7978 @end cartouche
7979 @noindent
7980 There are no variations from the standard.
7981
7982 @sp 1
7983 @cartouche
7984 @noindent
7985 @strong{5}.  Which @code{code_statement}s cause external
7986 interactions.  See 1.1.3(10).
7987 @end cartouche
7988 @noindent
7989 Any @code{code_statement} can potentially cause external interactions.
7990
7991 @sp 1
7992 @cartouche
7993 @noindent
7994 @strong{6}.  The coded representation for the text of an Ada
7995 program.  See 2.1(4).
7996 @end cartouche
7997 @noindent
7998 See separate section on source representation.
7999
8000 @sp 1
8001 @cartouche
8002 @noindent
8003 @strong{7}.  The control functions allowed in comments.  See 2.1(14).
8004 @end cartouche
8005 @noindent
8006 See separate section on source representation.
8007
8008 @sp 1
8009 @cartouche
8010 @noindent
8011 @strong{8}.  The representation for an end of line.  See 2.2(2).
8012 @end cartouche
8013 @noindent
8014 See separate section on source representation.
8015
8016 @sp 1
8017 @cartouche
8018 @noindent
8019 @strong{9}.  Maximum supported line length and lexical element
8020 length.  See 2.2(15).
8021 @end cartouche
8022 @noindent
8023 The maximum line length is 255 characters and the maximum length of a
8024 lexical element is also 255 characters.
8025
8026 @sp 1
8027 @cartouche
8028 @noindent
8029 @strong{10}.  Implementation defined pragmas.  See 2.8(14).
8030 @end cartouche
8031 @noindent
8032
8033 @xref{Implementation Defined Pragmas}.
8034
8035 @sp 1
8036 @cartouche
8037 @noindent
8038 @strong{11}.  Effect of pragma @code{Optimize}.  See 2.8(27).
8039 @end cartouche
8040 @noindent
8041 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
8042 parameter, checks that the optimization flag is set, and aborts if it is
8043 not.
8044
8045 @sp 1
8046 @cartouche
8047 @noindent
8048 @strong{12}.  The sequence of characters of the value returned by
8049 @code{@var{S}'Image} when some of the graphic characters of
8050 @code{@var{S}'Wide_Image} are not defined in @code{Character}.  See
8051 3.5(37).
8052 @end cartouche
8053 @noindent
8054 The sequence of characters is as defined by the wide character encoding
8055 method used for the source.  See section on source representation for
8056 further details.
8057
8058 @sp 1
8059 @cartouche
8060 @noindent
8061 @strong{13}.  The predefined integer types declared in
8062 @code{Standard}.  See 3.5.4(25).
8063 @end cartouche
8064 @noindent
8065 @table @code
8066 @item Short_Short_Integer
8067 8 bit signed
8068 @item Short_Integer
8069 (Short) 16 bit signed
8070 @item Integer
8071 32 bit signed
8072 @item Long_Integer
8073 64 bit signed (Alpha OpenVMS only)
8074 32 bit signed (all other targets)
8075 @item Long_Long_Integer
8076 64 bit signed
8077 @end table
8078
8079 @sp 1
8080 @cartouche
8081 @noindent
8082 @strong{14}.  Any nonstandard integer types and the operators defined
8083 for them.  See 3.5.4(26).
8084 @end cartouche
8085 @noindent
8086 There are no nonstandard integer types.
8087
8088 @sp 1
8089 @cartouche
8090 @noindent
8091 @strong{15}.  Any nonstandard real types and the operators defined for
8092 them.  See 3.5.6(8).
8093 @end cartouche
8094 @noindent
8095 There are no nonstandard real types.
8096
8097 @sp 1
8098 @cartouche
8099 @noindent
8100 @strong{16}.  What combinations of requested decimal precision and range
8101 are supported for floating point types.  See 3.5.7(7).
8102 @end cartouche
8103 @noindent
8104 The precision and range is as defined by the IEEE standard.
8105
8106 @sp 1
8107 @cartouche
8108 @noindent
8109 @strong{17}.  The predefined floating point types declared in
8110 @code{Standard}.  See 3.5.7(16).
8111 @end cartouche
8112 @noindent
8113 @table @code
8114 @item Short_Float
8115 32 bit IEEE short
8116 @item Float
8117 (Short) 32 bit IEEE short
8118 @item Long_Float
8119 64 bit IEEE long
8120 @item Long_Long_Float
8121 64 bit IEEE long (80 bit IEEE long on x86 processors)
8122 @end table
8123
8124 @sp 1
8125 @cartouche
8126 @noindent
8127 @strong{18}.  The small of an ordinary fixed point type.  See 3.5.9(8).
8128 @end cartouche
8129 @noindent
8130 @code{Fine_Delta} is 2**(@minus{}63)
8131
8132 @sp 1
8133 @cartouche
8134 @noindent
8135 @strong{19}.  What combinations of small, range, and digits are
8136 supported for fixed point types.  See 3.5.9(10).
8137 @end cartouche
8138 @noindent
8139 Any combinations are permitted that do not result in a small less than
8140 @code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
8141 If the mantissa is larger than 53 bits on machines where Long_Long_Float
8142 is 64 bits (true of all architectures except ia32), then the output from
8143 Text_IO is accurate to only 53 bits, rather than the full mantissa.  This
8144 is because floating-point conversions are used to convert fixed point.
8145
8146 @sp 1
8147 @cartouche
8148 @noindent
8149 @strong{20}.  The result of @code{Tags.Expanded_Name} for types declared
8150 within an unnamed @code{block_statement}.  See 3.9(10).
8151 @end cartouche
8152 @noindent
8153 Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
8154 decimal integer are allocated.
8155
8156 @sp 1
8157 @cartouche
8158 @noindent
8159 @strong{21}.  Implementation-defined attributes.  See 4.1.4(12).
8160 @end cartouche
8161 @noindent
8162 @xref{Implementation Defined Attributes}.
8163
8164 @sp 1
8165 @cartouche
8166 @noindent
8167 @strong{22}.  Any implementation-defined time types.  See 9.6(6).
8168 @end cartouche
8169 @noindent
8170 There are no implementation-defined time types.
8171
8172 @sp 1
8173 @cartouche
8174 @noindent
8175 @strong{23}.  The time base associated with relative delays.
8176 @end cartouche
8177 @noindent
8178 See 9.6(20).  The time base used is that provided by the C library
8179 function @code{gettimeofday}.
8180
8181 @sp 1
8182 @cartouche
8183 @noindent
8184 @strong{24}.  The time base of the type @code{Calendar.Time}.  See
8185 9.6(23).
8186 @end cartouche
8187 @noindent
8188 The time base used is that provided by the C library function
8189 @code{gettimeofday}.
8190
8191 @sp 1
8192 @cartouche
8193 @noindent
8194 @strong{25}.  The time zone used for package @code{Calendar}
8195 operations.  See 9.6(24).
8196 @end cartouche
8197 @noindent
8198 The time zone used by package @code{Calendar} is the current system time zone
8199 setting for local time, as accessed by the C library function
8200 @code{localtime}.
8201
8202 @sp 1
8203 @cartouche
8204 @noindent
8205 @strong{26}.  Any limit on @code{delay_until_statements} of
8206 @code{select_statements}.  See 9.6(29).
8207 @end cartouche
8208 @noindent
8209 There are no such limits.
8210
8211 @sp 1
8212 @cartouche
8213 @noindent
8214 @strong{27}.  Whether or not two non-overlapping parts of a composite
8215 object are independently addressable, in the case where packing, record
8216 layout, or @code{Component_Size} is specified for the object.  See
8217 9.10(1).
8218 @end cartouche
8219 @noindent
8220 Separate components are independently addressable if they do not share
8221 overlapping storage units.
8222
8223 @sp 1
8224 @cartouche
8225 @noindent
8226 @strong{28}.  The representation for a compilation.  See 10.1(2).
8227 @end cartouche
8228 @noindent
8229 A compilation is represented by a sequence of files presented to the
8230 compiler in a single invocation of the @command{gcc} command.
8231
8232 @sp 1
8233 @cartouche
8234 @noindent
8235 @strong{29}.  Any restrictions on compilations that contain multiple
8236 compilation_units.  See 10.1(4).
8237 @end cartouche
8238 @noindent
8239 No single file can contain more than one compilation unit, but any
8240 sequence of files can be presented to the compiler as a single
8241 compilation.
8242
8243 @sp 1
8244 @cartouche
8245 @noindent
8246 @strong{30}.  The mechanisms for creating an environment and for adding
8247 and replacing compilation units.  See 10.1.4(3).
8248 @end cartouche
8249 @noindent
8250 See separate section on compilation model.
8251
8252 @sp 1
8253 @cartouche
8254 @noindent
8255 @strong{31}.  The manner of explicitly assigning library units to a
8256 partition.  See 10.2(2).
8257 @end cartouche
8258 @noindent
8259 If a unit contains an Ada main program, then the Ada units for the partition
8260 are determined by recursive application of the rules in the Ada Reference
8261 Manual section 10.2(2-6).  In other words, the Ada units will be those that
8262 are needed by the main program, and then this definition of need is applied
8263 recursively to those units, and the partition contains the transitive
8264 closure determined by this relationship.  In short, all the necessary units
8265 are included, with no need to explicitly specify the list.  If additional
8266 units are required, e.g.@: by foreign language units, then all units must be
8267 mentioned in the context clause of one of the needed Ada units.
8268
8269 If the partition contains no main program, or if the main program is in
8270 a language other than Ada, then GNAT
8271 provides the binder options @option{-z} and @option{-n} respectively, and in
8272 this case a list of units can be explicitly supplied to the binder for
8273 inclusion in the partition (all units needed by these units will also
8274 be included automatically).  For full details on the use of these
8275 options, refer to @ref{The GNAT Make Program gnatmake,,, gnat_ugn,
8276 @value{EDITION} User's Guide}.
8277
8278 @sp 1
8279 @cartouche
8280 @noindent
8281 @strong{32}.  The implementation-defined means, if any, of specifying
8282 which compilation units are needed by a given compilation unit.  See
8283 10.2(2).
8284 @end cartouche
8285 @noindent
8286 The units needed by a given compilation unit are as defined in
8287 the Ada Reference Manual section 10.2(2-6).  There are no
8288 implementation-defined pragmas or other implementation-defined
8289 means for specifying needed units.
8290
8291 @sp 1
8292 @cartouche
8293 @noindent
8294 @strong{33}.  The manner of designating the main subprogram of a
8295 partition.  See 10.2(7).
8296 @end cartouche
8297 @noindent
8298 The main program is designated by providing the name of the
8299 corresponding @file{ALI} file as the input parameter to the binder.
8300
8301 @sp 1
8302 @cartouche
8303 @noindent
8304 @strong{34}.  The order of elaboration of @code{library_items}.  See
8305 10.2(18).
8306 @end cartouche
8307 @noindent
8308 The first constraint on ordering is that it meets the requirements of
8309 Chapter 10 of the Ada Reference Manual.  This still leaves some
8310 implementation dependent choices, which are resolved by first
8311 elaborating bodies as early as possible (i.e., in preference to specs
8312 where there is a choice), and second by evaluating the immediate with
8313 clauses of a unit to determine the probably best choice, and
8314 third by elaborating in alphabetical order of unit names
8315 where a choice still remains.
8316
8317 @sp 1
8318 @cartouche
8319 @noindent
8320 @strong{35}.  Parameter passing and function return for the main
8321 subprogram.  See 10.2(21).
8322 @end cartouche
8323 @noindent
8324 The main program has no parameters.  It may be a procedure, or a function
8325 returning an integer type.  In the latter case, the returned integer
8326 value is the return code of the program (overriding any value that
8327 may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
8328
8329 @sp 1
8330 @cartouche
8331 @noindent
8332 @strong{36}.  The mechanisms for building and running partitions.  See
8333 10.2(24).
8334 @end cartouche
8335 @noindent
8336 GNAT itself supports programs with only a single partition.  The GNATDIST
8337 tool provided with the GLADE package (which also includes an implementation
8338 of the PCS) provides a completely flexible method for building and running
8339 programs consisting of multiple partitions.  See the separate GLADE manual
8340 for details.
8341
8342 @sp 1
8343 @cartouche
8344 @noindent
8345 @strong{37}.  The details of program execution, including program
8346 termination.  See 10.2(25).
8347 @end cartouche
8348 @noindent
8349 See separate section on compilation model.
8350
8351 @sp 1
8352 @cartouche
8353 @noindent
8354 @strong{38}.  The semantics of any non-active partitions supported by the
8355 implementation.  See 10.2(28).
8356 @end cartouche
8357 @noindent
8358 Passive partitions are supported on targets where shared memory is
8359 provided by the operating system.  See the GLADE reference manual for
8360 further details.
8361
8362 @sp 1
8363 @cartouche
8364 @noindent
8365 @strong{39}.  The information returned by @code{Exception_Message}.  See
8366 11.4.1(10).
8367 @end cartouche
8368 @noindent
8369 Exception message returns the null string unless a specific message has
8370 been passed by the program.
8371
8372 @sp 1
8373 @cartouche
8374 @noindent
8375 @strong{40}.  The result of @code{Exceptions.Exception_Name} for types
8376 declared within an unnamed @code{block_statement}.  See 11.4.1(12).
8377 @end cartouche
8378 @noindent
8379 Blocks have implementation defined names of the form @code{B@var{nnn}}
8380 where @var{nnn} is an integer.
8381
8382 @sp 1
8383 @cartouche
8384 @noindent
8385 @strong{41}.  The information returned by
8386 @code{Exception_Information}.  See 11.4.1(13).
8387 @end cartouche
8388 @noindent
8389 @code{Exception_Information} returns a string in the following format:
8390
8391 @smallexample
8392 @emph{Exception_Name:} nnnnn
8393 @emph{Message:} mmmmm
8394 @emph{PID:} ppp
8395 @emph{Call stack traceback locations:}
8396 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
8397 @end smallexample
8398
8399 @noindent
8400 where
8401
8402 @itemize @bullet
8403 @item
8404 @code{nnnn} is the fully qualified name of the exception in all upper
8405 case letters. This line is always present.
8406
8407 @item
8408 @code{mmmm} is the message (this line present only if message is non-null)
8409
8410 @item
8411 @code{ppp} is the Process Id value as a decimal integer (this line is
8412 present only if the Process Id is nonzero). Currently we are
8413 not making use of this field.
8414
8415 @item
8416 The Call stack traceback locations line and the following values
8417 are present only if at least one traceback location was recorded.
8418 The values are given in C style format, with lower case letters
8419 for a-f, and only as many digits present as are necessary.
8420 @end itemize
8421
8422 @noindent
8423 The line terminator sequence at the end of each line, including
8424 the last line is a single @code{LF} character (@code{16#0A#}).
8425
8426 @sp 1
8427 @cartouche
8428 @noindent
8429 @strong{42}.  Implementation-defined check names.  See 11.5(27).
8430 @end cartouche
8431 @noindent
8432 The implementation defined check name Alignment_Check controls checking of
8433 address clause values for proper alignment (that is, the address supplied
8434 must be consistent with the alignment of the type).
8435
8436 In addition, a user program can add implementation-defined check names
8437 by means of the pragma Check_Name.
8438
8439 @sp 1
8440 @cartouche
8441 @noindent
8442 @strong{43}.  The interpretation of each aspect of representation.  See
8443 13.1(20).
8444 @end cartouche
8445 @noindent
8446 See separate section on data representations.
8447
8448 @sp 1
8449 @cartouche
8450 @noindent
8451 @strong{44}.  Any restrictions placed upon representation items.  See
8452 13.1(20).
8453 @end cartouche
8454 @noindent
8455 See separate section on data representations.
8456
8457 @sp 1
8458 @cartouche
8459 @noindent
8460 @strong{45}.  The meaning of @code{Size} for indefinite subtypes.  See
8461 13.3(48).
8462 @end cartouche
8463 @noindent
8464 Size for an indefinite subtype is the maximum possible size, except that
8465 for the case of a subprogram parameter, the size of the parameter object
8466 is the actual size.
8467
8468 @sp 1
8469 @cartouche
8470 @noindent
8471 @strong{46}.  The default external representation for a type tag.  See
8472 13.3(75).
8473 @end cartouche
8474 @noindent
8475 The default external representation for a type tag is the fully expanded
8476 name of the type in upper case letters.
8477
8478 @sp 1
8479 @cartouche
8480 @noindent
8481 @strong{47}.  What determines whether a compilation unit is the same in
8482 two different partitions.  See 13.3(76).
8483 @end cartouche
8484 @noindent
8485 A compilation unit is the same in two different partitions if and only
8486 if it derives from the same source file.
8487
8488 @sp 1
8489 @cartouche
8490 @noindent
8491 @strong{48}.  Implementation-defined components.  See 13.5.1(15).
8492 @end cartouche
8493 @noindent
8494 The only implementation defined component is the tag for a tagged type,
8495 which contains a pointer to the dispatching table.
8496
8497 @sp 1
8498 @cartouche
8499 @noindent
8500 @strong{49}.  If @code{Word_Size} = @code{Storage_Unit}, the default bit
8501 ordering.  See 13.5.3(5).
8502 @end cartouche
8503 @noindent
8504 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
8505 implementation, so no non-default bit ordering is supported.  The default
8506 bit ordering corresponds to the natural endianness of the target architecture.
8507
8508 @sp 1
8509 @cartouche
8510 @noindent
8511 @strong{50}.  The contents of the visible part of package @code{System}
8512 and its language-defined children.  See 13.7(2).
8513 @end cartouche
8514 @noindent
8515 See the definition of these packages in files @file{system.ads} and
8516 @file{s-stoele.ads}.
8517
8518 @sp 1
8519 @cartouche
8520 @noindent
8521 @strong{51}.  The contents of the visible part of package
8522 @code{System.Machine_Code}, and the meaning of
8523 @code{code_statements}.  See 13.8(7).
8524 @end cartouche
8525 @noindent
8526 See the definition and documentation in file @file{s-maccod.ads}.
8527
8528 @sp 1
8529 @cartouche
8530 @noindent
8531 @strong{52}.  The effect of unchecked conversion.  See 13.9(11).
8532 @end cartouche
8533 @noindent
8534 Unchecked conversion between types of the same size
8535 results in an uninterpreted transmission of the bits from one type
8536 to the other.  If the types are of unequal sizes, then in the case of
8537 discrete types, a shorter source is first zero or sign extended as
8538 necessary, and a shorter target is simply truncated on the left.
8539 For all non-discrete types, the source is first copied if necessary
8540 to ensure that the alignment requirements of the target are met, then
8541 a pointer is constructed to the source value, and the result is obtained
8542 by dereferencing this pointer after converting it to be a pointer to the
8543 target type. Unchecked conversions where the target subtype is an
8544 unconstrained array are not permitted. If the target alignment is
8545 greater than the source alignment, then a copy of the result is
8546 made with appropriate alignment
8547
8548 @sp 1
8549 @cartouche
8550 @noindent
8551 @strong{53}. The semantics of operations on invalid representations.
8552 See 13.9.2(10-11).
8553 @end cartouche
8554 @noindent
8555 For assignments and other operations where the use of invalid values cannot
8556 result in erroneous behavior, the compiler ignores the possibility of invalid
8557 values. An exception is raised at the point where an invalid value would
8558 result in erroneous behavior. For example executing:
8559
8560 @smallexample @c ada
8561 procedure invalidvals is
8562    X : Integer := -1;
8563    Y : Natural range 1 .. 10;
8564    for Y'Address use X'Address;
8565    Z : Natural range 1 .. 10;
8566    A : array (Natural range 1 .. 10) of Integer;
8567 begin
8568    Z := Y;     -- no exception
8569    A (Z) := 3; -- exception raised;
8570 end;
8571 @end smallexample
8572
8573 @noindent
8574 As indicated, an exception is raised on the array assignment, but not
8575 on the simple assignment of the invalid negative value from Y to Z.
8576
8577 @sp 1
8578 @cartouche
8579 @noindent
8580 @strong{53}.  The manner of choosing a storage pool for an access type
8581 when @code{Storage_Pool} is not specified for the type.  See 13.11(17).
8582 @end cartouche
8583 @noindent
8584 There are 3 different standard pools used by the compiler when
8585 @code{Storage_Pool} is not specified depending whether the type is local
8586 to a subprogram or defined at the library level and whether
8587 @code{Storage_Size}is specified or not.  See documentation in the runtime
8588 library units @code{System.Pool_Global}, @code{System.Pool_Size} and
8589 @code{System.Pool_Local} in files @file{s-poosiz.ads},
8590 @file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
8591 default pools used.
8592
8593 @sp 1
8594 @cartouche
8595 @noindent
8596 @strong{54}.  Whether or not the implementation provides user-accessible
8597 names for the standard pool type(s).  See 13.11(17).
8598 @end cartouche
8599 @noindent
8600
8601 See documentation in the sources of the run time mentioned in paragraph
8602 @strong{53} .  All these pools are accessible by means of @code{with}'ing
8603 these units.
8604
8605 @sp 1
8606 @cartouche
8607 @noindent
8608 @strong{55}.  The meaning of @code{Storage_Size}.  See 13.11(18).
8609 @end cartouche
8610 @noindent
8611 @code{Storage_Size} is measured in storage units, and refers to the
8612 total space available for an access type collection, or to the primary
8613 stack space for a task.
8614
8615 @sp 1
8616 @cartouche
8617 @noindent
8618 @strong{56}.  Implementation-defined aspects of storage pools.  See
8619 13.11(22).
8620 @end cartouche
8621 @noindent
8622 See documentation in the sources of the run time mentioned in paragraph
8623 @strong{53} for details on GNAT-defined aspects of storage pools.
8624
8625 @sp 1
8626 @cartouche
8627 @noindent
8628 @strong{57}.  The set of restrictions allowed in a pragma
8629 @code{Restrictions}.  See 13.12(7).
8630 @end cartouche
8631 @noindent
8632 All RM defined Restriction identifiers are implemented.  The following
8633 additional restriction identifiers are provided.  There are two separate
8634 lists of implementation dependent restriction identifiers.  The first
8635 set requires consistency throughout a partition (in other words, if the
8636 restriction identifier is used for any compilation unit in the partition,
8637 then all compilation units in the partition must obey the restriction.
8638
8639 @table @code
8640
8641 @item Simple_Barriers
8642 @findex Simple_Barriers
8643 This restriction ensures at compile time that barriers in entry declarations
8644 for protected types are restricted to either static boolean expressions or
8645 references to simple boolean variables defined in the private part of the
8646 protected type.  No other form of entry barriers is permitted.  This is one
8647 of the restrictions of the Ravenscar profile for limited tasking (see also
8648 pragma @code{Profile (Ravenscar)}).
8649
8650 @item Max_Entry_Queue_Length => Expr
8651 @findex Max_Entry_Queue_Length
8652 This restriction is a declaration that any protected entry compiled in
8653 the scope of the restriction has at most the specified number of
8654 tasks waiting on the entry
8655 at any one time, and so no queue is required.  This restriction is not
8656 checked at compile time.  A program execution is erroneous if an attempt
8657 is made to queue more than the specified number of tasks on such an entry.
8658
8659 @item No_Calendar
8660 @findex No_Calendar
8661 This restriction ensures at compile time that there is no implicit or
8662 explicit dependence on the package @code{Ada.Calendar}.
8663
8664 @item No_Default_Initialization
8665 @findex No_Default_Initialization
8666
8667 This restriction prohibits any instance of default initialization of variables.
8668 The binder implements a consistency rule which prevents any unit compiled
8669 without the restriction from with'ing a unit with the restriction (this allows
8670 the generation of initialization procedures to be skipped, since you can be
8671 sure that no call is ever generated to an initialization procedure in a unit
8672 with the restriction active). If used in conjunction with Initialize_Scalars or
8673 Normalize_Scalars, the effect is to prohibit all cases of variables declared
8674 without a specific initializer (including the case of OUT scalar parameters).
8675
8676 @item No_Direct_Boolean_Operators
8677 @findex No_Direct_Boolean_Operators
8678 This restriction ensures that no logical (and/or/xor) are used on
8679 operands of type Boolean (or any type derived
8680 from Boolean). This is intended for use in safety critical programs
8681 where the certification protocol requires the use of short-circuit
8682 (and then, or else) forms for all composite boolean operations.
8683
8684 @item No_Dispatching_Calls
8685 @findex No_Dispatching_Calls
8686 This restriction ensures at compile time that the code generated by the
8687 compiler involves no dispatching calls. The use of this restriction allows the
8688 safe use of record extensions, classwide membership tests and other classwide
8689 features not involving implicit dispatching. This restriction ensures that
8690 the code contains no indirect calls through a dispatching mechanism. Note that
8691 this includes internally-generated calls created by the compiler, for example
8692 in the implementation of class-wide objects assignments. The
8693 membership test is allowed in the presence of this restriction, because its
8694 implementation requires no dispatching.
8695 This restriction is comparable to the official Ada restriction
8696 @code{No_Dispatch} except that it is a bit less restrictive in that it allows
8697 all classwide constructs that do not imply dispatching.
8698 The following example indicates constructs that violate this restriction.
8699
8700 @smallexample
8701 package Pkg is
8702   type T is tagged record
8703     Data : Natural;
8704   end record;
8705   procedure P (X : T);
8706
8707   type DT is new T with record
8708     More_Data : Natural;
8709   end record;
8710   procedure Q (X : DT);
8711 end Pkg;
8712
8713 with Pkg; use Pkg;
8714 procedure Example is
8715   procedure Test (O : T'Class) is
8716     N : Natural  := O'Size;--  Error: Dispatching call
8717     C : T'Class := O;      --  Error: implicit Dispatching Call
8718   begin
8719     if O in DT'Class then  --  OK   : Membership test
8720        Q (DT (O));         --  OK   : Type conversion plus direct call
8721     else
8722        P (O);              --  Error: Dispatching call
8723     end if;
8724   end Test;
8725
8726   Obj : DT;
8727 begin
8728   P (Obj);                 --  OK   : Direct call
8729   P (T (Obj));             --  OK   : Type conversion plus direct call
8730   P (T'Class (Obj));       --  Error: Dispatching call
8731
8732   Test (Obj);              --  OK   : Type conversion
8733
8734   if Obj in T'Class then   --  OK   : Membership test
8735      null;
8736   end if;
8737 end Example;
8738 @end smallexample
8739
8740 @item No_Dynamic_Attachment
8741 @findex No_Dynamic_Attachment
8742 This restriction ensures that there is no call to any of the operations
8743 defined in package Ada.Interrupts.
8744
8745 @item No_Enumeration_Maps
8746 @findex No_Enumeration_Maps
8747 This restriction ensures at compile time that no operations requiring
8748 enumeration maps are used (that is Image and Value attributes applied
8749 to enumeration types).
8750
8751 @item No_Entry_Calls_In_Elaboration_Code
8752 @findex No_Entry_Calls_In_Elaboration_Code
8753 This restriction ensures at compile time that no task or protected entry
8754 calls are made during elaboration code.  As a result of the use of this
8755 restriction, the compiler can assume that no code past an accept statement
8756 in a task can be executed at elaboration time.
8757
8758 @item No_Exception_Handlers
8759 @findex No_Exception_Handlers
8760 This restriction ensures at compile time that there are no explicit
8761 exception handlers. It also indicates that no exception propagation will
8762 be provided. In this mode, exceptions may be raised but will result in
8763 an immediate call to the last chance handler, a routine that the user
8764 must define with the following profile:
8765
8766 @smallexample @c ada
8767 procedure Last_Chance_Handler
8768   (Source_Location : System.Address; Line : Integer);
8769 pragma Export (C, Last_Chance_Handler,
8770                "__gnat_last_chance_handler");
8771 @end smallexample
8772
8773 The parameter is a C null-terminated string representing a message to be
8774 associated with the exception (typically the source location of the raise
8775 statement generated by the compiler). The Line parameter when nonzero
8776 represents the line number in the source program where the raise occurs.
8777
8778 @item No_Exception_Propagation
8779 @findex No_Exception_Propagation
8780 This restriction guarantees that exceptions are never propagated to an outer
8781 subprogram scope). The only case in which an exception may be raised is when
8782 the handler is statically in the same subprogram, so that the effect of a raise
8783 is essentially like a goto statement. Any other raise statement (implicit or
8784 explicit) will be considered unhandled. Exception handlers are allowed, but may
8785 not contain an exception occurrence identifier (exception choice). In addition
8786 use of the package GNAT.Current_Exception is not permitted, and reraise
8787 statements (raise with no operand) are not permitted.
8788
8789 @item No_Exception_Registration
8790 @findex No_Exception_Registration
8791 This restriction ensures at compile time that no stream operations for
8792 types Exception_Id or Exception_Occurrence are used. This also makes it
8793 impossible to pass exceptions to or from a partition with this restriction
8794 in a distributed environment. If this exception is active, then the generated
8795 code is simplified by omitting the otherwise-required global registration
8796 of exceptions when they are declared.
8797
8798 @item No_Implicit_Conditionals
8799 @findex No_Implicit_Conditionals
8800 This restriction ensures that the generated code does not contain any
8801 implicit conditionals, either by modifying the generated code where possible,
8802 or by rejecting any construct that would otherwise generate an implicit
8803 conditional. Note that this check does not include run time constraint
8804 checks, which on some targets may generate implicit conditionals as
8805 well. To control the latter, constraint checks can be suppressed in the
8806 normal manner. Constructs generating implicit conditionals include comparisons
8807 of composite objects and the Max/Min attributes.
8808
8809 @item No_Implicit_Dynamic_Code
8810 @findex No_Implicit_Dynamic_Code
8811 @cindex trampoline
8812 This restriction prevents the compiler from building ``trampolines''.
8813 This is a structure that is built on the stack and contains dynamic
8814 code to be executed at run time. On some targets, a trampoline is
8815 built for the following features: @code{Access},
8816 @code{Unrestricted_Access}, or @code{Address} of a nested subprogram;
8817 nested task bodies; primitive operations of nested tagged types.
8818 Trampolines do not work on machines that prevent execution of stack
8819 data. For example, on windows systems, enabling DEP (data execution
8820 protection) will cause trampolines to raise an exception.
8821 Trampolines are also quite slow at run time.
8822
8823 On many targets, trampolines have been largely eliminated. Look at the
8824 version of system.ads for your target --- if it has
8825 Always_Compatible_Rep equal to False, then trampolines are largely
8826 eliminated. In particular, a trampoline is built for the following
8827 features: @code{Address} of a nested subprogram;
8828 @code{Access} or @code{Unrestricted_Access} of a nested subprogram,
8829 but only if pragma Favor_Top_Level applies, or the access type has a
8830 foreign-language convention; primitive operations of nested tagged
8831 types.
8832
8833 @item No_Implicit_Loops
8834 @findex No_Implicit_Loops
8835 This restriction ensures that the generated code does not contain any
8836 implicit @code{for} loops, either by modifying
8837 the generated code where possible,
8838 or by rejecting any construct that would otherwise generate an implicit
8839 @code{for} loop. If this restriction is active, it is possible to build
8840 large array aggregates with all static components without generating an
8841 intermediate temporary, and without generating a loop to initialize individual
8842 components. Otherwise, a loop is created for arrays larger than about 5000
8843 scalar components.
8844
8845 @item No_Initialize_Scalars
8846 @findex No_Initialize_Scalars
8847 This restriction ensures that no unit in the partition is compiled with
8848 pragma Initialize_Scalars. This allows the generation of more efficient
8849 code, and in particular eliminates dummy null initialization routines that
8850 are otherwise generated for some record and array types.
8851
8852 @item No_Local_Protected_Objects
8853 @findex No_Local_Protected_Objects
8854 This restriction ensures at compile time that protected objects are
8855 only declared at the library level.
8856
8857 @item No_Protected_Type_Allocators
8858 @findex No_Protected_Type_Allocators
8859 This restriction ensures at compile time that there are no allocator
8860 expressions that attempt to allocate protected objects.
8861
8862 @item No_Secondary_Stack
8863 @findex No_Secondary_Stack
8864 This restriction ensures at compile time that the generated code does not
8865 contain any reference to the secondary stack.  The secondary stack is used
8866 to implement functions returning unconstrained objects (arrays or records)
8867 on some targets.
8868
8869 @item No_Select_Statements
8870 @findex No_Select_Statements
8871 This restriction ensures at compile time no select statements of any kind
8872 are permitted, that is the keyword @code{select} may not appear.
8873 This is one of the restrictions of the Ravenscar
8874 profile for limited tasking (see also pragma @code{Profile (Ravenscar)}).
8875
8876 @item No_Standard_Storage_Pools
8877 @findex No_Standard_Storage_Pools
8878 This restriction ensures at compile time that no access types
8879 use the standard default storage pool.  Any access type declared must
8880 have an explicit Storage_Pool attribute defined specifying a
8881 user-defined storage pool.
8882
8883 @item No_Streams
8884 @findex No_Streams
8885 This restriction ensures at compile/bind time that there are no
8886 stream objects created and no use of stream attributes.
8887 This restriction does not forbid dependences on the package
8888 @code{Ada.Streams}. So it is permissible to with
8889 @code{Ada.Streams} (or another package that does so itself)
8890 as long as no actual stream objects are created and no
8891 stream attributes are used.
8892
8893 Note that the use of restriction allows optimization of tagged types,
8894 since they do not need to worry about dispatching stream operations.
8895 To take maximum advantage of this space-saving optimization, any
8896 unit declaring a tagged type should be compiled with the restriction,
8897 though this is not required.
8898
8899 @item No_Task_Attributes_Package
8900 @findex No_Task_Attributes_Package
8901 This restriction ensures at compile time that there are no implicit or
8902 explicit dependencies on the package @code{Ada.Task_Attributes}.
8903
8904 @item No_Task_Termination
8905 @findex No_Task_Termination
8906 This restriction ensures at compile time that no terminate alternatives
8907 appear in any task body.
8908
8909 @item No_Tasking
8910 @findex No_Tasking
8911 This restriction prevents the declaration of tasks or task types throughout
8912 the partition.  It is similar in effect to the use of @code{Max_Tasks => 0}
8913 except that violations are caught at compile time and cause an error message
8914 to be output either by the compiler or binder.
8915
8916 @item Static_Priorities
8917 @findex Static_Priorities
8918 This restriction ensures at compile time that all priority expressions
8919 are static, and that there are no dependencies on the package
8920 @code{Ada.Dynamic_Priorities}.
8921
8922 @item Static_Storage_Size
8923 @findex Static_Storage_Size
8924 This restriction ensures at compile time that any expression appearing
8925 in a Storage_Size pragma or attribute definition clause is static.
8926
8927 @end table
8928
8929 @noindent
8930 The second set of implementation dependent restriction identifiers
8931 does not require partition-wide consistency.
8932 The restriction may be enforced for a single
8933 compilation unit without any effect on any of the
8934 other compilation units in the partition.
8935
8936 @table @code
8937
8938 @item No_Elaboration_Code
8939 @findex No_Elaboration_Code
8940 This restriction ensures at compile time that no elaboration code is
8941 generated.  Note that this is not the same condition as is enforced
8942 by pragma @code{Preelaborate}.  There are cases in which pragma
8943 @code{Preelaborate} still permits code to be generated (e.g.@: code
8944 to initialize a large array to all zeroes), and there are cases of units
8945 which do not meet the requirements for pragma @code{Preelaborate},
8946 but for which no elaboration code is generated.  Generally, it is
8947 the case that preelaborable units will meet the restrictions, with
8948 the exception of large aggregates initialized with an others_clause,
8949 and exception declarations (which generate calls to a run-time
8950 registry procedure).  This restriction is enforced on
8951 a unit by unit basis, it need not be obeyed consistently
8952 throughout a partition.
8953
8954 In the case of aggregates with others, if the aggregate has a dynamic
8955 size, there is no way to eliminate the elaboration code (such dynamic
8956 bounds would be incompatible with @code{Preelaborate} in any case). If
8957 the bounds are static, then use of this restriction actually modifies
8958 the code choice of the compiler to avoid generating a loop, and instead
8959 generate the aggregate statically if possible, no matter how many times
8960 the data for the others clause must be repeatedly generated.
8961
8962 It is not possible to precisely document
8963 the constructs which are compatible with this restriction, since,
8964 unlike most other restrictions, this is not a restriction on the
8965 source code, but a restriction on the generated object code. For
8966 example, if the source contains a declaration:
8967
8968 @smallexample
8969    Val : constant Integer := X;
8970 @end smallexample
8971
8972 @noindent
8973 where X is not a static constant, it may be possible, depending
8974 on complex optimization circuitry, for the compiler to figure
8975 out the value of X at compile time, in which case this initialization
8976 can be done by the loader, and requires no initialization code. It
8977 is not possible to document the precise conditions under which the
8978 optimizer can figure this out.
8979
8980 Note that this the implementation of this restriction requires full
8981 code generation. If it is used in conjunction with "semantics only"
8982 checking, then some cases of violations may be missed.
8983
8984 @item No_Entry_Queue
8985 @findex No_Entry_Queue
8986 This restriction is a declaration that any protected entry compiled in
8987 the scope of the restriction has at most one task waiting on the entry
8988 at any one time, and so no queue is required.  This restriction is not
8989 checked at compile time.  A program execution is erroneous if an attempt
8990 is made to queue a second task on such an entry.
8991
8992 @item No_Implementation_Attributes
8993 @findex No_Implementation_Attributes
8994 This restriction checks at compile time that no GNAT-defined attributes
8995 are present.  With this restriction, the only attributes that can be used
8996 are those defined in the Ada Reference Manual.
8997
8998 @item No_Implementation_Pragmas
8999 @findex No_Implementation_Pragmas
9000 This restriction checks at compile time that no GNAT-defined pragmas
9001 are present.  With this restriction, the only pragmas that can be used
9002 are those defined in the Ada Reference Manual.
9003
9004 @item No_Implementation_Restrictions
9005 @findex No_Implementation_Restrictions
9006 This restriction checks at compile time that no GNAT-defined restriction
9007 identifiers (other than @code{No_Implementation_Restrictions} itself)
9008 are present.  With this restriction, the only other restriction identifiers
9009 that can be used are those defined in the Ada Reference Manual.
9010
9011 @item No_Wide_Characters
9012 @findex No_Wide_Characters
9013 This restriction ensures at compile time that no uses of the types
9014 @code{Wide_Character} or @code{Wide_String} or corresponding wide
9015 wide types
9016 appear, and that no wide or wide wide string or character literals
9017 appear in the program (that is literals representing characters not in
9018 type @code{Character}.
9019
9020 @end table
9021
9022 @sp 1
9023 @cartouche
9024 @noindent
9025 @strong{58}.  The consequences of violating limitations on
9026 @code{Restrictions} pragmas.  See 13.12(9).
9027 @end cartouche
9028 @noindent
9029 Restrictions that can be checked at compile time result in illegalities
9030 if violated.  Currently there are no other consequences of violating
9031 restrictions.
9032
9033 @sp 1
9034 @cartouche
9035 @noindent
9036 @strong{59}.  The representation used by the @code{Read} and
9037 @code{Write} attributes of elementary types in terms of stream
9038 elements.  See 13.13.2(9).
9039 @end cartouche
9040 @noindent
9041 The representation is the in-memory representation of the base type of
9042 the type, using the number of bits corresponding to the
9043 @code{@var{type}'Size} value, and the natural ordering of the machine.
9044
9045 @sp 1
9046 @cartouche
9047 @noindent
9048 @strong{60}.  The names and characteristics of the numeric subtypes
9049 declared in the visible part of package @code{Standard}.  See A.1(3).
9050 @end cartouche
9051 @noindent
9052 See items describing the integer and floating-point types supported.
9053
9054 @sp 1
9055 @cartouche
9056 @noindent
9057 @strong{61}.  The accuracy actually achieved by the elementary
9058 functions.  See A.5.1(1).
9059 @end cartouche
9060 @noindent
9061 The elementary functions correspond to the functions available in the C
9062 library.  Only fast math mode is implemented.
9063
9064 @sp 1
9065 @cartouche
9066 @noindent
9067 @strong{62}.  The sign of a zero result from some of the operators or
9068 functions in @code{Numerics.Generic_Elementary_Functions}, when
9069 @code{Float_Type'Signed_Zeros} is @code{True}.  See A.5.1(46).
9070 @end cartouche
9071 @noindent
9072 The sign of zeroes follows the requirements of the IEEE 754 standard on
9073 floating-point.
9074
9075 @sp 1
9076 @cartouche
9077 @noindent
9078 @strong{63}.  The value of
9079 @code{Numerics.Float_Random.Max_Image_Width}.  See A.5.2(27).
9080 @end cartouche
9081 @noindent
9082 Maximum image width is 6864, see library file @file{s-rannum.ads}.
9083
9084 @sp 1
9085 @cartouche
9086 @noindent
9087 @strong{64}.  The value of
9088 @code{Numerics.Discrete_Random.Max_Image_Width}.  See A.5.2(27).
9089 @end cartouche
9090 @noindent
9091 Maximum image width is 6864, see library file @file{s-rannum.ads}.
9092
9093 @sp 1
9094 @cartouche
9095 @noindent
9096 @strong{65}.  The algorithms for random number generation.  See
9097 A.5.2(32).
9098 @end cartouche
9099 @noindent
9100 The algorithm is the Mersenne Twister, as documented in the source file
9101 @file{s-rannum.adb}. This version of the algorithm has a period of
9102 2**19937-1.
9103
9104 @sp 1
9105 @cartouche
9106 @noindent
9107 @strong{66}.  The string representation of a random number generator's
9108 state.  See A.5.2(38).
9109 @end cartouche
9110 @noindent
9111 The value returned by the Image function is the concatenation of
9112 the fixed-width decimal representations of the 624 32-bit integers
9113 of the state vector.
9114
9115 @sp 1
9116 @cartouche
9117 @noindent
9118 @strong{67}.  The minimum time interval between calls to the
9119 time-dependent Reset procedure that are guaranteed to initiate different
9120 random number sequences.  See A.5.2(45).
9121 @end cartouche
9122 @noindent
9123 The minimum period between reset calls to guarantee distinct series of
9124 random numbers is one microsecond.
9125
9126 @sp 1
9127 @cartouche
9128 @noindent
9129 @strong{68}.  The values of the @code{Model_Mantissa},
9130 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
9131 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
9132 Annex is not supported.  See A.5.3(72).
9133 @end cartouche
9134 @noindent
9135 Run the compiler with @option{-gnatS} to produce a listing of package
9136 @code{Standard}, has the values of all numeric attributes.
9137
9138 @sp 1
9139 @cartouche
9140 @noindent
9141 @strong{69}.  Any implementation-defined characteristics of the
9142 input-output packages.  See A.7(14).
9143 @end cartouche
9144 @noindent
9145 There are no special implementation defined characteristics for these
9146 packages.
9147
9148 @sp 1
9149 @cartouche
9150 @noindent
9151 @strong{70}.  The value of @code{Buffer_Size} in @code{Storage_IO}.  See
9152 A.9(10).
9153 @end cartouche
9154 @noindent
9155 All type representations are contiguous, and the @code{Buffer_Size} is
9156 the value of @code{@var{type}'Size} rounded up to the next storage unit
9157 boundary.
9158
9159 @sp 1
9160 @cartouche
9161 @noindent
9162 @strong{71}.  External files for standard input, standard output, and
9163 standard error See A.10(5).
9164 @end cartouche
9165 @noindent
9166 These files are mapped onto the files provided by the C streams
9167 libraries.  See source file @file{i-cstrea.ads} for further details.
9168
9169 @sp 1
9170 @cartouche
9171 @noindent
9172 @strong{72}.  The accuracy of the value produced by @code{Put}.  See
9173 A.10.9(36).
9174 @end cartouche
9175 @noindent
9176 If more digits are requested in the output than are represented by the
9177 precision of the value, zeroes are output in the corresponding least
9178 significant digit positions.
9179
9180 @sp 1
9181 @cartouche
9182 @noindent
9183 @strong{73}.  The meaning of @code{Argument_Count}, @code{Argument}, and
9184 @code{Command_Name}.  See A.15(1).
9185 @end cartouche
9186 @noindent
9187 These are mapped onto the @code{argv} and @code{argc} parameters of the
9188 main program in the natural manner.
9189
9190 @sp 1
9191 @cartouche
9192 @noindent
9193 @strong{74}.  The interpretation of the @code{Form} parameter in procedure
9194 @code{Create_Directory}.  See A.16(56).
9195 @end cartouche
9196 @noindent
9197 The @code{Form} parameter is not used.
9198
9199 @sp 1
9200 @cartouche
9201 @noindent
9202 @strong{75}.  The interpretation of the @code{Form} parameter in procedure
9203 @code{Create_Path}.  See A.16(60).
9204 @end cartouche
9205 @noindent
9206 The @code{Form} parameter is not used.
9207
9208 @sp 1
9209 @cartouche
9210 @noindent
9211 @strong{76}.  The interpretation of the @code{Form} parameter in procedure
9212 @code{Copy_File}.  See A.16(68).
9213 @end cartouche
9214 @noindent
9215 The @code{Form} parameter is case-insensitive.
9216
9217 Two fields are recognized in the @code{Form} parameter:
9218
9219 @table @code
9220
9221 @item preserve=<value>
9222
9223 @item mode=<value>
9224
9225 @end table
9226
9227 @noindent
9228 <value> starts immediately after the character '=' and ends with the
9229 character immediately preceding the next comma (',') or with the last
9230 character of the parameter.
9231
9232 The only possible values for preserve= are:
9233
9234 @table @code
9235
9236 @item no_attributes
9237 Do not try to preserve any file attributes. This is the default if no
9238 preserve= is found in Form.
9239
9240 @item all_attributes
9241 Try to preserve all file attributes (timestamps, access rights).
9242
9243 @item timestamps
9244 Preserve the timestamp of the copied file, but not the other file attributes.
9245
9246 @end table
9247
9248 @noindent
9249 The only possible values for mode= are:
9250
9251 @table @code
9252
9253 @item copy
9254 Only do the copy if the destination file does not already exist. If it already
9255 exists, Copy_File fails.
9256
9257 @item overwrite
9258 Copy the file in all cases. Overwite an already existing destination file.
9259
9260 @item append
9261 Append the original file to the destination file. If the destination file does
9262 not exist, the destination file is a copy of the source file. When mode=append,
9263 the field preserve=, if it exists, is not taken into account.
9264
9265 @end table
9266
9267 @noindent
9268 If the Form parameter includes one or both of the fields and the value or
9269 values are incorrect, Copy_file fails with Use_Error.
9270
9271 Examples of correct Forms:
9272
9273 @smallexample
9274 Form => "preserve=no_attributes,mode=overwrite" (the default)
9275 Form => "mode=append"
9276 Form => "mode=copy, preserve=all_attributes"
9277 @end smallexample
9278
9279 @noindent
9280 Examples of incorrect Forms
9281
9282 @smallexample
9283 Form => "preserve=junk"
9284 Form => "mode=internal, preserve=timestamps"
9285 @end smallexample
9286
9287 @sp 1
9288 @cartouche
9289 @noindent
9290 @strong{77}.  Implementation-defined convention names.  See B.1(11).
9291 @end cartouche
9292 @noindent
9293 The following convention names are supported
9294
9295 @table @code
9296 @item  Ada
9297 Ada
9298 @item Assembler
9299 Assembly language
9300 @item Asm
9301 Synonym for Assembler
9302 @item Assembly
9303 Synonym for Assembler
9304 @item C
9305 C
9306 @item C_Pass_By_Copy
9307 Allowed only for record types, like C, but also notes that record
9308 is to be passed by copy rather than reference.
9309 @item COBOL
9310 COBOL
9311 @item C_Plus_Plus (or CPP)
9312 C++
9313 @item Default
9314 Treated the same as C
9315 @item External
9316 Treated the same as C
9317 @item Fortran
9318 Fortran
9319 @item Intrinsic
9320 For support of pragma @code{Import} with convention Intrinsic, see
9321 separate section on Intrinsic Subprograms.
9322 @item Stdcall
9323 Stdcall (used for Windows implementations only).  This convention correspond
9324 to the WINAPI (previously called Pascal convention) C/C++ convention under
9325 Windows.  A function with this convention cleans the stack before exit.
9326 @item DLL
9327 Synonym for Stdcall
9328 @item Win32
9329 Synonym for Stdcall
9330 @item Stubbed
9331 Stubbed is a special convention used to indicate that the body of the
9332 subprogram will be entirely ignored.  Any call to the subprogram
9333 is converted into a raise of the @code{Program_Error} exception.  If a
9334 pragma @code{Import} specifies convention @code{stubbed} then no body need
9335 be present at all.  This convention is useful during development for the
9336 inclusion of subprograms whose body has not yet been written.
9337
9338 @end table
9339 @noindent
9340 In addition, all otherwise unrecognized convention names are also
9341 treated as being synonymous with convention C@.  In all implementations
9342 except for VMS, use of such other names results in a warning.  In VMS
9343 implementations, these names are accepted silently.
9344
9345 @sp 1
9346 @cartouche
9347 @noindent
9348 @strong{78}.  The meaning of link names.  See B.1(36).
9349 @end cartouche
9350 @noindent
9351 Link names are the actual names used by the linker.
9352
9353 @sp 1
9354 @cartouche
9355 @noindent
9356 @strong{79}.  The manner of choosing link names when neither the link
9357 name nor the address of an imported or exported entity is specified.  See
9358 B.1(36).
9359 @end cartouche
9360 @noindent
9361 The default linker name is that which would be assigned by the relevant
9362 external language, interpreting the Ada name as being in all lower case
9363 letters.
9364
9365 @sp 1
9366 @cartouche
9367 @noindent
9368 @strong{80}.  The effect of pragma @code{Linker_Options}.  See B.1(37).
9369 @end cartouche
9370 @noindent
9371 The string passed to @code{Linker_Options} is presented uninterpreted as
9372 an argument to the link command, unless it contains ASCII.NUL characters.
9373 NUL characters if they appear act as argument separators, so for example
9374
9375 @smallexample @c ada
9376 pragma Linker_Options ("-labc" & ASCII.NUL & "-ldef");
9377 @end smallexample
9378
9379 @noindent
9380 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
9381 linker. The order of linker options is preserved for a given unit. The final
9382 list of options passed to the linker is in reverse order of the elaboration
9383 order. For example, linker options for a body always appear before the options
9384 from the corresponding package spec.
9385
9386 @sp 1
9387 @cartouche
9388 @noindent
9389 @strong{81}.  The contents of the visible part of package
9390 @code{Interfaces} and its language-defined descendants.  See B.2(1).
9391 @end cartouche
9392 @noindent
9393 See files with prefix @file{i-} in the distributed library.
9394
9395 @sp 1
9396 @cartouche
9397 @noindent
9398 @strong{82}.  Implementation-defined children of package
9399 @code{Interfaces}.  The contents of the visible part of package
9400 @code{Interfaces}.  See B.2(11).
9401 @end cartouche
9402 @noindent
9403 See files with prefix @file{i-} in the distributed library.
9404
9405 @sp 1
9406 @cartouche
9407 @noindent
9408 @strong{83}.  The types @code{Floating}, @code{Long_Floating},
9409 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
9410 @code{COBOL_Character}; and the initialization of the variables
9411 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
9412 @code{Interfaces.COBOL}.  See B.4(50).
9413 @end cartouche
9414 @noindent
9415 @table @code
9416 @item Floating
9417 Float
9418 @item Long_Floating
9419 (Floating) Long_Float
9420 @item Binary
9421 Integer
9422 @item Long_Binary
9423 Long_Long_Integer
9424 @item Decimal_Element
9425 Character
9426 @item COBOL_Character
9427 Character
9428 @end table
9429
9430 @noindent
9431 For initialization, see the file @file{i-cobol.ads} in the distributed library.
9432
9433 @sp 1
9434 @cartouche
9435 @noindent
9436 @strong{84}.  Support for access to machine instructions.  See C.1(1).
9437 @end cartouche
9438 @noindent
9439 See documentation in file @file{s-maccod.ads} in the distributed library.
9440
9441 @sp 1
9442 @cartouche
9443 @noindent
9444 @strong{85}.  Implementation-defined aspects of access to machine
9445 operations.  See C.1(9).
9446 @end cartouche
9447 @noindent
9448 See documentation in file @file{s-maccod.ads} in the distributed library.
9449
9450 @sp 1
9451 @cartouche
9452 @noindent
9453 @strong{86}.  Implementation-defined aspects of interrupts.  See C.3(2).
9454 @end cartouche
9455 @noindent
9456 Interrupts are mapped to signals or conditions as appropriate.  See
9457 definition of unit
9458 @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
9459 on the interrupts supported on a particular target.
9460
9461 @sp 1
9462 @cartouche
9463 @noindent
9464 @strong{87}.  Implementation-defined aspects of pre-elaboration.  See
9465 C.4(13).
9466 @end cartouche
9467 @noindent
9468 GNAT does not permit a partition to be restarted without reloading,
9469 except under control of the debugger.
9470
9471 @sp 1
9472 @cartouche
9473 @noindent
9474 @strong{88}.  The semantics of pragma @code{Discard_Names}.  See C.5(7).
9475 @end cartouche
9476 @noindent
9477 Pragma @code{Discard_Names} causes names of enumeration literals to
9478 be suppressed.  In the presence of this pragma, the Image attribute
9479 provides the image of the Pos of the literal, and Value accepts
9480 Pos values.
9481
9482 @sp 1
9483 @cartouche
9484 @noindent
9485 @strong{89}.  The result of the @code{Task_Identification.Image}
9486 attribute.  See C.7.1(7).
9487 @end cartouche
9488 @noindent
9489 The result of this attribute is a string that identifies
9490 the object or component that denotes a given task. If a variable @code{Var}
9491 has a task type, the image for this task will have the form @code{Var_@var{XXXXXXXX}},
9492 where the suffix
9493 is the hexadecimal representation of the virtual address of the corresponding
9494 task control block. If the variable is an array of tasks, the image of each
9495 task will have the form of an indexed component indicating the position of a
9496 given task in the array, e.g.@: @code{Group(5)_@var{XXXXXXX}}. If the task is a
9497 component of a record, the image of the task will have the form of a selected
9498 component. These rules are fully recursive, so that the image of a task that
9499 is a subcomponent of a composite object corresponds to the expression that
9500 designates this task.
9501 @noindent
9502 If a task is created by an allocator, its image depends on the context. If the
9503 allocator is part of an object declaration, the rules described above are used
9504 to construct its image, and this image is not affected by subsequent
9505 assignments. If the allocator appears within an expression, the image
9506 includes only the name of the task type.
9507 @noindent
9508 If the configuration pragma Discard_Names is present, or if the restriction
9509 No_Implicit_Heap_Allocation is in effect,  the image reduces to
9510 the numeric suffix, that is to say the hexadecimal representation of the
9511 virtual address of the control block of the task.
9512 @sp 1
9513 @cartouche
9514 @noindent
9515 @strong{90}.  The value of @code{Current_Task} when in a protected entry
9516 or interrupt handler.  See C.7.1(17).
9517 @end cartouche
9518 @noindent
9519 Protected entries or interrupt handlers can be executed by any
9520 convenient thread, so the value of @code{Current_Task} is undefined.
9521
9522 @sp 1
9523 @cartouche
9524 @noindent
9525 @strong{91}.  The effect of calling @code{Current_Task} from an entry
9526 body or interrupt handler.  See C.7.1(19).
9527 @end cartouche
9528 @noindent
9529 The effect of calling @code{Current_Task} from an entry body or
9530 interrupt handler is to return the identification of the task currently
9531 executing the code.
9532
9533 @sp 1
9534 @cartouche
9535 @noindent
9536 @strong{92}.  Implementation-defined aspects of
9537 @code{Task_Attributes}.  See C.7.2(19).
9538 @end cartouche
9539 @noindent
9540 There are no implementation-defined aspects of @code{Task_Attributes}.
9541
9542 @sp 1
9543 @cartouche
9544 @noindent
9545 @strong{93}.  Values of all @code{Metrics}.  See D(2).
9546 @end cartouche
9547 @noindent
9548 The metrics information for GNAT depends on the performance of the
9549 underlying operating system.  The sources of the run-time for tasking
9550 implementation, together with the output from @option{-gnatG} can be
9551 used to determine the exact sequence of operating systems calls made
9552 to implement various tasking constructs.  Together with appropriate
9553 information on the performance of the underlying operating system,
9554 on the exact target in use, this information can be used to determine
9555 the required metrics.
9556
9557 @sp 1
9558 @cartouche
9559 @noindent
9560 @strong{94}.  The declarations of @code{Any_Priority} and
9561 @code{Priority}.  See D.1(11).
9562 @end cartouche
9563 @noindent
9564 See declarations in file @file{system.ads}.
9565
9566 @sp 1
9567 @cartouche
9568 @noindent
9569 @strong{95}.  Implementation-defined execution resources.  See D.1(15).
9570 @end cartouche
9571 @noindent
9572 There are no implementation-defined execution resources.
9573
9574 @sp 1
9575 @cartouche
9576 @noindent
9577 @strong{96}.  Whether, on a multiprocessor, a task that is waiting for
9578 access to a protected object keeps its processor busy.  See D.2.1(3).
9579 @end cartouche
9580 @noindent
9581 On a multi-processor, a task that is waiting for access to a protected
9582 object does not keep its processor busy.
9583
9584 @sp 1
9585 @cartouche
9586 @noindent
9587 @strong{97}.  The affect of implementation defined execution resources
9588 on task dispatching.  See D.2.1(9).
9589 @end cartouche
9590 @noindent
9591 @c SGI info
9592 @ignore
9593 Tasks map to IRIX threads, and the dispatching policy is as defined by
9594 the IRIX implementation of threads.
9595 @end ignore
9596 Tasks map to threads in the threads package used by GNAT@.  Where possible
9597 and appropriate, these threads correspond to native threads of the
9598 underlying operating system.
9599
9600 @sp 1
9601 @cartouche
9602 @noindent
9603 @strong{98}.  Implementation-defined @code{policy_identifiers} allowed
9604 in a pragma @code{Task_Dispatching_Policy}.  See D.2.2(3).
9605 @end cartouche
9606 @noindent
9607 There are no implementation-defined policy-identifiers allowed in this
9608 pragma.
9609
9610 @sp 1
9611 @cartouche
9612 @noindent
9613 @strong{99}.  Implementation-defined aspects of priority inversion.  See
9614 D.2.2(16).
9615 @end cartouche
9616 @noindent
9617 Execution of a task cannot be preempted by the implementation processing
9618 of delay expirations for lower priority tasks.
9619
9620 @sp 1
9621 @cartouche
9622 @noindent
9623 @strong{100}.  Implementation defined task dispatching.  See D.2.2(18).
9624 @end cartouche
9625 @noindent
9626 @c SGI info:
9627 @ignore
9628 Tasks map to IRIX threads, and the dispatching policy is as defined by
9629 the IRIX implementation of threads.
9630 @end ignore
9631 The policy is the same as that of the underlying threads implementation.
9632
9633 @sp 1
9634 @cartouche
9635 @noindent
9636 @strong{101}.  Implementation-defined @code{policy_identifiers} allowed
9637 in a pragma @code{Locking_Policy}.  See D.3(4).
9638 @end cartouche
9639 @noindent
9640 The only implementation defined policy permitted in GNAT is
9641 @code{Inheritance_Locking}.  On targets that support this policy, locking
9642 is implemented by inheritance, i.e.@: the task owning the lock operates
9643 at a priority equal to the highest priority of any task currently
9644 requesting the lock.
9645
9646 @sp 1
9647 @cartouche
9648 @noindent
9649 @strong{102}.  Default ceiling priorities.  See D.3(10).
9650 @end cartouche
9651 @noindent
9652 The ceiling priority of protected objects of the type
9653 @code{System.Interrupt_Priority'Last} as described in the Ada
9654 Reference Manual D.3(10),
9655
9656 @sp 1
9657 @cartouche
9658 @noindent
9659 @strong{103}.  The ceiling of any protected object used internally by
9660 the implementation.  See D.3(16).
9661 @end cartouche
9662 @noindent
9663 The ceiling priority of internal protected objects is
9664 @code{System.Priority'Last}.
9665
9666 @sp 1
9667 @cartouche
9668 @noindent
9669 @strong{104}.  Implementation-defined queuing policies.  See D.4(1).
9670 @end cartouche
9671 @noindent
9672 There are no implementation-defined queuing policies.
9673
9674 @sp 1
9675 @cartouche
9676 @noindent
9677 @strong{105}.  On a multiprocessor, any conditions that cause the
9678 completion of an aborted construct to be delayed later than what is
9679 specified for a single processor.  See D.6(3).
9680 @end cartouche
9681 @noindent
9682 The semantics for abort on a multi-processor is the same as on a single
9683 processor, there are no further delays.
9684
9685 @sp 1
9686 @cartouche
9687 @noindent
9688 @strong{106}.  Any operations that implicitly require heap storage
9689 allocation.  See D.7(8).
9690 @end cartouche
9691 @noindent
9692 The only operation that implicitly requires heap storage allocation is
9693 task creation.
9694
9695 @sp 1
9696 @cartouche
9697 @noindent
9698 @strong{107}.  Implementation-defined aspects of pragma
9699 @code{Restrictions}.  See D.7(20).
9700 @end cartouche
9701 @noindent
9702 There are no such implementation-defined aspects.
9703
9704 @sp 1
9705 @cartouche
9706 @noindent
9707 @strong{108}.  Implementation-defined aspects of package
9708 @code{Real_Time}.  See D.8(17).
9709 @end cartouche
9710 @noindent
9711 There are no implementation defined aspects of package @code{Real_Time}.
9712
9713 @sp 1
9714 @cartouche
9715 @noindent
9716 @strong{109}.  Implementation-defined aspects of
9717 @code{delay_statements}.  See D.9(8).
9718 @end cartouche
9719 @noindent
9720 Any difference greater than one microsecond will cause the task to be
9721 delayed (see D.9(7)).
9722
9723 @sp 1
9724 @cartouche
9725 @noindent
9726 @strong{110}.  The upper bound on the duration of interrupt blocking
9727 caused by the implementation.  See D.12(5).
9728 @end cartouche
9729 @noindent
9730 The upper bound is determined by the underlying operating system.  In
9731 no cases is it more than 10 milliseconds.
9732
9733 @sp 1
9734 @cartouche
9735 @noindent
9736 @strong{111}.  The means for creating and executing distributed
9737 programs.  See E(5).
9738 @end cartouche
9739 @noindent
9740 The GLADE package provides a utility GNATDIST for creating and executing
9741 distributed programs.  See the GLADE reference manual for further details.
9742
9743 @sp 1
9744 @cartouche
9745 @noindent
9746 @strong{112}.  Any events that can result in a partition becoming
9747 inaccessible.  See E.1(7).
9748 @end cartouche
9749 @noindent
9750 See the GLADE reference manual for full details on such events.
9751
9752 @sp 1
9753 @cartouche
9754 @noindent
9755 @strong{113}.  The scheduling policies, treatment of priorities, and
9756 management of shared resources between partitions in certain cases.  See
9757 E.1(11).
9758 @end cartouche
9759 @noindent
9760 See the GLADE reference manual for full details on these aspects of
9761 multi-partition execution.
9762
9763 @sp 1
9764 @cartouche
9765 @noindent
9766 @strong{114}.  Events that cause the version of a compilation unit to
9767 change.  See E.3(5).
9768 @end cartouche
9769 @noindent
9770 Editing the source file of a compilation unit, or the source files of
9771 any units on which it is dependent in a significant way cause the version
9772 to change.  No other actions cause the version number to change.  All changes
9773 are significant except those which affect only layout, capitalization or
9774 comments.
9775
9776 @sp 1
9777 @cartouche
9778 @noindent
9779 @strong{115}.  Whether the execution of the remote subprogram is
9780 immediately aborted as a result of cancellation.  See E.4(13).
9781 @end cartouche
9782 @noindent
9783 See the GLADE reference manual for details on the effect of abort in
9784 a distributed application.
9785
9786 @sp 1
9787 @cartouche
9788 @noindent
9789 @strong{116}.  Implementation-defined aspects of the PCS@.  See E.5(25).
9790 @end cartouche
9791 @noindent
9792 See the GLADE reference manual for a full description of all implementation
9793 defined aspects of the PCS@.
9794
9795 @sp 1
9796 @cartouche
9797 @noindent
9798 @strong{117}.  Implementation-defined interfaces in the PCS@.  See
9799 E.5(26).
9800 @end cartouche
9801 @noindent
9802 See the GLADE reference manual for a full description of all
9803 implementation defined interfaces.
9804
9805 @sp 1
9806 @cartouche
9807 @noindent
9808 @strong{118}.  The values of named numbers in the package
9809 @code{Decimal}.  See F.2(7).
9810 @end cartouche
9811 @noindent
9812 @table @code
9813 @item Max_Scale
9814 +18
9815 @item Min_Scale
9816 -18
9817 @item Min_Delta
9818 1.0E-18
9819 @item Max_Delta
9820 1.0E+18
9821 @item Max_Decimal_Digits
9822 18
9823 @end table
9824
9825 @sp 1
9826 @cartouche
9827 @noindent
9828 @strong{119}.  The value of @code{Max_Picture_Length} in the package
9829 @code{Text_IO.Editing}.  See F.3.3(16).
9830 @end cartouche
9831 @noindent
9832 64
9833
9834 @sp 1
9835 @cartouche
9836 @noindent
9837 @strong{120}.  The value of @code{Max_Picture_Length} in the package
9838 @code{Wide_Text_IO.Editing}.  See F.3.4(5).
9839 @end cartouche
9840 @noindent
9841 64
9842
9843 @sp 1
9844 @cartouche
9845 @noindent
9846 @strong{121}.  The accuracy actually achieved by the complex elementary
9847 functions and by other complex arithmetic operations.  See G.1(1).
9848 @end cartouche
9849 @noindent
9850 Standard library functions are used for the complex arithmetic
9851 operations.  Only fast math mode is currently supported.
9852
9853 @sp 1
9854 @cartouche
9855 @noindent
9856 @strong{122}.  The sign of a zero result (or a component thereof) from
9857 any operator or function in @code{Numerics.Generic_Complex_Types}, when
9858 @code{Real'Signed_Zeros} is True.  See G.1.1(53).
9859 @end cartouche
9860 @noindent
9861 The signs of zero values are as recommended by the relevant
9862 implementation advice.
9863
9864 @sp 1
9865 @cartouche
9866 @noindent
9867 @strong{123}.  The sign of a zero result (or a component thereof) from
9868 any operator or function in
9869 @code{Numerics.Generic_Complex_Elementary_Functions}, when
9870 @code{Real'Signed_Zeros} is @code{True}.  See G.1.2(45).
9871 @end cartouche
9872 @noindent
9873 The signs of zero values are as recommended by the relevant
9874 implementation advice.
9875
9876 @sp 1
9877 @cartouche
9878 @noindent
9879 @strong{124}.  Whether the strict mode or the relaxed mode is the
9880 default.  See G.2(2).
9881 @end cartouche
9882 @noindent
9883 The strict mode is the default.  There is no separate relaxed mode.  GNAT
9884 provides a highly efficient implementation of strict mode.
9885
9886 @sp 1
9887 @cartouche
9888 @noindent
9889 @strong{125}.  The result interval in certain cases of fixed-to-float
9890 conversion.  See G.2.1(10).
9891 @end cartouche
9892 @noindent
9893 For cases where the result interval is implementation dependent, the
9894 accuracy is that provided by performing all operations in 64-bit IEEE
9895 floating-point format.
9896
9897 @sp 1
9898 @cartouche
9899 @noindent
9900 @strong{126}.  The result of a floating point arithmetic operation in
9901 overflow situations, when the @code{Machine_Overflows} attribute of the
9902 result type is @code{False}.  See G.2.1(13).
9903 @end cartouche
9904 @noindent
9905 Infinite and NaN values are produced as dictated by the IEEE
9906 floating-point standard.
9907
9908 Note that on machines that are not fully compliant with the IEEE
9909 floating-point standard, such as Alpha, the @option{-mieee} compiler flag
9910 must be used for achieving IEEE confirming behavior (although at the cost
9911 of a significant performance penalty), so infinite and NaN values are
9912 properly generated.
9913
9914 @sp 1
9915 @cartouche
9916 @noindent
9917 @strong{127}.  The result interval for division (or exponentiation by a
9918 negative exponent), when the floating point hardware implements division
9919 as multiplication by a reciprocal.  See G.2.1(16).
9920 @end cartouche
9921 @noindent
9922 Not relevant, division is IEEE exact.
9923
9924 @sp 1
9925 @cartouche
9926 @noindent
9927 @strong{128}.  The definition of close result set, which determines the
9928 accuracy of certain fixed point multiplications and divisions.  See
9929 G.2.3(5).
9930 @end cartouche
9931 @noindent
9932 Operations in the close result set are performed using IEEE long format
9933 floating-point arithmetic.  The input operands are converted to
9934 floating-point, the operation is done in floating-point, and the result
9935 is converted to the target type.
9936
9937 @sp 1
9938 @cartouche
9939 @noindent
9940 @strong{129}.  Conditions on a @code{universal_real} operand of a fixed
9941 point multiplication or division for which the result shall be in the
9942 perfect result set.  See G.2.3(22).
9943 @end cartouche
9944 @noindent
9945 The result is only defined to be in the perfect result set if the result
9946 can be computed by a single scaling operation involving a scale factor
9947 representable in 64-bits.
9948
9949 @sp 1
9950 @cartouche
9951 @noindent
9952 @strong{130}.  The result of a fixed point arithmetic operation in
9953 overflow situations, when the @code{Machine_Overflows} attribute of the
9954 result type is @code{False}.  See G.2.3(27).
9955 @end cartouche
9956 @noindent
9957 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
9958 types.
9959
9960 @sp 1
9961 @cartouche
9962 @noindent
9963 @strong{131}.  The result of an elementary function reference in
9964 overflow situations, when the @code{Machine_Overflows} attribute of the
9965 result type is @code{False}.  See G.2.4(4).
9966 @end cartouche
9967 @noindent
9968 IEEE infinite and Nan values are produced as appropriate.
9969
9970 @sp 1
9971 @cartouche
9972 @noindent
9973 @strong{132}.  The value of the angle threshold, within which certain
9974 elementary functions, complex arithmetic operations, and complex
9975 elementary functions yield results conforming to a maximum relative
9976 error bound.  See G.2.4(10).
9977 @end cartouche
9978 @noindent
9979 Information on this subject is not yet available.
9980
9981 @sp 1
9982 @cartouche
9983 @noindent
9984 @strong{133}.  The accuracy of certain elementary functions for
9985 parameters beyond the angle threshold.  See G.2.4(10).
9986 @end cartouche
9987 @noindent
9988 Information on this subject is not yet available.
9989
9990 @sp 1
9991 @cartouche
9992 @noindent
9993 @strong{134}.  The result of a complex arithmetic operation or complex
9994 elementary function reference in overflow situations, when the
9995 @code{Machine_Overflows} attribute of the corresponding real type is
9996 @code{False}.  See G.2.6(5).
9997 @end cartouche
9998 @noindent
9999 IEEE infinite and Nan values are produced as appropriate.
10000
10001 @sp 1
10002 @cartouche
10003 @noindent
10004 @strong{135}.  The accuracy of certain complex arithmetic operations and
10005 certain complex elementary functions for parameters (or components
10006 thereof) beyond the angle threshold.  See G.2.6(8).
10007 @end cartouche
10008 @noindent
10009 Information on those subjects is not yet available.
10010
10011 @sp 1
10012 @cartouche
10013 @noindent
10014 @strong{136}.  Information regarding bounded errors and erroneous
10015 execution.  See H.2(1).
10016 @end cartouche
10017 @noindent
10018 Information on this subject is not yet available.
10019
10020 @sp 1
10021 @cartouche
10022 @noindent
10023 @strong{137}.  Implementation-defined aspects of pragma
10024 @code{Inspection_Point}.  See H.3.2(8).
10025 @end cartouche
10026 @noindent
10027 Pragma @code{Inspection_Point} ensures that the variable is live and can
10028 be examined by the debugger at the inspection point.
10029
10030 @sp 1
10031 @cartouche
10032 @noindent
10033 @strong{138}.  Implementation-defined aspects of pragma
10034 @code{Restrictions}.  See H.4(25).
10035 @end cartouche
10036 @noindent
10037 There are no implementation-defined aspects of pragma @code{Restrictions}.  The
10038 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
10039 generated code.  Checks must suppressed by use of pragma @code{Suppress}.
10040
10041 @sp 1
10042 @cartouche
10043 @noindent
10044 @strong{139}.  Any restrictions on pragma @code{Restrictions}.  See
10045 H.4(27).
10046 @end cartouche
10047 @noindent
10048 There are no restrictions on pragma @code{Restrictions}.
10049
10050 @node Intrinsic Subprograms
10051 @chapter Intrinsic Subprograms
10052 @cindex Intrinsic Subprograms
10053
10054 @menu
10055 * Intrinsic Operators::
10056 * Enclosing_Entity::
10057 * Exception_Information::
10058 * Exception_Message::
10059 * Exception_Name::
10060 * File::
10061 * Line::
10062 * Rotate_Left::
10063 * Rotate_Right::
10064 * Shift_Left::
10065 * Shift_Right::
10066 * Shift_Right_Arithmetic::
10067 * Source_Location::
10068 @end menu
10069
10070 @noindent
10071 GNAT allows a user application program to write the declaration:
10072
10073 @smallexample @c ada
10074    pragma Import (Intrinsic, name);
10075 @end smallexample
10076
10077 @noindent
10078 providing that the name corresponds to one of the implemented intrinsic
10079 subprograms in GNAT, and that the parameter profile of the referenced
10080 subprogram meets the requirements.  This chapter describes the set of
10081 implemented intrinsic subprograms, and the requirements on parameter profiles.
10082 Note that no body is supplied; as with other uses of pragma Import, the
10083 body is supplied elsewhere (in this case by the compiler itself).  Note
10084 that any use of this feature is potentially non-portable, since the
10085 Ada standard does not require Ada compilers to implement this feature.
10086
10087 @node Intrinsic Operators
10088 @section Intrinsic Operators
10089 @cindex Intrinsic operator
10090
10091 @noindent
10092 All the predefined numeric operators in package Standard
10093 in @code{pragma Import (Intrinsic,..)}
10094 declarations.  In the binary operator case, the operands must have the same
10095 size.  The operand or operands must also be appropriate for
10096 the operator.  For example, for addition, the operands must
10097 both be floating-point or both be fixed-point, and the
10098 right operand for @code{"**"} must have a root type of
10099 @code{Standard.Integer'Base}.
10100 You can use an intrinsic operator declaration as in the following example:
10101
10102 @smallexample @c ada
10103    type Int1 is new Integer;
10104    type Int2 is new Integer;
10105
10106    function "+" (X1 : Int1; X2 : Int2) return Int1;
10107    function "+" (X1 : Int1; X2 : Int2) return Int2;
10108    pragma Import (Intrinsic, "+");
10109 @end smallexample
10110
10111 @noindent
10112 This declaration would permit ``mixed mode'' arithmetic on items
10113 of the differing types @code{Int1} and @code{Int2}.
10114 It is also possible to specify such operators for private types, if the
10115 full views are appropriate arithmetic types.
10116
10117 @node Enclosing_Entity
10118 @section Enclosing_Entity
10119 @cindex Enclosing_Entity
10120 @noindent
10121 This intrinsic subprogram is used in the implementation of the
10122 library routine @code{GNAT.Source_Info}.  The only useful use of the
10123 intrinsic import in this case is the one in this unit, so an
10124 application program should simply call the function
10125 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
10126 the current subprogram, package, task, entry, or protected subprogram.
10127
10128 @node Exception_Information
10129 @section Exception_Information
10130 @cindex Exception_Information'
10131 @noindent
10132 This intrinsic subprogram is used in the implementation of the
10133 library routine @code{GNAT.Current_Exception}.  The only useful
10134 use of the intrinsic import in this case is the one in this unit,
10135 so an application program should simply call the function
10136 @code{GNAT.Current_Exception.Exception_Information} to obtain
10137 the exception information associated with the current exception.
10138
10139 @node Exception_Message
10140 @section Exception_Message
10141 @cindex Exception_Message
10142 @noindent
10143 This intrinsic subprogram is used in the implementation of the
10144 library routine @code{GNAT.Current_Exception}.  The only useful
10145 use of the intrinsic import in this case is the one in this unit,
10146 so an application program should simply call the function
10147 @code{GNAT.Current_Exception.Exception_Message} to obtain
10148 the message associated with the current exception.
10149
10150 @node Exception_Name
10151 @section Exception_Name
10152 @cindex Exception_Name
10153 @noindent
10154 This intrinsic subprogram is used in the implementation of the
10155 library routine @code{GNAT.Current_Exception}.  The only useful
10156 use of the intrinsic import in this case is the one in this unit,
10157 so an application program should simply call the function
10158 @code{GNAT.Current_Exception.Exception_Name} to obtain
10159 the name of the current exception.
10160
10161 @node File
10162 @section File
10163 @cindex File
10164 @noindent
10165 This intrinsic subprogram is used in the implementation of the
10166 library routine @code{GNAT.Source_Info}.  The only useful use of the
10167 intrinsic import in this case is the one in this unit, so an
10168 application program should simply call the function
10169 @code{GNAT.Source_Info.File} to obtain the name of the current
10170 file.
10171
10172 @node Line
10173 @section Line
10174 @cindex Line
10175 @noindent
10176 This intrinsic subprogram is used in the implementation of the
10177 library routine @code{GNAT.Source_Info}.  The only useful use of the
10178 intrinsic import in this case is the one in this unit, so an
10179 application program should simply call the function
10180 @code{GNAT.Source_Info.Line} to obtain the number of the current
10181 source line.
10182
10183 @node Rotate_Left
10184 @section Rotate_Left
10185 @cindex Rotate_Left
10186 @noindent
10187 In standard Ada, the @code{Rotate_Left} function is available only
10188 for the predefined modular types in package @code{Interfaces}.  However, in
10189 GNAT it is possible to define a Rotate_Left function for a user
10190 defined modular type or any signed integer type as in this example:
10191
10192 @smallexample @c ada
10193    function Shift_Left
10194      (Value  : My_Modular_Type;
10195       Amount : Natural)
10196       return   My_Modular_Type;
10197 @end smallexample
10198
10199 @noindent
10200 The requirements are that the profile be exactly as in the example
10201 above.  The only modifications allowed are in the formal parameter
10202 names, and in the type of @code{Value} and the return type, which
10203 must be the same, and must be either a signed integer type, or
10204 a modular integer type with a binary modulus, and the size must
10205 be 8.  16, 32 or 64 bits.
10206
10207 @node Rotate_Right
10208 @section Rotate_Right
10209 @cindex Rotate_Right
10210 @noindent
10211 A @code{Rotate_Right} function can be defined for any user defined
10212 binary modular integer type, or signed integer type, as described
10213 above for @code{Rotate_Left}.
10214
10215 @node Shift_Left
10216 @section Shift_Left
10217 @cindex Shift_Left
10218 @noindent
10219 A @code{Shift_Left} function can be defined for any user defined
10220 binary modular integer type, or signed integer type, as described
10221 above for @code{Rotate_Left}.
10222
10223 @node Shift_Right
10224 @section Shift_Right
10225 @cindex Shift_Right
10226 @noindent
10227 A @code{Shift_Right} function can be defined for any user defined
10228 binary modular integer type, or signed integer type, as described
10229 above for @code{Rotate_Left}.
10230
10231 @node Shift_Right_Arithmetic
10232 @section Shift_Right_Arithmetic
10233 @cindex Shift_Right_Arithmetic
10234 @noindent
10235 A @code{Shift_Right_Arithmetic} function can be defined for any user
10236 defined binary modular integer type, or signed integer type, as described
10237 above for @code{Rotate_Left}.
10238
10239 @node Source_Location
10240 @section Source_Location
10241 @cindex Source_Location
10242 @noindent
10243 This intrinsic subprogram is used in the implementation of the
10244 library routine @code{GNAT.Source_Info}.  The only useful use of the
10245 intrinsic import in this case is the one in this unit, so an
10246 application program should simply call the function
10247 @code{GNAT.Source_Info.Source_Location} to obtain the current
10248 source file location.
10249
10250 @node Representation Clauses and Pragmas
10251 @chapter Representation Clauses and Pragmas
10252 @cindex Representation Clauses
10253
10254 @menu
10255 * Alignment Clauses::
10256 * Size Clauses::
10257 * Storage_Size Clauses::
10258 * Size of Variant Record Objects::
10259 * Biased Representation ::
10260 * Value_Size and Object_Size Clauses::
10261 * Component_Size Clauses::
10262 * Bit_Order Clauses::
10263 * Effect of Bit_Order on Byte Ordering::
10264 * Pragma Pack for Arrays::
10265 * Pragma Pack for Records::
10266 * Record Representation Clauses::
10267 * Enumeration Clauses::
10268 * Address Clauses::
10269 * Effect of Convention on Representation::
10270 * Determining the Representations chosen by GNAT::
10271 @end menu
10272
10273 @noindent
10274 @cindex Representation Clause
10275 @cindex Representation Pragma
10276 @cindex Pragma, representation
10277 This section describes the representation clauses accepted by GNAT, and
10278 their effect on the representation of corresponding data objects.
10279
10280 GNAT fully implements Annex C (Systems Programming).  This means that all
10281 the implementation advice sections in chapter 13 are fully implemented.
10282 However, these sections only require a minimal level of support for
10283 representation clauses.  GNAT provides much more extensive capabilities,
10284 and this section describes the additional capabilities provided.
10285
10286 @node Alignment Clauses
10287 @section Alignment Clauses
10288 @cindex Alignment Clause
10289
10290 @noindent
10291 GNAT requires that all alignment clauses specify a power of 2, and all
10292 default alignments are always a power of 2.  The default alignment
10293 values are as follows:
10294
10295 @itemize @bullet
10296 @item @emph{Primitive Types}.
10297 For primitive types, the alignment is the minimum of the actual size of
10298 objects of the type divided by @code{Storage_Unit},
10299 and the maximum alignment supported by the target.
10300 (This maximum alignment is given by the GNAT-specific attribute
10301 @code{Standard'Maximum_Alignment}; see @ref{Maximum_Alignment}.)
10302 @cindex @code{Maximum_Alignment} attribute
10303 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
10304 default alignment will be 8 on any target that supports alignments
10305 this large, but on some targets, the maximum alignment may be smaller
10306 than 8, in which case objects of type @code{Long_Float} will be maximally
10307 aligned.
10308
10309 @item @emph{Arrays}.
10310 For arrays, the alignment is equal to the alignment of the component type
10311 for the normal case where no packing or component size is given.  If the
10312 array is packed, and the packing is effective (see separate section on
10313 packed arrays), then the alignment will be one for long packed arrays,
10314 or arrays whose length is not known at compile time.  For short packed
10315 arrays, which are handled internally as modular types, the alignment
10316 will be as described for primitive types, e.g.@: a packed array of length
10317 31 bits will have an object size of four bytes, and an alignment of 4.
10318
10319 @item @emph{Records}.
10320 For the normal non-packed case, the alignment of a record is equal to
10321 the maximum alignment of any of its components.  For tagged records, this
10322 includes the implicit access type used for the tag.  If a pragma @code{Pack}
10323 is used and all components are packable (see separate section on pragma
10324 @code{Pack}), then the resulting alignment is 1, unless the layout of the
10325 record makes it profitable to increase it.
10326
10327 A special case is when:
10328 @itemize @bullet
10329 @item
10330 the size of the record is given explicitly, or a
10331 full record representation clause is given, and
10332 @item
10333 the size of the record is 2, 4, or 8 bytes.
10334 @end itemize
10335 @noindent
10336 In this case, an alignment is chosen to match the
10337 size of the record. For example, if we have:
10338
10339 @smallexample @c ada
10340    type Small is record
10341       A, B : Character;
10342    end record;
10343    for Small'Size use 16;
10344 @end smallexample
10345
10346 @noindent
10347 then the default alignment of the record type @code{Small} is 2, not 1. This
10348 leads to more efficient code when the record is treated as a unit, and also
10349 allows the type to specified as @code{Atomic} on architectures requiring
10350 strict alignment.
10351
10352 @end itemize
10353
10354 @noindent
10355 An alignment clause may specify a larger alignment than the default value
10356 up to some maximum value dependent on the target (obtainable by using the
10357 attribute reference @code{Standard'Maximum_Alignment}). It may also specify
10358 a smaller alignment than the default value for enumeration, integer and
10359 fixed point types, as well as for record types, for example
10360
10361 @smallexample @c ada
10362   type V is record
10363      A : Integer;
10364   end record;
10365
10366   for V'alignment use 1;
10367 @end smallexample
10368
10369 @noindent
10370 @cindex Alignment, default
10371 The default alignment for the type @code{V} is 4, as a result of the
10372 Integer field in the record, but it is permissible, as shown, to
10373 override the default alignment of the record with a smaller value.
10374
10375 @node Size Clauses
10376 @section Size Clauses
10377 @cindex Size Clause
10378
10379 @noindent
10380 The default size for a type @code{T} is obtainable through the
10381 language-defined attribute @code{T'Size} and also through the
10382 equivalent GNAT-defined attribute @code{T'Value_Size}.
10383 For objects of type @code{T}, GNAT will generally increase the type size
10384 so that the object size (obtainable through the GNAT-defined attribute
10385 @code{T'Object_Size})
10386 is a multiple of @code{T'Alignment * Storage_Unit}.
10387 For example
10388
10389 @smallexample @c ada
10390    type Smallint is range 1 .. 6;
10391
10392    type Rec is record
10393       Y1 : integer;
10394       Y2 : boolean;
10395    end record;
10396 @end smallexample
10397
10398 @noindent
10399 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
10400 as specified by the RM rules,
10401 but objects of this type will have a size of 8
10402 (@code{Smallint'Object_Size} = 8),
10403 since objects by default occupy an integral number
10404 of storage units.  On some targets, notably older
10405 versions of the Digital Alpha, the size of stand
10406 alone objects of this type may be 32, reflecting
10407 the inability of the hardware to do byte load/stores.
10408
10409 Similarly, the size of type @code{Rec} is 40 bits
10410 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
10411 the alignment is 4, so objects of this type will have
10412 their size increased to 64 bits so that it is a multiple
10413 of the alignment (in bits).  This decision is
10414 in accordance with the specific Implementation Advice in RM 13.3(43):
10415
10416 @quotation
10417 A @code{Size} clause should be supported for an object if the specified
10418 @code{Size} is at least as large as its subtype's @code{Size}, and corresponds
10419 to a size in storage elements that is a multiple of the object's
10420 @code{Alignment} (if the @code{Alignment} is nonzero).
10421 @end quotation
10422
10423 @noindent
10424 An explicit size clause may be used to override the default size by
10425 increasing it.  For example, if we have:
10426
10427 @smallexample @c ada
10428    type My_Boolean is new Boolean;
10429    for My_Boolean'Size use 32;
10430 @end smallexample
10431
10432 @noindent
10433 then values of this type will always be 32 bits long.  In the case of
10434 discrete types, the size can be increased up to 64 bits, with the effect
10435 that the entire specified field is used to hold the value, sign- or
10436 zero-extended as appropriate.  If more than 64 bits is specified, then
10437 padding space is allocated after the value, and a warning is issued that
10438 there are unused bits.
10439
10440 Similarly the size of records and arrays may be increased, and the effect
10441 is to add padding bits after the value.  This also causes a warning message
10442 to be generated.
10443
10444 The largest Size value permitted in GNAT is 2**31@minus{}1.  Since this is a
10445 Size in bits, this corresponds to an object of size 256 megabytes (minus
10446 one).  This limitation is true on all targets.  The reason for this
10447 limitation is that it improves the quality of the code in many cases
10448 if it is known that a Size value can be accommodated in an object of
10449 type Integer.
10450
10451 @node Storage_Size Clauses
10452 @section Storage_Size Clauses
10453 @cindex Storage_Size Clause
10454
10455 @noindent
10456 For tasks, the @code{Storage_Size} clause specifies the amount of space
10457 to be allocated for the task stack.  This cannot be extended, and if the
10458 stack is exhausted, then @code{Storage_Error} will be raised (if stack
10459 checking is enabled).  Use a @code{Storage_Size} attribute definition clause,
10460 or a @code{Storage_Size} pragma in the task definition to set the
10461 appropriate required size.  A useful technique is to include in every
10462 task definition a pragma of the form:
10463
10464 @smallexample @c ada
10465    pragma Storage_Size (Default_Stack_Size);
10466 @end smallexample
10467
10468 @noindent
10469 Then @code{Default_Stack_Size} can be defined in a global package, and
10470 modified as required. Any tasks requiring stack sizes different from the
10471 default can have an appropriate alternative reference in the pragma.
10472
10473 You can also use the @option{-d} binder switch to modify the default stack
10474 size.
10475
10476 For access types, the @code{Storage_Size} clause specifies the maximum
10477 space available for allocation of objects of the type.  If this space is
10478 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
10479 In the case where the access type is declared local to a subprogram, the
10480 use of a @code{Storage_Size} clause triggers automatic use of a special
10481 predefined storage pool (@code{System.Pool_Size}) that ensures that all
10482 space for the pool is automatically reclaimed on exit from the scope in
10483 which the type is declared.
10484
10485 A special case recognized by the compiler is the specification of a
10486 @code{Storage_Size} of zero for an access type.  This means that no
10487 items can be allocated from the pool, and this is recognized at compile
10488 time, and all the overhead normally associated with maintaining a fixed
10489 size storage pool is eliminated.  Consider the following example:
10490
10491 @smallexample @c ada
10492    procedure p is
10493       type R is array (Natural) of Character;
10494       type P is access all R;
10495       for P'Storage_Size use 0;
10496       --  Above access type intended only for interfacing purposes
10497
10498       y : P;
10499
10500       procedure g (m : P);
10501       pragma Import (C, g);
10502
10503       --  @dots{}
10504
10505    begin
10506       --  @dots{}
10507       y := new R;
10508    end;
10509 @end smallexample
10510
10511 @noindent
10512 As indicated in this example, these dummy storage pools are often useful in
10513 connection with interfacing where no object will ever be allocated.  If you
10514 compile the above example, you get the warning:
10515
10516 @smallexample
10517    p.adb:16:09: warning: allocation from empty storage pool
10518    p.adb:16:09: warning: Storage_Error will be raised at run time
10519 @end smallexample
10520
10521 @noindent
10522 Of course in practice, there will not be any explicit allocators in the
10523 case of such an access declaration.
10524
10525 @node Size of Variant Record Objects
10526 @section Size of Variant Record Objects
10527 @cindex Size, variant record objects
10528 @cindex Variant record objects, size
10529
10530 @noindent
10531 In the case of variant record objects, there is a question whether Size gives
10532 information about a particular variant, or the maximum size required
10533 for any variant.  Consider the following program
10534
10535 @smallexample @c ada
10536 with Text_IO; use Text_IO;
10537 procedure q is
10538    type R1 (A : Boolean := False) is record
10539      case A is
10540        when True  => X : Character;
10541        when False => null;
10542      end case;
10543    end record;
10544
10545    V1 : R1 (False);
10546    V2 : R1;
10547
10548 begin
10549    Put_Line (Integer'Image (V1'Size));
10550    Put_Line (Integer'Image (V2'Size));
10551 end q;
10552 @end smallexample
10553
10554 @noindent
10555 Here we are dealing with a variant record, where the True variant
10556 requires 16 bits, and the False variant requires 8 bits.
10557 In the above example, both V1 and V2 contain the False variant,
10558 which is only 8 bits long.  However, the result of running the
10559 program is:
10560
10561 @smallexample
10562 8
10563 16
10564 @end smallexample
10565
10566 @noindent
10567 The reason for the difference here is that the discriminant value of
10568 V1 is fixed, and will always be False.  It is not possible to assign
10569 a True variant value to V1, therefore 8 bits is sufficient.  On the
10570 other hand, in the case of V2, the initial discriminant value is
10571 False (from the default), but it is possible to assign a True
10572 variant value to V2, therefore 16 bits must be allocated for V2
10573 in the general case, even fewer bits may be needed at any particular
10574 point during the program execution.
10575
10576 As can be seen from the output of this program, the @code{'Size}
10577 attribute applied to such an object in GNAT gives the actual allocated
10578 size of the variable, which is the largest size of any of the variants.
10579 The Ada Reference Manual is not completely clear on what choice should
10580 be made here, but the GNAT behavior seems most consistent with the
10581 language in the RM@.
10582
10583 In some cases, it may be desirable to obtain the size of the current
10584 variant, rather than the size of the largest variant.  This can be
10585 achieved in GNAT by making use of the fact that in the case of a
10586 subprogram parameter, GNAT does indeed return the size of the current
10587 variant (because a subprogram has no way of knowing how much space
10588 is actually allocated for the actual).
10589
10590 Consider the following modified version of the above program:
10591
10592 @smallexample @c ada
10593 with Text_IO; use Text_IO;
10594 procedure q is
10595    type R1 (A : Boolean := False) is record
10596      case A is
10597        when True  => X : Character;
10598        when False => null;
10599      end case;
10600    end record;
10601
10602    V2 : R1;
10603
10604    function Size (V : R1) return Integer is
10605    begin
10606       return V'Size;
10607    end Size;
10608
10609 begin
10610    Put_Line (Integer'Image (V2'Size));
10611    Put_Line (Integer'IMage (Size (V2)));
10612    V2 := (True, 'x');
10613    Put_Line (Integer'Image (V2'Size));
10614    Put_Line (Integer'IMage (Size (V2)));
10615 end q;
10616 @end smallexample
10617
10618 @noindent
10619 The output from this program is
10620
10621 @smallexample
10622 16
10623 8
10624 16
10625 16
10626 @end smallexample
10627
10628 @noindent
10629 Here we see that while the @code{'Size} attribute always returns
10630 the maximum size, regardless of the current variant value, the
10631 @code{Size} function does indeed return the size of the current
10632 variant value.
10633
10634 @node Biased Representation
10635 @section Biased Representation
10636 @cindex Size for biased representation
10637 @cindex Biased representation
10638
10639 @noindent
10640 In the case of scalars with a range starting at other than zero, it is
10641 possible in some cases to specify a size smaller than the default minimum
10642 value, and in such cases, GNAT uses an unsigned biased representation,
10643 in which zero is used to represent the lower bound, and successive values
10644 represent successive values of the type.
10645
10646 For example, suppose we have the declaration:
10647
10648 @smallexample @c ada
10649    type Small is range -7 .. -4;
10650    for Small'Size use 2;
10651 @end smallexample
10652
10653 @noindent
10654 Although the default size of type @code{Small} is 4, the @code{Size}
10655 clause is accepted by GNAT and results in the following representation
10656 scheme:
10657
10658 @smallexample
10659   -7 is represented as 2#00#
10660   -6 is represented as 2#01#
10661   -5 is represented as 2#10#
10662   -4 is represented as 2#11#
10663 @end smallexample
10664
10665 @noindent
10666 Biased representation is only used if the specified @code{Size} clause
10667 cannot be accepted in any other manner.  These reduced sizes that force
10668 biased representation can be used for all discrete types except for
10669 enumeration types for which a representation clause is given.
10670
10671 @node Value_Size and Object_Size Clauses
10672 @section Value_Size and Object_Size Clauses
10673 @findex Value_Size
10674 @findex Object_Size
10675 @cindex Size, of objects
10676
10677 @noindent
10678 In Ada 95 and Ada 2005, @code{T'Size} for a type @code{T} is the minimum
10679 number of bits required to hold values of type @code{T}.
10680 Although this interpretation was allowed in Ada 83, it was not required,
10681 and this requirement in practice can cause some significant difficulties.
10682 For example, in most Ada 83 compilers, @code{Natural'Size} was 32.
10683 However, in Ada 95 and Ada 2005,
10684 @code{Natural'Size} is
10685 typically 31.  This means that code may change in behavior when moving
10686 from Ada 83 to Ada 95 or Ada 2005.  For example, consider:
10687
10688 @smallexample @c ada
10689    type Rec is record;
10690       A : Natural;
10691       B : Natural;
10692    end record;
10693
10694    for Rec use record
10695       at 0  range 0 .. Natural'Size - 1;
10696       at 0  range Natural'Size .. 2 * Natural'Size - 1;
10697    end record;
10698 @end smallexample
10699
10700 @noindent
10701 In the above code, since the typical size of @code{Natural} objects
10702 is 32 bits and @code{Natural'Size} is 31, the above code can cause
10703 unexpected inefficient packing in Ada 95 and Ada 2005, and in general
10704 there are cases where the fact that the object size can exceed the
10705 size of the type causes surprises.
10706
10707 To help get around this problem GNAT provides two implementation
10708 defined attributes, @code{Value_Size} and @code{Object_Size}.  When
10709 applied to a type, these attributes yield the size of the type
10710 (corresponding to the RM defined size attribute), and the size of
10711 objects of the type respectively.
10712
10713 The @code{Object_Size} is used for determining the default size of
10714 objects and components.  This size value can be referred to using the
10715 @code{Object_Size} attribute.  The phrase ``is used'' here means that it is
10716 the basis of the determination of the size.  The backend is free to
10717 pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
10718 character might be stored in 32 bits on a machine with no efficient
10719 byte access instructions such as the Alpha.
10720
10721 The default rules for the value of @code{Object_Size} for
10722 discrete types are as follows:
10723
10724 @itemize @bullet
10725 @item
10726 The @code{Object_Size} for base subtypes reflect the natural hardware
10727 size in bits (run the compiler with @option{-gnatS} to find those values
10728 for numeric types). Enumeration types and fixed-point base subtypes have
10729 8, 16, 32 or 64 bits for this size, depending on the range of values
10730 to be stored.
10731
10732 @item
10733 The @code{Object_Size} of a subtype is the same as the
10734 @code{Object_Size} of
10735 the type from which it is obtained.
10736
10737 @item
10738 The @code{Object_Size} of a derived base type is copied from the parent
10739 base type, and the @code{Object_Size} of a derived first subtype is copied
10740 from the parent first subtype.
10741 @end itemize
10742
10743 @noindent
10744 The @code{Value_Size} attribute
10745 is the (minimum) number of bits required to store a value
10746 of the type.
10747 This value is used to determine how tightly to pack
10748 records or arrays with components of this type, and also affects
10749 the semantics of unchecked conversion (unchecked conversions where
10750 the @code{Value_Size} values differ generate a warning, and are potentially
10751 target dependent).
10752
10753 The default rules for the value of @code{Value_Size} are as follows:
10754
10755 @itemize @bullet
10756 @item
10757 The @code{Value_Size} for a base subtype is the minimum number of bits
10758 required to store all values of the type (including the sign bit
10759 only if negative values are possible).
10760
10761 @item
10762 If a subtype statically matches the first subtype of a given type, then it has
10763 by default the same @code{Value_Size} as the first subtype.  This is a
10764 consequence of RM 13.1(14) (``if two subtypes statically match,
10765 then their subtype-specific aspects are the same''.)
10766
10767 @item
10768 All other subtypes have a @code{Value_Size} corresponding to the minimum
10769 number of bits required to store all values of the subtype.  For
10770 dynamic bounds, it is assumed that the value can range down or up
10771 to the corresponding bound of the ancestor
10772 @end itemize
10773
10774 @noindent
10775 The RM defined attribute @code{Size} corresponds to the
10776 @code{Value_Size} attribute.
10777
10778 The @code{Size} attribute may be defined for a first-named subtype.  This sets
10779 the @code{Value_Size} of
10780 the first-named subtype to the given value, and the
10781 @code{Object_Size} of this first-named subtype to the given value padded up
10782 to an appropriate boundary.  It is a consequence of the default rules
10783 above that this @code{Object_Size} will apply to all further subtypes.  On the
10784 other hand, @code{Value_Size} is affected only for the first subtype, any
10785 dynamic subtypes obtained from it directly, and any statically matching
10786 subtypes.  The @code{Value_Size} of any other static subtypes is not affected.
10787
10788 @code{Value_Size} and
10789 @code{Object_Size} may be explicitly set for any subtype using
10790 an attribute definition clause.  Note that the use of these attributes
10791 can cause the RM 13.1(14) rule to be violated.  If two access types
10792 reference aliased objects whose subtypes have differing @code{Object_Size}
10793 values as a result of explicit attribute definition clauses, then it
10794 is erroneous to convert from one access subtype to the other.
10795
10796 At the implementation level, Esize stores the Object_Size and the
10797 RM_Size field stores the @code{Value_Size} (and hence the value of the
10798 @code{Size} attribute,
10799 which, as noted above, is equivalent to @code{Value_Size}).
10800
10801 To get a feel for the difference, consider the following examples (note
10802 that in each case the base is @code{Short_Short_Integer} with a size of 8):
10803
10804 @smallexample
10805                                        Object_Size     Value_Size
10806
10807 type x1 is range 0 .. 5;                    8               3
10808
10809 type x2 is range 0 .. 5;
10810 for x2'size use 12;                        16              12
10811
10812 subtype x3 is x2 range 0 .. 3;             16               2
10813
10814 subtype x4 is x2'base range 0 .. 10;        8               4
10815
10816 subtype x5 is x2 range 0 .. dynamic;       16               3*
10817
10818 subtype x6 is x2'base range 0 .. dynamic;   8               3*
10819
10820 @end smallexample
10821
10822 @noindent
10823 Note: the entries marked ``3*'' are not actually specified by the Ada
10824 Reference Manual, but it seems in the spirit of the RM rules to allocate
10825 the minimum number of bits (here 3, given the range for @code{x2})
10826 known to be large enough to hold the given range of values.
10827
10828 So far, so good, but GNAT has to obey the RM rules, so the question is
10829 under what conditions must the RM @code{Size} be used.
10830 The following is a list
10831 of the occasions on which the RM @code{Size} must be used:
10832
10833 @itemize @bullet
10834 @item
10835 Component size for packed arrays or records
10836
10837 @item
10838 Value of the attribute @code{Size} for a type
10839
10840 @item
10841 Warning about sizes not matching for unchecked conversion
10842 @end itemize
10843
10844 @noindent
10845 For record types, the @code{Object_Size} is always a multiple of the
10846 alignment of the type (this is true for all types). In some cases the
10847 @code{Value_Size} can be smaller. Consider:
10848
10849 @smallexample
10850    type R is record
10851      X : Integer;
10852      Y : Character;
10853    end record;
10854 @end smallexample
10855
10856 @noindent
10857 On a typical 32-bit architecture, the X component will be four bytes, and
10858 require four-byte alignment, and the Y component will be one byte. In this
10859 case @code{R'Value_Size} will be 40 (bits) since this is the minimum size
10860 required to store a value of this type, and for example, it is permissible
10861 to have a component of type R in an outer array whose component size is
10862 specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits),
10863 since it must be rounded up so that this value is a multiple of the
10864 alignment (4 bytes = 32 bits).
10865
10866 @noindent
10867 For all other types, the @code{Object_Size}
10868 and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
10869 Only @code{Size} may be specified for such types.
10870
10871 @node Component_Size Clauses
10872 @section Component_Size Clauses
10873 @cindex Component_Size Clause
10874
10875 @noindent
10876 Normally, the value specified in a component size clause must be consistent
10877 with the subtype of the array component with regard to size and alignment.
10878 In other words, the value specified must be at least equal to the size
10879 of this subtype, and must be a multiple of the alignment value.
10880
10881 In addition, component size clauses are allowed which cause the array
10882 to be packed, by specifying a smaller value.  A first case is for
10883 component size values in the range 1 through 63.  The value specified
10884 must not be smaller than the Size of the subtype.  GNAT will accurately
10885 honor all packing requests in this range.  For example, if we have:
10886
10887 @smallexample @c ada
10888 type r is array (1 .. 8) of Natural;
10889 for r'Component_Size use 31;
10890 @end smallexample
10891
10892 @noindent
10893 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
10894 Of course access to the components of such an array is considerably
10895 less efficient than if the natural component size of 32 is used.
10896 A second case is when the subtype of the component is a record type
10897 padded because of its default alignment.  For example, if we have:
10898
10899 @smallexample @c ada
10900 type r is record
10901   i : Integer;
10902   j : Integer;
10903   b : Boolean;
10904 end record;
10905
10906 type a is array (1 .. 8) of r;
10907 for a'Component_Size use 72;
10908 @end smallexample
10909
10910 @noindent
10911 then the resulting array has a length of 72 bytes, instead of 96 bytes
10912 if the alignment of the record (4) was obeyed.
10913
10914 Note that there is no point in giving both a component size clause
10915 and a pragma Pack for the same array type. if such duplicate
10916 clauses are given, the pragma Pack will be ignored.
10917
10918 @node Bit_Order Clauses
10919 @section Bit_Order Clauses
10920 @cindex Bit_Order Clause
10921 @cindex bit ordering
10922 @cindex ordering, of bits
10923
10924 @noindent
10925 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
10926 attribute.  The specification may either correspond to the default bit
10927 order for the target, in which case the specification has no effect and
10928 places no additional restrictions, or it may be for the non-standard
10929 setting (that is the opposite of the default).
10930
10931 In the case where the non-standard value is specified, the effect is
10932 to renumber bits within each byte, but the ordering of bytes is not
10933 affected.  There are certain
10934 restrictions placed on component clauses as follows:
10935
10936 @itemize @bullet
10937
10938 @item Components fitting within a single storage unit.
10939 @noindent
10940 These are unrestricted, and the effect is merely to renumber bits.  For
10941 example if we are on a little-endian machine with @code{Low_Order_First}
10942 being the default, then the following two declarations have exactly
10943 the same effect:
10944
10945 @smallexample @c ada
10946    type R1 is record
10947       A : Boolean;
10948       B : Integer range 1 .. 120;
10949    end record;
10950
10951    for R1 use record
10952       A at 0 range 0 .. 0;
10953       B at 0 range 1 .. 7;
10954    end record;
10955
10956    type R2 is record
10957       A : Boolean;
10958       B : Integer range 1 .. 120;
10959    end record;
10960
10961    for R2'Bit_Order use High_Order_First;
10962
10963    for R2 use record
10964       A at 0 range 7 .. 7;
10965       B at 0 range 0 .. 6;
10966    end record;
10967 @end smallexample
10968
10969 @noindent
10970 The useful application here is to write the second declaration with the
10971 @code{Bit_Order} attribute definition clause, and know that it will be treated
10972 the same, regardless of whether the target is little-endian or big-endian.
10973
10974 @item Components occupying an integral number of bytes.
10975 @noindent
10976 These are components that exactly fit in two or more bytes.  Such component
10977 declarations are allowed, but have no effect, since it is important to realize
10978 that the @code{Bit_Order} specification does not affect the ordering of bytes.
10979 In particular, the following attempt at getting an endian-independent integer
10980 does not work:
10981
10982 @smallexample @c ada
10983    type R2 is record
10984       A : Integer;
10985    end record;
10986
10987    for R2'Bit_Order use High_Order_First;
10988
10989    for R2 use record
10990       A at 0 range 0 .. 31;
10991    end record;
10992 @end smallexample
10993
10994 @noindent
10995 This declaration will result in a little-endian integer on a
10996 little-endian machine, and a big-endian integer on a big-endian machine.
10997 If byte flipping is required for interoperability between big- and
10998 little-endian machines, this must be explicitly programmed.  This capability
10999 is not provided by @code{Bit_Order}.
11000
11001 @item Components that are positioned across byte boundaries
11002 @noindent
11003 but do not occupy an integral number of bytes.  Given that bytes are not
11004 reordered, such fields would occupy a non-contiguous sequence of bits
11005 in memory, requiring non-trivial code to reassemble.  They are for this
11006 reason not permitted, and any component clause specifying such a layout
11007 will be flagged as illegal by GNAT@.
11008
11009 @end itemize
11010
11011 @noindent
11012 Since the misconception that Bit_Order automatically deals with all
11013 endian-related incompatibilities is a common one, the specification of
11014 a component field that is an integral number of bytes will always
11015 generate a warning.  This warning may be suppressed using @code{pragma
11016 Warnings (Off)} if desired.  The following section contains additional
11017 details regarding the issue of byte ordering.
11018
11019 @node Effect of Bit_Order on Byte Ordering
11020 @section Effect of Bit_Order on Byte Ordering
11021 @cindex byte ordering
11022 @cindex ordering, of bytes
11023
11024 @noindent
11025 In this section we will review the effect of the @code{Bit_Order} attribute
11026 definition clause on byte ordering.  Briefly, it has no effect at all, but
11027 a detailed example will be helpful.  Before giving this
11028 example, let us review the precise
11029 definition of the effect of defining @code{Bit_Order}.  The effect of a
11030 non-standard bit order is described in section 15.5.3 of the Ada
11031 Reference Manual:
11032
11033 @quotation
11034 2   A bit ordering is a method of interpreting the meaning of
11035 the storage place attributes.
11036 @end quotation
11037
11038 @noindent
11039 To understand the precise definition of storage place attributes in
11040 this context, we visit section 13.5.1 of the manual:
11041
11042 @quotation
11043 13   A record_representation_clause (without the mod_clause)
11044 specifies the layout.  The storage place attributes (see 13.5.2)
11045 are taken from the values of the position, first_bit, and last_bit
11046 expressions after normalizing those values so that first_bit is
11047 less than Storage_Unit.
11048 @end quotation
11049
11050 @noindent
11051 The critical point here is that storage places are taken from
11052 the values after normalization, not before.  So the @code{Bit_Order}
11053 interpretation applies to normalized values.  The interpretation
11054 is described in the later part of the 15.5.3 paragraph:
11055
11056 @quotation
11057 2   A bit ordering is a method of interpreting the meaning of
11058 the storage place attributes.  High_Order_First (known in the
11059 vernacular as ``big endian'') means that the first bit of a
11060 storage element (bit 0) is the most significant bit (interpreting
11061 the sequence of bits that represent a component as an unsigned
11062 integer value).  Low_Order_First (known in the vernacular as
11063 ``little endian'') means the opposite: the first bit is the
11064 least significant.
11065 @end quotation
11066
11067 @noindent
11068 Note that the numbering is with respect to the bits of a storage
11069 unit.  In other words, the specification affects only the numbering
11070 of bits within a single storage unit.
11071
11072 We can make the effect clearer by giving an example.
11073
11074 Suppose that we have an external device which presents two bytes, the first
11075 byte presented, which is the first (low addressed byte) of the two byte
11076 record is called Master, and the second byte is called Slave.
11077
11078 The left most (most significant bit is called Control for each byte, and
11079 the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
11080 (least significant) bit.
11081
11082 On a big-endian machine, we can write the following representation clause
11083
11084 @smallexample @c ada
11085    type Data is record
11086       Master_Control : Bit;
11087       Master_V1      : Bit;
11088       Master_V2      : Bit;
11089       Master_V3      : Bit;
11090       Master_V4      : Bit;
11091       Master_V5      : Bit;
11092       Master_V6      : Bit;
11093       Master_V7      : Bit;
11094       Slave_Control  : Bit;
11095       Slave_V1       : Bit;
11096       Slave_V2       : Bit;
11097       Slave_V3       : Bit;
11098       Slave_V4       : Bit;
11099       Slave_V5       : Bit;
11100       Slave_V6       : Bit;
11101       Slave_V7       : Bit;
11102    end record;
11103
11104    for Data use record
11105       Master_Control at 0 range 0 .. 0;
11106       Master_V1      at 0 range 1 .. 1;
11107       Master_V2      at 0 range 2 .. 2;
11108       Master_V3      at 0 range 3 .. 3;
11109       Master_V4      at 0 range 4 .. 4;
11110       Master_V5      at 0 range 5 .. 5;
11111       Master_V6      at 0 range 6 .. 6;
11112       Master_V7      at 0 range 7 .. 7;
11113       Slave_Control  at 1 range 0 .. 0;
11114       Slave_V1       at 1 range 1 .. 1;
11115       Slave_V2       at 1 range 2 .. 2;
11116       Slave_V3       at 1 range 3 .. 3;
11117       Slave_V4       at 1 range 4 .. 4;
11118       Slave_V5       at 1 range 5 .. 5;
11119       Slave_V6       at 1 range 6 .. 6;
11120       Slave_V7       at 1 range 7 .. 7;
11121    end record;
11122 @end smallexample
11123
11124 @noindent
11125 Now if we move this to a little endian machine, then the bit ordering within
11126 the byte is backwards, so we have to rewrite the record rep clause as:
11127
11128 @smallexample @c ada
11129    for Data use record
11130       Master_Control at 0 range 7 .. 7;
11131       Master_V1      at 0 range 6 .. 6;
11132       Master_V2      at 0 range 5 .. 5;
11133       Master_V3      at 0 range 4 .. 4;
11134       Master_V4      at 0 range 3 .. 3;
11135       Master_V5      at 0 range 2 .. 2;
11136       Master_V6      at 0 range 1 .. 1;
11137       Master_V7      at 0 range 0 .. 0;
11138       Slave_Control  at 1 range 7 .. 7;
11139       Slave_V1       at 1 range 6 .. 6;
11140       Slave_V2       at 1 range 5 .. 5;
11141       Slave_V3       at 1 range 4 .. 4;
11142       Slave_V4       at 1 range 3 .. 3;
11143       Slave_V5       at 1 range 2 .. 2;
11144       Slave_V6       at 1 range 1 .. 1;
11145       Slave_V7       at 1 range 0 .. 0;
11146    end record;
11147 @end smallexample
11148
11149 @noindent
11150 It is a nuisance to have to rewrite the clause, especially if
11151 the code has to be maintained on both machines.  However,
11152 this is a case that we can handle with the
11153 @code{Bit_Order} attribute if it is implemented.
11154 Note that the implementation is not required on byte addressed
11155 machines, but it is indeed implemented in GNAT.
11156 This means that we can simply use the
11157 first record clause, together with the declaration
11158
11159 @smallexample @c ada
11160    for Data'Bit_Order use High_Order_First;
11161 @end smallexample
11162
11163 @noindent
11164 and the effect is what is desired, namely the layout is exactly the same,
11165 independent of whether the code is compiled on a big-endian or little-endian
11166 machine.
11167
11168 The important point to understand is that byte ordering is not affected.
11169 A @code{Bit_Order} attribute definition never affects which byte a field
11170 ends up in, only where it ends up in that byte.
11171 To make this clear, let us rewrite the record rep clause of the previous
11172 example as:
11173
11174 @smallexample @c ada
11175    for Data'Bit_Order use High_Order_First;
11176    for Data use record
11177       Master_Control at 0 range  0 .. 0;
11178       Master_V1      at 0 range  1 .. 1;
11179       Master_V2      at 0 range  2 .. 2;
11180       Master_V3      at 0 range  3 .. 3;
11181       Master_V4      at 0 range  4 .. 4;
11182       Master_V5      at 0 range  5 .. 5;
11183       Master_V6      at 0 range  6 .. 6;
11184       Master_V7      at 0 range  7 .. 7;
11185       Slave_Control  at 0 range  8 .. 8;
11186       Slave_V1       at 0 range  9 .. 9;
11187       Slave_V2       at 0 range 10 .. 10;
11188       Slave_V3       at 0 range 11 .. 11;
11189       Slave_V4       at 0 range 12 .. 12;
11190       Slave_V5       at 0 range 13 .. 13;
11191       Slave_V6       at 0 range 14 .. 14;
11192       Slave_V7       at 0 range 15 .. 15;
11193    end record;
11194 @end smallexample
11195
11196 @noindent
11197 This is exactly equivalent to saying (a repeat of the first example):
11198
11199 @smallexample @c ada
11200    for Data'Bit_Order use High_Order_First;
11201    for Data use record
11202       Master_Control at 0 range 0 .. 0;
11203       Master_V1      at 0 range 1 .. 1;
11204       Master_V2      at 0 range 2 .. 2;
11205       Master_V3      at 0 range 3 .. 3;
11206       Master_V4      at 0 range 4 .. 4;
11207       Master_V5      at 0 range 5 .. 5;
11208       Master_V6      at 0 range 6 .. 6;
11209       Master_V7      at 0 range 7 .. 7;
11210       Slave_Control  at 1 range 0 .. 0;
11211       Slave_V1       at 1 range 1 .. 1;
11212       Slave_V2       at 1 range 2 .. 2;
11213       Slave_V3       at 1 range 3 .. 3;
11214       Slave_V4       at 1 range 4 .. 4;
11215       Slave_V5       at 1 range 5 .. 5;
11216       Slave_V6       at 1 range 6 .. 6;
11217       Slave_V7       at 1 range 7 .. 7;
11218    end record;
11219 @end smallexample
11220
11221 @noindent
11222 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
11223 field.  The storage place attributes are obtained by normalizing the
11224 values given so that the @code{First_Bit} value is less than 8.  After
11225 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
11226 we specified in the other case.
11227
11228 Now one might expect that the @code{Bit_Order} attribute might affect
11229 bit numbering within the entire record component (two bytes in this
11230 case, thus affecting which byte fields end up in), but that is not
11231 the way this feature is defined, it only affects numbering of bits,
11232 not which byte they end up in.
11233
11234 Consequently it never makes sense to specify a starting bit number
11235 greater than 7 (for a byte addressable field) if an attribute
11236 definition for @code{Bit_Order} has been given, and indeed it
11237 may be actively confusing to specify such a value, so the compiler
11238 generates a warning for such usage.
11239
11240 If you do need to control byte ordering then appropriate conditional
11241 values must be used.  If in our example, the slave byte came first on
11242 some machines we might write:
11243
11244 @smallexample @c ada
11245    Master_Byte_First constant Boolean := @dots{};
11246
11247    Master_Byte : constant Natural :=
11248                    1 - Boolean'Pos (Master_Byte_First);
11249    Slave_Byte  : constant Natural :=
11250                    Boolean'Pos (Master_Byte_First);
11251
11252    for Data'Bit_Order use High_Order_First;
11253    for Data use record
11254       Master_Control at Master_Byte range 0 .. 0;
11255       Master_V1      at Master_Byte range 1 .. 1;
11256       Master_V2      at Master_Byte range 2 .. 2;
11257       Master_V3      at Master_Byte range 3 .. 3;
11258       Master_V4      at Master_Byte range 4 .. 4;
11259       Master_V5      at Master_Byte range 5 .. 5;
11260       Master_V6      at Master_Byte range 6 .. 6;
11261       Master_V7      at Master_Byte range 7 .. 7;
11262       Slave_Control  at Slave_Byte  range 0 .. 0;
11263       Slave_V1       at Slave_Byte  range 1 .. 1;
11264       Slave_V2       at Slave_Byte  range 2 .. 2;
11265       Slave_V3       at Slave_Byte  range 3 .. 3;
11266       Slave_V4       at Slave_Byte  range 4 .. 4;
11267       Slave_V5       at Slave_Byte  range 5 .. 5;
11268       Slave_V6       at Slave_Byte  range 6 .. 6;
11269       Slave_V7       at Slave_Byte  range 7 .. 7;
11270    end record;
11271 @end smallexample
11272
11273 @noindent
11274 Now to switch between machines, all that is necessary is
11275 to set the boolean constant @code{Master_Byte_First} in
11276 an appropriate manner.
11277
11278 @node Pragma Pack for Arrays
11279 @section Pragma Pack for Arrays
11280 @cindex Pragma Pack (for arrays)
11281
11282 @noindent
11283 Pragma @code{Pack} applied to an array has no effect unless the component type
11284 is packable.  For a component type to be packable, it must be one of the
11285 following cases:
11286
11287 @itemize @bullet
11288 @item
11289 Any scalar type
11290 @item
11291 Any type whose size is specified with a size clause
11292 @item
11293 Any packed array type with a static size
11294 @item
11295 Any record type padded because of its default alignment
11296 @end itemize
11297
11298 @noindent
11299 For all these cases, if the component subtype size is in the range
11300 1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
11301 component size were specified giving the component subtype size.
11302 For example if we have:
11303
11304 @smallexample @c ada
11305    type r is range 0 .. 17;
11306
11307    type ar is array (1 .. 8) of r;
11308    pragma Pack (ar);
11309 @end smallexample
11310
11311 @noindent
11312 Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
11313 and the size of the array @code{ar} will be exactly 40 bits.
11314
11315 Note that in some cases this rather fierce approach to packing can produce
11316 unexpected effects.  For example, in Ada 95 and Ada 2005,
11317 subtype @code{Natural} typically has a size of 31, meaning that if you
11318 pack an array of @code{Natural}, you get 31-bit
11319 close packing, which saves a few bits, but results in far less efficient
11320 access.  Since many other Ada compilers will ignore such a packing request,
11321 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
11322 might not be what is intended.  You can easily remove this warning by
11323 using an explicit @code{Component_Size} setting instead, which never generates
11324 a warning, since the intention of the programmer is clear in this case.
11325
11326 GNAT treats packed arrays in one of two ways.  If the size of the array is
11327 known at compile time and is less than 64 bits, then internally the array
11328 is represented as a single modular type, of exactly the appropriate number
11329 of bits.  If the length is greater than 63 bits, or is not known at compile
11330 time, then the packed array is represented as an array of bytes, and the
11331 length is always a multiple of 8 bits.
11332
11333 Note that to represent a packed array as a modular type, the alignment must
11334 be suitable for the modular type involved. For example, on typical machines
11335 a 32-bit packed array will be represented by a 32-bit modular integer with
11336 an alignment of four bytes. If you explicitly override the default alignment
11337 with an alignment clause that is too small, the modular representation
11338 cannot be used. For example, consider the following set of declarations:
11339
11340 @smallexample @c ada
11341    type R is range 1 .. 3;
11342    type S is array (1 .. 31) of R;
11343    for S'Component_Size use 2;
11344    for S'Size use 62;
11345    for S'Alignment use 1;
11346 @end smallexample
11347
11348 @noindent
11349 If the alignment clause were not present, then a 62-bit modular
11350 representation would be chosen (typically with an alignment of 4 or 8
11351 bytes depending on the target). But the default alignment is overridden
11352 with the explicit alignment clause. This means that the modular
11353 representation cannot be used, and instead the array of bytes
11354 representation must be used, meaning that the length must be a multiple
11355 of 8. Thus the above set of declarations will result in a diagnostic
11356 rejecting the size clause and noting that the minimum size allowed is 64.
11357
11358 @cindex Pragma Pack (for type Natural)
11359 @cindex Pragma Pack warning
11360
11361 One special case that is worth noting occurs when the base type of the
11362 component size is 8/16/32 and the subtype is one bit less. Notably this
11363 occurs with subtype @code{Natural}. Consider:
11364
11365 @smallexample @c ada
11366    type Arr is array (1 .. 32) of Natural;
11367    pragma Pack (Arr);
11368 @end smallexample
11369
11370 @noindent
11371 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
11372 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
11373 Ada 83 compilers did not attempt 31 bit packing.
11374
11375 In Ada 95 and Ada 2005, @code{Natural'Size} is required to be 31. Furthermore,
11376 GNAT really does pack 31-bit subtype to 31 bits. This may result in a
11377 substantial unintended performance penalty when porting legacy Ada 83 code.
11378 To help prevent this, GNAT generates a warning in such cases. If you really
11379 want 31 bit packing in a case like this, you can set the component size
11380 explicitly:
11381
11382 @smallexample @c ada
11383    type Arr is array (1 .. 32) of Natural;
11384    for Arr'Component_Size use 31;
11385 @end smallexample
11386
11387 @noindent
11388 Here 31-bit packing is achieved as required, and no warning is generated,
11389 since in this case the programmer intention is clear.
11390
11391 @node Pragma Pack for Records
11392 @section Pragma Pack for Records
11393 @cindex Pragma Pack (for records)
11394
11395 @noindent
11396 Pragma @code{Pack} applied to a record will pack the components to reduce
11397 wasted space from alignment gaps and by reducing the amount of space
11398 taken by components.  We distinguish between @emph{packable} components and
11399 @emph{non-packable} components.
11400 Components of the following types are considered packable:
11401 @itemize @bullet
11402 @item
11403 All primitive types are packable.
11404
11405 @item
11406 Small packed arrays, whose size does not exceed 64 bits, and where the
11407 size is statically known at compile time, are represented internally
11408 as modular integers, and so they are also packable.
11409
11410 @end itemize
11411
11412 @noindent
11413 All packable components occupy the exact number of bits corresponding to
11414 their @code{Size} value, and are packed with no padding bits, i.e.@: they
11415 can start on an arbitrary bit boundary.
11416
11417 All other types are non-packable, they occupy an integral number of
11418 storage units, and
11419 are placed at a boundary corresponding to their alignment requirements.
11420
11421 For example, consider the record
11422
11423 @smallexample @c ada
11424    type Rb1 is array (1 .. 13) of Boolean;
11425    pragma Pack (rb1);
11426
11427    type Rb2 is array (1 .. 65) of Boolean;
11428    pragma Pack (rb2);
11429
11430    type x2 is record
11431       l1 : Boolean;
11432       l2 : Duration;
11433       l3 : Float;
11434       l4 : Boolean;
11435       l5 : Rb1;
11436       l6 : Rb2;
11437    end record;
11438    pragma Pack (x2);
11439 @end smallexample
11440
11441 @noindent
11442 The representation for the record x2 is as follows:
11443
11444 @smallexample @c ada
11445 for x2'Size use 224;
11446 for x2 use record
11447    l1 at  0 range  0 .. 0;
11448    l2 at  0 range  1 .. 64;
11449    l3 at 12 range  0 .. 31;
11450    l4 at 16 range  0 .. 0;
11451    l5 at 16 range  1 .. 13;
11452    l6 at 18 range  0 .. 71;
11453 end record;
11454 @end smallexample
11455
11456 @noindent
11457 Studying this example, we see that the packable fields @code{l1}
11458 and @code{l2} are
11459 of length equal to their sizes, and placed at specific bit boundaries (and
11460 not byte boundaries) to
11461 eliminate padding.  But @code{l3} is of a non-packable float type, so
11462 it is on the next appropriate alignment boundary.
11463
11464 The next two fields are fully packable, so @code{l4} and @code{l5} are
11465 minimally packed with no gaps.  However, type @code{Rb2} is a packed
11466 array that is longer than 64 bits, so it is itself non-packable.  Thus
11467 the @code{l6} field is aligned to the next byte boundary, and takes an
11468 integral number of bytes, i.e.@: 72 bits.
11469
11470 @node Record Representation Clauses
11471 @section Record Representation Clauses
11472 @cindex Record Representation Clause
11473
11474 @noindent
11475 Record representation clauses may be given for all record types, including
11476 types obtained by record extension.  Component clauses are allowed for any
11477 static component.  The restrictions on component clauses depend on the type
11478 of the component.
11479
11480 @cindex Component Clause
11481 For all components of an elementary type, the only restriction on component
11482 clauses is that the size must be at least the 'Size value of the type
11483 (actually the Value_Size).  There are no restrictions due to alignment,
11484 and such components may freely cross storage boundaries.
11485
11486 Packed arrays with a size up to and including 64 bits are represented
11487 internally using a modular type with the appropriate number of bits, and
11488 thus the same lack of restriction applies.  For example, if you declare:
11489
11490 @smallexample @c ada
11491    type R is array (1 .. 49) of Boolean;
11492    pragma Pack (R);
11493    for R'Size use 49;
11494 @end smallexample
11495
11496 @noindent
11497 then a component clause for a component of type R may start on any
11498 specified bit boundary, and may specify a value of 49 bits or greater.
11499
11500 For packed bit arrays that are longer than 64 bits, there are two
11501 cases. If the component size is a power of 2 (1,2,4,8,16,32 bits),
11502 including the important case of single bits or boolean values, then
11503 there are no limitations on placement of such components, and they
11504 may start and end at arbitrary bit boundaries.
11505
11506 If the component size is not a power of 2 (e.g.@: 3 or 5), then
11507 an array of this type longer than 64 bits must always be placed on
11508 on a storage unit (byte) boundary and occupy an integral number
11509 of storage units (bytes). Any component clause that does not
11510 meet this requirement will be rejected.
11511
11512 Any aliased component, or component of an aliased type, must
11513 have its normal alignment and size. A component clause that
11514 does not meet this requirement will be rejected.
11515
11516 The tag field of a tagged type always occupies an address sized field at
11517 the start of the record.  No component clause may attempt to overlay this
11518 tag. When a tagged type appears as a component, the tag field must have
11519 proper alignment
11520
11521 In the case of a record extension T1, of a type T, no component clause applied
11522 to the type T1 can specify a storage location that would overlap the first
11523 T'Size bytes of the record.
11524
11525 For all other component types, including non-bit-packed arrays,
11526 the component can be placed at an arbitrary bit boundary,
11527 so for example, the following is permitted:
11528
11529 @smallexample @c ada
11530    type R is array (1 .. 10) of Boolean;
11531    for R'Size use 80;
11532
11533    type Q is record
11534       G, H : Boolean;
11535       L, M : R;
11536    end record;
11537
11538    for Q use record
11539       G at 0 range  0 ..   0;
11540       H at 0 range  1 ..   1;
11541       L at 0 range  2 ..  81;
11542       R at 0 range 82 .. 161;
11543    end record;
11544 @end smallexample
11545
11546 @noindent
11547 Note: the above rules apply to recent releases of GNAT 5.
11548 In GNAT 3, there are more severe restrictions on larger components.
11549 For non-primitive types, including packed arrays with a size greater than
11550 64 bits, component clauses must respect the alignment requirement of the
11551 type, in particular, always starting on a byte boundary, and the length
11552 must be a multiple of the storage unit.
11553
11554 @node Enumeration Clauses
11555 @section Enumeration Clauses
11556
11557 The only restriction on enumeration clauses is that the range of values
11558 must be representable.  For the signed case, if one or more of the
11559 representation values are negative, all values must be in the range:
11560
11561 @smallexample @c ada
11562    System.Min_Int .. System.Max_Int
11563 @end smallexample
11564
11565 @noindent
11566 For the unsigned case, where all values are nonnegative, the values must
11567 be in the range:
11568
11569 @smallexample @c ada
11570    0 .. System.Max_Binary_Modulus;
11571 @end smallexample
11572
11573 @noindent
11574 A @emph{confirming} representation clause is one in which the values range
11575 from 0 in sequence, i.e.@: a clause that confirms the default representation
11576 for an enumeration type.
11577 Such a confirming representation
11578 is permitted by these rules, and is specially recognized by the compiler so
11579 that no extra overhead results from the use of such a clause.
11580
11581 If an array has an index type which is an enumeration type to which an
11582 enumeration clause has been applied, then the array is stored in a compact
11583 manner.  Consider the declarations:
11584
11585 @smallexample @c ada
11586    type r is (A, B, C);
11587    for r use (A => 1, B => 5, C => 10);
11588    type t is array (r) of Character;
11589 @end smallexample
11590
11591 @noindent
11592 The array type t corresponds to a vector with exactly three elements and
11593 has a default size equal to @code{3*Character'Size}.  This ensures efficient
11594 use of space, but means that accesses to elements of the array will incur
11595 the overhead of converting representation values to the corresponding
11596 positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
11597
11598 @node Address Clauses
11599 @section Address Clauses
11600 @cindex Address Clause
11601
11602 The reference manual allows a general restriction on representation clauses,
11603 as found in RM 13.1(22):
11604
11605 @quotation
11606 An implementation need not support representation
11607 items containing nonstatic expressions, except that
11608 an implementation should support a representation item
11609 for a given entity if each nonstatic expression in the
11610 representation item is a name that statically denotes
11611 a constant declared before the entity.
11612 @end quotation
11613
11614 @noindent
11615 In practice this is applicable only to address clauses, since this is the
11616 only case in which a non-static expression is permitted by the syntax.  As
11617 the AARM notes in sections 13.1 (22.a-22.h):
11618
11619 @display
11620   22.a   Reason: This is to avoid the following sort of thing:
11621
11622   22.b        X : Integer := F(@dots{});
11623               Y : Address := G(@dots{});
11624               for X'Address use Y;
11625
11626   22.c   In the above, we have to evaluate the
11627          initialization expression for X before we
11628          know where to put the result.  This seems
11629          like an unreasonable implementation burden.
11630
11631   22.d   The above code should instead be written
11632          like this:
11633
11634   22.e        Y : constant Address := G(@dots{});
11635               X : Integer := F(@dots{});
11636               for X'Address use Y;
11637
11638   22.f   This allows the expression ``Y'' to be safely
11639          evaluated before X is created.
11640
11641   22.g   The constant could be a formal parameter of mode in.
11642
11643   22.h   An implementation can support other nonstatic
11644          expressions if it wants to.  Expressions of type
11645          Address are hardly ever static, but their value
11646          might be known at compile time anyway in many
11647          cases.
11648 @end display
11649
11650 @noindent
11651 GNAT does indeed permit many additional cases of non-static expressions.  In
11652 particular, if the type involved is elementary there are no restrictions
11653 (since in this case, holding a temporary copy of the initialization value,
11654 if one is present, is inexpensive).  In addition, if there is no implicit or
11655 explicit initialization, then there are no restrictions.  GNAT will reject
11656 only the case where all three of these conditions hold:
11657
11658 @itemize @bullet
11659
11660 @item
11661 The type of the item is non-elementary (e.g.@: a record or array).
11662
11663 @item
11664 There is explicit or implicit initialization required for the object.
11665 Note that access values are always implicitly initialized, and also
11666 in GNAT, certain bit-packed arrays (those having a dynamic length or
11667 a length greater than 64) will also be implicitly initialized to zero.
11668
11669 @item
11670 The address value is non-static.  Here GNAT is more permissive than the
11671 RM, and allows the address value to be the address of a previously declared
11672 stand-alone variable, as long as it does not itself have an address clause.
11673
11674 @smallexample @c ada
11675            Anchor  : Some_Initialized_Type;
11676            Overlay : Some_Initialized_Type;
11677            for Overlay'Address use Anchor'Address;
11678 @end smallexample
11679
11680 @noindent
11681 However, the prefix of the address clause cannot be an array component, or
11682 a component of a discriminated record.
11683
11684 @end itemize
11685
11686 @noindent
11687 As noted above in section 22.h, address values are typically non-static.  In
11688 particular the To_Address function, even if applied to a literal value, is
11689 a non-static function call.  To avoid this minor annoyance, GNAT provides
11690 the implementation defined attribute 'To_Address.  The following two
11691 expressions have identical values:
11692
11693 @findex Attribute
11694 @findex To_Address
11695 @smallexample @c ada
11696    To_Address (16#1234_0000#)
11697    System'To_Address (16#1234_0000#);
11698 @end smallexample
11699
11700 @noindent
11701 except that the second form is considered to be a static expression, and
11702 thus when used as an address clause value is always permitted.
11703
11704 @noindent
11705 Additionally, GNAT treats as static an address clause that is an
11706 unchecked_conversion of a static integer value.  This simplifies the porting
11707 of legacy code, and provides a portable equivalent to the GNAT attribute
11708 @code{To_Address}.
11709
11710 Another issue with address clauses is the interaction with alignment
11711 requirements.  When an address clause is given for an object, the address
11712 value must be consistent with the alignment of the object (which is usually
11713 the same as the alignment of the type of the object).  If an address clause
11714 is given that specifies an inappropriately aligned address value, then the
11715 program execution is erroneous.
11716
11717 Since this source of erroneous behavior can have unfortunate effects, GNAT
11718 checks (at compile time if possible, generating a warning, or at execution
11719 time with a run-time check) that the alignment is appropriate.  If the
11720 run-time check fails, then @code{Program_Error} is raised.  This run-time
11721 check is suppressed if range checks are suppressed, or if the special GNAT
11722 check Alignment_Check is suppressed, or if
11723 @code{pragma Restrictions (No_Elaboration_Code)} is in effect.
11724
11725 Finally, GNAT does not permit overlaying of objects of controlled types or
11726 composite types containing a controlled component. In most cases, the compiler
11727 can detect an attempt at such overlays and will generate a warning at compile
11728 time and a Program_Error exception at run time.
11729
11730 @findex Export
11731 An address clause cannot be given for an exported object.  More
11732 understandably the real restriction is that objects with an address
11733 clause cannot be exported.  This is because such variables are not
11734 defined by the Ada program, so there is no external object to export.
11735
11736 @findex Import
11737 It is permissible to give an address clause and a pragma Import for the
11738 same object.  In this case, the variable is not really defined by the
11739 Ada program, so there is no external symbol to be linked.  The link name
11740 and the external name are ignored in this case.  The reason that we allow this
11741 combination is that it provides a useful idiom to avoid unwanted
11742 initializations on objects with address clauses.
11743
11744 When an address clause is given for an object that has implicit or
11745 explicit initialization, then by default initialization takes place.  This
11746 means that the effect of the object declaration is to overwrite the
11747 memory at the specified address.  This is almost always not what the
11748 programmer wants, so GNAT will output a warning:
11749
11750 @smallexample
11751   with System;
11752   package G is
11753      type R is record
11754         M : Integer := 0;
11755      end record;
11756
11757      Ext : R;
11758      for Ext'Address use System'To_Address (16#1234_1234#);
11759          |
11760   >>> warning: implicit initialization of "Ext" may
11761       modify overlaid storage
11762   >>> warning: use pragma Import for "Ext" to suppress
11763       initialization (RM B(24))
11764
11765   end G;
11766 @end smallexample
11767
11768 @noindent
11769 As indicated by the warning message, the solution is to use a (dummy) pragma
11770 Import to suppress this initialization.  The pragma tell the compiler that the
11771 object is declared and initialized elsewhere.  The following package compiles
11772 without warnings (and the initialization is suppressed):
11773
11774 @smallexample @c ada
11775    with System;
11776    package G is
11777       type R is record
11778          M : Integer := 0;
11779       end record;
11780
11781       Ext : R;
11782       for Ext'Address use System'To_Address (16#1234_1234#);
11783       pragma Import (Ada, Ext);
11784    end G;
11785 @end smallexample
11786
11787 @noindent
11788 A final issue with address clauses involves their use for overlaying
11789 variables, as in the following example:
11790 @cindex Overlaying of objects
11791
11792 @smallexample @c ada
11793   A : Integer;
11794   B : Integer;
11795   for B'Address use A'Address;
11796 @end smallexample
11797
11798 @noindent
11799 or alternatively, using the form recommended by the RM:
11800
11801 @smallexample @c ada
11802   A    : Integer;
11803   Addr : constant Address := A'Address;
11804   B    : Integer;
11805   for B'Address use Addr;
11806 @end smallexample
11807
11808 @noindent
11809 In both of these cases, @code{A}
11810 and @code{B} become aliased to one another via the
11811 address clause. This use of address clauses to overlay
11812 variables, achieving an effect similar to unchecked
11813 conversion was erroneous in Ada 83, but in Ada 95 and Ada 2005
11814 the effect is implementation defined. Furthermore, the
11815 Ada RM specifically recommends that in a situation
11816 like this, @code{B} should be subject to the following
11817 implementation advice (RM 13.3(19)):
11818
11819 @quotation
11820 19  If the Address of an object is specified, or it is imported
11821     or exported, then the implementation should not perform
11822     optimizations based on assumptions of no aliases.
11823 @end quotation
11824
11825 @noindent
11826 GNAT follows this recommendation, and goes further by also applying
11827 this recommendation to the overlaid variable (@code{A}
11828 in the above example) in this case. This means that the overlay
11829 works "as expected", in that a modification to one of the variables
11830 will affect the value of the other.
11831
11832 @node Effect of Convention on Representation
11833 @section Effect of Convention on Representation
11834 @cindex Convention, effect on representation
11835
11836 @noindent
11837 Normally the specification of a foreign language convention for a type or
11838 an object has no effect on the chosen representation.  In particular, the
11839 representation chosen for data in GNAT generally meets the standard system
11840 conventions, and for example records are laid out in a manner that is
11841 consistent with C@.  This means that specifying convention C (for example)
11842 has no effect.
11843
11844 There are four exceptions to this general rule:
11845
11846 @itemize @bullet
11847
11848 @item Convention Fortran and array subtypes
11849 If pragma Convention Fortran is specified for an array subtype, then in
11850 accordance with the implementation advice in section 3.6.2(11) of the
11851 Ada Reference Manual, the array will be stored in a Fortran-compatible
11852 column-major manner, instead of the normal default row-major order.
11853
11854 @item Convention C and enumeration types
11855 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
11856 to accommodate all values of the type.  For example, for the enumeration
11857 type declared by:
11858
11859 @smallexample @c ada
11860    type Color is (Red, Green, Blue);
11861 @end smallexample
11862
11863 @noindent
11864 8 bits is sufficient to store all values of the type, so by default, objects
11865 of type @code{Color} will be represented using 8 bits.  However, normal C
11866 convention is to use 32 bits for all enum values in C, since enum values
11867 are essentially of type int.  If pragma @code{Convention C} is specified for an
11868 Ada enumeration type, then the size is modified as necessary (usually to
11869 32 bits) to be consistent with the C convention for enum values.
11870
11871 Note that this treatment applies only to types. If Convention C is given for
11872 an enumeration object, where the enumeration type is not Convention C, then
11873 Object_Size bits are allocated. For example, for a normal enumeration type,
11874 with less than 256 elements, only 8 bits will be allocated for the object.
11875 Since this may be a surprise in terms of what C expects, GNAT will issue a
11876 warning in this situation. The warning can be suppressed by giving an explicit
11877 size clause specifying the desired size.
11878
11879 @item Convention C/Fortran and Boolean types
11880 In C, the usual convention for boolean values, that is values used for
11881 conditions, is that zero represents false, and nonzero values represent
11882 true.  In Ada, the normal convention is that two specific values, typically
11883 0/1, are used to represent false/true respectively.
11884
11885 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
11886 value represents true).
11887
11888 To accommodate the Fortran and C conventions, if a pragma Convention specifies
11889 C or Fortran convention for a derived Boolean, as in the following example:
11890
11891 @smallexample @c ada
11892    type C_Switch is new Boolean;
11893    pragma Convention (C, C_Switch);
11894 @end smallexample
11895
11896 @noindent
11897 then the GNAT generated code will treat any nonzero value as true.  For truth
11898 values generated by GNAT, the conventional value 1 will be used for True, but
11899 when one of these values is read, any nonzero value is treated as True.
11900
11901 @item Access types on OpenVMS
11902 For 64-bit OpenVMS systems, access types (other than those for unconstrained
11903 arrays) are 64-bits long. An exception to this rule is for the case of
11904 C-convention access types where there is no explicit size clause present (or
11905 inherited for derived types). In this case, GNAT chooses to make these
11906 pointers 32-bits, which provides an easier path for migration of 32-bit legacy
11907 code. size clause specifying 64-bits must be used to obtain a 64-bit pointer.
11908
11909 @end itemize
11910
11911 @node Determining the Representations chosen by GNAT
11912 @section Determining the Representations chosen by GNAT
11913 @cindex Representation, determination of
11914 @cindex @option{-gnatR} switch
11915
11916 @noindent
11917 Although the descriptions in this section are intended to be complete, it is
11918 often easier to simply experiment to see what GNAT accepts and what the
11919 effect is on the layout of types and objects.
11920
11921 As required by the Ada RM, if a representation clause is not accepted, then
11922 it must be rejected as illegal by the compiler.  However, when a
11923 representation clause or pragma is accepted, there can still be questions
11924 of what the compiler actually does.  For example, if a partial record
11925 representation clause specifies the location of some components and not
11926 others, then where are the non-specified components placed? Or if pragma
11927 @code{Pack} is used on a record, then exactly where are the resulting
11928 fields placed? The section on pragma @code{Pack} in this chapter can be
11929 used to answer the second question, but it is often easier to just see
11930 what the compiler does.
11931
11932 For this purpose, GNAT provides the option @option{-gnatR}.  If you compile
11933 with this option, then the compiler will output information on the actual
11934 representations chosen, in a format similar to source representation
11935 clauses.  For example, if we compile the package:
11936
11937 @smallexample @c ada
11938 package q is
11939    type r (x : boolean) is tagged record
11940       case x is
11941          when True => S : String (1 .. 100);
11942          when False => null;
11943       end case;
11944    end record;
11945
11946    type r2 is new r (false) with record
11947       y2 : integer;
11948    end record;
11949
11950    for r2 use record
11951       y2 at 16 range 0 .. 31;
11952    end record;
11953
11954    type x is record
11955       y : character;
11956    end record;
11957
11958    type x1 is array (1 .. 10) of x;
11959    for x1'component_size use 11;
11960
11961    type ia is access integer;
11962
11963    type Rb1 is array (1 .. 13) of Boolean;
11964    pragma Pack (rb1);
11965
11966    type Rb2 is array (1 .. 65) of Boolean;
11967    pragma Pack (rb2);
11968
11969    type x2 is record
11970       l1 : Boolean;
11971       l2 : Duration;
11972       l3 : Float;
11973       l4 : Boolean;
11974       l5 : Rb1;
11975       l6 : Rb2;
11976    end record;
11977    pragma Pack (x2);
11978 end q;
11979 @end smallexample
11980
11981 @noindent
11982 using the switch @option{-gnatR} we obtain the following output:
11983
11984 @smallexample
11985 Representation information for unit q
11986 -------------------------------------
11987
11988 for r'Size use ??;
11989 for r'Alignment use 4;
11990 for r use record
11991    x    at 4 range  0 .. 7;
11992    _tag at 0 range  0 .. 31;
11993    s    at 5 range  0 .. 799;
11994 end record;
11995
11996 for r2'Size use 160;
11997 for r2'Alignment use 4;
11998 for r2 use record
11999    x       at  4 range  0 .. 7;
12000    _tag    at  0 range  0 .. 31;
12001    _parent at  0 range  0 .. 63;
12002    y2      at 16 range  0 .. 31;
12003 end record;
12004
12005 for x'Size use 8;
12006 for x'Alignment use 1;
12007 for x use record
12008    y at 0 range  0 .. 7;
12009 end record;
12010
12011 for x1'Size use 112;
12012 for x1'Alignment use 1;
12013 for x1'Component_Size use 11;
12014
12015 for rb1'Size use 13;
12016 for rb1'Alignment use 2;
12017 for rb1'Component_Size use 1;
12018
12019 for rb2'Size use 72;
12020 for rb2'Alignment use 1;
12021 for rb2'Component_Size use 1;
12022
12023 for x2'Size use 224;
12024 for x2'Alignment use 4;
12025 for x2 use record
12026    l1 at  0 range  0 .. 0;
12027    l2 at  0 range  1 .. 64;
12028    l3 at 12 range  0 .. 31;
12029    l4 at 16 range  0 .. 0;
12030    l5 at 16 range  1 .. 13;
12031    l6 at 18 range  0 .. 71;
12032 end record;
12033 @end smallexample
12034
12035 @noindent
12036 The Size values are actually the Object_Size, i.e.@: the default size that
12037 will be allocated for objects of the type.
12038 The ?? size for type r indicates that we have a variant record, and the
12039 actual size of objects will depend on the discriminant value.
12040
12041 The Alignment values show the actual alignment chosen by the compiler
12042 for each record or array type.
12043
12044 The record representation clause for type r shows where all fields
12045 are placed, including the compiler generated tag field (whose location
12046 cannot be controlled by the programmer).
12047
12048 The record representation clause for the type extension r2 shows all the
12049 fields present, including the parent field, which is a copy of the fields
12050 of the parent type of r2, i.e.@: r1.
12051
12052 The component size and size clauses for types rb1 and rb2 show
12053 the exact effect of pragma @code{Pack} on these arrays, and the record
12054 representation clause for type x2 shows how pragma @code{Pack} affects
12055 this record type.
12056
12057 In some cases, it may be useful to cut and paste the representation clauses
12058 generated by the compiler into the original source to fix and guarantee
12059 the actual representation to be used.
12060
12061 @node Standard Library Routines
12062 @chapter Standard Library Routines
12063
12064 @noindent
12065 The Ada Reference Manual contains in Annex A a full description of an
12066 extensive set of standard library routines that can be used in any Ada
12067 program, and which must be provided by all Ada compilers.  They are
12068 analogous to the standard C library used by C programs.
12069
12070 GNAT implements all of the facilities described in annex A, and for most
12071 purposes the description in the Ada Reference Manual, or appropriate Ada
12072 text book, will be sufficient for making use of these facilities.
12073
12074 In the case of the input-output facilities,
12075 @xref{The Implementation of Standard I/O},
12076 gives details on exactly how GNAT interfaces to the
12077 file system.  For the remaining packages, the Ada Reference Manual
12078 should be sufficient.  The following is a list of the packages included,
12079 together with a brief description of the functionality that is provided.
12080
12081 For completeness, references are included to other predefined library
12082 routines defined in other sections of the Ada Reference Manual (these are
12083 cross-indexed from Annex A).
12084
12085 @table @code
12086 @item Ada (A.2)
12087 This is a parent package for all the standard library packages.  It is
12088 usually included implicitly in your program, and itself contains no
12089 useful data or routines.
12090
12091 @item Ada.Calendar (9.6)
12092 @code{Calendar} provides time of day access, and routines for
12093 manipulating times and durations.
12094
12095 @item Ada.Characters (A.3.1)
12096 This is a dummy parent package that contains no useful entities
12097
12098 @item Ada.Characters.Handling (A.3.2)
12099 This package provides some basic character handling capabilities,
12100 including classification functions for classes of characters (e.g.@: test
12101 for letters, or digits).
12102
12103 @item Ada.Characters.Latin_1 (A.3.3)
12104 This package includes a complete set of definitions of the characters
12105 that appear in type CHARACTER@.  It is useful for writing programs that
12106 will run in international environments.  For example, if you want an
12107 upper case E with an acute accent in a string, it is often better to use
12108 the definition of @code{UC_E_Acute} in this package.  Then your program
12109 will print in an understandable manner even if your environment does not
12110 support these extended characters.
12111
12112 @item Ada.Command_Line (A.15)
12113 This package provides access to the command line parameters and the name
12114 of the current program (analogous to the use of @code{argc} and @code{argv}
12115 in C), and also allows the exit status for the program to be set in a
12116 system-independent manner.
12117
12118 @item Ada.Decimal (F.2)
12119 This package provides constants describing the range of decimal numbers
12120 implemented, and also a decimal divide routine (analogous to the COBOL
12121 verb DIVIDE @dots{} GIVING @dots{} REMAINDER @dots{})
12122
12123 @item Ada.Direct_IO (A.8.4)
12124 This package provides input-output using a model of a set of records of
12125 fixed-length, containing an arbitrary definite Ada type, indexed by an
12126 integer record number.
12127
12128 @item Ada.Dynamic_Priorities (D.5)
12129 This package allows the priorities of a task to be adjusted dynamically
12130 as the task is running.
12131
12132 @item Ada.Exceptions (11.4.1)
12133 This package provides additional information on exceptions, and also
12134 contains facilities for treating exceptions as data objects, and raising
12135 exceptions with associated messages.
12136
12137 @item Ada.Finalization (7.6)
12138 This package contains the declarations and subprograms to support the
12139 use of controlled types, providing for automatic initialization and
12140 finalization (analogous to the constructors and destructors of C++)
12141
12142 @item Ada.Interrupts (C.3.2)
12143 This package provides facilities for interfacing to interrupts, which
12144 includes the set of signals or conditions that can be raised and
12145 recognized as interrupts.
12146
12147 @item Ada.Interrupts.Names (C.3.2)
12148 This package provides the set of interrupt names (actually signal
12149 or condition names) that can be handled by GNAT@.
12150
12151 @item Ada.IO_Exceptions (A.13)
12152 This package defines the set of exceptions that can be raised by use of
12153 the standard IO packages.
12154
12155 @item Ada.Numerics
12156 This package contains some standard constants and exceptions used
12157 throughout the numerics packages.  Note that the constants pi and e are
12158 defined here, and it is better to use these definitions than rolling
12159 your own.
12160
12161 @item Ada.Numerics.Complex_Elementary_Functions
12162 Provides the implementation of standard elementary functions (such as
12163 log and trigonometric functions) operating on complex numbers using the
12164 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
12165 created by the package @code{Numerics.Complex_Types}.
12166
12167 @item Ada.Numerics.Complex_Types
12168 This is a predefined instantiation of
12169 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
12170 build the type @code{Complex} and @code{Imaginary}.
12171
12172 @item Ada.Numerics.Discrete_Random
12173 This generic package provides a random number generator suitable for generating
12174 uniformly distributed values of a specified discrete subtype.
12175
12176 @item Ada.Numerics.Float_Random
12177 This package provides a random number generator suitable for generating
12178 uniformly distributed floating point values in the unit interval.
12179
12180 @item Ada.Numerics.Generic_Complex_Elementary_Functions
12181 This is a generic version of the package that provides the
12182 implementation of standard elementary functions (such as log and
12183 trigonometric functions) for an arbitrary complex type.
12184
12185 The following predefined instantiations of this package are provided:
12186
12187 @table @code
12188 @item Short_Float
12189 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
12190 @item Float
12191 @code{Ada.Numerics.Complex_Elementary_Functions}
12192 @item Long_Float
12193 @code{Ada.Numerics.Long_Complex_Elementary_Functions}
12194 @end table
12195
12196 @item Ada.Numerics.Generic_Complex_Types
12197 This is a generic package that allows the creation of complex types,
12198 with associated complex arithmetic operations.
12199
12200 The following predefined instantiations of this package exist
12201 @table @code
12202 @item Short_Float
12203 @code{Ada.Numerics.Short_Complex_Complex_Types}
12204 @item Float
12205 @code{Ada.Numerics.Complex_Complex_Types}
12206 @item Long_Float
12207 @code{Ada.Numerics.Long_Complex_Complex_Types}
12208 @end table
12209
12210 @item Ada.Numerics.Generic_Elementary_Functions
12211 This is a generic package that provides the implementation of standard
12212 elementary functions (such as log an trigonometric functions) for an
12213 arbitrary float type.
12214
12215 The following predefined instantiations of this package exist
12216
12217 @table @code
12218 @item Short_Float
12219 @code{Ada.Numerics.Short_Elementary_Functions}
12220 @item Float
12221 @code{Ada.Numerics.Elementary_Functions}
12222 @item Long_Float
12223 @code{Ada.Numerics.Long_Elementary_Functions}
12224 @end table
12225
12226 @item Ada.Real_Time (D.8)
12227 This package provides facilities similar to those of @code{Calendar}, but
12228 operating with a finer clock suitable for real time control. Note that
12229 annex D requires that there be no backward clock jumps, and GNAT generally
12230 guarantees this behavior, but of course if the external clock on which
12231 the GNAT runtime depends is deliberately reset by some external event,
12232 then such a backward jump may occur.
12233
12234 @item Ada.Sequential_IO (A.8.1)
12235 This package provides input-output facilities for sequential files,
12236 which can contain a sequence of values of a single type, which can be
12237 any Ada type, including indefinite (unconstrained) types.
12238
12239 @item Ada.Storage_IO (A.9)
12240 This package provides a facility for mapping arbitrary Ada types to and
12241 from a storage buffer.  It is primarily intended for the creation of new
12242 IO packages.
12243
12244 @item Ada.Streams (13.13.1)
12245 This is a generic package that provides the basic support for the
12246 concept of streams as used by the stream attributes (@code{Input},
12247 @code{Output}, @code{Read} and @code{Write}).
12248
12249 @item Ada.Streams.Stream_IO (A.12.1)
12250 This package is a specialization of the type @code{Streams} defined in
12251 package @code{Streams} together with a set of operations providing
12252 Stream_IO capability.  The Stream_IO model permits both random and
12253 sequential access to a file which can contain an arbitrary set of values
12254 of one or more Ada types.
12255
12256 @item Ada.Strings (A.4.1)
12257 This package provides some basic constants used by the string handling
12258 packages.
12259
12260 @item Ada.Strings.Bounded (A.4.4)
12261 This package provides facilities for handling variable length
12262 strings.  The bounded model requires a maximum length.  It is thus
12263 somewhat more limited than the unbounded model, but avoids the use of
12264 dynamic allocation or finalization.
12265
12266 @item Ada.Strings.Fixed (A.4.3)
12267 This package provides facilities for handling fixed length strings.
12268
12269 @item Ada.Strings.Maps (A.4.2)
12270 This package provides facilities for handling character mappings and
12271 arbitrarily defined subsets of characters.  For instance it is useful in
12272 defining specialized translation tables.
12273
12274 @item Ada.Strings.Maps.Constants (A.4.6)
12275 This package provides a standard set of predefined mappings and
12276 predefined character sets.  For example, the standard upper to lower case
12277 conversion table is found in this package.  Note that upper to lower case
12278 conversion is non-trivial if you want to take the entire set of
12279 characters, including extended characters like E with an acute accent,
12280 into account.  You should use the mappings in this package (rather than
12281 adding 32 yourself) to do case mappings.
12282
12283 @item Ada.Strings.Unbounded (A.4.5)
12284 This package provides facilities for handling variable length
12285 strings.  The unbounded model allows arbitrary length strings, but
12286 requires the use of dynamic allocation and finalization.
12287
12288 @item Ada.Strings.Wide_Bounded (A.4.7)
12289 @itemx Ada.Strings.Wide_Fixed (A.4.7)
12290 @itemx Ada.Strings.Wide_Maps (A.4.7)
12291 @itemx Ada.Strings.Wide_Maps.Constants (A.4.7)
12292 @itemx Ada.Strings.Wide_Unbounded (A.4.7)
12293 These packages provide analogous capabilities to the corresponding
12294 packages without @samp{Wide_} in the name, but operate with the types
12295 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
12296 and @code{Character}.
12297
12298 @item Ada.Strings.Wide_Wide_Bounded (A.4.7)
12299 @itemx Ada.Strings.Wide_Wide_Fixed (A.4.7)
12300 @itemx Ada.Strings.Wide_Wide_Maps (A.4.7)
12301 @itemx Ada.Strings.Wide_Wide_Maps.Constants (A.4.7)
12302 @itemx Ada.Strings.Wide_Wide_Unbounded (A.4.7)
12303 These packages provide analogous capabilities to the corresponding
12304 packages without @samp{Wide_} in the name, but operate with the types
12305 @code{Wide_Wide_String} and @code{Wide_Wide_Character} instead
12306 of @code{String} and @code{Character}.
12307
12308 @item Ada.Synchronous_Task_Control (D.10)
12309 This package provides some standard facilities for controlling task
12310 communication in a synchronous manner.
12311
12312 @item Ada.Tags
12313 This package contains definitions for manipulation of the tags of tagged
12314 values.
12315
12316 @item Ada.Task_Attributes
12317 This package provides the capability of associating arbitrary
12318 task-specific data with separate tasks.
12319
12320 @item Ada.Text_IO
12321 This package provides basic text input-output capabilities for
12322 character, string and numeric data.  The subpackages of this
12323 package are listed next.
12324
12325 @item Ada.Text_IO.Decimal_IO
12326 Provides input-output facilities for decimal fixed-point types
12327
12328 @item Ada.Text_IO.Enumeration_IO
12329 Provides input-output facilities for enumeration types.
12330
12331 @item Ada.Text_IO.Fixed_IO
12332 Provides input-output facilities for ordinary fixed-point types.
12333
12334 @item Ada.Text_IO.Float_IO
12335 Provides input-output facilities for float types.  The following
12336 predefined instantiations of this generic package are available:
12337
12338 @table @code
12339 @item Short_Float
12340 @code{Short_Float_Text_IO}
12341 @item Float
12342 @code{Float_Text_IO}
12343 @item Long_Float
12344 @code{Long_Float_Text_IO}
12345 @end table
12346
12347 @item Ada.Text_IO.Integer_IO
12348 Provides input-output facilities for integer types.  The following
12349 predefined instantiations of this generic package are available:
12350
12351 @table @code
12352 @item Short_Short_Integer
12353 @code{Ada.Short_Short_Integer_Text_IO}
12354 @item Short_Integer
12355 @code{Ada.Short_Integer_Text_IO}
12356 @item Integer
12357 @code{Ada.Integer_Text_IO}
12358 @item Long_Integer
12359 @code{Ada.Long_Integer_Text_IO}
12360 @item Long_Long_Integer
12361 @code{Ada.Long_Long_Integer_Text_IO}
12362 @end table
12363
12364 @item Ada.Text_IO.Modular_IO
12365 Provides input-output facilities for modular (unsigned) types
12366
12367 @item Ada.Text_IO.Complex_IO (G.1.3)
12368 This package provides basic text input-output capabilities for complex
12369 data.
12370
12371 @item Ada.Text_IO.Editing (F.3.3)
12372 This package contains routines for edited output, analogous to the use
12373 of pictures in COBOL@.  The picture formats used by this package are a
12374 close copy of the facility in COBOL@.
12375
12376 @item Ada.Text_IO.Text_Streams (A.12.2)
12377 This package provides a facility that allows Text_IO files to be treated
12378 as streams, so that the stream attributes can be used for writing
12379 arbitrary data, including binary data, to Text_IO files.
12380
12381 @item Ada.Unchecked_Conversion (13.9)
12382 This generic package allows arbitrary conversion from one type to
12383 another of the same size, providing for breaking the type safety in
12384 special circumstances.
12385
12386 If the types have the same Size (more accurately the same Value_Size),
12387 then the effect is simply to transfer the bits from the source to the
12388 target type without any modification.  This usage is well defined, and
12389 for simple types whose representation is typically the same across
12390 all implementations, gives a portable method of performing such
12391 conversions.
12392
12393 If the types do not have the same size, then the result is implementation
12394 defined, and thus may be non-portable.  The following describes how GNAT
12395 handles such unchecked conversion cases.
12396
12397 If the types are of different sizes, and are both discrete types, then
12398 the effect is of a normal type conversion without any constraint checking.
12399 In particular if the result type has a larger size, the result will be
12400 zero or sign extended.  If the result type has a smaller size, the result
12401 will be truncated by ignoring high order bits.
12402
12403 If the types are of different sizes, and are not both discrete types,
12404 then the conversion works as though pointers were created to the source
12405 and target, and the pointer value is converted.  The effect is that bits
12406 are copied from successive low order storage units and bits of the source
12407 up to the length of the target type.
12408
12409 A warning is issued if the lengths differ, since the effect in this
12410 case is implementation dependent, and the above behavior may not match
12411 that of some other compiler.
12412
12413 A pointer to one type may be converted to a pointer to another type using
12414 unchecked conversion.  The only case in which the effect is undefined is
12415 when one or both pointers are pointers to unconstrained array types.  In
12416 this case, the bounds information may get incorrectly transferred, and in
12417 particular, GNAT uses double size pointers for such types, and it is
12418 meaningless to convert between such pointer types.  GNAT will issue a
12419 warning if the alignment of the target designated type is more strict
12420 than the alignment of the source designated type (since the result may
12421 be unaligned in this case).
12422
12423 A pointer other than a pointer to an unconstrained array type may be
12424 converted to and from System.Address.  Such usage is common in Ada 83
12425 programs, but note that Ada.Address_To_Access_Conversions is the
12426 preferred method of performing such conversions in Ada 95 and Ada 2005.
12427 Neither
12428 unchecked conversion nor Ada.Address_To_Access_Conversions should be
12429 used in conjunction with pointers to unconstrained objects, since
12430 the bounds information cannot be handled correctly in this case.
12431
12432 @item Ada.Unchecked_Deallocation (13.11.2)
12433 This generic package allows explicit freeing of storage previously
12434 allocated by use of an allocator.
12435
12436 @item Ada.Wide_Text_IO (A.11)
12437 This package is similar to @code{Ada.Text_IO}, except that the external
12438 file supports wide character representations, and the internal types are
12439 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
12440 and @code{String}.  It contains generic subpackages listed next.
12441
12442 @item Ada.Wide_Text_IO.Decimal_IO
12443 Provides input-output facilities for decimal fixed-point types
12444
12445 @item Ada.Wide_Text_IO.Enumeration_IO
12446 Provides input-output facilities for enumeration types.
12447
12448 @item Ada.Wide_Text_IO.Fixed_IO
12449 Provides input-output facilities for ordinary fixed-point types.
12450
12451 @item Ada.Wide_Text_IO.Float_IO
12452 Provides input-output facilities for float types.  The following
12453 predefined instantiations of this generic package are available:
12454
12455 @table @code
12456 @item Short_Float
12457 @code{Short_Float_Wide_Text_IO}
12458 @item Float
12459 @code{Float_Wide_Text_IO}
12460 @item Long_Float
12461 @code{Long_Float_Wide_Text_IO}
12462 @end table
12463
12464 @item Ada.Wide_Text_IO.Integer_IO
12465 Provides input-output facilities for integer types.  The following
12466 predefined instantiations of this generic package are available:
12467
12468 @table @code
12469 @item Short_Short_Integer
12470 @code{Ada.Short_Short_Integer_Wide_Text_IO}
12471 @item Short_Integer
12472 @code{Ada.Short_Integer_Wide_Text_IO}
12473 @item Integer
12474 @code{Ada.Integer_Wide_Text_IO}
12475 @item Long_Integer
12476 @code{Ada.Long_Integer_Wide_Text_IO}
12477 @item Long_Long_Integer
12478 @code{Ada.Long_Long_Integer_Wide_Text_IO}
12479 @end table
12480
12481 @item Ada.Wide_Text_IO.Modular_IO
12482 Provides input-output facilities for modular (unsigned) types
12483
12484 @item Ada.Wide_Text_IO.Complex_IO (G.1.3)
12485 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
12486 external file supports wide character representations.
12487
12488 @item Ada.Wide_Text_IO.Editing (F.3.4)
12489 This package is similar to @code{Ada.Text_IO.Editing}, except that the
12490 types are @code{Wide_Character} and @code{Wide_String} instead of
12491 @code{Character} and @code{String}.
12492
12493 @item Ada.Wide_Text_IO.Streams (A.12.3)
12494 This package is similar to @code{Ada.Text_IO.Streams}, except that the
12495 types are @code{Wide_Character} and @code{Wide_String} instead of
12496 @code{Character} and @code{String}.
12497
12498 @item Ada.Wide_Wide_Text_IO (A.11)
12499 This package is similar to @code{Ada.Text_IO}, except that the external
12500 file supports wide character representations, and the internal types are
12501 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
12502 and @code{String}.  It contains generic subpackages listed next.
12503
12504 @item Ada.Wide_Wide_Text_IO.Decimal_IO
12505 Provides input-output facilities for decimal fixed-point types
12506
12507 @item Ada.Wide_Wide_Text_IO.Enumeration_IO
12508 Provides input-output facilities for enumeration types.
12509
12510 @item Ada.Wide_Wide_Text_IO.Fixed_IO
12511 Provides input-output facilities for ordinary fixed-point types.
12512
12513 @item Ada.Wide_Wide_Text_IO.Float_IO
12514 Provides input-output facilities for float types.  The following
12515 predefined instantiations of this generic package are available:
12516
12517 @table @code
12518 @item Short_Float
12519 @code{Short_Float_Wide_Wide_Text_IO}
12520 @item Float
12521 @code{Float_Wide_Wide_Text_IO}
12522 @item Long_Float
12523 @code{Long_Float_Wide_Wide_Text_IO}
12524 @end table
12525
12526 @item Ada.Wide_Wide_Text_IO.Integer_IO
12527 Provides input-output facilities for integer types.  The following
12528 predefined instantiations of this generic package are available:
12529
12530 @table @code
12531 @item Short_Short_Integer
12532 @code{Ada.Short_Short_Integer_Wide_Wide_Text_IO}
12533 @item Short_Integer
12534 @code{Ada.Short_Integer_Wide_Wide_Text_IO}
12535 @item Integer
12536 @code{Ada.Integer_Wide_Wide_Text_IO}
12537 @item Long_Integer
12538 @code{Ada.Long_Integer_Wide_Wide_Text_IO}
12539 @item Long_Long_Integer
12540 @code{Ada.Long_Long_Integer_Wide_Wide_Text_IO}
12541 @end table
12542
12543 @item Ada.Wide_Wide_Text_IO.Modular_IO
12544 Provides input-output facilities for modular (unsigned) types
12545
12546 @item Ada.Wide_Wide_Text_IO.Complex_IO (G.1.3)
12547 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
12548 external file supports wide character representations.
12549
12550 @item Ada.Wide_Wide_Text_IO.Editing (F.3.4)
12551 This package is similar to @code{Ada.Text_IO.Editing}, except that the
12552 types are @code{Wide_Character} and @code{Wide_String} instead of
12553 @code{Character} and @code{String}.
12554
12555 @item Ada.Wide_Wide_Text_IO.Streams (A.12.3)
12556 This package is similar to @code{Ada.Text_IO.Streams}, except that the
12557 types are @code{Wide_Character} and @code{Wide_String} instead of
12558 @code{Character} and @code{String}.
12559 @end table
12560
12561 @node The Implementation of Standard I/O
12562 @chapter The Implementation of Standard I/O
12563
12564 @noindent
12565 GNAT implements all the required input-output facilities described in
12566 A.6 through A.14.  These sections of the Ada Reference Manual describe the
12567 required behavior of these packages from the Ada point of view, and if
12568 you are writing a portable Ada program that does not need to know the
12569 exact manner in which Ada maps to the outside world when it comes to
12570 reading or writing external files, then you do not need to read this
12571 chapter.  As long as your files are all regular files (not pipes or
12572 devices), and as long as you write and read the files only from Ada, the
12573 description in the Ada Reference Manual is sufficient.
12574
12575 However, if you want to do input-output to pipes or other devices, such
12576 as the keyboard or screen, or if the files you are dealing with are
12577 either generated by some other language, or to be read by some other
12578 language, then you need to know more about the details of how the GNAT
12579 implementation of these input-output facilities behaves.
12580
12581 In this chapter we give a detailed description of exactly how GNAT
12582 interfaces to the file system.  As always, the sources of the system are
12583 available to you for answering questions at an even more detailed level,
12584 but for most purposes the information in this chapter will suffice.
12585
12586 Another reason that you may need to know more about how input-output is
12587 implemented arises when you have a program written in mixed languages
12588 where, for example, files are shared between the C and Ada sections of
12589 the same program.  GNAT provides some additional facilities, in the form
12590 of additional child library packages, that facilitate this sharing, and
12591 these additional facilities are also described in this chapter.
12592
12593 @menu
12594 * Standard I/O Packages::
12595 * FORM Strings::
12596 * Direct_IO::
12597 * Sequential_IO::
12598 * Text_IO::
12599 * Wide_Text_IO::
12600 * Wide_Wide_Text_IO::
12601 * Stream_IO::
12602 * Text Translation::
12603 * Shared Files::
12604 * Filenames encoding::
12605 * Open Modes::
12606 * Operations on C Streams::
12607 * Interfacing to C Streams::
12608 @end menu
12609
12610 @node Standard I/O Packages
12611 @section Standard I/O Packages
12612
12613 @noindent
12614 The Standard I/O packages described in Annex A for
12615
12616 @itemize @bullet
12617 @item
12618 Ada.Text_IO
12619 @item
12620 Ada.Text_IO.Complex_IO
12621 @item
12622 Ada.Text_IO.Text_Streams
12623 @item
12624 Ada.Wide_Text_IO
12625 @item
12626 Ada.Wide_Text_IO.Complex_IO
12627 @item
12628 Ada.Wide_Text_IO.Text_Streams
12629 @item
12630 Ada.Wide_Wide_Text_IO
12631 @item
12632 Ada.Wide_Wide_Text_IO.Complex_IO
12633 @item
12634 Ada.Wide_Wide_Text_IO.Text_Streams
12635 @item
12636 Ada.Stream_IO
12637 @item
12638 Ada.Sequential_IO
12639 @item
12640 Ada.Direct_IO
12641 @end itemize
12642
12643 @noindent
12644 are implemented using the C
12645 library streams facility; where
12646
12647 @itemize @bullet
12648 @item
12649 All files are opened using @code{fopen}.
12650 @item
12651 All input/output operations use @code{fread}/@code{fwrite}.
12652 @end itemize
12653
12654 @noindent
12655 There is no internal buffering of any kind at the Ada library level. The only
12656 buffering is that provided at the system level in the implementation of the
12657 library routines that support streams. This facilitates shared use of these
12658 streams by mixed language programs. Note though that system level buffering is
12659 explicitly enabled at elaboration of the standard I/O packages and that can
12660 have an impact on mixed language programs, in particular those using I/O before
12661 calling the Ada elaboration routine (e.g.@: adainit). It is recommended to call
12662 the Ada elaboration routine before performing any I/O or when impractical,
12663 flush the common I/O streams and in particular Standard_Output before
12664 elaborating the Ada code.
12665
12666 @node FORM Strings
12667 @section FORM Strings
12668
12669 @noindent
12670 The format of a FORM string in GNAT is:
12671
12672 @smallexample
12673 "keyword=value,keyword=value,@dots{},keyword=value"
12674 @end smallexample
12675
12676 @noindent
12677 where letters may be in upper or lower case, and there are no spaces
12678 between values.  The order of the entries is not important.  Currently
12679 the following keywords defined.
12680
12681 @smallexample
12682 TEXT_TRANSLATION=[YES|NO]
12683 SHARED=[YES|NO]
12684 WCEM=[n|h|u|s|e|8|b]
12685 ENCODING=[UTF8|8BITS]
12686 @end smallexample
12687
12688 @noindent
12689 The use of these parameters is described later in this section.
12690
12691 @node Direct_IO
12692 @section Direct_IO
12693
12694 @noindent
12695 Direct_IO can only be instantiated for definite types.  This is a
12696 restriction of the Ada language, which means that the records are fixed
12697 length (the length being determined by @code{@var{type}'Size}, rounded
12698 up to the next storage unit boundary if necessary).
12699
12700 The records of a Direct_IO file are simply written to the file in index
12701 sequence, with the first record starting at offset zero, and subsequent
12702 records following.  There is no control information of any kind.  For
12703 example, if 32-bit integers are being written, each record takes
12704 4-bytes, so the record at index @var{K} starts at offset
12705 (@var{K}@minus{}1)*4.
12706
12707 There is no limit on the size of Direct_IO files, they are expanded as
12708 necessary to accommodate whatever records are written to the file.
12709
12710 @node Sequential_IO
12711 @section Sequential_IO
12712
12713 @noindent
12714 Sequential_IO may be instantiated with either a definite (constrained)
12715 or indefinite (unconstrained) type.
12716
12717 For the definite type case, the elements written to the file are simply
12718 the memory images of the data values with no control information of any
12719 kind.  The resulting file should be read using the same type, no validity
12720 checking is performed on input.
12721
12722 For the indefinite type case, the elements written consist of two
12723 parts.  First is the size of the data item, written as the memory image
12724 of a @code{Interfaces.C.size_t} value, followed by the memory image of
12725 the data value.  The resulting file can only be read using the same
12726 (unconstrained) type.  Normal assignment checks are performed on these
12727 read operations, and if these checks fail, @code{Data_Error} is
12728 raised.  In particular, in the array case, the lengths must match, and in
12729 the variant record case, if the variable for a particular read operation
12730 is constrained, the discriminants must match.
12731
12732 Note that it is not possible to use Sequential_IO to write variable
12733 length array items, and then read the data back into different length
12734 arrays.  For example, the following will raise @code{Data_Error}:
12735
12736 @smallexample @c ada
12737  package IO is new Sequential_IO (String);
12738  F : IO.File_Type;
12739  S : String (1..4);
12740  @dots{}
12741  IO.Create (F)
12742  IO.Write (F, "hello!")
12743  IO.Reset (F, Mode=>In_File);
12744  IO.Read (F, S);
12745  Put_Line (S);
12746
12747 @end smallexample
12748
12749 @noindent
12750 On some Ada implementations, this will print @code{hell}, but the program is
12751 clearly incorrect, since there is only one element in the file, and that
12752 element is the string @code{hello!}.
12753
12754 In Ada 95 and Ada 2005, this kind of behavior can be legitimately achieved
12755 using Stream_IO, and this is the preferred mechanism.  In particular, the
12756 above program fragment rewritten to use Stream_IO will work correctly.
12757
12758 @node Text_IO
12759 @section Text_IO
12760
12761 @noindent
12762 Text_IO files consist of a stream of characters containing the following
12763 special control characters:
12764
12765 @smallexample
12766 LF (line feed, 16#0A#) Line Mark
12767 FF (form feed, 16#0C#) Page Mark
12768 @end smallexample
12769
12770 @noindent
12771 A canonical Text_IO file is defined as one in which the following
12772 conditions are met:
12773
12774 @itemize @bullet
12775 @item
12776 The character @code{LF} is used only as a line mark, i.e.@: to mark the end
12777 of the line.
12778
12779 @item
12780 The character @code{FF} is used only as a page mark, i.e.@: to mark the
12781 end of a page and consequently can appear only immediately following a
12782 @code{LF} (line mark) character.
12783
12784 @item
12785 The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
12786 (line mark, page mark).  In the former case, the page mark is implicitly
12787 assumed to be present.
12788 @end itemize
12789
12790 @noindent
12791 A file written using Text_IO will be in canonical form provided that no
12792 explicit @code{LF} or @code{FF} characters are written using @code{Put}
12793 or @code{Put_Line}.  There will be no @code{FF} character at the end of
12794 the file unless an explicit @code{New_Page} operation was performed
12795 before closing the file.
12796
12797 A canonical Text_IO file that is a regular file (i.e., not a device or a
12798 pipe) can be read using any of the routines in Text_IO@.  The
12799 semantics in this case will be exactly as defined in the Ada Reference
12800 Manual, and all the routines in Text_IO are fully implemented.
12801
12802 A text file that does not meet the requirements for a canonical Text_IO
12803 file has one of the following:
12804
12805 @itemize @bullet
12806 @item
12807 The file contains @code{FF} characters not immediately following a
12808 @code{LF} character.
12809
12810 @item
12811 The file contains @code{LF} or @code{FF} characters written by
12812 @code{Put} or @code{Put_Line}, which are not logically considered to be
12813 line marks or page marks.
12814
12815 @item
12816 The file ends in a character other than @code{LF} or @code{FF},
12817 i.e.@: there is no explicit line mark or page mark at the end of the file.
12818 @end itemize
12819
12820 @noindent
12821 Text_IO can be used to read such non-standard text files but subprograms
12822 to do with line or page numbers do not have defined meanings.  In
12823 particular, a @code{FF} character that does not follow a @code{LF}
12824 character may or may not be treated as a page mark from the point of
12825 view of page and line numbering.  Every @code{LF} character is considered
12826 to end a line, and there is an implied @code{LF} character at the end of
12827 the file.
12828
12829 @menu
12830 * Text_IO Stream Pointer Positioning::
12831 * Text_IO Reading and Writing Non-Regular Files::
12832 * Get_Immediate::
12833 * Treating Text_IO Files as Streams::
12834 * Text_IO Extensions::
12835 * Text_IO Facilities for Unbounded Strings::
12836 @end menu
12837
12838 @node Text_IO Stream Pointer Positioning
12839 @subsection Stream Pointer Positioning
12840
12841 @noindent
12842 @code{Ada.Text_IO} has a definition of current position for a file that
12843 is being read.  No internal buffering occurs in Text_IO, and usually the
12844 physical position in the stream used to implement the file corresponds
12845 to this logical position defined by Text_IO@.  There are two exceptions:
12846
12847 @itemize @bullet
12848 @item
12849 After a call to @code{End_Of_Page} that returns @code{True}, the stream
12850 is positioned past the @code{LF} (line mark) that precedes the page
12851 mark.  Text_IO maintains an internal flag so that subsequent read
12852 operations properly handle the logical position which is unchanged by
12853 the @code{End_Of_Page} call.
12854
12855 @item
12856 After a call to @code{End_Of_File} that returns @code{True}, if the
12857 Text_IO file was positioned before the line mark at the end of file
12858 before the call, then the logical position is unchanged, but the stream
12859 is physically positioned right at the end of file (past the line mark,
12860 and past a possible page mark following the line mark.  Again Text_IO
12861 maintains internal flags so that subsequent read operations properly
12862 handle the logical position.
12863 @end itemize
12864
12865 @noindent
12866 These discrepancies have no effect on the observable behavior of
12867 Text_IO, but if a single Ada stream is shared between a C program and
12868 Ada program, or shared (using @samp{shared=yes} in the form string)
12869 between two Ada files, then the difference may be observable in some
12870 situations.
12871
12872 @node Text_IO Reading and Writing Non-Regular Files
12873 @subsection Reading and Writing Non-Regular Files
12874
12875 @noindent
12876 A non-regular file is a device (such as a keyboard), or a pipe.  Text_IO
12877 can be used for reading and writing.  Writing is not affected and the
12878 sequence of characters output is identical to the normal file case, but
12879 for reading, the behavior of Text_IO is modified to avoid undesirable
12880 look-ahead as follows:
12881
12882 An input file that is not a regular file is considered to have no page
12883 marks.  Any @code{Ascii.FF} characters (the character normally used for a
12884 page mark) appearing in the file are considered to be data
12885 characters.  In particular:
12886
12887 @itemize @bullet
12888 @item
12889 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
12890 following a line mark.  If a page mark appears, it will be treated as a
12891 data character.
12892
12893 @item
12894 This avoids the need to wait for an extra character to be typed or
12895 entered from the pipe to complete one of these operations.
12896
12897 @item
12898 @code{End_Of_Page} always returns @code{False}
12899
12900 @item
12901 @code{End_Of_File} will return @code{False} if there is a page mark at
12902 the end of the file.
12903 @end itemize
12904
12905 @noindent
12906 Output to non-regular files is the same as for regular files.  Page marks
12907 may be written to non-regular files using @code{New_Page}, but as noted
12908 above they will not be treated as page marks on input if the output is
12909 piped to another Ada program.
12910
12911 Another important discrepancy when reading non-regular files is that the end
12912 of file indication is not ``sticky''.  If an end of file is entered, e.g.@: by
12913 pressing the @key{EOT} key,
12914 then end of file
12915 is signaled once (i.e.@: the test @code{End_Of_File}
12916 will yield @code{True}, or a read will
12917 raise @code{End_Error}), but then reading can resume
12918 to read data past that end of
12919 file indication, until another end of file indication is entered.
12920
12921 @node Get_Immediate
12922 @subsection Get_Immediate
12923 @cindex Get_Immediate
12924
12925 @noindent
12926 Get_Immediate returns the next character (including control characters)
12927 from the input file.  In particular, Get_Immediate will return LF or FF
12928 characters used as line marks or page marks.  Such operations leave the
12929 file positioned past the control character, and it is thus not treated
12930 as having its normal function.  This means that page, line and column
12931 counts after this kind of Get_Immediate call are set as though the mark
12932 did not occur.  In the case where a Get_Immediate leaves the file
12933 positioned between the line mark and page mark (which is not normally
12934 possible), it is undefined whether the FF character will be treated as a
12935 page mark.
12936
12937 @node Treating Text_IO Files as Streams
12938 @subsection Treating Text_IO Files as Streams
12939 @cindex Stream files
12940
12941 @noindent
12942 The package @code{Text_IO.Streams} allows a Text_IO file to be treated
12943 as a stream.  Data written to a Text_IO file in this stream mode is
12944 binary data.  If this binary data contains bytes 16#0A# (@code{LF}) or
12945 16#0C# (@code{FF}), the resulting file may have non-standard
12946 format.  Similarly if read operations are used to read from a Text_IO
12947 file treated as a stream, then @code{LF} and @code{FF} characters may be
12948 skipped and the effect is similar to that described above for
12949 @code{Get_Immediate}.
12950
12951 @node Text_IO Extensions
12952 @subsection Text_IO Extensions
12953 @cindex Text_IO extensions
12954
12955 @noindent
12956 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
12957 to the standard @code{Text_IO} package:
12958
12959 @itemize @bullet
12960 @item function File_Exists (Name : String) return Boolean;
12961 Determines if a file of the given name exists.
12962
12963 @item function Get_Line return String;
12964 Reads a string from the standard input file.  The value returned is exactly
12965 the length of the line that was read.
12966
12967 @item function Get_Line (File : Ada.Text_IO.File_Type) return String;
12968 Similar, except that the parameter File specifies the file from which
12969 the string is to be read.
12970
12971 @end itemize
12972
12973 @node Text_IO Facilities for Unbounded Strings
12974 @subsection Text_IO Facilities for Unbounded Strings
12975 @cindex Text_IO for unbounded strings
12976 @cindex Unbounded_String, Text_IO operations
12977
12978 @noindent
12979 The package @code{Ada.Strings.Unbounded.Text_IO}
12980 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
12981 subprograms useful for Text_IO operations on unbounded strings:
12982
12983 @itemize @bullet
12984
12985 @item function Get_Line (File : File_Type) return Unbounded_String;
12986 Reads a line from the specified file
12987 and returns the result as an unbounded string.
12988
12989 @item procedure Put (File : File_Type; U : Unbounded_String);
12990 Writes the value of the given unbounded string to the specified file
12991 Similar to the effect of
12992 @code{Put (To_String (U))} except that an extra copy is avoided.
12993
12994 @item procedure Put_Line (File : File_Type; U : Unbounded_String);
12995 Writes the value of the given unbounded string to the specified file,
12996 followed by a @code{New_Line}.
12997 Similar to the effect of @code{Put_Line (To_String (U))} except
12998 that an extra copy is avoided.
12999 @end itemize
13000
13001 @noindent
13002 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
13003 and is optional.  If the parameter is omitted, then the standard input or
13004 output file is referenced as appropriate.
13005
13006 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
13007 files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended
13008 @code{Wide_Text_IO} functionality for unbounded wide strings.
13009
13010 The package @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} in library
13011 files @file{a-szuzti.ads} and @file{a-szuzti.adb} provides similar extended
13012 @code{Wide_Wide_Text_IO} functionality for unbounded wide wide strings.
13013
13014 @node Wide_Text_IO
13015 @section Wide_Text_IO
13016
13017 @noindent
13018 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
13019 both input and output files may contain special sequences that represent
13020 wide character values.  The encoding scheme for a given file may be
13021 specified using a FORM parameter:
13022
13023 @smallexample
13024 WCEM=@var{x}
13025 @end smallexample
13026
13027 @noindent
13028 as part of the FORM string (WCEM = wide character encoding method),
13029 where @var{x} is one of the following characters
13030
13031 @table @samp
13032 @item h
13033 Hex ESC encoding
13034 @item u
13035 Upper half encoding
13036 @item s
13037 Shift-JIS encoding
13038 @item e
13039 EUC Encoding
13040 @item 8
13041 UTF-8 encoding
13042 @item b
13043 Brackets encoding
13044 @end table
13045
13046 @noindent
13047 The encoding methods match those that
13048 can be used in a source
13049 program, but there is no requirement that the encoding method used for
13050 the source program be the same as the encoding method used for files,
13051 and different files may use different encoding methods.
13052
13053 The default encoding method for the standard files, and for opened files
13054 for which no WCEM parameter is given in the FORM string matches the
13055 wide character encoding specified for the main program (the default
13056 being brackets encoding if no coding method was specified with -gnatW).
13057
13058 @table @asis
13059 @item Hex Coding
13060 In this encoding, a wide character is represented by a five character
13061 sequence:
13062
13063 @smallexample
13064 ESC a b c d
13065 @end smallexample
13066
13067 @noindent
13068 where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
13069 characters (using upper case letters) of the wide character code.  For
13070 example, ESC A345 is used to represent the wide character with code
13071 16#A345#.  This scheme is compatible with use of the full
13072 @code{Wide_Character} set.
13073
13074 @item Upper Half Coding
13075 The wide character with encoding 16#abcd#, where the upper bit is on
13076 (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
13077 16#cd#.  The second byte may never be a format control character, but is
13078 not required to be in the upper half.  This method can be also used for
13079 shift-JIS or EUC where the internal coding matches the external coding.
13080
13081 @item Shift JIS Coding
13082 A wide character is represented by a two character sequence 16#ab# and
13083 16#cd#, with the restrictions described for upper half encoding as
13084 described above.  The internal character code is the corresponding JIS
13085 character according to the standard algorithm for Shift-JIS
13086 conversion.  Only characters defined in the JIS code set table can be
13087 used with this encoding method.
13088
13089 @item EUC Coding
13090 A wide character is represented by a two character sequence 16#ab# and
13091 16#cd#, with both characters being in the upper half.  The internal
13092 character code is the corresponding JIS character according to the EUC
13093 encoding algorithm.  Only characters defined in the JIS code set table
13094 can be used with this encoding method.
13095
13096 @item UTF-8 Coding
13097 A wide character is represented using
13098 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
13099 10646-1/Am.2.  Depending on the character value, the representation
13100 is a one, two, or three byte sequence:
13101
13102 @smallexample
13103 16#0000#-16#007f#: 2#0xxxxxxx#
13104 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
13105 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
13106 @end smallexample
13107
13108 @noindent
13109 where the @var{xxx} bits correspond to the left-padded bits of the
13110 16-bit character value.  Note that all lower half ASCII characters
13111 are represented as ASCII bytes and all upper half characters and
13112 other wide characters are represented as sequences of upper-half
13113 (The full UTF-8 scheme allows for encoding 31-bit characters as
13114 6-byte sequences, but in this implementation, all UTF-8 sequences
13115 of four or more bytes length will raise a Constraint_Error, as
13116 will all invalid UTF-8 sequences.)
13117
13118 @item Brackets Coding
13119 In this encoding, a wide character is represented by the following eight
13120 character sequence:
13121
13122 @smallexample
13123 [ " a b c d " ]
13124 @end smallexample
13125
13126 @noindent
13127 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
13128 characters (using uppercase letters) of the wide character code.  For
13129 example, @code{["A345"]} is used to represent the wide character with code
13130 @code{16#A345#}.
13131 This scheme is compatible with use of the full Wide_Character set.
13132 On input, brackets coding can also be used for upper half characters,
13133 e.g.@: @code{["C1"]} for lower case a.  However, on output, brackets notation
13134 is only used for wide characters with a code greater than @code{16#FF#}.
13135
13136 Note that brackets coding is not normally used in the context of
13137 Wide_Text_IO or Wide_Wide_Text_IO, since it is really just designed as
13138 a portable way of encoding source files. In the context of Wide_Text_IO
13139 or Wide_Wide_Text_IO, it can only be used if the file does not contain
13140 any instance of the left bracket character other than to encode wide
13141 character values using the brackets encoding method. In practice it is
13142 expected that some standard wide character encoding method such
13143 as UTF-8 will be used for text input output.
13144
13145 If brackets notation is used, then any occurrence of a left bracket
13146 in the input file which is not the start of a valid wide character
13147 sequence will cause Constraint_Error to be raised. It is possible to
13148 encode a left bracket as ["5B"] and Wide_Text_IO and Wide_Wide_Text_IO
13149 input will interpret this as a left bracket.
13150
13151 However, when a left bracket is output, it will be output as a left bracket
13152 and not as ["5B"]. We make this decision because for normal use of
13153 Wide_Text_IO for outputting messages, it is unpleasant to clobber left
13154 brackets. For example, if we write:
13155
13156 @smallexample
13157    Put_Line ("Start of output [first run]");
13158 @end smallexample
13159
13160 @noindent
13161 we really do not want to have the left bracket in this message clobbered so
13162 that the output reads:
13163
13164 @smallexample
13165    Start of output ["5B"]first run]
13166 @end smallexample
13167
13168 @noindent
13169 In practice brackets encoding is reasonably useful for normal Put_Line use
13170 since we won't get confused between left brackets and wide character
13171 sequences in the output. But for input, or when files are written out
13172 and read back in, it really makes better sense to use one of the standard
13173 encoding methods such as UTF-8.
13174
13175 @end table
13176
13177 @noindent
13178 For the coding schemes other than UTF-8, Hex, or Brackets encoding,
13179 not all wide character
13180 values can be represented.  An attempt to output a character that cannot
13181 be represented using the encoding scheme for the file causes
13182 Constraint_Error to be raised.  An invalid wide character sequence on
13183 input also causes Constraint_Error to be raised.
13184
13185 @menu
13186 * Wide_Text_IO Stream Pointer Positioning::
13187 * Wide_Text_IO Reading and Writing Non-Regular Files::
13188 @end menu
13189
13190 @node Wide_Text_IO Stream Pointer Positioning
13191 @subsection Stream Pointer Positioning
13192
13193 @noindent
13194 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
13195 of stream pointer positioning (@pxref{Text_IO}).  There is one additional
13196 case:
13197
13198 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
13199 normal lower ASCII set (i.e.@: a character in the range:
13200
13201 @smallexample @c ada
13202 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
13203 @end smallexample
13204
13205 @noindent
13206 then although the logical position of the file pointer is unchanged by
13207 the @code{Look_Ahead} call, the stream is physically positioned past the
13208 wide character sequence.  Again this is to avoid the need for buffering
13209 or backup, and all @code{Wide_Text_IO} routines check the internal
13210 indication that this situation has occurred so that this is not visible
13211 to a normal program using @code{Wide_Text_IO}.  However, this discrepancy
13212 can be observed if the wide text file shares a stream with another file.
13213
13214 @node Wide_Text_IO Reading and Writing Non-Regular Files
13215 @subsection Reading and Writing Non-Regular Files
13216
13217 @noindent
13218 As in the case of Text_IO, when a non-regular file is read, it is
13219 assumed that the file contains no page marks (any form characters are
13220 treated as data characters), and @code{End_Of_Page} always returns
13221 @code{False}.  Similarly, the end of file indication is not sticky, so
13222 it is possible to read beyond an end of file.
13223
13224 @node Wide_Wide_Text_IO
13225 @section Wide_Wide_Text_IO
13226
13227 @noindent
13228 @code{Wide_Wide_Text_IO} is similar in most respects to Text_IO, except that
13229 both input and output files may contain special sequences that represent
13230 wide wide character values.  The encoding scheme for a given file may be
13231 specified using a FORM parameter:
13232
13233 @smallexample
13234 WCEM=@var{x}
13235 @end smallexample
13236
13237 @noindent
13238 as part of the FORM string (WCEM = wide character encoding method),
13239 where @var{x} is one of the following characters
13240
13241 @table @samp
13242 @item h
13243 Hex ESC encoding
13244 @item u
13245 Upper half encoding
13246 @item s
13247 Shift-JIS encoding
13248 @item e
13249 EUC Encoding
13250 @item 8
13251 UTF-8 encoding
13252 @item b
13253 Brackets encoding
13254 @end table
13255
13256 @noindent
13257 The encoding methods match those that
13258 can be used in a source
13259 program, but there is no requirement that the encoding method used for
13260 the source program be the same as the encoding method used for files,
13261 and different files may use different encoding methods.
13262
13263 The default encoding method for the standard files, and for opened files
13264 for which no WCEM parameter is given in the FORM string matches the
13265 wide character encoding specified for the main program (the default
13266 being brackets encoding if no coding method was specified with -gnatW).
13267
13268 @table @asis
13269
13270 @item UTF-8 Coding
13271 A wide character is represented using
13272 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
13273 10646-1/Am.2.  Depending on the character value, the representation
13274 is a one, two, three, or four byte sequence:
13275
13276 @smallexample
13277 16#000000#-16#00007f#: 2#0xxxxxxx#
13278 16#000080#-16#0007ff#: 2#110xxxxx# 2#10xxxxxx#
13279 16#000800#-16#00ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
13280 16#010000#-16#10ffff#: 2#11110xxx# 2#10xxxxxx# 2#10xxxxxx# 2#10xxxxxx#
13281 @end smallexample
13282
13283 @noindent
13284 where the @var{xxx} bits correspond to the left-padded bits of the
13285 21-bit character value.  Note that all lower half ASCII characters
13286 are represented as ASCII bytes and all upper half characters and
13287 other wide characters are represented as sequences of upper-half
13288 characters.
13289
13290 @item Brackets Coding
13291 In this encoding, a wide wide character is represented by the following eight
13292 character sequence if is in wide character range
13293
13294 @smallexample
13295 [ " a b c d " ]
13296 @end smallexample
13297
13298 and by the following ten character sequence if not
13299
13300 @smallexample
13301 [ " a b c d e f " ]
13302 @end smallexample
13303
13304 @noindent
13305 where @code{a}, @code{b}, @code{c}, @code{d}, @code{e}, and @code{f}
13306 are the four or six hexadecimal
13307 characters (using uppercase letters) of the wide wide character code.  For
13308 example, @code{["01A345"]} is used to represent the wide wide character
13309 with code @code{16#01A345#}.
13310
13311 This scheme is compatible with use of the full Wide_Wide_Character set.
13312 On input, brackets coding can also be used for upper half characters,
13313 e.g.@: @code{["C1"]} for lower case a.  However, on output, brackets notation
13314 is only used for wide characters with a code greater than @code{16#FF#}.
13315
13316 @end table
13317
13318 @noindent
13319 If is also possible to use the other Wide_Character encoding methods,
13320 such as Shift-JIS, but the other schemes cannot support the full range
13321 of wide wide characters.
13322 An attempt to output a character that cannot
13323 be represented using the encoding scheme for the file causes
13324 Constraint_Error to be raised.  An invalid wide character sequence on
13325 input also causes Constraint_Error to be raised.
13326
13327 @menu
13328 * Wide_Wide_Text_IO Stream Pointer Positioning::
13329 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
13330 @end menu
13331
13332 @node Wide_Wide_Text_IO Stream Pointer Positioning
13333 @subsection Stream Pointer Positioning
13334
13335 @noindent
13336 @code{Ada.Wide_Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
13337 of stream pointer positioning (@pxref{Text_IO}).  There is one additional
13338 case:
13339
13340 If @code{Ada.Wide_Wide_Text_IO.Look_Ahead} reads a character outside the
13341 normal lower ASCII set (i.e.@: a character in the range:
13342
13343 @smallexample @c ada
13344 Wide_Wide_Character'Val (16#0080#) .. Wide_Wide_Character'Val (16#10FFFF#)
13345 @end smallexample
13346
13347 @noindent
13348 then although the logical position of the file pointer is unchanged by
13349 the @code{Look_Ahead} call, the stream is physically positioned past the
13350 wide character sequence.  Again this is to avoid the need for buffering
13351 or backup, and all @code{Wide_Wide_Text_IO} routines check the internal
13352 indication that this situation has occurred so that this is not visible
13353 to a normal program using @code{Wide_Wide_Text_IO}.  However, this discrepancy
13354 can be observed if the wide text file shares a stream with another file.
13355
13356 @node Wide_Wide_Text_IO Reading and Writing Non-Regular Files
13357 @subsection Reading and Writing Non-Regular Files
13358
13359 @noindent
13360 As in the case of Text_IO, when a non-regular file is read, it is
13361 assumed that the file contains no page marks (any form characters are
13362 treated as data characters), and @code{End_Of_Page} always returns
13363 @code{False}.  Similarly, the end of file indication is not sticky, so
13364 it is possible to read beyond an end of file.
13365
13366 @node Stream_IO
13367 @section Stream_IO
13368
13369 @noindent
13370 A stream file is a sequence of bytes, where individual elements are
13371 written to the file as described in the Ada Reference Manual.  The type
13372 @code{Stream_Element} is simply a byte.  There are two ways to read or
13373 write a stream file.
13374
13375 @itemize @bullet
13376 @item
13377 The operations @code{Read} and @code{Write} directly read or write a
13378 sequence of stream elements with no control information.
13379
13380 @item
13381 The stream attributes applied to a stream file transfer data in the
13382 manner described for stream attributes.
13383 @end itemize
13384
13385 @node Text Translation
13386 @section Text Translation
13387
13388 @noindent
13389 @samp{Text_Translation=@var{xxx}} may be used as the Form parameter
13390 passed to Text_IO.Create and Text_IO.Open:
13391 @samp{Text_Translation=@var{Yes}} is the default, which means to
13392 translate LF to/from CR/LF on Windows systems.
13393 @samp{Text_Translation=@var{No}} disables this translation; i.e. it
13394 uses binary mode. For output files, @samp{Text_Translation=@var{No}}
13395 may be used to create Unix-style files on
13396 Windows. @samp{Text_Translation=@var{xxx}} has no effect on Unix
13397 systems.
13398
13399 @node Shared Files
13400 @section Shared Files
13401
13402 @noindent
13403 Section A.14 of the Ada Reference Manual allows implementations to
13404 provide a wide variety of behavior if an attempt is made to access the
13405 same external file with two or more internal files.
13406
13407 To provide a full range of functionality, while at the same time
13408 minimizing the problems of portability caused by this implementation
13409 dependence, GNAT handles file sharing as follows:
13410
13411 @itemize @bullet
13412 @item
13413 In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
13414 to open two or more files with the same full name is considered an error
13415 and is not supported.  The exception @code{Use_Error} will be
13416 raised.  Note that a file that is not explicitly closed by the program
13417 remains open until the program terminates.
13418
13419 @item
13420 If the form parameter @samp{shared=no} appears in the form string, the
13421 file can be opened or created with its own separate stream identifier,
13422 regardless of whether other files sharing the same external file are
13423 opened.  The exact effect depends on how the C stream routines handle
13424 multiple accesses to the same external files using separate streams.
13425
13426 @item
13427 If the form parameter @samp{shared=yes} appears in the form string for
13428 each of two or more files opened using the same full name, the same
13429 stream is shared between these files, and the semantics are as described
13430 in Ada Reference Manual, Section A.14.
13431 @end itemize
13432
13433 @noindent
13434 When a program that opens multiple files with the same name is ported
13435 from another Ada compiler to GNAT, the effect will be that
13436 @code{Use_Error} is raised.
13437
13438 The documentation of the original compiler and the documentation of the
13439 program should then be examined to determine if file sharing was
13440 expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
13441 and @code{Create} calls as required.
13442
13443 When a program is ported from GNAT to some other Ada compiler, no
13444 special attention is required unless the @samp{shared=@var{xxx}} form
13445 parameter is used in the program.  In this case, you must examine the
13446 documentation of the new compiler to see if it supports the required
13447 file sharing semantics, and form strings modified appropriately.  Of
13448 course it may be the case that the program cannot be ported if the
13449 target compiler does not support the required functionality.  The best
13450 approach in writing portable code is to avoid file sharing (and hence
13451 the use of the @samp{shared=@var{xxx}} parameter in the form string)
13452 completely.
13453
13454 One common use of file sharing in Ada 83 is the use of instantiations of
13455 Sequential_IO on the same file with different types, to achieve
13456 heterogeneous input-output.  Although this approach will work in GNAT if
13457 @samp{shared=yes} is specified, it is preferable in Ada to use Stream_IO
13458 for this purpose (using the stream attributes)
13459
13460 @node Filenames encoding
13461 @section Filenames encoding
13462
13463 @noindent
13464 An encoding form parameter can be used to specify the filename
13465 encoding @samp{encoding=@var{xxx}}.
13466
13467 @itemize @bullet
13468 @item
13469 If the form parameter @samp{encoding=utf8} appears in the form string, the
13470 filename must be encoded in UTF-8.
13471
13472 @item
13473 If the form parameter @samp{encoding=8bits} appears in the form
13474 string, the filename must be a standard 8bits string.
13475 @end itemize
13476
13477 In the absence of a @samp{encoding=@var{xxx}} form parameter, the
13478 encoding is controlled by the @samp{GNAT_CODE_PAGE} environment
13479 variable. And if not set @samp{utf8} is assumed.
13480
13481 @table @samp
13482 @item CP_ACP
13483 The current system Windows ANSI code page.
13484 @item CP_UTF8
13485 UTF-8 encoding
13486 @end table
13487
13488 This encoding form parameter is only supported on the Windows
13489 platform. On the other Operating Systems the run-time is supporting
13490 UTF-8 natively.
13491
13492 @node Open Modes
13493 @section Open Modes
13494
13495 @noindent
13496 @code{Open} and @code{Create} calls result in a call to @code{fopen}
13497 using the mode shown in the following table:
13498
13499 @sp 2
13500 @center @code{Open} and @code{Create} Call Modes
13501 @smallexample
13502                                @b{OPEN }           @b{CREATE}
13503 Append_File                    "r+"             "w+"
13504 In_File                        "r"              "w+"
13505 Out_File (Direct_IO)           "r+"             "w"
13506 Out_File (all other cases)     "w"              "w"
13507 Inout_File                     "r+"             "w+"
13508 @end smallexample
13509
13510 @noindent
13511 If text file translation is required, then either @samp{b} or @samp{t}
13512 is added to the mode, depending on the setting of Text.  Text file
13513 translation refers to the mapping of CR/LF sequences in an external file
13514 to LF characters internally.  This mapping only occurs in DOS and
13515 DOS-like systems, and is not relevant to other systems.
13516
13517 A special case occurs with Stream_IO@.  As shown in the above table, the
13518 file is initially opened in @samp{r} or @samp{w} mode for the
13519 @code{In_File} and @code{Out_File} cases.  If a @code{Set_Mode} operation
13520 subsequently requires switching from reading to writing or vice-versa,
13521 then the file is reopened in @samp{r+} mode to permit the required operation.
13522
13523 @node Operations on C Streams
13524 @section Operations on C Streams
13525 The package @code{Interfaces.C_Streams} provides an Ada program with direct
13526 access to the C library functions for operations on C streams:
13527
13528 @smallexample @c adanocomment
13529 package Interfaces.C_Streams is
13530   -- Note: the reason we do not use the types that are in
13531   -- Interfaces.C is that we want to avoid dragging in the
13532   -- code in this unit if possible.
13533   subtype chars is System.Address;
13534   -- Pointer to null-terminated array of characters
13535   subtype FILEs is System.Address;
13536   -- Corresponds to the C type FILE*
13537   subtype voids is System.Address;
13538   -- Corresponds to the C type void*
13539   subtype int is Integer;
13540   subtype long is Long_Integer;
13541   -- Note: the above types are subtypes deliberately, and it
13542   -- is part of this spec that the above correspondences are
13543   -- guaranteed.  This means that it is legitimate to, for
13544   -- example, use Integer instead of int.  We provide these
13545   -- synonyms for clarity, but in some cases it may be
13546   -- convenient to use the underlying types (for example to
13547   -- avoid an unnecessary dependency of a spec on the spec
13548   -- of this unit).
13549   type size_t is mod 2 ** Standard'Address_Size;
13550   NULL_Stream : constant FILEs;
13551   -- Value returned (NULL in C) to indicate an
13552   -- fdopen/fopen/tmpfile error
13553   ----------------------------------
13554   -- Constants Defined in stdio.h --
13555   ----------------------------------
13556   EOF : constant int;
13557   -- Used by a number of routines to indicate error or
13558   -- end of file
13559   IOFBF : constant int;
13560   IOLBF : constant int;
13561   IONBF : constant int;
13562   -- Used to indicate buffering mode for setvbuf call
13563   SEEK_CUR : constant int;
13564   SEEK_END : constant int;
13565   SEEK_SET : constant int;
13566   -- Used to indicate origin for fseek call
13567   function stdin return FILEs;
13568   function stdout return FILEs;
13569   function stderr return FILEs;
13570   -- Streams associated with standard files
13571   --------------------------
13572   -- Standard C functions --
13573   --------------------------
13574   -- The functions selected below are ones that are
13575   -- available in UNIX (but not necessarily in ANSI C).
13576   -- These are very thin interfaces
13577   -- which copy exactly the C headers.  For more
13578   -- documentation on these functions, see the Microsoft C
13579   -- "Run-Time Library Reference" (Microsoft Press, 1990,
13580   -- ISBN 1-55615-225-6), which includes useful information
13581   -- on system compatibility.
13582   procedure clearerr (stream : FILEs);
13583   function fclose (stream : FILEs) return int;
13584   function fdopen (handle : int; mode : chars) return FILEs;
13585   function feof (stream : FILEs) return int;
13586   function ferror (stream : FILEs) return int;
13587   function fflush (stream : FILEs) return int;
13588   function fgetc (stream : FILEs) return int;
13589   function fgets (strng : chars; n : int; stream : FILEs)
13590       return chars;
13591   function fileno (stream : FILEs) return int;
13592   function fopen (filename : chars; Mode : chars)
13593       return FILEs;
13594   -- Note: to maintain target independence, use
13595   -- text_translation_required, a boolean variable defined in
13596   -- a-sysdep.c to deal with the target dependent text
13597   -- translation requirement.  If this variable is set,
13598   -- then  b/t should be appended to the standard mode
13599   -- argument to set the text translation mode off or on
13600   -- as required.
13601   function fputc (C : int; stream : FILEs) return int;
13602   function fputs (Strng : chars; Stream : FILEs) return int;
13603   function fread
13604      (buffer : voids;
13605       size : size_t;
13606       count : size_t;
13607       stream : FILEs)
13608       return size_t;
13609   function freopen
13610      (filename : chars;
13611       mode : chars;
13612       stream : FILEs)
13613       return FILEs;
13614   function fseek
13615      (stream : FILEs;
13616       offset : long;
13617       origin : int)
13618       return int;
13619   function ftell (stream : FILEs) return long;
13620   function fwrite
13621      (buffer : voids;
13622       size : size_t;
13623       count : size_t;
13624       stream : FILEs)
13625       return size_t;
13626   function isatty (handle : int) return int;
13627   procedure mktemp (template : chars);
13628   -- The return value (which is just a pointer to template)
13629   -- is discarded
13630   procedure rewind (stream : FILEs);
13631   function rmtmp return int;
13632   function setvbuf
13633      (stream : FILEs;
13634       buffer : chars;
13635       mode : int;
13636       size : size_t)
13637       return int;
13638
13639   function tmpfile return FILEs;
13640   function ungetc (c : int; stream : FILEs) return int;
13641   function unlink (filename : chars) return int;
13642   ---------------------
13643   -- Extra functions --
13644   ---------------------
13645   -- These functions supply slightly thicker bindings than
13646   -- those above.  They are derived from functions in the
13647   -- C Run-Time Library, but may do a bit more work than
13648   -- just directly calling one of the Library functions.
13649   function is_regular_file (handle : int) return int;
13650   -- Tests if given handle is for a regular file (result 1)
13651   -- or for a non-regular file (pipe or device, result 0).
13652   ---------------------------------
13653   -- Control of Text/Binary Mode --
13654   ---------------------------------
13655   -- If text_translation_required is true, then the following
13656   -- functions may be used to dynamically switch a file from
13657   -- binary to text mode or vice versa.  These functions have
13658   -- no effect if text_translation_required is false (i.e.@: in
13659   -- normal UNIX mode).  Use fileno to get a stream handle.
13660   procedure set_binary_mode (handle : int);
13661   procedure set_text_mode (handle : int);
13662   ----------------------------
13663   -- Full Path Name support --
13664   ----------------------------
13665   procedure full_name (nam : chars; buffer : chars);
13666   -- Given a NUL terminated string representing a file
13667   -- name, returns in buffer a NUL terminated string
13668   -- representing the full path name for the file name.
13669   -- On systems where it is relevant the   drive is also
13670   -- part of the full path name.  It is the responsibility
13671   -- of the caller to pass an actual parameter for buffer
13672   -- that is big enough for any full path name.  Use
13673   -- max_path_len given below as the size of buffer.
13674   max_path_len : integer;
13675   -- Maximum length of an allowable full path name on the
13676   -- system, including a terminating NUL character.
13677 end Interfaces.C_Streams;
13678 @end smallexample
13679
13680 @node Interfacing to C Streams
13681 @section Interfacing to C Streams
13682
13683 @noindent
13684 The packages in this section permit interfacing Ada files to C Stream
13685 operations.
13686
13687 @smallexample @c ada
13688  with Interfaces.C_Streams;
13689  package Ada.Sequential_IO.C_Streams is
13690     function C_Stream (F : File_Type)
13691        return Interfaces.C_Streams.FILEs;
13692     procedure Open
13693       (File : in out File_Type;
13694        Mode : in File_Mode;
13695        C_Stream : in Interfaces.C_Streams.FILEs;
13696        Form : in String := "");
13697  end Ada.Sequential_IO.C_Streams;
13698
13699   with Interfaces.C_Streams;
13700   package Ada.Direct_IO.C_Streams is
13701      function C_Stream (F : File_Type)
13702         return Interfaces.C_Streams.FILEs;
13703      procedure Open
13704        (File : in out File_Type;
13705         Mode : in File_Mode;
13706         C_Stream : in Interfaces.C_Streams.FILEs;
13707         Form : in String := "");
13708   end Ada.Direct_IO.C_Streams;
13709
13710   with Interfaces.C_Streams;
13711   package Ada.Text_IO.C_Streams is
13712      function C_Stream (F : File_Type)
13713         return Interfaces.C_Streams.FILEs;
13714      procedure Open
13715        (File : in out File_Type;
13716         Mode : in File_Mode;
13717         C_Stream : in Interfaces.C_Streams.FILEs;
13718         Form : in String := "");
13719   end Ada.Text_IO.C_Streams;
13720
13721   with Interfaces.C_Streams;
13722   package Ada.Wide_Text_IO.C_Streams is
13723      function C_Stream (F : File_Type)
13724         return Interfaces.C_Streams.FILEs;
13725      procedure Open
13726        (File : in out File_Type;
13727         Mode : in File_Mode;
13728         C_Stream : in Interfaces.C_Streams.FILEs;
13729         Form : in String := "");
13730  end Ada.Wide_Text_IO.C_Streams;
13731
13732   with Interfaces.C_Streams;
13733   package Ada.Wide_Wide_Text_IO.C_Streams is
13734      function C_Stream (F : File_Type)
13735         return Interfaces.C_Streams.FILEs;
13736      procedure Open
13737        (File : in out File_Type;
13738         Mode : in File_Mode;
13739         C_Stream : in Interfaces.C_Streams.FILEs;
13740         Form : in String := "");
13741  end Ada.Wide_Wide_Text_IO.C_Streams;
13742
13743  with Interfaces.C_Streams;
13744  package Ada.Stream_IO.C_Streams is
13745     function C_Stream (F : File_Type)
13746        return Interfaces.C_Streams.FILEs;
13747     procedure Open
13748       (File : in out File_Type;
13749        Mode : in File_Mode;
13750        C_Stream : in Interfaces.C_Streams.FILEs;
13751        Form : in String := "");
13752  end Ada.Stream_IO.C_Streams;
13753 @end smallexample
13754
13755 @noindent
13756 In each of these six packages, the @code{C_Stream} function obtains the
13757 @code{FILE} pointer from a currently opened Ada file.  It is then
13758 possible to use the @code{Interfaces.C_Streams} package to operate on
13759 this stream, or the stream can be passed to a C program which can
13760 operate on it directly.  Of course the program is responsible for
13761 ensuring that only appropriate sequences of operations are executed.
13762
13763 One particular use of relevance to an Ada program is that the
13764 @code{setvbuf} function can be used to control the buffering of the
13765 stream used by an Ada file.  In the absence of such a call the standard
13766 default buffering is used.
13767
13768 The @code{Open} procedures in these packages open a file giving an
13769 existing C Stream instead of a file name.  Typically this stream is
13770 imported from a C program, allowing an Ada file to operate on an
13771 existing C file.
13772
13773 @node The GNAT Library
13774 @chapter The GNAT Library
13775
13776 @noindent
13777 The GNAT library contains a number of general and special purpose packages.
13778 It represents functionality that the GNAT developers have found useful, and
13779 which is made available to GNAT users.  The packages described here are fully
13780 supported, and upwards compatibility will be maintained in future releases,
13781 so you can use these facilities with the confidence that the same functionality
13782 will be available in future releases.
13783
13784 The chapter here simply gives a brief summary of the facilities available.
13785 The full documentation is found in the spec file for the package.  The full
13786 sources of these library packages, including both spec and body, are provided
13787 with all GNAT releases.  For example, to find out the full specifications of
13788 the SPITBOL pattern matching capability, including a full tutorial and
13789 extensive examples, look in the @file{g-spipat.ads} file in the library.
13790
13791 For each entry here, the package name (as it would appear in a @code{with}
13792 clause) is given, followed by the name of the corresponding spec file in
13793 parentheses.  The packages are children in four hierarchies, @code{Ada},
13794 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
13795 GNAT-specific hierarchy.
13796
13797 Note that an application program should only use packages in one of these
13798 four hierarchies if the package is defined in the Ada Reference Manual,
13799 or is listed in this section of the GNAT Programmers Reference Manual.
13800 All other units should be considered internal implementation units and
13801 should not be directly @code{with}'ed by application code.  The use of
13802 a @code{with} statement that references one of these internal implementation
13803 units makes an application potentially dependent on changes in versions
13804 of GNAT, and will generate a warning message.
13805
13806 @menu
13807 * Ada.Characters.Latin_9 (a-chlat9.ads)::
13808 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
13809 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
13810 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
13811 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
13812 * Ada.Command_Line.Environment (a-colien.ads)::
13813 * Ada.Command_Line.Remove (a-colire.ads)::
13814 * Ada.Command_Line.Response_File (a-clrefi.ads)::
13815 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
13816 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
13817 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
13818 * Ada.Exceptions.Traceback (a-exctra.ads)::
13819 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
13820 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
13821 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
13822 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
13823 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
13824 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
13825 * Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)::
13826 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
13827 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
13828 * Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)::
13829 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
13830 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
13831 * Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)::
13832 * GNAT.Altivec (g-altive.ads)::
13833 * GNAT.Altivec.Conversions (g-altcon.ads)::
13834 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
13835 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
13836 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
13837 * GNAT.Array_Split (g-arrspl.ads)::
13838 * GNAT.AWK (g-awk.ads)::
13839 * GNAT.Bounded_Buffers (g-boubuf.ads)::
13840 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
13841 * GNAT.Bubble_Sort (g-bubsor.ads)::
13842 * GNAT.Bubble_Sort_A (g-busora.ads)::
13843 * GNAT.Bubble_Sort_G (g-busorg.ads)::
13844 * GNAT.Byte_Order_Mark (g-byorma.ads)::
13845 * GNAT.Byte_Swapping (g-bytswa.ads)::
13846 * GNAT.Calendar (g-calend.ads)::
13847 * GNAT.Calendar.Time_IO (g-catiio.ads)::
13848 * GNAT.Case_Util (g-casuti.ads)::
13849 * GNAT.CGI (g-cgi.ads)::
13850 * GNAT.CGI.Cookie (g-cgicoo.ads)::
13851 * GNAT.CGI.Debug (g-cgideb.ads)::
13852 * GNAT.Command_Line (g-comlin.ads)::
13853 * GNAT.Compiler_Version (g-comver.ads)::
13854 * GNAT.Ctrl_C (g-ctrl_c.ads)::
13855 * GNAT.CRC32 (g-crc32.ads)::
13856 * GNAT.Current_Exception (g-curexc.ads)::
13857 * GNAT.Debug_Pools (g-debpoo.ads)::
13858 * GNAT.Debug_Utilities (g-debuti.ads)::
13859 * GNAT.Decode_String (g-decstr.ads)::
13860 * GNAT.Decode_UTF8_String (g-deutst.ads)::
13861 * GNAT.Directory_Operations (g-dirope.ads)::
13862 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
13863 * GNAT.Dynamic_HTables (g-dynhta.ads)::
13864 * GNAT.Dynamic_Tables (g-dyntab.ads)::
13865 * GNAT.Encode_String (g-encstr.ads)::
13866 * GNAT.Encode_UTF8_String (g-enutst.ads)::
13867 * GNAT.Exception_Actions (g-excact.ads)::
13868 * GNAT.Exception_Traces (g-exctra.ads)::
13869 * GNAT.Exceptions (g-except.ads)::
13870 * GNAT.Expect (g-expect.ads)::
13871 * GNAT.Float_Control (g-flocon.ads)::
13872 * GNAT.Heap_Sort (g-heasor.ads)::
13873 * GNAT.Heap_Sort_A (g-hesora.ads)::
13874 * GNAT.Heap_Sort_G (g-hesorg.ads)::
13875 * GNAT.HTable (g-htable.ads)::
13876 * GNAT.IO (g-io.ads)::
13877 * GNAT.IO_Aux (g-io_aux.ads)::
13878 * GNAT.Lock_Files (g-locfil.ads)::
13879 * GNAT.MBBS_Discrete_Random (g-mbdira.ads)::
13880 * GNAT.MBBS_Float_Random (g-mbflra.ads)::
13881 * GNAT.MD5 (g-md5.ads)::
13882 * GNAT.Memory_Dump (g-memdum.ads)::
13883 * GNAT.Most_Recent_Exception (g-moreex.ads)::
13884 * GNAT.OS_Lib (g-os_lib.ads)::
13885 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
13886 * GNAT.Random_Numbers (g-rannum.ads)::
13887 * GNAT.Regexp (g-regexp.ads)::
13888 * GNAT.Registry (g-regist.ads)::
13889 * GNAT.Regpat (g-regpat.ads)::
13890 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
13891 * GNAT.Semaphores (g-semaph.ads)::
13892 * GNAT.Serial_Communications (g-sercom.ads)::
13893 * GNAT.SHA1 (g-sha1.ads)::
13894 * GNAT.SHA224 (g-sha224.ads)::
13895 * GNAT.SHA256 (g-sha256.ads)::
13896 * GNAT.SHA384 (g-sha384.ads)::
13897 * GNAT.SHA512 (g-sha512.ads)::
13898 * GNAT.Signals (g-signal.ads)::
13899 * GNAT.Sockets (g-socket.ads)::
13900 * GNAT.Source_Info (g-souinf.ads)::
13901 * GNAT.Spelling_Checker (g-speche.ads)::
13902 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
13903 * GNAT.Spitbol.Patterns (g-spipat.ads)::
13904 * GNAT.Spitbol (g-spitbo.ads)::
13905 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
13906 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
13907 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
13908 * GNAT.SSE (g-sse.ads)::
13909 * GNAT.SSE.Vector_Types (g-ssvety.ads)::
13910 * GNAT.Strings (g-string.ads)::
13911 * GNAT.String_Split (g-strspl.ads)::
13912 * GNAT.Table (g-table.ads)::
13913 * GNAT.Task_Lock (g-tasloc.ads)::
13914 * GNAT.Threads (g-thread.ads)::
13915 * GNAT.Time_Stamp (g-timsta.ads)::
13916 * GNAT.Traceback (g-traceb.ads)::
13917 * GNAT.Traceback.Symbolic (g-trasym.ads)::
13918 * GNAT.UTF_32 (g-utf_32.ads)::
13919 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
13920 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
13921 * GNAT.Wide_String_Split (g-wistsp.ads)::
13922 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
13923 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
13924 * Interfaces.C.Extensions (i-cexten.ads)::
13925 * Interfaces.C.Streams (i-cstrea.ads)::
13926 * Interfaces.CPP (i-cpp.ads)::
13927 * Interfaces.Packed_Decimal (i-pacdec.ads)::
13928 * Interfaces.VxWorks (i-vxwork.ads)::
13929 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
13930 * System.Address_Image (s-addima.ads)::
13931 * System.Assertions (s-assert.ads)::
13932 * System.Memory (s-memory.ads)::
13933 * System.Partition_Interface (s-parint.ads)::
13934 * System.Pool_Global (s-pooglo.ads)::
13935 * System.Pool_Local (s-pooloc.ads)::
13936 * System.Restrictions (s-restri.ads)::
13937 * System.Rident (s-rident.ads)::
13938 * System.Strings.Stream_Ops (s-ststop.ads)::
13939 * System.Task_Info (s-tasinf.ads)::
13940 * System.Wch_Cnv (s-wchcnv.ads)::
13941 * System.Wch_Con (s-wchcon.ads)::
13942 @end menu
13943
13944 @node Ada.Characters.Latin_9 (a-chlat9.ads)
13945 @section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
13946 @cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
13947 @cindex Latin_9 constants for Character
13948
13949 @noindent
13950 This child of @code{Ada.Characters}
13951 provides a set of definitions corresponding to those in the
13952 RM-defined package @code{Ada.Characters.Latin_1} but with the
13953 few modifications required for @code{Latin-9}
13954 The provision of such a package
13955 is specifically authorized by the Ada Reference Manual
13956 (RM A.3.3(27)).
13957
13958 @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
13959 @section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
13960 @cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
13961 @cindex Latin_1 constants for Wide_Character
13962
13963 @noindent
13964 This child of @code{Ada.Characters}
13965 provides a set of definitions corresponding to those in the
13966 RM-defined package @code{Ada.Characters.Latin_1} but with the
13967 types of the constants being @code{Wide_Character}
13968 instead of @code{Character}.  The provision of such a package
13969 is specifically authorized by the Ada Reference Manual
13970 (RM A.3.3(27)).
13971
13972 @node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
13973 @section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
13974 @cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
13975 @cindex Latin_9 constants for Wide_Character
13976
13977 @noindent
13978 This child of @code{Ada.Characters}
13979 provides a set of definitions corresponding to those in the
13980 GNAT defined package @code{Ada.Characters.Latin_9} but with the
13981 types of the constants being @code{Wide_Character}
13982 instead of @code{Character}.  The provision of such a package
13983 is specifically authorized by the Ada Reference Manual
13984 (RM A.3.3(27)).
13985
13986 @node Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)
13987 @section @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
13988 @cindex @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
13989 @cindex Latin_1 constants for Wide_Wide_Character
13990
13991 @noindent
13992 This child of @code{Ada.Characters}
13993 provides a set of definitions corresponding to those in the
13994 RM-defined package @code{Ada.Characters.Latin_1} but with the
13995 types of the constants being @code{Wide_Wide_Character}
13996 instead of @code{Character}.  The provision of such a package
13997 is specifically authorized by the Ada Reference Manual
13998 (RM A.3.3(27)).
13999
14000 @node Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)
14001 @section @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
14002 @cindex @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
14003 @cindex Latin_9 constants for Wide_Wide_Character
14004
14005 @noindent
14006 This child of @code{Ada.Characters}
14007 provides a set of definitions corresponding to those in the
14008 GNAT defined package @code{Ada.Characters.Latin_9} but with the
14009 types of the constants being @code{Wide_Wide_Character}
14010 instead of @code{Character}.  The provision of such a package
14011 is specifically authorized by the Ada Reference Manual
14012 (RM A.3.3(27)).
14013
14014 @node Ada.Command_Line.Environment (a-colien.ads)
14015 @section @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
14016 @cindex @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
14017 @cindex Environment entries
14018
14019 @noindent
14020 This child of @code{Ada.Command_Line}
14021 provides a mechanism for obtaining environment values on systems
14022 where this concept makes sense.
14023
14024 @node Ada.Command_Line.Remove (a-colire.ads)
14025 @section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
14026 @cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
14027 @cindex Removing command line arguments
14028 @cindex Command line, argument removal
14029
14030 @noindent
14031 This child of @code{Ada.Command_Line}
14032 provides a mechanism for logically removing
14033 arguments from the argument list.  Once removed, an argument is not visible
14034 to further calls on the subprograms in @code{Ada.Command_Line} will not
14035 see the removed argument.
14036
14037 @node Ada.Command_Line.Response_File (a-clrefi.ads)
14038 @section @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
14039 @cindex @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
14040 @cindex Response file for command line
14041 @cindex Command line, response file
14042 @cindex Command line, handling long command lines
14043
14044 @noindent
14045 This child of @code{Ada.Command_Line} provides a mechanism facilities for
14046 getting command line arguments from a text file, called a "response file".
14047 Using a response file allow passing a set of arguments to an executable longer
14048 than the maximum allowed by the system on the command line.
14049
14050 @node Ada.Direct_IO.C_Streams (a-diocst.ads)
14051 @section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
14052 @cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
14053 @cindex C Streams, Interfacing with Direct_IO
14054
14055 @noindent
14056 This package provides subprograms that allow interfacing between
14057 C streams and @code{Direct_IO}.  The stream identifier can be
14058 extracted from a file opened on the Ada side, and an Ada file
14059 can be constructed from a stream opened on the C side.
14060
14061 @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
14062 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
14063 @cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
14064 @cindex Null_Occurrence, testing for
14065
14066 @noindent
14067 This child subprogram provides a way of testing for the null
14068 exception occurrence (@code{Null_Occurrence}) without raising
14069 an exception.
14070
14071 @node Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)
14072 @section @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
14073 @cindex @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
14074 @cindex Null_Occurrence, testing for
14075
14076 @noindent
14077 This child subprogram is used for handling otherwise unhandled
14078 exceptions (hence the name last chance), and perform clean ups before
14079 terminating the program. Note that this subprogram never returns.
14080
14081 @node Ada.Exceptions.Traceback (a-exctra.ads)
14082 @section @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
14083 @cindex @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
14084 @cindex Traceback for Exception Occurrence
14085
14086 @noindent
14087 This child package provides the subprogram (@code{Tracebacks}) to
14088 give a traceback array of addresses based on an exception
14089 occurrence.
14090
14091 @node Ada.Sequential_IO.C_Streams (a-siocst.ads)
14092 @section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
14093 @cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
14094 @cindex C Streams, Interfacing with Sequential_IO
14095
14096 @noindent
14097 This package provides subprograms that allow interfacing between
14098 C streams and @code{Sequential_IO}.  The stream identifier can be
14099 extracted from a file opened on the Ada side, and an Ada file
14100 can be constructed from a stream opened on the C side.
14101
14102 @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
14103 @section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
14104 @cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
14105 @cindex C Streams, Interfacing with Stream_IO
14106
14107 @noindent
14108 This package provides subprograms that allow interfacing between
14109 C streams and @code{Stream_IO}.  The stream identifier can be
14110 extracted from a file opened on the Ada side, and an Ada file
14111 can be constructed from a stream opened on the C side.
14112
14113 @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
14114 @section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
14115 @cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
14116 @cindex @code{Unbounded_String}, IO support
14117 @cindex @code{Text_IO}, extensions for unbounded strings
14118
14119 @noindent
14120 This package provides subprograms for Text_IO for unbounded
14121 strings, avoiding the necessity for an intermediate operation
14122 with ordinary strings.
14123
14124 @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
14125 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
14126 @cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
14127 @cindex @code{Unbounded_Wide_String}, IO support
14128 @cindex @code{Text_IO}, extensions for unbounded wide strings
14129
14130 @noindent
14131 This package provides subprograms for Text_IO for unbounded
14132 wide strings, avoiding the necessity for an intermediate operation
14133 with ordinary wide strings.
14134
14135 @node Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)
14136 @section @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
14137 @cindex @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
14138 @cindex @code{Unbounded_Wide_Wide_String}, IO support
14139 @cindex @code{Text_IO}, extensions for unbounded wide wide strings
14140
14141 @noindent
14142 This package provides subprograms for Text_IO for unbounded
14143 wide wide strings, avoiding the necessity for an intermediate operation
14144 with ordinary wide wide strings.
14145
14146 @node Ada.Text_IO.C_Streams (a-tiocst.ads)
14147 @section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
14148 @cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
14149 @cindex C Streams, Interfacing with @code{Text_IO}
14150
14151 @noindent
14152 This package provides subprograms that allow interfacing between
14153 C streams and @code{Text_IO}.  The stream identifier can be
14154 extracted from a file opened on the Ada side, and an Ada file
14155 can be constructed from a stream opened on the C side.
14156
14157 @node Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)
14158 @section @code{Ada.Text_IO.Reset_Standard_Files} (@file{a-tirsfi.ads})
14159 @cindex @code{Ada.Text_IO.Reset_Standard_Files} (@file{a-tirsfi.ads})
14160 @cindex @code{Text_IO} resetting standard files
14161
14162 @noindent
14163 This procedure is used to reset the status of the standard files used
14164 by Ada.Text_IO.  This is useful in a situation (such as a restart in an
14165 embedded application) where the status of the files may change during
14166 execution (for example a standard input file may be redefined to be
14167 interactive).
14168
14169 @node Ada.Wide_Characters.Unicode (a-wichun.ads)
14170 @section @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
14171 @cindex @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
14172 @cindex Unicode categorization, Wide_Character
14173
14174 @noindent
14175 This package provides subprograms that allow categorization of
14176 Wide_Character values according to Unicode categories.
14177
14178 @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
14179 @section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
14180 @cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
14181 @cindex C Streams, Interfacing with @code{Wide_Text_IO}
14182
14183 @noindent
14184 This package provides subprograms that allow interfacing between
14185 C streams and @code{Wide_Text_IO}.  The stream identifier can be
14186 extracted from a file opened on the Ada side, and an Ada file
14187 can be constructed from a stream opened on the C side.
14188
14189 @node Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)
14190 @section @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@file{a-wrstfi.ads})
14191 @cindex @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@file{a-wrstfi.ads})
14192 @cindex @code{Wide_Text_IO} resetting standard files
14193
14194 @noindent
14195 This procedure is used to reset the status of the standard files used
14196 by Ada.Wide_Text_IO.  This is useful in a situation (such as a restart in an
14197 embedded application) where the status of the files may change during
14198 execution (for example a standard input file may be redefined to be
14199 interactive).
14200
14201 @node Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)
14202 @section @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
14203 @cindex @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
14204 @cindex Unicode categorization, Wide_Wide_Character
14205
14206 @noindent
14207 This package provides subprograms that allow categorization of
14208 Wide_Wide_Character values according to Unicode categories.
14209
14210 @node Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)
14211 @section @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
14212 @cindex @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
14213 @cindex C Streams, Interfacing with @code{Wide_Wide_Text_IO}
14214
14215 @noindent
14216 This package provides subprograms that allow interfacing between
14217 C streams and @code{Wide_Wide_Text_IO}.  The stream identifier can be
14218 extracted from a file opened on the Ada side, and an Ada file
14219 can be constructed from a stream opened on the C side.
14220
14221 @node Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)
14222 @section @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@file{a-zrstfi.ads})
14223 @cindex @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@file{a-zrstfi.ads})
14224 @cindex @code{Wide_Wide_Text_IO} resetting standard files
14225
14226 @noindent
14227 This procedure is used to reset the status of the standard files used
14228 by Ada.Wide_Wide_Text_IO. This is useful in a situation (such as a
14229 restart in an embedded application) where the status of the files may
14230 change during execution (for example a standard input file may be
14231 redefined to be interactive).
14232
14233 @node GNAT.Altivec (g-altive.ads)
14234 @section @code{GNAT.Altivec} (@file{g-altive.ads})
14235 @cindex @code{GNAT.Altivec} (@file{g-altive.ads})
14236 @cindex AltiVec
14237
14238 @noindent
14239 This is the root package of the GNAT AltiVec binding. It provides
14240 definitions of constants and types common to all the versions of the
14241 binding.
14242
14243 @node GNAT.Altivec.Conversions (g-altcon.ads)
14244 @section @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
14245 @cindex @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
14246 @cindex AltiVec
14247
14248 @noindent
14249 This package provides the Vector/View conversion routines.
14250
14251 @node GNAT.Altivec.Vector_Operations (g-alveop.ads)
14252 @section @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
14253 @cindex @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
14254 @cindex AltiVec
14255
14256 @noindent
14257 This package exposes the Ada interface to the AltiVec operations on
14258 vector objects. A soft emulation is included by default in the GNAT
14259 library. The hard binding is provided as a separate package. This unit
14260 is common to both bindings.
14261
14262 @node GNAT.Altivec.Vector_Types (g-alvety.ads)
14263 @section @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
14264 @cindex @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
14265 @cindex AltiVec
14266
14267 @noindent
14268 This package exposes the various vector types part of the Ada binding
14269 to AltiVec facilities.
14270
14271 @node GNAT.Altivec.Vector_Views (g-alvevi.ads)
14272 @section @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
14273 @cindex @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
14274 @cindex AltiVec
14275
14276 @noindent
14277 This package provides public 'View' data types from/to which private
14278 vector representations can be converted via
14279 GNAT.Altivec.Conversions. This allows convenient access to individual
14280 vector elements and provides a simple way to initialize vector
14281 objects.
14282
14283 @node GNAT.Array_Split (g-arrspl.ads)
14284 @section @code{GNAT.Array_Split} (@file{g-arrspl.ads})
14285 @cindex @code{GNAT.Array_Split} (@file{g-arrspl.ads})
14286 @cindex Array splitter
14287
14288 @noindent
14289 Useful array-manipulation routines: given a set of separators, split
14290 an array wherever the separators appear, and provide direct access
14291 to the resulting slices.
14292
14293 @node GNAT.AWK (g-awk.ads)
14294 @section @code{GNAT.AWK} (@file{g-awk.ads})
14295 @cindex @code{GNAT.AWK} (@file{g-awk.ads})
14296 @cindex Parsing
14297 @cindex AWK
14298
14299 @noindent
14300 Provides AWK-like parsing functions, with an easy interface for parsing one
14301 or more files containing formatted data.  The file is viewed as a database
14302 where each record is a line and a field is a data element in this line.
14303
14304 @node GNAT.Bounded_Buffers (g-boubuf.ads)
14305 @section @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
14306 @cindex @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
14307 @cindex Parsing
14308 @cindex Bounded Buffers
14309
14310 @noindent
14311 Provides a concurrent generic bounded buffer abstraction.  Instances are
14312 useful directly or as parts of the implementations of other abstractions,
14313 such as mailboxes.
14314
14315 @node GNAT.Bounded_Mailboxes (g-boumai.ads)
14316 @section @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
14317 @cindex @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
14318 @cindex Parsing
14319 @cindex Mailboxes
14320
14321 @noindent
14322 Provides a thread-safe asynchronous intertask mailbox communication facility.
14323
14324 @node GNAT.Bubble_Sort (g-bubsor.ads)
14325 @section @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
14326 @cindex @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
14327 @cindex Sorting
14328 @cindex Bubble sort
14329
14330 @noindent
14331 Provides a general implementation of bubble sort usable for sorting arbitrary
14332 data items.  Exchange and comparison procedures are provided by passing
14333 access-to-procedure values.
14334
14335 @node GNAT.Bubble_Sort_A (g-busora.ads)
14336 @section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
14337 @cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
14338 @cindex Sorting
14339 @cindex Bubble sort
14340
14341 @noindent
14342 Provides a general implementation of bubble sort usable for sorting arbitrary
14343 data items.  Move and comparison procedures are provided by passing
14344 access-to-procedure values. This is an older version, retained for
14345 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
14346
14347 @node GNAT.Bubble_Sort_G (g-busorg.ads)
14348 @section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
14349 @cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
14350 @cindex Sorting
14351 @cindex Bubble sort
14352
14353 @noindent
14354 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
14355 are provided as generic parameters, this improves efficiency, especially
14356 if the procedures can be inlined, at the expense of duplicating code for
14357 multiple instantiations.
14358
14359 @node GNAT.Byte_Order_Mark (g-byorma.ads)
14360 @section @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
14361 @cindex @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
14362 @cindex UTF-8 representation
14363 @cindex Wide characte representations
14364
14365 @noindent
14366 Provides a routine which given a string, reads the start of the string to
14367 see whether it is one of the standard byte order marks (BOM's) which signal
14368 the encoding of the string. The routine includes detection of special XML
14369 sequences for various UCS input formats.
14370
14371 @node GNAT.Byte_Swapping (g-bytswa.ads)
14372 @section @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
14373 @cindex @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
14374 @cindex Byte swapping
14375 @cindex Endian
14376
14377 @noindent
14378 General routines for swapping the bytes in 2-, 4-, and 8-byte quantities.
14379 Machine-specific implementations are available in some cases.
14380
14381 @node GNAT.Calendar (g-calend.ads)
14382 @section @code{GNAT.Calendar} (@file{g-calend.ads})
14383 @cindex @code{GNAT.Calendar} (@file{g-calend.ads})
14384 @cindex @code{Calendar}
14385
14386 @noindent
14387 Extends the facilities provided by @code{Ada.Calendar} to include handling
14388 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
14389 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
14390 C @code{timeval} format.
14391
14392 @node GNAT.Calendar.Time_IO (g-catiio.ads)
14393 @section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
14394 @cindex @code{Calendar}
14395 @cindex Time
14396 @cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
14397
14398 @node GNAT.CRC32 (g-crc32.ads)
14399 @section @code{GNAT.CRC32} (@file{g-crc32.ads})
14400 @cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
14401 @cindex CRC32
14402 @cindex Cyclic Redundancy Check
14403
14404 @noindent
14405 This package implements the CRC-32 algorithm.  For a full description
14406 of this algorithm see
14407 ``Computation of Cyclic Redundancy Checks via Table Look-Up'',
14408 @cite{Communications of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013,
14409 Aug.@: 1988.  Sarwate, D.V@.
14410
14411 @node GNAT.Case_Util (g-casuti.ads)
14412 @section @code{GNAT.Case_Util} (@file{g-casuti.ads})
14413 @cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
14414 @cindex Casing utilities
14415 @cindex Character handling (@code{GNAT.Case_Util})
14416
14417 @noindent
14418 A set of simple routines for handling upper and lower casing of strings
14419 without the overhead of the full casing tables
14420 in @code{Ada.Characters.Handling}.
14421
14422 @node GNAT.CGI (g-cgi.ads)
14423 @section @code{GNAT.CGI} (@file{g-cgi.ads})
14424 @cindex @code{GNAT.CGI} (@file{g-cgi.ads})
14425 @cindex CGI (Common Gateway Interface)
14426
14427 @noindent
14428 This is a package for interfacing a GNAT program with a Web server via the
14429 Common Gateway Interface (CGI)@.  Basically this package parses the CGI
14430 parameters, which are a set of key/value pairs sent by the Web server.  It
14431 builds a table whose index is the key and provides some services to deal
14432 with this table.
14433
14434 @node GNAT.CGI.Cookie (g-cgicoo.ads)
14435 @section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
14436 @cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
14437 @cindex CGI (Common Gateway Interface) cookie support
14438 @cindex Cookie support in CGI
14439
14440 @noindent
14441 This is a package to interface a GNAT program with a Web server via the
14442 Common Gateway Interface (CGI).  It exports services to deal with Web
14443 cookies (piece of information kept in the Web client software).
14444
14445 @node GNAT.CGI.Debug (g-cgideb.ads)
14446 @section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
14447 @cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
14448 @cindex CGI (Common Gateway Interface) debugging
14449
14450 @noindent
14451 This is a package to help debugging CGI (Common Gateway Interface)
14452 programs written in Ada.
14453
14454 @node GNAT.Command_Line (g-comlin.ads)
14455 @section @code{GNAT.Command_Line} (@file{g-comlin.ads})
14456 @cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
14457 @cindex Command line
14458
14459 @noindent
14460 Provides a high level interface to @code{Ada.Command_Line} facilities,
14461 including the ability to scan for named switches with optional parameters
14462 and expand file names using wild card notations.
14463
14464 @node GNAT.Compiler_Version (g-comver.ads)
14465 @section @code{GNAT.Compiler_Version} (@file{g-comver.ads})
14466 @cindex @code{GNAT.Compiler_Version} (@file{g-comver.ads})
14467 @cindex Compiler Version
14468 @cindex Version, of compiler
14469
14470 @noindent
14471 Provides a routine for obtaining the version of the compiler used to
14472 compile the program. More accurately this is the version of the binder
14473 used to bind the program (this will normally be the same as the version
14474 of the compiler if a consistent tool set is used to compile all units
14475 of a partition).
14476
14477 @node GNAT.Ctrl_C (g-ctrl_c.ads)
14478 @section @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
14479 @cindex @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
14480 @cindex Interrupt
14481
14482 @noindent
14483 Provides a simple interface to handle Ctrl-C keyboard events.
14484
14485 @node GNAT.Current_Exception (g-curexc.ads)
14486 @section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
14487 @cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
14488 @cindex Current exception
14489 @cindex Exception retrieval
14490
14491 @noindent
14492 Provides access to information on the current exception that has been raised
14493 without the need for using the Ada 95 / Ada 2005 exception choice parameter
14494 specification syntax.
14495 This is particularly useful in simulating typical facilities for
14496 obtaining information about exceptions provided by Ada 83 compilers.
14497
14498 @node GNAT.Debug_Pools (g-debpoo.ads)
14499 @section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
14500 @cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
14501 @cindex Debugging
14502 @cindex Debug pools
14503 @cindex Memory corruption debugging
14504
14505 @noindent
14506 Provide a debugging storage pools that helps tracking memory corruption
14507 problems.  @xref{The GNAT Debug Pool Facility,,, gnat_ugn,
14508 @value{EDITION} User's Guide}.
14509
14510 @node GNAT.Debug_Utilities (g-debuti.ads)
14511 @section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
14512 @cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
14513 @cindex Debugging
14514
14515 @noindent
14516 Provides a few useful utilities for debugging purposes, including conversion
14517 to and from string images of address values. Supports both C and Ada formats
14518 for hexadecimal literals.
14519
14520 @node GNAT.Decode_String (g-decstr.ads)
14521 @section @code{GNAT.Decode_String} (@file{g-decstr.ads})
14522 @cindex @code{GNAT.Decode_String} (@file{g-decstr.ads})
14523 @cindex Decoding strings
14524 @cindex String decoding
14525 @cindex Wide character encoding
14526 @cindex UTF-8
14527 @cindex Unicode
14528
14529 @noindent
14530 A generic package providing routines for decoding wide character and wide wide
14531 character strings encoded as sequences of 8-bit characters using a specified
14532 encoding method. Includes validation routines, and also routines for stepping
14533 to next or previous encoded character in an encoded string.
14534 Useful in conjunction with Unicode character coding. Note there is a
14535 preinstantiation for UTF-8. See next entry.
14536
14537 @node GNAT.Decode_UTF8_String (g-deutst.ads)
14538 @section @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
14539 @cindex @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
14540 @cindex Decoding strings
14541 @cindex Decoding UTF-8 strings
14542 @cindex UTF-8 string decoding
14543 @cindex Wide character decoding
14544 @cindex UTF-8
14545 @cindex Unicode
14546
14547 @noindent
14548 A preinstantiation of GNAT.Decode_Strings for UTF-8 encoding.
14549
14550 @node GNAT.Directory_Operations (g-dirope.ads)
14551 @section @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
14552 @cindex @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
14553 @cindex Directory operations
14554
14555 @noindent
14556 Provides a set of routines for manipulating directories, including changing
14557 the current directory, making new directories, and scanning the files in a
14558 directory.
14559
14560 @node GNAT.Directory_Operations.Iteration (g-diopit.ads)
14561 @section @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
14562 @cindex @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
14563 @cindex Directory operations iteration
14564
14565 @noindent
14566 A child unit of GNAT.Directory_Operations providing additional operations
14567 for iterating through directories.
14568
14569 @node GNAT.Dynamic_HTables (g-dynhta.ads)
14570 @section @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
14571 @cindex @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
14572 @cindex Hash tables
14573
14574 @noindent
14575 A generic implementation of hash tables that can be used to hash arbitrary
14576 data.  Provided in two forms, a simple form with built in hash functions,
14577 and a more complex form in which the hash function is supplied.
14578
14579 @noindent
14580 This package provides a facility similar to that of @code{GNAT.HTable},
14581 except that this package declares a type that can be used to define
14582 dynamic instances of the hash table, while an instantiation of
14583 @code{GNAT.HTable} creates a single instance of the hash table.
14584
14585 @node GNAT.Dynamic_Tables (g-dyntab.ads)
14586 @section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
14587 @cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
14588 @cindex Table implementation
14589 @cindex Arrays, extendable
14590
14591 @noindent
14592 A generic package providing a single dimension array abstraction where the
14593 length of the array can be dynamically modified.
14594
14595 @noindent
14596 This package provides a facility similar to that of @code{GNAT.Table},
14597 except that this package declares a type that can be used to define
14598 dynamic instances of the table, while an instantiation of
14599 @code{GNAT.Table} creates a single instance of the table type.
14600
14601 @node GNAT.Encode_String (g-encstr.ads)
14602 @section @code{GNAT.Encode_String} (@file{g-encstr.ads})
14603 @cindex @code{GNAT.Encode_String} (@file{g-encstr.ads})
14604 @cindex Encoding strings
14605 @cindex String encoding
14606 @cindex Wide character encoding
14607 @cindex UTF-8
14608 @cindex Unicode
14609
14610 @noindent
14611 A generic package providing routines for encoding wide character and wide
14612 wide character strings as sequences of 8-bit characters using a specified
14613 encoding method. Useful in conjunction with Unicode character coding.
14614 Note there is a preinstantiation for UTF-8. See next entry.
14615
14616 @node GNAT.Encode_UTF8_String (g-enutst.ads)
14617 @section @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
14618 @cindex @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
14619 @cindex Encoding strings
14620 @cindex Encoding UTF-8 strings
14621 @cindex UTF-8 string encoding
14622 @cindex Wide character encoding
14623 @cindex UTF-8
14624 @cindex Unicode
14625
14626 @noindent
14627 A preinstantiation of GNAT.Encode_Strings for UTF-8 encoding.
14628
14629 @node GNAT.Exception_Actions (g-excact.ads)
14630 @section @code{GNAT.Exception_Actions} (@file{g-excact.ads})
14631 @cindex @code{GNAT.Exception_Actions} (@file{g-excact.ads})
14632 @cindex Exception actions
14633
14634 @noindent
14635 Provides callbacks when an exception is raised. Callbacks can be registered
14636 for specific exceptions, or when any exception is raised. This
14637 can be used for instance to force a core dump to ease debugging.
14638
14639 @node GNAT.Exception_Traces (g-exctra.ads)
14640 @section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
14641 @cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
14642 @cindex Exception traces
14643 @cindex Debugging
14644
14645 @noindent
14646 Provides an interface allowing to control automatic output upon exception
14647 occurrences.
14648
14649 @node GNAT.Exceptions (g-except.ads)
14650 @section @code{GNAT.Exceptions} (@file{g-expect.ads})
14651 @cindex @code{GNAT.Exceptions} (@file{g-expect.ads})
14652 @cindex Exceptions, Pure
14653 @cindex Pure packages, exceptions
14654
14655 @noindent
14656 Normally it is not possible to raise an exception with
14657 a message from a subprogram in a pure package, since the
14658 necessary types and subprograms are in @code{Ada.Exceptions}
14659 which is not a pure unit. @code{GNAT.Exceptions} provides a
14660 facility for getting around this limitation for a few
14661 predefined exceptions, and for example allow raising
14662 @code{Constraint_Error} with a message from a pure subprogram.
14663
14664 @node GNAT.Expect (g-expect.ads)
14665 @section @code{GNAT.Expect} (@file{g-expect.ads})
14666 @cindex @code{GNAT.Expect} (@file{g-expect.ads})
14667
14668 @noindent
14669 Provides a set of subprograms similar to what is available
14670 with the standard Tcl Expect tool.
14671 It allows you to easily spawn and communicate with an external process.
14672 You can send commands or inputs to the process, and compare the output
14673 with some expected regular expression. Currently @code{GNAT.Expect}
14674 is implemented on all native GNAT ports except for OpenVMS@.
14675 It is not implemented for cross ports, and in particular is not
14676 implemented for VxWorks or LynxOS@.
14677
14678 @node GNAT.Float_Control (g-flocon.ads)
14679 @section @code{GNAT.Float_Control} (@file{g-flocon.ads})
14680 @cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
14681 @cindex Floating-Point Processor
14682
14683 @noindent
14684 Provides an interface for resetting the floating-point processor into the
14685 mode required for correct semantic operation in Ada.  Some third party
14686 library calls may cause this mode to be modified, and the Reset procedure
14687 in this package can be used to reestablish the required mode.
14688
14689 @node GNAT.Heap_Sort (g-heasor.ads)
14690 @section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
14691 @cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
14692 @cindex Sorting
14693
14694 @noindent
14695 Provides a general implementation of heap sort usable for sorting arbitrary
14696 data items. Exchange and comparison procedures are provided by passing
14697 access-to-procedure values.  The algorithm used is a modified heap sort
14698 that performs approximately N*log(N) comparisons in the worst case.
14699
14700 @node GNAT.Heap_Sort_A (g-hesora.ads)
14701 @section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
14702 @cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
14703 @cindex Sorting
14704
14705 @noindent
14706 Provides a general implementation of heap sort usable for sorting arbitrary
14707 data items. Move and comparison procedures are provided by passing
14708 access-to-procedure values.  The algorithm used is a modified heap sort
14709 that performs approximately N*log(N) comparisons in the worst case.
14710 This differs from @code{GNAT.Heap_Sort} in having a less convenient
14711 interface, but may be slightly more efficient.
14712
14713 @node GNAT.Heap_Sort_G (g-hesorg.ads)
14714 @section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
14715 @cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
14716 @cindex Sorting
14717
14718 @noindent
14719 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
14720 are provided as generic parameters, this improves efficiency, especially
14721 if the procedures can be inlined, at the expense of duplicating code for
14722 multiple instantiations.
14723
14724 @node GNAT.HTable (g-htable.ads)
14725 @section @code{GNAT.HTable} (@file{g-htable.ads})
14726 @cindex @code{GNAT.HTable} (@file{g-htable.ads})
14727 @cindex Hash tables
14728
14729 @noindent
14730 A generic implementation of hash tables that can be used to hash arbitrary
14731 data.  Provides two approaches, one a simple static approach, and the other
14732 allowing arbitrary dynamic hash tables.
14733
14734 @node GNAT.IO (g-io.ads)
14735 @section @code{GNAT.IO} (@file{g-io.ads})
14736 @cindex @code{GNAT.IO} (@file{g-io.ads})
14737 @cindex Simple I/O
14738 @cindex Input/Output facilities
14739
14740 @noindent
14741 A simple preelaborable input-output package that provides a subset of
14742 simple Text_IO functions for reading characters and strings from
14743 Standard_Input, and writing characters, strings and integers to either
14744 Standard_Output or Standard_Error.
14745
14746 @node GNAT.IO_Aux (g-io_aux.ads)
14747 @section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
14748 @cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
14749 @cindex Text_IO
14750 @cindex Input/Output facilities
14751
14752 Provides some auxiliary functions for use with Text_IO, including a test
14753 for whether a file exists, and functions for reading a line of text.
14754
14755 @node GNAT.Lock_Files (g-locfil.ads)
14756 @section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
14757 @cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
14758 @cindex File locking
14759 @cindex Locking using files
14760
14761 @noindent
14762 Provides a general interface for using files as locks.  Can be used for
14763 providing program level synchronization.
14764
14765 @node GNAT.MBBS_Discrete_Random (g-mbdira.ads)
14766 @section @code{GNAT.MBBS_Discrete_Random} (@file{g-mbdira.ads})
14767 @cindex @code{GNAT.MBBS_Discrete_Random} (@file{g-mbdira.ads})
14768 @cindex Random number generation
14769
14770 @noindent
14771 The original implementation of @code{Ada.Numerics.Discrete_Random}.  Uses
14772 a modified version of the Blum-Blum-Shub generator.
14773
14774 @node GNAT.MBBS_Float_Random (g-mbflra.ads)
14775 @section @code{GNAT.MBBS_Float_Random} (@file{g-mbflra.ads})
14776 @cindex @code{GNAT.MBBS_Float_Random} (@file{g-mbflra.ads})
14777 @cindex Random number generation
14778
14779 @noindent
14780 The original implementation of @code{Ada.Numerics.Float_Random}.  Uses
14781 a modified version of the Blum-Blum-Shub generator.
14782
14783 @node GNAT.MD5 (g-md5.ads)
14784 @section @code{GNAT.MD5} (@file{g-md5.ads})
14785 @cindex @code{GNAT.MD5} (@file{g-md5.ads})
14786 @cindex Message Digest MD5
14787
14788 @noindent
14789 Implements the MD5 Message-Digest Algorithm as described in RFC 1321.
14790
14791 @node GNAT.Memory_Dump (g-memdum.ads)
14792 @section @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
14793 @cindex @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
14794 @cindex Dump Memory
14795
14796 @noindent
14797 Provides a convenient routine for dumping raw memory to either the
14798 standard output or standard error files. Uses GNAT.IO for actual
14799 output.
14800
14801 @node GNAT.Most_Recent_Exception (g-moreex.ads)
14802 @section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
14803 @cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
14804 @cindex Exception, obtaining most recent
14805
14806 @noindent
14807 Provides access to the most recently raised exception.  Can be used for
14808 various logging purposes, including duplicating functionality of some
14809 Ada 83 implementation dependent extensions.
14810
14811 @node GNAT.OS_Lib (g-os_lib.ads)
14812 @section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
14813 @cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
14814 @cindex Operating System interface
14815 @cindex Spawn capability
14816
14817 @noindent
14818 Provides a range of target independent operating system interface functions,
14819 including time/date management, file operations, subprocess management,
14820 including a portable spawn procedure, and access to environment variables
14821 and error return codes.
14822
14823 @node GNAT.Perfect_Hash_Generators (g-pehage.ads)
14824 @section @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
14825 @cindex @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
14826 @cindex Hash functions
14827
14828 @noindent
14829 Provides a generator of static minimal perfect hash functions. No
14830 collisions occur and each item can be retrieved from the table in one
14831 probe (perfect property). The hash table size corresponds to the exact
14832 size of the key set and no larger (minimal property). The key set has to
14833 be know in advance (static property). The hash functions are also order
14834 preserving. If w2 is inserted after w1 in the generator, their
14835 hashcode are in the same order. These hashing functions are very
14836 convenient for use with realtime applications.
14837
14838 @node GNAT.Random_Numbers (g-rannum.ads)
14839 @section @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
14840 @cindex @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
14841 @cindex Random number generation
14842
14843 @noindent
14844 Provides random number capabilities which extend those available in the
14845 standard Ada library and are more convenient to use.
14846
14847 @node GNAT.Regexp (g-regexp.ads)
14848 @section @code{GNAT.Regexp} (@file{g-regexp.ads})
14849 @cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
14850 @cindex Regular expressions
14851 @cindex Pattern matching
14852
14853 @noindent
14854 A simple implementation of regular expressions, using a subset of regular
14855 expression syntax copied from familiar Unix style utilities.  This is the
14856 simples of the three pattern matching packages provided, and is particularly
14857 suitable for ``file globbing'' applications.
14858
14859 @node GNAT.Registry (g-regist.ads)
14860 @section @code{GNAT.Registry} (@file{g-regist.ads})
14861 @cindex @code{GNAT.Registry} (@file{g-regist.ads})
14862 @cindex Windows Registry
14863
14864 @noindent
14865 This is a high level binding to the Windows registry.  It is possible to
14866 do simple things like reading a key value, creating a new key.  For full
14867 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
14868 package provided with the Win32Ada binding
14869
14870 @node GNAT.Regpat (g-regpat.ads)
14871 @section @code{GNAT.Regpat} (@file{g-regpat.ads})
14872 @cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
14873 @cindex Regular expressions
14874 @cindex Pattern matching
14875
14876 @noindent
14877 A complete implementation of Unix-style regular expression matching, copied
14878 from the original V7 style regular expression library written in C by
14879 Henry Spencer (and binary compatible with this C library).
14880
14881 @node GNAT.Secondary_Stack_Info (g-sestin.ads)
14882 @section @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
14883 @cindex @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
14884 @cindex Secondary Stack Info
14885
14886 @noindent
14887 Provide the capability to query the high water mark of the current task's
14888 secondary stack.
14889
14890 @node GNAT.Semaphores (g-semaph.ads)
14891 @section @code{GNAT.Semaphores} (@file{g-semaph.ads})
14892 @cindex @code{GNAT.Semaphores} (@file{g-semaph.ads})
14893 @cindex Semaphores
14894
14895 @noindent
14896 Provides classic counting and binary semaphores using protected types.
14897
14898 @node GNAT.Serial_Communications (g-sercom.ads)
14899 @section @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
14900 @cindex @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
14901 @cindex Serial_Communications
14902
14903 @noindent
14904 Provides a simple interface to send and receive data over a serial
14905 port. This is only supported on GNU/Linux and Windows.
14906
14907 @node GNAT.SHA1 (g-sha1.ads)
14908 @section @code{GNAT.SHA1} (@file{g-sha1.ads})
14909 @cindex @code{GNAT.SHA1} (@file{g-sha1.ads})
14910 @cindex Secure Hash Algorithm SHA-1
14911
14912 @noindent
14913 Implements the SHA-1 Secure Hash Algorithm as described in FIPS PUB 180-3
14914 and RFC 3174.
14915
14916 @node GNAT.SHA224 (g-sha224.ads)
14917 @section @code{GNAT.SHA224} (@file{g-sha224.ads})
14918 @cindex @code{GNAT.SHA224} (@file{g-sha224.ads})
14919 @cindex Secure Hash Algorithm SHA-224
14920
14921 @noindent
14922 Implements the SHA-224 Secure Hash Algorithm as described in FIPS PUB 180-3.
14923
14924 @node GNAT.SHA256 (g-sha256.ads)
14925 @section @code{GNAT.SHA256} (@file{g-sha256.ads})
14926 @cindex @code{GNAT.SHA256} (@file{g-sha256.ads})
14927 @cindex Secure Hash Algorithm SHA-256
14928
14929 @noindent
14930 Implements the SHA-256 Secure Hash Algorithm as described in FIPS PUB 180-3.
14931
14932 @node GNAT.SHA384 (g-sha384.ads)
14933 @section @code{GNAT.SHA384} (@file{g-sha384.ads})
14934 @cindex @code{GNAT.SHA384} (@file{g-sha384.ads})
14935 @cindex Secure Hash Algorithm SHA-384
14936
14937 @noindent
14938 Implements the SHA-384 Secure Hash Algorithm as described in FIPS PUB 180-3.
14939
14940 @node GNAT.SHA512 (g-sha512.ads)
14941 @section @code{GNAT.SHA512} (@file{g-sha512.ads})
14942 @cindex @code{GNAT.SHA512} (@file{g-sha512.ads})
14943 @cindex Secure Hash Algorithm SHA-512
14944
14945 @noindent
14946 Implements the SHA-512 Secure Hash Algorithm as described in FIPS PUB 180-3.
14947
14948 @node GNAT.Signals (g-signal.ads)
14949 @section @code{GNAT.Signals} (@file{g-signal.ads})
14950 @cindex @code{GNAT.Signals} (@file{g-signal.ads})
14951 @cindex Signals
14952
14953 @noindent
14954 Provides the ability to manipulate the blocked status of signals on supported
14955 targets.
14956
14957 @node GNAT.Sockets (g-socket.ads)
14958 @section @code{GNAT.Sockets} (@file{g-socket.ads})
14959 @cindex @code{GNAT.Sockets} (@file{g-socket.ads})
14960 @cindex Sockets
14961
14962 @noindent
14963 A high level and portable interface to develop sockets based applications.
14964 This package is based on the sockets thin binding found in
14965 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
14966 on all native GNAT ports except for OpenVMS@.  It is not implemented
14967 for the LynxOS@ cross port.
14968
14969 @node GNAT.Source_Info (g-souinf.ads)
14970 @section @code{GNAT.Source_Info} (@file{g-souinf.ads})
14971 @cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
14972 @cindex Source Information
14973
14974 @noindent
14975 Provides subprograms that give access to source code information known at
14976 compile time, such as the current file name and line number.
14977
14978 @node GNAT.Spelling_Checker (g-speche.ads)
14979 @section @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
14980 @cindex @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
14981 @cindex Spell checking
14982
14983 @noindent
14984 Provides a function for determining whether one string is a plausible
14985 near misspelling of another string.
14986
14987 @node GNAT.Spelling_Checker_Generic (g-spchge.ads)
14988 @section @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
14989 @cindex @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
14990 @cindex Spell checking
14991
14992 @noindent
14993 Provides a generic function that can be instantiated with a string type for
14994 determining whether one string is a plausible near misspelling of another
14995 string.
14996
14997 @node GNAT.Spitbol.Patterns (g-spipat.ads)
14998 @section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
14999 @cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
15000 @cindex SPITBOL pattern matching
15001 @cindex Pattern matching
15002
15003 @noindent
15004 A complete implementation of SNOBOL4 style pattern matching.  This is the
15005 most elaborate of the pattern matching packages provided.  It fully duplicates
15006 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
15007 efficient algorithm developed by Robert Dewar for the SPITBOL system.
15008
15009 @node GNAT.Spitbol (g-spitbo.ads)
15010 @section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
15011 @cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
15012 @cindex SPITBOL interface
15013
15014 @noindent
15015 The top level package of the collection of SPITBOL-style functionality, this
15016 package provides basic SNOBOL4 string manipulation functions, such as
15017 Pad, Reverse, Trim, Substr capability, as well as a generic table function
15018 useful for constructing arbitrary mappings from strings in the style of
15019 the SNOBOL4 TABLE function.
15020
15021 @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
15022 @section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
15023 @cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
15024 @cindex Sets of strings
15025 @cindex SPITBOL Tables
15026
15027 @noindent
15028 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
15029 for type @code{Standard.Boolean}, giving an implementation of sets of
15030 string values.
15031
15032 @node GNAT.Spitbol.Table_Integer (g-sptain.ads)
15033 @section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
15034 @cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
15035 @cindex Integer maps
15036 @cindex Maps
15037 @cindex SPITBOL Tables
15038
15039 @noindent
15040 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
15041 for type @code{Standard.Integer}, giving an implementation of maps
15042 from string to integer values.
15043
15044 @node GNAT.Spitbol.Table_VString (g-sptavs.ads)
15045 @section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
15046 @cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
15047 @cindex String maps
15048 @cindex Maps
15049 @cindex SPITBOL Tables
15050
15051 @noindent
15052 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
15053 a variable length string type, giving an implementation of general
15054 maps from strings to strings.
15055
15056 @node GNAT.SSE (g-sse.ads)
15057 @section @code{GNAT.SSE} (@file{g-sse.ads})
15058 @cindex @code{GNAT.SSE} (@file{g-sse.ads})
15059
15060 @noindent
15061 Root of a set of units aimed at offering Ada bindings to a subset of
15062 the Intel(r) Streaming SIMD Extensions with GNAT on the x86 family of
15063 targets.  It exposes vector component types together with a general
15064 introduction to the binding contents and use.
15065
15066 @node GNAT.SSE.Vector_Types (g-ssvety.ads)
15067 @section @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
15068 @cindex @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
15069
15070 @noindent
15071 SSE vector types for use with SSE related intrinsics.
15072
15073 @node GNAT.Strings (g-string.ads)
15074 @section @code{GNAT.Strings} (@file{g-string.ads})
15075 @cindex @code{GNAT.Strings} (@file{g-string.ads})
15076
15077 @noindent
15078 Common String access types and related subprograms. Basically it
15079 defines a string access and an array of string access types.
15080
15081 @node GNAT.String_Split (g-strspl.ads)
15082 @section @code{GNAT.String_Split} (@file{g-strspl.ads})
15083 @cindex @code{GNAT.String_Split} (@file{g-strspl.ads})
15084 @cindex String splitter
15085
15086 @noindent
15087 Useful string manipulation routines: given a set of separators, split
15088 a string wherever the separators appear, and provide direct access
15089 to the resulting slices. This package is instantiated from
15090 @code{GNAT.Array_Split}.
15091
15092 @node GNAT.Table (g-table.ads)
15093 @section @code{GNAT.Table} (@file{g-table.ads})
15094 @cindex @code{GNAT.Table} (@file{g-table.ads})
15095 @cindex Table implementation
15096 @cindex Arrays, extendable
15097
15098 @noindent
15099 A generic package providing a single dimension array abstraction where the
15100 length of the array can be dynamically modified.
15101
15102 @noindent
15103 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
15104 except that this package declares a single instance of the table type,
15105 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
15106 used to define dynamic instances of the table.
15107
15108 @node GNAT.Task_Lock (g-tasloc.ads)
15109 @section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
15110 @cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
15111 @cindex Task synchronization
15112 @cindex Task locking
15113 @cindex Locking
15114
15115 @noindent
15116 A very simple facility for locking and unlocking sections of code using a
15117 single global task lock.  Appropriate for use in situations where contention
15118 between tasks is very rarely expected.
15119
15120 @node GNAT.Time_Stamp (g-timsta.ads)
15121 @section @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
15122 @cindex @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
15123 @cindex Time stamp
15124 @cindex Current time
15125
15126 @noindent
15127 Provides a simple function that returns a string YYYY-MM-DD HH:MM:SS.SS that
15128 represents the current date and time in ISO 8601 format. This is a very simple
15129 routine with minimal code and there are no dependencies on any other unit.
15130
15131 @node GNAT.Threads (g-thread.ads)
15132 @section @code{GNAT.Threads} (@file{g-thread.ads})
15133 @cindex @code{GNAT.Threads} (@file{g-thread.ads})
15134 @cindex Foreign threads
15135 @cindex Threads, foreign
15136
15137 @noindent
15138 Provides facilities for dealing with foreign threads which need to be known
15139 by the GNAT run-time system. Consult the documentation of this package for
15140 further details if your program has threads that are created by a non-Ada
15141 environment which then accesses Ada code.
15142
15143 @node GNAT.Traceback (g-traceb.ads)
15144 @section @code{GNAT.Traceback} (@file{g-traceb.ads})
15145 @cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
15146 @cindex Trace back facilities
15147
15148 @noindent
15149 Provides a facility for obtaining non-symbolic traceback information, useful
15150 in various debugging situations.
15151
15152 @node GNAT.Traceback.Symbolic (g-trasym.ads)
15153 @section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
15154 @cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
15155 @cindex Trace back facilities
15156
15157 @node GNAT.UTF_32 (g-utf_32.ads)
15158 @section @code{GNAT.UTF_32} (@file{g-table.ads})
15159 @cindex @code{GNAT.UTF_32} (@file{g-table.ads})
15160 @cindex Wide character codes
15161
15162 @noindent
15163 This is a package intended to be used in conjunction with the
15164 @code{Wide_Character} type in Ada 95 and the
15165 @code{Wide_Wide_Character} type in Ada 2005 (available
15166 in @code{GNAT} in Ada 2005 mode). This package contains
15167 Unicode categorization routines, as well as lexical
15168 categorization routines corresponding to the Ada 2005
15169 lexical rules for identifiers and strings, and also a
15170 lower case to upper case fold routine corresponding to
15171 the Ada 2005 rules for identifier equivalence.
15172
15173 @node GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)
15174 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
15175 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
15176 @cindex Spell checking
15177
15178 @noindent
15179 Provides a function for determining whether one wide wide string is a plausible
15180 near misspelling of another wide wide string, where the strings are represented
15181 using the UTF_32_String type defined in System.Wch_Cnv.
15182
15183 @node GNAT.Wide_Spelling_Checker (g-wispch.ads)
15184 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
15185 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
15186 @cindex Spell checking
15187
15188 @noindent
15189 Provides a function for determining whether one wide string is a plausible
15190 near misspelling of another wide string.
15191
15192 @node GNAT.Wide_String_Split (g-wistsp.ads)
15193 @section @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
15194 @cindex @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
15195 @cindex Wide_String splitter
15196
15197 @noindent
15198 Useful wide string manipulation routines: given a set of separators, split
15199 a wide string wherever the separators appear, and provide direct access
15200 to the resulting slices. This package is instantiated from
15201 @code{GNAT.Array_Split}.
15202
15203 @node GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)
15204 @section @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
15205 @cindex @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
15206 @cindex Spell checking
15207
15208 @noindent
15209 Provides a function for determining whether one wide wide string is a plausible
15210 near misspelling of another wide wide string.
15211
15212 @node GNAT.Wide_Wide_String_Split (g-zistsp.ads)
15213 @section @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
15214 @cindex @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
15215 @cindex Wide_Wide_String splitter
15216
15217 @noindent
15218 Useful wide wide string manipulation routines: given a set of separators, split
15219 a wide wide string wherever the separators appear, and provide direct access
15220 to the resulting slices. This package is instantiated from
15221 @code{GNAT.Array_Split}.
15222
15223 @node Interfaces.C.Extensions (i-cexten.ads)
15224 @section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
15225 @cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
15226
15227 @noindent
15228 This package contains additional C-related definitions, intended
15229 for use with either manually or automatically generated bindings
15230 to C libraries.
15231
15232 @node Interfaces.C.Streams (i-cstrea.ads)
15233 @section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
15234 @cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
15235 @cindex  C streams, interfacing
15236
15237 @noindent
15238 This package is a binding for the most commonly used operations
15239 on C streams.
15240
15241 @node Interfaces.CPP (i-cpp.ads)
15242 @section @code{Interfaces.CPP} (@file{i-cpp.ads})
15243 @cindex @code{Interfaces.CPP} (@file{i-cpp.ads})
15244 @cindex  C++ interfacing
15245 @cindex  Interfacing, to C++
15246
15247 @noindent
15248 This package provides facilities for use in interfacing to C++.  It
15249 is primarily intended to be used in connection with automated tools
15250 for the generation of C++ interfaces.
15251
15252 @node Interfaces.Packed_Decimal (i-pacdec.ads)
15253 @section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
15254 @cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
15255 @cindex  IBM Packed Format
15256 @cindex  Packed Decimal
15257
15258 @noindent
15259 This package provides a set of routines for conversions to and
15260 from a packed decimal format compatible with that used on IBM
15261 mainframes.
15262
15263 @node Interfaces.VxWorks (i-vxwork.ads)
15264 @section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
15265 @cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
15266 @cindex Interfacing to VxWorks
15267 @cindex VxWorks, interfacing
15268
15269 @noindent
15270 This package provides a limited binding to the VxWorks API.
15271 In particular, it interfaces with the
15272 VxWorks hardware interrupt facilities.
15273
15274 @node Interfaces.VxWorks.IO (i-vxwoio.ads)
15275 @section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
15276 @cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
15277 @cindex Interfacing to VxWorks' I/O
15278 @cindex VxWorks, I/O interfacing
15279 @cindex VxWorks, Get_Immediate
15280 @cindex Get_Immediate, VxWorks
15281
15282 @noindent
15283 This package provides a binding to the ioctl (IO/Control)
15284 function of VxWorks, defining a set of option values and
15285 function codes. A particular use of this package is
15286 to enable the use of Get_Immediate under VxWorks.
15287
15288 @node System.Address_Image (s-addima.ads)
15289 @section @code{System.Address_Image} (@file{s-addima.ads})
15290 @cindex @code{System.Address_Image} (@file{s-addima.ads})
15291 @cindex Address image
15292 @cindex Image, of an address
15293
15294 @noindent
15295 This function provides a useful debugging
15296 function that gives an (implementation dependent)
15297 string which identifies an address.
15298
15299 @node System.Assertions (s-assert.ads)
15300 @section @code{System.Assertions} (@file{s-assert.ads})
15301 @cindex @code{System.Assertions} (@file{s-assert.ads})
15302 @cindex Assertions
15303 @cindex Assert_Failure, exception
15304
15305 @noindent
15306 This package provides the declaration of the exception raised
15307 by an run-time assertion failure, as well as the routine that
15308 is used internally to raise this assertion.
15309
15310 @node System.Memory (s-memory.ads)
15311 @section @code{System.Memory} (@file{s-memory.ads})
15312 @cindex @code{System.Memory} (@file{s-memory.ads})
15313 @cindex Memory allocation
15314
15315 @noindent
15316 This package provides the interface to the low level routines used
15317 by the generated code for allocation and freeing storage for the
15318 default storage pool (analogous to the C routines malloc and free.
15319 It also provides a reallocation interface analogous to the C routine
15320 realloc. The body of this unit may be modified to provide alternative
15321 allocation mechanisms for the default pool, and in addition, direct
15322 calls to this unit may be made for low level allocation uses (for
15323 example see the body of @code{GNAT.Tables}).
15324
15325 @node System.Partition_Interface (s-parint.ads)
15326 @section @code{System.Partition_Interface} (@file{s-parint.ads})
15327 @cindex @code{System.Partition_Interface} (@file{s-parint.ads})
15328 @cindex Partition interfacing functions
15329
15330 @noindent
15331 This package provides facilities for partition interfacing.  It
15332 is used primarily in a distribution context when using Annex E
15333 with @code{GLADE}.
15334
15335 @node System.Pool_Global (s-pooglo.ads)
15336 @section @code{System.Pool_Global} (@file{s-pooglo.ads})
15337 @cindex @code{System.Pool_Global} (@file{s-pooglo.ads})
15338 @cindex Storage pool, global
15339 @cindex Global storage pool
15340
15341 @noindent
15342 This package provides a storage pool that is equivalent to the default
15343 storage pool used for access types for which no pool is specifically
15344 declared. It uses malloc/free to allocate/free and does not attempt to
15345 do any automatic reclamation.
15346
15347 @node System.Pool_Local (s-pooloc.ads)
15348 @section @code{System.Pool_Local} (@file{s-pooloc.ads})
15349 @cindex @code{System.Pool_Local} (@file{s-pooloc.ads})
15350 @cindex Storage pool, local
15351 @cindex Local storage pool
15352
15353 @noindent
15354 This package provides a storage pool that is intended for use with locally
15355 defined access types. It uses malloc/free for allocate/free, and maintains
15356 a list of allocated blocks, so that all storage allocated for the pool can
15357 be freed automatically when the pool is finalized.
15358
15359 @node System.Restrictions (s-restri.ads)
15360 @section @code{System.Restrictions} (@file{s-restri.ads})
15361 @cindex @code{System.Restrictions} (@file{s-restri.ads})
15362 @cindex Run-time restrictions access
15363
15364 @noindent
15365 This package provides facilities for accessing at run time
15366 the status of restrictions specified at compile time for
15367 the partition. Information is available both with regard
15368 to actual restrictions specified, and with regard to
15369 compiler determined information on which restrictions
15370 are violated by one or more packages in the partition.
15371
15372 @node System.Rident (s-rident.ads)
15373 @section @code{System.Rident} (@file{s-rident.ads})
15374 @cindex @code{System.Rident} (@file{s-rident.ads})
15375 @cindex Restrictions definitions
15376
15377 @noindent
15378 This package provides definitions of the restrictions
15379 identifiers supported by GNAT, and also the format of
15380 the restrictions provided in package System.Restrictions.
15381 It is not normally necessary to @code{with} this generic package
15382 since the necessary instantiation is included in
15383 package System.Restrictions.
15384
15385 @node System.Strings.Stream_Ops (s-ststop.ads)
15386 @section @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
15387 @cindex @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
15388 @cindex Stream operations
15389 @cindex String stream operations
15390
15391 @noindent
15392 This package provides a set of stream subprograms for standard string types.
15393 It is intended primarily to support implicit use of such subprograms when
15394 stream attributes are applied to string types, but the subprograms in this
15395 package can be used directly by application programs.
15396
15397 @node System.Task_Info (s-tasinf.ads)
15398 @section @code{System.Task_Info} (@file{s-tasinf.ads})
15399 @cindex @code{System.Task_Info} (@file{s-tasinf.ads})
15400 @cindex Task_Info pragma
15401
15402 @noindent
15403 This package provides target dependent functionality that is used
15404 to support the @code{Task_Info} pragma
15405
15406 @node System.Wch_Cnv (s-wchcnv.ads)
15407 @section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
15408 @cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
15409 @cindex Wide Character, Representation
15410 @cindex Wide String, Conversion
15411 @cindex Representation of wide characters
15412
15413 @noindent
15414 This package provides routines for converting between
15415 wide and wide wide characters and a representation as a value of type
15416 @code{Standard.String}, using a specified wide character
15417 encoding method.  It uses definitions in
15418 package @code{System.Wch_Con}.
15419
15420 @node System.Wch_Con (s-wchcon.ads)
15421 @section @code{System.Wch_Con} (@file{s-wchcon.ads})
15422 @cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
15423
15424 @noindent
15425 This package provides definitions and descriptions of
15426 the various methods used for encoding wide characters
15427 in ordinary strings.  These definitions are used by
15428 the package @code{System.Wch_Cnv}.
15429
15430 @node Interfacing to Other Languages
15431 @chapter Interfacing to Other Languages
15432 @noindent
15433 The facilities in annex B of the Ada Reference Manual are fully
15434 implemented in GNAT, and in addition, a full interface to C++ is
15435 provided.
15436
15437 @menu
15438 * Interfacing to C::
15439 * Interfacing to C++::
15440 * Interfacing to COBOL::
15441 * Interfacing to Fortran::
15442 * Interfacing to non-GNAT Ada code::
15443 @end menu
15444
15445 @node Interfacing to C
15446 @section Interfacing to C
15447
15448 @noindent
15449 Interfacing to C with GNAT can use one of two approaches:
15450
15451 @itemize @bullet
15452 @item
15453 The types in the package @code{Interfaces.C} may be used.
15454 @item
15455 Standard Ada types may be used directly.  This may be less portable to
15456 other compilers, but will work on all GNAT compilers, which guarantee
15457 correspondence between the C and Ada types.
15458 @end itemize
15459
15460 @noindent
15461 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
15462 effect, since this is the default.  The following table shows the
15463 correspondence between Ada scalar types and the corresponding C types.
15464
15465 @table @code
15466 @item Integer
15467 @code{int}
15468 @item Short_Integer
15469 @code{short}
15470 @item Short_Short_Integer
15471 @code{signed char}
15472 @item Long_Integer
15473 @code{long}
15474 @item Long_Long_Integer
15475 @code{long long}
15476 @item Short_Float
15477 @code{float}
15478 @item Float
15479 @code{float}
15480 @item Long_Float
15481 @code{double}
15482 @item Long_Long_Float
15483 This is the longest floating-point type supported by the hardware.
15484 @end table
15485
15486 @noindent
15487 Additionally, there are the following general correspondences between Ada
15488 and C types:
15489 @itemize @bullet
15490 @item
15491 Ada enumeration types map to C enumeration types directly if pragma
15492 @code{Convention C} is specified, which causes them to have int
15493 length.  Without pragma @code{Convention C}, Ada enumeration types map to
15494 8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short},
15495 @code{int}, respectively) depending on the number of values passed.
15496 This is the only case in which pragma @code{Convention C} affects the
15497 representation of an Ada type.
15498
15499 @item
15500 Ada access types map to C pointers, except for the case of pointers to
15501 unconstrained types in Ada, which have no direct C equivalent.
15502
15503 @item
15504 Ada arrays map directly to C arrays.
15505
15506 @item
15507 Ada records map directly to C structures.
15508
15509 @item
15510 Packed Ada records map to C structures where all members are bit fields
15511 of the length corresponding to the @code{@var{type}'Size} value in Ada.
15512 @end itemize
15513
15514 @node Interfacing to C++
15515 @section Interfacing to C++
15516
15517 @noindent
15518 The interface to C++ makes use of the following pragmas, which are
15519 primarily intended to be constructed automatically using a binding generator
15520 tool, although it is possible to construct them by hand.  No suitable binding
15521 generator tool is supplied with GNAT though.
15522
15523 Using these pragmas it is possible to achieve complete
15524 inter-operability between Ada tagged types and C++ class definitions.
15525 See @ref{Implementation Defined Pragmas}, for more details.
15526
15527 @table @code
15528 @item pragma CPP_Class ([Entity =>] @var{LOCAL_NAME})
15529 The argument denotes an entity in the current declarative region that is
15530 declared as a tagged or untagged record type. It indicates that the type
15531 corresponds to an externally declared C++ class type, and is to be laid
15532 out the same way that C++ would lay out the type.
15533
15534 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
15535 for backward compatibility but its functionality is available
15536 using pragma @code{Import} with @code{Convention} = @code{CPP}.
15537
15538 @item pragma CPP_Constructor ([Entity =>] @var{LOCAL_NAME})
15539 This pragma identifies an imported function (imported in the usual way
15540 with pragma @code{Import}) as corresponding to a C++ constructor.
15541 @end table
15542
15543 @node Interfacing to COBOL
15544 @section Interfacing to COBOL
15545
15546 @noindent
15547 Interfacing to COBOL is achieved as described in section B.4 of
15548 the Ada Reference Manual.
15549
15550 @node Interfacing to Fortran
15551 @section Interfacing to Fortran
15552
15553 @noindent
15554 Interfacing to Fortran is achieved as described in section B.5 of the
15555 Ada Reference Manual.  The pragma @code{Convention Fortran}, applied to a
15556 multi-dimensional array causes the array to be stored in column-major
15557 order as required for convenient interface to Fortran.
15558
15559 @node Interfacing to non-GNAT Ada code
15560 @section Interfacing to non-GNAT Ada code
15561
15562 It is possible to specify the convention @code{Ada} in a pragma
15563 @code{Import} or pragma @code{Export}.  However this refers to
15564 the calling conventions used by GNAT, which may or may not be
15565 similar enough to those used by some other Ada 83 / Ada 95 / Ada 2005
15566 compiler to allow interoperation.
15567
15568 If arguments types are kept simple, and if the foreign compiler generally
15569 follows system calling conventions, then it may be possible to integrate
15570 files compiled by other Ada compilers, provided that the elaboration
15571 issues are adequately addressed (for example by eliminating the
15572 need for any load time elaboration).
15573
15574 In particular, GNAT running on VMS is designed to
15575 be highly compatible with the DEC Ada 83 compiler, so this is one
15576 case in which it is possible to import foreign units of this type,
15577 provided that the data items passed are restricted to simple scalar
15578 values or simple record types without variants, or simple array
15579 types with fixed bounds.
15580
15581 @node Specialized Needs Annexes
15582 @chapter Specialized Needs Annexes
15583
15584 @noindent
15585 Ada 95 and Ada 2005 define a number of Specialized Needs Annexes, which are not
15586 required in all implementations.  However, as described in this chapter,
15587 GNAT implements all of these annexes:
15588
15589 @table @asis
15590 @item Systems Programming (Annex C)
15591 The Systems Programming Annex is fully implemented.
15592
15593 @item Real-Time Systems (Annex D)
15594 The Real-Time Systems Annex is fully implemented.
15595
15596 @item Distributed Systems (Annex E)
15597 Stub generation is fully implemented in the GNAT compiler.  In addition,
15598 a complete compatible PCS is available as part of the GLADE system,
15599 a separate product.  When the two
15600 products are used in conjunction, this annex is fully implemented.
15601
15602 @item Information Systems (Annex F)
15603 The Information Systems annex is fully implemented.
15604
15605 @item Numerics (Annex G)
15606 The Numerics Annex is fully implemented.
15607
15608 @item Safety and Security / High-Integrity Systems (Annex H)
15609 The Safety and Security Annex (termed the High-Integrity Systems Annex
15610 in Ada 2005) is fully implemented.
15611 @end table
15612
15613 @node Implementation of Specific Ada Features
15614 @chapter Implementation of Specific Ada Features
15615
15616 @noindent
15617 This chapter describes the GNAT implementation of several Ada language
15618 facilities.
15619
15620 @menu
15621 * Machine Code Insertions::
15622 * GNAT Implementation of Tasking::
15623 * GNAT Implementation of Shared Passive Packages::
15624 * Code Generation for Array Aggregates::
15625 * The Size of Discriminated Records with Default Discriminants::
15626 * Strict Conformance to the Ada Reference Manual::
15627 @end menu
15628
15629 @node Machine Code Insertions
15630 @section Machine Code Insertions
15631 @cindex Machine Code insertions
15632
15633 @noindent
15634 Package @code{Machine_Code} provides machine code support as described
15635 in the Ada Reference Manual in two separate forms:
15636 @itemize @bullet
15637 @item
15638 Machine code statements, consisting of qualified expressions that
15639 fit the requirements of RM section 13.8.
15640 @item
15641 An intrinsic callable procedure, providing an alternative mechanism of
15642 including machine instructions in a subprogram.
15643 @end itemize
15644
15645 @noindent
15646 The two features are similar, and both are closely related to the mechanism
15647 provided by the asm instruction in the GNU C compiler.  Full understanding
15648 and use of the facilities in this package requires understanding the asm
15649 instruction, see @ref{Extended Asm,, Assembler Instructions with C Expression
15650 Operands, gcc, Using the GNU Compiler Collection (GCC)}.
15651
15652 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
15653 semantic restrictions and effects as described below.  Both are provided so
15654 that the procedure call can be used as a statement, and the function call
15655 can be used to form a code_statement.
15656
15657 The first example given in the GCC documentation is the C @code{asm}
15658 instruction:
15659 @smallexample
15660    asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
15661 @end smallexample
15662
15663 @noindent
15664 The equivalent can be written for GNAT as:
15665
15666 @smallexample @c ada
15667 Asm ("fsinx %1 %0",
15668      My_Float'Asm_Output ("=f", result),
15669      My_Float'Asm_Input  ("f",  angle));
15670 @end smallexample
15671
15672 @noindent
15673 The first argument to @code{Asm} is the assembler template, and is
15674 identical to what is used in GNU C@.  This string must be a static
15675 expression.  The second argument is the output operand list.  It is
15676 either a single @code{Asm_Output} attribute reference, or a list of such
15677 references enclosed in parentheses (technically an array aggregate of
15678 such references).
15679
15680 The @code{Asm_Output} attribute denotes a function that takes two
15681 parameters.  The first is a string, the second is the name of a variable
15682 of the type designated by the attribute prefix.  The first (string)
15683 argument is required to be a static expression and designates the
15684 constraint for the parameter (e.g.@: what kind of register is
15685 required).  The second argument is the variable to be updated with the
15686 result.  The possible values for constraint are the same as those used in
15687 the RTL, and are dependent on the configuration file used to build the
15688 GCC back end.  If there are no output operands, then this argument may
15689 either be omitted, or explicitly given as @code{No_Output_Operands}.
15690
15691 The second argument of @code{@var{my_float}'Asm_Output} functions as
15692 though it were an @code{out} parameter, which is a little curious, but
15693 all names have the form of expressions, so there is no syntactic
15694 irregularity, even though normally functions would not be permitted
15695 @code{out} parameters.  The third argument is the list of input
15696 operands.  It is either a single @code{Asm_Input} attribute reference, or
15697 a list of such references enclosed in parentheses (technically an array
15698 aggregate of such references).
15699
15700 The @code{Asm_Input} attribute denotes a function that takes two
15701 parameters.  The first is a string, the second is an expression of the
15702 type designated by the prefix.  The first (string) argument is required
15703 to be a static expression, and is the constraint for the parameter,
15704 (e.g.@: what kind of register is required).  The second argument is the
15705 value to be used as the input argument.  The possible values for the
15706 constant are the same as those used in the RTL, and are dependent on
15707 the configuration file used to built the GCC back end.
15708
15709 If there are no input operands, this argument may either be omitted, or
15710 explicitly given as @code{No_Input_Operands}.  The fourth argument, not
15711 present in the above example, is a list of register names, called the
15712 @dfn{clobber} argument.  This argument, if given, must be a static string
15713 expression, and is a space or comma separated list of names of registers
15714 that must be considered destroyed as a result of the @code{Asm} call.  If
15715 this argument is the null string (the default value), then the code
15716 generator assumes that no additional registers are destroyed.
15717
15718 The fifth argument, not present in the above example, called the
15719 @dfn{volatile} argument, is by default @code{False}.  It can be set to
15720 the literal value @code{True} to indicate to the code generator that all
15721 optimizations with respect to the instruction specified should be
15722 suppressed, and that in particular, for an instruction that has outputs,
15723 the instruction will still be generated, even if none of the outputs are
15724 used.  @xref{Extended Asm,, Assembler Instructions with C Expression Operands,
15725 gcc, Using the GNU Compiler Collection (GCC)}, for the full description.
15726 Generally it is strongly advisable to use Volatile for any ASM statement
15727 that is missing either input or output operands, or when two or more ASM
15728 statements appear in sequence, to avoid unwanted optimizations. A warning
15729 is generated if this advice is not followed.
15730
15731 The @code{Asm} subprograms may be used in two ways.  First the procedure
15732 forms can be used anywhere a procedure call would be valid, and
15733 correspond to what the RM calls ``intrinsic'' routines.  Such calls can
15734 be used to intersperse machine instructions with other Ada statements.
15735 Second, the function forms, which return a dummy value of the limited
15736 private type @code{Asm_Insn}, can be used in code statements, and indeed
15737 this is the only context where such calls are allowed.  Code statements
15738 appear as aggregates of the form:
15739
15740 @smallexample @c ada
15741 Asm_Insn'(Asm (@dots{}));
15742 Asm_Insn'(Asm_Volatile (@dots{}));
15743 @end smallexample
15744
15745 @noindent
15746 In accordance with RM rules, such code statements are allowed only
15747 within subprograms whose entire body consists of such statements.  It is
15748 not permissible to intermix such statements with other Ada statements.
15749
15750 Typically the form using intrinsic procedure calls is more convenient
15751 and more flexible.  The code statement form is provided to meet the RM
15752 suggestion that such a facility should be made available.  The following
15753 is the exact syntax of the call to @code{Asm}. As usual, if named notation
15754 is used, the arguments may be given in arbitrary order, following the
15755 normal rules for use of positional and named arguments)
15756
15757 @smallexample
15758 ASM_CALL ::= Asm (
15759                  [Template =>] static_string_EXPRESSION
15760                [,[Outputs  =>] OUTPUT_OPERAND_LIST      ]
15761                [,[Inputs   =>] INPUT_OPERAND_LIST       ]
15762                [,[Clobber  =>] static_string_EXPRESSION ]
15763                [,[Volatile =>] static_boolean_EXPRESSION] )
15764
15765 OUTPUT_OPERAND_LIST ::=
15766   [PREFIX.]No_Output_Operands
15767 | OUTPUT_OPERAND_ATTRIBUTE
15768 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
15769
15770 OUTPUT_OPERAND_ATTRIBUTE ::=
15771   SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
15772
15773 INPUT_OPERAND_LIST ::=
15774   [PREFIX.]No_Input_Operands
15775 | INPUT_OPERAND_ATTRIBUTE
15776 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
15777
15778 INPUT_OPERAND_ATTRIBUTE ::=
15779   SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
15780 @end smallexample
15781
15782 @noindent
15783 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
15784 are declared in the package @code{Machine_Code} and must be referenced
15785 according to normal visibility rules. In particular if there is no
15786 @code{use} clause for this package, then appropriate package name
15787 qualification is required.
15788
15789 @node GNAT Implementation of Tasking
15790 @section GNAT Implementation of Tasking
15791
15792 @noindent
15793 This chapter outlines the basic GNAT approach to tasking (in particular,
15794 a multi-layered library for portability) and discusses issues related
15795 to compliance with the Real-Time Systems Annex.
15796
15797 @menu
15798 * Mapping Ada Tasks onto the Underlying Kernel Threads::
15799 * Ensuring Compliance with the Real-Time Annex::
15800 @end menu
15801
15802 @node Mapping Ada Tasks onto the Underlying Kernel Threads
15803 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
15804
15805 @noindent
15806 GNAT's run-time support comprises two layers:
15807
15808 @itemize @bullet
15809 @item GNARL (GNAT Run-time Layer)
15810 @item GNULL (GNAT Low-level Library)
15811 @end itemize
15812
15813 @noindent
15814 In GNAT, Ada's tasking services rely on a platform and OS independent
15815 layer known as GNARL@.  This code is responsible for implementing the
15816 correct semantics of Ada's task creation, rendezvous, protected
15817 operations etc.
15818
15819 GNARL decomposes Ada's tasking semantics into simpler lower level
15820 operations such as create a thread, set the priority of a thread,
15821 yield, create a lock, lock/unlock, etc.  The spec for these low-level
15822 operations constitutes GNULLI, the GNULL Interface.  This interface is
15823 directly inspired from the POSIX real-time API@.
15824
15825 If the underlying executive or OS implements the POSIX standard
15826 faithfully, the GNULL Interface maps as is to the services offered by
15827 the underlying kernel.  Otherwise, some target dependent glue code maps
15828 the services offered by the underlying kernel to the semantics expected
15829 by GNARL@.
15830
15831 Whatever the underlying OS (VxWorks, UNIX, Windows, etc.) the
15832 key point is that each Ada task is mapped on a thread in the underlying
15833 kernel.  For example, in the case of VxWorks, one Ada task = one VxWorks task.
15834
15835 In addition Ada task priorities map onto the underlying thread priorities.
15836 Mapping Ada tasks onto the underlying kernel threads has several advantages:
15837
15838 @itemize @bullet
15839 @item
15840 The underlying scheduler is used to schedule the Ada tasks.  This
15841 makes Ada tasks as efficient as kernel threads from a scheduling
15842 standpoint.
15843
15844 @item
15845 Interaction with code written in C containing threads is eased
15846 since at the lowest level Ada tasks and C threads map onto the same
15847 underlying kernel concept.
15848
15849 @item
15850 When an Ada task is blocked during I/O the remaining Ada tasks are
15851 able to proceed.
15852
15853 @item
15854 On multiprocessor systems Ada tasks can execute in parallel.
15855 @end itemize
15856
15857 @noindent
15858 Some threads libraries offer a mechanism to fork a new process, with the
15859 child process duplicating the threads from the parent.
15860 GNAT does not
15861 support this functionality when the parent contains more than one task.
15862 @cindex Forking a new process
15863
15864 @node Ensuring Compliance with the Real-Time Annex
15865 @subsection Ensuring Compliance with the Real-Time Annex
15866 @cindex Real-Time Systems Annex compliance
15867
15868 @noindent
15869 Although mapping Ada tasks onto
15870 the underlying threads has significant advantages, it does create some
15871 complications when it comes to respecting the scheduling semantics
15872 specified in the real-time annex (Annex D).
15873
15874 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
15875 scheduling policy states:
15876
15877 @quotation
15878 @emph{When the active priority of a ready task that is not running
15879 changes, or the setting of its base priority takes effect, the
15880 task is removed from the ready queue for its old active priority
15881 and is added at the tail of the ready queue for its new active
15882 priority, except in the case where the active priority is lowered
15883 due to the loss of inherited priority, in which case the task is
15884 added at the head of the ready queue for its new active priority.}
15885 @end quotation
15886
15887 @noindent
15888 While most kernels do put tasks at the end of the priority queue when
15889 a task changes its priority, (which respects the main
15890 FIFO_Within_Priorities requirement), almost none keep a thread at the
15891 beginning of its priority queue when its priority drops from the loss
15892 of inherited priority.
15893
15894 As a result most vendors have provided incomplete Annex D implementations.
15895
15896 The GNAT run-time, has a nice cooperative solution to this problem
15897 which ensures that accurate FIFO_Within_Priorities semantics are
15898 respected.
15899
15900 The principle is as follows.  When an Ada task T is about to start
15901 running, it checks whether some other Ada task R with the same
15902 priority as T has been suspended due to the loss of priority
15903 inheritance.  If this is the case, T yields and is placed at the end of
15904 its priority queue.  When R arrives at the front of the queue it
15905 executes.
15906
15907 Note that this simple scheme preserves the relative order of the tasks
15908 that were ready to execute in the priority queue where R has been
15909 placed at the end.
15910
15911 @node GNAT Implementation of Shared Passive Packages
15912 @section GNAT Implementation of Shared Passive Packages
15913 @cindex Shared passive packages
15914
15915 @noindent
15916 GNAT fully implements the pragma @code{Shared_Passive} for
15917 @cindex pragma @code{Shared_Passive}
15918 the purpose of designating shared passive packages.
15919 This allows the use of passive partitions in the
15920 context described in the Ada Reference Manual; i.e., for communication
15921 between separate partitions of a distributed application using the
15922 features in Annex E.
15923 @cindex Annex E
15924 @cindex Distribution Systems Annex
15925
15926 However, the implementation approach used by GNAT provides for more
15927 extensive usage as follows:
15928
15929 @table @emph
15930 @item Communication between separate programs
15931
15932 This allows separate programs to access the data in passive
15933 partitions, using protected objects for synchronization where
15934 needed. The only requirement is that the two programs have a
15935 common shared file system. It is even possible for programs
15936 running on different machines with different architectures
15937 (e.g.@: different endianness) to communicate via the data in
15938 a passive partition.
15939
15940 @item Persistence between program runs
15941
15942 The data in a passive package can persist from one run of a
15943 program to another, so that a later program sees the final
15944 values stored by a previous run of the same program.
15945
15946 @end table
15947
15948 @noindent
15949 The implementation approach used is to store the data in files. A
15950 separate stream file is created for each object in the package, and
15951 an access to an object causes the corresponding file to be read or
15952 written.
15953
15954 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
15955 @cindex @code{SHARED_MEMORY_DIRECTORY} environment variable
15956 set to the directory to be used for these files.
15957 The files in this directory
15958 have names that correspond to their fully qualified names. For
15959 example, if we have the package
15960
15961 @smallexample @c ada
15962 package X is
15963   pragma Shared_Passive (X);
15964   Y : Integer;
15965   Z : Float;
15966 end X;
15967 @end smallexample
15968
15969 @noindent
15970 and the environment variable is set to @code{/stemp/}, then the files created
15971 will have the names:
15972
15973 @smallexample
15974 /stemp/x.y
15975 /stemp/x.z
15976 @end smallexample
15977
15978 @noindent
15979 These files are created when a value is initially written to the object, and
15980 the files are retained until manually deleted. This provides the persistence
15981 semantics. If no file exists, it means that no partition has assigned a value
15982 to the variable; in this case the initial value declared in the package
15983 will be used. This model ensures that there are no issues in synchronizing
15984 the elaboration process, since elaboration of passive packages elaborates the
15985 initial values, but does not create the files.
15986
15987 The files are written using normal @code{Stream_IO} access.
15988 If you want to be able
15989 to communicate between programs or partitions running on different
15990 architectures, then you should use the XDR versions of the stream attribute
15991 routines, since these are architecture independent.
15992
15993 If active synchronization is required for access to the variables in the
15994 shared passive package, then as described in the Ada Reference Manual, the
15995 package may contain protected objects used for this purpose. In this case
15996 a lock file (whose name is @file{___lock} (three underscores)
15997 is created in the shared memory directory.
15998 @cindex @file{___lock} file (for shared passive packages)
15999 This is used to provide the required locking
16000 semantics for proper protected object synchronization.
16001
16002 As of January 2003, GNAT supports shared passive packages on all platforms
16003 except for OpenVMS.
16004
16005 @node Code Generation for Array Aggregates
16006 @section Code Generation for Array Aggregates
16007
16008 @menu
16009 * Static constant aggregates with static bounds::
16010 * Constant aggregates with unconstrained nominal types::
16011 * Aggregates with static bounds::
16012 * Aggregates with non-static bounds::
16013 * Aggregates in assignment statements::
16014 @end menu
16015
16016 @noindent
16017 Aggregates have a rich syntax and allow the user to specify the values of
16018 complex data structures by means of a single construct.  As a result, the
16019 code generated for aggregates can be quite complex and involve loops, case
16020 statements and multiple assignments.  In the simplest cases, however, the
16021 compiler will recognize aggregates whose components and constraints are
16022 fully static, and in those cases the compiler will generate little or no
16023 executable code.  The following is an outline of the code that GNAT generates
16024 for various aggregate constructs.  For further details, you will find it
16025 useful to examine the output produced by the -gnatG flag to see the expanded
16026 source that is input to the code generator.  You may also want to examine
16027 the assembly code generated at various levels of optimization.
16028
16029 The code generated for aggregates depends on the context, the component values,
16030 and the type.  In the context of an object declaration the code generated is
16031 generally simpler than in the case of an assignment.  As a general rule, static
16032 component values and static subtypes also lead to simpler code.
16033
16034 @node Static constant aggregates with static bounds
16035 @subsection Static constant aggregates with static bounds
16036
16037 @noindent
16038 For the declarations:
16039 @smallexample @c ada
16040     type One_Dim is array (1..10) of integer;
16041     ar0 : constant One_Dim := (1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
16042 @end smallexample
16043
16044 @noindent
16045 GNAT generates no executable code: the constant ar0 is placed in static memory.
16046 The same is true for constant aggregates with named associations:
16047
16048 @smallexample @c ada
16049     Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1 => 1, 5 .. 10 => 0);
16050     Cr3 : constant One_Dim := (others => 7777);
16051 @end smallexample
16052
16053 @noindent
16054 The same is true for multidimensional constant arrays such as:
16055
16056 @smallexample @c ada
16057     type two_dim is array (1..3, 1..3) of integer;
16058     Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
16059 @end smallexample
16060
16061 @noindent
16062 The same is true for arrays of one-dimensional arrays: the following are
16063 static:
16064
16065 @smallexample @c ada
16066 type ar1b  is array (1..3) of boolean;
16067 type ar_ar is array (1..3) of ar1b;
16068 None  : constant ar1b := (others => false);     --  fully static
16069 None2 : constant ar_ar := (1..3 => None);       --  fully static
16070 @end smallexample
16071
16072 @noindent
16073 However, for multidimensional aggregates with named associations, GNAT will
16074 generate assignments and loops, even if all associations are static.  The
16075 following two declarations generate a loop for the first dimension, and
16076 individual component assignments for the second dimension:
16077
16078 @smallexample @c ada
16079 Zero1: constant two_dim := (1..3 => (1..3 => 0));
16080 Zero2: constant two_dim := (others => (others => 0));
16081 @end smallexample
16082
16083 @node Constant aggregates with unconstrained nominal types
16084 @subsection Constant aggregates with unconstrained nominal types
16085
16086 @noindent
16087 In such cases the aggregate itself establishes the subtype, so that
16088 associations with @code{others} cannot be used.  GNAT determines the
16089 bounds for the actual subtype of the aggregate, and allocates the
16090 aggregate statically as well.  No code is generated for the following:
16091
16092 @smallexample @c ada
16093     type One_Unc is array (natural range <>) of integer;
16094     Cr_Unc : constant One_Unc := (12,24,36);
16095 @end smallexample
16096
16097 @node Aggregates with static bounds
16098 @subsection Aggregates with static bounds
16099
16100 @noindent
16101 In all previous examples the aggregate was the initial (and immutable) value
16102 of a constant.  If the aggregate initializes a variable, then code is generated
16103 for it as a combination of individual assignments and loops over the target
16104 object.  The declarations
16105
16106 @smallexample @c ada
16107        Cr_Var1 : One_Dim := (2, 5, 7, 11, 0, 0, 0, 0, 0, 0);
16108        Cr_Var2 : One_Dim := (others > -1);
16109 @end smallexample
16110
16111 @noindent
16112 generate the equivalent of
16113
16114 @smallexample @c ada
16115        Cr_Var1 (1) := 2;
16116        Cr_Var1 (2) := 3;
16117        Cr_Var1 (3) := 5;
16118        Cr_Var1 (4) := 11;
16119
16120        for I in Cr_Var2'range loop
16121           Cr_Var2 (I) := -1;
16122        end loop;
16123 @end smallexample
16124
16125 @node Aggregates with non-static bounds
16126 @subsection Aggregates with non-static bounds
16127
16128 @noindent
16129 If the bounds of the aggregate are not statically compatible with the bounds
16130 of the nominal subtype  of the target, then constraint checks have to be
16131 generated on the bounds.  For a multidimensional array, constraint checks may
16132 have to be applied to sub-arrays individually, if they do not have statically
16133 compatible subtypes.
16134
16135 @node Aggregates in assignment statements
16136 @subsection Aggregates in assignment statements
16137
16138 @noindent
16139 In general, aggregate assignment requires the construction of a temporary,
16140 and a copy from the temporary to the target of the assignment.  This is because
16141 it is not always possible to convert the assignment into a series of individual
16142 component assignments.  For example, consider the simple case:
16143
16144 @smallexample @c ada
16145         A := (A(2), A(1));
16146 @end smallexample
16147
16148 @noindent
16149 This cannot be converted into:
16150
16151 @smallexample @c ada
16152         A(1) := A(2);
16153         A(2) := A(1);
16154 @end smallexample
16155
16156 @noindent
16157 So the aggregate has to be built first in a separate location, and then
16158 copied into the target.  GNAT recognizes simple cases where this intermediate
16159 step is not required, and the assignments can be performed in place, directly
16160 into the target.  The following sufficient criteria are applied:
16161
16162 @itemize @bullet
16163 @item
16164 The bounds of the aggregate are static, and the associations are static.
16165 @item
16166 The components of the aggregate are static constants, names of
16167 simple variables that are not renamings, or expressions not involving
16168 indexed components whose operands obey these rules.
16169 @end itemize
16170
16171 @noindent
16172 If any of these conditions are violated, the aggregate will be built in
16173 a temporary (created either by the front-end or the code generator) and then
16174 that temporary will be copied onto the target.
16175
16176 @node The Size of Discriminated Records with Default Discriminants
16177 @section The Size of Discriminated Records with Default Discriminants
16178
16179 @noindent
16180 If a discriminated type @code{T} has discriminants with default values, it is
16181 possible to declare an object of this type without providing an explicit
16182 constraint:
16183
16184 @smallexample @c ada
16185 @group
16186 type Size is range 1..100;
16187
16188 type Rec (D : Size := 15) is record
16189    Name : String (1..D);
16190 end T;
16191
16192 Word : Rec;
16193 @end group
16194 @end smallexample
16195
16196 @noindent
16197 Such an object is said to be @emph{unconstrained}.
16198 The discriminant of the object
16199 can be modified by a full assignment to the object, as long as it preserves the
16200 relation between the value of the discriminant, and the value of the components
16201 that depend on it:
16202
16203 @smallexample @c ada
16204 @group
16205 Word := (3, "yes");
16206
16207 Word := (5, "maybe");
16208
16209 Word := (5, "no"); -- raises Constraint_Error
16210 @end group
16211 @end smallexample
16212
16213 @noindent
16214 In order to support this behavior efficiently, an unconstrained object is
16215 given the maximum size that any value of the type requires. In the case
16216 above, @code{Word} has storage for the discriminant and for
16217 a @code{String} of length 100.
16218 It is important to note that unconstrained objects do not require dynamic
16219 allocation. It would be an improper implementation to place on the heap those
16220 components whose size depends on discriminants. (This improper implementation
16221 was used by some Ada83 compilers, where the @code{Name} component above
16222 would have
16223 been stored as a pointer to a dynamic string). Following the principle that
16224 dynamic storage management should never be introduced implicitly,
16225 an Ada compiler should reserve the full size for an unconstrained declared
16226 object, and place it on the stack.
16227
16228 This maximum size approach
16229 has been a source of surprise to some users, who expect the default
16230 values of the discriminants to determine the size reserved for an
16231 unconstrained object: ``If the default is 15, why should the object occupy
16232 a larger size?''
16233 The answer, of course, is that the discriminant may be later modified,
16234 and its full range of values must be taken into account. This is why the
16235 declaration:
16236
16237 @smallexample
16238 @group
16239 type Rec (D : Positive := 15) is record
16240    Name : String (1..D);
16241 end record;
16242
16243 Too_Large : Rec;
16244 @end group
16245 @end smallexample
16246
16247 @noindent
16248 is flagged by the compiler with a warning:
16249 an attempt to create @code{Too_Large} will raise @code{Storage_Error},
16250 because the required size includes @code{Positive'Last}
16251 bytes. As the first example indicates, the proper approach is to declare an
16252 index type of ``reasonable'' range so that unconstrained objects are not too
16253 large.
16254
16255 One final wrinkle: if the object is declared to be @code{aliased}, or if it is
16256 created in the heap by means of an allocator, then it is @emph{not}
16257 unconstrained:
16258 it is constrained by the default values of the discriminants, and those values
16259 cannot be modified by full assignment. This is because in the presence of
16260 aliasing all views of the object (which may be manipulated by different tasks,
16261 say) must be consistent, so it is imperative that the object, once created,
16262 remain invariant.
16263
16264 @node Strict Conformance to the Ada Reference Manual
16265 @section Strict Conformance to the Ada Reference Manual
16266
16267 @noindent
16268 The dynamic semantics defined by the Ada Reference Manual impose a set of
16269 run-time checks to be generated. By default, the GNAT compiler will insert many
16270 run-time checks into the compiled code, including most of those required by the
16271 Ada Reference Manual. However, there are three checks that are not enabled
16272 in the default mode for efficiency reasons: arithmetic overflow checking for
16273 integer operations (including division by zero), checks for access before
16274 elaboration on subprogram calls, and stack overflow checking (most operating
16275 systems do not perform this check by default).
16276
16277 Strict conformance to the Ada Reference Manual can be achieved by adding
16278 three compiler options for overflow checking for integer operations
16279 (@option{-gnato}), dynamic checks for access-before-elaboration on subprogram
16280 calls and generic instantiations (@option{-gnatE}), and stack overflow
16281 checking (@option{-fstack-check}).
16282
16283 Note that the result of a floating point arithmetic operation in overflow and
16284 invalid situations, when the @code{Machine_Overflows} attribute of the result
16285 type is @code{False}, is to generate IEEE NaN and infinite values. This is the
16286 case for machines compliant with the IEEE floating-point standard, but on
16287 machines that are not fully compliant with this standard, such as Alpha, the
16288 @option{-mieee} compiler flag must be used for achieving IEEE confirming
16289 behavior (although at the cost of a significant performance penalty), so
16290 infinite and and NaN values are properly generated.
16291
16292
16293 @node Implementation of Ada 2012 Features
16294 @chapter Implementation of Ada 2012 Features
16295 @cindex Ada 2012 implementation status
16296
16297 This chapter contains a complete list of Ada 2012 features that have been
16298 implemented as of GNAT version 6.4. Generally, these features are only
16299 available if the @option{-gnat12} (Ada 2012 features enabled) flag is set
16300 @cindex @option{-gnat12} option
16301 or if the configuration pragma @code{Ada_2012} is used.
16302 @cindex pragma @code{Ada_2012}
16303 @cindex configuration pragma @code{Ada_2012}
16304 @cindex @code{Ada_2012} configuration pragma
16305 However, new pragmas, attributes, and restrictions are
16306 unconditionally available, since the Ada 95 standard allows the addition of
16307 new pragmas, attributes, and restrictions (there are exceptions, which are
16308 documented in the individual descriptions), and also certain packages
16309 were made available in earlier versions of Ada.
16310
16311 An ISO date (YYYY-MM-DD) appears in parentheses on the description line.
16312 This date shows the implementation date of the feature. Any wavefront
16313 subsequent to this date will contain the indicated feature, as will any
16314 subsequent releases. A date of 0000-00-00 means that GNAT has always
16315 implemented the feature, or implemented it as soon as it appeared as a
16316 binding interpretation.
16317
16318 Each feature corresponds to an Ada Issue (``AI'') approved by the Ada
16319 standardization group (ISO/IEC JTC1/SC22/WG9) for inclusion in Ada 2012.
16320 The features are ordered based on the relevant sections of the Ada
16321 Reference Manual (``RM'').  When a given AI relates to multiple points
16322 in the RM, the earliest is used.
16323
16324 A complete description of the AIs may be found in
16325 @url{www.ada-auth.org/ai05-summary.html}.
16326
16327 @itemize @bullet
16328
16329 @item
16330 @emph{AI-0176 Quantified expressions (2010-09-29)}
16331 @cindex AI-0176 (Ada 2012 feature)
16332
16333 @noindent
16334   Both universally and existentially quantified expressions are implemented.
16335   They use the new syntax for iterators proposed in AI05-139-2, as well as
16336   the standard Ada loop syntax.
16337
16338 @noindent
16339   RM References:  1.01.04 (12)   2.09 (2/2)   4.04 (7)   4.05.09 (0)
16340
16341 @item
16342 @emph{AI-0079 Allow @i{other_format} characters in source (2010-07-10)}
16343 @cindex AI-0079 (Ada 2012 feature)
16344
16345 @noindent
16346   Wide characters in the unicode category @i{other_format} are now allowed in
16347   source programs between tokens, but not within a token such as an identifier.
16348
16349 @noindent
16350   RM References:  2.01 (4/2)   2.02 (7)
16351
16352 @item
16353 @emph{AI-0091 Do not allow @i{other_format} in identifiers (0000-00-00)}
16354 @cindex AI-0091 (Ada 2012 feature)
16355
16356 @noindent
16357   Wide characters in the unicode category @i{other_format} are not permitted
16358   within  an identifier, since this can be a security problem. The error
16359   message for this case has been improved to be more specific, but GNAT has
16360   never allowed such characters to appear in identifiers.
16361
16362 @noindent
16363   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)
16364
16365 @item
16366 @emph{AI-0100 Placement of pragmas  (2010-07-01)}
16367 @cindex AI-0100 (Ada 2012 feature)
16368
16369 @noindent
16370   This AI is an earlier version of AI-163. It simplifies the rules
16371   for legal placement of pragmas. In the case of lists that allow pragmas, if
16372   the list may have no elements, then the list may consist solely of pragmas.
16373
16374 @noindent
16375   RM References:  2.08 (7)
16376
16377 @item
16378 @emph{AI-0163 Pragmas in place of null (2010-07-01)}
16379 @cindex AI-0163 (Ada 2012 feature)
16380
16381 @noindent
16382   A statement sequence may be composed entirely of pragmas. It is no longer
16383   necessary to add a dummy @code{null} statement to make the sequence legal.
16384
16385 @noindent
16386   RM References:  2.08 (7)   2.08 (16)
16387
16388
16389 @item
16390 @emph{AI-0080 ``View of'' not needed if clear from context (0000-00-00)}
16391 @cindex AI-0080 (Ada 2012 feature)
16392
16393 @noindent
16394   This is an editorial change only, described as non-testable in the AI.
16395
16396 @noindent
16397   RM References:  3.01 (7)
16398
16399
16400 @item
16401 @emph{AI-0183 Aspect specifications (2010-08-16)}
16402 @cindex AI-0183 (Ada 2012 feature)
16403
16404 @noindent
16405   Aspect specifications have been fully implemented except for pre and post-
16406   conditions, and type invariants, which have their own separate AI's. All
16407   forms of declarations listed in the AI are supported. The following is a
16408   list of the aspects supported (with GNAT implementation aspects marked)
16409
16410 @multitable {@code{Preelaborable_Initialization}} {--GNAT}
16411 @item @code{Ada_2005} @tab                      -- GNAT
16412 @item @code{Ada_2012} @tab                      -- GNAT
16413 @item @code{Address} @tab
16414 @item @code{Alignment} @tab
16415 @item @code{Atomic} @tab
16416 @item @code{Atomic_Components} @tab
16417 @item @code{Bit_Order} @tab
16418 @item @code{Component_Size} @tab
16419 @item @code{Discard_Names} @tab
16420 @item @code{External_Tag} @tab
16421 @item @code{Favor_Top_Level} @tab               -- GNAT
16422 @item @code{Inline} @tab
16423 @item @code{Inline_Always} @tab                 -- GNAT
16424 @item @code{Invariant} @tab
16425 @item @code{Machine_Radix} @tab
16426 @item @code{No_Return} @tab
16427 @item @code{Object_Size} @tab                   -- GNAT
16428 @item @code{Pack} @tab
16429 @item @code{Persistent_BSS} @tab                -- GNAT
16430 @item @code{Post} @tab
16431 @item @code{Pre} @tab
16432 @item @code{Predicate} @tab
16433 @item @code{Preelaborable_Initialization} @tab
16434 @item @code{Pure_Function} @tab                 -- GNAT
16435 @item @code{Shared} @tab                        -- GNAT
16436 @item @code{Size} @tab
16437 @item @code{Storage_Pool} @tab
16438 @item @code{Storage_Size} @tab
16439 @item @code{Stream_Size} @tab
16440 @item @code{Suppress} @tab
16441 @item @code{Suppress_Debug_Info} @tab           -- GNAT
16442 @item @code{Unchecked_Union} @tab
16443 @item @code{Universal_Aliasing} @tab            -- GNAT
16444 @item @code{Unmodified} @tab                    -- GNAT
16445 @item @code{Unreferenced} @tab                  -- GNAT
16446 @item @code{Unreferenced_Objects} @tab          -- GNAT
16447 @item @code{Unsuppress} @tab
16448 @item @code{Value_Size} @tab                    -- GNAT
16449 @item @code{Volatile} @tab
16450 @item @code{Volatile_Components}
16451 @item @code{Warnings} @tab                      -- GNAT
16452 @end multitable
16453
16454 @noindent
16455   Note that for aspects with an expression, e.g. @code{Size}, the expression is
16456   treated like a default expression (visibility is analyzed at the point of
16457   occurrence of the aspect, but evaluation of the expression occurs at the
16458   freeze point of the entity involved.
16459
16460 @noindent
16461   RM References:  3.02.01 (3)   3.02.02 (2)   3.03.01 (2/2)   3.08 (6)
16462   3.09.03 (1.1/2)   6.01 (2/2)   6.07 (2/2)   9.05.02 (2/2)   7.01 (3)   7.03
16463   (2)   7.03 (3)   9.01 (2/2)   9.01 (3/2)   9.04 (2/2)   9.04 (3/2)
16464   9.05.02 (2/2)   11.01 (2)   12.01 (3)   12.03 (2/2)   12.04 (2/2)   12.05 (2)
16465   12.06 (2.1/2)   12.06 (2.2/2)   12.07 (2)   13.01 (0.1/2)   13.03 (5/1)
16466   13.03.01 (0)
16467
16468
16469 @item
16470 @emph{AI-0128 Inequality is a primitive operation (0000-00-00)}
16471 @cindex AI-0128 (Ada 2012 feature)
16472
16473 @noindent
16474   If an equality operator ("=") is declared for a type, then the implicitly
16475   declared inequality operator ("/=") is a primitive operation of the type.
16476   This is the only reasonable interpretation, and is the one always implemented
16477   by GNAT, but the RM was not entirely clear in making this point.
16478
16479 @noindent
16480   RM References:  3.02.03 (6)   6.06 (6)
16481
16482 @item
16483 @emph{AI-0003 Qualified expressions as names (2010-07-11)}
16484 @cindex AI-0003 (Ada 2012 feature)
16485
16486 @noindent
16487    In Ada 2012, a qualified expression is considered to be syntatically a name,
16488    meaning that constructs such as @code{A'(F(X)).B} are now legal. This is
16489    useful in disambiguating some cases of overloading.
16490
16491 @noindent
16492   RM References:  3.03 (11)   3.03 (21)   4.01 (2)   4.04 (7)   4.07 (3)
16493   5.04 (7)
16494
16495 @item
16496 @emph{AI-0120 Constant instance of protected object (0000-00-00)}
16497 @cindex AI-0120 (Ada 2012 feature)
16498
16499 @noindent
16500   This is an RM editorial change only. The section that lists objects that are
16501   constant failed to include the current instance of a protected object
16502   within a protected function. This has always been treated as a constant
16503   in GNAT.
16504
16505 @noindent
16506   RM References:  3.03 (21)
16507
16508 @item
16509 @emph{AI-0008 General access to constrained objects (0000-00-00)}
16510 @cindex AI-0008 (Ada 2012 feature)
16511
16512 @noindent
16513   The wording in the RM implied that if you have a general access to a
16514   constrained object, it could be used to modify the discriminants. This was
16515   obviously not intended. @code{Constraint_Error} should be raised, and GNAT
16516   has always done so in this situation.
16517
16518 @noindent
16519   RM References:  3.03 (23)   3.10.02 (26/2)   4.01 (9)   6.04.01 (17)   8.05.01 (5/2)
16520
16521
16522 @item
16523 @emph{AI-0093 Additional rules use immutably limited (0000-00-00)}
16524 @cindex AI-0093 (Ada 2012 feature)
16525
16526 @noindent
16527   This is an editorial change only, to make more widespread use of the Ada 2012
16528   ``immutably limited''.
16529
16530 @noindent
16531   RM References:  3.03 (23.4/3)
16532
16533
16534
16535 @item
16536 @emph{AI-0096 Deriving from formal private types (2010-07-20)}
16537 @cindex AI-0096 (Ada 2012 feature)
16538
16539 @noindent
16540   In general it is illegal for a type derived from a formal limited type to be
16541   nonlimited.  This AI makes an exception to this rule: derivation is legal
16542   if it appears in the private part of the generic, and the formal type is not
16543   tagged. If the type is tagged, the legality check must be applied to the
16544   private part of the package.
16545
16546 @noindent
16547   RM References:  3.04 (5.1/2)   6.02 (7)
16548
16549
16550 @item
16551 @emph{AI-0181 Soft hyphen is a non-graphic character (2010-07-23)}
16552 @cindex AI-0181 (Ada 2012 feature)
16553
16554 @noindent
16555   From Ada 2005 on, soft hyphen is considered a non-graphic character, which
16556   means that it has a special name (@code{SOFT_HYPHEN}) in conjunction with the
16557   @code{Image} and @code{Value} attributes for the character types. Strictly
16558   speaking this is an inconsistency with Ada 95, but in practice the use of
16559   these attributes is so obscure that it will not cause problems.
16560
16561 @noindent
16562   RM References:  3.05.02 (2/2)   A.01 (35/2)   A.03.03 (21)
16563
16564
16565 @item
16566 @emph{AI-0182 Additional forms for @code{Character'Value} (0000-00-00)}
16567 @cindex AI-0182 (Ada 2012 feature)
16568
16569 @noindent
16570   This AI allows @code{Character'Value} to accept the string @code{'?'} where
16571   @code{?} is any character including non-graphic control characters. GNAT has
16572   always accepted such strings. It also allows strings such as
16573   @code{HEX_00000041} to be accepted, but GNAT does not take advantage of this
16574   permission and raises @code{Constraint_Error}, as is certainly still
16575   permitted.
16576
16577 @noindent
16578   RM References:  3.05 (56/2)
16579
16580
16581 @item
16582 @emph{AI-0214 Defaulted discriminants for limited tagged (2010-10-01)}
16583 @cindex AI-0214 (Ada 2012 feature)
16584
16585 @noindent
16586   Ada 2012 relaxes the restriction that forbids discriminants of tagged types
16587   to have default expressions by allowing them when the type is limited. It
16588   is often useful to define a default value for a discriminant even though
16589   it can't be changed by assignment.
16590
16591 @noindent
16592   RM References:  3.07 (9.1/2)   3.07.02 (3)
16593
16594
16595 @item
16596 @emph{AI-0102 Some implicit conversions are illegal (0000-00-00)}
16597 @cindex AI-0102 (Ada 2012 feature)
16598
16599 @noindent
16600   It is illegal to assign an anonymous access constant to an anonymous access
16601   variable. The RM did not have a clear rule to prevent this, but GNAT has
16602   always generated an error for this usage.
16603
16604 @noindent
16605   RM References:  3.07 (16)   3.07.01 (9)   6.04.01 (6)   8.06 (27/2)
16606
16607
16608 @item
16609 @emph{AI-0158 Generalizing membership tests (2010-09-16)}
16610 @cindex AI-0158 (Ada 2012 feature)
16611
16612 @noindent
16613   This AI extends the syntax of membership tests to simplify complex conditions
16614   that can be expressed as membership in a subset of values of any type. It
16615   introduces syntax for a list of expressions that may be used in loop contexts
16616   as well.
16617
16618 @noindent
16619   RM References:  3.08.01 (5)   4.04 (3)   4.05.02 (3)   4.05.02 (5)   4.05.02 (27)
16620
16621
16622 @item
16623 @emph{AI-0173 Testing if tags represent abstract types (2010-07-03)}
16624 @cindex AI-0173 (Ada 2012 feature)
16625
16626 @noindent
16627   The function @code{Ada.Tags.Type_Is_Abstract} returns @code{True} if invoked
16628   with the tag of an abstract type, and @code{False} otherwise.
16629
16630 @noindent
16631   RM References:  3.09 (7.4/2)   3.09 (12.4/2)
16632
16633
16634
16635 @item
16636 @emph{AI-0076 function with controlling result (0000-00-00)}
16637 @cindex AI-0076 (Ada 2012 feature)
16638
16639 @noindent
16640   This is an editorial change only. The RM defines calls with controlling
16641   results, but uses the term ``function with controlling result'' without an
16642   explicit definition.
16643
16644 @noindent
16645   RM References:  3.09.02 (2/2)
16646
16647
16648 @item
16649 @emph{AI-0126 Dispatching with no declared operation (0000-00-00)}
16650 @cindex AI-0126 (Ada 2012 feature)
16651
16652 @noindent
16653   This AI clarifies dispatching rules, and simply confirms that dispatching
16654   executes the operation of the parent type when there is no explicitly or
16655   implicitly declared operation for the descendant type. This has always been
16656   the case in all versions of GNAT.
16657
16658 @noindent
16659   RM References:  3.09.02 (20/2)   3.09.02 (20.1/2)   3.09.02 (20.2/2)
16660
16661
16662 @item
16663 @emph{AI-0097 Treatment of abstract null extension (2010-07-19)}
16664 @cindex AI-0097 (Ada 2012 feature)
16665
16666 @noindent
16667   The RM as written implied that in some cases it was possible to create an
16668   object of an abstract type, by having an abstract extension inherit a non-
16669   abstract constructor from its parent type. This mistake has been corrected
16670   in GNAT and in the RM, and this construct is now illegal.
16671
16672 @noindent
16673   RM References:  3.09.03 (4/2)
16674
16675
16676 @item
16677 @emph{AI-0203 Extended return cannot be abstract (0000-00-00)}
16678 @cindex AI-0203 (Ada 2012 feature)
16679
16680 @noindent
16681   A return_subtype_indication cannot denote an abstract subtype. GNAT has never
16682   permitted such usage.
16683
16684 @noindent
16685   RM References:  3.09.03 (8/3)
16686
16687
16688 @item
16689 @emph{AI-0198 Inheriting abstract operators  (0000-00-00)}
16690 @cindex AI-0198 (Ada 2012 feature)
16691
16692 @noindent
16693   This AI resolves a conflict between two rules involving inherited abstract
16694   operations and predefined operators. If a derived numeric type inherits
16695   an abstract operator, it overrides the predefined one. This interpretation
16696   was always the one implemented in GNAT.
16697
16698 @noindent
16699   RM References:  3.09.03 (4/3)
16700
16701 @item
16702 @emph{AI-0073 Functions returning abstract types (2010-07-10)}
16703 @cindex AI-0073 (Ada 2012 feature)
16704
16705 @noindent
16706   This AI covers a number of issues regarding returning abstract types. In
16707   particular generic fucntions cannot have abstract result types or access
16708   result types designated an abstract type. There are some other cases which
16709   are detailed in the AI. Note that this binding interpretation has not been
16710   retrofitted to operate before Ada 2012 mode, since it caused a significant
16711   number of regressions.
16712
16713 @noindent
16714   RM References:  3.09.03 (8)   3.09.03 (10)   6.05 (8/2)
16715
16716
16717 @item
16718 @emph{AI-0070 Elaboration of interface types (0000-00-00)}
16719 @cindex AI-0070 (Ada 2012 feature)
16720
16721 @noindent
16722   This is an editorial change only, there are no testable consequences short of
16723   checking for the absence of generated code for an interface declaration.
16724
16725 @noindent
16726   RM References:  3.09.04 (18/2)
16727
16728
16729 @item
16730 @emph{AI-0208 Characteristics of incomplete views (0000-00-00)}
16731 @cindex AI-0208 (Ada 2012 feature)
16732
16733 @noindent
16734   The wording in the Ada 2005 RM concerning characteristics of incomplete views
16735   was incorrect and implied that some programs intended to be legal were now
16736   illegal. GNAT had never considered such programs illegal, so it has always
16737   implemented the intent of this AI.
16738
16739 @noindent
16740   RM References:  3.10.01 (2.4/2)   3.10.01 (2.6/2)
16741
16742
16743 @item
16744 @emph{AI-0162 Incomplete type completed by partial view (2010-09-15)}
16745 @cindex AI-0162 (Ada 2012 feature)
16746
16747 @noindent
16748   Incomplete types are made more useful by allowing them to be completed by
16749   private types and private extensions.
16750
16751 @noindent
16752   RM References:  3.10.01 (2.5/2)   3.10.01 (2.6/2)   3.10.01 (3)   3.10.01 (4/2)
16753
16754
16755
16756 @item
16757 @emph{AI-0098 Anonymous subprogram access restrictions (0000-00-00)}
16758 @cindex AI-0098 (Ada 2012 feature)
16759
16760 @noindent
16761   An unintentional omission in the RM implied some inconsistent restrictions on
16762   the use of anonymous access to subprogram values. These restrictions were not
16763   intentional, and have never been enforced by GNAT.
16764
16765 @noindent
16766   RM References:  3.10.01 (6)   3.10.01 (9.2/2)
16767
16768
16769 @item
16770 @emph{AI-0199 Aggregate with anonymous access components (2010-07-14)}
16771 @cindex AI-0199 (Ada 2012 feature)
16772
16773 @noindent
16774   A choice list in a record aggregate can include several components of
16775   (distinct) anonymous access types as long as they have matching designated
16776   subtypes.
16777
16778 @noindent
16779   RM References:  4.03.01 (16)
16780
16781
16782 @item
16783 @emph{AI-0220 Needed components for aggregates (0000-00-00)}
16784 @cindex AI-0220 (Ada 2012 feature)
16785
16786 @noindent
16787   This AI addresses a wording problem in the RM that appears to permit some
16788   complex cases of aggregates with non-static discriminants. GNAT has always
16789   implemented the intended semantics.
16790
16791 @noindent
16792   RM References:  4.03.01 (17)
16793
16794 @item
16795 @emph{AI-0147 Conditional expressions (2009-03-29)}
16796 @cindex AI-0147 (Ada 2012 feature)
16797
16798 @noindent
16799   Conditional expressions are permitted. The form of such an expression is:
16800
16801 @smallexample
16802     (@b{if} @i{expr} @b{then} @i{expr} @{@b{elsif} @i{expr} @b{then} @i{expr}@} [@b{else} @i{expr}])
16803 @end smallexample
16804
16805   The parentheses can be omitted in contexts where parentheses are present
16806   anyway, such as subprogram arguments and pragma arguments. If the @b{else}
16807   clause is omitted, @b{else True} is assumed;
16808   thus @code{(@b{if} A @b{then} B)} is a way to conveniently represent
16809   @emph{(A implies B)} in standard logic.
16810
16811 @noindent
16812   RM References:  4.03.03 (15)   4.04 (1)   4.04 (7)   4.05.07 (0)   4.07 (2)
16813   4.07 (3)   4.09 (12)   4.09 (33)   5.03 (3)   5.03 (4)   7.05 (2.1/2)
16814
16815
16816 @item
16817 @emph{AI-0037 Out-of-range box associations in aggregate (0000-00-00)}
16818 @cindex AI-0037 (Ada 2012 feature)
16819
16820 @noindent
16821   This AI confirms that an association of the form @code{Indx => <>} in an
16822   array aggregate must raise @code{Constraint_Error} if @code{Indx}
16823   is out of range. The RM specified a range check on other associations, but
16824   not when the value of the association was defaulted. GNAT has always inserted
16825   a constraint check on the index value.
16826
16827 @noindent
16828   RM References:  4.03.03 (29)
16829
16830
16831 @item
16832 @emph{AI-0123 Composability of equality (2010-04-13)}
16833 @cindex AI-0123 (Ada 2012 feature)
16834
16835 @noindent
16836   Equality of untagged record composes, so that the predefined equality for a
16837   composite type that includes a component of some untagged record type
16838   @code{R} uses the equality operation of @code{R} (which may be user-defined
16839   or predefined). This makes the behavior of untagged records identical to that
16840   of tagged types in this respect.
16841
16842   This change is an incompatibility with previous versions of Ada, but it
16843   corrects a non-uniformity that was often a source of confusion. Analysis of
16844   a large number of industrial programs indicates that in those rare cases
16845   where a composite type had an untagged record component with a user-defined
16846   equality, either there was no use of the composite equality, or else the code
16847   expected the same composability as for tagged types, and thus had a bug that
16848   would be fixed by this change.
16849
16850 @noindent
16851   RM References:  4.05.02 (9.7/2)   4.05.02 (14)   4.05.02 (15)   4.05.02 (24)
16852   8.05.04 (8)
16853
16854
16855 @item
16856 @emph{AI-0088 The value of exponentiation (0000-00-00)}
16857 @cindex AI-0088 (Ada 2012 feature)
16858
16859 @noindent
16860   This AI clarifies the equivalence rule given for the dynamic semantics of
16861   exponentiation: the value of the operation can be obtained by repeated
16862   multiplication, but the operation can be implemented otherwise (for example
16863   using the familiar divide-by-two-and-square algorithm, even if this is less
16864   accurate), and does not imply repeated reads of a volatile base.
16865
16866 @noindent
16867   RM References:  4.05.06 (11)
16868
16869 @item
16870 @emph{AI-0188 Case expressions (2010-01-09)}
16871 @cindex AI-0188 (Ada 2012 feature)
16872
16873 @noindent
16874   Case expressions are permitted. This allows use of constructs such as:
16875 @smallexample
16876   X := (@b{case} Y @b{is when} 1 => 2, @b{when} 2 => 3, @b{when others} => 31)
16877 @end smallexample
16878
16879 @noindent
16880   RM References:  4.05.07 (0)   4.05.08 (0)   4.09 (12)   4.09 (33)
16881
16882 @item
16883 @emph{AI-0104 Null exclusion and uninitialized allocator (2010-07-15)}
16884 @cindex AI-0104 (Ada 2012 feature)
16885
16886 @noindent
16887   The assignment @code{Ptr := @b{new not null} Some_Ptr;} will raise
16888   @code{Constraint_Error} because the default value of the allocated object is
16889   @b{null}. This useless construct is illegal in Ada 2012.
16890
16891 @noindent
16892   RM References:  4.08 (2)
16893
16894 @item
16895 @emph{AI-0157 Allocation/Deallocation from empty pool (2010-07-11)}
16896 @cindex AI-0157 (Ada 2012 feature)
16897
16898 @noindent
16899   Allocation and Deallocation from an empty storage pool (i.e. allocation or
16900   deallocation of a pointer for which a static storage size clause of zero
16901   has been given) is now illegal and is detected as such. GNAT
16902   previously gave a warning but not an error.
16903
16904 @noindent
16905   RM References:  4.08 (5.3/2)   13.11.02 (4)   13.11.02 (17)
16906
16907 @item
16908 @emph{AI-0179 Statement not required after label (2010-04-10)}
16909 @cindex AI-0179 (Ada 2012 feature)
16910
16911 @noindent
16912   It is not necessary to have a statement following a label, so a label
16913   can appear at the end of a statement sequence without the need for putting a
16914   null statement afterwards, but it is not allowable to have only labels and
16915   no real statements in a statement sequence.
16916
16917 @noindent
16918   RM References:  5.01 (2)
16919
16920
16921 @item
16922 @emph{AI-139-2 Syntactic sugar for iterators (2010-09-29)}
16923 @cindex AI-139-2 (Ada 2012 feature)
16924
16925 @noindent
16926   The new syntax for iterating over arrays and containers is now implemented.
16927   Iteration over containers is for now limited to read-only iterators. Only
16928   default iterators are supported, with the syntax:  @code{@b{for} Elem @b{of} C}.
16929
16930 @noindent
16931   RM References:  5.05
16932
16933 @item
16934 @emph{AI-0134 Profiles must match for full conformance (0000-00-00)}
16935 @cindex AI-0134 (Ada 2012 feature)
16936
16937 @noindent
16938   For full conformance, the profiles of anonymous-access-to-subprogram
16939   parameters must match. GNAT has always enforced this rule.
16940
16941 @noindent
16942   RM References:  6.03.01 (18)
16943
16944 @item
16945 @emph{AI-0207 Mode conformance and access constant (0000-00-00)}
16946 @cindex AI-0207 (Ada 2012 feature)
16947
16948 @noindent
16949   This AI confirms that access_to_constant indication must match for mode
16950   conformance. This was implemented in GNAT when the qualifier was originally
16951   introduced in Ada 2005.
16952
16953 @noindent
16954   RM References:  6.03.01 (16/2)
16955
16956
16957 @item
16958 @emph{AI-0046 Null exclusion match for full conformance (2010-07-17)}
16959 @cindex AI-0046 (Ada 2012 feature)
16960
16961 @noindent
16962   For full conformance, in the case of access parameters, the null exclusion
16963   must match (either both or neither must have @code{@b{not null}}).
16964
16965 @noindent
16966   RM References:  6.03.02 (18)
16967
16968
16969 @item
16970 @emph{AI-0118 The association of parameter associations (0000-00-00)}
16971 @cindex AI-0118 (Ada 2012 feature)
16972
16973 @noindent
16974   This AI clarifies the rules for named associations in subprogram calls and
16975   generic instantiations. The rules have been in place since Ada 83.
16976
16977 @noindent
16978   RM References:  6.04.01 (2)   12.03 (9)
16979
16980
16981 @item
16982 @emph{AI-0196 Null exclusion tests for out parameters (0000-00-00)}
16983 @cindex AI-0196 (Ada 2012 feature)
16984
16985 @noindent
16986   Null exclusion checks are not made for @code{@b{out}} parameters when
16987   evaluating the actual parameters. GNAT has never generated these checks.
16988
16989 @noindent
16990   RM References:  6.04.01 (13)
16991
16992 @item
16993 @emph{AI-0015 Constant return objects (0000-00-00)}
16994 @cindex AI-0015 (Ada 2012 feature)
16995
16996 @noindent
16997   The return object declared in an @i{extended_return_statement} may be
16998   declared constant. This was always intended, and GNAT has always allowed it.
16999
17000 @noindent
17001   RM References:  6.05 (2.1/2)   3.03 (10/2)   3.03 (21)   6.05 (5/2)
17002   6.05 (5.7/2)
17003
17004
17005 @item
17006 @emph{AI-0032 Extended return for class-wide functions (0000-00-00)}
17007 @cindex AI-0032 (Ada 2012 feature)
17008
17009 @noindent
17010   If a function returns a class-wide type, the object of an extended return
17011   statement can be declared with a specific type that is covered by the class-
17012   wide type. This has been implemented in GNAT since the introduction of
17013   extended returns. Note AI-0103 complements this AI by imposing matching
17014   rules for constrained return types.
17015
17016 @noindent
17017   RM References:  6.05 (5.2/2)   6.05 (5.3/2)   6.05 (5.6/2)   6.05 (5.8/2)
17018   6.05 (8/2)
17019
17020 @item
17021 @emph{AI-0103 Static matching for extended return (2010-07-23)}
17022 @cindex AI-0103 (Ada 2012 feature)
17023
17024 @noindent
17025   If the return subtype of a function is an elementary type or a constrained
17026   type, the subtype indication in an extended return statement must match
17027   statically this return subtype.
17028
17029 @noindent
17030   RM References:  6.05 (5.2/2)
17031
17032
17033 @item
17034 @emph{AI-0058 Abnormal completion of an extended return (0000-00-00)}
17035 @cindex AI-0058 (Ada 2012 feature)
17036
17037 @noindent
17038   The RM had some incorrect wording implying wrong treatment of abnormal
17039   completion in an extended return. GNAT has always implemented the intended
17040   correct semantics as described by this AI.
17041
17042 @noindent
17043   RM References:  6.05 (22/2)
17044
17045
17046 @item
17047 @emph{AI-0050 Raising Constraingt_Errpr early for function call (0000-00-00)}
17048 @cindex AI-0050 (Ada 2012 feature)
17049
17050 @noindent
17051   The implementation permissions for raising @code{Constraing_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
17052   not take advantage of these incorrect permissions in any case.
17053
17054 @noindent
17055   RM References:  6.05 (24/2)
17056
17057
17058 @item
17059 @emph{AI-0125 Nonoverridable operations of an ancestor (2010-09-28)}
17060 @cindex AI-0125 (Ada 2012 feature)
17061
17062 @noindent
17063   In Ada 2012, the declaration of a primitive operation of a type extension
17064   or private extension can also override an inherited primitive that is not
17065   visible at the point of this declaration.
17066
17067 @noindent
17068   RM References:  7.03.01 (6)   8.03 (23)   8.03.01 (5/2)   8.03.01 (6/2)
17069
17070 @item
17071 @emph{AI-0062 Null exclusions and deferred constants (0000-00-00)}
17072 @cindex AI-0062 (Ada 2012 feature)
17073
17074 @noindent
17075   A full constant may have a null exclusion even if its associated deferred
17076   constant does not. GNAT has always allowed this.
17077
17078 @noindent
17079   RM References:  7.04 (6/2)   7.04 (7.1/2)
17080
17081
17082 @item
17083 @emph{AI-0178 Incomplete views are limited (0000-00-00)}
17084 @cindex AI-0178 (Ada 2012 feature)
17085
17086 @noindent
17087   This AI clarifies the role of incomplete views and plugs an omission in the
17088   RM. GNAT always correctly restricted the use of incomplete views and types.
17089
17090 @noindent
17091   RM References:  7.05 (3/2)   7.05 (6/2)
17092
17093 @item
17094 @emph{AI-0087 Actual for formal nonlimited derived type (2010-07-15)}
17095 @cindex AI-0087 (Ada 2012 feature)
17096
17097 @noindent
17098   The actual for a formal nonlimited derived type cannot be limited. In
17099   particular, a formal derived type that extends a limited interface but which
17100   is not explicitly limited cannot be instantiated with a limited type.
17101
17102 @noindent
17103   RM References:  7.05 (5/2)   12.05.01 (5.1/2)
17104
17105 @item
17106 @emph{AI-0099 Tag determines whether finalization needed (0000-00-00)}
17107 @cindex AI-0099 (Ada 2012 feature)
17108
17109 @noindent
17110   This AI clarifies that ``needs finalization'' is part of dynamic semantics,
17111   and therefore depends on the run-time charateristics of an object (i.e. its
17112   tag) and not on its nominal type. As the AI indicates: ``we do not expect
17113   this to affect any implementation''.
17114
17115 @noindent
17116   RM References:  7.06.01 (6)   7.06.01 (7)   7.06.01 (8)   7.06.01 (9/2)
17117
17118
17119
17120 @item
17121 @emph{AI-0064 Redundant finalization rule (0000-00-00)}
17122 @cindex AI-0064 (Ada 2012 feature)
17123
17124 @noindent
17125   This is an editorial change only. The intended behavior is already checked
17126   by an existing ACATS test, which GNAT has always executed correctly.
17127
17128 @noindent
17129   RM References:  7.06.01 (17.1/1)
17130
17131 @item
17132 @emph{AI-0026 Missing rules for Unchecked_Union (2010-07-07)}
17133 @cindex AI-0026 (Ada 2012 feature)
17134
17135 @noindent
17136   Record representation clauses concerning Unchecked_Union types cannot mention
17137   the discriminant of the type. The type of a component declared in the variant
17138   part of an Unchecked_Union cannot be controlled, have controlled components,
17139   nor have protected or task parts. If an Unchecked_Union type is declared
17140   within the body of a generic unit or its descendants, then the type of a
17141   component declared in the variant part cannot be a formal private type or a
17142   formal private extension declared within the same generic unit.
17143
17144 @noindent
17145   RM References:  7.06 (9.4/2)   B.03.03 (9/2)   B.03.03 (10/2)
17146
17147
17148 @item
17149 @emph{AI-0205 Extended return declares visible name (0000-00-00)}
17150 @cindex AI-0205 (Ada 2012 feature)
17151
17152 @noindent
17153   This AI corrects a simple omission in the RM. Return objects have always
17154   been visible within an extended return statement.
17155
17156 @noindent
17157   RM References:  8.03 (17)
17158
17159
17160 @item
17161 @emph{AI-0042 Overriding versus implemented-by (0000-00-00)}
17162 @cindex AI-0042 (Ada 2012 feature)
17163
17164 @noindent
17165   This AI fixes a wording gap in the RM. An operation of a synchronized
17166   interface can be implemented by a protected or task entry, but the abstract
17167   operation is not being overridden in the usual sense, and it must be stated
17168   separately that this implementation is legal. This has always been the case
17169   in GNAT.
17170
17171 @noindent
17172   RM References:  9.01 (9.2/2)   9.04 (11.1/2)
17173
17174 @item
17175 @emph{AI-0030 Requeue on synchronized interfaces (2010-07-19)}
17176 @cindex AI-0030 (Ada 2012 feature)
17177
17178 @noindent
17179   Requeue is permitted to a protected, synchronized or task interface primitive
17180   providing it is known that the overriding operation is an entry. Otherwise
17181   the requeue statement has the same effect as a procedure call. Use of pragma
17182   @code{Implemented} provides a way to impose a static requirement on the
17183   overriding operation by adhering to one of the implementation kinds: entry,
17184   protected procedure or any of the above.
17185
17186 @noindent
17187   RM References:  9.05 (9)   9.05.04 (2)   9.05.04 (3)   9.05.04 (5)
17188   9.05.04 (6)   9.05.04 (7)   9.05.04 (12)
17189
17190
17191 @item
17192 @emph{AI-0201 Independence of atomic object components (2010-07-22)}
17193 @cindex AI-0201 (Ada 2012 feature)
17194
17195 @noindent
17196   If an Atomic object has a pragma @code{Pack} or a @code{Component_Size}
17197   attribute, then individual components may not be addressable by independent
17198   tasks. However, if the representation clause has no effect (is confirming),
17199   then independence is not compromised. Furthermore, in GNAT, specification of
17200   other appropriately addressable component sizes (e.g. 16 for 8-bit
17201   characters) also preserves independence. GNAT now gives very clear warnings
17202   both for the declaration of such a type, and for any assignment to its components.
17203
17204 @noindent
17205   RM References:  9.10 (1/3)   C.06 (22/2)   C.06 (23/2)
17206
17207 @item
17208 @emph{AI-0009 Pragma Independent[_Components] (2010-07-23)}
17209 @cindex AI-0009 (Ada 2012 feature)
17210
17211 @noindent
17212   This AI introduces the new pragmas @code{Independent} and
17213   @code{Independent_Components},
17214   which control guaranteeing independence of access to objects and components.
17215   The AI also requires independence not unaffected by confirming rep clauses.
17216
17217 @noindent
17218   RM References:  9.10 (1)   13.01 (15/1)   13.02 (9)   13.03 (13)   C.06 (2)
17219   C.06 (4)   C.06 (6)   C.06 (9)   C.06 (13)   C.06 (14)
17220
17221
17222 @item
17223 @emph{AI-0072 Task signalling using 'Terminated (0000-00-00)}
17224 @cindex AI-0072 (Ada 2012 feature)
17225
17226 @noindent
17227   This AI clarifies that task signalling for reading @code{'Terminated} only
17228   occurs if the result is True. GNAT semantics has always been consistent with
17229   this notion of task signalling.
17230
17231 @noindent
17232   RM References:  9.10 (6.1/1)
17233
17234 @item
17235 @emph{AI-0108 Limited incomplete view and discriminants (0000-00-00)}
17236 @cindex AI-0108 (Ada 2012 feature)
17237
17238 @noindent
17239   This AI confirms that an incomplete type from a limited view does not have
17240   discriminants. This has always been the case in GNAT.
17241
17242 @noindent
17243   RM References:  10.01.01 (12.3/2)
17244
17245 @item
17246 @emph{AI-0129 Limited views and incomplete types (0000-00-00)}
17247 @cindex AI-0129 (Ada 2012 feature)
17248
17249 @noindent
17250   This AI clarifies the description of limited views: a limited view of a
17251   package includes only one view of a type that has an incomplete declaration
17252   and a full declaration (there is no possible ambiguity in a client package).
17253   This AI also fixes an omission: a nested package in the private part has no
17254   limited view. GNAT always implemented this correctly.
17255
17256 @noindent
17257   RM References:  10.01.01 (12.2/2)   10.01.01 (12.3/2)
17258
17259
17260
17261 @item
17262 @emph{AI-0077 Limited withs and scope of declarations (0000-00-00)}
17263 @cindex AI-0077 (Ada 2012 feature)
17264
17265 @noindent
17266   This AI clarifies that a declaration does not include a context clause,
17267   and confirms that it is illegal to have a context in which both a limited
17268   and a nonlimited view of a package are accessible. Such double visibility
17269   was always rejected by GNAT.
17270
17271 @noindent
17272   RM References:  10.01.02 (12/2)   10.01.02 (21/2)   10.01.02 (22/2)
17273
17274 @item
17275 @emph{AI-0122 Private with and children of generics (0000-00-00)}
17276 @cindex AI-0122 (Ada 2012 feature)
17277
17278 @noindent
17279   This AI clarifies the visibility of private children of generic units within
17280   instantiations of a parent. GNAT has always handled this correctly.
17281
17282 @noindent
17283   RM References:  10.01.02 (12/2)
17284
17285
17286
17287 @item
17288 @emph{AI-0040 Limited with clauses on descendant (0000-00-00)}
17289 @cindex AI-0040 (Ada 2012 feature)
17290
17291 @noindent
17292   This AI confirms that a limited with clause in a child unit cannot name
17293   an ancestor of the unit. This has always been checked in GNAT.
17294
17295 @noindent
17296   RM References:  10.01.02 (20/2)
17297
17298 @item
17299 @emph{AI-0132 Placement of library unit pragmas (0000-00-00)}
17300 @cindex AI-0132 (Ada 2012 feature)
17301
17302 @noindent
17303   This AI fills a gap in the description of library unit pragmas. The pragma
17304   clearly must apply to a library unit, even if it does not carry the name
17305   of the enclosing unit. GNAT has always enforced the required check.
17306
17307 @noindent
17308   RM References:  10.01.05 (7)
17309
17310
17311 @item
17312 @emph{AI-0034 Categorization of limited views (0000-00-00)}
17313 @cindex AI-0034 (Ada 2012 feature)
17314
17315 @noindent
17316   The RM makes certain limited with clauses illegal because of categorization
17317   considerations, when the corresponding normal with would be legal. This is
17318   not intended, and GNAT has always implemented the recommended behavior.
17319
17320 @noindent
17321   RM References:  10.02.01 (11/1)   10.02.01 (17/2)
17322
17323
17324 @item
17325 @emph{AI-0035 Inconsistencies with Pure units (0000-00-00)}
17326 @cindex AI-0035 (Ada 2012 feature)
17327
17328 @noindent
17329   This AI remedies some inconsistencies in the legality rules for Pure units.
17330   Derived access types are legal in a pure unit (on the assumption that the
17331   rule for a zero storage pool size has been enforced on the ancestor type).
17332   The rules are enforced in generic instances and in subunits. GNAT has always
17333   implemented the recommended behavior.
17334
17335 @noindent
17336   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)
17337
17338
17339 @item
17340 @emph{AI-0219 Pure permissions and limited parameters (2010-05-25)}
17341 @cindex AI-0219 (Ada 2012 feature)
17342
17343 @noindent
17344   This AI refines the rules for the cases with limited parameters which do not
17345   allow the implementations to omit ``redundant''. GNAT now properly conforms
17346   to the requirements of this binding interpretation.
17347
17348 @noindent
17349   RM References:  10.02.01 (18/2)
17350
17351 @item
17352 @emph{AI-0043 Rules about raising exceptions (0000-00-00)}
17353 @cindex AI-0043 (Ada 2012 feature)
17354
17355 @noindent
17356   This AI covers various omissions in the RM regarding the raising of
17357   exceptions. GNAT has always implemented the intended semantics.
17358
17359 @noindent
17360   RM References:  11.04.01 (10.1/2)   11 (2)
17361
17362
17363 @item
17364 @emph{AI-0200 Mismatches in formal package declarations (0000-00-00)}
17365 @cindex AI-0200 (Ada 2012 feature)
17366
17367 @noindent
17368   This AI plugs a gap in the RM which appeared to allow some obviously intended
17369   illegal instantiations. GNAT has never allowed these instantiations.
17370
17371 @noindent
17372   RM References:  12.07 (16)
17373
17374
17375 @item
17376 @emph{AI-0112 Detection of duplicate pragmas (2010-07-24)}
17377 @cindex AI-0112 (Ada 2012 feature)
17378
17379 @noindent
17380   This AI concerns giving names to various representation aspects, but the
17381   practical effect is simply to make the use of duplicate
17382   @code{Atomic}[@code{_Components}],
17383   @code{Volatile}[@code{_Components}] and
17384   @code{Independent}[@code{_Components}] pragmas illegal, and GNAT
17385   now performs this required check.
17386
17387 @noindent
17388   RM References:  13.01 (8)
17389
17390 @item
17391 @emph{AI-0106 No representation pragmas on generic formals (0000-00-00)}
17392 @cindex AI-0106 (Ada 2012 feature)
17393
17394 @noindent
17395   The RM appeared to allow representation pragmas on generic formal parameters,
17396   but this was not intended, and GNAT has never permitted this usage.
17397
17398 @noindent
17399   RM References:  13.01 (9.1/1)
17400
17401
17402 @item
17403 @emph{AI-0012 Pack/Component_Size for aliased/atomic (2010-07-15)}
17404 @cindex AI-0012 (Ada 2012 feature)
17405
17406 @noindent
17407   It is now illegal to give an inappropriate component size or a pragma
17408   @code{Pack} that attempts to change the component size in the case of atomic
17409   or aliased components. Previously GNAT ignored such an attempt with a
17410   warning.
17411
17412 @noindent
17413   RM References:  13.02 (6.1/2)   13.02 (7)   C.06 (10)   C.06 (11)   C.06 (21)
17414
17415
17416 @item
17417 @emph{AI-0039 Stream attributes cannot be dynamic (0000-00-00)}
17418 @cindex AI-0039 (Ada 2012 feature)
17419
17420 @noindent
17421   The RM permitted the use of dynamic expressions (such as @code{ptr.@b{all})}
17422   for stream attributes, but these were never useful and are now illegal. GNAT
17423   has always regarded such expressions as illegal.
17424
17425 @noindent
17426   RM References:  13.03 (4)   13.03 (6)   13.13.02 (38/2)
17427
17428
17429 @item
17430 @emph{AI-0095 Address of intrinsic subprograms (0000-00-00)}
17431 @cindex AI-0095 (Ada 2012 feature)
17432
17433 @noindent
17434   The prefix of @code{'Address} cannot statically denote a subprogram with
17435   convention @code{Intrinsic}. The use of the @code{Address} attribute raises
17436   @code{Program_Error} if the prefix denotes a subprogram with convention
17437   @code{Intrinsic}.
17438
17439 @noindent
17440   RM References:  13.03 (11/1)
17441
17442
17443 @item
17444 @emph{AI-0116 Alignment of class-wide objects (0000-00-00)}
17445 @cindex AI-0116 (Ada 2012 feature)
17446
17447 @noindent
17448   This AI requires that the alignment of a class-wide object be no greater
17449   than the alignment of any type in the class. GNAT has always followed this
17450   recommendation.
17451
17452 @noindent
17453   RM References:  13.03 (29)   13.11 (16)
17454
17455
17456 @item
17457 @emph{AI-0146 Type invariants (2009-09-21)}
17458 @cindex AI-0146 (Ada 2012 feature)
17459
17460 @noindent
17461   Type invariants may be specified for private types using the aspect notation.
17462   Aspect @code{Invariant} may be specified for any private type,
17463   @code{Invariant'Class} can
17464   only be specified for tagged types, and is inherited by any descendent of the
17465   tagged types. The invariant is a boolean expression that is tested for being
17466   true in the following situations: conversions to the private type, object
17467   declarations for the private type that are default initialized, and
17468   [@b{in}] @b{out}
17469   parameters and returned result on return from any primitive operation for
17470   the type that is visible to a client.
17471
17472 @noindent
17473   RM References:  13.03.03 (00)
17474
17475 @item
17476 @emph{AI-0078 Relax Unchecked_Conversion alignment rules (0000-00-00)}
17477 @cindex AI-0078 (Ada 2012 feature)
17478
17479 @noindent
17480   In Ada 2012, compilers are required to support unchecked conversion where the
17481   target alignment is a multiple of the source alignment. GNAT always supported
17482   this case (and indeed all cases of differing alignments, doing copies where
17483   required if the alignment was reduced).
17484
17485 @noindent
17486   RM References:  13.09 (7)
17487
17488
17489 @item
17490 @emph{AI-0195 Invalid value handling is implementation defined (2010-07-03)}
17491 @cindex AI-0195 (Ada 2012 feature)
17492
17493 @noindent
17494   The handling of invalid values is now designated to be implementation
17495   defined. This is a documentation change only, requiring Annex M in the GNAT
17496   Reference Manual to document this handling.
17497   In GNAT, checks for invalid values are made
17498   only when necessary to avoid erroneous behavior. Operations like assignments
17499   which cannot cause erroneous behavior ignore the possibility of invalid
17500   values and do not do a check. The date given above applies only to the
17501   documentation change, this behavior has always been implemented by GNAT.
17502
17503 @noindent
17504   RM References:  13.09.01 (10)
17505
17506 @item
17507 @emph{AI-0193 Alignment of allocators (2010-09-16)}
17508 @cindex AI-0193 (Ada 2012 feature)
17509
17510 @noindent
17511   This AI introduces a new attribute @code{Max_Alignment_For_Allocation},
17512   analogous to @code{Max_Size_In_Storage_Elements}, but for alignment instead
17513   of size.
17514
17515 @noindent
17516   RM References:  13.11 (16)   13.11 (21)   13.11.01 (0)   13.11.01 (1)
17517   13.11.01 (2)   13.11.01 (3)
17518
17519
17520 @item
17521 @emph{AI-0177 Parameterized expressions (2010-07-10)}
17522 @cindex AI-0177 (Ada 2012 feature)
17523
17524 @noindent
17525   The new Ada 2012 notion of parameterized expressions is implemented. The form
17526   is:
17527 @smallexample
17528   @i{function specification} @b{is} (@i{expression})
17529 @end smallexample
17530
17531 @noindent
17532   This is exactly equivalent to the
17533   corresponding function body that returns the expression, but it can appear
17534   in a package spec. Note that the expression must be parenthesized.
17535
17536 @noindent
17537   RM References:  13.11.01 (3/2)
17538
17539 @item
17540 @emph{AI-0033 Attach/Interrupt_Handler in generic (2010-07-24)}
17541 @cindex AI-0033 (Ada 2012 feature)
17542
17543 @noindent
17544   Neither of these two pragmas may appear within a generic template, because
17545   the generic might be instantiated at other than the library level.
17546
17547 @noindent
17548   RM References:  13.11.02 (16)   C.03.01 (7/2)   C.03.01 (8/2)
17549
17550
17551 @item
17552 @emph{AI-0161 Restriction No_Default_Stream_Attributes (2010-09-11)}
17553 @cindex AI-0161 (Ada 2012 feature)
17554
17555 @noindent
17556   A new restriction @code{No_Default_Stream_Attributes} prevents the use of any
17557   of the default stream attributes for elementary types. If this restriction is
17558   in force, then it is necessary to provide explicit subprograms for any
17559   stream attributes used.
17560
17561 @noindent
17562   RM References:  13.12.01 (4/2)   13.13.02 (40/2)   13.13.02 (52/2)
17563
17564 @item
17565 @emph{AI-0194 Value of Stream_Size attribute (0000-00-00)}
17566 @cindex AI-0194 (Ada 2012 feature)
17567
17568 @noindent
17569   The @code{Stream_Size} attribute returns the default number of bits in the
17570   stream representation of the given type.
17571   This value is not affected by the presence
17572   of stream subprogram attributes for the type. GNAT has always implemented
17573   this interpretation.
17574
17575 @noindent
17576   RM References:  13.13.02 (1.2/2)
17577
17578 @item
17579 @emph{AI-0109 Redundant check in S'Class'Input (0000-00-00)}
17580 @cindex AI-0109 (Ada 2012 feature)
17581
17582 @noindent
17583   This AI is an editorial change only. It removes the need for a tag check
17584   that can never fail.
17585
17586 @noindent
17587   RM References:  13.13.02 (34/2)
17588
17589 @item
17590 @emph{AI-0007 Stream read and private scalar types (0000-00-00)}
17591 @cindex AI-0007 (Ada 2012 feature)
17592
17593 @noindent
17594   The RM as written appeared to limit the possibilities of declaring read
17595   attribute procedures for private scalar types. This limitation was not
17596   intended, and has never been enforced by GNAT.
17597
17598 @noindent
17599   RM References:  13.13.02 (50/2)   13.13.02 (51/2)
17600
17601
17602 @item
17603 @emph{AI-0065 Remote access types and external streaming (0000-00-00)}
17604 @cindex AI-0065 (Ada 2012 feature)
17605
17606 @noindent
17607   This AI clarifies the fact that all remote access types support external
17608   streaming. This fixes an obvious oversight in the definition of the
17609   language, and GNAT always implemented the intended correct rules.
17610
17611 @noindent
17612   RM References:  13.13.02 (52/2)
17613
17614 @item
17615 @emph{AI-0019 Freezing of primitives for tagged types (0000-00-00)}
17616 @cindex AI-0019 (Ada 2012 feature)
17617
17618 @noindent
17619   The RM suggests that primitive subprograms of a specific tagged type are
17620   frozen when the tagged type is frozen. This would be an incompatible change
17621   and is not intended. GNAT has never attempted this kind of freezing and its
17622   behavior is consistent with the recommendation of this AI.
17623
17624 @noindent
17625   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)
17626
17627 @item
17628 @emph{AI-0017 Freezing and incomplete types (0000-00-00)}
17629 @cindex AI-0017 (Ada 2012 feature)
17630
17631 @noindent
17632   So-called ``Taft-amendment types'' (i.e., types that are completed in package
17633   bodies) are not frozen by the occurrence of bodies in the
17634   enclosing declarative part. GNAT always implemented this properly.
17635
17636 @noindent
17637   RM References:  13.14 (3/1)
17638
17639
17640 @item
17641 @emph{AI-0060 Extended definition of remote access types (0000-00-00)}
17642 @cindex AI-0060 (Ada 2012 feature)
17643
17644 @noindent
17645   This AI extends the definition of remote access types to include access
17646   to limited, synchronized, protected or task class-wide interface types.
17647   GNAT already implemented this extension.
17648
17649 @noindent
17650   RM References:  A (4)   E.02.02 (9/1)   E.02.02 (9.2/1)   E.02.02 (14/2)   E.02.02 (18)
17651
17652 @item
17653 @emph{AI-0114 Classification of letters (0000-00-00)}
17654 @cindex AI-0114 (Ada 2012 feature)
17655
17656 @noindent
17657   The code points 170 (@code{FEMININE ORDINAL INDICATOR}),
17658   181 (@code{MICRO SIGN}), and
17659   186 (@code{MASCULINE ORDINAL INDICATOR}) are technically considered
17660   lower case letters by Unicode.
17661   However, they are not allowed in identifiers, and they
17662   return @code{False} to @code{Ada.Characters.Handling.Is_Letter/Is_Lower}.
17663   This behavior is consistent with that defined in Ada 95.
17664
17665 @noindent
17666   RM References:  A.03.02 (59)   A.04.06 (7)
17667
17668
17669 @item
17670 @emph{AI-0185 Ada.Wide_[Wide_]Characters.Handling (2010-07-06)}
17671 @cindex AI-0185 (Ada 2012 feature)
17672
17673 @noindent
17674   Two new packages @code{Ada.Wide_[Wide_]Characters.Handling} provide
17675   classification functions for @code{Wide_Character} and
17676   @code{Wide_Wide_Character}, as well as providing
17677   case folding routines for @code{Wide_[Wide_]Character} and
17678   @code{Wide_[Wide_]String}.
17679
17680 @noindent
17681   RM References:  A.03.05 (0)   A.03.06 (0)
17682
17683
17684 @item
17685 @emph{AI-0031 Add From parameter to Find_Token (2010-07-25)}
17686 @cindex AI-0031 (Ada 2012 feature)
17687
17688 @noindent
17689   A new version of @code{Find_Token} is added to all relevant string packages,
17690   with an extra parameter @code{From}. Instead of starting at the first
17691   character of the string, the search for a matching Token starts at the
17692   character indexed by the value of @code{From}.
17693   These procedures are available in all versions of Ada
17694   but if used in versions earlier than Ada 2012 they will generate a warning
17695   that an Ada 2012 subprogram is being used.
17696
17697 @noindent
17698   RM References:  A.04.03 (16)   A.04.03 (67)   A.04.03 (68/1)   A.04.04 (51)
17699   A.04.05 (46)
17700
17701
17702 @item
17703 @emph{AI-0056 Index on null string returns zero (0000-00-00)}
17704 @cindex AI-0056 (Ada 2012 feature)
17705
17706 @noindent
17707   The wording in the Ada 2005 RM implied an incompatible handling of the
17708   @code{Index} functions, resulting in raising an exception instead of
17709   returning zero in some situations.
17710   This was not intended and has been corrected.
17711   GNAT always returned zero, and is thus consistent with this AI.
17712
17713 @noindent
17714   RM References:  A.04.03 (56.2/2)   A.04.03 (58.5/2)
17715
17716
17717 @item
17718 @emph{AI-0137 String encoding package (2010-03-25)}
17719 @cindex AI-0137 (Ada 2012 feature)
17720
17721 @noindent
17722   The packages @code{Ada.Strings.UTF_Encoding}, together with its child
17723   packages, @code{Conversions}, @code{Strings}, @code{Wide_Strings},
17724   and @code{Wide_Wide_Strings} have been
17725   implemented. These packages (whose documentation can be found in the spec
17726   files @file{a-stuten.ads}, @file{a-suenco.ads}, @file{a-suenst.ads},
17727   @file{a-suewst.ads}, @file{a-suezst.ads}) allow encoding and decoding of
17728   @code{String}, @code{Wide_String}, and @code{Wide_Wide_String}
17729   values using UTF coding schemes (including UTF-8, UTF-16LE, UTF-16BE, and
17730   UTF-16), as well as conversions between the different UTF encodings. With
17731   the exception of @code{Wide_Wide_Strings}, these packages are available in
17732   Ada 95 and Ada 2005 mode as well as Ada 2012 mode.
17733   The @code{Wide_Wide_Strings package}
17734   is available in Ada 2005 mode as well as Ada 2012 mode (but not in Ada 95
17735   mode since it uses @code{Wide_Wide_Character}).
17736
17737 @noindent
17738   RM References:  A.04.11
17739
17740 @item
17741 @emph{AI-0038 Minor errors in Text_IO (0000-00-00)}
17742 @cindex AI-0038 (Ada 2012 feature)
17743
17744 @noindent
17745   These are minor errors in the description on three points. The intent on
17746   all these points has always been clear, and GNAT has always implemented the
17747   correct intended semantics.
17748
17749 @noindent
17750   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)
17751
17752 @item
17753 @emph{AI-0044 Restrictions on container instantiations (0000-00-00)}
17754 @cindex AI-0044 (Ada 2012 feature)
17755
17756 @noindent
17757   This AI places restrictions on allowed instantiations of generic containers.
17758   These restrictions are not checked by the compiler, so there is nothing to
17759   change in the implementation. This affects only the RM documentation.
17760
17761 @noindent
17762   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)
17763
17764 @item
17765 @emph{AI-0127 Adding Locale Capabilities (2010-09-29)}
17766 @cindex AI-0127 (Ada 2012 feature)
17767
17768 @noindent
17769   This package provides an interface for identifying the current locale.
17770
17771 @noindent
17772   RM References:  A.19    A.19.01    A.19.02    A.19.03    A.19.05    A.19.06
17773   A.19.07    A.19.08    A.19.09    A.19.10    A.19.11    A.19.12    A.19.13
17774
17775
17776
17777 @item
17778 @emph{AI-0002 Export C with unconstrained arrays (0000-00-00)}
17779 @cindex AI-0002 (Ada 2012 feature)
17780
17781 @noindent
17782   The compiler is not required to support exporting an Ada subprogram with
17783   convention C if there are parameters or a return type of an unconstrained
17784   array type (such as @code{String}). GNAT allows such declarations but
17785   generates warnings. It is possible, but complicated, to write the
17786   corresponding C code and certainly such code would be specific to GNAT and
17787   non-portable.
17788
17789 @noindent
17790   RM References:  B.01 (17)   B.03 (62)   B.03 (71.1/2)
17791
17792
17793 @item
17794 @emph{AI-0216 No_Task_Hierarchy forbids local tasks (0000-00-00)}
17795 @cindex AI-0216 (Ada 2012 feature)
17796
17797 @noindent
17798   It is clearly the intention that @code{No_Task_Hierarchy} is intended to
17799   forbid tasks declared locally within subprograms, or functions returning task
17800   objects, and that is the implementation that GNAT has always provided.
17801   However the language in the RM was not sufficiently clear on this point.
17802   Thus this is a docmentation change in the RM only.
17803
17804 @noindent
17805   RM References:  D.07 (3/3)
17806
17807 @item
17808 @emph{AI-0211 No_Relative_Delays forbids Set_Handler use (2010-07-09)}
17809 @cindex AI-0211 (Ada 2012 feature)
17810
17811 @noindent
17812   The restriction @code{No_Relative_Delays} forbids any calls to the subprogram
17813   @code{Ada.Real_Time.Timing_Events.Set_Handler}.
17814
17815 @noindent
17816   RM References:  D.07 (5)   D.07 (10/2)   D.07 (10.4/2)   D.07 (10.7/2)
17817
17818 @item
17819 @emph{AI-0190 pragma Default_Storage_Pool (2010-09-15)}
17820 @cindex AI-0190 (Ada 2012 feature)
17821
17822 @noindent
17823   This AI introduces a new pragma @code{Default_Storage_Pool}, which can be
17824   used to control storage pools globally.
17825   In particular, you can force every access
17826   type that is used for allocation (@b{new}) to have an explicit storage pool,
17827   or you can declare a pool globally to be used for all access types that lack
17828   an explicit one.
17829
17830 @noindent
17831   RM References:  D.07 (8)
17832
17833 @item
17834 @emph{AI-0189 No_Allocators_After_Elaboration (2010-01-23)}
17835 @cindex AI-0189 (Ada 2012 feature)
17836
17837 @noindent
17838   This AI introduces a new restriction @code{No_Allocators_After_Elaboration},
17839   which says that no dynamic allocation will occur once elaboration is
17840   completed.
17841   In general this requires a run-time check, which is not required, and which
17842   GNAT does not attempt. But the static cases of allocators in a task body or
17843   in the body of the main program are detected and flagged at compile or bind
17844   time.
17845
17846 @noindent
17847   RM References:  D.07 (19.1/2)   H.04 (23.3/2)
17848
17849 @item
17850 @emph{AI-0171 Pragma CPU and Ravenscar Profile (2010-09-24)}
17851 @cindex AI-0171 (Ada 2012 feature)
17852
17853 @noindent
17854   A new package @code{System.Multiprocessors} is added, together with the
17855   definition of pragma @code{CPU} for controlling task affinity. A new no
17856   dependence restriction, on @code{System.Multiprocessors.Dispatching_Domains},
17857   is added to the Ravenscar profile.
17858
17859 @noindent
17860   RM References:  D.13.01 (4/2)   D.16
17861
17862
17863 @item
17864 @emph{AI-0210 Correct Timing_Events metric (0000-00-00)}
17865 @cindex AI-0210 (Ada 2012 feature)
17866
17867 @noindent
17868   This is a documentation only issue regarding wording of metric requirements,
17869   that does not affect the implementation of the compiler.
17870
17871 @noindent
17872   RM References:  D.15 (24/2)
17873
17874
17875 @item
17876 @emph{AI-0206 Remote types packages and preelaborate (2010-07-24)}
17877 @cindex AI-0206 (Ada 2012 feature)
17878
17879 @noindent
17880   Remote types packages are now allowed to depend on preelaborated packages.
17881   This was formerly considered illegal.
17882
17883 @noindent
17884   RM References:  E.02.02 (6)
17885
17886
17887
17888 @item
17889 @emph{AI-0152 Restriction No_Anonymous_Allocators (2010-09-08)}
17890 @cindex AI-0152 (Ada 2012 feature)
17891
17892 @noindent
17893   Restriction @code{No_Anonymous_Allocators} prevents the use of allocators
17894   where the type of the returned value is an anonymous access type.
17895
17896 @noindent
17897   RM References:  H.04 (8/1)
17898 @end itemize
17899
17900
17901 @node Obsolescent Features
17902 @chapter Obsolescent Features
17903
17904 @noindent
17905 This chapter describes features that are provided by GNAT, but are
17906 considered obsolescent since there are preferred ways of achieving
17907 the same effect. These features are provided solely for historical
17908 compatibility purposes.
17909
17910 @menu
17911 * pragma No_Run_Time::
17912 * pragma Ravenscar::
17913 * pragma Restricted_Run_Time::
17914 @end menu
17915
17916 @node pragma No_Run_Time
17917 @section pragma No_Run_Time
17918
17919 The pragma @code{No_Run_Time} is used to achieve an affect similar
17920 to the use of the "Zero Foot Print" configurable run time, but without
17921 requiring a specially configured run time. The result of using this
17922 pragma, which must be used for all units in a partition, is to restrict
17923 the use of any language features requiring run-time support code. The
17924 preferred usage is to use an appropriately configured run-time that
17925 includes just those features that are to be made accessible.
17926
17927 @node pragma Ravenscar
17928 @section pragma Ravenscar
17929
17930 The pragma @code{Ravenscar} has exactly the same effect as pragma
17931 @code{Profile (Ravenscar)}. The latter usage is preferred since it
17932 is part of the new Ada 2005 standard.
17933
17934 @node pragma Restricted_Run_Time
17935 @section pragma Restricted_Run_Time
17936
17937 The pragma @code{Restricted_Run_Time} has exactly the same effect as
17938 pragma @code{Profile (Restricted)}. The latter usage is
17939 preferred since the Ada 2005 pragma @code{Profile} is intended for
17940 this kind of implementation dependent addition.
17941
17942 @include fdl.texi
17943 @c GNU Free Documentation License
17944
17945 @node Index,,GNU Free Documentation License, Top
17946 @unnumbered Index
17947
17948 @printindex cp
17949
17950 @contents
17951
17952 @bye