OSDN Git Service

2f09ddcc7ae50c47a642192db8200bdecac5703c
[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 Assume_No_Invalid_Values::
106 * Pragma Ast_Entry::
107 * Pragma C_Pass_By_Copy::
108 * Pragma Check::
109 * Pragma Check_Name::
110 * Pragma Check_Policy::
111 * Pragma Comment::
112 * Pragma Common_Object::
113 * Pragma Compile_Time_Error::
114 * Pragma Compile_Time_Warning::
115 * Pragma Compiler_Unit::
116 * Pragma Complete_Representation::
117 * Pragma Complex_Representation::
118 * Pragma Component_Alignment::
119 * Pragma Convention_Identifier::
120 * Pragma CPP_Class::
121 * Pragma CPP_Constructor::
122 * Pragma CPP_Virtual::
123 * Pragma CPP_Vtable::
124 * Pragma Debug::
125 * Pragma Debug_Policy::
126 * Pragma Detect_Blocking::
127 * Pragma Elaboration_Checks::
128 * Pragma Eliminate::
129 * Pragma Export_Exception::
130 * Pragma Export_Function::
131 * Pragma Export_Object::
132 * Pragma Export_Procedure::
133 * Pragma Export_Value::
134 * Pragma Export_Valued_Procedure::
135 * Pragma Extend_System::
136 * Pragma External::
137 * Pragma External_Name_Casing::
138 * Pragma Fast_Math::
139 * Pragma Favor_Top_Level::
140 * Pragma Finalize_Storage_Only::
141 * Pragma Float_Representation::
142 * Pragma Ident::
143 * Pragma Implemented_By_Entry::
144 * Pragma Implicit_Packing::
145 * Pragma Import_Exception::
146 * Pragma Import_Function::
147 * Pragma Import_Object::
148 * Pragma Import_Procedure::
149 * Pragma Import_Valued_Procedure::
150 * Pragma Initialize_Scalars::
151 * Pragma Inline_Always::
152 * Pragma Inline_Generic::
153 * Pragma Interface::
154 * Pragma Interface_Name::
155 * Pragma Interrupt_Handler::
156 * Pragma Interrupt_State::
157 * Pragma Keep_Names::
158 * Pragma License::
159 * Pragma Link_With::
160 * Pragma Linker_Alias::
161 * Pragma Linker_Constructor::
162 * Pragma Linker_Destructor::
163 * Pragma Linker_Section::
164 * Pragma Long_Float::
165 * Pragma Machine_Attribute::
166 * Pragma Main::
167 * Pragma Main_Storage::
168 * Pragma No_Body::
169 * Pragma No_Return::
170 * Pragma No_Strict_Aliasing ::
171 * Pragma Normalize_Scalars::
172 * Pragma Obsolescent::
173 * Pragma Optimize_Alignment::
174 * Pragma Passive::
175 * Pragma Persistent_BSS::
176 * Pragma Polling::
177 * Pragma Postcondition::
178 * Pragma Precondition::
179 * Pragma Profile (Ravenscar)::
180 * Pragma Profile (Restricted)::
181 * Pragma Psect_Object::
182 * Pragma Pure_Function::
183 * Pragma Restriction_Warnings::
184 * Pragma Shared::
185 * Pragma Short_Circuit_And_Or::
186 * Pragma Source_File_Name::
187 * Pragma Source_File_Name_Project::
188 * Pragma Source_Reference::
189 * Pragma Stream_Convert::
190 * Pragma Style_Checks::
191 * Pragma Subtitle::
192 * Pragma Suppress::
193 * Pragma Suppress_All::
194 * Pragma Suppress_Exception_Locations::
195 * Pragma Suppress_Initialization::
196 * Pragma Task_Info::
197 * Pragma Task_Name::
198 * Pragma Task_Storage::
199 * Pragma Thread_Local_Storage::
200 * Pragma Time_Slice::
201 * Pragma Title::
202 * Pragma Unchecked_Union::
203 * Pragma Unimplemented_Unit::
204 * Pragma Universal_Aliasing ::
205 * Pragma Universal_Data::
206 * Pragma Unmodified::
207 * Pragma Unreferenced::
208 * Pragma Unreferenced_Objects::
209 * Pragma Unreserve_All_Interrupts::
210 * Pragma Unsuppress::
211 * Pragma Use_VADS_Size::
212 * Pragma Validity_Checks::
213 * Pragma Volatile::
214 * Pragma Warnings::
215 * Pragma Weak_External::
216 * Pragma Wide_Character_Encoding::
217
218 Implementation Defined Attributes
219
220 * Abort_Signal::
221 * Address_Size::
222 * Asm_Input::
223 * Asm_Output::
224 * AST_Entry::
225 * Bit::
226 * Bit_Position::
227 * Compiler_Version::
228 * Code_Address::
229 * Default_Bit_Order::
230 * Elaborated::
231 * Elab_Body::
232 * Elab_Spec::
233 * Emax::
234 * Enabled::
235 * Enum_Rep::
236 * Enum_Val::
237 * Epsilon::
238 * Fixed_Value::
239 * Has_Access_Values::
240 * Has_Discriminants::
241 * Img::
242 * Integer_Value::
243 * Invalid_Value::
244 * Large::
245 * Machine_Size::
246 * Mantissa::
247 * Max_Interrupt_Priority::
248 * Max_Priority::
249 * Maximum_Alignment::
250 * Mechanism_Code::
251 * Null_Parameter::
252 * Object_Size::
253 * Old::
254 * Passed_By_Reference::
255 * Pool_Address::
256 * Range_Length::
257 * Result::
258 * Safe_Emax::
259 * Safe_Large::
260 * Small::
261 * Storage_Unit::
262 * Stub_Type::
263 * Target_Name::
264 * Tick::
265 * To_Address::
266 * Type_Class::
267 * UET_Address::
268 * Unconstrained_Array::
269 * Universal_Literal_String::
270 * Unrestricted_Access::
271 * VADS_Size::
272 * Value_Size::
273 * Wchar_T_Size::
274 * Word_Size::
275
276 The Implementation of Standard I/O
277
278 * Standard I/O Packages::
279 * FORM Strings::
280 * Direct_IO::
281 * Sequential_IO::
282 * Text_IO::
283 * Wide_Text_IO::
284 * Wide_Wide_Text_IO::
285 * Stream_IO::
286 * Text Translation::
287 * Shared Files::
288 * Filenames encoding::
289 * Open Modes::
290 * Operations on C Streams::
291 * Interfacing to C Streams::
292
293 The GNAT Library
294
295 * Ada.Characters.Latin_9 (a-chlat9.ads)::
296 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
297 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
298 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
299 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
300 * Ada.Command_Line.Environment (a-colien.ads)::
301 * Ada.Command_Line.Remove (a-colire.ads)::
302 * Ada.Command_Line.Response_File (a-clrefi.ads)::
303 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
304 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
305 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
306 * Ada.Exceptions.Traceback (a-exctra.ads)::
307 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
308 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
309 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
310 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
311 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
312 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
313 * Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)::
314 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
315 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
316 * Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)::
317 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
318 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
319 * Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)::
320 * GNAT.Altivec (g-altive.ads)::
321 * GNAT.Altivec.Conversions (g-altcon.ads)::
322 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
323 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
324 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
325 * GNAT.Array_Split (g-arrspl.ads)::
326 * GNAT.AWK (g-awk.ads)::
327 * GNAT.Bounded_Buffers (g-boubuf.ads)::
328 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
329 * GNAT.Bubble_Sort (g-bubsor.ads)::
330 * GNAT.Bubble_Sort_A (g-busora.ads)::
331 * GNAT.Bubble_Sort_G (g-busorg.ads)::
332 * GNAT.Byte_Order_Mark (g-byorma.ads)::
333 * GNAT.Byte_Swapping (g-bytswa.ads)::
334 * GNAT.Calendar (g-calend.ads)::
335 * GNAT.Calendar.Time_IO (g-catiio.ads)::
336 * GNAT.Case_Util (g-casuti.ads)::
337 * GNAT.CGI (g-cgi.ads)::
338 * GNAT.CGI.Cookie (g-cgicoo.ads)::
339 * GNAT.CGI.Debug (g-cgideb.ads)::
340 * GNAT.Command_Line (g-comlin.ads)::
341 * GNAT.Compiler_Version (g-comver.ads)::
342 * GNAT.Ctrl_C (g-ctrl_c.ads)::
343 * GNAT.CRC32 (g-crc32.ads)::
344 * GNAT.Current_Exception (g-curexc.ads)::
345 * GNAT.Debug_Pools (g-debpoo.ads)::
346 * GNAT.Debug_Utilities (g-debuti.ads)::
347 * GNAT.Decode_String (g-decstr.ads)::
348 * GNAT.Decode_UTF8_String (g-deutst.ads)::
349 * GNAT.Directory_Operations (g-dirope.ads)::
350 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
351 * GNAT.Dynamic_HTables (g-dynhta.ads)::
352 * GNAT.Dynamic_Tables (g-dyntab.ads)::
353 * GNAT.Encode_String (g-encstr.ads)::
354 * GNAT.Encode_UTF8_String (g-enutst.ads)::
355 * GNAT.Exception_Actions (g-excact.ads)::
356 * GNAT.Exception_Traces (g-exctra.ads)::
357 * GNAT.Exceptions (g-except.ads)::
358 * GNAT.Expect (g-expect.ads)::
359 * GNAT.Float_Control (g-flocon.ads)::
360 * GNAT.Heap_Sort (g-heasor.ads)::
361 * GNAT.Heap_Sort_A (g-hesora.ads)::
362 * GNAT.Heap_Sort_G (g-hesorg.ads)::
363 * GNAT.HTable (g-htable.ads)::
364 * GNAT.IO (g-io.ads)::
365 * GNAT.IO_Aux (g-io_aux.ads)::
366 * GNAT.Lock_Files (g-locfil.ads)::
367 * GNAT.MD5 (g-md5.ads)::
368 * GNAT.Memory_Dump (g-memdum.ads)::
369 * GNAT.Most_Recent_Exception (g-moreex.ads)::
370 * GNAT.OS_Lib (g-os_lib.ads)::
371 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
372 * GNAT.Random_Numbers (g-rannum.ads)::
373 * GNAT.Regexp (g-regexp.ads)::
374 * GNAT.Registry (g-regist.ads)::
375 * GNAT.Regpat (g-regpat.ads)::
376 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
377 * GNAT.Semaphores (g-semaph.ads)::
378 * GNAT.Serial_Communications (g-sercom.ads)::
379 * GNAT.SHA1 (g-sha1.ads)::
380 * GNAT.Signals (g-signal.ads)::
381 * GNAT.Sockets (g-socket.ads)::
382 * GNAT.Source_Info (g-souinf.ads)::
383 * GNAT.Spelling_Checker (g-speche.ads)::
384 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
385 * GNAT.Spitbol.Patterns (g-spipat.ads)::
386 * GNAT.Spitbol (g-spitbo.ads)::
387 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
388 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
389 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
390 * GNAT.SSE (g-sse.ads)::
391 * GNAT.SSE.Vector_Types (g-ssvety.ads)::
392 * GNAT.Strings (g-string.ads)::
393 * GNAT.String_Split (g-strspl.ads)::
394 * GNAT.Table (g-table.ads)::
395 * GNAT.Task_Lock (g-tasloc.ads)::
396 * GNAT.Threads (g-thread.ads)::
397 * GNAT.Time_Stamp (g-timsta.ads)::
398 * GNAT.Traceback (g-traceb.ads)::
399 * GNAT.Traceback.Symbolic (g-trasym.ads)::
400 * GNAT.UTF_32 (g-utf_32.ads)::
401 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
402 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
403 * GNAT.Wide_String_Split (g-wistsp.ads)::
404 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
405 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
406 * Interfaces.C.Extensions (i-cexten.ads)::
407 * Interfaces.C.Streams (i-cstrea.ads)::
408 * Interfaces.CPP (i-cpp.ads)::
409 * Interfaces.Packed_Decimal (i-pacdec.ads)::
410 * Interfaces.VxWorks (i-vxwork.ads)::
411 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
412 * System.Address_Image (s-addima.ads)::
413 * System.Assertions (s-assert.ads)::
414 * System.Memory (s-memory.ads)::
415 * System.Partition_Interface (s-parint.ads)::
416 * System.Pool_Global (s-pooglo.ads)::
417 * System.Pool_Local (s-pooloc.ads)::
418 * System.Restrictions (s-restri.ads)::
419 * System.Rident (s-rident.ads)::
420 * System.Strings.Stream_Ops (s-ststop.ads)::
421 * System.Task_Info (s-tasinf.ads)::
422 * System.Wch_Cnv (s-wchcnv.ads)::
423 * System.Wch_Con (s-wchcon.ads)::
424
425 Text_IO
426
427 * Text_IO Stream Pointer Positioning::
428 * Text_IO Reading and Writing Non-Regular Files::
429 * Get_Immediate::
430 * Treating Text_IO Files as Streams::
431 * Text_IO Extensions::
432 * Text_IO Facilities for Unbounded Strings::
433
434 Wide_Text_IO
435
436 * Wide_Text_IO Stream Pointer Positioning::
437 * Wide_Text_IO Reading and Writing Non-Regular Files::
438
439 Wide_Wide_Text_IO
440
441 * Wide_Wide_Text_IO Stream Pointer Positioning::
442 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
443
444 Interfacing to Other Languages
445
446 * Interfacing to C::
447 * Interfacing to C++::
448 * Interfacing to COBOL::
449 * Interfacing to Fortran::
450 * Interfacing to non-GNAT Ada code::
451
452 Specialized Needs Annexes
453
454 Implementation of Specific Ada Features
455 * Machine Code Insertions::
456 * GNAT Implementation of Tasking::
457 * GNAT Implementation of Shared Passive Packages::
458 * Code Generation for Array Aggregates::
459 * The Size of Discriminated Records with Default Discriminants::
460 * Strict Conformance to the Ada Reference Manual::
461
462 Project File Reference
463
464 Obsolescent Features
465
466 GNU Free Documentation License
467
468 Index
469 @end menu
470
471 @end ifnottex
472
473 @node About This Guide
474 @unnumbered About This Guide
475
476 @noindent
477 This manual contains useful information in writing programs using the
478 @value{EDITION} compiler.  It includes information on implementation dependent
479 characteristics of @value{EDITION}, including all the information required by
480 Annex M of the Ada language standard.
481
482 @value{EDITION} implements Ada 95 and Ada 2005, and it may also be invoked in
483 Ada 83 compatibility mode.
484 By default, @value{EDITION} assumes @value{DEFAULTLANGUAGEVERSION},
485 but you can override with a compiler switch
486 to explicitly specify the language version.
487 (Please refer to @ref{Compiling Different Versions of Ada,,, gnat_ugn,
488 @value{EDITION} User's Guide}, for details on these switches.)
489 Throughout this manual, references to ``Ada'' without a year suffix
490 apply to both the Ada 95 and Ada 2005 versions of the language.
491
492 Ada is designed to be highly portable.
493 In general, a program will have the same effect even when compiled by
494 different compilers on different platforms.
495 However, since Ada is designed to be used in a
496 wide variety of applications, it also contains a number of system
497 dependent features to be used in interfacing to the external world.
498 @cindex Implementation-dependent features
499 @cindex Portability
500
501 Note: Any program that makes use of implementation-dependent features
502 may be non-portable.  You should follow good programming practice and
503 isolate and clearly document any sections of your program that make use
504 of these features in a non-portable manner.
505
506 @ifset PROEDITION
507 For ease of exposition, ``GNAT Pro'' will be referred to simply as
508 ``GNAT'' in the remainder of this document.
509 @end ifset
510
511 @menu
512 * What This Reference Manual Contains::
513 * Conventions::
514 * Related Information::
515 @end menu
516
517 @node What This Reference Manual Contains
518 @unnumberedsec What This Reference Manual Contains
519
520 @noindent
521 This reference manual contains the following chapters:
522
523 @itemize @bullet
524 @item
525 @ref{Implementation Defined Pragmas}, lists GNAT implementation-dependent
526 pragmas, which can be used to extend and enhance the functionality of the
527 compiler.
528
529 @item
530 @ref{Implementation Defined Attributes}, lists GNAT
531 implementation-dependent attributes which can be used to extend and
532 enhance the functionality of the compiler.
533
534 @item
535 @ref{Implementation Advice}, provides information on generally
536 desirable behavior which are not requirements that all compilers must
537 follow since it cannot be provided on all systems, or which may be
538 undesirable on some systems.
539
540 @item
541 @ref{Implementation Defined Characteristics}, provides a guide to
542 minimizing implementation dependent features.
543
544 @item
545 @ref{Intrinsic Subprograms}, describes the intrinsic subprograms
546 implemented by GNAT, and how they can be imported into user
547 application programs.
548
549 @item
550 @ref{Representation Clauses and Pragmas}, describes in detail the
551 way that GNAT represents data, and in particular the exact set
552 of representation clauses and pragmas that is accepted.
553
554 @item
555 @ref{Standard Library Routines}, provides a listing of packages and a
556 brief description of the functionality that is provided by Ada's
557 extensive set of standard library routines as implemented by GNAT@.
558
559 @item
560 @ref{The Implementation of Standard I/O}, details how the GNAT
561 implementation of the input-output facilities.
562
563 @item
564 @ref{The GNAT Library}, is a catalog of packages that complement
565 the Ada predefined library.
566
567 @item
568 @ref{Interfacing to Other Languages}, describes how programs
569 written in Ada using GNAT can be interfaced to other programming
570 languages.
571
572 @ref{Specialized Needs Annexes}, describes the GNAT implementation of all
573 of the specialized needs annexes.
574
575 @item
576 @ref{Implementation of Specific Ada Features}, discusses issues related
577 to GNAT's implementation of machine code insertions, tasking, and several
578 other features.
579
580 @item
581 @ref{Project File Reference}, presents the syntax and semantics
582 of project files.
583
584 @item
585 @ref{Obsolescent Features} documents implementation dependent features,
586 including pragmas and attributes, which are considered obsolescent, since
587 there are other preferred ways of achieving the same results. These
588 obsolescent forms are retained for backwards compatibility.
589
590 @end itemize
591
592 @cindex Ada 95 Language Reference Manual
593 @cindex Ada 2005 Language Reference Manual
594 @noindent
595 This reference manual assumes a basic familiarity with the Ada 95 language, as
596 described in the International Standard ANSI/ISO/IEC-8652:1995,
597 January 1995.
598 It does not require knowledge of the new features introduced by Ada 2005,
599 (officially known as ISO/IEC 8652:1995 with Technical Corrigendum 1
600 and Amendment 1).
601 Both reference manuals are included in the GNAT documentation
602 package.
603
604 @node Conventions
605 @unnumberedsec Conventions
606 @cindex Conventions, typographical
607 @cindex Typographical conventions
608
609 @noindent
610 Following are examples of the typographical and graphic conventions used
611 in this guide:
612
613 @itemize @bullet
614 @item
615 @code{Functions}, @code{utility program names}, @code{standard names},
616 and @code{classes}.
617
618 @item
619 @code{Option flags}
620
621 @item
622 @file{File names}, @samp{button names}, and @samp{field names}.
623
624 @item
625 @code{Variables}, @env{environment variables}, and @var{metasyntactic
626 variables}.
627
628 @item
629 @emph{Emphasis}.
630
631 @item
632 [optional information or parameters]
633
634 @item
635 Examples are described by text
636 @smallexample
637 and then shown this way.
638 @end smallexample
639 @end itemize
640
641 @noindent
642 Commands that are entered by the user are preceded in this manual by the
643 characters @samp{$ } (dollar sign followed by space).  If your system uses this
644 sequence as a prompt, then the commands will appear exactly as you see them
645 in the manual.  If your system uses some other prompt, then the command will
646 appear with the @samp{$} replaced by whatever prompt character you are using.
647
648 @node Related Information
649 @unnumberedsec Related Information
650 @noindent
651 See the following documents for further information on GNAT:
652
653 @itemize @bullet
654 @item
655 @xref{Top, @value{EDITION} User's Guide, About This Guide, gnat_ugn,
656 @value{EDITION} User's Guide}, which provides information on how to use the
657 GNAT compiler system.
658
659 @item
660 @cite{Ada 95 Reference Manual}, which contains all reference
661 material for the Ada 95 programming language.
662
663 @item
664 @cite{Ada 95 Annotated Reference Manual}, which is an annotated version
665 of the Ada 95 standard.  The annotations describe
666 detailed aspects of the design decision, and in particular contain useful
667 sections on Ada 83 compatibility.
668
669 @item
670 @cite{Ada 2005 Reference Manual}, which contains all reference
671 material for the Ada 2005 programming language.
672
673 @item
674 @cite{Ada 2005 Annotated Reference Manual}, which is an annotated version
675 of the Ada 2005 standard.  The annotations describe
676 detailed aspects of the design decision, and in particular contain useful
677 sections on Ada 83 and Ada 95 compatibility.
678
679 @item
680 @cite{DEC Ada, Technical Overview and Comparison on DIGITAL Platforms},
681 which contains specific information on compatibility between GNAT and
682 DEC Ada 83 systems.
683
684 @item
685 @cite{DEC Ada, Language Reference Manual, part number AA-PYZAB-TK} which
686 describes in detail the pragmas and attributes provided by the DEC Ada 83
687 compiler system.
688
689 @end itemize
690
691 @node Implementation Defined Pragmas
692 @chapter Implementation Defined Pragmas
693
694 @noindent
695 Ada defines a set of pragmas that can be used to supply additional
696 information to the compiler.  These language defined pragmas are
697 implemented in GNAT and work as described in the Ada Reference Manual.
698
699 In addition, Ada allows implementations to define additional pragmas
700 whose meaning is defined by the implementation.  GNAT provides a number
701 of these implementation-defined pragmas, which can be used to extend
702 and enhance the functionality of the compiler.  This section of the GNAT
703 Reference Manual describes these additional pragmas.
704
705 Note that any program using these pragmas might not be portable to other
706 compilers (although GNAT implements this set of pragmas on all
707 platforms).  Therefore if portability to other compilers is an important
708 consideration, the use of these pragmas should be minimized.
709
710 @menu
711 * Pragma Abort_Defer::
712 * Pragma Ada_83::
713 * Pragma Ada_95::
714 * Pragma Ada_05::
715 * Pragma Ada_2005::
716 * Pragma Annotate::
717 * Pragma Assert::
718 * Pragma Assume_No_Invalid_Values::
719 * Pragma Ast_Entry::
720 * Pragma C_Pass_By_Copy::
721 * Pragma Check::
722 * Pragma Check_Name::
723 * Pragma Check_Policy::
724 * Pragma Comment::
725 * Pragma Common_Object::
726 * Pragma Compile_Time_Error::
727 * Pragma Compile_Time_Warning::
728 * Pragma Compiler_Unit::
729 * Pragma Complete_Representation::
730 * Pragma Complex_Representation::
731 * Pragma Component_Alignment::
732 * Pragma Convention_Identifier::
733 * Pragma CPP_Class::
734 * Pragma CPP_Constructor::
735 * Pragma CPP_Virtual::
736 * Pragma CPP_Vtable::
737 * Pragma Debug::
738 * Pragma Debug_Policy::
739 * Pragma Detect_Blocking::
740 * Pragma Elaboration_Checks::
741 * Pragma Eliminate::
742 * Pragma Export_Exception::
743 * Pragma Export_Function::
744 * Pragma Export_Object::
745 * Pragma Export_Procedure::
746 * Pragma Export_Value::
747 * Pragma Export_Valued_Procedure::
748 * Pragma Extend_System::
749 * Pragma External::
750 * Pragma External_Name_Casing::
751 * Pragma Fast_Math::
752 * Pragma Favor_Top_Level::
753 * Pragma Finalize_Storage_Only::
754 * Pragma Float_Representation::
755 * Pragma Ident::
756 * Pragma Implemented_By_Entry::
757 * Pragma Implicit_Packing::
758 * Pragma Import_Exception::
759 * Pragma Import_Function::
760 * Pragma Import_Object::
761 * Pragma Import_Procedure::
762 * Pragma Import_Valued_Procedure::
763 * Pragma Initialize_Scalars::
764 * Pragma Inline_Always::
765 * Pragma Inline_Generic::
766 * Pragma Interface::
767 * Pragma Interface_Name::
768 * Pragma Interrupt_Handler::
769 * Pragma Interrupt_State::
770 * Pragma Keep_Names::
771 * Pragma License::
772 * Pragma Link_With::
773 * Pragma Linker_Alias::
774 * Pragma Linker_Constructor::
775 * Pragma Linker_Destructor::
776 * Pragma Linker_Section::
777 * Pragma Long_Float::
778 * Pragma Machine_Attribute::
779 * Pragma Main::
780 * Pragma Main_Storage::
781 * Pragma No_Body::
782 * Pragma No_Return::
783 * Pragma No_Strict_Aliasing::
784 * Pragma Normalize_Scalars::
785 * Pragma Obsolescent::
786 * Pragma Optimize_Alignment::
787 * Pragma Passive::
788 * Pragma Persistent_BSS::
789 * Pragma Polling::
790 * Pragma Postcondition::
791 * Pragma Precondition::
792 * Pragma Profile (Ravenscar)::
793 * Pragma Profile (Restricted)::
794 * Pragma Psect_Object::
795 * Pragma Pure_Function::
796 * Pragma Restriction_Warnings::
797 * Pragma Shared::
798 * Pragma Short_Circuit_And_Or::
799 * Pragma Source_File_Name::
800 * Pragma Source_File_Name_Project::
801 * Pragma Source_Reference::
802 * Pragma Stream_Convert::
803 * Pragma Style_Checks::
804 * Pragma Subtitle::
805 * Pragma Suppress::
806 * Pragma Suppress_All::
807 * Pragma Suppress_Exception_Locations::
808 * Pragma Suppress_Initialization::
809 * Pragma Task_Info::
810 * Pragma Task_Name::
811 * Pragma Task_Storage::
812 * Pragma Thread_Local_Storage::
813 * Pragma Time_Slice::
814 * Pragma Title::
815 * Pragma Unchecked_Union::
816 * Pragma Unimplemented_Unit::
817 * Pragma Universal_Aliasing ::
818 * Pragma Universal_Data::
819 * Pragma Unmodified::
820 * Pragma Unreferenced::
821 * Pragma Unreferenced_Objects::
822 * Pragma Unreserve_All_Interrupts::
823 * Pragma Unsuppress::
824 * Pragma Use_VADS_Size::
825 * Pragma Validity_Checks::
826 * Pragma Volatile::
827 * Pragma Warnings::
828 * Pragma Weak_External::
829 * Pragma Wide_Character_Encoding::
830 @end menu
831
832 @node Pragma Abort_Defer
833 @unnumberedsec Pragma Abort_Defer
834 @findex Abort_Defer
835 @cindex Deferring aborts
836 @noindent
837 Syntax:
838 @smallexample
839 pragma Abort_Defer;
840 @end smallexample
841
842 @noindent
843 This pragma must appear at the start of the statement sequence of a
844 handled sequence of statements (right after the @code{begin}).  It has
845 the effect of deferring aborts for the sequence of statements (but not
846 for the declarations or handlers, if any, associated with this statement
847 sequence).
848
849 @node Pragma Ada_83
850 @unnumberedsec Pragma Ada_83
851 @findex Ada_83
852 @noindent
853 Syntax:
854 @smallexample @c ada
855 pragma Ada_83;
856 @end smallexample
857
858 @noindent
859 A configuration pragma that establishes Ada 83 mode for the unit to
860 which it applies, regardless of the mode set by the command line
861 switches.  In Ada 83 mode, GNAT attempts to be as compatible with
862 the syntax and semantics of Ada 83, as defined in the original Ada
863 83 Reference Manual as possible.  In particular, the keywords added by Ada 95
864 and Ada 2005 are not recognized, optional package bodies are allowed,
865 and generics may name types with unknown discriminants without using
866 the @code{(<>)} notation.  In addition, some but not all of the additional
867 restrictions of Ada 83 are enforced.
868
869 Ada 83 mode is intended for two purposes.  Firstly, it allows existing
870 Ada 83 code to be compiled and adapted to GNAT with less effort.
871 Secondly, it aids in keeping code backwards compatible with Ada 83.
872 However, there is no guarantee that code that is processed correctly
873 by GNAT in Ada 83 mode will in fact compile and execute with an Ada
874 83 compiler, since GNAT does not enforce all the additional checks
875 required by Ada 83.
876
877 @node Pragma Ada_95
878 @unnumberedsec Pragma Ada_95
879 @findex Ada_95
880 @noindent
881 Syntax:
882 @smallexample @c ada
883 pragma Ada_95;
884 @end smallexample
885
886 @noindent
887 A configuration pragma that establishes Ada 95 mode for the unit to which
888 it applies, regardless of the mode set by the command line switches.
889 This mode is set automatically for the @code{Ada} and @code{System}
890 packages and their children, so you need not specify it in these
891 contexts.  This pragma is useful when writing a reusable component that
892 itself uses Ada 95 features, but which is intended to be usable from
893 either Ada 83 or Ada 95 programs.
894
895 @node Pragma Ada_05
896 @unnumberedsec Pragma Ada_05
897 @findex Ada_05
898 @noindent
899 Syntax:
900 @smallexample @c ada
901 pragma Ada_05;
902 @end smallexample
903
904 @noindent
905 A configuration pragma that establishes Ada 2005 mode for the unit to which
906 it applies, regardless of the mode set by the command line switches.
907 This mode is set automatically for the @code{Ada} and @code{System}
908 packages and their children, so you need not specify it in these
909 contexts.  This pragma is useful when writing a reusable component that
910 itself uses Ada 2005 features, but which is intended to be usable from
911 either Ada 83 or Ada 95 programs.
912
913 @node Pragma Ada_2005
914 @unnumberedsec Pragma Ada_2005
915 @findex Ada_2005
916 @noindent
917 Syntax:
918 @smallexample @c ada
919 pragma Ada_2005;
920 @end smallexample
921
922 @noindent
923 This configuration pragma is a synonym for pragma Ada_05 and has the
924 same syntax and effect.
925
926 @node Pragma Annotate
927 @unnumberedsec Pragma Annotate
928 @findex Annotate
929 @noindent
930 Syntax:
931 @smallexample @c ada
932 pragma Annotate (IDENTIFIER [,IDENTIFIER] @{, ARG@});
933
934 ARG ::= NAME | EXPRESSION
935 @end smallexample
936
937 @noindent
938 This pragma is used to annotate programs.  @var{identifier} identifies
939 the type of annotation.  GNAT verifies that it is an identifier, but does
940 not otherwise analyze it. The second optional identifier is also left
941 unanalyzed, and by convention is used to control the action of the tool to
942 which the annotation is addressed.  The remaining @var{arg} arguments
943 can be either string literals or more generally expressions.
944 String literals are assumed to be either of type
945 @code{Standard.String} or else @code{Wide_String} or @code{Wide_Wide_String}
946 depending on the character literals they contain.
947 All other kinds of arguments are analyzed as expressions, and must be
948 unambiguous.
949
950 The analyzed pragma is retained in the tree, but not otherwise processed
951 by any part of the GNAT compiler.  This pragma is intended for use by
952 external tools, including ASIS@.
953
954 @node Pragma Assert
955 @unnumberedsec Pragma Assert
956 @findex Assert
957 @noindent
958 Syntax:
959 @smallexample @c ada
960 pragma Assert (
961   boolean_EXPRESSION
962   [, string_EXPRESSION]);
963 @end smallexample
964
965 @noindent
966 The effect of this pragma depends on whether the corresponding command
967 line switch is set to activate assertions.  The pragma expands into code
968 equivalent to the following:
969
970 @smallexample @c ada
971 if assertions-enabled then
972    if not boolean_EXPRESSION then
973       System.Assertions.Raise_Assert_Failure
974         (string_EXPRESSION);
975    end if;
976 end if;
977 @end smallexample
978
979 @noindent
980 The string argument, if given, is the message that will be associated
981 with the exception occurrence if the exception is raised.  If no second
982 argument is given, the default message is @samp{@var{file}:@var{nnn}},
983 where @var{file} is the name of the source file containing the assert,
984 and @var{nnn} is the line number of the assert.  A pragma is not a
985 statement, so if a statement sequence contains nothing but a pragma
986 assert, then a null statement is required in addition, as in:
987
988 @smallexample @c ada
989 @dots{}
990 if J > 3 then
991    pragma Assert (K > 3, "Bad value for K");
992    null;
993 end if;
994 @end smallexample
995
996 @noindent
997 Note that, as with the @code{if} statement to which it is equivalent, the
998 type of the expression is either @code{Standard.Boolean}, or any type derived
999 from this standard type.
1000
1001 If assertions are disabled (switch @option{-gnata} not used), then there
1002 is no run-time effect (and in particular, any side effects from the
1003 expression will not occur at run time).  (The expression is still
1004 analyzed at compile time, and may cause types to be frozen if they are
1005 mentioned here for the first time).
1006
1007 If assertions are enabled, then the given expression is tested, and if
1008 it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
1009 which results in the raising of @code{Assert_Failure} with the given message.
1010
1011 You should generally avoid side effects in the expression arguments of
1012 this pragma, because these side effects will turn on and off with the
1013 setting of the assertions mode, resulting in assertions that have an
1014 effect on the program.  However, the expressions are analyzed for
1015 semantic correctness whether or not assertions are enabled, so turning
1016 assertions on and off cannot affect the legality of a program.
1017
1018 @node Pragma Assume_No_Invalid_Values
1019 @unnumberedsec Pragma Assume_No_Invalid_Values
1020 @findex Assume_No_Invalid_Values
1021 @cindex Invalid representations
1022 @cindex Invalid values
1023 @noindent
1024 Syntax:
1025 @smallexample @c ada
1026 pragma Assume_No_Invalid_Values (On | Off);
1027 @end smallexample
1028
1029 @noindent
1030 This is a configuration pragma that controls the assumptions made by the
1031 compiler about the occurrence of invalid representations (invalid values)
1032 in the code.
1033
1034 The default behavior (corresponding to an Off argument for this pragma), is
1035 to assume that values may in general be invalid unless the compiler can
1036 prove they are valid. Consider the following example:
1037
1038 @smallexample @c ada
1039 V1 : Integer range 1 .. 10;
1040 V2 : Integer range 11 .. 20;
1041 ...
1042 for J in V2 .. V1 loop
1043    ...
1044 end loop;
1045 @end smallexample
1046
1047 @noindent
1048 if V1 and V2 have valid values, then the loop is known at compile
1049 time not to execute since the lower bound must be greater than the
1050 upper bound. However in default mode, no such assumption is made,
1051 and the loop may execute. If @code{Assume_No_Invalid_Values (On)}
1052 is given, the compiler will assume that any occurrence of a variable
1053 other than in an explicit @code{'Valid} test always has a valid
1054 value, and the loop above will be optimized away.
1055
1056 The use of @code{Assume_No_Invalid_Values (On)} is appropriate if
1057 you know your code is free of uninitialized variables and other
1058 possible sources of invalid representations, and may result in
1059 more efficient code. A program that accesses an invalid representation
1060 with this pragma in effect is erroneous, so no guarantees can be made
1061 about its behavior.
1062
1063 It is peculiar though permissible to use this pragma in conjunction
1064 with validity checking (-gnatVa). In such cases, accessing invalid
1065 values will generally give an exception, though formally the program
1066 is erroneous so there are no guarantees that this will always be the
1067 case, and it is recommended that these two options not be used together.
1068
1069 @node Pragma Ast_Entry
1070 @unnumberedsec Pragma Ast_Entry
1071 @cindex OpenVMS
1072 @findex Ast_Entry
1073 @noindent
1074 Syntax:
1075 @smallexample @c ada
1076 pragma AST_Entry (entry_IDENTIFIER);
1077 @end smallexample
1078
1079 @noindent
1080 This pragma is implemented only in the OpenVMS implementation of GNAT@.  The
1081 argument is the simple name of a single entry; at most one @code{AST_Entry}
1082 pragma is allowed for any given entry.  This pragma must be used in
1083 conjunction with the @code{AST_Entry} attribute, and is only allowed after
1084 the entry declaration and in the same task type specification or single task
1085 as the entry to which it applies.  This pragma specifies that the given entry
1086 may be used to handle an OpenVMS asynchronous system trap (@code{AST})
1087 resulting from an OpenVMS system service call.  The pragma does not affect
1088 normal use of the entry.  For further details on this pragma, see the
1089 DEC Ada Language Reference Manual, section 9.12a.
1090
1091 @node Pragma C_Pass_By_Copy
1092 @unnumberedsec Pragma C_Pass_By_Copy
1093 @cindex Passing by copy
1094 @findex C_Pass_By_Copy
1095 @noindent
1096 Syntax:
1097 @smallexample @c ada
1098 pragma C_Pass_By_Copy
1099   ([Max_Size =>] static_integer_EXPRESSION);
1100 @end smallexample
1101
1102 @noindent
1103 Normally the default mechanism for passing C convention records to C
1104 convention subprograms is to pass them by reference, as suggested by RM
1105 B.3(69).  Use the configuration pragma @code{C_Pass_By_Copy} to change
1106 this default, by requiring that record formal parameters be passed by
1107 copy if all of the following conditions are met:
1108
1109 @itemize @bullet
1110 @item
1111 The size of the record type does not exceed the value specified for
1112 @code{Max_Size}.
1113 @item
1114 The record type has @code{Convention C}.
1115 @item
1116 The formal parameter has this record type, and the subprogram has a
1117 foreign (non-Ada) convention.
1118 @end itemize
1119
1120 @noindent
1121 If these conditions are met the argument is passed by copy, i.e.@: in a
1122 manner consistent with what C expects if the corresponding formal in the
1123 C prototype is a struct (rather than a pointer to a struct).
1124
1125 You can also pass records by copy by specifying the convention
1126 @code{C_Pass_By_Copy} for the record type, or by using the extended
1127 @code{Import} and @code{Export} pragmas, which allow specification of
1128 passing mechanisms on a parameter by parameter basis.
1129
1130 @node Pragma Check
1131 @unnumberedsec Pragma Check
1132 @cindex Assertions
1133 @cindex Named assertions
1134 @findex Check
1135 @noindent
1136 Syntax:
1137 @smallexample @c ada
1138 pragma Check (
1139      [Name    =>] Identifier,
1140      [Check   =>] Boolean_EXPRESSION
1141   [, [Message =>] string_EXPRESSION] );
1142 @end smallexample
1143
1144 @noindent
1145 This pragma is similar to the predefined pragma @code{Assert} except that an
1146 extra identifier argument is present. In conjunction with pragma
1147 @code{Check_Policy}, this can be used to define groups of assertions that can
1148 be independently controlled. The identifier @code{Assertion} is special, it
1149 refers to the normal set of pragma @code{Assert} statements. The identifiers
1150 @code{Precondition} and @code{Postcondition} correspond to the pragmas of these
1151 names, so these three names would normally not be used directly in a pragma
1152 @code{Check}.
1153
1154 Checks introduced by this pragma are normally deactivated by default. They can
1155 be activated either by the command line option @option{-gnata}, which turns on
1156 all checks, or individually controlled using pragma @code{Check_Policy}.
1157
1158 @node Pragma Check_Name
1159 @unnumberedsec Pragma Check_Name
1160 @cindex Defining check names
1161 @cindex Check names, defining
1162 @findex Check_Name
1163 @noindent
1164 Syntax:
1165 @smallexample @c ada
1166 pragma Check_Name (check_name_IDENTIFIER);
1167 @end smallexample
1168
1169 @noindent
1170 This is a configuration pragma that defines a new implementation
1171 defined check name (unless IDENTIFIER matches one of the predefined
1172 check names, in which case the pragma has no effect). Check names
1173 are global to a partition, so if two or more configuration pragmas
1174 are present in a partition mentioning the same name, only one new
1175 check name is introduced.
1176
1177 An implementation defined check name introduced with this pragma may
1178 be used in only three contexts: @code{pragma Suppress},
1179 @code{pragma Unsuppress},
1180 and as the prefix of a @code{Check_Name'Enabled} attribute reference. For
1181 any of these three cases, the check name must be visible. A check
1182 name is visible if it is in the configuration pragmas applying to
1183 the current unit, or if it appears at the start of any unit that
1184 is part of the dependency set of the current unit (e.g., units that
1185 are mentioned in @code{with} clauses).
1186
1187 @node Pragma Check_Policy
1188 @unnumberedsec Pragma Check_Policy
1189 @cindex Controlling assertions
1190 @cindex Assertions, control
1191 @cindex Check pragma control
1192 @cindex Named assertions
1193 @findex Check
1194 @noindent
1195 Syntax:
1196 @smallexample @c ada
1197 pragma Check_Policy
1198  ([Name   =>] Identifier,
1199   [Policy =>] POLICY_IDENTIFIER);
1200
1201 POLICY_IDENTIFIER ::= On | Off | Check | Ignore
1202 @end smallexample
1203
1204 @noindent
1205 This pragma is similar to the predefined pragma @code{Assertion_Policy},
1206 except that it controls sets of named assertions introduced using the
1207 @code{Check} pragmas. It can be used as a configuration pragma or (unlike
1208 @code{Assertion_Policy}) can be used within a declarative part, in which case
1209 it controls the status to the end of the corresponding construct (in a manner
1210 identical to pragma @code{Suppress)}.
1211
1212 The identifier given as the first argument corresponds to a name used in
1213 associated @code{Check} pragmas. For example, if the pragma:
1214
1215 @smallexample @c ada
1216 pragma Check_Policy (Critical_Error, Off);
1217 @end smallexample
1218
1219 @noindent
1220 is given, then subsequent @code{Check} pragmas whose first argument is also
1221 @code{Critical_Error} will be disabled. The special identifier @code{Assertion}
1222 controls the behavior of normal @code{Assert} pragmas (thus a pragma
1223 @code{Check_Policy} with this identifier is similar to the normal
1224 @code{Assertion_Policy} pragma except that it can appear within a
1225 declarative part).
1226
1227 The special identifiers @code{Precondition} and @code{Postcondition} control
1228 the status of preconditions and postconditions. If a @code{Precondition} pragma
1229 is encountered, it is ignored if turned off by a @code{Check_Policy} specifying
1230 that @code{Precondition} checks are @code{Off} or @code{Ignored}. Similarly use
1231 of the name @code{Postcondition} controls whether @code{Postcondition} pragmas
1232 are recognized.
1233
1234 The check policy is @code{Off} to turn off corresponding checks, and @code{On}
1235 to turn on corresponding checks. The default for a set of checks for which no
1236 @code{Check_Policy} is given is @code{Off} unless the compiler switch
1237 @option{-gnata} is given, which turns on all checks by default.
1238
1239 The check policy settings @code{Check} and @code{Ignore} are also recognized
1240 as synonyms for @code{On} and @code{Off}. These synonyms are provided for
1241 compatibility with the standard @code{Assertion_Policy} pragma.
1242
1243 @node Pragma Comment
1244 @unnumberedsec Pragma Comment
1245 @findex Comment
1246 @noindent
1247 Syntax:
1248
1249 @smallexample @c ada
1250 pragma Comment (static_string_EXPRESSION);
1251 @end smallexample
1252
1253 @noindent
1254 This is almost identical in effect to pragma @code{Ident}.  It allows the
1255 placement of a comment into the object file and hence into the
1256 executable file if the operating system permits such usage.  The
1257 difference is that @code{Comment}, unlike @code{Ident}, has
1258 no limitations on placement of the pragma (it can be placed
1259 anywhere in the main source unit), and if more than one pragma
1260 is used, all comments are retained.
1261
1262 @node Pragma Common_Object
1263 @unnumberedsec Pragma Common_Object
1264 @findex Common_Object
1265 @noindent
1266 Syntax:
1267
1268 @smallexample @c ada
1269 pragma Common_Object (
1270      [Internal =>] LOCAL_NAME
1271   [, [External =>] EXTERNAL_SYMBOL]
1272   [, [Size     =>] EXTERNAL_SYMBOL] );
1273
1274 EXTERNAL_SYMBOL ::=
1275   IDENTIFIER
1276 | static_string_EXPRESSION
1277 @end smallexample
1278
1279 @noindent
1280 This pragma enables the shared use of variables stored in overlaid
1281 linker areas corresponding to the use of @code{COMMON}
1282 in Fortran.  The single
1283 object @var{LOCAL_NAME} is assigned to the area designated by
1284 the @var{External} argument.
1285 You may define a record to correspond to a series
1286 of fields.  The @var{Size} argument
1287 is syntax checked in GNAT, but otherwise ignored.
1288
1289 @code{Common_Object} is not supported on all platforms.  If no
1290 support is available, then the code generator will issue a message
1291 indicating that the necessary attribute for implementation of this
1292 pragma is not available.
1293
1294 @node Pragma Compile_Time_Error
1295 @unnumberedsec Pragma Compile_Time_Error
1296 @findex Compile_Time_Error
1297 @noindent
1298 Syntax:
1299
1300 @smallexample @c ada
1301 pragma Compile_Time_Error
1302          (boolean_EXPRESSION, static_string_EXPRESSION);
1303 @end smallexample
1304
1305 @noindent
1306 This pragma can be used to generate additional compile time
1307 error messages. It
1308 is particularly useful in generics, where errors can be issued for
1309 specific problematic instantiations. The first parameter is a boolean
1310 expression. The pragma is effective only if the value of this expression
1311 is known at compile time, and has the value True. The set of expressions
1312 whose values are known at compile time includes all static boolean
1313 expressions, and also other values which the compiler can determine
1314 at compile time (e.g., the size of a record type set by an explicit
1315 size representation clause, or the value of a variable which was
1316 initialized to a constant and is known not to have been modified).
1317 If these conditions are met, an error message is generated using
1318 the value given as the second argument. This string value may contain
1319 embedded ASCII.LF characters to break the message into multiple lines.
1320
1321 @node Pragma Compile_Time_Warning
1322 @unnumberedsec Pragma Compile_Time_Warning
1323 @findex Compile_Time_Warning
1324 @noindent
1325 Syntax:
1326
1327 @smallexample @c ada
1328 pragma Compile_Time_Warning
1329          (boolean_EXPRESSION, static_string_EXPRESSION);
1330 @end smallexample
1331
1332 @noindent
1333 Same as pragma Compile_Time_Error, except a warning is issued instead
1334 of an error message. Note that if this pragma is used in a package that
1335 is with'ed by a client, the client will get the warning even though it
1336 is issued by a with'ed package (normally warnings in with'ed units are
1337 suppressed, but this is a special exception to that rule).
1338
1339 One typical use is within a generic where compile time known characteristics
1340 of formal parameters are tested, and warnings given appropriately. Another use
1341 with a first parameter of True is to warn a client about use of a package,
1342 for example that it is not fully implemented.
1343
1344 @node Pragma Compiler_Unit
1345 @unnumberedsec Pragma Compiler_Unit
1346 @findex Compiler_Unit
1347 @noindent
1348 Syntax:
1349
1350 @smallexample @c ada
1351 pragma Compiler_Unit;
1352 @end smallexample
1353
1354 @noindent
1355 This pragma is intended only for internal use in the GNAT run-time library.
1356 It indicates that the unit is used as part of the compiler build. The effect
1357 is to disallow constructs (raise with message, conditional expressions etc)
1358 that would cause trouble when bootstrapping using an older version of GNAT.
1359 For the exact list of restrictions, see the compiler sources and references
1360 to Is_Compiler_Unit.
1361
1362 @node Pragma Complete_Representation
1363 @unnumberedsec Pragma Complete_Representation
1364 @findex Complete_Representation
1365 @noindent
1366 Syntax:
1367
1368 @smallexample @c ada
1369 pragma Complete_Representation;
1370 @end smallexample
1371
1372 @noindent
1373 This pragma must appear immediately within a record representation
1374 clause. Typical placements are before the first component clause
1375 or after the last component clause. The effect is to give an error
1376 message if any component is missing a component clause. This pragma
1377 may be used to ensure that a record representation clause is
1378 complete, and that this invariant is maintained if fields are
1379 added to the record in the future.
1380
1381 @node Pragma Complex_Representation
1382 @unnumberedsec Pragma Complex_Representation
1383 @findex Complex_Representation
1384 @noindent
1385 Syntax:
1386
1387 @smallexample @c ada
1388 pragma Complex_Representation
1389         ([Entity =>] LOCAL_NAME);
1390 @end smallexample
1391
1392 @noindent
1393 The @var{Entity} argument must be the name of a record type which has
1394 two fields of the same floating-point type.  The effect of this pragma is
1395 to force gcc to use the special internal complex representation form for
1396 this record, which may be more efficient.  Note that this may result in
1397 the code for this type not conforming to standard ABI (application
1398 binary interface) requirements for the handling of record types.  For
1399 example, in some environments, there is a requirement for passing
1400 records by pointer, and the use of this pragma may result in passing
1401 this type in floating-point registers.
1402
1403 @node Pragma Component_Alignment
1404 @unnumberedsec Pragma Component_Alignment
1405 @cindex Alignments of components
1406 @findex Component_Alignment
1407 @noindent
1408 Syntax:
1409
1410 @smallexample @c ada
1411 pragma Component_Alignment (
1412      [Form =>] ALIGNMENT_CHOICE
1413   [, [Name =>] type_LOCAL_NAME]);
1414
1415 ALIGNMENT_CHOICE ::=
1416   Component_Size
1417 | Component_Size_4
1418 | Storage_Unit
1419 | Default
1420 @end smallexample
1421
1422 @noindent
1423 Specifies the alignment of components in array or record types.
1424 The meaning of the @var{Form} argument is as follows:
1425
1426 @table @code
1427 @findex Component_Size
1428 @item Component_Size
1429 Aligns scalar components and subcomponents of the array or record type
1430 on boundaries appropriate to their inherent size (naturally
1431 aligned).  For example, 1-byte components are aligned on byte boundaries,
1432 2-byte integer components are aligned on 2-byte boundaries, 4-byte
1433 integer components are aligned on 4-byte boundaries and so on.  These
1434 alignment rules correspond to the normal rules for C compilers on all
1435 machines except the VAX@.
1436
1437 @findex Component_Size_4
1438 @item Component_Size_4
1439 Naturally aligns components with a size of four or fewer
1440 bytes.  Components that are larger than 4 bytes are placed on the next
1441 4-byte boundary.
1442
1443 @findex Storage_Unit
1444 @item Storage_Unit
1445 Specifies that array or record components are byte aligned, i.e.@:
1446 aligned on boundaries determined by the value of the constant
1447 @code{System.Storage_Unit}.
1448
1449 @cindex OpenVMS
1450 @item Default
1451 Specifies that array or record components are aligned on default
1452 boundaries, appropriate to the underlying hardware or operating system or
1453 both.  For OpenVMS VAX systems, the @code{Default} choice is the same as
1454 the @code{Storage_Unit} choice (byte alignment).  For all other systems,
1455 the @code{Default} choice is the same as @code{Component_Size} (natural
1456 alignment).
1457 @end table
1458
1459 @noindent
1460 If the @code{Name} parameter is present, @var{type_LOCAL_NAME} must
1461 refer to a local record or array type, and the specified alignment
1462 choice applies to the specified type.  The use of
1463 @code{Component_Alignment} together with a pragma @code{Pack} causes the
1464 @code{Component_Alignment} pragma to be ignored.  The use of
1465 @code{Component_Alignment} together with a record representation clause
1466 is only effective for fields not specified by the representation clause.
1467
1468 If the @code{Name} parameter is absent, the pragma can be used as either
1469 a configuration pragma, in which case it applies to one or more units in
1470 accordance with the normal rules for configuration pragmas, or it can be
1471 used within a declarative part, in which case it applies to types that
1472 are declared within this declarative part, or within any nested scope
1473 within this declarative part.  In either case it specifies the alignment
1474 to be applied to any record or array type which has otherwise standard
1475 representation.
1476
1477 If the alignment for a record or array type is not specified (using
1478 pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
1479 clause), the GNAT uses the default alignment as described previously.
1480
1481 @node Pragma Convention_Identifier
1482 @unnumberedsec Pragma Convention_Identifier
1483 @findex Convention_Identifier
1484 @cindex Conventions, synonyms
1485 @noindent
1486 Syntax:
1487
1488 @smallexample @c ada
1489 pragma Convention_Identifier (
1490          [Name =>]       IDENTIFIER,
1491          [Convention =>] convention_IDENTIFIER);
1492 @end smallexample
1493
1494 @noindent
1495 This pragma provides a mechanism for supplying synonyms for existing
1496 convention identifiers. The @code{Name} identifier can subsequently
1497 be used as a synonym for the given convention in other pragmas (including
1498 for example pragma @code{Import} or another @code{Convention_Identifier}
1499 pragma). As an example of the use of this, suppose you had legacy code
1500 which used Fortran77 as the identifier for Fortran. Then the pragma:
1501
1502 @smallexample @c ada
1503 pragma Convention_Identifier (Fortran77, Fortran);
1504 @end smallexample
1505
1506 @noindent
1507 would allow the use of the convention identifier @code{Fortran77} in
1508 subsequent code, avoiding the need to modify the sources. As another
1509 example, you could use this to parametrize convention requirements
1510 according to systems. Suppose you needed to use @code{Stdcall} on
1511 windows systems, and @code{C} on some other system, then you could
1512 define a convention identifier @code{Library} and use a single
1513 @code{Convention_Identifier} pragma to specify which convention
1514 would be used system-wide.
1515
1516 @node Pragma CPP_Class
1517 @unnumberedsec Pragma CPP_Class
1518 @findex CPP_Class
1519 @cindex Interfacing with C++
1520 @noindent
1521 Syntax:
1522
1523 @smallexample @c ada
1524 pragma CPP_Class ([Entity =>] LOCAL_NAME);
1525 @end smallexample
1526
1527 @noindent
1528 The argument denotes an entity in the current declarative region that is
1529 declared as a record type. It indicates that the type corresponds to an
1530 externally declared C++ class type, and is to be laid out the same way
1531 that C++ would lay out the type. If the C++ class has virtual primitives
1532 then the record must be declared as a tagged record type.
1533
1534 Types for which @code{CPP_Class} is specified do not have assignment or
1535 equality operators defined (such operations can be imported or declared
1536 as subprograms as required). Initialization is allowed only by constructor
1537 functions (see pragma @code{CPP_Constructor}). Such types are implicitly
1538 limited if not explicitly declared as limited or derived from a limited
1539 type, and an error is issued in that case.
1540
1541 Pragma @code{CPP_Class} is intended primarily for automatic generation
1542 using an automatic binding generator tool.
1543 See @ref{Interfacing to C++} for related information.
1544
1545 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
1546 for backward compatibility but its functionality is available
1547 using pragma @code{Import} with @code{Convention} = @code{CPP}.
1548
1549 @node Pragma CPP_Constructor
1550 @unnumberedsec Pragma CPP_Constructor
1551 @cindex Interfacing with C++
1552 @findex CPP_Constructor
1553 @noindent
1554 Syntax:
1555
1556 @smallexample @c ada
1557 pragma CPP_Constructor ([Entity =>] LOCAL_NAME
1558   [, [External_Name =>] static_string_EXPRESSION ]
1559   [, [Link_Name     =>] static_string_EXPRESSION ]);
1560 @end smallexample
1561
1562 @noindent
1563 This pragma identifies an imported function (imported in the usual way
1564 with pragma @code{Import}) as corresponding to a C++ constructor. If
1565 @code{External_Name} and @code{Link_Name} are not specified then the
1566 @code{Entity} argument is a name that must have been previously mentioned
1567 in a pragma @code{Import} with @code{Convention} = @code{CPP}. Such name
1568 must be of one of the following forms:
1569
1570 @itemize @bullet
1571 @item
1572 @code{function @var{Fname} return @var{T}}
1573
1574 @itemize @bullet
1575 @item
1576 @code{function @var{Fname} return @var{T}'Class}
1577
1578 @item
1579 @code{function @var{Fname} (@dots{}) return @var{T}}
1580 @end itemize
1581
1582 @item
1583 @code{function @var{Fname} (@dots{}) return @var{T}'Class}
1584 @end itemize
1585
1586 @noindent
1587 where @var{T} is a limited record type imported from C++ with pragma
1588 @code{Import} and @code{Convention} = @code{CPP}.
1589
1590 The first two forms import the default constructor, used when an object
1591 of type @var{T} is created on the Ada side with no explicit constructor.
1592 The latter two forms cover all the non-default constructors of the type.
1593 See the GNAT users guide for details.
1594
1595 If no constructors are imported, it is impossible to create any objects
1596 on the Ada side and the type is implicitly declared abstract.
1597
1598 Pragma @code{CPP_Constructor} is intended primarily for automatic generation
1599 using an automatic binding generator tool.
1600 See @ref{Interfacing to C++} for more related information.
1601
1602 Note: The use of functions returning class-wide types for constructors is
1603 currently obsolete. They are supported for backward compatibility. The
1604 use of functions returning the type T leave the Ada sources more clear
1605 because the imported C++ constructors always return an object of type T;
1606 that is, they never return an object whose type is a descendant of type T.
1607
1608 @node Pragma CPP_Virtual
1609 @unnumberedsec Pragma CPP_Virtual
1610 @cindex Interfacing to C++
1611 @findex CPP_Virtual
1612 @noindent
1613 This pragma is now obsolete has has no effect because GNAT generates
1614 the same object layout than the G++ compiler.
1615
1616 See @ref{Interfacing to C++} for related information.
1617
1618 @node Pragma CPP_Vtable
1619 @unnumberedsec Pragma CPP_Vtable
1620 @cindex Interfacing with C++
1621 @findex CPP_Vtable
1622 @noindent
1623 This pragma is now obsolete has has no effect because GNAT generates
1624 the same object layout than the G++ compiler.
1625
1626 See @ref{Interfacing to C++} for related information.
1627
1628 @node Pragma Debug
1629 @unnumberedsec Pragma Debug
1630 @findex Debug
1631 @noindent
1632 Syntax:
1633
1634 @smallexample @c ada
1635 pragma Debug ([CONDITION, ]PROCEDURE_CALL_WITHOUT_SEMICOLON);
1636
1637 PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
1638   PROCEDURE_NAME
1639 | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
1640 @end smallexample
1641
1642 @noindent
1643 The procedure call argument has the syntactic form of an expression, meeting
1644 the syntactic requirements for pragmas.
1645
1646 If debug pragmas are not enabled or if the condition is present and evaluates
1647 to False, this pragma has no effect. If debug pragmas are enabled, the
1648 semantics of the pragma is exactly equivalent to the procedure call statement
1649 corresponding to the argument with a terminating semicolon. Pragmas are
1650 permitted in sequences of declarations, so you can use pragma @code{Debug} to
1651 intersperse calls to debug procedures in the middle of declarations. Debug
1652 pragmas can be enabled either by use of the command line switch @option{-gnata}
1653 or by use of the configuration pragma @code{Debug_Policy}.
1654
1655 @node Pragma Debug_Policy
1656 @unnumberedsec Pragma Debug_Policy
1657 @findex Debug_Policy
1658 @noindent
1659 Syntax:
1660
1661 @smallexample @c ada
1662 pragma Debug_Policy (CHECK | IGNORE);
1663 @end smallexample
1664
1665 @noindent
1666 If the argument is @code{CHECK}, then pragma @code{DEBUG} is enabled.
1667 If the argument is @code{IGNORE}, then pragma @code{DEBUG} is ignored.
1668 This pragma overrides the effect of the @option{-gnata} switch on the
1669 command line.
1670
1671 @node Pragma Detect_Blocking
1672 @unnumberedsec Pragma Detect_Blocking
1673 @findex Detect_Blocking
1674 @noindent
1675 Syntax:
1676
1677 @smallexample @c ada
1678 pragma Detect_Blocking;
1679 @end smallexample
1680
1681 @noindent
1682 This is a configuration pragma that forces the detection of potentially
1683 blocking operations within a protected operation, and to raise Program_Error
1684 if that happens.
1685
1686 @node Pragma Elaboration_Checks
1687 @unnumberedsec Pragma Elaboration_Checks
1688 @cindex Elaboration control
1689 @findex Elaboration_Checks
1690 @noindent
1691 Syntax:
1692
1693 @smallexample @c ada
1694 pragma Elaboration_Checks (Dynamic | Static);
1695 @end smallexample
1696
1697 @noindent
1698 This is a configuration pragma that provides control over the
1699 elaboration model used by the compilation affected by the
1700 pragma.  If the parameter is @code{Dynamic},
1701 then the dynamic elaboration
1702 model described in the Ada Reference Manual is used, as though
1703 the @option{-gnatE} switch had been specified on the command
1704 line.  If the parameter is @code{Static}, then the default GNAT static
1705 model is used.  This configuration pragma overrides the setting
1706 of the command line.  For full details on the elaboration models
1707 used by the GNAT compiler, see @ref{Elaboration Order Handling in GNAT,,,
1708 gnat_ugn, @value{EDITION} User's Guide}.
1709
1710 @node Pragma Eliminate
1711 @unnumberedsec Pragma Eliminate
1712 @cindex Elimination of unused subprograms
1713 @findex Eliminate
1714 @noindent
1715 Syntax:
1716
1717 @smallexample @c ada
1718 pragma Eliminate (
1719     [Unit_Name =>] IDENTIFIER |
1720                    SELECTED_COMPONENT);
1721
1722 pragma Eliminate (
1723     [Unit_Name       =>]  IDENTIFIER |
1724                           SELECTED_COMPONENT,
1725     [Entity          =>]  IDENTIFIER |
1726                           SELECTED_COMPONENT |
1727                           STRING_LITERAL
1728     [,OVERLOADING_RESOLUTION]);
1729
1730 OVERLOADING_RESOLUTION ::= PARAMETER_AND_RESULT_TYPE_PROFILE |
1731                            SOURCE_LOCATION
1732
1733 PARAMETER_AND_RESULT_TYPE_PROFILE ::= PROCEDURE_PROFILE |
1734                                       FUNCTION_PROFILE
1735
1736 PROCEDURE_PROFILE ::= Parameter_Types => PARAMETER_TYPES
1737
1738 FUNCTION_PROFILE ::= [Parameter_Types => PARAMETER_TYPES,]
1739                       Result_Type => result_SUBTYPE_NAME]
1740
1741 PARAMETER_TYPES ::= (SUBTYPE_NAME @{, SUBTYPE_NAME@})
1742 SUBTYPE_NAME    ::= STRING_VALUE
1743
1744 SOURCE_LOCATION ::= Source_Location => SOURCE_TRACE
1745 SOURCE_TRACE    ::= STRING_VALUE
1746
1747 STRING_VALUE ::= STRING_LITERAL @{& STRING_LITERAL@}
1748 @end smallexample
1749
1750 @noindent
1751 This pragma indicates that the given entity is not used outside the
1752 compilation unit it is defined in. The entity must be an explicitly declared
1753 subprogram; this includes  generic subprogram instances and
1754 subprograms declared in generic package instances.
1755
1756 If the entity to be eliminated is a library level subprogram, then
1757 the first form of pragma @code{Eliminate} is used with only a single argument.
1758 In this form, the @code{Unit_Name} argument specifies the name of the
1759 library  level unit to be eliminated.
1760
1761 In all other cases, both @code{Unit_Name} and @code{Entity} arguments
1762 are required. If item is an entity of a library package, then the first
1763 argument specifies the unit name, and the second argument specifies
1764 the particular entity.  If the second argument is in string form, it must
1765 correspond to the internal manner in which GNAT stores entity names (see
1766 compilation unit Namet in the compiler sources for details).
1767
1768 The remaining parameters (OVERLOADING_RESOLUTION) are optionally used
1769 to distinguish between overloaded subprograms. If a pragma does not contain
1770 the OVERLOADING_RESOLUTION parameter(s), it is applied to all the overloaded
1771 subprograms denoted by the first two parameters.
1772
1773 Use PARAMETER_AND_RESULT_TYPE_PROFILE to specify the profile of the subprogram
1774 to be eliminated in a manner similar to that used for the extended
1775 @code{Import} and @code{Export} pragmas, except that the subtype names are
1776 always given as strings. At the moment, this form of distinguishing
1777 overloaded subprograms is implemented only partially, so we do not recommend
1778 using it for practical subprogram elimination.
1779
1780 Note that in case of a parameterless procedure its profile is represented
1781 as @code{Parameter_Types => ("")}
1782
1783 Alternatively, the @code{Source_Location} parameter is used to specify
1784 which overloaded alternative is to be eliminated by pointing to the
1785 location of the DEFINING_PROGRAM_UNIT_NAME of this subprogram in the
1786 source text. The string literal (or concatenation of string literals)
1787 given as SOURCE_TRACE must have the following format:
1788
1789 @smallexample @c ada
1790 SOURCE_TRACE ::= SOURCE_LOCATION@{LBRACKET SOURCE_LOCATION RBRACKET@}
1791
1792 LBRACKET ::= [
1793 RBRACKET ::= ]
1794
1795 SOURCE_LOCATION ::= FILE_NAME:LINE_NUMBER
1796 FILE_NAME       ::= STRING_LITERAL
1797 LINE_NUMBER     ::= DIGIT @{DIGIT@}
1798 @end smallexample
1799
1800 SOURCE_TRACE should be the short name of the source file (with no directory
1801 information), and LINE_NUMBER is supposed to point to the line where the
1802 defining name of the subprogram is located.
1803
1804 For the subprograms that are not a part of generic instantiations, only one
1805 SOURCE_LOCATION is used. If a subprogram is declared in a package
1806 instantiation, SOURCE_TRACE contains two SOURCE_LOCATIONs, the first one is
1807 the location of the (DEFINING_PROGRAM_UNIT_NAME of the) instantiation, and the
1808 second one denotes the declaration of the corresponding subprogram in the
1809 generic package. This approach is recursively used to create SOURCE_LOCATIONs
1810 in case of nested instantiations.
1811
1812 The effect of the pragma is to allow the compiler to eliminate
1813 the code or data associated with the named entity.  Any reference to
1814 an eliminated entity outside the compilation unit it is defined in,
1815 causes a compile time or link time error.
1816
1817 The intention of pragma @code{Eliminate} is to allow a program to be compiled
1818 in a system independent manner, with unused entities eliminated, without
1819 the requirement of modifying the source text.  Normally the required set
1820 of @code{Eliminate} pragmas is constructed automatically using the gnatelim
1821 tool. Elimination of unused entities local to a compilation unit is
1822 automatic, without requiring the use of pragma @code{Eliminate}.
1823
1824 Note that the reason this pragma takes string literals where names might
1825 be expected is that a pragma @code{Eliminate} can appear in a context where the
1826 relevant names are not visible.
1827
1828 Note that any change in the source files that includes removing, splitting of
1829 adding lines may make the set of Eliminate pragmas using SOURCE_LOCATION
1830 parameter illegal.
1831
1832 It is legal to use pragma Eliminate where the referenced entity is a
1833 dispatching operation, but it is not clear what this would mean, since
1834 in general the call does not know which entity is actually being called.
1835 Consequently, a pragma Eliminate for a dispatching operation is ignored.
1836
1837 @node Pragma Export_Exception
1838 @unnumberedsec Pragma Export_Exception
1839 @cindex OpenVMS
1840 @findex Export_Exception
1841 @noindent
1842 Syntax:
1843
1844 @smallexample @c ada
1845 pragma Export_Exception (
1846      [Internal =>] LOCAL_NAME
1847   [, [External =>] EXTERNAL_SYMBOL]
1848   [, [Form     =>] Ada | VMS]
1849   [, [Code     =>] static_integer_EXPRESSION]);
1850
1851 EXTERNAL_SYMBOL ::=
1852   IDENTIFIER
1853 | static_string_EXPRESSION
1854 @end smallexample
1855
1856 @noindent
1857 This pragma is implemented only in the OpenVMS implementation of GNAT@.  It
1858 causes the specified exception to be propagated outside of the Ada program,
1859 so that it can be handled by programs written in other OpenVMS languages.
1860 This pragma establishes an external name for an Ada exception and makes the
1861 name available to the OpenVMS Linker as a global symbol.  For further details
1862 on this pragma, see the
1863 DEC Ada Language Reference Manual, section 13.9a3.2.
1864
1865 @node Pragma Export_Function
1866 @unnumberedsec Pragma Export_Function
1867 @cindex Argument passing mechanisms
1868 @findex Export_Function
1869
1870 @noindent
1871 Syntax:
1872
1873 @smallexample @c ada
1874 pragma Export_Function (
1875      [Internal         =>] LOCAL_NAME
1876   [, [External         =>] EXTERNAL_SYMBOL]
1877   [, [Parameter_Types  =>] PARAMETER_TYPES]
1878   [, [Result_Type      =>] result_SUBTYPE_MARK]
1879   [, [Mechanism        =>] MECHANISM]
1880   [, [Result_Mechanism =>] MECHANISM_NAME]);
1881
1882 EXTERNAL_SYMBOL ::=
1883   IDENTIFIER
1884 | static_string_EXPRESSION
1885 | ""
1886
1887 PARAMETER_TYPES ::=
1888   null
1889 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1890
1891 TYPE_DESIGNATOR ::=
1892   subtype_NAME
1893 | subtype_Name ' Access
1894
1895 MECHANISM ::=
1896   MECHANISM_NAME
1897 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1898
1899 MECHANISM_ASSOCIATION ::=
1900   [formal_parameter_NAME =>] MECHANISM_NAME
1901
1902 MECHANISM_NAME ::=
1903   Value
1904 | Reference
1905 | Descriptor [([Class =>] CLASS_NAME)]
1906 | Short_Descriptor [([Class =>] CLASS_NAME)]
1907
1908 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
1909 @end smallexample
1910
1911 @noindent
1912 Use this pragma to make a function externally callable and optionally
1913 provide information on mechanisms to be used for passing parameter and
1914 result values.  We recommend, for the purposes of improving portability,
1915 this pragma always be used in conjunction with a separate pragma
1916 @code{Export}, which must precede the pragma @code{Export_Function}.
1917 GNAT does not require a separate pragma @code{Export}, but if none is
1918 present, @code{Convention Ada} is assumed, which is usually
1919 not what is wanted, so it is usually appropriate to use this
1920 pragma in conjunction with a @code{Export} or @code{Convention}
1921 pragma that specifies the desired foreign convention.
1922 Pragma @code{Export_Function}
1923 (and @code{Export}, if present) must appear in the same declarative
1924 region as the function to which they apply.
1925
1926 @var{internal_name} must uniquely designate the function to which the
1927 pragma applies.  If more than one function name exists of this name in
1928 the declarative part you must use the @code{Parameter_Types} and
1929 @code{Result_Type} parameters is mandatory to achieve the required
1930 unique designation.  @var{subtype_mark}s in these parameters must
1931 exactly match the subtypes in the corresponding function specification,
1932 using positional notation to match parameters with subtype marks.
1933 The form with an @code{'Access} attribute can be used to match an
1934 anonymous access parameter.
1935
1936 @cindex OpenVMS
1937 @cindex Passing by descriptor
1938 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
1939 The default behavior for Export_Function is to accept either 64bit or
1940 32bit descriptors unless short_descriptor is specified, then only 32bit
1941 descriptors are accepted.
1942
1943 @cindex Suppressing external name
1944 Special treatment is given if the EXTERNAL is an explicit null
1945 string or a static string expressions that evaluates to the null
1946 string. In this case, no external name is generated. This form
1947 still allows the specification of parameter mechanisms.
1948
1949 @node Pragma Export_Object
1950 @unnumberedsec Pragma Export_Object
1951 @findex Export_Object
1952 @noindent
1953 Syntax:
1954
1955 @smallexample @c ada
1956 pragma Export_Object
1957       [Internal =>] LOCAL_NAME
1958    [, [External =>] EXTERNAL_SYMBOL]
1959    [, [Size     =>] EXTERNAL_SYMBOL]
1960
1961 EXTERNAL_SYMBOL ::=
1962   IDENTIFIER
1963 | static_string_EXPRESSION
1964 @end smallexample
1965
1966 @noindent
1967 This pragma designates an object as exported, and apart from the
1968 extended rules for external symbols, is identical in effect to the use of
1969 the normal @code{Export} pragma applied to an object.  You may use a
1970 separate Export pragma (and you probably should from the point of view
1971 of portability), but it is not required.  @var{Size} is syntax checked,
1972 but otherwise ignored by GNAT@.
1973
1974 @node Pragma Export_Procedure
1975 @unnumberedsec Pragma Export_Procedure
1976 @findex Export_Procedure
1977 @noindent
1978 Syntax:
1979
1980 @smallexample @c ada
1981 pragma Export_Procedure (
1982      [Internal        =>] LOCAL_NAME
1983   [, [External        =>] EXTERNAL_SYMBOL]
1984   [, [Parameter_Types =>] PARAMETER_TYPES]
1985   [, [Mechanism       =>] MECHANISM]);
1986
1987 EXTERNAL_SYMBOL ::=
1988   IDENTIFIER
1989 | static_string_EXPRESSION
1990 | ""
1991
1992 PARAMETER_TYPES ::=
1993   null
1994 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1995
1996 TYPE_DESIGNATOR ::=
1997   subtype_NAME
1998 | subtype_Name ' Access
1999
2000 MECHANISM ::=
2001   MECHANISM_NAME
2002 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2003
2004 MECHANISM_ASSOCIATION ::=
2005   [formal_parameter_NAME =>] MECHANISM_NAME
2006
2007 MECHANISM_NAME ::=
2008   Value
2009 | Reference
2010 | Descriptor [([Class =>] CLASS_NAME)]
2011 | Short_Descriptor [([Class =>] CLASS_NAME)]
2012
2013 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2014 @end smallexample
2015
2016 @noindent
2017 This pragma is identical to @code{Export_Function} except that it
2018 applies to a procedure rather than a function and the parameters
2019 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2020 GNAT does not require a separate pragma @code{Export}, but if none is
2021 present, @code{Convention Ada} is assumed, which is usually
2022 not what is wanted, so it is usually appropriate to use this
2023 pragma in conjunction with a @code{Export} or @code{Convention}
2024 pragma that specifies the desired foreign convention.
2025
2026 @cindex OpenVMS
2027 @cindex Passing by descriptor
2028 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2029 The default behavior for Export_Procedure is to accept either 64bit or
2030 32bit descriptors unless short_descriptor is specified, then only 32bit
2031 descriptors are accepted.
2032
2033 @cindex Suppressing external name
2034 Special treatment is given if the EXTERNAL is an explicit null
2035 string or a static string expressions that evaluates to the null
2036 string. In this case, no external name is generated. This form
2037 still allows the specification of parameter mechanisms.
2038
2039 @node Pragma Export_Value
2040 @unnumberedsec Pragma Export_Value
2041 @findex Export_Value
2042 @noindent
2043 Syntax:
2044
2045 @smallexample @c ada
2046 pragma Export_Value (
2047   [Value     =>] static_integer_EXPRESSION,
2048   [Link_Name =>] static_string_EXPRESSION);
2049 @end smallexample
2050
2051 @noindent
2052 This pragma serves to export a static integer value for external use.
2053 The first argument specifies the value to be exported. The Link_Name
2054 argument specifies the symbolic name to be associated with the integer
2055 value. This pragma is useful for defining a named static value in Ada
2056 that can be referenced in assembly language units to be linked with
2057 the application. This pragma is currently supported only for the
2058 AAMP target and is ignored for other targets.
2059
2060 @node Pragma Export_Valued_Procedure
2061 @unnumberedsec Pragma Export_Valued_Procedure
2062 @findex Export_Valued_Procedure
2063 @noindent
2064 Syntax:
2065
2066 @smallexample @c ada
2067 pragma Export_Valued_Procedure (
2068      [Internal        =>] LOCAL_NAME
2069   [, [External        =>] EXTERNAL_SYMBOL]
2070   [, [Parameter_Types =>] PARAMETER_TYPES]
2071   [, [Mechanism       =>] MECHANISM]);
2072
2073 EXTERNAL_SYMBOL ::=
2074   IDENTIFIER
2075 | static_string_EXPRESSION
2076 | ""
2077
2078 PARAMETER_TYPES ::=
2079   null
2080 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2081
2082 TYPE_DESIGNATOR ::=
2083   subtype_NAME
2084 | subtype_Name ' Access
2085
2086 MECHANISM ::=
2087   MECHANISM_NAME
2088 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2089
2090 MECHANISM_ASSOCIATION ::=
2091   [formal_parameter_NAME =>] MECHANISM_NAME
2092
2093 MECHANISM_NAME ::=
2094   Value
2095 | Reference
2096 | Descriptor [([Class =>] CLASS_NAME)]
2097 | Short_Descriptor [([Class =>] CLASS_NAME)]
2098
2099 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2100 @end smallexample
2101
2102 @noindent
2103 This pragma is identical to @code{Export_Procedure} except that the
2104 first parameter of @var{LOCAL_NAME}, which must be present, must be of
2105 mode @code{OUT}, and externally the subprogram is treated as a function
2106 with this parameter as the result of the function.  GNAT provides for
2107 this capability to allow the use of @code{OUT} and @code{IN OUT}
2108 parameters in interfacing to external functions (which are not permitted
2109 in Ada functions).
2110 GNAT does not require a separate pragma @code{Export}, but if none is
2111 present, @code{Convention Ada} is assumed, which is almost certainly
2112 not what is wanted since the whole point of this pragma is to interface
2113 with foreign language functions, so it is usually appropriate to use this
2114 pragma in conjunction with a @code{Export} or @code{Convention}
2115 pragma that specifies the desired foreign convention.
2116
2117 @cindex OpenVMS
2118 @cindex Passing by descriptor
2119 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2120 The default behavior for Export_Valued_Procedure is to accept either 64bit or
2121 32bit descriptors unless short_descriptor is specified, then only 32bit
2122 descriptors are accepted.
2123
2124 @cindex Suppressing external name
2125 Special treatment is given if the EXTERNAL is an explicit null
2126 string or a static string expressions that evaluates to the null
2127 string. In this case, no external name is generated. This form
2128 still allows the specification of parameter mechanisms.
2129
2130 @node Pragma Extend_System
2131 @unnumberedsec Pragma Extend_System
2132 @cindex @code{system}, extending
2133 @cindex Dec Ada 83
2134 @findex Extend_System
2135 @noindent
2136 Syntax:
2137
2138 @smallexample @c ada
2139 pragma Extend_System ([Name =>] IDENTIFIER);
2140 @end smallexample
2141
2142 @noindent
2143 This pragma is used to provide backwards compatibility with other
2144 implementations that extend the facilities of package @code{System}.  In
2145 GNAT, @code{System} contains only the definitions that are present in
2146 the Ada RM@.  However, other implementations, notably the DEC Ada 83
2147 implementation, provide many extensions to package @code{System}.
2148
2149 For each such implementation accommodated by this pragma, GNAT provides a
2150 package @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83
2151 implementation, which provides the required additional definitions.  You
2152 can use this package in two ways.  You can @code{with} it in the normal
2153 way and access entities either by selection or using a @code{use}
2154 clause.  In this case no special processing is required.
2155
2156 However, if existing code contains references such as
2157 @code{System.@var{xxx}} where @var{xxx} is an entity in the extended
2158 definitions provided in package @code{System}, you may use this pragma
2159 to extend visibility in @code{System} in a non-standard way that
2160 provides greater compatibility with the existing code.  Pragma
2161 @code{Extend_System} is a configuration pragma whose single argument is
2162 the name of the package containing the extended definition
2163 (e.g.@: @code{Aux_DEC} for the DEC Ada case).  A unit compiled under
2164 control of this pragma will be processed using special visibility
2165 processing that looks in package @code{System.Aux_@var{xxx}} where
2166 @code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
2167 package @code{System}, but not found in package @code{System}.
2168
2169 You can use this pragma either to access a predefined @code{System}
2170 extension supplied with the compiler, for example @code{Aux_DEC} or
2171 you can construct your own extension unit following the above
2172 definition.  Note that such a package is a child of @code{System}
2173 and thus is considered part of the implementation.  To compile
2174 it you will have to use the appropriate switch for compiling
2175 system units.  @xref{Top, @value{EDITION} User's Guide, About This
2176 Guide,, gnat_ugn, @value{EDITION} User's Guide}, for details.
2177
2178 @node Pragma External
2179 @unnumberedsec Pragma External
2180 @findex External
2181 @noindent
2182 Syntax:
2183
2184 @smallexample @c ada
2185 pragma External (
2186   [   Convention    =>] convention_IDENTIFIER,
2187   [   Entity        =>] LOCAL_NAME
2188   [, [External_Name =>] static_string_EXPRESSION ]
2189   [, [Link_Name     =>] static_string_EXPRESSION ]);
2190 @end smallexample
2191
2192 @noindent
2193 This pragma is identical in syntax and semantics to pragma
2194 @code{Export} as defined in the Ada Reference Manual.  It is
2195 provided for compatibility with some Ada 83 compilers that
2196 used this pragma for exactly the same purposes as pragma
2197 @code{Export} before the latter was standardized.
2198
2199 @node Pragma External_Name_Casing
2200 @unnumberedsec Pragma External_Name_Casing
2201 @cindex Dec Ada 83 casing compatibility
2202 @cindex External Names, casing
2203 @cindex Casing of External names
2204 @findex External_Name_Casing
2205 @noindent
2206 Syntax:
2207
2208 @smallexample @c ada
2209 pragma External_Name_Casing (
2210   Uppercase | Lowercase
2211   [, Uppercase | Lowercase | As_Is]);
2212 @end smallexample
2213
2214 @noindent
2215 This pragma provides control over the casing of external names associated
2216 with Import and Export pragmas.  There are two cases to consider:
2217
2218 @table @asis
2219 @item Implicit external names
2220 Implicit external names are derived from identifiers.  The most common case
2221 arises when a standard Ada Import or Export pragma is used with only two
2222 arguments, as in:
2223
2224 @smallexample @c ada
2225    pragma Import (C, C_Routine);
2226 @end smallexample
2227
2228 @noindent
2229 Since Ada is a case-insensitive language, the spelling of the identifier in
2230 the Ada source program does not provide any information on the desired
2231 casing of the external name, and so a convention is needed.  In GNAT the
2232 default treatment is that such names are converted to all lower case
2233 letters.  This corresponds to the normal C style in many environments.
2234 The first argument of pragma @code{External_Name_Casing} can be used to
2235 control this treatment.  If @code{Uppercase} is specified, then the name
2236 will be forced to all uppercase letters.  If @code{Lowercase} is specified,
2237 then the normal default of all lower case letters will be used.
2238
2239 This same implicit treatment is also used in the case of extended DEC Ada 83
2240 compatible Import and Export pragmas where an external name is explicitly
2241 specified using an identifier rather than a string.
2242
2243 @item Explicit external names
2244 Explicit external names are given as string literals.  The most common case
2245 arises when a standard Ada Import or Export pragma is used with three
2246 arguments, as in:
2247
2248 @smallexample @c ada
2249 pragma Import (C, C_Routine, "C_routine");
2250 @end smallexample
2251
2252 @noindent
2253 In this case, the string literal normally provides the exact casing required
2254 for the external name.  The second argument of pragma
2255 @code{External_Name_Casing} may be used to modify this behavior.
2256 If @code{Uppercase} is specified, then the name
2257 will be forced to all uppercase letters.  If @code{Lowercase} is specified,
2258 then the name will be forced to all lowercase letters.  A specification of
2259 @code{As_Is} provides the normal default behavior in which the casing is
2260 taken from the string provided.
2261 @end table
2262
2263 @noindent
2264 This pragma may appear anywhere that a pragma is valid.  In particular, it
2265 can be used as a configuration pragma in the @file{gnat.adc} file, in which
2266 case it applies to all subsequent compilations, or it can be used as a program
2267 unit pragma, in which case it only applies to the current unit, or it can
2268 be used more locally to control individual Import/Export pragmas.
2269
2270 It is primarily intended for use with OpenVMS systems, where many
2271 compilers convert all symbols to upper case by default.  For interfacing to
2272 such compilers (e.g.@: the DEC C compiler), it may be convenient to use
2273 the pragma:
2274
2275 @smallexample @c ada
2276 pragma External_Name_Casing (Uppercase, Uppercase);
2277 @end smallexample
2278
2279 @noindent
2280 to enforce the upper casing of all external symbols.
2281
2282 @node Pragma Fast_Math
2283 @unnumberedsec Pragma Fast_Math
2284 @findex Fast_Math
2285 @noindent
2286 Syntax:
2287
2288 @smallexample @c ada
2289 pragma Fast_Math;
2290 @end smallexample
2291
2292 @noindent
2293 This is a configuration pragma which activates a mode in which speed is
2294 considered more important for floating-point operations than absolutely
2295 accurate adherence to the requirements of the standard. Currently the
2296 following operations are affected:
2297
2298 @table @asis
2299 @item Complex Multiplication
2300 The normal simple formula for complex multiplication can result in intermediate
2301 overflows for numbers near the end of the range. The Ada standard requires that
2302 this situation be detected and corrected by scaling, but in Fast_Math mode such
2303 cases will simply result in overflow. Note that to take advantage of this you
2304 must instantiate your own version of @code{Ada.Numerics.Generic_Complex_Types}
2305 under control of the pragma, rather than use the preinstantiated versions.
2306 @end table
2307
2308 @node Pragma Favor_Top_Level
2309 @unnumberedsec Pragma Favor_Top_Level
2310 @findex Favor_Top_Level
2311 @noindent
2312 Syntax:
2313
2314 @smallexample @c ada
2315 pragma Favor_Top_Level (type_NAME);
2316 @end smallexample
2317
2318 @noindent
2319 The named type must be an access-to-subprogram type. This pragma is an
2320 efficiency hint to the compiler, regarding the use of 'Access or
2321 'Unrestricted_Access on nested (non-library-level) subprograms. The
2322 pragma means that nested subprograms are not used with this type, or
2323 are rare, so that the generated code should be efficient in the
2324 top-level case. When this pragma is used, dynamically generated
2325 trampolines may be used on some targets for nested subprograms.
2326 See also the No_Implicit_Dynamic_Code restriction.
2327
2328 @node Pragma Finalize_Storage_Only
2329 @unnumberedsec Pragma Finalize_Storage_Only
2330 @findex Finalize_Storage_Only
2331 @noindent
2332 Syntax:
2333
2334 @smallexample @c ada
2335 pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
2336 @end smallexample
2337
2338 @noindent
2339 This pragma allows the compiler not to emit a Finalize call for objects
2340 defined at the library level.  This is mostly useful for types where
2341 finalization is only used to deal with storage reclamation since in most
2342 environments it is not necessary to reclaim memory just before terminating
2343 execution, hence the name.
2344
2345 @node Pragma Float_Representation
2346 @unnumberedsec Pragma Float_Representation
2347 @cindex OpenVMS
2348 @findex Float_Representation
2349 @noindent
2350 Syntax:
2351
2352 @smallexample @c ada
2353 pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
2354
2355 FLOAT_REP ::= VAX_Float | IEEE_Float
2356 @end smallexample
2357
2358 @noindent
2359 In the one argument form, this pragma is a configuration pragma which
2360 allows control over the internal representation chosen for the predefined
2361 floating point types declared in the packages @code{Standard} and
2362 @code{System}. On all systems other than OpenVMS, the argument must
2363 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2364 argument may be @code{VAX_Float} to specify the use of the VAX float
2365 format for the floating-point types in Standard. This requires that
2366 the standard runtime libraries be recompiled.  @xref{The GNAT Run-Time
2367 Library Builder gnatlbr,,, gnat_ugn, @value{EDITION} User's Guide
2368 OpenVMS}, for a description of the @code{GNAT LIBRARY} command.
2369
2370 The two argument form specifies the representation to be used for
2371 the specified floating-point type. On all systems other than OpenVMS,
2372 the argument must
2373 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2374 argument may be @code{VAX_Float} to specify the use of the VAX float
2375 format, as follows:
2376
2377 @itemize @bullet
2378 @item
2379 For digits values up to 6, F float format will be used.
2380 @item
2381 For digits values from 7 to 9, G float format will be used.
2382 @item
2383 For digits values from 10 to 15, F float format will be used.
2384 @item
2385 Digits values above 15 are not allowed.
2386 @end itemize
2387
2388 @node Pragma Ident
2389 @unnumberedsec Pragma Ident
2390 @findex Ident
2391 @noindent
2392 Syntax:
2393
2394 @smallexample @c ada
2395 pragma Ident (static_string_EXPRESSION);
2396 @end smallexample
2397
2398 @noindent
2399 This pragma provides a string identification in the generated object file,
2400 if the system supports the concept of this kind of identification string.
2401 This pragma is allowed only in the outermost declarative part or
2402 declarative items of a compilation unit. If more than one @code{Ident}
2403 pragma is given, only the last one processed is effective.
2404 @cindex OpenVMS
2405 On OpenVMS systems, the effect of the pragma is identical to the effect of
2406 the DEC Ada 83 pragma of the same name. Note that in DEC Ada 83, the
2407 maximum allowed length is 31 characters, so if it is important to
2408 maintain compatibility with this compiler, you should obey this length
2409 limit.
2410
2411 @node Pragma Implemented_By_Entry
2412 @unnumberedsec Pragma Implemented_By_Entry
2413 @findex Implemented_By_Entry
2414 @noindent
2415 Syntax:
2416
2417 @smallexample @c ada
2418 pragma Implemented_By_Entry (LOCAL_NAME);
2419 @end smallexample
2420
2421 @noindent
2422 This is a representation pragma which applies to protected, synchronized and
2423 task interface primitives. If the pragma is applied to primitive operation Op
2424 of interface Iface, it is illegal to override Op in a type that implements
2425 Iface, with anything other than an entry.
2426
2427 @smallexample @c ada
2428 type Iface is protected interface;
2429 procedure Do_Something (Object : in out Iface) is abstract;
2430 pragma Implemented_By_Entry (Do_Something);
2431
2432 protected type P is new Iface with
2433    procedure Do_Something;  --  Illegal
2434 end P;
2435
2436 task type T is new Iface with
2437    entry Do_Something;      --  Legal
2438 end T;
2439 @end smallexample
2440
2441 @noindent
2442 NOTE: The pragma is still in its design stage by the Ada Rapporteur Group. It
2443 is intended to be used in conjunction with dispatching requeue statements as
2444 described in AI05-0030. Should the ARG decide on an official name and syntax,
2445 this pragma will become language-defined rather than GNAT-specific.
2446
2447 @node Pragma Implicit_Packing
2448 @unnumberedsec Pragma Implicit_Packing
2449 @findex Implicit_Packing
2450 @noindent
2451 Syntax:
2452
2453 @smallexample @c ada
2454 pragma Implicit_Packing;
2455 @end smallexample
2456
2457 @noindent
2458 This is a configuration pragma that requests implicit packing for packed
2459 arrays for which a size clause is given but no explicit pragma Pack or
2460 specification of Component_Size is present. It also applies to records
2461 where no record representation clause is present. Consider this example:
2462
2463 @smallexample @c ada
2464 type R is array (0 .. 7) of Boolean;
2465 for R'Size use 8;
2466 @end smallexample
2467
2468 @noindent
2469 In accordance with the recommendation in the RM (RM 13.3(53)), a Size clause
2470 does not change the layout of a composite object. So the Size clause in the
2471 above example is normally rejected, since the default layout of the array uses
2472 8-bit components, and thus the array requires a minimum of 64 bits.
2473
2474 If this declaration is compiled in a region of code covered by an occurrence
2475 of the configuration pragma Implicit_Packing, then the Size clause in this
2476 and similar examples will cause implicit packing and thus be accepted. For
2477 this implicit packing to occur, the type in question must be an array of small
2478 components whose size is known at compile time, and the Size clause must
2479 specify the exact size that corresponds to the length of the array multiplied
2480 by the size in bits of the component type.
2481 @cindex Array packing
2482
2483 Similarly, the following example shows the use in the record case
2484
2485 @smallexample @c ada
2486 type r is record
2487    a, b, c, d, e, f, g, h : boolean;
2488    chr                    : character;
2489 end record;
2490 for r'size use 16;
2491 @end smallexample
2492
2493 @noindent
2494 Without a pragma Pack, each Boolean field requires 8 bits, so the
2495 minimum size is 72 bits, but with a pragma Pack, 16 bits would be
2496 sufficient. The use of pragma Implciit_Packing allows this record
2497 declaration to compile without an explicit pragma Pack.
2498 @node Pragma Import_Exception
2499 @unnumberedsec Pragma Import_Exception
2500 @cindex OpenVMS
2501 @findex Import_Exception
2502 @noindent
2503 Syntax:
2504
2505 @smallexample @c ada
2506 pragma Import_Exception (
2507      [Internal =>] LOCAL_NAME
2508   [, [External =>] EXTERNAL_SYMBOL]
2509   [, [Form     =>] Ada | VMS]
2510   [, [Code     =>] static_integer_EXPRESSION]);
2511
2512 EXTERNAL_SYMBOL ::=
2513   IDENTIFIER
2514 | static_string_EXPRESSION
2515 @end smallexample
2516
2517 @noindent
2518 This pragma is implemented only in the OpenVMS implementation of GNAT@.
2519 It allows OpenVMS conditions (for example, from OpenVMS system services or
2520 other OpenVMS languages) to be propagated to Ada programs as Ada exceptions.
2521 The pragma specifies that the exception associated with an exception
2522 declaration in an Ada program be defined externally (in non-Ada code).
2523 For further details on this pragma, see the
2524 DEC Ada Language Reference Manual, section 13.9a.3.1.
2525
2526 @node Pragma Import_Function
2527 @unnumberedsec Pragma Import_Function
2528 @findex Import_Function
2529 @noindent
2530 Syntax:
2531
2532 @smallexample @c ada
2533 pragma Import_Function (
2534      [Internal                 =>] LOCAL_NAME,
2535   [, [External                 =>] EXTERNAL_SYMBOL]
2536   [, [Parameter_Types          =>] PARAMETER_TYPES]
2537   [, [Result_Type              =>] SUBTYPE_MARK]
2538   [, [Mechanism                =>] MECHANISM]
2539   [, [Result_Mechanism         =>] MECHANISM_NAME]
2540   [, [First_Optional_Parameter =>] IDENTIFIER]);
2541
2542 EXTERNAL_SYMBOL ::=
2543   IDENTIFIER
2544 | static_string_EXPRESSION
2545
2546 PARAMETER_TYPES ::=
2547   null
2548 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2549
2550 TYPE_DESIGNATOR ::=
2551   subtype_NAME
2552 | subtype_Name ' Access
2553
2554 MECHANISM ::=
2555   MECHANISM_NAME
2556 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2557
2558 MECHANISM_ASSOCIATION ::=
2559   [formal_parameter_NAME =>] MECHANISM_NAME
2560
2561 MECHANISM_NAME ::=
2562   Value
2563 | Reference
2564 | Descriptor [([Class =>] CLASS_NAME)]
2565 | Short_Descriptor [([Class =>] CLASS_NAME)]
2566
2567 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2568 @end smallexample
2569
2570 @noindent
2571 This pragma is used in conjunction with a pragma @code{Import} to
2572 specify additional information for an imported function.  The pragma
2573 @code{Import} (or equivalent pragma @code{Interface}) must precede the
2574 @code{Import_Function} pragma and both must appear in the same
2575 declarative part as the function specification.
2576
2577 The @var{Internal} argument must uniquely designate
2578 the function to which the
2579 pragma applies.  If more than one function name exists of this name in
2580 the declarative part you must use the @code{Parameter_Types} and
2581 @var{Result_Type} parameters to achieve the required unique
2582 designation.  Subtype marks in these parameters must exactly match the
2583 subtypes in the corresponding function specification, using positional
2584 notation to match parameters with subtype marks.
2585 The form with an @code{'Access} attribute can be used to match an
2586 anonymous access parameter.
2587
2588 You may optionally use the @var{Mechanism} and @var{Result_Mechanism}
2589 parameters to specify passing mechanisms for the
2590 parameters and result.  If you specify a single mechanism name, it
2591 applies to all parameters.  Otherwise you may specify a mechanism on a
2592 parameter by parameter basis using either positional or named
2593 notation.  If the mechanism is not specified, the default mechanism
2594 is used.
2595
2596 @cindex OpenVMS
2597 @cindex Passing by descriptor
2598 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2599 The default behavior for Import_Function is to pass a 64bit descriptor
2600 unless short_descriptor is specified, then a 32bit descriptor is passed.
2601
2602 @code{First_Optional_Parameter} applies only to OpenVMS ports of GNAT@.
2603 It specifies that the designated parameter and all following parameters
2604 are optional, meaning that they are not passed at the generated code
2605 level (this is distinct from the notion of optional parameters in Ada
2606 where the parameters are passed anyway with the designated optional
2607 parameters).  All optional parameters must be of mode @code{IN} and have
2608 default parameter values that are either known at compile time
2609 expressions, or uses of the @code{'Null_Parameter} attribute.
2610
2611 @node Pragma Import_Object
2612 @unnumberedsec Pragma Import_Object
2613 @findex Import_Object
2614 @noindent
2615 Syntax:
2616
2617 @smallexample @c ada
2618 pragma Import_Object
2619      [Internal =>] LOCAL_NAME
2620   [, [External =>] EXTERNAL_SYMBOL]
2621   [, [Size     =>] EXTERNAL_SYMBOL]);
2622
2623 EXTERNAL_SYMBOL ::=
2624   IDENTIFIER
2625 | static_string_EXPRESSION
2626 @end smallexample
2627
2628 @noindent
2629 This pragma designates an object as imported, and apart from the
2630 extended rules for external symbols, is identical in effect to the use of
2631 the normal @code{Import} pragma applied to an object.  Unlike the
2632 subprogram case, you need not use a separate @code{Import} pragma,
2633 although you may do so (and probably should do so from a portability
2634 point of view).  @var{size} is syntax checked, but otherwise ignored by
2635 GNAT@.
2636
2637 @node Pragma Import_Procedure
2638 @unnumberedsec Pragma Import_Procedure
2639 @findex Import_Procedure
2640 @noindent
2641 Syntax:
2642
2643 @smallexample @c ada
2644 pragma Import_Procedure (
2645      [Internal                 =>] LOCAL_NAME
2646   [, [External                 =>] EXTERNAL_SYMBOL]
2647   [, [Parameter_Types          =>] PARAMETER_TYPES]
2648   [, [Mechanism                =>] MECHANISM]
2649   [, [First_Optional_Parameter =>] IDENTIFIER]);
2650
2651 EXTERNAL_SYMBOL ::=
2652   IDENTIFIER
2653 | static_string_EXPRESSION
2654
2655 PARAMETER_TYPES ::=
2656   null
2657 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2658
2659 TYPE_DESIGNATOR ::=
2660   subtype_NAME
2661 | subtype_Name ' Access
2662
2663 MECHANISM ::=
2664   MECHANISM_NAME
2665 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2666
2667 MECHANISM_ASSOCIATION ::=
2668   [formal_parameter_NAME =>] MECHANISM_NAME
2669
2670 MECHANISM_NAME ::=
2671   Value
2672 | Reference
2673 | Descriptor [([Class =>] CLASS_NAME)]
2674 | Short_Descriptor [([Class =>] CLASS_NAME)]
2675
2676 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2677 @end smallexample
2678
2679 @noindent
2680 This pragma is identical to @code{Import_Function} except that it
2681 applies to a procedure rather than a function and the parameters
2682 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2683
2684 @node Pragma Import_Valued_Procedure
2685 @unnumberedsec Pragma Import_Valued_Procedure
2686 @findex Import_Valued_Procedure
2687 @noindent
2688 Syntax:
2689
2690 @smallexample @c ada
2691 pragma Import_Valued_Procedure (
2692      [Internal                 =>] LOCAL_NAME
2693   [, [External                 =>] EXTERNAL_SYMBOL]
2694   [, [Parameter_Types          =>] PARAMETER_TYPES]
2695   [, [Mechanism                =>] MECHANISM]
2696   [, [First_Optional_Parameter =>] IDENTIFIER]);
2697
2698 EXTERNAL_SYMBOL ::=
2699   IDENTIFIER
2700 | static_string_EXPRESSION
2701
2702 PARAMETER_TYPES ::=
2703   null
2704 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2705
2706 TYPE_DESIGNATOR ::=
2707   subtype_NAME
2708 | subtype_Name ' Access
2709
2710 MECHANISM ::=
2711   MECHANISM_NAME
2712 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2713
2714 MECHANISM_ASSOCIATION ::=
2715   [formal_parameter_NAME =>] MECHANISM_NAME
2716
2717 MECHANISM_NAME ::=
2718   Value
2719 | Reference
2720 | Descriptor [([Class =>] CLASS_NAME)]
2721 | Short_Descriptor [([Class =>] CLASS_NAME)]
2722
2723 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2724 @end smallexample
2725
2726 @noindent
2727 This pragma is identical to @code{Import_Procedure} except that the
2728 first parameter of @var{LOCAL_NAME}, which must be present, must be of
2729 mode @code{OUT}, and externally the subprogram is treated as a function
2730 with this parameter as the result of the function.  The purpose of this
2731 capability is to allow the use of @code{OUT} and @code{IN OUT}
2732 parameters in interfacing to external functions (which are not permitted
2733 in Ada functions).  You may optionally use the @code{Mechanism}
2734 parameters to specify passing mechanisms for the parameters.
2735 If you specify a single mechanism name, it applies to all parameters.
2736 Otherwise you may specify a mechanism on a parameter by parameter
2737 basis using either positional or named notation.  If the mechanism is not
2738 specified, the default mechanism is used.
2739
2740 Note that it is important to use this pragma in conjunction with a separate
2741 pragma Import that specifies the desired convention, since otherwise the
2742 default convention is Ada, which is almost certainly not what is required.
2743
2744 @node Pragma Initialize_Scalars
2745 @unnumberedsec Pragma Initialize_Scalars
2746 @findex Initialize_Scalars
2747 @cindex debugging with Initialize_Scalars
2748 @noindent
2749 Syntax:
2750
2751 @smallexample @c ada
2752 pragma Initialize_Scalars;
2753 @end smallexample
2754
2755 @noindent
2756 This pragma is similar to @code{Normalize_Scalars} conceptually but has
2757 two important differences.  First, there is no requirement for the pragma
2758 to be used uniformly in all units of a partition, in particular, it is fine
2759 to use this just for some or all of the application units of a partition,
2760 without needing to recompile the run-time library.
2761
2762 In the case where some units are compiled with the pragma, and some without,
2763 then a declaration of a variable where the type is defined in package
2764 Standard or is locally declared will always be subject to initialization,
2765 as will any declaration of a scalar variable.  For composite variables,
2766 whether the variable is initialized may also depend on whether the package
2767 in which the type of the variable is declared is compiled with the pragma.
2768
2769 The other important difference is that you can control the value used
2770 for initializing scalar objects.  At bind time, you can select several
2771 options for initialization. You can
2772 initialize with invalid values (similar to Normalize_Scalars, though for
2773 Initialize_Scalars it is not always possible to determine the invalid
2774 values in complex cases like signed component fields with non-standard
2775 sizes). You can also initialize with high or
2776 low values, or with a specified bit pattern.  See the users guide for binder
2777 options for specifying these cases.
2778
2779 This means that you can compile a program, and then without having to
2780 recompile the program, you can run it with different values being used
2781 for initializing otherwise uninitialized values, to test if your program
2782 behavior depends on the choice.  Of course the behavior should not change,
2783 and if it does, then most likely you have an erroneous reference to an
2784 uninitialized value.
2785
2786 It is even possible to change the value at execution time eliminating even
2787 the need to rebind with a different switch using an environment variable.
2788 See the GNAT users guide for details.
2789
2790 Note that pragma @code{Initialize_Scalars} is particularly useful in
2791 conjunction with the enhanced validity checking that is now provided
2792 in GNAT, which checks for invalid values under more conditions.
2793 Using this feature (see description of the @option{-gnatV} flag in the
2794 users guide) in conjunction with pragma @code{Initialize_Scalars}
2795 provides a powerful new tool to assist in the detection of problems
2796 caused by uninitialized variables.
2797
2798 Note: the use of @code{Initialize_Scalars} has a fairly extensive
2799 effect on the generated code. This may cause your code to be
2800 substantially larger. It may also cause an increase in the amount
2801 of stack required, so it is probably a good idea to turn on stack
2802 checking (see description of stack checking in the GNAT users guide)
2803 when using this pragma.
2804
2805 @node Pragma Inline_Always
2806 @unnumberedsec Pragma Inline_Always
2807 @findex Inline_Always
2808 @noindent
2809 Syntax:
2810
2811 @smallexample @c ada
2812 pragma Inline_Always (NAME [, NAME]);
2813 @end smallexample
2814
2815 @noindent
2816 Similar to pragma @code{Inline} except that inlining is not subject to
2817 the use of option @option{-gnatn} and the inlining happens regardless of
2818 whether this option is used.
2819
2820 @node Pragma Inline_Generic
2821 @unnumberedsec Pragma Inline_Generic
2822 @findex Inline_Generic
2823 @noindent
2824 Syntax:
2825
2826 @smallexample @c ada
2827 pragma Inline_Generic (generic_package_NAME);
2828 @end smallexample
2829
2830 @noindent
2831 This is implemented for compatibility with DEC Ada 83 and is recognized,
2832 but otherwise ignored, by GNAT@.  All generic instantiations are inlined
2833 by default when using GNAT@.
2834
2835 @node Pragma Interface
2836 @unnumberedsec Pragma Interface
2837 @findex Interface
2838 @noindent
2839 Syntax:
2840
2841 @smallexample @c ada
2842 pragma Interface (
2843      [Convention    =>] convention_identifier,
2844      [Entity        =>] local_NAME
2845   [, [External_Name =>] static_string_expression]
2846   [, [Link_Name     =>] static_string_expression]);
2847 @end smallexample
2848
2849 @noindent
2850 This pragma is identical in syntax and semantics to
2851 the standard Ada pragma @code{Import}.  It is provided for compatibility
2852 with Ada 83.  The definition is upwards compatible both with pragma
2853 @code{Interface} as defined in the Ada 83 Reference Manual, and also
2854 with some extended implementations of this pragma in certain Ada 83
2855 implementations.
2856
2857 @node Pragma Interface_Name
2858 @unnumberedsec Pragma Interface_Name
2859 @findex Interface_Name
2860 @noindent
2861 Syntax:
2862
2863 @smallexample @c ada
2864 pragma Interface_Name (
2865      [Entity        =>] LOCAL_NAME
2866   [, [External_Name =>] static_string_EXPRESSION]
2867   [, [Link_Name     =>] static_string_EXPRESSION]);
2868 @end smallexample
2869
2870 @noindent
2871 This pragma provides an alternative way of specifying the interface name
2872 for an interfaced subprogram, and is provided for compatibility with Ada
2873 83 compilers that use the pragma for this purpose.  You must provide at
2874 least one of @var{External_Name} or @var{Link_Name}.
2875
2876 @node Pragma Interrupt_Handler
2877 @unnumberedsec Pragma Interrupt_Handler
2878 @findex Interrupt_Handler
2879 @noindent
2880 Syntax:
2881
2882 @smallexample @c ada
2883 pragma Interrupt_Handler (procedure_LOCAL_NAME);
2884 @end smallexample
2885
2886 @noindent
2887 This program unit pragma is supported for parameterless protected procedures
2888 as described in Annex C of the Ada Reference Manual. On the AAMP target
2889 the pragma can also be specified for nonprotected parameterless procedures
2890 that are declared at the library level (which includes procedures
2891 declared at the top level of a library package). In the case of AAMP,
2892 when this pragma is applied to a nonprotected procedure, the instruction
2893 @code{IERET} is generated for returns from the procedure, enabling
2894 maskable interrupts, in place of the normal return instruction.
2895
2896 @node Pragma Interrupt_State
2897 @unnumberedsec Pragma Interrupt_State
2898 @findex Interrupt_State
2899 @noindent
2900 Syntax:
2901
2902 @smallexample @c ada
2903 pragma Interrupt_State
2904  ([Name  =>] value,
2905   [State =>] SYSTEM | RUNTIME | USER);
2906 @end smallexample
2907
2908 @noindent
2909 Normally certain interrupts are reserved to the implementation.  Any attempt
2910 to attach an interrupt causes Program_Error to be raised, as described in
2911 RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
2912 many systems for an @kbd{Ctrl-C} interrupt.  Normally this interrupt is
2913 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
2914 interrupt execution.  Additionally, signals such as @code{SIGSEGV},
2915 @code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
2916 Ada exceptions, or used to implement run-time functions such as the
2917 @code{abort} statement and stack overflow checking.
2918
2919 Pragma @code{Interrupt_State} provides a general mechanism for overriding
2920 such uses of interrupts.  It subsumes the functionality of pragma
2921 @code{Unreserve_All_Interrupts}.  Pragma @code{Interrupt_State} is not
2922 available on OS/2, Windows or VMS.  On all other platforms than VxWorks,
2923 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
2924 and may be used to mark interrupts required by the board support package
2925 as reserved.
2926
2927 Interrupts can be in one of three states:
2928 @itemize @bullet
2929 @item System
2930
2931 The interrupt is reserved (no Ada handler can be installed), and the
2932 Ada run-time may not install a handler. As a result you are guaranteed
2933 standard system default action if this interrupt is raised.
2934
2935 @item Runtime
2936
2937 The interrupt is reserved (no Ada handler can be installed). The run time
2938 is allowed to install a handler for internal control purposes, but is
2939 not required to do so.
2940
2941 @item User
2942
2943 The interrupt is unreserved.  The user may install a handler to provide
2944 some other action.
2945 @end itemize
2946
2947 @noindent
2948 These states are the allowed values of the @code{State} parameter of the
2949 pragma.  The @code{Name} parameter is a value of the type
2950 @code{Ada.Interrupts.Interrupt_ID}.  Typically, it is a name declared in
2951 @code{Ada.Interrupts.Names}.
2952
2953 This is a configuration pragma, and the binder will check that there
2954 are no inconsistencies between different units in a partition in how a
2955 given interrupt is specified. It may appear anywhere a pragma is legal.
2956
2957 The effect is to move the interrupt to the specified state.
2958
2959 By declaring interrupts to be SYSTEM, you guarantee the standard system
2960 action, such as a core dump.
2961
2962 By declaring interrupts to be USER, you guarantee that you can install
2963 a handler.
2964
2965 Note that certain signals on many operating systems cannot be caught and
2966 handled by applications.  In such cases, the pragma is ignored.  See the
2967 operating system documentation, or the value of the array @code{Reserved}
2968 declared in the spec of package @code{System.OS_Interface}.
2969
2970 Overriding the default state of signals used by the Ada runtime may interfere
2971 with an application's runtime behavior in the cases of the synchronous signals,
2972 and in the case of the signal used to implement the @code{abort} statement.
2973
2974 @node Pragma Keep_Names
2975 @unnumberedsec Pragma Keep_Names
2976 @findex Keep_Names
2977 @noindent
2978 Syntax:
2979
2980 @smallexample @c ada
2981 pragma Keep_Names ([On =>] enumeration_first_subtype_LOCAL_NAME);
2982 @end smallexample
2983
2984 @noindent
2985 The @var{LOCAL_NAME} argument
2986 must refer to an enumeration first subtype
2987 in the current declarative part. The effect is to retain the enumeration
2988 literal names for use by @code{Image} and @code{Value} even if a global
2989 @code{Discard_Names} pragma applies. This is useful when you want to
2990 generally suppress enumeration literal names and for example you therefore
2991 use a @code{Discard_Names} pragma in the @file{gnat.adc} file, but you
2992 want to retain the names for specific enumeration types.
2993
2994 @node Pragma License
2995 @unnumberedsec Pragma License
2996 @findex License
2997 @cindex License checking
2998 @noindent
2999 Syntax:
3000
3001 @smallexample @c ada
3002 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
3003 @end smallexample
3004
3005 @noindent
3006 This pragma is provided to allow automated checking for appropriate license
3007 conditions with respect to the standard and modified GPL@.  A pragma
3008 @code{License}, which is a configuration pragma that typically appears at
3009 the start of a source file or in a separate @file{gnat.adc} file, specifies
3010 the licensing conditions of a unit as follows:
3011
3012 @itemize @bullet
3013 @item Unrestricted
3014 This is used for a unit that can be freely used with no license restrictions.
3015 Examples of such units are public domain units, and units from the Ada
3016 Reference Manual.
3017
3018 @item GPL
3019 This is used for a unit that is licensed under the unmodified GPL, and which
3020 therefore cannot be @code{with}'ed by a restricted unit.
3021
3022 @item Modified_GPL
3023 This is used for a unit licensed under the GNAT modified GPL that includes
3024 a special exception paragraph that specifically permits the inclusion of
3025 the unit in programs without requiring the entire program to be released
3026 under the GPL@.
3027
3028 @item Restricted
3029 This is used for a unit that is restricted in that it is not permitted to
3030 depend on units that are licensed under the GPL@.  Typical examples are
3031 proprietary code that is to be released under more restrictive license
3032 conditions.  Note that restricted units are permitted to @code{with} units
3033 which are licensed under the modified GPL (this is the whole point of the
3034 modified GPL).
3035
3036 @end itemize
3037
3038 @noindent
3039 Normally a unit with no @code{License} pragma is considered to have an
3040 unknown license, and no checking is done.  However, standard GNAT headers
3041 are recognized, and license information is derived from them as follows.
3042
3043 @itemize @bullet
3044
3045 A GNAT license header starts with a line containing 78 hyphens.  The following
3046 comment text is searched for the appearance of any of the following strings.
3047
3048 If the string ``GNU General Public License'' is found, then the unit is assumed
3049 to have GPL license, unless the string ``As a special exception'' follows, in
3050 which case the license is assumed to be modified GPL@.
3051
3052 If one of the strings
3053 ``This specification is adapted from the Ada Semantic Interface'' or
3054 ``This specification is derived from the Ada Reference Manual'' is found
3055 then the unit is assumed to be unrestricted.
3056 @end itemize
3057
3058 @noindent
3059 These default actions means that a program with a restricted license pragma
3060 will automatically get warnings if a GPL unit is inappropriately
3061 @code{with}'ed.  For example, the program:
3062
3063 @smallexample @c ada
3064 with Sem_Ch3;
3065 with GNAT.Sockets;
3066 procedure Secret_Stuff is
3067   @dots{}
3068 end Secret_Stuff
3069 @end smallexample
3070
3071 @noindent
3072 if compiled with pragma @code{License} (@code{Restricted}) in a
3073 @file{gnat.adc} file will generate the warning:
3074
3075 @smallexample
3076 1.  with Sem_Ch3;
3077         |
3078    >>> license of withed unit "Sem_Ch3" is incompatible
3079
3080 2.  with GNAT.Sockets;
3081 3.  procedure Secret_Stuff is
3082 @end smallexample
3083
3084 @noindent
3085 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
3086 compiler and is licensed under the
3087 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
3088 run time, and is therefore licensed under the modified GPL@.
3089
3090 @node Pragma Link_With
3091 @unnumberedsec Pragma Link_With
3092 @findex Link_With
3093 @noindent
3094 Syntax:
3095
3096 @smallexample @c ada
3097 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
3098 @end smallexample
3099
3100 @noindent
3101 This pragma is provided for compatibility with certain Ada 83 compilers.
3102 It has exactly the same effect as pragma @code{Linker_Options} except
3103 that spaces occurring within one of the string expressions are treated
3104 as separators. For example, in the following case:
3105
3106 @smallexample @c ada
3107 pragma Link_With ("-labc -ldef");
3108 @end smallexample
3109
3110 @noindent
3111 results in passing the strings @code{-labc} and @code{-ldef} as two
3112 separate arguments to the linker. In addition pragma Link_With allows
3113 multiple arguments, with the same effect as successive pragmas.
3114
3115 @node Pragma Linker_Alias
3116 @unnumberedsec Pragma Linker_Alias
3117 @findex Linker_Alias
3118 @noindent
3119 Syntax:
3120
3121 @smallexample @c ada
3122 pragma Linker_Alias (
3123   [Entity =>] LOCAL_NAME,
3124   [Target =>] static_string_EXPRESSION);
3125 @end smallexample
3126
3127 @noindent
3128 @var{LOCAL_NAME} must refer to an object that is declared at the library
3129 level. This pragma establishes the given entity as a linker alias for the
3130 given target. It is equivalent to @code{__attribute__((alias))} in GNU C
3131 and causes @var{LOCAL_NAME} to be emitted as an alias for the symbol
3132 @var{static_string_EXPRESSION} in the object file, that is to say no space
3133 is reserved for @var{LOCAL_NAME} by the assembler and it will be resolved
3134 to the same address as @var{static_string_EXPRESSION} by the linker.
3135
3136 The actual linker name for the target must be used (e.g.@: the fully
3137 encoded name with qualification in Ada, or the mangled name in C++),
3138 or it must be declared using the C convention with @code{pragma Import}
3139 or @code{pragma Export}.
3140
3141 Not all target machines support this pragma. On some of them it is accepted
3142 only if @code{pragma Weak_External} has been applied to @var{LOCAL_NAME}.
3143
3144 @smallexample @c ada
3145 --  Example of the use of pragma Linker_Alias
3146
3147 package p is
3148   i : Integer := 1;
3149   pragma Export (C, i);
3150
3151   new_name_for_i : Integer;
3152   pragma Linker_Alias (new_name_for_i, "i");
3153 end p;
3154 @end smallexample
3155
3156 @node Pragma Linker_Constructor
3157 @unnumberedsec Pragma Linker_Constructor
3158 @findex Linker_Constructor
3159 @noindent
3160 Syntax:
3161
3162 @smallexample @c ada
3163 pragma Linker_Constructor (procedure_LOCAL_NAME);
3164 @end smallexample
3165
3166 @noindent
3167 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
3168 is declared at the library level. A procedure to which this pragma is
3169 applied will be treated as an initialization routine by the linker.
3170 It is equivalent to @code{__attribute__((constructor))} in GNU C and
3171 causes @var{procedure_LOCAL_NAME} to be invoked before the entry point
3172 of the executable is called (or immediately after the shared library is
3173 loaded if the procedure is linked in a shared library), in particular
3174 before the Ada run-time environment is set up.
3175
3176 Because of these specific contexts, the set of operations such a procedure
3177 can perform is very limited and the type of objects it can manipulate is
3178 essentially restricted to the elementary types. In particular, it must only
3179 contain code to which pragma Restrictions (No_Elaboration_Code) applies.
3180
3181 This pragma is used by GNAT to implement auto-initialization of shared Stand
3182 Alone Libraries, which provides a related capability without the restrictions
3183 listed above. Where possible, the use of Stand Alone Libraries is preferable
3184 to the use of this pragma.
3185
3186 @node Pragma Linker_Destructor
3187 @unnumberedsec Pragma Linker_Destructor
3188 @findex Linker_Destructor
3189 @noindent
3190 Syntax:
3191
3192 @smallexample @c ada
3193 pragma Linker_Destructor (procedure_LOCAL_NAME);
3194 @end smallexample
3195
3196 @noindent
3197 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
3198 is declared at the library level. A procedure to which this pragma is
3199 applied will be treated as a finalization routine by the linker.
3200 It is equivalent to @code{__attribute__((destructor))} in GNU C and
3201 causes @var{procedure_LOCAL_NAME} to be invoked after the entry point
3202 of the executable has exited (or immediately before the shared library
3203 is unloaded if the procedure is linked in a shared library), in particular
3204 after the Ada run-time environment is shut down.
3205
3206 See @code{pragma Linker_Constructor} for the set of restrictions that apply
3207 because of these specific contexts.
3208
3209 @node Pragma Linker_Section
3210 @unnumberedsec Pragma Linker_Section
3211 @findex Linker_Section
3212 @noindent
3213 Syntax:
3214
3215 @smallexample @c ada
3216 pragma Linker_Section (
3217   [Entity  =>] LOCAL_NAME,
3218   [Section =>] static_string_EXPRESSION);
3219 @end smallexample
3220
3221 @noindent
3222 @var{LOCAL_NAME} must refer to an object that is declared at the library
3223 level. This pragma specifies the name of the linker section for the given
3224 entity. It is equivalent to @code{__attribute__((section))} in GNU C and
3225 causes @var{LOCAL_NAME} to be placed in the @var{static_string_EXPRESSION}
3226 section of the executable (assuming the linker doesn't rename the section).
3227
3228 The compiler normally places library-level objects in standard sections
3229 depending on their type: procedures and functions generally go in the
3230 @code{.text} section, initialized variables in the @code{.data} section
3231 and uninitialized variables in the @code{.bss} section.
3232
3233 Other, special sections may exist on given target machines to map special
3234 hardware, for example I/O ports or flash memory. This pragma is a means to
3235 defer the final layout of the executable to the linker, thus fully working
3236 at the symbolic level with the compiler.
3237
3238 Some file formats do not support arbitrary sections so not all target
3239 machines support this pragma. The use of this pragma may cause a program
3240 execution to be erroneous if it is used to place an entity into an
3241 inappropriate section (e.g.@: a modified variable into the @code{.text}
3242 section). See also @code{pragma Persistent_BSS}.
3243
3244 @smallexample @c ada
3245 --  Example of the use of pragma Linker_Section
3246
3247 package IO_Card is
3248   Port_A : Integer;
3249   pragma Volatile (Port_A);
3250   pragma Linker_Section (Port_A, ".bss.port_a");
3251
3252   Port_B : Integer;
3253   pragma Volatile (Port_B);
3254   pragma Linker_Section (Port_B, ".bss.port_b");
3255 end IO_Card;
3256 @end smallexample
3257
3258 @node Pragma Long_Float
3259 @unnumberedsec Pragma Long_Float
3260 @cindex OpenVMS
3261 @findex Long_Float
3262 @noindent
3263 Syntax:
3264
3265 @smallexample @c ada
3266 pragma Long_Float (FLOAT_FORMAT);
3267
3268 FLOAT_FORMAT ::= D_Float | G_Float
3269 @end smallexample
3270
3271 @noindent
3272 This pragma is implemented only in the OpenVMS implementation of GNAT@.
3273 It allows control over the internal representation chosen for the predefined
3274 type @code{Long_Float} and for floating point type representations with
3275 @code{digits} specified in the range 7 through 15.
3276 For further details on this pragma, see the
3277 @cite{DEC Ada Language Reference Manual}, section 3.5.7b.  Note that to use
3278 this pragma, the standard runtime libraries must be recompiled.
3279 @xref{The GNAT Run-Time Library Builder gnatlbr,,, gnat_ugn,
3280 @value{EDITION} User's Guide OpenVMS}, for a description of the
3281 @code{GNAT LIBRARY} command.
3282
3283 @node Pragma Machine_Attribute
3284 @unnumberedsec Pragma Machine_Attribute
3285 @findex Machine_Attribute
3286 @noindent
3287 Syntax:
3288
3289 @smallexample @c ada
3290 pragma Machine_Attribute (
3291      [Entity         =>] LOCAL_NAME,
3292      [Attribute_Name =>] static_string_EXPRESSION
3293   [, [Info           =>] static_EXPRESSION] );
3294 @end smallexample
3295
3296 @noindent
3297 Machine-dependent attributes can be specified for types and/or
3298 declarations.  This pragma is semantically equivalent to
3299 @code{__attribute__((@var{attribute_name}))} (if @var{info} is not
3300 specified) or @code{__attribute__((@var{attribute_name}(@var{info})))}
3301 in GNU C, where @code{@var{attribute_name}} is recognized by the
3302 compiler middle-end or the @code{TARGET_ATTRIBUTE_TABLE} machine
3303 specific macro.  A string literal for the optional parameter @var{info}
3304 is transformed into an identifier, which may make this pragma unusable
3305 for some attributes.  @xref{Target Attributes,, Defining target-specific
3306 uses of @code{__attribute__}, gccint, GNU Compiler Collection (GCC)
3307 Internals}, further information.
3308
3309 @node Pragma Main
3310 @unnumberedsec Pragma Main
3311 @cindex OpenVMS
3312 @findex Main
3313 @noindent
3314 Syntax:
3315
3316 @smallexample @c ada
3317 pragma Main
3318  (MAIN_OPTION [, MAIN_OPTION]);
3319
3320 MAIN_OPTION ::=
3321   [Stack_Size              =>] static_integer_EXPRESSION
3322 | [Task_Stack_Size_Default =>] static_integer_EXPRESSION
3323 | [Time_Slicing_Enabled    =>] static_boolean_EXPRESSION
3324 @end smallexample
3325
3326 @noindent
3327 This pragma is provided for compatibility with OpenVMS VAX Systems.  It has
3328 no effect in GNAT, other than being syntax checked.
3329
3330 @node Pragma Main_Storage
3331 @unnumberedsec Pragma Main_Storage
3332 @cindex OpenVMS
3333 @findex Main_Storage
3334 @noindent
3335 Syntax:
3336
3337 @smallexample @c ada
3338 pragma Main_Storage
3339   (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
3340
3341 MAIN_STORAGE_OPTION ::=
3342   [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
3343 | [TOP_GUARD       =>] static_SIMPLE_EXPRESSION
3344 @end smallexample
3345
3346 @noindent
3347 This pragma is provided for compatibility with OpenVMS VAX Systems.  It has
3348 no effect in GNAT, other than being syntax checked.  Note that the pragma
3349 also has no effect in DEC Ada 83 for OpenVMS Alpha Systems.
3350
3351 @node Pragma No_Body
3352 @unnumberedsec Pragma No_Body
3353 @findex No_Body
3354 @noindent
3355 Syntax:
3356
3357 @smallexample @c ada
3358 pragma No_Body;
3359 @end smallexample
3360
3361 @noindent
3362 There are a number of cases in which a package spec does not require a body,
3363 and in fact a body is not permitted. GNAT will not permit the spec to be
3364 compiled if there is a body around. The pragma No_Body allows you to provide
3365 a body file, even in a case where no body is allowed. The body file must
3366 contain only comments and a single No_Body pragma. This is recognized by
3367 the compiler as indicating that no body is logically present.
3368
3369 This is particularly useful during maintenance when a package is modified in
3370 such a way that a body needed before is no longer needed. The provision of a
3371 dummy body with a No_Body pragma ensures that there is no interference from
3372 earlier versions of the package body.
3373
3374 @node Pragma No_Return
3375 @unnumberedsec Pragma No_Return
3376 @findex No_Return
3377 @noindent
3378 Syntax:
3379
3380 @smallexample @c ada
3381 pragma No_Return (procedure_LOCAL_NAME @{, procedure_LOCAL_NAME@});
3382 @end smallexample
3383
3384 @noindent
3385 Each @var{procedure_LOCAL_NAME} argument must refer to one or more procedure
3386 declarations in the current declarative part.  A procedure to which this
3387 pragma is applied may not contain any explicit @code{return} statements.
3388 In addition, if the procedure contains any implicit returns from falling
3389 off the end of a statement sequence, then execution of that implicit
3390 return will cause Program_Error to be raised.
3391
3392 One use of this pragma is to identify procedures whose only purpose is to raise
3393 an exception. Another use of this pragma is to suppress incorrect warnings
3394 about missing returns in functions, where the last statement of a function
3395 statement sequence is a call to such a procedure.
3396
3397 Note that in Ada 2005 mode, this pragma is part of the language, and is
3398 identical in effect to the pragma as implemented in Ada 95 mode.
3399
3400 @node Pragma No_Strict_Aliasing
3401 @unnumberedsec Pragma No_Strict_Aliasing
3402 @findex No_Strict_Aliasing
3403 @noindent
3404 Syntax:
3405
3406 @smallexample @c ada
3407 pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
3408 @end smallexample
3409
3410 @noindent
3411 @var{type_LOCAL_NAME} must refer to an access type
3412 declaration in the current declarative part.  The effect is to inhibit
3413 strict aliasing optimization for the given type.  The form with no
3414 arguments is a configuration pragma which applies to all access types
3415 declared in units to which the pragma applies. For a detailed
3416 description of the strict aliasing optimization, and the situations
3417 in which it must be suppressed, see @ref{Optimization and Strict
3418 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
3419
3420 @node Pragma Normalize_Scalars
3421 @unnumberedsec Pragma Normalize_Scalars
3422 @findex Normalize_Scalars
3423 @noindent
3424 Syntax:
3425
3426 @smallexample @c ada
3427 pragma Normalize_Scalars;
3428 @end smallexample
3429
3430 @noindent
3431 This is a language defined pragma which is fully implemented in GNAT@.  The
3432 effect is to cause all scalar objects that are not otherwise initialized
3433 to be initialized.  The initial values are implementation dependent and
3434 are as follows:
3435
3436 @table @code
3437 @item Standard.Character
3438 @noindent
3439 Objects whose root type is Standard.Character are initialized to
3440 Character'Last unless the subtype range excludes NUL (in which case
3441 NUL is used). This choice will always generate an invalid value if
3442 one exists.
3443
3444 @item Standard.Wide_Character
3445 @noindent
3446 Objects whose root type is Standard.Wide_Character are initialized to
3447 Wide_Character'Last unless the subtype range excludes NUL (in which case
3448 NUL is used). This choice will always generate an invalid value if
3449 one exists.
3450
3451 @item Standard.Wide_Wide_Character
3452 @noindent
3453 Objects whose root type is Standard.Wide_Wide_Character are initialized to
3454 the invalid value 16#FFFF_FFFF# unless the subtype range excludes NUL (in
3455 which case NUL is used). This choice will always generate an invalid value if
3456 one exists.
3457
3458 @item Integer types
3459 @noindent
3460 Objects of an integer type are treated differently depending on whether
3461 negative values are present in the subtype. If no negative values are
3462 present, then all one bits is used as the initial value except in the
3463 special case where zero is excluded from the subtype, in which case
3464 all zero bits are used. This choice will always generate an invalid
3465 value if one exists.
3466
3467 For subtypes with negative values present, the largest negative number
3468 is used, except in the unusual case where this largest negative number
3469 is in the subtype, and the largest positive number is not, in which case
3470 the largest positive value is used. This choice will always generate
3471 an invalid value if one exists.
3472
3473 @item Floating-Point Types
3474 Objects of all floating-point types are initialized to all 1-bits. For
3475 standard IEEE format, this corresponds to a NaN (not a number) which is
3476 indeed an invalid value.
3477
3478 @item Fixed-Point Types
3479 Objects of all fixed-point types are treated as described above for integers,
3480 with the rules applying to the underlying integer value used to represent
3481 the fixed-point value.
3482
3483 @item Modular types
3484 Objects of a modular type are initialized to all one bits, except in
3485 the special case where zero is excluded from the subtype, in which
3486 case all zero bits are used. This choice will always generate an
3487 invalid value if one exists.
3488
3489 @item Enumeration types
3490 Objects of an enumeration type are initialized to all one-bits, i.e.@: to
3491 the value @code{2 ** typ'Size - 1} unless the subtype excludes the literal
3492 whose Pos value is zero, in which case a code of zero is used. This choice
3493 will always generate an invalid value if one exists.
3494
3495 @end table
3496
3497 @node Pragma Obsolescent
3498 @unnumberedsec Pragma Obsolescent
3499 @findex Obsolescent
3500 @noindent
3501 Syntax:
3502
3503 @smallexample @c ada
3504 pragma Obsolescent;
3505
3506 pragma Obsolescent (
3507   [Message =>] static_string_EXPRESSION
3508 [,[Version =>] Ada_05]]);
3509
3510 pragma Obsolescent (
3511   [Entity  =>] NAME
3512 [,[Message =>] static_string_EXPRESSION
3513 [,[Version =>] Ada_05]] );
3514 @end smallexample
3515
3516 @noindent
3517 This pragma can occur immediately following a declaration of an entity,
3518 including the case of a record component. If no Entity argument is present,
3519 then this declaration is the one to which the pragma applies. If an Entity
3520 parameter is present, it must either match the name of the entity in this
3521 declaration, or alternatively, the pragma can immediately follow an enumeration
3522 type declaration, where the Entity argument names one of the enumeration
3523 literals.
3524
3525 This pragma is used to indicate that the named entity
3526 is considered obsolescent and should not be used. Typically this is
3527 used when an API must be modified by eventually removing or modifying
3528 existing subprograms or other entities. The pragma can be used at an
3529 intermediate stage when the entity is still present, but will be
3530 removed later.
3531
3532 The effect of this pragma is to output a warning message on a reference to
3533 an entity thus marked that the subprogram is obsolescent if the appropriate
3534 warning option in the compiler is activated. If the Message parameter is
3535 present, then a second warning message is given containing this text. In
3536 addition, a reference to the eneity is considered to be a violation of pragma
3537 Restrictions (No_Obsolescent_Features).
3538
3539 This pragma can also be used as a program unit pragma for a package,
3540 in which case the entity name is the name of the package, and the
3541 pragma indicates that the entire package is considered
3542 obsolescent. In this case a client @code{with}'ing such a package
3543 violates the restriction, and the @code{with} statement is
3544 flagged with warnings if the warning option is set.
3545
3546 If the Version parameter is present (which must be exactly
3547 the identifier Ada_05, no other argument is allowed), then the
3548 indication of obsolescence applies only when compiling in Ada 2005
3549 mode. This is primarily intended for dealing with the situations
3550 in the predefined library where subprograms or packages
3551 have become defined as obsolescent in Ada 2005
3552 (e.g.@: in Ada.Characters.Handling), but may be used anywhere.
3553
3554 The following examples show typical uses of this pragma:
3555
3556 @smallexample @c ada
3557 package p is
3558    pragma Obsolescent (p, Message => "use pp instead of p");
3559 end p;
3560
3561 package q is
3562    procedure q2;
3563    pragma Obsolescent ("use q2new instead");
3564
3565    type R is new integer;
3566    pragma Obsolescent
3567      (Entity  => R,
3568       Message => "use RR in Ada 2005",
3569       Version => Ada_05);
3570
3571    type M is record
3572       F1 : Integer;
3573       F2 : Integer;
3574       pragma Obsolescent;
3575       F3 : Integer;
3576    end record;
3577
3578    type E is (a, bc, 'd', quack);
3579    pragma Obsolescent (Entity => bc)
3580    pragma Obsolescent (Entity => 'd')
3581
3582    function "+"
3583      (a, b : character) return character;
3584    pragma Obsolescent (Entity => "+");
3585 end;
3586 @end smallexample
3587
3588 @noindent
3589 Note that, as for all pragmas, if you use a pragma argument identifier,
3590 then all subsequent parameters must also use a pragma argument identifier.
3591 So if you specify "Entity =>" for the Entity argument, and a Message
3592 argument is present, it must be preceded by "Message =>".
3593
3594 @node Pragma Optimize_Alignment
3595 @unnumberedsec Pragma Optimize_Alignment
3596 @findex Optimize_Alignment
3597 @cindex Alignment, default settings
3598 @noindent
3599 Syntax:
3600
3601 @smallexample @c ada
3602 pragma Optimize_Alignment (TIME | SPACE | OFF);
3603 @end smallexample
3604
3605 @noindent
3606 This is a configuration pragma which affects the choice of default alignments
3607 for types where no alignment is explicitly specified. There is a time/space
3608 trade-off in the selection of these values. Large alignments result in more
3609 efficient code, at the expense of larger data space, since sizes have to be
3610 increased to match these alignments. Smaller alignments save space, but the
3611 access code is slower. The normal choice of default alignments (which is what
3612 you get if you do not use this pragma, or if you use an argument of OFF),
3613 tries to balance these two requirements.
3614
3615 Specifying SPACE causes smaller default alignments to be chosen in two cases.
3616 First any packed record is given an alignment of 1. Second, if a size is given
3617 for the type, then the alignment is chosen to avoid increasing this size. For
3618 example, consider:
3619
3620 @smallexample @c ada
3621    type R is record
3622       X : Integer;
3623       Y : Character;
3624    end record;
3625
3626    for R'Size use 5*8;
3627 @end smallexample
3628
3629 @noindent
3630 In the default mode, this type gets an alignment of 4, so that access to the
3631 Integer field X are efficient. But this means that objects of the type end up
3632 with a size of 8 bytes. This is a valid choice, since sizes of objects are
3633 allowed to be bigger than the size of the type, but it can waste space if for
3634 example fields of type R appear in an enclosing record. If the above type is
3635 compiled in @code{Optimize_Alignment (Space)} mode, the alignment is set to 1.
3636
3637 Specifying TIME causes larger default alignments to be chosen in the case of
3638 small types with sizes that are not a power of 2. For example, consider:
3639
3640 @smallexample @c ada
3641    type R is record
3642       A : Character;
3643       B : Character;
3644       C : Boolean;
3645    end record;
3646
3647    pragma Pack (R);
3648    for R'Size use 17;
3649 @end smallexample
3650
3651 @noindent
3652 The default alignment for this record is normally 1, but if this type is
3653 compiled in @code{Optimize_Alignment (Time)} mode, then the alignment is set
3654 to 4, which wastes space for objects of the type, since they are now 4 bytes
3655 long, but results in more efficient access when the whole record is referenced.
3656
3657 As noted above, this is a configuration pragma, and there is a requirement
3658 that all units in a partition be compiled with a consistent setting of the
3659 optimization setting. This would normally be achieved by use of a configuration
3660 pragma file containing the appropriate setting. The exception to this rule is
3661 that units with an explicit configuration pragma in the same file as the source
3662 unit are excluded from the consistency check, as are all predefined units. The
3663 latter are compiled by default in pragma Optimize_Alignment (Off) mode if no
3664 pragma appears at the start of the file.
3665
3666 @node Pragma Passive
3667 @unnumberedsec Pragma Passive
3668 @findex Passive
3669 @noindent
3670 Syntax:
3671
3672 @smallexample @c ada
3673 pragma Passive [(Semaphore | No)];
3674 @end smallexample
3675
3676 @noindent
3677 Syntax checked, but otherwise ignored by GNAT@.  This is recognized for
3678 compatibility with DEC Ada 83 implementations, where it is used within a
3679 task definition to request that a task be made passive.  If the argument
3680 @code{Semaphore} is present, or the argument is omitted, then DEC Ada 83
3681 treats the pragma as an assertion that the containing task is passive
3682 and that optimization of context switch with this task is permitted and
3683 desired.  If the argument @code{No} is present, the task must not be
3684 optimized.  GNAT does not attempt to optimize any tasks in this manner
3685 (since protected objects are available in place of passive tasks).
3686
3687 @node Pragma Persistent_BSS
3688 @unnumberedsec Pragma Persistent_BSS
3689 @findex Persistent_BSS
3690 @noindent
3691 Syntax:
3692
3693 @smallexample @c ada
3694 pragma Persistent_BSS [(LOCAL_NAME)]
3695 @end smallexample
3696
3697 @noindent
3698 This pragma allows selected objects to be placed in the @code{.persistent_bss}
3699 section. On some targets the linker and loader provide for special
3700 treatment of this section, allowing a program to be reloaded without
3701 affecting the contents of this data (hence the name persistent).
3702
3703 There are two forms of usage. If an argument is given, it must be the
3704 local name of a library level object, with no explicit initialization
3705 and whose type is potentially persistent. If no argument is given, then
3706 the pragma is a configuration pragma, and applies to all library level
3707 objects with no explicit initialization of potentially persistent types.
3708
3709 A potentially persistent type is a scalar type, or a non-tagged,
3710 non-discriminated record, all of whose components have no explicit
3711 initialization and are themselves of a potentially persistent type,
3712 or an array, all of whose constraints are static, and whose component
3713 type is potentially persistent.
3714
3715 If this pragma is used on a target where this feature is not supported,
3716 then the pragma will be ignored. See also @code{pragma Linker_Section}.
3717
3718 @node Pragma Polling
3719 @unnumberedsec Pragma Polling
3720 @findex Polling
3721 @noindent
3722 Syntax:
3723
3724 @smallexample @c ada
3725 pragma Polling (ON | OFF);
3726 @end smallexample
3727
3728 @noindent
3729 This pragma controls the generation of polling code.  This is normally off.
3730 If @code{pragma Polling (ON)} is used then periodic calls are generated to
3731 the routine @code{Ada.Exceptions.Poll}.  This routine is a separate unit in the
3732 runtime library, and can be found in file @file{a-excpol.adb}.
3733
3734 Pragma @code{Polling} can appear as a configuration pragma (for example it
3735 can be placed in the @file{gnat.adc} file) to enable polling globally, or it
3736 can be used in the statement or declaration sequence to control polling
3737 more locally.
3738
3739 A call to the polling routine is generated at the start of every loop and
3740 at the start of every subprogram call.  This guarantees that the @code{Poll}
3741 routine is called frequently, and places an upper bound (determined by
3742 the complexity of the code) on the period between two @code{Poll} calls.
3743
3744 The primary purpose of the polling interface is to enable asynchronous
3745 aborts on targets that cannot otherwise support it (for example Windows
3746 NT), but it may be used for any other purpose requiring periodic polling.
3747 The standard version is null, and can be replaced by a user program.  This
3748 will require re-compilation of the @code{Ada.Exceptions} package that can
3749 be found in files @file{a-except.ads} and @file{a-except.adb}.
3750
3751 A standard alternative unit (in file @file{4wexcpol.adb} in the standard GNAT
3752 distribution) is used to enable the asynchronous abort capability on
3753 targets that do not normally support the capability.  The version of
3754 @code{Poll} in this file makes a call to the appropriate runtime routine
3755 to test for an abort condition.
3756
3757 Note that polling can also be enabled by use of the @option{-gnatP} switch.
3758 @xref{Switches for gcc,,, gnat_ugn, @value{EDITION} User's Guide}, for
3759 details.
3760
3761 @node Pragma Postcondition
3762 @unnumberedsec Pragma Postcondition
3763 @cindex Postconditions
3764 @cindex Checks, postconditions
3765 @findex Postconditions
3766 @noindent
3767 Syntax:
3768
3769 @smallexample @c ada
3770 pragma Postcondition (
3771    [Check   =>] Boolean_Expression
3772  [,[Message =>] String_Expression]);
3773 @end smallexample
3774
3775 @noindent
3776 The @code{Postcondition} pragma allows specification of automatic
3777 postcondition checks for subprograms. These checks are similar to
3778 assertions, but are automatically inserted just prior to the return
3779 statements of the subprogram with which they are associated (including
3780 implicit returns at the end of procedure bodies and associated
3781 exception handlers).
3782
3783 In addition, the boolean expression which is the condition which
3784 must be true may contain references to function'Result in the case
3785 of a function to refer to the returned value.
3786
3787 @code{Postcondition} pragmas may appear either immediate following the
3788 (separate) declaration of a subprogram, or at the start of the
3789 declarations of a subprogram body. Only other pragmas may intervene
3790 (that is appear between the subprogram declaration and its
3791 postconditions, or appear before the postcondition in the
3792 declaration sequence in a subprogram body). In the case of a
3793 postcondition appearing after a subprogram declaration, the
3794 formal arguments of the subprogram are visible, and can be
3795 referenced in the postcondition expressions.
3796
3797 The postconditions are collected and automatically tested just
3798 before any return (implicit or explicit) in the subprogram body.
3799 A postcondition is only recognized if postconditions are active
3800 at the time the pragma is encountered. The compiler switch @option{gnata}
3801 turns on all postconditions by default, and pragma @code{Check_Policy}
3802 with an identifier of @code{Postcondition} can also be used to
3803 control whether postconditions are active.
3804
3805 The general approach is that postconditions are placed in the spec
3806 if they represent functional aspects which make sense to the client.
3807 For example we might have:
3808
3809 @smallexample @c ada
3810    function Direction return Integer;
3811    pragma Postcondition
3812     (Direction'Result = +1
3813        or else
3814      Direction'Result = -1);
3815 @end smallexample
3816
3817 @noindent
3818 which serves to document that the result must be +1 or -1, and
3819 will test that this is the case at run time if postcondition
3820 checking is active.
3821
3822 Postconditions within the subprogram body can be used to
3823 check that some internal aspect of the implementation,
3824 not visible to the client, is operating as expected.
3825 For instance if a square root routine keeps an internal
3826 counter of the number of times it is called, then we
3827 might have the following postcondition:
3828
3829 @smallexample @c ada
3830    Sqrt_Calls : Natural := 0;
3831
3832    function Sqrt (Arg : Float) return Float is
3833      pragma Postcondition
3834        (Sqrt_Calls = Sqrt_Calls'Old + 1);
3835      ...
3836    end Sqrt
3837 @end smallexample
3838
3839 @noindent
3840 As this example, shows, the use of the @code{Old} attribute
3841 is often useful in postconditions to refer to the state on
3842 entry to the subprogram.
3843
3844 Note that postconditions are only checked on normal returns
3845 from the subprogram. If an abnormal return results from
3846 raising an exception, then the postconditions are not checked.
3847
3848 If a postcondition fails, then the exception
3849 @code{System.Assertions.Assert_Failure} is raised. If
3850 a message argument was supplied, then the given string
3851 will be used as the exception message. If no message
3852 argument was supplied, then the default message has
3853 the form "Postcondition failed at file:line". The
3854 exception is raised in the context of the subprogram
3855 body, so it is possible to catch postcondition failures
3856 within the subprogram body itself.
3857
3858 Within a package spec, normal visibility rules
3859 in Ada would prevent forward references within a
3860 postcondition pragma to functions defined later in
3861 the same package. This would introduce undesirable
3862 ordering constraints. To avoid this problem, all
3863 postcondition pragmas are analyzed at the end of
3864 the package spec, allowing forward references.
3865
3866 The following example shows that this even allows
3867 mutually recursive postconditions as in:
3868
3869 @smallexample @c ada
3870 package Parity_Functions is
3871    function Odd  (X : Natural) return Boolean;
3872    pragma Postcondition
3873      (Odd'Result =
3874         (x = 1
3875           or else
3876         (x /= 0 and then Even (X - 1))));
3877
3878    function Even (X : Natural) return Boolean;
3879    pragma Postcondition
3880      (Even'Result =
3881         (x = 0
3882           or else
3883         (x /= 1 and then Odd (X - 1))));
3884
3885 end Parity_Functions;
3886 @end smallexample
3887
3888 @noindent
3889 There are no restrictions on the complexity or form of
3890 conditions used within @code{Postcondition} pragmas.
3891 The following example shows that it is even possible
3892 to verify performance behavior.
3893
3894 @smallexample @c ada
3895 package Sort is
3896
3897    Performance : constant Float;
3898    --  Performance constant set by implementation
3899    --  to match target architecture behavior.
3900
3901    procedure Treesort (Arg : String);
3902    --  Sorts characters of argument using N*logN sort
3903    pragma Postcondition
3904      (Float (Clock - Clock'Old) <=
3905         Float (Arg'Length) *
3906         log (Float (Arg'Length)) *
3907         Performance);
3908 end Sort;
3909 @end smallexample
3910
3911 @noindent
3912 Note: postcondition pragmas associated with subprograms that are
3913 marked as Inline_Always, or those marked as Inline with front-end
3914 inlining (-gnatN option set) are accepted and legality-checked
3915 by the compiler, but are ignored at run-time even if postcondition
3916 checking is enabled.
3917
3918 @node Pragma Precondition
3919 @unnumberedsec Pragma Precondition
3920 @cindex Preconditions
3921 @cindex Checks, preconditions
3922 @findex Preconditions
3923 @noindent
3924 Syntax:
3925
3926 @smallexample @c ada
3927 pragma Precondition (
3928    [Check   =>] Boolean_Expression
3929  [,[Message =>] String_Expression]);
3930 @end smallexample
3931
3932 @noindent
3933 The @code{Precondition} pragma is similar to @code{Postcondition}
3934 except that the corresponding checks take place immediately upon
3935 entry to the subprogram, and if a precondition fails, the exception
3936 is raised in the context of the caller, and the attribute 'Result
3937 cannot be used within the precondition expression.
3938
3939 Otherwise, the placement and visibility rules are identical to those
3940 described for postconditions. The following is an example of use
3941 within a package spec:
3942
3943 @smallexample @c ada
3944 package Math_Functions is
3945    ...
3946    function Sqrt (Arg : Float) return Float;
3947    pragma Precondition (Arg >= 0.0)
3948    ...
3949 end Math_Functions;
3950 @end smallexample
3951
3952 @noindent
3953 @code{Precondition} pragmas may appear either immediate following the
3954 (separate) declaration of a subprogram, or at the start of the
3955 declarations of a subprogram body. Only other pragmas may intervene
3956 (that is appear between the subprogram declaration and its
3957 postconditions, or appear before the postcondition in the
3958 declaration sequence in a subprogram body).
3959
3960 Note: postcondition pragmas associated with subprograms that are
3961 marked as Inline_Always, or those marked as Inline with front-end
3962 inlining (-gnatN option set) are accepted and legality-checked
3963 by the compiler, but are ignored at run-time even if postcondition
3964 checking is enabled.
3965
3966
3967
3968 @node Pragma Profile (Ravenscar)
3969 @unnumberedsec Pragma Profile (Ravenscar)
3970 @findex Ravenscar
3971 @noindent
3972 Syntax:
3973
3974 @smallexample @c ada
3975 pragma Profile (Ravenscar);
3976 @end smallexample
3977
3978 @noindent
3979 A configuration pragma that establishes the following set of configuration
3980 pragmas:
3981
3982 @table @code
3983 @item Task_Dispatching_Policy (FIFO_Within_Priorities)
3984 [RM D.2.2] Tasks are dispatched following a preemptive
3985 priority-ordered scheduling policy.
3986
3987 @item Locking_Policy (Ceiling_Locking)
3988 [RM D.3] While tasks and interrupts execute a protected action, they inherit
3989 the ceiling priority of the corresponding protected object.
3990 @c
3991 @c @item Detect_Blocking
3992 @c This pragma forces the detection of potentially blocking operations within a
3993 @c protected operation, and to raise Program_Error if that happens.
3994 @end table
3995 @noindent
3996
3997 plus the following set of restrictions:
3998
3999 @table @code
4000 @item Max_Entry_Queue_Length = 1
4001 Defines the maximum number of calls that are queued on a (protected) entry.
4002 Note that this restrictions is checked at run time. Violation of this
4003 restriction results in the raising of Program_Error exception at the point of
4004 the call. For the Profile (Ravenscar) the value of Max_Entry_Queue_Length is
4005 always 1 and hence no task can be queued on a protected entry.
4006
4007 @item Max_Protected_Entries = 1
4008 [RM D.7] Specifies the maximum number of entries per protected type. The
4009 bounds of every entry family of a protected unit shall be static, or shall be
4010 defined by a discriminant of a subtype whose corresponding bound is static.
4011 For the Profile (Ravenscar) the value of Max_Protected_Entries is always 1.
4012
4013 @item Max_Task_Entries = 0
4014 [RM D.7] Specifies the maximum number of entries
4015 per task.  The bounds of every entry family
4016 of a task unit shall be static, or shall be
4017 defined by a discriminant of a subtype whose
4018 corresponding bound is static.  A value of zero
4019 indicates that no rendezvous are possible.  For
4020 the Profile (Ravenscar), the value of Max_Task_Entries is always
4021 0 (zero).
4022
4023 @item No_Abort_Statements
4024 [RM D.7] There are no abort_statements, and there are
4025 no calls to Task_Identification.Abort_Task.
4026
4027 @item No_Asynchronous_Control
4028 There are no semantic dependences on the package
4029 Asynchronous_Task_Control.
4030
4031 @item No_Calendar
4032 There are no semantic dependencies on the package Ada.Calendar.
4033
4034 @item No_Dynamic_Attachment
4035 There is no call to any of the operations defined in package Ada.Interrupts
4036 (Is_Reserved, Is_Attached, Current_Handler, Attach_Handler, Exchange_Handler,
4037 Detach_Handler, and Reference).
4038
4039 @item No_Dynamic_Priorities
4040 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
4041
4042 @item No_Implicit_Heap_Allocations
4043 [RM D.7] No constructs are allowed to cause implicit heap allocation.
4044
4045 @item No_Local_Protected_Objects
4046 Protected objects and access types that designate
4047 such objects shall be declared only at library level.
4048
4049 @item No_Local_Timing_Events
4050 [RM D.7] All objects of type Ada.Timing_Events.Timing_Event are
4051 declared at the library level.
4052
4053 @item No_Protected_Type_Allocators
4054 There are no allocators for protected types or
4055 types containing protected subcomponents.
4056
4057 @item No_Relative_Delay
4058 There are no delay_relative statements.
4059
4060 @item No_Requeue_Statements
4061 Requeue statements are not allowed.
4062
4063 @item No_Select_Statements
4064 There are no select_statements.
4065
4066 @item No_Specific_Termination_Handlers
4067 [RM D.7] There are no calls to Ada.Task_Termination.Set_Specific_Handler
4068 or to Ada.Task_Termination.Specific_Handler.
4069
4070 @item No_Task_Allocators
4071 [RM D.7] There are no allocators for task types
4072 or types containing task subcomponents.
4073
4074 @item No_Task_Attributes_Package
4075 There are no semantic dependencies on the Ada.Task_Attributes package.
4076
4077 @item No_Task_Hierarchy
4078 [RM D.7] All (non-environment) tasks depend
4079 directly on the environment task of the partition.
4080
4081 @item No_Task_Termination
4082 Tasks which terminate are erroneous.
4083
4084 @item No_Unchecked_Conversion
4085 There are no semantic dependencies on the Ada.Unchecked_Conversion package.
4086
4087 @item No_Unchecked_Deallocation
4088 There are no semantic dependencies on the Ada.Unchecked_Deallocation package.
4089
4090 @item Simple_Barriers
4091 Entry barrier condition expressions shall be either static
4092 boolean expressions or boolean objects which are declared in
4093 the protected type which contains the entry.
4094 @end table
4095
4096 @noindent
4097 This set of configuration pragmas and restrictions correspond to the
4098 definition of the ``Ravenscar Profile'' for limited tasking, devised and
4099 published by the @cite{International Real-Time Ada Workshop}, 1997,
4100 and whose most recent description is available at
4101 @url{http://www-users.cs.york.ac.uk/~burns/ravenscar.ps}.
4102
4103 The original definition of the profile was revised at subsequent IRTAW
4104 meetings. It has been included in the ISO
4105 @cite{Guide for the Use of the Ada Programming Language in High
4106 Integrity Systems}, and has been approved by ISO/IEC/SC22/WG9 for inclusion in
4107 the next revision of the standard. The formal definition given by
4108 the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
4109 AI-305) available at
4110 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00249.TXT} and
4111 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00305.TXT}
4112 respectively.
4113
4114 The above set is a superset of the restrictions provided by pragma
4115 @code{Profile (Restricted)}, it includes six additional restrictions
4116 (@code{Simple_Barriers}, @code{No_Select_Statements},
4117 @code{No_Calendar}, @code{No_Implicit_Heap_Allocations},
4118 @code{No_Relative_Delay} and @code{No_Task_Termination}).  This means
4119 that pragma @code{Profile (Ravenscar)}, like the pragma
4120 @code{Profile (Restricted)},
4121 automatically causes the use of a simplified,
4122 more efficient version of the tasking run-time system.
4123
4124 @node Pragma Profile (Restricted)
4125 @unnumberedsec Pragma Profile (Restricted)
4126 @findex Restricted Run Time
4127 @noindent
4128 Syntax:
4129
4130 @smallexample @c ada
4131 pragma Profile (Restricted);
4132 @end smallexample
4133
4134 @noindent
4135 A configuration pragma that establishes the following set of restrictions:
4136
4137 @itemize @bullet
4138 @item No_Abort_Statements
4139 @item No_Entry_Queue
4140 @item No_Task_Hierarchy
4141 @item No_Task_Allocators
4142 @item No_Dynamic_Priorities
4143 @item No_Terminate_Alternatives
4144 @item No_Dynamic_Attachment
4145 @item No_Protected_Type_Allocators
4146 @item No_Local_Protected_Objects
4147 @item No_Requeue_Statements
4148 @item No_Task_Attributes_Package
4149 @item Max_Asynchronous_Select_Nesting =  0
4150 @item Max_Task_Entries =  0
4151 @item Max_Protected_Entries = 1
4152 @item Max_Select_Alternatives = 0
4153 @end itemize
4154
4155 @noindent
4156 This set of restrictions causes the automatic selection of a simplified
4157 version of the run time that provides improved performance for the
4158 limited set of tasking functionality permitted by this set of restrictions.
4159
4160 @node Pragma Psect_Object
4161 @unnumberedsec Pragma Psect_Object
4162 @findex Psect_Object
4163 @noindent
4164 Syntax:
4165
4166 @smallexample @c ada
4167 pragma Psect_Object (
4168      [Internal =>] LOCAL_NAME,
4169   [, [External =>] EXTERNAL_SYMBOL]
4170   [, [Size     =>] EXTERNAL_SYMBOL]);
4171
4172 EXTERNAL_SYMBOL ::=
4173   IDENTIFIER
4174 | static_string_EXPRESSION
4175 @end smallexample
4176
4177 @noindent
4178 This pragma is identical in effect to pragma @code{Common_Object}.
4179
4180 @node Pragma Pure_Function
4181 @unnumberedsec Pragma Pure_Function
4182 @findex Pure_Function
4183 @noindent
4184 Syntax:
4185
4186 @smallexample @c ada
4187 pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
4188 @end smallexample
4189
4190 @noindent
4191 This pragma appears in the same declarative part as a function
4192 declaration (or a set of function declarations if more than one
4193 overloaded declaration exists, in which case the pragma applies
4194 to all entities).  It specifies that the function @code{Entity} is
4195 to be considered pure for the purposes of code generation.  This means
4196 that the compiler can assume that there are no side effects, and
4197 in particular that two calls with identical arguments produce the
4198 same result.  It also means that the function can be used in an
4199 address clause.
4200
4201 Note that, quite deliberately, there are no static checks to try
4202 to ensure that this promise is met, so @code{Pure_Function} can be used
4203 with functions that are conceptually pure, even if they do modify
4204 global variables.  For example, a square root function that is
4205 instrumented to count the number of times it is called is still
4206 conceptually pure, and can still be optimized, even though it
4207 modifies a global variable (the count).  Memo functions are another
4208 example (where a table of previous calls is kept and consulted to
4209 avoid re-computation).
4210
4211 @findex Pure
4212 Note: Most functions in a @code{Pure} package are automatically pure, and
4213 there is no need to use pragma @code{Pure_Function} for such functions.  One
4214 exception is any function that has at least one formal of type
4215 @code{System.Address} or a type derived from it.  Such functions are not
4216 considered pure by default, since the compiler assumes that the
4217 @code{Address} parameter may be functioning as a pointer and that the
4218 referenced data may change even if the address value does not.
4219 Similarly, imported functions are not considered to be pure by default,
4220 since there is no way of checking that they are in fact pure.  The use
4221 of pragma @code{Pure_Function} for such a function will override these default
4222 assumption, and cause the compiler to treat a designated subprogram as pure
4223 in these cases.
4224
4225 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
4226 applies to the underlying renamed function.  This can be used to
4227 disambiguate cases of overloading where some but not all functions
4228 in a set of overloaded functions are to be designated as pure.
4229
4230 If pragma @code{Pure_Function} is applied to a library level function, the
4231 function is also considered pure from an optimization point of view, but the
4232 unit is not a Pure unit in the categorization sense. So for example, a function
4233 thus marked is free to @code{with} non-pure units.
4234
4235 @node Pragma Restriction_Warnings
4236 @unnumberedsec Pragma Restriction_Warnings
4237 @findex Restriction_Warnings
4238 @noindent
4239 Syntax:
4240
4241 @smallexample @c ada
4242 pragma Restriction_Warnings
4243   (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
4244 @end smallexample
4245
4246 @noindent
4247 This pragma allows a series of restriction identifiers to be
4248 specified (the list of allowed identifiers is the same as for
4249 pragma @code{Restrictions}). For each of these identifiers
4250 the compiler checks for violations of the restriction, but
4251 generates a warning message rather than an error message
4252 if the restriction is violated.
4253
4254 @node Pragma Shared
4255 @unnumberedsec Pragma Shared
4256 @findex Shared
4257
4258 @noindent
4259 This pragma is provided for compatibility with Ada 83. The syntax and
4260 semantics are identical to pragma Atomic.
4261
4262 @node Pragma Short_Circuit_And_Or
4263 @unnumberedsec Pragma Short_Circuit_And_Or
4264 @findex Short_Circuit_And_Or
4265
4266 @noindent
4267 This configuration pragma causes any occurrence of the AND operator applied to
4268 operands of type Standard.Boolean to be short-circuited (i.e. the AND operator
4269 is treated as if it were AND THEN). Or is similarly treated as OR ELSE. This
4270 may be useful in the context of certification protocols requiring the use of
4271 short-circuited logical operators. If this configuration pragma occurs locally
4272 within the file being compiled, it applies only to the file being compiled.
4273 There is no requirement that all units in a partition use this option.
4274
4275 semantics are identical to pragma Atomic.
4276 @node Pragma Source_File_Name
4277 @unnumberedsec Pragma Source_File_Name
4278 @findex Source_File_Name
4279 @noindent
4280 Syntax:
4281
4282 @smallexample @c ada
4283 pragma Source_File_Name (
4284   [Unit_Name   =>] unit_NAME,
4285   Spec_File_Name =>  STRING_LITERAL,
4286   [Index => INTEGER_LITERAL]);
4287
4288 pragma Source_File_Name (
4289   [Unit_Name   =>] unit_NAME,
4290   Body_File_Name =>  STRING_LITERAL,
4291   [Index => INTEGER_LITERAL]);
4292 @end smallexample
4293
4294 @noindent
4295 Use this to override the normal naming convention.  It is a configuration
4296 pragma, and so has the usual applicability of configuration pragmas
4297 (i.e.@: it applies to either an entire partition, or to all units in a
4298 compilation, or to a single unit, depending on how it is used.
4299 @var{unit_name} is mapped to @var{file_name_literal}.  The identifier for
4300 the second argument is required, and indicates whether this is the file
4301 name for the spec or for the body.
4302
4303 The optional Index argument should be used when a file contains multiple
4304 units, and when you do not want to use @code{gnatchop} to separate then
4305 into multiple files (which is the recommended procedure to limit the
4306 number of recompilation that are needed when some sources change).
4307 For instance, if the source file @file{source.ada} contains
4308
4309 @smallexample @c ada
4310 package B is
4311 ...
4312 end B;
4313
4314 with B;
4315 procedure A is
4316 begin
4317    ..
4318 end A;
4319 @end smallexample
4320
4321 you could use the following configuration pragmas:
4322
4323 @smallexample @c ada
4324 pragma Source_File_Name
4325   (B, Spec_File_Name => "source.ada", Index => 1);
4326 pragma Source_File_Name
4327   (A, Body_File_Name => "source.ada", Index => 2);
4328 @end smallexample
4329
4330 Note that the @code{gnatname} utility can also be used to generate those
4331 configuration pragmas.
4332
4333 Another form of the @code{Source_File_Name} pragma allows
4334 the specification of patterns defining alternative file naming schemes
4335 to apply to all files.
4336
4337 @smallexample @c ada
4338 pragma Source_File_Name
4339   (  [Spec_File_Name  =>] STRING_LITERAL
4340    [,[Casing          =>] CASING_SPEC]
4341    [,[Dot_Replacement =>] STRING_LITERAL]);
4342
4343 pragma Source_File_Name
4344   (  [Body_File_Name  =>] STRING_LITERAL
4345    [,[Casing          =>] CASING_SPEC]
4346    [,[Dot_Replacement =>] STRING_LITERAL]);
4347
4348 pragma Source_File_Name
4349   (  [Subunit_File_Name =>] STRING_LITERAL
4350    [,[Casing            =>] CASING_SPEC]
4351    [,[Dot_Replacement   =>] STRING_LITERAL]);
4352
4353 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
4354 @end smallexample
4355
4356 @noindent
4357 The first argument is a pattern that contains a single asterisk indicating
4358 the point at which the unit name is to be inserted in the pattern string
4359 to form the file name.  The second argument is optional.  If present it
4360 specifies the casing of the unit name in the resulting file name string.
4361 The default is lower case.  Finally the third argument allows for systematic
4362 replacement of any dots in the unit name by the specified string literal.
4363
4364 A pragma Source_File_Name cannot appear after a
4365 @ref{Pragma Source_File_Name_Project}.
4366
4367 For more details on the use of the @code{Source_File_Name} pragma,
4368 @xref{Using Other File Names,,, gnat_ugn, @value{EDITION} User's Guide},
4369 and @ref{Alternative File Naming Schemes,,, gnat_ugn, @value{EDITION}
4370 User's Guide}.
4371
4372 @node Pragma Source_File_Name_Project
4373 @unnumberedsec Pragma Source_File_Name_Project
4374 @findex Source_File_Name_Project
4375 @noindent
4376
4377 This pragma has the same syntax and semantics as pragma Source_File_Name.
4378 It is only allowed as a stand alone configuration pragma.
4379 It cannot appear after a @ref{Pragma Source_File_Name}, and
4380 most importantly, once pragma Source_File_Name_Project appears,
4381 no further Source_File_Name pragmas are allowed.
4382
4383 The intention is that Source_File_Name_Project pragmas are always
4384 generated by the Project Manager in a manner consistent with the naming
4385 specified in a project file, and when naming is controlled in this manner,
4386 it is not permissible to attempt to modify this naming scheme using
4387 Source_File_Name pragmas (which would not be known to the project manager).
4388
4389 @node Pragma Source_Reference
4390 @unnumberedsec Pragma Source_Reference
4391 @findex Source_Reference
4392 @noindent
4393 Syntax:
4394
4395 @smallexample @c ada
4396 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
4397 @end smallexample
4398
4399 @noindent
4400 This pragma must appear as the first line of a source file.
4401 @var{integer_literal} is the logical line number of the line following
4402 the pragma line (for use in error messages and debugging
4403 information).  @var{string_literal} is a static string constant that
4404 specifies the file name to be used in error messages and debugging
4405 information.  This is most notably used for the output of @code{gnatchop}
4406 with the @option{-r} switch, to make sure that the original unchopped
4407 source file is the one referred to.
4408
4409 The second argument must be a string literal, it cannot be a static
4410 string expression other than a string literal.  This is because its value
4411 is needed for error messages issued by all phases of the compiler.
4412
4413 @node Pragma Stream_Convert
4414 @unnumberedsec Pragma Stream_Convert
4415 @findex Stream_Convert
4416 @noindent
4417 Syntax:
4418
4419 @smallexample @c ada
4420 pragma Stream_Convert (
4421   [Entity =>] type_LOCAL_NAME,
4422   [Read   =>] function_NAME,
4423   [Write  =>] function_NAME);
4424 @end smallexample
4425
4426 @noindent
4427 This pragma provides an efficient way of providing stream functions for
4428 types defined in packages.  Not only is it simpler to use than declaring
4429 the necessary functions with attribute representation clauses, but more
4430 significantly, it allows the declaration to made in such a way that the
4431 stream packages are not loaded unless they are needed.  The use of
4432 the Stream_Convert pragma adds no overhead at all, unless the stream
4433 attributes are actually used on the designated type.
4434
4435 The first argument specifies the type for which stream functions are
4436 provided.  The second parameter provides a function used to read values
4437 of this type.  It must name a function whose argument type may be any
4438 subtype, and whose returned type must be the type given as the first
4439 argument to the pragma.
4440
4441 The meaning of the @var{Read}
4442 parameter is that if a stream attribute directly
4443 or indirectly specifies reading of the type given as the first parameter,
4444 then a value of the type given as the argument to the Read function is
4445 read from the stream, and then the Read function is used to convert this
4446 to the required target type.
4447
4448 Similarly the @var{Write} parameter specifies how to treat write attributes
4449 that directly or indirectly apply to the type given as the first parameter.
4450 It must have an input parameter of the type specified by the first parameter,
4451 and the return type must be the same as the input type of the Read function.
4452 The effect is to first call the Write function to convert to the given stream
4453 type, and then write the result type to the stream.
4454
4455 The Read and Write functions must not be overloaded subprograms.  If necessary
4456 renamings can be supplied to meet this requirement.
4457 The usage of this attribute is best illustrated by a simple example, taken
4458 from the GNAT implementation of package Ada.Strings.Unbounded:
4459
4460 @smallexample @c ada
4461 function To_Unbounded (S : String)
4462            return Unbounded_String
4463   renames To_Unbounded_String;
4464
4465 pragma Stream_Convert
4466   (Unbounded_String, To_Unbounded, To_String);
4467 @end smallexample
4468
4469 @noindent
4470 The specifications of the referenced functions, as given in the Ada
4471 Reference Manual are:
4472
4473 @smallexample @c ada
4474 function To_Unbounded_String (Source : String)
4475   return Unbounded_String;
4476
4477 function To_String (Source : Unbounded_String)
4478   return String;
4479 @end smallexample
4480
4481 @noindent
4482 The effect is that if the value of an unbounded string is written to a stream,
4483 then the representation of the item in the stream is in the same format that
4484 would be used for @code{Standard.String'Output}, and this same representation
4485 is expected when a value of this type is read from the stream. Note that the
4486 value written always includes the bounds, even for Unbounded_String'Write,
4487 since Unbounded_String is not an array type.
4488
4489 @node Pragma Style_Checks
4490 @unnumberedsec Pragma Style_Checks
4491 @findex Style_Checks
4492 @noindent
4493 Syntax:
4494
4495 @smallexample @c ada
4496 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
4497                      On | Off [, LOCAL_NAME]);
4498 @end smallexample
4499
4500 @noindent
4501 This pragma is used in conjunction with compiler switches to control the
4502 built in style checking provided by GNAT@.  The compiler switches, if set,
4503 provide an initial setting for the switches, and this pragma may be used
4504 to modify these settings, or the settings may be provided entirely by
4505 the use of the pragma.  This pragma can be used anywhere that a pragma
4506 is legal, including use as a configuration pragma (including use in
4507 the @file{gnat.adc} file).
4508
4509 The form with a string literal specifies which style options are to be
4510 activated.  These are additive, so they apply in addition to any previously
4511 set style check options.  The codes for the options are the same as those
4512 used in the @option{-gnaty} switch to @command{gcc} or @command{gnatmake}.
4513 For example the following two methods can be used to enable
4514 layout checking:
4515
4516 @itemize @bullet
4517 @item
4518 @smallexample @c ada
4519 pragma Style_Checks ("l");
4520 @end smallexample
4521
4522 @item
4523 @smallexample
4524 gcc -c -gnatyl @dots{}
4525 @end smallexample
4526 @end itemize
4527
4528 @noindent
4529 The form ALL_CHECKS activates all standard checks (its use is equivalent
4530 to the use of the @code{gnaty} switch with no options.  @xref{Top,
4531 @value{EDITION} User's Guide, About This Guide, gnat_ugn,
4532 @value{EDITION} User's Guide}, for details.
4533
4534 The forms with @code{Off} and @code{On}
4535 can be used to temporarily disable style checks
4536 as shown in the following example:
4537
4538 @smallexample @c ada
4539 @iftex
4540 @leftskip=0cm
4541 @end iftex
4542 pragma Style_Checks ("k"); -- requires keywords in lower case
4543 pragma Style_Checks (Off); -- turn off style checks
4544 NULL;                      -- this will not generate an error message
4545 pragma Style_Checks (On);  -- turn style checks back on
4546 NULL;                      -- this will generate an error message
4547 @end smallexample
4548
4549 @noindent
4550 Finally the two argument form is allowed only if the first argument is
4551 @code{On} or @code{Off}.  The effect is to turn of semantic style checks
4552 for the specified entity, as shown in the following example:
4553
4554 @smallexample @c ada
4555 @iftex
4556 @leftskip=0cm
4557 @end iftex
4558 pragma Style_Checks ("r"); -- require consistency of identifier casing
4559 Arg : Integer;
4560 Rf1 : Integer := ARG;      -- incorrect, wrong case
4561 pragma Style_Checks (Off, Arg);
4562 Rf2 : Integer := ARG;      -- OK, no error
4563 @end smallexample
4564
4565 @node Pragma Subtitle
4566 @unnumberedsec Pragma Subtitle
4567 @findex Subtitle
4568 @noindent
4569 Syntax:
4570
4571 @smallexample @c ada
4572 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
4573 @end smallexample
4574
4575 @noindent
4576 This pragma is recognized for compatibility with other Ada compilers
4577 but is ignored by GNAT@.
4578
4579 @node Pragma Suppress
4580 @unnumberedsec Pragma Suppress
4581 @findex Suppress
4582 @noindent
4583 Syntax:
4584
4585 @smallexample @c ada
4586 pragma Suppress (Identifier [, [On =>] Name]);
4587 @end smallexample
4588
4589 @noindent
4590 This is a standard pragma, and supports all the check names required in
4591 the RM. It is included here because GNAT recognizes one additional check
4592 name: @code{Alignment_Check} which can be used to suppress alignment checks
4593 on addresses used in address clauses. Such checks can also be suppressed
4594 by suppressing range checks, but the specific use of @code{Alignment_Check}
4595 allows suppression of alignment checks without suppressing other range checks.
4596
4597 Note that pragma Suppress gives the compiler permission to omit
4598 checks, but does not require the compiler to omit checks. The compiler
4599 will generate checks if they are essentially free, even when they are
4600 suppressed. In particular, if the compiler can prove that a certain
4601 check will necessarily fail, it will generate code to do an
4602 unconditional ``raise'', even if checks are suppressed. The compiler
4603 warns in this case.
4604
4605 Of course, run-time checks are omitted whenever the compiler can prove
4606 that they will not fail, whether or not checks are suppressed.
4607
4608 @node Pragma Suppress_All
4609 @unnumberedsec Pragma Suppress_All
4610 @findex Suppress_All
4611 @noindent
4612 Syntax:
4613
4614 @smallexample @c ada
4615 pragma Suppress_All;
4616 @end smallexample
4617
4618 @noindent
4619 This pragma can only appear immediately following a compilation
4620 unit.  The effect is to apply @code{Suppress (All_Checks)} to the unit
4621 which it follows.  This pragma is implemented for compatibility with DEC
4622 Ada 83 usage.  The use of pragma @code{Suppress (All_Checks)} as a normal
4623 configuration pragma is the preferred usage in GNAT@.
4624
4625 @node Pragma Suppress_Exception_Locations
4626 @unnumberedsec Pragma Suppress_Exception_Locations
4627 @findex Suppress_Exception_Locations
4628 @noindent
4629 Syntax:
4630
4631 @smallexample @c ada
4632 pragma Suppress_Exception_Locations;
4633 @end smallexample
4634
4635 @noindent
4636 In normal mode, a raise statement for an exception by default generates
4637 an exception message giving the file name and line number for the location
4638 of the raise. This is useful for debugging and logging purposes, but this
4639 entails extra space for the strings for the messages. The configuration
4640 pragma @code{Suppress_Exception_Locations} can be used to suppress the
4641 generation of these strings, with the result that space is saved, but the
4642 exception message for such raises is null. This configuration pragma may
4643 appear in a global configuration pragma file, or in a specific unit as
4644 usual. It is not required that this pragma be used consistently within
4645 a partition, so it is fine to have some units within a partition compiled
4646 with this pragma and others compiled in normal mode without it.
4647
4648 @node Pragma Suppress_Initialization
4649 @unnumberedsec Pragma Suppress_Initialization
4650 @findex Suppress_Initialization
4651 @cindex Suppressing initialization
4652 @cindex Initialization, suppression of
4653 @noindent
4654 Syntax:
4655
4656 @smallexample @c ada
4657 pragma Suppress_Initialization ([Entity =>] type_Name);
4658 @end smallexample
4659
4660 @noindent
4661 This pragma suppresses any implicit or explicit initialization
4662 associated with the given type name for all variables of this type.
4663
4664 @node Pragma Task_Info
4665 @unnumberedsec Pragma Task_Info
4666 @findex Task_Info
4667 @noindent
4668 Syntax
4669
4670 @smallexample @c ada
4671 pragma Task_Info (EXPRESSION);
4672 @end smallexample
4673
4674 @noindent
4675 This pragma appears within a task definition (like pragma
4676 @code{Priority}) and applies to the task in which it appears.  The
4677 argument must be of type @code{System.Task_Info.Task_Info_Type}.
4678 The @code{Task_Info} pragma provides system dependent control over
4679 aspects of tasking implementation, for example, the ability to map
4680 tasks to specific processors.  For details on the facilities available
4681 for the version of GNAT that you are using, see the documentation
4682 in the spec of package System.Task_Info in the runtime
4683 library.
4684
4685 @node Pragma Task_Name
4686 @unnumberedsec Pragma Task_Name
4687 @findex Task_Name
4688 @noindent
4689 Syntax
4690
4691 @smallexample @c ada
4692 pragma Task_Name (string_EXPRESSION);
4693 @end smallexample
4694
4695 @noindent
4696 This pragma appears within a task definition (like pragma
4697 @code{Priority}) and applies to the task in which it appears.  The
4698 argument must be of type String, and provides a name to be used for
4699 the task instance when the task is created.  Note that this expression
4700 is not required to be static, and in particular, it can contain
4701 references to task discriminants.  This facility can be used to
4702 provide different names for different tasks as they are created,
4703 as illustrated in the example below.
4704
4705 The task name is recorded internally in the run-time structures
4706 and is accessible to tools like the debugger.  In addition the
4707 routine @code{Ada.Task_Identification.Image} will return this
4708 string, with a unique task address appended.
4709
4710 @smallexample @c ada
4711 --  Example of the use of pragma Task_Name
4712
4713 with Ada.Task_Identification;
4714 use Ada.Task_Identification;
4715 with Text_IO; use Text_IO;
4716 procedure t3 is
4717
4718    type Astring is access String;
4719
4720    task type Task_Typ (Name : access String) is
4721       pragma Task_Name (Name.all);
4722    end Task_Typ;
4723
4724    task body Task_Typ is
4725       Nam : constant String := Image (Current_Task);
4726    begin
4727       Put_Line ("-->" & Nam (1 .. 14) & "<--");
4728    end Task_Typ;
4729
4730    type Ptr_Task is access Task_Typ;
4731    Task_Var : Ptr_Task;
4732
4733 begin
4734    Task_Var :=
4735      new Task_Typ (new String'("This is task 1"));
4736    Task_Var :=
4737      new Task_Typ (new String'("This is task 2"));
4738 end;
4739 @end smallexample
4740
4741 @node Pragma Task_Storage
4742 @unnumberedsec Pragma Task_Storage
4743 @findex Task_Storage
4744 Syntax:
4745
4746 @smallexample @c ada
4747 pragma Task_Storage (
4748   [Task_Type =>] LOCAL_NAME,
4749   [Top_Guard =>] static_integer_EXPRESSION);
4750 @end smallexample
4751
4752 @noindent
4753 This pragma specifies the length of the guard area for tasks.  The guard
4754 area is an additional storage area allocated to a task.  A value of zero
4755 means that either no guard area is created or a minimal guard area is
4756 created, depending on the target.  This pragma can appear anywhere a
4757 @code{Storage_Size} attribute definition clause is allowed for a task
4758 type.
4759
4760 @node Pragma Thread_Local_Storage
4761 @unnumberedsec Pragma Thread_Local_Storage
4762 @findex Thread_Local_Storage
4763 @cindex Task specific storage
4764 @cindex TLS (Thread Local Storage)
4765 Syntax:
4766
4767 @smallexample @c ada
4768 pragma Thread_Local_Storage ([Entity =>] LOCAL_NAME);
4769 @end smallexample
4770
4771 @noindent
4772 This pragma specifies that the specified entity, which must be
4773 a variable declared in a library level package, is to be marked as
4774 "Thread Local Storage" (@code{TLS}). On systems supporting this (which
4775 include Solaris, GNU/Linux and VxWorks 6), this causes each thread
4776 (and hence each Ada task) to see a distinct copy of the variable.
4777
4778 The variable may not have default initialization, and if there is
4779 an explicit initialization, it must be either @code{null} for an
4780 access variable, or a static expression for a scalar variable.
4781 This provides a low level mechanism similar to that provided by
4782 the @code{Ada.Task_Attributes} package, but much more efficient
4783 and is also useful in writing interface code that will interact
4784 with foreign threads.
4785
4786 If this pragma is used on a system where @code{TLS} is not supported,
4787 then an error message will be generated and the program will be rejected.
4788
4789 @node Pragma Time_Slice
4790 @unnumberedsec Pragma Time_Slice
4791 @findex Time_Slice
4792 @noindent
4793 Syntax:
4794
4795 @smallexample @c ada
4796 pragma Time_Slice (static_duration_EXPRESSION);
4797 @end smallexample
4798
4799 @noindent
4800 For implementations of GNAT on operating systems where it is possible
4801 to supply a time slice value, this pragma may be used for this purpose.
4802 It is ignored if it is used in a system that does not allow this control,
4803 or if it appears in other than the main program unit.
4804 @cindex OpenVMS
4805 Note that the effect of this pragma is identical to the effect of the
4806 DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
4807
4808 @node Pragma Title
4809 @unnumberedsec Pragma Title
4810 @findex Title
4811 @noindent
4812 Syntax:
4813
4814 @smallexample @c ada
4815 pragma Title (TITLING_OPTION [, TITLING OPTION]);
4816
4817 TITLING_OPTION ::=
4818   [Title    =>] STRING_LITERAL,
4819 | [Subtitle =>] STRING_LITERAL
4820 @end smallexample
4821
4822 @noindent
4823 Syntax checked but otherwise ignored by GNAT@.  This is a listing control
4824 pragma used in DEC Ada 83 implementations to provide a title and/or
4825 subtitle for the program listing.  The program listing generated by GNAT
4826 does not have titles or subtitles.
4827
4828 Unlike other pragmas, the full flexibility of named notation is allowed
4829 for this pragma, i.e.@: the parameters may be given in any order if named
4830 notation is used, and named and positional notation can be mixed
4831 following the normal rules for procedure calls in Ada.
4832
4833 @node Pragma Unchecked_Union
4834 @unnumberedsec Pragma Unchecked_Union
4835 @cindex Unions in C
4836 @findex Unchecked_Union
4837 @noindent
4838 Syntax:
4839
4840 @smallexample @c ada
4841 pragma Unchecked_Union (first_subtype_LOCAL_NAME);
4842 @end smallexample
4843
4844 @noindent
4845 This pragma is used to specify a representation of a record type that is
4846 equivalent to a C union. It was introduced as a GNAT implementation defined
4847 pragma in the GNAT Ada 95 mode. Ada 2005 includes an extended version of this
4848 pragma, making it language defined, and GNAT fully implements this extended
4849 version in all language modes (Ada 83, Ada 95, and Ada 2005). For full
4850 details, consult the Ada 2005 Reference Manual, section B.3.3.
4851
4852 @node Pragma Unimplemented_Unit
4853 @unnumberedsec Pragma Unimplemented_Unit
4854 @findex Unimplemented_Unit
4855 @noindent
4856 Syntax:
4857
4858 @smallexample @c ada
4859 pragma Unimplemented_Unit;
4860 @end smallexample
4861
4862 @noindent
4863 If this pragma occurs in a unit that is processed by the compiler, GNAT
4864 aborts with the message @samp{@var{xxx} not implemented}, where
4865 @var{xxx} is the name of the current compilation unit.  This pragma is
4866 intended to allow the compiler to handle unimplemented library units in
4867 a clean manner.
4868
4869 The abort only happens if code is being generated.  Thus you can use
4870 specs of unimplemented packages in syntax or semantic checking mode.
4871
4872 @node Pragma Universal_Aliasing
4873 @unnumberedsec Pragma Universal_Aliasing
4874 @findex Universal_Aliasing
4875 @noindent
4876 Syntax:
4877
4878 @smallexample @c ada
4879 pragma Universal_Aliasing [([Entity =>] type_LOCAL_NAME)];
4880 @end smallexample
4881
4882 @noindent
4883 @var{type_LOCAL_NAME} must refer to a type declaration in the current
4884 declarative part.  The effect is to inhibit strict type-based aliasing
4885 optimization for the given type.  In other words, the effect is as though
4886 access types designating this type were subject to pragma No_Strict_Aliasing.
4887 For a detailed description of the strict aliasing optimization, and the
4888 situations in which it must be suppressed, @xref{Optimization and Strict
4889 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
4890
4891 @node Pragma Universal_Data
4892 @unnumberedsec Pragma Universal_Data
4893 @findex Universal_Data
4894 @noindent
4895 Syntax:
4896
4897 @smallexample @c ada
4898 pragma Universal_Data [(library_unit_Name)];
4899 @end smallexample
4900
4901 @noindent
4902 This pragma is supported only for the AAMP target and is ignored for
4903 other targets. The pragma specifies that all library-level objects
4904 (Counter 0 data) associated with the library unit are to be accessed
4905 and updated using universal addressing (24-bit addresses for AAMP5)
4906 rather than the default of 16-bit Data Environment (DENV) addressing.
4907 Use of this pragma will generally result in less efficient code for
4908 references to global data associated with the library unit, but
4909 allows such data to be located anywhere in memory. This pragma is
4910 a library unit pragma, but can also be used as a configuration pragma
4911 (including use in the @file{gnat.adc} file). The functionality
4912 of this pragma is also available by applying the -univ switch on the
4913 compilations of units where universal addressing of the data is desired.
4914
4915 @node Pragma Unmodified
4916 @unnumberedsec Pragma Unmodified
4917 @findex Unmodified
4918 @cindex Warnings, unmodified
4919 @noindent
4920 Syntax:
4921
4922 @smallexample @c ada
4923 pragma Unmodified (LOCAL_NAME @{, LOCAL_NAME@});
4924 @end smallexample
4925
4926 @noindent
4927 This pragma signals that the assignable entities (variables,
4928 @code{out} parameters, @code{in out} parameters) whose names are listed are
4929 deliberately not assigned in the current source unit. This
4930 suppresses warnings about the
4931 entities being referenced but not assigned, and in addition a warning will be
4932 generated if one of these entities is in fact assigned in the
4933 same unit as the pragma (or in the corresponding body, or one
4934 of its subunits).
4935
4936 This is particularly useful for clearly signaling that a particular
4937 parameter is not modified, even though the spec suggests that it might
4938 be.
4939
4940 @node Pragma Unreferenced
4941 @unnumberedsec Pragma Unreferenced
4942 @findex Unreferenced
4943 @cindex Warnings, unreferenced
4944 @noindent
4945 Syntax:
4946
4947 @smallexample @c ada
4948 pragma Unreferenced (LOCAL_NAME @{, LOCAL_NAME@});
4949 pragma Unreferenced (library_unit_NAME @{, library_unit_NAME@});
4950 @end smallexample
4951
4952 @noindent
4953 This pragma signals that the entities whose names are listed are
4954 deliberately not referenced in the current source unit. This
4955 suppresses warnings about the
4956 entities being unreferenced, and in addition a warning will be
4957 generated if one of these entities is in fact referenced in the
4958 same unit as the pragma (or in the corresponding body, or one
4959 of its subunits).
4960
4961 This is particularly useful for clearly signaling that a particular
4962 parameter is not referenced in some particular subprogram implementation
4963 and that this is deliberate. It can also be useful in the case of
4964 objects declared only for their initialization or finalization side
4965 effects.
4966
4967 If @code{LOCAL_NAME} identifies more than one matching homonym in the
4968 current scope, then the entity most recently declared is the one to which
4969 the pragma applies. Note that in the case of accept formals, the pragma
4970 Unreferenced may appear immediately after the keyword @code{do} which
4971 allows the indication of whether or not accept formals are referenced
4972 or not to be given individually for each accept statement.
4973
4974 The left hand side of an assignment does not count as a reference for the
4975 purpose of this pragma. Thus it is fine to assign to an entity for which
4976 pragma Unreferenced is given.
4977
4978 Note that if a warning is desired for all calls to a given subprogram,
4979 regardless of whether they occur in the same unit as the subprogram
4980 declaration, then this pragma should not be used (calls from another
4981 unit would not be flagged); pragma Obsolescent can be used instead
4982 for this purpose, see @xref{Pragma Obsolescent}.
4983
4984 The second form of pragma @code{Unreferenced} is used within a context
4985 clause. In this case the arguments must be unit names of units previously
4986 mentioned in @code{with} clauses (similar to the usage of pragma
4987 @code{Elaborate_All}. The effect is to suppress warnings about unreferenced
4988 units and unreferenced entities within these units.
4989
4990 @node Pragma Unreferenced_Objects
4991 @unnumberedsec Pragma Unreferenced_Objects
4992 @findex Unreferenced_Objects
4993 @cindex Warnings, unreferenced
4994 @noindent
4995 Syntax:
4996
4997 @smallexample @c ada
4998 pragma Unreferenced_Objects (local_subtype_NAME @{, local_subtype_NAME@});
4999 @end smallexample
5000
5001 @noindent
5002 This pragma signals that for the types or subtypes whose names are
5003 listed, objects which are declared with one of these types or subtypes may
5004 not be referenced, and if no references appear, no warnings are given.
5005
5006 This is particularly useful for objects which are declared solely for their
5007 initialization and finalization effect. Such variables are sometimes referred
5008 to as RAII variables (Resource Acquisition Is Initialization). Using this
5009 pragma on the relevant type (most typically a limited controlled type), the
5010 compiler will automatically suppress unwanted warnings about these variables
5011 not being referenced.
5012
5013 @node Pragma Unreserve_All_Interrupts
5014 @unnumberedsec Pragma Unreserve_All_Interrupts
5015 @findex Unreserve_All_Interrupts
5016 @noindent
5017 Syntax:
5018
5019 @smallexample @c ada
5020 pragma Unreserve_All_Interrupts;
5021 @end smallexample
5022
5023 @noindent
5024 Normally certain interrupts are reserved to the implementation.  Any attempt
5025 to attach an interrupt causes Program_Error to be raised, as described in
5026 RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
5027 many systems for a @kbd{Ctrl-C} interrupt.  Normally this interrupt is
5028 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
5029 interrupt execution.
5030
5031 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
5032 a program, then all such interrupts are unreserved.  This allows the
5033 program to handle these interrupts, but disables their standard
5034 functions.  For example, if this pragma is used, then pressing
5035 @kbd{Ctrl-C} will not automatically interrupt execution.  However,
5036 a program can then handle the @code{SIGINT} interrupt as it chooses.
5037
5038 For a full list of the interrupts handled in a specific implementation,
5039 see the source code for the spec of @code{Ada.Interrupts.Names} in
5040 file @file{a-intnam.ads}.  This is a target dependent file that contains the
5041 list of interrupts recognized for a given target.  The documentation in
5042 this file also specifies what interrupts are affected by the use of
5043 the @code{Unreserve_All_Interrupts} pragma.
5044
5045 For a more general facility for controlling what interrupts can be
5046 handled, see pragma @code{Interrupt_State}, which subsumes the functionality
5047 of the @code{Unreserve_All_Interrupts} pragma.
5048
5049 @node Pragma Unsuppress
5050 @unnumberedsec Pragma Unsuppress
5051 @findex Unsuppress
5052 @noindent
5053 Syntax:
5054
5055 @smallexample @c ada
5056 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
5057 @end smallexample
5058
5059 @noindent
5060 This pragma undoes the effect of a previous pragma @code{Suppress}.  If
5061 there is no corresponding pragma @code{Suppress} in effect, it has no
5062 effect.  The range of the effect is the same as for pragma
5063 @code{Suppress}.  The meaning of the arguments is identical to that used
5064 in pragma @code{Suppress}.
5065
5066 One important application is to ensure that checks are on in cases where
5067 code depends on the checks for its correct functioning, so that the code
5068 will compile correctly even if the compiler switches are set to suppress
5069 checks.
5070
5071 @node Pragma Use_VADS_Size
5072 @unnumberedsec Pragma Use_VADS_Size
5073 @cindex @code{Size}, VADS compatibility
5074 @findex Use_VADS_Size
5075 @noindent
5076 Syntax:
5077
5078 @smallexample @c ada
5079 pragma Use_VADS_Size;
5080 @end smallexample
5081
5082 @noindent
5083 This is a configuration pragma.  In a unit to which it applies, any use
5084 of the 'Size attribute is automatically interpreted as a use of the
5085 'VADS_Size attribute.  Note that this may result in incorrect semantic
5086 processing of valid Ada 95 or Ada 2005 programs.  This is intended to aid in
5087 the handling of existing code which depends on the interpretation of Size
5088 as implemented in the VADS compiler.  See description of the VADS_Size
5089 attribute for further details.
5090
5091 @node Pragma Validity_Checks
5092 @unnumberedsec Pragma Validity_Checks
5093 @findex Validity_Checks
5094 @noindent
5095 Syntax:
5096
5097 @smallexample @c ada
5098 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
5099 @end smallexample
5100
5101 @noindent
5102 This pragma is used in conjunction with compiler switches to control the
5103 built-in validity checking provided by GNAT@.  The compiler switches, if set
5104 provide an initial setting for the switches, and this pragma may be used
5105 to modify these settings, or the settings may be provided entirely by
5106 the use of the pragma.  This pragma can be used anywhere that a pragma
5107 is legal, including use as a configuration pragma (including use in
5108 the @file{gnat.adc} file).
5109
5110 The form with a string literal specifies which validity options are to be
5111 activated.  The validity checks are first set to include only the default
5112 reference manual settings, and then a string of letters in the string
5113 specifies the exact set of options required.  The form of this string
5114 is exactly as described for the @option{-gnatVx} compiler switch (see the
5115 GNAT users guide for details).  For example the following two methods
5116 can be used to enable validity checking for mode @code{in} and
5117 @code{in out} subprogram parameters:
5118
5119 @itemize @bullet
5120 @item
5121 @smallexample @c ada
5122 pragma Validity_Checks ("im");
5123 @end smallexample
5124
5125 @item
5126 @smallexample
5127 gcc -c -gnatVim @dots{}
5128 @end smallexample
5129 @end itemize
5130
5131 @noindent
5132 The form ALL_CHECKS activates all standard checks (its use is equivalent
5133 to the use of the @code{gnatva} switch.
5134
5135 The forms with @code{Off} and @code{On}
5136 can be used to temporarily disable validity checks
5137 as shown in the following example:
5138
5139 @smallexample @c ada
5140 @iftex
5141 @leftskip=0cm
5142 @end iftex
5143 pragma Validity_Checks ("c"); -- validity checks for copies
5144 pragma Validity_Checks (Off); -- turn off validity checks
5145 A := B;                       -- B will not be validity checked
5146 pragma Validity_Checks (On);  -- turn validity checks back on
5147 A := C;                       -- C will be validity checked
5148 @end smallexample
5149
5150 @node Pragma Volatile
5151 @unnumberedsec Pragma Volatile
5152 @findex Volatile
5153 @noindent
5154 Syntax:
5155
5156 @smallexample @c ada
5157 pragma Volatile (LOCAL_NAME);
5158 @end smallexample
5159
5160 @noindent
5161 This pragma is defined by the Ada Reference Manual, and the GNAT
5162 implementation is fully conformant with this definition.  The reason it
5163 is mentioned in this section is that a pragma of the same name was supplied
5164 in some Ada 83 compilers, including DEC Ada 83.  The Ada 95 / Ada 2005
5165 implementation of pragma Volatile is upwards compatible with the
5166 implementation in DEC Ada 83.
5167
5168 @node Pragma Warnings
5169 @unnumberedsec Pragma Warnings
5170 @findex Warnings
5171 @noindent
5172 Syntax:
5173
5174 @smallexample @c ada
5175 pragma Warnings (On | Off);
5176 pragma Warnings (On | Off, LOCAL_NAME);
5177 pragma Warnings (static_string_EXPRESSION);
5178 pragma Warnings (On | Off, static_string_EXPRESSION);
5179 @end smallexample
5180
5181 @noindent
5182 Normally warnings are enabled, with the output being controlled by
5183 the command line switch.  Warnings (@code{Off}) turns off generation of
5184 warnings until a Warnings (@code{On}) is encountered or the end of the
5185 current unit.  If generation of warnings is turned off using this
5186 pragma, then no warning messages are output, regardless of the
5187 setting of the command line switches.
5188
5189 The form with a single argument may be used as a configuration pragma.
5190
5191 If the @var{LOCAL_NAME} parameter is present, warnings are suppressed for
5192 the specified entity.  This suppression is effective from the point where
5193 it occurs till the end of the extended scope of the variable (similar to
5194 the scope of @code{Suppress}).
5195
5196 The form with a single static_string_EXPRESSION argument provides more precise
5197 control over which warnings are active. The string is a list of letters
5198 specifying which warnings are to be activated and which deactivated. The
5199 code for these letters is the same as the string used in the command
5200 line switch controlling warnings. For a brief summary, use the gnatmake
5201 command with no arguments, which will generate usage information containing
5202 the list of warnings switches supported. For
5203 full details see @ref{Warning Message Control,,, gnat_ugn, @value{EDITION}
5204 User's Guide}.
5205
5206 @noindent
5207 The specified warnings will be in effect until the end of the program
5208 or another pragma Warnings is encountered. The effect of the pragma is
5209 cumulative. Initially the set of warnings is the standard default set
5210 as possibly modified by compiler switches. Then each pragma Warning
5211 modifies this set of warnings as specified. This form of the pragma may
5212 also be used as a configuration pragma.
5213
5214 The fourth form, with an On|Off parameter and a string, is used to
5215 control individual messages, based on their text. The string argument
5216 is a pattern that is used to match against the text of individual
5217 warning messages (not including the initial "warning: " tag).
5218
5219 The pattern may contain asterisks, which match zero or more characters in
5220 the message. For example, you can use
5221 @code{pragma Warnings (Off, "*bits of*unused")} to suppress the warning
5222 message @code{warning: 960 bits of "a" unused}. No other regular
5223 expression notations are permitted. All characters other than asterisk in
5224 these three specific cases are treated as literal characters in the match.
5225
5226 There are two ways to use this pragma. The OFF form can be used as a
5227 configuration pragma. The effect is to suppress all warnings (if any)
5228 that match the pattern string throughout the compilation.
5229
5230 The second usage is to suppress a warning locally, and in this case, two
5231 pragmas must appear in sequence:
5232
5233 @smallexample @c ada
5234 pragma Warnings (Off, Pattern);
5235 @dots{} code where given warning is to be suppressed
5236 pragma Warnings (On, Pattern);
5237 @end smallexample
5238
5239 @noindent
5240 In this usage, the pattern string must match in the Off and On pragmas,
5241 and at least one matching warning must be suppressed.
5242
5243 Note: the debug flag -gnatd.i (@code{/NOWARNINGS_PRAGMAS} in VMS) can be
5244 used to cause the compiler to entirely ignore all WARNINGS pragmas. This can
5245 be useful in checking whether obsolete pragmas in existing programs are hiding
5246 real problems.
5247
5248 @node Pragma Weak_External
5249 @unnumberedsec Pragma Weak_External
5250 @findex Weak_External
5251 @noindent
5252 Syntax:
5253
5254 @smallexample @c ada
5255 pragma Weak_External ([Entity =>] LOCAL_NAME);
5256 @end smallexample
5257
5258 @noindent
5259 @var{LOCAL_NAME} must refer to an object that is declared at the library
5260 level. This pragma specifies that the given entity should be marked as a
5261 weak symbol for the linker. It is equivalent to @code{__attribute__((weak))}
5262 in GNU C and causes @var{LOCAL_NAME} to be emitted as a weak symbol instead
5263 of a regular symbol, that is to say a symbol that does not have to be
5264 resolved by the linker if used in conjunction with a pragma Import.
5265
5266 When a weak symbol is not resolved by the linker, its address is set to
5267 zero. This is useful in writing interfaces to external modules that may
5268 or may not be linked in the final executable, for example depending on
5269 configuration settings.
5270
5271 If a program references at run time an entity to which this pragma has been
5272 applied, and the corresponding symbol was not resolved at link time, then
5273 the execution of the program is erroneous. It is not erroneous to take the
5274 Address of such an entity, for example to guard potential references,
5275 as shown in the example below.
5276
5277 Some file formats do not support weak symbols so not all target machines
5278 support this pragma.
5279
5280 @smallexample @c ada
5281 --  Example of the use of pragma Weak_External
5282
5283 package External_Module is
5284   key : Integer;
5285   pragma Import (C, key);
5286   pragma Weak_External (key);
5287   function Present return boolean;
5288 end External_Module;
5289
5290 with System; use System;
5291 package body External_Module is
5292   function Present return boolean is
5293   begin
5294     return key'Address /= System.Null_Address;
5295   end Present;
5296 end External_Module;
5297 @end smallexample
5298
5299 @node Pragma Wide_Character_Encoding
5300 @unnumberedsec Pragma Wide_Character_Encoding
5301 @findex Wide_Character_Encoding
5302 @noindent
5303 Syntax:
5304
5305 @smallexample @c ada
5306 pragma Wide_Character_Encoding (IDENTIFIER | CHARACTER_LITERAL);
5307 @end smallexample
5308
5309 @noindent
5310 This pragma specifies the wide character encoding to be used in program
5311 source text appearing subsequently. It is a configuration pragma, but may
5312 also be used at any point that a pragma is allowed, and it is permissible
5313 to have more than one such pragma in a file, allowing multiple encodings
5314 to appear within the same file.
5315
5316 The argument can be an identifier or a character literal. In the identifier
5317 case, it is one of @code{HEX}, @code{UPPER}, @code{SHIFT_JIS},
5318 @code{EUC}, @code{UTF8}, or @code{BRACKETS}. In the character literal
5319 case it is correspondingly one of the characters @samp{h}, @samp{u},
5320 @samp{s}, @samp{e}, @samp{8}, or @samp{b}.
5321
5322 Note that when the pragma is used within a file, it affects only the
5323 encoding within that file, and does not affect withed units, specs,
5324 or subunits.
5325
5326 @node Implementation Defined Attributes
5327 @chapter Implementation Defined Attributes
5328 Ada defines (throughout the Ada reference manual,
5329 summarized in Annex K),
5330 a set of attributes that provide useful additional functionality in all
5331 areas of the language.  These language defined attributes are implemented
5332 in GNAT and work as described in the Ada Reference Manual.
5333
5334 In addition, Ada allows implementations to define additional
5335 attributes whose meaning is defined by the implementation.  GNAT provides
5336 a number of these implementation-dependent attributes which can be used
5337 to extend and enhance the functionality of the compiler.  This section of
5338 the GNAT reference manual describes these additional attributes.
5339
5340 Note that any program using these attributes may not be portable to
5341 other compilers (although GNAT implements this set of attributes on all
5342 platforms).  Therefore if portability to other compilers is an important
5343 consideration, you should minimize the use of these attributes.
5344
5345 @menu
5346 * Abort_Signal::
5347 * Address_Size::
5348 * Asm_Input::
5349 * Asm_Output::
5350 * AST_Entry::
5351 * Bit::
5352 * Bit_Position::
5353 * Compiler_Version::
5354 * Code_Address::
5355 * Default_Bit_Order::
5356 * Elaborated::
5357 * Elab_Body::
5358 * Elab_Spec::
5359 * Emax::
5360 * Enabled::
5361 * Enum_Rep::
5362 * Enum_Val::
5363 * Epsilon::
5364 * Fixed_Value::
5365 * Has_Access_Values::
5366 * Has_Discriminants::
5367 * Img::
5368 * Integer_Value::
5369 * Invalid_Value::
5370 * Large::
5371 * Machine_Size::
5372 * Mantissa::
5373 * Max_Interrupt_Priority::
5374 * Max_Priority::
5375 * Maximum_Alignment::
5376 * Mechanism_Code::
5377 * Null_Parameter::
5378 * Object_Size::
5379 * Old::
5380 * Passed_By_Reference::
5381 * Pool_Address::
5382 * Range_Length::
5383 * Result::
5384 * Safe_Emax::
5385 * Safe_Large::
5386 * Small::
5387 * Storage_Unit::
5388 * Stub_Type::
5389 * Target_Name::
5390 * Tick::
5391 * To_Address::
5392 * Type_Class::
5393 * UET_Address::
5394 * Unconstrained_Array::
5395 * Universal_Literal_String::
5396 * Unrestricted_Access::
5397 * VADS_Size::
5398 * Value_Size::
5399 * Wchar_T_Size::
5400 * Word_Size::
5401 @end menu
5402
5403 @node Abort_Signal
5404 @unnumberedsec Abort_Signal
5405 @findex Abort_Signal
5406 @noindent
5407 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
5408 prefix) provides the entity for the special exception used to signal
5409 task abort or asynchronous transfer of control.  Normally this attribute
5410 should only be used in the tasking runtime (it is highly peculiar, and
5411 completely outside the normal semantics of Ada, for a user program to
5412 intercept the abort exception).
5413
5414 @node Address_Size
5415 @unnumberedsec Address_Size
5416 @cindex Size of @code{Address}
5417 @findex Address_Size
5418 @noindent
5419 @code{Standard'Address_Size} (@code{Standard} is the only allowed
5420 prefix) is a static constant giving the number of bits in an
5421 @code{Address}. It is the same value as System.Address'Size,
5422 but has the advantage of being static, while a direct
5423 reference to System.Address'Size is non-static because Address
5424 is a private type.
5425
5426 @node Asm_Input
5427 @unnumberedsec Asm_Input
5428 @findex Asm_Input
5429 @noindent
5430 The @code{Asm_Input} attribute denotes a function that takes two
5431 parameters.  The first is a string, the second is an expression of the
5432 type designated by the prefix.  The first (string) argument is required
5433 to be a static expression, and is the constraint for the parameter,
5434 (e.g.@: what kind of register is required).  The second argument is the
5435 value to be used as the input argument.  The possible values for the
5436 constant are the same as those used in the RTL, and are dependent on
5437 the configuration file used to built the GCC back end.
5438 @ref{Machine Code Insertions}
5439
5440 @node Asm_Output
5441 @unnumberedsec Asm_Output
5442 @findex Asm_Output
5443 @noindent
5444 The @code{Asm_Output} attribute denotes a function that takes two
5445 parameters.  The first is a string, the second is the name of a variable
5446 of the type designated by the attribute prefix.  The first (string)
5447 argument is required to be a static expression and designates the
5448 constraint for the parameter (e.g.@: what kind of register is
5449 required).  The second argument is the variable to be updated with the
5450 result.  The possible values for constraint are the same as those used in
5451 the RTL, and are dependent on the configuration file used to build the
5452 GCC back end.  If there are no output operands, then this argument may
5453 either be omitted, or explicitly given as @code{No_Output_Operands}.
5454 @ref{Machine Code Insertions}
5455
5456 @node AST_Entry
5457 @unnumberedsec AST_Entry
5458 @cindex OpenVMS
5459 @findex AST_Entry
5460 @noindent
5461 This attribute is implemented only in OpenVMS versions of GNAT@.  Applied to
5462 the name of an entry, it yields a value of the predefined type AST_Handler
5463 (declared in the predefined package System, as extended by the use of
5464 pragma @code{Extend_System (Aux_DEC)}).  This value enables the given entry to
5465 be called when an AST occurs.  For further details, refer to the @cite{DEC Ada
5466 Language Reference Manual}, section 9.12a.
5467
5468 @node Bit
5469 @unnumberedsec Bit
5470 @findex Bit
5471 @code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
5472 offset within the storage unit (byte) that contains the first bit of
5473 storage allocated for the object.  The value of this attribute is of the
5474 type @code{Universal_Integer}, and is always a non-negative number not
5475 exceeding the value of @code{System.Storage_Unit}.
5476
5477 For an object that is a variable or a constant allocated in a register,
5478 the value is zero.  (The use of this attribute does not force the
5479 allocation of a variable to memory).
5480
5481 For an object that is a formal parameter, this attribute applies
5482 to either the matching actual parameter or to a copy of the
5483 matching actual parameter.
5484
5485 For an access object the value is zero.  Note that
5486 @code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
5487 designated object.  Similarly for a record component
5488 @code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
5489 @code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
5490 are subject to index checks.
5491
5492 This attribute is designed to be compatible with the DEC Ada 83 definition
5493 and implementation of the @code{Bit} attribute.
5494
5495 @node Bit_Position
5496 @unnumberedsec Bit_Position
5497 @findex Bit_Position
5498 @noindent
5499 @code{@var{R.C}'Bit}, where @var{R} is a record object and C is one
5500 of the fields of the record type, yields the bit
5501 offset within the record contains the first bit of
5502 storage allocated for the object.  The value of this attribute is of the
5503 type @code{Universal_Integer}.  The value depends only on the field
5504 @var{C} and is independent of the alignment of
5505 the containing record @var{R}.
5506
5507 @node Compiler_Version
5508 @unnumberedsec Compiler_Version
5509 @findex Compiler_Version
5510 @noindent
5511 @code{Standard'Compiler_Version} (@code{Standard} is the only allowed
5512 prefix) yields a static string identifying the version of the compiler
5513 being used to compile the unit containing the attribute reference. A
5514 typical result would be something like "GNAT Pro 6.3.0w (20090221)".
5515
5516 @node Code_Address
5517 @unnumberedsec Code_Address
5518 @findex Code_Address
5519 @cindex Subprogram address
5520 @cindex Address of subprogram code
5521 @noindent
5522 The @code{'Address}
5523 attribute may be applied to subprograms in Ada 95 and Ada 2005, but the
5524 intended effect seems to be to provide
5525 an address value which can be used to call the subprogram by means of
5526 an address clause as in the following example:
5527
5528 @smallexample @c ada
5529 procedure K is @dots{}
5530
5531 procedure L;
5532 for L'Address use K'Address;
5533 pragma Import (Ada, L);
5534 @end smallexample
5535
5536 @noindent
5537 A call to @code{L} is then expected to result in a call to @code{K}@.
5538 In Ada 83, where there were no access-to-subprogram values, this was
5539 a common work-around for getting the effect of an indirect call.
5540 GNAT implements the above use of @code{Address} and the technique
5541 illustrated by the example code works correctly.
5542
5543 However, for some purposes, it is useful to have the address of the start
5544 of the generated code for the subprogram.  On some architectures, this is
5545 not necessarily the same as the @code{Address} value described above.
5546 For example, the @code{Address} value may reference a subprogram
5547 descriptor rather than the subprogram itself.
5548
5549 The @code{'Code_Address} attribute, which can only be applied to
5550 subprogram entities, always returns the address of the start of the
5551 generated code of the specified subprogram, which may or may not be
5552 the same value as is returned by the corresponding @code{'Address}
5553 attribute.
5554
5555 @node Default_Bit_Order
5556 @unnumberedsec Default_Bit_Order
5557 @cindex Big endian
5558 @cindex Little endian
5559 @findex Default_Bit_Order
5560 @noindent
5561 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
5562 permissible prefix), provides the value @code{System.Default_Bit_Order}
5563 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
5564 @code{Low_Order_First}).  This is used to construct the definition of
5565 @code{Default_Bit_Order} in package @code{System}.
5566
5567 @node Elaborated
5568 @unnumberedsec Elaborated
5569 @findex Elaborated
5570 @noindent
5571 The prefix of the @code{'Elaborated} attribute must be a unit name.  The
5572 value is a Boolean which indicates whether or not the given unit has been
5573 elaborated.  This attribute is primarily intended for internal use by the
5574 generated code for dynamic elaboration checking, but it can also be used
5575 in user programs.  The value will always be True once elaboration of all
5576 units has been completed.  An exception is for units which need no
5577 elaboration, the value is always False for such units.
5578
5579 @node Elab_Body
5580 @unnumberedsec Elab_Body
5581 @findex Elab_Body
5582 @noindent
5583 This attribute can only be applied to a program unit name.  It returns
5584 the entity for the corresponding elaboration procedure for elaborating
5585 the body of the referenced unit.  This is used in the main generated
5586 elaboration procedure by the binder and is not normally used in any
5587 other context.  However, there may be specialized situations in which it
5588 is useful to be able to call this elaboration procedure from Ada code,
5589 e.g.@: if it is necessary to do selective re-elaboration to fix some
5590 error.
5591
5592 @node Elab_Spec
5593 @unnumberedsec Elab_Spec
5594 @findex Elab_Spec
5595 @noindent
5596 This attribute can only be applied to a program unit name.  It returns
5597 the entity for the corresponding elaboration procedure for elaborating
5598 the spec of the referenced unit.  This is used in the main
5599 generated elaboration procedure by the binder and is not normally used
5600 in any other context.  However, there may be specialized situations in
5601 which it is useful to be able to call this elaboration procedure from
5602 Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
5603 some error.
5604
5605 @node Emax
5606 @unnumberedsec Emax
5607 @cindex Ada 83 attributes
5608 @findex Emax
5609 @noindent
5610 The @code{Emax} attribute is provided for compatibility with Ada 83.  See
5611 the Ada 83 reference manual for an exact description of the semantics of
5612 this attribute.
5613
5614 @node Enabled
5615 @unnumberedsec Enabled
5616 @findex Enabled
5617 @noindent
5618 The @code{Enabled} attribute allows an application program to check at compile
5619 time to see if the designated check is currently enabled. The prefix is a
5620 simple identifier, referencing any predefined check name (other than
5621 @code{All_Checks}) or a check name introduced by pragma Check_Name. If
5622 no argument is given for the attribute, the check is for the general state
5623 of the check, if an argument is given, then it is an entity name, and the
5624 check indicates whether an @code{Suppress} or @code{Unsuppress} has been
5625 given naming the entity (if not, then the argument is ignored).
5626
5627 Note that instantiations inherit the check status at the point of the
5628 instantiation, so a useful idiom is to have a library package that
5629 introduces a check name with @code{pragma Check_Name}, and then contains
5630 generic packages or subprograms which use the @code{Enabled} attribute
5631 to see if the check is enabled. A user of this package can then issue
5632 a @code{pragma Suppress} or @code{pragma Unsuppress} before instantiating
5633 the package or subprogram, controlling whether the check will be present.
5634
5635 @node Enum_Rep
5636 @unnumberedsec Enum_Rep
5637 @cindex Representation of enums
5638 @findex Enum_Rep
5639 @noindent
5640 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
5641 function with the following spec:
5642
5643 @smallexample @c ada
5644 function @var{S}'Enum_Rep (Arg : @var{S}'Base)
5645   return @i{Universal_Integer};
5646 @end smallexample
5647
5648 @noindent
5649 It is also allowable to apply @code{Enum_Rep} directly to an object of an
5650 enumeration type or to a non-overloaded enumeration
5651 literal.  In this case @code{@var{S}'Enum_Rep} is equivalent to
5652 @code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
5653 enumeration literal or object.
5654
5655 The function returns the representation value for the given enumeration
5656 value.  This will be equal to value of the @code{Pos} attribute in the
5657 absence of an enumeration representation clause.  This is a static
5658 attribute (i.e.@: the result is static if the argument is static).
5659
5660 @code{@var{S}'Enum_Rep} can also be used with integer types and objects,
5661 in which case it simply returns the integer value.  The reason for this
5662 is to allow it to be used for @code{(<>)} discrete formal arguments in
5663 a generic unit that can be instantiated with either enumeration types
5664 or integer types.  Note that if @code{Enum_Rep} is used on a modular
5665 type whose upper bound exceeds the upper bound of the largest signed
5666 integer type, and the argument is a variable, so that the universal
5667 integer calculation is done at run time, then the call to @code{Enum_Rep}
5668 may raise @code{Constraint_Error}.
5669
5670 @node Enum_Val
5671 @unnumberedsec Enum_Val
5672 @cindex Representation of enums
5673 @findex Enum_Val
5674 @noindent
5675 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
5676 function with the following spec:
5677
5678 @smallexample @c ada
5679 function @var{S}'Enum_Rep (Arg : @i{Universal_Integer)
5680   return @var{S}'Base};
5681 @end smallexample
5682
5683 @noindent
5684 The function returns the enumeration value whose representation matches the
5685 argument, or raises Constraint_Error if no enumeration literal of the type
5686 has the matching value.
5687 This will be equal to value of the @code{Val} attribute in the
5688 absence of an enumeration representation clause.  This is a static
5689 attribute (i.e.@: the result is static if the argument is static).
5690
5691 @node Epsilon
5692 @unnumberedsec Epsilon
5693 @cindex Ada 83 attributes
5694 @findex Epsilon
5695 @noindent
5696 The @code{Epsilon} attribute is provided for compatibility with Ada 83.  See
5697 the Ada 83 reference manual for an exact description of the semantics of
5698 this attribute.
5699
5700 @node Fixed_Value
5701 @unnumberedsec Fixed_Value
5702 @findex Fixed_Value
5703 @noindent
5704 For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
5705 function with the following specification:
5706
5707 @smallexample @c ada
5708 function @var{S}'Fixed_Value (Arg : @i{Universal_Integer})
5709   return @var{S};
5710 @end smallexample
5711
5712 @noindent
5713 The value returned is the fixed-point value @var{V} such that
5714
5715 @smallexample @c ada
5716 @var{V} = Arg * @var{S}'Small
5717 @end smallexample
5718
5719 @noindent
5720 The effect is thus similar to first converting the argument to the
5721 integer type used to represent @var{S}, and then doing an unchecked
5722 conversion to the fixed-point type.  The difference is
5723 that there are full range checks, to ensure that the result is in range.
5724 This attribute is primarily intended for use in implementation of the
5725 input-output functions for fixed-point values.
5726
5727 @node Has_Access_Values
5728 @unnumberedsec Has_Access_Values
5729 @cindex Access values, testing for
5730 @findex Has_Access_Values
5731 @noindent
5732 The prefix of the @code{Has_Access_Values} attribute is a type.  The result
5733 is a Boolean value which is True if the is an access type, or is a composite
5734 type with a component (at any nesting depth) that is an access type, and is
5735 False otherwise.
5736 The intended use of this attribute is in conjunction with generic
5737 definitions.  If the attribute is applied to a generic private type, it
5738 indicates whether or not the corresponding actual type has access values.
5739
5740 @node Has_Discriminants
5741 @unnumberedsec Has_Discriminants
5742 @cindex Discriminants, testing for
5743 @findex Has_Discriminants
5744 @noindent
5745 The prefix of the @code{Has_Discriminants} attribute is a type.  The result
5746 is a Boolean value which is True if the type has discriminants, and False
5747 otherwise.  The intended use of this attribute is in conjunction with generic
5748 definitions.  If the attribute is applied to a generic private type, it
5749 indicates whether or not the corresponding actual type has discriminants.
5750
5751 @node Img
5752 @unnumberedsec Img
5753 @findex Img
5754 @noindent
5755 The @code{Img} attribute differs from @code{Image} in that it may be
5756 applied to objects as well as types, in which case it gives the
5757 @code{Image} for the subtype of the object.  This is convenient for
5758 debugging:
5759
5760 @smallexample @c ada
5761 Put_Line ("X = " & X'Img);
5762 @end smallexample
5763
5764 @noindent
5765 has the same meaning as the more verbose:
5766
5767 @smallexample @c ada
5768 Put_Line ("X = " & @var{T}'Image (X));
5769 @end smallexample
5770
5771 @noindent
5772 where @var{T} is the (sub)type of the object @code{X}.
5773
5774 @node Integer_Value
5775 @unnumberedsec Integer_Value
5776 @findex Integer_Value
5777 @noindent
5778 For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
5779 function with the following spec:
5780
5781 @smallexample @c ada
5782 function @var{S}'Integer_Value (Arg : @i{Universal_Fixed})
5783   return @var{S};
5784 @end smallexample
5785
5786 @noindent
5787 The value returned is the integer value @var{V}, such that
5788
5789 @smallexample @c ada
5790 Arg = @var{V} * @var{T}'Small
5791 @end smallexample
5792
5793 @noindent
5794 where @var{T} is the type of @code{Arg}.
5795 The effect is thus similar to first doing an unchecked conversion from
5796 the fixed-point type to its corresponding implementation type, and then
5797 converting the result to the target integer type.  The difference is
5798 that there are full range checks, to ensure that the result is in range.
5799 This attribute is primarily intended for use in implementation of the
5800 standard input-output functions for fixed-point values.
5801
5802 @node Invalid_Value
5803 @unnumberedsec Invalid_Value
5804 @findex Invalid_Value
5805 @noindent
5806 For every scalar type S, S'Invalid_Value returns an undefined value of the
5807 type. If possible this value is an invalid representation for the type. The
5808 value returned is identical to the value used to initialize an otherwise
5809 uninitialized value of the type if pragma Initialize_Scalars is used,
5810 including the ability to modify the value with the binder -Sxx flag and
5811 relevant environment variables at run time.
5812
5813 @node Large
5814 @unnumberedsec Large
5815 @cindex Ada 83 attributes
5816 @findex Large
5817 @noindent
5818 The @code{Large} attribute is provided for compatibility with Ada 83.  See
5819 the Ada 83 reference manual for an exact description of the semantics of
5820 this attribute.
5821
5822 @node Machine_Size
5823 @unnumberedsec Machine_Size
5824 @findex Machine_Size
5825 @noindent
5826 This attribute is identical to the @code{Object_Size} attribute.  It is
5827 provided for compatibility with the DEC Ada 83 attribute of this name.
5828
5829 @node Mantissa
5830 @unnumberedsec Mantissa
5831 @cindex Ada 83 attributes
5832 @findex Mantissa
5833 @noindent
5834 The @code{Mantissa} attribute is provided for compatibility with Ada 83.  See
5835 the Ada 83 reference manual for an exact description of the semantics of
5836 this attribute.
5837
5838 @node Max_Interrupt_Priority
5839 @unnumberedsec Max_Interrupt_Priority
5840 @cindex Interrupt priority, maximum
5841 @findex Max_Interrupt_Priority
5842 @noindent
5843 @code{Standard'Max_Interrupt_Priority} (@code{Standard} is the only
5844 permissible prefix), provides the same value as
5845 @code{System.Max_Interrupt_Priority}.
5846
5847 @node Max_Priority
5848 @unnumberedsec Max_Priority
5849 @cindex Priority, maximum
5850 @findex Max_Priority
5851 @noindent
5852 @code{Standard'Max_Priority} (@code{Standard} is the only permissible
5853 prefix) provides the same value as @code{System.Max_Priority}.
5854
5855 @node Maximum_Alignment
5856 @unnumberedsec Maximum_Alignment
5857 @cindex Alignment, maximum
5858 @findex Maximum_Alignment
5859 @noindent
5860 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
5861 permissible prefix) provides the maximum useful alignment value for the
5862 target.  This is a static value that can be used to specify the alignment
5863 for an object, guaranteeing that it is properly aligned in all
5864 cases.
5865
5866 @node Mechanism_Code
5867 @unnumberedsec Mechanism_Code
5868 @cindex Return values, passing mechanism
5869 @cindex Parameters, passing mechanism
5870 @findex Mechanism_Code
5871 @noindent
5872 @code{@var{function}'Mechanism_Code} yields an integer code for the
5873 mechanism used for the result of function, and
5874 @code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
5875 used for formal parameter number @var{n} (a static integer value with 1
5876 meaning the first parameter) of @var{subprogram}.  The code returned is:
5877
5878 @table @asis
5879 @item 1
5880 by copy (value)
5881 @item 2
5882 by reference
5883 @item 3
5884 by descriptor (default descriptor class)
5885 @item 4
5886 by descriptor (UBS: unaligned bit string)
5887 @item 5
5888 by descriptor (UBSB: aligned bit string with arbitrary bounds)
5889 @item 6
5890 by descriptor (UBA: unaligned bit array)
5891 @item 7
5892 by descriptor (S: string, also scalar access type parameter)
5893 @item 8
5894 by descriptor (SB: string with arbitrary bounds)
5895 @item 9
5896 by descriptor (A: contiguous array)
5897 @item 10
5898 by descriptor (NCA: non-contiguous array)
5899 @end table
5900
5901 @noindent
5902 Values from 3 through 10 are only relevant to Digital OpenVMS implementations.
5903 @cindex OpenVMS
5904
5905 @node Null_Parameter
5906 @unnumberedsec Null_Parameter
5907 @cindex Zero address, passing
5908 @findex Null_Parameter
5909 @noindent
5910 A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
5911 type or subtype @var{T} allocated at machine address zero.  The attribute
5912 is allowed only as the default expression of a formal parameter, or as
5913 an actual expression of a subprogram call.  In either case, the
5914 subprogram must be imported.
5915
5916 The identity of the object is represented by the address zero in the
5917 argument list, independent of the passing mechanism (explicit or
5918 default).
5919
5920 This capability is needed to specify that a zero address should be
5921 passed for a record or other composite object passed by reference.
5922 There is no way of indicating this without the @code{Null_Parameter}
5923 attribute.
5924
5925 @node Object_Size
5926 @unnumberedsec Object_Size
5927 @cindex Size, used for objects
5928 @findex Object_Size
5929 @noindent
5930 The size of an object is not necessarily the same as the size of the type
5931 of an object.  This is because by default object sizes are increased to be
5932 a multiple of the alignment of the object.  For example,
5933 @code{Natural'Size} is
5934 31, but by default objects of type @code{Natural} will have a size of 32 bits.
5935 Similarly, a record containing an integer and a character:
5936
5937 @smallexample @c ada
5938 type Rec is record
5939    I : Integer;
5940    C : Character;
5941 end record;
5942 @end smallexample
5943
5944 @noindent
5945 will have a size of 40 (that is @code{Rec'Size} will be 40.  The
5946 alignment will be 4, because of the
5947 integer field, and so the default size of record objects for this type
5948 will be 64 (8 bytes).
5949
5950 @node Old
5951 @unnumberedsec Old
5952 @cindex Capturing Old values
5953 @cindex Postconditions
5954 @noindent
5955 The attribute Prefix'Old can be used within a
5956 subprogram to refer to the value of the prefix on entry. So for
5957 example if you have an argument of a record type X called Arg1,
5958 you can refer to Arg1.Field'Old which yields the value of
5959 Arg1.Field on entry. The implementation simply involves generating
5960 an object declaration which captures the value on entry. Any
5961 prefix is allowed except one of a limited type (since limited
5962 types cannot be copied to capture their values) or a local variable
5963 (since it does not exist at subprogram entry time).
5964
5965 The following example shows the use of 'Old to implement
5966 a test of a postcondition:
5967
5968 @smallexample @c ada
5969 with Old_Pkg;
5970 procedure Old is
5971 begin
5972    Old_Pkg.Incr;
5973 end Old;
5974
5975 package Old_Pkg is
5976    procedure Incr;
5977 end Old_Pkg;
5978
5979 package body Old_Pkg is
5980    Count : Natural := 0;
5981
5982    procedure Incr is
5983    begin
5984       ... code manipulating the value of Count
5985
5986       pragma Assert (Count = Count'Old + 1);
5987    end Incr;
5988 end Old_Pkg;
5989 @end smallexample
5990
5991 @noindent
5992 Note that it is allowed to apply 'Old to a constant entity, but this will
5993 result in a warning, since the old and new values will always be the same.
5994
5995 @node Passed_By_Reference
5996 @unnumberedsec Passed_By_Reference
5997 @cindex Parameters, when passed by reference
5998 @findex Passed_By_Reference
5999 @noindent
6000 @code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
6001 a value of type @code{Boolean} value that is @code{True} if the type is
6002 normally passed by reference and @code{False} if the type is normally
6003 passed by copy in calls.  For scalar types, the result is always @code{False}
6004 and is static.  For non-scalar types, the result is non-static.
6005
6006 @node Pool_Address
6007 @unnumberedsec Pool_Address
6008 @cindex Parameters, when passed by reference
6009 @findex Pool_Address
6010 @noindent
6011 @code{@var{X}'Pool_Address} for any object @var{X} returns the address
6012 of X within its storage pool. This is the same as
6013 @code{@var{X}'Address}, except that for an unconstrained array whose
6014 bounds are allocated just before the first component,
6015 @code{@var{X}'Pool_Address} returns the address of those bounds,
6016 whereas @code{@var{X}'Address} returns the address of the first
6017 component.
6018
6019 Here, we are interpreting ``storage pool'' broadly to mean ``wherever
6020 the object is allocated'', which could be a user-defined storage pool,
6021 the global heap, on the stack, or in a static memory area. For an
6022 object created by @code{new}, @code{@var{Ptr.all}'Pool_Address} is
6023 what is passed to @code{Allocate} and returned from @code{Deallocate}.
6024
6025 @node Range_Length
6026 @unnumberedsec Range_Length
6027 @findex Range_Length
6028 @noindent
6029 @code{@var{type}'Range_Length} for any discrete type @var{type} yields
6030 the number of values represented by the subtype (zero for a null
6031 range).  The result is static for static subtypes.  @code{Range_Length}
6032 applied to the index subtype of a one dimensional array always gives the
6033 same result as @code{Range} applied to the array itself.
6034
6035 @node Result
6036 @unnumberedsec Result
6037 @findex Result
6038 @noindent
6039 @code{@var{function}'Result} can only be used with in a Postcondition pragma
6040 for a function. The prefix must be the name of the corresponding function. This
6041 is used to refer to the result of the function in the postcondition expression.
6042 For a further discussion of the use of this attribute and examples of its use,
6043 see the description of pragma Postcondition.
6044
6045 @node Safe_Emax
6046 @unnumberedsec Safe_Emax
6047 @cindex Ada 83 attributes
6048 @findex Safe_Emax
6049 @noindent
6050 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83.  See
6051 the Ada 83 reference manual for an exact description of the semantics of
6052 this attribute.
6053
6054 @node Safe_Large
6055 @unnumberedsec Safe_Large
6056 @cindex Ada 83 attributes
6057 @findex Safe_Large
6058 @noindent
6059 The @code{Safe_Large} attribute is provided for compatibility with Ada 83.  See
6060 the Ada 83 reference manual for an exact description of the semantics of
6061 this attribute.
6062
6063 @node Small
6064 @unnumberedsec Small
6065 @cindex Ada 83 attributes
6066 @findex Small
6067 @noindent
6068 The @code{Small} attribute is defined in Ada 95 (and Ada 2005) only for
6069 fixed-point types.
6070 GNAT also allows this attribute to be applied to floating-point types
6071 for compatibility with Ada 83.  See
6072 the Ada 83 reference manual for an exact description of the semantics of
6073 this attribute when applied to floating-point types.
6074
6075 @node Storage_Unit
6076 @unnumberedsec Storage_Unit
6077 @findex Storage_Unit
6078 @noindent
6079 @code{Standard'Storage_Unit} (@code{Standard} is the only permissible
6080 prefix) provides the same value as @code{System.Storage_Unit}.
6081
6082 @node Stub_Type
6083 @unnumberedsec Stub_Type
6084 @findex Stub_Type
6085 @noindent
6086 The GNAT implementation of remote access-to-classwide types is
6087 organized as described in AARM section E.4 (20.t): a value of an RACW type
6088 (designating a remote object) is represented as a normal access
6089 value, pointing to a "stub" object which in turn contains the
6090 necessary information to contact the designated remote object. A
6091 call on any dispatching operation of such a stub object does the
6092 remote call, if necessary, using the information in the stub object
6093 to locate the target partition, etc.
6094
6095 For a prefix @code{T} that denotes a remote access-to-classwide type,
6096 @code{T'Stub_Type} denotes the type of the corresponding stub objects.
6097
6098 By construction, the layout of @code{T'Stub_Type} is identical to that of
6099 type @code{RACW_Stub_Type} declared in the internal implementation-defined
6100 unit @code{System.Partition_Interface}. Use of this attribute will create
6101 an implicit dependency on this unit.
6102
6103 @node Target_Name
6104 @unnumberedsec Target_Name
6105 @findex Target_Name
6106 @noindent
6107 @code{Standard'Target_Name} (@code{Standard} is the only permissible
6108 prefix) provides a static string value that identifies the target
6109 for the current compilation. For GCC implementations, this is the
6110 standard gcc target name without the terminating slash (for
6111 example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
6112
6113 @node Tick
6114 @unnumberedsec Tick
6115 @findex Tick
6116 @noindent
6117 @code{Standard'Tick} (@code{Standard} is the only permissible prefix)
6118 provides the same value as @code{System.Tick},
6119
6120 @node To_Address
6121 @unnumberedsec To_Address
6122 @findex To_Address
6123 @noindent
6124 The @code{System'To_Address}
6125 (@code{System} is the only permissible prefix)
6126 denotes a function identical to
6127 @code{System.Storage_Elements.To_Address} except that
6128 it is a static attribute.  This means that if its argument is
6129 a static expression, then the result of the attribute is a
6130 static expression.  The result is that such an expression can be
6131 used in contexts (e.g.@: preelaborable packages) which require a
6132 static expression and where the function call could not be used
6133 (since the function call is always non-static, even if its
6134 argument is static).
6135
6136 @node Type_Class
6137 @unnumberedsec Type_Class
6138 @findex Type_Class
6139 @noindent
6140 @code{@var{type}'Type_Class} for any type or subtype @var{type} yields
6141 the value of the type class for the full type of @var{type}.  If
6142 @var{type} is a generic formal type, the value is the value for the
6143 corresponding actual subtype.  The value of this attribute is of type
6144 @code{System.Aux_DEC.Type_Class}, which has the following definition:
6145
6146 @smallexample @c ada
6147   type Type_Class is
6148     (Type_Class_Enumeration,
6149      Type_Class_Integer,
6150      Type_Class_Fixed_Point,
6151      Type_Class_Floating_Point,
6152      Type_Class_Array,
6153      Type_Class_Record,
6154      Type_Class_Access,
6155      Type_Class_Task,
6156      Type_Class_Address);
6157 @end smallexample
6158
6159 @noindent
6160 Protected types yield the value @code{Type_Class_Task}, which thus
6161 applies to all concurrent types.  This attribute is designed to
6162 be compatible with the DEC Ada 83 attribute of the same name.
6163
6164 @node UET_Address
6165 @unnumberedsec UET_Address
6166 @findex UET_Address
6167 @noindent
6168 The @code{UET_Address} attribute can only be used for a prefix which
6169 denotes a library package.  It yields the address of the unit exception
6170 table when zero cost exception handling is used.  This attribute is
6171 intended only for use within the GNAT implementation.  See the unit
6172 @code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb}
6173 for details on how this attribute is used in the implementation.
6174
6175 @node Unconstrained_Array
6176 @unnumberedsec Unconstrained_Array
6177 @findex Unconstrained_Array
6178 @noindent
6179 The @code{Unconstrained_Array} attribute can be used with a prefix that
6180 denotes any type or subtype. It is a static attribute that yields
6181 @code{True} if the prefix designates an unconstrained array,
6182 and @code{False} otherwise. In a generic instance, the result is
6183 still static, and yields the result of applying this test to the
6184 generic actual.
6185
6186 @node Universal_Literal_String
6187 @unnumberedsec Universal_Literal_String
6188 @cindex Named numbers, representation of
6189 @findex Universal_Literal_String
6190 @noindent
6191 The prefix of @code{Universal_Literal_String} must be a named
6192 number.  The static result is the string consisting of the characters of
6193 the number as defined in the original source.  This allows the user
6194 program to access the actual text of named numbers without intermediate
6195 conversions and without the need to enclose the strings in quotes (which
6196 would preclude their use as numbers).  This is used internally for the
6197 construction of values of the floating-point attributes from the file
6198 @file{ttypef.ads}, but may also be used by user programs.
6199
6200 For example, the following program prints the first 50 digits of pi:
6201
6202 @smallexample @c ada
6203 with Text_IO; use Text_IO;
6204 with Ada.Numerics;
6205 procedure Pi is
6206 begin
6207    Put (Ada.Numerics.Pi'Universal_Literal_String);
6208 end;
6209 @end smallexample
6210
6211 @node Unrestricted_Access
6212 @unnumberedsec Unrestricted_Access
6213 @cindex @code{Access}, unrestricted
6214 @findex Unrestricted_Access
6215 @noindent
6216 The @code{Unrestricted_Access} attribute is similar to @code{Access}
6217 except that all accessibility and aliased view checks are omitted.  This
6218 is a user-beware attribute.  It is similar to
6219 @code{Address}, for which it is a desirable replacement where the value
6220 desired is an access type.  In other words, its effect is identical to
6221 first applying the @code{Address} attribute and then doing an unchecked
6222 conversion to a desired access type.  In GNAT, but not necessarily in
6223 other implementations, the use of static chains for inner level
6224 subprograms means that @code{Unrestricted_Access} applied to a
6225 subprogram yields a value that can be called as long as the subprogram
6226 is in scope (normal Ada accessibility rules restrict this usage).
6227
6228 It is possible to use @code{Unrestricted_Access} for any type, but care
6229 must be exercised if it is used to create pointers to unconstrained
6230 objects. In this case, the resulting pointer has the same scope as the
6231 context of the attribute, and may not be returned to some enclosing
6232 scope. For instance, a function cannot use @code{Unrestricted_Access}
6233 to create a unconstrained pointer and then return that value to the
6234 caller.
6235
6236 @node VADS_Size
6237 @unnumberedsec VADS_Size
6238 @cindex @code{Size}, VADS compatibility
6239 @findex VADS_Size
6240 @noindent
6241 The @code{'VADS_Size} attribute is intended to make it easier to port
6242 legacy code which relies on the semantics of @code{'Size} as implemented
6243 by the VADS Ada 83 compiler.  GNAT makes a best effort at duplicating the
6244 same semantic interpretation.  In particular, @code{'VADS_Size} applied
6245 to a predefined or other primitive type with no Size clause yields the
6246 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
6247 typical machines).  In addition @code{'VADS_Size} applied to an object
6248 gives the result that would be obtained by applying the attribute to
6249 the corresponding type.
6250
6251 @node Value_Size
6252 @unnumberedsec Value_Size
6253 @cindex @code{Size}, setting for not-first subtype
6254 @findex Value_Size
6255 @code{@var{type}'Value_Size} is the number of bits required to represent
6256 a value of the given subtype.  It is the same as @code{@var{type}'Size},
6257 but, unlike @code{Size}, may be set for non-first subtypes.
6258
6259 @node Wchar_T_Size
6260 @unnumberedsec Wchar_T_Size
6261 @findex Wchar_T_Size
6262 @code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
6263 prefix) provides the size in bits of the C @code{wchar_t} type
6264 primarily for constructing the definition of this type in
6265 package @code{Interfaces.C}.
6266
6267 @node Word_Size
6268 @unnumberedsec Word_Size
6269 @findex Word_Size
6270 @code{Standard'Word_Size} (@code{Standard} is the only permissible
6271 prefix) provides the value @code{System.Word_Size}.
6272
6273 @c ------------------------
6274 @node Implementation Advice
6275 @chapter Implementation Advice
6276 @noindent
6277 The main text of the Ada Reference Manual describes the required
6278 behavior of all Ada compilers, and the GNAT compiler conforms to
6279 these requirements.
6280
6281 In addition, there are sections throughout the Ada Reference Manual headed
6282 by the phrase ``Implementation advice''.  These sections are not normative,
6283 i.e., they do not specify requirements that all compilers must
6284 follow.  Rather they provide advice on generally desirable behavior.  You
6285 may wonder why they are not requirements.  The most typical answer is
6286 that they describe behavior that seems generally desirable, but cannot
6287 be provided on all systems, or which may be undesirable on some systems.
6288
6289 As far as practical, GNAT follows the implementation advice sections in
6290 the Ada Reference Manual.  This chapter contains a table giving the
6291 reference manual section number, paragraph number and several keywords
6292 for each advice.  Each entry consists of the text of the advice followed
6293 by the GNAT interpretation of this advice.  Most often, this simply says
6294 ``followed'', which means that GNAT follows the advice.  However, in a
6295 number of cases, GNAT deliberately deviates from this advice, in which
6296 case the text describes what GNAT does and why.
6297
6298 @cindex Error detection
6299 @unnumberedsec 1.1.3(20): Error Detection
6300 @sp 1
6301 @cartouche
6302 If an implementation detects the use of an unsupported Specialized Needs
6303 Annex feature at run time, it should raise @code{Program_Error} if
6304 feasible.
6305 @end cartouche
6306 Not relevant.  All specialized needs annex features are either supported,
6307 or diagnosed at compile time.
6308
6309 @cindex Child Units
6310 @unnumberedsec 1.1.3(31): Child Units
6311 @sp 1
6312 @cartouche
6313 If an implementation wishes to provide implementation-defined
6314 extensions to the functionality of a language-defined library unit, it
6315 should normally do so by adding children to the library unit.
6316 @end cartouche
6317 Followed.
6318
6319 @cindex Bounded errors
6320 @unnumberedsec 1.1.5(12): Bounded Errors
6321 @sp 1
6322 @cartouche
6323 If an implementation detects a bounded error or erroneous
6324 execution, it should raise @code{Program_Error}.
6325 @end cartouche
6326 Followed in all cases in which the implementation detects a bounded
6327 error or erroneous execution.  Not all such situations are detected at
6328 runtime.
6329
6330 @cindex Pragmas
6331 @unnumberedsec 2.8(16): Pragmas
6332 @sp 1
6333 @cartouche
6334 Normally, implementation-defined pragmas should have no semantic effect
6335 for error-free programs; that is, if the implementation-defined pragmas
6336 are removed from a working program, the program should still be legal,
6337 and should still have the same semantics.
6338 @end cartouche
6339 The following implementation defined pragmas are exceptions to this
6340 rule:
6341
6342 @table @code
6343 @item Abort_Defer
6344 Affects semantics
6345 @item Ada_83
6346 Affects legality
6347 @item Assert
6348 Affects semantics
6349 @item CPP_Class
6350 Affects semantics
6351 @item CPP_Constructor
6352 Affects semantics
6353 @item Debug
6354 Affects semantics
6355 @item Interface_Name
6356 Affects semantics
6357 @item Machine_Attribute
6358 Affects semantics
6359 @item Unimplemented_Unit
6360 Affects legality
6361 @item Unchecked_Union
6362 Affects semantics
6363 @end table
6364
6365 @noindent
6366 In each of the above cases, it is essential to the purpose of the pragma
6367 that this advice not be followed.  For details see the separate section
6368 on implementation defined pragmas.
6369
6370 @unnumberedsec 2.8(17-19): Pragmas
6371 @sp 1
6372 @cartouche
6373 Normally, an implementation should not define pragmas that can
6374 make an illegal program legal, except as follows:
6375 @end cartouche
6376 @sp 1
6377 @cartouche
6378 A pragma used to complete a declaration, such as a pragma @code{Import};
6379 @end cartouche
6380 @sp 1
6381 @cartouche
6382 A pragma used to configure the environment by adding, removing, or
6383 replacing @code{library_items}.
6384 @end cartouche
6385 See response to paragraph 16 of this same section.
6386
6387 @cindex Character Sets
6388 @cindex Alternative Character Sets
6389 @unnumberedsec 3.5.2(5): Alternative Character Sets
6390 @sp 1
6391 @cartouche
6392 If an implementation supports a mode with alternative interpretations
6393 for @code{Character} and @code{Wide_Character}, the set of graphic
6394 characters of @code{Character} should nevertheless remain a proper
6395 subset of the set of graphic characters of @code{Wide_Character}.  Any
6396 character set ``localizations'' should be reflected in the results of
6397 the subprograms defined in the language-defined package
6398 @code{Characters.Handling} (see A.3) available in such a mode.  In a mode with
6399 an alternative interpretation of @code{Character}, the implementation should
6400 also support a corresponding change in what is a legal
6401 @code{identifier_letter}.
6402 @end cartouche
6403 Not all wide character modes follow this advice, in particular the JIS
6404 and IEC modes reflect standard usage in Japan, and in these encoding,
6405 the upper half of the Latin-1 set is not part of the wide-character
6406 subset, since the most significant bit is used for wide character
6407 encoding.  However, this only applies to the external forms.  Internally
6408 there is no such restriction.
6409
6410 @cindex Integer types
6411 @unnumberedsec 3.5.4(28): Integer Types
6412
6413 @sp 1
6414 @cartouche
6415 An implementation should support @code{Long_Integer} in addition to
6416 @code{Integer} if the target machine supports 32-bit (or longer)
6417 arithmetic.  No other named integer subtypes are recommended for package
6418 @code{Standard}.  Instead, appropriate named integer subtypes should be
6419 provided in the library package @code{Interfaces} (see B.2).
6420 @end cartouche
6421 @code{Long_Integer} is supported.  Other standard integer types are supported
6422 so this advice is not fully followed.  These types
6423 are supported for convenient interface to C, and so that all hardware
6424 types of the machine are easily available.
6425 @unnumberedsec 3.5.4(29): Integer Types
6426
6427 @sp 1
6428 @cartouche
6429 An implementation for a two's complement machine should support
6430 modular types with a binary modulus up to @code{System.Max_Int*2+2}.  An
6431 implementation should support a non-binary modules up to @code{Integer'Last}.
6432 @end cartouche
6433 Followed.
6434
6435 @cindex Enumeration values
6436 @unnumberedsec 3.5.5(8): Enumeration Values
6437 @sp 1
6438 @cartouche
6439 For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
6440 subtype, if the value of the operand does not correspond to the internal
6441 code for any enumeration literal of its type (perhaps due to an
6442 un-initialized variable), then the implementation should raise
6443 @code{Program_Error}.  This is particularly important for enumeration
6444 types with noncontiguous internal codes specified by an
6445 enumeration_representation_clause.
6446 @end cartouche
6447 Followed.
6448
6449 @cindex Float types
6450 @unnumberedsec 3.5.7(17): Float Types
6451 @sp 1
6452 @cartouche
6453 An implementation should support @code{Long_Float} in addition to
6454 @code{Float} if the target machine supports 11 or more digits of
6455 precision.  No other named floating point subtypes are recommended for
6456 package @code{Standard}.  Instead, appropriate named floating point subtypes
6457 should be provided in the library package @code{Interfaces} (see B.2).
6458 @end cartouche
6459 @code{Short_Float} and @code{Long_Long_Float} are also provided.  The
6460 former provides improved compatibility with other implementations
6461 supporting this type.  The latter corresponds to the highest precision
6462 floating-point type supported by the hardware.  On most machines, this
6463 will be the same as @code{Long_Float}, but on some machines, it will
6464 correspond to the IEEE extended form.  The notable case is all ia32
6465 (x86) implementations, where @code{Long_Long_Float} corresponds to
6466 the 80-bit extended precision format supported in hardware on this
6467 processor.  Note that the 128-bit format on SPARC is not supported,
6468 since this is a software rather than a hardware format.
6469
6470 @cindex Multidimensional arrays
6471 @cindex Arrays, multidimensional
6472 @unnumberedsec 3.6.2(11): Multidimensional Arrays
6473 @sp 1
6474 @cartouche
6475 An implementation should normally represent multidimensional arrays in
6476 row-major order, consistent with the notation used for multidimensional
6477 array aggregates (see 4.3.3).  However, if a pragma @code{Convention}
6478 (@code{Fortran}, @dots{}) applies to a multidimensional array type, then
6479 column-major order should be used instead (see B.5, ``Interfacing with
6480 Fortran'').
6481 @end cartouche
6482 Followed.
6483
6484 @findex Duration'Small
6485 @unnumberedsec 9.6(30-31): Duration'Small
6486 @sp 1
6487 @cartouche
6488 Whenever possible in an implementation, the value of @code{Duration'Small}
6489 should be no greater than 100 microseconds.
6490 @end cartouche
6491 Followed.  (@code{Duration'Small} = 10**(@minus{}9)).
6492
6493 @sp 1
6494 @cartouche
6495 The time base for @code{delay_relative_statements} should be monotonic;
6496 it need not be the same time base as used for @code{Calendar.Clock}.
6497 @end cartouche
6498 Followed.
6499
6500 @unnumberedsec 10.2.1(12): Consistent Representation
6501 @sp 1
6502 @cartouche
6503 In an implementation, a type declared in a pre-elaborated package should
6504 have the same representation in every elaboration of a given version of
6505 the package, whether the elaborations occur in distinct executions of
6506 the same program, or in executions of distinct programs or partitions
6507 that include the given version.
6508 @end cartouche
6509 Followed, except in the case of tagged types.  Tagged types involve
6510 implicit pointers to a local copy of a dispatch table, and these pointers
6511 have representations which thus depend on a particular elaboration of the
6512 package.  It is not easy to see how it would be possible to follow this
6513 advice without severely impacting efficiency of execution.
6514
6515 @cindex Exception information
6516 @unnumberedsec 11.4.1(19): Exception Information
6517 @sp 1
6518 @cartouche
6519 @code{Exception_Message} by default and @code{Exception_Information}
6520 should produce information useful for
6521 debugging.  @code{Exception_Message} should be short, about one
6522 line.  @code{Exception_Information} can be long.  @code{Exception_Message}
6523 should not include the
6524 @code{Exception_Name}.  @code{Exception_Information} should include both
6525 the @code{Exception_Name} and the @code{Exception_Message}.
6526 @end cartouche
6527 Followed.  For each exception that doesn't have a specified
6528 @code{Exception_Message}, the compiler generates one containing the location
6529 of the raise statement.  This location has the form ``file:line'', where
6530 file is the short file name (without path information) and line is the line
6531 number in the file.  Note that in the case of the Zero Cost Exception
6532 mechanism, these messages become redundant with the Exception_Information that
6533 contains a full backtrace of the calling sequence, so they are disabled.
6534 To disable explicitly the generation of the source location message, use the
6535 Pragma @code{Discard_Names}.
6536
6537 @cindex Suppression of checks
6538 @cindex Checks, suppression of
6539 @unnumberedsec 11.5(28): Suppression of Checks
6540 @sp 1
6541 @cartouche
6542 The implementation should minimize the code executed for checks that
6543 have been suppressed.
6544 @end cartouche
6545 Followed.
6546
6547 @cindex Representation clauses
6548 @unnumberedsec 13.1 (21-24): Representation Clauses
6549 @sp 1
6550 @cartouche
6551 The recommended level of support for all representation items is
6552 qualified as follows:
6553 @end cartouche
6554 @sp 1
6555 @cartouche
6556 An implementation need not support representation items containing
6557 non-static expressions, except that an implementation should support a
6558 representation item for a given entity if each non-static expression in
6559 the representation item is a name that statically denotes a constant
6560 declared before the entity.
6561 @end cartouche
6562 Followed.  In fact, GNAT goes beyond the recommended level of support
6563 by allowing nonstatic expressions in some representation clauses even
6564 without the need to declare constants initialized with the values of
6565 such expressions.
6566 For example:
6567
6568 @smallexample @c ada
6569   X : Integer;
6570   Y : Float;
6571   for Y'Address use X'Address;>>
6572 @end smallexample
6573
6574
6575 @sp 1
6576 @cartouche
6577 An implementation need not support a specification for the @code{Size}
6578 for a given composite subtype, nor the size or storage place for an
6579 object (including a component) of a given composite subtype, unless the
6580 constraints on the subtype and its composite subcomponents (if any) are
6581 all static constraints.
6582 @end cartouche
6583 Followed.  Size Clauses are not permitted on non-static components, as
6584 described above.
6585
6586 @sp 1
6587 @cartouche
6588 An aliased component, or a component whose type is by-reference, should
6589 always be allocated at an addressable location.
6590 @end cartouche
6591 Followed.
6592
6593 @cindex Packed types
6594 @unnumberedsec 13.2(6-8): Packed Types
6595 @sp 1
6596 @cartouche
6597 If a type is packed, then the implementation should try to minimize
6598 storage allocated to objects of the type, possibly at the expense of
6599 speed of accessing components, subject to reasonable complexity in
6600 addressing calculations.
6601 @end cartouche
6602 @sp 1
6603 @cartouche
6604 The recommended level of support pragma @code{Pack} is:
6605
6606 For a packed record type, the components should be packed as tightly as
6607 possible subject to the Sizes of the component subtypes, and subject to
6608 any @code{record_representation_clause} that applies to the type; the
6609 implementation may, but need not, reorder components or cross aligned
6610 word boundaries to improve the packing.  A component whose @code{Size} is
6611 greater than the word size may be allocated an integral number of words.
6612 @end cartouche
6613 Followed.  Tight packing of arrays is supported for all component sizes
6614 up to 64-bits. If the array component size is 1 (that is to say, if
6615 the component is a boolean type or an enumeration type with two values)
6616 then values of the type are implicitly initialized to zero. This
6617 happens both for objects of the packed type, and for objects that have a
6618 subcomponent of the packed type.
6619
6620 @sp 1
6621 @cartouche
6622 An implementation should support Address clauses for imported
6623 subprograms.
6624 @end cartouche
6625 Followed.
6626 @cindex @code{Address} clauses
6627 @unnumberedsec 13.3(14-19): Address Clauses
6628
6629 @sp 1
6630 @cartouche
6631 For an array @var{X}, @code{@var{X}'Address} should point at the first
6632 component of the array, and not at the array bounds.
6633 @end cartouche
6634 Followed.
6635
6636 @sp 1
6637 @cartouche
6638 The recommended level of support for the @code{Address} attribute is:
6639
6640 @code{@var{X}'Address} should produce a useful result if @var{X} is an
6641 object that is aliased or of a by-reference type, or is an entity whose
6642 @code{Address} has been specified.
6643 @end cartouche
6644 Followed.  A valid address will be produced even if none of those
6645 conditions have been met.  If necessary, the object is forced into
6646 memory to ensure the address is valid.
6647
6648 @sp 1
6649 @cartouche
6650 An implementation should support @code{Address} clauses for imported
6651 subprograms.
6652 @end cartouche
6653 Followed.
6654
6655 @sp 1
6656 @cartouche
6657 Objects (including subcomponents) that are aliased or of a by-reference
6658 type should be allocated on storage element boundaries.
6659 @end cartouche
6660 Followed.
6661
6662 @sp 1
6663 @cartouche
6664 If the @code{Address} of an object is specified, or it is imported or exported,
6665 then the implementation should not perform optimizations based on
6666 assumptions of no aliases.
6667 @end cartouche
6668 Followed.
6669
6670 @cindex @code{Alignment} clauses
6671 @unnumberedsec 13.3(29-35): Alignment Clauses
6672 @sp 1
6673 @cartouche
6674 The recommended level of support for the @code{Alignment} attribute for
6675 subtypes is:
6676
6677 An implementation should support specified Alignments that are factors
6678 and multiples of the number of storage elements per word, subject to the
6679 following:
6680 @end cartouche
6681 Followed.
6682
6683 @sp 1
6684 @cartouche
6685 An implementation need not support specified @code{Alignment}s for
6686 combinations of @code{Size}s and @code{Alignment}s that cannot be easily
6687 loaded and stored by available machine instructions.
6688 @end cartouche
6689 Followed.
6690
6691 @sp 1
6692 @cartouche
6693 An implementation need not support specified @code{Alignment}s that are
6694 greater than the maximum @code{Alignment} the implementation ever returns by
6695 default.
6696 @end cartouche
6697 Followed.
6698
6699 @sp 1
6700 @cartouche
6701 The recommended level of support for the @code{Alignment} attribute for
6702 objects is:
6703
6704 Same as above, for subtypes, but in addition:
6705 @end cartouche
6706 Followed.
6707
6708 @sp 1
6709 @cartouche
6710 For stand-alone library-level objects of statically constrained
6711 subtypes, the implementation should support all @code{Alignment}s
6712 supported by the target linker.  For example, page alignment is likely to
6713 be supported for such objects, but not for subtypes.
6714 @end cartouche
6715 Followed.
6716
6717 @cindex @code{Size} clauses
6718 @unnumberedsec 13.3(42-43): Size Clauses
6719 @sp 1
6720 @cartouche
6721 The recommended level of support for the @code{Size} attribute of
6722 objects is:
6723
6724 A @code{Size} clause should be supported for an object if the specified
6725 @code{Size} is at least as large as its subtype's @code{Size}, and
6726 corresponds to a size in storage elements that is a multiple of the
6727 object's @code{Alignment} (if the @code{Alignment} is nonzero).
6728 @end cartouche
6729 Followed.
6730
6731 @unnumberedsec 13.3(50-56): Size Clauses
6732 @sp 1
6733 @cartouche
6734 If the @code{Size} of a subtype is specified, and allows for efficient
6735 independent addressability (see 9.10) on the target architecture, then
6736 the @code{Size} of the following objects of the subtype should equal the
6737 @code{Size} of the subtype:
6738
6739 Aliased objects (including components).
6740 @end cartouche
6741 Followed.
6742
6743 @sp 1
6744 @cartouche
6745 @code{Size} clause on a composite subtype should not affect the
6746 internal layout of components.
6747 @end cartouche
6748 Followed. But note that this can be overridden by use of the implementation
6749 pragma Implicit_Packing in the case of packed arrays.
6750
6751 @sp 1
6752 @cartouche
6753 The recommended level of support for the @code{Size} attribute of subtypes is:
6754 @end cartouche
6755 @sp 1
6756 @cartouche
6757 The @code{Size} (if not specified) of a static discrete or fixed point
6758 subtype should be the number of bits needed to represent each value
6759 belonging to the subtype using an unbiased representation, leaving space
6760 for a sign bit only if the subtype contains negative values.  If such a
6761 subtype is a first subtype, then an implementation should support a
6762 specified @code{Size} for it that reflects this representation.
6763 @end cartouche
6764 Followed.
6765
6766 @sp 1
6767 @cartouche
6768 For a subtype implemented with levels of indirection, the @code{Size}
6769 should include the size of the pointers, but not the size of what they
6770 point at.
6771 @end cartouche
6772 Followed.
6773
6774 @cindex @code{Component_Size} clauses
6775 @unnumberedsec 13.3(71-73): Component Size Clauses
6776 @sp 1
6777 @cartouche
6778 The recommended level of support for the @code{Component_Size}
6779 attribute is:
6780 @end cartouche
6781 @sp 1
6782 @cartouche
6783 An implementation need not support specified @code{Component_Sizes} that are
6784 less than the @code{Size} of the component subtype.
6785 @end cartouche
6786 Followed.
6787
6788 @sp 1
6789 @cartouche
6790 An implementation should support specified @code{Component_Size}s that
6791 are factors and multiples of the word size.  For such
6792 @code{Component_Size}s, the array should contain no gaps between
6793 components.  For other @code{Component_Size}s (if supported), the array
6794 should contain no gaps between components when packing is also
6795 specified; the implementation should forbid this combination in cases
6796 where it cannot support a no-gaps representation.
6797 @end cartouche
6798 Followed.
6799
6800 @cindex Enumeration representation clauses
6801 @cindex Representation clauses, enumeration
6802 @unnumberedsec 13.4(9-10): Enumeration Representation Clauses
6803 @sp 1
6804 @cartouche
6805 The recommended level of support for enumeration representation clauses
6806 is:
6807
6808 An implementation need not support enumeration representation clauses
6809 for boolean types, but should at minimum support the internal codes in
6810 the range @code{System.Min_Int.System.Max_Int}.
6811 @end cartouche
6812 Followed.
6813
6814 @cindex Record representation clauses
6815 @cindex Representation clauses, records
6816 @unnumberedsec 13.5.1(17-22): Record Representation Clauses
6817 @sp 1
6818 @cartouche
6819 The recommended level of support for
6820 @*@code{record_representation_clauses} is:
6821
6822 An implementation should support storage places that can be extracted
6823 with a load, mask, shift sequence of machine code, and set with a load,
6824 shift, mask, store sequence, given the available machine instructions
6825 and run-time model.
6826 @end cartouche
6827 Followed.
6828
6829 @sp 1
6830 @cartouche
6831 A storage place should be supported if its size is equal to the
6832 @code{Size} of the component subtype, and it starts and ends on a
6833 boundary that obeys the @code{Alignment} of the component subtype.
6834 @end cartouche
6835 Followed.
6836
6837 @sp 1
6838 @cartouche
6839 If the default bit ordering applies to the declaration of a given type,
6840 then for a component whose subtype's @code{Size} is less than the word
6841 size, any storage place that does not cross an aligned word boundary
6842 should be supported.
6843 @end cartouche
6844 Followed.
6845
6846 @sp 1
6847 @cartouche
6848 An implementation may reserve a storage place for the tag field of a
6849 tagged type, and disallow other components from overlapping that place.
6850 @end cartouche
6851 Followed.  The storage place for the tag field is the beginning of the tagged
6852 record, and its size is Address'Size.  GNAT will reject an explicit component
6853 clause for the tag field.
6854
6855 @sp 1
6856 @cartouche
6857 An implementation need not support a @code{component_clause} for a
6858 component of an extension part if the storage place is not after the
6859 storage places of all components of the parent type, whether or not
6860 those storage places had been specified.
6861 @end cartouche
6862 Followed.  The above advice on record representation clauses is followed,
6863 and all mentioned features are implemented.
6864
6865 @cindex Storage place attributes
6866 @unnumberedsec 13.5.2(5): Storage Place Attributes
6867 @sp 1
6868 @cartouche
6869 If a component is represented using some form of pointer (such as an
6870 offset) to the actual data of the component, and this data is contiguous
6871 with the rest of the object, then the storage place attributes should
6872 reflect the place of the actual data, not the pointer.  If a component is
6873 allocated discontinuously from the rest of the object, then a warning
6874 should be generated upon reference to one of its storage place
6875 attributes.
6876 @end cartouche
6877 Followed.  There are no such components in GNAT@.
6878
6879 @cindex Bit ordering
6880 @unnumberedsec 13.5.3(7-8): Bit Ordering
6881 @sp 1
6882 @cartouche
6883 The recommended level of support for the non-default bit ordering is:
6884 @end cartouche
6885 @sp 1
6886 @cartouche
6887 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
6888 should support the non-default bit ordering in addition to the default
6889 bit ordering.
6890 @end cartouche
6891 Followed.  Word size does not equal storage size in this implementation.
6892 Thus non-default bit ordering is not supported.
6893
6894 @cindex @code{Address}, as private type
6895 @unnumberedsec 13.7(37): Address as Private
6896 @sp 1
6897 @cartouche
6898 @code{Address} should be of a private type.
6899 @end cartouche
6900 Followed.
6901
6902 @cindex Operations, on @code{Address}
6903 @cindex @code{Address}, operations of
6904 @unnumberedsec 13.7.1(16): Address Operations
6905 @sp 1
6906 @cartouche
6907 Operations in @code{System} and its children should reflect the target
6908 environment semantics as closely as is reasonable.  For example, on most
6909 machines, it makes sense for address arithmetic to ``wrap around''.
6910 Operations that do not make sense should raise @code{Program_Error}.
6911 @end cartouche
6912 Followed.  Address arithmetic is modular arithmetic that wraps around.  No
6913 operation raises @code{Program_Error}, since all operations make sense.
6914
6915 @cindex Unchecked conversion
6916 @unnumberedsec 13.9(14-17): Unchecked Conversion
6917 @sp 1
6918 @cartouche
6919 The @code{Size} of an array object should not include its bounds; hence,
6920 the bounds should not be part of the converted data.
6921 @end cartouche
6922 Followed.
6923
6924 @sp 1
6925 @cartouche
6926 The implementation should not generate unnecessary run-time checks to
6927 ensure that the representation of @var{S} is a representation of the
6928 target type.  It should take advantage of the permission to return by
6929 reference when possible.  Restrictions on unchecked conversions should be
6930 avoided unless required by the target environment.
6931 @end cartouche
6932 Followed.  There are no restrictions on unchecked conversion.  A warning is
6933 generated if the source and target types do not have the same size since
6934 the semantics in this case may be target dependent.
6935
6936 @sp 1
6937 @cartouche
6938 The recommended level of support for unchecked conversions is:
6939 @end cartouche
6940 @sp 1
6941 @cartouche
6942 Unchecked conversions should be supported and should be reversible in
6943 the cases where this clause defines the result.  To enable meaningful use
6944 of unchecked conversion, a contiguous representation should be used for
6945 elementary subtypes, for statically constrained array subtypes whose
6946 component subtype is one of the subtypes described in this paragraph,
6947 and for record subtypes without discriminants whose component subtypes
6948 are described in this paragraph.
6949 @end cartouche
6950 Followed.
6951
6952 @cindex Heap usage, implicit
6953 @unnumberedsec 13.11(23-25): Implicit Heap Usage
6954 @sp 1
6955 @cartouche
6956 An implementation should document any cases in which it dynamically
6957 allocates heap storage for a purpose other than the evaluation of an
6958 allocator.
6959 @end cartouche
6960 Followed, the only other points at which heap storage is dynamically
6961 allocated are as follows:
6962
6963 @itemize @bullet
6964 @item
6965 At initial elaboration time, to allocate dynamically sized global
6966 objects.
6967
6968 @item
6969 To allocate space for a task when a task is created.
6970
6971 @item
6972 To extend the secondary stack dynamically when needed.  The secondary
6973 stack is used for returning variable length results.
6974 @end itemize
6975
6976 @sp 1
6977 @cartouche
6978 A default (implementation-provided) storage pool for an
6979 access-to-constant type should not have overhead to support deallocation of
6980 individual objects.
6981 @end cartouche
6982 Followed.
6983
6984 @sp 1
6985 @cartouche
6986 A storage pool for an anonymous access type should be created at the
6987 point of an allocator for the type, and be reclaimed when the designated
6988 object becomes inaccessible.
6989 @end cartouche
6990 Followed.
6991
6992 @cindex Unchecked deallocation
6993 @unnumberedsec 13.11.2(17): Unchecked De-allocation
6994 @sp 1
6995 @cartouche
6996 For a standard storage pool, @code{Free} should actually reclaim the
6997 storage.
6998 @end cartouche
6999 Followed.
7000
7001 @cindex Stream oriented attributes
7002 @unnumberedsec 13.13.2(17): Stream Oriented Attributes
7003 @sp 1
7004 @cartouche
7005 If a stream element is the same size as a storage element, then the
7006 normal in-memory representation should be used by @code{Read} and
7007 @code{Write} for scalar objects.  Otherwise, @code{Read} and @code{Write}
7008 should use the smallest number of stream elements needed to represent
7009 all values in the base range of the scalar type.
7010 @end cartouche
7011
7012 Followed.  By default, GNAT uses the interpretation suggested by AI-195,
7013 which specifies using the size of the first subtype.
7014 However, such an implementation is based on direct binary
7015 representations and is therefore target- and endianness-dependent.
7016 To address this issue, GNAT also supplies an alternate implementation
7017 of the stream attributes @code{Read} and @code{Write},
7018 which uses the target-independent XDR standard representation
7019 for scalar types.
7020 @cindex XDR representation
7021 @cindex @code{Read} attribute
7022 @cindex @code{Write} attribute
7023 @cindex Stream oriented attributes
7024 The XDR implementation is provided as an alternative body of the
7025 @code{System.Stream_Attributes} package, in the file
7026 @file{s-strxdr.adb} in the GNAT library.
7027 There is no @file{s-strxdr.ads} file.
7028 In order to install the XDR implementation, do the following:
7029 @enumerate
7030 @item Replace the default implementation of the
7031 @code{System.Stream_Attributes} package with the XDR implementation.
7032 For example on a Unix platform issue the commands:
7033 @smallexample
7034 $ mv s-stratt.adb s-strold.adb
7035 $ mv s-strxdr.adb s-stratt.adb
7036 @end smallexample
7037
7038 @item
7039 Rebuild the GNAT run-time library as documented in
7040 @ref{GNAT and Libraries,,, gnat_ugn, @value{EDITION} User's Guide}.
7041 @end enumerate
7042
7043 @unnumberedsec A.1(52): Names of Predefined Numeric Types
7044 @sp 1
7045 @cartouche
7046 If an implementation provides additional named predefined integer types,
7047 then the names should end with @samp{Integer} as in
7048 @samp{Long_Integer}.  If an implementation provides additional named
7049 predefined floating point types, then the names should end with
7050 @samp{Float} as in @samp{Long_Float}.
7051 @end cartouche
7052 Followed.
7053
7054 @findex Ada.Characters.Handling
7055 @unnumberedsec A.3.2(49): @code{Ada.Characters.Handling}
7056 @sp 1
7057 @cartouche
7058 If an implementation provides a localized definition of @code{Character}
7059 or @code{Wide_Character}, then the effects of the subprograms in
7060 @code{Characters.Handling} should reflect the localizations.  See also
7061 3.5.2.
7062 @end cartouche
7063 Followed.  GNAT provides no such localized definitions.
7064
7065 @cindex Bounded-length strings
7066 @unnumberedsec A.4.4(106): Bounded-Length String Handling
7067 @sp 1
7068 @cartouche
7069 Bounded string objects should not be implemented by implicit pointers
7070 and dynamic allocation.
7071 @end cartouche
7072 Followed.  No implicit pointers or dynamic allocation are used.
7073
7074 @cindex Random number generation
7075 @unnumberedsec A.5.2(46-47): Random Number Generation
7076 @sp 1
7077 @cartouche
7078 Any storage associated with an object of type @code{Generator} should be
7079 reclaimed on exit from the scope of the object.
7080 @end cartouche
7081 Followed.
7082
7083 @sp 1
7084 @cartouche
7085 If the generator period is sufficiently long in relation to the number
7086 of distinct initiator values, then each possible value of
7087 @code{Initiator} passed to @code{Reset} should initiate a sequence of
7088 random numbers that does not, in a practical sense, overlap the sequence
7089 initiated by any other value.  If this is not possible, then the mapping
7090 between initiator values and generator states should be a rapidly
7091 varying function of the initiator value.
7092 @end cartouche
7093 Followed.  The generator period is sufficiently long for the first
7094 condition here to hold true.
7095
7096 @findex Get_Immediate
7097 @unnumberedsec A.10.7(23): @code{Get_Immediate}
7098 @sp 1
7099 @cartouche
7100 The @code{Get_Immediate} procedures should be implemented with
7101 unbuffered input.  For a device such as a keyboard, input should be
7102 @dfn{available} if a key has already been typed, whereas for a disk
7103 file, input should always be available except at end of file.  For a file
7104 associated with a keyboard-like device, any line-editing features of the
7105 underlying operating system should be disabled during the execution of
7106 @code{Get_Immediate}.
7107 @end cartouche
7108 Followed on all targets except VxWorks. For VxWorks, there is no way to
7109 provide this functionality that does not result in the input buffer being
7110 flushed before the @code{Get_Immediate} call. A special unit
7111 @code{Interfaces.Vxworks.IO} is provided that contains routines to enable
7112 this functionality.
7113
7114 @findex Export
7115 @unnumberedsec B.1(39-41): Pragma @code{Export}
7116 @sp 1
7117 @cartouche
7118 If an implementation supports pragma @code{Export} to a given language,
7119 then it should also allow the main subprogram to be written in that
7120 language.  It should support some mechanism for invoking the elaboration
7121 of the Ada library units included in the system, and for invoking the
7122 finalization of the environment task.  On typical systems, the
7123 recommended mechanism is to provide two subprograms whose link names are
7124 @code{adainit} and @code{adafinal}.  @code{adainit} should contain the
7125 elaboration code for library units.  @code{adafinal} should contain the
7126 finalization code.  These subprograms should have no effect the second
7127 and subsequent time they are called.
7128 @end cartouche
7129 Followed.
7130
7131 @sp 1
7132 @cartouche
7133 Automatic elaboration of pre-elaborated packages should be
7134 provided when pragma @code{Export} is supported.
7135 @end cartouche
7136 Followed when the main program is in Ada.  If the main program is in a
7137 foreign language, then
7138 @code{adainit} must be called to elaborate pre-elaborated
7139 packages.
7140
7141 @sp 1
7142 @cartouche
7143 For each supported convention @var{L} other than @code{Intrinsic}, an
7144 implementation should support @code{Import} and @code{Export} pragmas
7145 for objects of @var{L}-compatible types and for subprograms, and pragma
7146 @code{Convention} for @var{L}-eligible types and for subprograms,
7147 presuming the other language has corresponding features.  Pragma
7148 @code{Convention} need not be supported for scalar types.
7149 @end cartouche
7150 Followed.
7151
7152 @cindex Package @code{Interfaces}
7153 @findex Interfaces
7154 @unnumberedsec B.2(12-13): Package @code{Interfaces}
7155 @sp 1
7156 @cartouche
7157 For each implementation-defined convention identifier, there should be a
7158 child package of package Interfaces with the corresponding name.  This
7159 package should contain any declarations that would be useful for
7160 interfacing to the language (implementation) represented by the
7161 convention.  Any declarations useful for interfacing to any language on
7162 the given hardware architecture should be provided directly in
7163 @code{Interfaces}.
7164 @end cartouche
7165 Followed. An additional package not defined
7166 in the Ada Reference Manual is @code{Interfaces.CPP}, used
7167 for interfacing to C++.
7168
7169 @sp 1
7170 @cartouche
7171 An implementation supporting an interface to C, COBOL, or Fortran should
7172 provide the corresponding package or packages described in the following
7173 clauses.
7174 @end cartouche
7175 Followed.  GNAT provides all the packages described in this section.
7176
7177 @cindex C, interfacing with
7178 @unnumberedsec B.3(63-71): Interfacing with C
7179 @sp 1
7180 @cartouche
7181 An implementation should support the following interface correspondences
7182 between Ada and C@.
7183 @end cartouche
7184 Followed.
7185
7186 @sp 1
7187 @cartouche
7188 An Ada procedure corresponds to a void-returning C function.
7189 @end cartouche
7190 Followed.
7191
7192 @sp 1
7193 @cartouche
7194 An Ada function corresponds to a non-void C function.
7195 @end cartouche
7196 Followed.
7197
7198 @sp 1
7199 @cartouche
7200 An Ada @code{in} scalar parameter is passed as a scalar argument to a C
7201 function.
7202 @end cartouche
7203 Followed.
7204
7205 @sp 1
7206 @cartouche
7207 An Ada @code{in} parameter of an access-to-object type with designated
7208 type @var{T} is passed as a @code{@var{t}*} argument to a C function,
7209 where @var{t} is the C type corresponding to the Ada type @var{T}.
7210 @end cartouche
7211 Followed.
7212
7213 @sp 1
7214 @cartouche
7215 An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
7216 parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
7217 argument to a C function, where @var{t} is the C type corresponding to
7218 the Ada type @var{T}.  In the case of an elementary @code{out} or
7219 @code{in out} parameter, a pointer to a temporary copy is used to
7220 preserve by-copy semantics.
7221 @end cartouche
7222 Followed.
7223
7224 @sp 1
7225 @cartouche
7226 An Ada parameter of a record type @var{T}, of any mode, is passed as a
7227 @code{@var{t}*} argument to a C function, where @var{t} is the C
7228 structure corresponding to the Ada type @var{T}.
7229 @end cartouche
7230 Followed.  This convention may be overridden by the use of the C_Pass_By_Copy
7231 pragma, or Convention, or by explicitly specifying the mechanism for a given
7232 call using an extended import or export pragma.
7233
7234 @sp 1
7235 @cartouche
7236 An Ada parameter of an array type with component type @var{T}, of any
7237 mode, is passed as a @code{@var{t}*} argument to a C function, where
7238 @var{t} is the C type corresponding to the Ada type @var{T}.
7239 @end cartouche
7240 Followed.
7241
7242 @sp 1
7243 @cartouche
7244 An Ada parameter of an access-to-subprogram type is passed as a pointer
7245 to a C function whose prototype corresponds to the designated
7246 subprogram's specification.
7247 @end cartouche
7248 Followed.
7249
7250 @cindex COBOL, interfacing with
7251 @unnumberedsec B.4(95-98): Interfacing with COBOL
7252 @sp 1
7253 @cartouche
7254 An Ada implementation should support the following interface
7255 correspondences between Ada and COBOL@.
7256 @end cartouche
7257 Followed.
7258
7259 @sp 1
7260 @cartouche
7261 An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of
7262 the COBOL type corresponding to @var{T}.
7263 @end cartouche
7264 Followed.
7265
7266 @sp 1
7267 @cartouche
7268 An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of
7269 the corresponding COBOL type.
7270 @end cartouche
7271 Followed.
7272
7273 @sp 1
7274 @cartouche
7275 Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the
7276 COBOL type corresponding to the Ada parameter type; for scalars, a local
7277 copy is used if necessary to ensure by-copy semantics.
7278 @end cartouche
7279 Followed.
7280
7281 @cindex Fortran, interfacing with
7282 @unnumberedsec B.5(22-26): Interfacing with Fortran
7283 @sp 1
7284 @cartouche
7285 An Ada implementation should support the following interface
7286 correspondences between Ada and Fortran:
7287 @end cartouche
7288 Followed.
7289
7290 @sp 1
7291 @cartouche
7292 An Ada procedure corresponds to a Fortran subroutine.
7293 @end cartouche
7294 Followed.
7295
7296 @sp 1
7297 @cartouche
7298 An Ada function corresponds to a Fortran function.
7299 @end cartouche
7300 Followed.
7301
7302 @sp 1
7303 @cartouche
7304 An Ada parameter of an elementary, array, or record type @var{T} is
7305 passed as a @var{T} argument to a Fortran procedure, where @var{T} is
7306 the Fortran type corresponding to the Ada type @var{T}, and where the
7307 INTENT attribute of the corresponding dummy argument matches the Ada
7308 formal parameter mode; the Fortran implementation's parameter passing
7309 conventions are used.  For elementary types, a local copy is used if
7310 necessary to ensure by-copy semantics.
7311 @end cartouche
7312 Followed.
7313
7314 @sp 1
7315 @cartouche
7316 An Ada parameter of an access-to-subprogram type is passed as a
7317 reference to a Fortran procedure whose interface corresponds to the
7318 designated subprogram's specification.
7319 @end cartouche
7320 Followed.
7321
7322 @cindex Machine operations
7323 @unnumberedsec C.1(3-5): Access to Machine Operations
7324 @sp 1
7325 @cartouche
7326 The machine code or intrinsic support should allow access to all
7327 operations normally available to assembly language programmers for the
7328 target environment, including privileged instructions, if any.
7329 @end cartouche
7330 Followed.
7331
7332 @sp 1
7333 @cartouche
7334 The interfacing pragmas (see Annex B) should support interface to
7335 assembler; the default assembler should be associated with the
7336 convention identifier @code{Assembler}.
7337 @end cartouche
7338 Followed.
7339
7340 @sp 1
7341 @cartouche
7342 If an entity is exported to assembly language, then the implementation
7343 should allocate it at an addressable location, and should ensure that it
7344 is retained by the linking process, even if not otherwise referenced
7345 from the Ada code.  The implementation should assume that any call to a
7346 machine code or assembler subprogram is allowed to read or update every
7347 object that is specified as exported.
7348 @end cartouche
7349 Followed.
7350
7351 @unnumberedsec C.1(10-16): Access to Machine Operations
7352 @sp 1
7353 @cartouche
7354 The implementation should ensure that little or no overhead is
7355 associated with calling intrinsic and machine-code subprograms.
7356 @end cartouche
7357 Followed for both intrinsics and machine-code subprograms.
7358
7359 @sp 1
7360 @cartouche
7361 It is recommended that intrinsic subprograms be provided for convenient
7362 access to any machine operations that provide special capabilities or
7363 efficiency and that are not otherwise available through the language
7364 constructs.
7365 @end cartouche
7366 Followed.  A full set of machine operation intrinsic subprograms is provided.
7367
7368 @sp 1
7369 @cartouche
7370 Atomic read-modify-write operations---e.g.@:, test and set, compare and
7371 swap, decrement and test, enqueue/dequeue.
7372 @end cartouche
7373 Followed on any target supporting such operations.
7374
7375 @sp 1
7376 @cartouche
7377 Standard numeric functions---e.g.@:, sin, log.
7378 @end cartouche
7379 Followed on any target supporting such operations.
7380
7381 @sp 1
7382 @cartouche
7383 String manipulation operations---e.g.@:, translate and test.
7384 @end cartouche
7385 Followed on any target supporting such operations.
7386
7387 @sp 1
7388 @cartouche
7389 Vector operations---e.g.@:, compare vector against thresholds.
7390 @end cartouche
7391 Followed on any target supporting such operations.
7392
7393 @sp 1
7394 @cartouche
7395 Direct operations on I/O ports.
7396 @end cartouche
7397 Followed on any target supporting such operations.
7398
7399 @cindex Interrupt support
7400 @unnumberedsec C.3(28): Interrupt Support
7401 @sp 1
7402 @cartouche
7403 If the @code{Ceiling_Locking} policy is not in effect, the
7404 implementation should provide means for the application to specify which
7405 interrupts are to be blocked during protected actions, if the underlying
7406 system allows for a finer-grain control of interrupt blocking.
7407 @end cartouche
7408 Followed.  The underlying system does not allow for finer-grain control
7409 of interrupt blocking.
7410
7411 @cindex Protected procedure handlers
7412 @unnumberedsec C.3.1(20-21): Protected Procedure Handlers
7413 @sp 1
7414 @cartouche
7415 Whenever possible, the implementation should allow interrupt handlers to
7416 be called directly by the hardware.
7417 @end cartouche
7418 @c SGI info:
7419 @ignore
7420 This is never possible under IRIX, so this is followed by default.
7421 @end ignore
7422 Followed on any target where the underlying operating system permits
7423 such direct calls.
7424
7425 @sp 1
7426 @cartouche
7427 Whenever practical, violations of any
7428 implementation-defined restrictions should be detected before run time.
7429 @end cartouche
7430 Followed.  Compile time warnings are given when possible.
7431
7432 @cindex Package @code{Interrupts}
7433 @findex Interrupts
7434 @unnumberedsec C.3.2(25): Package @code{Interrupts}
7435
7436 @sp 1
7437 @cartouche
7438 If implementation-defined forms of interrupt handler procedures are
7439 supported, such as protected procedures with parameters, then for each
7440 such form of a handler, a type analogous to @code{Parameterless_Handler}
7441 should be specified in a child package of @code{Interrupts}, with the
7442 same operations as in the predefined package Interrupts.
7443 @end cartouche
7444 Followed.
7445
7446 @cindex Pre-elaboration requirements
7447 @unnumberedsec C.4(14): Pre-elaboration Requirements
7448 @sp 1
7449 @cartouche
7450 It is recommended that pre-elaborated packages be implemented in such a
7451 way that there should be little or no code executed at run time for the
7452 elaboration of entities not already covered by the Implementation
7453 Requirements.
7454 @end cartouche
7455 Followed.  Executable code is generated in some cases, e.g.@: loops
7456 to initialize large arrays.
7457
7458 @unnumberedsec C.5(8): Pragma @code{Discard_Names}
7459
7460 @sp 1
7461 @cartouche
7462 If the pragma applies to an entity, then the implementation should
7463 reduce the amount of storage used for storing names associated with that
7464 entity.
7465 @end cartouche
7466 Followed.
7467
7468 @cindex Package @code{Task_Attributes}
7469 @findex Task_Attributes
7470 @unnumberedsec C.7.2(30): The Package Task_Attributes
7471 @sp 1
7472 @cartouche
7473 Some implementations are targeted to domains in which memory use at run
7474 time must be completely deterministic.  For such implementations, it is
7475 recommended that the storage for task attributes will be pre-allocated
7476 statically and not from the heap.  This can be accomplished by either
7477 placing restrictions on the number and the size of the task's
7478 attributes, or by using the pre-allocated storage for the first @var{N}
7479 attribute objects, and the heap for the others.  In the latter case,
7480 @var{N} should be documented.
7481 @end cartouche
7482 Not followed.  This implementation is not targeted to such a domain.
7483
7484 @cindex Locking Policies
7485 @unnumberedsec D.3(17): Locking Policies
7486
7487 @sp 1
7488 @cartouche
7489 The implementation should use names that end with @samp{_Locking} for
7490 locking policies defined by the implementation.
7491 @end cartouche
7492 Followed.  A single implementation-defined locking policy is defined,
7493 whose name (@code{Inheritance_Locking}) follows this suggestion.
7494
7495 @cindex Entry queuing policies
7496 @unnumberedsec D.4(16): Entry Queuing Policies
7497 @sp 1
7498 @cartouche
7499 Names that end with @samp{_Queuing} should be used
7500 for all implementation-defined queuing policies.
7501 @end cartouche
7502 Followed.  No such implementation-defined queuing policies exist.
7503
7504 @cindex Preemptive abort
7505 @unnumberedsec D.6(9-10): Preemptive Abort
7506 @sp 1
7507 @cartouche
7508 Even though the @code{abort_statement} is included in the list of
7509 potentially blocking operations (see 9.5.1), it is recommended that this
7510 statement be implemented in a way that never requires the task executing
7511 the @code{abort_statement} to block.
7512 @end cartouche
7513 Followed.
7514
7515 @sp 1
7516 @cartouche
7517 On a multi-processor, the delay associated with aborting a task on
7518 another processor should be bounded; the implementation should use
7519 periodic polling, if necessary, to achieve this.
7520 @end cartouche
7521 Followed.
7522
7523 @cindex Tasking restrictions
7524 @unnumberedsec D.7(21): Tasking Restrictions
7525 @sp 1
7526 @cartouche
7527 When feasible, the implementation should take advantage of the specified
7528 restrictions to produce a more efficient implementation.
7529 @end cartouche
7530 GNAT currently takes advantage of these restrictions by providing an optimized
7531 run time when the Ravenscar profile and the GNAT restricted run time set
7532 of restrictions are specified.  See pragma @code{Profile (Ravenscar)} and
7533 pragma @code{Profile (Restricted)} for more details.
7534
7535 @cindex Time, monotonic
7536 @unnumberedsec D.8(47-49): Monotonic Time
7537 @sp 1
7538 @cartouche
7539 When appropriate, implementations should provide configuration
7540 mechanisms to change the value of @code{Tick}.
7541 @end cartouche
7542 Such configuration mechanisms are not appropriate to this implementation
7543 and are thus not supported.
7544
7545 @sp 1
7546 @cartouche
7547 It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
7548 be implemented as transformations of the same time base.
7549 @end cartouche
7550 Followed.
7551
7552 @sp 1
7553 @cartouche
7554 It is recommended that the @dfn{best} time base which exists in
7555 the underlying system be available to the application through
7556 @code{Clock}.  @dfn{Best} may mean highest accuracy or largest range.
7557 @end cartouche
7558 Followed.
7559
7560 @cindex Partition communication subsystem
7561 @cindex PCS
7562 @unnumberedsec E.5(28-29): Partition Communication Subsystem
7563 @sp 1
7564 @cartouche
7565 Whenever possible, the PCS on the called partition should allow for
7566 multiple tasks to call the RPC-receiver with different messages and
7567 should allow them to block until the corresponding subprogram body
7568 returns.
7569 @end cartouche
7570 Followed by GLADE, a separately supplied PCS that can be used with
7571 GNAT.
7572
7573 @sp 1
7574 @cartouche
7575 The @code{Write} operation on a stream of type @code{Params_Stream_Type}
7576 should raise @code{Storage_Error} if it runs out of space trying to
7577 write the @code{Item} into the stream.
7578 @end cartouche
7579 Followed by GLADE, a separately supplied PCS that can be used with
7580 GNAT@.
7581
7582 @cindex COBOL support
7583 @unnumberedsec F(7): COBOL Support
7584 @sp 1
7585 @cartouche
7586 If COBOL (respectively, C) is widely supported in the target
7587 environment, implementations supporting the Information Systems Annex
7588 should provide the child package @code{Interfaces.COBOL} (respectively,
7589 @code{Interfaces.C}) specified in Annex B and should support a
7590 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
7591 pragmas (see Annex B), thus allowing Ada programs to interface with
7592 programs written in that language.
7593 @end cartouche
7594 Followed.
7595
7596 @cindex Decimal radix support
7597 @unnumberedsec F.1(2): Decimal Radix Support
7598 @sp 1
7599 @cartouche
7600 Packed decimal should be used as the internal representation for objects
7601 of subtype @var{S} when @var{S}'Machine_Radix = 10.
7602 @end cartouche
7603 Not followed.  GNAT ignores @var{S}'Machine_Radix and always uses binary
7604 representations.
7605
7606 @cindex Numerics
7607 @unnumberedsec G: Numerics
7608 @sp 2
7609 @cartouche
7610 If Fortran (respectively, C) is widely supported in the target
7611 environment, implementations supporting the Numerics Annex
7612 should provide the child package @code{Interfaces.Fortran} (respectively,
7613 @code{Interfaces.C}) specified in Annex B and should support a
7614 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
7615 pragmas (see Annex B), thus allowing Ada programs to interface with
7616 programs written in that language.
7617 @end cartouche
7618 Followed.
7619
7620 @cindex Complex types
7621 @unnumberedsec G.1.1(56-58): Complex Types
7622 @sp 2
7623 @cartouche
7624 Because the usual mathematical meaning of multiplication of a complex
7625 operand and a real operand is that of the scaling of both components of
7626 the former by the latter, an implementation should not perform this
7627 operation by first promoting the real operand to complex type and then
7628 performing a full complex multiplication.  In systems that, in the
7629 future, support an Ada binding to IEC 559:1989, the latter technique
7630 will not generate the required result when one of the components of the
7631 complex operand is infinite.  (Explicit multiplication of the infinite
7632 component by the zero component obtained during promotion yields a NaN
7633 that propagates into the final result.) Analogous advice applies in the
7634 case of multiplication of a complex operand and a pure-imaginary
7635 operand, and in the case of division of a complex operand by a real or
7636 pure-imaginary operand.
7637 @end cartouche
7638 Not followed.
7639
7640 @sp 1
7641 @cartouche
7642 Similarly, because the usual mathematical meaning of addition of a
7643 complex operand and a real operand is that the imaginary operand remains
7644 unchanged, an implementation should not perform this operation by first
7645 promoting the real operand to complex type and then performing a full
7646 complex addition.  In implementations in which the @code{Signed_Zeros}
7647 attribute of the component type is @code{True} (and which therefore
7648 conform to IEC 559:1989 in regard to the handling of the sign of zero in
7649 predefined arithmetic operations), the latter technique will not
7650 generate the required result when the imaginary component of the complex
7651 operand is a negatively signed zero.  (Explicit addition of the negative
7652 zero to the zero obtained during promotion yields a positive zero.)
7653 Analogous advice applies in the case of addition of a complex operand
7654 and a pure-imaginary operand, and in the case of subtraction of a
7655 complex operand and a real or pure-imaginary operand.
7656 @end cartouche
7657 Not followed.
7658
7659 @sp 1
7660 @cartouche
7661 Implementations in which @code{Real'Signed_Zeros} is @code{True} should
7662 attempt to provide a rational treatment of the signs of zero results and
7663 result components.  As one example, the result of the @code{Argument}
7664 function should have the sign of the imaginary component of the
7665 parameter @code{X} when the point represented by that parameter lies on
7666 the positive real axis; as another, the sign of the imaginary component
7667 of the @code{Compose_From_Polar} function should be the same as
7668 (respectively, the opposite of) that of the @code{Argument} parameter when that
7669 parameter has a value of zero and the @code{Modulus} parameter has a
7670 nonnegative (respectively, negative) value.
7671 @end cartouche
7672 Followed.
7673
7674 @cindex Complex elementary functions
7675 @unnumberedsec G.1.2(49): Complex Elementary Functions
7676 @sp 1
7677 @cartouche
7678 Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
7679 @code{True} should attempt to provide a rational treatment of the signs
7680 of zero results and result components.  For example, many of the complex
7681 elementary functions have components that are odd functions of one of
7682 the parameter components; in these cases, the result component should
7683 have the sign of the parameter component at the origin.  Other complex
7684 elementary functions have zero components whose sign is opposite that of
7685 a parameter component at the origin, or is always positive or always
7686 negative.
7687 @end cartouche
7688 Followed.
7689
7690 @cindex Accuracy requirements
7691 @unnumberedsec G.2.4(19): Accuracy Requirements
7692 @sp 1
7693 @cartouche
7694 The versions of the forward trigonometric functions without a
7695 @code{Cycle} parameter should not be implemented by calling the
7696 corresponding version with a @code{Cycle} parameter of
7697 @code{2.0*Numerics.Pi}, since this will not provide the required
7698 accuracy in some portions of the domain.  For the same reason, the
7699 version of @code{Log} without a @code{Base} parameter should not be
7700 implemented by calling the corresponding version with a @code{Base}
7701 parameter of @code{Numerics.e}.
7702 @end cartouche
7703 Followed.
7704
7705 @cindex Complex arithmetic accuracy
7706 @cindex Accuracy, complex arithmetic
7707 @unnumberedsec G.2.6(15): Complex Arithmetic Accuracy
7708
7709 @sp 1
7710 @cartouche
7711 The version of the @code{Compose_From_Polar} function without a
7712 @code{Cycle} parameter should not be implemented by calling the
7713 corresponding version with a @code{Cycle} parameter of
7714 @code{2.0*Numerics.Pi}, since this will not provide the required
7715 accuracy in some portions of the domain.
7716 @end cartouche
7717 Followed.
7718
7719 @c -----------------------------------------
7720 @node Implementation Defined Characteristics
7721 @chapter Implementation Defined Characteristics
7722
7723 @noindent
7724 In addition to the implementation dependent pragmas and attributes, and
7725 the implementation advice, there are a number of other Ada features
7726 that are potentially implementation dependent.  These are mentioned
7727 throughout the Ada Reference Manual, and are summarized in Annex M@.
7728
7729 A requirement for conforming Ada compilers is that they provide
7730 documentation describing how the implementation deals with each of these
7731 issues.  In this chapter, you will find each point in Annex M listed
7732 followed by a description in italic font of how GNAT
7733 @c SGI info:
7734 @ignore
7735 in the ProDev Ada
7736 implementation on IRIX 5.3 operating system or greater
7737 @end ignore
7738 handles the implementation dependence.
7739
7740 You can use this chapter as a guide to minimizing implementation
7741 dependent features in your programs if portability to other compilers
7742 and other operating systems is an important consideration.  The numbers
7743 in each section below correspond to the paragraph number in the Ada
7744 Reference Manual.
7745
7746 @sp 1
7747 @cartouche
7748 @noindent
7749 @strong{2}.  Whether or not each recommendation given in Implementation
7750 Advice is followed.  See 1.1.2(37).
7751 @end cartouche
7752 @noindent
7753 @xref{Implementation Advice}.
7754
7755 @sp 1
7756 @cartouche
7757 @noindent
7758 @strong{3}.  Capacity limitations of the implementation.  See 1.1.3(3).
7759 @end cartouche
7760 @noindent
7761 The complexity of programs that can be processed is limited only by the
7762 total amount of available virtual memory, and disk space for the
7763 generated object files.
7764
7765 @sp 1
7766 @cartouche
7767 @noindent
7768 @strong{4}.  Variations from the standard that are impractical to avoid
7769 given the implementation's execution environment.  See 1.1.3(6).
7770 @end cartouche
7771 @noindent
7772 There are no variations from the standard.
7773
7774 @sp 1
7775 @cartouche
7776 @noindent
7777 @strong{5}.  Which @code{code_statement}s cause external
7778 interactions.  See 1.1.3(10).
7779 @end cartouche
7780 @noindent
7781 Any @code{code_statement} can potentially cause external interactions.
7782
7783 @sp 1
7784 @cartouche
7785 @noindent
7786 @strong{6}.  The coded representation for the text of an Ada
7787 program.  See 2.1(4).
7788 @end cartouche
7789 @noindent
7790 See separate section on source representation.
7791
7792 @sp 1
7793 @cartouche
7794 @noindent
7795 @strong{7}.  The control functions allowed in comments.  See 2.1(14).
7796 @end cartouche
7797 @noindent
7798 See separate section on source representation.
7799
7800 @sp 1
7801 @cartouche
7802 @noindent
7803 @strong{8}.  The representation for an end of line.  See 2.2(2).
7804 @end cartouche
7805 @noindent
7806 See separate section on source representation.
7807
7808 @sp 1
7809 @cartouche
7810 @noindent
7811 @strong{9}.  Maximum supported line length and lexical element
7812 length.  See 2.2(15).
7813 @end cartouche
7814 @noindent
7815 The maximum line length is 255 characters and the maximum length of a
7816 lexical element is also 255 characters.
7817
7818 @sp 1
7819 @cartouche
7820 @noindent
7821 @strong{10}.  Implementation defined pragmas.  See 2.8(14).
7822 @end cartouche
7823 @noindent
7824
7825 @xref{Implementation Defined Pragmas}.
7826
7827 @sp 1
7828 @cartouche
7829 @noindent
7830 @strong{11}.  Effect of pragma @code{Optimize}.  See 2.8(27).
7831 @end cartouche
7832 @noindent
7833 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
7834 parameter, checks that the optimization flag is set, and aborts if it is
7835 not.
7836
7837 @sp 1
7838 @cartouche
7839 @noindent
7840 @strong{12}.  The sequence of characters of the value returned by
7841 @code{@var{S}'Image} when some of the graphic characters of
7842 @code{@var{S}'Wide_Image} are not defined in @code{Character}.  See
7843 3.5(37).
7844 @end cartouche
7845 @noindent
7846 The sequence of characters is as defined by the wide character encoding
7847 method used for the source.  See section on source representation for
7848 further details.
7849
7850 @sp 1
7851 @cartouche
7852 @noindent
7853 @strong{13}.  The predefined integer types declared in
7854 @code{Standard}.  See 3.5.4(25).
7855 @end cartouche
7856 @noindent
7857 @table @code
7858 @item Short_Short_Integer
7859 8 bit signed
7860 @item Short_Integer
7861 (Short) 16 bit signed
7862 @item Integer
7863 32 bit signed
7864 @item Long_Integer
7865 64 bit signed (Alpha OpenVMS only)
7866 32 bit signed (all other targets)
7867 @item Long_Long_Integer
7868 64 bit signed
7869 @end table
7870
7871 @sp 1
7872 @cartouche
7873 @noindent
7874 @strong{14}.  Any nonstandard integer types and the operators defined
7875 for them.  See 3.5.4(26).
7876 @end cartouche
7877 @noindent
7878 There are no nonstandard integer types.
7879
7880 @sp 1
7881 @cartouche
7882 @noindent
7883 @strong{15}.  Any nonstandard real types and the operators defined for
7884 them.  See 3.5.6(8).
7885 @end cartouche
7886 @noindent
7887 There are no nonstandard real types.
7888
7889 @sp 1
7890 @cartouche
7891 @noindent
7892 @strong{16}.  What combinations of requested decimal precision and range
7893 are supported for floating point types.  See 3.5.7(7).
7894 @end cartouche
7895 @noindent
7896 The precision and range is as defined by the IEEE standard.
7897
7898 @sp 1
7899 @cartouche
7900 @noindent
7901 @strong{17}.  The predefined floating point types declared in
7902 @code{Standard}.  See 3.5.7(16).
7903 @end cartouche
7904 @noindent
7905 @table @code
7906 @item Short_Float
7907 32 bit IEEE short
7908 @item Float
7909 (Short) 32 bit IEEE short
7910 @item Long_Float
7911 64 bit IEEE long
7912 @item Long_Long_Float
7913 64 bit IEEE long (80 bit IEEE long on x86 processors)
7914 @end table
7915
7916 @sp 1
7917 @cartouche
7918 @noindent
7919 @strong{18}.  The small of an ordinary fixed point type.  See 3.5.9(8).
7920 @end cartouche
7921 @noindent
7922 @code{Fine_Delta} is 2**(@minus{}63)
7923
7924 @sp 1
7925 @cartouche
7926 @noindent
7927 @strong{19}.  What combinations of small, range, and digits are
7928 supported for fixed point types.  See 3.5.9(10).
7929 @end cartouche
7930 @noindent
7931 Any combinations are permitted that do not result in a small less than
7932 @code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
7933 If the mantissa is larger than 53 bits on machines where Long_Long_Float
7934 is 64 bits (true of all architectures except ia32), then the output from
7935 Text_IO is accurate to only 53 bits, rather than the full mantissa.  This
7936 is because floating-point conversions are used to convert fixed point.
7937
7938 @sp 1
7939 @cartouche
7940 @noindent
7941 @strong{20}.  The result of @code{Tags.Expanded_Name} for types declared
7942 within an unnamed @code{block_statement}.  See 3.9(10).
7943 @end cartouche
7944 @noindent
7945 Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
7946 decimal integer are allocated.
7947
7948 @sp 1
7949 @cartouche
7950 @noindent
7951 @strong{21}.  Implementation-defined attributes.  See 4.1.4(12).
7952 @end cartouche
7953 @noindent
7954 @xref{Implementation Defined Attributes}.
7955
7956 @sp 1
7957 @cartouche
7958 @noindent
7959 @strong{22}.  Any implementation-defined time types.  See 9.6(6).
7960 @end cartouche
7961 @noindent
7962 There are no implementation-defined time types.
7963
7964 @sp 1
7965 @cartouche
7966 @noindent
7967 @strong{23}.  The time base associated with relative delays.
7968 @end cartouche
7969 @noindent
7970 See 9.6(20).  The time base used is that provided by the C library
7971 function @code{gettimeofday}.
7972
7973 @sp 1
7974 @cartouche
7975 @noindent
7976 @strong{24}.  The time base of the type @code{Calendar.Time}.  See
7977 9.6(23).
7978 @end cartouche
7979 @noindent
7980 The time base used is that provided by the C library function
7981 @code{gettimeofday}.
7982
7983 @sp 1
7984 @cartouche
7985 @noindent
7986 @strong{25}.  The time zone used for package @code{Calendar}
7987 operations.  See 9.6(24).
7988 @end cartouche
7989 @noindent
7990 The time zone used by package @code{Calendar} is the current system time zone
7991 setting for local time, as accessed by the C library function
7992 @code{localtime}.
7993
7994 @sp 1
7995 @cartouche
7996 @noindent
7997 @strong{26}.  Any limit on @code{delay_until_statements} of
7998 @code{select_statements}.  See 9.6(29).
7999 @end cartouche
8000 @noindent
8001 There are no such limits.
8002
8003 @sp 1
8004 @cartouche
8005 @noindent
8006 @strong{27}.  Whether or not two non-overlapping parts of a composite
8007 object are independently addressable, in the case where packing, record
8008 layout, or @code{Component_Size} is specified for the object.  See
8009 9.10(1).
8010 @end cartouche
8011 @noindent
8012 Separate components are independently addressable if they do not share
8013 overlapping storage units.
8014
8015 @sp 1
8016 @cartouche
8017 @noindent
8018 @strong{28}.  The representation for a compilation.  See 10.1(2).
8019 @end cartouche
8020 @noindent
8021 A compilation is represented by a sequence of files presented to the
8022 compiler in a single invocation of the @command{gcc} command.
8023
8024 @sp 1
8025 @cartouche
8026 @noindent
8027 @strong{29}.  Any restrictions on compilations that contain multiple
8028 compilation_units.  See 10.1(4).
8029 @end cartouche
8030 @noindent
8031 No single file can contain more than one compilation unit, but any
8032 sequence of files can be presented to the compiler as a single
8033 compilation.
8034
8035 @sp 1
8036 @cartouche
8037 @noindent
8038 @strong{30}.  The mechanisms for creating an environment and for adding
8039 and replacing compilation units.  See 10.1.4(3).
8040 @end cartouche
8041 @noindent
8042 See separate section on compilation model.
8043
8044 @sp 1
8045 @cartouche
8046 @noindent
8047 @strong{31}.  The manner of explicitly assigning library units to a
8048 partition.  See 10.2(2).
8049 @end cartouche
8050 @noindent
8051 If a unit contains an Ada main program, then the Ada units for the partition
8052 are determined by recursive application of the rules in the Ada Reference
8053 Manual section 10.2(2-6).  In other words, the Ada units will be those that
8054 are needed by the main program, and then this definition of need is applied
8055 recursively to those units, and the partition contains the transitive
8056 closure determined by this relationship.  In short, all the necessary units
8057 are included, with no need to explicitly specify the list.  If additional
8058 units are required, e.g.@: by foreign language units, then all units must be
8059 mentioned in the context clause of one of the needed Ada units.
8060
8061 If the partition contains no main program, or if the main program is in
8062 a language other than Ada, then GNAT
8063 provides the binder options @option{-z} and @option{-n} respectively, and in
8064 this case a list of units can be explicitly supplied to the binder for
8065 inclusion in the partition (all units needed by these units will also
8066 be included automatically).  For full details on the use of these
8067 options, refer to @ref{The GNAT Make Program gnatmake,,, gnat_ugn,
8068 @value{EDITION} User's Guide}.
8069
8070 @sp 1
8071 @cartouche
8072 @noindent
8073 @strong{32}.  The implementation-defined means, if any, of specifying
8074 which compilation units are needed by a given compilation unit.  See
8075 10.2(2).
8076 @end cartouche
8077 @noindent
8078 The units needed by a given compilation unit are as defined in
8079 the Ada Reference Manual section 10.2(2-6).  There are no
8080 implementation-defined pragmas or other implementation-defined
8081 means for specifying needed units.
8082
8083 @sp 1
8084 @cartouche
8085 @noindent
8086 @strong{33}.  The manner of designating the main subprogram of a
8087 partition.  See 10.2(7).
8088 @end cartouche
8089 @noindent
8090 The main program is designated by providing the name of the
8091 corresponding @file{ALI} file as the input parameter to the binder.
8092
8093 @sp 1
8094 @cartouche
8095 @noindent
8096 @strong{34}.  The order of elaboration of @code{library_items}.  See
8097 10.2(18).
8098 @end cartouche
8099 @noindent
8100 The first constraint on ordering is that it meets the requirements of
8101 Chapter 10 of the Ada Reference Manual.  This still leaves some
8102 implementation dependent choices, which are resolved by first
8103 elaborating bodies as early as possible (i.e., in preference to specs
8104 where there is a choice), and second by evaluating the immediate with
8105 clauses of a unit to determine the probably best choice, and
8106 third by elaborating in alphabetical order of unit names
8107 where a choice still remains.
8108
8109 @sp 1
8110 @cartouche
8111 @noindent
8112 @strong{35}.  Parameter passing and function return for the main
8113 subprogram.  See 10.2(21).
8114 @end cartouche
8115 @noindent
8116 The main program has no parameters.  It may be a procedure, or a function
8117 returning an integer type.  In the latter case, the returned integer
8118 value is the return code of the program (overriding any value that
8119 may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
8120
8121 @sp 1
8122 @cartouche
8123 @noindent
8124 @strong{36}.  The mechanisms for building and running partitions.  See
8125 10.2(24).
8126 @end cartouche
8127 @noindent
8128 GNAT itself supports programs with only a single partition.  The GNATDIST
8129 tool provided with the GLADE package (which also includes an implementation
8130 of the PCS) provides a completely flexible method for building and running
8131 programs consisting of multiple partitions.  See the separate GLADE manual
8132 for details.
8133
8134 @sp 1
8135 @cartouche
8136 @noindent
8137 @strong{37}.  The details of program execution, including program
8138 termination.  See 10.2(25).
8139 @end cartouche
8140 @noindent
8141 See separate section on compilation model.
8142
8143 @sp 1
8144 @cartouche
8145 @noindent
8146 @strong{38}.  The semantics of any non-active partitions supported by the
8147 implementation.  See 10.2(28).
8148 @end cartouche
8149 @noindent
8150 Passive partitions are supported on targets where shared memory is
8151 provided by the operating system.  See the GLADE reference manual for
8152 further details.
8153
8154 @sp 1
8155 @cartouche
8156 @noindent
8157 @strong{39}.  The information returned by @code{Exception_Message}.  See
8158 11.4.1(10).
8159 @end cartouche
8160 @noindent
8161 Exception message returns the null string unless a specific message has
8162 been passed by the program.
8163
8164 @sp 1
8165 @cartouche
8166 @noindent
8167 @strong{40}.  The result of @code{Exceptions.Exception_Name} for types
8168 declared within an unnamed @code{block_statement}.  See 11.4.1(12).
8169 @end cartouche
8170 @noindent
8171 Blocks have implementation defined names of the form @code{B@var{nnn}}
8172 where @var{nnn} is an integer.
8173
8174 @sp 1
8175 @cartouche
8176 @noindent
8177 @strong{41}.  The information returned by
8178 @code{Exception_Information}.  See 11.4.1(13).
8179 @end cartouche
8180 @noindent
8181 @code{Exception_Information} returns a string in the following format:
8182
8183 @smallexample
8184 @emph{Exception_Name:} nnnnn
8185 @emph{Message:} mmmmm
8186 @emph{PID:} ppp
8187 @emph{Call stack traceback locations:}
8188 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
8189 @end smallexample
8190
8191 @noindent
8192 where
8193
8194 @itemize @bullet
8195 @item
8196 @code{nnnn} is the fully qualified name of the exception in all upper
8197 case letters. This line is always present.
8198
8199 @item
8200 @code{mmmm} is the message (this line present only if message is non-null)
8201
8202 @item
8203 @code{ppp} is the Process Id value as a decimal integer (this line is
8204 present only if the Process Id is nonzero). Currently we are
8205 not making use of this field.
8206
8207 @item
8208 The Call stack traceback locations line and the following values
8209 are present only if at least one traceback location was recorded.
8210 The values are given in C style format, with lower case letters
8211 for a-f, and only as many digits present as are necessary.
8212 @end itemize
8213
8214 @noindent
8215 The line terminator sequence at the end of each line, including
8216 the last line is a single @code{LF} character (@code{16#0A#}).
8217
8218 @sp 1
8219 @cartouche
8220 @noindent
8221 @strong{42}.  Implementation-defined check names.  See 11.5(27).
8222 @end cartouche
8223 @noindent
8224 The implementation defined check name Alignment_Check controls checking of
8225 address clause values for proper alignment (that is, the address supplied
8226 must be consistent with the alignment of the type).
8227
8228 In addition, a user program can add implementation-defined check names
8229 by means of the pragma Check_Name.
8230
8231 @sp 1
8232 @cartouche
8233 @noindent
8234 @strong{43}.  The interpretation of each aspect of representation.  See
8235 13.1(20).
8236 @end cartouche
8237 @noindent
8238 See separate section on data representations.
8239
8240 @sp 1
8241 @cartouche
8242 @noindent
8243 @strong{44}.  Any restrictions placed upon representation items.  See
8244 13.1(20).
8245 @end cartouche
8246 @noindent
8247 See separate section on data representations.
8248
8249 @sp 1
8250 @cartouche
8251 @noindent
8252 @strong{45}.  The meaning of @code{Size} for indefinite subtypes.  See
8253 13.3(48).
8254 @end cartouche
8255 @noindent
8256 Size for an indefinite subtype is the maximum possible size, except that
8257 for the case of a subprogram parameter, the size of the parameter object
8258 is the actual size.
8259
8260 @sp 1
8261 @cartouche
8262 @noindent
8263 @strong{46}.  The default external representation for a type tag.  See
8264 13.3(75).
8265 @end cartouche
8266 @noindent
8267 The default external representation for a type tag is the fully expanded
8268 name of the type in upper case letters.
8269
8270 @sp 1
8271 @cartouche
8272 @noindent
8273 @strong{47}.  What determines whether a compilation unit is the same in
8274 two different partitions.  See 13.3(76).
8275 @end cartouche
8276 @noindent
8277 A compilation unit is the same in two different partitions if and only
8278 if it derives from the same source file.
8279
8280 @sp 1
8281 @cartouche
8282 @noindent
8283 @strong{48}.  Implementation-defined components.  See 13.5.1(15).
8284 @end cartouche
8285 @noindent
8286 The only implementation defined component is the tag for a tagged type,
8287 which contains a pointer to the dispatching table.
8288
8289 @sp 1
8290 @cartouche
8291 @noindent
8292 @strong{49}.  If @code{Word_Size} = @code{Storage_Unit}, the default bit
8293 ordering.  See 13.5.3(5).
8294 @end cartouche
8295 @noindent
8296 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
8297 implementation, so no non-default bit ordering is supported.  The default
8298 bit ordering corresponds to the natural endianness of the target architecture.
8299
8300 @sp 1
8301 @cartouche
8302 @noindent
8303 @strong{50}.  The contents of the visible part of package @code{System}
8304 and its language-defined children.  See 13.7(2).
8305 @end cartouche
8306 @noindent
8307 See the definition of these packages in files @file{system.ads} and
8308 @file{s-stoele.ads}.
8309
8310 @sp 1
8311 @cartouche
8312 @noindent
8313 @strong{51}.  The contents of the visible part of package
8314 @code{System.Machine_Code}, and the meaning of
8315 @code{code_statements}.  See 13.8(7).
8316 @end cartouche
8317 @noindent
8318 See the definition and documentation in file @file{s-maccod.ads}.
8319
8320 @sp 1
8321 @cartouche
8322 @noindent
8323 @strong{52}.  The effect of unchecked conversion.  See 13.9(11).
8324 @end cartouche
8325 @noindent
8326 Unchecked conversion between types of the same size
8327 results in an uninterpreted transmission of the bits from one type
8328 to the other.  If the types are of unequal sizes, then in the case of
8329 discrete types, a shorter source is first zero or sign extended as
8330 necessary, and a shorter target is simply truncated on the left.
8331 For all non-discrete types, the source is first copied if necessary
8332 to ensure that the alignment requirements of the target are met, then
8333 a pointer is constructed to the source value, and the result is obtained
8334 by dereferencing this pointer after converting it to be a pointer to the
8335 target type. Unchecked conversions where the target subtype is an
8336 unconstrained array are not permitted. If the target alignment is
8337 greater than the source alignment, then a copy of the result is
8338 made with appropriate alignment
8339
8340 @sp 1
8341 @cartouche
8342 @noindent
8343 @strong{53}.  The manner of choosing a storage pool for an access type
8344 when @code{Storage_Pool} is not specified for the type.  See 13.11(17).
8345 @end cartouche
8346 @noindent
8347 There are 3 different standard pools used by the compiler when
8348 @code{Storage_Pool} is not specified depending whether the type is local
8349 to a subprogram or defined at the library level and whether
8350 @code{Storage_Size}is specified or not.  See documentation in the runtime
8351 library units @code{System.Pool_Global}, @code{System.Pool_Size} and
8352 @code{System.Pool_Local} in files @file{s-poosiz.ads},
8353 @file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
8354 default pools used.
8355
8356 @sp 1
8357 @cartouche
8358 @noindent
8359 @strong{54}.  Whether or not the implementation provides user-accessible
8360 names for the standard pool type(s).  See 13.11(17).
8361 @end cartouche
8362 @noindent
8363
8364 See documentation in the sources of the run time mentioned in paragraph
8365 @strong{53} .  All these pools are accessible by means of @code{with}'ing
8366 these units.
8367
8368 @sp 1
8369 @cartouche
8370 @noindent
8371 @strong{55}.  The meaning of @code{Storage_Size}.  See 13.11(18).
8372 @end cartouche
8373 @noindent
8374 @code{Storage_Size} is measured in storage units, and refers to the
8375 total space available for an access type collection, or to the primary
8376 stack space for a task.
8377
8378 @sp 1
8379 @cartouche
8380 @noindent
8381 @strong{56}.  Implementation-defined aspects of storage pools.  See
8382 13.11(22).
8383 @end cartouche
8384 @noindent
8385 See documentation in the sources of the run time mentioned in paragraph
8386 @strong{53} for details on GNAT-defined aspects of storage pools.
8387
8388 @sp 1
8389 @cartouche
8390 @noindent
8391 @strong{57}.  The set of restrictions allowed in a pragma
8392 @code{Restrictions}.  See 13.12(7).
8393 @end cartouche
8394 @noindent
8395 All RM defined Restriction identifiers are implemented.  The following
8396 additional restriction identifiers are provided.  There are two separate
8397 lists of implementation dependent restriction identifiers.  The first
8398 set requires consistency throughout a partition (in other words, if the
8399 restriction identifier is used for any compilation unit in the partition,
8400 then all compilation units in the partition must obey the restriction.
8401
8402 @table @code
8403
8404 @item Simple_Barriers
8405 @findex Simple_Barriers
8406 This restriction ensures at compile time that barriers in entry declarations
8407 for protected types are restricted to either static boolean expressions or
8408 references to simple boolean variables defined in the private part of the
8409 protected type.  No other form of entry barriers is permitted.  This is one
8410 of the restrictions of the Ravenscar profile for limited tasking (see also
8411 pragma @code{Profile (Ravenscar)}).
8412
8413 @item Max_Entry_Queue_Length => Expr
8414 @findex Max_Entry_Queue_Length
8415 This restriction is a declaration that any protected entry compiled in
8416 the scope of the restriction has at most the specified number of
8417 tasks waiting on the entry
8418 at any one time, and so no queue is required.  This restriction is not
8419 checked at compile time.  A program execution is erroneous if an attempt
8420 is made to queue more than the specified number of tasks on such an entry.
8421
8422 @item No_Calendar
8423 @findex No_Calendar
8424 This restriction ensures at compile time that there is no implicit or
8425 explicit dependence on the package @code{Ada.Calendar}.
8426
8427 @item No_Default_Initialization
8428 @findex No_Default_Initialization
8429
8430 This restriction prohibits any instance of default initialization of variables.
8431 The binder implements a consistency rule which prevents any unit compiled
8432 without the restriction from with'ing a unit with the restriction (this allows
8433 the generation of initialization procedures to be skipped, since you can be
8434 sure that no call is ever generated to an initialization procedure in a unit
8435 with the restriction active). If used in conjunction with Initialize_Scalars or
8436 Normalize_Scalars, the effect is to prohibit all cases of variables declared
8437 without a specific initializer (including the case of OUT scalar parameters).
8438
8439 @item No_Direct_Boolean_Operators
8440 @findex No_Direct_Boolean_Operators
8441 This restriction ensures that no logical (and/or/xor) are used on
8442 operands of type Boolean (or any type derived
8443 from Boolean). This is intended for use in safety critical programs
8444 where the certification protocol requires the use of short-circuit
8445 (and then, or else) forms for all composite boolean operations.
8446
8447 @item No_Dispatching_Calls
8448 @findex No_Dispatching_Calls
8449 This restriction ensures at compile time that the code generated by the
8450 compiler involves no dispatching calls. The use of this restriction allows the
8451 safe use of record extensions, classwide membership tests and other classwide
8452 features not involving implicit dispatching. This restriction ensures that
8453 the code contains no indirect calls through a dispatching mechanism. Note that
8454 this includes internally-generated calls created by the compiler, for example
8455 in the implementation of class-wide objects assignments. The
8456 membership test is allowed in the presence of this restriction, because its
8457 implementation requires no dispatching.
8458 This restriction is comparable to the official Ada restriction
8459 @code{No_Dispatch} except that it is a bit less restrictive in that it allows
8460 all classwide constructs that do not imply dispatching.
8461 The following example indicates constructs that violate this restriction.
8462
8463 @smallexample
8464 package Pkg is
8465   type T is tagged record
8466     Data : Natural;
8467   end record;
8468   procedure P (X : T);
8469
8470   type DT is new T with record
8471     More_Data : Natural;
8472   end record;
8473   procedure Q (X : DT);
8474 end Pkg;
8475
8476 with Pkg; use Pkg;
8477 procedure Example is
8478   procedure Test (O : T'Class) is
8479     N : Natural  := O'Size;--  Error: Dispatching call
8480     C : T'Class := O;      --  Error: implicit Dispatching Call
8481   begin
8482     if O in DT'Class then  --  OK   : Membership test
8483        Q (DT (O));         --  OK   : Type conversion plus direct call
8484     else
8485        P (O);              --  Error: Dispatching call
8486     end if;
8487   end Test;
8488
8489   Obj : DT;
8490 begin
8491   P (Obj);                 --  OK   : Direct call
8492   P (T (Obj));             --  OK   : Type conversion plus direct call
8493   P (T'Class (Obj));       --  Error: Dispatching call
8494
8495   Test (Obj);              --  OK   : Type conversion
8496
8497   if Obj in T'Class then   --  OK   : Membership test
8498      null;
8499   end if;
8500 end Example;
8501 @end smallexample
8502
8503 @item No_Dynamic_Attachment
8504 @findex No_Dynamic_Attachment
8505 This restriction ensures that there is no call to any of the operations
8506 defined in package Ada.Interrupts.
8507
8508 @item No_Enumeration_Maps
8509 @findex No_Enumeration_Maps
8510 This restriction ensures at compile time that no operations requiring
8511 enumeration maps are used (that is Image and Value attributes applied
8512 to enumeration types).
8513
8514 @item No_Entry_Calls_In_Elaboration_Code
8515 @findex No_Entry_Calls_In_Elaboration_Code
8516 This restriction ensures at compile time that no task or protected entry
8517 calls are made during elaboration code.  As a result of the use of this
8518 restriction, the compiler can assume that no code past an accept statement
8519 in a task can be executed at elaboration time.
8520
8521 @item No_Exception_Handlers
8522 @findex No_Exception_Handlers
8523 This restriction ensures at compile time that there are no explicit
8524 exception handlers. It also indicates that no exception propagation will
8525 be provided. In this mode, exceptions may be raised but will result in
8526 an immediate call to the last chance handler, a routine that the user
8527 must define with the following profile:
8528
8529 @smallexample @c ada
8530 procedure Last_Chance_Handler
8531   (Source_Location : System.Address; Line : Integer);
8532 pragma Export (C, Last_Chance_Handler,
8533                "__gnat_last_chance_handler");
8534 @end smallexample
8535
8536 The parameter is a C null-terminated string representing a message to be
8537 associated with the exception (typically the source location of the raise
8538 statement generated by the compiler). The Line parameter when nonzero
8539 represents the line number in the source program where the raise occurs.
8540
8541 @item No_Exception_Propagation
8542 @findex No_Exception_Propagation
8543 This restriction guarantees that exceptions are never propagated to an outer
8544 subprogram scope). The only case in which an exception may be raised is when
8545 the handler is statically in the same subprogram, so that the effect of a raise
8546 is essentially like a goto statement. Any other raise statement (implicit or
8547 explicit) will be considered unhandled. Exception handlers are allowed, but may
8548 not contain an exception occurrence identifier (exception choice). In addition
8549 use of the package GNAT.Current_Exception is not permitted, and reraise
8550 statements (raise with no operand) are not permitted.
8551
8552 @item No_Exception_Registration
8553 @findex No_Exception_Registration
8554 This restriction ensures at compile time that no stream operations for
8555 types Exception_Id or Exception_Occurrence are used. This also makes it
8556 impossible to pass exceptions to or from a partition with this restriction
8557 in a distributed environment. If this exception is active, then the generated
8558 code is simplified by omitting the otherwise-required global registration
8559 of exceptions when they are declared.
8560
8561 @item No_Implicit_Conditionals
8562 @findex No_Implicit_Conditionals
8563 This restriction ensures that the generated code does not contain any
8564 implicit conditionals, either by modifying the generated code where possible,
8565 or by rejecting any construct that would otherwise generate an implicit
8566 conditional. Note that this check does not include run time constraint
8567 checks, which on some targets may generate implicit conditionals as
8568 well. To control the latter, constraint checks can be suppressed in the
8569 normal manner. Constructs generating implicit conditionals include comparisons
8570 of composite objects and the Max/Min attributes.
8571
8572 @item No_Implicit_Dynamic_Code
8573 @findex No_Implicit_Dynamic_Code
8574 @cindex trampoline
8575 This restriction prevents the compiler from building ``trampolines''.
8576 This is a structure that is built on the stack and contains dynamic
8577 code to be executed at run time. On some targets, a trampoline is
8578 built for the following features: @code{Access},
8579 @code{Unrestricted_Access}, or @code{Address} of a nested subprogram;
8580 nested task bodies; primitive operations of nested tagged types.
8581 Trampolines do not work on machines that prevent execution of stack
8582 data. For example, on windows systems, enabling DEP (data execution
8583 protection) will cause trampolines to raise an exception.
8584 Trampolines are also quite slow at run time.
8585
8586 On many targets, trampolines have been largely eliminated. Look at the
8587 version of system.ads for your target --- if it has
8588 Always_Compatible_Rep equal to False, then trampolines are largely
8589 eliminated. In particular, a trampoline is built for the following
8590 features: @code{Address} of a nested subprogram;
8591 @code{Access} or @code{Unrestricted_Access} of a nested subprogram,
8592 but only if pragma Favor_Top_Level applies, or the access type has a
8593 foreign-language convention; primitive operations of nested tagged
8594 types.
8595
8596 @item No_Implicit_Loops
8597 @findex No_Implicit_Loops
8598 This restriction ensures that the generated code does not contain any
8599 implicit @code{for} loops, either by modifying
8600 the generated code where possible,
8601 or by rejecting any construct that would otherwise generate an implicit
8602 @code{for} loop. If this restriction is active, it is possible to build
8603 large array aggregates with all static components without generating an
8604 intermediate temporary, and without generating a loop to initialize individual
8605 components. Otherwise, a loop is created for arrays larger than about 5000
8606 scalar components.
8607
8608 @item No_Initialize_Scalars
8609 @findex No_Initialize_Scalars
8610 This restriction ensures that no unit in the partition is compiled with
8611 pragma Initialize_Scalars. This allows the generation of more efficient
8612 code, and in particular eliminates dummy null initialization routines that
8613 are otherwise generated for some record and array types.
8614
8615 @item No_Local_Protected_Objects
8616 @findex No_Local_Protected_Objects
8617 This restriction ensures at compile time that protected objects are
8618 only declared at the library level.
8619
8620 @item No_Protected_Type_Allocators
8621 @findex No_Protected_Type_Allocators
8622 This restriction ensures at compile time that there are no allocator
8623 expressions that attempt to allocate protected objects.
8624
8625 @item No_Secondary_Stack
8626 @findex No_Secondary_Stack
8627 This restriction ensures at compile time that the generated code does not
8628 contain any reference to the secondary stack.  The secondary stack is used
8629 to implement functions returning unconstrained objects (arrays or records)
8630 on some targets.
8631
8632 @item No_Select_Statements
8633 @findex No_Select_Statements
8634 This restriction ensures at compile time no select statements of any kind
8635 are permitted, that is the keyword @code{select} may not appear.
8636 This is one of the restrictions of the Ravenscar
8637 profile for limited tasking (see also pragma @code{Profile (Ravenscar)}).
8638
8639 @item No_Standard_Storage_Pools
8640 @findex No_Standard_Storage_Pools
8641 This restriction ensures at compile time that no access types
8642 use the standard default storage pool.  Any access type declared must
8643 have an explicit Storage_Pool attribute defined specifying a
8644 user-defined storage pool.
8645
8646 @item No_Streams
8647 @findex No_Streams
8648 This restriction ensures at compile/bind time that there are no
8649 stream objects created and no use of stream attributes.
8650 This restriction does not forbid dependences on the package
8651 @code{Ada.Streams}. So it is permissible to with
8652 @code{Ada.Streams} (or another package that does so itself)
8653 as long as no actual stream objects are created and no
8654 stream attributes are used.
8655
8656 Note that the use of restriction allows optimization of tagged types,
8657 since they do not need to worry about dispatching stream operations.
8658 To take maximum advantage of this space-saving optimization, any
8659 unit declaring a tagged type should be compiled with the restriction,
8660 though this is not required.
8661
8662 @item No_Task_Attributes_Package
8663 @findex No_Task_Attributes_Package
8664 This restriction ensures at compile time that there are no implicit or
8665 explicit dependencies on the package @code{Ada.Task_Attributes}.
8666
8667 @item No_Task_Termination
8668 @findex No_Task_Termination
8669 This restriction ensures at compile time that no terminate alternatives
8670 appear in any task body.
8671
8672 @item No_Tasking
8673 @findex No_Tasking
8674 This restriction prevents the declaration of tasks or task types throughout
8675 the partition.  It is similar in effect to the use of @code{Max_Tasks => 0}
8676 except that violations are caught at compile time and cause an error message
8677 to be output either by the compiler or binder.
8678
8679 @item Static_Priorities
8680 @findex Static_Priorities
8681 This restriction ensures at compile time that all priority expressions
8682 are static, and that there are no dependencies on the package
8683 @code{Ada.Dynamic_Priorities}.
8684
8685 @item Static_Storage_Size
8686 @findex Static_Storage_Size
8687 This restriction ensures at compile time that any expression appearing
8688 in a Storage_Size pragma or attribute definition clause is static.
8689
8690 @end table
8691
8692 @noindent
8693 The second set of implementation dependent restriction identifiers
8694 does not require partition-wide consistency.
8695 The restriction may be enforced for a single
8696 compilation unit without any effect on any of the
8697 other compilation units in the partition.
8698
8699 @table @code
8700
8701 @item No_Elaboration_Code
8702 @findex No_Elaboration_Code
8703 This restriction ensures at compile time that no elaboration code is
8704 generated.  Note that this is not the same condition as is enforced
8705 by pragma @code{Preelaborate}.  There are cases in which pragma
8706 @code{Preelaborate} still permits code to be generated (e.g.@: code
8707 to initialize a large array to all zeroes), and there are cases of units
8708 which do not meet the requirements for pragma @code{Preelaborate},
8709 but for which no elaboration code is generated.  Generally, it is
8710 the case that preelaborable units will meet the restrictions, with
8711 the exception of large aggregates initialized with an others_clause,
8712 and exception declarations (which generate calls to a run-time
8713 registry procedure).  This restriction is enforced on
8714 a unit by unit basis, it need not be obeyed consistently
8715 throughout a partition.
8716
8717 In the case of aggregates with others, if the aggregate has a dynamic
8718 size, there is no way to eliminate the elaboration code (such dynamic
8719 bounds would be incompatible with @code{Preelaborate} in any case). If
8720 the bounds are static, then use of this restriction actually modifies
8721 the code choice of the compiler to avoid generating a loop, and instead
8722 generate the aggregate statically if possible, no matter how many times
8723 the data for the others clause must be repeatedly generated.
8724
8725 It is not possible to precisely document
8726 the constructs which are compatible with this restriction, since,
8727 unlike most other restrictions, this is not a restriction on the
8728 source code, but a restriction on the generated object code. For
8729 example, if the source contains a declaration:
8730
8731 @smallexample
8732    Val : constant Integer := X;
8733 @end smallexample
8734
8735 @noindent
8736 where X is not a static constant, it may be possible, depending
8737 on complex optimization circuitry, for the compiler to figure
8738 out the value of X at compile time, in which case this initialization
8739 can be done by the loader, and requires no initialization code. It
8740 is not possible to document the precise conditions under which the
8741 optimizer can figure this out.
8742
8743 Note that this the implementation of this restriction requires full
8744 code generation. If it is used in conjunction with "semantics only"
8745 checking, then some cases of violations may be missed.
8746
8747 @item No_Entry_Queue
8748 @findex No_Entry_Queue
8749 This restriction is a declaration that any protected entry compiled in
8750 the scope of the restriction has at most one task waiting on the entry
8751 at any one time, and so no queue is required.  This restriction is not
8752 checked at compile time.  A program execution is erroneous if an attempt
8753 is made to queue a second task on such an entry.
8754
8755 @item No_Implementation_Attributes
8756 @findex No_Implementation_Attributes
8757 This restriction checks at compile time that no GNAT-defined attributes
8758 are present.  With this restriction, the only attributes that can be used
8759 are those defined in the Ada Reference Manual.
8760
8761 @item No_Implementation_Pragmas
8762 @findex No_Implementation_Pragmas
8763 This restriction checks at compile time that no GNAT-defined pragmas
8764 are present.  With this restriction, the only pragmas that can be used
8765 are those defined in the Ada Reference Manual.
8766
8767 @item No_Implementation_Restrictions
8768 @findex No_Implementation_Restrictions
8769 This restriction checks at compile time that no GNAT-defined restriction
8770 identifiers (other than @code{No_Implementation_Restrictions} itself)
8771 are present.  With this restriction, the only other restriction identifiers
8772 that can be used are those defined in the Ada Reference Manual.
8773
8774 @item No_Wide_Characters
8775 @findex No_Wide_Characters
8776 This restriction ensures at compile time that no uses of the types
8777 @code{Wide_Character} or @code{Wide_String} or corresponding wide
8778 wide types
8779 appear, and that no wide or wide wide string or character literals
8780 appear in the program (that is literals representing characters not in
8781 type @code{Character}.
8782
8783 @end table
8784
8785 @sp 1
8786 @cartouche
8787 @noindent
8788 @strong{58}.  The consequences of violating limitations on
8789 @code{Restrictions} pragmas.  See 13.12(9).
8790 @end cartouche
8791 @noindent
8792 Restrictions that can be checked at compile time result in illegalities
8793 if violated.  Currently there are no other consequences of violating
8794 restrictions.
8795
8796 @sp 1
8797 @cartouche
8798 @noindent
8799 @strong{59}.  The representation used by the @code{Read} and
8800 @code{Write} attributes of elementary types in terms of stream
8801 elements.  See 13.13.2(9).
8802 @end cartouche
8803 @noindent
8804 The representation is the in-memory representation of the base type of
8805 the type, using the number of bits corresponding to the
8806 @code{@var{type}'Size} value, and the natural ordering of the machine.
8807
8808 @sp 1
8809 @cartouche
8810 @noindent
8811 @strong{60}.  The names and characteristics of the numeric subtypes
8812 declared in the visible part of package @code{Standard}.  See A.1(3).
8813 @end cartouche
8814 @noindent
8815 See items describing the integer and floating-point types supported.
8816
8817 @sp 1
8818 @cartouche
8819 @noindent
8820 @strong{61}.  The accuracy actually achieved by the elementary
8821 functions.  See A.5.1(1).
8822 @end cartouche
8823 @noindent
8824 The elementary functions correspond to the functions available in the C
8825 library.  Only fast math mode is implemented.
8826
8827 @sp 1
8828 @cartouche
8829 @noindent
8830 @strong{62}.  The sign of a zero result from some of the operators or
8831 functions in @code{Numerics.Generic_Elementary_Functions}, when
8832 @code{Float_Type'Signed_Zeros} is @code{True}.  See A.5.1(46).
8833 @end cartouche
8834 @noindent
8835 The sign of zeroes follows the requirements of the IEEE 754 standard on
8836 floating-point.
8837
8838 @sp 1
8839 @cartouche
8840 @noindent
8841 @strong{63}.  The value of
8842 @code{Numerics.Float_Random.Max_Image_Width}.  See A.5.2(27).
8843 @end cartouche
8844 @noindent
8845 Maximum image width is 649, see library file @file{a-numran.ads}.
8846
8847 @sp 1
8848 @cartouche
8849 @noindent
8850 @strong{64}.  The value of
8851 @code{Numerics.Discrete_Random.Max_Image_Width}.  See A.5.2(27).
8852 @end cartouche
8853 @noindent
8854 Maximum image width is 80, see library file @file{a-nudira.ads}.
8855
8856 @sp 1
8857 @cartouche
8858 @noindent
8859 @strong{65}.  The algorithms for random number generation.  See
8860 A.5.2(32).
8861 @end cartouche
8862 @noindent
8863 The algorithm is documented in the source files @file{a-numran.ads} and
8864 @file{a-numran.adb}.
8865
8866 @sp 1
8867 @cartouche
8868 @noindent
8869 @strong{66}.  The string representation of a random number generator's
8870 state.  See A.5.2(38).
8871 @end cartouche
8872 @noindent
8873 See the documentation contained in the file @file{a-numran.adb}.
8874
8875 @sp 1
8876 @cartouche
8877 @noindent
8878 @strong{67}.  The minimum time interval between calls to the
8879 time-dependent Reset procedure that are guaranteed to initiate different
8880 random number sequences.  See A.5.2(45).
8881 @end cartouche
8882 @noindent
8883 The minimum period between reset calls to guarantee distinct series of
8884 random numbers is one microsecond.
8885
8886 @sp 1
8887 @cartouche
8888 @noindent
8889 @strong{68}.  The values of the @code{Model_Mantissa},
8890 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
8891 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
8892 Annex is not supported.  See A.5.3(72).
8893 @end cartouche
8894 @noindent
8895 See the source file @file{ttypef.ads} for the values of all numeric
8896 attributes.
8897
8898 @sp 1
8899 @cartouche
8900 @noindent
8901 @strong{69}.  Any implementation-defined characteristics of the
8902 input-output packages.  See A.7(14).
8903 @end cartouche
8904 @noindent
8905 There are no special implementation defined characteristics for these
8906 packages.
8907
8908 @sp 1
8909 @cartouche
8910 @noindent
8911 @strong{70}.  The value of @code{Buffer_Size} in @code{Storage_IO}.  See
8912 A.9(10).
8913 @end cartouche
8914 @noindent
8915 All type representations are contiguous, and the @code{Buffer_Size} is
8916 the value of @code{@var{type}'Size} rounded up to the next storage unit
8917 boundary.
8918
8919 @sp 1
8920 @cartouche
8921 @noindent
8922 @strong{71}.  External files for standard input, standard output, and
8923 standard error See A.10(5).
8924 @end cartouche
8925 @noindent
8926 These files are mapped onto the files provided by the C streams
8927 libraries.  See source file @file{i-cstrea.ads} for further details.
8928
8929 @sp 1
8930 @cartouche
8931 @noindent
8932 @strong{72}.  The accuracy of the value produced by @code{Put}.  See
8933 A.10.9(36).
8934 @end cartouche
8935 @noindent
8936 If more digits are requested in the output than are represented by the
8937 precision of the value, zeroes are output in the corresponding least
8938 significant digit positions.
8939
8940 @sp 1
8941 @cartouche
8942 @noindent
8943 @strong{73}.  The meaning of @code{Argument_Count}, @code{Argument}, and
8944 @code{Command_Name}.  See A.15(1).
8945 @end cartouche
8946 @noindent
8947 These are mapped onto the @code{argv} and @code{argc} parameters of the
8948 main program in the natural manner.
8949
8950 @sp 1
8951 @cartouche
8952 @noindent
8953 @strong{74}.  Implementation-defined convention names.  See B.1(11).
8954 @end cartouche
8955 @noindent
8956 The following convention names are supported
8957
8958 @table @code
8959 @item  Ada
8960 Ada
8961 @item Assembler
8962 Assembly language
8963 @item Asm
8964 Synonym for Assembler
8965 @item Assembly
8966 Synonym for Assembler
8967 @item C
8968 C
8969 @item C_Pass_By_Copy
8970 Allowed only for record types, like C, but also notes that record
8971 is to be passed by copy rather than reference.
8972 @item COBOL
8973 COBOL
8974 @item C_Plus_Plus (or CPP)
8975 C++
8976 @item Default
8977 Treated the same as C
8978 @item External
8979 Treated the same as C
8980 @item Fortran
8981 Fortran
8982 @item Intrinsic
8983 For support of pragma @code{Import} with convention Intrinsic, see
8984 separate section on Intrinsic Subprograms.
8985 @item Stdcall
8986 Stdcall (used for Windows implementations only).  This convention correspond
8987 to the WINAPI (previously called Pascal convention) C/C++ convention under
8988 Windows.  A function with this convention cleans the stack before exit.
8989 @item DLL
8990 Synonym for Stdcall
8991 @item Win32
8992 Synonym for Stdcall
8993 @item Stubbed
8994 Stubbed is a special convention used to indicate that the body of the
8995 subprogram will be entirely ignored.  Any call to the subprogram
8996 is converted into a raise of the @code{Program_Error} exception.  If a
8997 pragma @code{Import} specifies convention @code{stubbed} then no body need
8998 be present at all.  This convention is useful during development for the
8999 inclusion of subprograms whose body has not yet been written.
9000
9001 @end table
9002 @noindent
9003 In addition, all otherwise unrecognized convention names are also
9004 treated as being synonymous with convention C@.  In all implementations
9005 except for VMS, use of such other names results in a warning.  In VMS
9006 implementations, these names are accepted silently.
9007
9008 @sp 1
9009 @cartouche
9010 @noindent
9011 @strong{75}.  The meaning of link names.  See B.1(36).
9012 @end cartouche
9013 @noindent
9014 Link names are the actual names used by the linker.
9015
9016 @sp 1
9017 @cartouche
9018 @noindent
9019 @strong{76}.  The manner of choosing link names when neither the link
9020 name nor the address of an imported or exported entity is specified.  See
9021 B.1(36).
9022 @end cartouche
9023 @noindent
9024 The default linker name is that which would be assigned by the relevant
9025 external language, interpreting the Ada name as being in all lower case
9026 letters.
9027
9028 @sp 1
9029 @cartouche
9030 @noindent
9031 @strong{77}.  The effect of pragma @code{Linker_Options}.  See B.1(37).
9032 @end cartouche
9033 @noindent
9034 The string passed to @code{Linker_Options} is presented uninterpreted as
9035 an argument to the link command, unless it contains ASCII.NUL characters.
9036 NUL characters if they appear act as argument separators, so for example
9037
9038 @smallexample @c ada
9039 pragma Linker_Options ("-labc" & ASCII.NUL & "-ldef");
9040 @end smallexample
9041
9042 @noindent
9043 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
9044 linker. The order of linker options is preserved for a given unit. The final
9045 list of options passed to the linker is in reverse order of the elaboration
9046 order. For example, linker options for a body always appear before the options
9047 from the corresponding package spec.
9048
9049 @sp 1
9050 @cartouche
9051 @noindent
9052 @strong{78}.  The contents of the visible part of package
9053 @code{Interfaces} and its language-defined descendants.  See B.2(1).
9054 @end cartouche
9055 @noindent
9056 See files with prefix @file{i-} in the distributed library.
9057
9058 @sp 1
9059 @cartouche
9060 @noindent
9061 @strong{79}.  Implementation-defined children of package
9062 @code{Interfaces}.  The contents of the visible part of package
9063 @code{Interfaces}.  See B.2(11).
9064 @end cartouche
9065 @noindent
9066 See files with prefix @file{i-} in the distributed library.
9067
9068 @sp 1
9069 @cartouche
9070 @noindent
9071 @strong{80}.  The types @code{Floating}, @code{Long_Floating},
9072 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
9073 @code{COBOL_Character}; and the initialization of the variables
9074 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
9075 @code{Interfaces.COBOL}.  See B.4(50).
9076 @end cartouche
9077 @noindent
9078 @table @code
9079 @item Floating
9080 Float
9081 @item Long_Floating
9082 (Floating) Long_Float
9083 @item Binary
9084 Integer
9085 @item Long_Binary
9086 Long_Long_Integer
9087 @item Decimal_Element
9088 Character
9089 @item COBOL_Character
9090 Character
9091 @end table
9092
9093 @noindent
9094 For initialization, see the file @file{i-cobol.ads} in the distributed library.
9095
9096 @sp 1
9097 @cartouche
9098 @noindent
9099 @strong{81}.  Support for access to machine instructions.  See C.1(1).
9100 @end cartouche
9101 @noindent
9102 See documentation in file @file{s-maccod.ads} in the distributed library.
9103
9104 @sp 1
9105 @cartouche
9106 @noindent
9107 @strong{82}.  Implementation-defined aspects of access to machine
9108 operations.  See C.1(9).
9109 @end cartouche
9110 @noindent
9111 See documentation in file @file{s-maccod.ads} in the distributed library.
9112
9113 @sp 1
9114 @cartouche
9115 @noindent
9116 @strong{83}.  Implementation-defined aspects of interrupts.  See C.3(2).
9117 @end cartouche
9118 @noindent
9119 Interrupts are mapped to signals or conditions as appropriate.  See
9120 definition of unit
9121 @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
9122 on the interrupts supported on a particular target.
9123
9124 @sp 1
9125 @cartouche
9126 @noindent
9127 @strong{84}.  Implementation-defined aspects of pre-elaboration.  See
9128 C.4(13).
9129 @end cartouche
9130 @noindent
9131 GNAT does not permit a partition to be restarted without reloading,
9132 except under control of the debugger.
9133
9134 @sp 1
9135 @cartouche
9136 @noindent
9137 @strong{85}.  The semantics of pragma @code{Discard_Names}.  See C.5(7).
9138 @end cartouche
9139 @noindent
9140 Pragma @code{Discard_Names} causes names of enumeration literals to
9141 be suppressed.  In the presence of this pragma, the Image attribute
9142 provides the image of the Pos of the literal, and Value accepts
9143 Pos values.
9144
9145 @sp 1
9146 @cartouche
9147 @noindent
9148 @strong{86}.  The result of the @code{Task_Identification.Image}
9149 attribute.  See C.7.1(7).
9150 @end cartouche
9151 @noindent
9152 The result of this attribute is a string that identifies
9153 the object or component that denotes a given task. If a variable @code{Var}
9154 has a task type, the image for this task will have the form @code{Var_@var{XXXXXXXX}},
9155 where the suffix
9156 is the hexadecimal representation of the virtual address of the corresponding
9157 task control block. If the variable is an array of tasks, the image of each
9158 task will have the form of an indexed component indicating the position of a
9159 given task in the array, e.g.@: @code{Group(5)_@var{XXXXXXX}}. If the task is a
9160 component of a record, the image of the task will have the form of a selected
9161 component. These rules are fully recursive, so that the image of a task that
9162 is a subcomponent of a composite object corresponds to the expression that
9163 designates this task.
9164 @noindent
9165 If a task is created by an allocator, its image depends on the context. If the
9166 allocator is part of an object declaration, the rules described above are used
9167 to construct its image, and this image is not affected by subsequent
9168 assignments. If the allocator appears within an expression, the image
9169 includes only the name of the task type.
9170 @noindent
9171 If the configuration pragma Discard_Names is present, or if the restriction
9172 No_Implicit_Heap_Allocation is in effect,  the image reduces to
9173 the numeric suffix, that is to say the hexadecimal representation of the
9174 virtual address of the control block of the task.
9175 @sp 1
9176 @cartouche
9177 @noindent
9178 @strong{87}.  The value of @code{Current_Task} when in a protected entry
9179 or interrupt handler.  See C.7.1(17).
9180 @end cartouche
9181 @noindent
9182 Protected entries or interrupt handlers can be executed by any
9183 convenient thread, so the value of @code{Current_Task} is undefined.
9184
9185 @sp 1
9186 @cartouche
9187 @noindent
9188 @strong{88}.  The effect of calling @code{Current_Task} from an entry
9189 body or interrupt handler.  See C.7.1(19).
9190 @end cartouche
9191 @noindent
9192 The effect of calling @code{Current_Task} from an entry body or
9193 interrupt handler is to return the identification of the task currently
9194 executing the code.
9195
9196 @sp 1
9197 @cartouche
9198 @noindent
9199 @strong{89}.  Implementation-defined aspects of
9200 @code{Task_Attributes}.  See C.7.2(19).
9201 @end cartouche
9202 @noindent
9203 There are no implementation-defined aspects of @code{Task_Attributes}.
9204
9205 @sp 1
9206 @cartouche
9207 @noindent
9208 @strong{90}.  Values of all @code{Metrics}.  See D(2).
9209 @end cartouche
9210 @noindent
9211 The metrics information for GNAT depends on the performance of the
9212 underlying operating system.  The sources of the run-time for tasking
9213 implementation, together with the output from @option{-gnatG} can be
9214 used to determine the exact sequence of operating systems calls made
9215 to implement various tasking constructs.  Together with appropriate
9216 information on the performance of the underlying operating system,
9217 on the exact target in use, this information can be used to determine
9218 the required metrics.
9219
9220 @sp 1
9221 @cartouche
9222 @noindent
9223 @strong{91}.  The declarations of @code{Any_Priority} and
9224 @code{Priority}.  See D.1(11).
9225 @end cartouche
9226 @noindent
9227 See declarations in file @file{system.ads}.
9228
9229 @sp 1
9230 @cartouche
9231 @noindent
9232 @strong{92}.  Implementation-defined execution resources.  See D.1(15).
9233 @end cartouche
9234 @noindent
9235 There are no implementation-defined execution resources.
9236
9237 @sp 1
9238 @cartouche
9239 @noindent
9240 @strong{93}.  Whether, on a multiprocessor, a task that is waiting for
9241 access to a protected object keeps its processor busy.  See D.2.1(3).
9242 @end cartouche
9243 @noindent
9244 On a multi-processor, a task that is waiting for access to a protected
9245 object does not keep its processor busy.
9246
9247 @sp 1
9248 @cartouche
9249 @noindent
9250 @strong{94}.  The affect of implementation defined execution resources
9251 on task dispatching.  See D.2.1(9).
9252 @end cartouche
9253 @noindent
9254 @c SGI info
9255 @ignore
9256 Tasks map to IRIX threads, and the dispatching policy is as defined by
9257 the IRIX implementation of threads.
9258 @end ignore
9259 Tasks map to threads in the threads package used by GNAT@.  Where possible
9260 and appropriate, these threads correspond to native threads of the
9261 underlying operating system.
9262
9263 @sp 1
9264 @cartouche
9265 @noindent
9266 @strong{95}.  Implementation-defined @code{policy_identifiers} allowed
9267 in a pragma @code{Task_Dispatching_Policy}.  See D.2.2(3).
9268 @end cartouche
9269 @noindent
9270 There are no implementation-defined policy-identifiers allowed in this
9271 pragma.
9272
9273 @sp 1
9274 @cartouche
9275 @noindent
9276 @strong{96}.  Implementation-defined aspects of priority inversion.  See
9277 D.2.2(16).
9278 @end cartouche
9279 @noindent
9280 Execution of a task cannot be preempted by the implementation processing
9281 of delay expirations for lower priority tasks.
9282
9283 @sp 1
9284 @cartouche
9285 @noindent
9286 @strong{97}.  Implementation defined task dispatching.  See D.2.2(18).
9287 @end cartouche
9288 @noindent
9289 @c SGI info:
9290 @ignore
9291 Tasks map to IRIX threads, and the dispatching policy is as defined by
9292 the IRIX implementation of threads.
9293 @end ignore
9294 The policy is the same as that of the underlying threads implementation.
9295
9296 @sp 1
9297 @cartouche
9298 @noindent
9299 @strong{98}.  Implementation-defined @code{policy_identifiers} allowed
9300 in a pragma @code{Locking_Policy}.  See D.3(4).
9301 @end cartouche
9302 @noindent
9303 The only implementation defined policy permitted in GNAT is
9304 @code{Inheritance_Locking}.  On targets that support this policy, locking
9305 is implemented by inheritance, i.e.@: the task owning the lock operates
9306 at a priority equal to the highest priority of any task currently
9307 requesting the lock.
9308
9309 @sp 1
9310 @cartouche
9311 @noindent
9312 @strong{99}.  Default ceiling priorities.  See D.3(10).
9313 @end cartouche
9314 @noindent
9315 The ceiling priority of protected objects of the type
9316 @code{System.Interrupt_Priority'Last} as described in the Ada
9317 Reference Manual D.3(10),
9318
9319 @sp 1
9320 @cartouche
9321 @noindent
9322 @strong{100}.  The ceiling of any protected object used internally by
9323 the implementation.  See D.3(16).
9324 @end cartouche
9325 @noindent
9326 The ceiling priority of internal protected objects is
9327 @code{System.Priority'Last}.
9328
9329 @sp 1
9330 @cartouche
9331 @noindent
9332 @strong{101}.  Implementation-defined queuing policies.  See D.4(1).
9333 @end cartouche
9334 @noindent
9335 There are no implementation-defined queuing policies.
9336
9337 @sp 1
9338 @cartouche
9339 @noindent
9340 @strong{102}.  On a multiprocessor, any conditions that cause the
9341 completion of an aborted construct to be delayed later than what is
9342 specified for a single processor.  See D.6(3).
9343 @end cartouche
9344 @noindent
9345 The semantics for abort on a multi-processor is the same as on a single
9346 processor, there are no further delays.
9347
9348 @sp 1
9349 @cartouche
9350 @noindent
9351 @strong{103}.  Any operations that implicitly require heap storage
9352 allocation.  See D.7(8).
9353 @end cartouche
9354 @noindent
9355 The only operation that implicitly requires heap storage allocation is
9356 task creation.
9357
9358 @sp 1
9359 @cartouche
9360 @noindent
9361 @strong{104}.  Implementation-defined aspects of pragma
9362 @code{Restrictions}.  See D.7(20).
9363 @end cartouche
9364 @noindent
9365 There are no such implementation-defined aspects.
9366
9367 @sp 1
9368 @cartouche
9369 @noindent
9370 @strong{105}.  Implementation-defined aspects of package
9371 @code{Real_Time}.  See D.8(17).
9372 @end cartouche
9373 @noindent
9374 There are no implementation defined aspects of package @code{Real_Time}.
9375
9376 @sp 1
9377 @cartouche
9378 @noindent
9379 @strong{106}.  Implementation-defined aspects of
9380 @code{delay_statements}.  See D.9(8).
9381 @end cartouche
9382 @noindent
9383 Any difference greater than one microsecond will cause the task to be
9384 delayed (see D.9(7)).
9385
9386 @sp 1
9387 @cartouche
9388 @noindent
9389 @strong{107}.  The upper bound on the duration of interrupt blocking
9390 caused by the implementation.  See D.12(5).
9391 @end cartouche
9392 @noindent
9393 The upper bound is determined by the underlying operating system.  In
9394 no cases is it more than 10 milliseconds.
9395
9396 @sp 1
9397 @cartouche
9398 @noindent
9399 @strong{108}.  The means for creating and executing distributed
9400 programs.  See E(5).
9401 @end cartouche
9402 @noindent
9403 The GLADE package provides a utility GNATDIST for creating and executing
9404 distributed programs.  See the GLADE reference manual for further details.
9405
9406 @sp 1
9407 @cartouche
9408 @noindent
9409 @strong{109}.  Any events that can result in a partition becoming
9410 inaccessible.  See E.1(7).
9411 @end cartouche
9412 @noindent
9413 See the GLADE reference manual for full details on such events.
9414
9415 @sp 1
9416 @cartouche
9417 @noindent
9418 @strong{110}.  The scheduling policies, treatment of priorities, and
9419 management of shared resources between partitions in certain cases.  See
9420 E.1(11).
9421 @end cartouche
9422 @noindent
9423 See the GLADE reference manual for full details on these aspects of
9424 multi-partition execution.
9425
9426 @sp 1
9427 @cartouche
9428 @noindent
9429 @strong{111}.  Events that cause the version of a compilation unit to
9430 change.  See E.3(5).
9431 @end cartouche
9432 @noindent
9433 Editing the source file of a compilation unit, or the source files of
9434 any units on which it is dependent in a significant way cause the version
9435 to change.  No other actions cause the version number to change.  All changes
9436 are significant except those which affect only layout, capitalization or
9437 comments.
9438
9439 @sp 1
9440 @cartouche
9441 @noindent
9442 @strong{112}.  Whether the execution of the remote subprogram is
9443 immediately aborted as a result of cancellation.  See E.4(13).
9444 @end cartouche
9445 @noindent
9446 See the GLADE reference manual for details on the effect of abort in
9447 a distributed application.
9448
9449 @sp 1
9450 @cartouche
9451 @noindent
9452 @strong{113}.  Implementation-defined aspects of the PCS@.  See E.5(25).
9453 @end cartouche
9454 @noindent
9455 See the GLADE reference manual for a full description of all implementation
9456 defined aspects of the PCS@.
9457
9458 @sp 1
9459 @cartouche
9460 @noindent
9461 @strong{114}.  Implementation-defined interfaces in the PCS@.  See
9462 E.5(26).
9463 @end cartouche
9464 @noindent
9465 See the GLADE reference manual for a full description of all
9466 implementation defined interfaces.
9467
9468 @sp 1
9469 @cartouche
9470 @noindent
9471 @strong{115}.  The values of named numbers in the package
9472 @code{Decimal}.  See F.2(7).
9473 @end cartouche
9474 @noindent
9475 @table @code
9476 @item Max_Scale
9477 +18
9478 @item Min_Scale
9479 -18
9480 @item Min_Delta
9481 1.0E-18
9482 @item Max_Delta
9483 1.0E+18
9484 @item Max_Decimal_Digits
9485 18
9486 @end table
9487
9488 @sp 1
9489 @cartouche
9490 @noindent
9491 @strong{116}.  The value of @code{Max_Picture_Length} in the package
9492 @code{Text_IO.Editing}.  See F.3.3(16).
9493 @end cartouche
9494 @noindent
9495 64
9496
9497 @sp 1
9498 @cartouche
9499 @noindent
9500 @strong{117}.  The value of @code{Max_Picture_Length} in the package
9501 @code{Wide_Text_IO.Editing}.  See F.3.4(5).
9502 @end cartouche
9503 @noindent
9504 64
9505
9506 @sp 1
9507 @cartouche
9508 @noindent
9509 @strong{118}.  The accuracy actually achieved by the complex elementary
9510 functions and by other complex arithmetic operations.  See G.1(1).
9511 @end cartouche
9512 @noindent
9513 Standard library functions are used for the complex arithmetic
9514 operations.  Only fast math mode is currently supported.
9515
9516 @sp 1
9517 @cartouche
9518 @noindent
9519 @strong{119}.  The sign of a zero result (or a component thereof) from
9520 any operator or function in @code{Numerics.Generic_Complex_Types}, when
9521 @code{Real'Signed_Zeros} is True.  See G.1.1(53).
9522 @end cartouche
9523 @noindent
9524 The signs of zero values are as recommended by the relevant
9525 implementation advice.
9526
9527 @sp 1
9528 @cartouche
9529 @noindent
9530 @strong{120}.  The sign of a zero result (or a component thereof) from
9531 any operator or function in
9532 @code{Numerics.Generic_Complex_Elementary_Functions}, when
9533 @code{Real'Signed_Zeros} is @code{True}.  See G.1.2(45).
9534 @end cartouche
9535 @noindent
9536 The signs of zero values are as recommended by the relevant
9537 implementation advice.
9538
9539 @sp 1
9540 @cartouche
9541 @noindent
9542 @strong{121}.  Whether the strict mode or the relaxed mode is the
9543 default.  See G.2(2).
9544 @end cartouche
9545 @noindent
9546 The strict mode is the default.  There is no separate relaxed mode.  GNAT
9547 provides a highly efficient implementation of strict mode.
9548
9549 @sp 1
9550 @cartouche
9551 @noindent
9552 @strong{122}.  The result interval in certain cases of fixed-to-float
9553 conversion.  See G.2.1(10).
9554 @end cartouche
9555 @noindent
9556 For cases where the result interval is implementation dependent, the
9557 accuracy is that provided by performing all operations in 64-bit IEEE
9558 floating-point format.
9559
9560 @sp 1
9561 @cartouche
9562 @noindent
9563 @strong{123}.  The result of a floating point arithmetic operation in
9564 overflow situations, when the @code{Machine_Overflows} attribute of the
9565 result type is @code{False}.  See G.2.1(13).
9566 @end cartouche
9567 @noindent
9568 Infinite and NaN values are produced as dictated by the IEEE
9569 floating-point standard.
9570
9571 Note that on machines that are not fully compliant with the IEEE
9572 floating-point standard, such as Alpha, the @option{-mieee} compiler flag
9573 must be used for achieving IEEE confirming behavior (although at the cost
9574 of a significant performance penalty), so infinite and NaN values are
9575 properly generated.
9576
9577 @sp 1
9578 @cartouche
9579 @noindent
9580 @strong{124}.  The result interval for division (or exponentiation by a
9581 negative exponent), when the floating point hardware implements division
9582 as multiplication by a reciprocal.  See G.2.1(16).
9583 @end cartouche
9584 @noindent
9585 Not relevant, division is IEEE exact.
9586
9587 @sp 1
9588 @cartouche
9589 @noindent
9590 @strong{125}.  The definition of close result set, which determines the
9591 accuracy of certain fixed point multiplications and divisions.  See
9592 G.2.3(5).
9593 @end cartouche
9594 @noindent
9595 Operations in the close result set are performed using IEEE long format
9596 floating-point arithmetic.  The input operands are converted to
9597 floating-point, the operation is done in floating-point, and the result
9598 is converted to the target type.
9599
9600 @sp 1
9601 @cartouche
9602 @noindent
9603 @strong{126}.  Conditions on a @code{universal_real} operand of a fixed
9604 point multiplication or division for which the result shall be in the
9605 perfect result set.  See G.2.3(22).
9606 @end cartouche
9607 @noindent
9608 The result is only defined to be in the perfect result set if the result
9609 can be computed by a single scaling operation involving a scale factor
9610 representable in 64-bits.
9611
9612 @sp 1
9613 @cartouche
9614 @noindent
9615 @strong{127}.  The result of a fixed point arithmetic operation in
9616 overflow situations, when the @code{Machine_Overflows} attribute of the
9617 result type is @code{False}.  See G.2.3(27).
9618 @end cartouche
9619 @noindent
9620 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
9621 types.
9622
9623 @sp 1
9624 @cartouche
9625 @noindent
9626 @strong{128}.  The result of an elementary function reference in
9627 overflow situations, when the @code{Machine_Overflows} attribute of the
9628 result type is @code{False}.  See G.2.4(4).
9629 @end cartouche
9630 @noindent
9631 IEEE infinite and Nan values are produced as appropriate.
9632
9633 @sp 1
9634 @cartouche
9635 @noindent
9636 @strong{129}.  The value of the angle threshold, within which certain
9637 elementary functions, complex arithmetic operations, and complex
9638 elementary functions yield results conforming to a maximum relative
9639 error bound.  See G.2.4(10).
9640 @end cartouche
9641 @noindent
9642 Information on this subject is not yet available.
9643
9644 @sp 1
9645 @cartouche
9646 @noindent
9647 @strong{130}.  The accuracy of certain elementary functions for
9648 parameters beyond the angle threshold.  See G.2.4(10).
9649 @end cartouche
9650 @noindent
9651 Information on this subject is not yet available.
9652
9653 @sp 1
9654 @cartouche
9655 @noindent
9656 @strong{131}.  The result of a complex arithmetic operation or complex
9657 elementary function reference in overflow situations, when the
9658 @code{Machine_Overflows} attribute of the corresponding real type is
9659 @code{False}.  See G.2.6(5).
9660 @end cartouche
9661 @noindent
9662 IEEE infinite and Nan values are produced as appropriate.
9663
9664 @sp 1
9665 @cartouche
9666 @noindent
9667 @strong{132}.  The accuracy of certain complex arithmetic operations and
9668 certain complex elementary functions for parameters (or components
9669 thereof) beyond the angle threshold.  See G.2.6(8).
9670 @end cartouche
9671 @noindent
9672 Information on those subjects is not yet available.
9673
9674 @sp 1
9675 @cartouche
9676 @noindent
9677 @strong{133}.  Information regarding bounded errors and erroneous
9678 execution.  See H.2(1).
9679 @end cartouche
9680 @noindent
9681 Information on this subject is not yet available.
9682
9683 @sp 1
9684 @cartouche
9685 @noindent
9686 @strong{134}.  Implementation-defined aspects of pragma
9687 @code{Inspection_Point}.  See H.3.2(8).
9688 @end cartouche
9689 @noindent
9690 Pragma @code{Inspection_Point} ensures that the variable is live and can
9691 be examined by the debugger at the inspection point.
9692
9693 @sp 1
9694 @cartouche
9695 @noindent
9696 @strong{135}.  Implementation-defined aspects of pragma
9697 @code{Restrictions}.  See H.4(25).
9698 @end cartouche
9699 @noindent
9700 There are no implementation-defined aspects of pragma @code{Restrictions}.  The
9701 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
9702 generated code.  Checks must suppressed by use of pragma @code{Suppress}.
9703
9704 @sp 1
9705 @cartouche
9706 @noindent
9707 @strong{136}.  Any restrictions on pragma @code{Restrictions}.  See
9708 H.4(27).
9709 @end cartouche
9710 @noindent
9711 There are no restrictions on pragma @code{Restrictions}.
9712
9713 @node Intrinsic Subprograms
9714 @chapter Intrinsic Subprograms
9715 @cindex Intrinsic Subprograms
9716
9717 @menu
9718 * Intrinsic Operators::
9719 * Enclosing_Entity::
9720 * Exception_Information::
9721 * Exception_Message::
9722 * Exception_Name::
9723 * File::
9724 * Line::
9725 * Rotate_Left::
9726 * Rotate_Right::
9727 * Shift_Left::
9728 * Shift_Right::
9729 * Shift_Right_Arithmetic::
9730 * Source_Location::
9731 @end menu
9732
9733 @noindent
9734 GNAT allows a user application program to write the declaration:
9735
9736 @smallexample @c ada
9737    pragma Import (Intrinsic, name);
9738 @end smallexample
9739
9740 @noindent
9741 providing that the name corresponds to one of the implemented intrinsic
9742 subprograms in GNAT, and that the parameter profile of the referenced
9743 subprogram meets the requirements.  This chapter describes the set of
9744 implemented intrinsic subprograms, and the requirements on parameter profiles.
9745 Note that no body is supplied; as with other uses of pragma Import, the
9746 body is supplied elsewhere (in this case by the compiler itself).  Note
9747 that any use of this feature is potentially non-portable, since the
9748 Ada standard does not require Ada compilers to implement this feature.
9749
9750 @node Intrinsic Operators
9751 @section Intrinsic Operators
9752 @cindex Intrinsic operator
9753
9754 @noindent
9755 All the predefined numeric operators in package Standard
9756 in @code{pragma Import (Intrinsic,..)}
9757 declarations.  In the binary operator case, the operands must have the same
9758 size.  The operand or operands must also be appropriate for
9759 the operator.  For example, for addition, the operands must
9760 both be floating-point or both be fixed-point, and the
9761 right operand for @code{"**"} must have a root type of
9762 @code{Standard.Integer'Base}.
9763 You can use an intrinsic operator declaration as in the following example:
9764
9765 @smallexample @c ada
9766    type Int1 is new Integer;
9767    type Int2 is new Integer;
9768
9769    function "+" (X1 : Int1; X2 : Int2) return Int1;
9770    function "+" (X1 : Int1; X2 : Int2) return Int2;
9771    pragma Import (Intrinsic, "+");
9772 @end smallexample
9773
9774 @noindent
9775 This declaration would permit ``mixed mode'' arithmetic on items
9776 of the differing types @code{Int1} and @code{Int2}.
9777 It is also possible to specify such operators for private types, if the
9778 full views are appropriate arithmetic types.
9779
9780 @node Enclosing_Entity
9781 @section Enclosing_Entity
9782 @cindex Enclosing_Entity
9783 @noindent
9784 This intrinsic subprogram is used in the implementation of the
9785 library routine @code{GNAT.Source_Info}.  The only useful use of the
9786 intrinsic import in this case is the one in this unit, so an
9787 application program should simply call the function
9788 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
9789 the current subprogram, package, task, entry, or protected subprogram.
9790
9791 @node Exception_Information
9792 @section Exception_Information
9793 @cindex Exception_Information'
9794 @noindent
9795 This intrinsic subprogram is used in the implementation of the
9796 library routine @code{GNAT.Current_Exception}.  The only useful
9797 use of the intrinsic import in this case is the one in this unit,
9798 so an application program should simply call the function
9799 @code{GNAT.Current_Exception.Exception_Information} to obtain
9800 the exception information associated with the current exception.
9801
9802 @node Exception_Message
9803 @section Exception_Message
9804 @cindex Exception_Message
9805 @noindent
9806 This intrinsic subprogram is used in the implementation of the
9807 library routine @code{GNAT.Current_Exception}.  The only useful
9808 use of the intrinsic import in this case is the one in this unit,
9809 so an application program should simply call the function
9810 @code{GNAT.Current_Exception.Exception_Message} to obtain
9811 the message associated with the current exception.
9812
9813 @node Exception_Name
9814 @section Exception_Name
9815 @cindex Exception_Name
9816 @noindent
9817 This intrinsic subprogram is used in the implementation of the
9818 library routine @code{GNAT.Current_Exception}.  The only useful
9819 use of the intrinsic import in this case is the one in this unit,
9820 so an application program should simply call the function
9821 @code{GNAT.Current_Exception.Exception_Name} to obtain
9822 the name of the current exception.
9823
9824 @node File
9825 @section File
9826 @cindex File
9827 @noindent
9828 This intrinsic subprogram is used in the implementation of the
9829 library routine @code{GNAT.Source_Info}.  The only useful use of the
9830 intrinsic import in this case is the one in this unit, so an
9831 application program should simply call the function
9832 @code{GNAT.Source_Info.File} to obtain the name of the current
9833 file.
9834
9835 @node Line
9836 @section Line
9837 @cindex Line
9838 @noindent
9839 This intrinsic subprogram is used in the implementation of the
9840 library routine @code{GNAT.Source_Info}.  The only useful use of the
9841 intrinsic import in this case is the one in this unit, so an
9842 application program should simply call the function
9843 @code{GNAT.Source_Info.Line} to obtain the number of the current
9844 source line.
9845
9846 @node Rotate_Left
9847 @section Rotate_Left
9848 @cindex Rotate_Left
9849 @noindent
9850 In standard Ada, the @code{Rotate_Left} function is available only
9851 for the predefined modular types in package @code{Interfaces}.  However, in
9852 GNAT it is possible to define a Rotate_Left function for a user
9853 defined modular type or any signed integer type as in this example:
9854
9855 @smallexample @c ada
9856    function Shift_Left
9857      (Value  : My_Modular_Type;
9858       Amount : Natural)
9859       return   My_Modular_Type;
9860 @end smallexample
9861
9862 @noindent
9863 The requirements are that the profile be exactly as in the example
9864 above.  The only modifications allowed are in the formal parameter
9865 names, and in the type of @code{Value} and the return type, which
9866 must be the same, and must be either a signed integer type, or
9867 a modular integer type with a binary modulus, and the size must
9868 be 8.  16, 32 or 64 bits.
9869
9870 @node Rotate_Right
9871 @section Rotate_Right
9872 @cindex Rotate_Right
9873 @noindent
9874 A @code{Rotate_Right} function can be defined for any user defined
9875 binary modular integer type, or signed integer type, as described
9876 above for @code{Rotate_Left}.
9877
9878 @node Shift_Left
9879 @section Shift_Left
9880 @cindex Shift_Left
9881 @noindent
9882 A @code{Shift_Left} function can be defined for any user defined
9883 binary modular integer type, or signed integer type, as described
9884 above for @code{Rotate_Left}.
9885
9886 @node Shift_Right
9887 @section Shift_Right
9888 @cindex Shift_Right
9889 @noindent
9890 A @code{Shift_Right} function can be defined for any user defined
9891 binary modular integer type, or signed integer type, as described
9892 above for @code{Rotate_Left}.
9893
9894 @node Shift_Right_Arithmetic
9895 @section Shift_Right_Arithmetic
9896 @cindex Shift_Right_Arithmetic
9897 @noindent
9898 A @code{Shift_Right_Arithmetic} function can be defined for any user
9899 defined binary modular integer type, or signed integer type, as described
9900 above for @code{Rotate_Left}.
9901
9902 @node Source_Location
9903 @section Source_Location
9904 @cindex Source_Location
9905 @noindent
9906 This intrinsic subprogram is used in the implementation of the
9907 library routine @code{GNAT.Source_Info}.  The only useful use of the
9908 intrinsic import in this case is the one in this unit, so an
9909 application program should simply call the function
9910 @code{GNAT.Source_Info.Source_Location} to obtain the current
9911 source file location.
9912
9913 @node Representation Clauses and Pragmas
9914 @chapter Representation Clauses and Pragmas
9915 @cindex Representation Clauses
9916
9917 @menu
9918 * Alignment Clauses::
9919 * Size Clauses::
9920 * Storage_Size Clauses::
9921 * Size of Variant Record Objects::
9922 * Biased Representation ::
9923 * Value_Size and Object_Size Clauses::
9924 * Component_Size Clauses::
9925 * Bit_Order Clauses::
9926 * Effect of Bit_Order on Byte Ordering::
9927 * Pragma Pack for Arrays::
9928 * Pragma Pack for Records::
9929 * Record Representation Clauses::
9930 * Enumeration Clauses::
9931 * Address Clauses::
9932 * Effect of Convention on Representation::
9933 * Determining the Representations chosen by GNAT::
9934 @end menu
9935
9936 @noindent
9937 @cindex Representation Clause
9938 @cindex Representation Pragma
9939 @cindex Pragma, representation
9940 This section describes the representation clauses accepted by GNAT, and
9941 their effect on the representation of corresponding data objects.
9942
9943 GNAT fully implements Annex C (Systems Programming).  This means that all
9944 the implementation advice sections in chapter 13 are fully implemented.
9945 However, these sections only require a minimal level of support for
9946 representation clauses.  GNAT provides much more extensive capabilities,
9947 and this section describes the additional capabilities provided.
9948
9949 @node Alignment Clauses
9950 @section Alignment Clauses
9951 @cindex Alignment Clause
9952
9953 @noindent
9954 GNAT requires that all alignment clauses specify a power of 2, and all
9955 default alignments are always a power of 2.  The default alignment
9956 values are as follows:
9957
9958 @itemize @bullet
9959 @item @emph{Primitive Types}.
9960 For primitive types, the alignment is the minimum of the actual size of
9961 objects of the type divided by @code{Storage_Unit},
9962 and the maximum alignment supported by the target.
9963 (This maximum alignment is given by the GNAT-specific attribute
9964 @code{Standard'Maximum_Alignment}; see @ref{Maximum_Alignment}.)
9965 @cindex @code{Maximum_Alignment} attribute
9966 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
9967 default alignment will be 8 on any target that supports alignments
9968 this large, but on some targets, the maximum alignment may be smaller
9969 than 8, in which case objects of type @code{Long_Float} will be maximally
9970 aligned.
9971
9972 @item @emph{Arrays}.
9973 For arrays, the alignment is equal to the alignment of the component type
9974 for the normal case where no packing or component size is given.  If the
9975 array is packed, and the packing is effective (see separate section on
9976 packed arrays), then the alignment will be one for long packed arrays,
9977 or arrays whose length is not known at compile time.  For short packed
9978 arrays, which are handled internally as modular types, the alignment
9979 will be as described for primitive types, e.g.@: a packed array of length
9980 31 bits will have an object size of four bytes, and an alignment of 4.
9981
9982 @item @emph{Records}.
9983 For the normal non-packed case, the alignment of a record is equal to
9984 the maximum alignment of any of its components.  For tagged records, this
9985 includes the implicit access type used for the tag.  If a pragma @code{Pack}
9986 is used and all components are packable (see separate section on pragma
9987 @code{Pack}), then the resulting alignment is 1, unless the layout of the
9988 record makes it profitable to increase it.
9989
9990 A special case is when:
9991 @itemize @bullet
9992 @item
9993 the size of the record is given explicitly, or a
9994 full record representation clause is given, and
9995 @item
9996 the size of the record is 2, 4, or 8 bytes.
9997 @end itemize
9998 @noindent
9999 In this case, an alignment is chosen to match the
10000 size of the record. For example, if we have:
10001
10002 @smallexample @c ada
10003    type Small is record
10004       A, B : Character;
10005    end record;
10006    for Small'Size use 16;
10007 @end smallexample
10008
10009 @noindent
10010 then the default alignment of the record type @code{Small} is 2, not 1. This
10011 leads to more efficient code when the record is treated as a unit, and also
10012 allows the type to specified as @code{Atomic} on architectures requiring
10013 strict alignment.
10014
10015 @end itemize
10016
10017 @noindent
10018 An alignment clause may specify a larger alignment than the default value
10019 up to some maximum value dependent on the target (obtainable by using the
10020 attribute reference @code{Standard'Maximum_Alignment}). It may also specify
10021 a smaller alignment than the default value for enumeration, integer and
10022 fixed point types, as well as for record types, for example
10023
10024 @smallexample @c ada
10025   type V is record
10026      A : Integer;
10027   end record;
10028
10029   for V'alignment use 1;
10030 @end smallexample
10031
10032 @noindent
10033 @cindex Alignment, default
10034 The default alignment for the type @code{V} is 4, as a result of the
10035 Integer field in the record, but it is permissible, as shown, to
10036 override the default alignment of the record with a smaller value.
10037
10038 @node Size Clauses
10039 @section Size Clauses
10040 @cindex Size Clause
10041
10042 @noindent
10043 The default size for a type @code{T} is obtainable through the
10044 language-defined attribute @code{T'Size} and also through the
10045 equivalent GNAT-defined attribute @code{T'Value_Size}.
10046 For objects of type @code{T}, GNAT will generally increase the type size
10047 so that the object size (obtainable through the GNAT-defined attribute
10048 @code{T'Object_Size})
10049 is a multiple of @code{T'Alignment * Storage_Unit}.
10050 For example
10051
10052 @smallexample @c ada
10053    type Smallint is range 1 .. 6;
10054
10055    type Rec is record
10056       Y1 : integer;
10057       Y2 : boolean;
10058    end record;
10059 @end smallexample
10060
10061 @noindent
10062 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
10063 as specified by the RM rules,
10064 but objects of this type will have a size of 8
10065 (@code{Smallint'Object_Size} = 8),
10066 since objects by default occupy an integral number
10067 of storage units.  On some targets, notably older
10068 versions of the Digital Alpha, the size of stand
10069 alone objects of this type may be 32, reflecting
10070 the inability of the hardware to do byte load/stores.
10071
10072 Similarly, the size of type @code{Rec} is 40 bits
10073 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
10074 the alignment is 4, so objects of this type will have
10075 their size increased to 64 bits so that it is a multiple
10076 of the alignment (in bits).  This decision is
10077 in accordance with the specific Implementation Advice in RM 13.3(43):
10078
10079 @quotation
10080 A @code{Size} clause should be supported for an object if the specified
10081 @code{Size} is at least as large as its subtype's @code{Size}, and corresponds
10082 to a size in storage elements that is a multiple of the object's
10083 @code{Alignment} (if the @code{Alignment} is nonzero).
10084 @end quotation
10085
10086 @noindent
10087 An explicit size clause may be used to override the default size by
10088 increasing it.  For example, if we have:
10089
10090 @smallexample @c ada
10091    type My_Boolean is new Boolean;
10092    for My_Boolean'Size use 32;
10093 @end smallexample
10094
10095 @noindent
10096 then values of this type will always be 32 bits long.  In the case of
10097 discrete types, the size can be increased up to 64 bits, with the effect
10098 that the entire specified field is used to hold the value, sign- or
10099 zero-extended as appropriate.  If more than 64 bits is specified, then
10100 padding space is allocated after the value, and a warning is issued that
10101 there are unused bits.
10102
10103 Similarly the size of records and arrays may be increased, and the effect
10104 is to add padding bits after the value.  This also causes a warning message
10105 to be generated.
10106
10107 The largest Size value permitted in GNAT is 2**31@minus{}1.  Since this is a
10108 Size in bits, this corresponds to an object of size 256 megabytes (minus
10109 one).  This limitation is true on all targets.  The reason for this
10110 limitation is that it improves the quality of the code in many cases
10111 if it is known that a Size value can be accommodated in an object of
10112 type Integer.
10113
10114 @node Storage_Size Clauses
10115 @section Storage_Size Clauses
10116 @cindex Storage_Size Clause
10117
10118 @noindent
10119 For tasks, the @code{Storage_Size} clause specifies the amount of space
10120 to be allocated for the task stack.  This cannot be extended, and if the
10121 stack is exhausted, then @code{Storage_Error} will be raised (if stack
10122 checking is enabled).  Use a @code{Storage_Size} attribute definition clause,
10123 or a @code{Storage_Size} pragma in the task definition to set the
10124 appropriate required size.  A useful technique is to include in every
10125 task definition a pragma of the form:
10126
10127 @smallexample @c ada
10128    pragma Storage_Size (Default_Stack_Size);
10129 @end smallexample
10130
10131 @noindent
10132 Then @code{Default_Stack_Size} can be defined in a global package, and
10133 modified as required. Any tasks requiring stack sizes different from the
10134 default can have an appropriate alternative reference in the pragma.
10135
10136 You can also use the @option{-d} binder switch to modify the default stack
10137 size.
10138
10139 For access types, the @code{Storage_Size} clause specifies the maximum
10140 space available for allocation of objects of the type.  If this space is
10141 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
10142 In the case where the access type is declared local to a subprogram, the
10143 use of a @code{Storage_Size} clause triggers automatic use of a special
10144 predefined storage pool (@code{System.Pool_Size}) that ensures that all
10145 space for the pool is automatically reclaimed on exit from the scope in
10146 which the type is declared.
10147
10148 A special case recognized by the compiler is the specification of a
10149 @code{Storage_Size} of zero for an access type.  This means that no
10150 items can be allocated from the pool, and this is recognized at compile
10151 time, and all the overhead normally associated with maintaining a fixed
10152 size storage pool is eliminated.  Consider the following example:
10153
10154 @smallexample @c ada
10155    procedure p is
10156       type R is array (Natural) of Character;
10157       type P is access all R;
10158       for P'Storage_Size use 0;
10159       --  Above access type intended only for interfacing purposes
10160
10161       y : P;
10162
10163       procedure g (m : P);
10164       pragma Import (C, g);
10165
10166       --  @dots{}
10167
10168    begin
10169       --  @dots{}
10170       y := new R;
10171    end;
10172 @end smallexample
10173
10174 @noindent
10175 As indicated in this example, these dummy storage pools are often useful in
10176 connection with interfacing where no object will ever be allocated.  If you
10177 compile the above example, you get the warning:
10178
10179 @smallexample
10180    p.adb:16:09: warning: allocation from empty storage pool
10181    p.adb:16:09: warning: Storage_Error will be raised at run time
10182 @end smallexample
10183
10184 @noindent
10185 Of course in practice, there will not be any explicit allocators in the
10186 case of such an access declaration.
10187
10188 @node Size of Variant Record Objects
10189 @section Size of Variant Record Objects
10190 @cindex Size, variant record objects
10191 @cindex Variant record objects, size
10192
10193 @noindent
10194 In the case of variant record objects, there is a question whether Size gives
10195 information about a particular variant, or the maximum size required
10196 for any variant.  Consider the following program
10197
10198 @smallexample @c ada
10199 with Text_IO; use Text_IO;
10200 procedure q is
10201    type R1 (A : Boolean := False) is record
10202      case A is
10203        when True  => X : Character;
10204        when False => null;
10205      end case;
10206    end record;
10207
10208    V1 : R1 (False);
10209    V2 : R1;
10210
10211 begin
10212    Put_Line (Integer'Image (V1'Size));
10213    Put_Line (Integer'Image (V2'Size));
10214 end q;
10215 @end smallexample
10216
10217 @noindent
10218 Here we are dealing with a variant record, where the True variant
10219 requires 16 bits, and the False variant requires 8 bits.
10220 In the above example, both V1 and V2 contain the False variant,
10221 which is only 8 bits long.  However, the result of running the
10222 program is:
10223
10224 @smallexample
10225 8
10226 16
10227 @end smallexample
10228
10229 @noindent
10230 The reason for the difference here is that the discriminant value of
10231 V1 is fixed, and will always be False.  It is not possible to assign
10232 a True variant value to V1, therefore 8 bits is sufficient.  On the
10233 other hand, in the case of V2, the initial discriminant value is
10234 False (from the default), but it is possible to assign a True
10235 variant value to V2, therefore 16 bits must be allocated for V2
10236 in the general case, even fewer bits may be needed at any particular
10237 point during the program execution.
10238
10239 As can be seen from the output of this program, the @code{'Size}
10240 attribute applied to such an object in GNAT gives the actual allocated
10241 size of the variable, which is the largest size of any of the variants.
10242 The Ada Reference Manual is not completely clear on what choice should
10243 be made here, but the GNAT behavior seems most consistent with the
10244 language in the RM@.
10245
10246 In some cases, it may be desirable to obtain the size of the current
10247 variant, rather than the size of the largest variant.  This can be
10248 achieved in GNAT by making use of the fact that in the case of a
10249 subprogram parameter, GNAT does indeed return the size of the current
10250 variant (because a subprogram has no way of knowing how much space
10251 is actually allocated for the actual).
10252
10253 Consider the following modified version of the above program:
10254
10255 @smallexample @c ada
10256 with Text_IO; use Text_IO;
10257 procedure q is
10258    type R1 (A : Boolean := False) is record
10259      case A is
10260        when True  => X : Character;
10261        when False => null;
10262      end case;
10263    end record;
10264
10265    V2 : R1;
10266
10267    function Size (V : R1) return Integer is
10268    begin
10269       return V'Size;
10270    end Size;
10271
10272 begin
10273    Put_Line (Integer'Image (V2'Size));
10274    Put_Line (Integer'IMage (Size (V2)));
10275    V2 := (True, 'x');
10276    Put_Line (Integer'Image (V2'Size));
10277    Put_Line (Integer'IMage (Size (V2)));
10278 end q;
10279 @end smallexample
10280
10281 @noindent
10282 The output from this program is
10283
10284 @smallexample
10285 16
10286 8
10287 16
10288 16
10289 @end smallexample
10290
10291 @noindent
10292 Here we see that while the @code{'Size} attribute always returns
10293 the maximum size, regardless of the current variant value, the
10294 @code{Size} function does indeed return the size of the current
10295 variant value.
10296
10297 @node Biased Representation
10298 @section Biased Representation
10299 @cindex Size for biased representation
10300 @cindex Biased representation
10301
10302 @noindent
10303 In the case of scalars with a range starting at other than zero, it is
10304 possible in some cases to specify a size smaller than the default minimum
10305 value, and in such cases, GNAT uses an unsigned biased representation,
10306 in which zero is used to represent the lower bound, and successive values
10307 represent successive values of the type.
10308
10309 For example, suppose we have the declaration:
10310
10311 @smallexample @c ada
10312    type Small is range -7 .. -4;
10313    for Small'Size use 2;
10314 @end smallexample
10315
10316 @noindent
10317 Although the default size of type @code{Small} is 4, the @code{Size}
10318 clause is accepted by GNAT and results in the following representation
10319 scheme:
10320
10321 @smallexample
10322   -7 is represented as 2#00#
10323   -6 is represented as 2#01#
10324   -5 is represented as 2#10#
10325   -4 is represented as 2#11#
10326 @end smallexample
10327
10328 @noindent
10329 Biased representation is only used if the specified @code{Size} clause
10330 cannot be accepted in any other manner.  These reduced sizes that force
10331 biased representation can be used for all discrete types except for
10332 enumeration types for which a representation clause is given.
10333
10334 @node Value_Size and Object_Size Clauses
10335 @section Value_Size and Object_Size Clauses
10336 @findex Value_Size
10337 @findex Object_Size
10338 @cindex Size, of objects
10339
10340 @noindent
10341 In Ada 95 and Ada 2005, @code{T'Size} for a type @code{T} is the minimum
10342 number of bits required to hold values of type @code{T}.
10343 Although this interpretation was allowed in Ada 83, it was not required,
10344 and this requirement in practice can cause some significant difficulties.
10345 For example, in most Ada 83 compilers, @code{Natural'Size} was 32.
10346 However, in Ada 95 and Ada 2005,
10347 @code{Natural'Size} is
10348 typically 31.  This means that code may change in behavior when moving
10349 from Ada 83 to Ada 95 or Ada 2005.  For example, consider:
10350
10351 @smallexample @c ada
10352    type Rec is record;
10353       A : Natural;
10354       B : Natural;
10355    end record;
10356
10357    for Rec use record
10358       at 0  range 0 .. Natural'Size - 1;
10359       at 0  range Natural'Size .. 2 * Natural'Size - 1;
10360    end record;
10361 @end smallexample
10362
10363 @noindent
10364 In the above code, since the typical size of @code{Natural} objects
10365 is 32 bits and @code{Natural'Size} is 31, the above code can cause
10366 unexpected inefficient packing in Ada 95 and Ada 2005, and in general
10367 there are cases where the fact that the object size can exceed the
10368 size of the type causes surprises.
10369
10370 To help get around this problem GNAT provides two implementation
10371 defined attributes, @code{Value_Size} and @code{Object_Size}.  When
10372 applied to a type, these attributes yield the size of the type
10373 (corresponding to the RM defined size attribute), and the size of
10374 objects of the type respectively.
10375
10376 The @code{Object_Size} is used for determining the default size of
10377 objects and components.  This size value can be referred to using the
10378 @code{Object_Size} attribute.  The phrase ``is used'' here means that it is
10379 the basis of the determination of the size.  The backend is free to
10380 pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
10381 character might be stored in 32 bits on a machine with no efficient
10382 byte access instructions such as the Alpha.
10383
10384 The default rules for the value of @code{Object_Size} for
10385 discrete types are as follows:
10386
10387 @itemize @bullet
10388 @item
10389 The @code{Object_Size} for base subtypes reflect the natural hardware
10390 size in bits (run the compiler with @option{-gnatS} to find those values
10391 for numeric types). Enumeration types and fixed-point base subtypes have
10392 8, 16, 32 or 64 bits for this size, depending on the range of values
10393 to be stored.
10394
10395 @item
10396 The @code{Object_Size} of a subtype is the same as the
10397 @code{Object_Size} of
10398 the type from which it is obtained.
10399
10400 @item
10401 The @code{Object_Size} of a derived base type is copied from the parent
10402 base type, and the @code{Object_Size} of a derived first subtype is copied
10403 from the parent first subtype.
10404 @end itemize
10405
10406 @noindent
10407 The @code{Value_Size} attribute
10408 is the (minimum) number of bits required to store a value
10409 of the type.
10410 This value is used to determine how tightly to pack
10411 records or arrays with components of this type, and also affects
10412 the semantics of unchecked conversion (unchecked conversions where
10413 the @code{Value_Size} values differ generate a warning, and are potentially
10414 target dependent).
10415
10416 The default rules for the value of @code{Value_Size} are as follows:
10417
10418 @itemize @bullet
10419 @item
10420 The @code{Value_Size} for a base subtype is the minimum number of bits
10421 required to store all values of the type (including the sign bit
10422 only if negative values are possible).
10423
10424 @item
10425 If a subtype statically matches the first subtype of a given type, then it has
10426 by default the same @code{Value_Size} as the first subtype.  This is a
10427 consequence of RM 13.1(14) (``if two subtypes statically match,
10428 then their subtype-specific aspects are the same''.)
10429
10430 @item
10431 All other subtypes have a @code{Value_Size} corresponding to the minimum
10432 number of bits required to store all values of the subtype.  For
10433 dynamic bounds, it is assumed that the value can range down or up
10434 to the corresponding bound of the ancestor
10435 @end itemize
10436
10437 @noindent
10438 The RM defined attribute @code{Size} corresponds to the
10439 @code{Value_Size} attribute.
10440
10441 The @code{Size} attribute may be defined for a first-named subtype.  This sets
10442 the @code{Value_Size} of
10443 the first-named subtype to the given value, and the
10444 @code{Object_Size} of this first-named subtype to the given value padded up
10445 to an appropriate boundary.  It is a consequence of the default rules
10446 above that this @code{Object_Size} will apply to all further subtypes.  On the
10447 other hand, @code{Value_Size} is affected only for the first subtype, any
10448 dynamic subtypes obtained from it directly, and any statically matching
10449 subtypes.  The @code{Value_Size} of any other static subtypes is not affected.
10450
10451 @code{Value_Size} and
10452 @code{Object_Size} may be explicitly set for any subtype using
10453 an attribute definition clause.  Note that the use of these attributes
10454 can cause the RM 13.1(14) rule to be violated.  If two access types
10455 reference aliased objects whose subtypes have differing @code{Object_Size}
10456 values as a result of explicit attribute definition clauses, then it
10457 is erroneous to convert from one access subtype to the other.
10458
10459 At the implementation level, Esize stores the Object_Size and the
10460 RM_Size field stores the @code{Value_Size} (and hence the value of the
10461 @code{Size} attribute,
10462 which, as noted above, is equivalent to @code{Value_Size}).
10463
10464 To get a feel for the difference, consider the following examples (note
10465 that in each case the base is @code{Short_Short_Integer} with a size of 8):
10466
10467 @smallexample
10468                                        Object_Size     Value_Size
10469
10470 type x1 is range 0 .. 5;                    8               3
10471
10472 type x2 is range 0 .. 5;
10473 for x2'size use 12;                        16              12
10474
10475 subtype x3 is x2 range 0 .. 3;             16               2
10476
10477 subtype x4 is x2'base range 0 .. 10;        8               4
10478
10479 subtype x5 is x2 range 0 .. dynamic;       16               3*
10480
10481 subtype x6 is x2'base range 0 .. dynamic;   8               3*
10482
10483 @end smallexample
10484
10485 @noindent
10486 Note: the entries marked ``3*'' are not actually specified by the Ada
10487 Reference Manual, but it seems in the spirit of the RM rules to allocate
10488 the minimum number of bits (here 3, given the range for @code{x2})
10489 known to be large enough to hold the given range of values.
10490
10491 So far, so good, but GNAT has to obey the RM rules, so the question is
10492 under what conditions must the RM @code{Size} be used.
10493 The following is a list
10494 of the occasions on which the RM @code{Size} must be used:
10495
10496 @itemize @bullet
10497 @item
10498 Component size for packed arrays or records
10499
10500 @item
10501 Value of the attribute @code{Size} for a type
10502
10503 @item
10504 Warning about sizes not matching for unchecked conversion
10505 @end itemize
10506
10507 @noindent
10508 For record types, the @code{Object_Size} is always a multiple of the
10509 alignment of the type (this is true for all types). In some cases the
10510 @code{Value_Size} can be smaller. Consider:
10511
10512 @smallexample
10513    type R is record
10514      X : Integer;
10515      Y : Character;
10516    end record;
10517 @end smallexample
10518
10519 @noindent
10520 On a typical 32-bit architecture, the X component will be four bytes, and
10521 require four-byte alignment, and the Y component will be one byte. In this
10522 case @code{R'Value_Size} will be 40 (bits) since this is the minimum size
10523 required to store a value of this type, and for example, it is permissible
10524 to have a component of type R in an outer array whose component size is
10525 specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits),
10526 since it must be rounded up so that this value is a multiple of the
10527 alignment (4 bytes = 32 bits).
10528
10529 @noindent
10530 For all other types, the @code{Object_Size}
10531 and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
10532 Only @code{Size} may be specified for such types.
10533
10534 @node Component_Size Clauses
10535 @section Component_Size Clauses
10536 @cindex Component_Size Clause
10537
10538 @noindent
10539 Normally, the value specified in a component size clause must be consistent
10540 with the subtype of the array component with regard to size and alignment.
10541 In other words, the value specified must be at least equal to the size
10542 of this subtype, and must be a multiple of the alignment value.
10543
10544 In addition, component size clauses are allowed which cause the array
10545 to be packed, by specifying a smaller value.  A first case is for
10546 component size values in the range 1 through 63.  The value specified
10547 must not be smaller than the Size of the subtype.  GNAT will accurately
10548 honor all packing requests in this range.  For example, if we have:
10549
10550 @smallexample @c ada
10551 type r is array (1 .. 8) of Natural;
10552 for r'Component_Size use 31;
10553 @end smallexample
10554
10555 @noindent
10556 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
10557 Of course access to the components of such an array is considerably
10558 less efficient than if the natural component size of 32 is used.
10559 A second case is when the subtype of the component is a record type
10560 padded because of its default alignment.  For example, if we have:
10561
10562 @smallexample @c ada
10563 type r is record
10564   i : Integer;
10565   j : Integer;
10566   b : Boolean;
10567 end record;
10568
10569 type a is array (1 .. 8) of r;
10570 for a'Component_Size use 72;
10571 @end smallexample
10572
10573 @noindent
10574 then the resulting array has a length of 72 bytes, instead of 96 bytes
10575 if the alignment of the record (4) was obeyed.
10576
10577 Note that there is no point in giving both a component size clause
10578 and a pragma Pack for the same array type. if such duplicate
10579 clauses are given, the pragma Pack will be ignored.
10580
10581 @node Bit_Order Clauses
10582 @section Bit_Order Clauses
10583 @cindex Bit_Order Clause
10584 @cindex bit ordering
10585 @cindex ordering, of bits
10586
10587 @noindent
10588 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
10589 attribute.  The specification may either correspond to the default bit
10590 order for the target, in which case the specification has no effect and
10591 places no additional restrictions, or it may be for the non-standard
10592 setting (that is the opposite of the default).
10593
10594 In the case where the non-standard value is specified, the effect is
10595 to renumber bits within each byte, but the ordering of bytes is not
10596 affected.  There are certain
10597 restrictions placed on component clauses as follows:
10598
10599 @itemize @bullet
10600
10601 @item Components fitting within a single storage unit.
10602 @noindent
10603 These are unrestricted, and the effect is merely to renumber bits.  For
10604 example if we are on a little-endian machine with @code{Low_Order_First}
10605 being the default, then the following two declarations have exactly
10606 the same effect:
10607
10608 @smallexample @c ada
10609    type R1 is record
10610       A : Boolean;
10611       B : Integer range 1 .. 120;
10612    end record;
10613
10614    for R1 use record
10615       A at 0 range 0 .. 0;
10616       B at 0 range 1 .. 7;
10617    end record;
10618
10619    type R2 is record
10620       A : Boolean;
10621       B : Integer range 1 .. 120;
10622    end record;
10623
10624    for R2'Bit_Order use High_Order_First;
10625
10626    for R2 use record
10627       A at 0 range 7 .. 7;
10628       B at 0 range 0 .. 6;
10629    end record;
10630 @end smallexample
10631
10632 @noindent
10633 The useful application here is to write the second declaration with the
10634 @code{Bit_Order} attribute definition clause, and know that it will be treated
10635 the same, regardless of whether the target is little-endian or big-endian.
10636
10637 @item Components occupying an integral number of bytes.
10638 @noindent
10639 These are components that exactly fit in two or more bytes.  Such component
10640 declarations are allowed, but have no effect, since it is important to realize
10641 that the @code{Bit_Order} specification does not affect the ordering of bytes.
10642 In particular, the following attempt at getting an endian-independent integer
10643 does not work:
10644
10645 @smallexample @c ada
10646    type R2 is record
10647       A : Integer;
10648    end record;
10649
10650    for R2'Bit_Order use High_Order_First;
10651
10652    for R2 use record
10653       A at 0 range 0 .. 31;
10654    end record;
10655 @end smallexample
10656
10657 @noindent
10658 This declaration will result in a little-endian integer on a
10659 little-endian machine, and a big-endian integer on a big-endian machine.
10660 If byte flipping is required for interoperability between big- and
10661 little-endian machines, this must be explicitly programmed.  This capability
10662 is not provided by @code{Bit_Order}.
10663
10664 @item Components that are positioned across byte boundaries
10665 @noindent
10666 but do not occupy an integral number of bytes.  Given that bytes are not
10667 reordered, such fields would occupy a non-contiguous sequence of bits
10668 in memory, requiring non-trivial code to reassemble.  They are for this
10669 reason not permitted, and any component clause specifying such a layout
10670 will be flagged as illegal by GNAT@.
10671
10672 @end itemize
10673
10674 @noindent
10675 Since the misconception that Bit_Order automatically deals with all
10676 endian-related incompatibilities is a common one, the specification of
10677 a component field that is an integral number of bytes will always
10678 generate a warning.  This warning may be suppressed using @code{pragma
10679 Warnings (Off)} if desired.  The following section contains additional
10680 details regarding the issue of byte ordering.
10681
10682 @node Effect of Bit_Order on Byte Ordering
10683 @section Effect of Bit_Order on Byte Ordering
10684 @cindex byte ordering
10685 @cindex ordering, of bytes
10686
10687 @noindent
10688 In this section we will review the effect of the @code{Bit_Order} attribute
10689 definition clause on byte ordering.  Briefly, it has no effect at all, but
10690 a detailed example will be helpful.  Before giving this
10691 example, let us review the precise
10692 definition of the effect of defining @code{Bit_Order}.  The effect of a
10693 non-standard bit order is described in section 15.5.3 of the Ada
10694 Reference Manual:
10695
10696 @quotation
10697 2   A bit ordering is a method of interpreting the meaning of
10698 the storage place attributes.
10699 @end quotation
10700
10701 @noindent
10702 To understand the precise definition of storage place attributes in
10703 this context, we visit section 13.5.1 of the manual:
10704
10705 @quotation
10706 13   A record_representation_clause (without the mod_clause)
10707 specifies the layout.  The storage place attributes (see 13.5.2)
10708 are taken from the values of the position, first_bit, and last_bit
10709 expressions after normalizing those values so that first_bit is
10710 less than Storage_Unit.
10711 @end quotation
10712
10713 @noindent
10714 The critical point here is that storage places are taken from
10715 the values after normalization, not before.  So the @code{Bit_Order}
10716 interpretation applies to normalized values.  The interpretation
10717 is described in the later part of the 15.5.3 paragraph:
10718
10719 @quotation
10720 2   A bit ordering is a method of interpreting the meaning of
10721 the storage place attributes.  High_Order_First (known in the
10722 vernacular as ``big endian'') means that the first bit of a
10723 storage element (bit 0) is the most significant bit (interpreting
10724 the sequence of bits that represent a component as an unsigned
10725 integer value).  Low_Order_First (known in the vernacular as
10726 ``little endian'') means the opposite: the first bit is the
10727 least significant.
10728 @end quotation
10729
10730 @noindent
10731 Note that the numbering is with respect to the bits of a storage
10732 unit.  In other words, the specification affects only the numbering
10733 of bits within a single storage unit.
10734
10735 We can make the effect clearer by giving an example.
10736
10737 Suppose that we have an external device which presents two bytes, the first
10738 byte presented, which is the first (low addressed byte) of the two byte
10739 record is called Master, and the second byte is called Slave.
10740
10741 The left most (most significant bit is called Control for each byte, and
10742 the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
10743 (least significant) bit.
10744
10745 On a big-endian machine, we can write the following representation clause
10746
10747 @smallexample @c ada
10748    type Data is record
10749       Master_Control : Bit;
10750       Master_V1      : Bit;
10751       Master_V2      : Bit;
10752       Master_V3      : Bit;
10753       Master_V4      : Bit;
10754       Master_V5      : Bit;
10755       Master_V6      : Bit;
10756       Master_V7      : Bit;
10757       Slave_Control  : Bit;
10758       Slave_V1       : Bit;
10759       Slave_V2       : Bit;
10760       Slave_V3       : Bit;
10761       Slave_V4       : Bit;
10762       Slave_V5       : Bit;
10763       Slave_V6       : Bit;
10764       Slave_V7       : Bit;
10765    end record;
10766
10767    for Data use record
10768       Master_Control at 0 range 0 .. 0;
10769       Master_V1      at 0 range 1 .. 1;
10770       Master_V2      at 0 range 2 .. 2;
10771       Master_V3      at 0 range 3 .. 3;
10772       Master_V4      at 0 range 4 .. 4;
10773       Master_V5      at 0 range 5 .. 5;
10774       Master_V6      at 0 range 6 .. 6;
10775       Master_V7      at 0 range 7 .. 7;
10776       Slave_Control  at 1 range 0 .. 0;
10777       Slave_V1       at 1 range 1 .. 1;
10778       Slave_V2       at 1 range 2 .. 2;
10779       Slave_V3       at 1 range 3 .. 3;
10780       Slave_V4       at 1 range 4 .. 4;
10781       Slave_V5       at 1 range 5 .. 5;
10782       Slave_V6       at 1 range 6 .. 6;
10783       Slave_V7       at 1 range 7 .. 7;
10784    end record;
10785 @end smallexample
10786
10787 @noindent
10788 Now if we move this to a little endian machine, then the bit ordering within
10789 the byte is backwards, so we have to rewrite the record rep clause as:
10790
10791 @smallexample @c ada
10792    for Data use record
10793       Master_Control at 0 range 7 .. 7;
10794       Master_V1      at 0 range 6 .. 6;
10795       Master_V2      at 0 range 5 .. 5;
10796       Master_V3      at 0 range 4 .. 4;
10797       Master_V4      at 0 range 3 .. 3;
10798       Master_V5      at 0 range 2 .. 2;
10799       Master_V6      at 0 range 1 .. 1;
10800       Master_V7      at 0 range 0 .. 0;
10801       Slave_Control  at 1 range 7 .. 7;
10802       Slave_V1       at 1 range 6 .. 6;
10803       Slave_V2       at 1 range 5 .. 5;
10804       Slave_V3       at 1 range 4 .. 4;
10805       Slave_V4       at 1 range 3 .. 3;
10806       Slave_V5       at 1 range 2 .. 2;
10807       Slave_V6       at 1 range 1 .. 1;
10808       Slave_V7       at 1 range 0 .. 0;
10809    end record;
10810 @end smallexample
10811
10812 @noindent
10813 It is a nuisance to have to rewrite the clause, especially if
10814 the code has to be maintained on both machines.  However,
10815 this is a case that we can handle with the
10816 @code{Bit_Order} attribute if it is implemented.
10817 Note that the implementation is not required on byte addressed
10818 machines, but it is indeed implemented in GNAT.
10819 This means that we can simply use the
10820 first record clause, together with the declaration
10821
10822 @smallexample @c ada
10823    for Data'Bit_Order use High_Order_First;
10824 @end smallexample
10825
10826 @noindent
10827 and the effect is what is desired, namely the layout is exactly the same,
10828 independent of whether the code is compiled on a big-endian or little-endian
10829 machine.
10830
10831 The important point to understand is that byte ordering is not affected.
10832 A @code{Bit_Order} attribute definition never affects which byte a field
10833 ends up in, only where it ends up in that byte.
10834 To make this clear, let us rewrite the record rep clause of the previous
10835 example as:
10836
10837 @smallexample @c ada
10838    for Data'Bit_Order use High_Order_First;
10839    for Data use record
10840       Master_Control at 0 range  0 .. 0;
10841       Master_V1      at 0 range  1 .. 1;
10842       Master_V2      at 0 range  2 .. 2;
10843       Master_V3      at 0 range  3 .. 3;
10844       Master_V4      at 0 range  4 .. 4;
10845       Master_V5      at 0 range  5 .. 5;
10846       Master_V6      at 0 range  6 .. 6;
10847       Master_V7      at 0 range  7 .. 7;
10848       Slave_Control  at 0 range  8 .. 8;
10849       Slave_V1       at 0 range  9 .. 9;
10850       Slave_V2       at 0 range 10 .. 10;
10851       Slave_V3       at 0 range 11 .. 11;
10852       Slave_V4       at 0 range 12 .. 12;
10853       Slave_V5       at 0 range 13 .. 13;
10854       Slave_V6       at 0 range 14 .. 14;
10855       Slave_V7       at 0 range 15 .. 15;
10856    end record;
10857 @end smallexample
10858
10859 @noindent
10860 This is exactly equivalent to saying (a repeat of the first example):
10861
10862 @smallexample @c ada
10863    for Data'Bit_Order use High_Order_First;
10864    for Data use record
10865       Master_Control at 0 range 0 .. 0;
10866       Master_V1      at 0 range 1 .. 1;
10867       Master_V2      at 0 range 2 .. 2;
10868       Master_V3      at 0 range 3 .. 3;
10869       Master_V4      at 0 range 4 .. 4;
10870       Master_V5      at 0 range 5 .. 5;
10871       Master_V6      at 0 range 6 .. 6;
10872       Master_V7      at 0 range 7 .. 7;
10873       Slave_Control  at 1 range 0 .. 0;
10874       Slave_V1       at 1 range 1 .. 1;
10875       Slave_V2       at 1 range 2 .. 2;
10876       Slave_V3       at 1 range 3 .. 3;
10877       Slave_V4       at 1 range 4 .. 4;
10878       Slave_V5       at 1 range 5 .. 5;
10879       Slave_V6       at 1 range 6 .. 6;
10880       Slave_V7       at 1 range 7 .. 7;
10881    end record;
10882 @end smallexample
10883
10884 @noindent
10885 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
10886 field.  The storage place attributes are obtained by normalizing the
10887 values given so that the @code{First_Bit} value is less than 8.  After
10888 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
10889 we specified in the other case.
10890
10891 Now one might expect that the @code{Bit_Order} attribute might affect
10892 bit numbering within the entire record component (two bytes in this
10893 case, thus affecting which byte fields end up in), but that is not
10894 the way this feature is defined, it only affects numbering of bits,
10895 not which byte they end up in.
10896
10897 Consequently it never makes sense to specify a starting bit number
10898 greater than 7 (for a byte addressable field) if an attribute
10899 definition for @code{Bit_Order} has been given, and indeed it
10900 may be actively confusing to specify such a value, so the compiler
10901 generates a warning for such usage.
10902
10903 If you do need to control byte ordering then appropriate conditional
10904 values must be used.  If in our example, the slave byte came first on
10905 some machines we might write:
10906
10907 @smallexample @c ada
10908    Master_Byte_First constant Boolean := @dots{};
10909
10910    Master_Byte : constant Natural :=
10911                    1 - Boolean'Pos (Master_Byte_First);
10912    Slave_Byte  : constant Natural :=
10913                    Boolean'Pos (Master_Byte_First);
10914
10915    for Data'Bit_Order use High_Order_First;
10916    for Data use record
10917       Master_Control at Master_Byte range 0 .. 0;
10918       Master_V1      at Master_Byte range 1 .. 1;
10919       Master_V2      at Master_Byte range 2 .. 2;
10920       Master_V3      at Master_Byte range 3 .. 3;
10921       Master_V4      at Master_Byte range 4 .. 4;
10922       Master_V5      at Master_Byte range 5 .. 5;
10923       Master_V6      at Master_Byte range 6 .. 6;
10924       Master_V7      at Master_Byte range 7 .. 7;
10925       Slave_Control  at Slave_Byte  range 0 .. 0;
10926       Slave_V1       at Slave_Byte  range 1 .. 1;
10927       Slave_V2       at Slave_Byte  range 2 .. 2;
10928       Slave_V3       at Slave_Byte  range 3 .. 3;
10929       Slave_V4       at Slave_Byte  range 4 .. 4;
10930       Slave_V5       at Slave_Byte  range 5 .. 5;
10931       Slave_V6       at Slave_Byte  range 6 .. 6;
10932       Slave_V7       at Slave_Byte  range 7 .. 7;
10933    end record;
10934 @end smallexample
10935
10936 @noindent
10937 Now to switch between machines, all that is necessary is
10938 to set the boolean constant @code{Master_Byte_First} in
10939 an appropriate manner.
10940
10941 @node Pragma Pack for Arrays
10942 @section Pragma Pack for Arrays
10943 @cindex Pragma Pack (for arrays)
10944
10945 @noindent
10946 Pragma @code{Pack} applied to an array has no effect unless the component type
10947 is packable.  For a component type to be packable, it must be one of the
10948 following cases:
10949
10950 @itemize @bullet
10951 @item
10952 Any scalar type
10953 @item
10954 Any type whose size is specified with a size clause
10955 @item
10956 Any packed array type with a static size
10957 @item
10958 Any record type padded because of its default alignment
10959 @end itemize
10960
10961 @noindent
10962 For all these cases, if the component subtype size is in the range
10963 1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
10964 component size were specified giving the component subtype size.
10965 For example if we have:
10966
10967 @smallexample @c ada
10968    type r is range 0 .. 17;
10969
10970    type ar is array (1 .. 8) of r;
10971    pragma Pack (ar);
10972 @end smallexample
10973
10974 @noindent
10975 Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
10976 and the size of the array @code{ar} will be exactly 40 bits.
10977
10978 Note that in some cases this rather fierce approach to packing can produce
10979 unexpected effects.  For example, in Ada 95 and Ada 2005,
10980 subtype @code{Natural} typically has a size of 31, meaning that if you
10981 pack an array of @code{Natural}, you get 31-bit
10982 close packing, which saves a few bits, but results in far less efficient
10983 access.  Since many other Ada compilers will ignore such a packing request,
10984 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
10985 might not be what is intended.  You can easily remove this warning by
10986 using an explicit @code{Component_Size} setting instead, which never generates
10987 a warning, since the intention of the programmer is clear in this case.
10988
10989 GNAT treats packed arrays in one of two ways.  If the size of the array is
10990 known at compile time and is less than 64 bits, then internally the array
10991 is represented as a single modular type, of exactly the appropriate number
10992 of bits.  If the length is greater than 63 bits, or is not known at compile
10993 time, then the packed array is represented as an array of bytes, and the
10994 length is always a multiple of 8 bits.
10995
10996 Note that to represent a packed array as a modular type, the alignment must
10997 be suitable for the modular type involved. For example, on typical machines
10998 a 32-bit packed array will be represented by a 32-bit modular integer with
10999 an alignment of four bytes. If you explicitly override the default alignment
11000 with an alignment clause that is too small, the modular representation
11001 cannot be used. For example, consider the following set of declarations:
11002
11003 @smallexample @c ada
11004    type R is range 1 .. 3;
11005    type S is array (1 .. 31) of R;
11006    for S'Component_Size use 2;
11007    for S'Size use 62;
11008    for S'Alignment use 1;
11009 @end smallexample
11010
11011 @noindent
11012 If the alignment clause were not present, then a 62-bit modular
11013 representation would be chosen (typically with an alignment of 4 or 8
11014 bytes depending on the target). But the default alignment is overridden
11015 with the explicit alignment clause. This means that the modular
11016 representation cannot be used, and instead the array of bytes
11017 representation must be used, meaning that the length must be a multiple
11018 of 8. Thus the above set of declarations will result in a diagnostic
11019 rejecting the size clause and noting that the minimum size allowed is 64.
11020
11021 @cindex Pragma Pack (for type Natural)
11022 @cindex Pragma Pack warning
11023
11024 One special case that is worth noting occurs when the base type of the
11025 component size is 8/16/32 and the subtype is one bit less. Notably this
11026 occurs with subtype @code{Natural}. Consider:
11027
11028 @smallexample @c ada
11029    type Arr is array (1 .. 32) of Natural;
11030    pragma Pack (Arr);
11031 @end smallexample
11032
11033 @noindent
11034 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
11035 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
11036 Ada 83 compilers did not attempt 31 bit packing.
11037
11038 In Ada 95 and Ada 2005, @code{Natural'Size} is required to be 31. Furthermore,
11039 GNAT really does pack 31-bit subtype to 31 bits. This may result in a
11040 substantial unintended performance penalty when porting legacy Ada 83 code.
11041 To help prevent this, GNAT generates a warning in such cases. If you really
11042 want 31 bit packing in a case like this, you can set the component size
11043 explicitly:
11044
11045 @smallexample @c ada
11046    type Arr is array (1 .. 32) of Natural;
11047    for Arr'Component_Size use 31;
11048 @end smallexample
11049
11050 @noindent
11051 Here 31-bit packing is achieved as required, and no warning is generated,
11052 since in this case the programmer intention is clear.
11053
11054 @node Pragma Pack for Records
11055 @section Pragma Pack for Records
11056 @cindex Pragma Pack (for records)
11057
11058 @noindent
11059 Pragma @code{Pack} applied to a record will pack the components to reduce
11060 wasted space from alignment gaps and by reducing the amount of space
11061 taken by components.  We distinguish between @emph{packable} components and
11062 @emph{non-packable} components.
11063 Components of the following types are considered packable:
11064 @itemize @bullet
11065 @item
11066 All primitive types are packable.
11067
11068 @item
11069 Small packed arrays, whose size does not exceed 64 bits, and where the
11070 size is statically known at compile time, are represented internally
11071 as modular integers, and so they are also packable.
11072
11073 @end itemize
11074
11075 @noindent
11076 All packable components occupy the exact number of bits corresponding to
11077 their @code{Size} value, and are packed with no padding bits, i.e.@: they
11078 can start on an arbitrary bit boundary.
11079
11080 All other types are non-packable, they occupy an integral number of
11081 storage units, and
11082 are placed at a boundary corresponding to their alignment requirements.
11083
11084 For example, consider the record
11085
11086 @smallexample @c ada
11087    type Rb1 is array (1 .. 13) of Boolean;
11088    pragma Pack (rb1);
11089
11090    type Rb2 is array (1 .. 65) of Boolean;
11091    pragma Pack (rb2);
11092
11093    type x2 is record
11094       l1 : Boolean;
11095       l2 : Duration;
11096       l3 : Float;
11097       l4 : Boolean;
11098       l5 : Rb1;
11099       l6 : Rb2;
11100    end record;
11101    pragma Pack (x2);
11102 @end smallexample
11103
11104 @noindent
11105 The representation for the record x2 is as follows:
11106
11107 @smallexample @c ada
11108 for x2'Size use 224;
11109 for x2 use record
11110    l1 at  0 range  0 .. 0;
11111    l2 at  0 range  1 .. 64;
11112    l3 at 12 range  0 .. 31;
11113    l4 at 16 range  0 .. 0;
11114    l5 at 16 range  1 .. 13;
11115    l6 at 18 range  0 .. 71;
11116 end record;
11117 @end smallexample
11118
11119 @noindent
11120 Studying this example, we see that the packable fields @code{l1}
11121 and @code{l2} are
11122 of length equal to their sizes, and placed at specific bit boundaries (and
11123 not byte boundaries) to
11124 eliminate padding.  But @code{l3} is of a non-packable float type, so
11125 it is on the next appropriate alignment boundary.
11126
11127 The next two fields are fully packable, so @code{l4} and @code{l5} are
11128 minimally packed with no gaps.  However, type @code{Rb2} is a packed
11129 array that is longer than 64 bits, so it is itself non-packable.  Thus
11130 the @code{l6} field is aligned to the next byte boundary, and takes an
11131 integral number of bytes, i.e.@: 72 bits.
11132
11133 @node Record Representation Clauses
11134 @section Record Representation Clauses
11135 @cindex Record Representation Clause
11136
11137 @noindent
11138 Record representation clauses may be given for all record types, including
11139 types obtained by record extension.  Component clauses are allowed for any
11140 static component.  The restrictions on component clauses depend on the type
11141 of the component.
11142
11143 @cindex Component Clause
11144 For all components of an elementary type, the only restriction on component
11145 clauses is that the size must be at least the 'Size value of the type
11146 (actually the Value_Size).  There are no restrictions due to alignment,
11147 and such components may freely cross storage boundaries.
11148
11149 Packed arrays with a size up to and including 64 bits are represented
11150 internally using a modular type with the appropriate number of bits, and
11151 thus the same lack of restriction applies.  For example, if you declare:
11152
11153 @smallexample @c ada
11154    type R is array (1 .. 49) of Boolean;
11155    pragma Pack (R);
11156    for R'Size use 49;
11157 @end smallexample
11158
11159 @noindent
11160 then a component clause for a component of type R may start on any
11161 specified bit boundary, and may specify a value of 49 bits or greater.
11162
11163 For packed bit arrays that are longer than 64 bits, there are two
11164 cases. If the component size is a power of 2 (1,2,4,8,16,32 bits),
11165 including the important case of single bits or boolean values, then
11166 there are no limitations on placement of such components, and they
11167 may start and end at arbitrary bit boundaries.
11168
11169 If the component size is not a power of 2 (e.g.@: 3 or 5), then
11170 an array of this type longer than 64 bits must always be placed on
11171 on a storage unit (byte) boundary and occupy an integral number
11172 of storage units (bytes). Any component clause that does not
11173 meet this requirement will be rejected.
11174
11175 Any aliased component, or component of an aliased type, must
11176 have its normal alignment and size. A component clause that
11177 does not meet this requirement will be rejected.
11178
11179 The tag field of a tagged type always occupies an address sized field at
11180 the start of the record.  No component clause may attempt to overlay this
11181 tag. When a tagged type appears as a component, the tag field must have
11182 proper alignment
11183
11184 In the case of a record extension T1, of a type T, no component clause applied
11185 to the type T1 can specify a storage location that would overlap the first
11186 T'Size bytes of the record.
11187
11188 For all other component types, including non-bit-packed arrays,
11189 the component can be placed at an arbitrary bit boundary,
11190 so for example, the following is permitted:
11191
11192 @smallexample @c ada
11193    type R is array (1 .. 10) of Boolean;
11194    for R'Size use 80;
11195
11196    type Q is record
11197       G, H : Boolean;
11198       L, M : R;
11199    end record;
11200
11201    for Q use record
11202       G at 0 range  0 ..   0;
11203       H at 0 range  1 ..   1;
11204       L at 0 range  2 ..  81;
11205       R at 0 range 82 .. 161;
11206    end record;
11207 @end smallexample
11208
11209 @noindent
11210 Note: the above rules apply to recent releases of GNAT 5.
11211 In GNAT 3, there are more severe restrictions on larger components.
11212 For non-primitive types, including packed arrays with a size greater than
11213 64 bits, component clauses must respect the alignment requirement of the
11214 type, in particular, always starting on a byte boundary, and the length
11215 must be a multiple of the storage unit.
11216
11217 @node Enumeration Clauses
11218 @section Enumeration Clauses
11219
11220 The only restriction on enumeration clauses is that the range of values
11221 must be representable.  For the signed case, if one or more of the
11222 representation values are negative, all values must be in the range:
11223
11224 @smallexample @c ada
11225    System.Min_Int .. System.Max_Int
11226 @end smallexample
11227
11228 @noindent
11229 For the unsigned case, where all values are nonnegative, the values must
11230 be in the range:
11231
11232 @smallexample @c ada
11233    0 .. System.Max_Binary_Modulus;
11234 @end smallexample
11235
11236 @noindent
11237 A @emph{confirming} representation clause is one in which the values range
11238 from 0 in sequence, i.e.@: a clause that confirms the default representation
11239 for an enumeration type.
11240 Such a confirming representation
11241 is permitted by these rules, and is specially recognized by the compiler so
11242 that no extra overhead results from the use of such a clause.
11243
11244 If an array has an index type which is an enumeration type to which an
11245 enumeration clause has been applied, then the array is stored in a compact
11246 manner.  Consider the declarations:
11247
11248 @smallexample @c ada
11249    type r is (A, B, C);
11250    for r use (A => 1, B => 5, C => 10);
11251    type t is array (r) of Character;
11252 @end smallexample
11253
11254 @noindent
11255 The array type t corresponds to a vector with exactly three elements and
11256 has a default size equal to @code{3*Character'Size}.  This ensures efficient
11257 use of space, but means that accesses to elements of the array will incur
11258 the overhead of converting representation values to the corresponding
11259 positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
11260
11261 @node Address Clauses
11262 @section Address Clauses
11263 @cindex Address Clause
11264
11265 The reference manual allows a general restriction on representation clauses,
11266 as found in RM 13.1(22):
11267
11268 @quotation
11269 An implementation need not support representation
11270 items containing nonstatic expressions, except that
11271 an implementation should support a representation item
11272 for a given entity if each nonstatic expression in the
11273 representation item is a name that statically denotes
11274 a constant declared before the entity.
11275 @end quotation
11276
11277 @noindent
11278 In practice this is applicable only to address clauses, since this is the
11279 only case in which a non-static expression is permitted by the syntax.  As
11280 the AARM notes in sections 13.1 (22.a-22.h):
11281
11282 @display
11283   22.a   Reason: This is to avoid the following sort of thing:
11284
11285   22.b        X : Integer := F(@dots{});
11286               Y : Address := G(@dots{});
11287               for X'Address use Y;
11288
11289   22.c   In the above, we have to evaluate the
11290          initialization expression for X before we
11291          know where to put the result.  This seems
11292          like an unreasonable implementation burden.
11293
11294   22.d   The above code should instead be written
11295          like this:
11296
11297   22.e        Y : constant Address := G(@dots{});
11298               X : Integer := F(@dots{});
11299               for X'Address use Y;
11300
11301   22.f   This allows the expression ``Y'' to be safely
11302          evaluated before X is created.
11303
11304   22.g   The constant could be a formal parameter of mode in.
11305
11306   22.h   An implementation can support other nonstatic
11307          expressions if it wants to.  Expressions of type
11308          Address are hardly ever static, but their value
11309          might be known at compile time anyway in many
11310          cases.
11311 @end display
11312
11313 @noindent
11314 GNAT does indeed permit many additional cases of non-static expressions.  In
11315 particular, if the type involved is elementary there are no restrictions
11316 (since in this case, holding a temporary copy of the initialization value,
11317 if one is present, is inexpensive).  In addition, if there is no implicit or
11318 explicit initialization, then there are no restrictions.  GNAT will reject
11319 only the case where all three of these conditions hold:
11320
11321 @itemize @bullet
11322
11323 @item
11324 The type of the item is non-elementary (e.g.@: a record or array).
11325
11326 @item
11327 There is explicit or implicit initialization required for the object.
11328 Note that access values are always implicitly initialized, and also
11329 in GNAT, certain bit-packed arrays (those having a dynamic length or
11330 a length greater than 64) will also be implicitly initialized to zero.
11331
11332 @item
11333 The address value is non-static.  Here GNAT is more permissive than the
11334 RM, and allows the address value to be the address of a previously declared
11335 stand-alone variable, as long as it does not itself have an address clause.
11336
11337 @smallexample @c ada
11338            Anchor  : Some_Initialized_Type;
11339            Overlay : Some_Initialized_Type;
11340            for Overlay'Address use Anchor'Address;
11341 @end smallexample
11342
11343 @noindent
11344 However, the prefix of the address clause cannot be an array component, or
11345 a component of a discriminated record.
11346
11347 @end itemize
11348
11349 @noindent
11350 As noted above in section 22.h, address values are typically non-static.  In
11351 particular the To_Address function, even if applied to a literal value, is
11352 a non-static function call.  To avoid this minor annoyance, GNAT provides
11353 the implementation defined attribute 'To_Address.  The following two
11354 expressions have identical values:
11355
11356 @findex Attribute
11357 @findex To_Address
11358 @smallexample @c ada
11359    To_Address (16#1234_0000#)
11360    System'To_Address (16#1234_0000#);
11361 @end smallexample
11362
11363 @noindent
11364 except that the second form is considered to be a static expression, and
11365 thus when used as an address clause value is always permitted.
11366
11367 @noindent
11368 Additionally, GNAT treats as static an address clause that is an
11369 unchecked_conversion of a static integer value.  This simplifies the porting
11370 of legacy code, and provides a portable equivalent to the GNAT attribute
11371 @code{To_Address}.
11372
11373 Another issue with address clauses is the interaction with alignment
11374 requirements.  When an address clause is given for an object, the address
11375 value must be consistent with the alignment of the object (which is usually
11376 the same as the alignment of the type of the object).  If an address clause
11377 is given that specifies an inappropriately aligned address value, then the
11378 program execution is erroneous.
11379
11380 Since this source of erroneous behavior can have unfortunate effects, GNAT
11381 checks (at compile time if possible, generating a warning, or at execution
11382 time with a run-time check) that the alignment is appropriate.  If the
11383 run-time check fails, then @code{Program_Error} is raised.  This run-time
11384 check is suppressed if range checks are suppressed, or if the special GNAT
11385 check Alignment_Check is suppressed, or if
11386 @code{pragma Restrictions (No_Elaboration_Code)} is in effect.
11387
11388 Finally, GNAT does not permit overlaying of objects of controlled types or
11389 composite types containing a controlled component. In most cases, the compiler
11390 can detect an attempt at such overlays and will generate a warning at compile
11391 time and a Program_Error exception at run time.
11392
11393 @findex Export
11394 An address clause cannot be given for an exported object.  More
11395 understandably the real restriction is that objects with an address
11396 clause cannot be exported.  This is because such variables are not
11397 defined by the Ada program, so there is no external object to export.
11398
11399 @findex Import
11400 It is permissible to give an address clause and a pragma Import for the
11401 same object.  In this case, the variable is not really defined by the
11402 Ada program, so there is no external symbol to be linked.  The link name
11403 and the external name are ignored in this case.  The reason that we allow this
11404 combination is that it provides a useful idiom to avoid unwanted
11405 initializations on objects with address clauses.
11406
11407 When an address clause is given for an object that has implicit or
11408 explicit initialization, then by default initialization takes place.  This
11409 means that the effect of the object declaration is to overwrite the
11410 memory at the specified address.  This is almost always not what the
11411 programmer wants, so GNAT will output a warning:
11412
11413 @smallexample
11414   with System;
11415   package G is
11416      type R is record
11417         M : Integer := 0;
11418      end record;
11419
11420      Ext : R;
11421      for Ext'Address use System'To_Address (16#1234_1234#);
11422          |
11423   >>> warning: implicit initialization of "Ext" may
11424       modify overlaid storage
11425   >>> warning: use pragma Import for "Ext" to suppress
11426       initialization (RM B(24))
11427
11428   end G;
11429 @end smallexample
11430
11431 @noindent
11432 As indicated by the warning message, the solution is to use a (dummy) pragma
11433 Import to suppress this initialization.  The pragma tell the compiler that the
11434 object is declared and initialized elsewhere.  The following package compiles
11435 without warnings (and the initialization is suppressed):
11436
11437 @smallexample @c ada
11438    with System;
11439    package G is
11440       type R is record
11441          M : Integer := 0;
11442       end record;
11443
11444       Ext : R;
11445       for Ext'Address use System'To_Address (16#1234_1234#);
11446       pragma Import (Ada, Ext);
11447    end G;
11448 @end smallexample
11449
11450 @noindent
11451 A final issue with address clauses involves their use for overlaying
11452 variables, as in the following example:
11453 @cindex Overlaying of objects
11454
11455 @smallexample @c ada
11456   A : Integer;
11457   B : Integer;
11458   for B'Address use A'Address;
11459 @end smallexample
11460
11461 @noindent
11462 or alternatively, using the form recommended by the RM:
11463
11464 @smallexample @c ada
11465   A    : Integer;
11466   Addr : constant Address := A'Address;
11467   B    : Integer;
11468   for B'Address use Addr;
11469 @end smallexample
11470
11471 @noindent
11472 In both of these cases, @code{A}
11473 and @code{B} become aliased to one another via the
11474 address clause. This use of address clauses to overlay
11475 variables, achieving an effect similar to unchecked
11476 conversion was erroneous in Ada 83, but in Ada 95 and Ada 2005
11477 the effect is implementation defined. Furthermore, the
11478 Ada RM specifically recommends that in a situation
11479 like this, @code{B} should be subject to the following
11480 implementation advice (RM 13.3(19)):
11481
11482 @quotation
11483 19  If the Address of an object is specified, or it is imported
11484     or exported, then the implementation should not perform
11485     optimizations based on assumptions of no aliases.
11486 @end quotation
11487
11488 @noindent
11489 GNAT follows this recommendation, and goes further by also applying
11490 this recommendation to the overlaid variable (@code{A}
11491 in the above example) in this case. This means that the overlay
11492 works "as expected", in that a modification to one of the variables
11493 will affect the value of the other.
11494
11495 @node Effect of Convention on Representation
11496 @section Effect of Convention on Representation
11497 @cindex Convention, effect on representation
11498
11499 @noindent
11500 Normally the specification of a foreign language convention for a type or
11501 an object has no effect on the chosen representation.  In particular, the
11502 representation chosen for data in GNAT generally meets the standard system
11503 conventions, and for example records are laid out in a manner that is
11504 consistent with C@.  This means that specifying convention C (for example)
11505 has no effect.
11506
11507 There are four exceptions to this general rule:
11508
11509 @itemize @bullet
11510
11511 @item Convention Fortran and array subtypes
11512 If pragma Convention Fortran is specified for an array subtype, then in
11513 accordance with the implementation advice in section 3.6.2(11) of the
11514 Ada Reference Manual, the array will be stored in a Fortran-compatible
11515 column-major manner, instead of the normal default row-major order.
11516
11517 @item Convention C and enumeration types
11518 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
11519 to accommodate all values of the type.  For example, for the enumeration
11520 type declared by:
11521
11522 @smallexample @c ada
11523    type Color is (Red, Green, Blue);
11524 @end smallexample
11525
11526 @noindent
11527 8 bits is sufficient to store all values of the type, so by default, objects
11528 of type @code{Color} will be represented using 8 bits.  However, normal C
11529 convention is to use 32 bits for all enum values in C, since enum values
11530 are essentially of type int.  If pragma @code{Convention C} is specified for an
11531 Ada enumeration type, then the size is modified as necessary (usually to
11532 32 bits) to be consistent with the C convention for enum values.
11533
11534 Note that this treatment applies only to types. If Convention C is given for
11535 an enumeration object, where the enumeration type is not Convention C, then
11536 Object_Size bits are allocated. For example, for a normal enumeration type,
11537 with less than 256 elements, only 8 bits will be allocated for the object.
11538 Since this may be a surprise in terms of what C expects, GNAT will issue a
11539 warning in this situation. The warning can be suppressed by giving an explicit
11540 size clause specifying the desired size.
11541
11542 @item Convention C/Fortran and Boolean types
11543 In C, the usual convention for boolean values, that is values used for
11544 conditions, is that zero represents false, and nonzero values represent
11545 true.  In Ada, the normal convention is that two specific values, typically
11546 0/1, are used to represent false/true respectively.
11547
11548 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
11549 value represents true).
11550
11551 To accommodate the Fortran and C conventions, if a pragma Convention specifies
11552 C or Fortran convention for a derived Boolean, as in the following example:
11553
11554 @smallexample @c ada
11555    type C_Switch is new Boolean;
11556    pragma Convention (C, C_Switch);
11557 @end smallexample
11558
11559 @noindent
11560 then the GNAT generated code will treat any nonzero value as true.  For truth
11561 values generated by GNAT, the conventional value 1 will be used for True, but
11562 when one of these values is read, any nonzero value is treated as True.
11563
11564 @item Access types on OpenVMS
11565 For 64-bit OpenVMS systems, access types (other than those for unconstrained
11566 arrays) are 64-bits long. An exception to this rule is for the case of
11567 C-convention access types where there is no explicit size clause present (or
11568 inherited for derived types). In this case, GNAT chooses to make these
11569 pointers 32-bits, which provides an easier path for migration of 32-bit legacy
11570 code. size clause specifying 64-bits must be used to obtain a 64-bit pointer.
11571
11572 @end itemize
11573
11574 @node Determining the Representations chosen by GNAT
11575 @section Determining the Representations chosen by GNAT
11576 @cindex Representation, determination of
11577 @cindex @option{-gnatR} switch
11578
11579 @noindent
11580 Although the descriptions in this section are intended to be complete, it is
11581 often easier to simply experiment to see what GNAT accepts and what the
11582 effect is on the layout of types and objects.
11583
11584 As required by the Ada RM, if a representation clause is not accepted, then
11585 it must be rejected as illegal by the compiler.  However, when a
11586 representation clause or pragma is accepted, there can still be questions
11587 of what the compiler actually does.  For example, if a partial record
11588 representation clause specifies the location of some components and not
11589 others, then where are the non-specified components placed? Or if pragma
11590 @code{Pack} is used on a record, then exactly where are the resulting
11591 fields placed? The section on pragma @code{Pack} in this chapter can be
11592 used to answer the second question, but it is often easier to just see
11593 what the compiler does.
11594
11595 For this purpose, GNAT provides the option @option{-gnatR}.  If you compile
11596 with this option, then the compiler will output information on the actual
11597 representations chosen, in a format similar to source representation
11598 clauses.  For example, if we compile the package:
11599
11600 @smallexample @c ada
11601 package q is
11602    type r (x : boolean) is tagged record
11603       case x is
11604          when True => S : String (1 .. 100);
11605          when False => null;
11606       end case;
11607    end record;
11608
11609    type r2 is new r (false) with record
11610       y2 : integer;
11611    end record;
11612
11613    for r2 use record
11614       y2 at 16 range 0 .. 31;
11615    end record;
11616
11617    type x is record
11618       y : character;
11619    end record;
11620
11621    type x1 is array (1 .. 10) of x;
11622    for x1'component_size use 11;
11623
11624    type ia is access integer;
11625
11626    type Rb1 is array (1 .. 13) of Boolean;
11627    pragma Pack (rb1);
11628
11629    type Rb2 is array (1 .. 65) of Boolean;
11630    pragma Pack (rb2);
11631
11632    type x2 is record
11633       l1 : Boolean;
11634       l2 : Duration;
11635       l3 : Float;
11636       l4 : Boolean;
11637       l5 : Rb1;
11638       l6 : Rb2;
11639    end record;
11640    pragma Pack (x2);
11641 end q;
11642 @end smallexample
11643
11644 @noindent
11645 using the switch @option{-gnatR} we obtain the following output:
11646
11647 @smallexample
11648 Representation information for unit q
11649 -------------------------------------
11650
11651 for r'Size use ??;
11652 for r'Alignment use 4;
11653 for r use record
11654    x    at 4 range  0 .. 7;
11655    _tag at 0 range  0 .. 31;
11656    s    at 5 range  0 .. 799;
11657 end record;
11658
11659 for r2'Size use 160;
11660 for r2'Alignment use 4;
11661 for r2 use record
11662    x       at  4 range  0 .. 7;
11663    _tag    at  0 range  0 .. 31;
11664    _parent at  0 range  0 .. 63;
11665    y2      at 16 range  0 .. 31;
11666 end record;
11667
11668 for x'Size use 8;
11669 for x'Alignment use 1;
11670 for x use record
11671    y at 0 range  0 .. 7;
11672 end record;
11673
11674 for x1'Size use 112;
11675 for x1'Alignment use 1;
11676 for x1'Component_Size use 11;
11677
11678 for rb1'Size use 13;
11679 for rb1'Alignment use 2;
11680 for rb1'Component_Size use 1;
11681
11682 for rb2'Size use 72;
11683 for rb2'Alignment use 1;
11684 for rb2'Component_Size use 1;
11685
11686 for x2'Size use 224;
11687 for x2'Alignment use 4;
11688 for x2 use record
11689    l1 at  0 range  0 .. 0;
11690    l2 at  0 range  1 .. 64;
11691    l3 at 12 range  0 .. 31;
11692    l4 at 16 range  0 .. 0;
11693    l5 at 16 range  1 .. 13;
11694    l6 at 18 range  0 .. 71;
11695 end record;
11696 @end smallexample
11697
11698 @noindent
11699 The Size values are actually the Object_Size, i.e.@: the default size that
11700 will be allocated for objects of the type.
11701 The ?? size for type r indicates that we have a variant record, and the
11702 actual size of objects will depend on the discriminant value.
11703
11704 The Alignment values show the actual alignment chosen by the compiler
11705 for each record or array type.
11706
11707 The record representation clause for type r shows where all fields
11708 are placed, including the compiler generated tag field (whose location
11709 cannot be controlled by the programmer).
11710
11711 The record representation clause for the type extension r2 shows all the
11712 fields present, including the parent field, which is a copy of the fields
11713 of the parent type of r2, i.e.@: r1.
11714
11715 The component size and size clauses for types rb1 and rb2 show
11716 the exact effect of pragma @code{Pack} on these arrays, and the record
11717 representation clause for type x2 shows how pragma @code{Pack} affects
11718 this record type.
11719
11720 In some cases, it may be useful to cut and paste the representation clauses
11721 generated by the compiler into the original source to fix and guarantee
11722 the actual representation to be used.
11723
11724 @node Standard Library Routines
11725 @chapter Standard Library Routines
11726
11727 @noindent
11728 The Ada Reference Manual contains in Annex A a full description of an
11729 extensive set of standard library routines that can be used in any Ada
11730 program, and which must be provided by all Ada compilers.  They are
11731 analogous to the standard C library used by C programs.
11732
11733 GNAT implements all of the facilities described in annex A, and for most
11734 purposes the description in the Ada Reference Manual, or appropriate Ada
11735 text book, will be sufficient for making use of these facilities.
11736
11737 In the case of the input-output facilities,
11738 @xref{The Implementation of Standard I/O},
11739 gives details on exactly how GNAT interfaces to the
11740 file system.  For the remaining packages, the Ada Reference Manual
11741 should be sufficient.  The following is a list of the packages included,
11742 together with a brief description of the functionality that is provided.
11743
11744 For completeness, references are included to other predefined library
11745 routines defined in other sections of the Ada Reference Manual (these are
11746 cross-indexed from Annex A).
11747
11748 @table @code
11749 @item Ada (A.2)
11750 This is a parent package for all the standard library packages.  It is
11751 usually included implicitly in your program, and itself contains no
11752 useful data or routines.
11753
11754 @item Ada.Calendar (9.6)
11755 @code{Calendar} provides time of day access, and routines for
11756 manipulating times and durations.
11757
11758 @item Ada.Characters (A.3.1)
11759 This is a dummy parent package that contains no useful entities
11760
11761 @item Ada.Characters.Handling (A.3.2)
11762 This package provides some basic character handling capabilities,
11763 including classification functions for classes of characters (e.g.@: test
11764 for letters, or digits).
11765
11766 @item Ada.Characters.Latin_1 (A.3.3)
11767 This package includes a complete set of definitions of the characters
11768 that appear in type CHARACTER@.  It is useful for writing programs that
11769 will run in international environments.  For example, if you want an
11770 upper case E with an acute accent in a string, it is often better to use
11771 the definition of @code{UC_E_Acute} in this package.  Then your program
11772 will print in an understandable manner even if your environment does not
11773 support these extended characters.
11774
11775 @item Ada.Command_Line (A.15)
11776 This package provides access to the command line parameters and the name
11777 of the current program (analogous to the use of @code{argc} and @code{argv}
11778 in C), and also allows the exit status for the program to be set in a
11779 system-independent manner.
11780
11781 @item Ada.Decimal (F.2)
11782 This package provides constants describing the range of decimal numbers
11783 implemented, and also a decimal divide routine (analogous to the COBOL
11784 verb DIVIDE @dots{} GIVING @dots{} REMAINDER @dots{})
11785
11786 @item Ada.Direct_IO (A.8.4)
11787 This package provides input-output using a model of a set of records of
11788 fixed-length, containing an arbitrary definite Ada type, indexed by an
11789 integer record number.
11790
11791 @item Ada.Dynamic_Priorities (D.5)
11792 This package allows the priorities of a task to be adjusted dynamically
11793 as the task is running.
11794
11795 @item Ada.Exceptions (11.4.1)
11796 This package provides additional information on exceptions, and also
11797 contains facilities for treating exceptions as data objects, and raising
11798 exceptions with associated messages.
11799
11800 @item Ada.Finalization (7.6)
11801 This package contains the declarations and subprograms to support the
11802 use of controlled types, providing for automatic initialization and
11803 finalization (analogous to the constructors and destructors of C++)
11804
11805 @item Ada.Interrupts (C.3.2)
11806 This package provides facilities for interfacing to interrupts, which
11807 includes the set of signals or conditions that can be raised and
11808 recognized as interrupts.
11809
11810 @item Ada.Interrupts.Names (C.3.2)
11811 This package provides the set of interrupt names (actually signal
11812 or condition names) that can be handled by GNAT@.
11813
11814 @item Ada.IO_Exceptions (A.13)
11815 This package defines the set of exceptions that can be raised by use of
11816 the standard IO packages.
11817
11818 @item Ada.Numerics
11819 This package contains some standard constants and exceptions used
11820 throughout the numerics packages.  Note that the constants pi and e are
11821 defined here, and it is better to use these definitions than rolling
11822 your own.
11823
11824 @item Ada.Numerics.Complex_Elementary_Functions
11825 Provides the implementation of standard elementary functions (such as
11826 log and trigonometric functions) operating on complex numbers using the
11827 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
11828 created by the package @code{Numerics.Complex_Types}.
11829
11830 @item Ada.Numerics.Complex_Types
11831 This is a predefined instantiation of
11832 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
11833 build the type @code{Complex} and @code{Imaginary}.
11834
11835 @item Ada.Numerics.Discrete_Random
11836 This package provides a random number generator suitable for generating
11837 random integer values from a specified range.
11838
11839 @item Ada.Numerics.Float_Random
11840 This package provides a random number generator suitable for generating
11841 uniformly distributed floating point values.
11842
11843 @item Ada.Numerics.Generic_Complex_Elementary_Functions
11844 This is a generic version of the package that provides the
11845 implementation of standard elementary functions (such as log and
11846 trigonometric functions) for an arbitrary complex type.
11847
11848 The following predefined instantiations of this package are provided:
11849
11850 @table @code
11851 @item Short_Float
11852 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
11853 @item Float
11854 @code{Ada.Numerics.Complex_Elementary_Functions}
11855 @item Long_Float
11856 @code{Ada.Numerics.Long_Complex_Elementary_Functions}
11857 @end table
11858
11859 @item Ada.Numerics.Generic_Complex_Types
11860 This is a generic package that allows the creation of complex types,
11861 with associated complex arithmetic operations.
11862
11863 The following predefined instantiations of this package exist
11864 @table @code
11865 @item Short_Float
11866 @code{Ada.Numerics.Short_Complex_Complex_Types}
11867 @item Float
11868 @code{Ada.Numerics.Complex_Complex_Types}
11869 @item Long_Float
11870 @code{Ada.Numerics.Long_Complex_Complex_Types}
11871 @end table
11872
11873 @item Ada.Numerics.Generic_Elementary_Functions
11874 This is a generic package that provides the implementation of standard
11875 elementary functions (such as log an trigonometric functions) for an
11876 arbitrary float type.
11877
11878 The following predefined instantiations of this package exist
11879
11880 @table @code
11881 @item Short_Float
11882 @code{Ada.Numerics.Short_Elementary_Functions}
11883 @item Float
11884 @code{Ada.Numerics.Elementary_Functions}
11885 @item Long_Float
11886 @code{Ada.Numerics.Long_Elementary_Functions}
11887 @end table
11888
11889 @item Ada.Real_Time (D.8)
11890 This package provides facilities similar to those of @code{Calendar}, but
11891 operating with a finer clock suitable for real time control. Note that
11892 annex D requires that there be no backward clock jumps, and GNAT generally
11893 guarantees this behavior, but of course if the external clock on which
11894 the GNAT runtime depends is deliberately reset by some external event,
11895 then such a backward jump may occur.
11896
11897 @item Ada.Sequential_IO (A.8.1)
11898 This package provides input-output facilities for sequential files,
11899 which can contain a sequence of values of a single type, which can be
11900 any Ada type, including indefinite (unconstrained) types.
11901
11902 @item Ada.Storage_IO (A.9)
11903 This package provides a facility for mapping arbitrary Ada types to and
11904 from a storage buffer.  It is primarily intended for the creation of new
11905 IO packages.
11906
11907 @item Ada.Streams (13.13.1)
11908 This is a generic package that provides the basic support for the
11909 concept of streams as used by the stream attributes (@code{Input},
11910 @code{Output}, @code{Read} and @code{Write}).
11911
11912 @item Ada.Streams.Stream_IO (A.12.1)
11913 This package is a specialization of the type @code{Streams} defined in
11914 package @code{Streams} together with a set of operations providing
11915 Stream_IO capability.  The Stream_IO model permits both random and
11916 sequential access to a file which can contain an arbitrary set of values
11917 of one or more Ada types.
11918
11919 @item Ada.Strings (A.4.1)
11920 This package provides some basic constants used by the string handling
11921 packages.
11922
11923 @item Ada.Strings.Bounded (A.4.4)
11924 This package provides facilities for handling variable length
11925 strings.  The bounded model requires a maximum length.  It is thus
11926 somewhat more limited than the unbounded model, but avoids the use of
11927 dynamic allocation or finalization.
11928
11929 @item Ada.Strings.Fixed (A.4.3)
11930 This package provides facilities for handling fixed length strings.
11931
11932 @item Ada.Strings.Maps (A.4.2)
11933 This package provides facilities for handling character mappings and
11934 arbitrarily defined subsets of characters.  For instance it is useful in
11935 defining specialized translation tables.
11936
11937 @item Ada.Strings.Maps.Constants (A.4.6)
11938 This package provides a standard set of predefined mappings and
11939 predefined character sets.  For example, the standard upper to lower case
11940 conversion table is found in this package.  Note that upper to lower case
11941 conversion is non-trivial if you want to take the entire set of
11942 characters, including extended characters like E with an acute accent,
11943 into account.  You should use the mappings in this package (rather than
11944 adding 32 yourself) to do case mappings.
11945
11946 @item Ada.Strings.Unbounded (A.4.5)
11947 This package provides facilities for handling variable length
11948 strings.  The unbounded model allows arbitrary length strings, but
11949 requires the use of dynamic allocation and finalization.
11950
11951 @item Ada.Strings.Wide_Bounded (A.4.7)
11952 @itemx Ada.Strings.Wide_Fixed (A.4.7)
11953 @itemx Ada.Strings.Wide_Maps (A.4.7)
11954 @itemx Ada.Strings.Wide_Maps.Constants (A.4.7)
11955 @itemx Ada.Strings.Wide_Unbounded (A.4.7)
11956 These packages provide analogous capabilities to the corresponding
11957 packages without @samp{Wide_} in the name, but operate with the types
11958 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
11959 and @code{Character}.
11960
11961 @item Ada.Strings.Wide_Wide_Bounded (A.4.7)
11962 @itemx Ada.Strings.Wide_Wide_Fixed (A.4.7)
11963 @itemx Ada.Strings.Wide_Wide_Maps (A.4.7)
11964 @itemx Ada.Strings.Wide_Wide_Maps.Constants (A.4.7)
11965 @itemx Ada.Strings.Wide_Wide_Unbounded (A.4.7)
11966 These packages provide analogous capabilities to the corresponding
11967 packages without @samp{Wide_} in the name, but operate with the types
11968 @code{Wide_Wide_String} and @code{Wide_Wide_Character} instead
11969 of @code{String} and @code{Character}.
11970
11971 @item Ada.Synchronous_Task_Control (D.10)
11972 This package provides some standard facilities for controlling task
11973 communication in a synchronous manner.
11974
11975 @item Ada.Tags
11976 This package contains definitions for manipulation of the tags of tagged
11977 values.
11978
11979 @item Ada.Task_Attributes
11980 This package provides the capability of associating arbitrary
11981 task-specific data with separate tasks.
11982
11983 @item Ada.Text_IO
11984 This package provides basic text input-output capabilities for
11985 character, string and numeric data.  The subpackages of this
11986 package are listed next.
11987
11988 @item Ada.Text_IO.Decimal_IO
11989 Provides input-output facilities for decimal fixed-point types
11990
11991 @item Ada.Text_IO.Enumeration_IO
11992 Provides input-output facilities for enumeration types.
11993
11994 @item Ada.Text_IO.Fixed_IO
11995 Provides input-output facilities for ordinary fixed-point types.
11996
11997 @item Ada.Text_IO.Float_IO
11998 Provides input-output facilities for float types.  The following
11999 predefined instantiations of this generic package are available:
12000
12001 @table @code
12002 @item Short_Float
12003 @code{Short_Float_Text_IO}
12004 @item Float
12005 @code{Float_Text_IO}
12006 @item Long_Float
12007 @code{Long_Float_Text_IO}
12008 @end table
12009
12010 @item Ada.Text_IO.Integer_IO
12011 Provides input-output facilities for integer types.  The following
12012 predefined instantiations of this generic package are available:
12013
12014 @table @code
12015 @item Short_Short_Integer
12016 @code{Ada.Short_Short_Integer_Text_IO}
12017 @item Short_Integer
12018 @code{Ada.Short_Integer_Text_IO}
12019 @item Integer
12020 @code{Ada.Integer_Text_IO}
12021 @item Long_Integer
12022 @code{Ada.Long_Integer_Text_IO}
12023 @item Long_Long_Integer
12024 @code{Ada.Long_Long_Integer_Text_IO}
12025 @end table
12026
12027 @item Ada.Text_IO.Modular_IO
12028 Provides input-output facilities for modular (unsigned) types
12029
12030 @item Ada.Text_IO.Complex_IO (G.1.3)
12031 This package provides basic text input-output capabilities for complex
12032 data.
12033
12034 @item Ada.Text_IO.Editing (F.3.3)
12035 This package contains routines for edited output, analogous to the use
12036 of pictures in COBOL@.  The picture formats used by this package are a
12037 close copy of the facility in COBOL@.
12038
12039 @item Ada.Text_IO.Text_Streams (A.12.2)
12040 This package provides a facility that allows Text_IO files to be treated
12041 as streams, so that the stream attributes can be used for writing
12042 arbitrary data, including binary data, to Text_IO files.
12043
12044 @item Ada.Unchecked_Conversion (13.9)
12045 This generic package allows arbitrary conversion from one type to
12046 another of the same size, providing for breaking the type safety in
12047 special circumstances.
12048
12049 If the types have the same Size (more accurately the same Value_Size),
12050 then the effect is simply to transfer the bits from the source to the
12051 target type without any modification.  This usage is well defined, and
12052 for simple types whose representation is typically the same across
12053 all implementations, gives a portable method of performing such
12054 conversions.
12055
12056 If the types do not have the same size, then the result is implementation
12057 defined, and thus may be non-portable.  The following describes how GNAT
12058 handles such unchecked conversion cases.
12059
12060 If the types are of different sizes, and are both discrete types, then
12061 the effect is of a normal type conversion without any constraint checking.
12062 In particular if the result type has a larger size, the result will be
12063 zero or sign extended.  If the result type has a smaller size, the result
12064 will be truncated by ignoring high order bits.
12065
12066 If the types are of different sizes, and are not both discrete types,
12067 then the conversion works as though pointers were created to the source
12068 and target, and the pointer value is converted.  The effect is that bits
12069 are copied from successive low order storage units and bits of the source
12070 up to the length of the target type.
12071
12072 A warning is issued if the lengths differ, since the effect in this
12073 case is implementation dependent, and the above behavior may not match
12074 that of some other compiler.
12075
12076 A pointer to one type may be converted to a pointer to another type using
12077 unchecked conversion.  The only case in which the effect is undefined is
12078 when one or both pointers are pointers to unconstrained array types.  In
12079 this case, the bounds information may get incorrectly transferred, and in
12080 particular, GNAT uses double size pointers for such types, and it is
12081 meaningless to convert between such pointer types.  GNAT will issue a
12082 warning if the alignment of the target designated type is more strict
12083 than the alignment of the source designated type (since the result may
12084 be unaligned in this case).
12085
12086 A pointer other than a pointer to an unconstrained array type may be
12087 converted to and from System.Address.  Such usage is common in Ada 83
12088 programs, but note that Ada.Address_To_Access_Conversions is the
12089 preferred method of performing such conversions in Ada 95 and Ada 2005.
12090 Neither
12091 unchecked conversion nor Ada.Address_To_Access_Conversions should be
12092 used in conjunction with pointers to unconstrained objects, since
12093 the bounds information cannot be handled correctly in this case.
12094
12095 @item Ada.Unchecked_Deallocation (13.11.2)
12096 This generic package allows explicit freeing of storage previously
12097 allocated by use of an allocator.
12098
12099 @item Ada.Wide_Text_IO (A.11)
12100 This package is similar to @code{Ada.Text_IO}, except that the external
12101 file supports wide character representations, and the internal types are
12102 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
12103 and @code{String}.  It contains generic subpackages listed next.
12104
12105 @item Ada.Wide_Text_IO.Decimal_IO
12106 Provides input-output facilities for decimal fixed-point types
12107
12108 @item Ada.Wide_Text_IO.Enumeration_IO
12109 Provides input-output facilities for enumeration types.
12110
12111 @item Ada.Wide_Text_IO.Fixed_IO
12112 Provides input-output facilities for ordinary fixed-point types.
12113
12114 @item Ada.Wide_Text_IO.Float_IO
12115 Provides input-output facilities for float types.  The following
12116 predefined instantiations of this generic package are available:
12117
12118 @table @code
12119 @item Short_Float
12120 @code{Short_Float_Wide_Text_IO}
12121 @item Float
12122 @code{Float_Wide_Text_IO}
12123 @item Long_Float
12124 @code{Long_Float_Wide_Text_IO}
12125 @end table
12126
12127 @item Ada.Wide_Text_IO.Integer_IO
12128 Provides input-output facilities for integer types.  The following
12129 predefined instantiations of this generic package are available:
12130
12131 @table @code
12132 @item Short_Short_Integer
12133 @code{Ada.Short_Short_Integer_Wide_Text_IO}
12134 @item Short_Integer
12135 @code{Ada.Short_Integer_Wide_Text_IO}
12136 @item Integer
12137 @code{Ada.Integer_Wide_Text_IO}
12138 @item Long_Integer
12139 @code{Ada.Long_Integer_Wide_Text_IO}
12140 @item Long_Long_Integer
12141 @code{Ada.Long_Long_Integer_Wide_Text_IO}
12142 @end table
12143
12144 @item Ada.Wide_Text_IO.Modular_IO
12145 Provides input-output facilities for modular (unsigned) types
12146
12147 @item Ada.Wide_Text_IO.Complex_IO (G.1.3)
12148 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
12149 external file supports wide character representations.
12150
12151 @item Ada.Wide_Text_IO.Editing (F.3.4)
12152 This package is similar to @code{Ada.Text_IO.Editing}, except that the
12153 types are @code{Wide_Character} and @code{Wide_String} instead of
12154 @code{Character} and @code{String}.
12155
12156 @item Ada.Wide_Text_IO.Streams (A.12.3)
12157 This package is similar to @code{Ada.Text_IO.Streams}, except that the
12158 types are @code{Wide_Character} and @code{Wide_String} instead of
12159 @code{Character} and @code{String}.
12160
12161 @item Ada.Wide_Wide_Text_IO (A.11)
12162 This package is similar to @code{Ada.Text_IO}, except that the external
12163 file supports wide character representations, and the internal types are
12164 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
12165 and @code{String}.  It contains generic subpackages listed next.
12166
12167 @item Ada.Wide_Wide_Text_IO.Decimal_IO
12168 Provides input-output facilities for decimal fixed-point types
12169
12170 @item Ada.Wide_Wide_Text_IO.Enumeration_IO
12171 Provides input-output facilities for enumeration types.
12172
12173 @item Ada.Wide_Wide_Text_IO.Fixed_IO
12174 Provides input-output facilities for ordinary fixed-point types.
12175
12176 @item Ada.Wide_Wide_Text_IO.Float_IO
12177 Provides input-output facilities for float types.  The following
12178 predefined instantiations of this generic package are available:
12179
12180 @table @code
12181 @item Short_Float
12182 @code{Short_Float_Wide_Wide_Text_IO}
12183 @item Float
12184 @code{Float_Wide_Wide_Text_IO}
12185 @item Long_Float
12186 @code{Long_Float_Wide_Wide_Text_IO}
12187 @end table
12188
12189 @item Ada.Wide_Wide_Text_IO.Integer_IO
12190 Provides input-output facilities for integer types.  The following
12191 predefined instantiations of this generic package are available:
12192
12193 @table @code
12194 @item Short_Short_Integer
12195 @code{Ada.Short_Short_Integer_Wide_Wide_Text_IO}
12196 @item Short_Integer
12197 @code{Ada.Short_Integer_Wide_Wide_Text_IO}
12198 @item Integer
12199 @code{Ada.Integer_Wide_Wide_Text_IO}
12200 @item Long_Integer
12201 @code{Ada.Long_Integer_Wide_Wide_Text_IO}
12202 @item Long_Long_Integer
12203 @code{Ada.Long_Long_Integer_Wide_Wide_Text_IO}
12204 @end table
12205
12206 @item Ada.Wide_Wide_Text_IO.Modular_IO
12207 Provides input-output facilities for modular (unsigned) types
12208
12209 @item Ada.Wide_Wide_Text_IO.Complex_IO (G.1.3)
12210 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
12211 external file supports wide character representations.
12212
12213 @item Ada.Wide_Wide_Text_IO.Editing (F.3.4)
12214 This package is similar to @code{Ada.Text_IO.Editing}, except that the
12215 types are @code{Wide_Character} and @code{Wide_String} instead of
12216 @code{Character} and @code{String}.
12217
12218 @item Ada.Wide_Wide_Text_IO.Streams (A.12.3)
12219 This package is similar to @code{Ada.Text_IO.Streams}, except that the
12220 types are @code{Wide_Character} and @code{Wide_String} instead of
12221 @code{Character} and @code{String}.
12222 @end table
12223
12224
12225
12226 @node The Implementation of Standard I/O
12227 @chapter The Implementation of Standard I/O
12228
12229 @noindent
12230 GNAT implements all the required input-output facilities described in
12231 A.6 through A.14.  These sections of the Ada Reference Manual describe the
12232 required behavior of these packages from the Ada point of view, and if
12233 you are writing a portable Ada program that does not need to know the
12234 exact manner in which Ada maps to the outside world when it comes to
12235 reading or writing external files, then you do not need to read this
12236 chapter.  As long as your files are all regular files (not pipes or
12237 devices), and as long as you write and read the files only from Ada, the
12238 description in the Ada Reference Manual is sufficient.
12239
12240 However, if you want to do input-output to pipes or other devices, such
12241 as the keyboard or screen, or if the files you are dealing with are
12242 either generated by some other language, or to be read by some other
12243 language, then you need to know more about the details of how the GNAT
12244 implementation of these input-output facilities behaves.
12245
12246 In this chapter we give a detailed description of exactly how GNAT
12247 interfaces to the file system.  As always, the sources of the system are
12248 available to you for answering questions at an even more detailed level,
12249 but for most purposes the information in this chapter will suffice.
12250
12251 Another reason that you may need to know more about how input-output is
12252 implemented arises when you have a program written in mixed languages
12253 where, for example, files are shared between the C and Ada sections of
12254 the same program.  GNAT provides some additional facilities, in the form
12255 of additional child library packages, that facilitate this sharing, and
12256 these additional facilities are also described in this chapter.
12257
12258 @menu
12259 * Standard I/O Packages::
12260 * FORM Strings::
12261 * Direct_IO::
12262 * Sequential_IO::
12263 * Text_IO::
12264 * Wide_Text_IO::
12265 * Wide_Wide_Text_IO::
12266 * Stream_IO::
12267 * Text Translation::
12268 * Shared Files::
12269 * Filenames encoding::
12270 * Open Modes::
12271 * Operations on C Streams::
12272 * Interfacing to C Streams::
12273 @end menu
12274
12275 @node Standard I/O Packages
12276 @section Standard I/O Packages
12277
12278 @noindent
12279 The Standard I/O packages described in Annex A for
12280
12281 @itemize @bullet
12282 @item
12283 Ada.Text_IO
12284 @item
12285 Ada.Text_IO.Complex_IO
12286 @item
12287 Ada.Text_IO.Text_Streams
12288 @item
12289 Ada.Wide_Text_IO
12290 @item
12291 Ada.Wide_Text_IO.Complex_IO
12292 @item
12293 Ada.Wide_Text_IO.Text_Streams
12294 @item
12295 Ada.Wide_Wide_Text_IO
12296 @item
12297 Ada.Wide_Wide_Text_IO.Complex_IO
12298 @item
12299 Ada.Wide_Wide_Text_IO.Text_Streams
12300 @item
12301 Ada.Stream_IO
12302 @item
12303 Ada.Sequential_IO
12304 @item
12305 Ada.Direct_IO
12306 @end itemize
12307
12308 @noindent
12309 are implemented using the C
12310 library streams facility; where
12311
12312 @itemize @bullet
12313 @item
12314 All files are opened using @code{fopen}.
12315 @item
12316 All input/output operations use @code{fread}/@code{fwrite}.
12317 @end itemize
12318
12319 @noindent
12320 There is no internal buffering of any kind at the Ada library level. The only
12321 buffering is that provided at the system level in the implementation of the
12322 library routines that support streams. This facilitates shared use of these
12323 streams by mixed language programs. Note though that system level buffering is
12324 explicitly enabled at elaboration of the standard I/O packages and that can
12325 have an impact on mixed language programs, in particular those using I/O before
12326 calling the Ada elaboration routine (e.g.@: adainit). It is recommended to call
12327 the Ada elaboration routine before performing any I/O or when impractical,
12328 flush the common I/O streams and in particular Standard_Output before
12329 elaborating the Ada code.
12330
12331 @node FORM Strings
12332 @section FORM Strings
12333
12334 @noindent
12335 The format of a FORM string in GNAT is:
12336
12337 @smallexample
12338 "keyword=value,keyword=value,@dots{},keyword=value"
12339 @end smallexample
12340
12341 @noindent
12342 where letters may be in upper or lower case, and there are no spaces
12343 between values.  The order of the entries is not important.  Currently
12344 the following keywords defined.
12345
12346 @smallexample
12347 TEXT_TRANSLATION=[YES|NO]
12348 SHARED=[YES|NO]
12349 WCEM=[n|h|u|s|e|8|b]
12350 ENCODING=[UTF8|8BITS]
12351 @end smallexample
12352
12353 @noindent
12354 The use of these parameters is described later in this section.
12355
12356 @node Direct_IO
12357 @section Direct_IO
12358
12359 @noindent
12360 Direct_IO can only be instantiated for definite types.  This is a
12361 restriction of the Ada language, which means that the records are fixed
12362 length (the length being determined by @code{@var{type}'Size}, rounded
12363 up to the next storage unit boundary if necessary).
12364
12365 The records of a Direct_IO file are simply written to the file in index
12366 sequence, with the first record starting at offset zero, and subsequent
12367 records following.  There is no control information of any kind.  For
12368 example, if 32-bit integers are being written, each record takes
12369 4-bytes, so the record at index @var{K} starts at offset
12370 (@var{K}@minus{}1)*4.
12371
12372 There is no limit on the size of Direct_IO files, they are expanded as
12373 necessary to accommodate whatever records are written to the file.
12374
12375 @node Sequential_IO
12376 @section Sequential_IO
12377
12378 @noindent
12379 Sequential_IO may be instantiated with either a definite (constrained)
12380 or indefinite (unconstrained) type.
12381
12382 For the definite type case, the elements written to the file are simply
12383 the memory images of the data values with no control information of any
12384 kind.  The resulting file should be read using the same type, no validity
12385 checking is performed on input.
12386
12387 For the indefinite type case, the elements written consist of two
12388 parts.  First is the size of the data item, written as the memory image
12389 of a @code{Interfaces.C.size_t} value, followed by the memory image of
12390 the data value.  The resulting file can only be read using the same
12391 (unconstrained) type.  Normal assignment checks are performed on these
12392 read operations, and if these checks fail, @code{Data_Error} is
12393 raised.  In particular, in the array case, the lengths must match, and in
12394 the variant record case, if the variable for a particular read operation
12395 is constrained, the discriminants must match.
12396
12397 Note that it is not possible to use Sequential_IO to write variable
12398 length array items, and then read the data back into different length
12399 arrays.  For example, the following will raise @code{Data_Error}:
12400
12401 @smallexample @c ada
12402  package IO is new Sequential_IO (String);
12403  F : IO.File_Type;
12404  S : String (1..4);
12405  @dots{}
12406  IO.Create (F)
12407  IO.Write (F, "hello!")
12408  IO.Reset (F, Mode=>In_File);
12409  IO.Read (F, S);
12410  Put_Line (S);
12411
12412 @end smallexample
12413
12414 @noindent
12415 On some Ada implementations, this will print @code{hell}, but the program is
12416 clearly incorrect, since there is only one element in the file, and that
12417 element is the string @code{hello!}.
12418
12419 In Ada 95 and Ada 2005, this kind of behavior can be legitimately achieved
12420 using Stream_IO, and this is the preferred mechanism.  In particular, the
12421 above program fragment rewritten to use Stream_IO will work correctly.
12422
12423 @node Text_IO
12424 @section Text_IO
12425
12426 @noindent
12427 Text_IO files consist of a stream of characters containing the following
12428 special control characters:
12429
12430 @smallexample
12431 LF (line feed, 16#0A#) Line Mark
12432 FF (form feed, 16#0C#) Page Mark
12433 @end smallexample
12434
12435 @noindent
12436 A canonical Text_IO file is defined as one in which the following
12437 conditions are met:
12438
12439 @itemize @bullet
12440 @item
12441 The character @code{LF} is used only as a line mark, i.e.@: to mark the end
12442 of the line.
12443
12444 @item
12445 The character @code{FF} is used only as a page mark, i.e.@: to mark the
12446 end of a page and consequently can appear only immediately following a
12447 @code{LF} (line mark) character.
12448
12449 @item
12450 The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
12451 (line mark, page mark).  In the former case, the page mark is implicitly
12452 assumed to be present.
12453 @end itemize
12454
12455 @noindent
12456 A file written using Text_IO will be in canonical form provided that no
12457 explicit @code{LF} or @code{FF} characters are written using @code{Put}
12458 or @code{Put_Line}.  There will be no @code{FF} character at the end of
12459 the file unless an explicit @code{New_Page} operation was performed
12460 before closing the file.
12461
12462 A canonical Text_IO file that is a regular file (i.e., not a device or a
12463 pipe) can be read using any of the routines in Text_IO@.  The
12464 semantics in this case will be exactly as defined in the Ada Reference
12465 Manual, and all the routines in Text_IO are fully implemented.
12466
12467 A text file that does not meet the requirements for a canonical Text_IO
12468 file has one of the following:
12469
12470 @itemize @bullet
12471 @item
12472 The file contains @code{FF} characters not immediately following a
12473 @code{LF} character.
12474
12475 @item
12476 The file contains @code{LF} or @code{FF} characters written by
12477 @code{Put} or @code{Put_Line}, which are not logically considered to be
12478 line marks or page marks.
12479
12480 @item
12481 The file ends in a character other than @code{LF} or @code{FF},
12482 i.e.@: there is no explicit line mark or page mark at the end of the file.
12483 @end itemize
12484
12485 @noindent
12486 Text_IO can be used to read such non-standard text files but subprograms
12487 to do with line or page numbers do not have defined meanings.  In
12488 particular, a @code{FF} character that does not follow a @code{LF}
12489 character may or may not be treated as a page mark from the point of
12490 view of page and line numbering.  Every @code{LF} character is considered
12491 to end a line, and there is an implied @code{LF} character at the end of
12492 the file.
12493
12494 @menu
12495 * Text_IO Stream Pointer Positioning::
12496 * Text_IO Reading and Writing Non-Regular Files::
12497 * Get_Immediate::
12498 * Treating Text_IO Files as Streams::
12499 * Text_IO Extensions::
12500 * Text_IO Facilities for Unbounded Strings::
12501 @end menu
12502
12503 @node Text_IO Stream Pointer Positioning
12504 @subsection Stream Pointer Positioning
12505
12506 @noindent
12507 @code{Ada.Text_IO} has a definition of current position for a file that
12508 is being read.  No internal buffering occurs in Text_IO, and usually the
12509 physical position in the stream used to implement the file corresponds
12510 to this logical position defined by Text_IO@.  There are two exceptions:
12511
12512 @itemize @bullet
12513 @item
12514 After a call to @code{End_Of_Page} that returns @code{True}, the stream
12515 is positioned past the @code{LF} (line mark) that precedes the page
12516 mark.  Text_IO maintains an internal flag so that subsequent read
12517 operations properly handle the logical position which is unchanged by
12518 the @code{End_Of_Page} call.
12519
12520 @item
12521 After a call to @code{End_Of_File} that returns @code{True}, if the
12522 Text_IO file was positioned before the line mark at the end of file
12523 before the call, then the logical position is unchanged, but the stream
12524 is physically positioned right at the end of file (past the line mark,
12525 and past a possible page mark following the line mark.  Again Text_IO
12526 maintains internal flags so that subsequent read operations properly
12527 handle the logical position.
12528 @end itemize
12529
12530 @noindent
12531 These discrepancies have no effect on the observable behavior of
12532 Text_IO, but if a single Ada stream is shared between a C program and
12533 Ada program, or shared (using @samp{shared=yes} in the form string)
12534 between two Ada files, then the difference may be observable in some
12535 situations.
12536
12537 @node Text_IO Reading and Writing Non-Regular Files
12538 @subsection Reading and Writing Non-Regular Files
12539
12540 @noindent
12541 A non-regular file is a device (such as a keyboard), or a pipe.  Text_IO
12542 can be used for reading and writing.  Writing is not affected and the
12543 sequence of characters output is identical to the normal file case, but
12544 for reading, the behavior of Text_IO is modified to avoid undesirable
12545 look-ahead as follows:
12546
12547 An input file that is not a regular file is considered to have no page
12548 marks.  Any @code{Ascii.FF} characters (the character normally used for a
12549 page mark) appearing in the file are considered to be data
12550 characters.  In particular:
12551
12552 @itemize @bullet
12553 @item
12554 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
12555 following a line mark.  If a page mark appears, it will be treated as a
12556 data character.
12557
12558 @item
12559 This avoids the need to wait for an extra character to be typed or
12560 entered from the pipe to complete one of these operations.
12561
12562 @item
12563 @code{End_Of_Page} always returns @code{False}
12564
12565 @item
12566 @code{End_Of_File} will return @code{False} if there is a page mark at
12567 the end of the file.
12568 @end itemize
12569
12570 @noindent
12571 Output to non-regular files is the same as for regular files.  Page marks
12572 may be written to non-regular files using @code{New_Page}, but as noted
12573 above they will not be treated as page marks on input if the output is
12574 piped to another Ada program.
12575
12576 Another important discrepancy when reading non-regular files is that the end
12577 of file indication is not ``sticky''.  If an end of file is entered, e.g.@: by
12578 pressing the @key{EOT} key,
12579 then end of file
12580 is signaled once (i.e.@: the test @code{End_Of_File}
12581 will yield @code{True}, or a read will
12582 raise @code{End_Error}), but then reading can resume
12583 to read data past that end of
12584 file indication, until another end of file indication is entered.
12585
12586 @node Get_Immediate
12587 @subsection Get_Immediate
12588 @cindex Get_Immediate
12589
12590 @noindent
12591 Get_Immediate returns the next character (including control characters)
12592 from the input file.  In particular, Get_Immediate will return LF or FF
12593 characters used as line marks or page marks.  Such operations leave the
12594 file positioned past the control character, and it is thus not treated
12595 as having its normal function.  This means that page, line and column
12596 counts after this kind of Get_Immediate call are set as though the mark
12597 did not occur.  In the case where a Get_Immediate leaves the file
12598 positioned between the line mark and page mark (which is not normally
12599 possible), it is undefined whether the FF character will be treated as a
12600 page mark.
12601
12602 @node Treating Text_IO Files as Streams
12603 @subsection Treating Text_IO Files as Streams
12604 @cindex Stream files
12605
12606 @noindent
12607 The package @code{Text_IO.Streams} allows a Text_IO file to be treated
12608 as a stream.  Data written to a Text_IO file in this stream mode is
12609 binary data.  If this binary data contains bytes 16#0A# (@code{LF}) or
12610 16#0C# (@code{FF}), the resulting file may have non-standard
12611 format.  Similarly if read operations are used to read from a Text_IO
12612 file treated as a stream, then @code{LF} and @code{FF} characters may be
12613 skipped and the effect is similar to that described above for
12614 @code{Get_Immediate}.
12615
12616 @node Text_IO Extensions
12617 @subsection Text_IO Extensions
12618 @cindex Text_IO extensions
12619
12620 @noindent
12621 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
12622 to the standard @code{Text_IO} package:
12623
12624 @itemize @bullet
12625 @item function File_Exists (Name : String) return Boolean;
12626 Determines if a file of the given name exists.
12627
12628 @item function Get_Line return String;
12629 Reads a string from the standard input file.  The value returned is exactly
12630 the length of the line that was read.
12631
12632 @item function Get_Line (File : Ada.Text_IO.File_Type) return String;
12633 Similar, except that the parameter File specifies the file from which
12634 the string is to be read.
12635
12636 @end itemize
12637
12638 @node Text_IO Facilities for Unbounded Strings
12639 @subsection Text_IO Facilities for Unbounded Strings
12640 @cindex Text_IO for unbounded strings
12641 @cindex Unbounded_String, Text_IO operations
12642
12643 @noindent
12644 The package @code{Ada.Strings.Unbounded.Text_IO}
12645 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
12646 subprograms useful for Text_IO operations on unbounded strings:
12647
12648 @itemize @bullet
12649
12650 @item function Get_Line (File : File_Type) return Unbounded_String;
12651 Reads a line from the specified file
12652 and returns the result as an unbounded string.
12653
12654 @item procedure Put (File : File_Type; U : Unbounded_String);
12655 Writes the value of the given unbounded string to the specified file
12656 Similar to the effect of
12657 @code{Put (To_String (U))} except that an extra copy is avoided.
12658
12659 @item procedure Put_Line (File : File_Type; U : Unbounded_String);
12660 Writes the value of the given unbounded string to the specified file,
12661 followed by a @code{New_Line}.
12662 Similar to the effect of @code{Put_Line (To_String (U))} except
12663 that an extra copy is avoided.
12664 @end itemize
12665
12666 @noindent
12667 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
12668 and is optional.  If the parameter is omitted, then the standard input or
12669 output file is referenced as appropriate.
12670
12671 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
12672 files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended
12673 @code{Wide_Text_IO} functionality for unbounded wide strings.
12674
12675 The package @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} in library
12676 files @file{a-szuzti.ads} and @file{a-szuzti.adb} provides similar extended
12677 @code{Wide_Wide_Text_IO} functionality for unbounded wide wide strings.
12678
12679 @node Wide_Text_IO
12680 @section Wide_Text_IO
12681
12682 @noindent
12683 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
12684 both input and output files may contain special sequences that represent
12685 wide character values.  The encoding scheme for a given file may be
12686 specified using a FORM parameter:
12687
12688 @smallexample
12689 WCEM=@var{x}
12690 @end smallexample
12691
12692 @noindent
12693 as part of the FORM string (WCEM = wide character encoding method),
12694 where @var{x} is one of the following characters
12695
12696 @table @samp
12697 @item h
12698 Hex ESC encoding
12699 @item u
12700 Upper half encoding
12701 @item s
12702 Shift-JIS encoding
12703 @item e
12704 EUC Encoding
12705 @item 8
12706 UTF-8 encoding
12707 @item b
12708 Brackets encoding
12709 @end table
12710
12711 @noindent
12712 The encoding methods match those that
12713 can be used in a source
12714 program, but there is no requirement that the encoding method used for
12715 the source program be the same as the encoding method used for files,
12716 and different files may use different encoding methods.
12717
12718 The default encoding method for the standard files, and for opened files
12719 for which no WCEM parameter is given in the FORM string matches the
12720 wide character encoding specified for the main program (the default
12721 being brackets encoding if no coding method was specified with -gnatW).
12722
12723 @table @asis
12724 @item Hex Coding
12725 In this encoding, a wide character is represented by a five character
12726 sequence:
12727
12728 @smallexample
12729 ESC a b c d
12730 @end smallexample
12731
12732 @noindent
12733 where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
12734 characters (using upper case letters) of the wide character code.  For
12735 example, ESC A345 is used to represent the wide character with code
12736 16#A345#.  This scheme is compatible with use of the full
12737 @code{Wide_Character} set.
12738
12739 @item Upper Half Coding
12740 The wide character with encoding 16#abcd#, where the upper bit is on
12741 (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
12742 16#cd#.  The second byte may never be a format control character, but is
12743 not required to be in the upper half.  This method can be also used for
12744 shift-JIS or EUC where the internal coding matches the external coding.
12745
12746 @item Shift JIS Coding
12747 A wide character is represented by a two character sequence 16#ab# and
12748 16#cd#, with the restrictions described for upper half encoding as
12749 described above.  The internal character code is the corresponding JIS
12750 character according to the standard algorithm for Shift-JIS
12751 conversion.  Only characters defined in the JIS code set table can be
12752 used with this encoding method.
12753
12754 @item EUC Coding
12755 A wide character is represented by a two character sequence 16#ab# and
12756 16#cd#, with both characters being in the upper half.  The internal
12757 character code is the corresponding JIS character according to the EUC
12758 encoding algorithm.  Only characters defined in the JIS code set table
12759 can be used with this encoding method.
12760
12761 @item UTF-8 Coding
12762 A wide character is represented using
12763 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
12764 10646-1/Am.2.  Depending on the character value, the representation
12765 is a one, two, or three byte sequence:
12766
12767 @smallexample
12768 16#0000#-16#007f#: 2#0xxxxxxx#
12769 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
12770 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
12771 @end smallexample
12772
12773 @noindent
12774 where the @var{xxx} bits correspond to the left-padded bits of the
12775 16-bit character value.  Note that all lower half ASCII characters
12776 are represented as ASCII bytes and all upper half characters and
12777 other wide characters are represented as sequences of upper-half
12778 (The full UTF-8 scheme allows for encoding 31-bit characters as
12779 6-byte sequences, but in this implementation, all UTF-8 sequences
12780 of four or more bytes length will raise a Constraint_Error, as
12781 will all invalid UTF-8 sequences.)
12782
12783 @item Brackets Coding
12784 In this encoding, a wide character is represented by the following eight
12785 character sequence:
12786
12787 @smallexample
12788 [ " a b c d " ]
12789 @end smallexample
12790
12791 @noindent
12792 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
12793 characters (using uppercase letters) of the wide character code.  For
12794 example, @code{["A345"]} is used to represent the wide character with code
12795 @code{16#A345#}.
12796 This scheme is compatible with use of the full Wide_Character set.
12797 On input, brackets coding can also be used for upper half characters,
12798 e.g.@: @code{["C1"]} for lower case a.  However, on output, brackets notation
12799 is only used for wide characters with a code greater than @code{16#FF#}.
12800
12801 Note that brackets coding is not normally used in the context of
12802 Wide_Text_IO or Wide_Wide_Text_IO, since it is really just designed as
12803 a portable way of encoding source files. In the context of Wide_Text_IO
12804 or Wide_Wide_Text_IO, it can only be used if the file does not contain
12805 any instance of the left bracket character other than to encode wide
12806 character values using the brackets encoding method. In practice it is
12807 expected that some standard wide character encoding method such
12808 as UTF-8 will be used for text input output.
12809
12810 If brackets notation is used, then any occurrence of a left bracket
12811 in the input file which is not the start of a valid wide character
12812 sequence will cause Constraint_Error to be raised. It is possible to
12813 encode a left bracket as ["5B"] and Wide_Text_IO and Wide_Wide_Text_IO
12814 input will interpret this as a left bracket.
12815
12816 However, when a left bracket is output, it will be output as a left bracket
12817 and not as ["5B"]. We make this decision because for normal use of
12818 Wide_Text_IO for outputting messages, it is unpleasant to clobber left
12819 brackets. For example, if we write:
12820
12821 @smallexample
12822    Put_Line ("Start of output [first run]");
12823 @end smallexample
12824
12825 @noindent
12826 we really do not want to have the left bracket in this message clobbered so
12827 that the output reads:
12828
12829 @smallexample
12830    Start of output ["5B"]first run]
12831 @end smallexample
12832
12833 @noindent
12834 In practice brackets encoding is reasonably useful for normal Put_Line use
12835 since we won't get confused between left brackets and wide character
12836 sequences in the output. But for input, or when files are written out
12837 and read back in, it really makes better sense to use one of the standard
12838 encoding methods such as UTF-8.
12839
12840 @end table
12841
12842 @noindent
12843 For the coding schemes other than UTF-8, Hex, or Brackets encoding,
12844 not all wide character
12845 values can be represented.  An attempt to output a character that cannot
12846 be represented using the encoding scheme for the file causes
12847 Constraint_Error to be raised.  An invalid wide character sequence on
12848 input also causes Constraint_Error to be raised.
12849
12850 @menu
12851 * Wide_Text_IO Stream Pointer Positioning::
12852 * Wide_Text_IO Reading and Writing Non-Regular Files::
12853 @end menu
12854
12855 @node Wide_Text_IO Stream Pointer Positioning
12856 @subsection Stream Pointer Positioning
12857
12858 @noindent
12859 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
12860 of stream pointer positioning (@pxref{Text_IO}).  There is one additional
12861 case:
12862
12863 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
12864 normal lower ASCII set (i.e.@: a character in the range:
12865
12866 @smallexample @c ada
12867 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
12868 @end smallexample
12869
12870 @noindent
12871 then although the logical position of the file pointer is unchanged by
12872 the @code{Look_Ahead} call, the stream is physically positioned past the
12873 wide character sequence.  Again this is to avoid the need for buffering
12874 or backup, and all @code{Wide_Text_IO} routines check the internal
12875 indication that this situation has occurred so that this is not visible
12876 to a normal program using @code{Wide_Text_IO}.  However, this discrepancy
12877 can be observed if the wide text file shares a stream with another file.
12878
12879 @node Wide_Text_IO Reading and Writing Non-Regular Files
12880 @subsection Reading and Writing Non-Regular Files
12881
12882 @noindent
12883 As in the case of Text_IO, when a non-regular file is read, it is
12884 assumed that the file contains no page marks (any form characters are
12885 treated as data characters), and @code{End_Of_Page} always returns
12886 @code{False}.  Similarly, the end of file indication is not sticky, so
12887 it is possible to read beyond an end of file.
12888
12889 @node Wide_Wide_Text_IO
12890 @section Wide_Wide_Text_IO
12891
12892 @noindent
12893 @code{Wide_Wide_Text_IO} is similar in most respects to Text_IO, except that
12894 both input and output files may contain special sequences that represent
12895 wide wide character values.  The encoding scheme for a given file may be
12896 specified using a FORM parameter:
12897
12898 @smallexample
12899 WCEM=@var{x}
12900 @end smallexample
12901
12902 @noindent
12903 as part of the FORM string (WCEM = wide character encoding method),
12904 where @var{x} is one of the following characters
12905
12906 @table @samp
12907 @item h
12908 Hex ESC encoding
12909 @item u
12910 Upper half encoding
12911 @item s
12912 Shift-JIS encoding
12913 @item e
12914 EUC Encoding
12915 @item 8
12916 UTF-8 encoding
12917 @item b
12918 Brackets encoding
12919 @end table
12920
12921 @noindent
12922 The encoding methods match those that
12923 can be used in a source
12924 program, but there is no requirement that the encoding method used for
12925 the source program be the same as the encoding method used for files,
12926 and different files may use different encoding methods.
12927
12928 The default encoding method for the standard files, and for opened files
12929 for which no WCEM parameter is given in the FORM string matches the
12930 wide character encoding specified for the main program (the default
12931 being brackets encoding if no coding method was specified with -gnatW).
12932
12933 @table @asis
12934
12935 @item UTF-8 Coding
12936 A wide character is represented using
12937 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
12938 10646-1/Am.2.  Depending on the character value, the representation
12939 is a one, two, three, or four byte sequence:
12940
12941 @smallexample
12942 16#000000#-16#00007f#: 2#0xxxxxxx#
12943 16#000080#-16#0007ff#: 2#110xxxxx# 2#10xxxxxx#
12944 16#000800#-16#00ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
12945 16#010000#-16#10ffff#: 2#11110xxx# 2#10xxxxxx# 2#10xxxxxx# 2#10xxxxxx#
12946 @end smallexample
12947
12948 @noindent
12949 where the @var{xxx} bits correspond to the left-padded bits of the
12950 21-bit character value.  Note that all lower half ASCII characters
12951 are represented as ASCII bytes and all upper half characters and
12952 other wide characters are represented as sequences of upper-half
12953 characters.
12954
12955 @item Brackets Coding
12956 In this encoding, a wide wide character is represented by the following eight
12957 character sequence if is in wide character range
12958
12959 @smallexample
12960 [ " a b c d " ]
12961 @end smallexample
12962
12963 and by the following ten character sequence if not
12964
12965 @smallexample
12966 [ " a b c d e f " ]
12967 @end smallexample
12968
12969 @noindent
12970 where @code{a}, @code{b}, @code{c}, @code{d}, @code{e}, and @code{f}
12971 are the four or six hexadecimal
12972 characters (using uppercase letters) of the wide wide character code.  For
12973 example, @code{["01A345"]} is used to represent the wide wide character
12974 with code @code{16#01A345#}.
12975
12976 This scheme is compatible with use of the full Wide_Wide_Character set.
12977 On input, brackets coding can also be used for upper half characters,
12978 e.g.@: @code{["C1"]} for lower case a.  However, on output, brackets notation
12979 is only used for wide characters with a code greater than @code{16#FF#}.
12980
12981 @end table
12982
12983 @noindent
12984 If is also possible to use the other Wide_Character encoding methods,
12985 such as Shift-JIS, but the other schemes cannot support the full range
12986 of wide wide characters.
12987 An attempt to output a character that cannot
12988 be represented using the encoding scheme for the file causes
12989 Constraint_Error to be raised.  An invalid wide character sequence on
12990 input also causes Constraint_Error to be raised.
12991
12992 @menu
12993 * Wide_Wide_Text_IO Stream Pointer Positioning::
12994 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
12995 @end menu
12996
12997 @node Wide_Wide_Text_IO Stream Pointer Positioning
12998 @subsection Stream Pointer Positioning
12999
13000 @noindent
13001 @code{Ada.Wide_Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
13002 of stream pointer positioning (@pxref{Text_IO}).  There is one additional
13003 case:
13004
13005 If @code{Ada.Wide_Wide_Text_IO.Look_Ahead} reads a character outside the
13006 normal lower ASCII set (i.e.@: a character in the range:
13007
13008 @smallexample @c ada
13009 Wide_Wide_Character'Val (16#0080#) .. Wide_Wide_Character'Val (16#10FFFF#)
13010 @end smallexample
13011
13012 @noindent
13013 then although the logical position of the file pointer is unchanged by
13014 the @code{Look_Ahead} call, the stream is physically positioned past the
13015 wide character sequence.  Again this is to avoid the need for buffering
13016 or backup, and all @code{Wide_Wide_Text_IO} routines check the internal
13017 indication that this situation has occurred so that this is not visible
13018 to a normal program using @code{Wide_Wide_Text_IO}.  However, this discrepancy
13019 can be observed if the wide text file shares a stream with another file.
13020
13021 @node Wide_Wide_Text_IO Reading and Writing Non-Regular Files
13022 @subsection Reading and Writing Non-Regular Files
13023
13024 @noindent
13025 As in the case of Text_IO, when a non-regular file is read, it is
13026 assumed that the file contains no page marks (any form characters are
13027 treated as data characters), and @code{End_Of_Page} always returns
13028 @code{False}.  Similarly, the end of file indication is not sticky, so
13029 it is possible to read beyond an end of file.
13030
13031 @node Stream_IO
13032 @section Stream_IO
13033
13034 @noindent
13035 A stream file is a sequence of bytes, where individual elements are
13036 written to the file as described in the Ada Reference Manual.  The type
13037 @code{Stream_Element} is simply a byte.  There are two ways to read or
13038 write a stream file.
13039
13040 @itemize @bullet
13041 @item
13042 The operations @code{Read} and @code{Write} directly read or write a
13043 sequence of stream elements with no control information.
13044
13045 @item
13046 The stream attributes applied to a stream file transfer data in the
13047 manner described for stream attributes.
13048 @end itemize
13049
13050 @node Text Translation
13051 @section Text Translation
13052
13053 @noindent
13054 @samp{Text_Translation=@var{xxx}} may be used as the Form parameter
13055 passed to Text_IO.Create and Text_IO.Open:
13056 @samp{Text_Translation=@var{Yes}} is the default, which means to
13057 translate LF to/from CR/LF on Windows systems.
13058 @samp{Text_Translation=@var{No}} disables this translation; i.e. it
13059 uses binary mode. For output files, @samp{Text_Translation=@var{No}}
13060 may be used to create Unix-style files on
13061 Windows. @samp{Text_Translation=@var{xxx}} has no effect on Unix
13062 systems.
13063
13064 @node Shared Files
13065 @section Shared Files
13066
13067 @noindent
13068 Section A.14 of the Ada Reference Manual allows implementations to
13069 provide a wide variety of behavior if an attempt is made to access the
13070 same external file with two or more internal files.
13071
13072 To provide a full range of functionality, while at the same time
13073 minimizing the problems of portability caused by this implementation
13074 dependence, GNAT handles file sharing as follows:
13075
13076 @itemize @bullet
13077 @item
13078 In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
13079 to open two or more files with the same full name is considered an error
13080 and is not supported.  The exception @code{Use_Error} will be
13081 raised.  Note that a file that is not explicitly closed by the program
13082 remains open until the program terminates.
13083
13084 @item
13085 If the form parameter @samp{shared=no} appears in the form string, the
13086 file can be opened or created with its own separate stream identifier,
13087 regardless of whether other files sharing the same external file are
13088 opened.  The exact effect depends on how the C stream routines handle
13089 multiple accesses to the same external files using separate streams.
13090
13091 @item
13092 If the form parameter @samp{shared=yes} appears in the form string for
13093 each of two or more files opened using the same full name, the same
13094 stream is shared between these files, and the semantics are as described
13095 in Ada Reference Manual, Section A.14.
13096 @end itemize
13097
13098 @noindent
13099 When a program that opens multiple files with the same name is ported
13100 from another Ada compiler to GNAT, the effect will be that
13101 @code{Use_Error} is raised.
13102
13103 The documentation of the original compiler and the documentation of the
13104 program should then be examined to determine if file sharing was
13105 expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
13106 and @code{Create} calls as required.
13107
13108 When a program is ported from GNAT to some other Ada compiler, no
13109 special attention is required unless the @samp{shared=@var{xxx}} form
13110 parameter is used in the program.  In this case, you must examine the
13111 documentation of the new compiler to see if it supports the required
13112 file sharing semantics, and form strings modified appropriately.  Of
13113 course it may be the case that the program cannot be ported if the
13114 target compiler does not support the required functionality.  The best
13115 approach in writing portable code is to avoid file sharing (and hence
13116 the use of the @samp{shared=@var{xxx}} parameter in the form string)
13117 completely.
13118
13119 One common use of file sharing in Ada 83 is the use of instantiations of
13120 Sequential_IO on the same file with different types, to achieve
13121 heterogeneous input-output.  Although this approach will work in GNAT if
13122 @samp{shared=yes} is specified, it is preferable in Ada to use Stream_IO
13123 for this purpose (using the stream attributes)
13124
13125 @node Filenames encoding
13126 @section Filenames encoding
13127
13128 @noindent
13129 An encoding form parameter can be used to specify the filename
13130 encoding @samp{encoding=@var{xxx}}.
13131
13132 @itemize @bullet
13133 @item
13134 If the form parameter @samp{encoding=utf8} appears in the form string, the
13135 filename must be encoded in UTF-8.
13136
13137 @item
13138 If the form parameter @samp{encoding=8bits} appears in the form
13139 string, the filename must be a standard 8bits string.
13140 @end itemize
13141
13142 In the absence of a @samp{encoding=@var{xxx}} form parameter, the
13143 encoding is controlled by the @samp{GNAT_CODE_PAGE} environment
13144 variable. And if not set @samp{utf8} is assumed.
13145
13146 @table @samp
13147 @item CP_ACP
13148 The current system Windows ANSI code page.
13149 @item CP_UTF8
13150 UTF-8 encoding
13151 @end table
13152
13153 This encoding form parameter is only supported on the Windows
13154 platform. On the other Operating Systems the run-time is supporting
13155 UTF-8 natively.
13156
13157 @node Open Modes
13158 @section Open Modes
13159
13160 @noindent
13161 @code{Open} and @code{Create} calls result in a call to @code{fopen}
13162 using the mode shown in the following table:
13163
13164 @sp 2
13165 @center @code{Open} and @code{Create} Call Modes
13166 @smallexample
13167                                @b{OPEN }           @b{CREATE}
13168 Append_File                    "r+"             "w+"
13169 In_File                        "r"              "w+"
13170 Out_File (Direct_IO)           "r+"             "w"
13171 Out_File (all other cases)     "w"              "w"
13172 Inout_File                     "r+"             "w+"
13173 @end smallexample
13174
13175 @noindent
13176 If text file translation is required, then either @samp{b} or @samp{t}
13177 is added to the mode, depending on the setting of Text.  Text file
13178 translation refers to the mapping of CR/LF sequences in an external file
13179 to LF characters internally.  This mapping only occurs in DOS and
13180 DOS-like systems, and is not relevant to other systems.
13181
13182 A special case occurs with Stream_IO@.  As shown in the above table, the
13183 file is initially opened in @samp{r} or @samp{w} mode for the
13184 @code{In_File} and @code{Out_File} cases.  If a @code{Set_Mode} operation
13185 subsequently requires switching from reading to writing or vice-versa,
13186 then the file is reopened in @samp{r+} mode to permit the required operation.
13187
13188 @node Operations on C Streams
13189 @section Operations on C Streams
13190 The package @code{Interfaces.C_Streams} provides an Ada program with direct
13191 access to the C library functions for operations on C streams:
13192
13193 @smallexample @c adanocomment
13194 package Interfaces.C_Streams is
13195   -- Note: the reason we do not use the types that are in
13196   -- Interfaces.C is that we want to avoid dragging in the
13197   -- code in this unit if possible.
13198   subtype chars is System.Address;
13199   -- Pointer to null-terminated array of characters
13200   subtype FILEs is System.Address;
13201   -- Corresponds to the C type FILE*
13202   subtype voids is System.Address;
13203   -- Corresponds to the C type void*
13204   subtype int is Integer;
13205   subtype long is Long_Integer;
13206   -- Note: the above types are subtypes deliberately, and it
13207   -- is part of this spec that the above correspondences are
13208   -- guaranteed.  This means that it is legitimate to, for
13209   -- example, use Integer instead of int.  We provide these
13210   -- synonyms for clarity, but in some cases it may be
13211   -- convenient to use the underlying types (for example to
13212   -- avoid an unnecessary dependency of a spec on the spec
13213   -- of this unit).
13214   type size_t is mod 2 ** Standard'Address_Size;
13215   NULL_Stream : constant FILEs;
13216   -- Value returned (NULL in C) to indicate an
13217   -- fdopen/fopen/tmpfile error
13218   ----------------------------------
13219   -- Constants Defined in stdio.h --
13220   ----------------------------------
13221   EOF : constant int;
13222   -- Used by a number of routines to indicate error or
13223   -- end of file
13224   IOFBF : constant int;
13225   IOLBF : constant int;
13226   IONBF : constant int;
13227   -- Used to indicate buffering mode for setvbuf call
13228   SEEK_CUR : constant int;
13229   SEEK_END : constant int;
13230   SEEK_SET : constant int;
13231   -- Used to indicate origin for fseek call
13232   function stdin return FILEs;
13233   function stdout return FILEs;
13234   function stderr return FILEs;
13235   -- Streams associated with standard files
13236   --------------------------
13237   -- Standard C functions --
13238   --------------------------
13239   -- The functions selected below are ones that are
13240   -- available in DOS, OS/2, UNIX and Xenix (but not
13241   -- necessarily in ANSI C).  These are very thin interfaces
13242   -- which copy exactly the C headers.  For more
13243   -- documentation on these functions, see the Microsoft C
13244   -- "Run-Time Library Reference" (Microsoft Press, 1990,
13245   -- ISBN 1-55615-225-6), which includes useful information
13246   -- on system compatibility.
13247   procedure clearerr (stream : FILEs);
13248   function fclose (stream : FILEs) return int;
13249   function fdopen (handle : int; mode : chars) return FILEs;
13250   function feof (stream : FILEs) return int;
13251   function ferror (stream : FILEs) return int;
13252   function fflush (stream : FILEs) return int;
13253   function fgetc (stream : FILEs) return int;
13254   function fgets (strng : chars; n : int; stream : FILEs)
13255       return chars;
13256   function fileno (stream : FILEs) return int;
13257   function fopen (filename : chars; Mode : chars)
13258       return FILEs;
13259   -- Note: to maintain target independence, use
13260   -- text_translation_required, a boolean variable defined in
13261   -- a-sysdep.c to deal with the target dependent text
13262   -- translation requirement.  If this variable is set,
13263   -- then  b/t should be appended to the standard mode
13264   -- argument to set the text translation mode off or on
13265   -- as required.
13266   function fputc (C : int; stream : FILEs) return int;
13267   function fputs (Strng : chars; Stream : FILEs) return int;
13268   function fread
13269      (buffer : voids;
13270       size : size_t;
13271       count : size_t;
13272       stream : FILEs)
13273       return size_t;
13274   function freopen
13275      (filename : chars;
13276       mode : chars;
13277       stream : FILEs)
13278       return FILEs;
13279   function fseek
13280      (stream : FILEs;
13281       offset : long;
13282       origin : int)
13283       return int;
13284   function ftell (stream : FILEs) return long;
13285   function fwrite
13286      (buffer : voids;
13287       size : size_t;
13288       count : size_t;
13289       stream : FILEs)
13290       return size_t;
13291   function isatty (handle : int) return int;
13292   procedure mktemp (template : chars);
13293   -- The return value (which is just a pointer to template)
13294   -- is discarded
13295   procedure rewind (stream : FILEs);
13296   function rmtmp return int;
13297   function setvbuf
13298      (stream : FILEs;
13299       buffer : chars;
13300       mode : int;
13301       size : size_t)
13302       return int;
13303
13304   function tmpfile return FILEs;
13305   function ungetc (c : int; stream : FILEs) return int;
13306   function unlink (filename : chars) return int;
13307   ---------------------
13308   -- Extra functions --
13309   ---------------------
13310   -- These functions supply slightly thicker bindings than
13311   -- those above.  They are derived from functions in the
13312   -- C Run-Time Library, but may do a bit more work than
13313   -- just directly calling one of the Library functions.
13314   function is_regular_file (handle : int) return int;
13315   -- Tests if given handle is for a regular file (result 1)
13316   -- or for a non-regular file (pipe or device, result 0).
13317   ---------------------------------
13318   -- Control of Text/Binary Mode --
13319   ---------------------------------
13320   -- If text_translation_required is true, then the following
13321   -- functions may be used to dynamically switch a file from
13322   -- binary to text mode or vice versa.  These functions have
13323   -- no effect if text_translation_required is false (i.e.@: in
13324   -- normal UNIX mode).  Use fileno to get a stream handle.
13325   procedure set_binary_mode (handle : int);
13326   procedure set_text_mode (handle : int);
13327   ----------------------------
13328   -- Full Path Name support --
13329   ----------------------------
13330   procedure full_name (nam : chars; buffer : chars);
13331   -- Given a NUL terminated string representing a file
13332   -- name, returns in buffer a NUL terminated string
13333   -- representing the full path name for the file name.
13334   -- On systems where it is relevant the   drive is also
13335   -- part of the full path name.  It is the responsibility
13336   -- of the caller to pass an actual parameter for buffer
13337   -- that is big enough for any full path name.  Use
13338   -- max_path_len given below as the size of buffer.
13339   max_path_len : integer;
13340   -- Maximum length of an allowable full path name on the
13341   -- system, including a terminating NUL character.
13342 end Interfaces.C_Streams;
13343 @end smallexample
13344
13345 @node Interfacing to C Streams
13346 @section Interfacing to C Streams
13347
13348 @noindent
13349 The packages in this section permit interfacing Ada files to C Stream
13350 operations.
13351
13352 @smallexample @c ada
13353  with Interfaces.C_Streams;
13354  package Ada.Sequential_IO.C_Streams is
13355     function C_Stream (F : File_Type)
13356        return Interfaces.C_Streams.FILEs;
13357     procedure Open
13358       (File : in out File_Type;
13359        Mode : in File_Mode;
13360        C_Stream : in Interfaces.C_Streams.FILEs;
13361        Form : in String := "");
13362  end Ada.Sequential_IO.C_Streams;
13363
13364   with Interfaces.C_Streams;
13365   package Ada.Direct_IO.C_Streams is
13366      function C_Stream (F : File_Type)
13367         return Interfaces.C_Streams.FILEs;
13368      procedure Open
13369        (File : in out File_Type;
13370         Mode : in File_Mode;
13371         C_Stream : in Interfaces.C_Streams.FILEs;
13372         Form : in String := "");
13373   end Ada.Direct_IO.C_Streams;
13374
13375   with Interfaces.C_Streams;
13376   package Ada.Text_IO.C_Streams is
13377      function C_Stream (F : File_Type)
13378         return Interfaces.C_Streams.FILEs;
13379      procedure Open
13380        (File : in out File_Type;
13381         Mode : in File_Mode;
13382         C_Stream : in Interfaces.C_Streams.FILEs;
13383         Form : in String := "");
13384   end Ada.Text_IO.C_Streams;
13385
13386   with Interfaces.C_Streams;
13387   package Ada.Wide_Text_IO.C_Streams is
13388      function C_Stream (F : File_Type)
13389         return Interfaces.C_Streams.FILEs;
13390      procedure Open
13391        (File : in out File_Type;
13392         Mode : in File_Mode;
13393         C_Stream : in Interfaces.C_Streams.FILEs;
13394         Form : in String := "");
13395  end Ada.Wide_Text_IO.C_Streams;
13396
13397   with Interfaces.C_Streams;
13398   package Ada.Wide_Wide_Text_IO.C_Streams is
13399      function C_Stream (F : File_Type)
13400         return Interfaces.C_Streams.FILEs;
13401      procedure Open
13402        (File : in out File_Type;
13403         Mode : in File_Mode;
13404         C_Stream : in Interfaces.C_Streams.FILEs;
13405         Form : in String := "");
13406  end Ada.Wide_Wide_Text_IO.C_Streams;
13407
13408  with Interfaces.C_Streams;
13409  package Ada.Stream_IO.C_Streams is
13410     function C_Stream (F : File_Type)
13411        return Interfaces.C_Streams.FILEs;
13412     procedure Open
13413       (File : in out File_Type;
13414        Mode : in File_Mode;
13415        C_Stream : in Interfaces.C_Streams.FILEs;
13416        Form : in String := "");
13417  end Ada.Stream_IO.C_Streams;
13418 @end smallexample
13419
13420 @noindent
13421 In each of these six packages, the @code{C_Stream} function obtains the
13422 @code{FILE} pointer from a currently opened Ada file.  It is then
13423 possible to use the @code{Interfaces.C_Streams} package to operate on
13424 this stream, or the stream can be passed to a C program which can
13425 operate on it directly.  Of course the program is responsible for
13426 ensuring that only appropriate sequences of operations are executed.
13427
13428 One particular use of relevance to an Ada program is that the
13429 @code{setvbuf} function can be used to control the buffering of the
13430 stream used by an Ada file.  In the absence of such a call the standard
13431 default buffering is used.
13432
13433 The @code{Open} procedures in these packages open a file giving an
13434 existing C Stream instead of a file name.  Typically this stream is
13435 imported from a C program, allowing an Ada file to operate on an
13436 existing C file.
13437
13438 @node The GNAT Library
13439 @chapter The GNAT Library
13440
13441 @noindent
13442 The GNAT library contains a number of general and special purpose packages.
13443 It represents functionality that the GNAT developers have found useful, and
13444 which is made available to GNAT users.  The packages described here are fully
13445 supported, and upwards compatibility will be maintained in future releases,
13446 so you can use these facilities with the confidence that the same functionality
13447 will be available in future releases.
13448
13449 The chapter here simply gives a brief summary of the facilities available.
13450 The full documentation is found in the spec file for the package.  The full
13451 sources of these library packages, including both spec and body, are provided
13452 with all GNAT releases.  For example, to find out the full specifications of
13453 the SPITBOL pattern matching capability, including a full tutorial and
13454 extensive examples, look in the @file{g-spipat.ads} file in the library.
13455
13456 For each entry here, the package name (as it would appear in a @code{with}
13457 clause) is given, followed by the name of the corresponding spec file in
13458 parentheses.  The packages are children in four hierarchies, @code{Ada},
13459 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
13460 GNAT-specific hierarchy.
13461
13462 Note that an application program should only use packages in one of these
13463 four hierarchies if the package is defined in the Ada Reference Manual,
13464 or is listed in this section of the GNAT Programmers Reference Manual.
13465 All other units should be considered internal implementation units and
13466 should not be directly @code{with}'ed by application code.  The use of
13467 a @code{with} statement that references one of these internal implementation
13468 units makes an application potentially dependent on changes in versions
13469 of GNAT, and will generate a warning message.
13470
13471 @menu
13472 * Ada.Characters.Latin_9 (a-chlat9.ads)::
13473 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
13474 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
13475 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
13476 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
13477 * Ada.Command_Line.Environment (a-colien.ads)::
13478 * Ada.Command_Line.Remove (a-colire.ads)::
13479 * Ada.Command_Line.Response_File (a-clrefi.ads)::
13480 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
13481 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
13482 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
13483 * Ada.Exceptions.Traceback (a-exctra.ads)::
13484 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
13485 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
13486 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
13487 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
13488 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
13489 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
13490 * Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)::
13491 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
13492 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
13493 * Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)::
13494 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
13495 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
13496 * Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)::
13497 * GNAT.Altivec (g-altive.ads)::
13498 * GNAT.Altivec.Conversions (g-altcon.ads)::
13499 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
13500 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
13501 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
13502 * GNAT.Array_Split (g-arrspl.ads)::
13503 * GNAT.AWK (g-awk.ads)::
13504 * GNAT.Bounded_Buffers (g-boubuf.ads)::
13505 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
13506 * GNAT.Bubble_Sort (g-bubsor.ads)::
13507 * GNAT.Bubble_Sort_A (g-busora.ads)::
13508 * GNAT.Bubble_Sort_G (g-busorg.ads)::
13509 * GNAT.Byte_Order_Mark (g-byorma.ads)::
13510 * GNAT.Byte_Swapping (g-bytswa.ads)::
13511 * GNAT.Calendar (g-calend.ads)::
13512 * GNAT.Calendar.Time_IO (g-catiio.ads)::
13513 * GNAT.Case_Util (g-casuti.ads)::
13514 * GNAT.CGI (g-cgi.ads)::
13515 * GNAT.CGI.Cookie (g-cgicoo.ads)::
13516 * GNAT.CGI.Debug (g-cgideb.ads)::
13517 * GNAT.Command_Line (g-comlin.ads)::
13518 * GNAT.Compiler_Version (g-comver.ads)::
13519 * GNAT.Ctrl_C (g-ctrl_c.ads)::
13520 * GNAT.CRC32 (g-crc32.ads)::
13521 * GNAT.Current_Exception (g-curexc.ads)::
13522 * GNAT.Debug_Pools (g-debpoo.ads)::
13523 * GNAT.Debug_Utilities (g-debuti.ads)::
13524 * GNAT.Decode_String (g-decstr.ads)::
13525 * GNAT.Decode_UTF8_String (g-deutst.ads)::
13526 * GNAT.Directory_Operations (g-dirope.ads)::
13527 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
13528 * GNAT.Dynamic_HTables (g-dynhta.ads)::
13529 * GNAT.Dynamic_Tables (g-dyntab.ads)::
13530 * GNAT.Encode_String (g-encstr.ads)::
13531 * GNAT.Encode_UTF8_String (g-enutst.ads)::
13532 * GNAT.Exception_Actions (g-excact.ads)::
13533 * GNAT.Exception_Traces (g-exctra.ads)::
13534 * GNAT.Exceptions (g-except.ads)::
13535 * GNAT.Expect (g-expect.ads)::
13536 * GNAT.Float_Control (g-flocon.ads)::
13537 * GNAT.Heap_Sort (g-heasor.ads)::
13538 * GNAT.Heap_Sort_A (g-hesora.ads)::
13539 * GNAT.Heap_Sort_G (g-hesorg.ads)::
13540 * GNAT.HTable (g-htable.ads)::
13541 * GNAT.IO (g-io.ads)::
13542 * GNAT.IO_Aux (g-io_aux.ads)::
13543 * GNAT.Lock_Files (g-locfil.ads)::
13544 * GNAT.MD5 (g-md5.ads)::
13545 * GNAT.Memory_Dump (g-memdum.ads)::
13546 * GNAT.Most_Recent_Exception (g-moreex.ads)::
13547 * GNAT.OS_Lib (g-os_lib.ads)::
13548 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
13549 * GNAT.Random_Numbers (g-rannum.ads)::
13550 * GNAT.Regexp (g-regexp.ads)::
13551 * GNAT.Registry (g-regist.ads)::
13552 * GNAT.Regpat (g-regpat.ads)::
13553 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
13554 * GNAT.Semaphores (g-semaph.ads)::
13555 * GNAT.Serial_Communications (g-sercom.ads)::
13556 * GNAT.SHA1 (g-sha1.ads)::
13557 * GNAT.Signals (g-signal.ads)::
13558 * GNAT.Sockets (g-socket.ads)::
13559 * GNAT.Source_Info (g-souinf.ads)::
13560 * GNAT.Spelling_Checker (g-speche.ads)::
13561 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
13562 * GNAT.Spitbol.Patterns (g-spipat.ads)::
13563 * GNAT.Spitbol (g-spitbo.ads)::
13564 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
13565 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
13566 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
13567 * GNAT.SSE (g-sse.ads)::
13568 * GNAT.SSE.Vector_Types (g-ssvety.ads)::
13569 * GNAT.Strings (g-string.ads)::
13570 * GNAT.String_Split (g-strspl.ads)::
13571 * GNAT.Table (g-table.ads)::
13572 * GNAT.Task_Lock (g-tasloc.ads)::
13573 * GNAT.Threads (g-thread.ads)::
13574 * GNAT.Time_Stamp (g-timsta.ads)::
13575 * GNAT.Traceback (g-traceb.ads)::
13576 * GNAT.Traceback.Symbolic (g-trasym.ads)::
13577 * GNAT.UTF_32 (g-utf_32.ads)::
13578 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
13579 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
13580 * GNAT.Wide_String_Split (g-wistsp.ads)::
13581 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
13582 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
13583 * Interfaces.C.Extensions (i-cexten.ads)::
13584 * Interfaces.C.Streams (i-cstrea.ads)::
13585 * Interfaces.CPP (i-cpp.ads)::
13586 * Interfaces.Packed_Decimal (i-pacdec.ads)::
13587 * Interfaces.VxWorks (i-vxwork.ads)::
13588 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
13589 * System.Address_Image (s-addima.ads)::
13590 * System.Assertions (s-assert.ads)::
13591 * System.Memory (s-memory.ads)::
13592 * System.Partition_Interface (s-parint.ads)::
13593 * System.Pool_Global (s-pooglo.ads)::
13594 * System.Pool_Local (s-pooloc.ads)::
13595 * System.Restrictions (s-restri.ads)::
13596 * System.Rident (s-rident.ads)::
13597 * System.Strings.Stream_Ops (s-ststop.ads)::
13598 * System.Task_Info (s-tasinf.ads)::
13599 * System.Wch_Cnv (s-wchcnv.ads)::
13600 * System.Wch_Con (s-wchcon.ads)::
13601 @end menu
13602
13603 @node Ada.Characters.Latin_9 (a-chlat9.ads)
13604 @section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
13605 @cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
13606 @cindex Latin_9 constants for Character
13607
13608 @noindent
13609 This child of @code{Ada.Characters}
13610 provides a set of definitions corresponding to those in the
13611 RM-defined package @code{Ada.Characters.Latin_1} but with the
13612 few modifications required for @code{Latin-9}
13613 The provision of such a package
13614 is specifically authorized by the Ada Reference Manual
13615 (RM A.3.3(27)).
13616
13617 @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
13618 @section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
13619 @cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
13620 @cindex Latin_1 constants for Wide_Character
13621
13622 @noindent
13623 This child of @code{Ada.Characters}
13624 provides a set of definitions corresponding to those in the
13625 RM-defined package @code{Ada.Characters.Latin_1} but with the
13626 types of the constants being @code{Wide_Character}
13627 instead of @code{Character}.  The provision of such a package
13628 is specifically authorized by the Ada Reference Manual
13629 (RM A.3.3(27)).
13630
13631 @node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
13632 @section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
13633 @cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
13634 @cindex Latin_9 constants for Wide_Character
13635
13636 @noindent
13637 This child of @code{Ada.Characters}
13638 provides a set of definitions corresponding to those in the
13639 GNAT defined package @code{Ada.Characters.Latin_9} but with the
13640 types of the constants being @code{Wide_Character}
13641 instead of @code{Character}.  The provision of such a package
13642 is specifically authorized by the Ada Reference Manual
13643 (RM A.3.3(27)).
13644
13645 @node Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)
13646 @section @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
13647 @cindex @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
13648 @cindex Latin_1 constants for Wide_Wide_Character
13649
13650 @noindent
13651 This child of @code{Ada.Characters}
13652 provides a set of definitions corresponding to those in the
13653 RM-defined package @code{Ada.Characters.Latin_1} but with the
13654 types of the constants being @code{Wide_Wide_Character}
13655 instead of @code{Character}.  The provision of such a package
13656 is specifically authorized by the Ada Reference Manual
13657 (RM A.3.3(27)).
13658
13659 @node Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)
13660 @section @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
13661 @cindex @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
13662 @cindex Latin_9 constants for Wide_Wide_Character
13663
13664 @noindent
13665 This child of @code{Ada.Characters}
13666 provides a set of definitions corresponding to those in the
13667 GNAT defined package @code{Ada.Characters.Latin_9} but with the
13668 types of the constants being @code{Wide_Wide_Character}
13669 instead of @code{Character}.  The provision of such a package
13670 is specifically authorized by the Ada Reference Manual
13671 (RM A.3.3(27)).
13672
13673 @node Ada.Command_Line.Environment (a-colien.ads)
13674 @section @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
13675 @cindex @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
13676 @cindex Environment entries
13677
13678 @noindent
13679 This child of @code{Ada.Command_Line}
13680 provides a mechanism for obtaining environment values on systems
13681 where this concept makes sense.
13682
13683 @node Ada.Command_Line.Remove (a-colire.ads)
13684 @section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
13685 @cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
13686 @cindex Removing command line arguments
13687 @cindex Command line, argument removal
13688
13689 @noindent
13690 This child of @code{Ada.Command_Line}
13691 provides a mechanism for logically removing
13692 arguments from the argument list.  Once removed, an argument is not visible
13693 to further calls on the subprograms in @code{Ada.Command_Line} will not
13694 see the removed argument.
13695
13696 @node Ada.Command_Line.Response_File (a-clrefi.ads)
13697 @section @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
13698 @cindex @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
13699 @cindex Response file for command line
13700 @cindex Command line, response file
13701 @cindex Command line, handling long command lines
13702
13703 @noindent
13704 This child of @code{Ada.Command_Line} provides a mechanism facilities for
13705 getting command line arguments from a text file, called a "response file".
13706 Using a response file allow passing a set of arguments to an executable longer
13707 than the maximum allowed by the system on the command line.
13708
13709 @node Ada.Direct_IO.C_Streams (a-diocst.ads)
13710 @section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
13711 @cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
13712 @cindex C Streams, Interfacing with Direct_IO
13713
13714 @noindent
13715 This package provides subprograms that allow interfacing between
13716 C streams and @code{Direct_IO}.  The stream identifier can be
13717 extracted from a file opened on the Ada side, and an Ada file
13718 can be constructed from a stream opened on the C side.
13719
13720 @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
13721 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
13722 @cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
13723 @cindex Null_Occurrence, testing for
13724
13725 @noindent
13726 This child subprogram provides a way of testing for the null
13727 exception occurrence (@code{Null_Occurrence}) without raising
13728 an exception.
13729
13730 @node Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)
13731 @section @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
13732 @cindex @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
13733 @cindex Null_Occurrence, testing for
13734
13735 @noindent
13736 This child subprogram is used for handling otherwise unhandled
13737 exceptions (hence the name last chance), and perform clean ups before
13738 terminating the program. Note that this subprogram never returns.
13739
13740 @node Ada.Exceptions.Traceback (a-exctra.ads)
13741 @section @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
13742 @cindex @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
13743 @cindex Traceback for Exception Occurrence
13744
13745 @noindent
13746 This child package provides the subprogram (@code{Tracebacks}) to
13747 give a traceback array of addresses based on an exception
13748 occurrence.
13749
13750 @node Ada.Sequential_IO.C_Streams (a-siocst.ads)
13751 @section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
13752 @cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
13753 @cindex C Streams, Interfacing with Sequential_IO
13754
13755 @noindent
13756 This package provides subprograms that allow interfacing between
13757 C streams and @code{Sequential_IO}.  The stream identifier can be
13758 extracted from a file opened on the Ada side, and an Ada file
13759 can be constructed from a stream opened on the C side.
13760
13761 @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
13762 @section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
13763 @cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
13764 @cindex C Streams, Interfacing with Stream_IO
13765
13766 @noindent
13767 This package provides subprograms that allow interfacing between
13768 C streams and @code{Stream_IO}.  The stream identifier can be
13769 extracted from a file opened on the Ada side, and an Ada file
13770 can be constructed from a stream opened on the C side.
13771
13772 @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
13773 @section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
13774 @cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
13775 @cindex @code{Unbounded_String}, IO support
13776 @cindex @code{Text_IO}, extensions for unbounded strings
13777
13778 @noindent
13779 This package provides subprograms for Text_IO for unbounded
13780 strings, avoiding the necessity for an intermediate operation
13781 with ordinary strings.
13782
13783 @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
13784 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
13785 @cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
13786 @cindex @code{Unbounded_Wide_String}, IO support
13787 @cindex @code{Text_IO}, extensions for unbounded wide strings
13788
13789 @noindent
13790 This package provides subprograms for Text_IO for unbounded
13791 wide strings, avoiding the necessity for an intermediate operation
13792 with ordinary wide strings.
13793
13794 @node Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)
13795 @section @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
13796 @cindex @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
13797 @cindex @code{Unbounded_Wide_Wide_String}, IO support
13798 @cindex @code{Text_IO}, extensions for unbounded wide wide strings
13799
13800 @noindent
13801 This package provides subprograms for Text_IO for unbounded
13802 wide wide strings, avoiding the necessity for an intermediate operation
13803 with ordinary wide wide strings.
13804
13805 @node Ada.Text_IO.C_Streams (a-tiocst.ads)
13806 @section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
13807 @cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
13808 @cindex C Streams, Interfacing with @code{Text_IO}
13809
13810 @noindent
13811 This package provides subprograms that allow interfacing between
13812 C streams and @code{Text_IO}.  The stream identifier can be
13813 extracted from a file opened on the Ada side, and an Ada file
13814 can be constructed from a stream opened on the C side.
13815
13816 @node Ada.Text_IO.Reset_Standard_Files (a-tirsfi.ads)
13817 @section @code{Ada.Text_IO.Reset_Standard_Files} (@file{a-tirsfi.ads})
13818 @cindex @code{Ada.Text_IO.Reset_Standard_Files} (@file{a-tirsfi.ads})
13819 @cindex @code{Text_IO} resetting standard files
13820
13821 @noindent
13822 This procedure is used to reset the status of the standard files used
13823 by Ada.Text_IO.  This is useful in a situation (such as a restart in an
13824 embedded application) where the status of the files may change during
13825 execution (for example a standard input file may be redefined to be
13826 interactive).
13827
13828 @node Ada.Wide_Characters.Unicode (a-wichun.ads)
13829 @section @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
13830 @cindex @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
13831 @cindex Unicode categorization, Wide_Character
13832
13833 @noindent
13834 This package provides subprograms that allow categorization of
13835 Wide_Character values according to Unicode categories.
13836
13837 @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
13838 @section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
13839 @cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
13840 @cindex C Streams, Interfacing with @code{Wide_Text_IO}
13841
13842 @noindent
13843 This package provides subprograms that allow interfacing between
13844 C streams and @code{Wide_Text_IO}.  The stream identifier can be
13845 extracted from a file opened on the Ada side, and an Ada file
13846 can be constructed from a stream opened on the C side.
13847
13848 @node Ada.Wide_Text_IO.Reset_Standard_Files (a-wrstfi.ads)
13849 @section @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@file{a-wrstfi.ads})
13850 @cindex @code{Ada.Wide_Text_IO.Reset_Standard_Files} (@file{a-wrstfi.ads})
13851 @cindex @code{Wide_Text_IO} resetting standard files
13852
13853 @noindent
13854 This procedure is used to reset the status of the standard files used
13855 by Ada.Wide_Text_IO.  This is useful in a situation (such as a restart in an
13856 embedded application) where the status of the files may change during
13857 execution (for example a standard input file may be redefined to be
13858 interactive).
13859
13860 @node Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)
13861 @section @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
13862 @cindex @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
13863 @cindex Unicode categorization, Wide_Wide_Character
13864
13865 @noindent
13866 This package provides subprograms that allow categorization of
13867 Wide_Wide_Character values according to Unicode categories.
13868
13869 @node Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)
13870 @section @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
13871 @cindex @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
13872 @cindex C Streams, Interfacing with @code{Wide_Wide_Text_IO}
13873
13874 @noindent
13875 This package provides subprograms that allow interfacing between
13876 C streams and @code{Wide_Wide_Text_IO}.  The stream identifier can be
13877 extracted from a file opened on the Ada side, and an Ada file
13878 can be constructed from a stream opened on the C side.
13879
13880 @node Ada.Wide_Wide_Text_IO.Reset_Standard_Files (a-zrstfi.ads)
13881 @section @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@file{a-zrstfi.ads})
13882 @cindex @code{Ada.Wide_Wide_Text_IO.Reset_Standard_Files} (@file{a-zrstfi.ads})
13883 @cindex @code{Wide_Wide_Text_IO} resetting standard files
13884
13885 @noindent
13886 This procedure is used to reset the status of the standard files used
13887 by Ada.Wide_Wide_Text_IO. This is useful in a situation (such as a
13888 restart in an embedded application) where the status of the files may
13889 change during execution (for example a standard input file may be
13890 redefined to be interactive).
13891
13892 @node GNAT.Altivec (g-altive.ads)
13893 @section @code{GNAT.Altivec} (@file{g-altive.ads})
13894 @cindex @code{GNAT.Altivec} (@file{g-altive.ads})
13895 @cindex AltiVec
13896
13897 @noindent
13898 This is the root package of the GNAT AltiVec binding. It provides
13899 definitions of constants and types common to all the versions of the
13900 binding.
13901
13902 @node GNAT.Altivec.Conversions (g-altcon.ads)
13903 @section @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
13904 @cindex @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
13905 @cindex AltiVec
13906
13907 @noindent
13908 This package provides the Vector/View conversion routines.
13909
13910 @node GNAT.Altivec.Vector_Operations (g-alveop.ads)
13911 @section @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
13912 @cindex @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
13913 @cindex AltiVec
13914
13915 @noindent
13916 This package exposes the Ada interface to the AltiVec operations on
13917 vector objects. A soft emulation is included by default in the GNAT
13918 library. The hard binding is provided as a separate package. This unit
13919 is common to both bindings.
13920
13921 @node GNAT.Altivec.Vector_Types (g-alvety.ads)
13922 @section @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
13923 @cindex @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
13924 @cindex AltiVec
13925
13926 @noindent
13927 This package exposes the various vector types part of the Ada binding
13928 to AltiVec facilities.
13929
13930 @node GNAT.Altivec.Vector_Views (g-alvevi.ads)
13931 @section @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
13932 @cindex @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
13933 @cindex AltiVec
13934
13935 @noindent
13936 This package provides public 'View' data types from/to which private
13937 vector representations can be converted via
13938 GNAT.Altivec.Conversions. This allows convenient access to individual
13939 vector elements and provides a simple way to initialize vector
13940 objects.
13941
13942 @node GNAT.Array_Split (g-arrspl.ads)
13943 @section @code{GNAT.Array_Split} (@file{g-arrspl.ads})
13944 @cindex @code{GNAT.Array_Split} (@file{g-arrspl.ads})
13945 @cindex Array splitter
13946
13947 @noindent
13948 Useful array-manipulation routines: given a set of separators, split
13949 an array wherever the separators appear, and provide direct access
13950 to the resulting slices.
13951
13952 @node GNAT.AWK (g-awk.ads)
13953 @section @code{GNAT.AWK} (@file{g-awk.ads})
13954 @cindex @code{GNAT.AWK} (@file{g-awk.ads})
13955 @cindex Parsing
13956 @cindex AWK
13957
13958 @noindent
13959 Provides AWK-like parsing functions, with an easy interface for parsing one
13960 or more files containing formatted data.  The file is viewed as a database
13961 where each record is a line and a field is a data element in this line.
13962
13963 @node GNAT.Bounded_Buffers (g-boubuf.ads)
13964 @section @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
13965 @cindex @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
13966 @cindex Parsing
13967 @cindex Bounded Buffers
13968
13969 @noindent
13970 Provides a concurrent generic bounded buffer abstraction.  Instances are
13971 useful directly or as parts of the implementations of other abstractions,
13972 such as mailboxes.
13973
13974 @node GNAT.Bounded_Mailboxes (g-boumai.ads)
13975 @section @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
13976 @cindex @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
13977 @cindex Parsing
13978 @cindex Mailboxes
13979
13980 @noindent
13981 Provides a thread-safe asynchronous intertask mailbox communication facility.
13982
13983 @node GNAT.Bubble_Sort (g-bubsor.ads)
13984 @section @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
13985 @cindex @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
13986 @cindex Sorting
13987 @cindex Bubble sort
13988
13989 @noindent
13990 Provides a general implementation of bubble sort usable for sorting arbitrary
13991 data items.  Exchange and comparison procedures are provided by passing
13992 access-to-procedure values.
13993
13994 @node GNAT.Bubble_Sort_A (g-busora.ads)
13995 @section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
13996 @cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
13997 @cindex Sorting
13998 @cindex Bubble sort
13999
14000 @noindent
14001 Provides a general implementation of bubble sort usable for sorting arbitrary
14002 data items.  Move and comparison procedures are provided by passing
14003 access-to-procedure values. This is an older version, retained for
14004 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
14005
14006 @node GNAT.Bubble_Sort_G (g-busorg.ads)
14007 @section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
14008 @cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
14009 @cindex Sorting
14010 @cindex Bubble sort
14011
14012 @noindent
14013 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
14014 are provided as generic parameters, this improves efficiency, especially
14015 if the procedures can be inlined, at the expense of duplicating code for
14016 multiple instantiations.
14017
14018 @node GNAT.Byte_Order_Mark (g-byorma.ads)
14019 @section @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
14020 @cindex @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
14021 @cindex UTF-8 representation
14022 @cindex Wide characte representations
14023
14024 @noindent
14025 Provides a routine which given a string, reads the start of the string to
14026 see whether it is one of the standard byte order marks (BOM's) which signal
14027 the encoding of the string. The routine includes detection of special XML
14028 sequences for various UCS input formats.
14029
14030 @node GNAT.Byte_Swapping (g-bytswa.ads)
14031 @section @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
14032 @cindex @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
14033 @cindex Byte swapping
14034 @cindex Endian
14035
14036 @noindent
14037 General routines for swapping the bytes in 2-, 4-, and 8-byte quantities.
14038 Machine-specific implementations are available in some cases.
14039
14040 @node GNAT.Calendar (g-calend.ads)
14041 @section @code{GNAT.Calendar} (@file{g-calend.ads})
14042 @cindex @code{GNAT.Calendar} (@file{g-calend.ads})
14043 @cindex @code{Calendar}
14044
14045 @noindent
14046 Extends the facilities provided by @code{Ada.Calendar} to include handling
14047 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
14048 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
14049 C @code{timeval} format.
14050
14051 @node GNAT.Calendar.Time_IO (g-catiio.ads)
14052 @section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
14053 @cindex @code{Calendar}
14054 @cindex Time
14055 @cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
14056
14057 @node GNAT.CRC32 (g-crc32.ads)
14058 @section @code{GNAT.CRC32} (@file{g-crc32.ads})
14059 @cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
14060 @cindex CRC32
14061 @cindex Cyclic Redundancy Check
14062
14063 @noindent
14064 This package implements the CRC-32 algorithm.  For a full description
14065 of this algorithm see
14066 ``Computation of Cyclic Redundancy Checks via Table Look-Up'',
14067 @cite{Communications of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013,
14068 Aug.@: 1988.  Sarwate, D.V@.
14069
14070 @node GNAT.Case_Util (g-casuti.ads)
14071 @section @code{GNAT.Case_Util} (@file{g-casuti.ads})
14072 @cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
14073 @cindex Casing utilities
14074 @cindex Character handling (@code{GNAT.Case_Util})
14075
14076 @noindent
14077 A set of simple routines for handling upper and lower casing of strings
14078 without the overhead of the full casing tables
14079 in @code{Ada.Characters.Handling}.
14080
14081 @node GNAT.CGI (g-cgi.ads)
14082 @section @code{GNAT.CGI} (@file{g-cgi.ads})
14083 @cindex @code{GNAT.CGI} (@file{g-cgi.ads})
14084 @cindex CGI (Common Gateway Interface)
14085
14086 @noindent
14087 This is a package for interfacing a GNAT program with a Web server via the
14088 Common Gateway Interface (CGI)@.  Basically this package parses the CGI
14089 parameters, which are a set of key/value pairs sent by the Web server.  It
14090 builds a table whose index is the key and provides some services to deal
14091 with this table.
14092
14093 @node GNAT.CGI.Cookie (g-cgicoo.ads)
14094 @section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
14095 @cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
14096 @cindex CGI (Common Gateway Interface) cookie support
14097 @cindex Cookie support in CGI
14098
14099 @noindent
14100 This is a package to interface a GNAT program with a Web server via the
14101 Common Gateway Interface (CGI).  It exports services to deal with Web
14102 cookies (piece of information kept in the Web client software).
14103
14104 @node GNAT.CGI.Debug (g-cgideb.ads)
14105 @section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
14106 @cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
14107 @cindex CGI (Common Gateway Interface) debugging
14108
14109 @noindent
14110 This is a package to help debugging CGI (Common Gateway Interface)
14111 programs written in Ada.
14112
14113 @node GNAT.Command_Line (g-comlin.ads)
14114 @section @code{GNAT.Command_Line} (@file{g-comlin.ads})
14115 @cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
14116 @cindex Command line
14117
14118 @noindent
14119 Provides a high level interface to @code{Ada.Command_Line} facilities,
14120 including the ability to scan for named switches with optional parameters
14121 and expand file names using wild card notations.
14122
14123 @node GNAT.Compiler_Version (g-comver.ads)
14124 @section @code{GNAT.Compiler_Version} (@file{g-comver.ads})
14125 @cindex @code{GNAT.Compiler_Version} (@file{g-comver.ads})
14126 @cindex Compiler Version
14127 @cindex Version, of compiler
14128
14129 @noindent
14130 Provides a routine for obtaining the version of the compiler used to
14131 compile the program. More accurately this is the version of the binder
14132 used to bind the program (this will normally be the same as the version
14133 of the compiler if a consistent tool set is used to compile all units
14134 of a partition).
14135
14136 @node GNAT.Ctrl_C (g-ctrl_c.ads)
14137 @section @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
14138 @cindex @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
14139 @cindex Interrupt
14140
14141 @noindent
14142 Provides a simple interface to handle Ctrl-C keyboard events.
14143
14144 @node GNAT.Current_Exception (g-curexc.ads)
14145 @section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
14146 @cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
14147 @cindex Current exception
14148 @cindex Exception retrieval
14149
14150 @noindent
14151 Provides access to information on the current exception that has been raised
14152 without the need for using the Ada 95 / Ada 2005 exception choice parameter
14153 specification syntax.
14154 This is particularly useful in simulating typical facilities for
14155 obtaining information about exceptions provided by Ada 83 compilers.
14156
14157 @node GNAT.Debug_Pools (g-debpoo.ads)
14158 @section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
14159 @cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
14160 @cindex Debugging
14161 @cindex Debug pools
14162 @cindex Memory corruption debugging
14163
14164 @noindent
14165 Provide a debugging storage pools that helps tracking memory corruption
14166 problems.  @xref{The GNAT Debug Pool Facility,,, gnat_ugn,
14167 @value{EDITION} User's Guide}.
14168
14169 @node GNAT.Debug_Utilities (g-debuti.ads)
14170 @section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
14171 @cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
14172 @cindex Debugging
14173
14174 @noindent
14175 Provides a few useful utilities for debugging purposes, including conversion
14176 to and from string images of address values. Supports both C and Ada formats
14177 for hexadecimal literals.
14178
14179 @node GNAT.Decode_String (g-decstr.ads)
14180 @section @code{GNAT.Decode_String} (@file{g-decstr.ads})
14181 @cindex @code{GNAT.Decode_String} (@file{g-decstr.ads})
14182 @cindex Decoding strings
14183 @cindex String decoding
14184 @cindex Wide character encoding
14185 @cindex UTF-8
14186 @cindex Unicode
14187
14188 @noindent
14189 A generic package providing routines for decoding wide character and wide wide
14190 character strings encoded as sequences of 8-bit characters using a specified
14191 encoding method. Includes validation routines, and also routines for stepping
14192 to next or previous encoded character in an encoded string.
14193 Useful in conjunction with Unicode character coding. Note there is a
14194 preinstantiation for UTF-8. See next entry.
14195
14196 @node GNAT.Decode_UTF8_String (g-deutst.ads)
14197 @section @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
14198 @cindex @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
14199 @cindex Decoding strings
14200 @cindex Decoding UTF-8 strings
14201 @cindex UTF-8 string decoding
14202 @cindex Wide character decoding
14203 @cindex UTF-8
14204 @cindex Unicode
14205
14206 @noindent
14207 A preinstantiation of GNAT.Decode_Strings for UTF-8 encoding.
14208
14209 @node GNAT.Directory_Operations (g-dirope.ads)
14210 @section @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
14211 @cindex @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
14212 @cindex Directory operations
14213
14214 @noindent
14215 Provides a set of routines for manipulating directories, including changing
14216 the current directory, making new directories, and scanning the files in a
14217 directory.
14218
14219 @node GNAT.Directory_Operations.Iteration (g-diopit.ads)
14220 @section @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
14221 @cindex @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
14222 @cindex Directory operations iteration
14223
14224 @noindent
14225 A child unit of GNAT.Directory_Operations providing additional operations
14226 for iterating through directories.
14227
14228 @node GNAT.Dynamic_HTables (g-dynhta.ads)
14229 @section @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
14230 @cindex @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
14231 @cindex Hash tables
14232
14233 @noindent
14234 A generic implementation of hash tables that can be used to hash arbitrary
14235 data.  Provided in two forms, a simple form with built in hash functions,
14236 and a more complex form in which the hash function is supplied.
14237
14238 @noindent
14239 This package provides a facility similar to that of @code{GNAT.HTable},
14240 except that this package declares a type that can be used to define
14241 dynamic instances of the hash table, while an instantiation of
14242 @code{GNAT.HTable} creates a single instance of the hash table.
14243
14244 @node GNAT.Dynamic_Tables (g-dyntab.ads)
14245 @section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
14246 @cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
14247 @cindex Table implementation
14248 @cindex Arrays, extendable
14249
14250 @noindent
14251 A generic package providing a single dimension array abstraction where the
14252 length of the array can be dynamically modified.
14253
14254 @noindent
14255 This package provides a facility similar to that of @code{GNAT.Table},
14256 except that this package declares a type that can be used to define
14257 dynamic instances of the table, while an instantiation of
14258 @code{GNAT.Table} creates a single instance of the table type.
14259
14260 @node GNAT.Encode_String (g-encstr.ads)
14261 @section @code{GNAT.Encode_String} (@file{g-encstr.ads})
14262 @cindex @code{GNAT.Encode_String} (@file{g-encstr.ads})
14263 @cindex Encoding strings
14264 @cindex String encoding
14265 @cindex Wide character encoding
14266 @cindex UTF-8
14267 @cindex Unicode
14268
14269 @noindent
14270 A generic package providing routines for encoding wide character and wide
14271 wide character strings as sequences of 8-bit characters using a specified
14272 encoding method. Useful in conjunction with Unicode character coding.
14273 Note there is a preinstantiation for UTF-8. See next entry.
14274
14275 @node GNAT.Encode_UTF8_String (g-enutst.ads)
14276 @section @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
14277 @cindex @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
14278 @cindex Encoding strings
14279 @cindex Encoding UTF-8 strings
14280 @cindex UTF-8 string encoding
14281 @cindex Wide character encoding
14282 @cindex UTF-8
14283 @cindex Unicode
14284
14285 @noindent
14286 A preinstantiation of GNAT.Encode_Strings for UTF-8 encoding.
14287
14288 @node GNAT.Exception_Actions (g-excact.ads)
14289 @section @code{GNAT.Exception_Actions} (@file{g-excact.ads})
14290 @cindex @code{GNAT.Exception_Actions} (@file{g-excact.ads})
14291 @cindex Exception actions
14292
14293 @noindent
14294 Provides callbacks when an exception is raised. Callbacks can be registered
14295 for specific exceptions, or when any exception is raised. This
14296 can be used for instance to force a core dump to ease debugging.
14297
14298 @node GNAT.Exception_Traces (g-exctra.ads)
14299 @section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
14300 @cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
14301 @cindex Exception traces
14302 @cindex Debugging
14303
14304 @noindent
14305 Provides an interface allowing to control automatic output upon exception
14306 occurrences.
14307
14308 @node GNAT.Exceptions (g-except.ads)
14309 @section @code{GNAT.Exceptions} (@file{g-expect.ads})
14310 @cindex @code{GNAT.Exceptions} (@file{g-expect.ads})
14311 @cindex Exceptions, Pure
14312 @cindex Pure packages, exceptions
14313
14314 @noindent
14315 Normally it is not possible to raise an exception with
14316 a message from a subprogram in a pure package, since the
14317 necessary types and subprograms are in @code{Ada.Exceptions}
14318 which is not a pure unit. @code{GNAT.Exceptions} provides a
14319 facility for getting around this limitation for a few
14320 predefined exceptions, and for example allow raising
14321 @code{Constraint_Error} with a message from a pure subprogram.
14322
14323 @node GNAT.Expect (g-expect.ads)
14324 @section @code{GNAT.Expect} (@file{g-expect.ads})
14325 @cindex @code{GNAT.Expect} (@file{g-expect.ads})
14326
14327 @noindent
14328 Provides a set of subprograms similar to what is available
14329 with the standard Tcl Expect tool.
14330 It allows you to easily spawn and communicate with an external process.
14331 You can send commands or inputs to the process, and compare the output
14332 with some expected regular expression. Currently @code{GNAT.Expect}
14333 is implemented on all native GNAT ports except for OpenVMS@.
14334 It is not implemented for cross ports, and in particular is not
14335 implemented for VxWorks or LynxOS@.
14336
14337 @node GNAT.Float_Control (g-flocon.ads)
14338 @section @code{GNAT.Float_Control} (@file{g-flocon.ads})
14339 @cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
14340 @cindex Floating-Point Processor
14341
14342 @noindent
14343 Provides an interface for resetting the floating-point processor into the
14344 mode required for correct semantic operation in Ada.  Some third party
14345 library calls may cause this mode to be modified, and the Reset procedure
14346 in this package can be used to reestablish the required mode.
14347
14348 @node GNAT.Heap_Sort (g-heasor.ads)
14349 @section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
14350 @cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
14351 @cindex Sorting
14352
14353 @noindent
14354 Provides a general implementation of heap sort usable for sorting arbitrary
14355 data items. Exchange and comparison procedures are provided by passing
14356 access-to-procedure values.  The algorithm used is a modified heap sort
14357 that performs approximately N*log(N) comparisons in the worst case.
14358
14359 @node GNAT.Heap_Sort_A (g-hesora.ads)
14360 @section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
14361 @cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
14362 @cindex Sorting
14363
14364 @noindent
14365 Provides a general implementation of heap sort usable for sorting arbitrary
14366 data items. Move and comparison procedures are provided by passing
14367 access-to-procedure values.  The algorithm used is a modified heap sort
14368 that performs approximately N*log(N) comparisons in the worst case.
14369 This differs from @code{GNAT.Heap_Sort} in having a less convenient
14370 interface, but may be slightly more efficient.
14371
14372 @node GNAT.Heap_Sort_G (g-hesorg.ads)
14373 @section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
14374 @cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
14375 @cindex Sorting
14376
14377 @noindent
14378 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
14379 are provided as generic parameters, this improves efficiency, especially
14380 if the procedures can be inlined, at the expense of duplicating code for
14381 multiple instantiations.
14382
14383 @node GNAT.HTable (g-htable.ads)
14384 @section @code{GNAT.HTable} (@file{g-htable.ads})
14385 @cindex @code{GNAT.HTable} (@file{g-htable.ads})
14386 @cindex Hash tables
14387
14388 @noindent
14389 A generic implementation of hash tables that can be used to hash arbitrary
14390 data.  Provides two approaches, one a simple static approach, and the other
14391 allowing arbitrary dynamic hash tables.
14392
14393 @node GNAT.IO (g-io.ads)
14394 @section @code{GNAT.IO} (@file{g-io.ads})
14395 @cindex @code{GNAT.IO} (@file{g-io.ads})
14396 @cindex Simple I/O
14397 @cindex Input/Output facilities
14398
14399 @noindent
14400 A simple preelaborable input-output package that provides a subset of
14401 simple Text_IO functions for reading characters and strings from
14402 Standard_Input, and writing characters, strings and integers to either
14403 Standard_Output or Standard_Error.
14404
14405 @node GNAT.IO_Aux (g-io_aux.ads)
14406 @section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
14407 @cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
14408 @cindex Text_IO
14409 @cindex Input/Output facilities
14410
14411 Provides some auxiliary functions for use with Text_IO, including a test
14412 for whether a file exists, and functions for reading a line of text.
14413
14414 @node GNAT.Lock_Files (g-locfil.ads)
14415 @section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
14416 @cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
14417 @cindex File locking
14418 @cindex Locking using files
14419
14420 @noindent
14421 Provides a general interface for using files as locks.  Can be used for
14422 providing program level synchronization.
14423
14424 @node GNAT.MD5 (g-md5.ads)
14425 @section @code{GNAT.MD5} (@file{g-md5.ads})
14426 @cindex @code{GNAT.MD5} (@file{g-md5.ads})
14427 @cindex Message Digest MD5
14428
14429 @noindent
14430 Implements the MD5 Message-Digest Algorithm as described in RFC 1321.
14431
14432 @node GNAT.Memory_Dump (g-memdum.ads)
14433 @section @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
14434 @cindex @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
14435 @cindex Dump Memory
14436
14437 @noindent
14438 Provides a convenient routine for dumping raw memory to either the
14439 standard output or standard error files. Uses GNAT.IO for actual
14440 output.
14441
14442 @node GNAT.Most_Recent_Exception (g-moreex.ads)
14443 @section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
14444 @cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
14445 @cindex Exception, obtaining most recent
14446
14447 @noindent
14448 Provides access to the most recently raised exception.  Can be used for
14449 various logging purposes, including duplicating functionality of some
14450 Ada 83 implementation dependent extensions.
14451
14452 @node GNAT.OS_Lib (g-os_lib.ads)
14453 @section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
14454 @cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
14455 @cindex Operating System interface
14456 @cindex Spawn capability
14457
14458 @noindent
14459 Provides a range of target independent operating system interface functions,
14460 including time/date management, file operations, subprocess management,
14461 including a portable spawn procedure, and access to environment variables
14462 and error return codes.
14463
14464 @node GNAT.Perfect_Hash_Generators (g-pehage.ads)
14465 @section @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
14466 @cindex @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
14467 @cindex Hash functions
14468
14469 @noindent
14470 Provides a generator of static minimal perfect hash functions. No
14471 collisions occur and each item can be retrieved from the table in one
14472 probe (perfect property). The hash table size corresponds to the exact
14473 size of the key set and no larger (minimal property). The key set has to
14474 be know in advance (static property). The hash functions are also order
14475 preserving. If w2 is inserted after w1 in the generator, their
14476 hashcode are in the same order. These hashing functions are very
14477 convenient for use with realtime applications.
14478
14479 @node GNAT.Random_Numbers (g-rannum.ads)
14480 @section @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
14481 @cindex @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
14482 @cindex Random number generation
14483
14484 @noindent
14485 Provides random number capabilities which extend those available in the
14486 standard Ada library and are more convenient to use.
14487
14488 @node GNAT.Regexp (g-regexp.ads)
14489 @section @code{GNAT.Regexp} (@file{g-regexp.ads})
14490 @cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
14491 @cindex Regular expressions
14492 @cindex Pattern matching
14493
14494 @noindent
14495 A simple implementation of regular expressions, using a subset of regular
14496 expression syntax copied from familiar Unix style utilities.  This is the
14497 simples of the three pattern matching packages provided, and is particularly
14498 suitable for ``file globbing'' applications.
14499
14500 @node GNAT.Registry (g-regist.ads)
14501 @section @code{GNAT.Registry} (@file{g-regist.ads})
14502 @cindex @code{GNAT.Registry} (@file{g-regist.ads})
14503 @cindex Windows Registry
14504
14505 @noindent
14506 This is a high level binding to the Windows registry.  It is possible to
14507 do simple things like reading a key value, creating a new key.  For full
14508 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
14509 package provided with the Win32Ada binding
14510
14511 @node GNAT.Regpat (g-regpat.ads)
14512 @section @code{GNAT.Regpat} (@file{g-regpat.ads})
14513 @cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
14514 @cindex Regular expressions
14515 @cindex Pattern matching
14516
14517 @noindent
14518 A complete implementation of Unix-style regular expression matching, copied
14519 from the original V7 style regular expression library written in C by
14520 Henry Spencer (and binary compatible with this C library).
14521
14522 @node GNAT.Secondary_Stack_Info (g-sestin.ads)
14523 @section @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
14524 @cindex @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
14525 @cindex Secondary Stack Info
14526
14527 @noindent
14528 Provide the capability to query the high water mark of the current task's
14529 secondary stack.
14530
14531 @node GNAT.Semaphores (g-semaph.ads)
14532 @section @code{GNAT.Semaphores} (@file{g-semaph.ads})
14533 @cindex @code{GNAT.Semaphores} (@file{g-semaph.ads})
14534 @cindex Semaphores
14535
14536 @noindent
14537 Provides classic counting and binary semaphores using protected types.
14538
14539 @node GNAT.Serial_Communications (g-sercom.ads)
14540 @section @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
14541 @cindex @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
14542 @cindex Serial_Communications
14543
14544 @noindent
14545 Provides a simple interface to send and receive data over a serial
14546 port. This is only supported on GNU/Linux and Windows.
14547
14548 @node GNAT.SHA1 (g-sha1.ads)
14549 @section @code{GNAT.SHA1} (@file{g-sha1.ads})
14550 @cindex @code{GNAT.SHA1} (@file{g-sha1.ads})
14551 @cindex Secure Hash Algorithm SHA-1
14552
14553 @noindent
14554 Implements the SHA-1 Secure Hash Algorithm as described in RFC 3174.
14555
14556 @node GNAT.Signals (g-signal.ads)
14557 @section @code{GNAT.Signals} (@file{g-signal.ads})
14558 @cindex @code{GNAT.Signals} (@file{g-signal.ads})
14559 @cindex Signals
14560
14561 @noindent
14562 Provides the ability to manipulate the blocked status of signals on supported
14563 targets.
14564
14565 @node GNAT.Sockets (g-socket.ads)
14566 @section @code{GNAT.Sockets} (@file{g-socket.ads})
14567 @cindex @code{GNAT.Sockets} (@file{g-socket.ads})
14568 @cindex Sockets
14569
14570 @noindent
14571 A high level and portable interface to develop sockets based applications.
14572 This package is based on the sockets thin binding found in
14573 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
14574 on all native GNAT ports except for OpenVMS@.  It is not implemented
14575 for the LynxOS@ cross port.
14576
14577 @node GNAT.Source_Info (g-souinf.ads)
14578 @section @code{GNAT.Source_Info} (@file{g-souinf.ads})
14579 @cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
14580 @cindex Source Information
14581
14582 @noindent
14583 Provides subprograms that give access to source code information known at
14584 compile time, such as the current file name and line number.
14585
14586 @node GNAT.Spelling_Checker (g-speche.ads)
14587 @section @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
14588 @cindex @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
14589 @cindex Spell checking
14590
14591 @noindent
14592 Provides a function for determining whether one string is a plausible
14593 near misspelling of another string.
14594
14595 @node GNAT.Spelling_Checker_Generic (g-spchge.ads)
14596 @section @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
14597 @cindex @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
14598 @cindex Spell checking
14599
14600 @noindent
14601 Provides a generic function that can be instantiated with a string type for
14602 determining whether one string is a plausible near misspelling of another
14603 string.
14604
14605 @node GNAT.Spitbol.Patterns (g-spipat.ads)
14606 @section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
14607 @cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
14608 @cindex SPITBOL pattern matching
14609 @cindex Pattern matching
14610
14611 @noindent
14612 A complete implementation of SNOBOL4 style pattern matching.  This is the
14613 most elaborate of the pattern matching packages provided.  It fully duplicates
14614 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
14615 efficient algorithm developed by Robert Dewar for the SPITBOL system.
14616
14617 @node GNAT.Spitbol (g-spitbo.ads)
14618 @section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
14619 @cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
14620 @cindex SPITBOL interface
14621
14622 @noindent
14623 The top level package of the collection of SPITBOL-style functionality, this
14624 package provides basic SNOBOL4 string manipulation functions, such as
14625 Pad, Reverse, Trim, Substr capability, as well as a generic table function
14626 useful for constructing arbitrary mappings from strings in the style of
14627 the SNOBOL4 TABLE function.
14628
14629 @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
14630 @section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
14631 @cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
14632 @cindex Sets of strings
14633 @cindex SPITBOL Tables
14634
14635 @noindent
14636 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
14637 for type @code{Standard.Boolean}, giving an implementation of sets of
14638 string values.
14639
14640 @node GNAT.Spitbol.Table_Integer (g-sptain.ads)
14641 @section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
14642 @cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
14643 @cindex Integer maps
14644 @cindex Maps
14645 @cindex SPITBOL Tables
14646
14647 @noindent
14648 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
14649 for type @code{Standard.Integer}, giving an implementation of maps
14650 from string to integer values.
14651
14652 @node GNAT.Spitbol.Table_VString (g-sptavs.ads)
14653 @section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
14654 @cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
14655 @cindex String maps
14656 @cindex Maps
14657 @cindex SPITBOL Tables
14658
14659 @noindent
14660 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
14661 a variable length string type, giving an implementation of general
14662 maps from strings to strings.
14663
14664 @node GNAT.SSE (g-sse.ads)
14665 @section @code{GNAT.SSE} (@file{g-sse.ads})
14666 @cindex @code{GNAT.SSE} (@file{g-sse.ads})
14667
14668 @noindent
14669 Root of a set of units aimed at offering Ada bindings to a subset of
14670 the Intel(r) Streaming SIMD Extensions with GNAT on the x86 family of
14671 targets.  It exposes vector component types together with a general
14672 introduction to the binding contents and use.
14673
14674 @node GNAT.SSE.Vector_Types (g-ssvety.ads)
14675 @section @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
14676 @cindex @code{GNAT.SSE.Vector_Types} (@file{g-ssvety.ads})
14677
14678 @noindent
14679 SSE vector types for use with SSE related intrinsics.
14680
14681 @node GNAT.Strings (g-string.ads)
14682 @section @code{GNAT.Strings} (@file{g-string.ads})
14683 @cindex @code{GNAT.Strings} (@file{g-string.ads})
14684
14685 @noindent
14686 Common String access types and related subprograms. Basically it
14687 defines a string access and an array of string access types.
14688
14689 @node GNAT.String_Split (g-strspl.ads)
14690 @section @code{GNAT.String_Split} (@file{g-strspl.ads})
14691 @cindex @code{GNAT.String_Split} (@file{g-strspl.ads})
14692 @cindex String splitter
14693
14694 @noindent
14695 Useful string manipulation routines: given a set of separators, split
14696 a string wherever the separators appear, and provide direct access
14697 to the resulting slices. This package is instantiated from
14698 @code{GNAT.Array_Split}.
14699
14700 @node GNAT.Table (g-table.ads)
14701 @section @code{GNAT.Table} (@file{g-table.ads})
14702 @cindex @code{GNAT.Table} (@file{g-table.ads})
14703 @cindex Table implementation
14704 @cindex Arrays, extendable
14705
14706 @noindent
14707 A generic package providing a single dimension array abstraction where the
14708 length of the array can be dynamically modified.
14709
14710 @noindent
14711 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
14712 except that this package declares a single instance of the table type,
14713 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
14714 used to define dynamic instances of the table.
14715
14716 @node GNAT.Task_Lock (g-tasloc.ads)
14717 @section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
14718 @cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
14719 @cindex Task synchronization
14720 @cindex Task locking
14721 @cindex Locking
14722
14723 @noindent
14724 A very simple facility for locking and unlocking sections of code using a
14725 single global task lock.  Appropriate for use in situations where contention
14726 between tasks is very rarely expected.
14727
14728 @node GNAT.Time_Stamp (g-timsta.ads)
14729 @section @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
14730 @cindex @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
14731 @cindex Time stamp
14732 @cindex Current time
14733
14734 @noindent
14735 Provides a simple function that returns a string YYYY-MM-DD HH:MM:SS.SS that
14736 represents the current date and time in ISO 8601 format. This is a very simple
14737 routine with minimal code and there are no dependencies on any other unit.
14738
14739 @node GNAT.Threads (g-thread.ads)
14740 @section @code{GNAT.Threads} (@file{g-thread.ads})
14741 @cindex @code{GNAT.Threads} (@file{g-thread.ads})
14742 @cindex Foreign threads
14743 @cindex Threads, foreign
14744
14745 @noindent
14746 Provides facilities for dealing with foreign threads which need to be known
14747 by the GNAT run-time system. Consult the documentation of this package for
14748 further details if your program has threads that are created by a non-Ada
14749 environment which then accesses Ada code.
14750
14751 @node GNAT.Traceback (g-traceb.ads)
14752 @section @code{GNAT.Traceback} (@file{g-traceb.ads})
14753 @cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
14754 @cindex Trace back facilities
14755
14756 @noindent
14757 Provides a facility for obtaining non-symbolic traceback information, useful
14758 in various debugging situations.
14759
14760 @node GNAT.Traceback.Symbolic (g-trasym.ads)
14761 @section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
14762 @cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
14763 @cindex Trace back facilities
14764
14765 @node GNAT.UTF_32 (g-utf_32.ads)
14766 @section @code{GNAT.UTF_32} (@file{g-table.ads})
14767 @cindex @code{GNAT.UTF_32} (@file{g-table.ads})
14768 @cindex Wide character codes
14769
14770 @noindent
14771 This is a package intended to be used in conjunction with the
14772 @code{Wide_Character} type in Ada 95 and the
14773 @code{Wide_Wide_Character} type in Ada 2005 (available
14774 in @code{GNAT} in Ada 2005 mode). This package contains
14775 Unicode categorization routines, as well as lexical
14776 categorization routines corresponding to the Ada 2005
14777 lexical rules for identifiers and strings, and also a
14778 lower case to upper case fold routine corresponding to
14779 the Ada 2005 rules for identifier equivalence.
14780
14781 @node GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)
14782 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
14783 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
14784 @cindex Spell checking
14785
14786 @noindent
14787 Provides a function for determining whether one wide wide string is a plausible
14788 near misspelling of another wide wide string, where the strings are represented
14789 using the UTF_32_String type defined in System.Wch_Cnv.
14790
14791 @node GNAT.Wide_Spelling_Checker (g-wispch.ads)
14792 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
14793 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
14794 @cindex Spell checking
14795
14796 @noindent
14797 Provides a function for determining whether one wide string is a plausible
14798 near misspelling of another wide string.
14799
14800 @node GNAT.Wide_String_Split (g-wistsp.ads)
14801 @section @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
14802 @cindex @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
14803 @cindex Wide_String splitter
14804
14805 @noindent
14806 Useful wide string manipulation routines: given a set of separators, split
14807 a wide string wherever the separators appear, and provide direct access
14808 to the resulting slices. This package is instantiated from
14809 @code{GNAT.Array_Split}.
14810
14811 @node GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)
14812 @section @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
14813 @cindex @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
14814 @cindex Spell checking
14815
14816 @noindent
14817 Provides a function for determining whether one wide wide string is a plausible
14818 near misspelling of another wide wide string.
14819
14820 @node GNAT.Wide_Wide_String_Split (g-zistsp.ads)
14821 @section @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
14822 @cindex @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
14823 @cindex Wide_Wide_String splitter
14824
14825 @noindent
14826 Useful wide wide string manipulation routines: given a set of separators, split
14827 a wide wide string wherever the separators appear, and provide direct access
14828 to the resulting slices. This package is instantiated from
14829 @code{GNAT.Array_Split}.
14830
14831 @node Interfaces.C.Extensions (i-cexten.ads)
14832 @section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
14833 @cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
14834
14835 @noindent
14836 This package contains additional C-related definitions, intended
14837 for use with either manually or automatically generated bindings
14838 to C libraries.
14839
14840 @node Interfaces.C.Streams (i-cstrea.ads)
14841 @section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
14842 @cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
14843 @cindex  C streams, interfacing
14844
14845 @noindent
14846 This package is a binding for the most commonly used operations
14847 on C streams.
14848
14849 @node Interfaces.CPP (i-cpp.ads)
14850 @section @code{Interfaces.CPP} (@file{i-cpp.ads})
14851 @cindex @code{Interfaces.CPP} (@file{i-cpp.ads})
14852 @cindex  C++ interfacing
14853 @cindex  Interfacing, to C++
14854
14855 @noindent
14856 This package provides facilities for use in interfacing to C++.  It
14857 is primarily intended to be used in connection with automated tools
14858 for the generation of C++ interfaces.
14859
14860 @node Interfaces.Packed_Decimal (i-pacdec.ads)
14861 @section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
14862 @cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
14863 @cindex  IBM Packed Format
14864 @cindex  Packed Decimal
14865
14866 @noindent
14867 This package provides a set of routines for conversions to and
14868 from a packed decimal format compatible with that used on IBM
14869 mainframes.
14870
14871 @node Interfaces.VxWorks (i-vxwork.ads)
14872 @section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
14873 @cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
14874 @cindex Interfacing to VxWorks
14875 @cindex VxWorks, interfacing
14876
14877 @noindent
14878 This package provides a limited binding to the VxWorks API.
14879 In particular, it interfaces with the
14880 VxWorks hardware interrupt facilities.
14881
14882 @node Interfaces.VxWorks.IO (i-vxwoio.ads)
14883 @section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
14884 @cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
14885 @cindex Interfacing to VxWorks' I/O
14886 @cindex VxWorks, I/O interfacing
14887 @cindex VxWorks, Get_Immediate
14888 @cindex Get_Immediate, VxWorks
14889
14890 @noindent
14891 This package provides a binding to the ioctl (IO/Control)
14892 function of VxWorks, defining a set of option values and
14893 function codes. A particular use of this package is
14894 to enable the use of Get_Immediate under VxWorks.
14895
14896 @node System.Address_Image (s-addima.ads)
14897 @section @code{System.Address_Image} (@file{s-addima.ads})
14898 @cindex @code{System.Address_Image} (@file{s-addima.ads})
14899 @cindex Address image
14900 @cindex Image, of an address
14901
14902 @noindent
14903 This function provides a useful debugging
14904 function that gives an (implementation dependent)
14905 string which identifies an address.
14906
14907 @node System.Assertions (s-assert.ads)
14908 @section @code{System.Assertions} (@file{s-assert.ads})
14909 @cindex @code{System.Assertions} (@file{s-assert.ads})
14910 @cindex Assertions
14911 @cindex Assert_Failure, exception
14912
14913 @noindent
14914 This package provides the declaration of the exception raised
14915 by an run-time assertion failure, as well as the routine that
14916 is used internally to raise this assertion.
14917
14918 @node System.Memory (s-memory.ads)
14919 @section @code{System.Memory} (@file{s-memory.ads})
14920 @cindex @code{System.Memory} (@file{s-memory.ads})
14921 @cindex Memory allocation
14922
14923 @noindent
14924 This package provides the interface to the low level routines used
14925 by the generated code for allocation and freeing storage for the
14926 default storage pool (analogous to the C routines malloc and free.
14927 It also provides a reallocation interface analogous to the C routine
14928 realloc. The body of this unit may be modified to provide alternative
14929 allocation mechanisms for the default pool, and in addition, direct
14930 calls to this unit may be made for low level allocation uses (for
14931 example see the body of @code{GNAT.Tables}).
14932
14933 @node System.Partition_Interface (s-parint.ads)
14934 @section @code{System.Partition_Interface} (@file{s-parint.ads})
14935 @cindex @code{System.Partition_Interface} (@file{s-parint.ads})
14936 @cindex Partition interfacing functions
14937
14938 @noindent
14939 This package provides facilities for partition interfacing.  It
14940 is used primarily in a distribution context when using Annex E
14941 with @code{GLADE}.
14942
14943 @node System.Pool_Global (s-pooglo.ads)
14944 @section @code{System.Pool_Global} (@file{s-pooglo.ads})
14945 @cindex @code{System.Pool_Global} (@file{s-pooglo.ads})
14946 @cindex Storage pool, global
14947 @cindex Global storage pool
14948
14949 @noindent
14950 This package provides a storage pool that is equivalent to the default
14951 storage pool used for access types for which no pool is specifically
14952 declared. It uses malloc/free to allocate/free and does not attempt to
14953 do any automatic reclamation.
14954
14955 @node System.Pool_Local (s-pooloc.ads)
14956 @section @code{System.Pool_Local} (@file{s-pooloc.ads})
14957 @cindex @code{System.Pool_Local} (@file{s-pooloc.ads})
14958 @cindex Storage pool, local
14959 @cindex Local storage pool
14960
14961 @noindent
14962 This package provides a storage pool that is intended for use with locally
14963 defined access types. It uses malloc/free for allocate/free, and maintains
14964 a list of allocated blocks, so that all storage allocated for the pool can
14965 be freed automatically when the pool is finalized.
14966
14967 @node System.Restrictions (s-restri.ads)
14968 @section @code{System.Restrictions} (@file{s-restri.ads})
14969 @cindex @code{System.Restrictions} (@file{s-restri.ads})
14970 @cindex Run-time restrictions access
14971
14972 @noindent
14973 This package provides facilities for accessing at run time
14974 the status of restrictions specified at compile time for
14975 the partition. Information is available both with regard
14976 to actual restrictions specified, and with regard to
14977 compiler determined information on which restrictions
14978 are violated by one or more packages in the partition.
14979
14980 @node System.Rident (s-rident.ads)
14981 @section @code{System.Rident} (@file{s-rident.ads})
14982 @cindex @code{System.Rident} (@file{s-rident.ads})
14983 @cindex Restrictions definitions
14984
14985 @noindent
14986 This package provides definitions of the restrictions
14987 identifiers supported by GNAT, and also the format of
14988 the restrictions provided in package System.Restrictions.
14989 It is not normally necessary to @code{with} this generic package
14990 since the necessary instantiation is included in
14991 package System.Restrictions.
14992
14993 @node System.Strings.Stream_Ops (s-ststop.ads)
14994 @section @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
14995 @cindex @code{System.Strings.Stream_Ops} (@file{s-ststop.ads})
14996 @cindex Stream operations
14997 @cindex String stream operations
14998
14999 @noindent
15000 This package provides a set of stream subprograms for standard string types.
15001 It is intended primarily to support implicit use of such subprograms when
15002 stream attributes are applied to string types, but the subprograms in this
15003 package can be used directly by application programs.
15004
15005 @node System.Task_Info (s-tasinf.ads)
15006 @section @code{System.Task_Info} (@file{s-tasinf.ads})
15007 @cindex @code{System.Task_Info} (@file{s-tasinf.ads})
15008 @cindex Task_Info pragma
15009
15010 @noindent
15011 This package provides target dependent functionality that is used
15012 to support the @code{Task_Info} pragma
15013
15014 @node System.Wch_Cnv (s-wchcnv.ads)
15015 @section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
15016 @cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
15017 @cindex Wide Character, Representation
15018 @cindex Wide String, Conversion
15019 @cindex Representation of wide characters
15020
15021 @noindent
15022 This package provides routines for converting between
15023 wide and wide wide characters and a representation as a value of type
15024 @code{Standard.String}, using a specified wide character
15025 encoding method.  It uses definitions in
15026 package @code{System.Wch_Con}.
15027
15028 @node System.Wch_Con (s-wchcon.ads)
15029 @section @code{System.Wch_Con} (@file{s-wchcon.ads})
15030 @cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
15031
15032 @noindent
15033 This package provides definitions and descriptions of
15034 the various methods used for encoding wide characters
15035 in ordinary strings.  These definitions are used by
15036 the package @code{System.Wch_Cnv}.
15037
15038 @node Interfacing to Other Languages
15039 @chapter Interfacing to Other Languages
15040 @noindent
15041 The facilities in annex B of the Ada Reference Manual are fully
15042 implemented in GNAT, and in addition, a full interface to C++ is
15043 provided.
15044
15045 @menu
15046 * Interfacing to C::
15047 * Interfacing to C++::
15048 * Interfacing to COBOL::
15049 * Interfacing to Fortran::
15050 * Interfacing to non-GNAT Ada code::
15051 @end menu
15052
15053 @node Interfacing to C
15054 @section Interfacing to C
15055
15056 @noindent
15057 Interfacing to C with GNAT can use one of two approaches:
15058
15059 @itemize @bullet
15060 @item
15061 The types in the package @code{Interfaces.C} may be used.
15062 @item
15063 Standard Ada types may be used directly.  This may be less portable to
15064 other compilers, but will work on all GNAT compilers, which guarantee
15065 correspondence between the C and Ada types.
15066 @end itemize
15067
15068 @noindent
15069 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
15070 effect, since this is the default.  The following table shows the
15071 correspondence between Ada scalar types and the corresponding C types.
15072
15073 @table @code
15074 @item Integer
15075 @code{int}
15076 @item Short_Integer
15077 @code{short}
15078 @item Short_Short_Integer
15079 @code{signed char}
15080 @item Long_Integer
15081 @code{long}
15082 @item Long_Long_Integer
15083 @code{long long}
15084 @item Short_Float
15085 @code{float}
15086 @item Float
15087 @code{float}
15088 @item Long_Float
15089 @code{double}
15090 @item Long_Long_Float
15091 This is the longest floating-point type supported by the hardware.
15092 @end table
15093
15094 @noindent
15095 Additionally, there are the following general correspondences between Ada
15096 and C types:
15097 @itemize @bullet
15098 @item
15099 Ada enumeration types map to C enumeration types directly if pragma
15100 @code{Convention C} is specified, which causes them to have int
15101 length.  Without pragma @code{Convention C}, Ada enumeration types map to
15102 8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short},
15103 @code{int}, respectively) depending on the number of values passed.
15104 This is the only case in which pragma @code{Convention C} affects the
15105 representation of an Ada type.
15106
15107 @item
15108 Ada access types map to C pointers, except for the case of pointers to
15109 unconstrained types in Ada, which have no direct C equivalent.
15110
15111 @item
15112 Ada arrays map directly to C arrays.
15113
15114 @item
15115 Ada records map directly to C structures.
15116
15117 @item
15118 Packed Ada records map to C structures where all members are bit fields
15119 of the length corresponding to the @code{@var{type}'Size} value in Ada.
15120 @end itemize
15121
15122 @node Interfacing to C++
15123 @section Interfacing to C++
15124
15125 @noindent
15126 The interface to C++ makes use of the following pragmas, which are
15127 primarily intended to be constructed automatically using a binding generator
15128 tool, although it is possible to construct them by hand.  No suitable binding
15129 generator tool is supplied with GNAT though.
15130
15131 Using these pragmas it is possible to achieve complete
15132 inter-operability between Ada tagged types and C++ class definitions.
15133 See @ref{Implementation Defined Pragmas}, for more details.
15134
15135 @table @code
15136 @item pragma CPP_Class ([Entity =>] @var{LOCAL_NAME})
15137 The argument denotes an entity in the current declarative region that is
15138 declared as a tagged or untagged record type. It indicates that the type
15139 corresponds to an externally declared C++ class type, and is to be laid
15140 out the same way that C++ would lay out the type.
15141
15142 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
15143 for backward compatibility but its functionality is available
15144 using pragma @code{Import} with @code{Convention} = @code{CPP}.
15145
15146 @item pragma CPP_Constructor ([Entity =>] @var{LOCAL_NAME})
15147 This pragma identifies an imported function (imported in the usual way
15148 with pragma @code{Import}) as corresponding to a C++ constructor.
15149 @end table
15150
15151 @node Interfacing to COBOL
15152 @section Interfacing to COBOL
15153
15154 @noindent
15155 Interfacing to COBOL is achieved as described in section B.4 of
15156 the Ada Reference Manual.
15157
15158 @node Interfacing to Fortran
15159 @section Interfacing to Fortran
15160
15161 @noindent
15162 Interfacing to Fortran is achieved as described in section B.5 of the
15163 Ada Reference Manual.  The pragma @code{Convention Fortran}, applied to a
15164 multi-dimensional array causes the array to be stored in column-major
15165 order as required for convenient interface to Fortran.
15166
15167 @node Interfacing to non-GNAT Ada code
15168 @section Interfacing to non-GNAT Ada code
15169
15170 It is possible to specify the convention @code{Ada} in a pragma
15171 @code{Import} or pragma @code{Export}.  However this refers to
15172 the calling conventions used by GNAT, which may or may not be
15173 similar enough to those used by some other Ada 83 / Ada 95 / Ada 2005
15174 compiler to allow interoperation.
15175
15176 If arguments types are kept simple, and if the foreign compiler generally
15177 follows system calling conventions, then it may be possible to integrate
15178 files compiled by other Ada compilers, provided that the elaboration
15179 issues are adequately addressed (for example by eliminating the
15180 need for any load time elaboration).
15181
15182 In particular, GNAT running on VMS is designed to
15183 be highly compatible with the DEC Ada 83 compiler, so this is one
15184 case in which it is possible to import foreign units of this type,
15185 provided that the data items passed are restricted to simple scalar
15186 values or simple record types without variants, or simple array
15187 types with fixed bounds.
15188
15189 @node Specialized Needs Annexes
15190 @chapter Specialized Needs Annexes
15191
15192 @noindent
15193 Ada 95 and Ada 2005 define a number of Specialized Needs Annexes, which are not
15194 required in all implementations.  However, as described in this chapter,
15195 GNAT implements all of these annexes:
15196
15197 @table @asis
15198 @item Systems Programming (Annex C)
15199 The Systems Programming Annex is fully implemented.
15200
15201 @item Real-Time Systems (Annex D)
15202 The Real-Time Systems Annex is fully implemented.
15203
15204 @item Distributed Systems (Annex E)
15205 Stub generation is fully implemented in the GNAT compiler.  In addition,
15206 a complete compatible PCS is available as part of the GLADE system,
15207 a separate product.  When the two
15208 products are used in conjunction, this annex is fully implemented.
15209
15210 @item Information Systems (Annex F)
15211 The Information Systems annex is fully implemented.
15212
15213 @item Numerics (Annex G)
15214 The Numerics Annex is fully implemented.
15215
15216 @item Safety and Security / High-Integrity Systems (Annex H)
15217 The Safety and Security Annex (termed the High-Integrity Systems Annex
15218 in Ada 2005) is fully implemented.
15219 @end table
15220
15221 @node Implementation of Specific Ada Features
15222 @chapter Implementation of Specific Ada Features
15223
15224 @noindent
15225 This chapter describes the GNAT implementation of several Ada language
15226 facilities.
15227
15228 @menu
15229 * Machine Code Insertions::
15230 * GNAT Implementation of Tasking::
15231 * GNAT Implementation of Shared Passive Packages::
15232 * Code Generation for Array Aggregates::
15233 * The Size of Discriminated Records with Default Discriminants::
15234 * Strict Conformance to the Ada Reference Manual::
15235 @end menu
15236
15237 @node Machine Code Insertions
15238 @section Machine Code Insertions
15239 @cindex Machine Code insertions
15240
15241 @noindent
15242 Package @code{Machine_Code} provides machine code support as described
15243 in the Ada Reference Manual in two separate forms:
15244 @itemize @bullet
15245 @item
15246 Machine code statements, consisting of qualified expressions that
15247 fit the requirements of RM section 13.8.
15248 @item
15249 An intrinsic callable procedure, providing an alternative mechanism of
15250 including machine instructions in a subprogram.
15251 @end itemize
15252
15253 @noindent
15254 The two features are similar, and both are closely related to the mechanism
15255 provided by the asm instruction in the GNU C compiler.  Full understanding
15256 and use of the facilities in this package requires understanding the asm
15257 instruction, see @ref{Extended Asm,, Assembler Instructions with C Expression
15258 Operands, gcc, Using the GNU Compiler Collection (GCC)}.
15259
15260 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
15261 semantic restrictions and effects as described below.  Both are provided so
15262 that the procedure call can be used as a statement, and the function call
15263 can be used to form a code_statement.
15264
15265 The first example given in the GCC documentation is the C @code{asm}
15266 instruction:
15267 @smallexample
15268    asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
15269 @end smallexample
15270
15271 @noindent
15272 The equivalent can be written for GNAT as:
15273
15274 @smallexample @c ada
15275 Asm ("fsinx %1 %0",
15276      My_Float'Asm_Output ("=f", result),
15277      My_Float'Asm_Input  ("f",  angle));
15278 @end smallexample
15279
15280 @noindent
15281 The first argument to @code{Asm} is the assembler template, and is
15282 identical to what is used in GNU C@.  This string must be a static
15283 expression.  The second argument is the output operand list.  It is
15284 either a single @code{Asm_Output} attribute reference, or a list of such
15285 references enclosed in parentheses (technically an array aggregate of
15286 such references).
15287
15288 The @code{Asm_Output} attribute denotes a function that takes two
15289 parameters.  The first is a string, the second is the name of a variable
15290 of the type designated by the attribute prefix.  The first (string)
15291 argument is required to be a static expression and designates the
15292 constraint for the parameter (e.g.@: what kind of register is
15293 required).  The second argument is the variable to be updated with the
15294 result.  The possible values for constraint are the same as those used in
15295 the RTL, and are dependent on the configuration file used to build the
15296 GCC back end.  If there are no output operands, then this argument may
15297 either be omitted, or explicitly given as @code{No_Output_Operands}.
15298
15299 The second argument of @code{@var{my_float}'Asm_Output} functions as
15300 though it were an @code{out} parameter, which is a little curious, but
15301 all names have the form of expressions, so there is no syntactic
15302 irregularity, even though normally functions would not be permitted
15303 @code{out} parameters.  The third argument is the list of input
15304 operands.  It is either a single @code{Asm_Input} attribute reference, or
15305 a list of such references enclosed in parentheses (technically an array
15306 aggregate of such references).
15307
15308 The @code{Asm_Input} attribute denotes a function that takes two
15309 parameters.  The first is a string, the second is an expression of the
15310 type designated by the prefix.  The first (string) argument is required
15311 to be a static expression, and is the constraint for the parameter,
15312 (e.g.@: what kind of register is required).  The second argument is the
15313 value to be used as the input argument.  The possible values for the
15314 constant are the same as those used in the RTL, and are dependent on
15315 the configuration file used to built the GCC back end.
15316
15317 If there are no input operands, this argument may either be omitted, or
15318 explicitly given as @code{No_Input_Operands}.  The fourth argument, not
15319 present in the above example, is a list of register names, called the
15320 @dfn{clobber} argument.  This argument, if given, must be a static string
15321 expression, and is a space or comma separated list of names of registers
15322 that must be considered destroyed as a result of the @code{Asm} call.  If
15323 this argument is the null string (the default value), then the code
15324 generator assumes that no additional registers are destroyed.
15325
15326 The fifth argument, not present in the above example, called the
15327 @dfn{volatile} argument, is by default @code{False}.  It can be set to
15328 the literal value @code{True} to indicate to the code generator that all
15329 optimizations with respect to the instruction specified should be
15330 suppressed, and that in particular, for an instruction that has outputs,
15331 the instruction will still be generated, even if none of the outputs are
15332 used.  @xref{Extended Asm,, Assembler Instructions with C Expression Operands,
15333 gcc, Using the GNU Compiler Collection (GCC)}, for the full description.
15334 Generally it is strongly advisable to use Volatile for any ASM statement
15335 that is missing either input or output operands, or when two or more ASM
15336 statements appear in sequence, to avoid unwanted optimizations. A warning
15337 is generated if this advice is not followed.
15338
15339 The @code{Asm} subprograms may be used in two ways.  First the procedure
15340 forms can be used anywhere a procedure call would be valid, and
15341 correspond to what the RM calls ``intrinsic'' routines.  Such calls can
15342 be used to intersperse machine instructions with other Ada statements.
15343 Second, the function forms, which return a dummy value of the limited
15344 private type @code{Asm_Insn}, can be used in code statements, and indeed
15345 this is the only context where such calls are allowed.  Code statements
15346 appear as aggregates of the form:
15347
15348 @smallexample @c ada
15349 Asm_Insn'(Asm (@dots{}));
15350 Asm_Insn'(Asm_Volatile (@dots{}));
15351 @end smallexample
15352
15353 @noindent
15354 In accordance with RM rules, such code statements are allowed only
15355 within subprograms whose entire body consists of such statements.  It is
15356 not permissible to intermix such statements with other Ada statements.
15357
15358 Typically the form using intrinsic procedure calls is more convenient
15359 and more flexible.  The code statement form is provided to meet the RM
15360 suggestion that such a facility should be made available.  The following
15361 is the exact syntax of the call to @code{Asm}. As usual, if named notation
15362 is used, the arguments may be given in arbitrary order, following the
15363 normal rules for use of positional and named arguments)
15364
15365 @smallexample
15366 ASM_CALL ::= Asm (
15367                  [Template =>] static_string_EXPRESSION
15368                [,[Outputs  =>] OUTPUT_OPERAND_LIST      ]
15369                [,[Inputs   =>] INPUT_OPERAND_LIST       ]
15370                [,[Clobber  =>] static_string_EXPRESSION ]
15371                [,[Volatile =>] static_boolean_EXPRESSION] )
15372
15373 OUTPUT_OPERAND_LIST ::=
15374   [PREFIX.]No_Output_Operands
15375 | OUTPUT_OPERAND_ATTRIBUTE
15376 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
15377
15378 OUTPUT_OPERAND_ATTRIBUTE ::=
15379   SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
15380
15381 INPUT_OPERAND_LIST ::=
15382   [PREFIX.]No_Input_Operands
15383 | INPUT_OPERAND_ATTRIBUTE
15384 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
15385
15386 INPUT_OPERAND_ATTRIBUTE ::=
15387   SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
15388 @end smallexample
15389
15390 @noindent
15391 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
15392 are declared in the package @code{Machine_Code} and must be referenced
15393 according to normal visibility rules. In particular if there is no
15394 @code{use} clause for this package, then appropriate package name
15395 qualification is required.
15396
15397 @node GNAT Implementation of Tasking
15398 @section GNAT Implementation of Tasking
15399
15400 @noindent
15401 This chapter outlines the basic GNAT approach to tasking (in particular,
15402 a multi-layered library for portability) and discusses issues related
15403 to compliance with the Real-Time Systems Annex.
15404
15405 @menu
15406 * Mapping Ada Tasks onto the Underlying Kernel Threads::
15407 * Ensuring Compliance with the Real-Time Annex::
15408 @end menu
15409
15410 @node Mapping Ada Tasks onto the Underlying Kernel Threads
15411 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
15412
15413 @noindent
15414 GNAT's run-time support comprises two layers:
15415
15416 @itemize @bullet
15417 @item GNARL (GNAT Run-time Layer)
15418 @item GNULL (GNAT Low-level Library)
15419 @end itemize
15420
15421 @noindent
15422 In GNAT, Ada's tasking services rely on a platform and OS independent
15423 layer known as GNARL@.  This code is responsible for implementing the
15424 correct semantics of Ada's task creation, rendezvous, protected
15425 operations etc.
15426
15427 GNARL decomposes Ada's tasking semantics into simpler lower level
15428 operations such as create a thread, set the priority of a thread,
15429 yield, create a lock, lock/unlock, etc.  The spec for these low-level
15430 operations constitutes GNULLI, the GNULL Interface.  This interface is
15431 directly inspired from the POSIX real-time API@.
15432
15433 If the underlying executive or OS implements the POSIX standard
15434 faithfully, the GNULL Interface maps as is to the services offered by
15435 the underlying kernel.  Otherwise, some target dependent glue code maps
15436 the services offered by the underlying kernel to the semantics expected
15437 by GNARL@.
15438
15439 Whatever the underlying OS (VxWorks, UNIX, OS/2, Windows NT, etc.) the
15440 key point is that each Ada task is mapped on a thread in the underlying
15441 kernel.  For example, in the case of VxWorks, one Ada task = one VxWorks task.
15442
15443 In addition Ada task priorities map onto the underlying thread priorities.
15444 Mapping Ada tasks onto the underlying kernel threads has several advantages:
15445
15446 @itemize @bullet
15447 @item
15448 The underlying scheduler is used to schedule the Ada tasks.  This
15449 makes Ada tasks as efficient as kernel threads from a scheduling
15450 standpoint.
15451
15452 @item
15453 Interaction with code written in C containing threads is eased
15454 since at the lowest level Ada tasks and C threads map onto the same
15455 underlying kernel concept.
15456
15457 @item
15458 When an Ada task is blocked during I/O the remaining Ada tasks are
15459 able to proceed.
15460
15461 @item
15462 On multiprocessor systems Ada tasks can execute in parallel.
15463 @end itemize
15464
15465 @noindent
15466 Some threads libraries offer a mechanism to fork a new process, with the
15467 child process duplicating the threads from the parent.
15468 GNAT does not
15469 support this functionality when the parent contains more than one task.
15470 @cindex Forking a new process
15471
15472 @node Ensuring Compliance with the Real-Time Annex
15473 @subsection Ensuring Compliance with the Real-Time Annex
15474 @cindex Real-Time Systems Annex compliance
15475
15476 @noindent
15477 Although mapping Ada tasks onto
15478 the underlying threads has significant advantages, it does create some
15479 complications when it comes to respecting the scheduling semantics
15480 specified in the real-time annex (Annex D).
15481
15482 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
15483 scheduling policy states:
15484
15485 @quotation
15486 @emph{When the active priority of a ready task that is not running
15487 changes, or the setting of its base priority takes effect, the
15488 task is removed from the ready queue for its old active priority
15489 and is added at the tail of the ready queue for its new active
15490 priority, except in the case where the active priority is lowered
15491 due to the loss of inherited priority, in which case the task is
15492 added at the head of the ready queue for its new active priority.}
15493 @end quotation
15494
15495 @noindent
15496 While most kernels do put tasks at the end of the priority queue when
15497 a task changes its priority, (which respects the main
15498 FIFO_Within_Priorities requirement), almost none keep a thread at the
15499 beginning of its priority queue when its priority drops from the loss
15500 of inherited priority.
15501
15502 As a result most vendors have provided incomplete Annex D implementations.
15503
15504 The GNAT run-time, has a nice cooperative solution to this problem
15505 which ensures that accurate FIFO_Within_Priorities semantics are
15506 respected.
15507
15508 The principle is as follows.  When an Ada task T is about to start
15509 running, it checks whether some other Ada task R with the same
15510 priority as T has been suspended due to the loss of priority
15511 inheritance.  If this is the case, T yields and is placed at the end of
15512 its priority queue.  When R arrives at the front of the queue it
15513 executes.
15514
15515 Note that this simple scheme preserves the relative order of the tasks
15516 that were ready to execute in the priority queue where R has been
15517 placed at the end.
15518
15519 @node GNAT Implementation of Shared Passive Packages
15520 @section GNAT Implementation of Shared Passive Packages
15521 @cindex Shared passive packages
15522
15523 @noindent
15524 GNAT fully implements the pragma @code{Shared_Passive} for
15525 @cindex pragma @code{Shared_Passive}
15526 the purpose of designating shared passive packages.
15527 This allows the use of passive partitions in the
15528 context described in the Ada Reference Manual; i.e., for communication
15529 between separate partitions of a distributed application using the
15530 features in Annex E.
15531 @cindex Annex E
15532 @cindex Distribution Systems Annex
15533
15534 However, the implementation approach used by GNAT provides for more
15535 extensive usage as follows:
15536
15537 @table @emph
15538 @item Communication between separate programs
15539
15540 This allows separate programs to access the data in passive
15541 partitions, using protected objects for synchronization where
15542 needed. The only requirement is that the two programs have a
15543 common shared file system. It is even possible for programs
15544 running on different machines with different architectures
15545 (e.g.@: different endianness) to communicate via the data in
15546 a passive partition.
15547
15548 @item Persistence between program runs
15549
15550 The data in a passive package can persist from one run of a
15551 program to another, so that a later program sees the final
15552 values stored by a previous run of the same program.
15553
15554 @end table
15555
15556 @noindent
15557 The implementation approach used is to store the data in files. A
15558 separate stream file is created for each object in the package, and
15559 an access to an object causes the corresponding file to be read or
15560 written.
15561
15562 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
15563 @cindex @code{SHARED_MEMORY_DIRECTORY} environment variable
15564 set to the directory to be used for these files.
15565 The files in this directory
15566 have names that correspond to their fully qualified names. For
15567 example, if we have the package
15568
15569 @smallexample @c ada
15570 package X is
15571   pragma Shared_Passive (X);
15572   Y : Integer;
15573   Z : Float;
15574 end X;
15575 @end smallexample
15576
15577 @noindent
15578 and the environment variable is set to @code{/stemp/}, then the files created
15579 will have the names:
15580
15581 @smallexample
15582 /stemp/x.y
15583 /stemp/x.z
15584 @end smallexample
15585
15586 @noindent
15587 These files are created when a value is initially written to the object, and
15588 the files are retained until manually deleted. This provides the persistence
15589 semantics. If no file exists, it means that no partition has assigned a value
15590 to the variable; in this case the initial value declared in the package
15591 will be used. This model ensures that there are no issues in synchronizing
15592 the elaboration process, since elaboration of passive packages elaborates the
15593 initial values, but does not create the files.
15594
15595 The files are written using normal @code{Stream_IO} access.
15596 If you want to be able
15597 to communicate between programs or partitions running on different
15598 architectures, then you should use the XDR versions of the stream attribute
15599 routines, since these are architecture independent.
15600
15601 If active synchronization is required for access to the variables in the
15602 shared passive package, then as described in the Ada Reference Manual, the
15603 package may contain protected objects used for this purpose. In this case
15604 a lock file (whose name is @file{___lock} (three underscores)
15605 is created in the shared memory directory.
15606 @cindex @file{___lock} file (for shared passive packages)
15607 This is used to provide the required locking
15608 semantics for proper protected object synchronization.
15609
15610 As of January 2003, GNAT supports shared passive packages on all platforms
15611 except for OpenVMS.
15612
15613 @node Code Generation for Array Aggregates
15614 @section Code Generation for Array Aggregates
15615
15616 @menu
15617 * Static constant aggregates with static bounds::
15618 * Constant aggregates with unconstrained nominal types::
15619 * Aggregates with static bounds::
15620 * Aggregates with non-static bounds::
15621 * Aggregates in assignment statements::
15622 @end menu
15623
15624 @noindent
15625 Aggregates have a rich syntax and allow the user to specify the values of
15626 complex data structures by means of a single construct.  As a result, the
15627 code generated for aggregates can be quite complex and involve loops, case
15628 statements and multiple assignments.  In the simplest cases, however, the
15629 compiler will recognize aggregates whose components and constraints are
15630 fully static, and in those cases the compiler will generate little or no
15631 executable code.  The following is an outline of the code that GNAT generates
15632 for various aggregate constructs.  For further details, you will find it
15633 useful to examine the output produced by the -gnatG flag to see the expanded
15634 source that is input to the code generator.  You may also want to examine
15635 the assembly code generated at various levels of optimization.
15636
15637 The code generated for aggregates depends on the context, the component values,
15638 and the type.  In the context of an object declaration the code generated is
15639 generally simpler than in the case of an assignment.  As a general rule, static
15640 component values and static subtypes also lead to simpler code.
15641
15642 @node Static constant aggregates with static bounds
15643 @subsection Static constant aggregates with static bounds
15644
15645 @noindent
15646 For the declarations:
15647 @smallexample @c ada
15648     type One_Dim is array (1..10) of integer;
15649     ar0 : constant One_Dim := (1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
15650 @end smallexample
15651
15652 @noindent
15653 GNAT generates no executable code: the constant ar0 is placed in static memory.
15654 The same is true for constant aggregates with named associations:
15655
15656 @smallexample @c ada
15657     Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1 => 1, 5 .. 10 => 0);
15658     Cr3 : constant One_Dim := (others => 7777);
15659 @end smallexample
15660
15661 @noindent
15662 The same is true for multidimensional constant arrays such as:
15663
15664 @smallexample @c ada
15665     type two_dim is array (1..3, 1..3) of integer;
15666     Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
15667 @end smallexample
15668
15669 @noindent
15670 The same is true for arrays of one-dimensional arrays: the following are
15671 static:
15672
15673 @smallexample @c ada
15674 type ar1b  is array (1..3) of boolean;
15675 type ar_ar is array (1..3) of ar1b;
15676 None  : constant ar1b := (others => false);     --  fully static
15677 None2 : constant ar_ar := (1..3 => None);       --  fully static
15678 @end smallexample
15679
15680 @noindent
15681 However, for multidimensional aggregates with named associations, GNAT will
15682 generate assignments and loops, even if all associations are static.  The
15683 following two declarations generate a loop for the first dimension, and
15684 individual component assignments for the second dimension:
15685
15686 @smallexample @c ada
15687 Zero1: constant two_dim := (1..3 => (1..3 => 0));
15688 Zero2: constant two_dim := (others => (others => 0));
15689 @end smallexample
15690
15691 @node Constant aggregates with unconstrained nominal types
15692 @subsection Constant aggregates with unconstrained nominal types
15693
15694 @noindent
15695 In such cases the aggregate itself establishes the subtype, so that
15696 associations with @code{others} cannot be used.  GNAT determines the
15697 bounds for the actual subtype of the aggregate, and allocates the
15698 aggregate statically as well.  No code is generated for the following:
15699
15700 @smallexample @c ada
15701     type One_Unc is array (natural range <>) of integer;
15702     Cr_Unc : constant One_Unc := (12,24,36);
15703 @end smallexample
15704
15705 @node Aggregates with static bounds
15706 @subsection Aggregates with static bounds
15707
15708 @noindent
15709 In all previous examples the aggregate was the initial (and immutable) value
15710 of a constant.  If the aggregate initializes a variable, then code is generated
15711 for it as a combination of individual assignments and loops over the target
15712 object.  The declarations
15713
15714 @smallexample @c ada
15715        Cr_Var1 : One_Dim := (2, 5, 7, 11, 0, 0, 0, 0, 0, 0);
15716        Cr_Var2 : One_Dim := (others > -1);
15717 @end smallexample
15718
15719 @noindent
15720 generate the equivalent of
15721
15722 @smallexample @c ada
15723        Cr_Var1 (1) := 2;
15724        Cr_Var1 (2) := 3;
15725        Cr_Var1 (3) := 5;
15726        Cr_Var1 (4) := 11;
15727
15728        for I in Cr_Var2'range loop
15729           Cr_Var2 (I) := -1;
15730        end loop;
15731 @end smallexample
15732
15733 @node Aggregates with non-static bounds
15734 @subsection Aggregates with non-static bounds
15735
15736 @noindent
15737 If the bounds of the aggregate are not statically compatible with the bounds
15738 of the nominal subtype  of the target, then constraint checks have to be
15739 generated on the bounds.  For a multidimensional array, constraint checks may
15740 have to be applied to sub-arrays individually, if they do not have statically
15741 compatible subtypes.
15742
15743 @node Aggregates in assignment statements
15744 @subsection Aggregates in assignment statements
15745
15746 @noindent
15747 In general, aggregate assignment requires the construction of a temporary,
15748 and a copy from the temporary to the target of the assignment.  This is because
15749 it is not always possible to convert the assignment into a series of individual
15750 component assignments.  For example, consider the simple case:
15751
15752 @smallexample @c ada
15753         A := (A(2), A(1));
15754 @end smallexample
15755
15756 @noindent
15757 This cannot be converted into:
15758
15759 @smallexample @c ada
15760         A(1) := A(2);
15761         A(2) := A(1);
15762 @end smallexample
15763
15764 @noindent
15765 So the aggregate has to be built first in a separate location, and then
15766 copied into the target.  GNAT recognizes simple cases where this intermediate
15767 step is not required, and the assignments can be performed in place, directly
15768 into the target.  The following sufficient criteria are applied:
15769
15770 @itemize @bullet
15771 @item
15772 The bounds of the aggregate are static, and the associations are static.
15773 @item
15774 The components of the aggregate are static constants, names of
15775 simple variables that are not renamings, or expressions not involving
15776 indexed components whose operands obey these rules.
15777 @end itemize
15778
15779 @noindent
15780 If any of these conditions are violated, the aggregate will be built in
15781 a temporary (created either by the front-end or the code generator) and then
15782 that temporary will be copied onto the target.
15783
15784
15785 @node The Size of Discriminated Records with Default Discriminants
15786 @section The Size of Discriminated Records with Default Discriminants
15787
15788 @noindent
15789 If a discriminated type @code{T} has discriminants with default values, it is
15790 possible to declare an object of this type without providing an explicit
15791 constraint:
15792
15793 @smallexample @c ada
15794 @group
15795 type Size is range 1..100;
15796
15797 type Rec (D : Size := 15) is record
15798    Name : String (1..D);
15799 end T;
15800
15801 Word : Rec;
15802 @end group
15803 @end smallexample
15804
15805 @noindent
15806 Such an object is said to be @emph{unconstrained}.
15807 The discriminant of the object
15808 can be modified by a full assignment to the object, as long as it preserves the
15809 relation between the value of the discriminant, and the value of the components
15810 that depend on it:
15811
15812 @smallexample @c ada
15813 @group
15814 Word := (3, "yes");
15815
15816 Word := (5, "maybe");
15817
15818 Word := (5, "no"); -- raises Constraint_Error
15819 @end group
15820 @end smallexample
15821
15822 @noindent
15823 In order to support this behavior efficiently, an unconstrained object is
15824 given the maximum size that any value of the type requires. In the case
15825 above, @code{Word} has storage for the discriminant and for
15826 a @code{String} of length 100.
15827 It is important to note that unconstrained objects do not require dynamic
15828 allocation. It would be an improper implementation to place on the heap those
15829 components whose size depends on discriminants. (This improper implementation
15830 was used by some Ada83 compilers, where the @code{Name} component above
15831 would have
15832 been stored as a pointer to a dynamic string). Following the principle that
15833 dynamic storage management should never be introduced implicitly,
15834 an Ada compiler should reserve the full size for an unconstrained declared
15835 object, and place it on the stack.
15836
15837 This maximum size approach
15838 has been a source of surprise to some users, who expect the default
15839 values of the discriminants to determine the size reserved for an
15840 unconstrained object: ``If the default is 15, why should the object occupy
15841 a larger size?''
15842 The answer, of course, is that the discriminant may be later modified,
15843 and its full range of values must be taken into account. This is why the
15844 declaration:
15845
15846 @smallexample
15847 @group
15848 type Rec (D : Positive := 15) is record
15849    Name : String (1..D);
15850 end record;
15851
15852 Too_Large : Rec;
15853 @end group
15854 @end smallexample
15855
15856 @noindent
15857 is flagged by the compiler with a warning:
15858 an attempt to create @code{Too_Large} will raise @code{Storage_Error},
15859 because the required size includes @code{Positive'Last}
15860 bytes. As the first example indicates, the proper approach is to declare an
15861 index type of ``reasonable'' range so that unconstrained objects are not too
15862 large.
15863
15864 One final wrinkle: if the object is declared to be @code{aliased}, or if it is
15865 created in the heap by means of an allocator, then it is @emph{not}
15866 unconstrained:
15867 it is constrained by the default values of the discriminants, and those values
15868 cannot be modified by full assignment. This is because in the presence of
15869 aliasing all views of the object (which may be manipulated by different tasks,
15870 say) must be consistent, so it is imperative that the object, once created,
15871 remain invariant.
15872
15873 @node Strict Conformance to the Ada Reference Manual
15874 @section Strict Conformance to the Ada Reference Manual
15875
15876 @noindent
15877 The dynamic semantics defined by the Ada Reference Manual impose a set of
15878 run-time checks to be generated. By default, the GNAT compiler will insert many
15879 run-time checks into the compiled code, including most of those required by the
15880 Ada Reference Manual. However, there are three checks that are not enabled
15881 in the default mode for efficiency reasons: arithmetic overflow checking for
15882 integer operations (including division by zero), checks for access before
15883 elaboration on subprogram calls, and stack overflow checking (most operating
15884 systems do not perform this check by default).
15885
15886 Strict conformance to the Ada Reference Manual can be achieved by adding
15887 three compiler options for overflow checking for integer operations
15888 (@option{-gnato}), dynamic checks for access-before-elaboration on subprogram
15889 calls and generic instantiations (@option{-gnatE}), and stack overflow
15890 checking (@option{-fstack-check}).
15891
15892 Note that the result of a floating point arithmetic operation in overflow and
15893 invalid situations, when the @code{Machine_Overflows} attribute of the result
15894 type is @code{False}, is to generate IEEE NaN and infinite values. This is the
15895 case for machines compliant with the IEEE floating-point standard, but on
15896 machines that are not fully compliant with this standard, such as Alpha, the
15897 @option{-mieee} compiler flag must be used for achieving IEEE confirming
15898 behavior (although at the cost of a significant performance penalty), so
15899 infinite and and NaN values are properly generated.
15900
15901
15902 @node Project File Reference
15903 @chapter Project File Reference
15904
15905 @noindent
15906 This chapter describes the syntax and semantics of project files.
15907 Project files specify the options to be used when building a system.
15908 Project files can specify global settings for all tools,
15909 as well as tool-specific settings.
15910 @xref{Examples of Project Files,,, gnat_ugn, @value{EDITION} User's Guide},
15911 for examples of use.
15912
15913 @menu
15914 * Reserved Words::
15915 * Lexical Elements::
15916 * Declarations::
15917 * Empty declarations::
15918 * Typed string declarations::
15919 * Variables::
15920 * Expressions::
15921 * Attributes::
15922 * Project Attributes::
15923 * Attribute References::
15924 * External Values::
15925 * Case Construction::
15926 * Packages::
15927 * Package Renamings::
15928 * Projects::
15929 * Project Extensions::
15930 * Project File Elaboration::
15931 @end menu
15932
15933 @node Reserved Words
15934 @section Reserved Words
15935
15936 @noindent
15937 All Ada reserved words are reserved in project files, and cannot be used
15938 as variable names or project names. In addition, the following are
15939 also reserved in project files:
15940
15941 @itemize
15942 @item @code{extends}
15943
15944 @item @code{external}
15945
15946 @item @code{project}
15947
15948 @end itemize
15949
15950 @node Lexical Elements
15951 @section Lexical Elements
15952
15953 @noindent
15954 Rules for identifiers are the same as in Ada. Identifiers
15955 are case-insensitive.  Strings are case sensitive, except where noted.
15956 Comments have the same form as in Ada.
15957
15958 @noindent
15959 Syntax:
15960
15961 @smallexample
15962 simple_name ::=
15963   identifier
15964
15965 name ::=
15966   simple_name @{. simple_name@}
15967 @end smallexample
15968
15969 @node Declarations
15970 @section Declarations
15971
15972 @noindent
15973 Declarations introduce new entities that denote types, variables, attributes,
15974 and packages. Some declarations can only appear immediately within a project
15975 declaration. Others can appear within a project or within a package.
15976
15977 Syntax:
15978 @smallexample
15979 declarative_item ::=
15980   simple_declarative_item |
15981   typed_string_declaration |
15982   package_declaration
15983
15984 simple_declarative_item ::=
15985   variable_declaration |
15986   typed_variable_declaration |
15987   attribute_declaration |
15988   case_construction |
15989   empty_declaration
15990 @end smallexample
15991
15992 @node Empty declarations
15993 @section Empty declarations
15994
15995 @smallexample
15996 empty_declaration ::=
15997   @b{null} ;
15998 @end smallexample
15999
16000 An empty declaration is allowed anywhere a declaration is allowed.
16001 It has no effect.
16002
16003 @node Typed string declarations
16004 @section Typed string declarations
16005
16006 @noindent
16007 Typed strings are sequences of string literals. Typed strings are the only
16008 named types in project files. They are used in case constructions, where they
16009 provide support for conditional attribute definitions.
16010
16011 Syntax:
16012 @smallexample
16013 typed_string_declaration ::=
16014   @b{type} <typed_string_>_simple_name @b{is}
16015    ( string_literal @{, string_literal@} );
16016 @end smallexample
16017
16018 @noindent
16019 A typed string declaration can only appear immediately within a project
16020 declaration.
16021
16022 All the string literals in a typed string declaration must be distinct.
16023
16024 @node Variables
16025 @section Variables
16026
16027 @noindent
16028 Variables denote values, and appear as constituents of expressions.
16029
16030 @smallexample
16031 typed_variable_declaration ::=
16032   <typed_variable_>simple_name : <typed_string_>name :=  string_expression ;
16033
16034 variable_declaration ::=
16035   <variable_>simple_name := expression;
16036 @end smallexample
16037
16038 @noindent
16039 The elaboration of a variable declaration introduces the variable and
16040 assigns to it the value of the expression. The name of the variable is
16041 available after the assignment symbol.
16042
16043 @noindent
16044 A typed_variable can only be declare once.
16045
16046 @noindent
16047 a non-typed variable can be declared multiple times.
16048
16049 @noindent
16050 Before the completion of its first declaration, the value of variable
16051 is the null string.
16052
16053 @node Expressions
16054 @section Expressions
16055
16056 @noindent
16057 An expression is a formula that defines a computation or retrieval of a value.
16058 In a project file the value of an expression is either a string or a list
16059 of strings. A string value in an expression is either a literal, the current
16060 value of a variable, an external value, an attribute reference, or a
16061 concatenation operation.
16062
16063 Syntax:
16064
16065 @smallexample
16066 expression ::=
16067   term @{& term@}
16068
16069 term ::=
16070   string_literal |
16071   string_list |
16072   <variable_>name |
16073   external_value |
16074   attribute_reference
16075
16076 string_literal ::=
16077   (same as Ada)
16078
16079 string_list ::=
16080   ( <string_>expression @{ , <string_>expression @} )
16081 @end smallexample
16082
16083 @subsection Concatenation
16084 @noindent
16085 The following concatenation functions are defined:
16086
16087 @smallexample @c ada
16088   function "&" (X : String;      Y : String)      return String;
16089   function "&" (X : String_List; Y : String)      return String_List;
16090   function "&" (X : String_List; Y : String_List) return String_List;
16091 @end smallexample
16092
16093 @node Attributes
16094 @section Attributes
16095
16096 @noindent
16097 An attribute declaration defines a property of a project or package. This
16098 property can later be queried by means of an attribute reference.
16099 Attribute values are strings or string lists.
16100
16101 Some attributes are associative arrays. These attributes are mappings whose
16102 domain is a set of strings. These attributes are declared one association
16103 at a time, by specifying a point in the domain and the corresponding image
16104 of the attribute. They may also be declared as a full associative array,
16105 getting the same associations as the corresponding attribute in an imported
16106 or extended project.
16107
16108 Attributes that are not associative arrays are called simple attributes.
16109
16110 Syntax:
16111 @smallexample
16112 attribute_declaration ::=
16113   full_associative_array_declaration |
16114   @b{for} attribute_designator @b{use} expression ;
16115
16116 full_associative_array_declaration ::=
16117   @b{for} <associative_array_attribute_>simple_name @b{use}
16118   <project_>simple_name [ . <package_>simple_Name ] ' <attribute_>simple_name ;
16119
16120 attribute_designator ::=
16121   <simple_attribute_>simple_name |
16122   <associative_array_attribute_>simple_name ( string_literal )
16123 @end smallexample
16124
16125 @noindent
16126 Some attributes are project-specific, and can only appear immediately within
16127 a project declaration. Others are package-specific, and can only appear within
16128 the proper package.
16129
16130 The expression in an attribute definition must be a string or a string_list.
16131 The string literal appearing in the attribute_designator of an associative
16132 array attribute is case-insensitive.
16133
16134 @node Project Attributes
16135 @section Project Attributes
16136
16137 @noindent
16138 The following attributes apply to a project. All of them are simple
16139 attributes.
16140
16141 @table @code
16142 @item   Object_Dir
16143 Expression must be a path name. The attribute defines the
16144 directory in which the object files created by the build are to be placed. If
16145 not specified, object files are placed in the project directory.
16146
16147 @item   Exec_Dir
16148 Expression must be a path name. The attribute defines the
16149 directory in which the executables created by the build are to be placed.
16150 If not specified, executables are placed in the object directory.
16151
16152 @item  Source_Dirs
16153 Expression must be a list of path names. The attribute
16154 defines the directories in which the source files for the project are to be
16155 found. If not specified, source files are found in the project directory.
16156 If a string in the list ends with "/**", then the directory that precedes
16157 "/**" and all of its subdirectories (recursively) are included in the list
16158 of source directories.
16159
16160 @item  Excluded_Source_Dirs
16161 Expression must be a list of strings. Each entry designates a directory that
16162 is not to be included in the list of source directories of the project.
16163 This is normally used when there are strings ending with "/**" in the value
16164 of attribute Source_Dirs.
16165
16166 @item  Source_Files
16167 Expression must be a list of file names. The attribute
16168 defines the individual files, in the project directory, which are to be used
16169 as sources for the project. File names are path_names that contain no directory
16170 information. If the project has no sources the attribute must be declared
16171 explicitly with an empty list.
16172
16173 @item  Excluded_Source_Files (Locally_Removed_Files)
16174 Expression must be a list of strings that are legal file names.
16175 Each file name must designate a source that would normally be a source file
16176 in the source directories of the project or, if the project file is an
16177 extending project file, inherited by the current project file. It cannot
16178 designate an immediate source that is not inherited. Each of the source files
16179 in the list are not considered to be sources of the project file: they are not
16180 inherited. Attribute Locally_Removed_Files is obsolescent, attribute
16181 Excluded_Source_Files is preferred.
16182
16183 @item  Source_List_File
16184 Expression must a single path name. The attribute
16185 defines a text file that contains a list of source file names to be used
16186 as sources for the project
16187
16188 @item  Library_Dir
16189 Expression must be a path name. The attribute defines the
16190 directory in which a  library is to be built.  The directory must exist, must
16191 be distinct from the project's object directory, and must be writable.
16192
16193 @item  Library_Name
16194 Expression must be a string that is a legal file name,
16195 without extension. The attribute defines a string that is used to generate
16196 the name of the library to be built by the project.
16197
16198 @item  Library_Kind
16199 Argument must be a string value that must be one of the
16200 following @code{"static"}, @code{"dynamic"} or @code{"relocatable"}. This
16201 string is case-insensitive. If this attribute is not specified, the library is
16202 a static library. Otherwise, the library may be dynamic or relocatable. This
16203 distinction is operating-system dependent.
16204
16205 @item  Library_Version
16206 Expression must be a string value whose interpretation
16207 is platform dependent. On UNIX, it is used only for dynamic/relocatable
16208 libraries as the internal name of the library (the @code{"soname"}). If the
16209 library file name (built from the @code{Library_Name}) is different from the
16210 @code{Library_Version}, then the library file will be a symbolic link to the
16211 actual file whose name will be @code{Library_Version}.
16212
16213 @item Library_Interface
16214 Expression must be a string list. Each element of the string list
16215 must designate a unit of the project.
16216 If this attribute is present in a Library Project File, then the project
16217 file is a Stand-alone Library_Project_File.
16218
16219 @item Library_Auto_Init
16220 Expression must be a single string "true" or "false", case-insensitive.
16221 If this attribute is present in a Stand-alone Library Project File,
16222 it indicates if initialization is automatic when the dynamic library
16223 is loaded.
16224
16225 @item Library_Options
16226 Expression must be a string list. Indicates additional switches that
16227 are to be used when building a shared library.
16228
16229 @item Library_GCC
16230 Expression must be a single string. Designates an alternative to "gcc"
16231 for building shared libraries.
16232
16233 @item  Library_Src_Dir
16234 Expression must be a path name. The attribute defines the
16235 directory in which the sources of the interfaces of a Stand-alone Library will
16236 be copied.  The directory must exist, must be distinct from the project's
16237 object directory and source directories of all projects in the project tree,
16238 and must be writable.
16239
16240 @item  Library_Src_Dir
16241 Expression must be a path name. The attribute defines the
16242 directory in which the ALI files of a Library will
16243 be copied.  The directory must exist, must be distinct from the project's
16244 object directory and source directories of all projects in the project tree,
16245 and must be writable.
16246
16247 @item  Library_Symbol_File
16248 Expression must be a single string. Its value is the single file name of a
16249 symbol file to be created when building a stand-alone library when the
16250 symbol policy is either "compliant", "controlled" or "restricted",
16251 on platforms that support symbol control, such as VMS. When symbol policy
16252 is "direct", then a file with this name must exist in the object directory.
16253
16254 @item   Library_Reference_Symbol_File
16255 Expression must be a single string. Its value is the path name of a
16256 reference symbol file that is read when the symbol policy is either
16257 "compliant" or "controlled", on platforms that support symbol control,
16258 such as VMS, when building a stand-alone library. The path may be an absolute
16259 path or a path relative to the project directory.
16260
16261 @item  Library_Symbol_Policy
16262 Expression must be a single string. Its case-insensitive value can only be
16263 "autonomous", "default", "compliant", "controlled", "restricted" or "direct".
16264
16265 This attribute is not taken into account on all platforms. It controls the
16266 policy for exported symbols and, on some platforms (like VMS) that have the
16267 notions of major and minor IDs built in the library files, it controls
16268 the setting of these IDs.
16269
16270 "autonomous" or "default": exported symbols are not controlled.
16271
16272 "compliant": if attribute Library_Reference_Symbol_File is not defined, then
16273 it is equivalent to policy "autonomous". If there are exported symbols in
16274 the reference symbol file that are not in the object files of the interfaces,
16275 the major ID of the library is increased. If there are symbols in the
16276 object files of the interfaces that are not in the reference symbol file,
16277 these symbols are put at the end of the list in the newly created symbol file
16278 and the minor ID is increased.
16279
16280 "controlled": the attribute Library_Reference_Symbol_File must be defined.
16281 The library will fail to build if the exported symbols in the object files of
16282 the interfaces do not match exactly the symbol in the symbol file.
16283
16284 "restricted": The attribute Library_Symbol_File must be defined. The library
16285 will fail to build if there are symbols in the symbol file that are not in
16286 the exported symbols of the object files of the interfaces. Additional symbols
16287 in the object files are not added to the symbol file.
16288
16289 "direct": The attribute Library_Symbol_File must be defined and must designate
16290 an existing file in the object directory. This symbol file is passed directly
16291 to the underlying linker without any symbol processing.
16292
16293 @item  Main
16294 Expression must be a list of strings that are legal file names.
16295 These file names designate existing compilation units in the source directory
16296 that are legal main subprograms.
16297
16298 When a project file is elaborated, as part of the execution of a gnatmake
16299 command, one or several executables are built and placed in the Exec_Dir.
16300 If the gnatmake command does not include explicit file names, the executables
16301 that are built correspond to the files specified by this attribute.
16302
16303 @item  Externally_Built
16304 Expression must be a single string. Its value must be either "true" of "false",
16305 case-insensitive. The default is "false". When the value of this attribute is
16306 "true", no attempt is made to compile the sources or to build the library,
16307 when the project is a library project.
16308
16309 @item Main_Language
16310 This is a simple attribute. Its value is a string that specifies the
16311 language of the main program.
16312
16313 @item  Languages
16314 Expression must be a string list. Each string designates
16315 a programming language that is known to GNAT. The strings are case-insensitive.
16316
16317 @end table
16318
16319 @node Attribute References
16320 @section Attribute References
16321
16322 @noindent
16323 Attribute references are used to retrieve the value of previously defined
16324 attribute for a package or project.
16325 Syntax:
16326 @smallexample
16327 attribute_reference ::=
16328   attribute_prefix ' <simple_attribute_>simple_name [ ( string_literal ) ]
16329
16330 attribute_prefix ::=
16331   @b{project} |
16332   <project_simple_name | package_identifier |
16333   <project_>simple_name . package_identifier
16334 @end smallexample
16335
16336 @noindent
16337 If an attribute has not been specified for a given package or project, its
16338 value is the null string or the empty list.
16339
16340 @node External Values
16341 @section External Values
16342
16343 @noindent
16344 An external value is an expression whose value is obtained from the command
16345 that invoked the processing of the current project file (typically a
16346 gnatmake command).
16347
16348 Syntax:
16349 @smallexample
16350 external_value ::=
16351   @b{external} ( string_literal [, string_literal] )
16352 @end smallexample
16353
16354 @noindent
16355 The first string_literal is the string to be used on the command line or
16356 in the environment to specify the external value. The second string_literal,
16357 if present, is the default to use if there is no specification for this
16358 external value either on the command line or in the environment.
16359
16360 @node Case Construction
16361 @section Case Construction
16362
16363 @noindent
16364 A case construction supports attribute and variable declarations that depend
16365 on the value of a previously declared variable.
16366
16367 Syntax:
16368 @smallexample
16369 case_construction ::=
16370   @b{case} <typed_variable_>name @b{is}
16371     @{case_item@}
16372   @b{end case} ;
16373
16374 case_item ::=
16375   @b{when} discrete_choice_list =>
16376     @{case_construction |
16377       attribute_declaration |
16378       variable_declaration |
16379       empty_declaration@}
16380
16381 discrete_choice_list ::=
16382   string_literal @{| string_literal@} |
16383     @b{others}
16384 @end smallexample
16385
16386 @noindent
16387 Inside a case construction, variable declarations must be for variables that
16388 have already been declared before the case construction.
16389
16390 All choices in a choice list must be distinct. The choice lists of two
16391 distinct alternatives must be disjoint. Unlike Ada, the choice lists of all
16392 alternatives do not need to include all values of the type. An @code{others}
16393 choice must appear last in the list of alternatives.
16394
16395 @node Packages
16396 @section Packages
16397
16398 @noindent
16399 A package provides a grouping of variable declarations and attribute
16400 declarations to be used when invoking various GNAT tools. The name of
16401 the package indicates the tool(s) to which it applies.
16402 Syntax:
16403
16404 @smallexample
16405 package_declaration ::=
16406   package_spec | package_renaming
16407
16408 package_spec ::=
16409   @b{package} package_identifier @b{is}
16410     @{simple_declarative_item@}
16411   @b{end} package_identifier ;
16412
16413 package_identifier ::=
16414   @code{Naming} | @code{Builder} | @code{Compiler} | @code{Binder} |
16415   @code{Linker} | @code{Finder}  | @code{Cross_Reference} |
16416   @code{gnatls} | @code{IDE}     | @code{Pretty_Printer}
16417 @end smallexample
16418
16419 @subsection Package Naming
16420
16421 @noindent
16422 The attributes of a @code{Naming} package specifies the naming conventions
16423 that apply to the source files in a project. When invoking other GNAT tools,
16424 they will use the sources in the source directories that satisfy these
16425 naming conventions.
16426
16427 The following attributes apply to a @code{Naming} package:
16428
16429 @table @code
16430 @item Casing
16431 This is a simple attribute whose value is a string. Legal values of this
16432 string are @code{"lowercase"}, @code{"uppercase"} or @code{"mixedcase"}.
16433 These strings are themselves case insensitive.
16434
16435 @noindent
16436 If @code{Casing} is not specified, then the default is @code{"lowercase"}.
16437
16438 @item Dot_Replacement
16439 This is a simple attribute whose string value satisfies the following
16440 requirements:
16441
16442 @itemize @bullet
16443 @item It must not be empty
16444 @item It cannot start or end with an alphanumeric character
16445 @item It cannot be a single underscore
16446 @item It cannot start with an underscore followed by an alphanumeric
16447 @item It cannot contain a dot @code{'.'} if longer than one character
16448 @end itemize
16449
16450 @noindent
16451 If @code{Dot_Replacement} is not specified, then the default is @code{"-"}.
16452
16453 @item Spec_Suffix
16454 This is an associative array attribute, defined on language names,
16455 whose image is a string that must satisfy the following
16456 conditions:
16457
16458 @itemize @bullet
16459 @item It must not be empty
16460 @item It cannot start with an alphanumeric character
16461 @item It cannot start with an underscore followed by an alphanumeric character
16462 @end itemize
16463
16464 @noindent
16465 For Ada, the attribute denotes the suffix used in file names that contain
16466 library unit declarations, that is to say units that are package and
16467 subprogram declarations. If @code{Spec_Suffix ("Ada")} is not
16468 specified, then the default is @code{".ads"}.
16469
16470 For C and C++, the attribute denotes the suffix used in file names that
16471 contain prototypes.
16472
16473 @item Body_Suffix
16474 This is an associative array attribute defined on language names,
16475 whose image is a string that must satisfy the following
16476 conditions:
16477
16478 @itemize @bullet
16479 @item It must not be empty
16480 @item It cannot start with an alphanumeric character
16481 @item It cannot start with an underscore followed by an alphanumeric character
16482 @item It cannot be a suffix of @code{Spec_Suffix}
16483 @end itemize
16484
16485 @noindent
16486 For Ada, the attribute denotes the suffix used in file names that contain
16487 library bodies, that is to say units that are package and subprogram bodies.
16488 If @code{Body_Suffix ("Ada")} is not specified, then the default is
16489 @code{".adb"}.
16490
16491 For C and C++, the attribute denotes the suffix used in file names that contain
16492 source code.
16493
16494 @item Separate_Suffix
16495 This is a simple attribute whose value satisfies the same conditions as
16496 @code{Body_Suffix}.
16497
16498 This attribute is specific to Ada. It denotes the suffix used in file names
16499 that contain separate bodies. If it is not specified, then it defaults to same
16500 value as @code{Body_Suffix ("Ada")}.
16501
16502 @item Spec
16503 This is an associative array attribute, specific to Ada, defined over
16504 compilation unit names. The image is a string that is the name of the file
16505 that contains that library unit. The file name is case sensitive if the
16506 conventions of the host operating system require it.
16507
16508 @item Body
16509 This is an associative array attribute, specific to Ada, defined over
16510 compilation unit names. The image is a string that is the name of the file
16511 that contains the library unit body for the named unit. The file name is case
16512 sensitive if the conventions of the host operating system require it.
16513
16514 @item Specification_Exceptions
16515 This is an associative array attribute defined on language names,
16516 whose value is a list of strings.
16517
16518 This attribute is not significant for Ada.
16519
16520 For C and C++, each string in the list denotes the name of a file that
16521 contains prototypes, but whose suffix is not necessarily the
16522 @code{Spec_Suffix} for the language.
16523
16524 @item Implementation_Exceptions
16525 This is an associative array attribute defined on language names,
16526 whose value is a list of strings.
16527
16528 This attribute is not significant for Ada.
16529
16530 For C and C++, each string in the list denotes the name of a file that
16531 contains source code, but whose suffix is not necessarily the
16532 @code{Body_Suffix} for the language.
16533 @end table
16534
16535 The following attributes of package @code{Naming} are obsolescent. They are
16536 kept as synonyms of other attributes for compatibility with previous versions
16537 of the Project Manager.
16538
16539 @table @code
16540 @item Specification_Suffix
16541 This is a synonym of @code{Spec_Suffix}.
16542
16543 @item Implementation_Suffix
16544 This is a synonym of @code{Body_Suffix}.
16545
16546 @item Specification
16547 This is a synonym of @code{Spec}.
16548
16549 @item Implementation
16550 This is a synonym of @code{Body}.
16551 @end table
16552
16553 @subsection package Compiler
16554
16555 @noindent
16556 The attributes of the @code{Compiler} package specify the compilation options
16557 to be used by the underlying compiler.
16558
16559 @table @code
16560 @item  Default_Switches
16561 This is an associative array attribute. Its
16562 domain is a set of language names. Its range is a string list that
16563 specifies the compilation options to be used when compiling a component
16564 written in that language, for which no file-specific switches have been
16565 specified.
16566
16567 @item  Switches
16568 This is an associative array attribute. Its domain is
16569 a set of file names. Its range is a string list that specifies the
16570 compilation options to be used when compiling the named file. If a file
16571 is not specified in the Switches attribute, it is compiled with the
16572 options specified by Default_Switches of its language, if defined.
16573
16574 @item  Local_Configuration_Pragmas.
16575 This is a simple attribute, whose
16576 value is a path name that designates a file containing configuration pragmas
16577 to be used for all invocations of the compiler for immediate sources of the
16578 project.
16579 @end table
16580
16581 @subsection package Builder
16582
16583 @noindent
16584 The attributes of package @code{Builder} specify the compilation, binding, and
16585 linking options to be used when building an executable for a project. The
16586 following attributes apply to package @code{Builder}:
16587
16588 @table @code
16589 @item Default_Switches
16590 This is an associative array attribute. Its
16591 domain is a set of language names. Its range is a string list that
16592 specifies options to be used when building a main
16593 written in that language, for which no file-specific switches have been
16594 specified.
16595
16596 @item Switches
16597 This is an associative array attribute. Its domain is
16598 a set of file names. Its range is a string list that specifies
16599 options to be used when building the named main file. If a main file
16600 is not specified in the Switches attribute, it is built with the
16601 options specified by Default_Switches of its language, if defined.
16602
16603 @item Global_Configuration_Pragmas
16604 This is a simple attribute, whose
16605 value is a path name that designates a file that contains configuration pragmas
16606 to be used in every build of an executable. If both local and global
16607 configuration pragmas are specified, a compilation makes use of both sets.
16608
16609
16610 @item Executable
16611 This is an associative array attribute. Its domain is
16612 a set of main source file names. Its range is a simple string that specifies
16613 the executable file name to be used when linking the specified main source.
16614 If a main source is not specified in the Executable attribute, the executable
16615 file name is deducted from the main source file name.
16616 This attribute has no effect if its value is the empty string.
16617
16618 @item Executable_Suffix
16619 This is a simple attribute whose value is the suffix to be added to
16620 the executables that don't have an attribute Executable specified.
16621 @end table
16622
16623 @subsection package Gnatls
16624
16625 @noindent
16626 The attributes of package @code{Gnatls} specify the tool options to be used
16627 when invoking the library browser @command{gnatls}.
16628 The following attributes apply to package @code{Gnatls}:
16629
16630 @table @code
16631 @item Switches
16632 This is a single attribute with a string list value. Each nonempty string
16633 in the list is an option when invoking @code{gnatls}.
16634 @end table
16635
16636 @subsection package Binder
16637
16638 @noindent
16639 The attributes of package @code{Binder} specify the options to be used
16640 when invoking the binder in the construction of an executable.
16641 The following attributes apply to package @code{Binder}:
16642
16643 @table @code
16644 @item     Default_Switches
16645 This is an associative array attribute. Its
16646 domain is a set of language names. Its range is a string list that
16647 specifies options to be used when binding a main
16648 written in that language, for which no file-specific switches have been
16649 specified.
16650
16651 @item Switches
16652 This is an associative array attribute. Its domain is
16653 a set of file names. Its range is a string list that specifies
16654 options to be used when binding the named main file. If a main file
16655 is not specified in the Switches attribute, it is bound with the
16656 options specified by Default_Switches of its language, if defined.
16657 @end table
16658
16659 @subsection package Linker
16660
16661 @noindent
16662 The attributes of package @code{Linker} specify the options to be used when
16663 invoking the linker in the construction of an executable.
16664 The following attributes apply to package @code{Linker}:
16665
16666 @table @code
16667 @item     Default_Switches
16668 This is an associative array attribute. Its
16669 domain is a set of language names. Its range is a string list that
16670 specifies options to be used when linking a main
16671 written in that language, for which no file-specific switches have been
16672 specified.
16673
16674 @item Switches
16675 This is an associative array attribute. Its domain is
16676 a set of file names. Its range is a string list that specifies
16677 options to be used when linking the named main file. If a main file
16678 is not specified in the Switches attribute, it is linked with the
16679 options specified by Default_Switches of its language, if defined.
16680
16681 @item  Linker_Options
16682 This is a string list attribute. Its value specifies additional options that
16683 be given to the linker when linking an executable. This attribute is not
16684 used in the main project, only in projects imported directly or indirectly.
16685
16686 @end table
16687
16688 @subsection package Cross_Reference
16689
16690 @noindent
16691 The attributes of package @code{Cross_Reference} specify the tool options
16692 to be used
16693 when invoking the library tool @command{gnatxref}.
16694 The following attributes apply to package @code{Cross_Reference}:
16695
16696 @table @code
16697 @item     Default_Switches
16698 This is an associative array attribute. Its
16699 domain is a set of language names. Its range is a string list that
16700 specifies options to be used when calling @command{gnatxref} on a source
16701 written in that language, for which no file-specific switches have been
16702 specified.
16703
16704 @item Switches
16705 This is an associative array attribute. Its domain is
16706 a set of file names. Its range is a string list that specifies
16707 options to be used when calling @command{gnatxref} on the named main source.
16708 If a source is not specified in the Switches attribute, @command{gnatxref} will
16709 be called with the options specified by Default_Switches of its language,
16710 if defined.
16711 @end table
16712
16713 @subsection package   Finder
16714
16715 @noindent
16716 The attributes of package @code{Finder} specify the tool options to be used
16717 when invoking the search tool @command{gnatfind}.
16718 The following attributes apply to package @code{Finder}:
16719
16720 @table @code
16721 @item     Default_Switches
16722 This is an associative array attribute. Its
16723 domain is a set of language names. Its range is a string list that
16724 specifies options to be used when calling @command{gnatfind} on a source
16725 written in that language, for which no file-specific switches have been
16726 specified.
16727
16728 @item Switches
16729 This is an associative array attribute. Its domain is
16730 a set of file names. Its range is a string list that specifies
16731 options to be used when calling @command{gnatfind} on the named main source.
16732 If a source is not specified in the Switches attribute, @command{gnatfind} will
16733 be called with the options specified by Default_Switches of its language,
16734 if defined.
16735 @end table
16736
16737 @subsection package Pretty_Printer
16738
16739 @noindent
16740 The attributes of package @code{Pretty_Printer}
16741 specify the tool options to be used
16742 when invoking the formatting tool @command{gnatpp}.
16743 The following attributes apply to package @code{Pretty_Printer}:
16744
16745 @table @code
16746 @item     Default_switches
16747 This is an associative array attribute. Its
16748 domain is a set of language names. Its range is a string list that
16749 specifies options to be used when calling @command{gnatpp} on a source
16750 written in that language, for which no file-specific switches have been
16751 specified.
16752
16753 @item Switches
16754 This is an associative array attribute. Its domain is
16755 a set of file names. Its range is a string list that specifies
16756 options to be used when calling @command{gnatpp} on the named main source.
16757 If a source is not specified in the Switches attribute, @command{gnatpp} will
16758 be called with the options specified by Default_Switches of its language,
16759 if defined.
16760 @end table
16761
16762 @subsection package gnatstub
16763
16764 @noindent
16765 The attributes of package @code{gnatstub}
16766 specify the tool options to be used
16767 when invoking the tool @command{gnatstub}.
16768 The following attributes apply to package @code{gnatstub}:
16769
16770 @table @code
16771 @item     Default_switches
16772 This is an associative array attribute. Its
16773 domain is a set of language names. Its range is a string list that
16774 specifies options to be used when calling @command{gnatstub} on a source
16775 written in that language, for which no file-specific switches have been
16776 specified.
16777
16778 @item Switches
16779 This is an associative array attribute. Its domain is
16780 a set of file names. Its range is a string list that specifies
16781 options to be used when calling @command{gnatstub} on the named main source.
16782 If a source is not specified in the Switches attribute, @command{gnatpp} will
16783 be called with the options specified by Default_Switches of its language,
16784 if defined.
16785 @end table
16786
16787 @subsection package Eliminate
16788
16789 @noindent
16790 The attributes of package @code{Eliminate}
16791 specify the tool options to be used
16792 when invoking the tool @command{gnatelim}.
16793 The following attributes apply to package @code{Eliminate}:
16794
16795 @table @code
16796 @item     Default_switches
16797 This is an associative array attribute. Its
16798 domain is a set of language names. Its range is a string list that
16799 specifies options to be used when calling @command{gnatelim} on a source
16800 written in that language, for which no file-specific switches have been
16801 specified.
16802
16803 @item Switches
16804 This is an associative array attribute. Its domain is
16805 a set of file names. Its range is a string list that specifies
16806 options to be used when calling @command{gnatelim} on the named main source.
16807 If a source is not specified in the Switches attribute, @command{gnatelim} will
16808 be called with the options specified by Default_Switches of its language,
16809 if defined.
16810 @end table
16811
16812 @subsection package Metrics
16813
16814 @noindent
16815 The attributes of package @code{Metrics}
16816 specify the tool options to be used
16817 when invoking the tool @command{gnatmetric}.
16818 The following attributes apply to package @code{Metrics}:
16819
16820 @table @code
16821 @item     Default_switches
16822 This is an associative array attribute. Its
16823 domain is a set of language names. Its range is a string list that
16824 specifies options to be used when calling @command{gnatmetric} on a source
16825 written in that language, for which no file-specific switches have been
16826 specified.
16827
16828 @item Switches
16829 This is an associative array attribute. Its domain is
16830 a set of file names. Its range is a string list that specifies
16831 options to be used when calling @command{gnatmetric} on the named main source.
16832 If a source is not specified in the Switches attribute, @command{gnatmetric}
16833 will be called with the options specified by Default_Switches of its language,
16834 if defined.
16835 @end table
16836
16837 @subsection  package IDE
16838
16839 @noindent
16840 The attributes of package @code{IDE} specify the options to be used when using
16841 an Integrated Development Environment such as @command{GPS}.
16842
16843 @table @code
16844 @item Remote_Host
16845 This is a simple attribute. Its value is a string that designates the remote
16846 host in a cross-compilation environment, to be used for remote compilation and
16847 debugging. This field should not be specified when running on the local
16848 machine.
16849
16850 @item Program_Host
16851 This is a simple attribute. Its value is a string that specifies the
16852 name of IP address of the embedded target in a cross-compilation environment,
16853 on which the program should execute.
16854
16855 @item Communication_Protocol
16856 This is a simple string attribute. Its value is the name of the protocol
16857 to use to communicate with the target in a cross-compilation environment,
16858 e.g.@: @code{"wtx"} or @code{"vxworks"}.
16859
16860 @item Compiler_Command
16861 This is an associative array attribute, whose domain is a language name. Its
16862 value is  string that denotes the command to be used to invoke the compiler.
16863 The value of @code{Compiler_Command ("Ada")} is expected to be compatible with
16864 gnatmake, in particular in the handling of switches.
16865
16866 @item Debugger_Command
16867 This is simple attribute, Its value is a string that specifies the name of
16868 the debugger to be used, such as gdb, powerpc-wrs-vxworks-gdb or gdb-4.
16869
16870 @item Default_Switches
16871 This is an associative array attribute. Its indexes are the name of the
16872 external tools that the GNAT Programming System (GPS) is supporting. Its
16873 value is a list of switches to use when invoking that tool.
16874
16875 @item  Gnatlist
16876 This is a simple attribute.  Its value is a string that specifies the name
16877 of the @command{gnatls} utility to be used to retrieve information about the
16878 predefined path; e.g., @code{"gnatls"}, @code{"powerpc-wrs-vxworks-gnatls"}.
16879
16880 @item VCS_Kind
16881 This is a simple attribute. Its value is a string used to specify the
16882 Version Control System (VCS) to be used for this project, e.g.@: CVS, RCS
16883 ClearCase or Perforce.
16884
16885 @item VCS_File_Check
16886 This is a simple attribute. Its value is a string that specifies the
16887 command used by the VCS to check the validity of a file, either
16888 when the user explicitly asks for a check, or as a sanity check before
16889 doing the check-in.
16890
16891 @item VCS_Log_Check
16892 This is a simple attribute. Its value is a string that specifies
16893 the command used by the VCS to check the validity of a log file.
16894
16895 @item VCS_Repository_Root
16896 The VCS repository root path. This is used to create tags or branches
16897 of the repository. For subversion the value should be the @code{URL}
16898 as specified to check-out the working copy of the repository.
16899
16900 @item VCS_Patch_Root
16901 The local root directory to use for building patch file. All patch chunks
16902 will be relative to this path. The root project directory is used if
16903 this value is not defined.
16904
16905 @end table
16906
16907 @node Package Renamings
16908 @section Package Renamings
16909
16910 @noindent
16911 A package can be defined by a renaming declaration. The new package renames
16912 a package declared in a different project file, and has the same attributes
16913 as the package it renames.
16914 Syntax:
16915 @smallexample
16916 package_renaming ::==
16917   @b{package} package_identifier @b{renames}
16918        <project_>simple_name.package_identifier ;
16919 @end smallexample
16920
16921 @noindent
16922 The package_identifier of the renamed package must be the same as the
16923 package_identifier. The project whose name is the prefix of the renamed
16924 package must contain a package declaration with this name. This project
16925 must appear in the context_clause of the enclosing project declaration,
16926 or be the parent project of the enclosing child project.
16927
16928 @node Projects
16929 @section Projects
16930
16931 @noindent
16932 A project file specifies a set of rules for constructing a software system.
16933 A project file can be self-contained, or depend on other project files.
16934 Dependencies are expressed through a context clause that names other projects.
16935
16936 Syntax:
16937
16938 @smallexample
16939 project ::=
16940   context_clause project_declaration
16941
16942 project_declaration ::=
16943   simple_project_declaration | project_extension
16944
16945 simple_project_declaration ::=
16946   @b{project} <project_>simple_name @b{is}
16947     @{declarative_item@}
16948   @b{end} <project_>simple_name;
16949
16950 context_clause ::=
16951   @{with_clause@}
16952
16953 with_clause ::=
16954   [@b{limited}] @b{with} path_name @{ , path_name @} ;
16955
16956 path_name ::=
16957    string_literal
16958 @end smallexample
16959
16960 @noindent
16961 A path name denotes a project file. A path name can be absolute or relative.
16962 An absolute path name includes a sequence of directories, in the syntax of
16963 the host operating system, that identifies uniquely the project file in the
16964 file system. A relative path name identifies the project file, relative
16965 to the directory that contains the current project, or relative to a
16966 directory listed in the environment variable ADA_PROJECT_PATH.
16967 Path names are case sensitive if file names in the host operating system
16968 are case sensitive.
16969
16970 The syntax of the environment variable ADA_PROJECT_PATH is a list of
16971 directory names separated by colons (semicolons on Windows).
16972
16973 A given project name can appear only once in a context_clause.
16974
16975 It is illegal for a project imported by a context clause to refer, directly
16976 or indirectly, to the project in which this context clause appears (the
16977 dependency graph cannot contain cycles), except when one of the with_clause
16978 in the cycle is a @code{limited with}.
16979
16980 @node Project Extensions
16981 @section Project Extensions
16982
16983 @noindent
16984 A project extension introduces a new project, which inherits the declarations
16985 of another project.
16986 Syntax:
16987 @smallexample
16988
16989 project_extension ::=
16990   @b{project} <project_>simple_name  @b{extends} path_name @b{is}
16991     @{declarative_item@}
16992   @b{end} <project_>simple_name;
16993 @end smallexample
16994
16995 @noindent
16996 The project extension declares a child project. The child project inherits
16997 all the declarations and all the files of the parent project, These inherited
16998 declaration can be overridden in the child project, by means of suitable
16999 declarations.
17000
17001 @node Project File Elaboration
17002 @section Project File Elaboration
17003
17004 @noindent
17005 A project file is processed as part of the invocation of a gnat tool that
17006 uses the project option. Elaboration of the process file consists in the
17007 sequential elaboration of all its declarations. The computed values of
17008 attributes and variables in the project are then used to establish the
17009 environment in which the gnat tool will execute.
17010
17011 @node Obsolescent Features
17012 @chapter Obsolescent Features
17013
17014 @noindent
17015 This chapter describes features that are provided by GNAT, but are
17016 considered obsolescent since there are preferred ways of achieving
17017 the same effect. These features are provided solely for historical
17018 compatibility purposes.
17019
17020 @menu
17021 * pragma No_Run_Time::
17022 * pragma Ravenscar::
17023 * pragma Restricted_Run_Time::
17024 @end menu
17025
17026 @node pragma No_Run_Time
17027 @section pragma No_Run_Time
17028
17029 The pragma @code{No_Run_Time} is used to achieve an affect similar
17030 to the use of the "Zero Foot Print" configurable run time, but without
17031 requiring a specially configured run time. The result of using this
17032 pragma, which must be used for all units in a partition, is to restrict
17033 the use of any language features requiring run-time support code. The
17034 preferred usage is to use an appropriately configured run-time that
17035 includes just those features that are to be made accessible.
17036
17037 @node pragma Ravenscar
17038 @section pragma Ravenscar
17039
17040 The pragma @code{Ravenscar} has exactly the same effect as pragma
17041 @code{Profile (Ravenscar)}. The latter usage is preferred since it
17042 is part of the new Ada 2005 standard.
17043
17044 @node pragma Restricted_Run_Time
17045 @section pragma Restricted_Run_Time
17046
17047 The pragma @code{Restricted_Run_Time} has exactly the same effect as
17048 pragma @code{Profile (Restricted)}. The latter usage is
17049 preferred since the Ada 2005 pragma @code{Profile} is intended for
17050 this kind of implementation dependent addition.
17051
17052 @include fdl.texi
17053 @c GNU Free Documentation License
17054
17055 @node Index,,GNU Free Documentation License, Top
17056 @unnumbered Index
17057
17058 @printindex cp
17059
17060 @contents
17061
17062 @bye