OSDN Git Service

gcc/ada/
[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.2 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 * Project File Reference::
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 Annotate::
104 * Pragma Assert::
105 * Pragma Ast_Entry::
106 * Pragma C_Pass_By_Copy::
107 * Pragma Check::
108 * Pragma Check_Name::
109 * Pragma Check_Policy::
110 * Pragma Comment::
111 * Pragma Common_Object::
112 * Pragma Compile_Time_Error::
113 * Pragma Compile_Time_Warning::
114 * Pragma Complete_Representation::
115 * Pragma Complex_Representation::
116 * Pragma Component_Alignment::
117 * Pragma Convention_Identifier::
118 * Pragma CPP_Class::
119 * Pragma CPP_Constructor::
120 * Pragma CPP_Virtual::
121 * Pragma CPP_Vtable::
122 * Pragma Debug::
123 * Pragma Debug_Policy::
124 * Pragma Detect_Blocking::
125 * Pragma Elaboration_Checks::
126 * Pragma Eliminate::
127 * Pragma Export_Exception::
128 * Pragma Export_Function::
129 * Pragma Export_Object::
130 * Pragma Export_Procedure::
131 * Pragma Export_Value::
132 * Pragma Export_Valued_Procedure::
133 * Pragma Extend_System::
134 * Pragma External::
135 * Pragma External_Name_Casing::
136 * Pragma Fast_Math::
137 * Pragma Favor_Top_Level::
138 * Pragma Finalize_Storage_Only::
139 * Pragma Float_Representation::
140 * Pragma Ident::
141 * Pragma Implemented_By_Entry::
142 * Pragma Implicit_Packing::
143 * Pragma Import_Exception::
144 * Pragma Import_Function::
145 * Pragma Import_Object::
146 * Pragma Import_Procedure::
147 * Pragma Import_Valued_Procedure::
148 * Pragma Initialize_Scalars::
149 * Pragma Inline_Always::
150 * Pragma Inline_Generic::
151 * Pragma Interface::
152 * Pragma Interface_Name::
153 * Pragma Interrupt_Handler::
154 * Pragma Interrupt_State::
155 * Pragma Keep_Names::
156 * Pragma License::
157 * Pragma Link_With::
158 * Pragma Linker_Alias::
159 * Pragma Linker_Constructor::
160 * Pragma Linker_Destructor::
161 * Pragma Linker_Section::
162 * Pragma Long_Float::
163 * Pragma Machine_Attribute::
164 * Pragma Main::
165 * Pragma Main_Storage::
166 * Pragma No_Body::
167 * Pragma No_Return::
168 * Pragma No_Strict_Aliasing ::
169 * Pragma Normalize_Scalars::
170 * Pragma Obsolescent::
171 * Pragma Optimize_Alignment::
172 * Pragma Passive::
173 * Pragma Persistent_BSS::
174 * Pragma Polling::
175 * Pragma Postcondition::
176 * Pragma Precondition::
177 * Pragma Profile (Ravenscar)::
178 * Pragma Profile (Restricted)::
179 * Pragma Psect_Object::
180 * Pragma Pure_Function::
181 * Pragma Restriction_Warnings::
182 * Pragma Shared::
183 * Pragma Source_File_Name::
184 * Pragma Source_File_Name_Project::
185 * Pragma Source_Reference::
186 * Pragma Stream_Convert::
187 * Pragma Style_Checks::
188 * Pragma Subtitle::
189 * Pragma Suppress::
190 * Pragma Suppress_All::
191 * Pragma Suppress_Exception_Locations::
192 * Pragma Suppress_Initialization::
193 * Pragma Task_Info::
194 * Pragma Task_Name::
195 * Pragma Task_Storage::
196 * Pragma Time_Slice::
197 * Pragma Title::
198 * Pragma Unchecked_Union::
199 * Pragma Unimplemented_Unit::
200 * Pragma Universal_Aliasing ::
201 * Pragma Universal_Data::
202 * Pragma Unmodified::
203 * Pragma Unreferenced::
204 * Pragma Unreferenced_Objects::
205 * Pragma Unreserve_All_Interrupts::
206 * Pragma Unsuppress::
207 * Pragma Use_VADS_Size::
208 * Pragma Validity_Checks::
209 * Pragma Volatile::
210 * Pragma Warnings::
211 * Pragma Weak_External::
212 * Pragma Wide_Character_Encoding::
213
214 Implementation Defined Attributes
215
216 * Abort_Signal::
217 * Address_Size::
218 * Asm_Input::
219 * Asm_Output::
220 * AST_Entry::
221 * Bit::
222 * Bit_Position::
223 * Code_Address::
224 * Default_Bit_Order::
225 * Elaborated::
226 * Elab_Body::
227 * Elab_Spec::
228 * Emax::
229 * Enabled::
230 * Enum_Rep::
231 * Enum_Val::
232 * Epsilon::
233 * Fixed_Value::
234 * Has_Access_Values::
235 * Has_Discriminants::
236 * Img::
237 * Integer_Value::
238 * Invalid_Value::
239 * Large::
240 * Machine_Size::
241 * Mantissa::
242 * Max_Interrupt_Priority::
243 * Max_Priority::
244 * Maximum_Alignment::
245 * Mechanism_Code::
246 * Null_Parameter::
247 * Object_Size::
248 * Old::
249 * Passed_By_Reference::
250 * Pool_Address::
251 * Range_Length::
252 * Safe_Emax::
253 * Safe_Large::
254 * Small::
255 * Storage_Unit::
256 * Stub_Type::
257 * Target_Name::
258 * Tick::
259 * To_Address::
260 * Type_Class::
261 * UET_Address::
262 * Unconstrained_Array::
263 * Universal_Literal_String::
264 * Unrestricted_Access::
265 * VADS_Size::
266 * Value_Size::
267 * Wchar_T_Size::
268 * Word_Size::
269
270 The Implementation of Standard I/O
271
272 * Standard I/O Packages::
273 * FORM Strings::
274 * Direct_IO::
275 * Sequential_IO::
276 * Text_IO::
277 * Wide_Text_IO::
278 * Wide_Wide_Text_IO::
279 * Stream_IO::
280 * Shared Files::
281 * Filenames encoding::
282 * Open Modes::
283 * Operations on C Streams::
284 * Interfacing to C Streams::
285
286 The GNAT Library
287
288 * Ada.Characters.Latin_9 (a-chlat9.ads)::
289 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
290 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
291 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
292 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
293 * Ada.Command_Line.Environment (a-colien.ads)::
294 * Ada.Command_Line.Remove (a-colire.ads)::
295 * Ada.Command_Line.Response_File (a-clrefi.ads)::
296 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
297 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
298 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
299 * Ada.Exceptions.Traceback (a-exctra.ads)::
300 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
301 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
302 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
303 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
304 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
305 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
306 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
307 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
308 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
309 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
310 * GNAT.Altivec (g-altive.ads)::
311 * GNAT.Altivec.Conversions (g-altcon.ads)::
312 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
313 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
314 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
315 * GNAT.Array_Split (g-arrspl.ads)::
316 * GNAT.AWK (g-awk.ads)::
317 * GNAT.Bounded_Buffers (g-boubuf.ads)::
318 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
319 * GNAT.Bubble_Sort (g-bubsor.ads)::
320 * GNAT.Bubble_Sort_A (g-busora.ads)::
321 * GNAT.Bubble_Sort_G (g-busorg.ads)::
322 * GNAT.Byte_Order_Mark (g-byorma.ads)::
323 * GNAT.Byte_Swapping (g-bytswa.ads)::
324 * GNAT.Calendar (g-calend.ads)::
325 * GNAT.Calendar.Time_IO (g-catiio.ads)::
326 * GNAT.Case_Util (g-casuti.ads)::
327 * GNAT.CGI (g-cgi.ads)::
328 * GNAT.CGI.Cookie (g-cgicoo.ads)::
329 * GNAT.CGI.Debug (g-cgideb.ads)::
330 * GNAT.Command_Line (g-comlin.ads)::
331 * GNAT.Compiler_Version (g-comver.ads)::
332 * GNAT.Ctrl_C (g-ctrl_c.ads)::
333 * GNAT.CRC32 (g-crc32.ads)::
334 * GNAT.Current_Exception (g-curexc.ads)::
335 * GNAT.Debug_Pools (g-debpoo.ads)::
336 * GNAT.Debug_Utilities (g-debuti.ads)::
337 * GNAT.Decode_String (g-decstr.ads)::
338 * GNAT.Decode_UTF8_String (g-deutst.ads)::
339 * GNAT.Directory_Operations (g-dirope.ads)::
340 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
341 * GNAT.Dynamic_HTables (g-dynhta.ads)::
342 * GNAT.Dynamic_Tables (g-dyntab.ads)::
343 * GNAT.Encode_String (g-encstr.ads)::
344 * GNAT.Encode_UTF8_String (g-enutst.ads)::
345 * GNAT.Exception_Actions (g-excact.ads)::
346 * GNAT.Exception_Traces (g-exctra.ads)::
347 * GNAT.Exceptions (g-except.ads)::
348 * GNAT.Expect (g-expect.ads)::
349 * GNAT.Float_Control (g-flocon.ads)::
350 * GNAT.Heap_Sort (g-heasor.ads)::
351 * GNAT.Heap_Sort_A (g-hesora.ads)::
352 * GNAT.Heap_Sort_G (g-hesorg.ads)::
353 * GNAT.HTable (g-htable.ads)::
354 * GNAT.IO (g-io.ads)::
355 * GNAT.IO_Aux (g-io_aux.ads)::
356 * GNAT.Lock_Files (g-locfil.ads)::
357 * GNAT.MD5 (g-md5.ads)::
358 * GNAT.Memory_Dump (g-memdum.ads)::
359 * GNAT.Most_Recent_Exception (g-moreex.ads)::
360 * GNAT.OS_Lib (g-os_lib.ads)::
361 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
362 * GNAT.Random_Numbers (g-rannum.ads)::
363 * GNAT.Regexp (g-regexp.ads)::
364 * GNAT.Registry (g-regist.ads)::
365 * GNAT.Regpat (g-regpat.ads)::
366 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
367 * GNAT.Semaphores (g-semaph.ads)::
368 * GNAT.Serial_Communications (g-sercom.ads)::
369 * GNAT.SHA1 (g-sha1.ads)::
370 * GNAT.Signals (g-signal.ads)::
371 * GNAT.Sockets (g-socket.ads)::
372 * GNAT.Source_Info (g-souinf.ads)::
373 * GNAT.Spelling_Checker (g-speche.ads)::
374 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
375 * GNAT.Spitbol.Patterns (g-spipat.ads)::
376 * GNAT.Spitbol (g-spitbo.ads)::
377 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
378 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
379 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
380 * GNAT.Strings (g-string.ads)::
381 * GNAT.String_Split (g-strspl.ads)::
382 * GNAT.Table (g-table.ads)::
383 * GNAT.Task_Lock (g-tasloc.ads)::
384 * GNAT.Threads (g-thread.ads)::
385 * GNAT.Time_Stamp (g-timsta.ads)::
386 * GNAT.Traceback (g-traceb.ads)::
387 * GNAT.Traceback.Symbolic (g-trasym.ads)::
388 * GNAT.UTF_32 (g-utf_32.ads)::
389 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
390 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
391 * GNAT.Wide_String_Split (g-wistsp.ads)::
392 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
393 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
394 * Interfaces.C.Extensions (i-cexten.ads)::
395 * Interfaces.C.Streams (i-cstrea.ads)::
396 * Interfaces.CPP (i-cpp.ads)::
397 * Interfaces.Packed_Decimal (i-pacdec.ads)::
398 * Interfaces.VxWorks (i-vxwork.ads)::
399 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
400 * System.Address_Image (s-addima.ads)::
401 * System.Assertions (s-assert.ads)::
402 * System.Memory (s-memory.ads)::
403 * System.Partition_Interface (s-parint.ads)::
404 * System.Pool_Global (s-pooglo.ads)::
405 * System.Pool_Local (s-pooloc.ads)::
406 * System.Restrictions (s-restri.ads)::
407 * System.Rident (s-rident.ads)::
408 * System.Task_Info (s-tasinf.ads)::
409 * System.Wch_Cnv (s-wchcnv.ads)::
410 * System.Wch_Con (s-wchcon.ads)::
411
412 Text_IO
413
414 * Text_IO Stream Pointer Positioning::
415 * Text_IO Reading and Writing Non-Regular Files::
416 * Get_Immediate::
417 * Treating Text_IO Files as Streams::
418 * Text_IO Extensions::
419 * Text_IO Facilities for Unbounded Strings::
420
421 Wide_Text_IO
422
423 * Wide_Text_IO Stream Pointer Positioning::
424 * Wide_Text_IO Reading and Writing Non-Regular Files::
425
426 Wide_Wide_Text_IO
427
428 * Wide_Wide_Text_IO Stream Pointer Positioning::
429 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
430
431 Interfacing to Other Languages
432
433 * Interfacing to C::
434 * Interfacing to C++::
435 * Interfacing to COBOL::
436 * Interfacing to Fortran::
437 * Interfacing to non-GNAT Ada code::
438
439 Specialized Needs Annexes
440
441 Implementation of Specific Ada Features
442 * Machine Code Insertions::
443 * GNAT Implementation of Tasking::
444 * GNAT Implementation of Shared Passive Packages::
445 * Code Generation for Array Aggregates::
446 * The Size of Discriminated Records with Default Discriminants::
447 * Strict Conformance to the Ada Reference Manual::
448
449 Project File Reference
450
451 Obsolescent Features
452
453 GNU Free Documentation License
454
455 Index
456 @end menu
457
458 @end ifnottex
459
460 @node About This Guide
461 @unnumbered About This Guide
462
463 @noindent
464 This manual contains useful information in writing programs using the
465 @value{EDITION} compiler.  It includes information on implementation dependent
466 characteristics of @value{EDITION}, including all the information required by
467 Annex M of the Ada language standard.
468
469 @value{EDITION} implements Ada 95 and Ada 2005, and it may also be invoked in
470 Ada 83 compatibility mode.
471 By default, @value{EDITION} assumes @value{DEFAULTLANGUAGEVERSION},
472 but you can override with a compiler switch
473 to explicitly specify the language version.
474 (Please refer to @ref{Compiling Different Versions of Ada,,, gnat_ugn,
475 @value{EDITION} User's Guide}, for details on these switches.)
476 Throughout this manual, references to ``Ada'' without a year suffix
477 apply to both the Ada 95 and Ada 2005 versions of the language.
478
479 Ada is designed to be highly portable.
480 In general, a program will have the same effect even when compiled by
481 different compilers on different platforms.
482 However, since Ada is designed to be used in a
483 wide variety of applications, it also contains a number of system
484 dependent features to be used in interfacing to the external world.
485 @cindex Implementation-dependent features
486 @cindex Portability
487
488 Note: Any program that makes use of implementation-dependent features
489 may be non-portable.  You should follow good programming practice and
490 isolate and clearly document any sections of your program that make use
491 of these features in a non-portable manner.
492
493 @ifset PROEDITION
494 For ease of exposition, ``GNAT Pro'' will be referred to simply as
495 ``GNAT'' in the remainder of this document.
496 @end ifset
497
498 @menu
499 * What This Reference Manual Contains::
500 * Conventions::
501 * Related Information::
502 @end menu
503
504 @node What This Reference Manual Contains
505 @unnumberedsec What This Reference Manual Contains
506
507 @noindent
508 This reference manual contains the following chapters:
509
510 @itemize @bullet
511 @item
512 @ref{Implementation Defined Pragmas}, lists GNAT implementation-dependent
513 pragmas, which can be used to extend and enhance the functionality of the
514 compiler.
515
516 @item
517 @ref{Implementation Defined Attributes}, lists GNAT
518 implementation-dependent attributes which can be used to extend and
519 enhance the functionality of the compiler.
520
521 @item
522 @ref{Implementation Advice}, provides information on generally
523 desirable behavior which are not requirements that all compilers must
524 follow since it cannot be provided on all systems, or which may be
525 undesirable on some systems.
526
527 @item
528 @ref{Implementation Defined Characteristics}, provides a guide to
529 minimizing implementation dependent features.
530
531 @item
532 @ref{Intrinsic Subprograms}, describes the intrinsic subprograms
533 implemented by GNAT, and how they can be imported into user
534 application programs.
535
536 @item
537 @ref{Representation Clauses and Pragmas}, describes in detail the
538 way that GNAT represents data, and in particular the exact set
539 of representation clauses and pragmas that is accepted.
540
541 @item
542 @ref{Standard Library Routines}, provides a listing of packages and a
543 brief description of the functionality that is provided by Ada's
544 extensive set of standard library routines as implemented by GNAT@.
545
546 @item
547 @ref{The Implementation of Standard I/O}, details how the GNAT
548 implementation of the input-output facilities.
549
550 @item
551 @ref{The GNAT Library}, is a catalog of packages that complement
552 the Ada predefined library.
553
554 @item
555 @ref{Interfacing to Other Languages}, describes how programs
556 written in Ada using GNAT can be interfaced to other programming
557 languages.
558
559 @ref{Specialized Needs Annexes}, describes the GNAT implementation of all
560 of the specialized needs annexes.
561
562 @item
563 @ref{Implementation of Specific Ada Features}, discusses issues related
564 to GNAT's implementation of machine code insertions, tasking, and several
565 other features.
566
567 @item
568 @ref{Project File Reference}, presents the syntax and semantics
569 of project files.
570
571 @item
572 @ref{Obsolescent Features} documents implementation dependent features,
573 including pragmas and attributes, which are considered obsolescent, since
574 there are other preferred ways of achieving the same results. These
575 obsolescent forms are retained for backwards compatibility.
576
577 @end itemize
578
579 @cindex Ada 95 Language Reference Manual
580 @cindex Ada 2005 Language Reference Manual
581 @noindent
582 This reference manual assumes a basic familiarity with the Ada 95 language, as
583 described in the International Standard ANSI/ISO/IEC-8652:1995,
584 January 1995.
585 It does not require knowledge of the new features introduced by Ada 2005,
586 (officially known as ISO/IEC 8652:1995 with Technical Corrigendum 1
587 and Amendment 1).
588 Both reference manuals are included in the GNAT documentation
589 package.
590
591 @node Conventions
592 @unnumberedsec Conventions
593 @cindex Conventions, typographical
594 @cindex Typographical conventions
595
596 @noindent
597 Following are examples of the typographical and graphic conventions used
598 in this guide:
599
600 @itemize @bullet
601 @item
602 @code{Functions}, @code{utility program names}, @code{standard names},
603 and @code{classes}.
604
605 @item
606 @code{Option flags}
607
608 @item
609 @file{File names}, @samp{button names}, and @samp{field names}.
610
611 @item
612 @code{Variables}, @env{environment variables}, and @var{metasyntactic
613 variables}.
614
615 @item
616 @emph{Emphasis}.
617
618 @item
619 [optional information or parameters]
620
621 @item
622 Examples are described by text
623 @smallexample
624 and then shown this way.
625 @end smallexample
626 @end itemize
627
628 @noindent
629 Commands that are entered by the user are preceded in this manual by the
630 characters @samp{$ } (dollar sign followed by space).  If your system uses this
631 sequence as a prompt, then the commands will appear exactly as you see them
632 in the manual.  If your system uses some other prompt, then the command will
633 appear with the @samp{$} replaced by whatever prompt character you are using.
634
635 @node Related Information
636 @unnumberedsec Related Information
637 @noindent
638 See the following documents for further information on GNAT:
639
640 @itemize @bullet
641 @item
642 @xref{Top, @value{EDITION} User's Guide, About This Guide, gnat_ugn,
643 @value{EDITION} User's Guide}, which provides information on how to use the
644 GNAT compiler system.
645
646 @item
647 @cite{Ada 95 Reference Manual}, which contains all reference
648 material for the Ada 95 programming language.
649
650 @item
651 @cite{Ada 95 Annotated Reference Manual}, which is an annotated version
652 of the Ada 95 standard.  The annotations describe
653 detailed aspects of the design decision, and in particular contain useful
654 sections on Ada 83 compatibility.
655
656 @item
657 @cite{Ada 2005 Reference Manual}, which contains all reference
658 material for the Ada 2005 programming language.
659
660 @item
661 @cite{Ada 2005 Annotated Reference Manual}, which is an annotated version
662 of the Ada 2005 standard.  The annotations describe
663 detailed aspects of the design decision, and in particular contain useful
664 sections on Ada 83 and Ada 95 compatibility.
665
666 @item
667 @cite{DEC Ada, Technical Overview and Comparison on DIGITAL Platforms},
668 which contains specific information on compatibility between GNAT and
669 DEC Ada 83 systems.
670
671 @item
672 @cite{DEC Ada, Language Reference Manual, part number AA-PYZAB-TK} which
673 describes in detail the pragmas and attributes provided by the DEC Ada 83
674 compiler system.
675
676 @end itemize
677
678 @node Implementation Defined Pragmas
679 @chapter Implementation Defined Pragmas
680
681 @noindent
682 Ada defines a set of pragmas that can be used to supply additional
683 information to the compiler.  These language defined pragmas are
684 implemented in GNAT and work as described in the Ada Reference
685 Manual.
686
687 In addition, Ada allows implementations to define additional pragmas
688 whose meaning is defined by the implementation.  GNAT provides a number
689 of these implementation-defined pragmas, which can be used to extend
690 and enhance the functionality of the compiler.  This section of the GNAT
691 Reference Manual describes these additional pragmas.
692
693 Note that any program using these pragmas might not be portable to other
694 compilers (although GNAT implements this set of pragmas on all
695 platforms).  Therefore if portability to other compilers is an important
696 consideration, the use of these pragmas should be minimized.
697
698 @menu
699 * Pragma Abort_Defer::
700 * Pragma Ada_83::
701 * Pragma Ada_95::
702 * Pragma Ada_05::
703 * Pragma Ada_2005::
704 * Pragma Annotate::
705 * Pragma Assert::
706 * Pragma Ast_Entry::
707 * Pragma C_Pass_By_Copy::
708 * Pragma Check::
709 * Pragma Check_Name::
710 * Pragma Check_Policy::
711 * Pragma Comment::
712 * Pragma Common_Object::
713 * Pragma Compile_Time_Error::
714 * Pragma Compile_Time_Warning::
715 * Pragma Complete_Representation::
716 * Pragma Complex_Representation::
717 * Pragma Component_Alignment::
718 * Pragma Convention_Identifier::
719 * Pragma CPP_Class::
720 * Pragma CPP_Constructor::
721 * Pragma CPP_Virtual::
722 * Pragma CPP_Vtable::
723 * Pragma Debug::
724 * Pragma Debug_Policy::
725 * Pragma Detect_Blocking::
726 * Pragma Elaboration_Checks::
727 * Pragma Eliminate::
728 * Pragma Export_Exception::
729 * Pragma Export_Function::
730 * Pragma Export_Object::
731 * Pragma Export_Procedure::
732 * Pragma Export_Value::
733 * Pragma Export_Valued_Procedure::
734 * Pragma Extend_System::
735 * Pragma External::
736 * Pragma External_Name_Casing::
737 * Pragma Fast_Math::
738 * Pragma Favor_Top_Level::
739 * Pragma Finalize_Storage_Only::
740 * Pragma Float_Representation::
741 * Pragma Ident::
742 * Pragma Implemented_By_Entry::
743 * Pragma Implicit_Packing::
744 * Pragma Import_Exception::
745 * Pragma Import_Function::
746 * Pragma Import_Object::
747 * Pragma Import_Procedure::
748 * Pragma Import_Valued_Procedure::
749 * Pragma Initialize_Scalars::
750 * Pragma Inline_Always::
751 * Pragma Inline_Generic::
752 * Pragma Interface::
753 * Pragma Interface_Name::
754 * Pragma Interrupt_Handler::
755 * Pragma Interrupt_State::
756 * Pragma Keep_Names::
757 * Pragma License::
758 * Pragma Link_With::
759 * Pragma Linker_Alias::
760 * Pragma Linker_Constructor::
761 * Pragma Linker_Destructor::
762 * Pragma Linker_Section::
763 * Pragma Long_Float::
764 * Pragma Machine_Attribute::
765 * Pragma Main::
766 * Pragma Main_Storage::
767 * Pragma No_Body::
768 * Pragma No_Return::
769 * Pragma No_Strict_Aliasing::
770 * Pragma Normalize_Scalars::
771 * Pragma Obsolescent::
772 * Pragma Optimize_Alignment::
773 * Pragma Passive::
774 * Pragma Persistent_BSS::
775 * Pragma Polling::
776 * Pragma Postcondition::
777 * Pragma Precondition::
778 * Pragma Profile (Ravenscar)::
779 * Pragma Profile (Restricted)::
780 * Pragma Psect_Object::
781 * Pragma Pure_Function::
782 * Pragma Restriction_Warnings::
783 * Pragma Shared::
784 * Pragma Source_File_Name::
785 * Pragma Source_File_Name_Project::
786 * Pragma Source_Reference::
787 * Pragma Stream_Convert::
788 * Pragma Style_Checks::
789 * Pragma Subtitle::
790 * Pragma Suppress::
791 * Pragma Suppress_All::
792 * Pragma Suppress_Exception_Locations::
793 * Pragma Suppress_Initialization::
794 * Pragma Task_Info::
795 * Pragma Task_Name::
796 * Pragma Task_Storage::
797 * Pragma Time_Slice::
798 * Pragma Title::
799 * Pragma Unchecked_Union::
800 * Pragma Unimplemented_Unit::
801 * Pragma Universal_Aliasing ::
802 * Pragma Universal_Data::
803 * Pragma Unmodified::
804 * Pragma Unreferenced::
805 * Pragma Unreferenced_Objects::
806 * Pragma Unreserve_All_Interrupts::
807 * Pragma Unsuppress::
808 * Pragma Use_VADS_Size::
809 * Pragma Validity_Checks::
810 * Pragma Volatile::
811 * Pragma Warnings::
812 * Pragma Weak_External::
813 * Pragma Wide_Character_Encoding::
814 @end menu
815
816 @node Pragma Abort_Defer
817 @unnumberedsec Pragma Abort_Defer
818 @findex Abort_Defer
819 @cindex Deferring aborts
820 @noindent
821 Syntax:
822 @smallexample
823 pragma Abort_Defer;
824 @end smallexample
825
826 @noindent
827 This pragma must appear at the start of the statement sequence of a
828 handled sequence of statements (right after the @code{begin}).  It has
829 the effect of deferring aborts for the sequence of statements (but not
830 for the declarations or handlers, if any, associated with this statement
831 sequence).
832
833 @node Pragma Ada_83
834 @unnumberedsec Pragma Ada_83
835 @findex Ada_83
836 @noindent
837 Syntax:
838 @smallexample @c ada
839 pragma Ada_83;
840 @end smallexample
841
842 @noindent
843 A configuration pragma that establishes Ada 83 mode for the unit to
844 which it applies, regardless of the mode set by the command line
845 switches.  In Ada 83 mode, GNAT attempts to be as compatible with
846 the syntax and semantics of Ada 83, as defined in the original Ada
847 83 Reference Manual as possible.  In particular, the keywords added by Ada 95
848 and Ada 2005 are not recognized, optional package bodies are allowed,
849 and generics may name types with unknown discriminants without using
850 the @code{(<>)} notation.  In addition, some but not all of the additional
851 restrictions of Ada 83 are enforced.
852
853 Ada 83 mode is intended for two purposes.  Firstly, it allows existing
854 Ada 83 code to be compiled and adapted to GNAT with less effort.
855 Secondly, it aids in keeping code backwards compatible with Ada 83.
856 However, there is no guarantee that code that is processed correctly
857 by GNAT in Ada 83 mode will in fact compile and execute with an Ada
858 83 compiler, since GNAT does not enforce all the additional checks
859 required by Ada 83.
860
861 @node Pragma Ada_95
862 @unnumberedsec Pragma Ada_95
863 @findex Ada_95
864 @noindent
865 Syntax:
866 @smallexample @c ada
867 pragma Ada_95;
868 @end smallexample
869
870 @noindent
871 A configuration pragma that establishes Ada 95 mode for the unit to which
872 it applies, regardless of the mode set by the command line switches.
873 This mode is set automatically for the @code{Ada} and @code{System}
874 packages and their children, so you need not specify it in these
875 contexts.  This pragma is useful when writing a reusable component that
876 itself uses Ada 95 features, but which is intended to be usable from
877 either Ada 83 or Ada 95 programs.
878
879 @node Pragma Ada_05
880 @unnumberedsec Pragma Ada_05
881 @findex Ada_05
882 @noindent
883 Syntax:
884 @smallexample @c ada
885 pragma Ada_05;
886 @end smallexample
887
888 @noindent
889 A configuration pragma that establishes Ada 2005 mode for the unit to which
890 it applies, regardless of the mode set by the command line switches.
891 This mode is set automatically for the @code{Ada} and @code{System}
892 packages and their children, so you need not specify it in these
893 contexts.  This pragma is useful when writing a reusable component that
894 itself uses Ada 2005 features, but which is intended to be usable from
895 either Ada 83 or Ada 95 programs.
896
897 @node Pragma Ada_2005
898 @unnumberedsec Pragma Ada_2005
899 @findex Ada_2005
900 @noindent
901 Syntax:
902 @smallexample @c ada
903 pragma Ada_2005;
904 @end smallexample
905
906 @noindent
907 This configuration pragma is a synonym for pragma Ada_05 and has the
908 same syntax and effect.
909
910 @node Pragma Annotate
911 @unnumberedsec Pragma Annotate
912 @findex Annotate
913 @noindent
914 Syntax:
915 @smallexample @c ada
916 pragma Annotate (IDENTIFIER @{, ARG@});
917
918 ARG ::= NAME | EXPRESSION
919 @end smallexample
920
921 @noindent
922 This pragma is used to annotate programs.  @var{identifier} identifies
923 the type of annotation.  GNAT verifies that it is an identifier, but does
924 not otherwise analyze it.  The @var{arg} argument
925 can be either a string literal or an
926 expression.  String literals are assumed to be of type
927 @code{Standard.String}.  Names of entities are simply analyzed as entity
928 names.  All other expressions are analyzed as expressions, and must be
929 unambiguous.
930
931 The analyzed pragma is retained in the tree, but not otherwise processed
932 by any part of the GNAT compiler.  This pragma is intended for use by
933 external tools, including ASIS@.
934
935 @node Pragma Assert
936 @unnumberedsec Pragma Assert
937 @findex Assert
938 @noindent
939 Syntax:
940 @smallexample @c ada
941 pragma Assert (
942   boolean_EXPRESSION
943   [, string_EXPRESSION]);
944 @end smallexample
945
946 @noindent
947 The effect of this pragma depends on whether the corresponding command
948 line switch is set to activate assertions.  The pragma expands into code
949 equivalent to the following:
950
951 @smallexample @c ada
952 if assertions-enabled then
953    if not boolean_EXPRESSION then
954       System.Assertions.Raise_Assert_Failure
955         (string_EXPRESSION);
956    end if;
957 end if;
958 @end smallexample
959
960 @noindent
961 The string argument, if given, is the message that will be associated
962 with the exception occurrence if the exception is raised.  If no second
963 argument is given, the default message is @samp{@var{file}:@var{nnn}},
964 where @var{file} is the name of the source file containing the assert,
965 and @var{nnn} is the line number of the assert.  A pragma is not a
966 statement, so if a statement sequence contains nothing but a pragma
967 assert, then a null statement is required in addition, as in:
968
969 @smallexample @c ada
970 @dots{}
971 if J > 3 then
972    pragma Assert (K > 3, "Bad value for K");
973    null;
974 end if;
975 @end smallexample
976
977 @noindent
978 Note that, as with the @code{if} statement to which it is equivalent, the
979 type of the expression is either @code{Standard.Boolean}, or any type derived
980 from this standard type.
981
982 If assertions are disabled (switch @option{-gnata} not used), then there
983 is no run-time effect (and in particular, any side effects from the
984 expression will not occur at run time).  (The expression is still
985 analyzed at compile time, and may cause types to be frozen if they are
986 mentioned here for the first time).
987
988 If assertions are enabled, then the given expression is tested, and if
989 it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
990 which results in the raising of @code{Assert_Failure} with the given message.
991
992 You should generally avoid side effects in the expression arguments of
993 this pragma, because these side effects will turn on and off with the
994 setting of the assertions mode, resulting in assertions that have an
995 effect on the program.  However, the expressions are analyzed for
996 semantic correctness whether or not assertions are enabled, so turning
997 assertions on and off cannot affect the legality of a program.
998
999 @node Pragma Ast_Entry
1000 @unnumberedsec Pragma Ast_Entry
1001 @cindex OpenVMS
1002 @findex Ast_Entry
1003 @noindent
1004 Syntax:
1005 @smallexample @c ada
1006 pragma AST_Entry (entry_IDENTIFIER);
1007 @end smallexample
1008
1009 @noindent
1010 This pragma is implemented only in the OpenVMS implementation of GNAT@.  The
1011 argument is the simple name of a single entry; at most one @code{AST_Entry}
1012 pragma is allowed for any given entry.  This pragma must be used in
1013 conjunction with the @code{AST_Entry} attribute, and is only allowed after
1014 the entry declaration and in the same task type specification or single task
1015 as the entry to which it applies.  This pragma specifies that the given entry
1016 may be used to handle an OpenVMS asynchronous system trap (@code{AST})
1017 resulting from an OpenVMS system service call.  The pragma does not affect
1018 normal use of the entry.  For further details on this pragma, see the
1019 DEC Ada Language Reference Manual, section 9.12a.
1020
1021 @node Pragma C_Pass_By_Copy
1022 @unnumberedsec Pragma C_Pass_By_Copy
1023 @cindex Passing by copy
1024 @findex C_Pass_By_Copy
1025 @noindent
1026 Syntax:
1027 @smallexample @c ada
1028 pragma C_Pass_By_Copy
1029   ([Max_Size =>] static_integer_EXPRESSION);
1030 @end smallexample
1031
1032 @noindent
1033 Normally the default mechanism for passing C convention records to C
1034 convention subprograms is to pass them by reference, as suggested by RM
1035 B.3(69).  Use the configuration pragma @code{C_Pass_By_Copy} to change
1036 this default, by requiring that record formal parameters be passed by
1037 copy if all of the following conditions are met:
1038
1039 @itemize @bullet
1040 @item
1041 The size of the record type does not exceed the value specified for
1042 @code{Max_Size}.
1043 @item
1044 The record type has @code{Convention C}.
1045 @item
1046 The formal parameter has this record type, and the subprogram has a
1047 foreign (non-Ada) convention.
1048 @end itemize
1049
1050 @noindent
1051 If these conditions are met the argument is passed by copy, i.e.@: in a
1052 manner consistent with what C expects if the corresponding formal in the
1053 C prototype is a struct (rather than a pointer to a struct).
1054
1055 You can also pass records by copy by specifying the convention
1056 @code{C_Pass_By_Copy} for the record type, or by using the extended
1057 @code{Import} and @code{Export} pragmas, which allow specification of
1058 passing mechanisms on a parameter by parameter basis.
1059
1060 @node Pragma Check
1061 @unnumberedsec Pragma Check
1062 @cindex Assertions
1063 @cindex Named assertions
1064 @findex Check
1065 @noindent
1066 Syntax:
1067 @smallexample @c ada
1068 pragma Check (
1069      [Name    =>] Identifier,
1070      [Check   =>] Boolean_EXPRESSION
1071   [, [Message =>] string_EXPRESSION] );
1072 @end smallexample
1073
1074 @noindent
1075 This pragma is similar to the predefined pragma @code{Assert} except that an
1076 extra identifier argument is present. In conjunction with pragma
1077 @code{Check_Policy}, this can be used to define groups of assertions that can
1078 be independently controlled. The identifier @code{Assertion} is special, it
1079 refers to the normal set of pragma @code{Assert} statements. The identifiers
1080 @code{Precondition} and @code{Postcondition} correspond to the pragmas of these
1081 names, so these three names would normally not be used directly in a pragma
1082 @code{Check}.
1083
1084 Checks introduced by this pragma are normally deactivated by default. They can
1085 be activated either by the command line option @option{-gnata}, which turns on
1086 all checks, or individually controlled using pragma @code{Check_Policy}.
1087
1088 @node Pragma Check_Name
1089 @unnumberedsec Pragma Check_Name
1090 @cindex Defining check names
1091 @cindex Check names, defining
1092 @findex Check_Name
1093 @noindent
1094 Syntax:
1095 @smallexample @c ada
1096 pragma Check_Name (check_name_IDENTIFIER);
1097 @end smallexample
1098
1099 @noindent
1100 This is a configuration pragma that defines a new implementation
1101 defined check name (unless IDENTIFIER matches one of the predefined
1102 check names, in which case the pragma has no effect). Check names
1103 are global to a partition, so if two or more configuration pragmas
1104 are present in a partition mentioning the same name, only one new
1105 check name is introduced.
1106
1107 An implementation defined check name introduced with this pragma may
1108 be used in only three contexts: @code{pragma Suppress},
1109 @code{pragma Unsuppress},
1110 and as the prefix of a @code{Check_Name'Enabled} attribute reference. For
1111 any of these three cases, the check name must be visible. A check
1112 name is visible if it is in the configuration pragmas applying to
1113 the current unit, or if it appears at the start of any unit that
1114 is part of the dependency set of the current unit (e.g., units that
1115 are mentioned in @code{with} clauses).
1116
1117 @node Pragma Check_Policy
1118 @unnumberedsec Pragma Check_Policy
1119 @cindex Controlling assertions
1120 @cindex Assertions, control
1121 @cindex Check pragma control
1122 @cindex Named assertions
1123 @findex Check
1124 @noindent
1125 Syntax:
1126 @smallexample @c ada
1127 pragma Check_Policy ([Name =>] Identifier, POLICY_IDENTIFIER);
1128
1129 POLICY_IDENTIFIER ::= On | Off | Check | Ignore
1130 @end smallexample
1131
1132 @noindent
1133 This pragma is similar to the predefined pragma @code{Assertion_Policy},
1134 except that it controls sets of named assertions introduced using the
1135 @code{Check} pragmas. It can be used as a configuration pragma or (unlike
1136 @code{Assertion_Policy}) can be used within a declarative part, in which case
1137 it controls the status to the end of the corresponding construct (in a manner
1138 identical to pragma @code{Suppress)}.
1139
1140 The identifier given as the first argument corresponds to a name used in
1141 associated @code{Check} pragmas. For example, if the pragma:
1142
1143 @smallexample @c ada
1144 pragma Check_Policy (Critical_Error, Off);
1145 @end smallexample
1146
1147 @noindent
1148 is given, then subsequent @code{Check} pragmas whose first argument is also
1149 @code{Critical_Error} will be disabled. The special identifier @code{Assertion}
1150 controls the behavior of normal @code{Assert} pragmas (thus a pragma
1151 @code{Check_Policy} with this identifier is similar to the normal
1152 @code{Assertion_Policy} pragma except that it can appear within a
1153 declarative part).
1154
1155 The special identifiers @code{Precondition} and @code{Postcondition} control
1156 the status of preconditions and postconditions. If a @code{Precondition} pragma
1157 is encountered, it is ignored if turned off by a @code{Check_Policy} specifying
1158 that @code{Precondition} checks are @code{Off} or @code{Ignored}. Similarly use
1159 of the name @code{Postcondition} controls whether @code{Postcondition} pragmas
1160 are recognized.
1161
1162 The check policy is @code{Off} to turn off corresponding checks, and @code{On}
1163 to turn on corresponding checks. The default for a set of checks for which no
1164 @code{Check_Policy} is given is @code{Off} unless the compiler switch
1165 @option{-gnata} is given, which turns on all checks by default.
1166
1167 The check policy settings @code{Check} and @code{Ignore} are also recognized
1168 as synonyms for @code{On} and @code{Off}. These synonyms are provided for
1169 compatibility with the standard @code{Assertion_Policy} pragma.
1170
1171 @node Pragma Comment
1172 @unnumberedsec Pragma Comment
1173 @findex Comment
1174 @noindent
1175 Syntax:
1176
1177 @smallexample @c ada
1178 pragma Comment (static_string_EXPRESSION);
1179 @end smallexample
1180
1181 @noindent
1182 This is almost identical in effect to pragma @code{Ident}.  It allows the
1183 placement of a comment into the object file and hence into the
1184 executable file if the operating system permits such usage.  The
1185 difference is that @code{Comment}, unlike @code{Ident}, has
1186 no limitations on placement of the pragma (it can be placed
1187 anywhere in the main source unit), and if more than one pragma
1188 is used, all comments are retained.
1189
1190 @node Pragma Common_Object
1191 @unnumberedsec Pragma Common_Object
1192 @findex Common_Object
1193 @noindent
1194 Syntax:
1195
1196 @smallexample @c ada
1197 pragma Common_Object (
1198      [Internal =>] LOCAL_NAME
1199   [, [External =>] EXTERNAL_SYMBOL]
1200   [, [Size     =>] EXTERNAL_SYMBOL] );
1201
1202 EXTERNAL_SYMBOL ::=
1203   IDENTIFIER
1204 | static_string_EXPRESSION
1205 @end smallexample
1206
1207 @noindent
1208 This pragma enables the shared use of variables stored in overlaid
1209 linker areas corresponding to the use of @code{COMMON}
1210 in Fortran.  The single
1211 object @var{LOCAL_NAME} is assigned to the area designated by
1212 the @var{External} argument.
1213 You may define a record to correspond to a series
1214 of fields.  The @var{Size} argument
1215 is syntax checked in GNAT, but otherwise ignored.
1216
1217 @code{Common_Object} is not supported on all platforms.  If no
1218 support is available, then the code generator will issue a message
1219 indicating that the necessary attribute for implementation of this
1220 pragma is not available.
1221
1222 @node Pragma Compile_Time_Error
1223 @unnumberedsec Pragma Compile_Time_Error
1224 @findex Compile_Time_Error
1225 @noindent
1226 Syntax:
1227
1228 @smallexample @c ada
1229 pragma Compile_Time_Error
1230          (boolean_EXPRESSION, static_string_EXPRESSION);
1231 @end smallexample
1232
1233 @noindent
1234 This pragma can be used to generate additional compile time
1235 error messages. It
1236 is particularly useful in generics, where errors can be issued for
1237 specific problematic instantiations. The first parameter is a boolean
1238 expression. The pragma is effective only if the value of this expression
1239 is known at compile time, and has the value True. The set of expressions
1240 whose values are known at compile time includes all static boolean
1241 expressions, and also other values which the compiler can determine
1242 at compile time (e.g., the size of a record type set by an explicit
1243 size representation clause, or the value of a variable which was
1244 initialized to a constant and is known not to have been modified).
1245 If these conditions are met, an error message is generated using
1246 the value given as the second argument. This string value may contain
1247 embedded ASCII.LF characters to break the message into multiple lines.
1248
1249 @node Pragma Compile_Time_Warning
1250 @unnumberedsec Pragma Compile_Time_Warning
1251 @findex Compile_Time_Warning
1252 @noindent
1253 Syntax:
1254
1255 @smallexample @c ada
1256 pragma Compile_Time_Warning
1257          (boolean_EXPRESSION, static_string_EXPRESSION);
1258 @end smallexample
1259
1260 @noindent
1261 Same as pragma Compile_Time_Error, except a warning is issued instead
1262 of an error message. Note that if this pragma is used in a package that
1263 is with'ed by a client, the client will get the warning even though it
1264 is issued by a with'ed package (normally warnings in with'ed units are
1265 suppressed, but this is a special exception to that rule).
1266
1267 One typical use is within a generic where compile time known characteristics
1268 of formal parameters are tested, and warnings given appropriately. Another use
1269 with a first parameter of True is to warn a client about use of a package,
1270 for example that it is not fully implemented.
1271
1272 @node Pragma Complete_Representation
1273 @unnumberedsec Pragma Complete_Representation
1274 @findex Complete_Representation
1275 @noindent
1276 Syntax:
1277
1278 @smallexample @c ada
1279 pragma Complete_Representation;
1280 @end smallexample
1281
1282 @noindent
1283 This pragma must appear immediately within a record representation
1284 clause. Typical placements are before the first component clause
1285 or after the last component clause. The effect is to give an error
1286 message if any component is missing a component clause. This pragma
1287 may be used to ensure that a record representation clause is
1288 complete, and that this invariant is maintained if fields are
1289 added to the record in the future.
1290
1291 @node Pragma Complex_Representation
1292 @unnumberedsec Pragma Complex_Representation
1293 @findex Complex_Representation
1294 @noindent
1295 Syntax:
1296
1297 @smallexample @c ada
1298 pragma Complex_Representation
1299         ([Entity =>] LOCAL_NAME);
1300 @end smallexample
1301
1302 @noindent
1303 The @var{Entity} argument must be the name of a record type which has
1304 two fields of the same floating-point type.  The effect of this pragma is
1305 to force gcc to use the special internal complex representation form for
1306 this record, which may be more efficient.  Note that this may result in
1307 the code for this type not conforming to standard ABI (application
1308 binary interface) requirements for the handling of record types.  For
1309 example, in some environments, there is a requirement for passing
1310 records by pointer, and the use of this pragma may result in passing
1311 this type in floating-point registers.
1312
1313 @node Pragma Component_Alignment
1314 @unnumberedsec Pragma Component_Alignment
1315 @cindex Alignments of components
1316 @findex Component_Alignment
1317 @noindent
1318 Syntax:
1319
1320 @smallexample @c ada
1321 pragma Component_Alignment (
1322      [Form =>] ALIGNMENT_CHOICE
1323   [, [Name =>] type_LOCAL_NAME]);
1324
1325 ALIGNMENT_CHOICE ::=
1326   Component_Size
1327 | Component_Size_4
1328 | Storage_Unit
1329 | Default
1330 @end smallexample
1331
1332 @noindent
1333 Specifies the alignment of components in array or record types.
1334 The meaning of the @var{Form} argument is as follows:
1335
1336 @table @code
1337 @findex Component_Size
1338 @item Component_Size
1339 Aligns scalar components and subcomponents of the array or record type
1340 on boundaries appropriate to their inherent size (naturally
1341 aligned).  For example, 1-byte components are aligned on byte boundaries,
1342 2-byte integer components are aligned on 2-byte boundaries, 4-byte
1343 integer components are aligned on 4-byte boundaries and so on.  These
1344 alignment rules correspond to the normal rules for C compilers on all
1345 machines except the VAX@.
1346
1347 @findex Component_Size_4
1348 @item Component_Size_4
1349 Naturally aligns components with a size of four or fewer
1350 bytes.  Components that are larger than 4 bytes are placed on the next
1351 4-byte boundary.
1352
1353 @findex Storage_Unit
1354 @item Storage_Unit
1355 Specifies that array or record components are byte aligned, i.e.@:
1356 aligned on boundaries determined by the value of the constant
1357 @code{System.Storage_Unit}.
1358
1359 @cindex OpenVMS
1360 @item Default
1361 Specifies that array or record components are aligned on default
1362 boundaries, appropriate to the underlying hardware or operating system or
1363 both.  For OpenVMS VAX systems, the @code{Default} choice is the same as
1364 the @code{Storage_Unit} choice (byte alignment).  For all other systems,
1365 the @code{Default} choice is the same as @code{Component_Size} (natural
1366 alignment).
1367 @end table
1368
1369 @noindent
1370 If the @code{Name} parameter is present, @var{type_LOCAL_NAME} must
1371 refer to a local record or array type, and the specified alignment
1372 choice applies to the specified type.  The use of
1373 @code{Component_Alignment} together with a pragma @code{Pack} causes the
1374 @code{Component_Alignment} pragma to be ignored.  The use of
1375 @code{Component_Alignment} together with a record representation clause
1376 is only effective for fields not specified by the representation clause.
1377
1378 If the @code{Name} parameter is absent, the pragma can be used as either
1379 a configuration pragma, in which case it applies to one or more units in
1380 accordance with the normal rules for configuration pragmas, or it can be
1381 used within a declarative part, in which case it applies to types that
1382 are declared within this declarative part, or within any nested scope
1383 within this declarative part.  In either case it specifies the alignment
1384 to be applied to any record or array type which has otherwise standard
1385 representation.
1386
1387 If the alignment for a record or array type is not specified (using
1388 pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
1389 clause), the GNAT uses the default alignment as described previously.
1390
1391 @node Pragma Convention_Identifier
1392 @unnumberedsec Pragma Convention_Identifier
1393 @findex Convention_Identifier
1394 @cindex Conventions, synonyms
1395 @noindent
1396 Syntax:
1397
1398 @smallexample @c ada
1399 pragma Convention_Identifier (
1400          [Name =>]       IDENTIFIER,
1401          [Convention =>] convention_IDENTIFIER);
1402 @end smallexample
1403
1404 @noindent
1405 This pragma provides a mechanism for supplying synonyms for existing
1406 convention identifiers. The @code{Name} identifier can subsequently
1407 be used as a synonym for the given convention in other pragmas (including
1408 for example pragma @code{Import} or another @code{Convention_Identifier}
1409 pragma). As an example of the use of this, suppose you had legacy code
1410 which used Fortran77 as the identifier for Fortran. Then the pragma:
1411
1412 @smallexample @c ada
1413 pragma Convention_Identifier (Fortran77, Fortran);
1414 @end smallexample
1415
1416 @noindent
1417 would allow the use of the convention identifier @code{Fortran77} in
1418 subsequent code, avoiding the need to modify the sources. As another
1419 example, you could use this to parametrize convention requirements
1420 according to systems. Suppose you needed to use @code{Stdcall} on
1421 windows systems, and @code{C} on some other system, then you could
1422 define a convention identifier @code{Library} and use a single
1423 @code{Convention_Identifier} pragma to specify which convention
1424 would be used system-wide.
1425
1426 @node Pragma CPP_Class
1427 @unnumberedsec Pragma CPP_Class
1428 @findex CPP_Class
1429 @cindex Interfacing with C++
1430 @noindent
1431 Syntax:
1432
1433 @smallexample @c ada
1434 pragma CPP_Class ([Entity =>] LOCAL_NAME);
1435 @end smallexample
1436
1437 @noindent
1438 The argument denotes an entity in the current declarative region that is
1439 declared as a tagged record type. It indicates that the type corresponds
1440 to an externally declared C++ class type, and is to be laid out the same
1441 way that C++ would lay out the type.
1442
1443 Types for which @code{CPP_Class} is specified do not have assignment or
1444 equality operators defined (such operations can be imported or declared
1445 as subprograms as required). Initialization is allowed only by constructor
1446 functions (see pragma @code{CPP_Constructor}). Such types are implicitly
1447 limited if not explicitly declared as limited or derived from a limited
1448 type, and a warning is issued in that case.
1449
1450 Pragma @code{CPP_Class} is intended primarily for automatic generation
1451 using an automatic binding generator tool.
1452 See @ref{Interfacing to C++} for related information.
1453
1454 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
1455 for backward compatibility but its functionality is available
1456 using pragma @code{Import} with @code{Convention} = @code{CPP}.
1457
1458 @node Pragma CPP_Constructor
1459 @unnumberedsec Pragma CPP_Constructor
1460 @cindex Interfacing with C++
1461 @findex CPP_Constructor
1462 @noindent
1463 Syntax:
1464
1465 @smallexample @c ada
1466 pragma CPP_Constructor ([Entity =>] LOCAL_NAME
1467   [, [External_Name =>] static_string_EXPRESSION ]
1468   [, [Link_Name     =>] static_string_EXPRESSION ]);
1469 @end smallexample
1470
1471 @noindent
1472 This pragma identifies an imported function (imported in the usual way
1473 with pragma @code{Import}) as corresponding to a C++ constructor. If
1474 @code{External_Name} and @code{Link_Name} are not specified then the
1475 @code{Entity} argument is a name that must have been previously mentioned
1476 in a pragma @code{Import} with @code{Convention} = @code{CPP}. Such name
1477 must be of one of the following forms:
1478
1479 @itemize @bullet
1480 @item
1481 @code{function @var{Fname} return @var{T}'Class}
1482
1483 @item
1484 @code{function @var{Fname} (@dots{}) return @var{T}'Class}
1485 @end itemize
1486
1487 @noindent
1488 where @var{T} is a tagged type to which the pragma @code{CPP_Class} applies.
1489
1490 The first form is the default constructor, used when an object of type
1491 @var{T} is created on the Ada side with no explicit constructor.  Other
1492 constructors (including the copy constructor, which is simply a special
1493 case of the second form in which the one and only argument is of type
1494 @var{T}), can only appear in two contexts:
1495
1496 @itemize @bullet
1497 @item
1498 On the right side of an initialization of an object of type @var{T}.
1499 @item
1500 In an extension aggregate for an object of a type derived from @var{T}.
1501 @end itemize
1502
1503 @noindent
1504 Although the constructor is described as a function that returns a value
1505 on the Ada side, it is typically a procedure with an extra implicit
1506 argument (the object being initialized) at the implementation
1507 level.  GNAT issues the appropriate call, whatever it is, to get the
1508 object properly initialized.
1509
1510 In the case of derived objects, you may use one of two possible forms
1511 for declaring and creating an object:
1512
1513 @itemize @bullet
1514 @item @code{New_Object : Derived_T}
1515 @item @code{New_Object : Derived_T := (@var{constructor-call with} @dots{})}
1516 @end itemize
1517
1518 @noindent
1519 In the first case the default constructor is called and extension fields
1520 if any are initialized according to the default initialization
1521 expressions in the Ada declaration.  In the second case, the given
1522 constructor is called and the extension aggregate indicates the explicit
1523 values of the extension fields.
1524
1525 If no constructors are imported, it is impossible to create any objects
1526 on the Ada side.  If no default constructor is imported, only the
1527 initialization forms using an explicit call to a constructor are
1528 permitted.
1529
1530 Pragma @code{CPP_Constructor} is intended primarily for automatic generation
1531 using an automatic binding generator tool.
1532 See @ref{Interfacing to C++} for more related information.
1533
1534 @node Pragma CPP_Virtual
1535 @unnumberedsec Pragma CPP_Virtual
1536 @cindex Interfacing to C++
1537 @findex CPP_Virtual
1538 @noindent
1539 This pragma is now obsolete has has no effect because GNAT generates
1540 the same object layout than the G++ compiler.
1541
1542 See @ref{Interfacing to C++} for related information.
1543
1544 @node Pragma CPP_Vtable
1545 @unnumberedsec Pragma CPP_Vtable
1546 @cindex Interfacing with C++
1547 @findex CPP_Vtable
1548 @noindent
1549 This pragma is now obsolete has has no effect because GNAT generates
1550 the same object layout than the G++ compiler.
1551
1552 See @ref{Interfacing to C++} for related information.
1553
1554 @node Pragma Debug
1555 @unnumberedsec Pragma Debug
1556 @findex Debug
1557 @noindent
1558 Syntax:
1559
1560 @smallexample @c ada
1561 pragma Debug ([CONDITION, ]PROCEDURE_CALL_WITHOUT_SEMICOLON);
1562
1563 PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
1564   PROCEDURE_NAME
1565 | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
1566 @end smallexample
1567
1568 @noindent
1569 The procedure call argument has the syntactic form of an expression, meeting
1570 the syntactic requirements for pragmas.
1571
1572 If debug pragmas are not enabled or if the condition is present and evaluates
1573 to False, this pragma has no effect. If debug pragmas are enabled, the
1574 semantics of the pragma is exactly equivalent to the procedure call statement
1575 corresponding to the argument with a terminating semicolon. Pragmas are
1576 permitted in sequences of declarations, so you can use pragma @code{Debug} to
1577 intersperse calls to debug procedures in the middle of declarations. Debug
1578 pragmas can be enabled either by use of the command line switch @option{-gnata}
1579 or by use of the configuration pragma @code{Debug_Policy}.
1580
1581 @node Pragma Debug_Policy
1582 @unnumberedsec Pragma Debug_Policy
1583 @findex Debug_Policy
1584 @noindent
1585 Syntax:
1586
1587 @smallexample @c ada
1588 pragma Debug_Policy (CHECK | IGNORE);
1589 @end smallexample
1590
1591 @noindent
1592 If the argument is @code{CHECK}, then pragma @code{DEBUG} is enabled.
1593 If the argument is @code{IGNORE}, then pragma @code{DEBUG} is ignored.
1594 This pragma overrides the effect of the @option{-gnata} switch on the
1595 command line.
1596
1597 @node Pragma Detect_Blocking
1598 @unnumberedsec Pragma Detect_Blocking
1599 @findex Detect_Blocking
1600 @noindent
1601 Syntax:
1602
1603 @smallexample @c ada
1604 pragma Detect_Blocking;
1605 @end smallexample
1606
1607 @noindent
1608 This is a configuration pragma that forces the detection of potentially
1609 blocking operations within a protected operation, and to raise Program_Error
1610 if that happens.
1611
1612 @node Pragma Elaboration_Checks
1613 @unnumberedsec Pragma Elaboration_Checks
1614 @cindex Elaboration control
1615 @findex Elaboration_Checks
1616 @noindent
1617 Syntax:
1618
1619 @smallexample @c ada
1620 pragma Elaboration_Checks (Dynamic | Static);
1621 @end smallexample
1622
1623 @noindent
1624 This is a configuration pragma that provides control over the
1625 elaboration model used by the compilation affected by the
1626 pragma.  If the parameter is @code{Dynamic},
1627 then the dynamic elaboration
1628 model described in the Ada Reference Manual is used, as though
1629 the @option{-gnatE} switch had been specified on the command
1630 line.  If the parameter is @code{Static}, then the default GNAT static
1631 model is used.  This configuration pragma overrides the setting
1632 of the command line.  For full details on the elaboration models
1633 used by the GNAT compiler, see @ref{Elaboration Order Handling in GNAT,,,
1634 gnat_ugn, @value{EDITION} User's Guide}.
1635
1636 @node Pragma Eliminate
1637 @unnumberedsec Pragma Eliminate
1638 @cindex Elimination of unused subprograms
1639 @findex Eliminate
1640 @noindent
1641 Syntax:
1642
1643 @smallexample @c ada
1644 pragma Eliminate (
1645     [Unit_Name =>] IDENTIFIER |
1646                    SELECTED_COMPONENT);
1647
1648 pragma Eliminate (
1649     [Unit_Name       =>]  IDENTIFIER |
1650                           SELECTED_COMPONENT,
1651     [Entity          =>]  IDENTIFIER |
1652                           SELECTED_COMPONENT |
1653                           STRING_LITERAL
1654     [,OVERLOADING_RESOLUTION]);
1655
1656 OVERLOADING_RESOLUTION ::= PARAMETER_AND_RESULT_TYPE_PROFILE |
1657                            SOURCE_LOCATION
1658
1659 PARAMETER_AND_RESULT_TYPE_PROFILE ::= PROCEDURE_PROFILE |
1660                                       FUNCTION_PROFILE
1661
1662 PROCEDURE_PROFILE ::= Parameter_Types => PARAMETER_TYPES
1663
1664 FUNCTION_PROFILE ::= [Parameter_Types => PARAMETER_TYPES,]
1665                       Result_Type => result_SUBTYPE_NAME]
1666
1667 PARAMETER_TYPES ::= (SUBTYPE_NAME @{, SUBTYPE_NAME@})
1668 SUBTYPE_NAME    ::= STRING_VALUE
1669
1670 SOURCE_LOCATION ::= Source_Location => SOURCE_TRACE
1671 SOURCE_TRACE    ::= STRING_VALUE
1672
1673 STRING_VALUE ::= STRING_LITERAL @{& STRING_LITERAL@}
1674 @end smallexample
1675
1676 @noindent
1677 This pragma indicates that the given entity is not used outside the
1678 compilation unit it is defined in. The entity must be an explicitly declared
1679 subprogram; this includes  generic subprogram instances and
1680 subprograms declared in generic package instances.
1681
1682 If the entity to be eliminated is a library level subprogram, then
1683 the first form of pragma @code{Eliminate} is used with only a single argument.
1684 In this form, the @code{Unit_Name} argument specifies the name of the
1685 library  level unit to be eliminated.
1686
1687 In all other cases, both @code{Unit_Name} and @code{Entity} arguments
1688 are required. If item is an entity of a library package, then the first
1689 argument specifies the unit name, and the second argument specifies
1690 the particular entity.  If the second argument is in string form, it must
1691 correspond to the internal manner in which GNAT stores entity names (see
1692 compilation unit Namet in the compiler sources for details).
1693
1694 The remaining parameters (OVERLOADING_RESOLUTION) are optionally used
1695 to distinguish between overloaded subprograms. If a pragma does not contain
1696 the OVERLOADING_RESOLUTION parameter(s), it is applied to all the overloaded
1697 subprograms denoted by the first two parameters.
1698
1699 Use PARAMETER_AND_RESULT_TYPE_PROFILE to specify the profile of the subprogram
1700 to be eliminated in a manner similar to that used for the extended
1701 @code{Import} and @code{Export} pragmas, except that the subtype names are
1702 always given as strings. At the moment, this form of distinguishing
1703 overloaded subprograms is implemented only partially, so we do not recommend
1704 using it for practical subprogram elimination.
1705
1706 Note that in case of a parameterless procedure its profile is represented
1707 as @code{Parameter_Types => ("")}
1708
1709 Alternatively, the @code{Source_Location} parameter is used to specify
1710 which overloaded alternative is to be eliminated by pointing to the
1711 location of the DEFINING_PROGRAM_UNIT_NAME of this subprogram in the
1712 source text. The string literal (or concatenation of string literals)
1713 given as SOURCE_TRACE must have the following format:
1714
1715 @smallexample @c ada
1716 SOURCE_TRACE ::= SOURCE_LOCATION@{LBRACKET SOURCE_LOCATION RBRACKET@}
1717
1718 LBRACKET ::= [
1719 RBRACKET ::= ]
1720
1721 SOURCE_LOCATION ::= FILE_NAME:LINE_NUMBER
1722 FILE_NAME       ::= STRING_LITERAL
1723 LINE_NUMBER     ::= DIGIT @{DIGIT@}
1724 @end smallexample
1725
1726 SOURCE_TRACE should be the short name of the source file (with no directory
1727 information), and LINE_NUMBER is supposed to point to the line where the
1728 defining name of the subprogram is located.
1729
1730 For the subprograms that are not a part of generic instantiations, only one
1731 SOURCE_LOCATION is used. If a subprogram is declared in a package
1732 instantiation, SOURCE_TRACE contains two SOURCE_LOCATIONs, the first one is
1733 the location of the (DEFINING_PROGRAM_UNIT_NAME of the) instantiation, and the
1734 second one denotes the declaration of the corresponding subprogram in the
1735 generic package. This approach is recursively used to create SOURCE_LOCATIONs
1736 in case of nested instantiations.
1737
1738 The effect of the pragma is to allow the compiler to eliminate
1739 the code or data associated with the named entity.  Any reference to
1740 an eliminated entity outside the compilation unit it is defined in,
1741 causes a compile time or link time error.
1742
1743 The intention of pragma @code{Eliminate} is to allow a program to be compiled
1744 in a system independent manner, with unused entities eliminated, without
1745 the requirement of modifying the source text.  Normally the required set
1746 of @code{Eliminate} pragmas is constructed automatically using the gnatelim
1747 tool. Elimination of unused entities local to a compilation unit is
1748 automatic, without requiring the use of pragma @code{Eliminate}.
1749
1750 Note that the reason this pragma takes string literals where names might
1751 be expected is that a pragma @code{Eliminate} can appear in a context where the
1752 relevant names are not visible.
1753
1754 Note that any change in the source files that includes removing, splitting of
1755 adding lines may make the set of Eliminate pragmas using SOURCE_LOCATION
1756 parameter illegal.
1757
1758 It is legal to use pragma Eliminate where the referenced entity is a
1759 dispatching operation, but it is not clear what this would mean, since
1760 in general the call does not know which entity is actually being called.
1761 Consequently, a pragma Eliminate for a dispatching operation is ignored.
1762
1763 @node Pragma Export_Exception
1764 @unnumberedsec Pragma Export_Exception
1765 @cindex OpenVMS
1766 @findex Export_Exception
1767 @noindent
1768 Syntax:
1769
1770 @smallexample @c ada
1771 pragma Export_Exception (
1772      [Internal =>] LOCAL_NAME
1773   [, [External =>] EXTERNAL_SYMBOL]
1774   [, [Form     =>] Ada | VMS]
1775   [, [Code     =>] static_integer_EXPRESSION]);
1776
1777 EXTERNAL_SYMBOL ::=
1778   IDENTIFIER
1779 | static_string_EXPRESSION
1780 @end smallexample
1781
1782 @noindent
1783 This pragma is implemented only in the OpenVMS implementation of GNAT@.  It
1784 causes the specified exception to be propagated outside of the Ada program,
1785 so that it can be handled by programs written in other OpenVMS languages.
1786 This pragma establishes an external name for an Ada exception and makes the
1787 name available to the OpenVMS Linker as a global symbol.  For further details
1788 on this pragma, see the
1789 DEC Ada Language Reference Manual, section 13.9a3.2.
1790
1791 @node Pragma Export_Function
1792 @unnumberedsec Pragma Export_Function
1793 @cindex Argument passing mechanisms
1794 @findex Export_Function
1795
1796 @noindent
1797 Syntax:
1798
1799 @smallexample @c ada
1800 pragma Export_Function (
1801      [Internal         =>] LOCAL_NAME
1802   [, [External         =>] EXTERNAL_SYMBOL]
1803   [, [Parameter_Types  =>] PARAMETER_TYPES]
1804   [, [Result_Type      =>] result_SUBTYPE_MARK]
1805   [, [Mechanism        =>] MECHANISM]
1806   [, [Result_Mechanism =>] MECHANISM_NAME]);
1807
1808 EXTERNAL_SYMBOL ::=
1809   IDENTIFIER
1810 | static_string_EXPRESSION
1811 | ""
1812
1813 PARAMETER_TYPES ::=
1814   null
1815 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1816
1817 TYPE_DESIGNATOR ::=
1818   subtype_NAME
1819 | subtype_Name ' Access
1820
1821 MECHANISM ::=
1822   MECHANISM_NAME
1823 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1824
1825 MECHANISM_ASSOCIATION ::=
1826   [formal_parameter_NAME =>] MECHANISM_NAME
1827
1828 MECHANISM_NAME ::=
1829   Value
1830 | Reference
1831 | Descriptor [([Class =>] CLASS_NAME)]
1832
1833 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
1834 @end smallexample
1835
1836 @noindent
1837 Use this pragma to make a function externally callable and optionally
1838 provide information on mechanisms to be used for passing parameter and
1839 result values.  We recommend, for the purposes of improving portability,
1840 this pragma always be used in conjunction with a separate pragma
1841 @code{Export}, which must precede the pragma @code{Export_Function}.
1842 GNAT does not require a separate pragma @code{Export}, but if none is
1843 present, @code{Convention Ada} is assumed, which is usually
1844 not what is wanted, so it is usually appropriate to use this
1845 pragma in conjunction with a @code{Export} or @code{Convention}
1846 pragma that specifies the desired foreign convention.
1847 Pragma @code{Export_Function}
1848 (and @code{Export}, if present) must appear in the same declarative
1849 region as the function to which they apply.
1850
1851 @var{internal_name} must uniquely designate the function to which the
1852 pragma applies.  If more than one function name exists of this name in
1853 the declarative part you must use the @code{Parameter_Types} and
1854 @code{Result_Type} parameters is mandatory to achieve the required
1855 unique designation.  @var{subtype_mark}s in these parameters must
1856 exactly match the subtypes in the corresponding function specification,
1857 using positional notation to match parameters with subtype marks.
1858 The form with an @code{'Access} attribute can be used to match an
1859 anonymous access parameter.
1860
1861 @cindex OpenVMS
1862 @cindex Passing by descriptor
1863 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
1864
1865 @cindex Suppressing external name
1866 Special treatment is given if the EXTERNAL is an explicit null
1867 string or a static string expressions that evaluates to the null
1868 string. In this case, no external name is generated. This form
1869 still allows the specification of parameter mechanisms.
1870
1871 @node Pragma Export_Object
1872 @unnumberedsec Pragma Export_Object
1873 @findex Export_Object
1874 @noindent
1875 Syntax:
1876
1877 @smallexample @c ada
1878 pragma Export_Object
1879       [Internal =>] LOCAL_NAME
1880    [, [External =>] EXTERNAL_SYMBOL]
1881    [, [Size     =>] EXTERNAL_SYMBOL]
1882
1883 EXTERNAL_SYMBOL ::=
1884   IDENTIFIER
1885 | static_string_EXPRESSION
1886 @end smallexample
1887
1888 @noindent
1889 This pragma designates an object as exported, and apart from the
1890 extended rules for external symbols, is identical in effect to the use of
1891 the normal @code{Export} pragma applied to an object.  You may use a
1892 separate Export pragma (and you probably should from the point of view
1893 of portability), but it is not required.  @var{Size} is syntax checked,
1894 but otherwise ignored by GNAT@.
1895
1896 @node Pragma Export_Procedure
1897 @unnumberedsec Pragma Export_Procedure
1898 @findex Export_Procedure
1899 @noindent
1900 Syntax:
1901
1902 @smallexample @c ada
1903 pragma Export_Procedure (
1904      [Internal        =>] LOCAL_NAME
1905   [, [External        =>] EXTERNAL_SYMBOL]
1906   [, [Parameter_Types =>] PARAMETER_TYPES]
1907   [, [Mechanism       =>] MECHANISM]);
1908
1909 EXTERNAL_SYMBOL ::=
1910   IDENTIFIER
1911 | static_string_EXPRESSION
1912 | ""
1913
1914 PARAMETER_TYPES ::=
1915   null
1916 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1917
1918 TYPE_DESIGNATOR ::=
1919   subtype_NAME
1920 | subtype_Name ' Access
1921
1922 MECHANISM ::=
1923   MECHANISM_NAME
1924 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1925
1926 MECHANISM_ASSOCIATION ::=
1927   [formal_parameter_NAME =>] MECHANISM_NAME
1928
1929 MECHANISM_NAME ::=
1930   Value
1931 | Reference
1932 | Descriptor [([Class =>] CLASS_NAME)]
1933
1934 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
1935 @end smallexample
1936
1937 @noindent
1938 This pragma is identical to @code{Export_Function} except that it
1939 applies to a procedure rather than a function and the parameters
1940 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
1941 GNAT does not require a separate pragma @code{Export}, but if none is
1942 present, @code{Convention Ada} is assumed, which is usually
1943 not what is wanted, so it is usually appropriate to use this
1944 pragma in conjunction with a @code{Export} or @code{Convention}
1945 pragma that specifies the desired foreign convention.
1946
1947 @cindex OpenVMS
1948 @cindex Passing by descriptor
1949 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
1950
1951 @cindex Suppressing external name
1952 Special treatment is given if the EXTERNAL is an explicit null
1953 string or a static string expressions that evaluates to the null
1954 string. In this case, no external name is generated. This form
1955 still allows the specification of parameter mechanisms.
1956
1957 @node Pragma Export_Value
1958 @unnumberedsec Pragma Export_Value
1959 @findex Export_Value
1960 @noindent
1961 Syntax:
1962
1963 @smallexample @c ada
1964 pragma Export_Value (
1965   [Value     =>] static_integer_EXPRESSION,
1966   [Link_Name =>] static_string_EXPRESSION);
1967 @end smallexample
1968
1969 @noindent
1970 This pragma serves to export a static integer value for external use.
1971 The first argument specifies the value to be exported. The Link_Name
1972 argument specifies the symbolic name to be associated with the integer
1973 value. This pragma is useful for defining a named static value in Ada
1974 that can be referenced in assembly language units to be linked with
1975 the application. This pragma is currently supported only for the
1976 AAMP target and is ignored for other targets.
1977
1978 @node Pragma Export_Valued_Procedure
1979 @unnumberedsec Pragma Export_Valued_Procedure
1980 @findex Export_Valued_Procedure
1981 @noindent
1982 Syntax:
1983
1984 @smallexample @c ada
1985 pragma Export_Valued_Procedure (
1986      [Internal        =>] LOCAL_NAME
1987   [, [External        =>] EXTERNAL_SYMBOL]
1988   [, [Parameter_Types =>] PARAMETER_TYPES]
1989   [, [Mechanism       =>] MECHANISM]);
1990
1991 EXTERNAL_SYMBOL ::=
1992   IDENTIFIER
1993 | static_string_EXPRESSION
1994 | ""
1995
1996 PARAMETER_TYPES ::=
1997   null
1998 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1999
2000 TYPE_DESIGNATOR ::=
2001   subtype_NAME
2002 | subtype_Name ' Access
2003
2004 MECHANISM ::=
2005   MECHANISM_NAME
2006 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2007
2008 MECHANISM_ASSOCIATION ::=
2009   [formal_parameter_NAME =>] MECHANISM_NAME
2010
2011 MECHANISM_NAME ::=
2012   Value
2013 | Reference
2014 | Descriptor [([Class =>] CLASS_NAME)]
2015
2016 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2017 @end smallexample
2018
2019 @noindent
2020 This pragma is identical to @code{Export_Procedure} except that the
2021 first parameter of @var{LOCAL_NAME}, which must be present, must be of
2022 mode @code{OUT}, and externally the subprogram is treated as a function
2023 with this parameter as the result of the function.  GNAT provides for
2024 this capability to allow the use of @code{OUT} and @code{IN OUT}
2025 parameters in interfacing to external functions (which are not permitted
2026 in Ada functions).
2027 GNAT does not require a separate pragma @code{Export}, but if none is
2028 present, @code{Convention Ada} is assumed, which is almost certainly
2029 not what is wanted since the whole point of this pragma is to interface
2030 with foreign language functions, so it is usually appropriate to use this
2031 pragma in conjunction with a @code{Export} or @code{Convention}
2032 pragma that specifies the desired foreign convention.
2033
2034 @cindex OpenVMS
2035 @cindex Passing by descriptor
2036 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2037
2038 @cindex Suppressing external name
2039 Special treatment is given if the EXTERNAL is an explicit null
2040 string or a static string expressions that evaluates to the null
2041 string. In this case, no external name is generated. This form
2042 still allows the specification of parameter mechanisms.
2043
2044 @node Pragma Extend_System
2045 @unnumberedsec Pragma Extend_System
2046 @cindex @code{system}, extending
2047 @cindex Dec Ada 83
2048 @findex Extend_System
2049 @noindent
2050 Syntax:
2051
2052 @smallexample @c ada
2053 pragma Extend_System ([Name =>] IDENTIFIER);
2054 @end smallexample
2055
2056 @noindent
2057 This pragma is used to provide backwards compatibility with other
2058 implementations that extend the facilities of package @code{System}.  In
2059 GNAT, @code{System} contains only the definitions that are present in
2060 the Ada RM@.  However, other implementations, notably the DEC Ada 83
2061 implementation, provide many extensions to package @code{System}.
2062
2063 For each such implementation accommodated by this pragma, GNAT provides a
2064 package @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83
2065 implementation, which provides the required additional definitions.  You
2066 can use this package in two ways.  You can @code{with} it in the normal
2067 way and access entities either by selection or using a @code{use}
2068 clause.  In this case no special processing is required.
2069
2070 However, if existing code contains references such as
2071 @code{System.@var{xxx}} where @var{xxx} is an entity in the extended
2072 definitions provided in package @code{System}, you may use this pragma
2073 to extend visibility in @code{System} in a non-standard way that
2074 provides greater compatibility with the existing code.  Pragma
2075 @code{Extend_System} is a configuration pragma whose single argument is
2076 the name of the package containing the extended definition
2077 (e.g.@: @code{Aux_DEC} for the DEC Ada case).  A unit compiled under
2078 control of this pragma will be processed using special visibility
2079 processing that looks in package @code{System.Aux_@var{xxx}} where
2080 @code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
2081 package @code{System}, but not found in package @code{System}.
2082
2083 You can use this pragma either to access a predefined @code{System}
2084 extension supplied with the compiler, for example @code{Aux_DEC} or
2085 you can construct your own extension unit following the above
2086 definition.  Note that such a package is a child of @code{System}
2087 and thus is considered part of the implementation.  To compile
2088 it you will have to use the appropriate switch for compiling
2089 system units.  @xref{Top, @value{EDITION} User's Guide, About This
2090 Guide,, gnat_ugn, @value{EDITION} User's Guide}, for details.
2091
2092 @node Pragma External
2093 @unnumberedsec Pragma External
2094 @findex External
2095 @noindent
2096 Syntax:
2097
2098 @smallexample @c ada
2099 pragma External (
2100   [   Convention    =>] convention_IDENTIFIER,
2101   [   Entity        =>] LOCAL_NAME
2102   [, [External_Name =>] static_string_EXPRESSION ]
2103   [, [Link_Name     =>] static_string_EXPRESSION ]);
2104 @end smallexample
2105
2106 @noindent
2107 This pragma is identical in syntax and semantics to pragma
2108 @code{Export} as defined in the Ada Reference Manual.  It is
2109 provided for compatibility with some Ada 83 compilers that
2110 used this pragma for exactly the same purposes as pragma
2111 @code{Export} before the latter was standardized.
2112
2113 @node Pragma External_Name_Casing
2114 @unnumberedsec Pragma External_Name_Casing
2115 @cindex Dec Ada 83 casing compatibility
2116 @cindex External Names, casing
2117 @cindex Casing of External names
2118 @findex External_Name_Casing
2119 @noindent
2120 Syntax:
2121
2122 @smallexample @c ada
2123 pragma External_Name_Casing (
2124   Uppercase | Lowercase
2125   [, Uppercase | Lowercase | As_Is]);
2126 @end smallexample
2127
2128 @noindent
2129 This pragma provides control over the casing of external names associated
2130 with Import and Export pragmas.  There are two cases to consider:
2131
2132 @table @asis
2133 @item Implicit external names
2134 Implicit external names are derived from identifiers.  The most common case
2135 arises when a standard Ada Import or Export pragma is used with only two
2136 arguments, as in:
2137
2138 @smallexample @c ada
2139    pragma Import (C, C_Routine);
2140 @end smallexample
2141
2142 @noindent
2143 Since Ada is a case-insensitive language, the spelling of the identifier in
2144 the Ada source program does not provide any information on the desired
2145 casing of the external name, and so a convention is needed.  In GNAT the
2146 default treatment is that such names are converted to all lower case
2147 letters.  This corresponds to the normal C style in many environments.
2148 The first argument of pragma @code{External_Name_Casing} can be used to
2149 control this treatment.  If @code{Uppercase} is specified, then the name
2150 will be forced to all uppercase letters.  If @code{Lowercase} is specified,
2151 then the normal default of all lower case letters will be used.
2152
2153 This same implicit treatment is also used in the case of extended DEC Ada 83
2154 compatible Import and Export pragmas where an external name is explicitly
2155 specified using an identifier rather than a string.
2156
2157 @item Explicit external names
2158 Explicit external names are given as string literals.  The most common case
2159 arises when a standard Ada Import or Export pragma is used with three
2160 arguments, as in:
2161
2162 @smallexample @c ada
2163 pragma Import (C, C_Routine, "C_routine");
2164 @end smallexample
2165
2166 @noindent
2167 In this case, the string literal normally provides the exact casing required
2168 for the external name.  The second argument of pragma
2169 @code{External_Name_Casing} may be used to modify this behavior.
2170 If @code{Uppercase} is specified, then the name
2171 will be forced to all uppercase letters.  If @code{Lowercase} is specified,
2172 then the name will be forced to all lowercase letters.  A specification of
2173 @code{As_Is} provides the normal default behavior in which the casing is
2174 taken from the string provided.
2175 @end table
2176
2177 @noindent
2178 This pragma may appear anywhere that a pragma is valid.  In particular, it
2179 can be used as a configuration pragma in the @file{gnat.adc} file, in which
2180 case it applies to all subsequent compilations, or it can be used as a program
2181 unit pragma, in which case it only applies to the current unit, or it can
2182 be used more locally to control individual Import/Export pragmas.
2183
2184 It is primarily intended for use with OpenVMS systems, where many
2185 compilers convert all symbols to upper case by default.  For interfacing to
2186 such compilers (e.g.@: the DEC C compiler), it may be convenient to use
2187 the pragma:
2188
2189 @smallexample @c ada
2190 pragma External_Name_Casing (Uppercase, Uppercase);
2191 @end smallexample
2192
2193 @noindent
2194 to enforce the upper casing of all external symbols.
2195
2196 @node Pragma Fast_Math
2197 @unnumberedsec Pragma Fast_Math
2198 @findex Fast_Math
2199 @noindent
2200 Syntax:
2201
2202 @smallexample @c ada
2203 pragma Fast_Math;
2204 @end smallexample
2205
2206 @noindent
2207 This is a configuration pragma which activates a mode in which speed is
2208 considered more important for floating-point operations than absolutely
2209 accurate adherence to the requirements of the standard. Currently the
2210 following operations are affected:
2211
2212 @table @asis
2213 @item Complex Multiplication
2214 The normal simple formula for complex multiplication can result in intermediate
2215 overflows for numbers near the end of the range. The Ada standard requires that
2216 this situation be detected and corrected by scaling, but in Fast_Math mode such
2217 cases will simply result in overflow. Note that to take advantage of this you
2218 must instantiate your own version of @code{Ada.Numerics.Generic_Complex_Types}
2219 under control of the pragma, rather than use the preinstantiated versions.
2220 @end table
2221
2222 @node Pragma Favor_Top_Level
2223 @unnumberedsec Pragma Favor_Top_Level
2224 @findex Favor_Top_Level
2225 @noindent
2226 Syntax:
2227
2228 @smallexample @c ada
2229 pragma Favor_Top_Level (type_NAME);
2230 @end smallexample
2231
2232 @noindent
2233 The named type must be an access-to-subprogram type. This pragma is an
2234 efficiency hint to the compiler, regarding the use of 'Access or
2235 'Unrestricted_Access on nested (non-library-level) subprograms. The
2236 pragma means that nested subprograms are not used with this type, or
2237 are rare, so that the generated code should be efficient in the
2238 top-level case. When this pragma is used, dynamically generated
2239 trampolines may be used on some targets for nested subprograms.
2240 See also the No_Implicit_Dynamic_Code restriction.
2241
2242 @node Pragma Finalize_Storage_Only
2243 @unnumberedsec Pragma Finalize_Storage_Only
2244 @findex Finalize_Storage_Only
2245 @noindent
2246 Syntax:
2247
2248 @smallexample @c ada
2249 pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
2250 @end smallexample
2251
2252 @noindent
2253 This pragma allows the compiler not to emit a Finalize call for objects
2254 defined at the library level.  This is mostly useful for types where
2255 finalization is only used to deal with storage reclamation since in most
2256 environments it is not necessary to reclaim memory just before terminating
2257 execution, hence the name.
2258
2259 @node Pragma Float_Representation
2260 @unnumberedsec Pragma Float_Representation
2261 @cindex OpenVMS
2262 @findex Float_Representation
2263 @noindent
2264 Syntax:
2265
2266 @smallexample @c ada
2267 pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
2268
2269 FLOAT_REP ::= VAX_Float | IEEE_Float
2270 @end smallexample
2271
2272 @noindent
2273 In the one argument form, this pragma is a configuration pragma which
2274 allows control over the internal representation chosen for the predefined
2275 floating point types declared in the packages @code{Standard} and
2276 @code{System}. On all systems other than OpenVMS, the argument must
2277 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2278 argument may be @code{VAX_Float} to specify the use of the VAX float
2279 format for the floating-point types in Standard. This requires that
2280 the standard runtime libraries be recompiled.  @xref{The GNAT Run-Time
2281 Library Builder gnatlbr,,, gnat_ugn, @value{EDITION} User's Guide
2282 OpenVMS}, for a description of the @code{GNAT LIBRARY} command.
2283
2284 The two argument form specifies the representation to be used for
2285 the specified floating-point type. On all systems other than OpenVMS,
2286 the argument must
2287 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2288 argument may be @code{VAX_Float} to specify the use of the VAX float
2289 format, as follows:
2290
2291 @itemize @bullet
2292 @item
2293 For digits values up to 6, F float format will be used.
2294 @item
2295 For digits values from 7 to 9, G float format will be used.
2296 @item
2297 For digits values from 10 to 15, F float format will be used.
2298 @item
2299 Digits values above 15 are not allowed.
2300 @end itemize
2301
2302 @node Pragma Ident
2303 @unnumberedsec Pragma Ident
2304 @findex Ident
2305 @noindent
2306 Syntax:
2307
2308 @smallexample @c ada
2309 pragma Ident (static_string_EXPRESSION);
2310 @end smallexample
2311
2312 @noindent
2313 This pragma provides a string identification in the generated object file,
2314 if the system supports the concept of this kind of identification string.
2315 This pragma is allowed only in the outermost declarative part or
2316 declarative items of a compilation unit. If more than one @code{Ident}
2317 pragma is given, only the last one processed is effective.
2318 @cindex OpenVMS
2319 On OpenVMS systems, the effect of the pragma is identical to the effect of
2320 the DEC Ada 83 pragma of the same name. Note that in DEC Ada 83, the
2321 maximum allowed length is 31 characters, so if it is important to
2322 maintain compatibility with this compiler, you should obey this length
2323 limit.
2324
2325 @node Pragma Implemented_By_Entry
2326 @unnumberedsec Pragma Implemented_By_Entry
2327 @findex Implemented_By_Entry
2328 @noindent
2329 Syntax:
2330
2331 @smallexample @c ada
2332 pragma Implemented_By_Entry (LOCAL_NAME);
2333 @end smallexample
2334
2335 @noindent
2336 This is a representation pragma which applies to protected, synchronized and
2337 task interface primitives. If the pragma is applied to primitive operation Op
2338 of interface Iface, it is illegal to override Op in a type that implements
2339 Iface, with anything other than an entry.
2340
2341 @smallexample @c ada
2342 type Iface is protected interface;
2343 procedure Do_Something (Object : in out Iface) is abstract;
2344 pragma Implemented_By_Entry (Do_Something);
2345
2346 protected type P is new Iface with
2347    procedure Do_Something;  --  Illegal
2348 end P;
2349
2350 task type T is new Iface with
2351    entry Do_Something;      --  Legal
2352 end T;
2353 @end smallexample
2354
2355 @noindent
2356 NOTE: The pragma is still in its design stage by the Ada Rapporteur Group. It
2357 is intended to be used in conjunction with dispatching requeue statements as
2358 described in AI05-0030. Should the ARG decide on an official name and syntax,
2359 this pragma will become language-defined rather than GNAT-specific.
2360
2361 @node Pragma Implicit_Packing
2362 @unnumberedsec Pragma Implicit_Packing
2363 @findex Implicit_Packing
2364 @noindent
2365 Syntax:
2366
2367 @smallexample @c ada
2368 pragma Implicit_Packing;
2369 @end smallexample
2370
2371 @noindent
2372 This is a configuration pragma that requests implicit packing for packed
2373 arrays for which a size clause is given but no explicit pragma Pack or
2374 specification of Component_Size is present. Consider this example:
2375
2376 @smallexample @c ada
2377 type R is array (0 .. 7) of Boolean;
2378 for R'Size use 8;
2379 @end smallexample
2380
2381 @noindent
2382 In accordance with the recommendation in the RM (RM 13.3(53)), a Size clause
2383 does not change the layout of a composite object. So the Size clause in the
2384 above example is normally rejected, since the default layout of the array uses
2385 8-bit components, and thus the array requires a minimum of 64 bits.
2386
2387 If this declaration is compiled in a region of code covered by an occurrence
2388 of the configuration pragma Implicit_Packing, then the Size clause in this
2389 and similar examples will cause implicit packing and thus be accepted. For
2390 this implicit packing to occur, the type in question must be an array of small
2391 components whose size is known at compile time, and the Size clause must
2392 specify the exact size that corresponds to the length of the array multiplied
2393 by the size in bits of the component type.
2394 @cindex Array packing
2395
2396 @node Pragma Import_Exception
2397 @unnumberedsec Pragma Import_Exception
2398 @cindex OpenVMS
2399 @findex Import_Exception
2400 @noindent
2401 Syntax:
2402
2403 @smallexample @c ada
2404 pragma Import_Exception (
2405      [Internal =>] LOCAL_NAME
2406   [, [External =>] EXTERNAL_SYMBOL]
2407   [, [Form     =>] Ada | VMS]
2408   [, [Code     =>] static_integer_EXPRESSION]);
2409
2410 EXTERNAL_SYMBOL ::=
2411   IDENTIFIER
2412 | static_string_EXPRESSION
2413 @end smallexample
2414
2415 @noindent
2416 This pragma is implemented only in the OpenVMS implementation of GNAT@.
2417 It allows OpenVMS conditions (for example, from OpenVMS system services or
2418 other OpenVMS languages) to be propagated to Ada programs as Ada exceptions.
2419 The pragma specifies that the exception associated with an exception
2420 declaration in an Ada program be defined externally (in non-Ada code).
2421 For further details on this pragma, see the
2422 DEC Ada Language Reference Manual, section 13.9a.3.1.
2423
2424 @node Pragma Import_Function
2425 @unnumberedsec Pragma Import_Function
2426 @findex Import_Function
2427 @noindent
2428 Syntax:
2429
2430 @smallexample @c ada
2431 pragma Import_Function (
2432      [Internal                 =>] LOCAL_NAME,
2433   [, [External                 =>] EXTERNAL_SYMBOL]
2434   [, [Parameter_Types          =>] PARAMETER_TYPES]
2435   [, [Result_Type              =>] SUBTYPE_MARK]
2436   [, [Mechanism                =>] MECHANISM]
2437   [, [Result_Mechanism         =>] MECHANISM_NAME]
2438   [, [First_Optional_Parameter =>] IDENTIFIER]);
2439
2440 EXTERNAL_SYMBOL ::=
2441   IDENTIFIER
2442 | static_string_EXPRESSION
2443
2444 PARAMETER_TYPES ::=
2445   null
2446 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2447
2448 TYPE_DESIGNATOR ::=
2449   subtype_NAME
2450 | subtype_Name ' Access
2451
2452 MECHANISM ::=
2453   MECHANISM_NAME
2454 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2455
2456 MECHANISM_ASSOCIATION ::=
2457   [formal_parameter_NAME =>] MECHANISM_NAME
2458
2459 MECHANISM_NAME ::=
2460   Value
2461 | Reference
2462 | Descriptor [([Class =>] CLASS_NAME)]
2463
2464 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2465 @end smallexample
2466
2467 @noindent
2468 This pragma is used in conjunction with a pragma @code{Import} to
2469 specify additional information for an imported function.  The pragma
2470 @code{Import} (or equivalent pragma @code{Interface}) must precede the
2471 @code{Import_Function} pragma and both must appear in the same
2472 declarative part as the function specification.
2473
2474 The @var{Internal} argument must uniquely designate
2475 the function to which the
2476 pragma applies.  If more than one function name exists of this name in
2477 the declarative part you must use the @code{Parameter_Types} and
2478 @var{Result_Type} parameters to achieve the required unique
2479 designation.  Subtype marks in these parameters must exactly match the
2480 subtypes in the corresponding function specification, using positional
2481 notation to match parameters with subtype marks.
2482 The form with an @code{'Access} attribute can be used to match an
2483 anonymous access parameter.
2484
2485 You may optionally use the @var{Mechanism} and @var{Result_Mechanism}
2486 parameters to specify passing mechanisms for the
2487 parameters and result.  If you specify a single mechanism name, it
2488 applies to all parameters.  Otherwise you may specify a mechanism on a
2489 parameter by parameter basis using either positional or named
2490 notation.  If the mechanism is not specified, the default mechanism
2491 is used.
2492
2493 @cindex OpenVMS
2494 @cindex Passing by descriptor
2495 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2496
2497 @code{First_Optional_Parameter} applies only to OpenVMS ports of GNAT@.
2498 It specifies that the designated parameter and all following parameters
2499 are optional, meaning that they are not passed at the generated code
2500 level (this is distinct from the notion of optional parameters in Ada
2501 where the parameters are passed anyway with the designated optional
2502 parameters).  All optional parameters must be of mode @code{IN} and have
2503 default parameter values that are either known at compile time
2504 expressions, or uses of the @code{'Null_Parameter} attribute.
2505
2506 @node Pragma Import_Object
2507 @unnumberedsec Pragma Import_Object
2508 @findex Import_Object
2509 @noindent
2510 Syntax:
2511
2512 @smallexample @c ada
2513 pragma Import_Object
2514      [Internal =>] LOCAL_NAME
2515   [, [External =>] EXTERNAL_SYMBOL]
2516   [, [Size     =>] EXTERNAL_SYMBOL]);
2517
2518 EXTERNAL_SYMBOL ::=
2519   IDENTIFIER
2520 | static_string_EXPRESSION
2521 @end smallexample
2522
2523 @noindent
2524 This pragma designates an object as imported, and apart from the
2525 extended rules for external symbols, is identical in effect to the use of
2526 the normal @code{Import} pragma applied to an object.  Unlike the
2527 subprogram case, you need not use a separate @code{Import} pragma,
2528 although you may do so (and probably should do so from a portability
2529 point of view).  @var{size} is syntax checked, but otherwise ignored by
2530 GNAT@.
2531
2532 @node Pragma Import_Procedure
2533 @unnumberedsec Pragma Import_Procedure
2534 @findex Import_Procedure
2535 @noindent
2536 Syntax:
2537
2538 @smallexample @c ada
2539 pragma Import_Procedure (
2540      [Internal                 =>] LOCAL_NAME
2541   [, [External                 =>] EXTERNAL_SYMBOL]
2542   [, [Parameter_Types          =>] PARAMETER_TYPES]
2543   [, [Mechanism                =>] MECHANISM]
2544   [, [First_Optional_Parameter =>] IDENTIFIER]);
2545
2546 EXTERNAL_SYMBOL ::=
2547   IDENTIFIER
2548 | static_string_EXPRESSION
2549
2550 PARAMETER_TYPES ::=
2551   null
2552 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2553
2554 TYPE_DESIGNATOR ::=
2555   subtype_NAME
2556 | subtype_Name ' Access
2557
2558 MECHANISM ::=
2559   MECHANISM_NAME
2560 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2561
2562 MECHANISM_ASSOCIATION ::=
2563   [formal_parameter_NAME =>] MECHANISM_NAME
2564
2565 MECHANISM_NAME ::=
2566   Value
2567 | Reference
2568 | Descriptor [([Class =>] CLASS_NAME)]
2569
2570 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2571 @end smallexample
2572
2573 @noindent
2574 This pragma is identical to @code{Import_Function} except that it
2575 applies to a procedure rather than a function and the parameters
2576 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2577
2578 @node Pragma Import_Valued_Procedure
2579 @unnumberedsec Pragma Import_Valued_Procedure
2580 @findex Import_Valued_Procedure
2581 @noindent
2582 Syntax:
2583
2584 @smallexample @c ada
2585 pragma Import_Valued_Procedure (
2586      [Internal                 =>] LOCAL_NAME
2587   [, [External                 =>] EXTERNAL_SYMBOL]
2588   [, [Parameter_Types          =>] PARAMETER_TYPES]
2589   [, [Mechanism                =>] MECHANISM]
2590   [, [First_Optional_Parameter =>] IDENTIFIER]);
2591
2592 EXTERNAL_SYMBOL ::=
2593   IDENTIFIER
2594 | static_string_EXPRESSION
2595
2596 PARAMETER_TYPES ::=
2597   null
2598 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2599
2600 TYPE_DESIGNATOR ::=
2601   subtype_NAME
2602 | subtype_Name ' Access
2603
2604 MECHANISM ::=
2605   MECHANISM_NAME
2606 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2607
2608 MECHANISM_ASSOCIATION ::=
2609   [formal_parameter_NAME =>] MECHANISM_NAME
2610
2611 MECHANISM_NAME ::=
2612   Value
2613 | Reference
2614 | Descriptor [([Class =>] CLASS_NAME)]
2615
2616 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2617 @end smallexample
2618
2619 @noindent
2620 This pragma is identical to @code{Import_Procedure} except that the
2621 first parameter of @var{LOCAL_NAME}, which must be present, must be of
2622 mode @code{OUT}, and externally the subprogram is treated as a function
2623 with this parameter as the result of the function.  The purpose of this
2624 capability is to allow the use of @code{OUT} and @code{IN OUT}
2625 parameters in interfacing to external functions (which are not permitted
2626 in Ada functions).  You may optionally use the @code{Mechanism}
2627 parameters to specify passing mechanisms for the parameters.
2628 If you specify a single mechanism name, it applies to all parameters.
2629 Otherwise you may specify a mechanism on a parameter by parameter
2630 basis using either positional or named notation.  If the mechanism is not
2631 specified, the default mechanism is used.
2632
2633 Note that it is important to use this pragma in conjunction with a separate
2634 pragma Import that specifies the desired convention, since otherwise the
2635 default convention is Ada, which is almost certainly not what is required.
2636
2637 @node Pragma Initialize_Scalars
2638 @unnumberedsec Pragma Initialize_Scalars
2639 @findex Initialize_Scalars
2640 @cindex debugging with Initialize_Scalars
2641 @noindent
2642 Syntax:
2643
2644 @smallexample @c ada
2645 pragma Initialize_Scalars;
2646 @end smallexample
2647
2648 @noindent
2649 This pragma is similar to @code{Normalize_Scalars} conceptually but has
2650 two important differences.  First, there is no requirement for the pragma
2651 to be used uniformly in all units of a partition, in particular, it is fine
2652 to use this just for some or all of the application units of a partition,
2653 without needing to recompile the run-time library.
2654
2655 In the case where some units are compiled with the pragma, and some without,
2656 then a declaration of a variable where the type is defined in package
2657 Standard or is locally declared will always be subject to initialization,
2658 as will any declaration of a scalar variable.  For composite variables,
2659 whether the variable is initialized may also depend on whether the package
2660 in which the type of the variable is declared is compiled with the pragma.
2661
2662 The other important difference is that you can control the value used
2663 for initializing scalar objects.  At bind time, you can select several
2664 options for initialization. You can
2665 initialize with invalid values (similar to Normalize_Scalars, though for
2666 Initialize_Scalars it is not always possible to determine the invalid
2667 values in complex cases like signed component fields with non-standard
2668 sizes). You can also initialize with high or
2669 low values, or with a specified bit pattern.  See the users guide for binder
2670 options for specifying these cases.
2671
2672 This means that you can compile a program, and then without having to
2673 recompile the program, you can run it with different values being used
2674 for initializing otherwise uninitialized values, to test if your program
2675 behavior depends on the choice.  Of course the behavior should not change,
2676 and if it does, then most likely you have an erroneous reference to an
2677 uninitialized value.
2678
2679 It is even possible to change the value at execution time eliminating even
2680 the need to rebind with a different switch using an environment variable.
2681 See the GNAT users guide for details.
2682
2683 Note that pragma @code{Initialize_Scalars} is particularly useful in
2684 conjunction with the enhanced validity checking that is now provided
2685 in GNAT, which checks for invalid values under more conditions.
2686 Using this feature (see description of the @option{-gnatV} flag in the
2687 users guide) in conjunction with pragma @code{Initialize_Scalars}
2688 provides a powerful new tool to assist in the detection of problems
2689 caused by uninitialized variables.
2690
2691 Note: the use of @code{Initialize_Scalars} has a fairly extensive
2692 effect on the generated code. This may cause your code to be
2693 substantially larger. It may also cause an increase in the amount
2694 of stack required, so it is probably a good idea to turn on stack
2695 checking (see description of stack checking in the GNAT users guide)
2696 when using this pragma.
2697
2698 @node Pragma Inline_Always
2699 @unnumberedsec Pragma Inline_Always
2700 @findex Inline_Always
2701 @noindent
2702 Syntax:
2703
2704 @smallexample @c ada
2705 pragma Inline_Always (NAME [, NAME]);
2706 @end smallexample
2707
2708 @noindent
2709 Similar to pragma @code{Inline} except that inlining is not subject to
2710 the use of option @option{-gnatn} and the inlining happens regardless of
2711 whether this option is used.
2712
2713 @node Pragma Inline_Generic
2714 @unnumberedsec Pragma Inline_Generic
2715 @findex Inline_Generic
2716 @noindent
2717 Syntax:
2718
2719 @smallexample @c ada
2720 pragma Inline_Generic (generic_package_NAME);
2721 @end smallexample
2722
2723 @noindent
2724 This is implemented for compatibility with DEC Ada 83 and is recognized,
2725 but otherwise ignored, by GNAT@.  All generic instantiations are inlined
2726 by default when using GNAT@.
2727
2728 @node Pragma Interface
2729 @unnumberedsec Pragma Interface
2730 @findex Interface
2731 @noindent
2732 Syntax:
2733
2734 @smallexample @c ada
2735 pragma Interface (
2736      [Convention    =>] convention_identifier,
2737      [Entity        =>] local_NAME
2738   [, [External_Name =>] static_string_expression]
2739   [, [Link_Name     =>] static_string_expression]);
2740 @end smallexample
2741
2742 @noindent
2743 This pragma is identical in syntax and semantics to
2744 the standard Ada pragma @code{Import}.  It is provided for compatibility
2745 with Ada 83.  The definition is upwards compatible both with pragma
2746 @code{Interface} as defined in the Ada 83 Reference Manual, and also
2747 with some extended implementations of this pragma in certain Ada 83
2748 implementations.
2749
2750 @node Pragma Interface_Name
2751 @unnumberedsec Pragma Interface_Name
2752 @findex Interface_Name
2753 @noindent
2754 Syntax:
2755
2756 @smallexample @c ada
2757 pragma Interface_Name (
2758      [Entity        =>] LOCAL_NAME
2759   [, [External_Name =>] static_string_EXPRESSION]
2760   [, [Link_Name     =>] static_string_EXPRESSION]);
2761 @end smallexample
2762
2763 @noindent
2764 This pragma provides an alternative way of specifying the interface name
2765 for an interfaced subprogram, and is provided for compatibility with Ada
2766 83 compilers that use the pragma for this purpose.  You must provide at
2767 least one of @var{External_Name} or @var{Link_Name}.
2768
2769 @node Pragma Interrupt_Handler
2770 @unnumberedsec Pragma Interrupt_Handler
2771 @findex Interrupt_Handler
2772 @noindent
2773 Syntax:
2774
2775 @smallexample @c ada
2776 pragma Interrupt_Handler (procedure_LOCAL_NAME);
2777 @end smallexample
2778
2779 @noindent
2780 This program unit pragma is supported for parameterless protected procedures
2781 as described in Annex C of the Ada Reference Manual. On the AAMP target
2782 the pragma can also be specified for nonprotected parameterless procedures
2783 that are declared at the library level (which includes procedures
2784 declared at the top level of a library package). In the case of AAMP,
2785 when this pragma is applied to a nonprotected procedure, the instruction
2786 @code{IERET} is generated for returns from the procedure, enabling
2787 maskable interrupts, in place of the normal return instruction.
2788
2789 @node Pragma Interrupt_State
2790 @unnumberedsec Pragma Interrupt_State
2791 @findex Interrupt_State
2792 @noindent
2793 Syntax:
2794
2795 @smallexample @c ada
2796 pragma Interrupt_State (Name => value, State => SYSTEM | RUNTIME | USER);
2797 @end smallexample
2798
2799 @noindent
2800 Normally certain interrupts are reserved to the implementation.  Any attempt
2801 to attach an interrupt causes Program_Error to be raised, as described in
2802 RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
2803 many systems for an @kbd{Ctrl-C} interrupt.  Normally this interrupt is
2804 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
2805 interrupt execution.  Additionally, signals such as @code{SIGSEGV},
2806 @code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
2807 Ada exceptions, or used to implement run-time functions such as the
2808 @code{abort} statement and stack overflow checking.
2809
2810 Pragma @code{Interrupt_State} provides a general mechanism for overriding
2811 such uses of interrupts.  It subsumes the functionality of pragma
2812 @code{Unreserve_All_Interrupts}.  Pragma @code{Interrupt_State} is not
2813 available on OS/2, Windows or VMS.  On all other platforms than VxWorks,
2814 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
2815 and may be used to mark interrupts required by the board support package
2816 as reserved.
2817
2818 Interrupts can be in one of three states:
2819 @itemize @bullet
2820 @item System
2821
2822 The interrupt is reserved (no Ada handler can be installed), and the
2823 Ada run-time may not install a handler. As a result you are guaranteed
2824 standard system default action if this interrupt is raised.
2825
2826 @item Runtime
2827
2828 The interrupt is reserved (no Ada handler can be installed). The run time
2829 is allowed to install a handler for internal control purposes, but is
2830 not required to do so.
2831
2832 @item User
2833
2834 The interrupt is unreserved.  The user may install a handler to provide
2835 some other action.
2836 @end itemize
2837
2838 @noindent
2839 These states are the allowed values of the @code{State} parameter of the
2840 pragma.  The @code{Name} parameter is a value of the type
2841 @code{Ada.Interrupts.Interrupt_ID}.  Typically, it is a name declared in
2842 @code{Ada.Interrupts.Names}.
2843
2844 This is a configuration pragma, and the binder will check that there
2845 are no inconsistencies between different units in a partition in how a
2846 given interrupt is specified. It may appear anywhere a pragma is legal.
2847
2848 The effect is to move the interrupt to the specified state.
2849
2850 By declaring interrupts to be SYSTEM, you guarantee the standard system
2851 action, such as a core dump.
2852
2853 By declaring interrupts to be USER, you guarantee that you can install
2854 a handler.
2855
2856 Note that certain signals on many operating systems cannot be caught and
2857 handled by applications.  In such cases, the pragma is ignored.  See the
2858 operating system documentation, or the value of the array @code{Reserved}
2859 declared in the spec of package @code{System.OS_Interface}.
2860
2861 Overriding the default state of signals used by the Ada runtime may interfere
2862 with an application's runtime behavior in the cases of the synchronous signals,
2863 and in the case of the signal used to implement the @code{abort} statement.
2864
2865 @node Pragma Keep_Names
2866 @unnumberedsec Pragma Keep_Names
2867 @findex Keep_Names
2868 @noindent
2869 Syntax:
2870
2871 @smallexample @c ada
2872 pragma Keep_Names ([On =>] enumeration_first_subtype_LOCAL_NAME);
2873 @end smallexample
2874
2875 @noindent
2876 The @var{LOCAL_NAME} argument
2877 must refer to an enumeration first subtype
2878 in the current declarative part. The effect is to retain the enumeration
2879 literal names for use by @code{Image} and @code{Value} even if a global
2880 @code{Discard_Names} pragma applies. This is useful when you want to
2881 generally suppress enumeration literal names and for example you therefore
2882 use a @code{Discard_Names} pragma in the @file{gnat.adc} file, but you
2883 want to retain the names for specific enumeration types.
2884
2885 @node Pragma License
2886 @unnumberedsec Pragma License
2887 @findex License
2888 @cindex License checking
2889 @noindent
2890 Syntax:
2891
2892 @smallexample @c ada
2893 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
2894 @end smallexample
2895
2896 @noindent
2897 This pragma is provided to allow automated checking for appropriate license
2898 conditions with respect to the standard and modified GPL@.  A pragma
2899 @code{License}, which is a configuration pragma that typically appears at
2900 the start of a source file or in a separate @file{gnat.adc} file, specifies
2901 the licensing conditions of a unit as follows:
2902
2903 @itemize @bullet
2904 @item Unrestricted
2905 This is used for a unit that can be freely used with no license restrictions.
2906 Examples of such units are public domain units, and units from the Ada
2907 Reference Manual.
2908
2909 @item GPL
2910 This is used for a unit that is licensed under the unmodified GPL, and which
2911 therefore cannot be @code{with}'ed by a restricted unit.
2912
2913 @item Modified_GPL
2914 This is used for a unit licensed under the GNAT modified GPL that includes
2915 a special exception paragraph that specifically permits the inclusion of
2916 the unit in programs without requiring the entire program to be released
2917 under the GPL@.
2918
2919 @item Restricted
2920 This is used for a unit that is restricted in that it is not permitted to
2921 depend on units that are licensed under the GPL@.  Typical examples are
2922 proprietary code that is to be released under more restrictive license
2923 conditions.  Note that restricted units are permitted to @code{with} units
2924 which are licensed under the modified GPL (this is the whole point of the
2925 modified GPL).
2926
2927 @end itemize
2928
2929 @noindent
2930 Normally a unit with no @code{License} pragma is considered to have an
2931 unknown license, and no checking is done.  However, standard GNAT headers
2932 are recognized, and license information is derived from them as follows.
2933
2934 @itemize @bullet
2935
2936 A GNAT license header starts with a line containing 78 hyphens.  The following
2937 comment text is searched for the appearance of any of the following strings.
2938
2939 If the string ``GNU General Public License'' is found, then the unit is assumed
2940 to have GPL license, unless the string ``As a special exception'' follows, in
2941 which case the license is assumed to be modified GPL@.
2942
2943 If one of the strings
2944 ``This specification is adapted from the Ada Semantic Interface'' or
2945 ``This specification is derived from the Ada Reference Manual'' is found
2946 then the unit is assumed to be unrestricted.
2947 @end itemize
2948
2949 @noindent
2950 These default actions means that a program with a restricted license pragma
2951 will automatically get warnings if a GPL unit is inappropriately
2952 @code{with}'ed.  For example, the program:
2953
2954 @smallexample @c ada
2955 with Sem_Ch3;
2956 with GNAT.Sockets;
2957 procedure Secret_Stuff is
2958   @dots{}
2959 end Secret_Stuff
2960 @end smallexample
2961
2962 @noindent
2963 if compiled with pragma @code{License} (@code{Restricted}) in a
2964 @file{gnat.adc} file will generate the warning:
2965
2966 @smallexample
2967 1.  with Sem_Ch3;
2968         |
2969    >>> license of withed unit "Sem_Ch3" is incompatible
2970
2971 2.  with GNAT.Sockets;
2972 3.  procedure Secret_Stuff is
2973 @end smallexample
2974
2975 @noindent
2976 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
2977 compiler and is licensed under the
2978 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
2979 run time, and is therefore licensed under the modified GPL@.
2980
2981 @node Pragma Link_With
2982 @unnumberedsec Pragma Link_With
2983 @findex Link_With
2984 @noindent
2985 Syntax:
2986
2987 @smallexample @c ada
2988 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
2989 @end smallexample
2990
2991 @noindent
2992 This pragma is provided for compatibility with certain Ada 83 compilers.
2993 It has exactly the same effect as pragma @code{Linker_Options} except
2994 that spaces occurring within one of the string expressions are treated
2995 as separators. For example, in the following case:
2996
2997 @smallexample @c ada
2998 pragma Link_With ("-labc -ldef");
2999 @end smallexample
3000
3001 @noindent
3002 results in passing the strings @code{-labc} and @code{-ldef} as two
3003 separate arguments to the linker. In addition pragma Link_With allows
3004 multiple arguments, with the same effect as successive pragmas.
3005
3006 @node Pragma Linker_Alias
3007 @unnumberedsec Pragma Linker_Alias
3008 @findex Linker_Alias
3009 @noindent
3010 Syntax:
3011
3012 @smallexample @c ada
3013 pragma Linker_Alias (
3014   [Entity =>] LOCAL_NAME,
3015   [Target =>] static_string_EXPRESSION);
3016 @end smallexample
3017
3018 @noindent
3019 @var{LOCAL_NAME} must refer to an object that is declared at the library
3020 level. This pragma establishes the given entity as a linker alias for the
3021 given target. It is equivalent to @code{__attribute__((alias))} in GNU C
3022 and causes @var{LOCAL_NAME} to be emitted as an alias for the symbol
3023 @var{static_string_EXPRESSION} in the object file, that is to say no space
3024 is reserved for @var{LOCAL_NAME} by the assembler and it will be resolved
3025 to the same address as @var{static_string_EXPRESSION} by the linker.
3026
3027 The actual linker name for the target must be used (e.g.@: the fully
3028 encoded name with qualification in Ada, or the mangled name in C++),
3029 or it must be declared using the C convention with @code{pragma Import}
3030 or @code{pragma Export}.
3031
3032 Not all target machines support this pragma. On some of them it is accepted
3033 only if @code{pragma Weak_External} has been applied to @var{LOCAL_NAME}.
3034
3035 @smallexample @c ada
3036 --  Example of the use of pragma Linker_Alias
3037
3038 package p is
3039   i : Integer := 1;
3040   pragma Export (C, i);
3041
3042   new_name_for_i : Integer;
3043   pragma Linker_Alias (new_name_for_i, "i");
3044 end p;
3045 @end smallexample
3046
3047 @node Pragma Linker_Constructor
3048 @unnumberedsec Pragma Linker_Constructor
3049 @findex Linker_Constructor
3050 @noindent
3051 Syntax:
3052
3053 @smallexample @c ada
3054 pragma Linker_Constructor (procedure_LOCAL_NAME);
3055 @end smallexample
3056
3057 @noindent
3058 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
3059 is declared at the library level. A procedure to which this pragma is
3060 applied will be treated as an initialization routine by the linker.
3061 It is equivalent to @code{__attribute__((constructor))} in GNU C and
3062 causes @var{procedure_LOCAL_NAME} to be invoked before the entry point
3063 of the executable is called (or immediately after the shared library is
3064 loaded if the procedure is linked in a shared library), in particular
3065 before the Ada run-time environment is set up.
3066
3067 Because of these specific contexts, the set of operations such a procedure
3068 can perform is very limited and the type of objects it can manipulate is
3069 essentially restricted to the elementary types. In particular, it must only
3070 contain code to which pragma Restrictions (No_Elaboration_Code) applies.
3071
3072 This pragma is used by GNAT to implement auto-initialization of shared Stand
3073 Alone Libraries, which provides a related capability without the restrictions
3074 listed above. Where possible, the use of Stand Alone Libraries is preferable
3075 to the use of this pragma.
3076
3077 @node Pragma Linker_Destructor
3078 @unnumberedsec Pragma Linker_Destructor
3079 @findex Linker_Destructor
3080 @noindent
3081 Syntax:
3082
3083 @smallexample @c ada
3084 pragma Linker_Destructor (procedure_LOCAL_NAME);
3085 @end smallexample
3086
3087 @noindent
3088 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
3089 is declared at the library level. A procedure to which this pragma is
3090 applied will be treated as a finalization routine by the linker.
3091 It is equivalent to @code{__attribute__((destructor))} in GNU C and
3092 causes @var{procedure_LOCAL_NAME} to be invoked after the entry point
3093 of the executable has exited (or immediately before the shared library
3094 is unloaded if the procedure is linked in a shared library), in particular
3095 after the Ada run-time environment is shut down.
3096
3097 See @code{pragma Linker_Constructor} for the set of restrictions that apply
3098 because of these specific contexts.
3099
3100 @node Pragma Linker_Section
3101 @unnumberedsec Pragma Linker_Section
3102 @findex Linker_Section
3103 @noindent
3104 Syntax:
3105
3106 @smallexample @c ada
3107 pragma Linker_Section (
3108   [Entity  =>] LOCAL_NAME,
3109   [Section =>] static_string_EXPRESSION);
3110 @end smallexample
3111
3112 @noindent
3113 @var{LOCAL_NAME} must refer to an object that is declared at the library
3114 level. This pragma specifies the name of the linker section for the given
3115 entity. It is equivalent to @code{__attribute__((section))} in GNU C and
3116 causes @var{LOCAL_NAME} to be placed in the @var{static_string_EXPRESSION}
3117 section of the executable (assuming the linker doesn't rename the section).
3118
3119 The compiler normally places library-level objects in standard sections
3120 depending on their type: procedures and functions generally go in the
3121 @code{.text} section, initialized variables in the @code{.data} section
3122 and uninitialized variables in the @code{.bss} section.
3123
3124 Other, special sections may exist on given target machines to map special
3125 hardware, for example I/O ports or flash memory. This pragma is a means to
3126 defer the final layout of the executable to the linker, thus fully working
3127 at the symbolic level with the compiler.
3128
3129 Some file formats do not support arbitrary sections so not all target
3130 machines support this pragma. The use of this pragma may cause a program
3131 execution to be erroneous if it is used to place an entity into an
3132 inappropriate section (e.g.@: a modified variable into the @code{.text}
3133 section). See also @code{pragma Persistent_BSS}.
3134
3135 @smallexample @c ada
3136 --  Example of the use of pragma Linker_Section
3137
3138 package IO_Card is
3139   Port_A : Integer;
3140   pragma Volatile (Port_A);
3141   pragma Linker_Section (Port_A, ".bss.port_a");
3142
3143   Port_B : Integer;
3144   pragma Volatile (Port_B);
3145   pragma Linker_Section (Port_B, ".bss.port_b");
3146 end IO_Card;
3147 @end smallexample
3148
3149 @node Pragma Long_Float
3150 @unnumberedsec Pragma Long_Float
3151 @cindex OpenVMS
3152 @findex Long_Float
3153 @noindent
3154 Syntax:
3155
3156 @smallexample @c ada
3157 pragma Long_Float (FLOAT_FORMAT);
3158
3159 FLOAT_FORMAT ::= D_Float | G_Float
3160 @end smallexample
3161
3162 @noindent
3163 This pragma is implemented only in the OpenVMS implementation of GNAT@.
3164 It allows control over the internal representation chosen for the predefined
3165 type @code{Long_Float} and for floating point type representations with
3166 @code{digits} specified in the range 7 through 15.
3167 For further details on this pragma, see the
3168 @cite{DEC Ada Language Reference Manual}, section 3.5.7b.  Note that to use
3169 this pragma, the standard runtime libraries must be recompiled.
3170 @xref{The GNAT Run-Time Library Builder gnatlbr,,, gnat_ugn,
3171 @value{EDITION} User's Guide OpenVMS}, for a description of the
3172 @code{GNAT LIBRARY} command.
3173
3174 @node Pragma Machine_Attribute
3175 @unnumberedsec Pragma Machine_Attribute
3176 @findex Machine_Attribute
3177 @noindent
3178 Syntax:
3179
3180 @smallexample @c ada
3181 pragma Machine_Attribute (
3182      [Entity         =>] LOCAL_NAME,
3183      [Attribute_Name =>] static_string_EXPRESSION
3184   [, [Info           =>] static_string_EXPRESSION] );
3185 @end smallexample
3186
3187 @noindent
3188 Machine-dependent attributes can be specified for types and/or
3189 declarations.  This pragma is semantically equivalent to
3190 @code{__attribute__((@var{attribute_name}))} (if @var{info} is not
3191 specified) or @code{__attribute__((@var{attribute_name}(@var{info})))}
3192 in GNU C, where @code{@var{attribute_name}} is recognized by the
3193 target macro @code{TARGET_ATTRIBUTE_TABLE} which is defined for each
3194 machine.  The optional parameter @var{info} is transformed into an
3195 identifier, which may make this pragma unusable for some attributes
3196 (parameter of some attributes must be a number or a string).
3197 @xref{Target Attributes,, Defining target-specific uses of
3198 @code{__attribute__}, gccint, GNU Compiler Colletion (GCC) Internals},
3199 further information.  It is not possible to specify
3200 attributes defined by other languages, only attributes defined by the
3201 machine the code is intended to run on.
3202
3203 @node Pragma Main
3204 @unnumberedsec Pragma Main
3205 @cindex OpenVMS
3206 @findex Main
3207 @noindent
3208 Syntax:
3209
3210 @smallexample @c ada
3211 pragma Main
3212  (MAIN_OPTION [, MAIN_OPTION]);
3213
3214 MAIN_OPTION ::=
3215   [STACK_SIZE              =>] static_integer_EXPRESSION
3216 | [TASK_STACK_SIZE_DEFAULT =>] static_integer_EXPRESSION
3217 | [TIME_SLICING_ENABLED    =>] static_boolean_EXPRESSION
3218 @end smallexample
3219
3220 @noindent
3221 This pragma is provided for compatibility with OpenVMS VAX Systems.  It has
3222 no effect in GNAT, other than being syntax checked.
3223
3224 @node Pragma Main_Storage
3225 @unnumberedsec Pragma Main_Storage
3226 @cindex OpenVMS
3227 @findex Main_Storage
3228 @noindent
3229 Syntax:
3230
3231 @smallexample @c ada
3232 pragma Main_Storage
3233   (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
3234
3235 MAIN_STORAGE_OPTION ::=
3236   [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
3237 | [TOP_GUARD       =>] static_SIMPLE_EXPRESSION
3238 @end smallexample
3239
3240 @noindent
3241 This pragma is provided for compatibility with OpenVMS VAX Systems.  It has
3242 no effect in GNAT, other than being syntax checked.  Note that the pragma
3243 also has no effect in DEC Ada 83 for OpenVMS Alpha Systems.
3244
3245 @node Pragma No_Body
3246 @unnumberedsec Pragma No_Body
3247 @findex No_Body
3248 @noindent
3249 Syntax:
3250
3251 @smallexample @c ada
3252 pragma No_Body;
3253 @end smallexample
3254
3255 @noindent
3256 There are a number of cases in which a package spec does not require a body,
3257 and in fact a body is not permitted. GNAT will not permit the spec to be
3258 compiled if there is a body around. The pragma No_Body allows you to provide
3259 a body file, even in a case where no body is allowed. The body file must
3260 contain only comments and a single No_Body pragma. This is recognized by
3261 the compiler as indicating that no body is logically present.
3262
3263 This is particularly useful during maintenance when a package is modified in
3264 such a way that a body needed before is no longer needed. The provision of a
3265 dummy body with a No_Body pragma ensures that there is no interference from
3266 earlier versions of the package body.
3267
3268 @node Pragma No_Return
3269 @unnumberedsec Pragma No_Return
3270 @findex No_Return
3271 @noindent
3272 Syntax:
3273
3274 @smallexample @c ada
3275 pragma No_Return (procedure_LOCAL_NAME @{, procedure_LOCAL_NAME@});
3276 @end smallexample
3277
3278 @noindent
3279 Each @var{procedure_LOCAL_NAME} argument must refer to one or more procedure
3280 declarations in the current declarative part.  A procedure to which this
3281 pragma is applied may not contain any explicit @code{return} statements.
3282 In addition, if the procedure contains any implicit returns from falling
3283 off the end of a statement sequence, then execution of that implicit
3284 return will cause Program_Error to be raised.
3285
3286 One use of this pragma is to identify procedures whose only purpose is to raise
3287 an exception. Another use of this pragma is to suppress incorrect warnings
3288 about missing returns in functions, where the last statement of a function
3289 statement sequence is a call to such a procedure.
3290
3291 Note that in Ada 2005 mode, this pragma is part of the language, and is
3292 identical in effect to the pragma as implemented in Ada 95 mode.
3293
3294 @node Pragma No_Strict_Aliasing
3295 @unnumberedsec Pragma No_Strict_Aliasing
3296 @findex No_Strict_Aliasing
3297 @noindent
3298 Syntax:
3299
3300 @smallexample @c ada
3301 pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
3302 @end smallexample
3303
3304 @noindent
3305 @var{type_LOCAL_NAME} must refer to an access type
3306 declaration in the current declarative part.  The effect is to inhibit
3307 strict aliasing optimization for the given type.  The form with no
3308 arguments is a configuration pragma which applies to all access types
3309 declared in units to which the pragma applies. For a detailed
3310 description of the strict aliasing optimization, and the situations
3311 in which it must be suppressed, see @ref{Optimization and Strict
3312 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
3313
3314 @node Pragma Normalize_Scalars
3315 @unnumberedsec Pragma Normalize_Scalars
3316 @findex Normalize_Scalars
3317 @noindent
3318 Syntax:
3319
3320 @smallexample @c ada
3321 pragma Normalize_Scalars;
3322 @end smallexample
3323
3324 @noindent
3325 This is a language defined pragma which is fully implemented in GNAT@.  The
3326 effect is to cause all scalar objects that are not otherwise initialized
3327 to be initialized.  The initial values are implementation dependent and
3328 are as follows:
3329
3330 @table @code
3331 @item Standard.Character
3332 @noindent
3333 Objects whose root type is Standard.Character are initialized to
3334 Character'Last unless the subtype range excludes NUL (in which case
3335 NUL is used). This choice will always generate an invalid value if
3336 one exists.
3337
3338 @item Standard.Wide_Character
3339 @noindent
3340 Objects whose root type is Standard.Wide_Character are initialized to
3341 Wide_Character'Last unless the subtype range excludes NUL (in which case
3342 NUL is used). This choice will always generate an invalid value if
3343 one exists.
3344
3345 @item Standard.Wide_Wide_Character
3346 @noindent
3347 Objects whose root type is Standard.Wide_Wide_Character are initialized to
3348 the invalid value 16#FFFF_FFFF# unless the subtype range excludes NUL (in
3349 which case NUL is used). This choice will always generate an invalid value if
3350 one exists.
3351
3352 @item Integer types
3353 @noindent
3354 Objects of an integer type are treated differently depending on whether
3355 negative values are present in the subtype. If no negative values are
3356 present, then all one bits is used as the initial value except in the
3357 special case where zero is excluded from the subtype, in which case
3358 all zero bits are used. This choice will always generate an invalid
3359 value if one exists.
3360
3361 For subtypes with negative values present, the largest negative number
3362 is used, except in the unusual case where this largest negative number
3363 is in the subtype, and the largest positive number is not, in which case
3364 the largest positive value is used. This choice will always generate
3365 an invalid value if one exists.
3366
3367 @item Floating-Point Types
3368 Objects of all floating-point types are initialized to all 1-bits. For
3369 standard IEEE format, this corresponds to a NaN (not a number) which is
3370 indeed an invalid value.
3371
3372 @item Fixed-Point Types
3373 Objects of all fixed-point types are treated as described above for integers,
3374 with the rules applying to the underlying integer value used to represent
3375 the fixed-point value.
3376
3377 @item Modular types
3378 Objects of a modular type are initialized to all one bits, except in
3379 the special case where zero is excluded from the subtype, in which
3380 case all zero bits are used. This choice will always generate an
3381 invalid value if one exists.
3382
3383 @item Enumeration types
3384 Objects of an enumeration type are initialized to all one-bits, i.e.@: to
3385 the value @code{2 ** typ'Size - 1} unless the subtype excludes the literal
3386 whose Pos value is zero, in which case a code of zero is used. This choice
3387 will always generate an invalid value if one exists.
3388
3389 @end table
3390
3391 @node Pragma Obsolescent
3392 @unnumberedsec Pragma Obsolescent
3393 @findex Obsolescent
3394 @noindent
3395 Syntax:
3396
3397 @smallexample @c ada
3398 pragma Obsolescent
3399   (Entity => NAME [, static_string_EXPRESSION [,Ada_05]]);
3400 @end smallexample
3401
3402 @noindent
3403 This pragma can occur immediately following a declaration of an entity,
3404 including the case of a record component, and usually the Entity name
3405 must match the name of the entity declared by this declaration.
3406 Alternatively, the pragma can immediately follow an
3407 enumeration type declaration, where the entity argument names one of the
3408 enumeration literals.
3409
3410 This pragma is used to indicate that the named entity
3411 is considered obsolescent and should not be used. Typically this is
3412 used when an API must be modified by eventually removing or modifying
3413 existing subprograms or other entities. The pragma can be used at an
3414 intermediate stage when the entity is still present, but will be
3415 removed later.
3416
3417 The effect of this pragma is to output a warning message on
3418 a call to a program thus marked that the
3419 subprogram is obsolescent if the appropriate warning option in the
3420 compiler is activated. If the string parameter is present, then a second
3421 warning message is given containing this text.
3422 In addition, a call to such a program is considered a violation of
3423 pragma Restrictions (No_Obsolescent_Features).
3424
3425 This pragma can also be used as a program unit pragma for a package,
3426 in which case the entity name is the name of the package, and the
3427 pragma indicates that the entire package is considered
3428 obsolescent. In this case a client @code{with}'ing such a package
3429 violates the restriction, and the @code{with} statement is
3430 flagged with warnings if the warning option is set.
3431
3432 If the optional third parameter is present (which must be exactly
3433 the identifier Ada_05, no other argument is allowed), then the
3434 indication of obsolescence applies only when compiling in Ada 2005
3435 mode. This is primarily intended for dealing with the situations
3436 in the predefined library where subprograms or packages
3437 have become defined as obsolescent in Ada 2005
3438 (e.g.@: in Ada.Characters.Handling), but may be used anywhere.
3439
3440 The following examples show typical uses of this pragma:
3441
3442 @smallexample @c ada
3443 package p is
3444    pragma Obsolescent
3445      (Entity => p, "use pp instead of p");
3446 end p;
3447
3448 package q is
3449    procedure q2;
3450    pragma Obsolescent
3451      (Entity => q2, "use q2new instead");
3452
3453    type R is new integer;
3454    pragma Obsolescent
3455      (Entity => R, "use RR in Ada 2005", Ada_05);
3456
3457    type M is record
3458       F1 : Integer;
3459       F2 : Integer;
3460       pragma Obsolescent (Entity => F2);
3461       F3 : Integer;
3462    end record;
3463
3464    type E is (a, bc, 'd', quack);
3465    pragma Obsolescent (Entity => bc)
3466    pragma Obsolescent (Entity => 'd')
3467
3468    function "+"
3469      (a, b : character) return character;
3470    pragma Obsolescent (Entity => "+");
3471 end;
3472 @end smallexample
3473
3474 @noindent
3475 In an earlier version of GNAT, the Entity parameter was not required,
3476 and this form is still accepted for compatibility purposes. If the
3477 Entity parameter is omitted, then the pragma applies to the declaration
3478 immediately preceding the pragma (this form cannot be used for the
3479 enumeration literal case).
3480
3481 @node Pragma Optimize_Alignment
3482 @unnumberedsec Pragma Optimize_Alignment
3483 @findex Optimize_Alignment
3484 @cindex Alignment, default settings
3485 @noindent
3486 Syntax:
3487
3488 @smallexample @c ada
3489 pragma Optimize_Alignment (TIME | SPACE | OFF);
3490 @end smallexample
3491
3492 @noindent
3493 This is a configuration pragma which affects the choice of default alignments
3494 for types where no alignment is explicitly specified. There is a time/space
3495 trade-off in the selection of these values. Large alignments result in more
3496 efficient code, at the expense of larger data space, since sizes have to be
3497 increased to match these alignments. Smaller alignments save space, but the
3498 access code is slower. The normal choice of default alignments (which is what
3499 you get if you do not use this pragma, or if you use an argument of OFF),
3500 tries to balance these two requirements.
3501
3502 Specifying SPACE causes smaller default alignments to be chosen in two cases.
3503 First any packed record is given an alignment of 1. Second, if a size is given
3504 for the type, then the alignment is chosen to avoid increasing this size. For
3505 example, consider:
3506
3507 @smallexample @c ada
3508    type R is record
3509       X : Integer;
3510       Y : Character;
3511    end record;
3512
3513    for R'Size use 5*8;
3514 @end smallexample
3515
3516 @noindent
3517 In the default mode, this type gets an alignment of 4, so that access to the
3518 Integer field X are efficient. But this means that objects of the type end up
3519 with a size of 8 bytes. This is a valid choice, since sizes of objects are
3520 allowed to be bigger than the size of the type, but it can waste space if for
3521 example fields of type R appear in an enclosing record. If the above type is
3522 compiled in @code{Optimize_Alignment (Space)} mode, the alignment is set to 1.
3523
3524 Specifying TIME causes larger default alignments to be chosen in the case of
3525 small types with sizes that are not a power of 2. For example, consider:
3526
3527 @smallexample @c ada
3528    type R is record
3529       A : Character;
3530       B : Character;
3531       C : Boolean;
3532    end record;
3533
3534    pragma Pack (R);
3535    for R'Size use 17;
3536 @end smallexample
3537
3538 @noindent
3539 The default alignment for this record is normally 1, but if this type is
3540 compiled in @code{Optimize_Alignment (Time)} mode, then the alignment is set
3541 to 4, which wastes space for objects of the type, since they are now 4 bytes
3542 long, but results in more efficient access when the whole record is referenced.
3543
3544 As noted above, this is a configuration pragma, and there is a requirement
3545 that all units in a partition be compiled with a consistent setting of the
3546 optimization setting. This would normally be achieved by use of a configuration
3547 pragma file containing the appropriate setting. The exception to this rule is
3548 that units with an explicit configuration pragma in the same file as the source
3549 unit are excluded from the consistency check, as are all predefined units. The
3550 latter are compiled by default in pragma Optimize_Alignment (Off) mode if no
3551 pragma appears at the start of the file.
3552
3553 @node Pragma Passive
3554 @unnumberedsec Pragma Passive
3555 @findex Passive
3556 @noindent
3557 Syntax:
3558
3559 @smallexample @c ada
3560 pragma Passive [(Semaphore | No)];
3561 @end smallexample
3562
3563 @noindent
3564 Syntax checked, but otherwise ignored by GNAT@.  This is recognized for
3565 compatibility with DEC Ada 83 implementations, where it is used within a
3566 task definition to request that a task be made passive.  If the argument
3567 @code{Semaphore} is present, or the argument is omitted, then DEC Ada 83
3568 treats the pragma as an assertion that the containing task is passive
3569 and that optimization of context switch with this task is permitted and
3570 desired.  If the argument @code{No} is present, the task must not be
3571 optimized.  GNAT does not attempt to optimize any tasks in this manner
3572 (since protected objects are available in place of passive tasks).
3573
3574 @node Pragma Persistent_BSS
3575 @unnumberedsec Pragma Persistent_BSS
3576 @findex Persistent_BSS
3577 @noindent
3578 Syntax:
3579
3580 @smallexample @c ada
3581 pragma Persistent_BSS [(LOCAL_NAME)]
3582 @end smallexample
3583
3584 @noindent
3585 This pragma allows selected objects to be placed in the @code{.persistent_bss}
3586 section. On some targets the linker and loader provide for special
3587 treatment of this section, allowing a program to be reloaded without
3588 affecting the contents of this data (hence the name persistent).
3589
3590 There are two forms of usage. If an argument is given, it must be the
3591 local name of a library level object, with no explicit initialization
3592 and whose type is potentially persistent. If no argument is given, then
3593 the pragma is a configuration pragma, and applies to all library level
3594 objects with no explicit initialization of potentially persistent types.
3595
3596 A potentially persistent type is a scalar type, or a non-tagged,
3597 non-discriminated record, all of whose components have no explicit
3598 initialization and are themselves of a potentially persistent type,
3599 or an array, all of whose constraints are static, and whose component
3600 type is potentially persistent.
3601
3602 If this pragma is used on a target where this feature is not supported,
3603 then the pragma will be ignored. See also @code{pragma Linker_Section}.
3604
3605 @node Pragma Polling
3606 @unnumberedsec Pragma Polling
3607 @findex Polling
3608 @noindent
3609 Syntax:
3610
3611 @smallexample @c ada
3612 pragma Polling (ON | OFF);
3613 @end smallexample
3614
3615 @noindent
3616 This pragma controls the generation of polling code.  This is normally off.
3617 If @code{pragma Polling (ON)} is used then periodic calls are generated to
3618 the routine @code{Ada.Exceptions.Poll}.  This routine is a separate unit in the
3619 runtime library, and can be found in file @file{a-excpol.adb}.
3620
3621 Pragma @code{Polling} can appear as a configuration pragma (for example it
3622 can be placed in the @file{gnat.adc} file) to enable polling globally, or it
3623 can be used in the statement or declaration sequence to control polling
3624 more locally.
3625
3626 A call to the polling routine is generated at the start of every loop and
3627 at the start of every subprogram call.  This guarantees that the @code{Poll}
3628 routine is called frequently, and places an upper bound (determined by
3629 the complexity of the code) on the period between two @code{Poll} calls.
3630
3631 The primary purpose of the polling interface is to enable asynchronous
3632 aborts on targets that cannot otherwise support it (for example Windows
3633 NT), but it may be used for any other purpose requiring periodic polling.
3634 The standard version is null, and can be replaced by a user program.  This
3635 will require re-compilation of the @code{Ada.Exceptions} package that can
3636 be found in files @file{a-except.ads} and @file{a-except.adb}.
3637
3638 A standard alternative unit (in file @file{4wexcpol.adb} in the standard GNAT
3639 distribution) is used to enable the asynchronous abort capability on
3640 targets that do not normally support the capability.  The version of
3641 @code{Poll} in this file makes a call to the appropriate runtime routine
3642 to test for an abort condition.
3643
3644 Note that polling can also be enabled by use of the @option{-gnatP} switch.
3645 @xref{Switches for gcc,,, gnat_ugn, @value{EDITION} User's Guide}, for
3646 details.
3647
3648 @node Pragma Postcondition
3649 @unnumberedsec Pragma Postcondition
3650 @cindex Postconditions
3651 @cindex Checks, postconditions
3652 @findex Postconditions
3653 @noindent
3654 Syntax:
3655
3656 @smallexample @c ada
3657 pragma Postcondition (
3658    [Check   =>] Boolean_Expression
3659  [,[Message =>] String_Expression]);
3660 @end smallexample
3661
3662 @noindent
3663 The @code{Postcondition} pragma allows specification of automatic
3664 postcondition checks for subprograms. These checks are similar to
3665 assertions, but are automatically inserted just prior to the return
3666 statements of the subprogram with which they are associated.
3667 Furthermore, the boolean expression which is the condition which
3668 must be true may contain references to function'Result in the case
3669 of a function to refer to the returned value.
3670
3671 @code{Postcondition} pragmas may appear either immediate following the
3672 (separate) declaration of a subprogram, or at the start of the
3673 declarations of a subprogram body. Only other pragmas may intervene
3674 (that is appear between the subprogram declaration and its
3675 postconditions, or appear before the postcondition in the
3676 declaration sequence in a subprogram body). In the case of a
3677 postcondition appearing after a subprogram declaration, the
3678 formal arguments of the subprogram are visible, and can be
3679 referenced in the postcondition expressions.
3680
3681 The postconditions are collected and automatically tested just
3682 before any return (implicit or explicit) in the subprogram body.
3683 A postcondition is only recognized if postconditions are active
3684 at the time the pragma is encountered. The compiler switch @option{gnata}
3685 turns on all postconditions by default, and pragma @code{Check_Policy}
3686 with an identifier of @code{Postcondition} can also be used to
3687 control whether postconditions are active.
3688
3689 The general approach is that postconditions are placed in the spec
3690 if they represent functional aspects which make sense to the client.
3691 For example we might have:
3692
3693 @smallexample @c ada
3694    function Direction return Integer;
3695    pragma Postcondition
3696     (Direction'Result = +1
3697        or else
3698      Direction'Result = -1);
3699 @end smallexample
3700
3701 @noindent
3702 which serves to document that the result must be +1 or -1, and
3703 will test that this is the case at run time if postcondition
3704 checking is active.
3705
3706 Postconditions within the subprogram body can be used to
3707 check that some internal aspect of the implementation,
3708 not visible to the client, is operating as expected.
3709 For instance if a square root routine keeps an internal
3710 counter of the number of times it is called, then we
3711 might have the following postcondition:
3712
3713 @smallexample @c ada
3714    Sqrt_Calls : Natural := 0;
3715
3716    function Sqrt (Arg : Float) return Float is
3717      pragma Postcondition
3718        (Sqrt_Calls = Sqrt_Calls'Old + 1);
3719      ...
3720    end Sqrt
3721 @end smallexample
3722
3723 @noindent
3724 As this example, shows, the use of the @code{Old} attribute
3725 is often useful in postconditions to refer to the state on
3726 entry to the subprogram.
3727
3728 Note that postconditions are only checked on normal returns
3729 from the subprogram. If an abnormal return results from
3730 raising an exception, then the postconditions are not checked.
3731
3732 If a postcondition fails, then the exception
3733 @code{System.Assertions.Assert_Failure} is raised. If
3734 a message argument was supplied, then the given string
3735 will be used as the exception message. If no message
3736 argument was supplied, then the default message has
3737 the form "Postcondition failed at file:line". The
3738 exception is raised in the context of the subprogram
3739 body, so it is possible to catch postcondition failures
3740 within the subprogram body itself.
3741
3742 Within a package spec, normal visibility rules
3743 in Ada would prevent forward references within a
3744 postcondition pragma to functions defined later in
3745 the same package. This would introduce undesirable
3746 ordering constraints. To avoid this problem, all
3747 postcondition pragmas are analyzed at the end of
3748 the package spec, allowing forward references.
3749
3750 The following example shows that this even allows
3751 mutually recursive postconditions as in:
3752
3753 @smallexample @c ada
3754 package Parity_Functions is
3755    function Odd  (X : Natural) return Boolean;
3756    pragma Postcondition
3757      (Odd'Result =
3758         (x = 1
3759           or else
3760         (x /= 0 and then Even (X - 1))));
3761
3762    function Even (X : Natural) return Boolean;
3763    pragma Postcondition
3764      (Even'Result =
3765         (x = 0
3766           or else
3767         (x /= 1 and then Odd (X - 1))));
3768
3769 end Parity_Functions;
3770 @end smallexample
3771
3772 @noindent
3773 There are no restrictions on the complexity or form of
3774 conditions used within @code{Postcondition} pragmas.
3775 The following example shows that it is even possible
3776 to verify performance behavior.
3777
3778 @smallexample @c ada
3779 package Sort is
3780
3781    Performance : constant Float;
3782    --  Performance constant set by implementation
3783    --  to match target architecture behavior.
3784
3785    procedure Treesort (Arg : String);
3786    --  Sorts characters of argument using N*logN sort
3787    pragma Postcondition
3788      (Float (Clock - Clock'Old) <=
3789         Float (Arg'Length) *
3790         log (Float (Arg'Length)) *
3791         Performance);
3792 end Sort;
3793 @end smallexample
3794
3795 @node Pragma Precondition
3796 @unnumberedsec Pragma Precondition
3797 @cindex Preconditions
3798 @cindex Checks, preconditions
3799 @findex Preconditions
3800 @noindent
3801 Syntax:
3802
3803 @smallexample @c ada
3804 pragma Precondition (
3805    [Check   =>] Boolean_Expression
3806  [,[Message =>] String_Expression]);
3807 @end smallexample
3808
3809 @noindent
3810 The @code{Precondition} pragma is similar to @code{Postcondition}
3811 except that the corresponding checks take place immediately upon
3812 entry to the subprogram, and if a precondition fails, the exception
3813 is raised in the context of the caller, and the attribute 'Result
3814 cannot be used within the precondition expression.
3815
3816 Otherwise, the placement and visibility rules are identical to those
3817 described for postconditions. The following is an example of use
3818 within a package spec:
3819
3820 @smallexample @c ada
3821 package Math_Functions is
3822    ...
3823    function Sqrt (Arg : Float) return Float;
3824    pragma Precondition (Arg >= 0.0)
3825    ...
3826 end Math_Functions;
3827 @end smallexample
3828
3829 @code{Postcondition} pragmas may appear either immediate following the
3830 (separate) declaration of a subprogram, or at the start of the
3831 declarations of a subprogram body. Only other pragmas may intervene
3832 (that is appear between the subprogram declaration and its
3833 postconditions, or appear before the postcondition in the
3834 declaration sequence in a subprogram body).
3835
3836 @node Pragma Profile (Ravenscar)
3837 @unnumberedsec Pragma Profile (Ravenscar)
3838 @findex Ravenscar
3839 @noindent
3840 Syntax:
3841
3842 @smallexample @c ada
3843 pragma Profile (Ravenscar);
3844 @end smallexample
3845
3846 @noindent
3847 A configuration pragma that establishes the following set of configuration
3848 pragmas:
3849
3850 @table @code
3851 @item Task_Dispatching_Policy (FIFO_Within_Priorities)
3852 [RM D.2.2] Tasks are dispatched following a preemptive
3853 priority-ordered scheduling policy.
3854
3855 @item Locking_Policy (Ceiling_Locking)
3856 [RM D.3] While tasks and interrupts execute a protected action, they inherit
3857 the ceiling priority of the corresponding protected object.
3858 @c
3859 @c @item Detect_Blocking
3860 @c This pragma forces the detection of potentially blocking operations within a
3861 @c protected operation, and to raise Program_Error if that happens.
3862 @end table
3863 @noindent
3864
3865 plus the following set of restrictions:
3866
3867 @table @code
3868 @item Max_Entry_Queue_Length = 1
3869 Defines the maximum number of calls that are queued on a (protected) entry.
3870 Note that this restrictions is checked at run time. Violation of this
3871 restriction results in the raising of Program_Error exception at the point of
3872 the call. For the Profile (Ravenscar) the value of Max_Entry_Queue_Length is
3873 always 1 and hence no task can be queued on a protected entry.
3874
3875 @item Max_Protected_Entries = 1
3876 [RM D.7] Specifies the maximum number of entries per protected type. The
3877 bounds of every entry family of a protected unit shall be static, or shall be
3878 defined by a discriminant of a subtype whose corresponding bound is static.
3879 For the Profile (Ravenscar) the value of Max_Protected_Entries is always 1.
3880
3881 @item Max_Task_Entries = 0
3882 [RM D.7] Specifies the maximum number of entries
3883 per task.  The bounds of every entry family
3884 of a task unit shall be static, or shall be
3885 defined by a discriminant of a subtype whose
3886 corresponding bound is static.  A value of zero
3887 indicates that no rendezvous are possible.  For
3888 the Profile (Ravenscar), the value of Max_Task_Entries is always
3889 0 (zero).
3890
3891 @item No_Abort_Statements
3892 [RM D.7] There are no abort_statements, and there are
3893 no calls to Task_Identification.Abort_Task.
3894
3895 @item No_Asynchronous_Control
3896 There are no semantic dependences on the package
3897 Asynchronous_Task_Control.
3898
3899 @item No_Calendar
3900 There are no semantic dependencies on the package Ada.Calendar.
3901
3902 @item No_Dynamic_Attachment
3903 There is no call to any of the operations defined in package Ada.Interrupts
3904 (Is_Reserved, Is_Attached, Current_Handler, Attach_Handler, Exchange_Handler,
3905 Detach_Handler, and Reference).
3906
3907 @item No_Dynamic_Priorities
3908 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
3909
3910 @item No_Implicit_Heap_Allocations
3911 [RM D.7] No constructs are allowed to cause implicit heap allocation.
3912
3913 @item No_Local_Protected_Objects
3914 Protected objects and access types that designate
3915 such objects shall be declared only at library level.
3916
3917 @item No_Local_Timing_Events
3918 [RM D.7] All objects of type Ada.Timing_Events.Timing_Event are
3919 declared at the library level.
3920
3921 @item No_Protected_Type_Allocators
3922 There are no allocators for protected types or
3923 types containing protected subcomponents.
3924
3925 @item No_Relative_Delay
3926 There are no delay_relative statements.
3927
3928 @item No_Requeue_Statements
3929 Requeue statements are not allowed.
3930
3931 @item No_Select_Statements
3932 There are no select_statements.
3933
3934 @item No_Specific_Termination_Handlers
3935 [RM D.7] There are no calls to Ada.Task_Termination.Set_Specific_Handler
3936 or to Ada.Task_Termination.Specific_Handler.
3937
3938 @item No_Task_Allocators
3939 [RM D.7] There are no allocators for task types
3940 or types containing task subcomponents.
3941
3942 @item No_Task_Attributes_Package
3943 There are no semantic dependencies on the Ada.Task_Attributes package.
3944
3945 @item No_Task_Hierarchy
3946 [RM D.7] All (non-environment) tasks depend
3947 directly on the environment task of the partition.
3948
3949 @item No_Task_Termination
3950 Tasks which terminate are erroneous.
3951
3952 @item No_Unchecked_Conversion
3953 There are no semantic dependencies on the Ada.Unchecked_Conversion package.
3954
3955 @item No_Unchecked_Deallocation
3956 There are no semantic dependencies on the Ada.Unchecked_Deallocation package.
3957
3958 @item Simple_Barriers
3959 Entry barrier condition expressions shall be either static
3960 boolean expressions or boolean objects which are declared in
3961 the protected type which contains the entry.
3962 @end table
3963
3964 @noindent
3965 This set of configuration pragmas and restrictions correspond to the
3966 definition of the ``Ravenscar Profile'' for limited tasking, devised and
3967 published by the @cite{International Real-Time Ada Workshop}, 1997,
3968 and whose most recent description is available at
3969 @url{http://www-users.cs.york.ac.uk/~burns/ravenscar.ps}.
3970
3971 The original definition of the profile was revised at subsequent IRTAW
3972 meetings. It has been included in the ISO
3973 @cite{Guide for the Use of the Ada Programming Language in High
3974 Integrity Systems}, and has been approved by ISO/IEC/SC22/WG9 for inclusion in
3975 the next revision of the standard. The formal definition given by
3976 the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
3977 AI-305) available at
3978 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00249.TXT} and
3979 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00305.TXT}
3980 respectively.
3981
3982 The above set is a superset of the restrictions provided by pragma
3983 @code{Profile (Restricted)}, it includes six additional restrictions
3984 (@code{Simple_Barriers}, @code{No_Select_Statements},
3985 @code{No_Calendar}, @code{No_Implicit_Heap_Allocations},
3986 @code{No_Relative_Delay} and @code{No_Task_Termination}).  This means
3987 that pragma @code{Profile (Ravenscar)}, like the pragma
3988 @code{Profile (Restricted)},
3989 automatically causes the use of a simplified,
3990 more efficient version of the tasking run-time system.
3991
3992 @node Pragma Profile (Restricted)
3993 @unnumberedsec Pragma Profile (Restricted)
3994 @findex Restricted Run Time
3995 @noindent
3996 Syntax:
3997
3998 @smallexample @c ada
3999 pragma Profile (Restricted);
4000 @end smallexample
4001
4002 @noindent
4003 A configuration pragma that establishes the following set of restrictions:
4004
4005 @itemize @bullet
4006 @item No_Abort_Statements
4007 @item No_Entry_Queue
4008 @item No_Task_Hierarchy
4009 @item No_Task_Allocators
4010 @item No_Dynamic_Priorities
4011 @item No_Terminate_Alternatives
4012 @item No_Dynamic_Attachment
4013 @item No_Protected_Type_Allocators
4014 @item No_Local_Protected_Objects
4015 @item No_Requeue_Statements
4016 @item No_Task_Attributes_Package
4017 @item Max_Asynchronous_Select_Nesting =  0
4018 @item Max_Task_Entries =  0
4019 @item Max_Protected_Entries = 1
4020 @item Max_Select_Alternatives = 0
4021 @end itemize
4022
4023 @noindent
4024 This set of restrictions causes the automatic selection of a simplified
4025 version of the run time that provides improved performance for the
4026 limited set of tasking functionality permitted by this set of restrictions.
4027
4028 @node Pragma Psect_Object
4029 @unnumberedsec Pragma Psect_Object
4030 @findex Psect_Object
4031 @noindent
4032 Syntax:
4033
4034 @smallexample @c ada
4035 pragma Psect_Object (
4036      [Internal =>] LOCAL_NAME,
4037   [, [External =>] EXTERNAL_SYMBOL]
4038   [, [Size     =>] EXTERNAL_SYMBOL]);
4039
4040 EXTERNAL_SYMBOL ::=
4041   IDENTIFIER
4042 | static_string_EXPRESSION
4043 @end smallexample
4044
4045 @noindent
4046 This pragma is identical in effect to pragma @code{Common_Object}.
4047
4048 @node Pragma Pure_Function
4049 @unnumberedsec Pragma Pure_Function
4050 @findex Pure_Function
4051 @noindent
4052 Syntax:
4053
4054 @smallexample @c ada
4055 pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
4056 @end smallexample
4057
4058 @noindent
4059 This pragma appears in the same declarative part as a function
4060 declaration (or a set of function declarations if more than one
4061 overloaded declaration exists, in which case the pragma applies
4062 to all entities).  It specifies that the function @code{Entity} is
4063 to be considered pure for the purposes of code generation.  This means
4064 that the compiler can assume that there are no side effects, and
4065 in particular that two calls with identical arguments produce the
4066 same result.  It also means that the function can be used in an
4067 address clause.
4068
4069 Note that, quite deliberately, there are no static checks to try
4070 to ensure that this promise is met, so @code{Pure_Function} can be used
4071 with functions that are conceptually pure, even if they do modify
4072 global variables.  For example, a square root function that is
4073 instrumented to count the number of times it is called is still
4074 conceptually pure, and can still be optimized, even though it
4075 modifies a global variable (the count).  Memo functions are another
4076 example (where a table of previous calls is kept and consulted to
4077 avoid re-computation).
4078
4079 @findex Pure
4080 Note: Most functions in a @code{Pure} package are automatically pure, and
4081 there is no need to use pragma @code{Pure_Function} for such functions.  One
4082 exception is any function that has at least one formal of type
4083 @code{System.Address} or a type derived from it.  Such functions are not
4084 considered pure by default, since the compiler assumes that the
4085 @code{Address} parameter may be functioning as a pointer and that the
4086 referenced data may change even if the address value does not.
4087 Similarly, imported functions are not considered to be pure by default,
4088 since there is no way of checking that they are in fact pure.  The use
4089 of pragma @code{Pure_Function} for such a function will override these default
4090 assumption, and cause the compiler to treat a designated subprogram as pure
4091 in these cases.
4092
4093 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
4094 applies to the underlying renamed function.  This can be used to
4095 disambiguate cases of overloading where some but not all functions
4096 in a set of overloaded functions are to be designated as pure.
4097
4098 If pragma @code{Pure_Function} is applied to a library level function, the
4099 function is also considered pure from an optimization point of view, but the
4100 unit is not a Pure unit in the categorization sense. So for example, a function
4101 thus marked is free to @code{with} non-pure units.
4102
4103 @node Pragma Restriction_Warnings
4104 @unnumberedsec Pragma Restriction_Warnings
4105 @findex Restriction_Warnings
4106 @noindent
4107 Syntax:
4108
4109 @smallexample @c ada
4110 pragma Restriction_Warnings
4111   (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
4112 @end smallexample
4113
4114 @noindent
4115 This pragma allows a series of restriction identifiers to be
4116 specified (the list of allowed identifiers is the same as for
4117 pragma @code{Restrictions}). For each of these identifiers
4118 the compiler checks for violations of the restriction, but
4119 generates a warning message rather than an error message
4120 if the restriction is violated.
4121
4122 @node Pragma Shared
4123 @unnumberedsec Pragma Shared
4124 @findex Shared
4125
4126 @noindent
4127 This pragma is provided for compatibility with Ada 83. The syntax and
4128 semantics are identical to pragma Atomic.
4129
4130 @node Pragma Source_File_Name
4131 @unnumberedsec Pragma Source_File_Name
4132 @findex Source_File_Name
4133 @noindent
4134 Syntax:
4135
4136 @smallexample @c ada
4137 pragma Source_File_Name (
4138   [Unit_Name   =>] unit_NAME,
4139   Spec_File_Name =>  STRING_LITERAL);
4140
4141 pragma Source_File_Name (
4142   [Unit_Name   =>] unit_NAME,
4143   Body_File_Name =>  STRING_LITERAL);
4144 @end smallexample
4145
4146 @noindent
4147 Use this to override the normal naming convention.  It is a configuration
4148 pragma, and so has the usual applicability of configuration pragmas
4149 (i.e.@: it applies to either an entire partition, or to all units in a
4150 compilation, or to a single unit, depending on how it is used.
4151 @var{unit_name} is mapped to @var{file_name_literal}.  The identifier for
4152 the second argument is required, and indicates whether this is the file
4153 name for the spec or for the body.
4154
4155 Another form of the @code{Source_File_Name} pragma allows
4156 the specification of patterns defining alternative file naming schemes
4157 to apply to all files.
4158
4159 @smallexample @c ada
4160 pragma Source_File_Name
4161   (Spec_File_Name => STRING_LITERAL
4162    [,Casing => CASING_SPEC]
4163    [,Dot_Replacement => STRING_LITERAL]);
4164
4165 pragma Source_File_Name
4166   (Body_File_Name => STRING_LITERAL
4167    [,Casing => CASING_SPEC]
4168    [,Dot_Replacement => STRING_LITERAL]);
4169
4170 pragma Source_File_Name
4171   (Subunit_File_Name => STRING_LITERAL
4172    [,Casing => CASING_SPEC]
4173    [,Dot_Replacement => STRING_LITERAL]);
4174
4175 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
4176 @end smallexample
4177
4178 @noindent
4179 The first argument is a pattern that contains a single asterisk indicating
4180 the point at which the unit name is to be inserted in the pattern string
4181 to form the file name.  The second argument is optional.  If present it
4182 specifies the casing of the unit name in the resulting file name string.
4183 The default is lower case.  Finally the third argument allows for systematic
4184 replacement of any dots in the unit name by the specified string literal.
4185
4186 A pragma Source_File_Name cannot appear after a
4187 @ref{Pragma Source_File_Name_Project}.
4188
4189 For more details on the use of the @code{Source_File_Name} pragma,
4190 @xref{Using Other File Names,,, gnat_ugn, @value{EDITION} User's Guide},
4191 and @ref{Alternative File Naming Schemes,,, gnat_ugn, @value{EDITION}
4192 User's Guide}.
4193
4194 @node Pragma Source_File_Name_Project
4195 @unnumberedsec Pragma Source_File_Name_Project
4196 @findex Source_File_Name_Project
4197 @noindent
4198
4199 This pragma has the same syntax and semantics as pragma Source_File_Name.
4200 It is only allowed as a stand alone configuration pragma.
4201 It cannot appear after a @ref{Pragma Source_File_Name}, and
4202 most importantly, once pragma Source_File_Name_Project appears,
4203 no further Source_File_Name pragmas are allowed.
4204
4205 The intention is that Source_File_Name_Project pragmas are always
4206 generated by the Project Manager in a manner consistent with the naming
4207 specified in a project file, and when naming is controlled in this manner,
4208 it is not permissible to attempt to modify this naming scheme using
4209 Source_File_Name pragmas (which would not be known to the project manager).
4210
4211 @node Pragma Source_Reference
4212 @unnumberedsec Pragma Source_Reference
4213 @findex Source_Reference
4214 @noindent
4215 Syntax:
4216
4217 @smallexample @c ada
4218 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
4219 @end smallexample
4220
4221 @noindent
4222 This pragma must appear as the first line of a source file.
4223 @var{integer_literal} is the logical line number of the line following
4224 the pragma line (for use in error messages and debugging
4225 information).  @var{string_literal} is a static string constant that
4226 specifies the file name to be used in error messages and debugging
4227 information.  This is most notably used for the output of @code{gnatchop}
4228 with the @option{-r} switch, to make sure that the original unchopped
4229 source file is the one referred to.
4230
4231 The second argument must be a string literal, it cannot be a static
4232 string expression other than a string literal.  This is because its value
4233 is needed for error messages issued by all phases of the compiler.
4234
4235 @node Pragma Stream_Convert
4236 @unnumberedsec Pragma Stream_Convert
4237 @findex Stream_Convert
4238 @noindent
4239 Syntax:
4240
4241 @smallexample @c ada
4242 pragma Stream_Convert (
4243   [Entity =>] type_LOCAL_NAME,
4244   [Read   =>] function_NAME,
4245   [Write  =>] function_NAME);
4246 @end smallexample
4247
4248 @noindent
4249 This pragma provides an efficient way of providing stream functions for
4250 types defined in packages.  Not only is it simpler to use than declaring
4251 the necessary functions with attribute representation clauses, but more
4252 significantly, it allows the declaration to made in such a way that the
4253 stream packages are not loaded unless they are needed.  The use of
4254 the Stream_Convert pragma adds no overhead at all, unless the stream
4255 attributes are actually used on the designated type.
4256
4257 The first argument specifies the type for which stream functions are
4258 provided.  The second parameter provides a function used to read values
4259 of this type.  It must name a function whose argument type may be any
4260 subtype, and whose returned type must be the type given as the first
4261 argument to the pragma.
4262
4263 The meaning of the @var{Read}
4264 parameter is that if a stream attribute directly
4265 or indirectly specifies reading of the type given as the first parameter,
4266 then a value of the type given as the argument to the Read function is
4267 read from the stream, and then the Read function is used to convert this
4268 to the required target type.
4269
4270 Similarly the @var{Write} parameter specifies how to treat write attributes
4271 that directly or indirectly apply to the type given as the first parameter.
4272 It must have an input parameter of the type specified by the first parameter,
4273 and the return type must be the same as the input type of the Read function.
4274 The effect is to first call the Write function to convert to the given stream
4275 type, and then write the result type to the stream.
4276
4277 The Read and Write functions must not be overloaded subprograms.  If necessary
4278 renamings can be supplied to meet this requirement.
4279 The usage of this attribute is best illustrated by a simple example, taken
4280 from the GNAT implementation of package Ada.Strings.Unbounded:
4281
4282 @smallexample @c ada
4283 function To_Unbounded (S : String)
4284            return Unbounded_String
4285   renames To_Unbounded_String;
4286
4287 pragma Stream_Convert
4288   (Unbounded_String, To_Unbounded, To_String);
4289 @end smallexample
4290
4291 @noindent
4292 The specifications of the referenced functions, as given in the Ada
4293 Reference Manual are:
4294
4295 @smallexample @c ada
4296 function To_Unbounded_String (Source : String)
4297   return Unbounded_String;
4298
4299 function To_String (Source : Unbounded_String)
4300   return String;
4301 @end smallexample
4302
4303 @noindent
4304 The effect is that if the value of an unbounded string is written to a
4305 stream, then the representation of the item in the stream is in the same
4306 format used for @code{Standard.String}, and this same representation is
4307 expected when a value of this type is read from the stream.
4308
4309 @node Pragma Style_Checks
4310 @unnumberedsec Pragma Style_Checks
4311 @findex Style_Checks
4312 @noindent
4313 Syntax:
4314
4315 @smallexample @c ada
4316 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
4317                      On | Off [, LOCAL_NAME]);
4318 @end smallexample
4319
4320 @noindent
4321 This pragma is used in conjunction with compiler switches to control the
4322 built in style checking provided by GNAT@.  The compiler switches, if set,
4323 provide an initial setting for the switches, and this pragma may be used
4324 to modify these settings, or the settings may be provided entirely by
4325 the use of the pragma.  This pragma can be used anywhere that a pragma
4326 is legal, including use as a configuration pragma (including use in
4327 the @file{gnat.adc} file).
4328
4329 The form with a string literal specifies which style options are to be
4330 activated.  These are additive, so they apply in addition to any previously
4331 set style check options.  The codes for the options are the same as those
4332 used in the @option{-gnaty} switch to @command{gcc} or @command{gnatmake}.
4333 For example the following two methods can be used to enable
4334 layout checking:
4335
4336 @itemize @bullet
4337 @item
4338 @smallexample @c ada
4339 pragma Style_Checks ("l");
4340 @end smallexample
4341
4342 @item
4343 @smallexample
4344 gcc -c -gnatyl @dots{}
4345 @end smallexample
4346 @end itemize
4347
4348 @noindent
4349 The form ALL_CHECKS activates all standard checks (its use is equivalent
4350 to the use of the @code{gnaty} switch with no options.  @xref{Top,
4351 @value{EDITION} User's Guide, About This Guide, gnat_ugn,
4352 @value{EDITION} User's Guide}, for details.
4353
4354 The forms with @code{Off} and @code{On}
4355 can be used to temporarily disable style checks
4356 as shown in the following example:
4357
4358 @smallexample @c ada
4359 @iftex
4360 @leftskip=0cm
4361 @end iftex
4362 pragma Style_Checks ("k"); -- requires keywords in lower case
4363 pragma Style_Checks (Off); -- turn off style checks
4364 NULL;                      -- this will not generate an error message
4365 pragma Style_Checks (On);  -- turn style checks back on
4366 NULL;                      -- this will generate an error message
4367 @end smallexample
4368
4369 @noindent
4370 Finally the two argument form is allowed only if the first argument is
4371 @code{On} or @code{Off}.  The effect is to turn of semantic style checks
4372 for the specified entity, as shown in the following example:
4373
4374 @smallexample @c ada
4375 @iftex
4376 @leftskip=0cm
4377 @end iftex
4378 pragma Style_Checks ("r"); -- require consistency of identifier casing
4379 Arg : Integer;
4380 Rf1 : Integer := ARG;      -- incorrect, wrong case
4381 pragma Style_Checks (Off, Arg);
4382 Rf2 : Integer := ARG;      -- OK, no error
4383 @end smallexample
4384
4385 @node Pragma Subtitle
4386 @unnumberedsec Pragma Subtitle
4387 @findex Subtitle
4388 @noindent
4389 Syntax:
4390
4391 @smallexample @c ada
4392 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
4393 @end smallexample
4394
4395 @noindent
4396 This pragma is recognized for compatibility with other Ada compilers
4397 but is ignored by GNAT@.
4398
4399 @node Pragma Suppress
4400 @unnumberedsec Pragma Suppress
4401 @findex Suppress
4402 @noindent
4403 Syntax:
4404
4405 @smallexample @c ada
4406 pragma Suppress (Identifier [, [On =>] Name]);
4407 @end smallexample
4408
4409 @noindent
4410 This is a standard pragma, and supports all the check names required in
4411 the RM. It is included here because GNAT recognizes one additional check
4412 name: @code{Alignment_Check} which can be used to suppress alignment checks
4413 on addresses used in address clauses. Such checks can also be suppressed
4414 by suppressing range checks, but the specific use of @code{Alignment_Check}
4415 allows suppression of alignment checks without suppressing other range checks.
4416
4417 @node Pragma Suppress_All
4418 @unnumberedsec Pragma Suppress_All
4419 @findex Suppress_All
4420 @noindent
4421 Syntax:
4422
4423 @smallexample @c ada
4424 pragma Suppress_All;
4425 @end smallexample
4426
4427 @noindent
4428 This pragma can only appear immediately following a compilation
4429 unit.  The effect is to apply @code{Suppress (All_Checks)} to the unit
4430 which it follows.  This pragma is implemented for compatibility with DEC
4431 Ada 83 usage.  The use of pragma @code{Suppress (All_Checks)} as a normal
4432 configuration pragma is the preferred usage in GNAT@.
4433
4434 @node Pragma Suppress_Exception_Locations
4435 @unnumberedsec Pragma Suppress_Exception_Locations
4436 @findex Suppress_Exception_Locations
4437 @noindent
4438 Syntax:
4439
4440 @smallexample @c ada
4441 pragma Suppress_Exception_Locations;
4442 @end smallexample
4443
4444 @noindent
4445 In normal mode, a raise statement for an exception by default generates
4446 an exception message giving the file name and line number for the location
4447 of the raise. This is useful for debugging and logging purposes, but this
4448 entails extra space for the strings for the messages. The configuration
4449 pragma @code{Suppress_Exception_Locations} can be used to suppress the
4450 generation of these strings, with the result that space is saved, but the
4451 exception message for such raises is null. This configuration pragma may
4452 appear in a global configuration pragma file, or in a specific unit as
4453 usual. It is not required that this pragma be used consistently within
4454 a partition, so it is fine to have some units within a partition compiled
4455 with this pragma and others compiled in normal mode without it.
4456
4457 @node Pragma Suppress_Initialization
4458 @unnumberedsec Pragma Suppress_Initialization
4459 @findex Suppress_Initialization
4460 @cindex Suppressing initialization
4461 @cindex Initialization, suppression of
4462 @noindent
4463 Syntax:
4464
4465 @smallexample @c ada
4466 pragma Suppress_Initialization ([Entity =>] type_Name);
4467 @end smallexample
4468
4469 @noindent
4470 This pragma suppresses any implicit or explicit initialization
4471 associated with the given type name for all variables of this type.
4472
4473 @node Pragma Task_Info
4474 @unnumberedsec Pragma Task_Info
4475 @findex Task_Info
4476 @noindent
4477 Syntax
4478
4479 @smallexample @c ada
4480 pragma Task_Info (EXPRESSION);
4481 @end smallexample
4482
4483 @noindent
4484 This pragma appears within a task definition (like pragma
4485 @code{Priority}) and applies to the task in which it appears.  The
4486 argument must be of type @code{System.Task_Info.Task_Info_Type}.
4487 The @code{Task_Info} pragma provides system dependent control over
4488 aspects of tasking implementation, for example, the ability to map
4489 tasks to specific processors.  For details on the facilities available
4490 for the version of GNAT that you are using, see the documentation
4491 in the spec of package System.Task_Info in the runtime
4492 library.
4493
4494 @node Pragma Task_Name
4495 @unnumberedsec Pragma Task_Name
4496 @findex Task_Name
4497 @noindent
4498 Syntax
4499
4500 @smallexample @c ada
4501 pragma Task_Name (string_EXPRESSION);
4502 @end smallexample
4503
4504 @noindent
4505 This pragma appears within a task definition (like pragma
4506 @code{Priority}) and applies to the task in which it appears.  The
4507 argument must be of type String, and provides a name to be used for
4508 the task instance when the task is created.  Note that this expression
4509 is not required to be static, and in particular, it can contain
4510 references to task discriminants.  This facility can be used to
4511 provide different names for different tasks as they are created,
4512 as illustrated in the example below.
4513
4514 The task name is recorded internally in the run-time structures
4515 and is accessible to tools like the debugger.  In addition the
4516 routine @code{Ada.Task_Identification.Image} will return this
4517 string, with a unique task address appended.
4518
4519 @smallexample @c ada
4520 --  Example of the use of pragma Task_Name
4521
4522 with Ada.Task_Identification;
4523 use Ada.Task_Identification;
4524 with Text_IO; use Text_IO;
4525 procedure t3 is
4526
4527    type Astring is access String;
4528
4529    task type Task_Typ (Name : access String) is
4530       pragma Task_Name (Name.all);
4531    end Task_Typ;
4532
4533    task body Task_Typ is
4534       Nam : constant String := Image (Current_Task);
4535    begin
4536       Put_Line ("-->" & Nam (1 .. 14) & "<--");
4537    end Task_Typ;
4538
4539    type Ptr_Task is access Task_Typ;
4540    Task_Var : Ptr_Task;
4541
4542 begin
4543    Task_Var :=
4544      new Task_Typ (new String'("This is task 1"));
4545    Task_Var :=
4546      new Task_Typ (new String'("This is task 2"));
4547 end;
4548 @end smallexample
4549
4550 @node Pragma Task_Storage
4551 @unnumberedsec Pragma Task_Storage
4552 @findex Task_Storage
4553 Syntax:
4554
4555 @smallexample @c ada
4556 pragma Task_Storage (
4557   [Task_Type =>] LOCAL_NAME,
4558   [Top_Guard =>] static_integer_EXPRESSION);
4559 @end smallexample
4560
4561 @noindent
4562 This pragma specifies the length of the guard area for tasks.  The guard
4563 area is an additional storage area allocated to a task.  A value of zero
4564 means that either no guard area is created or a minimal guard area is
4565 created, depending on the target.  This pragma can appear anywhere a
4566 @code{Storage_Size} attribute definition clause is allowed for a task
4567 type.
4568
4569 @node Pragma Time_Slice
4570 @unnumberedsec Pragma Time_Slice
4571 @findex Time_Slice
4572 @noindent
4573 Syntax:
4574
4575 @smallexample @c ada
4576 pragma Time_Slice (static_duration_EXPRESSION);
4577 @end smallexample
4578
4579 @noindent
4580 For implementations of GNAT on operating systems where it is possible
4581 to supply a time slice value, this pragma may be used for this purpose.
4582 It is ignored if it is used in a system that does not allow this control,
4583 or if it appears in other than the main program unit.
4584 @cindex OpenVMS
4585 Note that the effect of this pragma is identical to the effect of the
4586 DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
4587
4588 @node Pragma Title
4589 @unnumberedsec Pragma Title
4590 @findex Title
4591 @noindent
4592 Syntax:
4593
4594 @smallexample @c ada
4595 pragma Title (TITLING_OPTION [, TITLING OPTION]);
4596
4597 TITLING_OPTION ::=
4598   [Title    =>] STRING_LITERAL,
4599 | [Subtitle =>] STRING_LITERAL
4600 @end smallexample
4601
4602 @noindent
4603 Syntax checked but otherwise ignored by GNAT@.  This is a listing control
4604 pragma used in DEC Ada 83 implementations to provide a title and/or
4605 subtitle for the program listing.  The program listing generated by GNAT
4606 does not have titles or subtitles.
4607
4608 Unlike other pragmas, the full flexibility of named notation is allowed
4609 for this pragma, i.e.@: the parameters may be given in any order if named
4610 notation is used, and named and positional notation can be mixed
4611 following the normal rules for procedure calls in Ada.
4612
4613 @node Pragma Unchecked_Union
4614 @unnumberedsec Pragma Unchecked_Union
4615 @cindex Unions in C
4616 @findex Unchecked_Union
4617 @noindent
4618 Syntax:
4619
4620 @smallexample @c ada
4621 pragma Unchecked_Union (first_subtype_LOCAL_NAME);
4622 @end smallexample
4623
4624 @noindent
4625 This pragma is used to specify a representation of a record type that is
4626 equivalent to a C union. It was introduced as a GNAT implementation defined
4627 pragma in the GNAT Ada 95 mode. Ada 2005 includes an extended version of this
4628 pragma, making it language defined, and GNAT fully implements this extended
4629 version in all language modes (Ada 83, Ada 95, and Ada 2005). For full
4630 details, consult the Ada 2005 Reference Manual, section B.3.3.
4631
4632 @node Pragma Unimplemented_Unit
4633 @unnumberedsec Pragma Unimplemented_Unit
4634 @findex Unimplemented_Unit
4635 @noindent
4636 Syntax:
4637
4638 @smallexample @c ada
4639 pragma Unimplemented_Unit;
4640 @end smallexample
4641
4642 @noindent
4643 If this pragma occurs in a unit that is processed by the compiler, GNAT
4644 aborts with the message @samp{@var{xxx} not implemented}, where
4645 @var{xxx} is the name of the current compilation unit.  This pragma is
4646 intended to allow the compiler to handle unimplemented library units in
4647 a clean manner.
4648
4649 The abort only happens if code is being generated.  Thus you can use
4650 specs of unimplemented packages in syntax or semantic checking mode.
4651
4652 @node Pragma Universal_Aliasing
4653 @unnumberedsec Pragma Universal_Aliasing
4654 @findex Universal_Aliasing
4655 @noindent
4656 Syntax:
4657
4658 @smallexample @c ada
4659 pragma Universal_Aliasing [([Entity =>] type_LOCAL_NAME)];
4660 @end smallexample
4661
4662 @noindent
4663 @var{type_LOCAL_NAME} must refer to a type declaration in the current
4664 declarative part.  The effect is to inhibit strict type-based aliasing
4665 optimization for the given type.  In other words, the effect is as though
4666 access types designating this type were subject to pragma No_Strict_Aliasing.
4667 For a detailed description of the strict aliasing optimization, and the
4668 situations in which it must be suppressed, @xref{Optimization and Strict
4669 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
4670
4671 @node Pragma Universal_Data
4672 @unnumberedsec Pragma Universal_Data
4673 @findex Universal_Data
4674 @noindent
4675 Syntax:
4676
4677 @smallexample @c ada
4678 pragma Universal_Data [(library_unit_Name)];
4679 @end smallexample
4680
4681 @noindent
4682 This pragma is supported only for the AAMP target and is ignored for
4683 other targets. The pragma specifies that all library-level objects
4684 (Counter 0 data) associated with the library unit are to be accessed
4685 and updated using universal addressing (24-bit addresses for AAMP5)
4686 rather than the default of 16-bit Data Environment (DENV) addressing.
4687 Use of this pragma will generally result in less efficient code for
4688 references to global data associated with the library unit, but
4689 allows such data to be located anywhere in memory. This pragma is
4690 a library unit pragma, but can also be used as a configuration pragma
4691 (including use in the @file{gnat.adc} file). The functionality
4692 of this pragma is also available by applying the -univ switch on the
4693 compilations of units where universal addressing of the data is desired.
4694
4695 @node Pragma Unmodified
4696 @unnumberedsec Pragma Unmodified
4697 @findex Unmodified
4698 @cindex Warnings, unmodified
4699 @noindent
4700 Syntax:
4701
4702 @smallexample @c ada
4703 pragma Unmodified (LOCAL_NAME @{, LOCAL_NAME@});
4704 @end smallexample
4705
4706 @noindent
4707 This pragma signals that the assignable entities (variables,
4708 @code{out} parameters, @code{in out} parameters) whose names are listed are
4709 deliberately not assigned in the current source unit. This
4710 suppresses warnings about the
4711 entities being referenced but not assigned, and in addition a warning will be
4712 generated if one of these entities is in fact assigned in the
4713 same unit as the pragma (or in the corresponding body, or one
4714 of its subunits).
4715
4716 This is particularly useful for clearly signaling that a particular
4717 parameter is not modified, even though the spec suggests that it might
4718 be.
4719
4720 @node Pragma Unreferenced
4721 @unnumberedsec Pragma Unreferenced
4722 @findex Unreferenced
4723 @cindex Warnings, unreferenced
4724 @noindent
4725 Syntax:
4726
4727 @smallexample @c ada
4728 pragma Unreferenced (LOCAL_NAME @{, LOCAL_NAME@});
4729 pragma Unreferenced (library_unit_NAME @{, library_unit_NAME@});
4730 @end smallexample
4731
4732 @noindent
4733 This pragma signals that the entities whose names are listed are
4734 deliberately not referenced in the current source unit. This
4735 suppresses warnings about the
4736 entities being unreferenced, and in addition a warning will be
4737 generated if one of these entities is in fact referenced in the
4738 same unit as the pragma (or in the corresponding body, or one
4739 of its subunits).
4740
4741 This is particularly useful for clearly signaling that a particular
4742 parameter is not referenced in some particular subprogram implementation
4743 and that this is deliberate. It can also be useful in the case of
4744 objects declared only for their initialization or finalization side
4745 effects.
4746
4747 If @code{LOCAL_NAME} identifies more than one matching homonym in the
4748 current scope, then the entity most recently declared is the one to which
4749 the pragma applies. Note that in the case of accept formals, the pragma
4750 Unreferenced may appear immediately after the keyword @code{do} which
4751 allows the indication of whether or not accept formals are referenced
4752 or not to be given individually for each accept statement.
4753
4754 The left hand side of an assignment does not count as a reference for the
4755 purpose of this pragma. Thus it is fine to assign to an entity for which
4756 pragma Unreferenced is given.
4757
4758 Note that if a warning is desired for all calls to a given subprogram,
4759 regardless of whether they occur in the same unit as the subprogram
4760 declaration, then this pragma should not be used (calls from another
4761 unit would not be flagged); pragma Obsolescent can be used instead
4762 for this purpose, see @xref{Pragma Obsolescent}.
4763
4764 The second form of pragma @code{Unreferenced} is used within a context
4765 clause. In this case the arguments must be unit names of units previously
4766 mentioned in @code{with} clauses (similar to the usage of pragma
4767 @code{Elaborate_All}. The effect is to suppress warnings about unreferenced
4768 units and unreferenced entities within these units.
4769
4770 @node Pragma Unreferenced_Objects
4771 @unnumberedsec Pragma Unreferenced_Objects
4772 @findex Unreferenced_Objects
4773 @cindex Warnings, unreferenced
4774 @noindent
4775 Syntax:
4776
4777 @smallexample @c ada
4778 pragma Unreferenced_Objects (local_subtype_NAME @{, local_subtype_NAME@});
4779 @end smallexample
4780
4781 @noindent
4782 This pragma signals that for the types or subtypes whose names are
4783 listed, objects which are declared with one of these types or subtypes may
4784 not be referenced, and if no references appear, no warnings are given.
4785
4786 This is particularly useful for objects which are declared solely for their
4787 initialization and finalization effect. Such variables are sometimes referred
4788 to as RAII variables (Resource Acquisition Is Initialization). Using this
4789 pragma on the relevant type (most typically a limited controlled type), the
4790 compiler will automatically suppress unwanted warnings about these variables
4791 not being referenced.
4792
4793 @node Pragma Unreserve_All_Interrupts
4794 @unnumberedsec Pragma Unreserve_All_Interrupts
4795 @findex Unreserve_All_Interrupts
4796 @noindent
4797 Syntax:
4798
4799 @smallexample @c ada
4800 pragma Unreserve_All_Interrupts;
4801 @end smallexample
4802
4803 @noindent
4804 Normally certain interrupts are reserved to the implementation.  Any attempt
4805 to attach an interrupt causes Program_Error to be raised, as described in
4806 RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
4807 many systems for a @kbd{Ctrl-C} interrupt.  Normally this interrupt is
4808 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
4809 interrupt execution.
4810
4811 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
4812 a program, then all such interrupts are unreserved.  This allows the
4813 program to handle these interrupts, but disables their standard
4814 functions.  For example, if this pragma is used, then pressing
4815 @kbd{Ctrl-C} will not automatically interrupt execution.  However,
4816 a program can then handle the @code{SIGINT} interrupt as it chooses.
4817
4818 For a full list of the interrupts handled in a specific implementation,
4819 see the source code for the spec of @code{Ada.Interrupts.Names} in
4820 file @file{a-intnam.ads}.  This is a target dependent file that contains the
4821 list of interrupts recognized for a given target.  The documentation in
4822 this file also specifies what interrupts are affected by the use of
4823 the @code{Unreserve_All_Interrupts} pragma.
4824
4825 For a more general facility for controlling what interrupts can be
4826 handled, see pragma @code{Interrupt_State}, which subsumes the functionality
4827 of the @code{Unreserve_All_Interrupts} pragma.
4828
4829 @node Pragma Unsuppress
4830 @unnumberedsec Pragma Unsuppress
4831 @findex Unsuppress
4832 @noindent
4833 Syntax:
4834
4835 @smallexample @c ada
4836 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
4837 @end smallexample
4838
4839 @noindent
4840 This pragma undoes the effect of a previous pragma @code{Suppress}.  If
4841 there is no corresponding pragma @code{Suppress} in effect, it has no
4842 effect.  The range of the effect is the same as for pragma
4843 @code{Suppress}.  The meaning of the arguments is identical to that used
4844 in pragma @code{Suppress}.
4845
4846 One important application is to ensure that checks are on in cases where
4847 code depends on the checks for its correct functioning, so that the code
4848 will compile correctly even if the compiler switches are set to suppress
4849 checks.
4850
4851 @node Pragma Use_VADS_Size
4852 @unnumberedsec Pragma Use_VADS_Size
4853 @cindex @code{Size}, VADS compatibility
4854 @findex Use_VADS_Size
4855 @noindent
4856 Syntax:
4857
4858 @smallexample @c ada
4859 pragma Use_VADS_Size;
4860 @end smallexample
4861
4862 @noindent
4863 This is a configuration pragma.  In a unit to which it applies, any use
4864 of the 'Size attribute is automatically interpreted as a use of the
4865 'VADS_Size attribute.  Note that this may result in incorrect semantic
4866 processing of valid Ada 95 or Ada 2005 programs.  This is intended to aid in
4867 the handling of existing code which depends on the interpretation of Size
4868 as implemented in the VADS compiler.  See description of the VADS_Size
4869 attribute for further details.
4870
4871 @node Pragma Validity_Checks
4872 @unnumberedsec Pragma Validity_Checks
4873 @findex Validity_Checks
4874 @noindent
4875 Syntax:
4876
4877 @smallexample @c ada
4878 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
4879 @end smallexample
4880
4881 @noindent
4882 This pragma is used in conjunction with compiler switches to control the
4883 built-in validity checking provided by GNAT@.  The compiler switches, if set
4884 provide an initial setting for the switches, and this pragma may be used
4885 to modify these settings, or the settings may be provided entirely by
4886 the use of the pragma.  This pragma can be used anywhere that a pragma
4887 is legal, including use as a configuration pragma (including use in
4888 the @file{gnat.adc} file).
4889
4890 The form with a string literal specifies which validity options are to be
4891 activated.  The validity checks are first set to include only the default
4892 reference manual settings, and then a string of letters in the string
4893 specifies the exact set of options required.  The form of this string
4894 is exactly as described for the @option{-gnatVx} compiler switch (see the
4895 GNAT users guide for details).  For example the following two methods
4896 can be used to enable validity checking for mode @code{in} and
4897 @code{in out} subprogram parameters:
4898
4899 @itemize @bullet
4900 @item
4901 @smallexample @c ada
4902 pragma Validity_Checks ("im");
4903 @end smallexample
4904
4905 @item
4906 @smallexample
4907 gcc -c -gnatVim @dots{}
4908 @end smallexample
4909 @end itemize
4910
4911 @noindent
4912 The form ALL_CHECKS activates all standard checks (its use is equivalent
4913 to the use of the @code{gnatva} switch.
4914
4915 The forms with @code{Off} and @code{On}
4916 can be used to temporarily disable validity checks
4917 as shown in the following example:
4918
4919 @smallexample @c ada
4920 @iftex
4921 @leftskip=0cm
4922 @end iftex
4923 pragma Validity_Checks ("c"); -- validity checks for copies
4924 pragma Validity_Checks (Off); -- turn off validity checks
4925 A := B;                       -- B will not be validity checked
4926 pragma Validity_Checks (On);  -- turn validity checks back on
4927 A := C;                       -- C will be validity checked
4928 @end smallexample
4929
4930 @node Pragma Volatile
4931 @unnumberedsec Pragma Volatile
4932 @findex Volatile
4933 @noindent
4934 Syntax:
4935
4936 @smallexample @c ada
4937 pragma Volatile (LOCAL_NAME);
4938 @end smallexample
4939
4940 @noindent
4941 This pragma is defined by the Ada Reference Manual, and the GNAT
4942 implementation is fully conformant with this definition.  The reason it
4943 is mentioned in this section is that a pragma of the same name was supplied
4944 in some Ada 83 compilers, including DEC Ada 83.  The Ada 95 / Ada 2005
4945 implementation of pragma Volatile is upwards compatible with the
4946 implementation in DEC Ada 83.
4947
4948 @node Pragma Warnings
4949 @unnumberedsec Pragma Warnings
4950 @findex Warnings
4951 @noindent
4952 Syntax:
4953
4954 @smallexample @c ada
4955 pragma Warnings (On | Off);
4956 pragma Warnings (On | Off, LOCAL_NAME);
4957 pragma Warnings (static_string_EXPRESSION);
4958 pragma Warnings (On | Off, static_string_EXPRESSION);
4959 @end smallexample
4960
4961 @noindent
4962 Normally warnings are enabled, with the output being controlled by
4963 the command line switch.  Warnings (@code{Off}) turns off generation of
4964 warnings until a Warnings (@code{On}) is encountered or the end of the
4965 current unit.  If generation of warnings is turned off using this
4966 pragma, then no warning messages are output, regardless of the
4967 setting of the command line switches.
4968
4969 The form with a single argument may be used as a configuration pragma.
4970
4971 If the @var{LOCAL_NAME} parameter is present, warnings are suppressed for
4972 the specified entity.  This suppression is effective from the point where
4973 it occurs till the end of the extended scope of the variable (similar to
4974 the scope of @code{Suppress}).
4975
4976 The form with a single static_string_EXPRESSION argument provides more precise
4977 control over which warnings are active. The string is a list of letters
4978 specifying which warnings are to be activated and which deactivated. The
4979 code for these letters is the same as the string used in the command
4980 line switch controlling warnings. The following is a brief summary. For
4981 full details see @ref{Warning Message Control,,, gnat_ugn, @value{EDITION}
4982 User's Guide}.
4983
4984 @smallexample
4985 a    turn on all optional warnings (except d h l .o)
4986 A    turn off all optional warnings
4987 .a*  turn on warnings for failing assertions
4988 .A   turn off warnings for failing assertions
4989 b    turn on warnings for bad fixed value (not multiple of small)
4990 B*   turn off warnings for bad fixed value (not multiple of small)
4991 c    turn on warnings for constant conditional
4992 C*   turn off warnings for constant conditional
4993 .c   turn on warnings for unrepped components
4994 .C*  turn off warnings for unrepped components
4995 d    turn on warnings for implicit dereference
4996 D*   turn off warnings for implicit dereference
4997 e    treat all warnings as errors
4998 f    turn on warnings for unreferenced formal
4999 F*   turn off warnings for unreferenced formal
5000 g*   turn on warnings for unrecognized pragma
5001 G    turn off warnings for unrecognized pragma
5002 h    turn on warnings for hiding variable
5003 H*   turn off warnings for hiding variable
5004 i*   turn on warnings for implementation unit
5005 I    turn off warnings for implementation unit
5006 j    turn on warnings for obsolescent (annex J) feature
5007 J*   turn off warnings for obsolescent (annex J) feature
5008 k    turn on warnings on constant variable
5009 K*   turn off warnings on constant variable
5010 l    turn on warnings for missing elaboration pragma
5011 L*   turn off warnings for missing elaboration pragma
5012 m    turn on warnings for variable assigned but not read
5013 M*   turn off warnings for variable assigned but not read
5014 n*   normal warning mode (cancels -gnatws/-gnatwe)
5015 o*   turn on warnings for address clause overlay
5016 O    turn off warnings for address clause overlay
5017 .o   turn on warnings for out parameters assigned but not read
5018 .O*  turn off warnings for out parameters assigned but not read
5019 p    turn on warnings for ineffective pragma Inline in frontend
5020 P*   turn off warnings for ineffective pragma Inline in frontend
5021 q*   turn on warnings for questionable missing parentheses
5022 Q    turn off warnings for questionable missing parentheses
5023 r    turn on warnings for redundant construct
5024 R*   turn off warnings for redundant construct
5025 .r   turn on warnings for object renaming function
5026 .R*  turn off warnings for object renaming function
5027 s    suppress all warnings
5028 t    turn on warnings for tracking deleted code
5029 T*   turn off warnings for tracking deleted code
5030 u    turn on warnings for unused entity
5031 U*   turn off warnings for unused entity
5032 v*   turn on warnings for unassigned variable
5033 V    turn off warnings for unassigned variable
5034 w*   turn on warnings for wrong low bound assumption
5035 W    turn off warnings for wrong low bound assumption
5036 x*   turn on warnings for export/import
5037 X    turn off warnings for export/import
5038 .x   turn on warnings for non-local exceptions
5039 .X*  turn off warnings for non-local exceptions
5040 y*   turn on warnings for Ada 2005 incompatibility
5041 Y    turn off warnings for Ada 2005 incompatibility
5042 z*   turn on convention/size/align warnings for unchecked conversion
5043 Z    turn off convention/size/align warnings for unchecked conversion
5044 *    indicates default in above list
5045 @end smallexample
5046
5047 @noindent
5048 The specified warnings will be in effect until the end of the program
5049 or another pragma Warnings is encountered. The effect of the pragma is
5050 cumulative. Initially the set of warnings is the standard default set
5051 as possibly modified by compiler switches. Then each pragma Warning
5052 modifies this set of warnings as specified. This form of the pragma may
5053 also be used as a configuration pragma.
5054
5055 The fourth form, with an On|Off parameter and a string, is used to
5056 control individual messages, based on their text. The string argument
5057 is a pattern that is used to match against the text of individual
5058 warning messages (not including the initial "warnings: " tag).
5059
5060 The pattern may contain asterisks which match zero or more characters in
5061 the message. For example, you can use
5062 @code{pragma Warnings (Off, "*bits of*unused")} to suppress the warning
5063 message @code{warning: 960 bits of "a" unused}. No other regular
5064 expression notations are permitted. All characters other than asterisk in
5065 these three specific cases are treated as literal characters in the match.
5066
5067 There are two ways to use this pragma. The OFF form can be used as a
5068 configuration pragma. The effect is to suppress all warnings (if any)
5069 that match the pattern string throughout the compilation.
5070
5071 The second usage is to suppress a warning locally, and in this case, two
5072 pragmas must appear in sequence:
5073
5074 @smallexample @c ada
5075 pragma Warnings (Off, Pattern);
5076 @dots{} code where given warning is to be suppressed
5077 pragma Warnings (On, Pattern);
5078 @end smallexample
5079
5080 @noindent
5081 In this usage, the pattern string must match in the Off and On pragmas,
5082 and at least one matching warning must be suppressed.
5083
5084 @node Pragma Weak_External
5085 @unnumberedsec Pragma Weak_External
5086 @findex Weak_External
5087 @noindent
5088 Syntax:
5089
5090 @smallexample @c ada
5091 pragma Weak_External ([Entity =>] LOCAL_NAME);
5092 @end smallexample
5093
5094 @noindent
5095 @var{LOCAL_NAME} must refer to an object that is declared at the library
5096 level. This pragma specifies that the given entity should be marked as a
5097 weak symbol for the linker. It is equivalent to @code{__attribute__((weak))}
5098 in GNU C and causes @var{LOCAL_NAME} to be emitted as a weak symbol instead
5099 of a regular symbol, that is to say a symbol that does not have to be
5100 resolved by the linker if used in conjunction with a pragma Import.
5101
5102 When a weak symbol is not resolved by the linker, its address is set to
5103 zero. This is useful in writing interfaces to external modules that may
5104 or may not be linked in the final executable, for example depending on
5105 configuration settings.
5106
5107 If a program references at run time an entity to which this pragma has been
5108 applied, and the corresponding symbol was not resolved at link time, then
5109 the execution of the program is erroneous. It is not erroneous to take the
5110 Address of such an entity, for example to guard potential references,
5111 as shown in the example below.
5112
5113 Some file formats do not support weak symbols so not all target machines
5114 support this pragma.
5115
5116 @smallexample @c ada
5117 --  Example of the use of pragma Weak_External
5118
5119 package External_Module is
5120   key : Integer;
5121   pragma Import (C, key);
5122   pragma Weak_External (key);
5123   function Present return boolean;
5124 end External_Module;
5125
5126 with System; use System;
5127 package body External_Module is
5128   function Present return boolean is
5129   begin
5130     return key'Address /= System.Null_Address;
5131   end Present;
5132 end External_Module;
5133 @end smallexample
5134
5135 @node Pragma Wide_Character_Encoding
5136 @unnumberedsec Pragma Wide_Character_Encoding
5137 @findex Wide_Character_Encoding
5138 @noindent
5139 Syntax:
5140
5141 @smallexample @c ada
5142 pragma Wide_Character_Encoding (IDENTIFIER | CHARACTER_LITERAL);
5143 @end smallexample
5144
5145 @noindent
5146 This pragma specifies the wide character encoding to be used in program
5147 source text appearing subsequently. It is a configuration pragma, but may
5148 also be used at any point that a pragma is allowed, and it is permissible
5149 to have more than one such pragma in a file, allowing multiple encodings
5150 to appear within the same file.
5151
5152 The argument can be an identifier or a character literal. In the identifier
5153 case, it is one of @code{HEX}, @code{UPPER}, @code{SHIFT_JIS},
5154 @code{EUC}, @code{UTF8}, or @code{BRACKETS}. In the character literal
5155 case it is correspondingly one of the characters @samp{h}, @samp{u},
5156 @samp{s}, @samp{e}, @samp{8}, or @samp{b}.
5157
5158 Note that when the pragma is used within a file, it affects only the
5159 encoding within that file, and does not affect withed units, specs,
5160 or subunits.
5161
5162 @node Implementation Defined Attributes
5163 @chapter Implementation Defined Attributes
5164 Ada defines (throughout the Ada reference manual,
5165 summarized in Annex K),
5166 a set of attributes that provide useful additional functionality in all
5167 areas of the language.  These language defined attributes are implemented
5168 in GNAT and work as described in the Ada Reference Manual.
5169
5170 In addition, Ada allows implementations to define additional
5171 attributes whose meaning is defined by the implementation.  GNAT provides
5172 a number of these implementation-dependent attributes which can be used
5173 to extend and enhance the functionality of the compiler.  This section of
5174 the GNAT reference manual describes these additional attributes.
5175
5176 Note that any program using these attributes may not be portable to
5177 other compilers (although GNAT implements this set of attributes on all
5178 platforms).  Therefore if portability to other compilers is an important
5179 consideration, you should minimize the use of these attributes.
5180
5181 @menu
5182 * Abort_Signal::
5183 * Address_Size::
5184 * Asm_Input::
5185 * Asm_Output::
5186 * AST_Entry::
5187 * Bit::
5188 * Bit_Position::
5189 * Code_Address::
5190 * Default_Bit_Order::
5191 * Elaborated::
5192 * Elab_Body::
5193 * Elab_Spec::
5194 * Emax::
5195 * Enabled::
5196 * Enum_Rep::
5197 * Enum_Val::
5198 * Epsilon::
5199 * Fixed_Value::
5200 * Has_Access_Values::
5201 * Has_Discriminants::
5202 * Img::
5203 * Integer_Value::
5204 * Invalid_Value::
5205 * Large::
5206 * Machine_Size::
5207 * Mantissa::
5208 * Max_Interrupt_Priority::
5209 * Max_Priority::
5210 * Maximum_Alignment::
5211 * Mechanism_Code::
5212 * Null_Parameter::
5213 * Object_Size::
5214 * Old::
5215 * Passed_By_Reference::
5216 * Pool_Address::
5217 * Range_Length::
5218 * Safe_Emax::
5219 * Safe_Large::
5220 * Small::
5221 * Storage_Unit::
5222 * Stub_Type::
5223 * Target_Name::
5224 * Tick::
5225 * To_Address::
5226 * Type_Class::
5227 * UET_Address::
5228 * Unconstrained_Array::
5229 * Universal_Literal_String::
5230 * Unrestricted_Access::
5231 * VADS_Size::
5232 * Value_Size::
5233 * Wchar_T_Size::
5234 * Word_Size::
5235 @end menu
5236
5237 @node Abort_Signal
5238 @unnumberedsec Abort_Signal
5239 @findex Abort_Signal
5240 @noindent
5241 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
5242 prefix) provides the entity for the special exception used to signal
5243 task abort or asynchronous transfer of control.  Normally this attribute
5244 should only be used in the tasking runtime (it is highly peculiar, and
5245 completely outside the normal semantics of Ada, for a user program to
5246 intercept the abort exception).
5247
5248 @node Address_Size
5249 @unnumberedsec Address_Size
5250 @cindex Size of @code{Address}
5251 @findex Address_Size
5252 @noindent
5253 @code{Standard'Address_Size} (@code{Standard} is the only allowed
5254 prefix) is a static constant giving the number of bits in an
5255 @code{Address}. It is the same value as System.Address'Size,
5256 but has the advantage of being static, while a direct
5257 reference to System.Address'Size is non-static because Address
5258 is a private type.
5259
5260 @node Asm_Input
5261 @unnumberedsec Asm_Input
5262 @findex Asm_Input
5263 @noindent
5264 The @code{Asm_Input} attribute denotes a function that takes two
5265 parameters.  The first is a string, the second is an expression of the
5266 type designated by the prefix.  The first (string) argument is required
5267 to be a static expression, and is the constraint for the parameter,
5268 (e.g.@: what kind of register is required).  The second argument is the
5269 value to be used as the input argument.  The possible values for the
5270 constant are the same as those used in the RTL, and are dependent on
5271 the configuration file used to built the GCC back end.
5272 @ref{Machine Code Insertions}
5273
5274 @node Asm_Output
5275 @unnumberedsec Asm_Output
5276 @findex Asm_Output
5277 @noindent
5278 The @code{Asm_Output} attribute denotes a function that takes two
5279 parameters.  The first is a string, the second is the name of a variable
5280 of the type designated by the attribute prefix.  The first (string)
5281 argument is required to be a static expression and designates the
5282 constraint for the parameter (e.g.@: what kind of register is
5283 required).  The second argument is the variable to be updated with the
5284 result.  The possible values for constraint are the same as those used in
5285 the RTL, and are dependent on the configuration file used to build the
5286 GCC back end.  If there are no output operands, then this argument may
5287 either be omitted, or explicitly given as @code{No_Output_Operands}.
5288 @ref{Machine Code Insertions}
5289
5290 @node AST_Entry
5291 @unnumberedsec AST_Entry
5292 @cindex OpenVMS
5293 @findex AST_Entry
5294 @noindent
5295 This attribute is implemented only in OpenVMS versions of GNAT@.  Applied to
5296 the name of an entry, it yields a value of the predefined type AST_Handler
5297 (declared in the predefined package System, as extended by the use of
5298 pragma @code{Extend_System (Aux_DEC)}).  This value enables the given entry to
5299 be called when an AST occurs.  For further details, refer to the @cite{DEC Ada
5300 Language Reference Manual}, section 9.12a.
5301
5302 @node Bit
5303 @unnumberedsec Bit
5304 @findex Bit
5305 @code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
5306 offset within the storage unit (byte) that contains the first bit of
5307 storage allocated for the object.  The value of this attribute is of the
5308 type @code{Universal_Integer}, and is always a non-negative number not
5309 exceeding the value of @code{System.Storage_Unit}.
5310
5311 For an object that is a variable or a constant allocated in a register,
5312 the value is zero.  (The use of this attribute does not force the
5313 allocation of a variable to memory).
5314
5315 For an object that is a formal parameter, this attribute applies
5316 to either the matching actual parameter or to a copy of the
5317 matching actual parameter.
5318
5319 For an access object the value is zero.  Note that
5320 @code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
5321 designated object.  Similarly for a record component
5322 @code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
5323 @code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
5324 are subject to index checks.
5325
5326 This attribute is designed to be compatible with the DEC Ada 83 definition
5327 and implementation of the @code{Bit} attribute.
5328
5329 @node Bit_Position
5330 @unnumberedsec Bit_Position
5331 @findex Bit_Position
5332 @noindent
5333 @code{@var{R.C}'Bit}, where @var{R} is a record object and C is one
5334 of the fields of the record type, yields the bit
5335 offset within the record contains the first bit of
5336 storage allocated for the object.  The value of this attribute is of the
5337 type @code{Universal_Integer}.  The value depends only on the field
5338 @var{C} and is independent of the alignment of
5339 the containing record @var{R}.
5340
5341 @node Code_Address
5342 @unnumberedsec Code_Address
5343 @findex Code_Address
5344 @cindex Subprogram address
5345 @cindex Address of subprogram code
5346 @noindent
5347 The @code{'Address}
5348 attribute may be applied to subprograms in Ada 95 and Ada 2005, but the
5349 intended effect seems to be to provide
5350 an address value which can be used to call the subprogram by means of
5351 an address clause as in the following example:
5352
5353 @smallexample @c ada
5354 procedure K is @dots{}
5355
5356 procedure L;
5357 for L'Address use K'Address;
5358 pragma Import (Ada, L);
5359 @end smallexample
5360
5361 @noindent
5362 A call to @code{L} is then expected to result in a call to @code{K}@.
5363 In Ada 83, where there were no access-to-subprogram values, this was
5364 a common work-around for getting the effect of an indirect call.
5365 GNAT implements the above use of @code{Address} and the technique
5366 illustrated by the example code works correctly.
5367
5368 However, for some purposes, it is useful to have the address of the start
5369 of the generated code for the subprogram.  On some architectures, this is
5370 not necessarily the same as the @code{Address} value described above.
5371 For example, the @code{Address} value may reference a subprogram
5372 descriptor rather than the subprogram itself.
5373
5374 The @code{'Code_Address} attribute, which can only be applied to
5375 subprogram entities, always returns the address of the start of the
5376 generated code of the specified subprogram, which may or may not be
5377 the same value as is returned by the corresponding @code{'Address}
5378 attribute.
5379
5380 @node Default_Bit_Order
5381 @unnumberedsec Default_Bit_Order
5382 @cindex Big endian
5383 @cindex Little endian
5384 @findex Default_Bit_Order
5385 @noindent
5386 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
5387 permissible prefix), provides the value @code{System.Default_Bit_Order}
5388 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
5389 @code{Low_Order_First}).  This is used to construct the definition of
5390 @code{Default_Bit_Order} in package @code{System}.
5391
5392 @node Elaborated
5393 @unnumberedsec Elaborated
5394 @findex Elaborated
5395 @noindent
5396 The prefix of the @code{'Elaborated} attribute must be a unit name.  The
5397 value is a Boolean which indicates whether or not the given unit has been
5398 elaborated.  This attribute is primarily intended for internal use by the
5399 generated code for dynamic elaboration checking, but it can also be used
5400 in user programs.  The value will always be True once elaboration of all
5401 units has been completed.  An exception is for units which need no
5402 elaboration, the value is always False for such units.
5403
5404 @node Elab_Body
5405 @unnumberedsec Elab_Body
5406 @findex Elab_Body
5407 @noindent
5408 This attribute can only be applied to a program unit name.  It returns
5409 the entity for the corresponding elaboration procedure for elaborating
5410 the body of the referenced unit.  This is used in the main generated
5411 elaboration procedure by the binder and is not normally used in any
5412 other context.  However, there may be specialized situations in which it
5413 is useful to be able to call this elaboration procedure from Ada code,
5414 e.g.@: if it is necessary to do selective re-elaboration to fix some
5415 error.
5416
5417 @node Elab_Spec
5418 @unnumberedsec Elab_Spec
5419 @findex Elab_Spec
5420 @noindent
5421 This attribute can only be applied to a program unit name.  It returns
5422 the entity for the corresponding elaboration procedure for elaborating
5423 the spec of the referenced unit.  This is used in the main
5424 generated elaboration procedure by the binder and is not normally used
5425 in any other context.  However, there may be specialized situations in
5426 which it is useful to be able to call this elaboration procedure from
5427 Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
5428 some error.
5429
5430 @node Emax
5431 @unnumberedsec Emax
5432 @cindex Ada 83 attributes
5433 @findex Emax
5434 @noindent
5435 The @code{Emax} attribute is provided for compatibility with Ada 83.  See
5436 the Ada 83 reference manual for an exact description of the semantics of
5437 this attribute.
5438
5439 @node Enabled
5440 @unnumberedsec Enabled
5441 @findex Enabled
5442 @noindent
5443 The @code{Enabled} attribute allows an application program to check at compile
5444 time to see if the designated check is currently enabled. The prefix is a
5445 simple identifier, referencing any predefined check name (other than
5446 @code{All_Checks}) or a check name introduced by pragma Check_Name. If
5447 no argument is given for the attribute, the check is for the general state
5448 of the check, if an argument is given, then it is an entity name, and the
5449 check indicates whether an @code{Suppress} or @code{Unsuppress} has been
5450 given naming the entity (if not, then the argument is ignored).
5451
5452 Note that instantiations inherit the check status at the point of the
5453 instantiation, so a useful idiom is to have a library package that
5454 introduces a check name with @code{pragma Check_Name}, and then contains
5455 generic packages or subprograms which use the @code{Enabled} attribute
5456 to see if the check is enabled. A user of this package can then issue
5457 a @code{pragma Suppress} or @code{pragma Unsuppress} before instantiating
5458 the package or subprogram, controlling whether the check will be present.
5459
5460 @node Enum_Rep
5461 @unnumberedsec Enum_Rep
5462 @cindex Representation of enums
5463 @findex Enum_Rep
5464 @noindent
5465 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
5466 function with the following spec:
5467
5468 @smallexample @c ada
5469 function @var{S}'Enum_Rep (Arg : @var{S}'Base)
5470   return @i{Universal_Integer};
5471 @end smallexample
5472
5473 @noindent
5474 It is also allowable to apply @code{Enum_Rep} directly to an object of an
5475 enumeration type or to a non-overloaded enumeration
5476 literal.  In this case @code{@var{S}'Enum_Rep} is equivalent to
5477 @code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
5478 enumeration literal or object.
5479
5480 The function returns the representation value for the given enumeration
5481 value.  This will be equal to value of the @code{Pos} attribute in the
5482 absence of an enumeration representation clause.  This is a static
5483 attribute (i.e.@: the result is static if the argument is static).
5484
5485 @code{@var{S}'Enum_Rep} can also be used with integer types and objects,
5486 in which case it simply returns the integer value.  The reason for this
5487 is to allow it to be used for @code{(<>)} discrete formal arguments in
5488 a generic unit that can be instantiated with either enumeration types
5489 or integer types.  Note that if @code{Enum_Rep} is used on a modular
5490 type whose upper bound exceeds the upper bound of the largest signed
5491 integer type, and the argument is a variable, so that the universal
5492 integer calculation is done at run time, then the call to @code{Enum_Rep}
5493 may raise @code{Constraint_Error}.
5494
5495 @node Enum_Val
5496 @unnumberedsec Enum_Val
5497 @cindex Representation of enums
5498 @findex Enum_Val
5499 @noindent
5500 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
5501 function with the following spec:
5502
5503 @smallexample @c ada
5504 function @var{S}'Enum_Rep (Arg : @i{Universal_Integer)
5505   return @var{S}'Base};
5506 @end smallexample
5507
5508 @noindent
5509 The function returns the enumeration value whose representation matches the
5510 argument, or raises Constraint_Error if no enumeration literal of the type
5511 has the matching value.
5512 This will be equal to value of the @code{Val} attribute in the
5513 absence of an enumeration representation clause.  This is a static
5514 attribute (i.e.@: the result is static if the argument is static).
5515
5516 @node Epsilon
5517 @unnumberedsec Epsilon
5518 @cindex Ada 83 attributes
5519 @findex Epsilon
5520 @noindent
5521 The @code{Epsilon} attribute is provided for compatibility with Ada 83.  See
5522 the Ada 83 reference manual for an exact description of the semantics of
5523 this attribute.
5524
5525 @node Fixed_Value
5526 @unnumberedsec Fixed_Value
5527 @findex Fixed_Value
5528 @noindent
5529 For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
5530 function with the following specification:
5531
5532 @smallexample @c ada
5533 function @var{S}'Fixed_Value (Arg : @i{Universal_Integer})
5534   return @var{S};
5535 @end smallexample
5536
5537 @noindent
5538 The value returned is the fixed-point value @var{V} such that
5539
5540 @smallexample @c ada
5541 @var{V} = Arg * @var{S}'Small
5542 @end smallexample
5543
5544 @noindent
5545 The effect is thus similar to first converting the argument to the
5546 integer type used to represent @var{S}, and then doing an unchecked
5547 conversion to the fixed-point type.  The difference is
5548 that there are full range checks, to ensure that the result is in range.
5549 This attribute is primarily intended for use in implementation of the
5550 input-output functions for fixed-point values.
5551
5552 @node Has_Access_Values
5553 @unnumberedsec Has_Access_Values
5554 @cindex Access values, testing for
5555 @findex Has_Access_Values
5556 @noindent
5557 The prefix of the @code{Has_Access_Values} attribute is a type.  The result
5558 is a Boolean value which is True if the is an access type, or is a composite
5559 type with a component (at any nesting depth) that is an access type, and is
5560 False otherwise.
5561 The intended use of this attribute is in conjunction with generic
5562 definitions.  If the attribute is applied to a generic private type, it
5563 indicates whether or not the corresponding actual type has access values.
5564
5565 @node Has_Discriminants
5566 @unnumberedsec Has_Discriminants
5567 @cindex Discriminants, testing for
5568 @findex Has_Discriminants
5569 @noindent
5570 The prefix of the @code{Has_Discriminants} attribute is a type.  The result
5571 is a Boolean value which is True if the type has discriminants, and False
5572 otherwise.  The intended use of this attribute is in conjunction with generic
5573 definitions.  If the attribute is applied to a generic private type, it
5574 indicates whether or not the corresponding actual type has discriminants.
5575
5576 @node Img
5577 @unnumberedsec Img
5578 @findex Img
5579 @noindent
5580 The @code{Img} attribute differs from @code{Image} in that it may be
5581 applied to objects as well as types, in which case it gives the
5582 @code{Image} for the subtype of the object.  This is convenient for
5583 debugging:
5584
5585 @smallexample @c ada
5586 Put_Line ("X = " & X'Img);
5587 @end smallexample
5588
5589 @noindent
5590 has the same meaning as the more verbose:
5591
5592 @smallexample @c ada
5593 Put_Line ("X = " & @var{T}'Image (X));
5594 @end smallexample
5595
5596 @noindent
5597 where @var{T} is the (sub)type of the object @code{X}.
5598
5599 @node Integer_Value
5600 @unnumberedsec Integer_Value
5601 @findex Integer_Value
5602 @noindent
5603 For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
5604 function with the following spec:
5605
5606 @smallexample @c ada
5607 function @var{S}'Integer_Value (Arg : @i{Universal_Fixed})
5608   return @var{S};
5609 @end smallexample
5610
5611 @noindent
5612 The value returned is the integer value @var{V}, such that
5613
5614 @smallexample @c ada
5615 Arg = @var{V} * @var{T}'Small
5616 @end smallexample
5617
5618 @noindent
5619 where @var{T} is the type of @code{Arg}.
5620 The effect is thus similar to first doing an unchecked conversion from
5621 the fixed-point type to its corresponding implementation type, and then
5622 converting the result to the target integer type.  The difference is
5623 that there are full range checks, to ensure that the result is in range.
5624 This attribute is primarily intended for use in implementation of the
5625 standard input-output functions for fixed-point values.
5626
5627 @node Invalid_Value
5628 @unnumberedsec Invalid_Value
5629 @findex Invalid_Value
5630 @noindent
5631 For every scalar type S, S'Invalid_Value returns an undefined value of the
5632 type. If possible this value is an invalid representation for the type. The
5633 value returned is identical to the value used to initialize an otherwise
5634 uninitialized value of the type if pragma Initialize_Scalars is used,
5635 including the ability to modify the value with the binder -Sxx flag and
5636 relevant environment variables at run time.
5637
5638 @node Large
5639 @unnumberedsec Large
5640 @cindex Ada 83 attributes
5641 @findex Large
5642 @noindent
5643 The @code{Large} attribute is provided for compatibility with Ada 83.  See
5644 the Ada 83 reference manual for an exact description of the semantics of
5645 this attribute.
5646
5647 @node Machine_Size
5648 @unnumberedsec Machine_Size
5649 @findex Machine_Size
5650 @noindent
5651 This attribute is identical to the @code{Object_Size} attribute.  It is
5652 provided for compatibility with the DEC Ada 83 attribute of this name.
5653
5654 @node Mantissa
5655 @unnumberedsec Mantissa
5656 @cindex Ada 83 attributes
5657 @findex Mantissa
5658 @noindent
5659 The @code{Mantissa} attribute is provided for compatibility with Ada 83.  See
5660 the Ada 83 reference manual for an exact description of the semantics of
5661 this attribute.
5662
5663 @node Max_Interrupt_Priority
5664 @unnumberedsec Max_Interrupt_Priority
5665 @cindex Interrupt priority, maximum
5666 @findex Max_Interrupt_Priority
5667 @noindent
5668 @code{Standard'Max_Interrupt_Priority} (@code{Standard} is the only
5669 permissible prefix), provides the same value as
5670 @code{System.Max_Interrupt_Priority}.
5671
5672 @node Max_Priority
5673 @unnumberedsec Max_Priority
5674 @cindex Priority, maximum
5675 @findex Max_Priority
5676 @noindent
5677 @code{Standard'Max_Priority} (@code{Standard} is the only permissible
5678 prefix) provides the same value as @code{System.Max_Priority}.
5679
5680 @node Maximum_Alignment
5681 @unnumberedsec Maximum_Alignment
5682 @cindex Alignment, maximum
5683 @findex Maximum_Alignment
5684 @noindent
5685 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
5686 permissible prefix) provides the maximum useful alignment value for the
5687 target.  This is a static value that can be used to specify the alignment
5688 for an object, guaranteeing that it is properly aligned in all
5689 cases.
5690
5691 @node Mechanism_Code
5692 @unnumberedsec Mechanism_Code
5693 @cindex Return values, passing mechanism
5694 @cindex Parameters, passing mechanism
5695 @findex Mechanism_Code
5696 @noindent
5697 @code{@var{function}'Mechanism_Code} yields an integer code for the
5698 mechanism used for the result of function, and
5699 @code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
5700 used for formal parameter number @var{n} (a static integer value with 1
5701 meaning the first parameter) of @var{subprogram}.  The code returned is:
5702
5703 @table @asis
5704 @item 1
5705 by copy (value)
5706 @item 2
5707 by reference
5708 @item 3
5709 by descriptor (default descriptor class)
5710 @item 4
5711 by descriptor (UBS: unaligned bit string)
5712 @item 5
5713 by descriptor (UBSB: aligned bit string with arbitrary bounds)
5714 @item 6
5715 by descriptor (UBA: unaligned bit array)
5716 @item 7
5717 by descriptor (S: string, also scalar access type parameter)
5718 @item 8
5719 by descriptor (SB: string with arbitrary bounds)
5720 @item 9
5721 by descriptor (A: contiguous array)
5722 @item 10
5723 by descriptor (NCA: non-contiguous array)
5724 @end table
5725
5726 @noindent
5727 Values from 3 through 10 are only relevant to Digital OpenVMS implementations.
5728 @cindex OpenVMS
5729
5730 @node Null_Parameter
5731 @unnumberedsec Null_Parameter
5732 @cindex Zero address, passing
5733 @findex Null_Parameter
5734 @noindent
5735 A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
5736 type or subtype @var{T} allocated at machine address zero.  The attribute
5737 is allowed only as the default expression of a formal parameter, or as
5738 an actual expression of a subprogram call.  In either case, the
5739 subprogram must be imported.
5740
5741 The identity of the object is represented by the address zero in the
5742 argument list, independent of the passing mechanism (explicit or
5743 default).
5744
5745 This capability is needed to specify that a zero address should be
5746 passed for a record or other composite object passed by reference.
5747 There is no way of indicating this without the @code{Null_Parameter}
5748 attribute.
5749
5750 @node Object_Size
5751 @unnumberedsec Object_Size
5752 @cindex Size, used for objects
5753 @findex Object_Size
5754 @noindent
5755 The size of an object is not necessarily the same as the size of the type
5756 of an object.  This is because by default object sizes are increased to be
5757 a multiple of the alignment of the object.  For example,
5758 @code{Natural'Size} is
5759 31, but by default objects of type @code{Natural} will have a size of 32 bits.
5760 Similarly, a record containing an integer and a character:
5761
5762 @smallexample @c ada
5763 type Rec is record
5764    I : Integer;
5765    C : Character;
5766 end record;
5767 @end smallexample
5768
5769 @noindent
5770 will have a size of 40 (that is @code{Rec'Size} will be 40.  The
5771 alignment will be 4, because of the
5772 integer field, and so the default size of record objects for this type
5773 will be 64 (8 bytes).
5774
5775 @node Old
5776 @unnumberedsec Old
5777 @cindex Capturing Old values
5778 @cindex Postconditions
5779 @noindent
5780 The attribute Prefix'Old can be used within a
5781 subprogram to refer to the value of the prefix on entry. So for
5782 example if you have an argument of a record type X called Arg1,
5783 you can refer to Arg1.Field'Old which yields the value of
5784 Arg1.Field on entry. The implementation simply involves generating
5785 an object declaration which captures the value on entry. Any
5786 prefix is allowed except one of a limited type (since limited
5787 types cannot be copied to capture their values) or a local variable
5788 (since it does not exist at subprogram entry time).
5789
5790 The following example shows the use of 'Old to implement
5791 a test of a postcondition:
5792
5793 @smallexample @c ada
5794 with Old_Pkg;
5795 procedure Old is
5796 begin
5797    Old_Pkg.Incr;
5798 end Old;
5799
5800 package Old_Pkg is
5801    procedure Incr;
5802 end Old_Pkg;
5803
5804 package body Old_Pkg is
5805    Count : Natural := 0;
5806
5807    procedure Incr is
5808    begin
5809       ... code manipulating the value of Count
5810
5811       pragma Assert (Count = Count'Old + 1);
5812    end Incr;
5813 end Old_Pkg;
5814 @end smallexample
5815
5816 @noindent
5817 Note that it is allowed to apply 'Old to a constant entity, but this will
5818 result in a warning, since the old and new values will always be the same.
5819
5820 @node Passed_By_Reference
5821 @unnumberedsec Passed_By_Reference
5822 @cindex Parameters, when passed by reference
5823 @findex Passed_By_Reference
5824 @noindent
5825 @code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
5826 a value of type @code{Boolean} value that is @code{True} if the type is
5827 normally passed by reference and @code{False} if the type is normally
5828 passed by copy in calls.  For scalar types, the result is always @code{False}
5829 and is static.  For non-scalar types, the result is non-static.
5830
5831 @node Pool_Address
5832 @unnumberedsec Pool_Address
5833 @cindex Parameters, when passed by reference
5834 @findex Pool_Address
5835 @noindent
5836 @code{@var{X}'Pool_Address} for any object @var{X} returns the address
5837 of X within its storage pool. This is the same as
5838 @code{@var{X}'Address}, except that for an unconstrained array whose
5839 bounds are allocated just before the first component,
5840 @code{@var{X}'Pool_Address} returns the address of those bounds,
5841 whereas @code{@var{X}'Address} returns the address of the first
5842 component.
5843
5844 Here, we are interpreting ``storage pool'' broadly to mean ``wherever
5845 the object is allocated'', which could be a user-defined storage pool,
5846 the global heap, on the stack, or in a static memory area. For an
5847 object created by @code{new}, @code{@var{Ptr.all}'Pool_Address} is
5848 what is passed to @code{Allocate} and returned from @code{Deallocate}.
5849
5850 @node Range_Length
5851 @unnumberedsec Range_Length
5852 @findex Range_Length
5853 @noindent
5854 @code{@var{type}'Range_Length} for any discrete type @var{type} yields
5855 the number of values represented by the subtype (zero for a null
5856 range).  The result is static for static subtypes.  @code{Range_Length}
5857 applied to the index subtype of a one dimensional array always gives the
5858 same result as @code{Range} applied to the array itself.
5859
5860 @node Safe_Emax
5861 @unnumberedsec Safe_Emax
5862 @cindex Ada 83 attributes
5863 @findex Safe_Emax
5864 @noindent
5865 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83.  See
5866 the Ada 83 reference manual for an exact description of the semantics of
5867 this attribute.
5868
5869 @node Safe_Large
5870 @unnumberedsec Safe_Large
5871 @cindex Ada 83 attributes
5872 @findex Safe_Large
5873 @noindent
5874 The @code{Safe_Large} attribute is provided for compatibility with Ada 83.  See
5875 the Ada 83 reference manual for an exact description of the semantics of
5876 this attribute.
5877
5878 @node Small
5879 @unnumberedsec Small
5880 @cindex Ada 83 attributes
5881 @findex Small
5882 @noindent
5883 The @code{Small} attribute is defined in Ada 95 (and Ada 2005) only for
5884 fixed-point types.
5885 GNAT also allows this attribute to be applied to floating-point types
5886 for compatibility with Ada 83.  See
5887 the Ada 83 reference manual for an exact description of the semantics of
5888 this attribute when applied to floating-point types.
5889
5890 @node Storage_Unit
5891 @unnumberedsec Storage_Unit
5892 @findex Storage_Unit
5893 @noindent
5894 @code{Standard'Storage_Unit} (@code{Standard} is the only permissible
5895 prefix) provides the same value as @code{System.Storage_Unit}.
5896
5897 @node Stub_Type
5898 @unnumberedsec Stub_Type
5899 @findex Stub_Type
5900 @noindent
5901 The GNAT implementation of remote access-to-classwide types is
5902 organized as described in AARM section E.4 (20.t): a value of an RACW type
5903 (designating a remote object) is represented as a normal access
5904 value, pointing to a "stub" object which in turn contains the
5905 necessary information to contact the designated remote object. A
5906 call on any dispatching operation of such a stub object does the
5907 remote call, if necessary, using the information in the stub object
5908 to locate the target partition, etc.
5909
5910 For a prefix @code{T} that denotes a remote access-to-classwide type,
5911 @code{T'Stub_Type} denotes the type of the corresponding stub objects.
5912
5913 By construction, the layout of @code{T'Stub_Type} is identical to that of
5914 type @code{RACW_Stub_Type} declared in the internal implementation-defined
5915 unit @code{System.Partition_Interface}. Use of this attribute will create
5916 an implicit dependency on this unit.
5917
5918 @node Target_Name
5919 @unnumberedsec Target_Name
5920 @findex Target_Name
5921 @noindent
5922 @code{Standard'Target_Name} (@code{Standard} is the only permissible
5923 prefix) provides a static string value that identifies the target
5924 for the current compilation. For GCC implementations, this is the
5925 standard gcc target name without the terminating slash (for
5926 example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
5927
5928 @node Tick
5929 @unnumberedsec Tick
5930 @findex Tick
5931 @noindent
5932 @code{Standard'Tick} (@code{Standard} is the only permissible prefix)
5933 provides the same value as @code{System.Tick},
5934
5935 @node To_Address
5936 @unnumberedsec To_Address
5937 @findex To_Address
5938 @noindent
5939 The @code{System'To_Address}
5940 (@code{System} is the only permissible prefix)
5941 denotes a function identical to
5942 @code{System.Storage_Elements.To_Address} except that
5943 it is a static attribute.  This means that if its argument is
5944 a static expression, then the result of the attribute is a
5945 static expression.  The result is that such an expression can be
5946 used in contexts (e.g.@: preelaborable packages) which require a
5947 static expression and where the function call could not be used
5948 (since the function call is always non-static, even if its
5949 argument is static).
5950
5951 @node Type_Class
5952 @unnumberedsec Type_Class
5953 @findex Type_Class
5954 @noindent
5955 @code{@var{type}'Type_Class} for any type or subtype @var{type} yields
5956 the value of the type class for the full type of @var{type}.  If
5957 @var{type} is a generic formal type, the value is the value for the
5958 corresponding actual subtype.  The value of this attribute is of type
5959 @code{System.Aux_DEC.Type_Class}, which has the following definition:
5960
5961 @smallexample @c ada
5962   type Type_Class is
5963     (Type_Class_Enumeration,
5964      Type_Class_Integer,
5965      Type_Class_Fixed_Point,
5966      Type_Class_Floating_Point,
5967      Type_Class_Array,
5968      Type_Class_Record,
5969      Type_Class_Access,
5970      Type_Class_Task,
5971      Type_Class_Address);
5972 @end smallexample
5973
5974 @noindent
5975 Protected types yield the value @code{Type_Class_Task}, which thus
5976 applies to all concurrent types.  This attribute is designed to
5977 be compatible with the DEC Ada 83 attribute of the same name.
5978
5979 @node UET_Address
5980 @unnumberedsec UET_Address
5981 @findex UET_Address
5982 @noindent
5983 The @code{UET_Address} attribute can only be used for a prefix which
5984 denotes a library package.  It yields the address of the unit exception
5985 table when zero cost exception handling is used.  This attribute is
5986 intended only for use within the GNAT implementation.  See the unit
5987 @code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb}
5988 for details on how this attribute is used in the implementation.
5989
5990 @node Unconstrained_Array
5991 @unnumberedsec Unconstrained_Array
5992 @findex Unconstrained_Array
5993 @noindent
5994 The @code{Unconstrained_Array} attribute can be used with a prefix that
5995 denotes any type or subtype. It is a static attribute that yields
5996 @code{True} if the prefix designates an unconstrained array,
5997 and @code{False} otherwise. In a generic instance, the result is
5998 still static, and yields the result of applying this test to the
5999 generic actual.
6000
6001 @node Universal_Literal_String
6002 @unnumberedsec Universal_Literal_String
6003 @cindex Named numbers, representation of
6004 @findex Universal_Literal_String
6005 @noindent
6006 The prefix of @code{Universal_Literal_String} must be a named
6007 number.  The static result is the string consisting of the characters of
6008 the number as defined in the original source.  This allows the user
6009 program to access the actual text of named numbers without intermediate
6010 conversions and without the need to enclose the strings in quotes (which
6011 would preclude their use as numbers).  This is used internally for the
6012 construction of values of the floating-point attributes from the file
6013 @file{ttypef.ads}, but may also be used by user programs.
6014
6015 For example, the following program prints the first 50 digits of pi:
6016
6017 @smallexample @c ada
6018 with Text_IO; use Text_IO;
6019 with Ada.Numerics;
6020 procedure Pi is
6021 begin
6022    Put (Ada.Numerics.Pi'Universal_Literal_String);
6023 end;
6024 @end smallexample
6025
6026 @node Unrestricted_Access
6027 @unnumberedsec Unrestricted_Access
6028 @cindex @code{Access}, unrestricted
6029 @findex Unrestricted_Access
6030 @noindent
6031 The @code{Unrestricted_Access} attribute is similar to @code{Access}
6032 except that all accessibility and aliased view checks are omitted.  This
6033 is a user-beware attribute.  It is similar to
6034 @code{Address}, for which it is a desirable replacement where the value
6035 desired is an access type.  In other words, its effect is identical to
6036 first applying the @code{Address} attribute and then doing an unchecked
6037 conversion to a desired access type.  In GNAT, but not necessarily in
6038 other implementations, the use of static chains for inner level
6039 subprograms means that @code{Unrestricted_Access} applied to a
6040 subprogram yields a value that can be called as long as the subprogram
6041 is in scope (normal Ada accessibility rules restrict this usage).
6042
6043 It is possible to use @code{Unrestricted_Access} for any type, but care
6044 must be exercised if it is used to create pointers to unconstrained
6045 objects. In this case, the resulting pointer has the same scope as the
6046 context of the attribute, and may not be returned to some enclosing
6047 scope. For instance, a function cannot use @code{Unrestricted_Access}
6048 to create a unconstrained pointer and then return that value to the
6049 caller.
6050
6051 @node VADS_Size
6052 @unnumberedsec VADS_Size
6053 @cindex @code{Size}, VADS compatibility
6054 @findex VADS_Size
6055 @noindent
6056 The @code{'VADS_Size} attribute is intended to make it easier to port
6057 legacy code which relies on the semantics of @code{'Size} as implemented
6058 by the VADS Ada 83 compiler.  GNAT makes a best effort at duplicating the
6059 same semantic interpretation.  In particular, @code{'VADS_Size} applied
6060 to a predefined or other primitive type with no Size clause yields the
6061 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
6062 typical machines).  In addition @code{'VADS_Size} applied to an object
6063 gives the result that would be obtained by applying the attribute to
6064 the corresponding type.
6065
6066 @node Value_Size
6067 @unnumberedsec Value_Size
6068 @cindex @code{Size}, setting for not-first subtype
6069 @findex Value_Size
6070 @code{@var{type}'Value_Size} is the number of bits required to represent
6071 a value of the given subtype.  It is the same as @code{@var{type}'Size},
6072 but, unlike @code{Size}, may be set for non-first subtypes.
6073
6074 @node Wchar_T_Size
6075 @unnumberedsec Wchar_T_Size
6076 @findex Wchar_T_Size
6077 @code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
6078 prefix) provides the size in bits of the C @code{wchar_t} type
6079 primarily for constructing the definition of this type in
6080 package @code{Interfaces.C}.
6081
6082 @node Word_Size
6083 @unnumberedsec Word_Size
6084 @findex Word_Size
6085 @code{Standard'Word_Size} (@code{Standard} is the only permissible
6086 prefix) provides the value @code{System.Word_Size}.
6087
6088 @c ------------------------
6089 @node Implementation Advice
6090 @chapter Implementation Advice
6091 @noindent
6092 The main text of the Ada Reference Manual describes the required
6093 behavior of all Ada compilers, and the GNAT compiler conforms to
6094 these requirements.
6095
6096 In addition, there are sections throughout the Ada Reference Manual headed
6097 by the phrase ``Implementation advice''.  These sections are not normative,
6098 i.e., they do not specify requirements that all compilers must
6099 follow.  Rather they provide advice on generally desirable behavior.  You
6100 may wonder why they are not requirements.  The most typical answer is
6101 that they describe behavior that seems generally desirable, but cannot
6102 be provided on all systems, or which may be undesirable on some systems.
6103
6104 As far as practical, GNAT follows the implementation advice sections in
6105 the Ada Reference Manual.  This chapter contains a table giving the
6106 reference manual section number, paragraph number and several keywords
6107 for each advice.  Each entry consists of the text of the advice followed
6108 by the GNAT interpretation of this advice.  Most often, this simply says
6109 ``followed'', which means that GNAT follows the advice.  However, in a
6110 number of cases, GNAT deliberately deviates from this advice, in which
6111 case the text describes what GNAT does and why.
6112
6113 @cindex Error detection
6114 @unnumberedsec 1.1.3(20): Error Detection
6115 @sp 1
6116 @cartouche
6117 If an implementation detects the use of an unsupported Specialized Needs
6118 Annex feature at run time, it should raise @code{Program_Error} if
6119 feasible.
6120 @end cartouche
6121 Not relevant.  All specialized needs annex features are either supported,
6122 or diagnosed at compile time.
6123
6124 @cindex Child Units
6125 @unnumberedsec 1.1.3(31): Child Units
6126 @sp 1
6127 @cartouche
6128 If an implementation wishes to provide implementation-defined
6129 extensions to the functionality of a language-defined library unit, it
6130 should normally do so by adding children to the library unit.
6131 @end cartouche
6132 Followed.
6133
6134 @cindex Bounded errors
6135 @unnumberedsec 1.1.5(12): Bounded Errors
6136 @sp 1
6137 @cartouche
6138 If an implementation detects a bounded error or erroneous
6139 execution, it should raise @code{Program_Error}.
6140 @end cartouche
6141 Followed in all cases in which the implementation detects a bounded
6142 error or erroneous execution.  Not all such situations are detected at
6143 runtime.
6144
6145 @cindex Pragmas
6146 @unnumberedsec 2.8(16): Pragmas
6147 @sp 1
6148 @cartouche
6149 Normally, implementation-defined pragmas should have no semantic effect
6150 for error-free programs; that is, if the implementation-defined pragmas
6151 are removed from a working program, the program should still be legal,
6152 and should still have the same semantics.
6153 @end cartouche
6154 The following implementation defined pragmas are exceptions to this
6155 rule:
6156
6157 @table @code
6158 @item Abort_Defer
6159 Affects semantics
6160 @item Ada_83
6161 Affects legality
6162 @item Assert
6163 Affects semantics
6164 @item CPP_Class
6165 Affects semantics
6166 @item CPP_Constructor
6167 Affects semantics
6168 @item Debug
6169 Affects semantics
6170 @item Interface_Name
6171 Affects semantics
6172 @item Machine_Attribute
6173 Affects semantics
6174 @item Unimplemented_Unit
6175 Affects legality
6176 @item Unchecked_Union
6177 Affects semantics
6178 @end table
6179
6180 @noindent
6181 In each of the above cases, it is essential to the purpose of the pragma
6182 that this advice not be followed.  For details see the separate section
6183 on implementation defined pragmas.
6184
6185 @unnumberedsec 2.8(17-19): Pragmas
6186 @sp 1
6187 @cartouche
6188 Normally, an implementation should not define pragmas that can
6189 make an illegal program legal, except as follows:
6190 @end cartouche
6191 @sp 1
6192 @cartouche
6193 A pragma used to complete a declaration, such as a pragma @code{Import};
6194 @end cartouche
6195 @sp 1
6196 @cartouche
6197 A pragma used to configure the environment by adding, removing, or
6198 replacing @code{library_items}.
6199 @end cartouche
6200 See response to paragraph 16 of this same section.
6201
6202 @cindex Character Sets
6203 @cindex Alternative Character Sets
6204 @unnumberedsec 3.5.2(5): Alternative Character Sets
6205 @sp 1
6206 @cartouche
6207 If an implementation supports a mode with alternative interpretations
6208 for @code{Character} and @code{Wide_Character}, the set of graphic
6209 characters of @code{Character} should nevertheless remain a proper
6210 subset of the set of graphic characters of @code{Wide_Character}.  Any
6211 character set ``localizations'' should be reflected in the results of
6212 the subprograms defined in the language-defined package
6213 @code{Characters.Handling} (see A.3) available in such a mode.  In a mode with
6214 an alternative interpretation of @code{Character}, the implementation should
6215 also support a corresponding change in what is a legal
6216 @code{identifier_letter}.
6217 @end cartouche
6218 Not all wide character modes follow this advice, in particular the JIS
6219 and IEC modes reflect standard usage in Japan, and in these encoding,
6220 the upper half of the Latin-1 set is not part of the wide-character
6221 subset, since the most significant bit is used for wide character
6222 encoding.  However, this only applies to the external forms.  Internally
6223 there is no such restriction.
6224
6225 @cindex Integer types
6226 @unnumberedsec 3.5.4(28): Integer Types
6227
6228 @sp 1
6229 @cartouche
6230 An implementation should support @code{Long_Integer} in addition to
6231 @code{Integer} if the target machine supports 32-bit (or longer)
6232 arithmetic.  No other named integer subtypes are recommended for package
6233 @code{Standard}.  Instead, appropriate named integer subtypes should be
6234 provided in the library package @code{Interfaces} (see B.2).
6235 @end cartouche
6236 @code{Long_Integer} is supported.  Other standard integer types are supported
6237 so this advice is not fully followed.  These types
6238 are supported for convenient interface to C, and so that all hardware
6239 types of the machine are easily available.
6240 @unnumberedsec 3.5.4(29): Integer Types
6241
6242 @sp 1
6243 @cartouche
6244 An implementation for a two's complement machine should support
6245 modular types with a binary modulus up to @code{System.Max_Int*2+2}.  An
6246 implementation should support a non-binary modules up to @code{Integer'Last}.
6247 @end cartouche
6248 Followed.
6249
6250 @cindex Enumeration values
6251 @unnumberedsec 3.5.5(8): Enumeration Values
6252 @sp 1
6253 @cartouche
6254 For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
6255 subtype, if the value of the operand does not correspond to the internal
6256 code for any enumeration literal of its type (perhaps due to an
6257 un-initialized variable), then the implementation should raise
6258 @code{Program_Error}.  This is particularly important for enumeration
6259 types with noncontiguous internal codes specified by an
6260 enumeration_representation_clause.
6261 @end cartouche
6262 Followed.
6263
6264 @cindex Float types
6265 @unnumberedsec 3.5.7(17): Float Types
6266 @sp 1
6267 @cartouche
6268 An implementation should support @code{Long_Float} in addition to
6269 @code{Float} if the target machine supports 11 or more digits of
6270 precision.  No other named floating point subtypes are recommended for
6271 package @code{Standard}.  Instead, appropriate named floating point subtypes
6272 should be provided in the library package @code{Interfaces} (see B.2).
6273 @end cartouche
6274 @code{Short_Float} and @code{Long_Long_Float} are also provided.  The
6275 former provides improved compatibility with other implementations
6276 supporting this type.  The latter corresponds to the highest precision
6277 floating-point type supported by the hardware.  On most machines, this
6278 will be the same as @code{Long_Float}, but on some machines, it will
6279 correspond to the IEEE extended form.  The notable case is all ia32
6280 (x86) implementations, where @code{Long_Long_Float} corresponds to
6281 the 80-bit extended precision format supported in hardware on this
6282 processor.  Note that the 128-bit format on SPARC is not supported,
6283 since this is a software rather than a hardware format.
6284
6285 @cindex Multidimensional arrays
6286 @cindex Arrays, multidimensional
6287 @unnumberedsec 3.6.2(11): Multidimensional Arrays
6288 @sp 1
6289 @cartouche
6290 An implementation should normally represent multidimensional arrays in
6291 row-major order, consistent with the notation used for multidimensional
6292 array aggregates (see 4.3.3).  However, if a pragma @code{Convention}
6293 (@code{Fortran}, @dots{}) applies to a multidimensional array type, then
6294 column-major order should be used instead (see B.5, ``Interfacing with
6295 Fortran'').
6296 @end cartouche
6297 Followed.
6298
6299 @findex Duration'Small
6300 @unnumberedsec 9.6(30-31): Duration'Small
6301 @sp 1
6302 @cartouche
6303 Whenever possible in an implementation, the value of @code{Duration'Small}
6304 should be no greater than 100 microseconds.
6305 @end cartouche
6306 Followed.  (@code{Duration'Small} = 10**(@minus{}9)).
6307
6308 @sp 1
6309 @cartouche
6310 The time base for @code{delay_relative_statements} should be monotonic;
6311 it need not be the same time base as used for @code{Calendar.Clock}.
6312 @end cartouche
6313 Followed.
6314
6315 @unnumberedsec 10.2.1(12): Consistent Representation
6316 @sp 1
6317 @cartouche
6318 In an implementation, a type declared in a pre-elaborated package should
6319 have the same representation in every elaboration of a given version of
6320 the package, whether the elaborations occur in distinct executions of
6321 the same program, or in executions of distinct programs or partitions
6322 that include the given version.
6323 @end cartouche
6324 Followed, except in the case of tagged types.  Tagged types involve
6325 implicit pointers to a local copy of a dispatch table, and these pointers
6326 have representations which thus depend on a particular elaboration of the
6327 package.  It is not easy to see how it would be possible to follow this
6328 advice without severely impacting efficiency of execution.
6329
6330 @cindex Exception information
6331 @unnumberedsec 11.4.1(19): Exception Information
6332 @sp 1
6333 @cartouche
6334 @code{Exception_Message} by default and @code{Exception_Information}
6335 should produce information useful for
6336 debugging.  @code{Exception_Message} should be short, about one
6337 line.  @code{Exception_Information} can be long.  @code{Exception_Message}
6338 should not include the
6339 @code{Exception_Name}.  @code{Exception_Information} should include both
6340 the @code{Exception_Name} and the @code{Exception_Message}.
6341 @end cartouche
6342 Followed.  For each exception that doesn't have a specified
6343 @code{Exception_Message}, the compiler generates one containing the location
6344 of the raise statement.  This location has the form ``file:line'', where
6345 file is the short file name (without path information) and line is the line
6346 number in the file.  Note that in the case of the Zero Cost Exception
6347 mechanism, these messages become redundant with the Exception_Information that
6348 contains a full backtrace of the calling sequence, so they are disabled.
6349 To disable explicitly the generation of the source location message, use the
6350 Pragma @code{Discard_Names}.
6351
6352 @cindex Suppression of checks
6353 @cindex Checks, suppression of
6354 @unnumberedsec 11.5(28): Suppression of Checks
6355 @sp 1
6356 @cartouche
6357 The implementation should minimize the code executed for checks that
6358 have been suppressed.
6359 @end cartouche
6360 Followed.
6361
6362 @cindex Representation clauses
6363 @unnumberedsec 13.1 (21-24): Representation Clauses
6364 @sp 1
6365 @cartouche
6366 The recommended level of support for all representation items is
6367 qualified as follows:
6368 @end cartouche
6369 @sp 1
6370 @cartouche
6371 An implementation need not support representation items containing
6372 non-static expressions, except that an implementation should support a
6373 representation item for a given entity if each non-static expression in
6374 the representation item is a name that statically denotes a constant
6375 declared before the entity.
6376 @end cartouche
6377 Followed.  In fact, GNAT goes beyond the recommended level of support
6378 by allowing nonstatic expressions in some representation clauses even
6379 without the need to declare constants initialized with the values of
6380 such expressions.
6381 For example:
6382
6383 @smallexample @c ada
6384   X : Integer;
6385   Y : Float;
6386   for Y'Address use X'Address;>>
6387 @end smallexample
6388
6389
6390 @sp 1
6391 @cartouche
6392 An implementation need not support a specification for the @code{Size}
6393 for a given composite subtype, nor the size or storage place for an
6394 object (including a component) of a given composite subtype, unless the
6395 constraints on the subtype and its composite subcomponents (if any) are
6396 all static constraints.
6397 @end cartouche
6398 Followed.  Size Clauses are not permitted on non-static components, as
6399 described above.
6400
6401 @sp 1
6402 @cartouche
6403 An aliased component, or a component whose type is by-reference, should
6404 always be allocated at an addressable location.
6405 @end cartouche
6406 Followed.
6407
6408 @cindex Packed types
6409 @unnumberedsec 13.2(6-8): Packed Types
6410 @sp 1
6411 @cartouche
6412 If a type is packed, then the implementation should try to minimize
6413 storage allocated to objects of the type, possibly at the expense of
6414 speed of accessing components, subject to reasonable complexity in
6415 addressing calculations.
6416 @end cartouche
6417 @sp 1
6418 @cartouche
6419 The recommended level of support pragma @code{Pack} is:
6420
6421 For a packed record type, the components should be packed as tightly as
6422 possible subject to the Sizes of the component subtypes, and subject to
6423 any @code{record_representation_clause} that applies to the type; the
6424 implementation may, but need not, reorder components or cross aligned
6425 word boundaries to improve the packing.  A component whose @code{Size} is
6426 greater than the word size may be allocated an integral number of words.
6427 @end cartouche
6428 Followed.  Tight packing of arrays is supported for all component sizes
6429 up to 64-bits. If the array component size is 1 (that is to say, if
6430 the component is a boolean type or an enumeration type with two values)
6431 then values of the type are implicitly initialized to zero. This
6432 happens both for objects of the packed type, and for objects that have a
6433 subcomponent of the packed type.
6434
6435 @sp 1
6436 @cartouche
6437 An implementation should support Address clauses for imported
6438 subprograms.
6439 @end cartouche
6440 Followed.
6441 @cindex @code{Address} clauses
6442 @unnumberedsec 13.3(14-19): Address Clauses
6443
6444 @sp 1
6445 @cartouche
6446 For an array @var{X}, @code{@var{X}'Address} should point at the first
6447 component of the array, and not at the array bounds.
6448 @end cartouche
6449 Followed.
6450
6451 @sp 1
6452 @cartouche
6453 The recommended level of support for the @code{Address} attribute is:
6454
6455 @code{@var{X}'Address} should produce a useful result if @var{X} is an
6456 object that is aliased or of a by-reference type, or is an entity whose
6457 @code{Address} has been specified.
6458 @end cartouche
6459 Followed.  A valid address will be produced even if none of those
6460 conditions have been met.  If necessary, the object is forced into
6461 memory to ensure the address is valid.
6462
6463 @sp 1
6464 @cartouche
6465 An implementation should support @code{Address} clauses for imported
6466 subprograms.
6467 @end cartouche
6468 Followed.
6469
6470 @sp 1
6471 @cartouche
6472 Objects (including subcomponents) that are aliased or of a by-reference
6473 type should be allocated on storage element boundaries.
6474 @end cartouche
6475 Followed.
6476
6477 @sp 1
6478 @cartouche
6479 If the @code{Address} of an object is specified, or it is imported or exported,
6480 then the implementation should not perform optimizations based on
6481 assumptions of no aliases.
6482 @end cartouche
6483 Followed.
6484
6485 @cindex @code{Alignment} clauses
6486 @unnumberedsec 13.3(29-35): Alignment Clauses
6487 @sp 1
6488 @cartouche
6489 The recommended level of support for the @code{Alignment} attribute for
6490 subtypes is:
6491
6492 An implementation should support specified Alignments that are factors
6493 and multiples of the number of storage elements per word, subject to the
6494 following:
6495 @end cartouche
6496 Followed.
6497
6498 @sp 1
6499 @cartouche
6500 An implementation need not support specified @code{Alignment}s for
6501 combinations of @code{Size}s and @code{Alignment}s that cannot be easily
6502 loaded and stored by available machine instructions.
6503 @end cartouche
6504 Followed.
6505
6506 @sp 1
6507 @cartouche
6508 An implementation need not support specified @code{Alignment}s that are
6509 greater than the maximum @code{Alignment} the implementation ever returns by
6510 default.
6511 @end cartouche
6512 Followed.
6513
6514 @sp 1
6515 @cartouche
6516 The recommended level of support for the @code{Alignment} attribute for
6517 objects is:
6518
6519 Same as above, for subtypes, but in addition:
6520 @end cartouche
6521 Followed.
6522
6523 @sp 1
6524 @cartouche
6525 For stand-alone library-level objects of statically constrained
6526 subtypes, the implementation should support all @code{Alignment}s
6527 supported by the target linker.  For example, page alignment is likely to
6528 be supported for such objects, but not for subtypes.
6529 @end cartouche
6530 Followed.
6531
6532 @cindex @code{Size} clauses
6533 @unnumberedsec 13.3(42-43): Size Clauses
6534 @sp 1
6535 @cartouche
6536 The recommended level of support for the @code{Size} attribute of
6537 objects is:
6538
6539 A @code{Size} clause should be supported for an object if the specified
6540 @code{Size} is at least as large as its subtype's @code{Size}, and
6541 corresponds to a size in storage elements that is a multiple of the
6542 object's @code{Alignment} (if the @code{Alignment} is nonzero).
6543 @end cartouche
6544 Followed.
6545
6546 @unnumberedsec 13.3(50-56): Size Clauses
6547 @sp 1
6548 @cartouche
6549 If the @code{Size} of a subtype is specified, and allows for efficient
6550 independent addressability (see 9.10) on the target architecture, then
6551 the @code{Size} of the following objects of the subtype should equal the
6552 @code{Size} of the subtype:
6553
6554 Aliased objects (including components).
6555 @end cartouche
6556 Followed.
6557
6558 @sp 1
6559 @cartouche
6560 @code{Size} clause on a composite subtype should not affect the
6561 internal layout of components.
6562 @end cartouche
6563 Followed. But note that this can be overridden by use of the implementation
6564 pragma Implicit_Packing in the case of packed arrays.
6565
6566 @sp 1
6567 @cartouche
6568 The recommended level of support for the @code{Size} attribute of subtypes is:
6569 @end cartouche
6570 @sp 1
6571 @cartouche
6572 The @code{Size} (if not specified) of a static discrete or fixed point
6573 subtype should be the number of bits needed to represent each value
6574 belonging to the subtype using an unbiased representation, leaving space
6575 for a sign bit only if the subtype contains negative values.  If such a
6576 subtype is a first subtype, then an implementation should support a
6577 specified @code{Size} for it that reflects this representation.
6578 @end cartouche
6579 Followed.
6580
6581 @sp 1
6582 @cartouche
6583 For a subtype implemented with levels of indirection, the @code{Size}
6584 should include the size of the pointers, but not the size of what they
6585 point at.
6586 @end cartouche
6587 Followed.
6588
6589 @cindex @code{Component_Size} clauses
6590 @unnumberedsec 13.3(71-73): Component Size Clauses
6591 @sp 1
6592 @cartouche
6593 The recommended level of support for the @code{Component_Size}
6594 attribute is:
6595 @end cartouche
6596 @sp 1
6597 @cartouche
6598 An implementation need not support specified @code{Component_Sizes} that are
6599 less than the @code{Size} of the component subtype.
6600 @end cartouche
6601 Followed.
6602
6603 @sp 1
6604 @cartouche
6605 An implementation should support specified @code{Component_Size}s that
6606 are factors and multiples of the word size.  For such
6607 @code{Component_Size}s, the array should contain no gaps between
6608 components.  For other @code{Component_Size}s (if supported), the array
6609 should contain no gaps between components when packing is also
6610 specified; the implementation should forbid this combination in cases
6611 where it cannot support a no-gaps representation.
6612 @end cartouche
6613 Followed.
6614
6615 @cindex Enumeration representation clauses
6616 @cindex Representation clauses, enumeration
6617 @unnumberedsec 13.4(9-10): Enumeration Representation Clauses
6618 @sp 1
6619 @cartouche
6620 The recommended level of support for enumeration representation clauses
6621 is:
6622
6623 An implementation need not support enumeration representation clauses
6624 for boolean types, but should at minimum support the internal codes in
6625 the range @code{System.Min_Int.System.Max_Int}.
6626 @end cartouche
6627 Followed.
6628
6629 @cindex Record representation clauses
6630 @cindex Representation clauses, records
6631 @unnumberedsec 13.5.1(17-22): Record Representation Clauses
6632 @sp 1
6633 @cartouche
6634 The recommended level of support for
6635 @*@code{record_representation_clauses} is:
6636
6637 An implementation should support storage places that can be extracted
6638 with a load, mask, shift sequence of machine code, and set with a load,
6639 shift, mask, store sequence, given the available machine instructions
6640 and run-time model.
6641 @end cartouche
6642 Followed.
6643
6644 @sp 1
6645 @cartouche
6646 A storage place should be supported if its size is equal to the
6647 @code{Size} of the component subtype, and it starts and ends on a
6648 boundary that obeys the @code{Alignment} of the component subtype.
6649 @end cartouche
6650 Followed.
6651
6652 @sp 1
6653 @cartouche
6654 If the default bit ordering applies to the declaration of a given type,
6655 then for a component whose subtype's @code{Size} is less than the word
6656 size, any storage place that does not cross an aligned word boundary
6657 should be supported.
6658 @end cartouche
6659 Followed.
6660
6661 @sp 1
6662 @cartouche
6663 An implementation may reserve a storage place for the tag field of a
6664 tagged type, and disallow other components from overlapping that place.
6665 @end cartouche
6666 Followed.  The storage place for the tag field is the beginning of the tagged
6667 record, and its size is Address'Size.  GNAT will reject an explicit component
6668 clause for the tag field.
6669
6670 @sp 1
6671 @cartouche
6672 An implementation need not support a @code{component_clause} for a
6673 component of an extension part if the storage place is not after the
6674 storage places of all components of the parent type, whether or not
6675 those storage places had been specified.
6676 @end cartouche
6677 Followed.  The above advice on record representation clauses is followed,
6678 and all mentioned features are implemented.
6679
6680 @cindex Storage place attributes
6681 @unnumberedsec 13.5.2(5): Storage Place Attributes
6682 @sp 1
6683 @cartouche
6684 If a component is represented using some form of pointer (such as an
6685 offset) to the actual data of the component, and this data is contiguous
6686 with the rest of the object, then the storage place attributes should
6687 reflect the place of the actual data, not the pointer.  If a component is
6688 allocated discontinuously from the rest of the object, then a warning
6689 should be generated upon reference to one of its storage place
6690 attributes.
6691 @end cartouche
6692 Followed.  There are no such components in GNAT@.
6693
6694 @cindex Bit ordering
6695 @unnumberedsec 13.5.3(7-8): Bit Ordering
6696 @sp 1
6697 @cartouche
6698 The recommended level of support for the non-default bit ordering is:
6699 @end cartouche
6700 @sp 1
6701 @cartouche
6702 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
6703 should support the non-default bit ordering in addition to the default
6704 bit ordering.
6705 @end cartouche
6706 Followed.  Word size does not equal storage size in this implementation.
6707 Thus non-default bit ordering is not supported.
6708
6709 @cindex @code{Address}, as private type
6710 @unnumberedsec 13.7(37): Address as Private
6711 @sp 1
6712 @cartouche
6713 @code{Address} should be of a private type.
6714 @end cartouche
6715 Followed.
6716
6717 @cindex Operations, on @code{Address}
6718 @cindex @code{Address}, operations of
6719 @unnumberedsec 13.7.1(16): Address Operations
6720 @sp 1
6721 @cartouche
6722 Operations in @code{System} and its children should reflect the target
6723 environment semantics as closely as is reasonable.  For example, on most
6724 machines, it makes sense for address arithmetic to ``wrap around''.
6725 Operations that do not make sense should raise @code{Program_Error}.
6726 @end cartouche
6727 Followed.  Address arithmetic is modular arithmetic that wraps around.  No
6728 operation raises @code{Program_Error}, since all operations make sense.
6729
6730 @cindex Unchecked conversion
6731 @unnumberedsec 13.9(14-17): Unchecked Conversion
6732 @sp 1
6733 @cartouche
6734 The @code{Size} of an array object should not include its bounds; hence,
6735 the bounds should not be part of the converted data.
6736 @end cartouche
6737 Followed.
6738
6739 @sp 1
6740 @cartouche
6741 The implementation should not generate unnecessary run-time checks to
6742 ensure that the representation of @var{S} is a representation of the
6743 target type.  It should take advantage of the permission to return by
6744 reference when possible.  Restrictions on unchecked conversions should be
6745 avoided unless required by the target environment.
6746 @end cartouche
6747 Followed.  There are no restrictions on unchecked conversion.  A warning is
6748 generated if the source and target types do not have the same size since
6749 the semantics in this case may be target dependent.
6750
6751 @sp 1
6752 @cartouche
6753 The recommended level of support for unchecked conversions is:
6754 @end cartouche
6755 @sp 1
6756 @cartouche
6757 Unchecked conversions should be supported and should be reversible in
6758 the cases where this clause defines the result.  To enable meaningful use
6759 of unchecked conversion, a contiguous representation should be used for
6760 elementary subtypes, for statically constrained array subtypes whose
6761 component subtype is one of the subtypes described in this paragraph,
6762 and for record subtypes without discriminants whose component subtypes
6763 are described in this paragraph.
6764 @end cartouche
6765 Followed.
6766
6767 @cindex Heap usage, implicit
6768 @unnumberedsec 13.11(23-25): Implicit Heap Usage
6769 @sp 1
6770 @cartouche
6771 An implementation should document any cases in which it dynamically
6772 allocates heap storage for a purpose other than the evaluation of an
6773 allocator.
6774 @end cartouche
6775 Followed, the only other points at which heap storage is dynamically
6776 allocated are as follows:
6777
6778 @itemize @bullet
6779 @item
6780 At initial elaboration time, to allocate dynamically sized global
6781 objects.
6782
6783 @item
6784 To allocate space for a task when a task is created.
6785
6786 @item
6787 To extend the secondary stack dynamically when needed.  The secondary
6788 stack is used for returning variable length results.
6789 @end itemize
6790
6791 @sp 1
6792 @cartouche
6793 A default (implementation-provided) storage pool for an
6794 access-to-constant type should not have overhead to support deallocation of
6795 individual objects.
6796 @end cartouche
6797 Followed.
6798
6799 @sp 1
6800 @cartouche
6801 A storage pool for an anonymous access type should be created at the
6802 point of an allocator for the type, and be reclaimed when the designated
6803 object becomes inaccessible.
6804 @end cartouche
6805 Followed.
6806
6807 @cindex Unchecked deallocation
6808 @unnumberedsec 13.11.2(17): Unchecked De-allocation
6809 @sp 1
6810 @cartouche
6811 For a standard storage pool, @code{Free} should actually reclaim the
6812 storage.
6813 @end cartouche
6814 Followed.
6815
6816 @cindex Stream oriented attributes
6817 @unnumberedsec 13.13.2(17): Stream Oriented Attributes
6818 @sp 1
6819 @cartouche
6820 If a stream element is the same size as a storage element, then the
6821 normal in-memory representation should be used by @code{Read} and
6822 @code{Write} for scalar objects.  Otherwise, @code{Read} and @code{Write}
6823 should use the smallest number of stream elements needed to represent
6824 all values in the base range of the scalar type.
6825 @end cartouche
6826
6827 Followed.  By default, GNAT uses the interpretation suggested by AI-195,
6828 which specifies using the size of the first subtype.
6829 However, such an implementation is based on direct binary
6830 representations and is therefore target- and endianness-dependent.
6831 To address this issue, GNAT also supplies an alternate implementation
6832 of the stream attributes @code{Read} and @code{Write},
6833 which uses the target-independent XDR standard representation
6834 for scalar types.
6835 @cindex XDR representation
6836 @cindex @code{Read} attribute
6837 @cindex @code{Write} attribute
6838 @cindex Stream oriented attributes
6839 The XDR implementation is provided as an alternative body of the
6840 @code{System.Stream_Attributes} package, in the file
6841 @file{s-strxdr.adb} in the GNAT library.
6842 There is no @file{s-strxdr.ads} file.
6843 In order to install the XDR implementation, do the following:
6844 @enumerate
6845 @item Replace the default implementation of the
6846 @code{System.Stream_Attributes} package with the XDR implementation.
6847 For example on a Unix platform issue the commands:
6848 @smallexample
6849 $ mv s-stratt.adb s-strold.adb
6850 $ mv s-strxdr.adb s-stratt.adb
6851 @end smallexample
6852
6853 @item
6854 Rebuild the GNAT run-time library as documented in
6855 @ref{GNAT and Libraries,,, gnat_ugn, @value{EDITION} User's Guide}.
6856 @end enumerate
6857
6858 @unnumberedsec A.1(52): Names of Predefined Numeric Types
6859 @sp 1
6860 @cartouche
6861 If an implementation provides additional named predefined integer types,
6862 then the names should end with @samp{Integer} as in
6863 @samp{Long_Integer}.  If an implementation provides additional named
6864 predefined floating point types, then the names should end with
6865 @samp{Float} as in @samp{Long_Float}.
6866 @end cartouche
6867 Followed.
6868
6869 @findex Ada.Characters.Handling
6870 @unnumberedsec A.3.2(49): @code{Ada.Characters.Handling}
6871 @sp 1
6872 @cartouche
6873 If an implementation provides a localized definition of @code{Character}
6874 or @code{Wide_Character}, then the effects of the subprograms in
6875 @code{Characters.Handling} should reflect the localizations.  See also
6876 3.5.2.
6877 @end cartouche
6878 Followed.  GNAT provides no such localized definitions.
6879
6880 @cindex Bounded-length strings
6881 @unnumberedsec A.4.4(106): Bounded-Length String Handling
6882 @sp 1
6883 @cartouche
6884 Bounded string objects should not be implemented by implicit pointers
6885 and dynamic allocation.
6886 @end cartouche
6887 Followed.  No implicit pointers or dynamic allocation are used.
6888
6889 @cindex Random number generation
6890 @unnumberedsec A.5.2(46-47): Random Number Generation
6891 @sp 1
6892 @cartouche
6893 Any storage associated with an object of type @code{Generator} should be
6894 reclaimed on exit from the scope of the object.
6895 @end cartouche
6896 Followed.
6897
6898 @sp 1
6899 @cartouche
6900 If the generator period is sufficiently long in relation to the number
6901 of distinct initiator values, then each possible value of
6902 @code{Initiator} passed to @code{Reset} should initiate a sequence of
6903 random numbers that does not, in a practical sense, overlap the sequence
6904 initiated by any other value.  If this is not possible, then the mapping
6905 between initiator values and generator states should be a rapidly
6906 varying function of the initiator value.
6907 @end cartouche
6908 Followed.  The generator period is sufficiently long for the first
6909 condition here to hold true.
6910
6911 @findex Get_Immediate
6912 @unnumberedsec A.10.7(23): @code{Get_Immediate}
6913 @sp 1
6914 @cartouche
6915 The @code{Get_Immediate} procedures should be implemented with
6916 unbuffered input.  For a device such as a keyboard, input should be
6917 @dfn{available} if a key has already been typed, whereas for a disk
6918 file, input should always be available except at end of file.  For a file
6919 associated with a keyboard-like device, any line-editing features of the
6920 underlying operating system should be disabled during the execution of
6921 @code{Get_Immediate}.
6922 @end cartouche
6923 Followed on all targets except VxWorks. For VxWorks, there is no way to
6924 provide this functionality that does not result in the input buffer being
6925 flushed before the @code{Get_Immediate} call. A special unit
6926 @code{Interfaces.Vxworks.IO} is provided that contains routines to enable
6927 this functionality.
6928
6929 @findex Export
6930 @unnumberedsec B.1(39-41): Pragma @code{Export}
6931 @sp 1
6932 @cartouche
6933 If an implementation supports pragma @code{Export} to a given language,
6934 then it should also allow the main subprogram to be written in that
6935 language.  It should support some mechanism for invoking the elaboration
6936 of the Ada library units included in the system, and for invoking the
6937 finalization of the environment task.  On typical systems, the
6938 recommended mechanism is to provide two subprograms whose link names are
6939 @code{adainit} and @code{adafinal}.  @code{adainit} should contain the
6940 elaboration code for library units.  @code{adafinal} should contain the
6941 finalization code.  These subprograms should have no effect the second
6942 and subsequent time they are called.
6943 @end cartouche
6944 Followed.
6945
6946 @sp 1
6947 @cartouche
6948 Automatic elaboration of pre-elaborated packages should be
6949 provided when pragma @code{Export} is supported.
6950 @end cartouche
6951 Followed when the main program is in Ada.  If the main program is in a
6952 foreign language, then
6953 @code{adainit} must be called to elaborate pre-elaborated
6954 packages.
6955
6956 @sp 1
6957 @cartouche
6958 For each supported convention @var{L} other than @code{Intrinsic}, an
6959 implementation should support @code{Import} and @code{Export} pragmas
6960 for objects of @var{L}-compatible types and for subprograms, and pragma
6961 @code{Convention} for @var{L}-eligible types and for subprograms,
6962 presuming the other language has corresponding features.  Pragma
6963 @code{Convention} need not be supported for scalar types.
6964 @end cartouche
6965 Followed.
6966
6967 @cindex Package @code{Interfaces}
6968 @findex Interfaces
6969 @unnumberedsec B.2(12-13): Package @code{Interfaces}
6970 @sp 1
6971 @cartouche
6972 For each implementation-defined convention identifier, there should be a
6973 child package of package Interfaces with the corresponding name.  This
6974 package should contain any declarations that would be useful for
6975 interfacing to the language (implementation) represented by the
6976 convention.  Any declarations useful for interfacing to any language on
6977 the given hardware architecture should be provided directly in
6978 @code{Interfaces}.
6979 @end cartouche
6980 Followed. An additional package not defined
6981 in the Ada Reference Manual is @code{Interfaces.CPP}, used
6982 for interfacing to C++.
6983
6984 @sp 1
6985 @cartouche
6986 An implementation supporting an interface to C, COBOL, or Fortran should
6987 provide the corresponding package or packages described in the following
6988 clauses.
6989 @end cartouche
6990 Followed.  GNAT provides all the packages described in this section.
6991
6992 @cindex C, interfacing with
6993 @unnumberedsec B.3(63-71): Interfacing with C
6994 @sp 1
6995 @cartouche
6996 An implementation should support the following interface correspondences
6997 between Ada and C@.
6998 @end cartouche
6999 Followed.
7000
7001 @sp 1
7002 @cartouche
7003 An Ada procedure corresponds to a void-returning C function.
7004 @end cartouche
7005 Followed.
7006
7007 @sp 1
7008 @cartouche
7009 An Ada function corresponds to a non-void C function.
7010 @end cartouche
7011 Followed.
7012
7013 @sp 1
7014 @cartouche
7015 An Ada @code{in} scalar parameter is passed as a scalar argument to a C
7016 function.
7017 @end cartouche
7018 Followed.
7019
7020 @sp 1
7021 @cartouche
7022 An Ada @code{in} parameter of an access-to-object type with designated
7023 type @var{T} is passed as a @code{@var{t}*} argument to a C function,
7024 where @var{t} is the C type corresponding to the Ada type @var{T}.
7025 @end cartouche
7026 Followed.
7027
7028 @sp 1
7029 @cartouche
7030 An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
7031 parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
7032 argument to a C function, where @var{t} is the C type corresponding to
7033 the Ada type @var{T}.  In the case of an elementary @code{out} or
7034 @code{in out} parameter, a pointer to a temporary copy is used to
7035 preserve by-copy semantics.
7036 @end cartouche
7037 Followed.
7038
7039 @sp 1
7040 @cartouche
7041 An Ada parameter of a record type @var{T}, of any mode, is passed as a
7042 @code{@var{t}*} argument to a C function, where @var{t} is the C
7043 structure corresponding to the Ada type @var{T}.
7044 @end cartouche
7045 Followed.  This convention may be overridden by the use of the C_Pass_By_Copy
7046 pragma, or Convention, or by explicitly specifying the mechanism for a given
7047 call using an extended import or export pragma.
7048
7049 @sp 1
7050 @cartouche
7051 An Ada parameter of an array type with component type @var{T}, of any
7052 mode, is passed as a @code{@var{t}*} argument to a C function, where
7053 @var{t} is the C type corresponding to the Ada type @var{T}.
7054 @end cartouche
7055 Followed.
7056
7057 @sp 1
7058 @cartouche
7059 An Ada parameter of an access-to-subprogram type is passed as a pointer
7060 to a C function whose prototype corresponds to the designated
7061 subprogram's specification.
7062 @end cartouche
7063 Followed.
7064
7065 @cindex COBOL, interfacing with
7066 @unnumberedsec B.4(95-98): Interfacing with COBOL
7067 @sp 1
7068 @cartouche
7069 An Ada implementation should support the following interface
7070 correspondences between Ada and COBOL@.
7071 @end cartouche
7072 Followed.
7073
7074 @sp 1
7075 @cartouche
7076 An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of
7077 the COBOL type corresponding to @var{T}.
7078 @end cartouche
7079 Followed.
7080
7081 @sp 1
7082 @cartouche
7083 An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of
7084 the corresponding COBOL type.
7085 @end cartouche
7086 Followed.
7087
7088 @sp 1
7089 @cartouche
7090 Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the
7091 COBOL type corresponding to the Ada parameter type; for scalars, a local
7092 copy is used if necessary to ensure by-copy semantics.
7093 @end cartouche
7094 Followed.
7095
7096 @cindex Fortran, interfacing with
7097 @unnumberedsec B.5(22-26): Interfacing with Fortran
7098 @sp 1
7099 @cartouche
7100 An Ada implementation should support the following interface
7101 correspondences between Ada and Fortran:
7102 @end cartouche
7103 Followed.
7104
7105 @sp 1
7106 @cartouche
7107 An Ada procedure corresponds to a Fortran subroutine.
7108 @end cartouche
7109 Followed.
7110
7111 @sp 1
7112 @cartouche
7113 An Ada function corresponds to a Fortran function.
7114 @end cartouche
7115 Followed.
7116
7117 @sp 1
7118 @cartouche
7119 An Ada parameter of an elementary, array, or record type @var{T} is
7120 passed as a @var{T} argument to a Fortran procedure, where @var{T} is
7121 the Fortran type corresponding to the Ada type @var{T}, and where the
7122 INTENT attribute of the corresponding dummy argument matches the Ada
7123 formal parameter mode; the Fortran implementation's parameter passing
7124 conventions are used.  For elementary types, a local copy is used if
7125 necessary to ensure by-copy semantics.
7126 @end cartouche
7127 Followed.
7128
7129 @sp 1
7130 @cartouche
7131 An Ada parameter of an access-to-subprogram type is passed as a
7132 reference to a Fortran procedure whose interface corresponds to the
7133 designated subprogram's specification.
7134 @end cartouche
7135 Followed.
7136
7137 @cindex Machine operations
7138 @unnumberedsec C.1(3-5): Access to Machine Operations
7139 @sp 1
7140 @cartouche
7141 The machine code or intrinsic support should allow access to all
7142 operations normally available to assembly language programmers for the
7143 target environment, including privileged instructions, if any.
7144 @end cartouche
7145 Followed.
7146
7147 @sp 1
7148 @cartouche
7149 The interfacing pragmas (see Annex B) should support interface to
7150 assembler; the default assembler should be associated with the
7151 convention identifier @code{Assembler}.
7152 @end cartouche
7153 Followed.
7154
7155 @sp 1
7156 @cartouche
7157 If an entity is exported to assembly language, then the implementation
7158 should allocate it at an addressable location, and should ensure that it
7159 is retained by the linking process, even if not otherwise referenced
7160 from the Ada code.  The implementation should assume that any call to a
7161 machine code or assembler subprogram is allowed to read or update every
7162 object that is specified as exported.
7163 @end cartouche
7164 Followed.
7165
7166 @unnumberedsec C.1(10-16): Access to Machine Operations
7167 @sp 1
7168 @cartouche
7169 The implementation should ensure that little or no overhead is
7170 associated with calling intrinsic and machine-code subprograms.
7171 @end cartouche
7172 Followed for both intrinsics and machine-code subprograms.
7173
7174 @sp 1
7175 @cartouche
7176 It is recommended that intrinsic subprograms be provided for convenient
7177 access to any machine operations that provide special capabilities or
7178 efficiency and that are not otherwise available through the language
7179 constructs.
7180 @end cartouche
7181 Followed.  A full set of machine operation intrinsic subprograms is provided.
7182
7183 @sp 1
7184 @cartouche
7185 Atomic read-modify-write operations---e.g.@:, test and set, compare and
7186 swap, decrement and test, enqueue/dequeue.
7187 @end cartouche
7188 Followed on any target supporting such operations.
7189
7190 @sp 1
7191 @cartouche
7192 Standard numeric functions---e.g.@:, sin, log.
7193 @end cartouche
7194 Followed on any target supporting such operations.
7195
7196 @sp 1
7197 @cartouche
7198 String manipulation operations---e.g.@:, translate and test.
7199 @end cartouche
7200 Followed on any target supporting such operations.
7201
7202 @sp 1
7203 @cartouche
7204 Vector operations---e.g.@:, compare vector against thresholds.
7205 @end cartouche
7206 Followed on any target supporting such operations.
7207
7208 @sp 1
7209 @cartouche
7210 Direct operations on I/O ports.
7211 @end cartouche
7212 Followed on any target supporting such operations.
7213
7214 @cindex Interrupt support
7215 @unnumberedsec C.3(28): Interrupt Support
7216 @sp 1
7217 @cartouche
7218 If the @code{Ceiling_Locking} policy is not in effect, the
7219 implementation should provide means for the application to specify which
7220 interrupts are to be blocked during protected actions, if the underlying
7221 system allows for a finer-grain control of interrupt blocking.
7222 @end cartouche
7223 Followed.  The underlying system does not allow for finer-grain control
7224 of interrupt blocking.
7225
7226 @cindex Protected procedure handlers
7227 @unnumberedsec C.3.1(20-21): Protected Procedure Handlers
7228 @sp 1
7229 @cartouche
7230 Whenever possible, the implementation should allow interrupt handlers to
7231 be called directly by the hardware.
7232 @end cartouche
7233 @c SGI info:
7234 @ignore
7235 This is never possible under IRIX, so this is followed by default.
7236 @end ignore
7237 Followed on any target where the underlying operating system permits
7238 such direct calls.
7239
7240 @sp 1
7241 @cartouche
7242 Whenever practical, violations of any
7243 implementation-defined restrictions should be detected before run time.
7244 @end cartouche
7245 Followed.  Compile time warnings are given when possible.
7246
7247 @cindex Package @code{Interrupts}
7248 @findex Interrupts
7249 @unnumberedsec C.3.2(25): Package @code{Interrupts}
7250
7251 @sp 1
7252 @cartouche
7253 If implementation-defined forms of interrupt handler procedures are
7254 supported, such as protected procedures with parameters, then for each
7255 such form of a handler, a type analogous to @code{Parameterless_Handler}
7256 should be specified in a child package of @code{Interrupts}, with the
7257 same operations as in the predefined package Interrupts.
7258 @end cartouche
7259 Followed.
7260
7261 @cindex Pre-elaboration requirements
7262 @unnumberedsec C.4(14): Pre-elaboration Requirements
7263 @sp 1
7264 @cartouche
7265 It is recommended that pre-elaborated packages be implemented in such a
7266 way that there should be little or no code executed at run time for the
7267 elaboration of entities not already covered by the Implementation
7268 Requirements.
7269 @end cartouche
7270 Followed.  Executable code is generated in some cases, e.g.@: loops
7271 to initialize large arrays.
7272
7273 @unnumberedsec C.5(8): Pragma @code{Discard_Names}
7274
7275 @sp 1
7276 @cartouche
7277 If the pragma applies to an entity, then the implementation should
7278 reduce the amount of storage used for storing names associated with that
7279 entity.
7280 @end cartouche
7281 Followed.
7282
7283 @cindex Package @code{Task_Attributes}
7284 @findex Task_Attributes
7285 @unnumberedsec C.7.2(30): The Package Task_Attributes
7286 @sp 1
7287 @cartouche
7288 Some implementations are targeted to domains in which memory use at run
7289 time must be completely deterministic.  For such implementations, it is
7290 recommended that the storage for task attributes will be pre-allocated
7291 statically and not from the heap.  This can be accomplished by either
7292 placing restrictions on the number and the size of the task's
7293 attributes, or by using the pre-allocated storage for the first @var{N}
7294 attribute objects, and the heap for the others.  In the latter case,
7295 @var{N} should be documented.
7296 @end cartouche
7297 Not followed.  This implementation is not targeted to such a domain.
7298
7299 @cindex Locking Policies
7300 @unnumberedsec D.3(17): Locking Policies
7301
7302 @sp 1
7303 @cartouche
7304 The implementation should use names that end with @samp{_Locking} for
7305 locking policies defined by the implementation.
7306 @end cartouche
7307 Followed.  A single implementation-defined locking policy is defined,
7308 whose name (@code{Inheritance_Locking}) follows this suggestion.
7309
7310 @cindex Entry queuing policies
7311 @unnumberedsec D.4(16): Entry Queuing Policies
7312 @sp 1
7313 @cartouche
7314 Names that end with @samp{_Queuing} should be used
7315 for all implementation-defined queuing policies.
7316 @end cartouche
7317 Followed.  No such implementation-defined queuing policies exist.
7318
7319 @cindex Preemptive abort
7320 @unnumberedsec D.6(9-10): Preemptive Abort
7321 @sp 1
7322 @cartouche
7323 Even though the @code{abort_statement} is included in the list of
7324 potentially blocking operations (see 9.5.1), it is recommended that this
7325 statement be implemented in a way that never requires the task executing
7326 the @code{abort_statement} to block.
7327 @end cartouche
7328 Followed.
7329
7330 @sp 1
7331 @cartouche
7332 On a multi-processor, the delay associated with aborting a task on
7333 another processor should be bounded; the implementation should use
7334 periodic polling, if necessary, to achieve this.
7335 @end cartouche
7336 Followed.
7337
7338 @cindex Tasking restrictions
7339 @unnumberedsec D.7(21): Tasking Restrictions
7340 @sp 1
7341 @cartouche
7342 When feasible, the implementation should take advantage of the specified
7343 restrictions to produce a more efficient implementation.
7344 @end cartouche
7345 GNAT currently takes advantage of these restrictions by providing an optimized
7346 run time when the Ravenscar profile and the GNAT restricted run time set
7347 of restrictions are specified.  See pragma @code{Profile (Ravenscar)} and
7348 pragma @code{Profile (Restricted)} for more details.
7349
7350 @cindex Time, monotonic
7351 @unnumberedsec D.8(47-49): Monotonic Time
7352 @sp 1
7353 @cartouche
7354 When appropriate, implementations should provide configuration
7355 mechanisms to change the value of @code{Tick}.
7356 @end cartouche
7357 Such configuration mechanisms are not appropriate to this implementation
7358 and are thus not supported.
7359
7360 @sp 1
7361 @cartouche
7362 It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
7363 be implemented as transformations of the same time base.
7364 @end cartouche
7365 Followed.
7366
7367 @sp 1
7368 @cartouche
7369 It is recommended that the @dfn{best} time base which exists in
7370 the underlying system be available to the application through
7371 @code{Clock}.  @dfn{Best} may mean highest accuracy or largest range.
7372 @end cartouche
7373 Followed.
7374
7375 @cindex Partition communication subsystem
7376 @cindex PCS
7377 @unnumberedsec E.5(28-29): Partition Communication Subsystem
7378 @sp 1
7379 @cartouche
7380 Whenever possible, the PCS on the called partition should allow for
7381 multiple tasks to call the RPC-receiver with different messages and
7382 should allow them to block until the corresponding subprogram body
7383 returns.
7384 @end cartouche
7385 Followed by GLADE, a separately supplied PCS that can be used with
7386 GNAT.
7387
7388 @sp 1
7389 @cartouche
7390 The @code{Write} operation on a stream of type @code{Params_Stream_Type}
7391 should raise @code{Storage_Error} if it runs out of space trying to
7392 write the @code{Item} into the stream.
7393 @end cartouche
7394 Followed by GLADE, a separately supplied PCS that can be used with
7395 GNAT@.
7396
7397 @cindex COBOL support
7398 @unnumberedsec F(7): COBOL Support
7399 @sp 1
7400 @cartouche
7401 If COBOL (respectively, C) is widely supported in the target
7402 environment, implementations supporting the Information Systems Annex
7403 should provide the child package @code{Interfaces.COBOL} (respectively,
7404 @code{Interfaces.C}) specified in Annex B and should support a
7405 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
7406 pragmas (see Annex B), thus allowing Ada programs to interface with
7407 programs written in that language.
7408 @end cartouche
7409 Followed.
7410
7411 @cindex Decimal radix support
7412 @unnumberedsec F.1(2): Decimal Radix Support
7413 @sp 1
7414 @cartouche
7415 Packed decimal should be used as the internal representation for objects
7416 of subtype @var{S} when @var{S}'Machine_Radix = 10.
7417 @end cartouche
7418 Not followed.  GNAT ignores @var{S}'Machine_Radix and always uses binary
7419 representations.
7420
7421 @cindex Numerics
7422 @unnumberedsec G: Numerics
7423 @sp 2
7424 @cartouche
7425 If Fortran (respectively, C) is widely supported in the target
7426 environment, implementations supporting the Numerics Annex
7427 should provide the child package @code{Interfaces.Fortran} (respectively,
7428 @code{Interfaces.C}) specified in Annex B and should support a
7429 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
7430 pragmas (see Annex B), thus allowing Ada programs to interface with
7431 programs written in that language.
7432 @end cartouche
7433 Followed.
7434
7435 @cindex Complex types
7436 @unnumberedsec G.1.1(56-58): Complex Types
7437 @sp 2
7438 @cartouche
7439 Because the usual mathematical meaning of multiplication of a complex
7440 operand and a real operand is that of the scaling of both components of
7441 the former by the latter, an implementation should not perform this
7442 operation by first promoting the real operand to complex type and then
7443 performing a full complex multiplication.  In systems that, in the
7444 future, support an Ada binding to IEC 559:1989, the latter technique
7445 will not generate the required result when one of the components of the
7446 complex operand is infinite.  (Explicit multiplication of the infinite
7447 component by the zero component obtained during promotion yields a NaN
7448 that propagates into the final result.) Analogous advice applies in the
7449 case of multiplication of a complex operand and a pure-imaginary
7450 operand, and in the case of division of a complex operand by a real or
7451 pure-imaginary operand.
7452 @end cartouche
7453 Not followed.
7454
7455 @sp 1
7456 @cartouche
7457 Similarly, because the usual mathematical meaning of addition of a
7458 complex operand and a real operand is that the imaginary operand remains
7459 unchanged, an implementation should not perform this operation by first
7460 promoting the real operand to complex type and then performing a full
7461 complex addition.  In implementations in which the @code{Signed_Zeros}
7462 attribute of the component type is @code{True} (and which therefore
7463 conform to IEC 559:1989 in regard to the handling of the sign of zero in
7464 predefined arithmetic operations), the latter technique will not
7465 generate the required result when the imaginary component of the complex
7466 operand is a negatively signed zero.  (Explicit addition of the negative
7467 zero to the zero obtained during promotion yields a positive zero.)
7468 Analogous advice applies in the case of addition of a complex operand
7469 and a pure-imaginary operand, and in the case of subtraction of a
7470 complex operand and a real or pure-imaginary operand.
7471 @end cartouche
7472 Not followed.
7473
7474 @sp 1
7475 @cartouche
7476 Implementations in which @code{Real'Signed_Zeros} is @code{True} should
7477 attempt to provide a rational treatment of the signs of zero results and
7478 result components.  As one example, the result of the @code{Argument}
7479 function should have the sign of the imaginary component of the
7480 parameter @code{X} when the point represented by that parameter lies on
7481 the positive real axis; as another, the sign of the imaginary component
7482 of the @code{Compose_From_Polar} function should be the same as
7483 (respectively, the opposite of) that of the @code{Argument} parameter when that
7484 parameter has a value of zero and the @code{Modulus} parameter has a
7485 nonnegative (respectively, negative) value.
7486 @end cartouche
7487 Followed.
7488
7489 @cindex Complex elementary functions
7490 @unnumberedsec G.1.2(49): Complex Elementary Functions
7491 @sp 1
7492 @cartouche
7493 Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
7494 @code{True} should attempt to provide a rational treatment of the signs
7495 of zero results and result components.  For example, many of the complex
7496 elementary functions have components that are odd functions of one of
7497 the parameter components; in these cases, the result component should
7498 have the sign of the parameter component at the origin.  Other complex
7499 elementary functions have zero components whose sign is opposite that of
7500 a parameter component at the origin, or is always positive or always
7501 negative.
7502 @end cartouche
7503 Followed.
7504
7505 @cindex Accuracy requirements
7506 @unnumberedsec G.2.4(19): Accuracy Requirements
7507 @sp 1
7508 @cartouche
7509 The versions of the forward trigonometric functions without a
7510 @code{Cycle} parameter should not be implemented by calling the
7511 corresponding version with a @code{Cycle} parameter of
7512 @code{2.0*Numerics.Pi}, since this will not provide the required
7513 accuracy in some portions of the domain.  For the same reason, the
7514 version of @code{Log} without a @code{Base} parameter should not be
7515 implemented by calling the corresponding version with a @code{Base}
7516 parameter of @code{Numerics.e}.
7517 @end cartouche
7518 Followed.
7519
7520 @cindex Complex arithmetic accuracy
7521 @cindex Accuracy, complex arithmetic
7522 @unnumberedsec G.2.6(15): Complex Arithmetic Accuracy
7523
7524 @sp 1
7525 @cartouche
7526 The version of the @code{Compose_From_Polar} function without a
7527 @code{Cycle} parameter should not be implemented by calling the
7528 corresponding version with a @code{Cycle} parameter of
7529 @code{2.0*Numerics.Pi}, since this will not provide the required
7530 accuracy in some portions of the domain.
7531 @end cartouche
7532 Followed.
7533
7534 @c -----------------------------------------
7535 @node Implementation Defined Characteristics
7536 @chapter Implementation Defined Characteristics
7537
7538 @noindent
7539 In addition to the implementation dependent pragmas and attributes, and
7540 the implementation advice, there are a number of other Ada features
7541 that are potentially implementation dependent.  These are mentioned
7542 throughout the Ada Reference Manual, and are summarized in annex M@.
7543
7544 A requirement for conforming Ada compilers is that they provide
7545 documentation describing how the implementation deals with each of these
7546 issues.  In this chapter, you will find each point in annex M listed
7547 followed by a description in italic font of how GNAT
7548 @c SGI info:
7549 @ignore
7550 in the ProDev Ada
7551 implementation on IRIX 5.3 operating system or greater
7552 @end ignore
7553 handles the implementation dependence.
7554
7555 You can use this chapter as a guide to minimizing implementation
7556 dependent features in your programs if portability to other compilers
7557 and other operating systems is an important consideration.  The numbers
7558 in each section below correspond to the paragraph number in the Ada
7559 Reference Manual.
7560
7561 @sp 1
7562 @cartouche
7563 @noindent
7564 @strong{2}.  Whether or not each recommendation given in Implementation
7565 Advice is followed.  See 1.1.2(37).
7566 @end cartouche
7567 @noindent
7568 @xref{Implementation Advice}.
7569
7570 @sp 1
7571 @cartouche
7572 @noindent
7573 @strong{3}.  Capacity limitations of the implementation.  See 1.1.3(3).
7574 @end cartouche
7575 @noindent
7576 The complexity of programs that can be processed is limited only by the
7577 total amount of available virtual memory, and disk space for the
7578 generated object files.
7579
7580 @sp 1
7581 @cartouche
7582 @noindent
7583 @strong{4}.  Variations from the standard that are impractical to avoid
7584 given the implementation's execution environment.  See 1.1.3(6).
7585 @end cartouche
7586 @noindent
7587 There are no variations from the standard.
7588
7589 @sp 1
7590 @cartouche
7591 @noindent
7592 @strong{5}.  Which @code{code_statement}s cause external
7593 interactions.  See 1.1.3(10).
7594 @end cartouche
7595 @noindent
7596 Any @code{code_statement} can potentially cause external interactions.
7597
7598 @sp 1
7599 @cartouche
7600 @noindent
7601 @strong{6}.  The coded representation for the text of an Ada
7602 program.  See 2.1(4).
7603 @end cartouche
7604 @noindent
7605 See separate section on source representation.
7606
7607 @sp 1
7608 @cartouche
7609 @noindent
7610 @strong{7}.  The control functions allowed in comments.  See 2.1(14).
7611 @end cartouche
7612 @noindent
7613 See separate section on source representation.
7614
7615 @sp 1
7616 @cartouche
7617 @noindent
7618 @strong{8}.  The representation for an end of line.  See 2.2(2).
7619 @end cartouche
7620 @noindent
7621 See separate section on source representation.
7622
7623 @sp 1
7624 @cartouche
7625 @noindent
7626 @strong{9}.  Maximum supported line length and lexical element
7627 length.  See 2.2(15).
7628 @end cartouche
7629 @noindent
7630 The maximum line length is 255 characters and the maximum length of a
7631 lexical element is also 255 characters.
7632
7633 @sp 1
7634 @cartouche
7635 @noindent
7636 @strong{10}.  Implementation defined pragmas.  See 2.8(14).
7637 @end cartouche
7638 @noindent
7639
7640 @xref{Implementation Defined Pragmas}.
7641
7642 @sp 1
7643 @cartouche
7644 @noindent
7645 @strong{11}.  Effect of pragma @code{Optimize}.  See 2.8(27).
7646 @end cartouche
7647 @noindent
7648 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
7649 parameter, checks that the optimization flag is set, and aborts if it is
7650 not.
7651
7652 @sp 1
7653 @cartouche
7654 @noindent
7655 @strong{12}.  The sequence of characters of the value returned by
7656 @code{@var{S}'Image} when some of the graphic characters of
7657 @code{@var{S}'Wide_Image} are not defined in @code{Character}.  See
7658 3.5(37).
7659 @end cartouche
7660 @noindent
7661 The sequence of characters is as defined by the wide character encoding
7662 method used for the source.  See section on source representation for
7663 further details.
7664
7665 @sp 1
7666 @cartouche
7667 @noindent
7668 @strong{13}.  The predefined integer types declared in
7669 @code{Standard}.  See 3.5.4(25).
7670 @end cartouche
7671 @noindent
7672 @table @code
7673 @item Short_Short_Integer
7674 8 bit signed
7675 @item Short_Integer
7676 (Short) 16 bit signed
7677 @item Integer
7678 32 bit signed
7679 @item Long_Integer
7680 64 bit signed (Alpha OpenVMS only)
7681 32 bit signed (all other targets)
7682 @item Long_Long_Integer
7683 64 bit signed
7684 @end table
7685
7686 @sp 1
7687 @cartouche
7688 @noindent
7689 @strong{14}.  Any nonstandard integer types and the operators defined
7690 for them.  See 3.5.4(26).
7691 @end cartouche
7692 @noindent
7693 There are no nonstandard integer types.
7694
7695 @sp 1
7696 @cartouche
7697 @noindent
7698 @strong{15}.  Any nonstandard real types and the operators defined for
7699 them.  See 3.5.6(8).
7700 @end cartouche
7701 @noindent
7702 There are no nonstandard real types.
7703
7704 @sp 1
7705 @cartouche
7706 @noindent
7707 @strong{16}.  What combinations of requested decimal precision and range
7708 are supported for floating point types.  See 3.5.7(7).
7709 @end cartouche
7710 @noindent
7711 The precision and range is as defined by the IEEE standard.
7712
7713 @sp 1
7714 @cartouche
7715 @noindent
7716 @strong{17}.  The predefined floating point types declared in
7717 @code{Standard}.  See 3.5.7(16).
7718 @end cartouche
7719 @noindent
7720 @table @code
7721 @item Short_Float
7722 32 bit IEEE short
7723 @item Float
7724 (Short) 32 bit IEEE short
7725 @item Long_Float
7726 64 bit IEEE long
7727 @item Long_Long_Float
7728 64 bit IEEE long (80 bit IEEE long on x86 processors)
7729 @end table
7730
7731 @sp 1
7732 @cartouche
7733 @noindent
7734 @strong{18}.  The small of an ordinary fixed point type.  See 3.5.9(8).
7735 @end cartouche
7736 @noindent
7737 @code{Fine_Delta} is 2**(@minus{}63)
7738
7739 @sp 1
7740 @cartouche
7741 @noindent
7742 @strong{19}.  What combinations of small, range, and digits are
7743 supported for fixed point types.  See 3.5.9(10).
7744 @end cartouche
7745 @noindent
7746 Any combinations are permitted that do not result in a small less than
7747 @code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
7748 If the mantissa is larger than 53 bits on machines where Long_Long_Float
7749 is 64 bits (true of all architectures except ia32), then the output from
7750 Text_IO is accurate to only 53 bits, rather than the full mantissa.  This
7751 is because floating-point conversions are used to convert fixed point.
7752
7753 @sp 1
7754 @cartouche
7755 @noindent
7756 @strong{20}.  The result of @code{Tags.Expanded_Name} for types declared
7757 within an unnamed @code{block_statement}.  See 3.9(10).
7758 @end cartouche
7759 @noindent
7760 Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
7761 decimal integer are allocated.
7762
7763 @sp 1
7764 @cartouche
7765 @noindent
7766 @strong{21}.  Implementation-defined attributes.  See 4.1.4(12).
7767 @end cartouche
7768 @noindent
7769 @xref{Implementation Defined Attributes}.
7770
7771 @sp 1
7772 @cartouche
7773 @noindent
7774 @strong{22}.  Any implementation-defined time types.  See 9.6(6).
7775 @end cartouche
7776 @noindent
7777 There are no implementation-defined time types.
7778
7779 @sp 1
7780 @cartouche
7781 @noindent
7782 @strong{23}.  The time base associated with relative delays.
7783 @end cartouche
7784 @noindent
7785 See 9.6(20).  The time base used is that provided by the C library
7786 function @code{gettimeofday}.
7787
7788 @sp 1
7789 @cartouche
7790 @noindent
7791 @strong{24}.  The time base of the type @code{Calendar.Time}.  See
7792 9.6(23).
7793 @end cartouche
7794 @noindent
7795 The time base used is that provided by the C library function
7796 @code{gettimeofday}.
7797
7798 @sp 1
7799 @cartouche
7800 @noindent
7801 @strong{25}.  The time zone used for package @code{Calendar}
7802 operations.  See 9.6(24).
7803 @end cartouche
7804 @noindent
7805 The time zone used by package @code{Calendar} is the current system time zone
7806 setting for local time, as accessed by the C library function
7807 @code{localtime}.
7808
7809 @sp 1
7810 @cartouche
7811 @noindent
7812 @strong{26}.  Any limit on @code{delay_until_statements} of
7813 @code{select_statements}.  See 9.6(29).
7814 @end cartouche
7815 @noindent
7816 There are no such limits.
7817
7818 @sp 1
7819 @cartouche
7820 @noindent
7821 @strong{27}.  Whether or not two non-overlapping parts of a composite
7822 object are independently addressable, in the case where packing, record
7823 layout, or @code{Component_Size} is specified for the object.  See
7824 9.10(1).
7825 @end cartouche
7826 @noindent
7827 Separate components are independently addressable if they do not share
7828 overlapping storage units.
7829
7830 @sp 1
7831 @cartouche
7832 @noindent
7833 @strong{28}.  The representation for a compilation.  See 10.1(2).
7834 @end cartouche
7835 @noindent
7836 A compilation is represented by a sequence of files presented to the
7837 compiler in a single invocation of the @command{gcc} command.
7838
7839 @sp 1
7840 @cartouche
7841 @noindent
7842 @strong{29}.  Any restrictions on compilations that contain multiple
7843 compilation_units.  See 10.1(4).
7844 @end cartouche
7845 @noindent
7846 No single file can contain more than one compilation unit, but any
7847 sequence of files can be presented to the compiler as a single
7848 compilation.
7849
7850 @sp 1
7851 @cartouche
7852 @noindent
7853 @strong{30}.  The mechanisms for creating an environment and for adding
7854 and replacing compilation units.  See 10.1.4(3).
7855 @end cartouche
7856 @noindent
7857 See separate section on compilation model.
7858
7859 @sp 1
7860 @cartouche
7861 @noindent
7862 @strong{31}.  The manner of explicitly assigning library units to a
7863 partition.  See 10.2(2).
7864 @end cartouche
7865 @noindent
7866 If a unit contains an Ada main program, then the Ada units for the partition
7867 are determined by recursive application of the rules in the Ada Reference
7868 Manual section 10.2(2-6).  In other words, the Ada units will be those that
7869 are needed by the main program, and then this definition of need is applied
7870 recursively to those units, and the partition contains the transitive
7871 closure determined by this relationship.  In short, all the necessary units
7872 are included, with no need to explicitly specify the list.  If additional
7873 units are required, e.g.@: by foreign language units, then all units must be
7874 mentioned in the context clause of one of the needed Ada units.
7875
7876 If the partition contains no main program, or if the main program is in
7877 a language other than Ada, then GNAT
7878 provides the binder options @option{-z} and @option{-n} respectively, and in
7879 this case a list of units can be explicitly supplied to the binder for
7880 inclusion in the partition (all units needed by these units will also
7881 be included automatically).  For full details on the use of these
7882 options, refer to @ref{The GNAT Make Program gnatmake,,, gnat_ugn,
7883 @value{EDITION} User's Guide}.
7884
7885 @sp 1
7886 @cartouche
7887 @noindent
7888 @strong{32}.  The implementation-defined means, if any, of specifying
7889 which compilation units are needed by a given compilation unit.  See
7890 10.2(2).
7891 @end cartouche
7892 @noindent
7893 The units needed by a given compilation unit are as defined in
7894 the Ada Reference Manual section 10.2(2-6).  There are no
7895 implementation-defined pragmas or other implementation-defined
7896 means for specifying needed units.
7897
7898 @sp 1
7899 @cartouche
7900 @noindent
7901 @strong{33}.  The manner of designating the main subprogram of a
7902 partition.  See 10.2(7).
7903 @end cartouche
7904 @noindent
7905 The main program is designated by providing the name of the
7906 corresponding @file{ALI} file as the input parameter to the binder.
7907
7908 @sp 1
7909 @cartouche
7910 @noindent
7911 @strong{34}.  The order of elaboration of @code{library_items}.  See
7912 10.2(18).
7913 @end cartouche
7914 @noindent
7915 The first constraint on ordering is that it meets the requirements of
7916 Chapter 10 of the Ada Reference Manual.  This still leaves some
7917 implementation dependent choices, which are resolved by first
7918 elaborating bodies as early as possible (i.e., in preference to specs
7919 where there is a choice), and second by evaluating the immediate with
7920 clauses of a unit to determine the probably best choice, and
7921 third by elaborating in alphabetical order of unit names
7922 where a choice still remains.
7923
7924 @sp 1
7925 @cartouche
7926 @noindent
7927 @strong{35}.  Parameter passing and function return for the main
7928 subprogram.  See 10.2(21).
7929 @end cartouche
7930 @noindent
7931 The main program has no parameters.  It may be a procedure, or a function
7932 returning an integer type.  In the latter case, the returned integer
7933 value is the return code of the program (overriding any value that
7934 may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
7935
7936 @sp 1
7937 @cartouche
7938 @noindent
7939 @strong{36}.  The mechanisms for building and running partitions.  See
7940 10.2(24).
7941 @end cartouche
7942 @noindent
7943 GNAT itself supports programs with only a single partition.  The GNATDIST
7944 tool provided with the GLADE package (which also includes an implementation
7945 of the PCS) provides a completely flexible method for building and running
7946 programs consisting of multiple partitions.  See the separate GLADE manual
7947 for details.
7948
7949 @sp 1
7950 @cartouche
7951 @noindent
7952 @strong{37}.  The details of program execution, including program
7953 termination.  See 10.2(25).
7954 @end cartouche
7955 @noindent
7956 See separate section on compilation model.
7957
7958 @sp 1
7959 @cartouche
7960 @noindent
7961 @strong{38}.  The semantics of any non-active partitions supported by the
7962 implementation.  See 10.2(28).
7963 @end cartouche
7964 @noindent
7965 Passive partitions are supported on targets where shared memory is
7966 provided by the operating system.  See the GLADE reference manual for
7967 further details.
7968
7969 @sp 1
7970 @cartouche
7971 @noindent
7972 @strong{39}.  The information returned by @code{Exception_Message}.  See
7973 11.4.1(10).
7974 @end cartouche
7975 @noindent
7976 Exception message returns the null string unless a specific message has
7977 been passed by the program.
7978
7979 @sp 1
7980 @cartouche
7981 @noindent
7982 @strong{40}.  The result of @code{Exceptions.Exception_Name} for types
7983 declared within an unnamed @code{block_statement}.  See 11.4.1(12).
7984 @end cartouche
7985 @noindent
7986 Blocks have implementation defined names of the form @code{B@var{nnn}}
7987 where @var{nnn} is an integer.
7988
7989 @sp 1
7990 @cartouche
7991 @noindent
7992 @strong{41}.  The information returned by
7993 @code{Exception_Information}.  See 11.4.1(13).
7994 @end cartouche
7995 @noindent
7996 @code{Exception_Information} returns a string in the following format:
7997
7998 @smallexample
7999 @emph{Exception_Name:} nnnnn
8000 @emph{Message:} mmmmm
8001 @emph{PID:} ppp
8002 @emph{Call stack traceback locations:}
8003 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
8004 @end smallexample
8005
8006 @noindent
8007 where
8008
8009 @itemize @bullet
8010 @item
8011 @code{nnnn} is the fully qualified name of the exception in all upper
8012 case letters. This line is always present.
8013
8014 @item
8015 @code{mmmm} is the message (this line present only if message is non-null)
8016
8017 @item
8018 @code{ppp} is the Process Id value as a decimal integer (this line is
8019 present only if the Process Id is nonzero). Currently we are
8020 not making use of this field.
8021
8022 @item
8023 The Call stack traceback locations line and the following values
8024 are present only if at least one traceback location was recorded.
8025 The values are given in C style format, with lower case letters
8026 for a-f, and only as many digits present as are necessary.
8027 @end itemize
8028
8029 @noindent
8030 The line terminator sequence at the end of each line, including
8031 the last line is a single @code{LF} character (@code{16#0A#}).
8032
8033 @sp 1
8034 @cartouche
8035 @noindent
8036 @strong{42}.  Implementation-defined check names.  See 11.5(27).
8037 @end cartouche
8038 @noindent
8039 The implementation defined check name Alignment_Check controls checking of
8040 address clause values for proper alignment (that is, the address supplied
8041 must be consistent with the alignment of the type).
8042
8043 In addition, a user program can add implementation-defined check names
8044 by means of the pragma Check_Name.
8045
8046 @sp 1
8047 @cartouche
8048 @noindent
8049 @strong{43}.  The interpretation of each aspect of representation.  See
8050 13.1(20).
8051 @end cartouche
8052 @noindent
8053 See separate section on data representations.
8054
8055 @sp 1
8056 @cartouche
8057 @noindent
8058 @strong{44}.  Any restrictions placed upon representation items.  See
8059 13.1(20).
8060 @end cartouche
8061 @noindent
8062 See separate section on data representations.
8063
8064 @sp 1
8065 @cartouche
8066 @noindent
8067 @strong{45}.  The meaning of @code{Size} for indefinite subtypes.  See
8068 13.3(48).
8069 @end cartouche
8070 @noindent
8071 Size for an indefinite subtype is the maximum possible size, except that
8072 for the case of a subprogram parameter, the size of the parameter object
8073 is the actual size.
8074
8075 @sp 1
8076 @cartouche
8077 @noindent
8078 @strong{46}.  The default external representation for a type tag.  See
8079 13.3(75).
8080 @end cartouche
8081 @noindent
8082 The default external representation for a type tag is the fully expanded
8083 name of the type in upper case letters.
8084
8085 @sp 1
8086 @cartouche
8087 @noindent
8088 @strong{47}.  What determines whether a compilation unit is the same in
8089 two different partitions.  See 13.3(76).
8090 @end cartouche
8091 @noindent
8092 A compilation unit is the same in two different partitions if and only
8093 if it derives from the same source file.
8094
8095 @sp 1
8096 @cartouche
8097 @noindent
8098 @strong{48}.  Implementation-defined components.  See 13.5.1(15).
8099 @end cartouche
8100 @noindent
8101 The only implementation defined component is the tag for a tagged type,
8102 which contains a pointer to the dispatching table.
8103
8104 @sp 1
8105 @cartouche
8106 @noindent
8107 @strong{49}.  If @code{Word_Size} = @code{Storage_Unit}, the default bit
8108 ordering.  See 13.5.3(5).
8109 @end cartouche
8110 @noindent
8111 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
8112 implementation, so no non-default bit ordering is supported.  The default
8113 bit ordering corresponds to the natural endianness of the target architecture.
8114
8115 @sp 1
8116 @cartouche
8117 @noindent
8118 @strong{50}.  The contents of the visible part of package @code{System}
8119 and its language-defined children.  See 13.7(2).
8120 @end cartouche
8121 @noindent
8122 See the definition of these packages in files @file{system.ads} and
8123 @file{s-stoele.ads}.
8124
8125 @sp 1
8126 @cartouche
8127 @noindent
8128 @strong{51}.  The contents of the visible part of package
8129 @code{System.Machine_Code}, and the meaning of
8130 @code{code_statements}.  See 13.8(7).
8131 @end cartouche
8132 @noindent
8133 See the definition and documentation in file @file{s-maccod.ads}.
8134
8135 @sp 1
8136 @cartouche
8137 @noindent
8138 @strong{52}.  The effect of unchecked conversion.  See 13.9(11).
8139 @end cartouche
8140 @noindent
8141 Unchecked conversion between types of the same size
8142 results in an uninterpreted transmission of the bits from one type
8143 to the other.  If the types are of unequal sizes, then in the case of
8144 discrete types, a shorter source is first zero or sign extended as
8145 necessary, and a shorter target is simply truncated on the left.
8146 For all non-discrete types, the source is first copied if necessary
8147 to ensure that the alignment requirements of the target are met, then
8148 a pointer is constructed to the source value, and the result is obtained
8149 by dereferencing this pointer after converting it to be a pointer to the
8150 target type. Unchecked conversions where the target subtype is an
8151 unconstrained array are not permitted. If the target alignment is
8152 greater than the source alignment, then a copy of the result is
8153 made with appropriate alignment
8154
8155 @sp 1
8156 @cartouche
8157 @noindent
8158 @strong{53}.  The manner of choosing a storage pool for an access type
8159 when @code{Storage_Pool} is not specified for the type.  See 13.11(17).
8160 @end cartouche
8161 @noindent
8162 There are 3 different standard pools used by the compiler when
8163 @code{Storage_Pool} is not specified depending whether the type is local
8164 to a subprogram or defined at the library level and whether
8165 @code{Storage_Size}is specified or not.  See documentation in the runtime
8166 library units @code{System.Pool_Global}, @code{System.Pool_Size} and
8167 @code{System.Pool_Local} in files @file{s-poosiz.ads},
8168 @file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
8169 default pools used.
8170
8171 @sp 1
8172 @cartouche
8173 @noindent
8174 @strong{54}.  Whether or not the implementation provides user-accessible
8175 names for the standard pool type(s).  See 13.11(17).
8176 @end cartouche
8177 @noindent
8178
8179 See documentation in the sources of the run time mentioned in paragraph
8180 @strong{53} .  All these pools are accessible by means of @code{with}'ing
8181 these units.
8182
8183 @sp 1
8184 @cartouche
8185 @noindent
8186 @strong{55}.  The meaning of @code{Storage_Size}.  See 13.11(18).
8187 @end cartouche
8188 @noindent
8189 @code{Storage_Size} is measured in storage units, and refers to the
8190 total space available for an access type collection, or to the primary
8191 stack space for a task.
8192
8193 @sp 1
8194 @cartouche
8195 @noindent
8196 @strong{56}.  Implementation-defined aspects of storage pools.  See
8197 13.11(22).
8198 @end cartouche
8199 @noindent
8200 See documentation in the sources of the run time mentioned in paragraph
8201 @strong{53} for details on GNAT-defined aspects of storage pools.
8202
8203 @sp 1
8204 @cartouche
8205 @noindent
8206 @strong{57}.  The set of restrictions allowed in a pragma
8207 @code{Restrictions}.  See 13.12(7).
8208 @end cartouche
8209 @noindent
8210 All RM defined Restriction identifiers are implemented.  The following
8211 additional restriction identifiers are provided.  There are two separate
8212 lists of implementation dependent restriction identifiers.  The first
8213 set requires consistency throughout a partition (in other words, if the
8214 restriction identifier is used for any compilation unit in the partition,
8215 then all compilation units in the partition must obey the restriction.
8216
8217 @table @code
8218
8219 @item Simple_Barriers
8220 @findex Simple_Barriers
8221 This restriction ensures at compile time that barriers in entry declarations
8222 for protected types are restricted to either static boolean expressions or
8223 references to simple boolean variables defined in the private part of the
8224 protected type.  No other form of entry barriers is permitted.  This is one
8225 of the restrictions of the Ravenscar profile for limited tasking (see also
8226 pragma @code{Profile (Ravenscar)}).
8227
8228 @item Max_Entry_Queue_Length => Expr
8229 @findex Max_Entry_Queue_Length
8230 This restriction is a declaration that any protected entry compiled in
8231 the scope of the restriction has at most the specified number of
8232 tasks waiting on the entry
8233 at any one time, and so no queue is required.  This restriction is not
8234 checked at compile time.  A program execution is erroneous if an attempt
8235 is made to queue more than the specified number of tasks on such an entry.
8236
8237 @item No_Calendar
8238 @findex No_Calendar
8239 This restriction ensures at compile time that there is no implicit or
8240 explicit dependence on the package @code{Ada.Calendar}.
8241
8242 @item No_Default_Initialization
8243 @findex No_Default_Initialization
8244
8245 This restriction prohibits any instance of default initialization of variables.
8246 The binder implements a consistency rule which prevents any unit compiled
8247 without the restriction from with'ing a unit with the restriction (this allows
8248 the generation of initialization procedures to be skipped, since you can be
8249 sure that no call is ever generated to an initialization procedure in a unit
8250 with the restriction active). If used in conjunction with Initialize_Scalars or
8251 Normalize_Scalars, the effect is to prohibit all cases of variables declared
8252 without a specific initializer (including the case of OUT scalar parameters).
8253
8254 @item No_Direct_Boolean_Operators
8255 @findex No_Direct_Boolean_Operators
8256 This restriction ensures that no logical (and/or/xor) or comparison
8257 operators are used on operands of type Boolean (or any type derived
8258 from Boolean). This is intended for use in safety critical programs
8259 where the certification protocol requires the use of short-circuit
8260 (and then, or else) forms for all composite boolean operations.
8261
8262 @item No_Dispatching_Calls
8263 @findex No_Dispatching_Calls
8264 This restriction ensures at compile time that the code generated by the
8265 compiler involves no dispatching calls. The use of this restriction allows the
8266 safe use of record extensions, classwide membership tests and other classwide
8267 features not involving implicit dispatching. This restriction ensures that
8268 the code contains no indirect calls through a dispatching mechanism. Note that
8269 this includes internally-generated calls created by the compiler, for example
8270 in the implementation of class-wide objects assignments. The
8271 membership test is allowed in the presence of this restriction, because its
8272 implementation requires no dispatching.
8273 This restriction is comparable to the official Ada restriction
8274 @code{No_Dispatch} except that it is a bit less restrictive in that it allows
8275 all classwide constructs that do not imply dispatching.
8276 The following example indicates constructs that violate this restriction.
8277
8278 @smallexample
8279 package Pkg is
8280   type T is tagged record
8281     Data : Natural;
8282   end record;
8283   procedure P (X : T);
8284
8285   type DT is new T with record
8286     More_Data : Natural;
8287   end record;
8288   procedure Q (X : DT);
8289 end Pkg;
8290
8291 with Pkg; use Pkg;
8292 procedure Example is
8293   procedure Test (O : T'Class) is
8294     N : Natural  := O'Size;--  Error: Dispatching call
8295     C : T'Class := O;      --  Error: implicit Dispatching Call
8296   begin
8297     if O in DT'Class then  --  OK   : Membership test
8298        Q (DT (O));         --  OK   : Type conversion plus direct call
8299     else
8300        P (O);              --  Error: Dispatching call
8301     end if;
8302   end Test;
8303
8304   Obj : DT;
8305 begin
8306   P (Obj);                 --  OK   : Direct call
8307   P (T (Obj));             --  OK   : Type conversion plus direct call
8308   P (T'Class (Obj));       --  Error: Dispatching call
8309
8310   Test (Obj);              --  OK   : Type conversion
8311
8312   if Obj in T'Class then   --  OK   : Membership test
8313      null;
8314   end if;
8315 end Example;
8316 @end smallexample
8317
8318 @item No_Dynamic_Attachment
8319 @findex No_Dynamic_Attachment
8320 This restriction ensures that there is no call to any of the operations
8321 defined in package Ada.Interrupts.
8322
8323 @item No_Enumeration_Maps
8324 @findex No_Enumeration_Maps
8325 This restriction ensures at compile time that no operations requiring
8326 enumeration maps are used (that is Image and Value attributes applied
8327 to enumeration types).
8328
8329 @item No_Entry_Calls_In_Elaboration_Code
8330 @findex No_Entry_Calls_In_Elaboration_Code
8331 This restriction ensures at compile time that no task or protected entry
8332 calls are made during elaboration code.  As a result of the use of this
8333 restriction, the compiler can assume that no code past an accept statement
8334 in a task can be executed at elaboration time.
8335
8336 @item No_Exception_Handlers
8337 @findex No_Exception_Handlers
8338 This restriction ensures at compile time that there are no explicit
8339 exception handlers. It also indicates that no exception propagation will
8340 be provided. In this mode, exceptions may be raised but will result in
8341 an immediate call to the last chance handler, a routine that the user
8342 must define with the following profile:
8343
8344 @smallexample @c ada
8345 procedure Last_Chance_Handler
8346   (Source_Location : System.Address; Line : Integer);
8347 pragma Export (C, Last_Chance_Handler,
8348                "__gnat_last_chance_handler");
8349 @end smallexample
8350
8351 The parameter is a C null-terminated string representing a message to be
8352 associated with the exception (typically the source location of the raise
8353 statement generated by the compiler). The Line parameter when nonzero
8354 represents the line number in the source program where the raise occurs.
8355
8356 @item No_Exception_Propagation
8357 @findex No_Exception_Propagation
8358 This restriction guarantees that exceptions are never propagated to an outer
8359 subprogram scope). The only case in which an exception may be raised is when
8360 the handler is statically in the same subprogram, so that the effect of a raise
8361 is essentially like a goto statement. Any other raise statement (implicit or
8362 explicit) will be considered unhandled. Exception handlers are allowed, but may
8363 not contain an exception occurrence identifier (exception choice). In addition
8364 use of the package GNAT.Current_Exception is not permitted, and reraise
8365 statements (raise with no operand) are not permitted.
8366
8367 @item No_Exception_Registration
8368 @findex No_Exception_Registration
8369 This restriction ensures at compile time that no stream operations for
8370 types Exception_Id or Exception_Occurrence are used. This also makes it
8371 impossible to pass exceptions to or from a partition with this restriction
8372 in a distributed environment. If this exception is active, then the generated
8373 code is simplified by omitting the otherwise-required global registration
8374 of exceptions when they are declared.
8375
8376 @item No_Implicit_Conditionals
8377 @findex No_Implicit_Conditionals
8378 This restriction ensures that the generated code does not contain any
8379 implicit conditionals, either by modifying the generated code where possible,
8380 or by rejecting any construct that would otherwise generate an implicit
8381 conditional. Note that this check does not include run time constraint
8382 checks, which on some targets may generate implicit conditionals as
8383 well. To control the latter, constraint checks can be suppressed in the
8384 normal manner. Constructs generating implicit conditionals include comparisons
8385 of composite objects and the Max/Min attributes.
8386
8387 @item No_Implicit_Dynamic_Code
8388 @findex No_Implicit_Dynamic_Code
8389 @cindex trampoline
8390 This restriction prevents the compiler from building ``trampolines''.
8391 This is a structure that is built on the stack and contains dynamic
8392 code to be executed at run time. On some targets, a trampoline is
8393 built for the following features: @code{Access},
8394 @code{Unrestricted_Access}, or @code{Address} of a nested subprogram;
8395 nested task bodies; primitive operations of nested tagged types.
8396 Trampolines do not work on machines that prevent execution of stack
8397 data. For example, on windows systems, enabling DEP (data execution
8398 protection) will cause trampolines to raise an exception.
8399 Trampolines are also quite slow at run time.
8400
8401 On many targets, trampolines have been largely eliminated. Look at the
8402 version of system.ads for your target --- if it has
8403 Always_Compatible_Rep equal to False, then trampolines are largely
8404 eliminated. In particular, a trampoline is built for the following
8405 features: @code{Address} of a nested subprogram;
8406 @code{Access} or @code{Unrestricted_Access} of a nested subprogram,
8407 but only if pragma Favor_Top_Level applies, or the access type has a
8408 foreign-language convention; primitive operations of nested tagged
8409 types.
8410
8411 @item No_Implicit_Loops
8412 @findex No_Implicit_Loops
8413 This restriction ensures that the generated code does not contain any
8414 implicit @code{for} loops, either by modifying
8415 the generated code where possible,
8416 or by rejecting any construct that would otherwise generate an implicit
8417 @code{for} loop. If this restriction is active, it is possible to build
8418 large array aggregates with all static components without generating an
8419 intermediate temporary, and without generating a loop to initialize individual
8420 components. Otherwise, a loop is created for arrays larger than about 5000
8421 scalar components.
8422
8423 @item No_Initialize_Scalars
8424 @findex No_Initialize_Scalars
8425 This restriction ensures that no unit in the partition is compiled with
8426 pragma Initialize_Scalars. This allows the generation of more efficient
8427 code, and in particular eliminates dummy null initialization routines that
8428 are otherwise generated for some record and array types.
8429
8430 @item No_Local_Protected_Objects
8431 @findex No_Local_Protected_Objects
8432 This restriction ensures at compile time that protected objects are
8433 only declared at the library level.
8434
8435 @item No_Protected_Type_Allocators
8436 @findex No_Protected_Type_Allocators
8437 This restriction ensures at compile time that there are no allocator
8438 expressions that attempt to allocate protected objects.
8439
8440 @item No_Secondary_Stack
8441 @findex No_Secondary_Stack
8442 This restriction ensures at compile time that the generated code does not
8443 contain any reference to the secondary stack.  The secondary stack is used
8444 to implement functions returning unconstrained objects (arrays or records)
8445 on some targets.
8446
8447 @item No_Select_Statements
8448 @findex No_Select_Statements
8449 This restriction ensures at compile time no select statements of any kind
8450 are permitted, that is the keyword @code{select} may not appear.
8451 This is one of the restrictions of the Ravenscar
8452 profile for limited tasking (see also pragma @code{Profile (Ravenscar)}).
8453
8454 @item No_Standard_Storage_Pools
8455 @findex No_Standard_Storage_Pools
8456 This restriction ensures at compile time that no access types
8457 use the standard default storage pool.  Any access type declared must
8458 have an explicit Storage_Pool attribute defined specifying a
8459 user-defined storage pool.
8460
8461 @item No_Streams
8462 @findex No_Streams
8463 This restriction ensures at compile/bind time that there are no
8464 stream objects created (and therefore no actual stream operations).
8465 This restriction does not forbid dependences on the package
8466 @code{Ada.Streams}. So it is permissible to with
8467 @code{Ada.Streams} (or another package that does so itself)
8468 as long as no actual stream objects are created.
8469
8470 @item No_Task_Attributes_Package
8471 @findex No_Task_Attributes_Package
8472 This restriction ensures at compile time that there are no implicit or
8473 explicit dependencies on the package @code{Ada.Task_Attributes}.
8474
8475 @item No_Task_Termination
8476 @findex No_Task_Termination
8477 This restriction ensures at compile time that no terminate alternatives
8478 appear in any task body.
8479
8480 @item No_Tasking
8481 @findex No_Tasking
8482 This restriction prevents the declaration of tasks or task types throughout
8483 the partition.  It is similar in effect to the use of @code{Max_Tasks => 0}
8484 except that violations are caught at compile time and cause an error message
8485 to be output either by the compiler or binder.
8486
8487 @item Static_Priorities
8488 @findex Static_Priorities
8489 This restriction ensures at compile time that all priority expressions
8490 are static, and that there are no dependencies on the package
8491 @code{Ada.Dynamic_Priorities}.
8492
8493 @item Static_Storage_Size
8494 @findex Static_Storage_Size
8495 This restriction ensures at compile time that any expression appearing
8496 in a Storage_Size pragma or attribute definition clause is static.
8497
8498 @end table
8499
8500 @noindent
8501 The second set of implementation dependent restriction identifiers
8502 does not require partition-wide consistency.
8503 The restriction may be enforced for a single
8504 compilation unit without any effect on any of the
8505 other compilation units in the partition.
8506
8507 @table @code
8508
8509 @item No_Elaboration_Code
8510 @findex No_Elaboration_Code
8511 This restriction ensures at compile time that no elaboration code is
8512 generated.  Note that this is not the same condition as is enforced
8513 by pragma @code{Preelaborate}.  There are cases in which pragma
8514 @code{Preelaborate} still permits code to be generated (e.g.@: code
8515 to initialize a large array to all zeroes), and there are cases of units
8516 which do not meet the requirements for pragma @code{Preelaborate},
8517 but for which no elaboration code is generated.  Generally, it is
8518 the case that preelaborable units will meet the restrictions, with
8519 the exception of large aggregates initialized with an others_clause,
8520 and exception declarations (which generate calls to a run-time
8521 registry procedure).  This restriction is enforced on
8522 a unit by unit basis, it need not be obeyed consistently
8523 throughout a partition.
8524
8525 In the case of aggregates with others, if the aggregate has a dynamic
8526 size, there is no way to eliminate the elaboration code (such dynamic
8527 bounds would be incompatible with @code{Preelaborate} in any case). If
8528 the bounds are static, then use of this restriction actually modifies
8529 the code choice of the compiler to avoid generating a loop, and instead
8530 generate the aggregate statically if possible, no matter how many times
8531 the data for the others clause must be repeatedly generated.
8532
8533 It is not possible to precisely document
8534 the constructs which are compatible with this restriction, since,
8535 unlike most other restrictions, this is not a restriction on the
8536 source code, but a restriction on the generated object code. For
8537 example, if the source contains a declaration:
8538
8539 @smallexample
8540    Val : constant Integer := X;
8541 @end smallexample
8542
8543 @noindent
8544 where X is not a static constant, it may be possible, depending
8545 on complex optimization circuitry, for the compiler to figure
8546 out the value of X at compile time, in which case this initialization
8547 can be done by the loader, and requires no initialization code. It
8548 is not possible to document the precise conditions under which the
8549 optimizer can figure this out.
8550
8551 Note that this the implementation of this restriction requires full
8552 code generation. If it is used in conjunction with "semantics only"
8553 checking, then some cases of violations may be missed.
8554
8555 @item No_Entry_Queue
8556 @findex No_Entry_Queue
8557 This restriction is a declaration that any protected entry compiled in
8558 the scope of the restriction has at most one task waiting on the entry
8559 at any one time, and so no queue is required.  This restriction is not
8560 checked at compile time.  A program execution is erroneous if an attempt
8561 is made to queue a second task on such an entry.
8562
8563 @item No_Implementation_Attributes
8564 @findex No_Implementation_Attributes
8565 This restriction checks at compile time that no GNAT-defined attributes
8566 are present.  With this restriction, the only attributes that can be used
8567 are those defined in the Ada Reference Manual.
8568
8569 @item No_Implementation_Pragmas
8570 @findex No_Implementation_Pragmas
8571 This restriction checks at compile time that no GNAT-defined pragmas
8572 are present.  With this restriction, the only pragmas that can be used
8573 are those defined in the Ada Reference Manual.
8574
8575 @item No_Implementation_Restrictions
8576 @findex No_Implementation_Restrictions
8577 This restriction checks at compile time that no GNAT-defined restriction
8578 identifiers (other than @code{No_Implementation_Restrictions} itself)
8579 are present.  With this restriction, the only other restriction identifiers
8580 that can be used are those defined in the Ada Reference Manual.
8581
8582 @item No_Wide_Characters
8583 @findex No_Wide_Characters
8584 This restriction ensures at compile time that no uses of the types
8585 @code{Wide_Character} or @code{Wide_String} or corresponding wide
8586 wide types
8587 appear, and that no wide or wide wide string or character literals
8588 appear in the program (that is literals representing characters not in
8589 type @code{Character}.
8590
8591 @end table
8592
8593 @sp 1
8594 @cartouche
8595 @noindent
8596 @strong{58}.  The consequences of violating limitations on
8597 @code{Restrictions} pragmas.  See 13.12(9).
8598 @end cartouche
8599 @noindent
8600 Restrictions that can be checked at compile time result in illegalities
8601 if violated.  Currently there are no other consequences of violating
8602 restrictions.
8603
8604 @sp 1
8605 @cartouche
8606 @noindent
8607 @strong{59}.  The representation used by the @code{Read} and
8608 @code{Write} attributes of elementary types in terms of stream
8609 elements.  See 13.13.2(9).
8610 @end cartouche
8611 @noindent
8612 The representation is the in-memory representation of the base type of
8613 the type, using the number of bits corresponding to the
8614 @code{@var{type}'Size} value, and the natural ordering of the machine.
8615
8616 @sp 1
8617 @cartouche
8618 @noindent
8619 @strong{60}.  The names and characteristics of the numeric subtypes
8620 declared in the visible part of package @code{Standard}.  See A.1(3).
8621 @end cartouche
8622 @noindent
8623 See items describing the integer and floating-point types supported.
8624
8625 @sp 1
8626 @cartouche
8627 @noindent
8628 @strong{61}.  The accuracy actually achieved by the elementary
8629 functions.  See A.5.1(1).
8630 @end cartouche
8631 @noindent
8632 The elementary functions correspond to the functions available in the C
8633 library.  Only fast math mode is implemented.
8634
8635 @sp 1
8636 @cartouche
8637 @noindent
8638 @strong{62}.  The sign of a zero result from some of the operators or
8639 functions in @code{Numerics.Generic_Elementary_Functions}, when
8640 @code{Float_Type'Signed_Zeros} is @code{True}.  See A.5.1(46).
8641 @end cartouche
8642 @noindent
8643 The sign of zeroes follows the requirements of the IEEE 754 standard on
8644 floating-point.
8645
8646 @sp 1
8647 @cartouche
8648 @noindent
8649 @strong{63}.  The value of
8650 @code{Numerics.Float_Random.Max_Image_Width}.  See A.5.2(27).
8651 @end cartouche
8652 @noindent
8653 Maximum image width is 649, see library file @file{a-numran.ads}.
8654
8655 @sp 1
8656 @cartouche
8657 @noindent
8658 @strong{64}.  The value of
8659 @code{Numerics.Discrete_Random.Max_Image_Width}.  See A.5.2(27).
8660 @end cartouche
8661 @noindent
8662 Maximum image width is 80, see library file @file{a-nudira.ads}.
8663
8664 @sp 1
8665 @cartouche
8666 @noindent
8667 @strong{65}.  The algorithms for random number generation.  See
8668 A.5.2(32).
8669 @end cartouche
8670 @noindent
8671 The algorithm is documented in the source files @file{a-numran.ads} and
8672 @file{a-numran.adb}.
8673
8674 @sp 1
8675 @cartouche
8676 @noindent
8677 @strong{66}.  The string representation of a random number generator's
8678 state.  See A.5.2(38).
8679 @end cartouche
8680 @noindent
8681 See the documentation contained in the file @file{a-numran.adb}.
8682
8683 @sp 1
8684 @cartouche
8685 @noindent
8686 @strong{67}.  The minimum time interval between calls to the
8687 time-dependent Reset procedure that are guaranteed to initiate different
8688 random number sequences.  See A.5.2(45).
8689 @end cartouche
8690 @noindent
8691 The minimum period between reset calls to guarantee distinct series of
8692 random numbers is one microsecond.
8693
8694 @sp 1
8695 @cartouche
8696 @noindent
8697 @strong{68}.  The values of the @code{Model_Mantissa},
8698 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
8699 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
8700 Annex is not supported.  See A.5.3(72).
8701 @end cartouche
8702 @noindent
8703 See the source file @file{ttypef.ads} for the values of all numeric
8704 attributes.
8705
8706 @sp 1
8707 @cartouche
8708 @noindent
8709 @strong{69}.  Any implementation-defined characteristics of the
8710 input-output packages.  See A.7(14).
8711 @end cartouche
8712 @noindent
8713 There are no special implementation defined characteristics for these
8714 packages.
8715
8716 @sp 1
8717 @cartouche
8718 @noindent
8719 @strong{70}.  The value of @code{Buffer_Size} in @code{Storage_IO}.  See
8720 A.9(10).
8721 @end cartouche
8722 @noindent
8723 All type representations are contiguous, and the @code{Buffer_Size} is
8724 the value of @code{@var{type}'Size} rounded up to the next storage unit
8725 boundary.
8726
8727 @sp 1
8728 @cartouche
8729 @noindent
8730 @strong{71}.  External files for standard input, standard output, and
8731 standard error See A.10(5).
8732 @end cartouche
8733 @noindent
8734 These files are mapped onto the files provided by the C streams
8735 libraries.  See source file @file{i-cstrea.ads} for further details.
8736
8737 @sp 1
8738 @cartouche
8739 @noindent
8740 @strong{72}.  The accuracy of the value produced by @code{Put}.  See
8741 A.10.9(36).
8742 @end cartouche
8743 @noindent
8744 If more digits are requested in the output than are represented by the
8745 precision of the value, zeroes are output in the corresponding least
8746 significant digit positions.
8747
8748 @sp 1
8749 @cartouche
8750 @noindent
8751 @strong{73}.  The meaning of @code{Argument_Count}, @code{Argument}, and
8752 @code{Command_Name}.  See A.15(1).
8753 @end cartouche
8754 @noindent
8755 These are mapped onto the @code{argv} and @code{argc} parameters of the
8756 main program in the natural manner.
8757
8758 @sp 1
8759 @cartouche
8760 @noindent
8761 @strong{74}.  Implementation-defined convention names.  See B.1(11).
8762 @end cartouche
8763 @noindent
8764 The following convention names are supported
8765
8766 @table @code
8767 @item  Ada
8768 Ada
8769 @item Assembler
8770 Assembly language
8771 @item Asm
8772 Synonym for Assembler
8773 @item Assembly
8774 Synonym for Assembler
8775 @item C
8776 C
8777 @item C_Pass_By_Copy
8778 Allowed only for record types, like C, but also notes that record
8779 is to be passed by copy rather than reference.
8780 @item COBOL
8781 COBOL
8782 @item C_Plus_Plus (or CPP)
8783 C++
8784 @item Default
8785 Treated the same as C
8786 @item External
8787 Treated the same as C
8788 @item Fortran
8789 Fortran
8790 @item Intrinsic
8791 For support of pragma @code{Import} with convention Intrinsic, see
8792 separate section on Intrinsic Subprograms.
8793 @item Stdcall
8794 Stdcall (used for Windows implementations only).  This convention correspond
8795 to the WINAPI (previously called Pascal convention) C/C++ convention under
8796 Windows.  A function with this convention cleans the stack before exit.
8797 @item DLL
8798 Synonym for Stdcall
8799 @item Win32
8800 Synonym for Stdcall
8801 @item Stubbed
8802 Stubbed is a special convention used to indicate that the body of the
8803 subprogram will be entirely ignored.  Any call to the subprogram
8804 is converted into a raise of the @code{Program_Error} exception.  If a
8805 pragma @code{Import} specifies convention @code{stubbed} then no body need
8806 be present at all.  This convention is useful during development for the
8807 inclusion of subprograms whose body has not yet been written.
8808
8809 @end table
8810 @noindent
8811 In addition, all otherwise unrecognized convention names are also
8812 treated as being synonymous with convention C@.  In all implementations
8813 except for VMS, use of such other names results in a warning.  In VMS
8814 implementations, these names are accepted silently.
8815
8816 @sp 1
8817 @cartouche
8818 @noindent
8819 @strong{75}.  The meaning of link names.  See B.1(36).
8820 @end cartouche
8821 @noindent
8822 Link names are the actual names used by the linker.
8823
8824 @sp 1
8825 @cartouche
8826 @noindent
8827 @strong{76}.  The manner of choosing link names when neither the link
8828 name nor the address of an imported or exported entity is specified.  See
8829 B.1(36).
8830 @end cartouche
8831 @noindent
8832 The default linker name is that which would be assigned by the relevant
8833 external language, interpreting the Ada name as being in all lower case
8834 letters.
8835
8836 @sp 1
8837 @cartouche
8838 @noindent
8839 @strong{77}.  The effect of pragma @code{Linker_Options}.  See B.1(37).
8840 @end cartouche
8841 @noindent
8842 The string passed to @code{Linker_Options} is presented uninterpreted as
8843 an argument to the link command, unless it contains ASCII.NUL characters.
8844 NUL characters if they appear act as argument separators, so for example
8845
8846 @smallexample @c ada
8847 pragma Linker_Options ("-labc" & ASCII.NUL & "-ldef");
8848 @end smallexample
8849
8850 @noindent
8851 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
8852 linker. The order of linker options is preserved for a given unit. The final
8853 list of options passed to the linker is in reverse order of the elaboration
8854 order. For example, linker options for a body always appear before the options
8855 from the corresponding package spec.
8856
8857 @sp 1
8858 @cartouche
8859 @noindent
8860 @strong{78}.  The contents of the visible part of package
8861 @code{Interfaces} and its language-defined descendants.  See B.2(1).
8862 @end cartouche
8863 @noindent
8864 See files with prefix @file{i-} in the distributed library.
8865
8866 @sp 1
8867 @cartouche
8868 @noindent
8869 @strong{79}.  Implementation-defined children of package
8870 @code{Interfaces}.  The contents of the visible part of package
8871 @code{Interfaces}.  See B.2(11).
8872 @end cartouche
8873 @noindent
8874 See files with prefix @file{i-} in the distributed library.
8875
8876 @sp 1
8877 @cartouche
8878 @noindent
8879 @strong{80}.  The types @code{Floating}, @code{Long_Floating},
8880 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
8881 @code{COBOL_Character}; and the initialization of the variables
8882 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
8883 @code{Interfaces.COBOL}.  See B.4(50).
8884 @end cartouche
8885 @noindent
8886 @table @code
8887 @item Floating
8888 Float
8889 @item Long_Floating
8890 (Floating) Long_Float
8891 @item Binary
8892 Integer
8893 @item Long_Binary
8894 Long_Long_Integer
8895 @item Decimal_Element
8896 Character
8897 @item COBOL_Character
8898 Character
8899 @end table
8900
8901 @noindent
8902 For initialization, see the file @file{i-cobol.ads} in the distributed library.
8903
8904 @sp 1
8905 @cartouche
8906 @noindent
8907 @strong{81}.  Support for access to machine instructions.  See C.1(1).
8908 @end cartouche
8909 @noindent
8910 See documentation in file @file{s-maccod.ads} in the distributed library.
8911
8912 @sp 1
8913 @cartouche
8914 @noindent
8915 @strong{82}.  Implementation-defined aspects of access to machine
8916 operations.  See C.1(9).
8917 @end cartouche
8918 @noindent
8919 See documentation in file @file{s-maccod.ads} in the distributed library.
8920
8921 @sp 1
8922 @cartouche
8923 @noindent
8924 @strong{83}.  Implementation-defined aspects of interrupts.  See C.3(2).
8925 @end cartouche
8926 @noindent
8927 Interrupts are mapped to signals or conditions as appropriate.  See
8928 definition of unit
8929 @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
8930 on the interrupts supported on a particular target.
8931
8932 @sp 1
8933 @cartouche
8934 @noindent
8935 @strong{84}.  Implementation-defined aspects of pre-elaboration.  See
8936 C.4(13).
8937 @end cartouche
8938 @noindent
8939 GNAT does not permit a partition to be restarted without reloading,
8940 except under control of the debugger.
8941
8942 @sp 1
8943 @cartouche
8944 @noindent
8945 @strong{85}.  The semantics of pragma @code{Discard_Names}.  See C.5(7).
8946 @end cartouche
8947 @noindent
8948 Pragma @code{Discard_Names} causes names of enumeration literals to
8949 be suppressed.  In the presence of this pragma, the Image attribute
8950 provides the image of the Pos of the literal, and Value accepts
8951 Pos values.
8952
8953 @sp 1
8954 @cartouche
8955 @noindent
8956 @strong{86}.  The result of the @code{Task_Identification.Image}
8957 attribute.  See C.7.1(7).
8958 @end cartouche
8959 @noindent
8960 The result of this attribute is a string that identifies
8961 the object or component that denotes a given task. If a variable @code{Var}
8962 has a task type, the image for this task will have the form @code{Var_@var{XXXXXXXX}},
8963 where the suffix
8964 is the hexadecimal representation of the virtual address of the corresponding
8965 task control block. If the variable is an array of tasks, the image of each
8966 task will have the form of an indexed component indicating the position of a
8967 given task in the array, e.g.@: @code{Group(5)_@var{XXXXXXX}}. If the task is a
8968 component of a record, the image of the task will have the form of a selected
8969 component. These rules are fully recursive, so that the image of a task that
8970 is a subcomponent of a composite object corresponds to the expression that
8971 designates this task.
8972 @noindent
8973 If a task is created by an allocator, its image depends on the context. If the
8974 allocator is part of an object declaration, the rules described above are used
8975 to construct its image, and this image is not affected by subsequent
8976 assignments. If the allocator appears within an expression, the image
8977 includes only the name of the task type.
8978 @noindent
8979 If the configuration pragma Discard_Names is present, or if the restriction
8980 No_Implicit_Heap_Allocation is in effect,  the image reduces to
8981 the numeric suffix, that is to say the hexadecimal representation of the
8982 virtual address of the control block of the task.
8983 @sp 1
8984 @cartouche
8985 @noindent
8986 @strong{87}.  The value of @code{Current_Task} when in a protected entry
8987 or interrupt handler.  See C.7.1(17).
8988 @end cartouche
8989 @noindent
8990 Protected entries or interrupt handlers can be executed by any
8991 convenient thread, so the value of @code{Current_Task} is undefined.
8992
8993 @sp 1
8994 @cartouche
8995 @noindent
8996 @strong{88}.  The effect of calling @code{Current_Task} from an entry
8997 body or interrupt handler.  See C.7.1(19).
8998 @end cartouche
8999 @noindent
9000 The effect of calling @code{Current_Task} from an entry body or
9001 interrupt handler is to return the identification of the task currently
9002 executing the code.
9003
9004 @sp 1
9005 @cartouche
9006 @noindent
9007 @strong{89}.  Implementation-defined aspects of
9008 @code{Task_Attributes}.  See C.7.2(19).
9009 @end cartouche
9010 @noindent
9011 There are no implementation-defined aspects of @code{Task_Attributes}.
9012
9013 @sp 1
9014 @cartouche
9015 @noindent
9016 @strong{90}.  Values of all @code{Metrics}.  See D(2).
9017 @end cartouche
9018 @noindent
9019 The metrics information for GNAT depends on the performance of the
9020 underlying operating system.  The sources of the run-time for tasking
9021 implementation, together with the output from @option{-gnatG} can be
9022 used to determine the exact sequence of operating systems calls made
9023 to implement various tasking constructs.  Together with appropriate
9024 information on the performance of the underlying operating system,
9025 on the exact target in use, this information can be used to determine
9026 the required metrics.
9027
9028 @sp 1
9029 @cartouche
9030 @noindent
9031 @strong{91}.  The declarations of @code{Any_Priority} and
9032 @code{Priority}.  See D.1(11).
9033 @end cartouche
9034 @noindent
9035 See declarations in file @file{system.ads}.
9036
9037 @sp 1
9038 @cartouche
9039 @noindent
9040 @strong{92}.  Implementation-defined execution resources.  See D.1(15).
9041 @end cartouche
9042 @noindent
9043 There are no implementation-defined execution resources.
9044
9045 @sp 1
9046 @cartouche
9047 @noindent
9048 @strong{93}.  Whether, on a multiprocessor, a task that is waiting for
9049 access to a protected object keeps its processor busy.  See D.2.1(3).
9050 @end cartouche
9051 @noindent
9052 On a multi-processor, a task that is waiting for access to a protected
9053 object does not keep its processor busy.
9054
9055 @sp 1
9056 @cartouche
9057 @noindent
9058 @strong{94}.  The affect of implementation defined execution resources
9059 on task dispatching.  See D.2.1(9).
9060 @end cartouche
9061 @noindent
9062 @c SGI info
9063 @ignore
9064 Tasks map to IRIX threads, and the dispatching policy is as defined by
9065 the IRIX implementation of threads.
9066 @end ignore
9067 Tasks map to threads in the threads package used by GNAT@.  Where possible
9068 and appropriate, these threads correspond to native threads of the
9069 underlying operating system.
9070
9071 @sp 1
9072 @cartouche
9073 @noindent
9074 @strong{95}.  Implementation-defined @code{policy_identifiers} allowed
9075 in a pragma @code{Task_Dispatching_Policy}.  See D.2.2(3).
9076 @end cartouche
9077 @noindent
9078 There are no implementation-defined policy-identifiers allowed in this
9079 pragma.
9080
9081 @sp 1
9082 @cartouche
9083 @noindent
9084 @strong{96}.  Implementation-defined aspects of priority inversion.  See
9085 D.2.2(16).
9086 @end cartouche
9087 @noindent
9088 Execution of a task cannot be preempted by the implementation processing
9089 of delay expirations for lower priority tasks.
9090
9091 @sp 1
9092 @cartouche
9093 @noindent
9094 @strong{97}.  Implementation defined task dispatching.  See D.2.2(18).
9095 @end cartouche
9096 @noindent
9097 @c SGI info:
9098 @ignore
9099 Tasks map to IRIX threads, and the dispatching policy is as defined by
9100 the IRIX implementation of threads.
9101 @end ignore
9102 The policy is the same as that of the underlying threads implementation.
9103
9104 @sp 1
9105 @cartouche
9106 @noindent
9107 @strong{98}.  Implementation-defined @code{policy_identifiers} allowed
9108 in a pragma @code{Locking_Policy}.  See D.3(4).
9109 @end cartouche
9110 @noindent
9111 The only implementation defined policy permitted in GNAT is
9112 @code{Inheritance_Locking}.  On targets that support this policy, locking
9113 is implemented by inheritance, i.e.@: the task owning the lock operates
9114 at a priority equal to the highest priority of any task currently
9115 requesting the lock.
9116
9117 @sp 1
9118 @cartouche
9119 @noindent
9120 @strong{99}.  Default ceiling priorities.  See D.3(10).
9121 @end cartouche
9122 @noindent
9123 The ceiling priority of protected objects of the type
9124 @code{System.Interrupt_Priority'Last} as described in the Ada
9125 Reference Manual D.3(10),
9126
9127 @sp 1
9128 @cartouche
9129 @noindent
9130 @strong{100}.  The ceiling of any protected object used internally by
9131 the implementation.  See D.3(16).
9132 @end cartouche
9133 @noindent
9134 The ceiling priority of internal protected objects is
9135 @code{System.Priority'Last}.
9136
9137 @sp 1
9138 @cartouche
9139 @noindent
9140 @strong{101}.  Implementation-defined queuing policies.  See D.4(1).
9141 @end cartouche
9142 @noindent
9143 There are no implementation-defined queuing policies.
9144
9145 @sp 1
9146 @cartouche
9147 @noindent
9148 @strong{102}.  On a multiprocessor, any conditions that cause the
9149 completion of an aborted construct to be delayed later than what is
9150 specified for a single processor.  See D.6(3).
9151 @end cartouche
9152 @noindent
9153 The semantics for abort on a multi-processor is the same as on a single
9154 processor, there are no further delays.
9155
9156 @sp 1
9157 @cartouche
9158 @noindent
9159 @strong{103}.  Any operations that implicitly require heap storage
9160 allocation.  See D.7(8).
9161 @end cartouche
9162 @noindent
9163 The only operation that implicitly requires heap storage allocation is
9164 task creation.
9165
9166 @sp 1
9167 @cartouche
9168 @noindent
9169 @strong{104}.  Implementation-defined aspects of pragma
9170 @code{Restrictions}.  See D.7(20).
9171 @end cartouche
9172 @noindent
9173 There are no such implementation-defined aspects.
9174
9175 @sp 1
9176 @cartouche
9177 @noindent
9178 @strong{105}.  Implementation-defined aspects of package
9179 @code{Real_Time}.  See D.8(17).
9180 @end cartouche
9181 @noindent
9182 There are no implementation defined aspects of package @code{Real_Time}.
9183
9184 @sp 1
9185 @cartouche
9186 @noindent
9187 @strong{106}.  Implementation-defined aspects of
9188 @code{delay_statements}.  See D.9(8).
9189 @end cartouche
9190 @noindent
9191 Any difference greater than one microsecond will cause the task to be
9192 delayed (see D.9(7)).
9193
9194 @sp 1
9195 @cartouche
9196 @noindent
9197 @strong{107}.  The upper bound on the duration of interrupt blocking
9198 caused by the implementation.  See D.12(5).
9199 @end cartouche
9200 @noindent
9201 The upper bound is determined by the underlying operating system.  In
9202 no cases is it more than 10 milliseconds.
9203
9204 @sp 1
9205 @cartouche
9206 @noindent
9207 @strong{108}.  The means for creating and executing distributed
9208 programs.  See E(5).
9209 @end cartouche
9210 @noindent
9211 The GLADE package provides a utility GNATDIST for creating and executing
9212 distributed programs.  See the GLADE reference manual for further details.
9213
9214 @sp 1
9215 @cartouche
9216 @noindent
9217 @strong{109}.  Any events that can result in a partition becoming
9218 inaccessible.  See E.1(7).
9219 @end cartouche
9220 @noindent
9221 See the GLADE reference manual for full details on such events.
9222
9223 @sp 1
9224 @cartouche
9225 @noindent
9226 @strong{110}.  The scheduling policies, treatment of priorities, and
9227 management of shared resources between partitions in certain cases.  See
9228 E.1(11).
9229 @end cartouche
9230 @noindent
9231 See the GLADE reference manual for full details on these aspects of
9232 multi-partition execution.
9233
9234 @sp 1
9235 @cartouche
9236 @noindent
9237 @strong{111}.  Events that cause the version of a compilation unit to
9238 change.  See E.3(5).
9239 @end cartouche
9240 @noindent
9241 Editing the source file of a compilation unit, or the source files of
9242 any units on which it is dependent in a significant way cause the version
9243 to change.  No other actions cause the version number to change.  All changes
9244 are significant except those which affect only layout, capitalization or
9245 comments.
9246
9247 @sp 1
9248 @cartouche
9249 @noindent
9250 @strong{112}.  Whether the execution of the remote subprogram is
9251 immediately aborted as a result of cancellation.  See E.4(13).
9252 @end cartouche
9253 @noindent
9254 See the GLADE reference manual for details on the effect of abort in
9255 a distributed application.
9256
9257 @sp 1
9258 @cartouche
9259 @noindent
9260 @strong{113}.  Implementation-defined aspects of the PCS@.  See E.5(25).
9261 @end cartouche
9262 @noindent
9263 See the GLADE reference manual for a full description of all implementation
9264 defined aspects of the PCS@.
9265
9266 @sp 1
9267 @cartouche
9268 @noindent
9269 @strong{114}.  Implementation-defined interfaces in the PCS@.  See
9270 E.5(26).
9271 @end cartouche
9272 @noindent
9273 See the GLADE reference manual for a full description of all
9274 implementation defined interfaces.
9275
9276 @sp 1
9277 @cartouche
9278 @noindent
9279 @strong{115}.  The values of named numbers in the package
9280 @code{Decimal}.  See F.2(7).
9281 @end cartouche
9282 @noindent
9283 @table @code
9284 @item Max_Scale
9285 +18
9286 @item Min_Scale
9287 -18
9288 @item Min_Delta
9289 1.0E-18
9290 @item Max_Delta
9291 1.0E+18
9292 @item Max_Decimal_Digits
9293 18
9294 @end table
9295
9296 @sp 1
9297 @cartouche
9298 @noindent
9299 @strong{116}.  The value of @code{Max_Picture_Length} in the package
9300 @code{Text_IO.Editing}.  See F.3.3(16).
9301 @end cartouche
9302 @noindent
9303 64
9304
9305 @sp 1
9306 @cartouche
9307 @noindent
9308 @strong{117}.  The value of @code{Max_Picture_Length} in the package
9309 @code{Wide_Text_IO.Editing}.  See F.3.4(5).
9310 @end cartouche
9311 @noindent
9312 64
9313
9314 @sp 1
9315 @cartouche
9316 @noindent
9317 @strong{118}.  The accuracy actually achieved by the complex elementary
9318 functions and by other complex arithmetic operations.  See G.1(1).
9319 @end cartouche
9320 @noindent
9321 Standard library functions are used for the complex arithmetic
9322 operations.  Only fast math mode is currently supported.
9323
9324 @sp 1
9325 @cartouche
9326 @noindent
9327 @strong{119}.  The sign of a zero result (or a component thereof) from
9328 any operator or function in @code{Numerics.Generic_Complex_Types}, when
9329 @code{Real'Signed_Zeros} is True.  See G.1.1(53).
9330 @end cartouche
9331 @noindent
9332 The signs of zero values are as recommended by the relevant
9333 implementation advice.
9334
9335 @sp 1
9336 @cartouche
9337 @noindent
9338 @strong{120}.  The sign of a zero result (or a component thereof) from
9339 any operator or function in
9340 @code{Numerics.Generic_Complex_Elementary_Functions}, when
9341 @code{Real'Signed_Zeros} is @code{True}.  See G.1.2(45).
9342 @end cartouche
9343 @noindent
9344 The signs of zero values are as recommended by the relevant
9345 implementation advice.
9346
9347 @sp 1
9348 @cartouche
9349 @noindent
9350 @strong{121}.  Whether the strict mode or the relaxed mode is the
9351 default.  See G.2(2).
9352 @end cartouche
9353 @noindent
9354 The strict mode is the default.  There is no separate relaxed mode.  GNAT
9355 provides a highly efficient implementation of strict mode.
9356
9357 @sp 1
9358 @cartouche
9359 @noindent
9360 @strong{122}.  The result interval in certain cases of fixed-to-float
9361 conversion.  See G.2.1(10).
9362 @end cartouche
9363 @noindent
9364 For cases where the result interval is implementation dependent, the
9365 accuracy is that provided by performing all operations in 64-bit IEEE
9366 floating-point format.
9367
9368 @sp 1
9369 @cartouche
9370 @noindent
9371 @strong{123}.  The result of a floating point arithmetic operation in
9372 overflow situations, when the @code{Machine_Overflows} attribute of the
9373 result type is @code{False}.  See G.2.1(13).
9374 @end cartouche
9375 @noindent
9376 Infinite and NaN values are produced as dictated by the IEEE
9377 floating-point standard.
9378
9379 Note that on machines that are not fully compliant with the IEEE
9380 floating-point standard, such as Alpha, the @option{-mieee} compiler flag
9381 must be used for achieving IEEE confirming behavior (although at the cost
9382 of a significant performance penalty), so infinite and NaN values are
9383 properly generated.
9384
9385 @sp 1
9386 @cartouche
9387 @noindent
9388 @strong{124}.  The result interval for division (or exponentiation by a
9389 negative exponent), when the floating point hardware implements division
9390 as multiplication by a reciprocal.  See G.2.1(16).
9391 @end cartouche
9392 @noindent
9393 Not relevant, division is IEEE exact.
9394
9395 @sp 1
9396 @cartouche
9397 @noindent
9398 @strong{125}.  The definition of close result set, which determines the
9399 accuracy of certain fixed point multiplications and divisions.  See
9400 G.2.3(5).
9401 @end cartouche
9402 @noindent
9403 Operations in the close result set are performed using IEEE long format
9404 floating-point arithmetic.  The input operands are converted to
9405 floating-point, the operation is done in floating-point, and the result
9406 is converted to the target type.
9407
9408 @sp 1
9409 @cartouche
9410 @noindent
9411 @strong{126}.  Conditions on a @code{universal_real} operand of a fixed
9412 point multiplication or division for which the result shall be in the
9413 perfect result set.  See G.2.3(22).
9414 @end cartouche
9415 @noindent
9416 The result is only defined to be in the perfect result set if the result
9417 can be computed by a single scaling operation involving a scale factor
9418 representable in 64-bits.
9419
9420 @sp 1
9421 @cartouche
9422 @noindent
9423 @strong{127}.  The result of a fixed point arithmetic operation in
9424 overflow situations, when the @code{Machine_Overflows} attribute of the
9425 result type is @code{False}.  See G.2.3(27).
9426 @end cartouche
9427 @noindent
9428 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
9429 types.
9430
9431 @sp 1
9432 @cartouche
9433 @noindent
9434 @strong{128}.  The result of an elementary function reference in
9435 overflow situations, when the @code{Machine_Overflows} attribute of the
9436 result type is @code{False}.  See G.2.4(4).
9437 @end cartouche
9438 @noindent
9439 IEEE infinite and Nan values are produced as appropriate.
9440
9441 @sp 1
9442 @cartouche
9443 @noindent
9444 @strong{129}.  The value of the angle threshold, within which certain
9445 elementary functions, complex arithmetic operations, and complex
9446 elementary functions yield results conforming to a maximum relative
9447 error bound.  See G.2.4(10).
9448 @end cartouche
9449 @noindent
9450 Information on this subject is not yet available.
9451
9452 @sp 1
9453 @cartouche
9454 @noindent
9455 @strong{130}.  The accuracy of certain elementary functions for
9456 parameters beyond the angle threshold.  See G.2.4(10).
9457 @end cartouche
9458 @noindent
9459 Information on this subject is not yet available.
9460
9461 @sp 1
9462 @cartouche
9463 @noindent
9464 @strong{131}.  The result of a complex arithmetic operation or complex
9465 elementary function reference in overflow situations, when the
9466 @code{Machine_Overflows} attribute of the corresponding real type is
9467 @code{False}.  See G.2.6(5).
9468 @end cartouche
9469 @noindent
9470 IEEE infinite and Nan values are produced as appropriate.
9471
9472 @sp 1
9473 @cartouche
9474 @noindent
9475 @strong{132}.  The accuracy of certain complex arithmetic operations and
9476 certain complex elementary functions for parameters (or components
9477 thereof) beyond the angle threshold.  See G.2.6(8).
9478 @end cartouche
9479 @noindent
9480 Information on those subjects is not yet available.
9481
9482 @sp 1
9483 @cartouche
9484 @noindent
9485 @strong{133}.  Information regarding bounded errors and erroneous
9486 execution.  See H.2(1).
9487 @end cartouche
9488 @noindent
9489 Information on this subject is not yet available.
9490
9491 @sp 1
9492 @cartouche
9493 @noindent
9494 @strong{134}.  Implementation-defined aspects of pragma
9495 @code{Inspection_Point}.  See H.3.2(8).
9496 @end cartouche
9497 @noindent
9498 Pragma @code{Inspection_Point} ensures that the variable is live and can
9499 be examined by the debugger at the inspection point.
9500
9501 @sp 1
9502 @cartouche
9503 @noindent
9504 @strong{135}.  Implementation-defined aspects of pragma
9505 @code{Restrictions}.  See H.4(25).
9506 @end cartouche
9507 @noindent
9508 There are no implementation-defined aspects of pragma @code{Restrictions}.  The
9509 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
9510 generated code.  Checks must suppressed by use of pragma @code{Suppress}.
9511
9512 @sp 1
9513 @cartouche
9514 @noindent
9515 @strong{136}.  Any restrictions on pragma @code{Restrictions}.  See
9516 H.4(27).
9517 @end cartouche
9518 @noindent
9519 There are no restrictions on pragma @code{Restrictions}.
9520
9521 @node Intrinsic Subprograms
9522 @chapter Intrinsic Subprograms
9523 @cindex Intrinsic Subprograms
9524
9525 @menu
9526 * Intrinsic Operators::
9527 * Enclosing_Entity::
9528 * Exception_Information::
9529 * Exception_Message::
9530 * Exception_Name::
9531 * File::
9532 * Line::
9533 * Rotate_Left::
9534 * Rotate_Right::
9535 * Shift_Left::
9536 * Shift_Right::
9537 * Shift_Right_Arithmetic::
9538 * Source_Location::
9539 @end menu
9540
9541 @noindent
9542 GNAT allows a user application program to write the declaration:
9543
9544 @smallexample @c ada
9545    pragma Import (Intrinsic, name);
9546 @end smallexample
9547
9548 @noindent
9549 providing that the name corresponds to one of the implemented intrinsic
9550 subprograms in GNAT, and that the parameter profile of the referenced
9551 subprogram meets the requirements.  This chapter describes the set of
9552 implemented intrinsic subprograms, and the requirements on parameter profiles.
9553 Note that no body is supplied; as with other uses of pragma Import, the
9554 body is supplied elsewhere (in this case by the compiler itself).  Note
9555 that any use of this feature is potentially non-portable, since the
9556 Ada standard does not require Ada compilers to implement this feature.
9557
9558 @node Intrinsic Operators
9559 @section Intrinsic Operators
9560 @cindex Intrinsic operator
9561
9562 @noindent
9563 All the predefined numeric operators in package Standard
9564 in @code{pragma Import (Intrinsic,..)}
9565 declarations.  In the binary operator case, the operands must have the same
9566 size.  The operand or operands must also be appropriate for
9567 the operator.  For example, for addition, the operands must
9568 both be floating-point or both be fixed-point, and the
9569 right operand for @code{"**"} must have a root type of
9570 @code{Standard.Integer'Base}.
9571 You can use an intrinsic operator declaration as in the following example:
9572
9573 @smallexample @c ada
9574    type Int1 is new Integer;
9575    type Int2 is new Integer;
9576
9577    function "+" (X1 : Int1; X2 : Int2) return Int1;
9578    function "+" (X1 : Int1; X2 : Int2) return Int2;
9579    pragma Import (Intrinsic, "+");
9580 @end smallexample
9581
9582 @noindent
9583 This declaration would permit ``mixed mode'' arithmetic on items
9584 of the differing types @code{Int1} and @code{Int2}.
9585 It is also possible to specify such operators for private types, if the
9586 full views are appropriate arithmetic types.
9587
9588 @node Enclosing_Entity
9589 @section Enclosing_Entity
9590 @cindex Enclosing_Entity
9591 @noindent
9592 This intrinsic subprogram is used in the implementation of the
9593 library routine @code{GNAT.Source_Info}.  The only useful use of the
9594 intrinsic import in this case is the one in this unit, so an
9595 application program should simply call the function
9596 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
9597 the current subprogram, package, task, entry, or protected subprogram.
9598
9599 @node Exception_Information
9600 @section Exception_Information
9601 @cindex Exception_Information'
9602 @noindent
9603 This intrinsic subprogram is used in the implementation of the
9604 library routine @code{GNAT.Current_Exception}.  The only useful
9605 use of the intrinsic import in this case is the one in this unit,
9606 so an application program should simply call the function
9607 @code{GNAT.Current_Exception.Exception_Information} to obtain
9608 the exception information associated with the current exception.
9609
9610 @node Exception_Message
9611 @section Exception_Message
9612 @cindex Exception_Message
9613 @noindent
9614 This intrinsic subprogram is used in the implementation of the
9615 library routine @code{GNAT.Current_Exception}.  The only useful
9616 use of the intrinsic import in this case is the one in this unit,
9617 so an application program should simply call the function
9618 @code{GNAT.Current_Exception.Exception_Message} to obtain
9619 the message associated with the current exception.
9620
9621 @node Exception_Name
9622 @section Exception_Name
9623 @cindex Exception_Name
9624 @noindent
9625 This intrinsic subprogram is used in the implementation of the
9626 library routine @code{GNAT.Current_Exception}.  The only useful
9627 use of the intrinsic import in this case is the one in this unit,
9628 so an application program should simply call the function
9629 @code{GNAT.Current_Exception.Exception_Name} to obtain
9630 the name of the current exception.
9631
9632 @node File
9633 @section File
9634 @cindex File
9635 @noindent
9636 This intrinsic subprogram is used in the implementation of the
9637 library routine @code{GNAT.Source_Info}.  The only useful use of the
9638 intrinsic import in this case is the one in this unit, so an
9639 application program should simply call the function
9640 @code{GNAT.Source_Info.File} to obtain the name of the current
9641 file.
9642
9643 @node Line
9644 @section Line
9645 @cindex Line
9646 @noindent
9647 This intrinsic subprogram is used in the implementation of the
9648 library routine @code{GNAT.Source_Info}.  The only useful use of the
9649 intrinsic import in this case is the one in this unit, so an
9650 application program should simply call the function
9651 @code{GNAT.Source_Info.Line} to obtain the number of the current
9652 source line.
9653
9654 @node Rotate_Left
9655 @section Rotate_Left
9656 @cindex Rotate_Left
9657 @noindent
9658 In standard Ada, the @code{Rotate_Left} function is available only
9659 for the predefined modular types in package @code{Interfaces}.  However, in
9660 GNAT it is possible to define a Rotate_Left function for a user
9661 defined modular type or any signed integer type as in this example:
9662
9663 @smallexample @c ada
9664    function Shift_Left
9665      (Value  : My_Modular_Type;
9666       Amount : Natural)
9667       return   My_Modular_Type;
9668 @end smallexample
9669
9670 @noindent
9671 The requirements are that the profile be exactly as in the example
9672 above.  The only modifications allowed are in the formal parameter
9673 names, and in the type of @code{Value} and the return type, which
9674 must be the same, and must be either a signed integer type, or
9675 a modular integer type with a binary modulus, and the size must
9676 be 8.  16, 32 or 64 bits.
9677
9678 @node Rotate_Right
9679 @section Rotate_Right
9680 @cindex Rotate_Right
9681 @noindent
9682 A @code{Rotate_Right} function can be defined for any user defined
9683 binary modular integer type, or signed integer type, as described
9684 above for @code{Rotate_Left}.
9685
9686 @node Shift_Left
9687 @section Shift_Left
9688 @cindex Shift_Left
9689 @noindent
9690 A @code{Shift_Left} function can be defined for any user defined
9691 binary modular integer type, or signed integer type, as described
9692 above for @code{Rotate_Left}.
9693
9694 @node Shift_Right
9695 @section Shift_Right
9696 @cindex Shift_Right
9697 @noindent
9698 A @code{Shift_Right} function can be defined for any user defined
9699 binary modular integer type, or signed integer type, as described
9700 above for @code{Rotate_Left}.
9701
9702 @node Shift_Right_Arithmetic
9703 @section Shift_Right_Arithmetic
9704 @cindex Shift_Right_Arithmetic
9705 @noindent
9706 A @code{Shift_Right_Arithmetic} function can be defined for any user
9707 defined binary modular integer type, or signed integer type, as described
9708 above for @code{Rotate_Left}.
9709
9710 @node Source_Location
9711 @section Source_Location
9712 @cindex Source_Location
9713 @noindent
9714 This intrinsic subprogram is used in the implementation of the
9715 library routine @code{GNAT.Source_Info}.  The only useful use of the
9716 intrinsic import in this case is the one in this unit, so an
9717 application program should simply call the function
9718 @code{GNAT.Source_Info.Source_Location} to obtain the current
9719 source file location.
9720
9721 @node Representation Clauses and Pragmas
9722 @chapter Representation Clauses and Pragmas
9723 @cindex Representation Clauses
9724
9725 @menu
9726 * Alignment Clauses::
9727 * Size Clauses::
9728 * Storage_Size Clauses::
9729 * Size of Variant Record Objects::
9730 * Biased Representation ::
9731 * Value_Size and Object_Size Clauses::
9732 * Component_Size Clauses::
9733 * Bit_Order Clauses::
9734 * Effect of Bit_Order on Byte Ordering::
9735 * Pragma Pack for Arrays::
9736 * Pragma Pack for Records::
9737 * Record Representation Clauses::
9738 * Enumeration Clauses::
9739 * Address Clauses::
9740 * Effect of Convention on Representation::
9741 * Determining the Representations chosen by GNAT::
9742 @end menu
9743
9744 @noindent
9745 @cindex Representation Clause
9746 @cindex Representation Pragma
9747 @cindex Pragma, representation
9748 This section describes the representation clauses accepted by GNAT, and
9749 their effect on the representation of corresponding data objects.
9750
9751 GNAT fully implements Annex C (Systems Programming).  This means that all
9752 the implementation advice sections in chapter 13 are fully implemented.
9753 However, these sections only require a minimal level of support for
9754 representation clauses.  GNAT provides much more extensive capabilities,
9755 and this section describes the additional capabilities provided.
9756
9757 @node Alignment Clauses
9758 @section Alignment Clauses
9759 @cindex Alignment Clause
9760
9761 @noindent
9762 GNAT requires that all alignment clauses specify a power of 2, and all
9763 default alignments are always a power of 2.  The default alignment
9764 values are as follows:
9765
9766 @itemize @bullet
9767 @item @emph{Primitive Types}.
9768 For primitive types, the alignment is the minimum of the actual size of
9769 objects of the type divided by @code{Storage_Unit},
9770 and the maximum alignment supported by the target.
9771 (This maximum alignment is given by the GNAT-specific attribute
9772 @code{Standard'Maximum_Alignment}; see @ref{Maximum_Alignment}.)
9773 @cindex @code{Maximum_Alignment} attribute
9774 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
9775 default alignment will be 8 on any target that supports alignments
9776 this large, but on some targets, the maximum alignment may be smaller
9777 than 8, in which case objects of type @code{Long_Float} will be maximally
9778 aligned.
9779
9780 @item @emph{Arrays}.
9781 For arrays, the alignment is equal to the alignment of the component type
9782 for the normal case where no packing or component size is given.  If the
9783 array is packed, and the packing is effective (see separate section on
9784 packed arrays), then the alignment will be one for long packed arrays,
9785 or arrays whose length is not known at compile time.  For short packed
9786 arrays, which are handled internally as modular types, the alignment
9787 will be as described for primitive types, e.g.@: a packed array of length
9788 31 bits will have an object size of four bytes, and an alignment of 4.
9789
9790 @item @emph{Records}.
9791 For the normal non-packed case, the alignment of a record is equal to
9792 the maximum alignment of any of its components.  For tagged records, this
9793 includes the implicit access type used for the tag.  If a pragma @code{Pack}
9794 is used and all components are packable (see separate section on pragma
9795 @code{Pack}), then the resulting alignment is 1, unless the layout of the
9796 record makes it profitable to increase it.
9797
9798 A special case is when:
9799 @itemize @bullet
9800 @item
9801 the size of the record is given explicitly, or a
9802 full record representation clause is given, and
9803 @item
9804 the size of the record is 2, 4, or 8 bytes.
9805 @end itemize
9806 @noindent
9807 In this case, an alignment is chosen to match the
9808 size of the record. For example, if we have:
9809
9810 @smallexample @c ada
9811    type Small is record
9812       A, B : Character;
9813    end record;
9814    for Small'Size use 16;
9815 @end smallexample
9816
9817 @noindent
9818 then the default alignment of the record type @code{Small} is 2, not 1. This
9819 leads to more efficient code when the record is treated as a unit, and also
9820 allows the type to specified as @code{Atomic} on architectures requiring
9821 strict alignment.
9822
9823 @end itemize
9824
9825 @noindent
9826 An alignment clause may specify a larger alignment than the default value
9827 up to some maximum value dependent on the target (obtainable by using the
9828 attribute reference @code{Standard'Maximum_Alignment}). It may also specify
9829 a smaller alignment than the default value for enumeration, integer and
9830 fixed point types, as well as for record types, for example
9831
9832 @smallexample @c ada
9833   type V is record
9834      A : Integer;
9835   end record;
9836
9837   for V'alignment use 1;
9838 @end smallexample
9839
9840 @noindent
9841 @cindex Alignment, default
9842 The default alignment for the type @code{V} is 4, as a result of the
9843 Integer field in the record, but it is permissible, as shown, to
9844 override the default alignment of the record with a smaller value.
9845
9846 @node Size Clauses
9847 @section Size Clauses
9848 @cindex Size Clause
9849
9850 @noindent
9851 The default size for a type @code{T} is obtainable through the
9852 language-defined attribute @code{T'Size} and also through the
9853 equivalent GNAT-defined attribute @code{T'Value_Size}.
9854 For objects of type @code{T}, GNAT will generally increase the type size
9855 so that the object size (obtainable through the GNAT-defined attribute
9856 @code{T'Object_Size})
9857 is a multiple of @code{T'Alignment * Storage_Unit}.
9858 For example
9859
9860 @smallexample @c ada
9861    type Smallint is range 1 .. 6;
9862
9863    type Rec is record
9864       Y1 : integer;
9865       Y2 : boolean;
9866    end record;
9867 @end smallexample
9868
9869 @noindent
9870 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
9871 as specified by the RM rules,
9872 but objects of this type will have a size of 8
9873 (@code{Smallint'Object_Size} = 8),
9874 since objects by default occupy an integral number
9875 of storage units.  On some targets, notably older
9876 versions of the Digital Alpha, the size of stand
9877 alone objects of this type may be 32, reflecting
9878 the inability of the hardware to do byte load/stores.
9879
9880 Similarly, the size of type @code{Rec} is 40 bits
9881 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
9882 the alignment is 4, so objects of this type will have
9883 their size increased to 64 bits so that it is a multiple
9884 of the alignment (in bits).  This decision is
9885 in accordance with the specific Implementation Advice in RM 13.3(43):
9886
9887 @quotation
9888 A @code{Size} clause should be supported for an object if the specified
9889 @code{Size} is at least as large as its subtype's @code{Size}, and corresponds
9890 to a size in storage elements that is a multiple of the object's
9891 @code{Alignment} (if the @code{Alignment} is nonzero).
9892 @end quotation
9893
9894 @noindent
9895 An explicit size clause may be used to override the default size by
9896 increasing it.  For example, if we have:
9897
9898 @smallexample @c ada
9899    type My_Boolean is new Boolean;
9900    for My_Boolean'Size use 32;
9901 @end smallexample
9902
9903 @noindent
9904 then values of this type will always be 32 bits long.  In the case of
9905 discrete types, the size can be increased up to 64 bits, with the effect
9906 that the entire specified field is used to hold the value, sign- or
9907 zero-extended as appropriate.  If more than 64 bits is specified, then
9908 padding space is allocated after the value, and a warning is issued that
9909 there are unused bits.
9910
9911 Similarly the size of records and arrays may be increased, and the effect
9912 is to add padding bits after the value.  This also causes a warning message
9913 to be generated.
9914
9915 The largest Size value permitted in GNAT is 2**31@minus{}1.  Since this is a
9916 Size in bits, this corresponds to an object of size 256 megabytes (minus
9917 one).  This limitation is true on all targets.  The reason for this
9918 limitation is that it improves the quality of the code in many cases
9919 if it is known that a Size value can be accommodated in an object of
9920 type Integer.
9921
9922 @node Storage_Size Clauses
9923 @section Storage_Size Clauses
9924 @cindex Storage_Size Clause
9925
9926 @noindent
9927 For tasks, the @code{Storage_Size} clause specifies the amount of space
9928 to be allocated for the task stack.  This cannot be extended, and if the
9929 stack is exhausted, then @code{Storage_Error} will be raised (if stack
9930 checking is enabled).  Use a @code{Storage_Size} attribute definition clause,
9931 or a @code{Storage_Size} pragma in the task definition to set the
9932 appropriate required size.  A useful technique is to include in every
9933 task definition a pragma of the form:
9934
9935 @smallexample @c ada
9936    pragma Storage_Size (Default_Stack_Size);
9937 @end smallexample
9938
9939 @noindent
9940 Then @code{Default_Stack_Size} can be defined in a global package, and
9941 modified as required. Any tasks requiring stack sizes different from the
9942 default can have an appropriate alternative reference in the pragma.
9943
9944 You can also use the @option{-d} binder switch to modify the default stack
9945 size.
9946
9947 For access types, the @code{Storage_Size} clause specifies the maximum
9948 space available for allocation of objects of the type.  If this space is
9949 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
9950 In the case where the access type is declared local to a subprogram, the
9951 use of a @code{Storage_Size} clause triggers automatic use of a special
9952 predefined storage pool (@code{System.Pool_Size}) that ensures that all
9953 space for the pool is automatically reclaimed on exit from the scope in
9954 which the type is declared.
9955
9956 A special case recognized by the compiler is the specification of a
9957 @code{Storage_Size} of zero for an access type.  This means that no
9958 items can be allocated from the pool, and this is recognized at compile
9959 time, and all the overhead normally associated with maintaining a fixed
9960 size storage pool is eliminated.  Consider the following example:
9961
9962 @smallexample @c ada
9963    procedure p is
9964       type R is array (Natural) of Character;
9965       type P is access all R;
9966       for P'Storage_Size use 0;
9967       --  Above access type intended only for interfacing purposes
9968
9969       y : P;
9970
9971       procedure g (m : P);
9972       pragma Import (C, g);
9973
9974       --  @dots{}
9975
9976    begin
9977       --  @dots{}
9978       y := new R;
9979    end;
9980 @end smallexample
9981
9982 @noindent
9983 As indicated in this example, these dummy storage pools are often useful in
9984 connection with interfacing where no object will ever be allocated.  If you
9985 compile the above example, you get the warning:
9986
9987 @smallexample
9988    p.adb:16:09: warning: allocation from empty storage pool
9989    p.adb:16:09: warning: Storage_Error will be raised at run time
9990 @end smallexample
9991
9992 @noindent
9993 Of course in practice, there will not be any explicit allocators in the
9994 case of such an access declaration.
9995
9996 @node Size of Variant Record Objects
9997 @section Size of Variant Record Objects
9998 @cindex Size, variant record objects
9999 @cindex Variant record objects, size
10000
10001 @noindent
10002 In the case of variant record objects, there is a question whether Size gives
10003 information about a particular variant, or the maximum size required
10004 for any variant.  Consider the following program
10005
10006 @smallexample @c ada
10007 with Text_IO; use Text_IO;
10008 procedure q is
10009    type R1 (A : Boolean := False) is record
10010      case A is
10011        when True  => X : Character;
10012        when False => null;
10013      end case;
10014    end record;
10015
10016    V1 : R1 (False);
10017    V2 : R1;
10018
10019 begin
10020    Put_Line (Integer'Image (V1'Size));
10021    Put_Line (Integer'Image (V2'Size));
10022 end q;
10023 @end smallexample
10024
10025 @noindent
10026 Here we are dealing with a variant record, where the True variant
10027 requires 16 bits, and the False variant requires 8 bits.
10028 In the above example, both V1 and V2 contain the False variant,
10029 which is only 8 bits long.  However, the result of running the
10030 program is:
10031
10032 @smallexample
10033 8
10034 16
10035 @end smallexample
10036
10037 @noindent
10038 The reason for the difference here is that the discriminant value of
10039 V1 is fixed, and will always be False.  It is not possible to assign
10040 a True variant value to V1, therefore 8 bits is sufficient.  On the
10041 other hand, in the case of V2, the initial discriminant value is
10042 False (from the default), but it is possible to assign a True
10043 variant value to V2, therefore 16 bits must be allocated for V2
10044 in the general case, even fewer bits may be needed at any particular
10045 point during the program execution.
10046
10047 As can be seen from the output of this program, the @code{'Size}
10048 attribute applied to such an object in GNAT gives the actual allocated
10049 size of the variable, which is the largest size of any of the variants.
10050 The Ada Reference Manual is not completely clear on what choice should
10051 be made here, but the GNAT behavior seems most consistent with the
10052 language in the RM@.
10053
10054 In some cases, it may be desirable to obtain the size of the current
10055 variant, rather than the size of the largest variant.  This can be
10056 achieved in GNAT by making use of the fact that in the case of a
10057 subprogram parameter, GNAT does indeed return the size of the current
10058 variant (because a subprogram has no way of knowing how much space
10059 is actually allocated for the actual).
10060
10061 Consider the following modified version of the above program:
10062
10063 @smallexample @c ada
10064 with Text_IO; use Text_IO;
10065 procedure q is
10066    type R1 (A : Boolean := False) is record
10067      case A is
10068        when True  => X : Character;
10069        when False => null;
10070      end case;
10071    end record;
10072
10073    V2 : R1;
10074
10075    function Size (V : R1) return Integer is
10076    begin
10077       return V'Size;
10078    end Size;
10079
10080 begin
10081    Put_Line (Integer'Image (V2'Size));
10082    Put_Line (Integer'IMage (Size (V2)));
10083    V2 := (True, 'x');
10084    Put_Line (Integer'Image (V2'Size));
10085    Put_Line (Integer'IMage (Size (V2)));
10086 end q;
10087 @end smallexample
10088
10089 @noindent
10090 The output from this program is
10091
10092 @smallexample
10093 16
10094 8
10095 16
10096 16
10097 @end smallexample
10098
10099 @noindent
10100 Here we see that while the @code{'Size} attribute always returns
10101 the maximum size, regardless of the current variant value, the
10102 @code{Size} function does indeed return the size of the current
10103 variant value.
10104
10105 @node Biased Representation
10106 @section Biased Representation
10107 @cindex Size for biased representation
10108 @cindex Biased representation
10109
10110 @noindent
10111 In the case of scalars with a range starting at other than zero, it is
10112 possible in some cases to specify a size smaller than the default minimum
10113 value, and in such cases, GNAT uses an unsigned biased representation,
10114 in which zero is used to represent the lower bound, and successive values
10115 represent successive values of the type.
10116
10117 For example, suppose we have the declaration:
10118
10119 @smallexample @c ada
10120    type Small is range -7 .. -4;
10121    for Small'Size use 2;
10122 @end smallexample
10123
10124 @noindent
10125 Although the default size of type @code{Small} is 4, the @code{Size}
10126 clause is accepted by GNAT and results in the following representation
10127 scheme:
10128
10129 @smallexample
10130   -7 is represented as 2#00#
10131   -6 is represented as 2#01#
10132   -5 is represented as 2#10#
10133   -4 is represented as 2#11#
10134 @end smallexample
10135
10136 @noindent
10137 Biased representation is only used if the specified @code{Size} clause
10138 cannot be accepted in any other manner.  These reduced sizes that force
10139 biased representation can be used for all discrete types except for
10140 enumeration types for which a representation clause is given.
10141
10142 @node Value_Size and Object_Size Clauses
10143 @section Value_Size and Object_Size Clauses
10144 @findex Value_Size
10145 @findex Object_Size
10146 @cindex Size, of objects
10147
10148 @noindent
10149 In Ada 95 and Ada 2005, @code{T'Size} for a type @code{T} is the minimum
10150 number of bits required to hold values of type @code{T}.
10151 Although this interpretation was allowed in Ada 83, it was not required,
10152 and this requirement in practice can cause some significant difficulties.
10153 For example, in most Ada 83 compilers, @code{Natural'Size} was 32.
10154 However, in Ada 95 and Ada 2005,
10155 @code{Natural'Size} is
10156 typically 31.  This means that code may change in behavior when moving
10157 from Ada 83 to Ada 95 or Ada 2005.  For example, consider:
10158
10159 @smallexample @c ada
10160    type Rec is record;
10161       A : Natural;
10162       B : Natural;
10163    end record;
10164
10165    for Rec use record
10166       at 0  range 0 .. Natural'Size - 1;
10167       at 0  range Natural'Size .. 2 * Natural'Size - 1;
10168    end record;
10169 @end smallexample
10170
10171 @noindent
10172 In the above code, since the typical size of @code{Natural} objects
10173 is 32 bits and @code{Natural'Size} is 31, the above code can cause
10174 unexpected inefficient packing in Ada 95 and Ada 2005, and in general
10175 there are cases where the fact that the object size can exceed the
10176 size of the type causes surprises.
10177
10178 To help get around this problem GNAT provides two implementation
10179 defined attributes, @code{Value_Size} and @code{Object_Size}.  When
10180 applied to a type, these attributes yield the size of the type
10181 (corresponding to the RM defined size attribute), and the size of
10182 objects of the type respectively.
10183
10184 The @code{Object_Size} is used for determining the default size of
10185 objects and components.  This size value can be referred to using the
10186 @code{Object_Size} attribute.  The phrase ``is used'' here means that it is
10187 the basis of the determination of the size.  The backend is free to
10188 pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
10189 character might be stored in 32 bits on a machine with no efficient
10190 byte access instructions such as the Alpha.
10191
10192 The default rules for the value of @code{Object_Size} for
10193 discrete types are as follows:
10194
10195 @itemize @bullet
10196 @item
10197 The @code{Object_Size} for base subtypes reflect the natural hardware
10198 size in bits (run the compiler with @option{-gnatS} to find those values
10199 for numeric types). Enumeration types and fixed-point base subtypes have
10200 8, 16, 32 or 64 bits for this size, depending on the range of values
10201 to be stored.
10202
10203 @item
10204 The @code{Object_Size} of a subtype is the same as the
10205 @code{Object_Size} of
10206 the type from which it is obtained.
10207
10208 @item
10209 The @code{Object_Size} of a derived base type is copied from the parent
10210 base type, and the @code{Object_Size} of a derived first subtype is copied
10211 from the parent first subtype.
10212 @end itemize
10213
10214 @noindent
10215 The @code{Value_Size} attribute
10216 is the (minimum) number of bits required to store a value
10217 of the type.
10218 This value is used to determine how tightly to pack
10219 records or arrays with components of this type, and also affects
10220 the semantics of unchecked conversion (unchecked conversions where
10221 the @code{Value_Size} values differ generate a warning, and are potentially
10222 target dependent).
10223
10224 The default rules for the value of @code{Value_Size} are as follows:
10225
10226 @itemize @bullet
10227 @item
10228 The @code{Value_Size} for a base subtype is the minimum number of bits
10229 required to store all values of the type (including the sign bit
10230 only if negative values are possible).
10231
10232 @item
10233 If a subtype statically matches the first subtype of a given type, then it has
10234 by default the same @code{Value_Size} as the first subtype.  This is a
10235 consequence of RM 13.1(14) (``if two subtypes statically match,
10236 then their subtype-specific aspects are the same''.)
10237
10238 @item
10239 All other subtypes have a @code{Value_Size} corresponding to the minimum
10240 number of bits required to store all values of the subtype.  For
10241 dynamic bounds, it is assumed that the value can range down or up
10242 to the corresponding bound of the ancestor
10243 @end itemize
10244
10245 @noindent
10246 The RM defined attribute @code{Size} corresponds to the
10247 @code{Value_Size} attribute.
10248
10249 The @code{Size} attribute may be defined for a first-named subtype.  This sets
10250 the @code{Value_Size} of
10251 the first-named subtype to the given value, and the
10252 @code{Object_Size} of this first-named subtype to the given value padded up
10253 to an appropriate boundary.  It is a consequence of the default rules
10254 above that this @code{Object_Size} will apply to all further subtypes.  On the
10255 other hand, @code{Value_Size} is affected only for the first subtype, any
10256 dynamic subtypes obtained from it directly, and any statically matching
10257 subtypes.  The @code{Value_Size} of any other static subtypes is not affected.
10258
10259 @code{Value_Size} and
10260 @code{Object_Size} may be explicitly set for any subtype using
10261 an attribute definition clause.  Note that the use of these attributes
10262 can cause the RM 13.1(14) rule to be violated.  If two access types
10263 reference aliased objects whose subtypes have differing @code{Object_Size}
10264 values as a result of explicit attribute definition clauses, then it
10265 is erroneous to convert from one access subtype to the other.
10266
10267 At the implementation level, Esize stores the Object_Size and the
10268 RM_Size field stores the @code{Value_Size} (and hence the value of the
10269 @code{Size} attribute,
10270 which, as noted above, is equivalent to @code{Value_Size}).
10271
10272 To get a feel for the difference, consider the following examples (note
10273 that in each case the base is @code{Short_Short_Integer} with a size of 8):
10274
10275 @smallexample
10276                                        Object_Size     Value_Size
10277
10278 type x1 is range 0 .. 5;                    8               3
10279
10280 type x2 is range 0 .. 5;
10281 for x2'size use 12;                        16              12
10282
10283 subtype x3 is x2 range 0 .. 3;             16               2
10284
10285 subtype x4 is x2'base range 0 .. 10;        8               4
10286
10287 subtype x5 is x2 range 0 .. dynamic;       16               3*
10288
10289 subtype x6 is x2'base range 0 .. dynamic;   8               3*
10290
10291 @end smallexample
10292
10293 @noindent
10294 Note: the entries marked ``3*'' are not actually specified by the Ada
10295 Reference Manual, but it seems in the spirit of the RM rules to allocate
10296 the minimum number of bits (here 3, given the range for @code{x2})
10297 known to be large enough to hold the given range of values.
10298
10299 So far, so good, but GNAT has to obey the RM rules, so the question is
10300 under what conditions must the RM @code{Size} be used.
10301 The following is a list
10302 of the occasions on which the RM @code{Size} must be used:
10303
10304 @itemize @bullet
10305 @item
10306 Component size for packed arrays or records
10307
10308 @item
10309 Value of the attribute @code{Size} for a type
10310
10311 @item
10312 Warning about sizes not matching for unchecked conversion
10313 @end itemize
10314
10315 @noindent
10316 For record types, the @code{Object_Size} is always a multiple of the
10317 alignment of the type (this is true for all types). In some cases the
10318 @code{Value_Size} can be smaller. Consider:
10319
10320 @smallexample
10321    type R is record
10322      X : Integer;
10323      Y : Character;
10324    end record;
10325 @end smallexample
10326
10327 @noindent
10328 On a typical 32-bit architecture, the X component will be four bytes, and
10329 require four-byte alignment, and the Y component will be one byte. In this
10330 case @code{R'Value_Size} will be 40 (bits) since this is the minimum size
10331 required to store a value of this type, and for example, it is permissible
10332 to have a component of type R in an outer record whose component size is
10333 specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits),
10334 since it must be rounded up so that this value is a multiple of the
10335 alignment (4 bytes = 32 bits).
10336
10337 @noindent
10338 For all other types, the @code{Object_Size}
10339 and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
10340 Only @code{Size} may be specified for such types.
10341
10342 @node Component_Size Clauses
10343 @section Component_Size Clauses
10344 @cindex Component_Size Clause
10345
10346 @noindent
10347 Normally, the value specified in a component size clause must be consistent
10348 with the subtype of the array component with regard to size and alignment.
10349 In other words, the value specified must be at least equal to the size
10350 of this subtype, and must be a multiple of the alignment value.
10351
10352 In addition, component size clauses are allowed which cause the array
10353 to be packed, by specifying a smaller value.  A first case is for
10354 component size values in the range 1 through 63.  The value specified
10355 must not be smaller than the Size of the subtype.  GNAT will accurately
10356 honor all packing requests in this range.  For example, if we have:
10357
10358 @smallexample @c ada
10359 type r is array (1 .. 8) of Natural;
10360 for r'Component_Size use 31;
10361 @end smallexample
10362
10363 @noindent
10364 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
10365 Of course access to the components of such an array is considerably
10366 less efficient than if the natural component size of 32 is used.
10367 A second case is when the subtype of the component is a record type
10368 padded because of its default alignment.  For example, if we have:
10369
10370 @smallexample @c ada
10371 type r is record
10372   i : Integer;
10373   j : Integer;
10374   b : Boolean;
10375 end record;
10376
10377 type a is array (1 .. 8) of r;
10378 for a'Component_Size use 72;
10379 @end smallexample
10380
10381 @noindent
10382 then the resulting array has a length of 72 bytes, instead of 96 bytes
10383 if the alignment of the record (4) was obeyed.
10384
10385 Note that there is no point in giving both a component size clause
10386 and a pragma Pack for the same array type. if such duplicate
10387 clauses are given, the pragma Pack will be ignored.
10388
10389 @node Bit_Order Clauses
10390 @section Bit_Order Clauses
10391 @cindex Bit_Order Clause
10392 @cindex bit ordering
10393 @cindex ordering, of bits
10394
10395 @noindent
10396 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
10397 attribute.  The specification may either correspond to the default bit
10398 order for the target, in which case the specification has no effect and
10399 places no additional restrictions, or it may be for the non-standard
10400 setting (that is the opposite of the default).
10401
10402 In the case where the non-standard value is specified, the effect is
10403 to renumber bits within each byte, but the ordering of bytes is not
10404 affected.  There are certain
10405 restrictions placed on component clauses as follows:
10406
10407 @itemize @bullet
10408
10409 @item Components fitting within a single storage unit.
10410 @noindent
10411 These are unrestricted, and the effect is merely to renumber bits.  For
10412 example if we are on a little-endian machine with @code{Low_Order_First}
10413 being the default, then the following two declarations have exactly
10414 the same effect:
10415
10416 @smallexample @c ada
10417    type R1 is record
10418       A : Boolean;
10419       B : Integer range 1 .. 120;
10420    end record;
10421
10422    for R1 use record
10423       A at 0 range 0 .. 0;
10424       B at 0 range 1 .. 7;
10425    end record;
10426
10427    type R2 is record
10428       A : Boolean;
10429       B : Integer range 1 .. 120;
10430    end record;
10431
10432    for R2'Bit_Order use High_Order_First;
10433
10434    for R2 use record
10435       A at 0 range 7 .. 7;
10436       B at 0 range 0 .. 6;
10437    end record;
10438 @end smallexample
10439
10440 @noindent
10441 The useful application here is to write the second declaration with the
10442 @code{Bit_Order} attribute definition clause, and know that it will be treated
10443 the same, regardless of whether the target is little-endian or big-endian.
10444
10445 @item Components occupying an integral number of bytes.
10446 @noindent
10447 These are components that exactly fit in two or more bytes.  Such component
10448 declarations are allowed, but have no effect, since it is important to realize
10449 that the @code{Bit_Order} specification does not affect the ordering of bytes.
10450 In particular, the following attempt at getting an endian-independent integer
10451 does not work:
10452
10453 @smallexample @c ada
10454    type R2 is record
10455       A : Integer;
10456    end record;
10457
10458    for R2'Bit_Order use High_Order_First;
10459
10460    for R2 use record
10461       A at 0 range 0 .. 31;
10462    end record;
10463 @end smallexample
10464
10465 @noindent
10466 This declaration will result in a little-endian integer on a
10467 little-endian machine, and a big-endian integer on a big-endian machine.
10468 If byte flipping is required for interoperability between big- and
10469 little-endian machines, this must be explicitly programmed.  This capability
10470 is not provided by @code{Bit_Order}.
10471
10472 @item Components that are positioned across byte boundaries
10473 @noindent
10474 but do not occupy an integral number of bytes.  Given that bytes are not
10475 reordered, such fields would occupy a non-contiguous sequence of bits
10476 in memory, requiring non-trivial code to reassemble.  They are for this
10477 reason not permitted, and any component clause specifying such a layout
10478 will be flagged as illegal by GNAT@.
10479
10480 @end itemize
10481
10482 @noindent
10483 Since the misconception that Bit_Order automatically deals with all
10484 endian-related incompatibilities is a common one, the specification of
10485 a component field that is an integral number of bytes will always
10486 generate a warning.  This warning may be suppressed using @code{pragma
10487 Warnings (Off)} if desired.  The following section contains additional
10488 details regarding the issue of byte ordering.
10489
10490 @node Effect of Bit_Order on Byte Ordering
10491 @section Effect of Bit_Order on Byte Ordering
10492 @cindex byte ordering
10493 @cindex ordering, of bytes
10494
10495 @noindent
10496 In this section we will review the effect of the @code{Bit_Order} attribute
10497 definition clause on byte ordering.  Briefly, it has no effect at all, but
10498 a detailed example will be helpful.  Before giving this
10499 example, let us review the precise
10500 definition of the effect of defining @code{Bit_Order}.  The effect of a
10501 non-standard bit order is described in section 15.5.3 of the Ada
10502 Reference Manual:
10503
10504 @quotation
10505 2   A bit ordering is a method of interpreting the meaning of
10506 the storage place attributes.
10507 @end quotation
10508
10509 @noindent
10510 To understand the precise definition of storage place attributes in
10511 this context, we visit section 13.5.1 of the manual:
10512
10513 @quotation
10514 13   A record_representation_clause (without the mod_clause)
10515 specifies the layout.  The storage place attributes (see 13.5.2)
10516 are taken from the values of the position, first_bit, and last_bit
10517 expressions after normalizing those values so that first_bit is
10518 less than Storage_Unit.
10519 @end quotation
10520
10521 @noindent
10522 The critical point here is that storage places are taken from
10523 the values after normalization, not before.  So the @code{Bit_Order}
10524 interpretation applies to normalized values.  The interpretation
10525 is described in the later part of the 15.5.3 paragraph:
10526
10527 @quotation
10528 2   A bit ordering is a method of interpreting the meaning of
10529 the storage place attributes.  High_Order_First (known in the
10530 vernacular as ``big endian'') means that the first bit of a
10531 storage element (bit 0) is the most significant bit (interpreting
10532 the sequence of bits that represent a component as an unsigned
10533 integer value).  Low_Order_First (known in the vernacular as
10534 ``little endian'') means the opposite: the first bit is the
10535 least significant.
10536 @end quotation
10537
10538 @noindent
10539 Note that the numbering is with respect to the bits of a storage
10540 unit.  In other words, the specification affects only the numbering
10541 of bits within a single storage unit.
10542
10543 We can make the effect clearer by giving an example.
10544
10545 Suppose that we have an external device which presents two bytes, the first
10546 byte presented, which is the first (low addressed byte) of the two byte
10547 record is called Master, and the second byte is called Slave.
10548
10549 The left most (most significant bit is called Control for each byte, and
10550 the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
10551 (least significant) bit.
10552
10553 On a big-endian machine, we can write the following representation clause
10554
10555 @smallexample @c ada
10556    type Data is record
10557       Master_Control : Bit;
10558       Master_V1      : Bit;
10559       Master_V2      : Bit;
10560       Master_V3      : Bit;
10561       Master_V4      : Bit;
10562       Master_V5      : Bit;
10563       Master_V6      : Bit;
10564       Master_V7      : Bit;
10565       Slave_Control  : Bit;
10566       Slave_V1       : Bit;
10567       Slave_V2       : Bit;
10568       Slave_V3       : Bit;
10569       Slave_V4       : Bit;
10570       Slave_V5       : Bit;
10571       Slave_V6       : Bit;
10572       Slave_V7       : Bit;
10573    end record;
10574
10575    for Data use record
10576       Master_Control at 0 range 0 .. 0;
10577       Master_V1      at 0 range 1 .. 1;
10578       Master_V2      at 0 range 2 .. 2;
10579       Master_V3      at 0 range 3 .. 3;
10580       Master_V4      at 0 range 4 .. 4;
10581       Master_V5      at 0 range 5 .. 5;
10582       Master_V6      at 0 range 6 .. 6;
10583       Master_V7      at 0 range 7 .. 7;
10584       Slave_Control  at 1 range 0 .. 0;
10585       Slave_V1       at 1 range 1 .. 1;
10586       Slave_V2       at 1 range 2 .. 2;
10587       Slave_V3       at 1 range 3 .. 3;
10588       Slave_V4       at 1 range 4 .. 4;
10589       Slave_V5       at 1 range 5 .. 5;
10590       Slave_V6       at 1 range 6 .. 6;
10591       Slave_V7       at 1 range 7 .. 7;
10592    end record;
10593 @end smallexample
10594
10595 @noindent
10596 Now if we move this to a little endian machine, then the bit ordering within
10597 the byte is backwards, so we have to rewrite the record rep clause as:
10598
10599 @smallexample @c ada
10600    for Data use record
10601       Master_Control at 0 range 7 .. 7;
10602       Master_V1      at 0 range 6 .. 6;
10603       Master_V2      at 0 range 5 .. 5;
10604       Master_V3      at 0 range 4 .. 4;
10605       Master_V4      at 0 range 3 .. 3;
10606       Master_V5      at 0 range 2 .. 2;
10607       Master_V6      at 0 range 1 .. 1;
10608       Master_V7      at 0 range 0 .. 0;
10609       Slave_Control  at 1 range 7 .. 7;
10610       Slave_V1       at 1 range 6 .. 6;
10611       Slave_V2       at 1 range 5 .. 5;
10612       Slave_V3       at 1 range 4 .. 4;
10613       Slave_V4       at 1 range 3 .. 3;
10614       Slave_V5       at 1 range 2 .. 2;
10615       Slave_V6       at 1 range 1 .. 1;
10616       Slave_V7       at 1 range 0 .. 0;
10617    end record;
10618 @end smallexample
10619
10620 @noindent
10621 It is a nuisance to have to rewrite the clause, especially if
10622 the code has to be maintained on both machines.  However,
10623 this is a case that we can handle with the
10624 @code{Bit_Order} attribute if it is implemented.
10625 Note that the implementation is not required on byte addressed
10626 machines, but it is indeed implemented in GNAT.
10627 This means that we can simply use the
10628 first record clause, together with the declaration
10629
10630 @smallexample @c ada
10631    for Data'Bit_Order use High_Order_First;
10632 @end smallexample
10633
10634 @noindent
10635 and the effect is what is desired, namely the layout is exactly the same,
10636 independent of whether the code is compiled on a big-endian or little-endian
10637 machine.
10638
10639 The important point to understand is that byte ordering is not affected.
10640 A @code{Bit_Order} attribute definition never affects which byte a field
10641 ends up in, only where it ends up in that byte.
10642 To make this clear, let us rewrite the record rep clause of the previous
10643 example as:
10644
10645 @smallexample @c ada
10646    for Data'Bit_Order use High_Order_First;
10647    for Data use record
10648       Master_Control at 0 range  0 .. 0;
10649       Master_V1      at 0 range  1 .. 1;
10650       Master_V2      at 0 range  2 .. 2;
10651       Master_V3      at 0 range  3 .. 3;
10652       Master_V4      at 0 range  4 .. 4;
10653       Master_V5      at 0 range  5 .. 5;
10654       Master_V6      at 0 range  6 .. 6;
10655       Master_V7      at 0 range  7 .. 7;
10656       Slave_Control  at 0 range  8 .. 8;
10657       Slave_V1       at 0 range  9 .. 9;
10658       Slave_V2       at 0 range 10 .. 10;
10659       Slave_V3       at 0 range 11 .. 11;
10660       Slave_V4       at 0 range 12 .. 12;
10661       Slave_V5       at 0 range 13 .. 13;
10662       Slave_V6       at 0 range 14 .. 14;
10663       Slave_V7       at 0 range 15 .. 15;
10664    end record;
10665 @end smallexample
10666
10667 @noindent
10668 This is exactly equivalent to saying (a repeat of the first example):
10669
10670 @smallexample @c ada
10671    for Data'Bit_Order use High_Order_First;
10672    for Data use record
10673       Master_Control at 0 range 0 .. 0;
10674       Master_V1      at 0 range 1 .. 1;
10675       Master_V2      at 0 range 2 .. 2;
10676       Master_V3      at 0 range 3 .. 3;
10677       Master_V4      at 0 range 4 .. 4;
10678       Master_V5      at 0 range 5 .. 5;
10679       Master_V6      at 0 range 6 .. 6;
10680       Master_V7      at 0 range 7 .. 7;
10681       Slave_Control  at 1 range 0 .. 0;
10682       Slave_V1       at 1 range 1 .. 1;
10683       Slave_V2       at 1 range 2 .. 2;
10684       Slave_V3       at 1 range 3 .. 3;
10685       Slave_V4       at 1 range 4 .. 4;
10686       Slave_V5       at 1 range 5 .. 5;
10687       Slave_V6       at 1 range 6 .. 6;
10688       Slave_V7       at 1 range 7 .. 7;
10689    end record;
10690 @end smallexample
10691
10692 @noindent
10693 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
10694 field.  The storage place attributes are obtained by normalizing the
10695 values given so that the @code{First_Bit} value is less than 8.  After
10696 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
10697 we specified in the other case.
10698
10699 Now one might expect that the @code{Bit_Order} attribute might affect
10700 bit numbering within the entire record component (two bytes in this
10701 case, thus affecting which byte fields end up in), but that is not
10702 the way this feature is defined, it only affects numbering of bits,
10703 not which byte they end up in.
10704
10705 Consequently it never makes sense to specify a starting bit number
10706 greater than 7 (for a byte addressable field) if an attribute
10707 definition for @code{Bit_Order} has been given, and indeed it
10708 may be actively confusing to specify such a value, so the compiler
10709 generates a warning for such usage.
10710
10711 If you do need to control byte ordering then appropriate conditional
10712 values must be used.  If in our example, the slave byte came first on
10713 some machines we might write:
10714
10715 @smallexample @c ada
10716    Master_Byte_First constant Boolean := @dots{};
10717
10718    Master_Byte : constant Natural :=
10719                    1 - Boolean'Pos (Master_Byte_First);
10720    Slave_Byte  : constant Natural :=
10721                    Boolean'Pos (Master_Byte_First);
10722
10723    for Data'Bit_Order use High_Order_First;
10724    for Data use record
10725       Master_Control at Master_Byte range 0 .. 0;
10726       Master_V1      at Master_Byte range 1 .. 1;
10727       Master_V2      at Master_Byte range 2 .. 2;
10728       Master_V3      at Master_Byte range 3 .. 3;
10729       Master_V4      at Master_Byte range 4 .. 4;
10730       Master_V5      at Master_Byte range 5 .. 5;
10731       Master_V6      at Master_Byte range 6 .. 6;
10732       Master_V7      at Master_Byte range 7 .. 7;
10733       Slave_Control  at Slave_Byte  range 0 .. 0;
10734       Slave_V1       at Slave_Byte  range 1 .. 1;
10735       Slave_V2       at Slave_Byte  range 2 .. 2;
10736       Slave_V3       at Slave_Byte  range 3 .. 3;
10737       Slave_V4       at Slave_Byte  range 4 .. 4;
10738       Slave_V5       at Slave_Byte  range 5 .. 5;
10739       Slave_V6       at Slave_Byte  range 6 .. 6;
10740       Slave_V7       at Slave_Byte  range 7 .. 7;
10741    end record;
10742 @end smallexample
10743
10744 @noindent
10745 Now to switch between machines, all that is necessary is
10746 to set the boolean constant @code{Master_Byte_First} in
10747 an appropriate manner.
10748
10749 @node Pragma Pack for Arrays
10750 @section Pragma Pack for Arrays
10751 @cindex Pragma Pack (for arrays)
10752
10753 @noindent
10754 Pragma @code{Pack} applied to an array has no effect unless the component type
10755 is packable.  For a component type to be packable, it must be one of the
10756 following cases:
10757
10758 @itemize @bullet
10759 @item
10760 Any scalar type
10761 @item
10762 Any type whose size is specified with a size clause
10763 @item
10764 Any packed array type with a static size
10765 @item
10766 Any record type padded because of its default alignment
10767 @end itemize
10768
10769 @noindent
10770 For all these cases, if the component subtype size is in the range
10771 1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
10772 component size were specified giving the component subtype size.
10773 For example if we have:
10774
10775 @smallexample @c ada
10776    type r is range 0 .. 17;
10777
10778    type ar is array (1 .. 8) of r;
10779    pragma Pack (ar);
10780 @end smallexample
10781
10782 @noindent
10783 Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
10784 and the size of the array @code{ar} will be exactly 40 bits.
10785
10786 Note that in some cases this rather fierce approach to packing can produce
10787 unexpected effects.  For example, in Ada 95 and Ada 2005,
10788 subtype @code{Natural} typically has a size of 31, meaning that if you
10789 pack an array of @code{Natural}, you get 31-bit
10790 close packing, which saves a few bits, but results in far less efficient
10791 access.  Since many other Ada compilers will ignore such a packing request,
10792 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
10793 might not be what is intended.  You can easily remove this warning by
10794 using an explicit @code{Component_Size} setting instead, which never generates
10795 a warning, since the intention of the programmer is clear in this case.
10796
10797 GNAT treats packed arrays in one of two ways.  If the size of the array is
10798 known at compile time and is less than 64 bits, then internally the array
10799 is represented as a single modular type, of exactly the appropriate number
10800 of bits.  If the length is greater than 63 bits, or is not known at compile
10801 time, then the packed array is represented as an array of bytes, and the
10802 length is always a multiple of 8 bits.
10803
10804 Note that to represent a packed array as a modular type, the alignment must
10805 be suitable for the modular type involved. For example, on typical machines
10806 a 32-bit packed array will be represented by a 32-bit modular integer with
10807 an alignment of four bytes. If you explicitly override the default alignment
10808 with an alignment clause that is too small, the modular representation
10809 cannot be used. For example, consider the following set of declarations:
10810
10811 @smallexample @c ada
10812    type R is range 1 .. 3;
10813    type S is array (1 .. 31) of R;
10814    for S'Component_Size use 2;
10815    for S'Size use 62;
10816    for S'Alignment use 1;
10817 @end smallexample
10818
10819 @noindent
10820 If the alignment clause were not present, then a 62-bit modular
10821 representation would be chosen (typically with an alignment of 4 or 8
10822 bytes depending on the target). But the default alignment is overridden
10823 with the explicit alignment clause. This means that the modular
10824 representation cannot be used, and instead the array of bytes
10825 representation must be used, meaning that the length must be a multiple
10826 of 8. Thus the above set of declarations will result in a diagnostic
10827 rejecting the size clause and noting that the minimum size allowed is 64.
10828
10829 @cindex Pragma Pack (for type Natural)
10830 @cindex Pragma Pack warning
10831
10832 One special case that is worth noting occurs when the base type of the
10833 component size is 8/16/32 and the subtype is one bit less. Notably this
10834 occurs with subtype @code{Natural}. Consider:
10835
10836 @smallexample @c ada
10837    type Arr is array (1 .. 32) of Natural;
10838    pragma Pack (Arr);
10839 @end smallexample
10840
10841 @noindent
10842 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
10843 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
10844 Ada 83 compilers did not attempt 31 bit packing.
10845
10846 In Ada 95 and Ada 2005, @code{Natural'Size} is required to be 31. Furthermore,
10847 GNAT really does pack 31-bit subtype to 31 bits. This may result in a
10848 substantial unintended performance penalty when porting legacy Ada 83 code.
10849 To help prevent this, GNAT generates a warning in such cases. If you really
10850 want 31 bit packing in a case like this, you can set the component size
10851 explicitly:
10852
10853 @smallexample @c ada
10854    type Arr is array (1 .. 32) of Natural;
10855    for Arr'Component_Size use 31;
10856 @end smallexample
10857
10858 @noindent
10859 Here 31-bit packing is achieved as required, and no warning is generated,
10860 since in this case the programmer intention is clear.
10861
10862 @node Pragma Pack for Records
10863 @section Pragma Pack for Records
10864 @cindex Pragma Pack (for records)
10865
10866 @noindent
10867 Pragma @code{Pack} applied to a record will pack the components to reduce
10868 wasted space from alignment gaps and by reducing the amount of space
10869 taken by components.  We distinguish between @emph{packable} components and
10870 @emph{non-packable} components.
10871 Components of the following types are considered packable:
10872 @itemize @bullet
10873 @item
10874 All primitive types are packable.
10875
10876 @item
10877 Small packed arrays, whose size does not exceed 64 bits, and where the
10878 size is statically known at compile time, are represented internally
10879 as modular integers, and so they are also packable.
10880
10881 @end itemize
10882
10883 @noindent
10884 All packable components occupy the exact number of bits corresponding to
10885 their @code{Size} value, and are packed with no padding bits, i.e.@: they
10886 can start on an arbitrary bit boundary.
10887
10888 All other types are non-packable, they occupy an integral number of
10889 storage units, and
10890 are placed at a boundary corresponding to their alignment requirements.
10891
10892 For example, consider the record
10893
10894 @smallexample @c ada
10895    type Rb1 is array (1 .. 13) of Boolean;
10896    pragma Pack (rb1);
10897
10898    type Rb2 is array (1 .. 65) of Boolean;
10899    pragma Pack (rb2);
10900
10901    type x2 is record
10902       l1 : Boolean;
10903       l2 : Duration;
10904       l3 : Float;
10905       l4 : Boolean;
10906       l5 : Rb1;
10907       l6 : Rb2;
10908    end record;
10909    pragma Pack (x2);
10910 @end smallexample
10911
10912 @noindent
10913 The representation for the record x2 is as follows:
10914
10915 @smallexample @c ada
10916 for x2'Size use 224;
10917 for x2 use record
10918    l1 at  0 range  0 .. 0;
10919    l2 at  0 range  1 .. 64;
10920    l3 at 12 range  0 .. 31;
10921    l4 at 16 range  0 .. 0;
10922    l5 at 16 range  1 .. 13;
10923    l6 at 18 range  0 .. 71;
10924 end record;
10925 @end smallexample
10926
10927 @noindent
10928 Studying this example, we see that the packable fields @code{l1}
10929 and @code{l2} are
10930 of length equal to their sizes, and placed at specific bit boundaries (and
10931 not byte boundaries) to
10932 eliminate padding.  But @code{l3} is of a non-packable float type, so
10933 it is on the next appropriate alignment boundary.
10934
10935 The next two fields are fully packable, so @code{l4} and @code{l5} are
10936 minimally packed with no gaps.  However, type @code{Rb2} is a packed
10937 array that is longer than 64 bits, so it is itself non-packable.  Thus
10938 the @code{l6} field is aligned to the next byte boundary, and takes an
10939 integral number of bytes, i.e.@: 72 bits.
10940
10941 @node Record Representation Clauses
10942 @section Record Representation Clauses
10943 @cindex Record Representation Clause
10944
10945 @noindent
10946 Record representation clauses may be given for all record types, including
10947 types obtained by record extension.  Component clauses are allowed for any
10948 static component.  The restrictions on component clauses depend on the type
10949 of the component.
10950
10951 @cindex Component Clause
10952 For all components of an elementary type, the only restriction on component
10953 clauses is that the size must be at least the 'Size value of the type
10954 (actually the Value_Size).  There are no restrictions due to alignment,
10955 and such components may freely cross storage boundaries.
10956
10957 Packed arrays with a size up to and including 64 bits are represented
10958 internally using a modular type with the appropriate number of bits, and
10959 thus the same lack of restriction applies.  For example, if you declare:
10960
10961 @smallexample @c ada
10962    type R is array (1 .. 49) of Boolean;
10963    pragma Pack (R);
10964    for R'Size use 49;
10965 @end smallexample
10966
10967 @noindent
10968 then a component clause for a component of type R may start on any
10969 specified bit boundary, and may specify a value of 49 bits or greater.
10970
10971 For packed bit arrays that are longer than 64 bits, there are two
10972 cases. If the component size is a power of 2 (1,2,4,8,16,32 bits),
10973 including the important case of single bits or boolean values, then
10974 there are no limitations on placement of such components, and they
10975 may start and end at arbitrary bit boundaries.
10976
10977 If the component size is not a power of 2 (e.g.@: 3 or 5), then
10978 an array of this type longer than 64 bits must always be placed on
10979 on a storage unit (byte) boundary and occupy an integral number
10980 of storage units (bytes). Any component clause that does not
10981 meet this requirement will be rejected.
10982
10983 Any aliased component, or component of an aliased type, must
10984 have its normal alignment and size. A component clause that
10985 does not meet this requirement will be rejected.
10986
10987 The tag field of a tagged type always occupies an address sized field at
10988 the start of the record.  No component clause may attempt to overlay this
10989 tag. When a tagged type appears as a component, the tag field must have
10990 proper alignment
10991
10992 In the case of a record extension T1, of a type T, no component clause applied
10993 to the type T1 can specify a storage location that would overlap the first
10994 T'Size bytes of the record.
10995
10996 For all other component types, including non-bit-packed arrays,
10997 the component can be placed at an arbitrary bit boundary,
10998 so for example, the following is permitted:
10999
11000 @smallexample @c ada
11001    type R is array (1 .. 10) of Boolean;
11002    for R'Size use 80;
11003
11004    type Q is record
11005       G, H : Boolean;
11006       L, M : R;
11007    end record;
11008
11009    for Q use record
11010       G at 0 range  0 ..   0;
11011       H at 0 range  1 ..   1;
11012       L at 0 range  2 ..  81;
11013       R at 0 range 82 .. 161;
11014    end record;
11015 @end smallexample
11016
11017 @noindent
11018 Note: the above rules apply to recent releases of GNAT 5.
11019 In GNAT 3, there are more severe restrictions on larger components.
11020 For non-primitive types, including packed arrays with a size greater than
11021 64 bits, component clauses must respect the alignment requirement of the
11022 type, in particular, always starting on a byte boundary, and the length
11023 must be a multiple of the storage unit.
11024
11025 @node Enumeration Clauses
11026 @section Enumeration Clauses
11027
11028 The only restriction on enumeration clauses is that the range of values
11029 must be representable.  For the signed case, if one or more of the
11030 representation values are negative, all values must be in the range:
11031
11032 @smallexample @c ada
11033    System.Min_Int .. System.Max_Int
11034 @end smallexample
11035
11036 @noindent
11037 For the unsigned case, where all values are nonnegative, the values must
11038 be in the range:
11039
11040 @smallexample @c ada
11041    0 .. System.Max_Binary_Modulus;
11042 @end smallexample
11043
11044 @noindent
11045 A @emph{confirming} representation clause is one in which the values range
11046 from 0 in sequence, i.e.@: a clause that confirms the default representation
11047 for an enumeration type.
11048 Such a confirming representation
11049 is permitted by these rules, and is specially recognized by the compiler so
11050 that no extra overhead results from the use of such a clause.
11051
11052 If an array has an index type which is an enumeration type to which an
11053 enumeration clause has been applied, then the array is stored in a compact
11054 manner.  Consider the declarations:
11055
11056 @smallexample @c ada
11057    type r is (A, B, C);
11058    for r use (A => 1, B => 5, C => 10);
11059    type t is array (r) of Character;
11060 @end smallexample
11061
11062 @noindent
11063 The array type t corresponds to a vector with exactly three elements and
11064 has a default size equal to @code{3*Character'Size}.  This ensures efficient
11065 use of space, but means that accesses to elements of the array will incur
11066 the overhead of converting representation values to the corresponding
11067 positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
11068
11069 @node Address Clauses
11070 @section Address Clauses
11071 @cindex Address Clause
11072
11073 The reference manual allows a general restriction on representation clauses,
11074 as found in RM 13.1(22):
11075
11076 @quotation
11077 An implementation need not support representation
11078 items containing nonstatic expressions, except that
11079 an implementation should support a representation item
11080 for a given entity if each nonstatic expression in the
11081 representation item is a name that statically denotes
11082 a constant declared before the entity.
11083 @end quotation
11084
11085 @noindent
11086 In practice this is applicable only to address clauses, since this is the
11087 only case in which a non-static expression is permitted by the syntax.  As
11088 the AARM notes in sections 13.1 (22.a-22.h):
11089
11090 @display
11091   22.a   Reason: This is to avoid the following sort of thing:
11092
11093   22.b        X : Integer := F(@dots{});
11094               Y : Address := G(@dots{});
11095               for X'Address use Y;
11096
11097   22.c   In the above, we have to evaluate the
11098          initialization expression for X before we
11099          know where to put the result.  This seems
11100          like an unreasonable implementation burden.
11101
11102   22.d   The above code should instead be written
11103          like this:
11104
11105   22.e        Y : constant Address := G(@dots{});
11106               X : Integer := F(@dots{});
11107               for X'Address use Y;
11108
11109   22.f   This allows the expression ``Y'' to be safely
11110          evaluated before X is created.
11111
11112   22.g   The constant could be a formal parameter of mode in.
11113
11114   22.h   An implementation can support other nonstatic
11115          expressions if it wants to.  Expressions of type
11116          Address are hardly ever static, but their value
11117          might be known at compile time anyway in many
11118          cases.
11119 @end display
11120
11121 @noindent
11122 GNAT does indeed permit many additional cases of non-static expressions.  In
11123 particular, if the type involved is elementary there are no restrictions
11124 (since in this case, holding a temporary copy of the initialization value,
11125 if one is present, is inexpensive).  In addition, if there is no implicit or
11126 explicit initialization, then there are no restrictions.  GNAT will reject
11127 only the case where all three of these conditions hold:
11128
11129 @itemize @bullet
11130
11131 @item
11132 The type of the item is non-elementary (e.g.@: a record or array).
11133
11134 @item
11135 There is explicit or implicit initialization required for the object.
11136 Note that access values are always implicitly initialized, and also
11137 in GNAT, certain bit-packed arrays (those having a dynamic length or
11138 a length greater than 64) will also be implicitly initialized to zero.
11139
11140 @item
11141 The address value is non-static.  Here GNAT is more permissive than the
11142 RM, and allows the address value to be the address of a previously declared
11143 stand-alone variable, as long as it does not itself have an address clause.
11144
11145 @smallexample @c ada
11146            Anchor  : Some_Initialized_Type;
11147            Overlay : Some_Initialized_Type;
11148            for Overlay'Address use Anchor'Address;
11149 @end smallexample
11150
11151 @noindent
11152 However, the prefix of the address clause cannot be an array component, or
11153 a component of a discriminated record.
11154
11155 @end itemize
11156
11157 @noindent
11158 As noted above in section 22.h, address values are typically non-static.  In
11159 particular the To_Address function, even if applied to a literal value, is
11160 a non-static function call.  To avoid this minor annoyance, GNAT provides
11161 the implementation defined attribute 'To_Address.  The following two
11162 expressions have identical values:
11163
11164 @findex Attribute
11165 @findex To_Address
11166 @smallexample @c ada
11167    To_Address (16#1234_0000#)
11168    System'To_Address (16#1234_0000#);
11169 @end smallexample
11170
11171 @noindent
11172 except that the second form is considered to be a static expression, and
11173 thus when used as an address clause value is always permitted.
11174
11175 @noindent
11176 Additionally, GNAT treats as static an address clause that is an
11177 unchecked_conversion of a static integer value.  This simplifies the porting
11178 of legacy code, and provides a portable equivalent to the GNAT attribute
11179 @code{To_Address}.
11180
11181 Another issue with address clauses is the interaction with alignment
11182 requirements.  When an address clause is given for an object, the address
11183 value must be consistent with the alignment of the object (which is usually
11184 the same as the alignment of the type of the object).  If an address clause
11185 is given that specifies an inappropriately aligned address value, then the
11186 program execution is erroneous.
11187
11188 Since this source of erroneous behavior can have unfortunate effects, GNAT
11189 checks (at compile time if possible, generating a warning, or at execution
11190 time with a run-time check) that the alignment is appropriate.  If the
11191 run-time check fails, then @code{Program_Error} is raised.  This run-time
11192 check is suppressed if range checks are suppressed, or if the special GNAT
11193 check Alignment_Check is suppressed, or if
11194 @code{pragma Restrictions (No_Elaboration_Code)} is in effect.
11195
11196 Finally, GNAT does not permit overlaying of objects of controlled types or
11197 composite types containing a controlled component. In most cases, the compiler
11198 can detect an attempt at such overlays and will generate a warning at compile
11199 time and a Program_Error exception at run time.
11200
11201 @findex Export
11202 An address clause cannot be given for an exported object.  More
11203 understandably the real restriction is that objects with an address
11204 clause cannot be exported.  This is because such variables are not
11205 defined by the Ada program, so there is no external object to export.
11206
11207 @findex Import
11208 It is permissible to give an address clause and a pragma Import for the
11209 same object.  In this case, the variable is not really defined by the
11210 Ada program, so there is no external symbol to be linked.  The link name
11211 and the external name are ignored in this case.  The reason that we allow this
11212 combination is that it provides a useful idiom to avoid unwanted
11213 initializations on objects with address clauses.
11214
11215 When an address clause is given for an object that has implicit or
11216 explicit initialization, then by default initialization takes place.  This
11217 means that the effect of the object declaration is to overwrite the
11218 memory at the specified address.  This is almost always not what the
11219 programmer wants, so GNAT will output a warning:
11220
11221 @smallexample
11222   with System;
11223   package G is
11224      type R is record
11225         M : Integer := 0;
11226      end record;
11227
11228      Ext : R;
11229      for Ext'Address use System'To_Address (16#1234_1234#);
11230          |
11231   >>> warning: implicit initialization of "Ext" may
11232       modify overlaid storage
11233   >>> warning: use pragma Import for "Ext" to suppress
11234       initialization (RM B(24))
11235
11236   end G;
11237 @end smallexample
11238
11239 @noindent
11240 As indicated by the warning message, the solution is to use a (dummy) pragma
11241 Import to suppress this initialization.  The pragma tell the compiler that the
11242 object is declared and initialized elsewhere.  The following package compiles
11243 without warnings (and the initialization is suppressed):
11244
11245 @smallexample @c ada
11246    with System;
11247    package G is
11248       type R is record
11249          M : Integer := 0;
11250       end record;
11251
11252       Ext : R;
11253       for Ext'Address use System'To_Address (16#1234_1234#);
11254       pragma Import (Ada, Ext);
11255    end G;
11256 @end smallexample
11257
11258 @noindent
11259 A final issue with address clauses involves their use for overlaying
11260 variables, as in the following example:
11261 @cindex Overlaying of objects
11262
11263 @smallexample @c ada
11264   A : Integer;
11265   B : Integer;
11266   for B'Address use A'Address;
11267 @end smallexample
11268
11269 @noindent
11270 or alternatively, using the form recommended by the RM:
11271
11272 @smallexample @c ada
11273   A    : Integer;
11274   Addr : constant Address := A'Address;
11275   B    : Integer;
11276   for B'Address use Addr;
11277 @end smallexample
11278
11279 @noindent
11280 In both of these cases, @code{A}
11281 and @code{B} become aliased to one another via the
11282 address clause. This use of address clauses to overlay
11283 variables, achieving an effect similar to unchecked
11284 conversion was erroneous in Ada 83, but in Ada 95 and Ada 2005
11285 the effect is implementation defined. Furthermore, the
11286 Ada RM specifically recommends that in a situation
11287 like this, @code{B} should be subject to the following
11288 implementation advice (RM 13.3(19)):
11289
11290 @quotation
11291 19  If the Address of an object is specified, or it is imported
11292     or exported, then the implementation should not perform
11293     optimizations based on assumptions of no aliases.
11294 @end quotation
11295
11296 @noindent
11297 GNAT follows this recommendation, and goes further by also applying
11298 this recommendation to the overlaid variable (@code{A}
11299 in the above example) in this case. This means that the overlay
11300 works "as expected", in that a modification to one of the variables
11301 will affect the value of the other.
11302
11303 @node Effect of Convention on Representation
11304 @section Effect of Convention on Representation
11305 @cindex Convention, effect on representation
11306
11307 @noindent
11308 Normally the specification of a foreign language convention for a type or
11309 an object has no effect on the chosen representation.  In particular, the
11310 representation chosen for data in GNAT generally meets the standard system
11311 conventions, and for example records are laid out in a manner that is
11312 consistent with C@.  This means that specifying convention C (for example)
11313 has no effect.
11314
11315 There are four exceptions to this general rule:
11316
11317 @itemize @bullet
11318
11319 @item Convention Fortran and array subtypes
11320 If pragma Convention Fortran is specified for an array subtype, then in
11321 accordance with the implementation advice in section 3.6.2(11) of the
11322 Ada Reference Manual, the array will be stored in a Fortran-compatible
11323 column-major manner, instead of the normal default row-major order.
11324
11325 @item Convention C and enumeration types
11326 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
11327 to accommodate all values of the type.  For example, for the enumeration
11328 type declared by:
11329
11330 @smallexample @c ada
11331    type Color is (Red, Green, Blue);
11332 @end smallexample
11333
11334 @noindent
11335 8 bits is sufficient to store all values of the type, so by default, objects
11336 of type @code{Color} will be represented using 8 bits.  However, normal C
11337 convention is to use 32 bits for all enum values in C, since enum values
11338 are essentially of type int.  If pragma @code{Convention C} is specified for an
11339 Ada enumeration type, then the size is modified as necessary (usually to
11340 32 bits) to be consistent with the C convention for enum values.
11341
11342 Note that this treatment applies only to types. If Convention C is given for
11343 an enumeration object, where the enumeration type is not Convention C, then
11344 Object_Size bits are allocated. For example, for a normal enumeration type,
11345 with less than 256 elements, only 8 bits will be allocated for the object.
11346 Since this may be a surprise in terms of what C expects, GNAT will issue a
11347 warning in this situation. The warning can be suppressed by giving an explicit
11348 size clause specifying the desired size.
11349
11350 @item Convention C/Fortran and Boolean types
11351 In C, the usual convention for boolean values, that is values used for
11352 conditions, is that zero represents false, and nonzero values represent
11353 true.  In Ada, the normal convention is that two specific values, typically
11354 0/1, are used to represent false/true respectively.
11355
11356 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
11357 value represents true).
11358
11359 To accommodate the Fortran and C conventions, if a pragma Convention specifies
11360 C or Fortran convention for a derived Boolean, as in the following example:
11361
11362 @smallexample @c ada
11363    type C_Switch is new Boolean;
11364    pragma Convention (C, C_Switch);
11365 @end smallexample
11366
11367 @noindent
11368 then the GNAT generated code will treat any nonzero value as true.  For truth
11369 values generated by GNAT, the conventional value 1 will be used for True, but
11370 when one of these values is read, any nonzero value is treated as True.
11371
11372 @item Access types on OpenVMS
11373 For 64-bit OpenVMS systems, access types (other than those for unconstrained
11374 arrays) are 64-bits long. An exception to this rule is for the case of
11375 C-convention access types where there is no explicit size clause present (or
11376 inherited for derived types). In this case, GNAT chooses to make these
11377 pointers 32-bits, which provides an easier path for migration of 32-bit legacy
11378 code. size clause specifying 64-bits must be used to obtain a 64-bit pointer.
11379
11380 @end itemize
11381
11382 @node Determining the Representations chosen by GNAT
11383 @section Determining the Representations chosen by GNAT
11384 @cindex Representation, determination of
11385 @cindex @option{-gnatR} switch
11386
11387 @noindent
11388 Although the descriptions in this section are intended to be complete, it is
11389 often easier to simply experiment to see what GNAT accepts and what the
11390 effect is on the layout of types and objects.
11391
11392 As required by the Ada RM, if a representation clause is not accepted, then
11393 it must be rejected as illegal by the compiler.  However, when a
11394 representation clause or pragma is accepted, there can still be questions
11395 of what the compiler actually does.  For example, if a partial record
11396 representation clause specifies the location of some components and not
11397 others, then where are the non-specified components placed? Or if pragma
11398 @code{Pack} is used on a record, then exactly where are the resulting
11399 fields placed? The section on pragma @code{Pack} in this chapter can be
11400 used to answer the second question, but it is often easier to just see
11401 what the compiler does.
11402
11403 For this purpose, GNAT provides the option @option{-gnatR}.  If you compile
11404 with this option, then the compiler will output information on the actual
11405 representations chosen, in a format similar to source representation
11406 clauses.  For example, if we compile the package:
11407
11408 @smallexample @c ada
11409 package q is
11410    type r (x : boolean) is tagged record
11411       case x is
11412          when True => S : String (1 .. 100);
11413          when False => null;
11414       end case;
11415    end record;
11416
11417    type r2 is new r (false) with record
11418       y2 : integer;
11419    end record;
11420
11421    for r2 use record
11422       y2 at 16 range 0 .. 31;
11423    end record;
11424
11425    type x is record
11426       y : character;
11427    end record;
11428
11429    type x1 is array (1 .. 10) of x;
11430    for x1'component_size use 11;
11431
11432    type ia is access integer;
11433
11434    type Rb1 is array (1 .. 13) of Boolean;
11435    pragma Pack (rb1);
11436
11437    type Rb2 is array (1 .. 65) of Boolean;
11438    pragma Pack (rb2);
11439
11440    type x2 is record
11441       l1 : Boolean;
11442       l2 : Duration;
11443       l3 : Float;
11444       l4 : Boolean;
11445       l5 : Rb1;
11446       l6 : Rb2;
11447    end record;
11448    pragma Pack (x2);
11449 end q;
11450 @end smallexample
11451
11452 @noindent
11453 using the switch @option{-gnatR} we obtain the following output:
11454
11455 @smallexample
11456 Representation information for unit q
11457 -------------------------------------
11458
11459 for r'Size use ??;
11460 for r'Alignment use 4;
11461 for r use record
11462    x    at 4 range  0 .. 7;
11463    _tag at 0 range  0 .. 31;
11464    s    at 5 range  0 .. 799;
11465 end record;
11466
11467 for r2'Size use 160;
11468 for r2'Alignment use 4;
11469 for r2 use record
11470    x       at  4 range  0 .. 7;
11471    _tag    at  0 range  0 .. 31;
11472    _parent at  0 range  0 .. 63;
11473    y2      at 16 range  0 .. 31;
11474 end record;
11475
11476 for x'Size use 8;
11477 for x'Alignment use 1;
11478 for x use record
11479    y at 0 range  0 .. 7;
11480 end record;
11481
11482 for x1'Size use 112;
11483 for x1'Alignment use 1;
11484 for x1'Component_Size use 11;
11485
11486 for rb1'Size use 13;
11487 for rb1'Alignment use 2;
11488 for rb1'Component_Size use 1;
11489
11490 for rb2'Size use 72;
11491 for rb2'Alignment use 1;
11492 for rb2'Component_Size use 1;
11493
11494 for x2'Size use 224;
11495 for x2'Alignment use 4;
11496 for x2 use record
11497    l1 at  0 range  0 .. 0;
11498    l2 at  0 range  1 .. 64;
11499    l3 at 12 range  0 .. 31;
11500    l4 at 16 range  0 .. 0;
11501    l5 at 16 range  1 .. 13;
11502    l6 at 18 range  0 .. 71;
11503 end record;
11504 @end smallexample
11505
11506 @noindent
11507 The Size values are actually the Object_Size, i.e.@: the default size that
11508 will be allocated for objects of the type.
11509 The ?? size for type r indicates that we have a variant record, and the
11510 actual size of objects will depend on the discriminant value.
11511
11512 The Alignment values show the actual alignment chosen by the compiler
11513 for each record or array type.
11514
11515 The record representation clause for type r shows where all fields
11516 are placed, including the compiler generated tag field (whose location
11517 cannot be controlled by the programmer).
11518
11519 The record representation clause for the type extension r2 shows all the
11520 fields present, including the parent field, which is a copy of the fields
11521 of the parent type of r2, i.e.@: r1.
11522
11523 The component size and size clauses for types rb1 and rb2 show
11524 the exact effect of pragma @code{Pack} on these arrays, and the record
11525 representation clause for type x2 shows how pragma @code{Pack} affects
11526 this record type.
11527
11528 In some cases, it may be useful to cut and paste the representation clauses
11529 generated by the compiler into the original source to fix and guarantee
11530 the actual representation to be used.
11531
11532 @node Standard Library Routines
11533 @chapter Standard Library Routines
11534
11535 @noindent
11536 The Ada Reference Manual contains in Annex A a full description of an
11537 extensive set of standard library routines that can be used in any Ada
11538 program, and which must be provided by all Ada compilers.  They are
11539 analogous to the standard C library used by C programs.
11540
11541 GNAT implements all of the facilities described in annex A, and for most
11542 purposes the description in the Ada Reference Manual, or appropriate Ada
11543 text book, will be sufficient for making use of these facilities.
11544
11545 In the case of the input-output facilities,
11546 @xref{The Implementation of Standard I/O},
11547 gives details on exactly how GNAT interfaces to the
11548 file system.  For the remaining packages, the Ada Reference Manual
11549 should be sufficient.  The following is a list of the packages included,
11550 together with a brief description of the functionality that is provided.
11551
11552 For completeness, references are included to other predefined library
11553 routines defined in other sections of the Ada Reference Manual (these are
11554 cross-indexed from Annex A).
11555
11556 @table @code
11557 @item Ada (A.2)
11558 This is a parent package for all the standard library packages.  It is
11559 usually included implicitly in your program, and itself contains no
11560 useful data or routines.
11561
11562 @item Ada.Calendar (9.6)
11563 @code{Calendar} provides time of day access, and routines for
11564 manipulating times and durations.
11565
11566 @item Ada.Characters (A.3.1)
11567 This is a dummy parent package that contains no useful entities
11568
11569 @item Ada.Characters.Handling (A.3.2)
11570 This package provides some basic character handling capabilities,
11571 including classification functions for classes of characters (e.g.@: test
11572 for letters, or digits).
11573
11574 @item Ada.Characters.Latin_1 (A.3.3)
11575 This package includes a complete set of definitions of the characters
11576 that appear in type CHARACTER@.  It is useful for writing programs that
11577 will run in international environments.  For example, if you want an
11578 upper case E with an acute accent in a string, it is often better to use
11579 the definition of @code{UC_E_Acute} in this package.  Then your program
11580 will print in an understandable manner even if your environment does not
11581 support these extended characters.
11582
11583 @item Ada.Command_Line (A.15)
11584 This package provides access to the command line parameters and the name
11585 of the current program (analogous to the use of @code{argc} and @code{argv}
11586 in C), and also allows the exit status for the program to be set in a
11587 system-independent manner.
11588
11589 @item Ada.Decimal (F.2)
11590 This package provides constants describing the range of decimal numbers
11591 implemented, and also a decimal divide routine (analogous to the COBOL
11592 verb DIVIDE @dots{} GIVING @dots{} REMAINDER @dots{})
11593
11594 @item Ada.Direct_IO (A.8.4)
11595 This package provides input-output using a model of a set of records of
11596 fixed-length, containing an arbitrary definite Ada type, indexed by an
11597 integer record number.
11598
11599 @item Ada.Dynamic_Priorities (D.5)
11600 This package allows the priorities of a task to be adjusted dynamically
11601 as the task is running.
11602
11603 @item Ada.Exceptions (11.4.1)
11604 This package provides additional information on exceptions, and also
11605 contains facilities for treating exceptions as data objects, and raising
11606 exceptions with associated messages.
11607
11608 @item Ada.Finalization (7.6)
11609 This package contains the declarations and subprograms to support the
11610 use of controlled types, providing for automatic initialization and
11611 finalization (analogous to the constructors and destructors of C++)
11612
11613 @item Ada.Interrupts (C.3.2)
11614 This package provides facilities for interfacing to interrupts, which
11615 includes the set of signals or conditions that can be raised and
11616 recognized as interrupts.
11617
11618 @item Ada.Interrupts.Names (C.3.2)
11619 This package provides the set of interrupt names (actually signal
11620 or condition names) that can be handled by GNAT@.
11621
11622 @item Ada.IO_Exceptions (A.13)
11623 This package defines the set of exceptions that can be raised by use of
11624 the standard IO packages.
11625
11626 @item Ada.Numerics
11627 This package contains some standard constants and exceptions used
11628 throughout the numerics packages.  Note that the constants pi and e are
11629 defined here, and it is better to use these definitions than rolling
11630 your own.
11631
11632 @item Ada.Numerics.Complex_Elementary_Functions
11633 Provides the implementation of standard elementary functions (such as
11634 log and trigonometric functions) operating on complex numbers using the
11635 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
11636 created by the package @code{Numerics.Complex_Types}.
11637
11638 @item Ada.Numerics.Complex_Types
11639 This is a predefined instantiation of
11640 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
11641 build the type @code{Complex} and @code{Imaginary}.
11642
11643 @item Ada.Numerics.Discrete_Random
11644 This package provides a random number generator suitable for generating
11645 random integer values from a specified range.
11646
11647 @item Ada.Numerics.Float_Random
11648 This package provides a random number generator suitable for generating
11649 uniformly distributed floating point values.
11650
11651 @item Ada.Numerics.Generic_Complex_Elementary_Functions
11652 This is a generic version of the package that provides the
11653 implementation of standard elementary functions (such as log and
11654 trigonometric functions) for an arbitrary complex type.
11655
11656 The following predefined instantiations of this package are provided:
11657
11658 @table @code
11659 @item Short_Float
11660 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
11661 @item Float
11662 @code{Ada.Numerics.Complex_Elementary_Functions}
11663 @item Long_Float
11664 @code{Ada.Numerics.Long_Complex_Elementary_Functions}
11665 @end table
11666
11667 @item Ada.Numerics.Generic_Complex_Types
11668 This is a generic package that allows the creation of complex types,
11669 with associated complex arithmetic operations.
11670
11671 The following predefined instantiations of this package exist
11672 @table @code
11673 @item Short_Float
11674 @code{Ada.Numerics.Short_Complex_Complex_Types}
11675 @item Float
11676 @code{Ada.Numerics.Complex_Complex_Types}
11677 @item Long_Float
11678 @code{Ada.Numerics.Long_Complex_Complex_Types}
11679 @end table
11680
11681 @item Ada.Numerics.Generic_Elementary_Functions
11682 This is a generic package that provides the implementation of standard
11683 elementary functions (such as log an trigonometric functions) for an
11684 arbitrary float type.
11685
11686 The following predefined instantiations of this package exist
11687
11688 @table @code
11689 @item Short_Float
11690 @code{Ada.Numerics.Short_Elementary_Functions}
11691 @item Float
11692 @code{Ada.Numerics.Elementary_Functions}
11693 @item Long_Float
11694 @code{Ada.Numerics.Long_Elementary_Functions}
11695 @end table
11696
11697 @item Ada.Real_Time (D.8)
11698 This package provides facilities similar to those of @code{Calendar}, but
11699 operating with a finer clock suitable for real time control. Note that
11700 annex D requires that there be no backward clock jumps, and GNAT generally
11701 guarantees this behavior, but of course if the external clock on which
11702 the GNAT runtime depends is deliberately reset by some external event,
11703 then such a backward jump may occur.
11704
11705 @item Ada.Sequential_IO (A.8.1)
11706 This package provides input-output facilities for sequential files,
11707 which can contain a sequence of values of a single type, which can be
11708 any Ada type, including indefinite (unconstrained) types.
11709
11710 @item Ada.Storage_IO (A.9)
11711 This package provides a facility for mapping arbitrary Ada types to and
11712 from a storage buffer.  It is primarily intended for the creation of new
11713 IO packages.
11714
11715 @item Ada.Streams (13.13.1)
11716 This is a generic package that provides the basic support for the
11717 concept of streams as used by the stream attributes (@code{Input},
11718 @code{Output}, @code{Read} and @code{Write}).
11719
11720 @item Ada.Streams.Stream_IO (A.12.1)
11721 This package is a specialization of the type @code{Streams} defined in
11722 package @code{Streams} together with a set of operations providing
11723 Stream_IO capability.  The Stream_IO model permits both random and
11724 sequential access to a file which can contain an arbitrary set of values
11725 of one or more Ada types.
11726
11727 @item Ada.Strings (A.4.1)
11728 This package provides some basic constants used by the string handling
11729 packages.
11730
11731 @item Ada.Strings.Bounded (A.4.4)
11732 This package provides facilities for handling variable length
11733 strings.  The bounded model requires a maximum length.  It is thus
11734 somewhat more limited than the unbounded model, but avoids the use of
11735 dynamic allocation or finalization.
11736
11737 @item Ada.Strings.Fixed (A.4.3)
11738 This package provides facilities for handling fixed length strings.
11739
11740 @item Ada.Strings.Maps (A.4.2)
11741 This package provides facilities for handling character mappings and
11742 arbitrarily defined subsets of characters.  For instance it is useful in
11743 defining specialized translation tables.
11744
11745 @item Ada.Strings.Maps.Constants (A.4.6)
11746 This package provides a standard set of predefined mappings and
11747 predefined character sets.  For example, the standard upper to lower case
11748 conversion table is found in this package.  Note that upper to lower case
11749 conversion is non-trivial if you want to take the entire set of
11750 characters, including extended characters like E with an acute accent,
11751 into account.  You should use the mappings in this package (rather than
11752 adding 32 yourself) to do case mappings.
11753
11754 @item Ada.Strings.Unbounded (A.4.5)
11755 This package provides facilities for handling variable length
11756 strings.  The unbounded model allows arbitrary length strings, but
11757 requires the use of dynamic allocation and finalization.
11758
11759 @item Ada.Strings.Wide_Bounded (A.4.7)
11760 @itemx Ada.Strings.Wide_Fixed (A.4.7)
11761 @itemx Ada.Strings.Wide_Maps (A.4.7)
11762 @itemx Ada.Strings.Wide_Maps.Constants (A.4.7)
11763 @itemx Ada.Strings.Wide_Unbounded (A.4.7)
11764 These packages provide analogous capabilities to the corresponding
11765 packages without @samp{Wide_} in the name, but operate with the types
11766 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
11767 and @code{Character}.
11768
11769 @item Ada.Strings.Wide_Wide_Bounded (A.4.7)
11770 @itemx Ada.Strings.Wide_Wide_Fixed (A.4.7)
11771 @itemx Ada.Strings.Wide_Wide_Maps (A.4.7)
11772 @itemx Ada.Strings.Wide_Wide_Maps.Constants (A.4.7)
11773 @itemx Ada.Strings.Wide_Wide_Unbounded (A.4.7)
11774 These packages provide analogous capabilities to the corresponding
11775 packages without @samp{Wide_} in the name, but operate with the types
11776 @code{Wide_Wide_String} and @code{Wide_Wide_Character} instead
11777 of @code{String} and @code{Character}.
11778
11779 @item Ada.Synchronous_Task_Control (D.10)
11780 This package provides some standard facilities for controlling task
11781 communication in a synchronous manner.
11782
11783 @item Ada.Tags
11784 This package contains definitions for manipulation of the tags of tagged
11785 values.
11786
11787 @item Ada.Task_Attributes
11788 This package provides the capability of associating arbitrary
11789 task-specific data with separate tasks.
11790
11791 @item Ada.Text_IO
11792 This package provides basic text input-output capabilities for
11793 character, string and numeric data.  The subpackages of this
11794 package are listed next.
11795
11796 @item Ada.Text_IO.Decimal_IO
11797 Provides input-output facilities for decimal fixed-point types
11798
11799 @item Ada.Text_IO.Enumeration_IO
11800 Provides input-output facilities for enumeration types.
11801
11802 @item Ada.Text_IO.Fixed_IO
11803 Provides input-output facilities for ordinary fixed-point types.
11804
11805 @item Ada.Text_IO.Float_IO
11806 Provides input-output facilities for float types.  The following
11807 predefined instantiations of this generic package are available:
11808
11809 @table @code
11810 @item Short_Float
11811 @code{Short_Float_Text_IO}
11812 @item Float
11813 @code{Float_Text_IO}
11814 @item Long_Float
11815 @code{Long_Float_Text_IO}
11816 @end table
11817
11818 @item Ada.Text_IO.Integer_IO
11819 Provides input-output facilities for integer types.  The following
11820 predefined instantiations of this generic package are available:
11821
11822 @table @code
11823 @item Short_Short_Integer
11824 @code{Ada.Short_Short_Integer_Text_IO}
11825 @item Short_Integer
11826 @code{Ada.Short_Integer_Text_IO}
11827 @item Integer
11828 @code{Ada.Integer_Text_IO}
11829 @item Long_Integer
11830 @code{Ada.Long_Integer_Text_IO}
11831 @item Long_Long_Integer
11832 @code{Ada.Long_Long_Integer_Text_IO}
11833 @end table
11834
11835 @item Ada.Text_IO.Modular_IO
11836 Provides input-output facilities for modular (unsigned) types
11837
11838 @item Ada.Text_IO.Complex_IO (G.1.3)
11839 This package provides basic text input-output capabilities for complex
11840 data.
11841
11842 @item Ada.Text_IO.Editing (F.3.3)
11843 This package contains routines for edited output, analogous to the use
11844 of pictures in COBOL@.  The picture formats used by this package are a
11845 close copy of the facility in COBOL@.
11846
11847 @item Ada.Text_IO.Text_Streams (A.12.2)
11848 This package provides a facility that allows Text_IO files to be treated
11849 as streams, so that the stream attributes can be used for writing
11850 arbitrary data, including binary data, to Text_IO files.
11851
11852 @item Ada.Unchecked_Conversion (13.9)
11853 This generic package allows arbitrary conversion from one type to
11854 another of the same size, providing for breaking the type safety in
11855 special circumstances.
11856
11857 If the types have the same Size (more accurately the same Value_Size),
11858 then the effect is simply to transfer the bits from the source to the
11859 target type without any modification.  This usage is well defined, and
11860 for simple types whose representation is typically the same across
11861 all implementations, gives a portable method of performing such
11862 conversions.
11863
11864 If the types do not have the same size, then the result is implementation
11865 defined, and thus may be non-portable.  The following describes how GNAT
11866 handles such unchecked conversion cases.
11867
11868 If the types are of different sizes, and are both discrete types, then
11869 the effect is of a normal type conversion without any constraint checking.
11870 In particular if the result type has a larger size, the result will be
11871 zero or sign extended.  If the result type has a smaller size, the result
11872 will be truncated by ignoring high order bits.
11873
11874 If the types are of different sizes, and are not both discrete types,
11875 then the conversion works as though pointers were created to the source
11876 and target, and the pointer value is converted.  The effect is that bits
11877 are copied from successive low order storage units and bits of the source
11878 up to the length of the target type.
11879
11880 A warning is issued if the lengths differ, since the effect in this
11881 case is implementation dependent, and the above behavior may not match
11882 that of some other compiler.
11883
11884 A pointer to one type may be converted to a pointer to another type using
11885 unchecked conversion.  The only case in which the effect is undefined is
11886 when one or both pointers are pointers to unconstrained array types.  In
11887 this case, the bounds information may get incorrectly transferred, and in
11888 particular, GNAT uses double size pointers for such types, and it is
11889 meaningless to convert between such pointer types.  GNAT will issue a
11890 warning if the alignment of the target designated type is more strict
11891 than the alignment of the source designated type (since the result may
11892 be unaligned in this case).
11893
11894 A pointer other than a pointer to an unconstrained array type may be
11895 converted to and from System.Address.  Such usage is common in Ada 83
11896 programs, but note that Ada.Address_To_Access_Conversions is the
11897 preferred method of performing such conversions in Ada 95 and Ada 2005.
11898 Neither
11899 unchecked conversion nor Ada.Address_To_Access_Conversions should be
11900 used in conjunction with pointers to unconstrained objects, since
11901 the bounds information cannot be handled correctly in this case.
11902
11903 @item Ada.Unchecked_Deallocation (13.11.2)
11904 This generic package allows explicit freeing of storage previously
11905 allocated by use of an allocator.
11906
11907 @item Ada.Wide_Text_IO (A.11)
11908 This package is similar to @code{Ada.Text_IO}, except that the external
11909 file supports wide character representations, and the internal types are
11910 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
11911 and @code{String}.  It contains generic subpackages listed next.
11912
11913 @item Ada.Wide_Text_IO.Decimal_IO
11914 Provides input-output facilities for decimal fixed-point types
11915
11916 @item Ada.Wide_Text_IO.Enumeration_IO
11917 Provides input-output facilities for enumeration types.
11918
11919 @item Ada.Wide_Text_IO.Fixed_IO
11920 Provides input-output facilities for ordinary fixed-point types.
11921
11922 @item Ada.Wide_Text_IO.Float_IO
11923 Provides input-output facilities for float types.  The following
11924 predefined instantiations of this generic package are available:
11925
11926 @table @code
11927 @item Short_Float
11928 @code{Short_Float_Wide_Text_IO}
11929 @item Float
11930 @code{Float_Wide_Text_IO}
11931 @item Long_Float
11932 @code{Long_Float_Wide_Text_IO}
11933 @end table
11934
11935 @item Ada.Wide_Text_IO.Integer_IO
11936 Provides input-output facilities for integer types.  The following
11937 predefined instantiations of this generic package are available:
11938
11939 @table @code
11940 @item Short_Short_Integer
11941 @code{Ada.Short_Short_Integer_Wide_Text_IO}
11942 @item Short_Integer
11943 @code{Ada.Short_Integer_Wide_Text_IO}
11944 @item Integer
11945 @code{Ada.Integer_Wide_Text_IO}
11946 @item Long_Integer
11947 @code{Ada.Long_Integer_Wide_Text_IO}
11948 @item Long_Long_Integer
11949 @code{Ada.Long_Long_Integer_Wide_Text_IO}
11950 @end table
11951
11952 @item Ada.Wide_Text_IO.Modular_IO
11953 Provides input-output facilities for modular (unsigned) types
11954
11955 @item Ada.Wide_Text_IO.Complex_IO (G.1.3)
11956 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
11957 external file supports wide character representations.
11958
11959 @item Ada.Wide_Text_IO.Editing (F.3.4)
11960 This package is similar to @code{Ada.Text_IO.Editing}, except that the
11961 types are @code{Wide_Character} and @code{Wide_String} instead of
11962 @code{Character} and @code{String}.
11963
11964 @item Ada.Wide_Text_IO.Streams (A.12.3)
11965 This package is similar to @code{Ada.Text_IO.Streams}, except that the
11966 types are @code{Wide_Character} and @code{Wide_String} instead of
11967 @code{Character} and @code{String}.
11968
11969 @item Ada.Wide_Wide_Text_IO (A.11)
11970 This package is similar to @code{Ada.Text_IO}, except that the external
11971 file supports wide character representations, and the internal types are
11972 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
11973 and @code{String}.  It contains generic subpackages listed next.
11974
11975 @item Ada.Wide_Wide_Text_IO.Decimal_IO
11976 Provides input-output facilities for decimal fixed-point types
11977
11978 @item Ada.Wide_Wide_Text_IO.Enumeration_IO
11979 Provides input-output facilities for enumeration types.
11980
11981 @item Ada.Wide_Wide_Text_IO.Fixed_IO
11982 Provides input-output facilities for ordinary fixed-point types.
11983
11984 @item Ada.Wide_Wide_Text_IO.Float_IO
11985 Provides input-output facilities for float types.  The following
11986 predefined instantiations of this generic package are available:
11987
11988 @table @code
11989 @item Short_Float
11990 @code{Short_Float_Wide_Wide_Text_IO}
11991 @item Float
11992 @code{Float_Wide_Wide_Text_IO}
11993 @item Long_Float
11994 @code{Long_Float_Wide_Wide_Text_IO}
11995 @end table
11996
11997 @item Ada.Wide_Wide_Text_IO.Integer_IO
11998 Provides input-output facilities for integer types.  The following
11999 predefined instantiations of this generic package are available:
12000
12001 @table @code
12002 @item Short_Short_Integer
12003 @code{Ada.Short_Short_Integer_Wide_Wide_Text_IO}
12004 @item Short_Integer
12005 @code{Ada.Short_Integer_Wide_Wide_Text_IO}
12006 @item Integer
12007 @code{Ada.Integer_Wide_Wide_Text_IO}
12008 @item Long_Integer
12009 @code{Ada.Long_Integer_Wide_Wide_Text_IO}
12010 @item Long_Long_Integer
12011 @code{Ada.Long_Long_Integer_Wide_Wide_Text_IO}
12012 @end table
12013
12014 @item Ada.Wide_Wide_Text_IO.Modular_IO
12015 Provides input-output facilities for modular (unsigned) types
12016
12017 @item Ada.Wide_Wide_Text_IO.Complex_IO (G.1.3)
12018 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
12019 external file supports wide character representations.
12020
12021 @item Ada.Wide_Wide_Text_IO.Editing (F.3.4)
12022 This package is similar to @code{Ada.Text_IO.Editing}, except that the
12023 types are @code{Wide_Character} and @code{Wide_String} instead of
12024 @code{Character} and @code{String}.
12025
12026 @item Ada.Wide_Wide_Text_IO.Streams (A.12.3)
12027 This package is similar to @code{Ada.Text_IO.Streams}, except that the
12028 types are @code{Wide_Character} and @code{Wide_String} instead of
12029 @code{Character} and @code{String}.
12030 @end table
12031
12032
12033
12034 @node The Implementation of Standard I/O
12035 @chapter The Implementation of Standard I/O
12036
12037 @noindent
12038 GNAT implements all the required input-output facilities described in
12039 A.6 through A.14.  These sections of the Ada Reference Manual describe the
12040 required behavior of these packages from the Ada point of view, and if
12041 you are writing a portable Ada program that does not need to know the
12042 exact manner in which Ada maps to the outside world when it comes to
12043 reading or writing external files, then you do not need to read this
12044 chapter.  As long as your files are all regular files (not pipes or
12045 devices), and as long as you write and read the files only from Ada, the
12046 description in the Ada Reference Manual is sufficient.
12047
12048 However, if you want to do input-output to pipes or other devices, such
12049 as the keyboard or screen, or if the files you are dealing with are
12050 either generated by some other language, or to be read by some other
12051 language, then you need to know more about the details of how the GNAT
12052 implementation of these input-output facilities behaves.
12053
12054 In this chapter we give a detailed description of exactly how GNAT
12055 interfaces to the file system.  As always, the sources of the system are
12056 available to you for answering questions at an even more detailed level,
12057 but for most purposes the information in this chapter will suffice.
12058
12059 Another reason that you may need to know more about how input-output is
12060 implemented arises when you have a program written in mixed languages
12061 where, for example, files are shared between the C and Ada sections of
12062 the same program.  GNAT provides some additional facilities, in the form
12063 of additional child library packages, that facilitate this sharing, and
12064 these additional facilities are also described in this chapter.
12065
12066 @menu
12067 * Standard I/O Packages::
12068 * FORM Strings::
12069 * Direct_IO::
12070 * Sequential_IO::
12071 * Text_IO::
12072 * Wide_Text_IO::
12073 * Wide_Wide_Text_IO::
12074 * Stream_IO::
12075 * Shared Files::
12076 * Filenames encoding::
12077 * Open Modes::
12078 * Operations on C Streams::
12079 * Interfacing to C Streams::
12080 @end menu
12081
12082 @node Standard I/O Packages
12083 @section Standard I/O Packages
12084
12085 @noindent
12086 The Standard I/O packages described in Annex A for
12087
12088 @itemize @bullet
12089 @item
12090 Ada.Text_IO
12091 @item
12092 Ada.Text_IO.Complex_IO
12093 @item
12094 Ada.Text_IO.Text_Streams
12095 @item
12096 Ada.Wide_Text_IO
12097 @item
12098 Ada.Wide_Text_IO.Complex_IO
12099 @item
12100 Ada.Wide_Text_IO.Text_Streams
12101 @item
12102 Ada.Wide_Wide_Text_IO
12103 @item
12104 Ada.Wide_Wide_Text_IO.Complex_IO
12105 @item
12106 Ada.Wide_Wide_Text_IO.Text_Streams
12107 @item
12108 Ada.Stream_IO
12109 @item
12110 Ada.Sequential_IO
12111 @item
12112 Ada.Direct_IO
12113 @end itemize
12114
12115 @noindent
12116 are implemented using the C
12117 library streams facility; where
12118
12119 @itemize @bullet
12120 @item
12121 All files are opened using @code{fopen}.
12122 @item
12123 All input/output operations use @code{fread}/@code{fwrite}.
12124 @end itemize
12125
12126 @noindent
12127 There is no internal buffering of any kind at the Ada library level. The only
12128 buffering is that provided at the system level in the implementation of the
12129 library routines that support streams. This facilitates shared use of these
12130 streams by mixed language programs. Note though that system level buffering is
12131 explicitly enabled at elaboration of the standard I/O packages and that can
12132 have an impact on mixed language programs, in particular those using I/O before
12133 calling the Ada elaboration routine (e.g.@: adainit). It is recommended to call
12134 the Ada elaboration routine before performing any I/O or when impractical,
12135 flush the common I/O streams and in particular Standard_Output before
12136 elaborating the Ada code.
12137
12138 @node FORM Strings
12139 @section FORM Strings
12140
12141 @noindent
12142 The format of a FORM string in GNAT is:
12143
12144 @smallexample
12145 "keyword=value,keyword=value,@dots{},keyword=value"
12146 @end smallexample
12147
12148 @noindent
12149 where letters may be in upper or lower case, and there are no spaces
12150 between values.  The order of the entries is not important.  Currently
12151 there are two keywords defined.
12152
12153 @smallexample
12154 SHARED=[YES|NO]
12155 WCEM=[n|h|u|s|e|8|b]
12156 @end smallexample
12157
12158 @noindent
12159 The use of these parameters is described later in this section.
12160
12161 @node Direct_IO
12162 @section Direct_IO
12163
12164 @noindent
12165 Direct_IO can only be instantiated for definite types.  This is a
12166 restriction of the Ada language, which means that the records are fixed
12167 length (the length being determined by @code{@var{type}'Size}, rounded
12168 up to the next storage unit boundary if necessary).
12169
12170 The records of a Direct_IO file are simply written to the file in index
12171 sequence, with the first record starting at offset zero, and subsequent
12172 records following.  There is no control information of any kind.  For
12173 example, if 32-bit integers are being written, each record takes
12174 4-bytes, so the record at index @var{K} starts at offset
12175 (@var{K}@minus{}1)*4.
12176
12177 There is no limit on the size of Direct_IO files, they are expanded as
12178 necessary to accommodate whatever records are written to the file.
12179
12180 @node Sequential_IO
12181 @section Sequential_IO
12182
12183 @noindent
12184 Sequential_IO may be instantiated with either a definite (constrained)
12185 or indefinite (unconstrained) type.
12186
12187 For the definite type case, the elements written to the file are simply
12188 the memory images of the data values with no control information of any
12189 kind.  The resulting file should be read using the same type, no validity
12190 checking is performed on input.
12191
12192 For the indefinite type case, the elements written consist of two
12193 parts.  First is the size of the data item, written as the memory image
12194 of a @code{Interfaces.C.size_t} value, followed by the memory image of
12195 the data value.  The resulting file can only be read using the same
12196 (unconstrained) type.  Normal assignment checks are performed on these
12197 read operations, and if these checks fail, @code{Data_Error} is
12198 raised.  In particular, in the array case, the lengths must match, and in
12199 the variant record case, if the variable for a particular read operation
12200 is constrained, the discriminants must match.
12201
12202 Note that it is not possible to use Sequential_IO to write variable
12203 length array items, and then read the data back into different length
12204 arrays.  For example, the following will raise @code{Data_Error}:
12205
12206 @smallexample @c ada
12207  package IO is new Sequential_IO (String);
12208  F : IO.File_Type;
12209  S : String (1..4);
12210  @dots{}
12211  IO.Create (F)
12212  IO.Write (F, "hello!")
12213  IO.Reset (F, Mode=>In_File);
12214  IO.Read (F, S);
12215  Put_Line (S);
12216
12217 @end smallexample
12218
12219 @noindent
12220 On some Ada implementations, this will print @code{hell}, but the program is
12221 clearly incorrect, since there is only one element in the file, and that
12222 element is the string @code{hello!}.
12223
12224 In Ada 95 and Ada 2005, this kind of behavior can be legitimately achieved
12225 using Stream_IO, and this is the preferred mechanism.  In particular, the
12226 above program fragment rewritten to use Stream_IO will work correctly.
12227
12228 @node Text_IO
12229 @section Text_IO
12230
12231 @noindent
12232 Text_IO files consist of a stream of characters containing the following
12233 special control characters:
12234
12235 @smallexample
12236 LF (line feed, 16#0A#) Line Mark
12237 FF (form feed, 16#0C#) Page Mark
12238 @end smallexample
12239
12240 @noindent
12241 A canonical Text_IO file is defined as one in which the following
12242 conditions are met:
12243
12244 @itemize @bullet
12245 @item
12246 The character @code{LF} is used only as a line mark, i.e.@: to mark the end
12247 of the line.
12248
12249 @item
12250 The character @code{FF} is used only as a page mark, i.e.@: to mark the
12251 end of a page and consequently can appear only immediately following a
12252 @code{LF} (line mark) character.
12253
12254 @item
12255 The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
12256 (line mark, page mark).  In the former case, the page mark is implicitly
12257 assumed to be present.
12258 @end itemize
12259
12260 @noindent
12261 A file written using Text_IO will be in canonical form provided that no
12262 explicit @code{LF} or @code{FF} characters are written using @code{Put}
12263 or @code{Put_Line}.  There will be no @code{FF} character at the end of
12264 the file unless an explicit @code{New_Page} operation was performed
12265 before closing the file.
12266
12267 A canonical Text_IO file that is a regular file (i.e., not a device or a
12268 pipe) can be read using any of the routines in Text_IO@.  The
12269 semantics in this case will be exactly as defined in the Ada Reference
12270 Manual, and all the routines in Text_IO are fully implemented.
12271
12272 A text file that does not meet the requirements for a canonical Text_IO
12273 file has one of the following:
12274
12275 @itemize @bullet
12276 @item
12277 The file contains @code{FF} characters not immediately following a
12278 @code{LF} character.
12279
12280 @item
12281 The file contains @code{LF} or @code{FF} characters written by
12282 @code{Put} or @code{Put_Line}, which are not logically considered to be
12283 line marks or page marks.
12284
12285 @item
12286 The file ends in a character other than @code{LF} or @code{FF},
12287 i.e.@: there is no explicit line mark or page mark at the end of the file.
12288 @end itemize
12289
12290 @noindent
12291 Text_IO can be used to read such non-standard text files but subprograms
12292 to do with line or page numbers do not have defined meanings.  In
12293 particular, a @code{FF} character that does not follow a @code{LF}
12294 character may or may not be treated as a page mark from the point of
12295 view of page and line numbering.  Every @code{LF} character is considered
12296 to end a line, and there is an implied @code{LF} character at the end of
12297 the file.
12298
12299 @menu
12300 * Text_IO Stream Pointer Positioning::
12301 * Text_IO Reading and Writing Non-Regular Files::
12302 * Get_Immediate::
12303 * Treating Text_IO Files as Streams::
12304 * Text_IO Extensions::
12305 * Text_IO Facilities for Unbounded Strings::
12306 @end menu
12307
12308 @node Text_IO Stream Pointer Positioning
12309 @subsection Stream Pointer Positioning
12310
12311 @noindent
12312 @code{Ada.Text_IO} has a definition of current position for a file that
12313 is being read.  No internal buffering occurs in Text_IO, and usually the
12314 physical position in the stream used to implement the file corresponds
12315 to this logical position defined by Text_IO@.  There are two exceptions:
12316
12317 @itemize @bullet
12318 @item
12319 After a call to @code{End_Of_Page} that returns @code{True}, the stream
12320 is positioned past the @code{LF} (line mark) that precedes the page
12321 mark.  Text_IO maintains an internal flag so that subsequent read
12322 operations properly handle the logical position which is unchanged by
12323 the @code{End_Of_Page} call.
12324
12325 @item
12326 After a call to @code{End_Of_File} that returns @code{True}, if the
12327 Text_IO file was positioned before the line mark at the end of file
12328 before the call, then the logical position is unchanged, but the stream
12329 is physically positioned right at the end of file (past the line mark,
12330 and past a possible page mark following the line mark.  Again Text_IO
12331 maintains internal flags so that subsequent read operations properly
12332 handle the logical position.
12333 @end itemize
12334
12335 @noindent
12336 These discrepancies have no effect on the observable behavior of
12337 Text_IO, but if a single Ada stream is shared between a C program and
12338 Ada program, or shared (using @samp{shared=yes} in the form string)
12339 between two Ada files, then the difference may be observable in some
12340 situations.
12341
12342 @node Text_IO Reading and Writing Non-Regular Files
12343 @subsection Reading and Writing Non-Regular Files
12344
12345 @noindent
12346 A non-regular file is a device (such as a keyboard), or a pipe.  Text_IO
12347 can be used for reading and writing.  Writing is not affected and the
12348 sequence of characters output is identical to the normal file case, but
12349 for reading, the behavior of Text_IO is modified to avoid undesirable
12350 look-ahead as follows:
12351
12352 An input file that is not a regular file is considered to have no page
12353 marks.  Any @code{Ascii.FF} characters (the character normally used for a
12354 page mark) appearing in the file are considered to be data
12355 characters.  In particular:
12356
12357 @itemize @bullet
12358 @item
12359 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
12360 following a line mark.  If a page mark appears, it will be treated as a
12361 data character.
12362
12363 @item
12364 This avoids the need to wait for an extra character to be typed or
12365 entered from the pipe to complete one of these operations.
12366
12367 @item
12368 @code{End_Of_Page} always returns @code{False}
12369
12370 @item
12371 @code{End_Of_File} will return @code{False} if there is a page mark at
12372 the end of the file.
12373 @end itemize
12374
12375 @noindent
12376 Output to non-regular files is the same as for regular files.  Page marks
12377 may be written to non-regular files using @code{New_Page}, but as noted
12378 above they will not be treated as page marks on input if the output is
12379 piped to another Ada program.
12380
12381 Another important discrepancy when reading non-regular files is that the end
12382 of file indication is not ``sticky''.  If an end of file is entered, e.g.@: by
12383 pressing the @key{EOT} key,
12384 then end of file
12385 is signaled once (i.e.@: the test @code{End_Of_File}
12386 will yield @code{True}, or a read will
12387 raise @code{End_Error}), but then reading can resume
12388 to read data past that end of
12389 file indication, until another end of file indication is entered.
12390
12391 @node Get_Immediate
12392 @subsection Get_Immediate
12393 @cindex Get_Immediate
12394
12395 @noindent
12396 Get_Immediate returns the next character (including control characters)
12397 from the input file.  In particular, Get_Immediate will return LF or FF
12398 characters used as line marks or page marks.  Such operations leave the
12399 file positioned past the control character, and it is thus not treated
12400 as having its normal function.  This means that page, line and column
12401 counts after this kind of Get_Immediate call are set as though the mark
12402 did not occur.  In the case where a Get_Immediate leaves the file
12403 positioned between the line mark and page mark (which is not normally
12404 possible), it is undefined whether the FF character will be treated as a
12405 page mark.
12406
12407 @node Treating Text_IO Files as Streams
12408 @subsection Treating Text_IO Files as Streams
12409 @cindex Stream files
12410
12411 @noindent
12412 The package @code{Text_IO.Streams} allows a Text_IO file to be treated
12413 as a stream.  Data written to a Text_IO file in this stream mode is
12414 binary data.  If this binary data contains bytes 16#0A# (@code{LF}) or
12415 16#0C# (@code{FF}), the resulting file may have non-standard
12416 format.  Similarly if read operations are used to read from a Text_IO
12417 file treated as a stream, then @code{LF} and @code{FF} characters may be
12418 skipped and the effect is similar to that described above for
12419 @code{Get_Immediate}.
12420
12421 @node Text_IO Extensions
12422 @subsection Text_IO Extensions
12423 @cindex Text_IO extensions
12424
12425 @noindent
12426 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
12427 to the standard @code{Text_IO} package:
12428
12429 @itemize @bullet
12430 @item function File_Exists (Name : String) return Boolean;
12431 Determines if a file of the given name exists.
12432
12433 @item function Get_Line return String;
12434 Reads a string from the standard input file.  The value returned is exactly
12435 the length of the line that was read.
12436
12437 @item function Get_Line (File : Ada.Text_IO.File_Type) return String;
12438 Similar, except that the parameter File specifies the file from which
12439 the string is to be read.
12440
12441 @end itemize
12442
12443 @node Text_IO Facilities for Unbounded Strings
12444 @subsection Text_IO Facilities for Unbounded Strings
12445 @cindex Text_IO for unbounded strings
12446 @cindex Unbounded_String, Text_IO operations
12447
12448 @noindent
12449 The package @code{Ada.Strings.Unbounded.Text_IO}
12450 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
12451 subprograms useful for Text_IO operations on unbounded strings:
12452
12453 @itemize @bullet
12454
12455 @item function Get_Line (File : File_Type) return Unbounded_String;
12456 Reads a line from the specified file
12457 and returns the result as an unbounded string.
12458
12459 @item procedure Put (File : File_Type; U : Unbounded_String);
12460 Writes the value of the given unbounded string to the specified file
12461 Similar to the effect of
12462 @code{Put (To_String (U))} except that an extra copy is avoided.
12463
12464 @item procedure Put_Line (File : File_Type; U : Unbounded_String);
12465 Writes the value of the given unbounded string to the specified file,
12466 followed by a @code{New_Line}.
12467 Similar to the effect of @code{Put_Line (To_String (U))} except
12468 that an extra copy is avoided.
12469 @end itemize
12470
12471 @noindent
12472 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
12473 and is optional.  If the parameter is omitted, then the standard input or
12474 output file is referenced as appropriate.
12475
12476 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
12477 files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended
12478 @code{Wide_Text_IO} functionality for unbounded wide strings.
12479
12480 The package @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} in library
12481 files @file{a-szuzti.ads} and @file{a-szuzti.adb} provides similar extended
12482 @code{Wide_Wide_Text_IO} functionality for unbounded wide wide strings.
12483
12484 @node Wide_Text_IO
12485 @section Wide_Text_IO
12486
12487 @noindent
12488 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
12489 both input and output files may contain special sequences that represent
12490 wide character values.  The encoding scheme for a given file may be
12491 specified using a FORM parameter:
12492
12493 @smallexample
12494 WCEM=@var{x}
12495 @end smallexample
12496
12497 @noindent
12498 as part of the FORM string (WCEM = wide character encoding method),
12499 where @var{x} is one of the following characters
12500
12501 @table @samp
12502 @item h
12503 Hex ESC encoding
12504 @item u
12505 Upper half encoding
12506 @item s
12507 Shift-JIS encoding
12508 @item e
12509 EUC Encoding
12510 @item 8
12511 UTF-8 encoding
12512 @item b
12513 Brackets encoding
12514 @end table
12515
12516 @noindent
12517 The encoding methods match those that
12518 can be used in a source
12519 program, but there is no requirement that the encoding method used for
12520 the source program be the same as the encoding method used for files,
12521 and different files may use different encoding methods.
12522
12523 The default encoding method for the standard files, and for opened files
12524 for which no WCEM parameter is given in the FORM string matches the
12525 wide character encoding specified for the main program (the default
12526 being brackets encoding if no coding method was specified with -gnatW).
12527
12528 @table @asis
12529 @item Hex Coding
12530 In this encoding, a wide character is represented by a five character
12531 sequence:
12532
12533 @smallexample
12534 ESC a b c d
12535 @end smallexample
12536
12537 @noindent
12538 where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
12539 characters (using upper case letters) of the wide character code.  For
12540 example, ESC A345 is used to represent the wide character with code
12541 16#A345#.  This scheme is compatible with use of the full
12542 @code{Wide_Character} set.
12543
12544 @item Upper Half Coding
12545 The wide character with encoding 16#abcd#, where the upper bit is on
12546 (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
12547 16#cd#.  The second byte may never be a format control character, but is
12548 not required to be in the upper half.  This method can be also used for
12549 shift-JIS or EUC where the internal coding matches the external coding.
12550
12551 @item Shift JIS Coding
12552 A wide character is represented by a two character sequence 16#ab# and
12553 16#cd#, with the restrictions described for upper half encoding as
12554 described above.  The internal character code is the corresponding JIS
12555 character according to the standard algorithm for Shift-JIS
12556 conversion.  Only characters defined in the JIS code set table can be
12557 used with this encoding method.
12558
12559 @item EUC Coding
12560 A wide character is represented by a two character sequence 16#ab# and
12561 16#cd#, with both characters being in the upper half.  The internal
12562 character code is the corresponding JIS character according to the EUC
12563 encoding algorithm.  Only characters defined in the JIS code set table
12564 can be used with this encoding method.
12565
12566 @item UTF-8 Coding
12567 A wide character is represented using
12568 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
12569 10646-1/Am.2.  Depending on the character value, the representation
12570 is a one, two, or three byte sequence:
12571
12572 @smallexample
12573 16#0000#-16#007f#: 2#0xxxxxxx#
12574 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
12575 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
12576 @end smallexample
12577
12578 @noindent
12579 where the @var{xxx} bits correspond to the left-padded bits of the
12580 16-bit character value.  Note that all lower half ASCII characters
12581 are represented as ASCII bytes and all upper half characters and
12582 other wide characters are represented as sequences of upper-half
12583 (The full UTF-8 scheme allows for encoding 31-bit characters as
12584 6-byte sequences, but in this implementation, all UTF-8 sequences
12585 of four or more bytes length will raise a Constraint_Error, as
12586 will all invalid UTF-8 sequences.)
12587
12588 @item Brackets Coding
12589 In this encoding, a wide character is represented by the following eight
12590 character sequence:
12591
12592 @smallexample
12593 [ " a b c d " ]
12594 @end smallexample
12595
12596 @noindent
12597 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
12598 characters (using uppercase letters) of the wide character code.  For
12599 example, @code{["A345"]} is used to represent the wide character with code
12600 @code{16#A345#}.
12601 This scheme is compatible with use of the full Wide_Character set.
12602 On input, brackets coding can also be used for upper half characters,
12603 e.g.@: @code{["C1"]} for lower case a.  However, on output, brackets notation
12604 is only used for wide characters with a code greater than @code{16#FF#}.
12605
12606 Note that brackets coding is not normally used in the context of
12607 Wide_Text_IO or Wide_Wide_Text_IO, since it is really just designed as
12608 a portable way of encoding source files. In the context of Wide_Text_IO
12609 or Wide_Wide_Text_IO, it can only be used if the file does not contain
12610 any instance of the left bracket character other than to encode wide
12611 character values using the brackets encoding method. In practice it is
12612 expected that some standard wide character encoding method such
12613 as UTF-8 will be used for text input output.
12614
12615 If brackets notation is used, then any occurrence of a left bracket
12616 in the input file which is not the start of a valid wide character
12617 sequence will cause Constraint_Error to be raised. It is possible to
12618 encode a left bracket as ["5B"] and Wide_Text_IO and Wide_Wide_Text_IO
12619 input will interpret this as a left bracket.
12620
12621 However, when a left bracket is output, it will be output as a left bracket
12622 and not as ["5B"]. We make this decision because for normal use of
12623 Wide_Text_IO for outputting messages, it is unpleasant to clobber left
12624 brackets. For example, if we write:
12625
12626 @smallexample
12627    Put_Line ("Start of output [first run]");
12628 @end smallexample
12629
12630 @noindent
12631 we really do not want to have the left bracket in this message clobbered so
12632 that the output reads:
12633
12634 @smallexample
12635    Start of output ["5B"]first run]
12636 @end smallexample
12637
12638 @noindent
12639 In practice brackets encoding is reasonably useful for normal Put_Line use
12640 since we won't get confused between left brackets and wide character
12641 sequences in the output. But for input, or when files are written out
12642 and read back in, it really makes better sense to use one of the standard
12643 encoding methods such as UTF-8.
12644
12645 @end table
12646
12647 @noindent
12648 For the coding schemes other than UTF-8, Hex, or Brackets encoding,
12649 not all wide character
12650 values can be represented.  An attempt to output a character that cannot
12651 be represented using the encoding scheme for the file causes
12652 Constraint_Error to be raised.  An invalid wide character sequence on
12653 input also causes Constraint_Error to be raised.
12654
12655 @menu
12656 * Wide_Text_IO Stream Pointer Positioning::
12657 * Wide_Text_IO Reading and Writing Non-Regular Files::
12658 @end menu
12659
12660 @node Wide_Text_IO Stream Pointer Positioning
12661 @subsection Stream Pointer Positioning
12662
12663 @noindent
12664 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
12665 of stream pointer positioning (@pxref{Text_IO}).  There is one additional
12666 case:
12667
12668 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
12669 normal lower ASCII set (i.e.@: a character in the range:
12670
12671 @smallexample @c ada
12672 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
12673 @end smallexample
12674
12675 @noindent
12676 then although the logical position of the file pointer is unchanged by
12677 the @code{Look_Ahead} call, the stream is physically positioned past the
12678 wide character sequence.  Again this is to avoid the need for buffering
12679 or backup, and all @code{Wide_Text_IO} routines check the internal
12680 indication that this situation has occurred so that this is not visible
12681 to a normal program using @code{Wide_Text_IO}.  However, this discrepancy
12682 can be observed if the wide text file shares a stream with another file.
12683
12684 @node Wide_Text_IO Reading and Writing Non-Regular Files
12685 @subsection Reading and Writing Non-Regular Files
12686
12687 @noindent
12688 As in the case of Text_IO, when a non-regular file is read, it is
12689 assumed that the file contains no page marks (any form characters are
12690 treated as data characters), and @code{End_Of_Page} always returns
12691 @code{False}.  Similarly, the end of file indication is not sticky, so
12692 it is possible to read beyond an end of file.
12693
12694 @node Wide_Wide_Text_IO
12695 @section Wide_Wide_Text_IO
12696
12697 @noindent
12698 @code{Wide_Wide_Text_IO} is similar in most respects to Text_IO, except that
12699 both input and output files may contain special sequences that represent
12700 wide wide character values.  The encoding scheme for a given file may be
12701 specified using a FORM parameter:
12702
12703 @smallexample
12704 WCEM=@var{x}
12705 @end smallexample
12706
12707 @noindent
12708 as part of the FORM string (WCEM = wide character encoding method),
12709 where @var{x} is one of the following characters
12710
12711 @table @samp
12712 @item h
12713 Hex ESC encoding
12714 @item u
12715 Upper half encoding
12716 @item s
12717 Shift-JIS encoding
12718 @item e
12719 EUC Encoding
12720 @item 8
12721 UTF-8 encoding
12722 @item b
12723 Brackets encoding
12724 @end table
12725
12726 @noindent
12727 The encoding methods match those that
12728 can be used in a source
12729 program, but there is no requirement that the encoding method used for
12730 the source program be the same as the encoding method used for files,
12731 and different files may use different encoding methods.
12732
12733 The default encoding method for the standard files, and for opened files
12734 for which no WCEM parameter is given in the FORM string matches the
12735 wide character encoding specified for the main program (the default
12736 being brackets encoding if no coding method was specified with -gnatW).
12737
12738 @table @asis
12739
12740 @item UTF-8 Coding
12741 A wide character is represented using
12742 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
12743 10646-1/Am.2.  Depending on the character value, the representation
12744 is a one, two, three, or four byte sequence:
12745
12746 @smallexample
12747 16#000000#-16#00007f#: 2#0xxxxxxx#
12748 16#000080#-16#0007ff#: 2#110xxxxx# 2#10xxxxxx#
12749 16#000800#-16#00ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
12750 16#010000#-16#10ffff#: 2#11110xxx# 2#10xxxxxx# 2#10xxxxxx# 2#10xxxxxx#
12751 @end smallexample
12752
12753 @noindent
12754 where the @var{xxx} bits correspond to the left-padded bits of the
12755 21-bit character value.  Note that all lower half ASCII characters
12756 are represented as ASCII bytes and all upper half characters and
12757 other wide characters are represented as sequences of upper-half
12758 characters.
12759
12760 @item Brackets Coding
12761 In this encoding, a wide wide character is represented by the following eight
12762 character sequence if is in wide character range
12763
12764 @smallexample
12765 [ " a b c d " ]
12766 @end smallexample
12767
12768 and by the following ten character sequence if not
12769
12770 @smallexample
12771 [ " a b c d e f " ]
12772 @end smallexample
12773
12774 @noindent
12775 where @code{a}, @code{b}, @code{c}, @code{d}, @code{e}, and @code{f}
12776 are the four or six hexadecimal
12777 characters (using uppercase letters) of the wide wide character code.  For
12778 example, @code{["01A345"]} is used to represent the wide wide character
12779 with code @code{16#01A345#}.
12780
12781 This scheme is compatible with use of the full Wide_Wide_Character set.
12782 On input, brackets coding can also be used for upper half characters,
12783 e.g.@: @code{["C1"]} for lower case a.  However, on output, brackets notation
12784 is only used for wide characters with a code greater than @code{16#FF#}.
12785
12786 @end table
12787
12788 @noindent
12789 If is also possible to use the other Wide_Character encoding methods,
12790 such as Shift-JIS, but the other schemes cannot support the full range
12791 of wide wide characters.
12792 An attempt to output a character that cannot
12793 be represented using the encoding scheme for the file causes
12794 Constraint_Error to be raised.  An invalid wide character sequence on
12795 input also causes Constraint_Error to be raised.
12796
12797 @menu
12798 * Wide_Wide_Text_IO Stream Pointer Positioning::
12799 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
12800 @end menu
12801
12802 @node Wide_Wide_Text_IO Stream Pointer Positioning
12803 @subsection Stream Pointer Positioning
12804
12805 @noindent
12806 @code{Ada.Wide_Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
12807 of stream pointer positioning (@pxref{Text_IO}).  There is one additional
12808 case:
12809
12810 If @code{Ada.Wide_Wide_Text_IO.Look_Ahead} reads a character outside the
12811 normal lower ASCII set (i.e.@: a character in the range:
12812
12813 @smallexample @c ada
12814 Wide_Wide_Character'Val (16#0080#) .. Wide_Wide_Character'Val (16#10FFFF#)
12815 @end smallexample
12816
12817 @noindent
12818 then although the logical position of the file pointer is unchanged by
12819 the @code{Look_Ahead} call, the stream is physically positioned past the
12820 wide character sequence.  Again this is to avoid the need for buffering
12821 or backup, and all @code{Wide_Wide_Text_IO} routines check the internal
12822 indication that this situation has occurred so that this is not visible
12823 to a normal program using @code{Wide_Wide_Text_IO}.  However, this discrepancy
12824 can be observed if the wide text file shares a stream with another file.
12825
12826 @node Wide_Wide_Text_IO Reading and Writing Non-Regular Files
12827 @subsection Reading and Writing Non-Regular Files
12828
12829 @noindent
12830 As in the case of Text_IO, when a non-regular file is read, it is
12831 assumed that the file contains no page marks (any form characters are
12832 treated as data characters), and @code{End_Of_Page} always returns
12833 @code{False}.  Similarly, the end of file indication is not sticky, so
12834 it is possible to read beyond an end of file.
12835
12836 @node Stream_IO
12837 @section Stream_IO
12838
12839 @noindent
12840 A stream file is a sequence of bytes, where individual elements are
12841 written to the file as described in the Ada Reference Manual.  The type
12842 @code{Stream_Element} is simply a byte.  There are two ways to read or
12843 write a stream file.
12844
12845 @itemize @bullet
12846 @item
12847 The operations @code{Read} and @code{Write} directly read or write a
12848 sequence of stream elements with no control information.
12849
12850 @item
12851 The stream attributes applied to a stream file transfer data in the
12852 manner described for stream attributes.
12853 @end itemize
12854
12855 @node Shared Files
12856 @section Shared Files
12857
12858 @noindent
12859 Section A.14 of the Ada Reference Manual allows implementations to
12860 provide a wide variety of behavior if an attempt is made to access the
12861 same external file with two or more internal files.
12862
12863 To provide a full range of functionality, while at the same time
12864 minimizing the problems of portability caused by this implementation
12865 dependence, GNAT handles file sharing as follows:
12866
12867 @itemize @bullet
12868 @item
12869 In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
12870 to open two or more files with the same full name is considered an error
12871 and is not supported.  The exception @code{Use_Error} will be
12872 raised.  Note that a file that is not explicitly closed by the program
12873 remains open until the program terminates.
12874
12875 @item
12876 If the form parameter @samp{shared=no} appears in the form string, the
12877 file can be opened or created with its own separate stream identifier,
12878 regardless of whether other files sharing the same external file are
12879 opened.  The exact effect depends on how the C stream routines handle
12880 multiple accesses to the same external files using separate streams.
12881
12882 @item
12883 If the form parameter @samp{shared=yes} appears in the form string for
12884 each of two or more files opened using the same full name, the same
12885 stream is shared between these files, and the semantics are as described
12886 in Ada Reference Manual, Section A.14.
12887 @end itemize
12888
12889 @noindent
12890 When a program that opens multiple files with the same name is ported
12891 from another Ada compiler to GNAT, the effect will be that
12892 @code{Use_Error} is raised.
12893
12894 The documentation of the original compiler and the documentation of the
12895 program should then be examined to determine if file sharing was
12896 expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
12897 and @code{Create} calls as required.
12898
12899 When a program is ported from GNAT to some other Ada compiler, no
12900 special attention is required unless the @samp{shared=@var{xxx}} form
12901 parameter is used in the program.  In this case, you must examine the
12902 documentation of the new compiler to see if it supports the required
12903 file sharing semantics, and form strings modified appropriately.  Of
12904 course it may be the case that the program cannot be ported if the
12905 target compiler does not support the required functionality.  The best
12906 approach in writing portable code is to avoid file sharing (and hence
12907 the use of the @samp{shared=@var{xxx}} parameter in the form string)
12908 completely.
12909
12910 One common use of file sharing in Ada 83 is the use of instantiations of
12911 Sequential_IO on the same file with different types, to achieve
12912 heterogeneous input-output.  Although this approach will work in GNAT if
12913 @samp{shared=yes} is specified, it is preferable in Ada to use Stream_IO
12914 for this purpose (using the stream attributes)
12915
12916 @node Filenames encoding
12917 @section Filenames encoding
12918
12919 @noindent
12920 An encoding form parameter can be used to specify the filename
12921 encoding @samp{encoding=@var{xxx}}.
12922
12923 @itemize @bullet
12924 @item
12925 If the form parameter @samp{encoding=utf8} appears in the form string, the
12926 filename must be encoded in UTF-8.
12927
12928 @item
12929 If the form parameter @samp{encoding=8bits} appears in the form
12930 string, the filename must be a standard 8bits string.
12931 @end itemize
12932
12933 In the absence of a @samp{encoding=@var{xxx}} form parameter, the
12934 value UTF-8 is used. This encoding form parameter is only supported on
12935 the Windows platform. On the other Operating Systems the runtime is
12936 supporting UTF-8 natively.
12937
12938 @node Open Modes
12939 @section Open Modes
12940
12941 @noindent
12942 @code{Open} and @code{Create} calls result in a call to @code{fopen}
12943 using the mode shown in the following table:
12944
12945 @sp 2
12946 @center @code{Open} and @code{Create} Call Modes
12947 @smallexample
12948                                @b{OPEN }           @b{CREATE}
12949 Append_File                    "r+"             "w+"
12950 In_File                        "r"              "w+"
12951 Out_File (Direct_IO)           "r+"             "w"
12952 Out_File (all other cases)     "w"              "w"
12953 Inout_File                     "r+"             "w+"
12954 @end smallexample
12955
12956 @noindent
12957 If text file translation is required, then either @samp{b} or @samp{t}
12958 is added to the mode, depending on the setting of Text.  Text file
12959 translation refers to the mapping of CR/LF sequences in an external file
12960 to LF characters internally.  This mapping only occurs in DOS and
12961 DOS-like systems, and is not relevant to other systems.
12962
12963 A special case occurs with Stream_IO@.  As shown in the above table, the
12964 file is initially opened in @samp{r} or @samp{w} mode for the
12965 @code{In_File} and @code{Out_File} cases.  If a @code{Set_Mode} operation
12966 subsequently requires switching from reading to writing or vice-versa,
12967 then the file is reopened in @samp{r+} mode to permit the required operation.
12968
12969 @node Operations on C Streams
12970 @section Operations on C Streams
12971 The package @code{Interfaces.C_Streams} provides an Ada program with direct
12972 access to the C library functions for operations on C streams:
12973
12974 @smallexample @c adanocomment
12975 package Interfaces.C_Streams is
12976   -- Note: the reason we do not use the types that are in
12977   -- Interfaces.C is that we want to avoid dragging in the
12978   -- code in this unit if possible.
12979   subtype chars is System.Address;
12980   -- Pointer to null-terminated array of characters
12981   subtype FILEs is System.Address;
12982   -- Corresponds to the C type FILE*
12983   subtype voids is System.Address;
12984   -- Corresponds to the C type void*
12985   subtype int is Integer;
12986   subtype long is Long_Integer;
12987   -- Note: the above types are subtypes deliberately, and it
12988   -- is part of this spec that the above correspondences are
12989   -- guaranteed.  This means that it is legitimate to, for
12990   -- example, use Integer instead of int.  We provide these
12991   -- synonyms for clarity, but in some cases it may be
12992   -- convenient to use the underlying types (for example to
12993   -- avoid an unnecessary dependency of a spec on the spec
12994   -- of this unit).
12995   type size_t is mod 2 ** Standard'Address_Size;
12996   NULL_Stream : constant FILEs;
12997   -- Value returned (NULL in C) to indicate an
12998   -- fdopen/fopen/tmpfile error
12999   ----------------------------------
13000   -- Constants Defined in stdio.h --
13001   ----------------------------------
13002   EOF : constant int;
13003   -- Used by a number of routines to indicate error or
13004   -- end of file
13005   IOFBF : constant int;
13006   IOLBF : constant int;
13007   IONBF : constant int;
13008   -- Used to indicate buffering mode for setvbuf call
13009   SEEK_CUR : constant int;
13010   SEEK_END : constant int;
13011   SEEK_SET : constant int;
13012   -- Used to indicate origin for fseek call
13013   function stdin return FILEs;
13014   function stdout return FILEs;
13015   function stderr return FILEs;
13016   -- Streams associated with standard files
13017   --------------------------
13018   -- Standard C functions --
13019   --------------------------
13020   -- The functions selected below are ones that are
13021   -- available in DOS, OS/2, UNIX and Xenix (but not
13022   -- necessarily in ANSI C).  These are very thin interfaces
13023   -- which copy exactly the C headers.  For more
13024   -- documentation on these functions, see the Microsoft C
13025   -- "Run-Time Library Reference" (Microsoft Press, 1990,
13026   -- ISBN 1-55615-225-6), which includes useful information
13027   -- on system compatibility.
13028   procedure clearerr (stream : FILEs);
13029   function fclose (stream : FILEs) return int;
13030   function fdopen (handle : int; mode : chars) return FILEs;
13031   function feof (stream : FILEs) return int;
13032   function ferror (stream : FILEs) return int;
13033   function fflush (stream : FILEs) return int;
13034   function fgetc (stream : FILEs) return int;
13035   function fgets (strng : chars; n : int; stream : FILEs)
13036       return chars;
13037   function fileno (stream : FILEs) return int;
13038   function fopen (filename : chars; Mode : chars)
13039       return FILEs;
13040   -- Note: to maintain target independence, use
13041   -- text_translation_required, a boolean variable defined in
13042   -- a-sysdep.c to deal with the target dependent text
13043   -- translation requirement.  If this variable is set,
13044   -- then  b/t should be appended to the standard mode
13045   -- argument to set the text translation mode off or on
13046   -- as required.
13047   function fputc (C : int; stream : FILEs) return int;
13048   function fputs (Strng : chars; Stream : FILEs) return int;
13049   function fread
13050      (buffer : voids;
13051       size : size_t;
13052       count : size_t;
13053       stream : FILEs)
13054       return size_t;
13055   function freopen
13056      (filename : chars;
13057       mode : chars;
13058       stream : FILEs)
13059       return FILEs;
13060   function fseek
13061      (stream : FILEs;
13062       offset : long;
13063       origin : int)
13064       return int;
13065   function ftell (stream : FILEs) return long;
13066   function fwrite
13067      (buffer : voids;
13068       size : size_t;
13069       count : size_t;
13070       stream : FILEs)
13071       return size_t;
13072   function isatty (handle : int) return int;
13073   procedure mktemp (template : chars);
13074   -- The return value (which is just a pointer to template)
13075   -- is discarded
13076   procedure rewind (stream : FILEs);
13077   function rmtmp return int;
13078   function setvbuf
13079      (stream : FILEs;
13080       buffer : chars;
13081       mode : int;
13082       size : size_t)
13083       return int;
13084
13085   function tmpfile return FILEs;
13086   function ungetc (c : int; stream : FILEs) return int;
13087   function unlink (filename : chars) return int;
13088   ---------------------
13089   -- Extra functions --
13090   ---------------------
13091   -- These functions supply slightly thicker bindings than
13092   -- those above.  They are derived from functions in the
13093   -- C Run-Time Library, but may do a bit more work than
13094   -- just directly calling one of the Library functions.
13095   function is_regular_file (handle : int) return int;
13096   -- Tests if given handle is for a regular file (result 1)
13097   -- or for a non-regular file (pipe or device, result 0).
13098   ---------------------------------
13099   -- Control of Text/Binary Mode --
13100   ---------------------------------
13101   -- If text_translation_required is true, then the following
13102   -- functions may be used to dynamically switch a file from
13103   -- binary to text mode or vice versa.  These functions have
13104   -- no effect if text_translation_required is false (i.e.@: in
13105   -- normal UNIX mode).  Use fileno to get a stream handle.
13106   procedure set_binary_mode (handle : int);
13107   procedure set_text_mode (handle : int);
13108   ----------------------------
13109   -- Full Path Name support --
13110   ----------------------------
13111   procedure full_name (nam : chars; buffer : chars);
13112   -- Given a NUL terminated string representing a file
13113   -- name, returns in buffer a NUL terminated string
13114   -- representing the full path name for the file name.
13115   -- On systems where it is relevant the   drive is also
13116   -- part of the full path name.  It is the responsibility
13117   -- of the caller to pass an actual parameter for buffer
13118   -- that is big enough for any full path name.  Use
13119   -- max_path_len given below as the size of buffer.
13120   max_path_len : integer;
13121   -- Maximum length of an allowable full path name on the
13122   -- system, including a terminating NUL character.
13123 end Interfaces.C_Streams;
13124 @end smallexample
13125
13126 @node Interfacing to C Streams
13127 @section Interfacing to C Streams
13128
13129 @noindent
13130 The packages in this section permit interfacing Ada files to C Stream
13131 operations.
13132
13133 @smallexample @c ada
13134  with Interfaces.C_Streams;
13135  package Ada.Sequential_IO.C_Streams is
13136     function C_Stream (F : File_Type)
13137        return Interfaces.C_Streams.FILEs;
13138     procedure Open
13139       (File : in out File_Type;
13140        Mode : in File_Mode;
13141        C_Stream : in Interfaces.C_Streams.FILEs;
13142        Form : in String := "");
13143  end Ada.Sequential_IO.C_Streams;
13144
13145   with Interfaces.C_Streams;
13146   package Ada.Direct_IO.C_Streams is
13147      function C_Stream (F : File_Type)
13148         return Interfaces.C_Streams.FILEs;
13149      procedure Open
13150        (File : in out File_Type;
13151         Mode : in File_Mode;
13152         C_Stream : in Interfaces.C_Streams.FILEs;
13153         Form : in String := "");
13154   end Ada.Direct_IO.C_Streams;
13155
13156   with Interfaces.C_Streams;
13157   package Ada.Text_IO.C_Streams is
13158      function C_Stream (F : File_Type)
13159         return Interfaces.C_Streams.FILEs;
13160      procedure Open
13161        (File : in out File_Type;
13162         Mode : in File_Mode;
13163         C_Stream : in Interfaces.C_Streams.FILEs;
13164         Form : in String := "");
13165   end Ada.Text_IO.C_Streams;
13166
13167   with Interfaces.C_Streams;
13168   package Ada.Wide_Text_IO.C_Streams is
13169      function C_Stream (F : File_Type)
13170         return Interfaces.C_Streams.FILEs;
13171      procedure Open
13172        (File : in out File_Type;
13173         Mode : in File_Mode;
13174         C_Stream : in Interfaces.C_Streams.FILEs;
13175         Form : in String := "");
13176  end Ada.Wide_Text_IO.C_Streams;
13177
13178   with Interfaces.C_Streams;
13179   package Ada.Wide_Wide_Text_IO.C_Streams is
13180      function C_Stream (F : File_Type)
13181         return Interfaces.C_Streams.FILEs;
13182      procedure Open
13183        (File : in out File_Type;
13184         Mode : in File_Mode;
13185         C_Stream : in Interfaces.C_Streams.FILEs;
13186         Form : in String := "");
13187  end Ada.Wide_Wide_Text_IO.C_Streams;
13188
13189  with Interfaces.C_Streams;
13190  package Ada.Stream_IO.C_Streams is
13191     function C_Stream (F : File_Type)
13192        return Interfaces.C_Streams.FILEs;
13193     procedure Open
13194       (File : in out File_Type;
13195        Mode : in File_Mode;
13196        C_Stream : in Interfaces.C_Streams.FILEs;
13197        Form : in String := "");
13198  end Ada.Stream_IO.C_Streams;
13199 @end smallexample
13200
13201 @noindent
13202 In each of these six packages, the @code{C_Stream} function obtains the
13203 @code{FILE} pointer from a currently opened Ada file.  It is then
13204 possible to use the @code{Interfaces.C_Streams} package to operate on
13205 this stream, or the stream can be passed to a C program which can
13206 operate on it directly.  Of course the program is responsible for
13207 ensuring that only appropriate sequences of operations are executed.
13208
13209 One particular use of relevance to an Ada program is that the
13210 @code{setvbuf} function can be used to control the buffering of the
13211 stream used by an Ada file.  In the absence of such a call the standard
13212 default buffering is used.
13213
13214 The @code{Open} procedures in these packages open a file giving an
13215 existing C Stream instead of a file name.  Typically this stream is
13216 imported from a C program, allowing an Ada file to operate on an
13217 existing C file.
13218
13219 @node The GNAT Library
13220 @chapter The GNAT Library
13221
13222 @noindent
13223 The GNAT library contains a number of general and special purpose packages.
13224 It represents functionality that the GNAT developers have found useful, and
13225 which is made available to GNAT users.  The packages described here are fully
13226 supported, and upwards compatibility will be maintained in future releases,
13227 so you can use these facilities with the confidence that the same functionality
13228 will be available in future releases.
13229
13230 The chapter here simply gives a brief summary of the facilities available.
13231 The full documentation is found in the spec file for the package.  The full
13232 sources of these library packages, including both spec and body, are provided
13233 with all GNAT releases.  For example, to find out the full specifications of
13234 the SPITBOL pattern matching capability, including a full tutorial and
13235 extensive examples, look in the @file{g-spipat.ads} file in the library.
13236
13237 For each entry here, the package name (as it would appear in a @code{with}
13238 clause) is given, followed by the name of the corresponding spec file in
13239 parentheses.  The packages are children in four hierarchies, @code{Ada},
13240 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
13241 GNAT-specific hierarchy.
13242
13243 Note that an application program should only use packages in one of these
13244 four hierarchies if the package is defined in the Ada Reference Manual,
13245 or is listed in this section of the GNAT Programmers Reference Manual.
13246 All other units should be considered internal implementation units and
13247 should not be directly @code{with}'ed by application code.  The use of
13248 a @code{with} statement that references one of these internal implementation
13249 units makes an application potentially dependent on changes in versions
13250 of GNAT, and will generate a warning message.
13251
13252 @menu
13253 * Ada.Characters.Latin_9 (a-chlat9.ads)::
13254 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
13255 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
13256 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
13257 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
13258 * Ada.Command_Line.Environment (a-colien.ads)::
13259 * Ada.Command_Line.Remove (a-colire.ads)::
13260 * Ada.Command_Line.Response_File (a-clrefi.ads)::
13261 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
13262 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
13263 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
13264 * Ada.Exceptions.Traceback (a-exctra.ads)::
13265 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
13266 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
13267 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
13268 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
13269 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
13270 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
13271 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
13272 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
13273 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
13274 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
13275 * GNAT.Altivec (g-altive.ads)::
13276 * GNAT.Altivec.Conversions (g-altcon.ads)::
13277 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
13278 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
13279 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
13280 * GNAT.Array_Split (g-arrspl.ads)::
13281 * GNAT.AWK (g-awk.ads)::
13282 * GNAT.Bounded_Buffers (g-boubuf.ads)::
13283 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
13284 * GNAT.Bubble_Sort (g-bubsor.ads)::
13285 * GNAT.Bubble_Sort_A (g-busora.ads)::
13286 * GNAT.Bubble_Sort_G (g-busorg.ads)::
13287 * GNAT.Byte_Order_Mark (g-byorma.ads)::
13288 * GNAT.Byte_Swapping (g-bytswa.ads)::
13289 * GNAT.Calendar (g-calend.ads)::
13290 * GNAT.Calendar.Time_IO (g-catiio.ads)::
13291 * GNAT.Case_Util (g-casuti.ads)::
13292 * GNAT.CGI (g-cgi.ads)::
13293 * GNAT.CGI.Cookie (g-cgicoo.ads)::
13294 * GNAT.CGI.Debug (g-cgideb.ads)::
13295 * GNAT.Command_Line (g-comlin.ads)::
13296 * GNAT.Compiler_Version (g-comver.ads)::
13297 * GNAT.Ctrl_C (g-ctrl_c.ads)::
13298 * GNAT.CRC32 (g-crc32.ads)::
13299 * GNAT.Current_Exception (g-curexc.ads)::
13300 * GNAT.Debug_Pools (g-debpoo.ads)::
13301 * GNAT.Debug_Utilities (g-debuti.ads)::
13302 * GNAT.Decode_String (g-decstr.ads)::
13303 * GNAT.Decode_UTF8_String (g-deutst.ads)::
13304 * GNAT.Directory_Operations (g-dirope.ads)::
13305 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
13306 * GNAT.Dynamic_HTables (g-dynhta.ads)::
13307 * GNAT.Dynamic_Tables (g-dyntab.ads)::
13308 * GNAT.Encode_String (g-encstr.ads)::
13309 * GNAT.Encode_UTF8_String (g-enutst.ads)::
13310 * GNAT.Exception_Actions (g-excact.ads)::
13311 * GNAT.Exception_Traces (g-exctra.ads)::
13312 * GNAT.Exceptions (g-except.ads)::
13313 * GNAT.Expect (g-expect.ads)::
13314 * GNAT.Float_Control (g-flocon.ads)::
13315 * GNAT.Heap_Sort (g-heasor.ads)::
13316 * GNAT.Heap_Sort_A (g-hesora.ads)::
13317 * GNAT.Heap_Sort_G (g-hesorg.ads)::
13318 * GNAT.HTable (g-htable.ads)::
13319 * GNAT.IO (g-io.ads)::
13320 * GNAT.IO_Aux (g-io_aux.ads)::
13321 * GNAT.Lock_Files (g-locfil.ads)::
13322 * GNAT.MD5 (g-md5.ads)::
13323 * GNAT.Memory_Dump (g-memdum.ads)::
13324 * GNAT.Most_Recent_Exception (g-moreex.ads)::
13325 * GNAT.OS_Lib (g-os_lib.ads)::
13326 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
13327 * GNAT.Random_Numbers (g-rannum.ads)::
13328 * GNAT.Regexp (g-regexp.ads)::
13329 * GNAT.Registry (g-regist.ads)::
13330 * GNAT.Regpat (g-regpat.ads)::
13331 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
13332 * GNAT.Semaphores (g-semaph.ads)::
13333 * GNAT.Serial_Communications (g-sercom.ads)::
13334 * GNAT.SHA1 (g-sha1.ads)::
13335 * GNAT.Signals (g-signal.ads)::
13336 * GNAT.Sockets (g-socket.ads)::
13337 * GNAT.Source_Info (g-souinf.ads)::
13338 * GNAT.Spelling_Checker (g-speche.ads)::
13339 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
13340 * GNAT.Spitbol.Patterns (g-spipat.ads)::
13341 * GNAT.Spitbol (g-spitbo.ads)::
13342 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
13343 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
13344 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
13345 * GNAT.Strings (g-string.ads)::
13346 * GNAT.String_Split (g-strspl.ads)::
13347 * GNAT.Table (g-table.ads)::
13348 * GNAT.Task_Lock (g-tasloc.ads)::
13349 * GNAT.Threads (g-thread.ads)::
13350 * GNAT.Time_Stamp (g-timsta.ads)::
13351 * GNAT.Traceback (g-traceb.ads)::
13352 * GNAT.Traceback.Symbolic (g-trasym.ads)::
13353 * GNAT.UTF_32 (g-utf_32.ads)::
13354 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
13355 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
13356 * GNAT.Wide_String_Split (g-wistsp.ads)::
13357 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
13358 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
13359 * Interfaces.C.Extensions (i-cexten.ads)::
13360 * Interfaces.C.Streams (i-cstrea.ads)::
13361 * Interfaces.CPP (i-cpp.ads)::
13362 * Interfaces.Packed_Decimal (i-pacdec.ads)::
13363 * Interfaces.VxWorks (i-vxwork.ads)::
13364 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
13365 * System.Address_Image (s-addima.ads)::
13366 * System.Assertions (s-assert.ads)::
13367 * System.Memory (s-memory.ads)::
13368 * System.Partition_Interface (s-parint.ads)::
13369 * System.Pool_Global (s-pooglo.ads)::
13370 * System.Pool_Local (s-pooloc.ads)::
13371 * System.Restrictions (s-restri.ads)::
13372 * System.Rident (s-rident.ads)::
13373 * System.Task_Info (s-tasinf.ads)::
13374 * System.Wch_Cnv (s-wchcnv.ads)::
13375 * System.Wch_Con (s-wchcon.ads)::
13376 @end menu
13377
13378 @node Ada.Characters.Latin_9 (a-chlat9.ads)
13379 @section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
13380 @cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
13381 @cindex Latin_9 constants for Character
13382
13383 @noindent
13384 This child of @code{Ada.Characters}
13385 provides a set of definitions corresponding to those in the
13386 RM-defined package @code{Ada.Characters.Latin_1} but with the
13387 few modifications required for @code{Latin-9}
13388 The provision of such a package
13389 is specifically authorized by the Ada Reference Manual
13390 (RM A.3.3(27)).
13391
13392 @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
13393 @section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
13394 @cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
13395 @cindex Latin_1 constants for Wide_Character
13396
13397 @noindent
13398 This child of @code{Ada.Characters}
13399 provides a set of definitions corresponding to those in the
13400 RM-defined package @code{Ada.Characters.Latin_1} but with the
13401 types of the constants being @code{Wide_Character}
13402 instead of @code{Character}.  The provision of such a package
13403 is specifically authorized by the Ada Reference Manual
13404 (RM A.3.3(27)).
13405
13406 @node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
13407 @section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
13408 @cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
13409 @cindex Latin_9 constants for Wide_Character
13410
13411 @noindent
13412 This child of @code{Ada.Characters}
13413 provides a set of definitions corresponding to those in the
13414 GNAT defined package @code{Ada.Characters.Latin_9} but with the
13415 types of the constants being @code{Wide_Character}
13416 instead of @code{Character}.  The provision of such a package
13417 is specifically authorized by the Ada Reference Manual
13418 (RM A.3.3(27)).
13419
13420 @node Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)
13421 @section @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
13422 @cindex @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
13423 @cindex Latin_1 constants for Wide_Wide_Character
13424
13425 @noindent
13426 This child of @code{Ada.Characters}
13427 provides a set of definitions corresponding to those in the
13428 RM-defined package @code{Ada.Characters.Latin_1} but with the
13429 types of the constants being @code{Wide_Wide_Character}
13430 instead of @code{Character}.  The provision of such a package
13431 is specifically authorized by the Ada Reference Manual
13432 (RM A.3.3(27)).
13433
13434 @node Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)
13435 @section @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
13436 @cindex @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
13437 @cindex Latin_9 constants for Wide_Wide_Character
13438
13439 @noindent
13440 This child of @code{Ada.Characters}
13441 provides a set of definitions corresponding to those in the
13442 GNAT defined package @code{Ada.Characters.Latin_9} but with the
13443 types of the constants being @code{Wide_Wide_Character}
13444 instead of @code{Character}.  The provision of such a package
13445 is specifically authorized by the Ada Reference Manual
13446 (RM A.3.3(27)).
13447
13448 @node Ada.Command_Line.Environment (a-colien.ads)
13449 @section @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
13450 @cindex @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
13451 @cindex Environment entries
13452
13453 @noindent
13454 This child of @code{Ada.Command_Line}
13455 provides a mechanism for obtaining environment values on systems
13456 where this concept makes sense.
13457
13458 @node Ada.Command_Line.Remove (a-colire.ads)
13459 @section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
13460 @cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
13461 @cindex Removing command line arguments
13462 @cindex Command line, argument removal
13463
13464 @noindent
13465 This child of @code{Ada.Command_Line}
13466 provides a mechanism for logically removing
13467 arguments from the argument list.  Once removed, an argument is not visible
13468 to further calls on the subprograms in @code{Ada.Command_Line} will not
13469 see the removed argument.
13470
13471 @node Ada.Command_Line.Response_File (a-clrefi.ads)
13472 @section @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
13473 @cindex @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
13474 @cindex Response file for command line
13475 @cindex Command line, response file
13476 @cindex Command line, handling long command lines
13477
13478 @noindent
13479 This child of @code{Ada.Command_Line} provides a mechanism facilities for
13480 getting command line arguments from a text file, called a "response file".
13481 Using a response file allow passing a set of arguments to an executable longer
13482 than the maximum allowed by the system on the command line.
13483
13484 @node Ada.Direct_IO.C_Streams (a-diocst.ads)
13485 @section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
13486 @cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
13487 @cindex C Streams, Interfacing with Direct_IO
13488
13489 @noindent
13490 This package provides subprograms that allow interfacing between
13491 C streams and @code{Direct_IO}.  The stream identifier can be
13492 extracted from a file opened on the Ada side, and an Ada file
13493 can be constructed from a stream opened on the C side.
13494
13495 @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
13496 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
13497 @cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
13498 @cindex Null_Occurrence, testing for
13499
13500 @noindent
13501 This child subprogram provides a way of testing for the null
13502 exception occurrence (@code{Null_Occurrence}) without raising
13503 an exception.
13504
13505 @node Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)
13506 @section @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
13507 @cindex @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
13508 @cindex Null_Occurrence, testing for
13509
13510 @noindent
13511 This child subprogram is used for handling otherwise unhandled
13512 exceptions (hence the name last chance), and perform clean ups before
13513 terminating the program. Note that this subprogram never returns.
13514
13515 @node Ada.Exceptions.Traceback (a-exctra.ads)
13516 @section @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
13517 @cindex @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
13518 @cindex Traceback for Exception Occurrence
13519
13520 @noindent
13521 This child package provides the subprogram (@code{Tracebacks}) to
13522 give a traceback array of addresses based on an exception
13523 occurrence.
13524
13525 @node Ada.Sequential_IO.C_Streams (a-siocst.ads)
13526 @section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
13527 @cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
13528 @cindex C Streams, Interfacing with Sequential_IO
13529
13530 @noindent
13531 This package provides subprograms that allow interfacing between
13532 C streams and @code{Sequential_IO}.  The stream identifier can be
13533 extracted from a file opened on the Ada side, and an Ada file
13534 can be constructed from a stream opened on the C side.
13535
13536 @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
13537 @section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
13538 @cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
13539 @cindex C Streams, Interfacing with Stream_IO
13540
13541 @noindent
13542 This package provides subprograms that allow interfacing between
13543 C streams and @code{Stream_IO}.  The stream identifier can be
13544 extracted from a file opened on the Ada side, and an Ada file
13545 can be constructed from a stream opened on the C side.
13546
13547 @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
13548 @section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
13549 @cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
13550 @cindex @code{Unbounded_String}, IO support
13551 @cindex @code{Text_IO}, extensions for unbounded strings
13552
13553 @noindent
13554 This package provides subprograms for Text_IO for unbounded
13555 strings, avoiding the necessity for an intermediate operation
13556 with ordinary strings.
13557
13558 @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
13559 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
13560 @cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
13561 @cindex @code{Unbounded_Wide_String}, IO support
13562 @cindex @code{Text_IO}, extensions for unbounded wide strings
13563
13564 @noindent
13565 This package provides subprograms for Text_IO for unbounded
13566 wide strings, avoiding the necessity for an intermediate operation
13567 with ordinary wide strings.
13568
13569 @node Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)
13570 @section @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
13571 @cindex @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
13572 @cindex @code{Unbounded_Wide_Wide_String}, IO support
13573 @cindex @code{Text_IO}, extensions for unbounded wide wide strings
13574
13575 @noindent
13576 This package provides subprograms for Text_IO for unbounded
13577 wide wide strings, avoiding the necessity for an intermediate operation
13578 with ordinary wide wide strings.
13579
13580 @node Ada.Text_IO.C_Streams (a-tiocst.ads)
13581 @section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
13582 @cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
13583 @cindex C Streams, Interfacing with @code{Text_IO}
13584
13585 @noindent
13586 This package provides subprograms that allow interfacing between
13587 C streams and @code{Text_IO}.  The stream identifier can be
13588 extracted from a file opened on the Ada side, and an Ada file
13589 can be constructed from a stream opened on the C side.
13590
13591 @node Ada.Wide_Characters.Unicode (a-wichun.ads)
13592 @section @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
13593 @cindex @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
13594 @cindex Unicode categorization, Wide_Character
13595
13596 @noindent
13597 This package provides subprograms that allow categorization of
13598 Wide_Character values according to Unicode categories.
13599
13600 @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
13601 @section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
13602 @cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
13603 @cindex C Streams, Interfacing with @code{Wide_Text_IO}
13604
13605 @noindent
13606 This package provides subprograms that allow interfacing between
13607 C streams and @code{Wide_Text_IO}.  The stream identifier can be
13608 extracted from a file opened on the Ada side, and an Ada file
13609 can be constructed from a stream opened on the C side.
13610
13611 @node Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)
13612 @section @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
13613 @cindex @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
13614 @cindex Unicode categorization, Wide_Wide_Character
13615
13616 @noindent
13617 This package provides subprograms that allow categorization of
13618 Wide_Wide_Character values according to Unicode categories.
13619
13620 @node Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)
13621 @section @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
13622 @cindex @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
13623 @cindex C Streams, Interfacing with @code{Wide_Wide_Text_IO}
13624
13625 @noindent
13626 This package provides subprograms that allow interfacing between
13627 C streams and @code{Wide_Wide_Text_IO}.  The stream identifier can be
13628 extracted from a file opened on the Ada side, and an Ada file
13629 can be constructed from a stream opened on the C side.
13630
13631 @node GNAT.Altivec (g-altive.ads)
13632 @section @code{GNAT.Altivec} (@file{g-altive.ads})
13633 @cindex @code{GNAT.Altivec} (@file{g-altive.ads})
13634 @cindex AltiVec
13635
13636 @noindent
13637 This is the root package of the GNAT AltiVec binding. It provides
13638 definitions of constants and types common to all the versions of the
13639 binding.
13640
13641 @node GNAT.Altivec.Conversions (g-altcon.ads)
13642 @section @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
13643 @cindex @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
13644 @cindex AltiVec
13645
13646 @noindent
13647 This package provides the Vector/View conversion routines.
13648
13649 @node GNAT.Altivec.Vector_Operations (g-alveop.ads)
13650 @section @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
13651 @cindex @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
13652 @cindex AltiVec
13653
13654 @noindent
13655 This package exposes the Ada interface to the AltiVec operations on
13656 vector objects. A soft emulation is included by default in the GNAT
13657 library. The hard binding is provided as a separate package. This unit
13658 is common to both bindings.
13659
13660 @node GNAT.Altivec.Vector_Types (g-alvety.ads)
13661 @section @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
13662 @cindex @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
13663 @cindex AltiVec
13664
13665 @noindent
13666 This package exposes the various vector types part of the Ada binding
13667 to AltiVec facilities.
13668
13669 @node GNAT.Altivec.Vector_Views (g-alvevi.ads)
13670 @section @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
13671 @cindex @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
13672 @cindex AltiVec
13673
13674 @noindent
13675 This package provides public 'View' data types from/to which private
13676 vector representations can be converted via
13677 GNAT.Altivec.Conversions. This allows convenient access to individual
13678 vector elements and provides a simple way to initialize vector
13679 objects.
13680
13681 @node GNAT.Array_Split (g-arrspl.ads)
13682 @section @code{GNAT.Array_Split} (@file{g-arrspl.ads})
13683 @cindex @code{GNAT.Array_Split} (@file{g-arrspl.ads})
13684 @cindex Array splitter
13685
13686 @noindent
13687 Useful array-manipulation routines: given a set of separators, split
13688 an array wherever the separators appear, and provide direct access
13689 to the resulting slices.
13690
13691 @node GNAT.AWK (g-awk.ads)
13692 @section @code{GNAT.AWK} (@file{g-awk.ads})
13693 @cindex @code{GNAT.AWK} (@file{g-awk.ads})
13694 @cindex Parsing
13695 @cindex AWK
13696
13697 @noindent
13698 Provides AWK-like parsing functions, with an easy interface for parsing one
13699 or more files containing formatted data.  The file is viewed as a database
13700 where each record is a line and a field is a data element in this line.
13701
13702 @node GNAT.Bounded_Buffers (g-boubuf.ads)
13703 @section @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
13704 @cindex @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
13705 @cindex Parsing
13706 @cindex Bounded Buffers
13707
13708 @noindent
13709 Provides a concurrent generic bounded buffer abstraction.  Instances are
13710 useful directly or as parts of the implementations of other abstractions,
13711 such as mailboxes.
13712
13713 @node GNAT.Bounded_Mailboxes (g-boumai.ads)
13714 @section @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
13715 @cindex @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
13716 @cindex Parsing
13717 @cindex Mailboxes
13718
13719 @noindent
13720 Provides a thread-safe asynchronous intertask mailbox communication facility.
13721
13722 @node GNAT.Bubble_Sort (g-bubsor.ads)
13723 @section @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
13724 @cindex @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
13725 @cindex Sorting
13726 @cindex Bubble sort
13727
13728 @noindent
13729 Provides a general implementation of bubble sort usable for sorting arbitrary
13730 data items.  Exchange and comparison procedures are provided by passing
13731 access-to-procedure values.
13732
13733 @node GNAT.Bubble_Sort_A (g-busora.ads)
13734 @section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
13735 @cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
13736 @cindex Sorting
13737 @cindex Bubble sort
13738
13739 @noindent
13740 Provides a general implementation of bubble sort usable for sorting arbitrary
13741 data items.  Move and comparison procedures are provided by passing
13742 access-to-procedure values. This is an older version, retained for
13743 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
13744
13745 @node GNAT.Bubble_Sort_G (g-busorg.ads)
13746 @section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
13747 @cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
13748 @cindex Sorting
13749 @cindex Bubble sort
13750
13751 @noindent
13752 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
13753 are provided as generic parameters, this improves efficiency, especially
13754 if the procedures can be inlined, at the expense of duplicating code for
13755 multiple instantiations.
13756
13757 @node GNAT.Byte_Order_Mark (g-byorma.ads)
13758 @section @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
13759 @cindex @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
13760 @cindex UTF-8 representation
13761 @cindex Wide characte representations
13762
13763 @noindent
13764 Provides a routine which given a string, reads the start of the string to
13765 see whether it is one of the standard byte order marks (BOM's) which signal
13766 the encoding of the string. The routine includes detection of special XML
13767 sequences for various UCS input formats.
13768
13769 @node GNAT.Byte_Swapping (g-bytswa.ads)
13770 @section @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
13771 @cindex @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
13772 @cindex Byte swapping
13773 @cindex Endian
13774
13775 @noindent
13776 General routines for swapping the bytes in 2-, 4-, and 8-byte quantities.
13777 Machine-specific implementations are available in some cases.
13778
13779 @node GNAT.Calendar (g-calend.ads)
13780 @section @code{GNAT.Calendar} (@file{g-calend.ads})
13781 @cindex @code{GNAT.Calendar} (@file{g-calend.ads})
13782 @cindex @code{Calendar}
13783
13784 @noindent
13785 Extends the facilities provided by @code{Ada.Calendar} to include handling
13786 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
13787 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
13788 C @code{timeval} format.
13789
13790 @node GNAT.Calendar.Time_IO (g-catiio.ads)
13791 @section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
13792 @cindex @code{Calendar}
13793 @cindex Time
13794 @cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
13795
13796 @node GNAT.CRC32 (g-crc32.ads)
13797 @section @code{GNAT.CRC32} (@file{g-crc32.ads})
13798 @cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
13799 @cindex CRC32
13800 @cindex Cyclic Redundancy Check
13801
13802 @noindent
13803 This package implements the CRC-32 algorithm.  For a full description
13804 of this algorithm see
13805 ``Computation of Cyclic Redundancy Checks via Table Look-Up'',
13806 @cite{Communications of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013,
13807 Aug.@: 1988.  Sarwate, D.V@.
13808
13809 @node GNAT.Case_Util (g-casuti.ads)
13810 @section @code{GNAT.Case_Util} (@file{g-casuti.ads})
13811 @cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
13812 @cindex Casing utilities
13813 @cindex Character handling (@code{GNAT.Case_Util})
13814
13815 @noindent
13816 A set of simple routines for handling upper and lower casing of strings
13817 without the overhead of the full casing tables
13818 in @code{Ada.Characters.Handling}.
13819
13820 @node GNAT.CGI (g-cgi.ads)
13821 @section @code{GNAT.CGI} (@file{g-cgi.ads})
13822 @cindex @code{GNAT.CGI} (@file{g-cgi.ads})
13823 @cindex CGI (Common Gateway Interface)
13824
13825 @noindent
13826 This is a package for interfacing a GNAT program with a Web server via the
13827 Common Gateway Interface (CGI)@.  Basically this package parses the CGI
13828 parameters, which are a set of key/value pairs sent by the Web server.  It
13829 builds a table whose index is the key and provides some services to deal
13830 with this table.
13831
13832 @node GNAT.CGI.Cookie (g-cgicoo.ads)
13833 @section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
13834 @cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
13835 @cindex CGI (Common Gateway Interface) cookie support
13836 @cindex Cookie support in CGI
13837
13838 @noindent
13839 This is a package to interface a GNAT program with a Web server via the
13840 Common Gateway Interface (CGI).  It exports services to deal with Web
13841 cookies (piece of information kept in the Web client software).
13842
13843 @node GNAT.CGI.Debug (g-cgideb.ads)
13844 @section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
13845 @cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
13846 @cindex CGI (Common Gateway Interface) debugging
13847
13848 @noindent
13849 This is a package to help debugging CGI (Common Gateway Interface)
13850 programs written in Ada.
13851
13852 @node GNAT.Command_Line (g-comlin.ads)
13853 @section @code{GNAT.Command_Line} (@file{g-comlin.ads})
13854 @cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
13855 @cindex Command line
13856
13857 @noindent
13858 Provides a high level interface to @code{Ada.Command_Line} facilities,
13859 including the ability to scan for named switches with optional parameters
13860 and expand file names using wild card notations.
13861
13862 @node GNAT.Compiler_Version (g-comver.ads)
13863 @section @code{GNAT.Compiler_Version} (@file{g-comver.ads})
13864 @cindex @code{GNAT.Compiler_Version} (@file{g-comver.ads})
13865 @cindex Compiler Version
13866 @cindex Version, of compiler
13867
13868 @noindent
13869 Provides a routine for obtaining the version of the compiler used to
13870 compile the program. More accurately this is the version of the binder
13871 used to bind the program (this will normally be the same as the version
13872 of the compiler if a consistent tool set is used to compile all units
13873 of a partition).
13874
13875 @node GNAT.Ctrl_C (g-ctrl_c.ads)
13876 @section @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
13877 @cindex @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
13878 @cindex Interrupt
13879
13880 @noindent
13881 Provides a simple interface to handle Ctrl-C keyboard events.
13882
13883 @node GNAT.Current_Exception (g-curexc.ads)
13884 @section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
13885 @cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
13886 @cindex Current exception
13887 @cindex Exception retrieval
13888
13889 @noindent
13890 Provides access to information on the current exception that has been raised
13891 without the need for using the Ada 95 / Ada 2005 exception choice parameter
13892 specification syntax.
13893 This is particularly useful in simulating typical facilities for
13894 obtaining information about exceptions provided by Ada 83 compilers.
13895
13896 @node GNAT.Debug_Pools (g-debpoo.ads)
13897 @section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
13898 @cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
13899 @cindex Debugging
13900 @cindex Debug pools
13901 @cindex Memory corruption debugging
13902
13903 @noindent
13904 Provide a debugging storage pools that helps tracking memory corruption
13905 problems.  @xref{The GNAT Debug Pool Facility,,, gnat_ugn,
13906 @value{EDITION} User's Guide}.
13907
13908 @node GNAT.Debug_Utilities (g-debuti.ads)
13909 @section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
13910 @cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
13911 @cindex Debugging
13912
13913 @noindent
13914 Provides a few useful utilities for debugging purposes, including conversion
13915 to and from string images of address values. Supports both C and Ada formats
13916 for hexadecimal literals.
13917
13918 @node GNAT.Decode_String (g-decstr.ads)
13919 @section @code{GNAT.Decode_String} (@file{g-decstr.ads})
13920 @cindex @code{GNAT.Decode_String} (@file{g-decstr.ads})
13921 @cindex Decoding strings
13922 @cindex String decoding
13923 @cindex Wide character encoding
13924 @cindex UTF-8
13925 @cindex Unicode
13926
13927 @noindent
13928 A generic package providing routines for decoding wide character and wide wide
13929 character strings encoded as sequences of 8-bit characters using a specified
13930 encoding method. Includes validation routines, and also routines for stepping
13931 to next or previous encoded character in an encoded string.
13932 Useful in conjunction with Unicode character coding. Note there is a
13933 preinstantiation for UTF-8. See next entry.
13934
13935 @node GNAT.Decode_UTF8_String (g-deutst.ads)
13936 @section @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
13937 @cindex @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
13938 @cindex Decoding strings
13939 @cindex Decoding UTF-8 strings
13940 @cindex UTF-8 string decoding
13941 @cindex Wide character decoding
13942 @cindex UTF-8
13943 @cindex Unicode
13944
13945 @noindent
13946 A preinstantiation of GNAT.Decode_Strings for UTF-8 encoding.
13947
13948 @node GNAT.Directory_Operations (g-dirope.ads)
13949 @section @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
13950 @cindex @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
13951 @cindex Directory operations
13952
13953 @noindent
13954 Provides a set of routines for manipulating directories, including changing
13955 the current directory, making new directories, and scanning the files in a
13956 directory.
13957
13958 @node GNAT.Directory_Operations.Iteration (g-diopit.ads)
13959 @section @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
13960 @cindex @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
13961 @cindex Directory operations iteration
13962
13963 @noindent
13964 A child unit of GNAT.Directory_Operations providing additional operations
13965 for iterating through directories.
13966
13967 @node GNAT.Dynamic_HTables (g-dynhta.ads)
13968 @section @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
13969 @cindex @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
13970 @cindex Hash tables
13971
13972 @noindent
13973 A generic implementation of hash tables that can be used to hash arbitrary
13974 data.  Provided in two forms, a simple form with built in hash functions,
13975 and a more complex form in which the hash function is supplied.
13976
13977 @noindent
13978 This package provides a facility similar to that of @code{GNAT.HTable},
13979 except that this package declares a type that can be used to define
13980 dynamic instances of the hash table, while an instantiation of
13981 @code{GNAT.HTable} creates a single instance of the hash table.
13982
13983 @node GNAT.Dynamic_Tables (g-dyntab.ads)
13984 @section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
13985 @cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
13986 @cindex Table implementation
13987 @cindex Arrays, extendable
13988
13989 @noindent
13990 A generic package providing a single dimension array abstraction where the
13991 length of the array can be dynamically modified.
13992
13993 @noindent
13994 This package provides a facility similar to that of @code{GNAT.Table},
13995 except that this package declares a type that can be used to define
13996 dynamic instances of the table, while an instantiation of
13997 @code{GNAT.Table} creates a single instance of the table type.
13998
13999 @node GNAT.Encode_String (g-encstr.ads)
14000 @section @code{GNAT.Encode_String} (@file{g-encstr.ads})
14001 @cindex @code{GNAT.Encode_String} (@file{g-encstr.ads})
14002 @cindex Encoding strings
14003 @cindex String encoding
14004 @cindex Wide character encoding
14005 @cindex UTF-8
14006 @cindex Unicode
14007
14008 @noindent
14009 A generic package providing routines for encoding wide character and wide
14010 wide character strings as sequences of 8-bit characters using a specified
14011 encoding method. Useful in conjunction with Unicode character coding.
14012 Note there is a preinstantiation for UTF-8. See next entry.
14013
14014 @node GNAT.Encode_UTF8_String (g-enutst.ads)
14015 @section @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
14016 @cindex @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
14017 @cindex Encoding strings
14018 @cindex Encoding UTF-8 strings
14019 @cindex UTF-8 string encoding
14020 @cindex Wide character encoding
14021 @cindex UTF-8
14022 @cindex Unicode
14023
14024 @noindent
14025 A preinstantiation of GNAT.Encode_Strings for UTF-8 encoding.
14026
14027 @node GNAT.Exception_Actions (g-excact.ads)
14028 @section @code{GNAT.Exception_Actions} (@file{g-excact.ads})
14029 @cindex @code{GNAT.Exception_Actions} (@file{g-excact.ads})
14030 @cindex Exception actions
14031
14032 @noindent
14033 Provides callbacks when an exception is raised. Callbacks can be registered
14034 for specific exceptions, or when any exception is raised. This
14035 can be used for instance to force a core dump to ease debugging.
14036
14037 @node GNAT.Exception_Traces (g-exctra.ads)
14038 @section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
14039 @cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
14040 @cindex Exception traces
14041 @cindex Debugging
14042
14043 @noindent
14044 Provides an interface allowing to control automatic output upon exception
14045 occurrences.
14046
14047 @node GNAT.Exceptions (g-except.ads)
14048 @section @code{GNAT.Exceptions} (@file{g-expect.ads})
14049 @cindex @code{GNAT.Exceptions} (@file{g-expect.ads})
14050 @cindex Exceptions, Pure
14051 @cindex Pure packages, exceptions
14052
14053 @noindent
14054 Normally it is not possible to raise an exception with
14055 a message from a subprogram in a pure package, since the
14056 necessary types and subprograms are in @code{Ada.Exceptions}
14057 which is not a pure unit. @code{GNAT.Exceptions} provides a
14058 facility for getting around this limitation for a few
14059 predefined exceptions, and for example allow raising
14060 @code{Constraint_Error} with a message from a pure subprogram.
14061
14062 @node GNAT.Expect (g-expect.ads)
14063 @section @code{GNAT.Expect} (@file{g-expect.ads})
14064 @cindex @code{GNAT.Expect} (@file{g-expect.ads})
14065
14066 @noindent
14067 Provides a set of subprograms similar to what is available
14068 with the standard Tcl Expect tool.
14069 It allows you to easily spawn and communicate with an external process.
14070 You can send commands or inputs to the process, and compare the output
14071 with some expected regular expression. Currently @code{GNAT.Expect}
14072 is implemented on all native GNAT ports except for OpenVMS@.
14073 It is not implemented for cross ports, and in particular is not
14074 implemented for VxWorks or LynxOS@.
14075
14076 @node GNAT.Float_Control (g-flocon.ads)
14077 @section @code{GNAT.Float_Control} (@file{g-flocon.ads})
14078 @cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
14079 @cindex Floating-Point Processor
14080
14081 @noindent
14082 Provides an interface for resetting the floating-point processor into the
14083 mode required for correct semantic operation in Ada.  Some third party
14084 library calls may cause this mode to be modified, and the Reset procedure
14085 in this package can be used to reestablish the required mode.
14086
14087 @node GNAT.Heap_Sort (g-heasor.ads)
14088 @section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
14089 @cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
14090 @cindex Sorting
14091
14092 @noindent
14093 Provides a general implementation of heap sort usable for sorting arbitrary
14094 data items. Exchange and comparison procedures are provided by passing
14095 access-to-procedure values.  The algorithm used is a modified heap sort
14096 that performs approximately N*log(N) comparisons in the worst case.
14097
14098 @node GNAT.Heap_Sort_A (g-hesora.ads)
14099 @section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
14100 @cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
14101 @cindex Sorting
14102
14103 @noindent
14104 Provides a general implementation of heap sort usable for sorting arbitrary
14105 data items. Move and comparison procedures are provided by passing
14106 access-to-procedure values.  The algorithm used is a modified heap sort
14107 that performs approximately N*log(N) comparisons in the worst case.
14108 This differs from @code{GNAT.Heap_Sort} in having a less convenient
14109 interface, but may be slightly more efficient.
14110
14111 @node GNAT.Heap_Sort_G (g-hesorg.ads)
14112 @section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
14113 @cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
14114 @cindex Sorting
14115
14116 @noindent
14117 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
14118 are provided as generic parameters, this improves efficiency, especially
14119 if the procedures can be inlined, at the expense of duplicating code for
14120 multiple instantiations.
14121
14122 @node GNAT.HTable (g-htable.ads)
14123 @section @code{GNAT.HTable} (@file{g-htable.ads})
14124 @cindex @code{GNAT.HTable} (@file{g-htable.ads})
14125 @cindex Hash tables
14126
14127 @noindent
14128 A generic implementation of hash tables that can be used to hash arbitrary
14129 data.  Provides two approaches, one a simple static approach, and the other
14130 allowing arbitrary dynamic hash tables.
14131
14132 @node GNAT.IO (g-io.ads)
14133 @section @code{GNAT.IO} (@file{g-io.ads})
14134 @cindex @code{GNAT.IO} (@file{g-io.ads})
14135 @cindex Simple I/O
14136 @cindex Input/Output facilities
14137
14138 @noindent
14139 A simple preelaborable input-output package that provides a subset of
14140 simple Text_IO functions for reading characters and strings from
14141 Standard_Input, and writing characters, strings and integers to either
14142 Standard_Output or Standard_Error.
14143
14144 @node GNAT.IO_Aux (g-io_aux.ads)
14145 @section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
14146 @cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
14147 @cindex Text_IO
14148 @cindex Input/Output facilities
14149
14150 Provides some auxiliary functions for use with Text_IO, including a test
14151 for whether a file exists, and functions for reading a line of text.
14152
14153 @node GNAT.Lock_Files (g-locfil.ads)
14154 @section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
14155 @cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
14156 @cindex File locking
14157 @cindex Locking using files
14158
14159 @noindent
14160 Provides a general interface for using files as locks.  Can be used for
14161 providing program level synchronization.
14162
14163 @node GNAT.MD5 (g-md5.ads)
14164 @section @code{GNAT.MD5} (@file{g-md5.ads})
14165 @cindex @code{GNAT.MD5} (@file{g-md5.ads})
14166 @cindex Message Digest MD5
14167
14168 @noindent
14169 Implements the MD5 Message-Digest Algorithm as described in RFC 1321.
14170
14171 @node GNAT.Memory_Dump (g-memdum.ads)
14172 @section @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
14173 @cindex @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
14174 @cindex Dump Memory
14175
14176 @noindent
14177 Provides a convenient routine for dumping raw memory to either the
14178 standard output or standard error files. Uses GNAT.IO for actual
14179 output.
14180
14181 @node GNAT.Most_Recent_Exception (g-moreex.ads)
14182 @section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
14183 @cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
14184 @cindex Exception, obtaining most recent
14185
14186 @noindent
14187 Provides access to the most recently raised exception.  Can be used for
14188 various logging purposes, including duplicating functionality of some
14189 Ada 83 implementation dependent extensions.
14190
14191 @node GNAT.OS_Lib (g-os_lib.ads)
14192 @section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
14193 @cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
14194 @cindex Operating System interface
14195 @cindex Spawn capability
14196
14197 @noindent
14198 Provides a range of target independent operating system interface functions,
14199 including time/date management, file operations, subprocess management,
14200 including a portable spawn procedure, and access to environment variables
14201 and error return codes.
14202
14203 @node GNAT.Perfect_Hash_Generators (g-pehage.ads)
14204 @section @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
14205 @cindex @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
14206 @cindex Hash functions
14207
14208 @noindent
14209 Provides a generator of static minimal perfect hash functions. No
14210 collisions occur and each item can be retrieved from the table in one
14211 probe (perfect property). The hash table size corresponds to the exact
14212 size of the key set and no larger (minimal property). The key set has to
14213 be know in advance (static property). The hash functions are also order
14214 preserving. If w2 is inserted after w1 in the generator, their
14215 hashcode are in the same order. These hashing functions are very
14216 convenient for use with realtime applications.
14217
14218 @node GNAT.Random_Numbers (g-rannum.ads)
14219 @section @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
14220 @cindex @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
14221 @cindex Random number generation
14222
14223 @noindent
14224 Provides random number capabilities which extend those available in the
14225 standard Ada library and are more convenient to use.
14226
14227 @node GNAT.Regexp (g-regexp.ads)
14228 @section @code{GNAT.Regexp} (@file{g-regexp.ads})
14229 @cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
14230 @cindex Regular expressions
14231 @cindex Pattern matching
14232
14233 @noindent
14234 A simple implementation of regular expressions, using a subset of regular
14235 expression syntax copied from familiar Unix style utilities.  This is the
14236 simples of the three pattern matching packages provided, and is particularly
14237 suitable for ``file globbing'' applications.
14238
14239 @node GNAT.Registry (g-regist.ads)
14240 @section @code{GNAT.Registry} (@file{g-regist.ads})
14241 @cindex @code{GNAT.Registry} (@file{g-regist.ads})
14242 @cindex Windows Registry
14243
14244 @noindent
14245 This is a high level binding to the Windows registry.  It is possible to
14246 do simple things like reading a key value, creating a new key.  For full
14247 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
14248 package provided with the Win32Ada binding
14249
14250 @node GNAT.Regpat (g-regpat.ads)
14251 @section @code{GNAT.Regpat} (@file{g-regpat.ads})
14252 @cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
14253 @cindex Regular expressions
14254 @cindex Pattern matching
14255
14256 @noindent
14257 A complete implementation of Unix-style regular expression matching, copied
14258 from the original V7 style regular expression library written in C by
14259 Henry Spencer (and binary compatible with this C library).
14260
14261 @node GNAT.Secondary_Stack_Info (g-sestin.ads)
14262 @section @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
14263 @cindex @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
14264 @cindex Secondary Stack Info
14265
14266 @noindent
14267 Provide the capability to query the high water mark of the current task's
14268 secondary stack.
14269
14270 @node GNAT.Semaphores (g-semaph.ads)
14271 @section @code{GNAT.Semaphores} (@file{g-semaph.ads})
14272 @cindex @code{GNAT.Semaphores} (@file{g-semaph.ads})
14273 @cindex Semaphores
14274
14275 @noindent
14276 Provides classic counting and binary semaphores using protected types.
14277
14278 @node GNAT.Serial_Communications (g-sercom.ads)
14279 @section @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
14280 @cindex @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
14281 @cindex Serial_Communications
14282
14283 @noindent
14284 Provides a simple interface to send and receive data over a serial
14285 port. This is only supported on GNU/Linux and Windows.
14286
14287 @node GNAT.SHA1 (g-sha1.ads)
14288 @section @code{GNAT.SHA1} (@file{g-sha1.ads})
14289 @cindex @code{GNAT.SHA1} (@file{g-sha1.ads})
14290 @cindex Secure Hash Algorithm SHA-1
14291
14292 @noindent
14293 Implements the SHA-1 Secure Hash Algorithm as described in RFC 3174.
14294
14295 @node GNAT.Signals (g-signal.ads)
14296 @section @code{GNAT.Signals} (@file{g-signal.ads})
14297 @cindex @code{GNAT.Signals} (@file{g-signal.ads})
14298 @cindex Signals
14299
14300 @noindent
14301 Provides the ability to manipulate the blocked status of signals on supported
14302 targets.
14303
14304 @node GNAT.Sockets (g-socket.ads)
14305 @section @code{GNAT.Sockets} (@file{g-socket.ads})
14306 @cindex @code{GNAT.Sockets} (@file{g-socket.ads})
14307 @cindex Sockets
14308
14309 @noindent
14310 A high level and portable interface to develop sockets based applications.
14311 This package is based on the sockets thin binding found in
14312 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
14313 on all native GNAT ports except for OpenVMS@.  It is not implemented
14314 for the LynxOS@ cross port.
14315
14316 @node GNAT.Source_Info (g-souinf.ads)
14317 @section @code{GNAT.Source_Info} (@file{g-souinf.ads})
14318 @cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
14319 @cindex Source Information
14320
14321 @noindent
14322 Provides subprograms that give access to source code information known at
14323 compile time, such as the current file name and line number.
14324
14325 @node GNAT.Spelling_Checker (g-speche.ads)
14326 @section @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
14327 @cindex @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
14328 @cindex Spell checking
14329
14330 @noindent
14331 Provides a function for determining whether one string is a plausible
14332 near misspelling of another string.
14333
14334 @node GNAT.Spelling_Checker_Generic (g-spchge.ads)
14335 @section @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
14336 @cindex @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
14337 @cindex Spell checking
14338
14339 @noindent
14340 Provides a generic function that can be instantiated with a string type for
14341 determining whether one string is a plausible near misspelling of another
14342 string.
14343
14344 @node GNAT.Spitbol.Patterns (g-spipat.ads)
14345 @section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
14346 @cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
14347 @cindex SPITBOL pattern matching
14348 @cindex Pattern matching
14349
14350 @noindent
14351 A complete implementation of SNOBOL4 style pattern matching.  This is the
14352 most elaborate of the pattern matching packages provided.  It fully duplicates
14353 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
14354 efficient algorithm developed by Robert Dewar for the SPITBOL system.
14355
14356 @node GNAT.Spitbol (g-spitbo.ads)
14357 @section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
14358 @cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
14359 @cindex SPITBOL interface
14360
14361 @noindent
14362 The top level package of the collection of SPITBOL-style functionality, this
14363 package provides basic SNOBOL4 string manipulation functions, such as
14364 Pad, Reverse, Trim, Substr capability, as well as a generic table function
14365 useful for constructing arbitrary mappings from strings in the style of
14366 the SNOBOL4 TABLE function.
14367
14368 @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
14369 @section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
14370 @cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
14371 @cindex Sets of strings
14372 @cindex SPITBOL Tables
14373
14374 @noindent
14375 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
14376 for type @code{Standard.Boolean}, giving an implementation of sets of
14377 string values.
14378
14379 @node GNAT.Spitbol.Table_Integer (g-sptain.ads)
14380 @section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
14381 @cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
14382 @cindex Integer maps
14383 @cindex Maps
14384 @cindex SPITBOL Tables
14385
14386 @noindent
14387 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
14388 for type @code{Standard.Integer}, giving an implementation of maps
14389 from string to integer values.
14390
14391 @node GNAT.Spitbol.Table_VString (g-sptavs.ads)
14392 @section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
14393 @cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
14394 @cindex String maps
14395 @cindex Maps
14396 @cindex SPITBOL Tables
14397
14398 @noindent
14399 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
14400 a variable length string type, giving an implementation of general
14401 maps from strings to strings.
14402
14403 @node GNAT.Strings (g-string.ads)
14404 @section @code{GNAT.Strings} (@file{g-string.ads})
14405 @cindex @code{GNAT.Strings} (@file{g-string.ads})
14406
14407 @noindent
14408 Common String access types and related subprograms. Basically it
14409 defines a string access and an array of string access types.
14410
14411 @node GNAT.String_Split (g-strspl.ads)
14412 @section @code{GNAT.String_Split} (@file{g-strspl.ads})
14413 @cindex @code{GNAT.String_Split} (@file{g-strspl.ads})
14414 @cindex String splitter
14415
14416 @noindent
14417 Useful string manipulation routines: given a set of separators, split
14418 a string wherever the separators appear, and provide direct access
14419 to the resulting slices. This package is instantiated from
14420 @code{GNAT.Array_Split}.
14421
14422 @node GNAT.Table (g-table.ads)
14423 @section @code{GNAT.Table} (@file{g-table.ads})
14424 @cindex @code{GNAT.Table} (@file{g-table.ads})
14425 @cindex Table implementation
14426 @cindex Arrays, extendable
14427
14428 @noindent
14429 A generic package providing a single dimension array abstraction where the
14430 length of the array can be dynamically modified.
14431
14432 @noindent
14433 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
14434 except that this package declares a single instance of the table type,
14435 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
14436 used to define dynamic instances of the table.
14437
14438 @node GNAT.Task_Lock (g-tasloc.ads)
14439 @section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
14440 @cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
14441 @cindex Task synchronization
14442 @cindex Task locking
14443 @cindex Locking
14444
14445 @noindent
14446 A very simple facility for locking and unlocking sections of code using a
14447 single global task lock.  Appropriate for use in situations where contention
14448 between tasks is very rarely expected.
14449
14450 @node GNAT.Time_Stamp (g-timsta.ads)
14451 @section @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
14452 @cindex @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
14453 @cindex Time stamp
14454 @cindex Current time
14455
14456 @noindent
14457 Provides a simple function that returns a string YYYY-MM-DD HH:MM:SS.SS that
14458 represents the current date and time in ISO 8601 format. This is a very simple
14459 routine with minimal code and there are no dependencies on any other unit.
14460
14461 @node GNAT.Threads (g-thread.ads)
14462 @section @code{GNAT.Threads} (@file{g-thread.ads})
14463 @cindex @code{GNAT.Threads} (@file{g-thread.ads})
14464 @cindex Foreign threads
14465 @cindex Threads, foreign
14466
14467 @noindent
14468 Provides facilities for dealing with foreign threads which need to be known
14469 by the GNAT run-time system. Consult the documentation of this package for
14470 further details if your program has threads that are created by a non-Ada
14471 environment which then accesses Ada code.
14472
14473 @node GNAT.Traceback (g-traceb.ads)
14474 @section @code{GNAT.Traceback} (@file{g-traceb.ads})
14475 @cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
14476 @cindex Trace back facilities
14477
14478 @noindent
14479 Provides a facility for obtaining non-symbolic traceback information, useful
14480 in various debugging situations.
14481
14482 @node GNAT.Traceback.Symbolic (g-trasym.ads)
14483 @section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
14484 @cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
14485 @cindex Trace back facilities
14486
14487 @node GNAT.UTF_32 (g-utf_32.ads)
14488 @section @code{GNAT.UTF_32} (@file{g-table.ads})
14489 @cindex @code{GNAT.UTF_32} (@file{g-table.ads})
14490 @cindex Wide character codes
14491
14492 @noindent
14493 This is a package intended to be used in conjunction with the
14494 @code{Wide_Character} type in Ada 95 and the
14495 @code{Wide_Wide_Character} type in Ada 2005 (available
14496 in @code{GNAT} in Ada 2005 mode). This package contains
14497 Unicode categorization routines, as well as lexical
14498 categorization routines corresponding to the Ada 2005
14499 lexical rules for identifiers and strings, and also a
14500 lower case to upper case fold routine corresponding to
14501 the Ada 2005 rules for identifier equivalence.
14502
14503 @node GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)
14504 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
14505 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
14506 @cindex Spell checking
14507
14508 @noindent
14509 Provides a function for determining whether one wide wide string is a plausible
14510 near misspelling of another wide wide string, where the strings are represented
14511 using the UTF_32_String type defined in System.Wch_Cnv.
14512
14513 @node GNAT.Wide_Spelling_Checker (g-wispch.ads)
14514 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
14515 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
14516 @cindex Spell checking
14517
14518 @noindent
14519 Provides a function for determining whether one wide string is a plausible
14520 near misspelling of another wide string.
14521
14522 @node GNAT.Wide_String_Split (g-wistsp.ads)
14523 @section @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
14524 @cindex @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
14525 @cindex Wide_String splitter
14526
14527 @noindent
14528 Useful wide string manipulation routines: given a set of separators, split
14529 a wide string wherever the separators appear, and provide direct access
14530 to the resulting slices. This package is instantiated from
14531 @code{GNAT.Array_Split}.
14532
14533 @node GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)
14534 @section @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
14535 @cindex @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
14536 @cindex Spell checking
14537
14538 @noindent
14539 Provides a function for determining whether one wide wide string is a plausible
14540 near misspelling of another wide wide string.
14541
14542 @node GNAT.Wide_Wide_String_Split (g-zistsp.ads)
14543 @section @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
14544 @cindex @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
14545 @cindex Wide_Wide_String splitter
14546
14547 @noindent
14548 Useful wide wide string manipulation routines: given a set of separators, split
14549 a wide wide string wherever the separators appear, and provide direct access
14550 to the resulting slices. This package is instantiated from
14551 @code{GNAT.Array_Split}.
14552
14553 @node Interfaces.C.Extensions (i-cexten.ads)
14554 @section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
14555 @cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
14556
14557 @noindent
14558 This package contains additional C-related definitions, intended
14559 for use with either manually or automatically generated bindings
14560 to C libraries.
14561
14562 @node Interfaces.C.Streams (i-cstrea.ads)
14563 @section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
14564 @cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
14565 @cindex  C streams, interfacing
14566
14567 @noindent
14568 This package is a binding for the most commonly used operations
14569 on C streams.
14570
14571 @node Interfaces.CPP (i-cpp.ads)
14572 @section @code{Interfaces.CPP} (@file{i-cpp.ads})
14573 @cindex @code{Interfaces.CPP} (@file{i-cpp.ads})
14574 @cindex  C++ interfacing
14575 @cindex  Interfacing, to C++
14576
14577 @noindent
14578 This package provides facilities for use in interfacing to C++.  It
14579 is primarily intended to be used in connection with automated tools
14580 for the generation of C++ interfaces.
14581
14582 @node Interfaces.Packed_Decimal (i-pacdec.ads)
14583 @section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
14584 @cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
14585 @cindex  IBM Packed Format
14586 @cindex  Packed Decimal
14587
14588 @noindent
14589 This package provides a set of routines for conversions to and
14590 from a packed decimal format compatible with that used on IBM
14591 mainframes.
14592
14593 @node Interfaces.VxWorks (i-vxwork.ads)
14594 @section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
14595 @cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
14596 @cindex Interfacing to VxWorks
14597 @cindex VxWorks, interfacing
14598
14599 @noindent
14600 This package provides a limited binding to the VxWorks API.
14601 In particular, it interfaces with the
14602 VxWorks hardware interrupt facilities.
14603
14604 @node Interfaces.VxWorks.IO (i-vxwoio.ads)
14605 @section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
14606 @cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
14607 @cindex Interfacing to VxWorks' I/O
14608 @cindex VxWorks, I/O interfacing
14609 @cindex VxWorks, Get_Immediate
14610 @cindex Get_Immediate, VxWorks
14611
14612 @noindent
14613 This package provides a binding to the ioctl (IO/Control)
14614 function of VxWorks, defining a set of option values and
14615 function codes. A particular use of this package is
14616 to enable the use of Get_Immediate under VxWorks.
14617
14618 @node System.Address_Image (s-addima.ads)
14619 @section @code{System.Address_Image} (@file{s-addima.ads})
14620 @cindex @code{System.Address_Image} (@file{s-addima.ads})
14621 @cindex Address image
14622 @cindex Image, of an address
14623
14624 @noindent
14625 This function provides a useful debugging
14626 function that gives an (implementation dependent)
14627 string which identifies an address.
14628
14629 @node System.Assertions (s-assert.ads)
14630 @section @code{System.Assertions} (@file{s-assert.ads})
14631 @cindex @code{System.Assertions} (@file{s-assert.ads})
14632 @cindex Assertions
14633 @cindex Assert_Failure, exception
14634
14635 @noindent
14636 This package provides the declaration of the exception raised
14637 by an run-time assertion failure, as well as the routine that
14638 is used internally to raise this assertion.
14639
14640 @node System.Memory (s-memory.ads)
14641 @section @code{System.Memory} (@file{s-memory.ads})
14642 @cindex @code{System.Memory} (@file{s-memory.ads})
14643 @cindex Memory allocation
14644
14645 @noindent
14646 This package provides the interface to the low level routines used
14647 by the generated code for allocation and freeing storage for the
14648 default storage pool (analogous to the C routines malloc and free.
14649 It also provides a reallocation interface analogous to the C routine
14650 realloc. The body of this unit may be modified to provide alternative
14651 allocation mechanisms for the default pool, and in addition, direct
14652 calls to this unit may be made for low level allocation uses (for
14653 example see the body of @code{GNAT.Tables}).
14654
14655 @node System.Partition_Interface (s-parint.ads)
14656 @section @code{System.Partition_Interface} (@file{s-parint.ads})
14657 @cindex @code{System.Partition_Interface} (@file{s-parint.ads})
14658 @cindex Partition interfacing functions
14659
14660 @noindent
14661 This package provides facilities for partition interfacing.  It
14662 is used primarily in a distribution context when using Annex E
14663 with @code{GLADE}.
14664
14665 @node System.Pool_Global (s-pooglo.ads)
14666 @section @code{System.Pool_Global} (@file{s-pooglo.ads})
14667 @cindex @code{System.Pool_Global} (@file{s-pooglo.ads})
14668 @cindex Storage pool, global
14669 @cindex Global storage pool
14670
14671 @noindent
14672 This package provides a storage pool that is equivalent to the default
14673 storage pool used for access types for which no pool is specifically
14674 declared. It uses malloc/free to allocate/free and does not attempt to
14675 do any automatic reclamation.
14676
14677 @node System.Pool_Local (s-pooloc.ads)
14678 @section @code{System.Pool_Local} (@file{s-pooloc.ads})
14679 @cindex @code{System.Pool_Local} (@file{s-pooloc.ads})
14680 @cindex Storage pool, local
14681 @cindex Local storage pool
14682
14683 @noindent
14684 This package provides a storage pool that is intended for use with locally
14685 defined access types. It uses malloc/free for allocate/free, and maintains
14686 a list of allocated blocks, so that all storage allocated for the pool can
14687 be freed automatically when the pool is finalized.
14688
14689 @node System.Restrictions (s-restri.ads)
14690 @section @code{System.Restrictions} (@file{s-restri.ads})
14691 @cindex @code{System.Restrictions} (@file{s-restri.ads})
14692 @cindex Run-time restrictions access
14693
14694 @noindent
14695 This package provides facilities for accessing at run time
14696 the status of restrictions specified at compile time for
14697 the partition. Information is available both with regard
14698 to actual restrictions specified, and with regard to
14699 compiler determined information on which restrictions
14700 are violated by one or more packages in the partition.
14701
14702 @node System.Rident (s-rident.ads)
14703 @section @code{System.Rident} (@file{s-rident.ads})
14704 @cindex @code{System.Rident} (@file{s-rident.ads})
14705 @cindex Restrictions definitions
14706
14707 @noindent
14708 This package provides definitions of the restrictions
14709 identifiers supported by GNAT, and also the format of
14710 the restrictions provided in package System.Restrictions.
14711 It is not normally necessary to @code{with} this generic package
14712 since the necessary instantiation is included in
14713 package System.Restrictions.
14714
14715 @node System.Task_Info (s-tasinf.ads)
14716 @section @code{System.Task_Info} (@file{s-tasinf.ads})
14717 @cindex @code{System.Task_Info} (@file{s-tasinf.ads})
14718 @cindex Task_Info pragma
14719
14720 @noindent
14721 This package provides target dependent functionality that is used
14722 to support the @code{Task_Info} pragma
14723
14724 @node System.Wch_Cnv (s-wchcnv.ads)
14725 @section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
14726 @cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
14727 @cindex Wide Character, Representation
14728 @cindex Wide String, Conversion
14729 @cindex Representation of wide characters
14730
14731 @noindent
14732 This package provides routines for converting between
14733 wide and wide wide characters and a representation as a value of type
14734 @code{Standard.String}, using a specified wide character
14735 encoding method.  It uses definitions in
14736 package @code{System.Wch_Con}.
14737
14738 @node System.Wch_Con (s-wchcon.ads)
14739 @section @code{System.Wch_Con} (@file{s-wchcon.ads})
14740 @cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
14741
14742 @noindent
14743 This package provides definitions and descriptions of
14744 the various methods used for encoding wide characters
14745 in ordinary strings.  These definitions are used by
14746 the package @code{System.Wch_Cnv}.
14747
14748 @node Interfacing to Other Languages
14749 @chapter Interfacing to Other Languages
14750 @noindent
14751 The facilities in annex B of the Ada Reference Manual are fully
14752 implemented in GNAT, and in addition, a full interface to C++ is
14753 provided.
14754
14755 @menu
14756 * Interfacing to C::
14757 * Interfacing to C++::
14758 * Interfacing to COBOL::
14759 * Interfacing to Fortran::
14760 * Interfacing to non-GNAT Ada code::
14761 @end menu
14762
14763 @node Interfacing to C
14764 @section Interfacing to C
14765
14766 @noindent
14767 Interfacing to C with GNAT can use one of two approaches:
14768
14769 @itemize @bullet
14770 @item
14771 The types in the package @code{Interfaces.C} may be used.
14772 @item
14773 Standard Ada types may be used directly.  This may be less portable to
14774 other compilers, but will work on all GNAT compilers, which guarantee
14775 correspondence between the C and Ada types.
14776 @end itemize
14777
14778 @noindent
14779 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
14780 effect, since this is the default.  The following table shows the
14781 correspondence between Ada scalar types and the corresponding C types.
14782
14783 @table @code
14784 @item Integer
14785 @code{int}
14786 @item Short_Integer
14787 @code{short}
14788 @item Short_Short_Integer
14789 @code{signed char}
14790 @item Long_Integer
14791 @code{long}
14792 @item Long_Long_Integer
14793 @code{long long}
14794 @item Short_Float
14795 @code{float}
14796 @item Float
14797 @code{float}
14798 @item Long_Float
14799 @code{double}
14800 @item Long_Long_Float
14801 This is the longest floating-point type supported by the hardware.
14802 @end table
14803
14804 @noindent
14805 Additionally, there are the following general correspondences between Ada
14806 and C types:
14807 @itemize @bullet
14808 @item
14809 Ada enumeration types map to C enumeration types directly if pragma
14810 @code{Convention C} is specified, which causes them to have int
14811 length.  Without pragma @code{Convention C}, Ada enumeration types map to
14812 8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short},
14813 @code{int}, respectively) depending on the number of values passed.
14814 This is the only case in which pragma @code{Convention C} affects the
14815 representation of an Ada type.
14816
14817 @item
14818 Ada access types map to C pointers, except for the case of pointers to
14819 unconstrained types in Ada, which have no direct C equivalent.
14820
14821 @item
14822 Ada arrays map directly to C arrays.
14823
14824 @item
14825 Ada records map directly to C structures.
14826
14827 @item
14828 Packed Ada records map to C structures where all members are bit fields
14829 of the length corresponding to the @code{@var{type}'Size} value in Ada.
14830 @end itemize
14831
14832 @node Interfacing to C++
14833 @section Interfacing to C++
14834
14835 @noindent
14836 The interface to C++ makes use of the following pragmas, which are
14837 primarily intended to be constructed automatically using a binding generator
14838 tool, although it is possible to construct them by hand.  No suitable binding
14839 generator tool is supplied with GNAT though.
14840
14841 Using these pragmas it is possible to achieve complete
14842 inter-operability between Ada tagged types and C++ class definitions.
14843 See @ref{Implementation Defined Pragmas}, for more details.
14844
14845 @table @code
14846 @item pragma CPP_Class ([Entity =>] @var{LOCAL_NAME})
14847 The argument denotes an entity in the current declarative region that is
14848 declared as a tagged or untagged record type. It indicates that the type
14849 corresponds to an externally declared C++ class type, and is to be laid
14850 out the same way that C++ would lay out the type.
14851
14852 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
14853 for backward compatibility but its functionality is available
14854 using pragma @code{Import} with @code{Convention} = @code{CPP}.
14855
14856 @item pragma CPP_Constructor ([Entity =>] @var{LOCAL_NAME})
14857 This pragma identifies an imported function (imported in the usual way
14858 with pragma @code{Import}) as corresponding to a C++ constructor.
14859 @end table
14860
14861 @node Interfacing to COBOL
14862 @section Interfacing to COBOL
14863
14864 @noindent
14865 Interfacing to COBOL is achieved as described in section B.4 of
14866 the Ada Reference Manual.
14867
14868 @node Interfacing to Fortran
14869 @section Interfacing to Fortran
14870
14871 @noindent
14872 Interfacing to Fortran is achieved as described in section B.5 of the
14873 Ada Reference Manual.  The pragma @code{Convention Fortran}, applied to a
14874 multi-dimensional array causes the array to be stored in column-major
14875 order as required for convenient interface to Fortran.
14876
14877 @node Interfacing to non-GNAT Ada code
14878 @section Interfacing to non-GNAT Ada code
14879
14880 It is possible to specify the convention @code{Ada} in a pragma
14881 @code{Import} or pragma @code{Export}.  However this refers to
14882 the calling conventions used by GNAT, which may or may not be
14883 similar enough to those used by some other Ada 83 / Ada 95 / Ada 2005
14884 compiler to allow interoperation.
14885
14886 If arguments types are kept simple, and if the foreign compiler generally
14887 follows system calling conventions, then it may be possible to integrate
14888 files compiled by other Ada compilers, provided that the elaboration
14889 issues are adequately addressed (for example by eliminating the
14890 need for any load time elaboration).
14891
14892 In particular, GNAT running on VMS is designed to
14893 be highly compatible with the DEC Ada 83 compiler, so this is one
14894 case in which it is possible to import foreign units of this type,
14895 provided that the data items passed are restricted to simple scalar
14896 values or simple record types without variants, or simple array
14897 types with fixed bounds.
14898
14899 @node Specialized Needs Annexes
14900 @chapter Specialized Needs Annexes
14901
14902 @noindent
14903 Ada 95 and Ada 2005 define a number of Specialized Needs Annexes, which are not
14904 required in all implementations.  However, as described in this chapter,
14905 GNAT implements all of these annexes:
14906
14907 @table @asis
14908 @item Systems Programming (Annex C)
14909 The Systems Programming Annex is fully implemented.
14910
14911 @item Real-Time Systems (Annex D)
14912 The Real-Time Systems Annex is fully implemented.
14913
14914 @item Distributed Systems (Annex E)
14915 Stub generation is fully implemented in the GNAT compiler.  In addition,
14916 a complete compatible PCS is available as part of the GLADE system,
14917 a separate product.  When the two
14918 products are used in conjunction, this annex is fully implemented.
14919
14920 @item Information Systems (Annex F)
14921 The Information Systems annex is fully implemented.
14922
14923 @item Numerics (Annex G)
14924 The Numerics Annex is fully implemented.
14925
14926 @item Safety and Security / High-Integrity Systems (Annex H)
14927 The Safety and Security Annex (termed the High-Integrity Systems Annex
14928 in Ada 2005) is fully implemented.
14929 @end table
14930
14931 @node Implementation of Specific Ada Features
14932 @chapter Implementation of Specific Ada Features
14933
14934 @noindent
14935 This chapter describes the GNAT implementation of several Ada language
14936 facilities.
14937
14938 @menu
14939 * Machine Code Insertions::
14940 * GNAT Implementation of Tasking::
14941 * GNAT Implementation of Shared Passive Packages::
14942 * Code Generation for Array Aggregates::
14943 * The Size of Discriminated Records with Default Discriminants::
14944 * Strict Conformance to the Ada Reference Manual::
14945 @end menu
14946
14947 @node Machine Code Insertions
14948 @section Machine Code Insertions
14949 @cindex Machine Code insertions
14950
14951 @noindent
14952 Package @code{Machine_Code} provides machine code support as described
14953 in the Ada Reference Manual in two separate forms:
14954 @itemize @bullet
14955 @item
14956 Machine code statements, consisting of qualified expressions that
14957 fit the requirements of RM section 13.8.
14958 @item
14959 An intrinsic callable procedure, providing an alternative mechanism of
14960 including machine instructions in a subprogram.
14961 @end itemize
14962
14963 @noindent
14964 The two features are similar, and both are closely related to the mechanism
14965 provided by the asm instruction in the GNU C compiler.  Full understanding
14966 and use of the facilities in this package requires understanding the asm
14967 instruction, see @ref{Extended Asm,, Assembler Instructions with C Expression
14968 Operands, gcc, Using the GNU Compiler Collection (GCC)}.
14969
14970 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
14971 semantic restrictions and effects as described below.  Both are provided so
14972 that the procedure call can be used as a statement, and the function call
14973 can be used to form a code_statement.
14974
14975 The first example given in the GCC documentation is the C @code{asm}
14976 instruction:
14977 @smallexample
14978    asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
14979 @end smallexample
14980
14981 @noindent
14982 The equivalent can be written for GNAT as:
14983
14984 @smallexample @c ada
14985 Asm ("fsinx %1 %0",
14986      My_Float'Asm_Output ("=f", result),
14987      My_Float'Asm_Input  ("f",  angle));
14988 @end smallexample
14989
14990 @noindent
14991 The first argument to @code{Asm} is the assembler template, and is
14992 identical to what is used in GNU C@.  This string must be a static
14993 expression.  The second argument is the output operand list.  It is
14994 either a single @code{Asm_Output} attribute reference, or a list of such
14995 references enclosed in parentheses (technically an array aggregate of
14996 such references).
14997
14998 The @code{Asm_Output} attribute denotes a function that takes two
14999 parameters.  The first is a string, the second is the name of a variable
15000 of the type designated by the attribute prefix.  The first (string)
15001 argument is required to be a static expression and designates the
15002 constraint for the parameter (e.g.@: what kind of register is
15003 required).  The second argument is the variable to be updated with the
15004 result.  The possible values for constraint are the same as those used in
15005 the RTL, and are dependent on the configuration file used to build the
15006 GCC back end.  If there are no output operands, then this argument may
15007 either be omitted, or explicitly given as @code{No_Output_Operands}.
15008
15009 The second argument of @code{@var{my_float}'Asm_Output} functions as
15010 though it were an @code{out} parameter, which is a little curious, but
15011 all names have the form of expressions, so there is no syntactic
15012 irregularity, even though normally functions would not be permitted
15013 @code{out} parameters.  The third argument is the list of input
15014 operands.  It is either a single @code{Asm_Input} attribute reference, or
15015 a list of such references enclosed in parentheses (technically an array
15016 aggregate of such references).
15017
15018 The @code{Asm_Input} attribute denotes a function that takes two
15019 parameters.  The first is a string, the second is an expression of the
15020 type designated by the prefix.  The first (string) argument is required
15021 to be a static expression, and is the constraint for the parameter,
15022 (e.g.@: what kind of register is required).  The second argument is the
15023 value to be used as the input argument.  The possible values for the
15024 constant are the same as those used in the RTL, and are dependent on
15025 the configuration file used to built the GCC back end.
15026
15027 If there are no input operands, this argument may either be omitted, or
15028 explicitly given as @code{No_Input_Operands}.  The fourth argument, not
15029 present in the above example, is a list of register names, called the
15030 @dfn{clobber} argument.  This argument, if given, must be a static string
15031 expression, and is a space or comma separated list of names of registers
15032 that must be considered destroyed as a result of the @code{Asm} call.  If
15033 this argument is the null string (the default value), then the code
15034 generator assumes that no additional registers are destroyed.
15035
15036 The fifth argument, not present in the above example, called the
15037 @dfn{volatile} argument, is by default @code{False}.  It can be set to
15038 the literal value @code{True} to indicate to the code generator that all
15039 optimizations with respect to the instruction specified should be
15040 suppressed, and that in particular, for an instruction that has outputs,
15041 the instruction will still be generated, even if none of the outputs are
15042 used.  @xref{Extended Asm,, Assembler Instructions with C Expression Operands,
15043 gcc, Using the GNU Compiler Collection (GCC)}, for the full description.
15044 Generally it is strongly advisable to use Volatile for any ASM statement
15045 that is missing either input or output operands, or when two or more ASM
15046 statements appear in sequence, to avoid unwanted optimizations. A warning
15047 is generated if this advice is not followed.
15048
15049 The @code{Asm} subprograms may be used in two ways.  First the procedure
15050 forms can be used anywhere a procedure call would be valid, and
15051 correspond to what the RM calls ``intrinsic'' routines.  Such calls can
15052 be used to intersperse machine instructions with other Ada statements.
15053 Second, the function forms, which return a dummy value of the limited
15054 private type @code{Asm_Insn}, can be used in code statements, and indeed
15055 this is the only context where such calls are allowed.  Code statements
15056 appear as aggregates of the form:
15057
15058 @smallexample @c ada
15059 Asm_Insn'(Asm (@dots{}));
15060 Asm_Insn'(Asm_Volatile (@dots{}));
15061 @end smallexample
15062
15063 @noindent
15064 In accordance with RM rules, such code statements are allowed only
15065 within subprograms whose entire body consists of such statements.  It is
15066 not permissible to intermix such statements with other Ada statements.
15067
15068 Typically the form using intrinsic procedure calls is more convenient
15069 and more flexible.  The code statement form is provided to meet the RM
15070 suggestion that such a facility should be made available.  The following
15071 is the exact syntax of the call to @code{Asm}. As usual, if named notation
15072 is used, the arguments may be given in arbitrary order, following the
15073 normal rules for use of positional and named arguments)
15074
15075 @smallexample
15076 ASM_CALL ::= Asm (
15077                  [Template =>] static_string_EXPRESSION
15078                [,[Outputs  =>] OUTPUT_OPERAND_LIST      ]
15079                [,[Inputs   =>] INPUT_OPERAND_LIST       ]
15080                [,[Clobber  =>] static_string_EXPRESSION ]
15081                [,[Volatile =>] static_boolean_EXPRESSION] )
15082
15083 OUTPUT_OPERAND_LIST ::=
15084   [PREFIX.]No_Output_Operands
15085 | OUTPUT_OPERAND_ATTRIBUTE
15086 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
15087
15088 OUTPUT_OPERAND_ATTRIBUTE ::=
15089   SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
15090
15091 INPUT_OPERAND_LIST ::=
15092   [PREFIX.]No_Input_Operands
15093 | INPUT_OPERAND_ATTRIBUTE
15094 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
15095
15096 INPUT_OPERAND_ATTRIBUTE ::=
15097   SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
15098 @end smallexample
15099
15100 @noindent
15101 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
15102 are declared in the package @code{Machine_Code} and must be referenced
15103 according to normal visibility rules. In particular if there is no
15104 @code{use} clause for this package, then appropriate package name
15105 qualification is required.
15106
15107 @node GNAT Implementation of Tasking
15108 @section GNAT Implementation of Tasking
15109
15110 @noindent
15111 This chapter outlines the basic GNAT approach to tasking (in particular,
15112 a multi-layered library for portability) and discusses issues related
15113 to compliance with the Real-Time Systems Annex.
15114
15115 @menu
15116 * Mapping Ada Tasks onto the Underlying Kernel Threads::
15117 * Ensuring Compliance with the Real-Time Annex::
15118 @end menu
15119
15120 @node Mapping Ada Tasks onto the Underlying Kernel Threads
15121 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
15122
15123 @noindent
15124 GNAT's run-time support comprises two layers:
15125
15126 @itemize @bullet
15127 @item GNARL (GNAT Run-time Layer)
15128 @item GNULL (GNAT Low-level Library)
15129 @end itemize
15130
15131 @noindent
15132 In GNAT, Ada's tasking services rely on a platform and OS independent
15133 layer known as GNARL@.  This code is responsible for implementing the
15134 correct semantics of Ada's task creation, rendezvous, protected
15135 operations etc.
15136
15137 GNARL decomposes Ada's tasking semantics into simpler lower level
15138 operations such as create a thread, set the priority of a thread,
15139 yield, create a lock, lock/unlock, etc.  The spec for these low-level
15140 operations constitutes GNULLI, the GNULL Interface.  This interface is
15141 directly inspired from the POSIX real-time API@.
15142
15143 If the underlying executive or OS implements the POSIX standard
15144 faithfully, the GNULL Interface maps as is to the services offered by
15145 the underlying kernel.  Otherwise, some target dependent glue code maps
15146 the services offered by the underlying kernel to the semantics expected
15147 by GNARL@.
15148
15149 Whatever the underlying OS (VxWorks, UNIX, OS/2, Windows NT, etc.) the
15150 key point is that each Ada task is mapped on a thread in the underlying
15151 kernel.  For example, in the case of VxWorks, one Ada task = one VxWorks task.
15152
15153 In addition Ada task priorities map onto the underlying thread priorities.
15154 Mapping Ada tasks onto the underlying kernel threads has several advantages:
15155
15156 @itemize @bullet
15157 @item
15158 The underlying scheduler is used to schedule the Ada tasks.  This
15159 makes Ada tasks as efficient as kernel threads from a scheduling
15160 standpoint.
15161
15162 @item
15163 Interaction with code written in C containing threads is eased
15164 since at the lowest level Ada tasks and C threads map onto the same
15165 underlying kernel concept.
15166
15167 @item
15168 When an Ada task is blocked during I/O the remaining Ada tasks are
15169 able to proceed.
15170
15171 @item
15172 On multiprocessor systems Ada tasks can execute in parallel.
15173 @end itemize
15174
15175 @noindent
15176 Some threads libraries offer a mechanism to fork a new process, with the
15177 child process duplicating the threads from the parent.
15178 GNAT does not
15179 support this functionality when the parent contains more than one task.
15180 @cindex Forking a new process
15181
15182 @node Ensuring Compliance with the Real-Time Annex
15183 @subsection Ensuring Compliance with the Real-Time Annex
15184 @cindex Real-Time Systems Annex compliance
15185
15186 @noindent
15187 Although mapping Ada tasks onto
15188 the underlying threads has significant advantages, it does create some
15189 complications when it comes to respecting the scheduling semantics
15190 specified in the real-time annex (Annex D).
15191
15192 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
15193 scheduling policy states:
15194
15195 @quotation
15196 @emph{When the active priority of a ready task that is not running
15197 changes, or the setting of its base priority takes effect, the
15198 task is removed from the ready queue for its old active priority
15199 and is added at the tail of the ready queue for its new active
15200 priority, except in the case where the active priority is lowered
15201 due to the loss of inherited priority, in which case the task is
15202 added at the head of the ready queue for its new active priority.}
15203 @end quotation
15204
15205 @noindent
15206 While most kernels do put tasks at the end of the priority queue when
15207 a task changes its priority, (which respects the main
15208 FIFO_Within_Priorities requirement), almost none keep a thread at the
15209 beginning of its priority queue when its priority drops from the loss
15210 of inherited priority.
15211
15212 As a result most vendors have provided incomplete Annex D implementations.
15213
15214 The GNAT run-time, has a nice cooperative solution to this problem
15215 which ensures that accurate FIFO_Within_Priorities semantics are
15216 respected.
15217
15218 The principle is as follows.  When an Ada task T is about to start
15219 running, it checks whether some other Ada task R with the same
15220 priority as T has been suspended due to the loss of priority
15221 inheritance.  If this is the case, T yields and is placed at the end of
15222 its priority queue.  When R arrives at the front of the queue it
15223 executes.
15224
15225 Note that this simple scheme preserves the relative order of the tasks
15226 that were ready to execute in the priority queue where R has been
15227 placed at the end.
15228
15229 @node GNAT Implementation of Shared Passive Packages
15230 @section GNAT Implementation of Shared Passive Packages
15231 @cindex Shared passive packages
15232
15233 @noindent
15234 GNAT fully implements the pragma @code{Shared_Passive} for
15235 @cindex pragma @code{Shared_Passive}
15236 the purpose of designating shared passive packages.
15237 This allows the use of passive partitions in the
15238 context described in the Ada Reference Manual; i.e., for communication
15239 between separate partitions of a distributed application using the
15240 features in Annex E.
15241 @cindex Annex E
15242 @cindex Distribution Systems Annex
15243
15244 However, the implementation approach used by GNAT provides for more
15245 extensive usage as follows:
15246
15247 @table @emph
15248 @item Communication between separate programs
15249
15250 This allows separate programs to access the data in passive
15251 partitions, using protected objects for synchronization where
15252 needed. The only requirement is that the two programs have a
15253 common shared file system. It is even possible for programs
15254 running on different machines with different architectures
15255 (e.g.@: different endianness) to communicate via the data in
15256 a passive partition.
15257
15258 @item Persistence between program runs
15259
15260 The data in a passive package can persist from one run of a
15261 program to another, so that a later program sees the final
15262 values stored by a previous run of the same program.
15263
15264 @end table
15265
15266 @noindent
15267 The implementation approach used is to store the data in files. A
15268 separate stream file is created for each object in the package, and
15269 an access to an object causes the corresponding file to be read or
15270 written.
15271
15272 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
15273 @cindex @code{SHARED_MEMORY_DIRECTORY} environment variable
15274 set to the directory to be used for these files.
15275 The files in this directory
15276 have names that correspond to their fully qualified names. For
15277 example, if we have the package
15278
15279 @smallexample @c ada
15280 package X is
15281   pragma Shared_Passive (X);
15282   Y : Integer;
15283   Z : Float;
15284 end X;
15285 @end smallexample
15286
15287 @noindent
15288 and the environment variable is set to @code{/stemp/}, then the files created
15289 will have the names:
15290
15291 @smallexample
15292 /stemp/x.y
15293 /stemp/x.z
15294 @end smallexample
15295
15296 @noindent
15297 These files are created when a value is initially written to the object, and
15298 the files are retained until manually deleted. This provides the persistence
15299 semantics. If no file exists, it means that no partition has assigned a value
15300 to the variable; in this case the initial value declared in the package
15301 will be used. This model ensures that there are no issues in synchronizing
15302 the elaboration process, since elaboration of passive packages elaborates the
15303 initial values, but does not create the files.
15304
15305 The files are written using normal @code{Stream_IO} access.
15306 If you want to be able
15307 to communicate between programs or partitions running on different
15308 architectures, then you should use the XDR versions of the stream attribute
15309 routines, since these are architecture independent.
15310
15311 If active synchronization is required for access to the variables in the
15312 shared passive package, then as described in the Ada Reference Manual, the
15313 package may contain protected objects used for this purpose. In this case
15314 a lock file (whose name is @file{___lock} (three underscores)
15315 is created in the shared memory directory.
15316 @cindex @file{___lock} file (for shared passive packages)
15317 This is used to provide the required locking
15318 semantics for proper protected object synchronization.
15319
15320 As of January 2003, GNAT supports shared passive packages on all platforms
15321 except for OpenVMS.
15322
15323 @node Code Generation for Array Aggregates
15324 @section Code Generation for Array Aggregates
15325
15326 @menu
15327 * Static constant aggregates with static bounds::
15328 * Constant aggregates with unconstrained nominal types::
15329 * Aggregates with static bounds::
15330 * Aggregates with non-static bounds::
15331 * Aggregates in assignment statements::
15332 @end menu
15333
15334 @noindent
15335 Aggregates have a rich syntax and allow the user to specify the values of
15336 complex data structures by means of a single construct.  As a result, the
15337 code generated for aggregates can be quite complex and involve loops, case
15338 statements and multiple assignments.  In the simplest cases, however, the
15339 compiler will recognize aggregates whose components and constraints are
15340 fully static, and in those cases the compiler will generate little or no
15341 executable code.  The following is an outline of the code that GNAT generates
15342 for various aggregate constructs.  For further details, you will find it
15343 useful to examine the output produced by the -gnatG flag to see the expanded
15344 source that is input to the code generator.  You may also want to examine
15345 the assembly code generated at various levels of optimization.
15346
15347 The code generated for aggregates depends on the context, the component values,
15348 and the type.  In the context of an object declaration the code generated is
15349 generally simpler than in the case of an assignment.  As a general rule, static
15350 component values and static subtypes also lead to simpler code.
15351
15352 @node Static constant aggregates with static bounds
15353 @subsection Static constant aggregates with static bounds
15354
15355 @noindent
15356 For the declarations:
15357 @smallexample @c ada
15358     type One_Dim is array (1..10) of integer;
15359     ar0 : constant One_Dim := (1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
15360 @end smallexample
15361
15362 @noindent
15363 GNAT generates no executable code: the constant ar0 is placed in static memory.
15364 The same is true for constant aggregates with named associations:
15365
15366 @smallexample @c ada
15367     Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1 => 1, 5 .. 10 => 0);
15368     Cr3 : constant One_Dim := (others => 7777);
15369 @end smallexample
15370
15371 @noindent
15372 The same is true for multidimensional constant arrays such as:
15373
15374 @smallexample @c ada
15375     type two_dim is array (1..3, 1..3) of integer;
15376     Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
15377 @end smallexample
15378
15379 @noindent
15380 The same is true for arrays of one-dimensional arrays: the following are
15381 static:
15382
15383 @smallexample @c ada
15384 type ar1b  is array (1..3) of boolean;
15385 type ar_ar is array (1..3) of ar1b;
15386 None  : constant ar1b := (others => false);     --  fully static
15387 None2 : constant ar_ar := (1..3 => None);       --  fully static
15388 @end smallexample
15389
15390 @noindent
15391 However, for multidimensional aggregates with named associations, GNAT will
15392 generate assignments and loops, even if all associations are static.  The
15393 following two declarations generate a loop for the first dimension, and
15394 individual component assignments for the second dimension:
15395
15396 @smallexample @c ada
15397 Zero1: constant two_dim := (1..3 => (1..3 => 0));
15398 Zero2: constant two_dim := (others => (others => 0));
15399 @end smallexample
15400
15401 @node Constant aggregates with unconstrained nominal types
15402 @subsection Constant aggregates with unconstrained nominal types
15403
15404 @noindent
15405 In such cases the aggregate itself establishes the subtype, so that
15406 associations with @code{others} cannot be used.  GNAT determines the
15407 bounds for the actual subtype of the aggregate, and allocates the
15408 aggregate statically as well.  No code is generated for the following:
15409
15410 @smallexample @c ada
15411     type One_Unc is array (natural range <>) of integer;
15412     Cr_Unc : constant One_Unc := (12,24,36);
15413 @end smallexample
15414
15415 @node Aggregates with static bounds
15416 @subsection Aggregates with static bounds
15417
15418 @noindent
15419 In all previous examples the aggregate was the initial (and immutable) value
15420 of a constant.  If the aggregate initializes a variable, then code is generated
15421 for it as a combination of individual assignments and loops over the target
15422 object.  The declarations
15423
15424 @smallexample @c ada
15425        Cr_Var1 : One_Dim := (2, 5, 7, 11, 0, 0, 0, 0, 0, 0);
15426        Cr_Var2 : One_Dim := (others > -1);
15427 @end smallexample
15428
15429 @noindent
15430 generate the equivalent of
15431
15432 @smallexample @c ada
15433        Cr_Var1 (1) := 2;
15434        Cr_Var1 (2) := 3;
15435        Cr_Var1 (3) := 5;
15436        Cr_Var1 (4) := 11;
15437
15438        for I in Cr_Var2'range loop
15439           Cr_Var2 (I) := -1;
15440        end loop;
15441 @end smallexample
15442
15443 @node Aggregates with non-static bounds
15444 @subsection Aggregates with non-static bounds
15445
15446 @noindent
15447 If the bounds of the aggregate are not statically compatible with the bounds
15448 of the nominal subtype  of the target, then constraint checks have to be
15449 generated on the bounds.  For a multidimensional array, constraint checks may
15450 have to be applied to sub-arrays individually, if they do not have statically
15451 compatible subtypes.
15452
15453 @node Aggregates in assignment statements
15454 @subsection Aggregates in assignment statements
15455
15456 @noindent
15457 In general, aggregate assignment requires the construction of a temporary,
15458 and a copy from the temporary to the target of the assignment.  This is because
15459 it is not always possible to convert the assignment into a series of individual
15460 component assignments.  For example, consider the simple case:
15461
15462 @smallexample @c ada
15463         A := (A(2), A(1));
15464 @end smallexample
15465
15466 @noindent
15467 This cannot be converted into:
15468
15469 @smallexample @c ada
15470         A(1) := A(2);
15471         A(2) := A(1);
15472 @end smallexample
15473
15474 @noindent
15475 So the aggregate has to be built first in a separate location, and then
15476 copied into the target.  GNAT recognizes simple cases where this intermediate
15477 step is not required, and the assignments can be performed in place, directly
15478 into the target.  The following sufficient criteria are applied:
15479
15480 @itemize @bullet
15481 @item
15482 The bounds of the aggregate are static, and the associations are static.
15483 @item
15484 The components of the aggregate are static constants, names of
15485 simple variables that are not renamings, or expressions not involving
15486 indexed components whose operands obey these rules.
15487 @end itemize
15488
15489 @noindent
15490 If any of these conditions are violated, the aggregate will be built in
15491 a temporary (created either by the front-end or the code generator) and then
15492 that temporary will be copied onto the target.
15493
15494
15495 @node The Size of Discriminated Records with Default Discriminants
15496 @section The Size of Discriminated Records with Default Discriminants
15497
15498 @noindent
15499 If a discriminated type @code{T} has discriminants with default values, it is
15500 possible to declare an object of this type without providing an explicit
15501 constraint:
15502
15503 @smallexample @c ada
15504 @group
15505 type Size is range 1..100;
15506
15507 type Rec (D : Size := 15) is record
15508    Name : String (1..D);
15509 end T;
15510
15511 Word : Rec;
15512 @end group
15513 @end smallexample
15514
15515 @noindent
15516 Such an object is said to be @emph{unconstrained}.
15517 The discriminant of the object
15518 can be modified by a full assignment to the object, as long as it preserves the
15519 relation between the value of the discriminant, and the value of the components
15520 that depend on it:
15521
15522 @smallexample @c ada
15523 @group
15524 Word := (3, "yes");
15525
15526 Word := (5, "maybe");
15527
15528 Word := (5, "no"); -- raises Constraint_Error
15529 @end group
15530 @end smallexample
15531
15532 @noindent
15533 In order to support this behavior efficiently, an unconstrained object is
15534 given the maximum size that any value of the type requires. In the case
15535 above, @code{Word} has storage for the discriminant and for
15536 a @code{String} of length 100.
15537 It is important to note that unconstrained objects do not require dynamic
15538 allocation. It would be an improper implementation to place on the heap those
15539 components whose size depends on discriminants. (This improper implementation
15540 was used by some Ada83 compilers, where the @code{Name} component above
15541 would have
15542 been stored as a pointer to a dynamic string). Following the principle that
15543 dynamic storage management should never be introduced implicitly,
15544 an Ada compiler should reserve the full size for an unconstrained declared
15545 object, and place it on the stack.
15546
15547 This maximum size approach
15548 has been a source of surprise to some users, who expect the default
15549 values of the discriminants to determine the size reserved for an
15550 unconstrained object: ``If the default is 15, why should the object occupy
15551 a larger size?''
15552 The answer, of course, is that the discriminant may be later modified,
15553 and its full range of values must be taken into account. This is why the
15554 declaration:
15555
15556 @smallexample
15557 @group
15558 type Rec (D : Positive := 15) is record
15559    Name : String (1..D);
15560 end record;
15561
15562 Too_Large : Rec;
15563 @end group
15564 @end smallexample
15565
15566 @noindent
15567 is flagged by the compiler with a warning:
15568 an attempt to create @code{Too_Large} will raise @code{Storage_Error},
15569 because the required size includes @code{Positive'Last}
15570 bytes. As the first example indicates, the proper approach is to declare an
15571 index type of ``reasonable'' range so that unconstrained objects are not too
15572 large.
15573
15574 One final wrinkle: if the object is declared to be @code{aliased}, or if it is
15575 created in the heap by means of an allocator, then it is @emph{not}
15576 unconstrained:
15577 it is constrained by the default values of the discriminants, and those values
15578 cannot be modified by full assignment. This is because in the presence of
15579 aliasing all views of the object (which may be manipulated by different tasks,
15580 say) must be consistent, so it is imperative that the object, once created,
15581 remain invariant.
15582
15583 @node Strict Conformance to the Ada Reference Manual
15584 @section Strict Conformance to the Ada Reference Manual
15585
15586 @noindent
15587 The dynamic semantics defined by the Ada Reference Manual impose a set of
15588 run-time checks to be generated. By default, the GNAT compiler will insert many
15589 run-time checks into the compiled code, including most of those required by the
15590 Ada Reference Manual. However, there are three checks that are not enabled
15591 in the default mode for efficiency reasons: arithmetic overflow checking for
15592 integer operations (including division by zero), checks for access before
15593 elaboration on subprogram calls, and stack overflow checking (most operating
15594 systems do not perform this check by default).
15595
15596 Strict conformance to the Ada Reference Manual can be achieved by adding
15597 three compiler options for overflow checking for integer operations
15598 (@option{-gnato}), dynamic checks for access-before-elaboration on subprogram
15599 calls and generic instantiations (@option{-gnatE}), and stack overflow
15600 checking (@option{-fstack-check}).
15601
15602 Note that the result of a floating point arithmetic operation in overflow and
15603 invalid situations, when the @code{Machine_Overflows} attribute of the result
15604 type is @code{False}, is to generate IEEE NaN and infinite values. This is the
15605 case for machines compliant with the IEEE floating-point standard, but on
15606 machines that are not fully compliant with this standard, such as Alpha, the
15607 @option{-mieee} compiler flag must be used for achieving IEEE confirming
15608 behavior (although at the cost of a significant performance penalty), so
15609 infinite and and NaN values are properly generated.
15610
15611
15612 @node Project File Reference
15613 @chapter Project File Reference
15614
15615 @noindent
15616 This chapter describes the syntax and semantics of project files.
15617 Project files specify the options to be used when building a system.
15618 Project files can specify global settings for all tools,
15619 as well as tool-specific settings.
15620 @xref{Examples of Project Files,,, gnat_ugn, @value{EDITION} User's Guide},
15621 for examples of use.
15622
15623 @menu
15624 * Reserved Words::
15625 * Lexical Elements::
15626 * Declarations::
15627 * Empty declarations::
15628 * Typed string declarations::
15629 * Variables::
15630 * Expressions::
15631 * Attributes::
15632 * Project Attributes::
15633 * Attribute References::
15634 * External Values::
15635 * Case Construction::
15636 * Packages::
15637 * Package Renamings::
15638 * Projects::
15639 * Project Extensions::
15640 * Project File Elaboration::
15641 @end menu
15642
15643 @node Reserved Words
15644 @section Reserved Words
15645
15646 @noindent
15647 All Ada reserved words are reserved in project files, and cannot be used
15648 as variable names or project names. In addition, the following are
15649 also reserved in project files:
15650
15651 @itemize
15652 @item @code{extends}
15653
15654 @item @code{external}
15655
15656 @item @code{project}
15657
15658 @end itemize
15659
15660 @node Lexical Elements
15661 @section Lexical Elements
15662
15663 @noindent
15664 Rules for identifiers are the same as in Ada. Identifiers
15665 are case-insensitive.  Strings are case sensitive, except where noted.
15666 Comments have the same form as in Ada.
15667
15668 @noindent
15669 Syntax:
15670
15671 @smallexample
15672 simple_name ::=
15673   identifier
15674
15675 name ::=
15676   simple_name @{. simple_name@}
15677 @end smallexample
15678
15679 @node Declarations
15680 @section Declarations
15681
15682 @noindent
15683 Declarations introduce new entities that denote types, variables, attributes,
15684 and packages. Some declarations can only appear immediately within a project
15685 declaration. Others can appear within a project or within a package.
15686
15687 Syntax:
15688 @smallexample
15689 declarative_item ::=
15690   simple_declarative_item |
15691   typed_string_declaration |
15692   package_declaration
15693
15694 simple_declarative_item ::=
15695   variable_declaration |
15696   typed_variable_declaration |
15697   attribute_declaration |
15698   case_construction |
15699   empty_declaration
15700 @end smallexample
15701
15702 @node Empty declarations
15703 @section Empty declarations
15704
15705 @smallexample
15706 empty_declaration ::=
15707   @b{null} ;
15708 @end smallexample
15709
15710 An empty declaration is allowed anywhere a declaration is allowed.
15711 It has no effect.
15712
15713 @node Typed string declarations
15714 @section Typed string declarations
15715
15716 @noindent
15717 Typed strings are sequences of string literals. Typed strings are the only
15718 named types in project files. They are used in case constructions, where they
15719 provide support for conditional attribute definitions.
15720
15721 Syntax:
15722 @smallexample
15723 typed_string_declaration ::=
15724   @b{type} <typed_string_>_simple_name @b{is}
15725    ( string_literal @{, string_literal@} );
15726 @end smallexample
15727
15728 @noindent
15729 A typed string declaration can only appear immediately within a project
15730 declaration.
15731
15732 All the string literals in a typed string declaration must be distinct.
15733
15734 @node Variables
15735 @section Variables
15736
15737 @noindent
15738 Variables denote values, and appear as constituents of expressions.
15739
15740 @smallexample
15741 typed_variable_declaration ::=
15742   <typed_variable_>simple_name : <typed_string_>name :=  string_expression ;
15743
15744 variable_declaration ::=
15745   <variable_>simple_name := expression;
15746 @end smallexample
15747
15748 @noindent
15749 The elaboration of a variable declaration introduces the variable and
15750 assigns to it the value of the expression. The name of the variable is
15751 available after the assignment symbol.
15752
15753 @noindent
15754 A typed_variable can only be declare once.
15755
15756 @noindent
15757 a non-typed variable can be declared multiple times.
15758
15759 @noindent
15760 Before the completion of its first declaration, the value of variable
15761 is the null string.
15762
15763 @node Expressions
15764 @section Expressions
15765
15766 @noindent
15767 An expression is a formula that defines a computation or retrieval of a value.
15768 In a project file the value of an expression is either a string or a list
15769 of strings. A string value in an expression is either a literal, the current
15770 value of a variable, an external value, an attribute reference, or a
15771 concatenation operation.
15772
15773 Syntax:
15774
15775 @smallexample
15776 expression ::=
15777   term @{& term@}
15778
15779 term ::=
15780   string_literal |
15781   string_list |
15782   <variable_>name |
15783   external_value |
15784   attribute_reference
15785
15786 string_literal ::=
15787   (same as Ada)
15788
15789 string_list ::=
15790   ( <string_>expression @{ , <string_>expression @} )
15791 @end smallexample
15792
15793 @subsection Concatenation
15794 @noindent
15795 The following concatenation functions are defined:
15796
15797 @smallexample @c ada
15798   function "&" (X : String;      Y : String)      return String;
15799   function "&" (X : String_List; Y : String)      return String_List;
15800   function "&" (X : String_List; Y : String_List) return String_List;
15801 @end smallexample
15802
15803 @node Attributes
15804 @section Attributes
15805
15806 @noindent
15807 An attribute declaration defines a property of a project or package. This
15808 property can later be queried by means of an attribute reference.
15809 Attribute values are strings or string lists.
15810
15811 Some attributes are associative arrays. These attributes are mappings whose
15812 domain is a set of strings. These attributes are declared one association
15813 at a time, by specifying a point in the domain and the corresponding image
15814 of the attribute. They may also be declared as a full associative array,
15815 getting the same associations as the corresponding attribute in an imported
15816 or extended project.
15817
15818 Attributes that are not associative arrays are called simple attributes.
15819
15820 Syntax:
15821 @smallexample
15822 attribute_declaration ::=
15823   full_associative_array_declaration |
15824   @b{for} attribute_designator @b{use} expression ;
15825
15826 full_associative_array_declaration ::=
15827   @b{for} <associative_array_attribute_>simple_name @b{use}
15828   <project_>simple_name [ . <package_>simple_Name ] ' <attribute_>simple_name ;
15829
15830 attribute_designator ::=
15831   <simple_attribute_>simple_name |
15832   <associative_array_attribute_>simple_name ( string_literal )
15833 @end smallexample
15834
15835 @noindent
15836 Some attributes are project-specific, and can only appear immediately within
15837 a project declaration. Others are package-specific, and can only appear within
15838 the proper package.
15839
15840 The expression in an attribute definition must be a string or a string_list.
15841 The string literal appearing in the attribute_designator of an associative
15842 array attribute is case-insensitive.
15843
15844 @node Project Attributes
15845 @section Project Attributes
15846
15847 @noindent
15848 The following attributes apply to a project. All of them are simple
15849 attributes.
15850
15851 @table @code
15852 @item   Object_Dir
15853 Expression must be a path name. The attribute defines the
15854 directory in which the object files created by the build are to be placed. If
15855 not specified, object files are placed in the project directory.
15856
15857 @item   Exec_Dir
15858 Expression must be a path name. The attribute defines the
15859 directory in which the executables created by the build are to be placed.
15860 If not specified, executables are placed in the object directory.
15861
15862 @item  Source_Dirs
15863 Expression must be a list of path names. The attribute
15864 defines the directories in which the source files for the project are to be
15865 found. If not specified, source files are found in the project directory.
15866 If a string in the list ends with "/**", then the directory that precedes
15867 "/**" and all of its subdirectories (recursively) are included in the list
15868 of source directories.
15869
15870 @item  Excluded_Source_Dirs
15871 Expression must be a list of strings. Each entry designates a directory that
15872 is not to be included in the list of source directories of the project.
15873 This is normally used when there are strings ending with "/**" in the value
15874 of attribute Source_Dirs.
15875
15876 @item  Source_Files
15877 Expression must be a list of file names. The attribute
15878 defines the individual files, in the project directory, which are to be used
15879 as sources for the project. File names are path_names that contain no directory
15880 information. If the project has no sources the attribute must be declared
15881 explicitly with an empty list.
15882
15883 @item  Excluded_Source_Files (Locally_Removed_Files)
15884 Expression must be a list of strings that are legal file names.
15885 Each file name must designate a source that would normally be a source file
15886 in the source directories of the project or, if the project file is an
15887 extending project file, inherited by the current project file. It cannot
15888 designate an immediate source that is not inherited. Each of the source files
15889 in the list are not considered to be sources of the project file: they are not
15890 inherited. Attribute Locally_Removed_Files is obsolescent, attribute
15891 Excluded_Source_Files is preferred.
15892
15893 @item  Source_List_File
15894 Expression must a single path name. The attribute
15895 defines a text file that contains a list of source file names to be used
15896 as sources for the project
15897
15898 @item  Library_Dir
15899 Expression must be a path name. The attribute defines the
15900 directory in which a  library is to be built.  The directory must exist, must
15901 be distinct from the project's object directory, and must be writable.
15902
15903 @item  Library_Name
15904 Expression must be a string that is a legal file name,
15905 without extension. The attribute defines a string that is used to generate
15906 the name of the library to be built by the project.
15907
15908 @item  Library_Kind
15909 Argument must be a string value that must be one of the
15910 following @code{"static"}, @code{"dynamic"} or @code{"relocatable"}. This
15911 string is case-insensitive. If this attribute is not specified, the library is
15912 a static library. Otherwise, the library may be dynamic or relocatable. This
15913 distinction is operating-system dependent.
15914
15915 @item  Library_Version
15916 Expression must be a string value whose interpretation
15917 is platform dependent. On UNIX, it is used only for dynamic/relocatable
15918 libraries as the internal name of the library (the @code{"soname"}). If the
15919 library file name (built from the @code{Library_Name}) is different from the
15920 @code{Library_Version}, then the library file will be a symbolic link to the
15921 actual file whose name will be @code{Library_Version}.
15922
15923 @item Library_Interface
15924 Expression must be a string list. Each element of the string list
15925 must designate a unit of the project.
15926 If this attribute is present in a Library Project File, then the project
15927 file is a Stand-alone Library_Project_File.
15928
15929 @item Library_Auto_Init
15930 Expression must be a single string "true" or "false", case-insensitive.
15931 If this attribute is present in a Stand-alone Library Project File,
15932 it indicates if initialization is automatic when the dynamic library
15933 is loaded.
15934
15935 @item Library_Options
15936 Expression must be a string list. Indicates additional switches that
15937 are to be used when building a shared library.
15938
15939 @item Library_GCC
15940 Expression must be a single string. Designates an alternative to "gcc"
15941 for building shared libraries.
15942
15943 @item  Library_Src_Dir
15944 Expression must be a path name. The attribute defines the
15945 directory in which the sources of the interfaces of a Stand-alone Library will
15946 be copied.  The directory must exist, must be distinct from the project's
15947 object directory and source directories of all projects in the project tree,
15948 and must be writable.
15949
15950 @item  Library_Src_Dir
15951 Expression must be a path name. The attribute defines the
15952 directory in which the ALI files of a Library will
15953 be copied.  The directory must exist, must be distinct from the project's
15954 object directory and source directories of all projects in the project tree,
15955 and must be writable.
15956
15957 @item  Library_Symbol_File
15958 Expression must be a single string. Its value is the single file name of a
15959 symbol file to be created when building a stand-alone library when the
15960 symbol policy is either "compliant", "controlled" or "restricted",
15961 on platforms that support symbol control, such as VMS. When symbol policy
15962 is "direct", then a file with this name must exist in the object directory.
15963
15964 @item   Library_Reference_Symbol_File
15965 Expression must be a single string. Its value is the path name of a
15966 reference symbol file that is read when the symbol policy is either
15967 "compliant" or "controlled", on platforms that support symbol control,
15968 such as VMS, when building a stand-alone library. The path may be an absolute
15969 path or a path relative to the project directory.
15970
15971 @item  Library_Symbol_Policy
15972 Expression must be a single string. Its case-insensitive value can only be
15973 "autonomous", "default", "compliant", "controlled", "restricted" or "direct".
15974
15975 This attribute is not taken into account on all platforms. It controls the
15976 policy for exported symbols and, on some platforms (like VMS) that have the
15977 notions of major and minor IDs built in the library files, it controls
15978 the setting of these IDs.
15979
15980 "autonomous" or "default": exported symbols are not controlled.
15981
15982 "compliant": if attribute Library_Reference_Symbol_File is not defined, then
15983 it is equivalent to policy "autonomous". If there are exported symbols in
15984 the reference symbol file that are not in the object files of the interfaces,
15985 the major ID of the library is increased. If there are symbols in the
15986 object files of the interfaces that are not in the reference symbol file,
15987 these symbols are put at the end of the list in the newly created symbol file
15988 and the minor ID is increased.
15989
15990 "controlled": the attribute Library_Reference_Symbol_File must be defined.
15991 The library will fail to build if the exported symbols in the object files of
15992 the interfaces do not match exactly the symbol in the symbol file.
15993
15994 "restricted": The attribute Library_Symbol_File must be defined. The library
15995 will fail to build if there are symbols in the symbol file that are not in
15996 the exported symbols of the object files of the interfaces. Additional symbols
15997 in the object files are not added to the symbol file.
15998
15999 "direct": The attribute Library_Symbol_File must be defined and must designate
16000 an existing file in the object directory. This symbol file is passed directly
16001 to the underlying linker without any symbol processing.
16002
16003 @item  Main
16004 Expression must be a list of strings that are legal file names.
16005 These file names designate existing compilation units in the source directory
16006 that are legal main subprograms.
16007
16008 When a project file is elaborated, as part of the execution of a gnatmake
16009 command, one or several executables are built and placed in the Exec_Dir.
16010 If the gnatmake command does not include explicit file names, the executables
16011 that are built correspond to the files specified by this attribute.
16012
16013 @item  Externally_Built
16014 Expression must be a single string. Its value must be either "true" of "false",
16015 case-insensitive. The default is "false". When the value of this attribute is
16016 "true", no attempt is made to compile the sources or to build the library,
16017 when the project is a library project.
16018
16019 @item Main_Language
16020 This is a simple attribute. Its value is a string that specifies the
16021 language of the main program.
16022
16023 @item  Languages
16024 Expression must be a string list. Each string designates
16025 a programming language that is known to GNAT. The strings are case-insensitive.
16026
16027 @end table
16028
16029 @node Attribute References
16030 @section Attribute References
16031
16032 @noindent
16033 Attribute references are used to retrieve the value of previously defined
16034 attribute for a package or project.
16035 Syntax:
16036 @smallexample
16037 attribute_reference ::=
16038   attribute_prefix ' <simple_attribute_>simple_name [ ( string_literal ) ]
16039
16040 attribute_prefix ::=
16041   @b{project} |
16042   <project_simple_name | package_identifier |
16043   <project_>simple_name . package_identifier
16044 @end smallexample
16045
16046 @noindent
16047 If an attribute has not been specified for a given package or project, its
16048 value is the null string or the empty list.
16049
16050 @node External Values
16051 @section External Values
16052
16053 @noindent
16054 An external value is an expression whose value is obtained from the command
16055 that invoked the processing of the current project file (typically a
16056 gnatmake command).
16057
16058 Syntax:
16059 @smallexample
16060 external_value ::=
16061   @b{external} ( string_literal [, string_literal] )
16062 @end smallexample
16063
16064 @noindent
16065 The first string_literal is the string to be used on the command line or
16066 in the environment to specify the external value. The second string_literal,
16067 if present, is the default to use if there is no specification for this
16068 external value either on the command line or in the environment.
16069
16070 @node Case Construction
16071 @section Case Construction
16072
16073 @noindent
16074 A case construction supports attribute and variable declarations that depend
16075 on the value of a previously declared variable.
16076
16077 Syntax:
16078 @smallexample
16079 case_construction ::=
16080   @b{case} <typed_variable_>name @b{is}
16081     @{case_item@}
16082   @b{end case} ;
16083
16084 case_item ::=
16085   @b{when} discrete_choice_list =>
16086     @{case_construction |
16087       attribute_declaration |
16088       variable_declaration |
16089       empty_declaration@}
16090
16091 discrete_choice_list ::=
16092   string_literal @{| string_literal@} |
16093     @b{others}
16094 @end smallexample
16095
16096 @noindent
16097 Inside a case construction, variable declarations must be for variables that
16098 have already been declared before the case construction.
16099
16100 All choices in a choice list must be distinct. The choice lists of two
16101 distinct alternatives must be disjoint. Unlike Ada, the choice lists of all
16102 alternatives do not need to include all values of the type. An @code{others}
16103 choice must appear last in the list of alternatives.
16104
16105 @node Packages
16106 @section Packages
16107
16108 @noindent
16109 A package provides a grouping of variable declarations and attribute
16110 declarations to be used when invoking various GNAT tools. The name of
16111 the package indicates the tool(s) to which it applies.
16112 Syntax:
16113
16114 @smallexample
16115 package_declaration ::=
16116   package_spec | package_renaming
16117
16118 package_spec ::=
16119   @b{package} package_identifier @b{is}
16120     @{simple_declarative_item@}
16121   @b{end} package_identifier ;
16122
16123 package_identifier ::=
16124   @code{Naming} | @code{Builder} | @code{Compiler} | @code{Binder} |
16125   @code{Linker} | @code{Finder}  | @code{Cross_Reference} |
16126   @code{gnatls} | @code{IDE}     | @code{Pretty_Printer}
16127 @end smallexample
16128
16129 @subsection Package Naming
16130
16131 @noindent
16132 The attributes of a @code{Naming} package specifies the naming conventions
16133 that apply to the source files in a project. When invoking other GNAT tools,
16134 they will use the sources in the source directories that satisfy these
16135 naming conventions.
16136
16137 The following attributes apply to a @code{Naming} package:
16138
16139 @table @code
16140 @item Casing
16141 This is a simple attribute whose value is a string. Legal values of this
16142 string are @code{"lowercase"}, @code{"uppercase"} or @code{"mixedcase"}.
16143 These strings are themselves case insensitive.
16144
16145 @noindent
16146 If @code{Casing} is not specified, then the default is @code{"lowercase"}.
16147
16148 @item Dot_Replacement
16149 This is a simple attribute whose string value satisfies the following
16150 requirements:
16151
16152 @itemize @bullet
16153 @item It must not be empty
16154 @item It cannot start or end with an alphanumeric character
16155 @item It cannot be a single underscore
16156 @item It cannot start with an underscore followed by an alphanumeric
16157 @item It cannot contain a dot @code{'.'} if longer than one character
16158 @end itemize
16159
16160 @noindent
16161 If @code{Dot_Replacement} is not specified, then the default is @code{"-"}.
16162
16163 @item Spec_Suffix
16164 This is an associative array attribute, defined on language names,
16165 whose image is a string that must satisfy the following
16166 conditions:
16167
16168 @itemize @bullet
16169 @item It must not be empty
16170 @item It cannot start with an alphanumeric character
16171 @item It cannot start with an underscore followed by an alphanumeric character
16172 @end itemize
16173
16174 @noindent
16175 For Ada, the attribute denotes the suffix used in file names that contain
16176 library unit declarations, that is to say units that are package and
16177 subprogram declarations. If @code{Spec_Suffix ("Ada")} is not
16178 specified, then the default is @code{".ads"}.
16179
16180 For C and C++, the attribute denotes the suffix used in file names that
16181 contain prototypes.
16182
16183 @item Body_Suffix
16184 This is an associative array attribute defined on language names,
16185 whose image is a string that must satisfy the following
16186 conditions:
16187
16188 @itemize @bullet
16189 @item It must not be empty
16190 @item It cannot start with an alphanumeric character
16191 @item It cannot start with an underscore followed by an alphanumeric character
16192 @item It cannot be a suffix of @code{Spec_Suffix}
16193 @end itemize
16194
16195 @noindent
16196 For Ada, the attribute denotes the suffix used in file names that contain
16197 library bodies, that is to say units that are package and subprogram bodies.
16198 If @code{Body_Suffix ("Ada")} is not specified, then the default is
16199 @code{".adb"}.
16200
16201 For C and C++, the attribute denotes the suffix used in file names that contain
16202 source code.
16203
16204 @item Separate_Suffix
16205 This is a simple attribute whose value satisfies the same conditions as
16206 @code{Body_Suffix}.
16207
16208 This attribute is specific to Ada. It denotes the suffix used in file names
16209 that contain separate bodies. If it is not specified, then it defaults to same
16210 value as @code{Body_Suffix ("Ada")}.
16211
16212 @item Spec
16213 This is an associative array attribute, specific to Ada, defined over
16214 compilation unit names. The image is a string that is the name of the file
16215 that contains that library unit. The file name is case sensitive if the
16216 conventions of the host operating system require it.
16217
16218 @item Body
16219 This is an associative array attribute, specific to Ada, defined over
16220 compilation unit names. The image is a string that is the name of the file
16221 that contains the library unit body for the named unit. The file name is case
16222 sensitive if the conventions of the host operating system require it.
16223
16224 @item Specification_Exceptions
16225 This is an associative array attribute defined on language names,
16226 whose value is a list of strings.
16227
16228 This attribute is not significant for Ada.
16229
16230 For C and C++, each string in the list denotes the name of a file that
16231 contains prototypes, but whose suffix is not necessarily the
16232 @code{Spec_Suffix} for the language.
16233
16234 @item Implementation_Exceptions
16235 This is an associative array attribute defined on language names,
16236 whose value is a list of strings.
16237
16238 This attribute is not significant for Ada.
16239
16240 For C and C++, each string in the list denotes the name of a file that
16241 contains source code, but whose suffix is not necessarily the
16242 @code{Body_Suffix} for the language.
16243 @end table
16244
16245 The following attributes of package @code{Naming} are obsolescent. They are
16246 kept as synonyms of other attributes for compatibility with previous versions
16247 of the Project Manager.
16248
16249 @table @code
16250 @item Specification_Suffix
16251 This is a synonym of @code{Spec_Suffix}.
16252
16253 @item Implementation_Suffix
16254 This is a synonym of @code{Body_Suffix}.
16255
16256 @item Specification
16257 This is a synonym of @code{Spec}.
16258
16259 @item Implementation
16260 This is a synonym of @code{Body}.
16261 @end table
16262
16263 @subsection package Compiler
16264
16265 @noindent
16266 The attributes of the @code{Compiler} package specify the compilation options
16267 to be used by the underlying compiler.
16268
16269 @table @code
16270 @item  Default_Switches
16271 This is an associative array attribute. Its
16272 domain is a set of language names. Its range is a string list that
16273 specifies the compilation options to be used when compiling a component
16274 written in that language, for which no file-specific switches have been
16275 specified.
16276
16277 @item  Switches
16278 This is an associative array attribute. Its domain is
16279 a set of file names. Its range is a string list that specifies the
16280 compilation options to be used when compiling the named file. If a file
16281 is not specified in the Switches attribute, it is compiled with the
16282 options specified by Default_Switches of its language, if defined.
16283
16284 @item  Local_Configuration_Pragmas.
16285 This is a simple attribute, whose
16286 value is a path name that designates a file containing configuration pragmas
16287 to be used for all invocations of the compiler for immediate sources of the
16288 project.
16289 @end table
16290
16291 @subsection package Builder
16292
16293 @noindent
16294 The attributes of package @code{Builder} specify the compilation, binding, and
16295 linking options to be used when building an executable for a project. The
16296 following attributes apply to package @code{Builder}:
16297
16298 @table @code
16299 @item Default_Switches
16300 This is an associative array attribute. Its
16301 domain is a set of language names. Its range is a string list that
16302 specifies options to be used when building a main
16303 written in that language, for which no file-specific switches have been
16304 specified.
16305
16306 @item Switches
16307 This is an associative array attribute. Its domain is
16308 a set of file names. Its range is a string list that specifies
16309 options to be used when building the named main file. If a main file
16310 is not specified in the Switches attribute, it is built with the
16311 options specified by Default_Switches of its language, if defined.
16312
16313 @item Global_Configuration_Pragmas
16314 This is a simple attribute, whose
16315 value is a path name that designates a file that contains configuration pragmas
16316 to be used in every build of an executable. If both local and global
16317 configuration pragmas are specified, a compilation makes use of both sets.
16318
16319
16320 @item Executable
16321 This is an associative array attribute. Its domain is
16322 a set of main source file names. Its range is a simple string that specifies
16323 the executable file name to be used when linking the specified main source.
16324 If a main source is not specified in the Executable attribute, the executable
16325 file name is deducted from the main source file name.
16326 This attribute has no effect if its value is the empty string.
16327
16328 @item Executable_Suffix
16329 This is a simple attribute whose value is the suffix to be added to
16330 the executables that don't have an attribute Executable specified.
16331 @end table
16332
16333 @subsection package Gnatls
16334
16335 @noindent
16336 The attributes of package @code{Gnatls} specify the tool options to be used
16337 when invoking the library browser @command{gnatls}.
16338 The following attributes apply to package @code{Gnatls}:
16339
16340 @table @code
16341 @item Switches
16342 This is a single attribute with a string list value. Each nonempty string
16343 in the list is an option when invoking @code{gnatls}.
16344 @end table
16345
16346 @subsection package Binder
16347
16348 @noindent
16349 The attributes of package @code{Binder} specify the options to be used
16350 when invoking the binder in the construction of an executable.
16351 The following attributes apply to package @code{Binder}:
16352
16353 @table @code
16354 @item     Default_Switches
16355 This is an associative array attribute. Its
16356 domain is a set of language names. Its range is a string list that
16357 specifies options to be used when binding a main
16358 written in that language, for which no file-specific switches have been
16359 specified.
16360
16361 @item Switches
16362 This is an associative array attribute. Its domain is
16363 a set of file names. Its range is a string list that specifies
16364 options to be used when binding the named main file. If a main file
16365 is not specified in the Switches attribute, it is bound with the
16366 options specified by Default_Switches of its language, if defined.
16367 @end table
16368
16369 @subsection package Linker
16370
16371 @noindent
16372 The attributes of package @code{Linker} specify the options to be used when
16373 invoking the linker in the construction of an executable.
16374 The following attributes apply to package @code{Linker}:
16375
16376 @table @code
16377 @item     Default_Switches
16378 This is an associative array attribute. Its
16379 domain is a set of language names. Its range is a string list that
16380 specifies options to be used when linking a main
16381 written in that language, for which no file-specific switches have been
16382 specified.
16383
16384 @item Switches
16385 This is an associative array attribute. Its domain is
16386 a set of file names. Its range is a string list that specifies
16387 options to be used when linking the named main file. If a main file
16388 is not specified in the Switches attribute, it is linked with the
16389 options specified by Default_Switches of its language, if defined.
16390
16391 @item  Linker_Options
16392 This is a string list attribute. Its value specifies additional options that
16393 be given to the linker when linking an executable. This attribute is not
16394 used in the main project, only in projects imported directly or indirectly.
16395
16396 @end table
16397
16398 @subsection package Cross_Reference
16399
16400 @noindent
16401 The attributes of package @code{Cross_Reference} specify the tool options
16402 to be used
16403 when invoking the library tool @command{gnatxref}.
16404 The following attributes apply to package @code{Cross_Reference}:
16405
16406 @table @code
16407 @item     Default_Switches
16408 This is an associative array attribute. Its
16409 domain is a set of language names. Its range is a string list that
16410 specifies options to be used when calling @command{gnatxref} on a source
16411 written in that language, for which no file-specific switches have been
16412 specified.
16413
16414 @item Switches
16415 This is an associative array attribute. Its domain is
16416 a set of file names. Its range is a string list that specifies
16417 options to be used when calling @command{gnatxref} on the named main source.
16418 If a source is not specified in the Switches attribute, @command{gnatxref} will
16419 be called with the options specified by Default_Switches of its language,
16420 if defined.
16421 @end table
16422
16423 @subsection package   Finder
16424
16425 @noindent
16426 The attributes of package @code{Finder} specify the tool options to be used
16427 when invoking the search tool @command{gnatfind}.
16428 The following attributes apply to package @code{Finder}:
16429
16430 @table @code
16431 @item     Default_Switches
16432 This is an associative array attribute. Its
16433 domain is a set of language names. Its range is a string list that
16434 specifies options to be used when calling @command{gnatfind} on a source
16435 written in that language, for which no file-specific switches have been
16436 specified.
16437
16438 @item Switches
16439 This is an associative array attribute. Its domain is
16440 a set of file names. Its range is a string list that specifies
16441 options to be used when calling @command{gnatfind} on the named main source.
16442 If a source is not specified in the Switches attribute, @command{gnatfind} will
16443 be called with the options specified by Default_Switches of its language,
16444 if defined.
16445 @end table
16446
16447 @subsection package Pretty_Printer
16448
16449 @noindent
16450 The attributes of package @code{Pretty_Printer}
16451 specify the tool options to be used
16452 when invoking the formatting tool @command{gnatpp}.
16453 The following attributes apply to package @code{Pretty_Printer}:
16454
16455 @table @code
16456 @item     Default_switches
16457 This is an associative array attribute. Its
16458 domain is a set of language names. Its range is a string list that
16459 specifies options to be used when calling @command{gnatpp} on a source
16460 written in that language, for which no file-specific switches have been
16461 specified.
16462
16463 @item Switches
16464 This is an associative array attribute. Its domain is
16465 a set of file names. Its range is a string list that specifies
16466 options to be used when calling @command{gnatpp} on the named main source.
16467 If a source is not specified in the Switches attribute, @command{gnatpp} will
16468 be called with the options specified by Default_Switches of its language,
16469 if defined.
16470 @end table
16471
16472 @subsection package gnatstub
16473
16474 @noindent
16475 The attributes of package @code{gnatstub}
16476 specify the tool options to be used
16477 when invoking the tool @command{gnatstub}.
16478 The following attributes apply to package @code{gnatstub}:
16479
16480 @table @code
16481 @item     Default_switches
16482 This is an associative array attribute. Its
16483 domain is a set of language names. Its range is a string list that
16484 specifies options to be used when calling @command{gnatstub} on a source
16485 written in that language, for which no file-specific switches have been
16486 specified.
16487
16488 @item Switches
16489 This is an associative array attribute. Its domain is
16490 a set of file names. Its range is a string list that specifies
16491 options to be used when calling @command{gnatstub} on the named main source.
16492 If a source is not specified in the Switches attribute, @command{gnatpp} will
16493 be called with the options specified by Default_Switches of its language,
16494 if defined.
16495 @end table
16496
16497 @subsection package Eliminate
16498
16499 @noindent
16500 The attributes of package @code{Eliminate}
16501 specify the tool options to be used
16502 when invoking the tool @command{gnatelim}.
16503 The following attributes apply to package @code{Eliminate}:
16504
16505 @table @code
16506 @item     Default_switches
16507 This is an associative array attribute. Its
16508 domain is a set of language names. Its range is a string list that
16509 specifies options to be used when calling @command{gnatelim} on a source
16510 written in that language, for which no file-specific switches have been
16511 specified.
16512
16513 @item Switches
16514 This is an associative array attribute. Its domain is
16515 a set of file names. Its range is a string list that specifies
16516 options to be used when calling @command{gnatelim} on the named main source.
16517 If a source is not specified in the Switches attribute, @command{gnatelim} will
16518 be called with the options specified by Default_Switches of its language,
16519 if defined.
16520 @end table
16521
16522 @subsection package Metrics
16523
16524 @noindent
16525 The attributes of package @code{Metrics}
16526 specify the tool options to be used
16527 when invoking the tool @command{gnatmetric}.
16528 The following attributes apply to package @code{Metrics}:
16529
16530 @table @code
16531 @item     Default_switches
16532 This is an associative array attribute. Its
16533 domain is a set of language names. Its range is a string list that
16534 specifies options to be used when calling @command{gnatmetric} on a source
16535 written in that language, for which no file-specific switches have been
16536 specified.
16537
16538 @item Switches
16539 This is an associative array attribute. Its domain is
16540 a set of file names. Its range is a string list that specifies
16541 options to be used when calling @command{gnatmetric} on the named main source.
16542 If a source is not specified in the Switches attribute, @command{gnatmetric}
16543 will be called with the options specified by Default_Switches of its language,
16544 if defined.
16545 @end table
16546
16547 @subsection  package IDE
16548
16549 @noindent
16550 The attributes of package @code{IDE} specify the options to be used when using
16551 an Integrated Development Environment such as @command{GPS}.
16552
16553 @table @code
16554 @item Remote_Host
16555 This is a simple attribute. Its value is a string that designates the remote
16556 host in a cross-compilation environment, to be used for remote compilation and
16557 debugging. This field should not be specified when running on the local
16558 machine.
16559
16560 @item Program_Host
16561 This is a simple attribute. Its value is a string that specifies the
16562 name of IP address of the embedded target in a cross-compilation environment,
16563 on which the program should execute.
16564
16565 @item Communication_Protocol
16566 This is a simple string attribute. Its value is the name of the protocol
16567 to use to communicate with the target in a cross-compilation environment,
16568 e.g.@: @code{"wtx"} or @code{"vxworks"}.
16569
16570 @item Compiler_Command
16571 This is an associative array attribute, whose domain is a language name. Its
16572 value is  string that denotes the command to be used to invoke the compiler.
16573 The value of @code{Compiler_Command ("Ada")} is expected to be compatible with
16574 gnatmake, in particular in the handling of switches.
16575
16576 @item Debugger_Command
16577 This is simple attribute, Its value is a string that specifies the name of
16578 the debugger to be used, such as gdb, powerpc-wrs-vxworks-gdb or gdb-4.
16579
16580 @item Default_Switches
16581 This is an associative array attribute. Its indexes are the name of the
16582 external tools that the GNAT Programming System (GPS) is supporting. Its
16583 value is a list of switches to use when invoking that tool.
16584
16585 @item  Gnatlist
16586 This is a simple attribute.  Its value is a string that specifies the name
16587 of the @command{gnatls} utility to be used to retrieve information about the
16588 predefined path; e.g., @code{"gnatls"}, @code{"powerpc-wrs-vxworks-gnatls"}.
16589
16590 @item VCS_Kind
16591 This is a simple attribute. Its value is a string used to specify the
16592 Version Control System (VCS) to be used for this project, e.g.@: CVS, RCS
16593 ClearCase or Perforce.
16594
16595 @item VCS_File_Check
16596 This is a simple attribute. Its value is a string that specifies the
16597 command used by the VCS to check the validity of a file, either
16598 when the user explicitly asks for a check, or as a sanity check before
16599 doing the check-in.
16600
16601 @item VCS_Log_Check
16602 This is a simple attribute. Its value is a string that specifies
16603 the command used by the VCS to check the validity of a log file.
16604
16605 @item VCS_Repository_Root
16606 The VCS repository root path. This is used to create tags or branches
16607 of the repository. For subversion the value should be the @code{URL}
16608 as specified to check-out the working copy of the repository.
16609
16610 @item VCS_Patch_Root
16611 The local root directory to use for building patch file. All patch chunks
16612 will be relative to this path. The root project directory is used if
16613 this value is not defined.
16614
16615 @end table
16616
16617 @node Package Renamings
16618 @section Package Renamings
16619
16620 @noindent
16621 A package can be defined by a renaming declaration. The new package renames
16622 a package declared in a different project file, and has the same attributes
16623 as the package it renames.
16624 Syntax:
16625 @smallexample
16626 package_renaming ::==
16627   @b{package} package_identifier @b{renames}
16628        <project_>simple_name.package_identifier ;
16629 @end smallexample
16630
16631 @noindent
16632 The package_identifier of the renamed package must be the same as the
16633 package_identifier. The project whose name is the prefix of the renamed
16634 package must contain a package declaration with this name. This project
16635 must appear in the context_clause of the enclosing project declaration,
16636 or be the parent project of the enclosing child project.
16637
16638 @node Projects
16639 @section Projects
16640
16641 @noindent
16642 A project file specifies a set of rules for constructing a software system.
16643 A project file can be self-contained, or depend on other project files.
16644 Dependencies are expressed through a context clause that names other projects.
16645
16646 Syntax:
16647
16648 @smallexample
16649 project ::=
16650   context_clause project_declaration
16651
16652 project_declaration ::=
16653   simple_project_declaration | project_extension
16654
16655 simple_project_declaration ::=
16656   @b{project} <project_>simple_name @b{is}
16657     @{declarative_item@}
16658   @b{end} <project_>simple_name;
16659
16660 context_clause ::=
16661   @{with_clause@}
16662
16663 with_clause ::=
16664   [@b{limited}] @b{with} path_name @{ , path_name @} ;
16665
16666 path_name ::=
16667    string_literal
16668 @end smallexample
16669
16670 @noindent
16671 A path name denotes a project file. A path name can be absolute or relative.
16672 An absolute path name includes a sequence of directories, in the syntax of
16673 the host operating system, that identifies uniquely the project file in the
16674 file system. A relative path name identifies the project file, relative
16675 to the directory that contains the current project, or relative to a
16676 directory listed in the environment variable ADA_PROJECT_PATH.
16677 Path names are case sensitive if file names in the host operating system
16678 are case sensitive.
16679
16680 The syntax of the environment variable ADA_PROJECT_PATH is a list of
16681 directory names separated by colons (semicolons on Windows).
16682
16683 A given project name can appear only once in a context_clause.
16684
16685 It is illegal for a project imported by a context clause to refer, directly
16686 or indirectly, to the project in which this context clause appears (the
16687 dependency graph cannot contain cycles), except when one of the with_clause
16688 in the cycle is a @code{limited with}.
16689
16690 @node Project Extensions
16691 @section Project Extensions
16692
16693 @noindent
16694 A project extension introduces a new project, which inherits the declarations
16695 of another project.
16696 Syntax:
16697 @smallexample
16698
16699 project_extension ::=
16700   @b{project} <project_>simple_name  @b{extends} path_name @b{is}
16701     @{declarative_item@}
16702   @b{end} <project_>simple_name;
16703 @end smallexample
16704
16705 @noindent
16706 The project extension declares a child project. The child project inherits
16707 all the declarations and all the files of the parent project, These inherited
16708 declaration can be overridden in the child project, by means of suitable
16709 declarations.
16710
16711 @node Project File Elaboration
16712 @section Project File Elaboration
16713
16714 @noindent
16715 A project file is processed as part of the invocation of a gnat tool that
16716 uses the project option. Elaboration of the process file consists in the
16717 sequential elaboration of all its declarations. The computed values of
16718 attributes and variables in the project are then used to establish the
16719 environment in which the gnat tool will execute.
16720
16721 @node Obsolescent Features
16722 @chapter Obsolescent Features
16723
16724 @noindent
16725 This chapter describes features that are provided by GNAT, but are
16726 considered obsolescent since there are preferred ways of achieving
16727 the same effect. These features are provided solely for historical
16728 compatibility purposes.
16729
16730 @menu
16731 * pragma No_Run_Time::
16732 * pragma Ravenscar::
16733 * pragma Restricted_Run_Time::
16734 @end menu
16735
16736 @node pragma No_Run_Time
16737 @section pragma No_Run_Time
16738
16739 The pragma @code{No_Run_Time} is used to achieve an affect similar
16740 to the use of the "Zero Foot Print" configurable run time, but without
16741 requiring a specially configured run time. The result of using this
16742 pragma, which must be used for all units in a partition, is to restrict
16743 the use of any language features requiring run-time support code. The
16744 preferred usage is to use an appropriately configured run-time that
16745 includes just those features that are to be made accessible.
16746
16747 @node pragma Ravenscar
16748 @section pragma Ravenscar
16749
16750 The pragma @code{Ravenscar} has exactly the same effect as pragma
16751 @code{Profile (Ravenscar)}. The latter usage is preferred since it
16752 is part of the new Ada 2005 standard.
16753
16754 @node pragma Restricted_Run_Time
16755 @section pragma Restricted_Run_Time
16756
16757 The pragma @code{Restricted_Run_Time} has exactly the same effect as
16758 pragma @code{Profile (Restricted)}. The latter usage is
16759 preferred since the Ada 2005 pragma @code{Profile} is intended for
16760 this kind of implementation dependent addition.
16761
16762 @include fdl.texi
16763 @c GNU Free Documentation License
16764
16765 @node Index,,GNU Free Documentation License, Top
16766 @unnumbered Index
16767
16768 @printindex cp
16769
16770 @contents
16771
16772 @bye