OSDN Git Service

PR bootstrap/38262
[pf3gnuchains/gcc-fork.git] / gcc / ada / gnat_rm.texi
1 \input texinfo   @c -*-texinfo-*-
2
3 @c %**start of header
4
5 @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
6 @c                                                                            o
7 @c                           GNAT DOCUMENTATION                               o
8 @c                                                                            o
9 @c                              G N A T _ RM                                  o
10 @c                                                                            o
11 @c  GNAT is maintained by Ada Core Technologies Inc (http://www.gnat.com).    o
12 @c                                                                            o
13 @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
14
15 @setfilename gnat_rm.info
16
17 @copying
18 Copyright @copyright{} 1995-2008, Free Software Foundation, Inc.
19
20 Permission is granted to copy, distribute and/or modify this document
21 under the terms of the GNU Free Documentation License, Version 1.2 or
22 any later version published by the Free Software Foundation; with no
23 Invariant Sections, with the Front-Cover Texts being ``GNAT Reference
24 Manual'', and with no Back-Cover Texts.  A copy of the license is
25 included in the section entitled ``GNU Free Documentation License''.
26 @end copying
27
28 @set EDITION GNAT
29 @set DEFAULTLANGUAGEVERSION Ada 2005
30 @set NONDEFAULTLANGUAGEVERSION Ada 95
31
32 @settitle GNAT Reference Manual
33
34 @setchapternewpage odd
35 @syncodeindex fn cp
36
37 @include gcc-common.texi
38
39 @dircategory GNU Ada tools
40 @direntry
41 * GNAT Reference Manual: (gnat_rm).  Reference Manual for GNU Ada tools.
42 @end direntry
43
44 @titlepage
45 @title GNAT Reference Manual
46 @subtitle GNAT, The GNU Ada Compiler
47 @versionsubtitle
48 @author AdaCore
49 @page
50 @vskip 0pt plus 1filll
51
52 @insertcopying
53
54 @end titlepage
55
56 @ifnottex
57 @node Top, About This Guide, (dir), (dir)
58 @top GNAT Reference Manual
59
60 @noindent
61 GNAT Reference Manual
62
63 @noindent
64 GNAT, The GNU Ada Compiler@*
65 GCC version @value{version-GCC}@*
66
67 @noindent
68 AdaCore
69
70 @menu
71 * About This Guide::
72 * Implementation Defined Pragmas::
73 * Implementation Defined Attributes::
74 * Implementation Advice::
75 * Implementation Defined Characteristics::
76 * Intrinsic Subprograms::
77 * Representation Clauses and Pragmas::
78 * Standard Library Routines::
79 * The Implementation of Standard I/O::
80 * The GNAT Library::
81 * Interfacing to Other Languages::
82 * Specialized Needs Annexes::
83 * Implementation of Specific Ada Features::
84 * Project File Reference::
85 * Obsolescent Features::
86 * GNU Free Documentation License::
87 * Index::
88
89  --- The Detailed Node Listing ---
90
91 About This Guide
92
93 * What This Reference Manual Contains::
94 * Related Information::
95
96 Implementation Defined Pragmas
97
98 * Pragma Abort_Defer::
99 * Pragma Ada_83::
100 * Pragma Ada_95::
101 * Pragma Ada_05::
102 * Pragma Ada_2005::
103 * Pragma Annotate::
104 * Pragma Assert::
105 * Pragma Ast_Entry::
106 * Pragma C_Pass_By_Copy::
107 * Pragma Check::
108 * Pragma Check_Name::
109 * Pragma Check_Policy::
110 * Pragma Comment::
111 * Pragma Common_Object::
112 * Pragma Compile_Time_Error::
113 * Pragma Compile_Time_Warning::
114 * Pragma Complete_Representation::
115 * Pragma Complex_Representation::
116 * Pragma Component_Alignment::
117 * Pragma Convention_Identifier::
118 * Pragma CPP_Class::
119 * Pragma CPP_Constructor::
120 * Pragma CPP_Virtual::
121 * Pragma CPP_Vtable::
122 * Pragma Debug::
123 * Pragma Debug_Policy::
124 * Pragma Detect_Blocking::
125 * Pragma Elaboration_Checks::
126 * Pragma Eliminate::
127 * Pragma Export_Exception::
128 * Pragma Export_Function::
129 * Pragma Export_Object::
130 * Pragma Export_Procedure::
131 * Pragma Export_Value::
132 * Pragma Export_Valued_Procedure::
133 * Pragma Extend_System::
134 * Pragma External::
135 * Pragma External_Name_Casing::
136 * Pragma Fast_Math::
137 * Pragma Favor_Top_Level::
138 * Pragma Finalize_Storage_Only::
139 * Pragma Float_Representation::
140 * Pragma Ident::
141 * Pragma Implemented_By_Entry::
142 * Pragma Implicit_Packing::
143 * Pragma Import_Exception::
144 * Pragma Import_Function::
145 * Pragma Import_Object::
146 * Pragma Import_Procedure::
147 * Pragma Import_Valued_Procedure::
148 * Pragma Initialize_Scalars::
149 * Pragma Inline_Always::
150 * Pragma Inline_Generic::
151 * Pragma Interface::
152 * Pragma Interface_Name::
153 * Pragma Interrupt_Handler::
154 * Pragma Interrupt_State::
155 * Pragma Keep_Names::
156 * Pragma License::
157 * Pragma Link_With::
158 * Pragma Linker_Alias::
159 * Pragma Linker_Constructor::
160 * Pragma Linker_Destructor::
161 * Pragma Linker_Section::
162 * Pragma Long_Float::
163 * Pragma Machine_Attribute::
164 * Pragma Main::
165 * Pragma Main_Storage::
166 * Pragma No_Body::
167 * Pragma No_Return::
168 * Pragma No_Strict_Aliasing ::
169 * Pragma Normalize_Scalars::
170 * Pragma Obsolescent::
171 * Pragma Optimize_Alignment::
172 * Pragma Passive::
173 * Pragma Persistent_BSS::
174 * Pragma Polling::
175 * Pragma Postcondition::
176 * Pragma Precondition::
177 * Pragma Profile (Ravenscar)::
178 * Pragma Profile (Restricted)::
179 * Pragma Psect_Object::
180 * Pragma Pure_Function::
181 * Pragma Restriction_Warnings::
182 * Pragma Shared::
183 * Pragma Source_File_Name::
184 * Pragma Source_File_Name_Project::
185 * Pragma Source_Reference::
186 * Pragma Stream_Convert::
187 * Pragma Style_Checks::
188 * Pragma Subtitle::
189 * Pragma Suppress::
190 * Pragma Suppress_All::
191 * Pragma Suppress_Exception_Locations::
192 * Pragma Suppress_Initialization::
193 * Pragma Task_Info::
194 * Pragma Task_Name::
195 * Pragma Task_Storage::
196 * Pragma Time_Slice::
197 * Pragma Title::
198 * Pragma Unchecked_Union::
199 * Pragma Unimplemented_Unit::
200 * Pragma Universal_Aliasing ::
201 * Pragma Universal_Data::
202 * Pragma Unmodified::
203 * Pragma Unreferenced::
204 * Pragma Unreferenced_Objects::
205 * Pragma Unreserve_All_Interrupts::
206 * Pragma Unsuppress::
207 * Pragma Use_VADS_Size::
208 * Pragma Validity_Checks::
209 * Pragma Volatile::
210 * Pragma Warnings::
211 * Pragma Weak_External::
212 * Pragma Wide_Character_Encoding::
213
214 Implementation Defined Attributes
215
216 * Abort_Signal::
217 * Address_Size::
218 * Asm_Input::
219 * Asm_Output::
220 * AST_Entry::
221 * Bit::
222 * Bit_Position::
223 * Code_Address::
224 * Default_Bit_Order::
225 * Elaborated::
226 * Elab_Body::
227 * Elab_Spec::
228 * Emax::
229 * Enabled::
230 * Enum_Rep::
231 * Enum_Val::
232 * Epsilon::
233 * Fixed_Value::
234 * Has_Access_Values::
235 * Has_Discriminants::
236 * Img::
237 * Integer_Value::
238 * Invalid_Value::
239 * Large::
240 * Machine_Size::
241 * Mantissa::
242 * Max_Interrupt_Priority::
243 * Max_Priority::
244 * Maximum_Alignment::
245 * Mechanism_Code::
246 * Null_Parameter::
247 * Object_Size::
248 * Old::
249 * Passed_By_Reference::
250 * Pool_Address::
251 * Range_Length::
252 * Safe_Emax::
253 * Safe_Large::
254 * Small::
255 * Storage_Unit::
256 * Stub_Type::
257 * Target_Name::
258 * Tick::
259 * To_Address::
260 * Type_Class::
261 * UET_Address::
262 * Unconstrained_Array::
263 * Universal_Literal_String::
264 * Unrestricted_Access::
265 * VADS_Size::
266 * Value_Size::
267 * Wchar_T_Size::
268 * Word_Size::
269
270 The Implementation of Standard I/O
271
272 * Standard I/O Packages::
273 * FORM Strings::
274 * Direct_IO::
275 * Sequential_IO::
276 * Text_IO::
277 * Wide_Text_IO::
278 * Wide_Wide_Text_IO::
279 * Stream_IO::
280 * Shared Files::
281 * Filenames encoding::
282 * Open Modes::
283 * Operations on C Streams::
284 * Interfacing to C Streams::
285
286 The GNAT Library
287
288 * Ada.Characters.Latin_9 (a-chlat9.ads)::
289 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
290 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
291 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
292 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
293 * Ada.Command_Line.Environment (a-colien.ads)::
294 * Ada.Command_Line.Remove (a-colire.ads)::
295 * Ada.Command_Line.Response_File (a-clrefi.ads)::
296 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
297 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
298 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
299 * Ada.Exceptions.Traceback (a-exctra.ads)::
300 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
301 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
302 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
303 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
304 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
305 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
306 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
307 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
308 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
309 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
310 * GNAT.Altivec (g-altive.ads)::
311 * GNAT.Altivec.Conversions (g-altcon.ads)::
312 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
313 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
314 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
315 * GNAT.Array_Split (g-arrspl.ads)::
316 * GNAT.AWK (g-awk.ads)::
317 * GNAT.Bounded_Buffers (g-boubuf.ads)::
318 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
319 * GNAT.Bubble_Sort (g-bubsor.ads)::
320 * GNAT.Bubble_Sort_A (g-busora.ads)::
321 * GNAT.Bubble_Sort_G (g-busorg.ads)::
322 * GNAT.Byte_Order_Mark (g-byorma.ads)::
323 * GNAT.Byte_Swapping (g-bytswa.ads)::
324 * GNAT.Calendar (g-calend.ads)::
325 * GNAT.Calendar.Time_IO (g-catiio.ads)::
326 * GNAT.Case_Util (g-casuti.ads)::
327 * GNAT.CGI (g-cgi.ads)::
328 * GNAT.CGI.Cookie (g-cgicoo.ads)::
329 * GNAT.CGI.Debug (g-cgideb.ads)::
330 * GNAT.Command_Line (g-comlin.ads)::
331 * GNAT.Compiler_Version (g-comver.ads)::
332 * GNAT.Ctrl_C (g-ctrl_c.ads)::
333 * GNAT.CRC32 (g-crc32.ads)::
334 * GNAT.Current_Exception (g-curexc.ads)::
335 * GNAT.Debug_Pools (g-debpoo.ads)::
336 * GNAT.Debug_Utilities (g-debuti.ads)::
337 * GNAT.Decode_String (g-decstr.ads)::
338 * GNAT.Decode_UTF8_String (g-deutst.ads)::
339 * GNAT.Directory_Operations (g-dirope.ads)::
340 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
341 * GNAT.Dynamic_HTables (g-dynhta.ads)::
342 * GNAT.Dynamic_Tables (g-dyntab.ads)::
343 * GNAT.Encode_String (g-encstr.ads)::
344 * GNAT.Encode_UTF8_String (g-enutst.ads)::
345 * GNAT.Exception_Actions (g-excact.ads)::
346 * GNAT.Exception_Traces (g-exctra.ads)::
347 * GNAT.Exceptions (g-except.ads)::
348 * GNAT.Expect (g-expect.ads)::
349 * GNAT.Float_Control (g-flocon.ads)::
350 * GNAT.Heap_Sort (g-heasor.ads)::
351 * GNAT.Heap_Sort_A (g-hesora.ads)::
352 * GNAT.Heap_Sort_G (g-hesorg.ads)::
353 * GNAT.HTable (g-htable.ads)::
354 * GNAT.IO (g-io.ads)::
355 * GNAT.IO_Aux (g-io_aux.ads)::
356 * GNAT.Lock_Files (g-locfil.ads)::
357 * GNAT.MD5 (g-md5.ads)::
358 * GNAT.Memory_Dump (g-memdum.ads)::
359 * GNAT.Most_Recent_Exception (g-moreex.ads)::
360 * GNAT.OS_Lib (g-os_lib.ads)::
361 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
362 * GNAT.Random_Numbers (g-rannum.ads)::
363 * GNAT.Regexp (g-regexp.ads)::
364 * GNAT.Registry (g-regist.ads)::
365 * GNAT.Regpat (g-regpat.ads)::
366 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
367 * GNAT.Semaphores (g-semaph.ads)::
368 * GNAT.Serial_Communications (g-sercom.ads)::
369 * GNAT.SHA1 (g-sha1.ads)::
370 * GNAT.Signals (g-signal.ads)::
371 * GNAT.Sockets (g-socket.ads)::
372 * GNAT.Source_Info (g-souinf.ads)::
373 * GNAT.Spelling_Checker (g-speche.ads)::
374 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
375 * GNAT.Spitbol.Patterns (g-spipat.ads)::
376 * GNAT.Spitbol (g-spitbo.ads)::
377 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
378 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
379 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
380 * GNAT.Strings (g-string.ads)::
381 * GNAT.String_Split (g-strspl.ads)::
382 * GNAT.Table (g-table.ads)::
383 * GNAT.Task_Lock (g-tasloc.ads)::
384 * GNAT.Threads (g-thread.ads)::
385 * GNAT.Time_Stamp (g-timsta.ads)::
386 * GNAT.Traceback (g-traceb.ads)::
387 * GNAT.Traceback.Symbolic (g-trasym.ads)::
388 * GNAT.UTF_32 (g-utf_32.ads)::
389 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
390 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
391 * GNAT.Wide_String_Split (g-wistsp.ads)::
392 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
393 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
394 * Interfaces.C.Extensions (i-cexten.ads)::
395 * Interfaces.C.Streams (i-cstrea.ads)::
396 * Interfaces.CPP (i-cpp.ads)::
397 * Interfaces.Packed_Decimal (i-pacdec.ads)::
398 * Interfaces.VxWorks (i-vxwork.ads)::
399 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
400 * System.Address_Image (s-addima.ads)::
401 * System.Assertions (s-assert.ads)::
402 * System.Memory (s-memory.ads)::
403 * System.Partition_Interface (s-parint.ads)::
404 * System.Pool_Global (s-pooglo.ads)::
405 * System.Pool_Local (s-pooloc.ads)::
406 * System.Restrictions (s-restri.ads)::
407 * System.Rident (s-rident.ads)::
408 * System.Task_Info (s-tasinf.ads)::
409 * System.Wch_Cnv (s-wchcnv.ads)::
410 * System.Wch_Con (s-wchcon.ads)::
411
412 Text_IO
413
414 * Text_IO Stream Pointer Positioning::
415 * Text_IO Reading and Writing Non-Regular Files::
416 * Get_Immediate::
417 * Treating Text_IO Files as Streams::
418 * Text_IO Extensions::
419 * Text_IO Facilities for Unbounded Strings::
420
421 Wide_Text_IO
422
423 * Wide_Text_IO Stream Pointer Positioning::
424 * Wide_Text_IO Reading and Writing Non-Regular Files::
425
426 Wide_Wide_Text_IO
427
428 * Wide_Wide_Text_IO Stream Pointer Positioning::
429 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
430
431 Interfacing to Other Languages
432
433 * Interfacing to C::
434 * Interfacing to C++::
435 * Interfacing to COBOL::
436 * Interfacing to Fortran::
437 * Interfacing to non-GNAT Ada code::
438
439 Specialized Needs Annexes
440
441 Implementation of Specific Ada Features
442 * Machine Code Insertions::
443 * GNAT Implementation of Tasking::
444 * GNAT Implementation of Shared Passive Packages::
445 * Code Generation for Array Aggregates::
446 * The Size of Discriminated Records with Default Discriminants::
447 * Strict Conformance to the Ada Reference Manual::
448
449 Project File Reference
450
451 Obsolescent Features
452
453 GNU Free Documentation License
454
455 Index
456 @end menu
457
458 @end ifnottex
459
460 @node About This Guide
461 @unnumbered About This Guide
462
463 @noindent
464 This manual contains useful information in writing programs using the
465 @value{EDITION} compiler.  It includes information on implementation dependent
466 characteristics of @value{EDITION}, including all the information required by
467 Annex M of the Ada language standard.
468
469 @value{EDITION} implements Ada 95 and Ada 2005, and it may also be invoked in
470 Ada 83 compatibility mode.
471 By default, @value{EDITION} assumes @value{DEFAULTLANGUAGEVERSION},
472 but you can override with a compiler switch
473 to explicitly specify the language version.
474 (Please refer to @ref{Compiling Different Versions of Ada,,, gnat_ugn,
475 @value{EDITION} User's Guide}, for details on these switches.)
476 Throughout this manual, references to ``Ada'' without a year suffix
477 apply to both the Ada 95 and Ada 2005 versions of the language.
478
479 Ada is designed to be highly portable.
480 In general, a program will have the same effect even when compiled by
481 different compilers on different platforms.
482 However, since Ada is designed to be used in a
483 wide variety of applications, it also contains a number of system
484 dependent features to be used in interfacing to the external world.
485 @cindex Implementation-dependent features
486 @cindex Portability
487
488 Note: Any program that makes use of implementation-dependent features
489 may be non-portable.  You should follow good programming practice and
490 isolate and clearly document any sections of your program that make use
491 of these features in a non-portable manner.
492
493 @ifset PROEDITION
494 For ease of exposition, ``GNAT Pro'' will be referred to simply as
495 ``GNAT'' in the remainder of this document.
496 @end ifset
497
498 @menu
499 * What This Reference Manual Contains::
500 * Conventions::
501 * Related Information::
502 @end menu
503
504 @node What This Reference Manual Contains
505 @unnumberedsec What This Reference Manual Contains
506
507 @noindent
508 This reference manual contains the following chapters:
509
510 @itemize @bullet
511 @item
512 @ref{Implementation Defined Pragmas}, lists GNAT implementation-dependent
513 pragmas, which can be used to extend and enhance the functionality of the
514 compiler.
515
516 @item
517 @ref{Implementation Defined Attributes}, lists GNAT
518 implementation-dependent attributes which can be used to extend and
519 enhance the functionality of the compiler.
520
521 @item
522 @ref{Implementation Advice}, provides information on generally
523 desirable behavior which are not requirements that all compilers must
524 follow since it cannot be provided on all systems, or which may be
525 undesirable on some systems.
526
527 @item
528 @ref{Implementation Defined Characteristics}, provides a guide to
529 minimizing implementation dependent features.
530
531 @item
532 @ref{Intrinsic Subprograms}, describes the intrinsic subprograms
533 implemented by GNAT, and how they can be imported into user
534 application programs.
535
536 @item
537 @ref{Representation Clauses and Pragmas}, describes in detail the
538 way that GNAT represents data, and in particular the exact set
539 of representation clauses and pragmas that is accepted.
540
541 @item
542 @ref{Standard Library Routines}, provides a listing of packages and a
543 brief description of the functionality that is provided by Ada's
544 extensive set of standard library routines as implemented by GNAT@.
545
546 @item
547 @ref{The Implementation of Standard I/O}, details how the GNAT
548 implementation of the input-output facilities.
549
550 @item
551 @ref{The GNAT Library}, is a catalog of packages that complement
552 the Ada predefined library.
553
554 @item
555 @ref{Interfacing to Other Languages}, describes how programs
556 written in Ada using GNAT can be interfaced to other programming
557 languages.
558
559 @ref{Specialized Needs Annexes}, describes the GNAT implementation of all
560 of the specialized needs annexes.
561
562 @item
563 @ref{Implementation of Specific Ada Features}, discusses issues related
564 to GNAT's implementation of machine code insertions, tasking, and several
565 other features.
566
567 @item
568 @ref{Project File Reference}, presents the syntax and semantics
569 of project files.
570
571 @item
572 @ref{Obsolescent Features} documents implementation dependent features,
573 including pragmas and attributes, which are considered obsolescent, since
574 there are other preferred ways of achieving the same results. These
575 obsolescent forms are retained for backwards compatibility.
576
577 @end itemize
578
579 @cindex Ada 95 Language Reference Manual
580 @cindex Ada 2005 Language Reference Manual
581 @noindent
582 This reference manual assumes a basic familiarity with the Ada 95 language, as
583 described in the International Standard ANSI/ISO/IEC-8652:1995,
584 January 1995.
585 It does not require knowledge of the new features introduced by Ada 2005,
586 (officially known as ISO/IEC 8652:1995 with Technical Corrigendum 1
587 and Amendment 1).
588 Both reference manuals are included in the GNAT documentation
589 package.
590
591 @node Conventions
592 @unnumberedsec Conventions
593 @cindex Conventions, typographical
594 @cindex Typographical conventions
595
596 @noindent
597 Following are examples of the typographical and graphic conventions used
598 in this guide:
599
600 @itemize @bullet
601 @item
602 @code{Functions}, @code{utility program names}, @code{standard names},
603 and @code{classes}.
604
605 @item
606 @code{Option flags}
607
608 @item
609 @file{File names}, @samp{button names}, and @samp{field names}.
610
611 @item
612 @code{Variables}, @env{environment variables}, and @var{metasyntactic
613 variables}.
614
615 @item
616 @emph{Emphasis}.
617
618 @item
619 [optional information or parameters]
620
621 @item
622 Examples are described by text
623 @smallexample
624 and then shown this way.
625 @end smallexample
626 @end itemize
627
628 @noindent
629 Commands that are entered by the user are preceded in this manual by the
630 characters @samp{$ } (dollar sign followed by space).  If your system uses this
631 sequence as a prompt, then the commands will appear exactly as you see them
632 in the manual.  If your system uses some other prompt, then the command will
633 appear with the @samp{$} replaced by whatever prompt character you are using.
634
635 @node Related Information
636 @unnumberedsec Related Information
637 @noindent
638 See the following documents for further information on GNAT:
639
640 @itemize @bullet
641 @item
642 @xref{Top, @value{EDITION} User's Guide, About This Guide, gnat_ugn,
643 @value{EDITION} User's Guide}, which provides information on how to use the
644 GNAT compiler system.
645
646 @item
647 @cite{Ada 95 Reference Manual}, which contains all reference
648 material for the Ada 95 programming language.
649
650 @item
651 @cite{Ada 95 Annotated Reference Manual}, which is an annotated version
652 of the Ada 95 standard.  The annotations describe
653 detailed aspects of the design decision, and in particular contain useful
654 sections on Ada 83 compatibility.
655
656 @item
657 @cite{Ada 2005 Reference Manual}, which contains all reference
658 material for the Ada 2005 programming language.
659
660 @item
661 @cite{Ada 2005 Annotated Reference Manual}, which is an annotated version
662 of the Ada 2005 standard.  The annotations describe
663 detailed aspects of the design decision, and in particular contain useful
664 sections on Ada 83 and Ada 95 compatibility.
665
666 @item
667 @cite{DEC Ada, Technical Overview and Comparison on DIGITAL Platforms},
668 which contains specific information on compatibility between GNAT and
669 DEC Ada 83 systems.
670
671 @item
672 @cite{DEC Ada, Language Reference Manual, part number AA-PYZAB-TK} which
673 describes in detail the pragmas and attributes provided by the DEC Ada 83
674 compiler system.
675
676 @end itemize
677
678 @node Implementation Defined Pragmas
679 @chapter Implementation Defined Pragmas
680
681 @noindent
682 Ada defines a set of pragmas that can be used to supply additional
683 information to the compiler.  These language defined pragmas are
684 implemented in GNAT and work as described in the Ada Reference
685 Manual.
686
687 In addition, Ada allows implementations to define additional pragmas
688 whose meaning is defined by the implementation.  GNAT provides a number
689 of these implementation-defined pragmas, which can be used to extend
690 and enhance the functionality of the compiler.  This section of the GNAT
691 Reference Manual describes these additional pragmas.
692
693 Note that any program using these pragmas might not be portable to other
694 compilers (although GNAT implements this set of pragmas on all
695 platforms).  Therefore if portability to other compilers is an important
696 consideration, the use of these pragmas should be minimized.
697
698 @menu
699 * Pragma Abort_Defer::
700 * Pragma Ada_83::
701 * Pragma Ada_95::
702 * Pragma Ada_05::
703 * Pragma Ada_2005::
704 * Pragma Annotate::
705 * Pragma Assert::
706 * Pragma Ast_Entry::
707 * Pragma C_Pass_By_Copy::
708 * Pragma Check::
709 * Pragma Check_Name::
710 * Pragma Check_Policy::
711 * Pragma Comment::
712 * Pragma Common_Object::
713 * Pragma Compile_Time_Error::
714 * Pragma Compile_Time_Warning::
715 * Pragma Complete_Representation::
716 * Pragma Complex_Representation::
717 * Pragma Component_Alignment::
718 * Pragma Convention_Identifier::
719 * Pragma CPP_Class::
720 * Pragma CPP_Constructor::
721 * Pragma CPP_Virtual::
722 * Pragma CPP_Vtable::
723 * Pragma Debug::
724 * Pragma Debug_Policy::
725 * Pragma Detect_Blocking::
726 * Pragma Elaboration_Checks::
727 * Pragma Eliminate::
728 * Pragma Export_Exception::
729 * Pragma Export_Function::
730 * Pragma Export_Object::
731 * Pragma Export_Procedure::
732 * Pragma Export_Value::
733 * Pragma Export_Valued_Procedure::
734 * Pragma Extend_System::
735 * Pragma External::
736 * Pragma External_Name_Casing::
737 * Pragma Fast_Math::
738 * Pragma Favor_Top_Level::
739 * Pragma Finalize_Storage_Only::
740 * Pragma Float_Representation::
741 * Pragma Ident::
742 * Pragma Implemented_By_Entry::
743 * Pragma Implicit_Packing::
744 * Pragma Import_Exception::
745 * Pragma Import_Function::
746 * Pragma Import_Object::
747 * Pragma Import_Procedure::
748 * Pragma Import_Valued_Procedure::
749 * Pragma Initialize_Scalars::
750 * Pragma Inline_Always::
751 * Pragma Inline_Generic::
752 * Pragma Interface::
753 * Pragma Interface_Name::
754 * Pragma Interrupt_Handler::
755 * Pragma Interrupt_State::
756 * Pragma Keep_Names::
757 * Pragma License::
758 * Pragma Link_With::
759 * Pragma Linker_Alias::
760 * Pragma Linker_Constructor::
761 * Pragma Linker_Destructor::
762 * Pragma Linker_Section::
763 * Pragma Long_Float::
764 * Pragma Machine_Attribute::
765 * Pragma Main::
766 * Pragma Main_Storage::
767 * Pragma No_Body::
768 * Pragma No_Return::
769 * Pragma No_Strict_Aliasing::
770 * Pragma Normalize_Scalars::
771 * Pragma Obsolescent::
772 * Pragma Optimize_Alignment::
773 * Pragma Passive::
774 * Pragma Persistent_BSS::
775 * Pragma Polling::
776 * Pragma Postcondition::
777 * Pragma Precondition::
778 * Pragma Profile (Ravenscar)::
779 * Pragma Profile (Restricted)::
780 * Pragma Psect_Object::
781 * Pragma Pure_Function::
782 * Pragma Restriction_Warnings::
783 * Pragma Shared::
784 * Pragma Source_File_Name::
785 * Pragma Source_File_Name_Project::
786 * Pragma Source_Reference::
787 * Pragma Stream_Convert::
788 * Pragma Style_Checks::
789 * Pragma Subtitle::
790 * Pragma Suppress::
791 * Pragma Suppress_All::
792 * Pragma Suppress_Exception_Locations::
793 * Pragma Suppress_Initialization::
794 * Pragma Task_Info::
795 * Pragma Task_Name::
796 * Pragma Task_Storage::
797 * Pragma Time_Slice::
798 * Pragma Title::
799 * Pragma Unchecked_Union::
800 * Pragma Unimplemented_Unit::
801 * Pragma Universal_Aliasing ::
802 * Pragma Universal_Data::
803 * Pragma Unmodified::
804 * Pragma Unreferenced::
805 * Pragma Unreferenced_Objects::
806 * Pragma Unreserve_All_Interrupts::
807 * Pragma Unsuppress::
808 * Pragma Use_VADS_Size::
809 * Pragma Validity_Checks::
810 * Pragma Volatile::
811 * Pragma Warnings::
812 * Pragma Weak_External::
813 * Pragma Wide_Character_Encoding::
814 @end menu
815
816 @node Pragma Abort_Defer
817 @unnumberedsec Pragma Abort_Defer
818 @findex Abort_Defer
819 @cindex Deferring aborts
820 @noindent
821 Syntax:
822 @smallexample
823 pragma Abort_Defer;
824 @end smallexample
825
826 @noindent
827 This pragma must appear at the start of the statement sequence of a
828 handled sequence of statements (right after the @code{begin}).  It has
829 the effect of deferring aborts for the sequence of statements (but not
830 for the declarations or handlers, if any, associated with this statement
831 sequence).
832
833 @node Pragma Ada_83
834 @unnumberedsec Pragma Ada_83
835 @findex Ada_83
836 @noindent
837 Syntax:
838 @smallexample @c ada
839 pragma Ada_83;
840 @end smallexample
841
842 @noindent
843 A configuration pragma that establishes Ada 83 mode for the unit to
844 which it applies, regardless of the mode set by the command line
845 switches.  In Ada 83 mode, GNAT attempts to be as compatible with
846 the syntax and semantics of Ada 83, as defined in the original Ada
847 83 Reference Manual as possible.  In particular, the keywords added by Ada 95
848 and Ada 2005 are not recognized, optional package bodies are allowed,
849 and generics may name types with unknown discriminants without using
850 the @code{(<>)} notation.  In addition, some but not all of the additional
851 restrictions of Ada 83 are enforced.
852
853 Ada 83 mode is intended for two purposes.  Firstly, it allows existing
854 Ada 83 code to be compiled and adapted to GNAT with less effort.
855 Secondly, it aids in keeping code backwards compatible with Ada 83.
856 However, there is no guarantee that code that is processed correctly
857 by GNAT in Ada 83 mode will in fact compile and execute with an Ada
858 83 compiler, since GNAT does not enforce all the additional checks
859 required by Ada 83.
860
861 @node Pragma Ada_95
862 @unnumberedsec Pragma Ada_95
863 @findex Ada_95
864 @noindent
865 Syntax:
866 @smallexample @c ada
867 pragma Ada_95;
868 @end smallexample
869
870 @noindent
871 A configuration pragma that establishes Ada 95 mode for the unit to which
872 it applies, regardless of the mode set by the command line switches.
873 This mode is set automatically for the @code{Ada} and @code{System}
874 packages and their children, so you need not specify it in these
875 contexts.  This pragma is useful when writing a reusable component that
876 itself uses Ada 95 features, but which is intended to be usable from
877 either Ada 83 or Ada 95 programs.
878
879 @node Pragma Ada_05
880 @unnumberedsec Pragma Ada_05
881 @findex Ada_05
882 @noindent
883 Syntax:
884 @smallexample @c ada
885 pragma Ada_05;
886 @end smallexample
887
888 @noindent
889 A configuration pragma that establishes Ada 2005 mode for the unit to which
890 it applies, regardless of the mode set by the command line switches.
891 This mode is set automatically for the @code{Ada} and @code{System}
892 packages and their children, so you need not specify it in these
893 contexts.  This pragma is useful when writing a reusable component that
894 itself uses Ada 2005 features, but which is intended to be usable from
895 either Ada 83 or Ada 95 programs.
896
897 @node Pragma Ada_2005
898 @unnumberedsec Pragma Ada_2005
899 @findex Ada_2005
900 @noindent
901 Syntax:
902 @smallexample @c ada
903 pragma Ada_2005;
904 @end smallexample
905
906 @noindent
907 This configuration pragma is a synonym for pragma Ada_05 and has the
908 same syntax and effect.
909
910 @node Pragma Annotate
911 @unnumberedsec Pragma Annotate
912 @findex Annotate
913 @noindent
914 Syntax:
915 @smallexample @c ada
916 pragma Annotate (IDENTIFIER @{, ARG@});
917
918 ARG ::= NAME | EXPRESSION
919 @end smallexample
920
921 @noindent
922 This pragma is used to annotate programs.  @var{identifier} identifies
923 the type of annotation.  GNAT verifies that it is an identifier, but does
924 not otherwise analyze it.  The @var{arg} argument
925 can be either a string literal or an
926 expression.  String literals are assumed to be of type
927 @code{Standard.String}.  Names of entities are simply analyzed as entity
928 names.  All other expressions are analyzed as expressions, and must be
929 unambiguous.
930
931 The analyzed pragma is retained in the tree, but not otherwise processed
932 by any part of the GNAT compiler.  This pragma is intended for use by
933 external tools, including ASIS@.
934
935 @node Pragma Assert
936 @unnumberedsec Pragma Assert
937 @findex Assert
938 @noindent
939 Syntax:
940 @smallexample @c ada
941 pragma Assert (
942   boolean_EXPRESSION
943   [, string_EXPRESSION]);
944 @end smallexample
945
946 @noindent
947 The effect of this pragma depends on whether the corresponding command
948 line switch is set to activate assertions.  The pragma expands into code
949 equivalent to the following:
950
951 @smallexample @c ada
952 if assertions-enabled then
953    if not boolean_EXPRESSION then
954       System.Assertions.Raise_Assert_Failure
955         (string_EXPRESSION);
956    end if;
957 end if;
958 @end smallexample
959
960 @noindent
961 The string argument, if given, is the message that will be associated
962 with the exception occurrence if the exception is raised.  If no second
963 argument is given, the default message is @samp{@var{file}:@var{nnn}},
964 where @var{file} is the name of the source file containing the assert,
965 and @var{nnn} is the line number of the assert.  A pragma is not a
966 statement, so if a statement sequence contains nothing but a pragma
967 assert, then a null statement is required in addition, as in:
968
969 @smallexample @c ada
970 @dots{}
971 if J > 3 then
972    pragma Assert (K > 3, "Bad value for K");
973    null;
974 end if;
975 @end smallexample
976
977 @noindent
978 Note that, as with the @code{if} statement to which it is equivalent, the
979 type of the expression is either @code{Standard.Boolean}, or any type derived
980 from this standard type.
981
982 If assertions are disabled (switch @option{-gnata} not used), then there
983 is no run-time effect (and in particular, any side effects from the
984 expression will not occur at run time).  (The expression is still
985 analyzed at compile time, and may cause types to be frozen if they are
986 mentioned here for the first time).
987
988 If assertions are enabled, then the given expression is tested, and if
989 it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
990 which results in the raising of @code{Assert_Failure} with the given message.
991
992 You should generally avoid side effects in the expression arguments of
993 this pragma, because these side effects will turn on and off with the
994 setting of the assertions mode, resulting in assertions that have an
995 effect on the program.  However, the expressions are analyzed for
996 semantic correctness whether or not assertions are enabled, so turning
997 assertions on and off cannot affect the legality of a program.
998
999 @node Pragma Ast_Entry
1000 @unnumberedsec Pragma Ast_Entry
1001 @cindex OpenVMS
1002 @findex Ast_Entry
1003 @noindent
1004 Syntax:
1005 @smallexample @c ada
1006 pragma AST_Entry (entry_IDENTIFIER);
1007 @end smallexample
1008
1009 @noindent
1010 This pragma is implemented only in the OpenVMS implementation of GNAT@.  The
1011 argument is the simple name of a single entry; at most one @code{AST_Entry}
1012 pragma is allowed for any given entry.  This pragma must be used in
1013 conjunction with the @code{AST_Entry} attribute, and is only allowed after
1014 the entry declaration and in the same task type specification or single task
1015 as the entry to which it applies.  This pragma specifies that the given entry
1016 may be used to handle an OpenVMS asynchronous system trap (@code{AST})
1017 resulting from an OpenVMS system service call.  The pragma does not affect
1018 normal use of the entry.  For further details on this pragma, see the
1019 DEC Ada Language Reference Manual, section 9.12a.
1020
1021 @node Pragma C_Pass_By_Copy
1022 @unnumberedsec Pragma C_Pass_By_Copy
1023 @cindex Passing by copy
1024 @findex C_Pass_By_Copy
1025 @noindent
1026 Syntax:
1027 @smallexample @c ada
1028 pragma C_Pass_By_Copy
1029   ([Max_Size =>] static_integer_EXPRESSION);
1030 @end smallexample
1031
1032 @noindent
1033 Normally the default mechanism for passing C convention records to C
1034 convention subprograms is to pass them by reference, as suggested by RM
1035 B.3(69).  Use the configuration pragma @code{C_Pass_By_Copy} to change
1036 this default, by requiring that record formal parameters be passed by
1037 copy if all of the following conditions are met:
1038
1039 @itemize @bullet
1040 @item
1041 The size of the record type does not exceed the value specified for
1042 @code{Max_Size}.
1043 @item
1044 The record type has @code{Convention C}.
1045 @item
1046 The formal parameter has this record type, and the subprogram has a
1047 foreign (non-Ada) convention.
1048 @end itemize
1049
1050 @noindent
1051 If these conditions are met the argument is passed by copy, i.e.@: in a
1052 manner consistent with what C expects if the corresponding formal in the
1053 C prototype is a struct (rather than a pointer to a struct).
1054
1055 You can also pass records by copy by specifying the convention
1056 @code{C_Pass_By_Copy} for the record type, or by using the extended
1057 @code{Import} and @code{Export} pragmas, which allow specification of
1058 passing mechanisms on a parameter by parameter basis.
1059
1060 @node Pragma Check
1061 @unnumberedsec Pragma Check
1062 @cindex Assertions
1063 @cindex Named assertions
1064 @findex Check
1065 @noindent
1066 Syntax:
1067 @smallexample @c ada
1068 pragma Check (
1069      [Name    =>] Identifier,
1070      [Check   =>] Boolean_EXPRESSION
1071   [, [Message =>] string_EXPRESSION] );
1072 @end smallexample
1073
1074 @noindent
1075 This pragma is similar to the predefined pragma @code{Assert} except that an
1076 extra identifier argument is present. In conjunction with pragma
1077 @code{Check_Policy}, this can be used to define groups of assertions that can
1078 be independently controlled. The identifier @code{Assertion} is special, it
1079 refers to the normal set of pragma @code{Assert} statements. The identifiers
1080 @code{Precondition} and @code{Postcondition} correspond to the pragmas of these
1081 names, so these three names would normally not be used directly in a pragma
1082 @code{Check}.
1083
1084 Checks introduced by this pragma are normally deactivated by default. They can
1085 be activated either by the command line option @option{-gnata}, which turns on
1086 all checks, or individually controlled using pragma @code{Check_Policy}.
1087
1088 @node Pragma Check_Name
1089 @unnumberedsec Pragma Check_Name
1090 @cindex Defining check names
1091 @cindex Check names, defining
1092 @findex Check_Name
1093 @noindent
1094 Syntax:
1095 @smallexample @c ada
1096 pragma Check_Name (check_name_IDENTIFIER);
1097 @end smallexample
1098
1099 @noindent
1100 This is a configuration pragma that defines a new implementation
1101 defined check name (unless IDENTIFIER matches one of the predefined
1102 check names, in which case the pragma has no effect). Check names
1103 are global to a partition, so if two or more configuration pragmas
1104 are present in a partition mentioning the same name, only one new
1105 check name is introduced.
1106
1107 An implementation defined check name introduced with this pragma may
1108 be used in only three contexts: @code{pragma Suppress},
1109 @code{pragma Unsuppress},
1110 and as the prefix of a @code{Check_Name'Enabled} attribute reference. For
1111 any of these three cases, the check name must be visible. A check
1112 name is visible if it is in the configuration pragmas applying to
1113 the current unit, or if it appears at the start of any unit that
1114 is part of the dependency set of the current unit (e.g., units that
1115 are mentioned in @code{with} clauses).
1116
1117 @node Pragma Check_Policy
1118 @unnumberedsec Pragma Check_Policy
1119 @cindex Controlling assertions
1120 @cindex Assertions, control
1121 @cindex Check pragma control
1122 @cindex Named assertions
1123 @findex Check
1124 @noindent
1125 Syntax:
1126 @smallexample @c ada
1127 pragma Check_Policy ([Name =>] Identifier, POLICY_IDENTIFIER);
1128
1129 POLICY_IDENTIFIER ::= On | Off | Check | Ignore
1130 @end smallexample
1131
1132 @noindent
1133 This pragma is similar to the predefined pragma @code{Assertion_Policy},
1134 except that it controls sets of named assertions introduced using the
1135 @code{Check} pragmas. It can be used as a configuration pragma or (unlike
1136 @code{Assertion_Policy}) can be used within a declarative part, in which case
1137 it controls the status to the end of the corresponding construct (in a manner
1138 identical to pragma @code{Suppress)}.
1139
1140 The identifier given as the first argument corresponds to a name used in
1141 associated @code{Check} pragmas. For example, if the pragma:
1142
1143 @smallexample @c ada
1144 pragma Check_Policy (Critical_Error, Off);
1145 @end smallexample
1146
1147 @noindent
1148 is given, then subsequent @code{Check} pragmas whose first argument is also
1149 @code{Critical_Error} will be disabled. The special identifier @code{Assertion}
1150 controls the behavior of normal @code{Assert} pragmas (thus a pragma
1151 @code{Check_Policy} with this identifier is similar to the normal
1152 @code{Assertion_Policy} pragma except that it can appear within a
1153 declarative part).
1154
1155 The special identifiers @code{Precondition} and @code{Postcondition} control
1156 the status of preconditions and postconditions. If a @code{Precondition} pragma
1157 is encountered, it is ignored if turned off by a @code{Check_Policy} specifying
1158 that @code{Precondition} checks are @code{Off} or @code{Ignored}. Similarly use
1159 of the name @code{Postcondition} controls whether @code{Postcondition} pragmas
1160 are recognized.
1161
1162 The check policy is @code{Off} to turn off corresponding checks, and @code{On}
1163 to turn on corresponding checks. The default for a set of checks for which no
1164 @code{Check_Policy} is given is @code{Off} unless the compiler switch
1165 @option{-gnata} is given, which turns on all checks by default.
1166
1167 The check policy settings @code{Check} and @code{Ignore} are also recognized
1168 as synonyms for @code{On} and @code{Off}. These synonyms are provided for
1169 compatibility with the standard @code{Assertion_Policy} pragma.
1170
1171 @node Pragma Comment
1172 @unnumberedsec Pragma Comment
1173 @findex Comment
1174 @noindent
1175 Syntax:
1176
1177 @smallexample @c ada
1178 pragma Comment (static_string_EXPRESSION);
1179 @end smallexample
1180
1181 @noindent
1182 This is almost identical in effect to pragma @code{Ident}.  It allows the
1183 placement of a comment into the object file and hence into the
1184 executable file if the operating system permits such usage.  The
1185 difference is that @code{Comment}, unlike @code{Ident}, has
1186 no limitations on placement of the pragma (it can be placed
1187 anywhere in the main source unit), and if more than one pragma
1188 is used, all comments are retained.
1189
1190 @node Pragma Common_Object
1191 @unnumberedsec Pragma Common_Object
1192 @findex Common_Object
1193 @noindent
1194 Syntax:
1195
1196 @smallexample @c ada
1197 pragma Common_Object (
1198      [Internal =>] LOCAL_NAME
1199   [, [External =>] EXTERNAL_SYMBOL]
1200   [, [Size     =>] EXTERNAL_SYMBOL] );
1201
1202 EXTERNAL_SYMBOL ::=
1203   IDENTIFIER
1204 | static_string_EXPRESSION
1205 @end smallexample
1206
1207 @noindent
1208 This pragma enables the shared use of variables stored in overlaid
1209 linker areas corresponding to the use of @code{COMMON}
1210 in Fortran.  The single
1211 object @var{LOCAL_NAME} is assigned to the area designated by
1212 the @var{External} argument.
1213 You may define a record to correspond to a series
1214 of fields.  The @var{Size} argument
1215 is syntax checked in GNAT, but otherwise ignored.
1216
1217 @code{Common_Object} is not supported on all platforms.  If no
1218 support is available, then the code generator will issue a message
1219 indicating that the necessary attribute for implementation of this
1220 pragma is not available.
1221
1222 @node Pragma Compile_Time_Error
1223 @unnumberedsec Pragma Compile_Time_Error
1224 @findex Compile_Time_Error
1225 @noindent
1226 Syntax:
1227
1228 @smallexample @c ada
1229 pragma Compile_Time_Error
1230          (boolean_EXPRESSION, static_string_EXPRESSION);
1231 @end smallexample
1232
1233 @noindent
1234 This pragma can be used to generate additional compile time
1235 error messages. It
1236 is particularly useful in generics, where errors can be issued for
1237 specific problematic instantiations. The first parameter is a boolean
1238 expression. The pragma is effective only if the value of this expression
1239 is known at compile time, and has the value True. The set of expressions
1240 whose values are known at compile time includes all static boolean
1241 expressions, and also other values which the compiler can determine
1242 at compile time (e.g., the size of a record type set by an explicit
1243 size representation clause, or the value of a variable which was
1244 initialized to a constant and is known not to have been modified).
1245 If these conditions are met, an error message is generated using
1246 the value given as the second argument. This string value may contain
1247 embedded ASCII.LF characters to break the message into multiple lines.
1248
1249 @node Pragma Compile_Time_Warning
1250 @unnumberedsec Pragma Compile_Time_Warning
1251 @findex Compile_Time_Warning
1252 @noindent
1253 Syntax:
1254
1255 @smallexample @c ada
1256 pragma Compile_Time_Warning
1257          (boolean_EXPRESSION, static_string_EXPRESSION);
1258 @end smallexample
1259
1260 @noindent
1261 Same as pragma Compile_Time_Error, except a warning is issued instead
1262 of an error message. Note that if this pragma is used in a package that
1263 is with'ed by a client, the client will get the warning even though it
1264 is issued by a with'ed package (normally warnings in with'ed units are
1265 suppressed, but this is a special exception to that rule).
1266
1267 One typical use is within a generic where compile time known characteristics
1268 of formal parameters are tested, and warnings given appropriately. Another use
1269 with a first parameter of True is to warn a client about use of a package,
1270 for example that it is not fully implemented.
1271
1272 @node Pragma Complete_Representation
1273 @unnumberedsec Pragma Complete_Representation
1274 @findex Complete_Representation
1275 @noindent
1276 Syntax:
1277
1278 @smallexample @c ada
1279 pragma Complete_Representation;
1280 @end smallexample
1281
1282 @noindent
1283 This pragma must appear immediately within a record representation
1284 clause. Typical placements are before the first component clause
1285 or after the last component clause. The effect is to give an error
1286 message if any component is missing a component clause. This pragma
1287 may be used to ensure that a record representation clause is
1288 complete, and that this invariant is maintained if fields are
1289 added to the record in the future.
1290
1291 @node Pragma Complex_Representation
1292 @unnumberedsec Pragma Complex_Representation
1293 @findex Complex_Representation
1294 @noindent
1295 Syntax:
1296
1297 @smallexample @c ada
1298 pragma Complex_Representation
1299         ([Entity =>] LOCAL_NAME);
1300 @end smallexample
1301
1302 @noindent
1303 The @var{Entity} argument must be the name of a record type which has
1304 two fields of the same floating-point type.  The effect of this pragma is
1305 to force gcc to use the special internal complex representation form for
1306 this record, which may be more efficient.  Note that this may result in
1307 the code for this type not conforming to standard ABI (application
1308 binary interface) requirements for the handling of record types.  For
1309 example, in some environments, there is a requirement for passing
1310 records by pointer, and the use of this pragma may result in passing
1311 this type in floating-point registers.
1312
1313 @node Pragma Component_Alignment
1314 @unnumberedsec Pragma Component_Alignment
1315 @cindex Alignments of components
1316 @findex Component_Alignment
1317 @noindent
1318 Syntax:
1319
1320 @smallexample @c ada
1321 pragma Component_Alignment (
1322      [Form =>] ALIGNMENT_CHOICE
1323   [, [Name =>] type_LOCAL_NAME]);
1324
1325 ALIGNMENT_CHOICE ::=
1326   Component_Size
1327 | Component_Size_4
1328 | Storage_Unit
1329 | Default
1330 @end smallexample
1331
1332 @noindent
1333 Specifies the alignment of components in array or record types.
1334 The meaning of the @var{Form} argument is as follows:
1335
1336 @table @code
1337 @findex Component_Size
1338 @item Component_Size
1339 Aligns scalar components and subcomponents of the array or record type
1340 on boundaries appropriate to their inherent size (naturally
1341 aligned).  For example, 1-byte components are aligned on byte boundaries,
1342 2-byte integer components are aligned on 2-byte boundaries, 4-byte
1343 integer components are aligned on 4-byte boundaries and so on.  These
1344 alignment rules correspond to the normal rules for C compilers on all
1345 machines except the VAX@.
1346
1347 @findex Component_Size_4
1348 @item Component_Size_4
1349 Naturally aligns components with a size of four or fewer
1350 bytes.  Components that are larger than 4 bytes are placed on the next
1351 4-byte boundary.
1352
1353 @findex Storage_Unit
1354 @item Storage_Unit
1355 Specifies that array or record components are byte aligned, i.e.@:
1356 aligned on boundaries determined by the value of the constant
1357 @code{System.Storage_Unit}.
1358
1359 @cindex OpenVMS
1360 @item Default
1361 Specifies that array or record components are aligned on default
1362 boundaries, appropriate to the underlying hardware or operating system or
1363 both.  For OpenVMS VAX systems, the @code{Default} choice is the same as
1364 the @code{Storage_Unit} choice (byte alignment).  For all other systems,
1365 the @code{Default} choice is the same as @code{Component_Size} (natural
1366 alignment).
1367 @end table
1368
1369 @noindent
1370 If the @code{Name} parameter is present, @var{type_LOCAL_NAME} must
1371 refer to a local record or array type, and the specified alignment
1372 choice applies to the specified type.  The use of
1373 @code{Component_Alignment} together with a pragma @code{Pack} causes the
1374 @code{Component_Alignment} pragma to be ignored.  The use of
1375 @code{Component_Alignment} together with a record representation clause
1376 is only effective for fields not specified by the representation clause.
1377
1378 If the @code{Name} parameter is absent, the pragma can be used as either
1379 a configuration pragma, in which case it applies to one or more units in
1380 accordance with the normal rules for configuration pragmas, or it can be
1381 used within a declarative part, in which case it applies to types that
1382 are declared within this declarative part, or within any nested scope
1383 within this declarative part.  In either case it specifies the alignment
1384 to be applied to any record or array type which has otherwise standard
1385 representation.
1386
1387 If the alignment for a record or array type is not specified (using
1388 pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
1389 clause), the GNAT uses the default alignment as described previously.
1390
1391 @node Pragma Convention_Identifier
1392 @unnumberedsec Pragma Convention_Identifier
1393 @findex Convention_Identifier
1394 @cindex Conventions, synonyms
1395 @noindent
1396 Syntax:
1397
1398 @smallexample @c ada
1399 pragma Convention_Identifier (
1400          [Name =>]       IDENTIFIER,
1401          [Convention =>] convention_IDENTIFIER);
1402 @end smallexample
1403
1404 @noindent
1405 This pragma provides a mechanism for supplying synonyms for existing
1406 convention identifiers. The @code{Name} identifier can subsequently
1407 be used as a synonym for the given convention in other pragmas (including
1408 for example pragma @code{Import} or another @code{Convention_Identifier}
1409 pragma). As an example of the use of this, suppose you had legacy code
1410 which used Fortran77 as the identifier for Fortran. Then the pragma:
1411
1412 @smallexample @c ada
1413 pragma Convention_Identifier (Fortran77, Fortran);
1414 @end smallexample
1415
1416 @noindent
1417 would allow the use of the convention identifier @code{Fortran77} in
1418 subsequent code, avoiding the need to modify the sources. As another
1419 example, you could use this to parametrize convention requirements
1420 according to systems. Suppose you needed to use @code{Stdcall} on
1421 windows systems, and @code{C} on some other system, then you could
1422 define a convention identifier @code{Library} and use a single
1423 @code{Convention_Identifier} pragma to specify which convention
1424 would be used system-wide.
1425
1426 @node Pragma CPP_Class
1427 @unnumberedsec Pragma CPP_Class
1428 @findex CPP_Class
1429 @cindex Interfacing with C++
1430 @noindent
1431 Syntax:
1432
1433 @smallexample @c ada
1434 pragma CPP_Class ([Entity =>] LOCAL_NAME);
1435 @end smallexample
1436
1437 @noindent
1438 The argument denotes an entity in the current declarative region that is
1439 declared as a tagged record type. It indicates that the type corresponds
1440 to an externally declared C++ class type, and is to be laid out the same
1441 way that C++ would lay out the type.
1442
1443 Types for which @code{CPP_Class} is specified do not have assignment or
1444 equality operators defined (such operations can be imported or declared
1445 as subprograms as required). Initialization is allowed only by constructor
1446 functions (see pragma @code{CPP_Constructor}). Such types are implicitly
1447 limited if not explicitly declared as limited or derived from a limited
1448 type, and a warning is issued in that case.
1449
1450 Pragma @code{CPP_Class} is intended primarily for automatic generation
1451 using an automatic binding generator tool.
1452 See @ref{Interfacing to C++} for related information.
1453
1454 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
1455 for backward compatibility but its functionality is available
1456 using pragma @code{Import} with @code{Convention} = @code{CPP}.
1457
1458 @node Pragma CPP_Constructor
1459 @unnumberedsec Pragma CPP_Constructor
1460 @cindex Interfacing with C++
1461 @findex CPP_Constructor
1462 @noindent
1463 Syntax:
1464
1465 @smallexample @c ada
1466 pragma CPP_Constructor ([Entity =>] LOCAL_NAME
1467   [, [External_Name =>] static_string_EXPRESSION ]
1468   [, [Link_Name     =>] static_string_EXPRESSION ]);
1469 @end smallexample
1470
1471 @noindent
1472 This pragma identifies an imported function (imported in the usual way
1473 with pragma @code{Import}) as corresponding to a C++ constructor. If
1474 @code{External_Name} and @code{Link_Name} are not specified then the
1475 @code{Entity} argument is a name that must have been previously mentioned
1476 in a pragma @code{Import} with @code{Convention} = @code{CPP}. Such name
1477 must be of one of the following forms:
1478
1479 @itemize @bullet
1480 @item
1481 @code{function @var{Fname} return @var{T}'Class}
1482
1483 @item
1484 @code{function @var{Fname} (@dots{}) return @var{T}'Class}
1485 @end itemize
1486
1487 @noindent
1488 where @var{T} is a tagged type to which the pragma @code{CPP_Class} applies.
1489
1490 The first form is the default constructor, used when an object of type
1491 @var{T} is created on the Ada side with no explicit constructor.  Other
1492 constructors (including the copy constructor, which is simply a special
1493 case of the second form in which the one and only argument is of type
1494 @var{T}), can only appear in two contexts:
1495
1496 @itemize @bullet
1497 @item
1498 On the right side of an initialization of an object of type @var{T}.
1499 @item
1500 In an extension aggregate for an object of a type derived from @var{T}.
1501 @end itemize
1502
1503 @noindent
1504 Although the constructor is described as a function that returns a value
1505 on the Ada side, it is typically a procedure with an extra implicit
1506 argument (the object being initialized) at the implementation
1507 level.  GNAT issues the appropriate call, whatever it is, to get the
1508 object properly initialized.
1509
1510 In the case of derived objects, you may use one of two possible forms
1511 for declaring and creating an object:
1512
1513 @itemize @bullet
1514 @item @code{New_Object : Derived_T}
1515 @item @code{New_Object : Derived_T := (@var{constructor-call with} @dots{})}
1516 @end itemize
1517
1518 @noindent
1519 In the first case the default constructor is called and extension fields
1520 if any are initialized according to the default initialization
1521 expressions in the Ada declaration.  In the second case, the given
1522 constructor is called and the extension aggregate indicates the explicit
1523 values of the extension fields.
1524
1525 If no constructors are imported, it is impossible to create any objects
1526 on the Ada side.  If no default constructor is imported, only the
1527 initialization forms using an explicit call to a constructor are
1528 permitted.
1529
1530 Pragma @code{CPP_Constructor} is intended primarily for automatic generation
1531 using an automatic binding generator tool.
1532 See @ref{Interfacing to C++} for more related information.
1533
1534 @node Pragma CPP_Virtual
1535 @unnumberedsec Pragma CPP_Virtual
1536 @cindex Interfacing to C++
1537 @findex CPP_Virtual
1538 @noindent
1539 This pragma is now obsolete has has no effect because GNAT generates
1540 the same object layout than the G++ compiler.
1541
1542 See @ref{Interfacing to C++} for related information.
1543
1544 @node Pragma CPP_Vtable
1545 @unnumberedsec Pragma CPP_Vtable
1546 @cindex Interfacing with C++
1547 @findex CPP_Vtable
1548 @noindent
1549 This pragma is now obsolete has has no effect because GNAT generates
1550 the same object layout than the G++ compiler.
1551
1552 See @ref{Interfacing to C++} for related information.
1553
1554 @node Pragma Debug
1555 @unnumberedsec Pragma Debug
1556 @findex Debug
1557 @noindent
1558 Syntax:
1559
1560 @smallexample @c ada
1561 pragma Debug ([CONDITION, ]PROCEDURE_CALL_WITHOUT_SEMICOLON);
1562
1563 PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
1564   PROCEDURE_NAME
1565 | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
1566 @end smallexample
1567
1568 @noindent
1569 The procedure call argument has the syntactic form of an expression, meeting
1570 the syntactic requirements for pragmas.
1571
1572 If debug pragmas are not enabled or if the condition is present and evaluates
1573 to False, this pragma has no effect. If debug pragmas are enabled, the
1574 semantics of the pragma is exactly equivalent to the procedure call statement
1575 corresponding to the argument with a terminating semicolon. Pragmas are
1576 permitted in sequences of declarations, so you can use pragma @code{Debug} to
1577 intersperse calls to debug procedures in the middle of declarations. Debug
1578 pragmas can be enabled either by use of the command line switch @option{-gnata}
1579 or by use of the configuration pragma @code{Debug_Policy}.
1580
1581 @node Pragma Debug_Policy
1582 @unnumberedsec Pragma Debug_Policy
1583 @findex Debug_Policy
1584 @noindent
1585 Syntax:
1586
1587 @smallexample @c ada
1588 pragma Debug_Policy (CHECK | IGNORE);
1589 @end smallexample
1590
1591 @noindent
1592 If the argument is @code{CHECK}, then pragma @code{DEBUG} is enabled.
1593 If the argument is @code{IGNORE}, then pragma @code{DEBUG} is ignored.
1594 This pragma overrides the effect of the @option{-gnata} switch on the
1595 command line.
1596
1597 @node Pragma Detect_Blocking
1598 @unnumberedsec Pragma Detect_Blocking
1599 @findex Detect_Blocking
1600 @noindent
1601 Syntax:
1602
1603 @smallexample @c ada
1604 pragma Detect_Blocking;
1605 @end smallexample
1606
1607 @noindent
1608 This is a configuration pragma that forces the detection of potentially
1609 blocking operations within a protected operation, and to raise Program_Error
1610 if that happens.
1611
1612 @node Pragma Elaboration_Checks
1613 @unnumberedsec Pragma Elaboration_Checks
1614 @cindex Elaboration control
1615 @findex Elaboration_Checks
1616 @noindent
1617 Syntax:
1618
1619 @smallexample @c ada
1620 pragma Elaboration_Checks (Dynamic | Static);
1621 @end smallexample
1622
1623 @noindent
1624 This is a configuration pragma that provides control over the
1625 elaboration model used by the compilation affected by the
1626 pragma.  If the parameter is @code{Dynamic},
1627 then the dynamic elaboration
1628 model described in the Ada Reference Manual is used, as though
1629 the @option{-gnatE} switch had been specified on the command
1630 line.  If the parameter is @code{Static}, then the default GNAT static
1631 model is used.  This configuration pragma overrides the setting
1632 of the command line.  For full details on the elaboration models
1633 used by the GNAT compiler, see @ref{Elaboration Order Handling in GNAT,,,
1634 gnat_ugn, @value{EDITION} User's Guide}.
1635
1636 @node Pragma Eliminate
1637 @unnumberedsec Pragma Eliminate
1638 @cindex Elimination of unused subprograms
1639 @findex Eliminate
1640 @noindent
1641 Syntax:
1642
1643 @smallexample @c ada
1644 pragma Eliminate (
1645     [Unit_Name =>] IDENTIFIER |
1646                    SELECTED_COMPONENT);
1647
1648 pragma Eliminate (
1649     [Unit_Name       =>]  IDENTIFIER |
1650                           SELECTED_COMPONENT,
1651     [Entity          =>]  IDENTIFIER |
1652                           SELECTED_COMPONENT |
1653                           STRING_LITERAL
1654     [,OVERLOADING_RESOLUTION]);
1655
1656 OVERLOADING_RESOLUTION ::= PARAMETER_AND_RESULT_TYPE_PROFILE |
1657                            SOURCE_LOCATION
1658
1659 PARAMETER_AND_RESULT_TYPE_PROFILE ::= PROCEDURE_PROFILE |
1660                                       FUNCTION_PROFILE
1661
1662 PROCEDURE_PROFILE ::= Parameter_Types => PARAMETER_TYPES
1663
1664 FUNCTION_PROFILE ::= [Parameter_Types => PARAMETER_TYPES,]
1665                       Result_Type => result_SUBTYPE_NAME]
1666
1667 PARAMETER_TYPES ::= (SUBTYPE_NAME @{, SUBTYPE_NAME@})
1668 SUBTYPE_NAME    ::= STRING_VALUE
1669
1670 SOURCE_LOCATION ::= Source_Location => SOURCE_TRACE
1671 SOURCE_TRACE    ::= STRING_VALUE
1672
1673 STRING_VALUE ::= STRING_LITERAL @{& STRING_LITERAL@}
1674 @end smallexample
1675
1676 @noindent
1677 This pragma indicates that the given entity is not used outside the
1678 compilation unit it is defined in. The entity must be an explicitly declared
1679 subprogram; this includes  generic subprogram instances and
1680 subprograms declared in generic package instances.
1681
1682 If the entity to be eliminated is a library level subprogram, then
1683 the first form of pragma @code{Eliminate} is used with only a single argument.
1684 In this form, the @code{Unit_Name} argument specifies the name of the
1685 library  level unit to be eliminated.
1686
1687 In all other cases, both @code{Unit_Name} and @code{Entity} arguments
1688 are required. If item is an entity of a library package, then the first
1689 argument specifies the unit name, and the second argument specifies
1690 the particular entity.  If the second argument is in string form, it must
1691 correspond to the internal manner in which GNAT stores entity names (see
1692 compilation unit Namet in the compiler sources for details).
1693
1694 The remaining parameters (OVERLOADING_RESOLUTION) are optionally used
1695 to distinguish between overloaded subprograms. If a pragma does not contain
1696 the OVERLOADING_RESOLUTION parameter(s), it is applied to all the overloaded
1697 subprograms denoted by the first two parameters.
1698
1699 Use PARAMETER_AND_RESULT_TYPE_PROFILE to specify the profile of the subprogram
1700 to be eliminated in a manner similar to that used for the extended
1701 @code{Import} and @code{Export} pragmas, except that the subtype names are
1702 always given as strings. At the moment, this form of distinguishing
1703 overloaded subprograms is implemented only partially, so we do not recommend
1704 using it for practical subprogram elimination.
1705
1706 Note that in case of a parameterless procedure its profile is represented
1707 as @code{Parameter_Types => ("")}
1708
1709 Alternatively, the @code{Source_Location} parameter is used to specify
1710 which overloaded alternative is to be eliminated by pointing to the
1711 location of the DEFINING_PROGRAM_UNIT_NAME of this subprogram in the
1712 source text. The string literal (or concatenation of string literals)
1713 given as SOURCE_TRACE must have the following format:
1714
1715 @smallexample @c ada
1716 SOURCE_TRACE ::= SOURCE_LOCATION@{LBRACKET SOURCE_LOCATION RBRACKET@}
1717
1718 LBRACKET ::= [
1719 RBRACKET ::= ]
1720
1721 SOURCE_LOCATION ::= FILE_NAME:LINE_NUMBER
1722 FILE_NAME       ::= STRING_LITERAL
1723 LINE_NUMBER     ::= DIGIT @{DIGIT@}
1724 @end smallexample
1725
1726 SOURCE_TRACE should be the short name of the source file (with no directory
1727 information), and LINE_NUMBER is supposed to point to the line where the
1728 defining name of the subprogram is located.
1729
1730 For the subprograms that are not a part of generic instantiations, only one
1731 SOURCE_LOCATION is used. If a subprogram is declared in a package
1732 instantiation, SOURCE_TRACE contains two SOURCE_LOCATIONs, the first one is
1733 the location of the (DEFINING_PROGRAM_UNIT_NAME of the) instantiation, and the
1734 second one denotes the declaration of the corresponding subprogram in the
1735 generic package. This approach is recursively used to create SOURCE_LOCATIONs
1736 in case of nested instantiations.
1737
1738 The effect of the pragma is to allow the compiler to eliminate
1739 the code or data associated with the named entity.  Any reference to
1740 an eliminated entity outside the compilation unit it is defined in,
1741 causes a compile time or link time error.
1742
1743 The intention of pragma @code{Eliminate} is to allow a program to be compiled
1744 in a system independent manner, with unused entities eliminated, without
1745 the requirement of modifying the source text.  Normally the required set
1746 of @code{Eliminate} pragmas is constructed automatically using the gnatelim
1747 tool. Elimination of unused entities local to a compilation unit is
1748 automatic, without requiring the use of pragma @code{Eliminate}.
1749
1750 Note that the reason this pragma takes string literals where names might
1751 be expected is that a pragma @code{Eliminate} can appear in a context where the
1752 relevant names are not visible.
1753
1754 Note that any change in the source files that includes removing, splitting of
1755 adding lines may make the set of Eliminate pragmas using SOURCE_LOCATION
1756 parameter illegal.
1757
1758 It is legal to use pragma Eliminate where the referenced entity is a
1759 dispatching operation, but it is not clear what this would mean, since
1760 in general the call does not know which entity is actually being called.
1761 Consequently, a pragma Eliminate for a dispatching operation is ignored.
1762
1763 @node Pragma Export_Exception
1764 @unnumberedsec Pragma Export_Exception
1765 @cindex OpenVMS
1766 @findex Export_Exception
1767 @noindent
1768 Syntax:
1769
1770 @smallexample @c ada
1771 pragma Export_Exception (
1772      [Internal =>] LOCAL_NAME
1773   [, [External =>] EXTERNAL_SYMBOL]
1774   [, [Form     =>] Ada | VMS]
1775   [, [Code     =>] static_integer_EXPRESSION]);
1776
1777 EXTERNAL_SYMBOL ::=
1778   IDENTIFIER
1779 | static_string_EXPRESSION
1780 @end smallexample
1781
1782 @noindent
1783 This pragma is implemented only in the OpenVMS implementation of GNAT@.  It
1784 causes the specified exception to be propagated outside of the Ada program,
1785 so that it can be handled by programs written in other OpenVMS languages.
1786 This pragma establishes an external name for an Ada exception and makes the
1787 name available to the OpenVMS Linker as a global symbol.  For further details
1788 on this pragma, see the
1789 DEC Ada Language Reference Manual, section 13.9a3.2.
1790
1791 @node Pragma Export_Function
1792 @unnumberedsec Pragma Export_Function
1793 @cindex Argument passing mechanisms
1794 @findex Export_Function
1795
1796 @noindent
1797 Syntax:
1798
1799 @smallexample @c ada
1800 pragma Export_Function (
1801      [Internal         =>] LOCAL_NAME
1802   [, [External         =>] EXTERNAL_SYMBOL]
1803   [, [Parameter_Types  =>] PARAMETER_TYPES]
1804   [, [Result_Type      =>] result_SUBTYPE_MARK]
1805   [, [Mechanism        =>] MECHANISM]
1806   [, [Result_Mechanism =>] MECHANISM_NAME]);
1807
1808 EXTERNAL_SYMBOL ::=
1809   IDENTIFIER
1810 | static_string_EXPRESSION
1811 | ""
1812
1813 PARAMETER_TYPES ::=
1814   null
1815 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1816
1817 TYPE_DESIGNATOR ::=
1818   subtype_NAME
1819 | subtype_Name ' Access
1820
1821 MECHANISM ::=
1822   MECHANISM_NAME
1823 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1824
1825 MECHANISM_ASSOCIATION ::=
1826   [formal_parameter_NAME =>] MECHANISM_NAME
1827
1828 MECHANISM_NAME ::=
1829   Value
1830 | Reference
1831 | Descriptor [([Class =>] CLASS_NAME)]
1832 | Short_Descriptor [([Class =>] CLASS_NAME)]
1833
1834 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
1835 @end smallexample
1836
1837 @noindent
1838 Use this pragma to make a function externally callable and optionally
1839 provide information on mechanisms to be used for passing parameter and
1840 result values.  We recommend, for the purposes of improving portability,
1841 this pragma always be used in conjunction with a separate pragma
1842 @code{Export}, which must precede the pragma @code{Export_Function}.
1843 GNAT does not require a separate pragma @code{Export}, but if none is
1844 present, @code{Convention Ada} is assumed, which is usually
1845 not what is wanted, so it is usually appropriate to use this
1846 pragma in conjunction with a @code{Export} or @code{Convention}
1847 pragma that specifies the desired foreign convention.
1848 Pragma @code{Export_Function}
1849 (and @code{Export}, if present) must appear in the same declarative
1850 region as the function to which they apply.
1851
1852 @var{internal_name} must uniquely designate the function to which the
1853 pragma applies.  If more than one function name exists of this name in
1854 the declarative part you must use the @code{Parameter_Types} and
1855 @code{Result_Type} parameters is mandatory to achieve the required
1856 unique designation.  @var{subtype_mark}s in these parameters must
1857 exactly match the subtypes in the corresponding function specification,
1858 using positional notation to match parameters with subtype marks.
1859 The form with an @code{'Access} attribute can be used to match an
1860 anonymous access parameter.
1861
1862 @cindex OpenVMS
1863 @cindex Passing by descriptor
1864 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
1865 The default behavior for Export_Function is to accept either 64bit or
1866 32bit descriptors unless short_descriptor is specified, then only 32bit
1867 descriptors are accepted.
1868
1869 @cindex Suppressing external name
1870 Special treatment is given if the EXTERNAL is an explicit null
1871 string or a static string expressions that evaluates to the null
1872 string. In this case, no external name is generated. This form
1873 still allows the specification of parameter mechanisms.
1874
1875 @node Pragma Export_Object
1876 @unnumberedsec Pragma Export_Object
1877 @findex Export_Object
1878 @noindent
1879 Syntax:
1880
1881 @smallexample @c ada
1882 pragma Export_Object
1883       [Internal =>] LOCAL_NAME
1884    [, [External =>] EXTERNAL_SYMBOL]
1885    [, [Size     =>] EXTERNAL_SYMBOL]
1886
1887 EXTERNAL_SYMBOL ::=
1888   IDENTIFIER
1889 | static_string_EXPRESSION
1890 @end smallexample
1891
1892 @noindent
1893 This pragma designates an object as exported, and apart from the
1894 extended rules for external symbols, is identical in effect to the use of
1895 the normal @code{Export} pragma applied to an object.  You may use a
1896 separate Export pragma (and you probably should from the point of view
1897 of portability), but it is not required.  @var{Size} is syntax checked,
1898 but otherwise ignored by GNAT@.
1899
1900 @node Pragma Export_Procedure
1901 @unnumberedsec Pragma Export_Procedure
1902 @findex Export_Procedure
1903 @noindent
1904 Syntax:
1905
1906 @smallexample @c ada
1907 pragma Export_Procedure (
1908      [Internal        =>] LOCAL_NAME
1909   [, [External        =>] EXTERNAL_SYMBOL]
1910   [, [Parameter_Types =>] PARAMETER_TYPES]
1911   [, [Mechanism       =>] MECHANISM]);
1912
1913 EXTERNAL_SYMBOL ::=
1914   IDENTIFIER
1915 | static_string_EXPRESSION
1916 | ""
1917
1918 PARAMETER_TYPES ::=
1919   null
1920 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1921
1922 TYPE_DESIGNATOR ::=
1923   subtype_NAME
1924 | subtype_Name ' Access
1925
1926 MECHANISM ::=
1927   MECHANISM_NAME
1928 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1929
1930 MECHANISM_ASSOCIATION ::=
1931   [formal_parameter_NAME =>] MECHANISM_NAME
1932
1933 MECHANISM_NAME ::=
1934   Value
1935 | Reference
1936 | Descriptor [([Class =>] CLASS_NAME)]
1937 | Short_Descriptor [([Class =>] CLASS_NAME)]
1938
1939 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
1940 @end smallexample
1941
1942 @noindent
1943 This pragma is identical to @code{Export_Function} except that it
1944 applies to a procedure rather than a function and the parameters
1945 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
1946 GNAT does not require a separate pragma @code{Export}, but if none is
1947 present, @code{Convention Ada} is assumed, which is usually
1948 not what is wanted, so it is usually appropriate to use this
1949 pragma in conjunction with a @code{Export} or @code{Convention}
1950 pragma that specifies the desired foreign convention.
1951
1952 @cindex OpenVMS
1953 @cindex Passing by descriptor
1954 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
1955 The default behavior for Export_Procedure is to accept either 64bit or
1956 32bit descriptors unless short_descriptor is specified, then only 32bit
1957 descriptors are accepted.
1958
1959 @cindex Suppressing external name
1960 Special treatment is given if the EXTERNAL is an explicit null
1961 string or a static string expressions that evaluates to the null
1962 string. In this case, no external name is generated. This form
1963 still allows the specification of parameter mechanisms.
1964
1965 @node Pragma Export_Value
1966 @unnumberedsec Pragma Export_Value
1967 @findex Export_Value
1968 @noindent
1969 Syntax:
1970
1971 @smallexample @c ada
1972 pragma Export_Value (
1973   [Value     =>] static_integer_EXPRESSION,
1974   [Link_Name =>] static_string_EXPRESSION);
1975 @end smallexample
1976
1977 @noindent
1978 This pragma serves to export a static integer value for external use.
1979 The first argument specifies the value to be exported. The Link_Name
1980 argument specifies the symbolic name to be associated with the integer
1981 value. This pragma is useful for defining a named static value in Ada
1982 that can be referenced in assembly language units to be linked with
1983 the application. This pragma is currently supported only for the
1984 AAMP target and is ignored for other targets.
1985
1986 @node Pragma Export_Valued_Procedure
1987 @unnumberedsec Pragma Export_Valued_Procedure
1988 @findex Export_Valued_Procedure
1989 @noindent
1990 Syntax:
1991
1992 @smallexample @c ada
1993 pragma Export_Valued_Procedure (
1994      [Internal        =>] LOCAL_NAME
1995   [, [External        =>] EXTERNAL_SYMBOL]
1996   [, [Parameter_Types =>] PARAMETER_TYPES]
1997   [, [Mechanism       =>] MECHANISM]);
1998
1999 EXTERNAL_SYMBOL ::=
2000   IDENTIFIER
2001 | static_string_EXPRESSION
2002 | ""
2003
2004 PARAMETER_TYPES ::=
2005   null
2006 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2007
2008 TYPE_DESIGNATOR ::=
2009   subtype_NAME
2010 | subtype_Name ' Access
2011
2012 MECHANISM ::=
2013   MECHANISM_NAME
2014 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2015
2016 MECHANISM_ASSOCIATION ::=
2017   [formal_parameter_NAME =>] MECHANISM_NAME
2018
2019 MECHANISM_NAME ::=
2020   Value
2021 | Reference
2022 | Descriptor [([Class =>] CLASS_NAME)]
2023 | Short_Descriptor [([Class =>] CLASS_NAME)]
2024
2025 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
2026 @end smallexample
2027
2028 @noindent
2029 This pragma is identical to @code{Export_Procedure} except that the
2030 first parameter of @var{LOCAL_NAME}, which must be present, must be of
2031 mode @code{OUT}, and externally the subprogram is treated as a function
2032 with this parameter as the result of the function.  GNAT provides for
2033 this capability to allow the use of @code{OUT} and @code{IN OUT}
2034 parameters in interfacing to external functions (which are not permitted
2035 in Ada functions).
2036 GNAT does not require a separate pragma @code{Export}, but if none is
2037 present, @code{Convention Ada} is assumed, which is almost certainly
2038 not what is wanted since the whole point of this pragma is to interface
2039 with foreign language functions, so it is usually appropriate to use this
2040 pragma in conjunction with a @code{Export} or @code{Convention}
2041 pragma that specifies the desired foreign convention.
2042
2043 @cindex OpenVMS
2044 @cindex Passing by descriptor
2045 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2046 The default behavior for Export_Valued_Procedure is to accept either 64bit or
2047 32bit descriptors unless short_descriptor is specified, then only 32bit
2048 descriptors are accepted.
2049
2050 @cindex Suppressing external name
2051 Special treatment is given if the EXTERNAL is an explicit null
2052 string or a static string expressions that evaluates to the null
2053 string. In this case, no external name is generated. This form
2054 still allows the specification of parameter mechanisms.
2055
2056 @node Pragma Extend_System
2057 @unnumberedsec Pragma Extend_System
2058 @cindex @code{system}, extending
2059 @cindex Dec Ada 83
2060 @findex Extend_System
2061 @noindent
2062 Syntax:
2063
2064 @smallexample @c ada
2065 pragma Extend_System ([Name =>] IDENTIFIER);
2066 @end smallexample
2067
2068 @noindent
2069 This pragma is used to provide backwards compatibility with other
2070 implementations that extend the facilities of package @code{System}.  In
2071 GNAT, @code{System} contains only the definitions that are present in
2072 the Ada RM@.  However, other implementations, notably the DEC Ada 83
2073 implementation, provide many extensions to package @code{System}.
2074
2075 For each such implementation accommodated by this pragma, GNAT provides a
2076 package @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83
2077 implementation, which provides the required additional definitions.  You
2078 can use this package in two ways.  You can @code{with} it in the normal
2079 way and access entities either by selection or using a @code{use}
2080 clause.  In this case no special processing is required.
2081
2082 However, if existing code contains references such as
2083 @code{System.@var{xxx}} where @var{xxx} is an entity in the extended
2084 definitions provided in package @code{System}, you may use this pragma
2085 to extend visibility in @code{System} in a non-standard way that
2086 provides greater compatibility with the existing code.  Pragma
2087 @code{Extend_System} is a configuration pragma whose single argument is
2088 the name of the package containing the extended definition
2089 (e.g.@: @code{Aux_DEC} for the DEC Ada case).  A unit compiled under
2090 control of this pragma will be processed using special visibility
2091 processing that looks in package @code{System.Aux_@var{xxx}} where
2092 @code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
2093 package @code{System}, but not found in package @code{System}.
2094
2095 You can use this pragma either to access a predefined @code{System}
2096 extension supplied with the compiler, for example @code{Aux_DEC} or
2097 you can construct your own extension unit following the above
2098 definition.  Note that such a package is a child of @code{System}
2099 and thus is considered part of the implementation.  To compile
2100 it you will have to use the appropriate switch for compiling
2101 system units.  @xref{Top, @value{EDITION} User's Guide, About This
2102 Guide,, gnat_ugn, @value{EDITION} User's Guide}, for details.
2103
2104 @node Pragma External
2105 @unnumberedsec Pragma External
2106 @findex External
2107 @noindent
2108 Syntax:
2109
2110 @smallexample @c ada
2111 pragma External (
2112   [   Convention    =>] convention_IDENTIFIER,
2113   [   Entity        =>] LOCAL_NAME
2114   [, [External_Name =>] static_string_EXPRESSION ]
2115   [, [Link_Name     =>] static_string_EXPRESSION ]);
2116 @end smallexample
2117
2118 @noindent
2119 This pragma is identical in syntax and semantics to pragma
2120 @code{Export} as defined in the Ada Reference Manual.  It is
2121 provided for compatibility with some Ada 83 compilers that
2122 used this pragma for exactly the same purposes as pragma
2123 @code{Export} before the latter was standardized.
2124
2125 @node Pragma External_Name_Casing
2126 @unnumberedsec Pragma External_Name_Casing
2127 @cindex Dec Ada 83 casing compatibility
2128 @cindex External Names, casing
2129 @cindex Casing of External names
2130 @findex External_Name_Casing
2131 @noindent
2132 Syntax:
2133
2134 @smallexample @c ada
2135 pragma External_Name_Casing (
2136   Uppercase | Lowercase
2137   [, Uppercase | Lowercase | As_Is]);
2138 @end smallexample
2139
2140 @noindent
2141 This pragma provides control over the casing of external names associated
2142 with Import and Export pragmas.  There are two cases to consider:
2143
2144 @table @asis
2145 @item Implicit external names
2146 Implicit external names are derived from identifiers.  The most common case
2147 arises when a standard Ada Import or Export pragma is used with only two
2148 arguments, as in:
2149
2150 @smallexample @c ada
2151    pragma Import (C, C_Routine);
2152 @end smallexample
2153
2154 @noindent
2155 Since Ada is a case-insensitive language, the spelling of the identifier in
2156 the Ada source program does not provide any information on the desired
2157 casing of the external name, and so a convention is needed.  In GNAT the
2158 default treatment is that such names are converted to all lower case
2159 letters.  This corresponds to the normal C style in many environments.
2160 The first argument of pragma @code{External_Name_Casing} can be used to
2161 control this treatment.  If @code{Uppercase} is specified, then the name
2162 will be forced to all uppercase letters.  If @code{Lowercase} is specified,
2163 then the normal default of all lower case letters will be used.
2164
2165 This same implicit treatment is also used in the case of extended DEC Ada 83
2166 compatible Import and Export pragmas where an external name is explicitly
2167 specified using an identifier rather than a string.
2168
2169 @item Explicit external names
2170 Explicit external names are given as string literals.  The most common case
2171 arises when a standard Ada Import or Export pragma is used with three
2172 arguments, as in:
2173
2174 @smallexample @c ada
2175 pragma Import (C, C_Routine, "C_routine");
2176 @end smallexample
2177
2178 @noindent
2179 In this case, the string literal normally provides the exact casing required
2180 for the external name.  The second argument of pragma
2181 @code{External_Name_Casing} may be used to modify this behavior.
2182 If @code{Uppercase} is specified, then the name
2183 will be forced to all uppercase letters.  If @code{Lowercase} is specified,
2184 then the name will be forced to all lowercase letters.  A specification of
2185 @code{As_Is} provides the normal default behavior in which the casing is
2186 taken from the string provided.
2187 @end table
2188
2189 @noindent
2190 This pragma may appear anywhere that a pragma is valid.  In particular, it
2191 can be used as a configuration pragma in the @file{gnat.adc} file, in which
2192 case it applies to all subsequent compilations, or it can be used as a program
2193 unit pragma, in which case it only applies to the current unit, or it can
2194 be used more locally to control individual Import/Export pragmas.
2195
2196 It is primarily intended for use with OpenVMS systems, where many
2197 compilers convert all symbols to upper case by default.  For interfacing to
2198 such compilers (e.g.@: the DEC C compiler), it may be convenient to use
2199 the pragma:
2200
2201 @smallexample @c ada
2202 pragma External_Name_Casing (Uppercase, Uppercase);
2203 @end smallexample
2204
2205 @noindent
2206 to enforce the upper casing of all external symbols.
2207
2208 @node Pragma Fast_Math
2209 @unnumberedsec Pragma Fast_Math
2210 @findex Fast_Math
2211 @noindent
2212 Syntax:
2213
2214 @smallexample @c ada
2215 pragma Fast_Math;
2216 @end smallexample
2217
2218 @noindent
2219 This is a configuration pragma which activates a mode in which speed is
2220 considered more important for floating-point operations than absolutely
2221 accurate adherence to the requirements of the standard. Currently the
2222 following operations are affected:
2223
2224 @table @asis
2225 @item Complex Multiplication
2226 The normal simple formula for complex multiplication can result in intermediate
2227 overflows for numbers near the end of the range. The Ada standard requires that
2228 this situation be detected and corrected by scaling, but in Fast_Math mode such
2229 cases will simply result in overflow. Note that to take advantage of this you
2230 must instantiate your own version of @code{Ada.Numerics.Generic_Complex_Types}
2231 under control of the pragma, rather than use the preinstantiated versions.
2232 @end table
2233
2234 @node Pragma Favor_Top_Level
2235 @unnumberedsec Pragma Favor_Top_Level
2236 @findex Favor_Top_Level
2237 @noindent
2238 Syntax:
2239
2240 @smallexample @c ada
2241 pragma Favor_Top_Level (type_NAME);
2242 @end smallexample
2243
2244 @noindent
2245 The named type must be an access-to-subprogram type. This pragma is an
2246 efficiency hint to the compiler, regarding the use of 'Access or
2247 'Unrestricted_Access on nested (non-library-level) subprograms. The
2248 pragma means that nested subprograms are not used with this type, or
2249 are rare, so that the generated code should be efficient in the
2250 top-level case. When this pragma is used, dynamically generated
2251 trampolines may be used on some targets for nested subprograms.
2252 See also the No_Implicit_Dynamic_Code restriction.
2253
2254 @node Pragma Finalize_Storage_Only
2255 @unnumberedsec Pragma Finalize_Storage_Only
2256 @findex Finalize_Storage_Only
2257 @noindent
2258 Syntax:
2259
2260 @smallexample @c ada
2261 pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
2262 @end smallexample
2263
2264 @noindent
2265 This pragma allows the compiler not to emit a Finalize call for objects
2266 defined at the library level.  This is mostly useful for types where
2267 finalization is only used to deal with storage reclamation since in most
2268 environments it is not necessary to reclaim memory just before terminating
2269 execution, hence the name.
2270
2271 @node Pragma Float_Representation
2272 @unnumberedsec Pragma Float_Representation
2273 @cindex OpenVMS
2274 @findex Float_Representation
2275 @noindent
2276 Syntax:
2277
2278 @smallexample @c ada
2279 pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
2280
2281 FLOAT_REP ::= VAX_Float | IEEE_Float
2282 @end smallexample
2283
2284 @noindent
2285 In the one argument form, this pragma is a configuration pragma which
2286 allows control over the internal representation chosen for the predefined
2287 floating point types declared in the packages @code{Standard} and
2288 @code{System}. On all systems other than OpenVMS, the argument must
2289 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2290 argument may be @code{VAX_Float} to specify the use of the VAX float
2291 format for the floating-point types in Standard. This requires that
2292 the standard runtime libraries be recompiled.  @xref{The GNAT Run-Time
2293 Library Builder gnatlbr,,, gnat_ugn, @value{EDITION} User's Guide
2294 OpenVMS}, for a description of the @code{GNAT LIBRARY} command.
2295
2296 The two argument form specifies the representation to be used for
2297 the specified floating-point type. On all systems other than OpenVMS,
2298 the argument must
2299 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2300 argument may be @code{VAX_Float} to specify the use of the VAX float
2301 format, as follows:
2302
2303 @itemize @bullet
2304 @item
2305 For digits values up to 6, F float format will be used.
2306 @item
2307 For digits values from 7 to 9, G float format will be used.
2308 @item
2309 For digits values from 10 to 15, F float format will be used.
2310 @item
2311 Digits values above 15 are not allowed.
2312 @end itemize
2313
2314 @node Pragma Ident
2315 @unnumberedsec Pragma Ident
2316 @findex Ident
2317 @noindent
2318 Syntax:
2319
2320 @smallexample @c ada
2321 pragma Ident (static_string_EXPRESSION);
2322 @end smallexample
2323
2324 @noindent
2325 This pragma provides a string identification in the generated object file,
2326 if the system supports the concept of this kind of identification string.
2327 This pragma is allowed only in the outermost declarative part or
2328 declarative items of a compilation unit. If more than one @code{Ident}
2329 pragma is given, only the last one processed is effective.
2330 @cindex OpenVMS
2331 On OpenVMS systems, the effect of the pragma is identical to the effect of
2332 the DEC Ada 83 pragma of the same name. Note that in DEC Ada 83, the
2333 maximum allowed length is 31 characters, so if it is important to
2334 maintain compatibility with this compiler, you should obey this length
2335 limit.
2336
2337 @node Pragma Implemented_By_Entry
2338 @unnumberedsec Pragma Implemented_By_Entry
2339 @findex Implemented_By_Entry
2340 @noindent
2341 Syntax:
2342
2343 @smallexample @c ada
2344 pragma Implemented_By_Entry (LOCAL_NAME);
2345 @end smallexample
2346
2347 @noindent
2348 This is a representation pragma which applies to protected, synchronized and
2349 task interface primitives. If the pragma is applied to primitive operation Op
2350 of interface Iface, it is illegal to override Op in a type that implements
2351 Iface, with anything other than an entry.
2352
2353 @smallexample @c ada
2354 type Iface is protected interface;
2355 procedure Do_Something (Object : in out Iface) is abstract;
2356 pragma Implemented_By_Entry (Do_Something);
2357
2358 protected type P is new Iface with
2359    procedure Do_Something;  --  Illegal
2360 end P;
2361
2362 task type T is new Iface with
2363    entry Do_Something;      --  Legal
2364 end T;
2365 @end smallexample
2366
2367 @noindent
2368 NOTE: The pragma is still in its design stage by the Ada Rapporteur Group. It
2369 is intended to be used in conjunction with dispatching requeue statements as
2370 described in AI05-0030. Should the ARG decide on an official name and syntax,
2371 this pragma will become language-defined rather than GNAT-specific.
2372
2373 @node Pragma Implicit_Packing
2374 @unnumberedsec Pragma Implicit_Packing
2375 @findex Implicit_Packing
2376 @noindent
2377 Syntax:
2378
2379 @smallexample @c ada
2380 pragma Implicit_Packing;
2381 @end smallexample
2382
2383 @noindent
2384 This is a configuration pragma that requests implicit packing for packed
2385 arrays for which a size clause is given but no explicit pragma Pack or
2386 specification of Component_Size is present. Consider this example:
2387
2388 @smallexample @c ada
2389 type R is array (0 .. 7) of Boolean;
2390 for R'Size use 8;
2391 @end smallexample
2392
2393 @noindent
2394 In accordance with the recommendation in the RM (RM 13.3(53)), a Size clause
2395 does not change the layout of a composite object. So the Size clause in the
2396 above example is normally rejected, since the default layout of the array uses
2397 8-bit components, and thus the array requires a minimum of 64 bits.
2398
2399 If this declaration is compiled in a region of code covered by an occurrence
2400 of the configuration pragma Implicit_Packing, then the Size clause in this
2401 and similar examples will cause implicit packing and thus be accepted. For
2402 this implicit packing to occur, the type in question must be an array of small
2403 components whose size is known at compile time, and the Size clause must
2404 specify the exact size that corresponds to the length of the array multiplied
2405 by the size in bits of the component type.
2406 @cindex Array packing
2407
2408 @node Pragma Import_Exception
2409 @unnumberedsec Pragma Import_Exception
2410 @cindex OpenVMS
2411 @findex Import_Exception
2412 @noindent
2413 Syntax:
2414
2415 @smallexample @c ada
2416 pragma Import_Exception (
2417      [Internal =>] LOCAL_NAME
2418   [, [External =>] EXTERNAL_SYMBOL]
2419   [, [Form     =>] Ada | VMS]
2420   [, [Code     =>] static_integer_EXPRESSION]);
2421
2422 EXTERNAL_SYMBOL ::=
2423   IDENTIFIER
2424 | static_string_EXPRESSION
2425 @end smallexample
2426
2427 @noindent
2428 This pragma is implemented only in the OpenVMS implementation of GNAT@.
2429 It allows OpenVMS conditions (for example, from OpenVMS system services or
2430 other OpenVMS languages) to be propagated to Ada programs as Ada exceptions.
2431 The pragma specifies that the exception associated with an exception
2432 declaration in an Ada program be defined externally (in non-Ada code).
2433 For further details on this pragma, see the
2434 DEC Ada Language Reference Manual, section 13.9a.3.1.
2435
2436 @node Pragma Import_Function
2437 @unnumberedsec Pragma Import_Function
2438 @findex Import_Function
2439 @noindent
2440 Syntax:
2441
2442 @smallexample @c ada
2443 pragma Import_Function (
2444      [Internal                 =>] LOCAL_NAME,
2445   [, [External                 =>] EXTERNAL_SYMBOL]
2446   [, [Parameter_Types          =>] PARAMETER_TYPES]
2447   [, [Result_Type              =>] SUBTYPE_MARK]
2448   [, [Mechanism                =>] MECHANISM]
2449   [, [Result_Mechanism         =>] MECHANISM_NAME]
2450   [, [First_Optional_Parameter =>] IDENTIFIER]);
2451
2452 EXTERNAL_SYMBOL ::=
2453   IDENTIFIER
2454 | static_string_EXPRESSION
2455
2456 PARAMETER_TYPES ::=
2457   null
2458 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2459
2460 TYPE_DESIGNATOR ::=
2461   subtype_NAME
2462 | subtype_Name ' Access
2463
2464 MECHANISM ::=
2465   MECHANISM_NAME
2466 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2467
2468 MECHANISM_ASSOCIATION ::=
2469   [formal_parameter_NAME =>] MECHANISM_NAME
2470
2471 MECHANISM_NAME ::=
2472   Value
2473 | Reference
2474 | Descriptor [([Class =>] CLASS_NAME)]
2475 | Short_Descriptor [([Class =>] CLASS_NAME)]
2476
2477 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2478 @end smallexample
2479
2480 @noindent
2481 This pragma is used in conjunction with a pragma @code{Import} to
2482 specify additional information for an imported function.  The pragma
2483 @code{Import} (or equivalent pragma @code{Interface}) must precede the
2484 @code{Import_Function} pragma and both must appear in the same
2485 declarative part as the function specification.
2486
2487 The @var{Internal} argument must uniquely designate
2488 the function to which the
2489 pragma applies.  If more than one function name exists of this name in
2490 the declarative part you must use the @code{Parameter_Types} and
2491 @var{Result_Type} parameters to achieve the required unique
2492 designation.  Subtype marks in these parameters must exactly match the
2493 subtypes in the corresponding function specification, using positional
2494 notation to match parameters with subtype marks.
2495 The form with an @code{'Access} attribute can be used to match an
2496 anonymous access parameter.
2497
2498 You may optionally use the @var{Mechanism} and @var{Result_Mechanism}
2499 parameters to specify passing mechanisms for the
2500 parameters and result.  If you specify a single mechanism name, it
2501 applies to all parameters.  Otherwise you may specify a mechanism on a
2502 parameter by parameter basis using either positional or named
2503 notation.  If the mechanism is not specified, the default mechanism
2504 is used.
2505
2506 @cindex OpenVMS
2507 @cindex Passing by descriptor
2508 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2509 The default behavior for Import_Function is to pass a 64bit descriptor
2510 unless short_descriptor is specified, then a 32bit descriptor is passed.
2511
2512 @code{First_Optional_Parameter} applies only to OpenVMS ports of GNAT@.
2513 It specifies that the designated parameter and all following parameters
2514 are optional, meaning that they are not passed at the generated code
2515 level (this is distinct from the notion of optional parameters in Ada
2516 where the parameters are passed anyway with the designated optional
2517 parameters).  All optional parameters must be of mode @code{IN} and have
2518 default parameter values that are either known at compile time
2519 expressions, or uses of the @code{'Null_Parameter} attribute.
2520
2521 @node Pragma Import_Object
2522 @unnumberedsec Pragma Import_Object
2523 @findex Import_Object
2524 @noindent
2525 Syntax:
2526
2527 @smallexample @c ada
2528 pragma Import_Object
2529      [Internal =>] LOCAL_NAME
2530   [, [External =>] EXTERNAL_SYMBOL]
2531   [, [Size     =>] EXTERNAL_SYMBOL]);
2532
2533 EXTERNAL_SYMBOL ::=
2534   IDENTIFIER
2535 | static_string_EXPRESSION
2536 @end smallexample
2537
2538 @noindent
2539 This pragma designates an object as imported, and apart from the
2540 extended rules for external symbols, is identical in effect to the use of
2541 the normal @code{Import} pragma applied to an object.  Unlike the
2542 subprogram case, you need not use a separate @code{Import} pragma,
2543 although you may do so (and probably should do so from a portability
2544 point of view).  @var{size} is syntax checked, but otherwise ignored by
2545 GNAT@.
2546
2547 @node Pragma Import_Procedure
2548 @unnumberedsec Pragma Import_Procedure
2549 @findex Import_Procedure
2550 @noindent
2551 Syntax:
2552
2553 @smallexample @c ada
2554 pragma Import_Procedure (
2555      [Internal                 =>] LOCAL_NAME
2556   [, [External                 =>] EXTERNAL_SYMBOL]
2557   [, [Parameter_Types          =>] PARAMETER_TYPES]
2558   [, [Mechanism                =>] MECHANISM]
2559   [, [First_Optional_Parameter =>] IDENTIFIER]);
2560
2561 EXTERNAL_SYMBOL ::=
2562   IDENTIFIER
2563 | static_string_EXPRESSION
2564
2565 PARAMETER_TYPES ::=
2566   null
2567 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2568
2569 TYPE_DESIGNATOR ::=
2570   subtype_NAME
2571 | subtype_Name ' Access
2572
2573 MECHANISM ::=
2574   MECHANISM_NAME
2575 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2576
2577 MECHANISM_ASSOCIATION ::=
2578   [formal_parameter_NAME =>] MECHANISM_NAME
2579
2580 MECHANISM_NAME ::=
2581   Value
2582 | Reference
2583 | Descriptor [([Class =>] CLASS_NAME)]
2584 | Short_Descriptor [([Class =>] CLASS_NAME)]
2585
2586 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2587 @end smallexample
2588
2589 @noindent
2590 This pragma is identical to @code{Import_Function} except that it
2591 applies to a procedure rather than a function and the parameters
2592 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2593
2594 @node Pragma Import_Valued_Procedure
2595 @unnumberedsec Pragma Import_Valued_Procedure
2596 @findex Import_Valued_Procedure
2597 @noindent
2598 Syntax:
2599
2600 @smallexample @c ada
2601 pragma Import_Valued_Procedure (
2602      [Internal                 =>] LOCAL_NAME
2603   [, [External                 =>] EXTERNAL_SYMBOL]
2604   [, [Parameter_Types          =>] PARAMETER_TYPES]
2605   [, [Mechanism                =>] MECHANISM]
2606   [, [First_Optional_Parameter =>] IDENTIFIER]);
2607
2608 EXTERNAL_SYMBOL ::=
2609   IDENTIFIER
2610 | static_string_EXPRESSION
2611
2612 PARAMETER_TYPES ::=
2613   null
2614 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2615
2616 TYPE_DESIGNATOR ::=
2617   subtype_NAME
2618 | subtype_Name ' Access
2619
2620 MECHANISM ::=
2621   MECHANISM_NAME
2622 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2623
2624 MECHANISM_ASSOCIATION ::=
2625   [formal_parameter_NAME =>] MECHANISM_NAME
2626
2627 MECHANISM_NAME ::=
2628   Value
2629 | Reference
2630 | Descriptor [([Class =>] CLASS_NAME)]
2631 | Short_Descriptor [([Class =>] CLASS_NAME)]
2632
2633 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2634 @end smallexample
2635
2636 @noindent
2637 This pragma is identical to @code{Import_Procedure} except that the
2638 first parameter of @var{LOCAL_NAME}, which must be present, must be of
2639 mode @code{OUT}, and externally the subprogram is treated as a function
2640 with this parameter as the result of the function.  The purpose of this
2641 capability is to allow the use of @code{OUT} and @code{IN OUT}
2642 parameters in interfacing to external functions (which are not permitted
2643 in Ada functions).  You may optionally use the @code{Mechanism}
2644 parameters to specify passing mechanisms for the parameters.
2645 If you specify a single mechanism name, it applies to all parameters.
2646 Otherwise you may specify a mechanism on a parameter by parameter
2647 basis using either positional or named notation.  If the mechanism is not
2648 specified, the default mechanism is used.
2649
2650 Note that it is important to use this pragma in conjunction with a separate
2651 pragma Import that specifies the desired convention, since otherwise the
2652 default convention is Ada, which is almost certainly not what is required.
2653
2654 @node Pragma Initialize_Scalars
2655 @unnumberedsec Pragma Initialize_Scalars
2656 @findex Initialize_Scalars
2657 @cindex debugging with Initialize_Scalars
2658 @noindent
2659 Syntax:
2660
2661 @smallexample @c ada
2662 pragma Initialize_Scalars;
2663 @end smallexample
2664
2665 @noindent
2666 This pragma is similar to @code{Normalize_Scalars} conceptually but has
2667 two important differences.  First, there is no requirement for the pragma
2668 to be used uniformly in all units of a partition, in particular, it is fine
2669 to use this just for some or all of the application units of a partition,
2670 without needing to recompile the run-time library.
2671
2672 In the case where some units are compiled with the pragma, and some without,
2673 then a declaration of a variable where the type is defined in package
2674 Standard or is locally declared will always be subject to initialization,
2675 as will any declaration of a scalar variable.  For composite variables,
2676 whether the variable is initialized may also depend on whether the package
2677 in which the type of the variable is declared is compiled with the pragma.
2678
2679 The other important difference is that you can control the value used
2680 for initializing scalar objects.  At bind time, you can select several
2681 options for initialization. You can
2682 initialize with invalid values (similar to Normalize_Scalars, though for
2683 Initialize_Scalars it is not always possible to determine the invalid
2684 values in complex cases like signed component fields with non-standard
2685 sizes). You can also initialize with high or
2686 low values, or with a specified bit pattern.  See the users guide for binder
2687 options for specifying these cases.
2688
2689 This means that you can compile a program, and then without having to
2690 recompile the program, you can run it with different values being used
2691 for initializing otherwise uninitialized values, to test if your program
2692 behavior depends on the choice.  Of course the behavior should not change,
2693 and if it does, then most likely you have an erroneous reference to an
2694 uninitialized value.
2695
2696 It is even possible to change the value at execution time eliminating even
2697 the need to rebind with a different switch using an environment variable.
2698 See the GNAT users guide for details.
2699
2700 Note that pragma @code{Initialize_Scalars} is particularly useful in
2701 conjunction with the enhanced validity checking that is now provided
2702 in GNAT, which checks for invalid values under more conditions.
2703 Using this feature (see description of the @option{-gnatV} flag in the
2704 users guide) in conjunction with pragma @code{Initialize_Scalars}
2705 provides a powerful new tool to assist in the detection of problems
2706 caused by uninitialized variables.
2707
2708 Note: the use of @code{Initialize_Scalars} has a fairly extensive
2709 effect on the generated code. This may cause your code to be
2710 substantially larger. It may also cause an increase in the amount
2711 of stack required, so it is probably a good idea to turn on stack
2712 checking (see description of stack checking in the GNAT users guide)
2713 when using this pragma.
2714
2715 @node Pragma Inline_Always
2716 @unnumberedsec Pragma Inline_Always
2717 @findex Inline_Always
2718 @noindent
2719 Syntax:
2720
2721 @smallexample @c ada
2722 pragma Inline_Always (NAME [, NAME]);
2723 @end smallexample
2724
2725 @noindent
2726 Similar to pragma @code{Inline} except that inlining is not subject to
2727 the use of option @option{-gnatn} and the inlining happens regardless of
2728 whether this option is used.
2729
2730 @node Pragma Inline_Generic
2731 @unnumberedsec Pragma Inline_Generic
2732 @findex Inline_Generic
2733 @noindent
2734 Syntax:
2735
2736 @smallexample @c ada
2737 pragma Inline_Generic (generic_package_NAME);
2738 @end smallexample
2739
2740 @noindent
2741 This is implemented for compatibility with DEC Ada 83 and is recognized,
2742 but otherwise ignored, by GNAT@.  All generic instantiations are inlined
2743 by default when using GNAT@.
2744
2745 @node Pragma Interface
2746 @unnumberedsec Pragma Interface
2747 @findex Interface
2748 @noindent
2749 Syntax:
2750
2751 @smallexample @c ada
2752 pragma Interface (
2753      [Convention    =>] convention_identifier,
2754      [Entity        =>] local_NAME
2755   [, [External_Name =>] static_string_expression]
2756   [, [Link_Name     =>] static_string_expression]);
2757 @end smallexample
2758
2759 @noindent
2760 This pragma is identical in syntax and semantics to
2761 the standard Ada pragma @code{Import}.  It is provided for compatibility
2762 with Ada 83.  The definition is upwards compatible both with pragma
2763 @code{Interface} as defined in the Ada 83 Reference Manual, and also
2764 with some extended implementations of this pragma in certain Ada 83
2765 implementations.
2766
2767 @node Pragma Interface_Name
2768 @unnumberedsec Pragma Interface_Name
2769 @findex Interface_Name
2770 @noindent
2771 Syntax:
2772
2773 @smallexample @c ada
2774 pragma Interface_Name (
2775      [Entity        =>] LOCAL_NAME
2776   [, [External_Name =>] static_string_EXPRESSION]
2777   [, [Link_Name     =>] static_string_EXPRESSION]);
2778 @end smallexample
2779
2780 @noindent
2781 This pragma provides an alternative way of specifying the interface name
2782 for an interfaced subprogram, and is provided for compatibility with Ada
2783 83 compilers that use the pragma for this purpose.  You must provide at
2784 least one of @var{External_Name} or @var{Link_Name}.
2785
2786 @node Pragma Interrupt_Handler
2787 @unnumberedsec Pragma Interrupt_Handler
2788 @findex Interrupt_Handler
2789 @noindent
2790 Syntax:
2791
2792 @smallexample @c ada
2793 pragma Interrupt_Handler (procedure_LOCAL_NAME);
2794 @end smallexample
2795
2796 @noindent
2797 This program unit pragma is supported for parameterless protected procedures
2798 as described in Annex C of the Ada Reference Manual. On the AAMP target
2799 the pragma can also be specified for nonprotected parameterless procedures
2800 that are declared at the library level (which includes procedures
2801 declared at the top level of a library package). In the case of AAMP,
2802 when this pragma is applied to a nonprotected procedure, the instruction
2803 @code{IERET} is generated for returns from the procedure, enabling
2804 maskable interrupts, in place of the normal return instruction.
2805
2806 @node Pragma Interrupt_State
2807 @unnumberedsec Pragma Interrupt_State
2808 @findex Interrupt_State
2809 @noindent
2810 Syntax:
2811
2812 @smallexample @c ada
2813 pragma Interrupt_State (Name => value, State => SYSTEM | RUNTIME | USER);
2814 @end smallexample
2815
2816 @noindent
2817 Normally certain interrupts are reserved to the implementation.  Any attempt
2818 to attach an interrupt causes Program_Error to be raised, as described in
2819 RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
2820 many systems for an @kbd{Ctrl-C} interrupt.  Normally this interrupt is
2821 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
2822 interrupt execution.  Additionally, signals such as @code{SIGSEGV},
2823 @code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
2824 Ada exceptions, or used to implement run-time functions such as the
2825 @code{abort} statement and stack overflow checking.
2826
2827 Pragma @code{Interrupt_State} provides a general mechanism for overriding
2828 such uses of interrupts.  It subsumes the functionality of pragma
2829 @code{Unreserve_All_Interrupts}.  Pragma @code{Interrupt_State} is not
2830 available on OS/2, Windows or VMS.  On all other platforms than VxWorks,
2831 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
2832 and may be used to mark interrupts required by the board support package
2833 as reserved.
2834
2835 Interrupts can be in one of three states:
2836 @itemize @bullet
2837 @item System
2838
2839 The interrupt is reserved (no Ada handler can be installed), and the
2840 Ada run-time may not install a handler. As a result you are guaranteed
2841 standard system default action if this interrupt is raised.
2842
2843 @item Runtime
2844
2845 The interrupt is reserved (no Ada handler can be installed). The run time
2846 is allowed to install a handler for internal control purposes, but is
2847 not required to do so.
2848
2849 @item User
2850
2851 The interrupt is unreserved.  The user may install a handler to provide
2852 some other action.
2853 @end itemize
2854
2855 @noindent
2856 These states are the allowed values of the @code{State} parameter of the
2857 pragma.  The @code{Name} parameter is a value of the type
2858 @code{Ada.Interrupts.Interrupt_ID}.  Typically, it is a name declared in
2859 @code{Ada.Interrupts.Names}.
2860
2861 This is a configuration pragma, and the binder will check that there
2862 are no inconsistencies between different units in a partition in how a
2863 given interrupt is specified. It may appear anywhere a pragma is legal.
2864
2865 The effect is to move the interrupt to the specified state.
2866
2867 By declaring interrupts to be SYSTEM, you guarantee the standard system
2868 action, such as a core dump.
2869
2870 By declaring interrupts to be USER, you guarantee that you can install
2871 a handler.
2872
2873 Note that certain signals on many operating systems cannot be caught and
2874 handled by applications.  In such cases, the pragma is ignored.  See the
2875 operating system documentation, or the value of the array @code{Reserved}
2876 declared in the spec of package @code{System.OS_Interface}.
2877
2878 Overriding the default state of signals used by the Ada runtime may interfere
2879 with an application's runtime behavior in the cases of the synchronous signals,
2880 and in the case of the signal used to implement the @code{abort} statement.
2881
2882 @node Pragma Keep_Names
2883 @unnumberedsec Pragma Keep_Names
2884 @findex Keep_Names
2885 @noindent
2886 Syntax:
2887
2888 @smallexample @c ada
2889 pragma Keep_Names ([On =>] enumeration_first_subtype_LOCAL_NAME);
2890 @end smallexample
2891
2892 @noindent
2893 The @var{LOCAL_NAME} argument
2894 must refer to an enumeration first subtype
2895 in the current declarative part. The effect is to retain the enumeration
2896 literal names for use by @code{Image} and @code{Value} even if a global
2897 @code{Discard_Names} pragma applies. This is useful when you want to
2898 generally suppress enumeration literal names and for example you therefore
2899 use a @code{Discard_Names} pragma in the @file{gnat.adc} file, but you
2900 want to retain the names for specific enumeration types.
2901
2902 @node Pragma License
2903 @unnumberedsec Pragma License
2904 @findex License
2905 @cindex License checking
2906 @noindent
2907 Syntax:
2908
2909 @smallexample @c ada
2910 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
2911 @end smallexample
2912
2913 @noindent
2914 This pragma is provided to allow automated checking for appropriate license
2915 conditions with respect to the standard and modified GPL@.  A pragma
2916 @code{License}, which is a configuration pragma that typically appears at
2917 the start of a source file or in a separate @file{gnat.adc} file, specifies
2918 the licensing conditions of a unit as follows:
2919
2920 @itemize @bullet
2921 @item Unrestricted
2922 This is used for a unit that can be freely used with no license restrictions.
2923 Examples of such units are public domain units, and units from the Ada
2924 Reference Manual.
2925
2926 @item GPL
2927 This is used for a unit that is licensed under the unmodified GPL, and which
2928 therefore cannot be @code{with}'ed by a restricted unit.
2929
2930 @item Modified_GPL
2931 This is used for a unit licensed under the GNAT modified GPL that includes
2932 a special exception paragraph that specifically permits the inclusion of
2933 the unit in programs without requiring the entire program to be released
2934 under the GPL@.
2935
2936 @item Restricted
2937 This is used for a unit that is restricted in that it is not permitted to
2938 depend on units that are licensed under the GPL@.  Typical examples are
2939 proprietary code that is to be released under more restrictive license
2940 conditions.  Note that restricted units are permitted to @code{with} units
2941 which are licensed under the modified GPL (this is the whole point of the
2942 modified GPL).
2943
2944 @end itemize
2945
2946 @noindent
2947 Normally a unit with no @code{License} pragma is considered to have an
2948 unknown license, and no checking is done.  However, standard GNAT headers
2949 are recognized, and license information is derived from them as follows.
2950
2951 @itemize @bullet
2952
2953 A GNAT license header starts with a line containing 78 hyphens.  The following
2954 comment text is searched for the appearance of any of the following strings.
2955
2956 If the string ``GNU General Public License'' is found, then the unit is assumed
2957 to have GPL license, unless the string ``As a special exception'' follows, in
2958 which case the license is assumed to be modified GPL@.
2959
2960 If one of the strings
2961 ``This specification is adapted from the Ada Semantic Interface'' or
2962 ``This specification is derived from the Ada Reference Manual'' is found
2963 then the unit is assumed to be unrestricted.
2964 @end itemize
2965
2966 @noindent
2967 These default actions means that a program with a restricted license pragma
2968 will automatically get warnings if a GPL unit is inappropriately
2969 @code{with}'ed.  For example, the program:
2970
2971 @smallexample @c ada
2972 with Sem_Ch3;
2973 with GNAT.Sockets;
2974 procedure Secret_Stuff is
2975   @dots{}
2976 end Secret_Stuff
2977 @end smallexample
2978
2979 @noindent
2980 if compiled with pragma @code{License} (@code{Restricted}) in a
2981 @file{gnat.adc} file will generate the warning:
2982
2983 @smallexample
2984 1.  with Sem_Ch3;
2985         |
2986    >>> license of withed unit "Sem_Ch3" is incompatible
2987
2988 2.  with GNAT.Sockets;
2989 3.  procedure Secret_Stuff is
2990 @end smallexample
2991
2992 @noindent
2993 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
2994 compiler and is licensed under the
2995 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
2996 run time, and is therefore licensed under the modified GPL@.
2997
2998 @node Pragma Link_With
2999 @unnumberedsec Pragma Link_With
3000 @findex Link_With
3001 @noindent
3002 Syntax:
3003
3004 @smallexample @c ada
3005 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
3006 @end smallexample
3007
3008 @noindent
3009 This pragma is provided for compatibility with certain Ada 83 compilers.
3010 It has exactly the same effect as pragma @code{Linker_Options} except
3011 that spaces occurring within one of the string expressions are treated
3012 as separators. For example, in the following case:
3013
3014 @smallexample @c ada
3015 pragma Link_With ("-labc -ldef");
3016 @end smallexample
3017
3018 @noindent
3019 results in passing the strings @code{-labc} and @code{-ldef} as two
3020 separate arguments to the linker. In addition pragma Link_With allows
3021 multiple arguments, with the same effect as successive pragmas.
3022
3023 @node Pragma Linker_Alias
3024 @unnumberedsec Pragma Linker_Alias
3025 @findex Linker_Alias
3026 @noindent
3027 Syntax:
3028
3029 @smallexample @c ada
3030 pragma Linker_Alias (
3031   [Entity =>] LOCAL_NAME,
3032   [Target =>] static_string_EXPRESSION);
3033 @end smallexample
3034
3035 @noindent
3036 @var{LOCAL_NAME} must refer to an object that is declared at the library
3037 level. This pragma establishes the given entity as a linker alias for the
3038 given target. It is equivalent to @code{__attribute__((alias))} in GNU C
3039 and causes @var{LOCAL_NAME} to be emitted as an alias for the symbol
3040 @var{static_string_EXPRESSION} in the object file, that is to say no space
3041 is reserved for @var{LOCAL_NAME} by the assembler and it will be resolved
3042 to the same address as @var{static_string_EXPRESSION} by the linker.
3043
3044 The actual linker name for the target must be used (e.g.@: the fully
3045 encoded name with qualification in Ada, or the mangled name in C++),
3046 or it must be declared using the C convention with @code{pragma Import}
3047 or @code{pragma Export}.
3048
3049 Not all target machines support this pragma. On some of them it is accepted
3050 only if @code{pragma Weak_External} has been applied to @var{LOCAL_NAME}.
3051
3052 @smallexample @c ada
3053 --  Example of the use of pragma Linker_Alias
3054
3055 package p is
3056   i : Integer := 1;
3057   pragma Export (C, i);
3058
3059   new_name_for_i : Integer;
3060   pragma Linker_Alias (new_name_for_i, "i");
3061 end p;
3062 @end smallexample
3063
3064 @node Pragma Linker_Constructor
3065 @unnumberedsec Pragma Linker_Constructor
3066 @findex Linker_Constructor
3067 @noindent
3068 Syntax:
3069
3070 @smallexample @c ada
3071 pragma Linker_Constructor (procedure_LOCAL_NAME);
3072 @end smallexample
3073
3074 @noindent
3075 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
3076 is declared at the library level. A procedure to which this pragma is
3077 applied will be treated as an initialization routine by the linker.
3078 It is equivalent to @code{__attribute__((constructor))} in GNU C and
3079 causes @var{procedure_LOCAL_NAME} to be invoked before the entry point
3080 of the executable is called (or immediately after the shared library is
3081 loaded if the procedure is linked in a shared library), in particular
3082 before the Ada run-time environment is set up.
3083
3084 Because of these specific contexts, the set of operations such a procedure
3085 can perform is very limited and the type of objects it can manipulate is
3086 essentially restricted to the elementary types. In particular, it must only
3087 contain code to which pragma Restrictions (No_Elaboration_Code) applies.
3088
3089 This pragma is used by GNAT to implement auto-initialization of shared Stand
3090 Alone Libraries, which provides a related capability without the restrictions
3091 listed above. Where possible, the use of Stand Alone Libraries is preferable
3092 to the use of this pragma.
3093
3094 @node Pragma Linker_Destructor
3095 @unnumberedsec Pragma Linker_Destructor
3096 @findex Linker_Destructor
3097 @noindent
3098 Syntax:
3099
3100 @smallexample @c ada
3101 pragma Linker_Destructor (procedure_LOCAL_NAME);
3102 @end smallexample
3103
3104 @noindent
3105 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
3106 is declared at the library level. A procedure to which this pragma is
3107 applied will be treated as a finalization routine by the linker.
3108 It is equivalent to @code{__attribute__((destructor))} in GNU C and
3109 causes @var{procedure_LOCAL_NAME} to be invoked after the entry point
3110 of the executable has exited (or immediately before the shared library
3111 is unloaded if the procedure is linked in a shared library), in particular
3112 after the Ada run-time environment is shut down.
3113
3114 See @code{pragma Linker_Constructor} for the set of restrictions that apply
3115 because of these specific contexts.
3116
3117 @node Pragma Linker_Section
3118 @unnumberedsec Pragma Linker_Section
3119 @findex Linker_Section
3120 @noindent
3121 Syntax:
3122
3123 @smallexample @c ada
3124 pragma Linker_Section (
3125   [Entity  =>] LOCAL_NAME,
3126   [Section =>] static_string_EXPRESSION);
3127 @end smallexample
3128
3129 @noindent
3130 @var{LOCAL_NAME} must refer to an object that is declared at the library
3131 level. This pragma specifies the name of the linker section for the given
3132 entity. It is equivalent to @code{__attribute__((section))} in GNU C and
3133 causes @var{LOCAL_NAME} to be placed in the @var{static_string_EXPRESSION}
3134 section of the executable (assuming the linker doesn't rename the section).
3135
3136 The compiler normally places library-level objects in standard sections
3137 depending on their type: procedures and functions generally go in the
3138 @code{.text} section, initialized variables in the @code{.data} section
3139 and uninitialized variables in the @code{.bss} section.
3140
3141 Other, special sections may exist on given target machines to map special
3142 hardware, for example I/O ports or flash memory. This pragma is a means to
3143 defer the final layout of the executable to the linker, thus fully working
3144 at the symbolic level with the compiler.
3145
3146 Some file formats do not support arbitrary sections so not all target
3147 machines support this pragma. The use of this pragma may cause a program
3148 execution to be erroneous if it is used to place an entity into an
3149 inappropriate section (e.g.@: a modified variable into the @code{.text}
3150 section). See also @code{pragma Persistent_BSS}.
3151
3152 @smallexample @c ada
3153 --  Example of the use of pragma Linker_Section
3154
3155 package IO_Card is
3156   Port_A : Integer;
3157   pragma Volatile (Port_A);
3158   pragma Linker_Section (Port_A, ".bss.port_a");
3159
3160   Port_B : Integer;
3161   pragma Volatile (Port_B);
3162   pragma Linker_Section (Port_B, ".bss.port_b");
3163 end IO_Card;
3164 @end smallexample
3165
3166 @node Pragma Long_Float
3167 @unnumberedsec Pragma Long_Float
3168 @cindex OpenVMS
3169 @findex Long_Float
3170 @noindent
3171 Syntax:
3172
3173 @smallexample @c ada
3174 pragma Long_Float (FLOAT_FORMAT);
3175
3176 FLOAT_FORMAT ::= D_Float | G_Float
3177 @end smallexample
3178
3179 @noindent
3180 This pragma is implemented only in the OpenVMS implementation of GNAT@.
3181 It allows control over the internal representation chosen for the predefined
3182 type @code{Long_Float} and for floating point type representations with
3183 @code{digits} specified in the range 7 through 15.
3184 For further details on this pragma, see the
3185 @cite{DEC Ada Language Reference Manual}, section 3.5.7b.  Note that to use
3186 this pragma, the standard runtime libraries must be recompiled.
3187 @xref{The GNAT Run-Time Library Builder gnatlbr,,, gnat_ugn,
3188 @value{EDITION} User's Guide OpenVMS}, for a description of the
3189 @code{GNAT LIBRARY} command.
3190
3191 @node Pragma Machine_Attribute
3192 @unnumberedsec Pragma Machine_Attribute
3193 @findex Machine_Attribute
3194 @noindent
3195 Syntax:
3196
3197 @smallexample @c ada
3198 pragma Machine_Attribute (
3199      [Entity         =>] LOCAL_NAME,
3200      [Attribute_Name =>] static_string_EXPRESSION
3201   [, [Info           =>] static_string_EXPRESSION] );
3202 @end smallexample
3203
3204 @noindent
3205 Machine-dependent attributes can be specified for types and/or
3206 declarations.  This pragma is semantically equivalent to
3207 @code{__attribute__((@var{attribute_name}))} (if @var{info} is not
3208 specified) or @code{__attribute__((@var{attribute_name}(@var{info})))}
3209 in GNU C, where @code{@var{attribute_name}} is recognized by the
3210 target macro @code{TARGET_ATTRIBUTE_TABLE} which is defined for each
3211 machine.  The optional parameter @var{info} is transformed into an
3212 identifier, which may make this pragma unusable for some attributes
3213 (parameter of some attributes must be a number or a string).
3214 @xref{Target Attributes,, Defining target-specific uses of
3215 @code{__attribute__}, gccint, GNU Compiler Colletion (GCC) Internals},
3216 further information.  It is not possible to specify
3217 attributes defined by other languages, only attributes defined by the
3218 machine the code is intended to run on.
3219
3220 @node Pragma Main
3221 @unnumberedsec Pragma Main
3222 @cindex OpenVMS
3223 @findex Main
3224 @noindent
3225 Syntax:
3226
3227 @smallexample @c ada
3228 pragma Main
3229  (MAIN_OPTION [, MAIN_OPTION]);
3230
3231 MAIN_OPTION ::=
3232   [STACK_SIZE              =>] static_integer_EXPRESSION
3233 | [TASK_STACK_SIZE_DEFAULT =>] static_integer_EXPRESSION
3234 | [TIME_SLICING_ENABLED    =>] static_boolean_EXPRESSION
3235 @end smallexample
3236
3237 @noindent
3238 This pragma is provided for compatibility with OpenVMS VAX Systems.  It has
3239 no effect in GNAT, other than being syntax checked.
3240
3241 @node Pragma Main_Storage
3242 @unnumberedsec Pragma Main_Storage
3243 @cindex OpenVMS
3244 @findex Main_Storage
3245 @noindent
3246 Syntax:
3247
3248 @smallexample @c ada
3249 pragma Main_Storage
3250   (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
3251
3252 MAIN_STORAGE_OPTION ::=
3253   [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
3254 | [TOP_GUARD       =>] static_SIMPLE_EXPRESSION
3255 @end smallexample
3256
3257 @noindent
3258 This pragma is provided for compatibility with OpenVMS VAX Systems.  It has
3259 no effect in GNAT, other than being syntax checked.  Note that the pragma
3260 also has no effect in DEC Ada 83 for OpenVMS Alpha Systems.
3261
3262 @node Pragma No_Body
3263 @unnumberedsec Pragma No_Body
3264 @findex No_Body
3265 @noindent
3266 Syntax:
3267
3268 @smallexample @c ada
3269 pragma No_Body;
3270 @end smallexample
3271
3272 @noindent
3273 There are a number of cases in which a package spec does not require a body,
3274 and in fact a body is not permitted. GNAT will not permit the spec to be
3275 compiled if there is a body around. The pragma No_Body allows you to provide
3276 a body file, even in a case where no body is allowed. The body file must
3277 contain only comments and a single No_Body pragma. This is recognized by
3278 the compiler as indicating that no body is logically present.
3279
3280 This is particularly useful during maintenance when a package is modified in
3281 such a way that a body needed before is no longer needed. The provision of a
3282 dummy body with a No_Body pragma ensures that there is no interference from
3283 earlier versions of the package body.
3284
3285 @node Pragma No_Return
3286 @unnumberedsec Pragma No_Return
3287 @findex No_Return
3288 @noindent
3289 Syntax:
3290
3291 @smallexample @c ada
3292 pragma No_Return (procedure_LOCAL_NAME @{, procedure_LOCAL_NAME@});
3293 @end smallexample
3294
3295 @noindent
3296 Each @var{procedure_LOCAL_NAME} argument must refer to one or more procedure
3297 declarations in the current declarative part.  A procedure to which this
3298 pragma is applied may not contain any explicit @code{return} statements.
3299 In addition, if the procedure contains any implicit returns from falling
3300 off the end of a statement sequence, then execution of that implicit
3301 return will cause Program_Error to be raised.
3302
3303 One use of this pragma is to identify procedures whose only purpose is to raise
3304 an exception. Another use of this pragma is to suppress incorrect warnings
3305 about missing returns in functions, where the last statement of a function
3306 statement sequence is a call to such a procedure.
3307
3308 Note that in Ada 2005 mode, this pragma is part of the language, and is
3309 identical in effect to the pragma as implemented in Ada 95 mode.
3310
3311 @node Pragma No_Strict_Aliasing
3312 @unnumberedsec Pragma No_Strict_Aliasing
3313 @findex No_Strict_Aliasing
3314 @noindent
3315 Syntax:
3316
3317 @smallexample @c ada
3318 pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
3319 @end smallexample
3320
3321 @noindent
3322 @var{type_LOCAL_NAME} must refer to an access type
3323 declaration in the current declarative part.  The effect is to inhibit
3324 strict aliasing optimization for the given type.  The form with no
3325 arguments is a configuration pragma which applies to all access types
3326 declared in units to which the pragma applies. For a detailed
3327 description of the strict aliasing optimization, and the situations
3328 in which it must be suppressed, see @ref{Optimization and Strict
3329 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
3330
3331 @node Pragma Normalize_Scalars
3332 @unnumberedsec Pragma Normalize_Scalars
3333 @findex Normalize_Scalars
3334 @noindent
3335 Syntax:
3336
3337 @smallexample @c ada
3338 pragma Normalize_Scalars;
3339 @end smallexample
3340
3341 @noindent
3342 This is a language defined pragma which is fully implemented in GNAT@.  The
3343 effect is to cause all scalar objects that are not otherwise initialized
3344 to be initialized.  The initial values are implementation dependent and
3345 are as follows:
3346
3347 @table @code
3348 @item Standard.Character
3349 @noindent
3350 Objects whose root type is Standard.Character are initialized to
3351 Character'Last unless the subtype range excludes NUL (in which case
3352 NUL is used). This choice will always generate an invalid value if
3353 one exists.
3354
3355 @item Standard.Wide_Character
3356 @noindent
3357 Objects whose root type is Standard.Wide_Character are initialized to
3358 Wide_Character'Last unless the subtype range excludes NUL (in which case
3359 NUL is used). This choice will always generate an invalid value if
3360 one exists.
3361
3362 @item Standard.Wide_Wide_Character
3363 @noindent
3364 Objects whose root type is Standard.Wide_Wide_Character are initialized to
3365 the invalid value 16#FFFF_FFFF# unless the subtype range excludes NUL (in
3366 which case NUL is used). This choice will always generate an invalid value if
3367 one exists.
3368
3369 @item Integer types
3370 @noindent
3371 Objects of an integer type are treated differently depending on whether
3372 negative values are present in the subtype. If no negative values are
3373 present, then all one bits is used as the initial value except in the
3374 special case where zero is excluded from the subtype, in which case
3375 all zero bits are used. This choice will always generate an invalid
3376 value if one exists.
3377
3378 For subtypes with negative values present, the largest negative number
3379 is used, except in the unusual case where this largest negative number
3380 is in the subtype, and the largest positive number is not, in which case
3381 the largest positive value is used. This choice will always generate
3382 an invalid value if one exists.
3383
3384 @item Floating-Point Types
3385 Objects of all floating-point types are initialized to all 1-bits. For
3386 standard IEEE format, this corresponds to a NaN (not a number) which is
3387 indeed an invalid value.
3388
3389 @item Fixed-Point Types
3390 Objects of all fixed-point types are treated as described above for integers,
3391 with the rules applying to the underlying integer value used to represent
3392 the fixed-point value.
3393
3394 @item Modular types
3395 Objects of a modular type are initialized to all one bits, except in
3396 the special case where zero is excluded from the subtype, in which
3397 case all zero bits are used. This choice will always generate an
3398 invalid value if one exists.
3399
3400 @item Enumeration types
3401 Objects of an enumeration type are initialized to all one-bits, i.e.@: to
3402 the value @code{2 ** typ'Size - 1} unless the subtype excludes the literal
3403 whose Pos value is zero, in which case a code of zero is used. This choice
3404 will always generate an invalid value if one exists.
3405
3406 @end table
3407
3408 @node Pragma Obsolescent
3409 @unnumberedsec Pragma Obsolescent
3410 @findex Obsolescent
3411 @noindent
3412 Syntax:
3413
3414 @smallexample @c ada
3415 pragma Obsolescent
3416   [(Entity => NAME [, static_string_EXPRESSION [,Ada_05]])];
3417 @end smallexample
3418
3419 @noindent
3420 This pragma can occur immediately following a declaration of an entity,
3421 including the case of a record component, and usually the Entity name
3422 must match the name of the entity declared by this declaration.
3423 Alternatively, the pragma can immediately follow an
3424 enumeration type declaration, where the entity argument names one of the
3425 enumeration literals.
3426
3427 This pragma is used to indicate that the named entity
3428 is considered obsolescent and should not be used. Typically this is
3429 used when an API must be modified by eventually removing or modifying
3430 existing subprograms or other entities. The pragma can be used at an
3431 intermediate stage when the entity is still present, but will be
3432 removed later.
3433
3434 The effect of this pragma is to output a warning message on
3435 a call to a program thus marked that the
3436 subprogram is obsolescent if the appropriate warning option in the
3437 compiler is activated. If the string parameter is present, then a second
3438 warning message is given containing this text.
3439 In addition, a call to such a program is considered a violation of
3440 pragma Restrictions (No_Obsolescent_Features).
3441
3442 This pragma can also be used as a program unit pragma for a package,
3443 in which case the entity name is the name of the package, and the
3444 pragma indicates that the entire package is considered
3445 obsolescent. In this case a client @code{with}'ing such a package
3446 violates the restriction, and the @code{with} statement is
3447 flagged with warnings if the warning option is set.
3448
3449 If the optional third parameter is present (which must be exactly
3450 the identifier Ada_05, no other argument is allowed), then the
3451 indication of obsolescence applies only when compiling in Ada 2005
3452 mode. This is primarily intended for dealing with the situations
3453 in the predefined library where subprograms or packages
3454 have become defined as obsolescent in Ada 2005
3455 (e.g.@: in Ada.Characters.Handling), but may be used anywhere.
3456
3457 The following examples show typical uses of this pragma:
3458
3459 @smallexample @c ada
3460 package p is
3461    pragma Obsolescent
3462      (Entity => p, "use pp instead of p");
3463 end p;
3464
3465 package q is
3466    procedure q2;
3467    pragma Obsolescent
3468      (Entity => q2, "use q2new instead");
3469
3470    type R is new integer;
3471    pragma Obsolescent
3472      (Entity => R, "use RR in Ada 2005", Ada_05);
3473
3474    type M is record
3475       F1 : Integer;
3476       F2 : Integer;
3477       pragma Obsolescent (Entity => F2);
3478       F3 : Integer;
3479    end record;
3480
3481    type E is (a, bc, 'd', quack);
3482    pragma Obsolescent (Entity => bc)
3483    pragma Obsolescent (Entity => 'd')
3484
3485    function "+"
3486      (a, b : character) return character;
3487    pragma Obsolescent (Entity => "+");
3488 end;
3489 @end smallexample
3490
3491 @noindent
3492 In an earlier version of GNAT, the Entity parameter was not required,
3493 and this form is still accepted for compatibility purposes. If the
3494 Entity parameter is omitted, then the pragma applies to the declaration
3495 immediately preceding the pragma (this form cannot be used for the
3496 enumeration literal case).
3497
3498 @node Pragma Optimize_Alignment
3499 @unnumberedsec Pragma Optimize_Alignment
3500 @findex Optimize_Alignment
3501 @cindex Alignment, default settings
3502 @noindent
3503 Syntax:
3504
3505 @smallexample @c ada
3506 pragma Optimize_Alignment (TIME | SPACE | OFF);
3507 @end smallexample
3508
3509 @noindent
3510 This is a configuration pragma which affects the choice of default alignments
3511 for types where no alignment is explicitly specified. There is a time/space
3512 trade-off in the selection of these values. Large alignments result in more
3513 efficient code, at the expense of larger data space, since sizes have to be
3514 increased to match these alignments. Smaller alignments save space, but the
3515 access code is slower. The normal choice of default alignments (which is what
3516 you get if you do not use this pragma, or if you use an argument of OFF),
3517 tries to balance these two requirements.
3518
3519 Specifying SPACE causes smaller default alignments to be chosen in two cases.
3520 First any packed record is given an alignment of 1. Second, if a size is given
3521 for the type, then the alignment is chosen to avoid increasing this size. For
3522 example, consider:
3523
3524 @smallexample @c ada
3525    type R is record
3526       X : Integer;
3527       Y : Character;
3528    end record;
3529
3530    for R'Size use 5*8;
3531 @end smallexample
3532
3533 @noindent
3534 In the default mode, this type gets an alignment of 4, so that access to the
3535 Integer field X are efficient. But this means that objects of the type end up
3536 with a size of 8 bytes. This is a valid choice, since sizes of objects are
3537 allowed to be bigger than the size of the type, but it can waste space if for
3538 example fields of type R appear in an enclosing record. If the above type is
3539 compiled in @code{Optimize_Alignment (Space)} mode, the alignment is set to 1.
3540
3541 Specifying TIME causes larger default alignments to be chosen in the case of
3542 small types with sizes that are not a power of 2. For example, consider:
3543
3544 @smallexample @c ada
3545    type R is record
3546       A : Character;
3547       B : Character;
3548       C : Boolean;
3549    end record;
3550
3551    pragma Pack (R);
3552    for R'Size use 17;
3553 @end smallexample
3554
3555 @noindent
3556 The default alignment for this record is normally 1, but if this type is
3557 compiled in @code{Optimize_Alignment (Time)} mode, then the alignment is set
3558 to 4, which wastes space for objects of the type, since they are now 4 bytes
3559 long, but results in more efficient access when the whole record is referenced.
3560
3561 As noted above, this is a configuration pragma, and there is a requirement
3562 that all units in a partition be compiled with a consistent setting of the
3563 optimization setting. This would normally be achieved by use of a configuration
3564 pragma file containing the appropriate setting. The exception to this rule is
3565 that units with an explicit configuration pragma in the same file as the source
3566 unit are excluded from the consistency check, as are all predefined units. The
3567 latter are compiled by default in pragma Optimize_Alignment (Off) mode if no
3568 pragma appears at the start of the file.
3569
3570 @node Pragma Passive
3571 @unnumberedsec Pragma Passive
3572 @findex Passive
3573 @noindent
3574 Syntax:
3575
3576 @smallexample @c ada
3577 pragma Passive [(Semaphore | No)];
3578 @end smallexample
3579
3580 @noindent
3581 Syntax checked, but otherwise ignored by GNAT@.  This is recognized for
3582 compatibility with DEC Ada 83 implementations, where it is used within a
3583 task definition to request that a task be made passive.  If the argument
3584 @code{Semaphore} is present, or the argument is omitted, then DEC Ada 83
3585 treats the pragma as an assertion that the containing task is passive
3586 and that optimization of context switch with this task is permitted and
3587 desired.  If the argument @code{No} is present, the task must not be
3588 optimized.  GNAT does not attempt to optimize any tasks in this manner
3589 (since protected objects are available in place of passive tasks).
3590
3591 @node Pragma Persistent_BSS
3592 @unnumberedsec Pragma Persistent_BSS
3593 @findex Persistent_BSS
3594 @noindent
3595 Syntax:
3596
3597 @smallexample @c ada
3598 pragma Persistent_BSS [(LOCAL_NAME)]
3599 @end smallexample
3600
3601 @noindent
3602 This pragma allows selected objects to be placed in the @code{.persistent_bss}
3603 section. On some targets the linker and loader provide for special
3604 treatment of this section, allowing a program to be reloaded without
3605 affecting the contents of this data (hence the name persistent).
3606
3607 There are two forms of usage. If an argument is given, it must be the
3608 local name of a library level object, with no explicit initialization
3609 and whose type is potentially persistent. If no argument is given, then
3610 the pragma is a configuration pragma, and applies to all library level
3611 objects with no explicit initialization of potentially persistent types.
3612
3613 A potentially persistent type is a scalar type, or a non-tagged,
3614 non-discriminated record, all of whose components have no explicit
3615 initialization and are themselves of a potentially persistent type,
3616 or an array, all of whose constraints are static, and whose component
3617 type is potentially persistent.
3618
3619 If this pragma is used on a target where this feature is not supported,
3620 then the pragma will be ignored. See also @code{pragma Linker_Section}.
3621
3622 @node Pragma Polling
3623 @unnumberedsec Pragma Polling
3624 @findex Polling
3625 @noindent
3626 Syntax:
3627
3628 @smallexample @c ada
3629 pragma Polling (ON | OFF);
3630 @end smallexample
3631
3632 @noindent
3633 This pragma controls the generation of polling code.  This is normally off.
3634 If @code{pragma Polling (ON)} is used then periodic calls are generated to
3635 the routine @code{Ada.Exceptions.Poll}.  This routine is a separate unit in the
3636 runtime library, and can be found in file @file{a-excpol.adb}.
3637
3638 Pragma @code{Polling} can appear as a configuration pragma (for example it
3639 can be placed in the @file{gnat.adc} file) to enable polling globally, or it
3640 can be used in the statement or declaration sequence to control polling
3641 more locally.
3642
3643 A call to the polling routine is generated at the start of every loop and
3644 at the start of every subprogram call.  This guarantees that the @code{Poll}
3645 routine is called frequently, and places an upper bound (determined by
3646 the complexity of the code) on the period between two @code{Poll} calls.
3647
3648 The primary purpose of the polling interface is to enable asynchronous
3649 aborts on targets that cannot otherwise support it (for example Windows
3650 NT), but it may be used for any other purpose requiring periodic polling.
3651 The standard version is null, and can be replaced by a user program.  This
3652 will require re-compilation of the @code{Ada.Exceptions} package that can
3653 be found in files @file{a-except.ads} and @file{a-except.adb}.
3654
3655 A standard alternative unit (in file @file{4wexcpol.adb} in the standard GNAT
3656 distribution) is used to enable the asynchronous abort capability on
3657 targets that do not normally support the capability.  The version of
3658 @code{Poll} in this file makes a call to the appropriate runtime routine
3659 to test for an abort condition.
3660
3661 Note that polling can also be enabled by use of the @option{-gnatP} switch.
3662 @xref{Switches for gcc,,, gnat_ugn, @value{EDITION} User's Guide}, for
3663 details.
3664
3665 @node Pragma Postcondition
3666 @unnumberedsec Pragma Postcondition
3667 @cindex Postconditions
3668 @cindex Checks, postconditions
3669 @findex Postconditions
3670 @noindent
3671 Syntax:
3672
3673 @smallexample @c ada
3674 pragma Postcondition (
3675    [Check   =>] Boolean_Expression
3676  [,[Message =>] String_Expression]);
3677 @end smallexample
3678
3679 @noindent
3680 The @code{Postcondition} pragma allows specification of automatic
3681 postcondition checks for subprograms. These checks are similar to
3682 assertions, but are automatically inserted just prior to the return
3683 statements of the subprogram with which they are associated.
3684 Furthermore, the boolean expression which is the condition which
3685 must be true may contain references to function'Result in the case
3686 of a function to refer to the returned value.
3687
3688 @code{Postcondition} pragmas may appear either immediate following the
3689 (separate) declaration of a subprogram, or at the start of the
3690 declarations of a subprogram body. Only other pragmas may intervene
3691 (that is appear between the subprogram declaration and its
3692 postconditions, or appear before the postcondition in the
3693 declaration sequence in a subprogram body). In the case of a
3694 postcondition appearing after a subprogram declaration, the
3695 formal arguments of the subprogram are visible, and can be
3696 referenced in the postcondition expressions.
3697
3698 The postconditions are collected and automatically tested just
3699 before any return (implicit or explicit) in the subprogram body.
3700 A postcondition is only recognized if postconditions are active
3701 at the time the pragma is encountered. The compiler switch @option{gnata}
3702 turns on all postconditions by default, and pragma @code{Check_Policy}
3703 with an identifier of @code{Postcondition} can also be used to
3704 control whether postconditions are active.
3705
3706 The general approach is that postconditions are placed in the spec
3707 if they represent functional aspects which make sense to the client.
3708 For example we might have:
3709
3710 @smallexample @c ada
3711    function Direction return Integer;
3712    pragma Postcondition
3713     (Direction'Result = +1
3714        or else
3715      Direction'Result = -1);
3716 @end smallexample
3717
3718 @noindent
3719 which serves to document that the result must be +1 or -1, and
3720 will test that this is the case at run time if postcondition
3721 checking is active.
3722
3723 Postconditions within the subprogram body can be used to
3724 check that some internal aspect of the implementation,
3725 not visible to the client, is operating as expected.
3726 For instance if a square root routine keeps an internal
3727 counter of the number of times it is called, then we
3728 might have the following postcondition:
3729
3730 @smallexample @c ada
3731    Sqrt_Calls : Natural := 0;
3732
3733    function Sqrt (Arg : Float) return Float is
3734      pragma Postcondition
3735        (Sqrt_Calls = Sqrt_Calls'Old + 1);
3736      ...
3737    end Sqrt
3738 @end smallexample
3739
3740 @noindent
3741 As this example, shows, the use of the @code{Old} attribute
3742 is often useful in postconditions to refer to the state on
3743 entry to the subprogram.
3744
3745 Note that postconditions are only checked on normal returns
3746 from the subprogram. If an abnormal return results from
3747 raising an exception, then the postconditions are not checked.
3748
3749 If a postcondition fails, then the exception
3750 @code{System.Assertions.Assert_Failure} is raised. If
3751 a message argument was supplied, then the given string
3752 will be used as the exception message. If no message
3753 argument was supplied, then the default message has
3754 the form "Postcondition failed at file:line". The
3755 exception is raised in the context of the subprogram
3756 body, so it is possible to catch postcondition failures
3757 within the subprogram body itself.
3758
3759 Within a package spec, normal visibility rules
3760 in Ada would prevent forward references within a
3761 postcondition pragma to functions defined later in
3762 the same package. This would introduce undesirable
3763 ordering constraints. To avoid this problem, all
3764 postcondition pragmas are analyzed at the end of
3765 the package spec, allowing forward references.
3766
3767 The following example shows that this even allows
3768 mutually recursive postconditions as in:
3769
3770 @smallexample @c ada
3771 package Parity_Functions is
3772    function Odd  (X : Natural) return Boolean;
3773    pragma Postcondition
3774      (Odd'Result =
3775         (x = 1
3776           or else
3777         (x /= 0 and then Even (X - 1))));
3778
3779    function Even (X : Natural) return Boolean;
3780    pragma Postcondition
3781      (Even'Result =
3782         (x = 0
3783           or else
3784         (x /= 1 and then Odd (X - 1))));
3785
3786 end Parity_Functions;
3787 @end smallexample
3788
3789 @noindent
3790 There are no restrictions on the complexity or form of
3791 conditions used within @code{Postcondition} pragmas.
3792 The following example shows that it is even possible
3793 to verify performance behavior.
3794
3795 @smallexample @c ada
3796 package Sort is
3797
3798    Performance : constant Float;
3799    --  Performance constant set by implementation
3800    --  to match target architecture behavior.
3801
3802    procedure Treesort (Arg : String);
3803    --  Sorts characters of argument using N*logN sort
3804    pragma Postcondition
3805      (Float (Clock - Clock'Old) <=
3806         Float (Arg'Length) *
3807         log (Float (Arg'Length)) *
3808         Performance);
3809 end Sort;
3810 @end smallexample
3811
3812 @noindent
3813 Note: postcondition pragmas associated with subprograms that are
3814 marked as Inline_Always, or those marked as Inline with front-end
3815 inlining (-gnatN option set) are accepted and legality-checked
3816 by the compiler, but are ignored at run-time even if postcondition
3817 checking is enabled.
3818
3819 @node Pragma Precondition
3820 @unnumberedsec Pragma Precondition
3821 @cindex Preconditions
3822 @cindex Checks, preconditions
3823 @findex Preconditions
3824 @noindent
3825 Syntax:
3826
3827 @smallexample @c ada
3828 pragma Precondition (
3829    [Check   =>] Boolean_Expression
3830  [,[Message =>] String_Expression]);
3831 @end smallexample
3832
3833 @noindent
3834 The @code{Precondition} pragma is similar to @code{Postcondition}
3835 except that the corresponding checks take place immediately upon
3836 entry to the subprogram, and if a precondition fails, the exception
3837 is raised in the context of the caller, and the attribute 'Result
3838 cannot be used within the precondition expression.
3839
3840 Otherwise, the placement and visibility rules are identical to those
3841 described for postconditions. The following is an example of use
3842 within a package spec:
3843
3844 @smallexample @c ada
3845 package Math_Functions is
3846    ...
3847    function Sqrt (Arg : Float) return Float;
3848    pragma Precondition (Arg >= 0.0)
3849    ...
3850 end Math_Functions;
3851 @end smallexample
3852
3853 @noindent
3854 @code{Precondition} pragmas may appear either immediate following the
3855 (separate) declaration of a subprogram, or at the start of the
3856 declarations of a subprogram body. Only other pragmas may intervene
3857 (that is appear between the subprogram declaration and its
3858 postconditions, or appear before the postcondition in the
3859 declaration sequence in a subprogram body).
3860
3861 Note: postcondition pragmas associated with subprograms that are
3862 marked as Inline_Always, or those marked as Inline with front-end
3863 inlining (-gnatN option set) are accepted and legality-checked
3864 by the compiler, but are ignored at run-time even if postcondition
3865 checking is enabled.
3866
3867
3868
3869 @node Pragma Profile (Ravenscar)
3870 @unnumberedsec Pragma Profile (Ravenscar)
3871 @findex Ravenscar
3872 @noindent
3873 Syntax:
3874
3875 @smallexample @c ada
3876 pragma Profile (Ravenscar);
3877 @end smallexample
3878
3879 @noindent
3880 A configuration pragma that establishes the following set of configuration
3881 pragmas:
3882
3883 @table @code
3884 @item Task_Dispatching_Policy (FIFO_Within_Priorities)
3885 [RM D.2.2] Tasks are dispatched following a preemptive
3886 priority-ordered scheduling policy.
3887
3888 @item Locking_Policy (Ceiling_Locking)
3889 [RM D.3] While tasks and interrupts execute a protected action, they inherit
3890 the ceiling priority of the corresponding protected object.
3891 @c
3892 @c @item Detect_Blocking
3893 @c This pragma forces the detection of potentially blocking operations within a
3894 @c protected operation, and to raise Program_Error if that happens.
3895 @end table
3896 @noindent
3897
3898 plus the following set of restrictions:
3899
3900 @table @code
3901 @item Max_Entry_Queue_Length = 1
3902 Defines the maximum number of calls that are queued on a (protected) entry.
3903 Note that this restrictions is checked at run time. Violation of this
3904 restriction results in the raising of Program_Error exception at the point of
3905 the call. For the Profile (Ravenscar) the value of Max_Entry_Queue_Length is
3906 always 1 and hence no task can be queued on a protected entry.
3907
3908 @item Max_Protected_Entries = 1
3909 [RM D.7] Specifies the maximum number of entries per protected type. The
3910 bounds of every entry family of a protected unit shall be static, or shall be
3911 defined by a discriminant of a subtype whose corresponding bound is static.
3912 For the Profile (Ravenscar) the value of Max_Protected_Entries is always 1.
3913
3914 @item Max_Task_Entries = 0
3915 [RM D.7] Specifies the maximum number of entries
3916 per task.  The bounds of every entry family
3917 of a task unit shall be static, or shall be
3918 defined by a discriminant of a subtype whose
3919 corresponding bound is static.  A value of zero
3920 indicates that no rendezvous are possible.  For
3921 the Profile (Ravenscar), the value of Max_Task_Entries is always
3922 0 (zero).
3923
3924 @item No_Abort_Statements
3925 [RM D.7] There are no abort_statements, and there are
3926 no calls to Task_Identification.Abort_Task.
3927
3928 @item No_Asynchronous_Control
3929 There are no semantic dependences on the package
3930 Asynchronous_Task_Control.
3931
3932 @item No_Calendar
3933 There are no semantic dependencies on the package Ada.Calendar.
3934
3935 @item No_Dynamic_Attachment
3936 There is no call to any of the operations defined in package Ada.Interrupts
3937 (Is_Reserved, Is_Attached, Current_Handler, Attach_Handler, Exchange_Handler,
3938 Detach_Handler, and Reference).
3939
3940 @item No_Dynamic_Priorities
3941 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
3942
3943 @item No_Implicit_Heap_Allocations
3944 [RM D.7] No constructs are allowed to cause implicit heap allocation.
3945
3946 @item No_Local_Protected_Objects
3947 Protected objects and access types that designate
3948 such objects shall be declared only at library level.
3949
3950 @item No_Local_Timing_Events
3951 [RM D.7] All objects of type Ada.Timing_Events.Timing_Event are
3952 declared at the library level.
3953
3954 @item No_Protected_Type_Allocators
3955 There are no allocators for protected types or
3956 types containing protected subcomponents.
3957
3958 @item No_Relative_Delay
3959 There are no delay_relative statements.
3960
3961 @item No_Requeue_Statements
3962 Requeue statements are not allowed.
3963
3964 @item No_Select_Statements
3965 There are no select_statements.
3966
3967 @item No_Specific_Termination_Handlers
3968 [RM D.7] There are no calls to Ada.Task_Termination.Set_Specific_Handler
3969 or to Ada.Task_Termination.Specific_Handler.
3970
3971 @item No_Task_Allocators
3972 [RM D.7] There are no allocators for task types
3973 or types containing task subcomponents.
3974
3975 @item No_Task_Attributes_Package
3976 There are no semantic dependencies on the Ada.Task_Attributes package.
3977
3978 @item No_Task_Hierarchy
3979 [RM D.7] All (non-environment) tasks depend
3980 directly on the environment task of the partition.
3981
3982 @item No_Task_Termination
3983 Tasks which terminate are erroneous.
3984
3985 @item No_Unchecked_Conversion
3986 There are no semantic dependencies on the Ada.Unchecked_Conversion package.
3987
3988 @item No_Unchecked_Deallocation
3989 There are no semantic dependencies on the Ada.Unchecked_Deallocation package.
3990
3991 @item Simple_Barriers
3992 Entry barrier condition expressions shall be either static
3993 boolean expressions or boolean objects which are declared in
3994 the protected type which contains the entry.
3995 @end table
3996
3997 @noindent
3998 This set of configuration pragmas and restrictions correspond to the
3999 definition of the ``Ravenscar Profile'' for limited tasking, devised and
4000 published by the @cite{International Real-Time Ada Workshop}, 1997,
4001 and whose most recent description is available at
4002 @url{http://www-users.cs.york.ac.uk/~burns/ravenscar.ps}.
4003
4004 The original definition of the profile was revised at subsequent IRTAW
4005 meetings. It has been included in the ISO
4006 @cite{Guide for the Use of the Ada Programming Language in High
4007 Integrity Systems}, and has been approved by ISO/IEC/SC22/WG9 for inclusion in
4008 the next revision of the standard. The formal definition given by
4009 the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
4010 AI-305) available at
4011 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00249.TXT} and
4012 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00305.TXT}
4013 respectively.
4014
4015 The above set is a superset of the restrictions provided by pragma
4016 @code{Profile (Restricted)}, it includes six additional restrictions
4017 (@code{Simple_Barriers}, @code{No_Select_Statements},
4018 @code{No_Calendar}, @code{No_Implicit_Heap_Allocations},
4019 @code{No_Relative_Delay} and @code{No_Task_Termination}).  This means
4020 that pragma @code{Profile (Ravenscar)}, like the pragma
4021 @code{Profile (Restricted)},
4022 automatically causes the use of a simplified,
4023 more efficient version of the tasking run-time system.
4024
4025 @node Pragma Profile (Restricted)
4026 @unnumberedsec Pragma Profile (Restricted)
4027 @findex Restricted Run Time
4028 @noindent
4029 Syntax:
4030
4031 @smallexample @c ada
4032 pragma Profile (Restricted);
4033 @end smallexample
4034
4035 @noindent
4036 A configuration pragma that establishes the following set of restrictions:
4037
4038 @itemize @bullet
4039 @item No_Abort_Statements
4040 @item No_Entry_Queue
4041 @item No_Task_Hierarchy
4042 @item No_Task_Allocators
4043 @item No_Dynamic_Priorities
4044 @item No_Terminate_Alternatives
4045 @item No_Dynamic_Attachment
4046 @item No_Protected_Type_Allocators
4047 @item No_Local_Protected_Objects
4048 @item No_Requeue_Statements
4049 @item No_Task_Attributes_Package
4050 @item Max_Asynchronous_Select_Nesting =  0
4051 @item Max_Task_Entries =  0
4052 @item Max_Protected_Entries = 1
4053 @item Max_Select_Alternatives = 0
4054 @end itemize
4055
4056 @noindent
4057 This set of restrictions causes the automatic selection of a simplified
4058 version of the run time that provides improved performance for the
4059 limited set of tasking functionality permitted by this set of restrictions.
4060
4061 @node Pragma Psect_Object
4062 @unnumberedsec Pragma Psect_Object
4063 @findex Psect_Object
4064 @noindent
4065 Syntax:
4066
4067 @smallexample @c ada
4068 pragma Psect_Object (
4069      [Internal =>] LOCAL_NAME,
4070   [, [External =>] EXTERNAL_SYMBOL]
4071   [, [Size     =>] EXTERNAL_SYMBOL]);
4072
4073 EXTERNAL_SYMBOL ::=
4074   IDENTIFIER
4075 | static_string_EXPRESSION
4076 @end smallexample
4077
4078 @noindent
4079 This pragma is identical in effect to pragma @code{Common_Object}.
4080
4081 @node Pragma Pure_Function
4082 @unnumberedsec Pragma Pure_Function
4083 @findex Pure_Function
4084 @noindent
4085 Syntax:
4086
4087 @smallexample @c ada
4088 pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
4089 @end smallexample
4090
4091 @noindent
4092 This pragma appears in the same declarative part as a function
4093 declaration (or a set of function declarations if more than one
4094 overloaded declaration exists, in which case the pragma applies
4095 to all entities).  It specifies that the function @code{Entity} is
4096 to be considered pure for the purposes of code generation.  This means
4097 that the compiler can assume that there are no side effects, and
4098 in particular that two calls with identical arguments produce the
4099 same result.  It also means that the function can be used in an
4100 address clause.
4101
4102 Note that, quite deliberately, there are no static checks to try
4103 to ensure that this promise is met, so @code{Pure_Function} can be used
4104 with functions that are conceptually pure, even if they do modify
4105 global variables.  For example, a square root function that is
4106 instrumented to count the number of times it is called is still
4107 conceptually pure, and can still be optimized, even though it
4108 modifies a global variable (the count).  Memo functions are another
4109 example (where a table of previous calls is kept and consulted to
4110 avoid re-computation).
4111
4112 @findex Pure
4113 Note: Most functions in a @code{Pure} package are automatically pure, and
4114 there is no need to use pragma @code{Pure_Function} for such functions.  One
4115 exception is any function that has at least one formal of type
4116 @code{System.Address} or a type derived from it.  Such functions are not
4117 considered pure by default, since the compiler assumes that the
4118 @code{Address} parameter may be functioning as a pointer and that the
4119 referenced data may change even if the address value does not.
4120 Similarly, imported functions are not considered to be pure by default,
4121 since there is no way of checking that they are in fact pure.  The use
4122 of pragma @code{Pure_Function} for such a function will override these default
4123 assumption, and cause the compiler to treat a designated subprogram as pure
4124 in these cases.
4125
4126 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
4127 applies to the underlying renamed function.  This can be used to
4128 disambiguate cases of overloading where some but not all functions
4129 in a set of overloaded functions are to be designated as pure.
4130
4131 If pragma @code{Pure_Function} is applied to a library level function, the
4132 function is also considered pure from an optimization point of view, but the
4133 unit is not a Pure unit in the categorization sense. So for example, a function
4134 thus marked is free to @code{with} non-pure units.
4135
4136 @node Pragma Restriction_Warnings
4137 @unnumberedsec Pragma Restriction_Warnings
4138 @findex Restriction_Warnings
4139 @noindent
4140 Syntax:
4141
4142 @smallexample @c ada
4143 pragma Restriction_Warnings
4144   (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
4145 @end smallexample
4146
4147 @noindent
4148 This pragma allows a series of restriction identifiers to be
4149 specified (the list of allowed identifiers is the same as for
4150 pragma @code{Restrictions}). For each of these identifiers
4151 the compiler checks for violations of the restriction, but
4152 generates a warning message rather than an error message
4153 if the restriction is violated.
4154
4155 @node Pragma Shared
4156 @unnumberedsec Pragma Shared
4157 @findex Shared
4158
4159 @noindent
4160 This pragma is provided for compatibility with Ada 83. The syntax and
4161 semantics are identical to pragma Atomic.
4162
4163 @node Pragma Source_File_Name
4164 @unnumberedsec Pragma Source_File_Name
4165 @findex Source_File_Name
4166 @noindent
4167 Syntax:
4168
4169 @smallexample @c ada
4170 pragma Source_File_Name (
4171   [Unit_Name   =>] unit_NAME,
4172   Spec_File_Name =>  STRING_LITERAL);
4173
4174 pragma Source_File_Name (
4175   [Unit_Name   =>] unit_NAME,
4176   Body_File_Name =>  STRING_LITERAL);
4177 @end smallexample
4178
4179 @noindent
4180 Use this to override the normal naming convention.  It is a configuration
4181 pragma, and so has the usual applicability of configuration pragmas
4182 (i.e.@: it applies to either an entire partition, or to all units in a
4183 compilation, or to a single unit, depending on how it is used.
4184 @var{unit_name} is mapped to @var{file_name_literal}.  The identifier for
4185 the second argument is required, and indicates whether this is the file
4186 name for the spec or for the body.
4187
4188 Another form of the @code{Source_File_Name} pragma allows
4189 the specification of patterns defining alternative file naming schemes
4190 to apply to all files.
4191
4192 @smallexample @c ada
4193 pragma Source_File_Name
4194   (Spec_File_Name => STRING_LITERAL
4195    [,Casing => CASING_SPEC]
4196    [,Dot_Replacement => STRING_LITERAL]);
4197
4198 pragma Source_File_Name
4199   (Body_File_Name => STRING_LITERAL
4200    [,Casing => CASING_SPEC]
4201    [,Dot_Replacement => STRING_LITERAL]);
4202
4203 pragma Source_File_Name
4204   (Subunit_File_Name => STRING_LITERAL
4205    [,Casing => CASING_SPEC]
4206    [,Dot_Replacement => STRING_LITERAL]);
4207
4208 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
4209 @end smallexample
4210
4211 @noindent
4212 The first argument is a pattern that contains a single asterisk indicating
4213 the point at which the unit name is to be inserted in the pattern string
4214 to form the file name.  The second argument is optional.  If present it
4215 specifies the casing of the unit name in the resulting file name string.
4216 The default is lower case.  Finally the third argument allows for systematic
4217 replacement of any dots in the unit name by the specified string literal.
4218
4219 A pragma Source_File_Name cannot appear after a
4220 @ref{Pragma Source_File_Name_Project}.
4221
4222 For more details on the use of the @code{Source_File_Name} pragma,
4223 @xref{Using Other File Names,,, gnat_ugn, @value{EDITION} User's Guide},
4224 and @ref{Alternative File Naming Schemes,,, gnat_ugn, @value{EDITION}
4225 User's Guide}.
4226
4227 @node Pragma Source_File_Name_Project
4228 @unnumberedsec Pragma Source_File_Name_Project
4229 @findex Source_File_Name_Project
4230 @noindent
4231
4232 This pragma has the same syntax and semantics as pragma Source_File_Name.
4233 It is only allowed as a stand alone configuration pragma.
4234 It cannot appear after a @ref{Pragma Source_File_Name}, and
4235 most importantly, once pragma Source_File_Name_Project appears,
4236 no further Source_File_Name pragmas are allowed.
4237
4238 The intention is that Source_File_Name_Project pragmas are always
4239 generated by the Project Manager in a manner consistent with the naming
4240 specified in a project file, and when naming is controlled in this manner,
4241 it is not permissible to attempt to modify this naming scheme using
4242 Source_File_Name pragmas (which would not be known to the project manager).
4243
4244 @node Pragma Source_Reference
4245 @unnumberedsec Pragma Source_Reference
4246 @findex Source_Reference
4247 @noindent
4248 Syntax:
4249
4250 @smallexample @c ada
4251 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
4252 @end smallexample
4253
4254 @noindent
4255 This pragma must appear as the first line of a source file.
4256 @var{integer_literal} is the logical line number of the line following
4257 the pragma line (for use in error messages and debugging
4258 information).  @var{string_literal} is a static string constant that
4259 specifies the file name to be used in error messages and debugging
4260 information.  This is most notably used for the output of @code{gnatchop}
4261 with the @option{-r} switch, to make sure that the original unchopped
4262 source file is the one referred to.
4263
4264 The second argument must be a string literal, it cannot be a static
4265 string expression other than a string literal.  This is because its value
4266 is needed for error messages issued by all phases of the compiler.
4267
4268 @node Pragma Stream_Convert
4269 @unnumberedsec Pragma Stream_Convert
4270 @findex Stream_Convert
4271 @noindent
4272 Syntax:
4273
4274 @smallexample @c ada
4275 pragma Stream_Convert (
4276   [Entity =>] type_LOCAL_NAME,
4277   [Read   =>] function_NAME,
4278   [Write  =>] function_NAME);
4279 @end smallexample
4280
4281 @noindent
4282 This pragma provides an efficient way of providing stream functions for
4283 types defined in packages.  Not only is it simpler to use than declaring
4284 the necessary functions with attribute representation clauses, but more
4285 significantly, it allows the declaration to made in such a way that the
4286 stream packages are not loaded unless they are needed.  The use of
4287 the Stream_Convert pragma adds no overhead at all, unless the stream
4288 attributes are actually used on the designated type.
4289
4290 The first argument specifies the type for which stream functions are
4291 provided.  The second parameter provides a function used to read values
4292 of this type.  It must name a function whose argument type may be any
4293 subtype, and whose returned type must be the type given as the first
4294 argument to the pragma.
4295
4296 The meaning of the @var{Read}
4297 parameter is that if a stream attribute directly
4298 or indirectly specifies reading of the type given as the first parameter,
4299 then a value of the type given as the argument to the Read function is
4300 read from the stream, and then the Read function is used to convert this
4301 to the required target type.
4302
4303 Similarly the @var{Write} parameter specifies how to treat write attributes
4304 that directly or indirectly apply to the type given as the first parameter.
4305 It must have an input parameter of the type specified by the first parameter,
4306 and the return type must be the same as the input type of the Read function.
4307 The effect is to first call the Write function to convert to the given stream
4308 type, and then write the result type to the stream.
4309
4310 The Read and Write functions must not be overloaded subprograms.  If necessary
4311 renamings can be supplied to meet this requirement.
4312 The usage of this attribute is best illustrated by a simple example, taken
4313 from the GNAT implementation of package Ada.Strings.Unbounded:
4314
4315 @smallexample @c ada
4316 function To_Unbounded (S : String)
4317            return Unbounded_String
4318   renames To_Unbounded_String;
4319
4320 pragma Stream_Convert
4321   (Unbounded_String, To_Unbounded, To_String);
4322 @end smallexample
4323
4324 @noindent
4325 The specifications of the referenced functions, as given in the Ada
4326 Reference Manual are:
4327
4328 @smallexample @c ada
4329 function To_Unbounded_String (Source : String)
4330   return Unbounded_String;
4331
4332 function To_String (Source : Unbounded_String)
4333   return String;
4334 @end smallexample
4335
4336 @noindent
4337 The effect is that if the value of an unbounded string is written to a
4338 stream, then the representation of the item in the stream is in the same
4339 format used for @code{Standard.String}, and this same representation is
4340 expected when a value of this type is read from the stream.
4341
4342 @node Pragma Style_Checks
4343 @unnumberedsec Pragma Style_Checks
4344 @findex Style_Checks
4345 @noindent
4346 Syntax:
4347
4348 @smallexample @c ada
4349 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
4350                      On | Off [, LOCAL_NAME]);
4351 @end smallexample
4352
4353 @noindent
4354 This pragma is used in conjunction with compiler switches to control the
4355 built in style checking provided by GNAT@.  The compiler switches, if set,
4356 provide an initial setting for the switches, and this pragma may be used
4357 to modify these settings, or the settings may be provided entirely by
4358 the use of the pragma.  This pragma can be used anywhere that a pragma
4359 is legal, including use as a configuration pragma (including use in
4360 the @file{gnat.adc} file).
4361
4362 The form with a string literal specifies which style options are to be
4363 activated.  These are additive, so they apply in addition to any previously
4364 set style check options.  The codes for the options are the same as those
4365 used in the @option{-gnaty} switch to @command{gcc} or @command{gnatmake}.
4366 For example the following two methods can be used to enable
4367 layout checking:
4368
4369 @itemize @bullet
4370 @item
4371 @smallexample @c ada
4372 pragma Style_Checks ("l");
4373 @end smallexample
4374
4375 @item
4376 @smallexample
4377 gcc -c -gnatyl @dots{}
4378 @end smallexample
4379 @end itemize
4380
4381 @noindent
4382 The form ALL_CHECKS activates all standard checks (its use is equivalent
4383 to the use of the @code{gnaty} switch with no options.  @xref{Top,
4384 @value{EDITION} User's Guide, About This Guide, gnat_ugn,
4385 @value{EDITION} User's Guide}, for details.
4386
4387 The forms with @code{Off} and @code{On}
4388 can be used to temporarily disable style checks
4389 as shown in the following example:
4390
4391 @smallexample @c ada
4392 @iftex
4393 @leftskip=0cm
4394 @end iftex
4395 pragma Style_Checks ("k"); -- requires keywords in lower case
4396 pragma Style_Checks (Off); -- turn off style checks
4397 NULL;                      -- this will not generate an error message
4398 pragma Style_Checks (On);  -- turn style checks back on
4399 NULL;                      -- this will generate an error message
4400 @end smallexample
4401
4402 @noindent
4403 Finally the two argument form is allowed only if the first argument is
4404 @code{On} or @code{Off}.  The effect is to turn of semantic style checks
4405 for the specified entity, as shown in the following example:
4406
4407 @smallexample @c ada
4408 @iftex
4409 @leftskip=0cm
4410 @end iftex
4411 pragma Style_Checks ("r"); -- require consistency of identifier casing
4412 Arg : Integer;
4413 Rf1 : Integer := ARG;      -- incorrect, wrong case
4414 pragma Style_Checks (Off, Arg);
4415 Rf2 : Integer := ARG;      -- OK, no error
4416 @end smallexample
4417
4418 @node Pragma Subtitle
4419 @unnumberedsec Pragma Subtitle
4420 @findex Subtitle
4421 @noindent
4422 Syntax:
4423
4424 @smallexample @c ada
4425 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
4426 @end smallexample
4427
4428 @noindent
4429 This pragma is recognized for compatibility with other Ada compilers
4430 but is ignored by GNAT@.
4431
4432 @node Pragma Suppress
4433 @unnumberedsec Pragma Suppress
4434 @findex Suppress
4435 @noindent
4436 Syntax:
4437
4438 @smallexample @c ada
4439 pragma Suppress (Identifier [, [On =>] Name]);
4440 @end smallexample
4441
4442 @noindent
4443 This is a standard pragma, and supports all the check names required in
4444 the RM. It is included here because GNAT recognizes one additional check
4445 name: @code{Alignment_Check} which can be used to suppress alignment checks
4446 on addresses used in address clauses. Such checks can also be suppressed
4447 by suppressing range checks, but the specific use of @code{Alignment_Check}
4448 allows suppression of alignment checks without suppressing other range checks.
4449
4450 Note that pragma Suppress gives the compiler permission to omit
4451 checks, but does not require the compiler to omit checks. The compiler
4452 will generate checks if they are essentially free, even when they are
4453 suppressed. In particular, if the compiler can prove that a certain
4454 check will necessarily fail, it will generate code to do an
4455 unconditional ``raise'', even if checks are suppressed. The compiler
4456 warns in this case.
4457
4458 Of course, run-time checks are omitted whenever the compiler can prove
4459 that they will not fail, whether or not checks are suppressed.
4460
4461 @node Pragma Suppress_All
4462 @unnumberedsec Pragma Suppress_All
4463 @findex Suppress_All
4464 @noindent
4465 Syntax:
4466
4467 @smallexample @c ada
4468 pragma Suppress_All;
4469 @end smallexample
4470
4471 @noindent
4472 This pragma can only appear immediately following a compilation
4473 unit.  The effect is to apply @code{Suppress (All_Checks)} to the unit
4474 which it follows.  This pragma is implemented for compatibility with DEC
4475 Ada 83 usage.  The use of pragma @code{Suppress (All_Checks)} as a normal
4476 configuration pragma is the preferred usage in GNAT@.
4477
4478 @node Pragma Suppress_Exception_Locations
4479 @unnumberedsec Pragma Suppress_Exception_Locations
4480 @findex Suppress_Exception_Locations
4481 @noindent
4482 Syntax:
4483
4484 @smallexample @c ada
4485 pragma Suppress_Exception_Locations;
4486 @end smallexample
4487
4488 @noindent
4489 In normal mode, a raise statement for an exception by default generates
4490 an exception message giving the file name and line number for the location
4491 of the raise. This is useful for debugging and logging purposes, but this
4492 entails extra space for the strings for the messages. The configuration
4493 pragma @code{Suppress_Exception_Locations} can be used to suppress the
4494 generation of these strings, with the result that space is saved, but the
4495 exception message for such raises is null. This configuration pragma may
4496 appear in a global configuration pragma file, or in a specific unit as
4497 usual. It is not required that this pragma be used consistently within
4498 a partition, so it is fine to have some units within a partition compiled
4499 with this pragma and others compiled in normal mode without it.
4500
4501 @node Pragma Suppress_Initialization
4502 @unnumberedsec Pragma Suppress_Initialization
4503 @findex Suppress_Initialization
4504 @cindex Suppressing initialization
4505 @cindex Initialization, suppression of
4506 @noindent
4507 Syntax:
4508
4509 @smallexample @c ada
4510 pragma Suppress_Initialization ([Entity =>] type_Name);
4511 @end smallexample
4512
4513 @noindent
4514 This pragma suppresses any implicit or explicit initialization
4515 associated with the given type name for all variables of this type.
4516
4517 @node Pragma Task_Info
4518 @unnumberedsec Pragma Task_Info
4519 @findex Task_Info
4520 @noindent
4521 Syntax
4522
4523 @smallexample @c ada
4524 pragma Task_Info (EXPRESSION);
4525 @end smallexample
4526
4527 @noindent
4528 This pragma appears within a task definition (like pragma
4529 @code{Priority}) and applies to the task in which it appears.  The
4530 argument must be of type @code{System.Task_Info.Task_Info_Type}.
4531 The @code{Task_Info} pragma provides system dependent control over
4532 aspects of tasking implementation, for example, the ability to map
4533 tasks to specific processors.  For details on the facilities available
4534 for the version of GNAT that you are using, see the documentation
4535 in the spec of package System.Task_Info in the runtime
4536 library.
4537
4538 @node Pragma Task_Name
4539 @unnumberedsec Pragma Task_Name
4540 @findex Task_Name
4541 @noindent
4542 Syntax
4543
4544 @smallexample @c ada
4545 pragma Task_Name (string_EXPRESSION);
4546 @end smallexample
4547
4548 @noindent
4549 This pragma appears within a task definition (like pragma
4550 @code{Priority}) and applies to the task in which it appears.  The
4551 argument must be of type String, and provides a name to be used for
4552 the task instance when the task is created.  Note that this expression
4553 is not required to be static, and in particular, it can contain
4554 references to task discriminants.  This facility can be used to
4555 provide different names for different tasks as they are created,
4556 as illustrated in the example below.
4557
4558 The task name is recorded internally in the run-time structures
4559 and is accessible to tools like the debugger.  In addition the
4560 routine @code{Ada.Task_Identification.Image} will return this
4561 string, with a unique task address appended.
4562
4563 @smallexample @c ada
4564 --  Example of the use of pragma Task_Name
4565
4566 with Ada.Task_Identification;
4567 use Ada.Task_Identification;
4568 with Text_IO; use Text_IO;
4569 procedure t3 is
4570
4571    type Astring is access String;
4572
4573    task type Task_Typ (Name : access String) is
4574       pragma Task_Name (Name.all);
4575    end Task_Typ;
4576
4577    task body Task_Typ is
4578       Nam : constant String := Image (Current_Task);
4579    begin
4580       Put_Line ("-->" & Nam (1 .. 14) & "<--");
4581    end Task_Typ;
4582
4583    type Ptr_Task is access Task_Typ;
4584    Task_Var : Ptr_Task;
4585
4586 begin
4587    Task_Var :=
4588      new Task_Typ (new String'("This is task 1"));
4589    Task_Var :=
4590      new Task_Typ (new String'("This is task 2"));
4591 end;
4592 @end smallexample
4593
4594 @node Pragma Task_Storage
4595 @unnumberedsec Pragma Task_Storage
4596 @findex Task_Storage
4597 Syntax:
4598
4599 @smallexample @c ada
4600 pragma Task_Storage (
4601   [Task_Type =>] LOCAL_NAME,
4602   [Top_Guard =>] static_integer_EXPRESSION);
4603 @end smallexample
4604
4605 @noindent
4606 This pragma specifies the length of the guard area for tasks.  The guard
4607 area is an additional storage area allocated to a task.  A value of zero
4608 means that either no guard area is created or a minimal guard area is
4609 created, depending on the target.  This pragma can appear anywhere a
4610 @code{Storage_Size} attribute definition clause is allowed for a task
4611 type.
4612
4613 @node Pragma Time_Slice
4614 @unnumberedsec Pragma Time_Slice
4615 @findex Time_Slice
4616 @noindent
4617 Syntax:
4618
4619 @smallexample @c ada
4620 pragma Time_Slice (static_duration_EXPRESSION);
4621 @end smallexample
4622
4623 @noindent
4624 For implementations of GNAT on operating systems where it is possible
4625 to supply a time slice value, this pragma may be used for this purpose.
4626 It is ignored if it is used in a system that does not allow this control,
4627 or if it appears in other than the main program unit.
4628 @cindex OpenVMS
4629 Note that the effect of this pragma is identical to the effect of the
4630 DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
4631
4632 @node Pragma Title
4633 @unnumberedsec Pragma Title
4634 @findex Title
4635 @noindent
4636 Syntax:
4637
4638 @smallexample @c ada
4639 pragma Title (TITLING_OPTION [, TITLING OPTION]);
4640
4641 TITLING_OPTION ::=
4642   [Title    =>] STRING_LITERAL,
4643 | [Subtitle =>] STRING_LITERAL
4644 @end smallexample
4645
4646 @noindent
4647 Syntax checked but otherwise ignored by GNAT@.  This is a listing control
4648 pragma used in DEC Ada 83 implementations to provide a title and/or
4649 subtitle for the program listing.  The program listing generated by GNAT
4650 does not have titles or subtitles.
4651
4652 Unlike other pragmas, the full flexibility of named notation is allowed
4653 for this pragma, i.e.@: the parameters may be given in any order if named
4654 notation is used, and named and positional notation can be mixed
4655 following the normal rules for procedure calls in Ada.
4656
4657 @node Pragma Unchecked_Union
4658 @unnumberedsec Pragma Unchecked_Union
4659 @cindex Unions in C
4660 @findex Unchecked_Union
4661 @noindent
4662 Syntax:
4663
4664 @smallexample @c ada
4665 pragma Unchecked_Union (first_subtype_LOCAL_NAME);
4666 @end smallexample
4667
4668 @noindent
4669 This pragma is used to specify a representation of a record type that is
4670 equivalent to a C union. It was introduced as a GNAT implementation defined
4671 pragma in the GNAT Ada 95 mode. Ada 2005 includes an extended version of this
4672 pragma, making it language defined, and GNAT fully implements this extended
4673 version in all language modes (Ada 83, Ada 95, and Ada 2005). For full
4674 details, consult the Ada 2005 Reference Manual, section B.3.3.
4675
4676 @node Pragma Unimplemented_Unit
4677 @unnumberedsec Pragma Unimplemented_Unit
4678 @findex Unimplemented_Unit
4679 @noindent
4680 Syntax:
4681
4682 @smallexample @c ada
4683 pragma Unimplemented_Unit;
4684 @end smallexample
4685
4686 @noindent
4687 If this pragma occurs in a unit that is processed by the compiler, GNAT
4688 aborts with the message @samp{@var{xxx} not implemented}, where
4689 @var{xxx} is the name of the current compilation unit.  This pragma is
4690 intended to allow the compiler to handle unimplemented library units in
4691 a clean manner.
4692
4693 The abort only happens if code is being generated.  Thus you can use
4694 specs of unimplemented packages in syntax or semantic checking mode.
4695
4696 @node Pragma Universal_Aliasing
4697 @unnumberedsec Pragma Universal_Aliasing
4698 @findex Universal_Aliasing
4699 @noindent
4700 Syntax:
4701
4702 @smallexample @c ada
4703 pragma Universal_Aliasing [([Entity =>] type_LOCAL_NAME)];
4704 @end smallexample
4705
4706 @noindent
4707 @var{type_LOCAL_NAME} must refer to a type declaration in the current
4708 declarative part.  The effect is to inhibit strict type-based aliasing
4709 optimization for the given type.  In other words, the effect is as though
4710 access types designating this type were subject to pragma No_Strict_Aliasing.
4711 For a detailed description of the strict aliasing optimization, and the
4712 situations in which it must be suppressed, @xref{Optimization and Strict
4713 Aliasing,,, gnat_ugn, @value{EDITION} User's Guide}.
4714
4715 @node Pragma Universal_Data
4716 @unnumberedsec Pragma Universal_Data
4717 @findex Universal_Data
4718 @noindent
4719 Syntax:
4720
4721 @smallexample @c ada
4722 pragma Universal_Data [(library_unit_Name)];
4723 @end smallexample
4724
4725 @noindent
4726 This pragma is supported only for the AAMP target and is ignored for
4727 other targets. The pragma specifies that all library-level objects
4728 (Counter 0 data) associated with the library unit are to be accessed
4729 and updated using universal addressing (24-bit addresses for AAMP5)
4730 rather than the default of 16-bit Data Environment (DENV) addressing.
4731 Use of this pragma will generally result in less efficient code for
4732 references to global data associated with the library unit, but
4733 allows such data to be located anywhere in memory. This pragma is
4734 a library unit pragma, but can also be used as a configuration pragma
4735 (including use in the @file{gnat.adc} file). The functionality
4736 of this pragma is also available by applying the -univ switch on the
4737 compilations of units where universal addressing of the data is desired.
4738
4739 @node Pragma Unmodified
4740 @unnumberedsec Pragma Unmodified
4741 @findex Unmodified
4742 @cindex Warnings, unmodified
4743 @noindent
4744 Syntax:
4745
4746 @smallexample @c ada
4747 pragma Unmodified (LOCAL_NAME @{, LOCAL_NAME@});
4748 @end smallexample
4749
4750 @noindent
4751 This pragma signals that the assignable entities (variables,
4752 @code{out} parameters, @code{in out} parameters) whose names are listed are
4753 deliberately not assigned in the current source unit. This
4754 suppresses warnings about the
4755 entities being referenced but not assigned, and in addition a warning will be
4756 generated if one of these entities is in fact assigned in the
4757 same unit as the pragma (or in the corresponding body, or one
4758 of its subunits).
4759
4760 This is particularly useful for clearly signaling that a particular
4761 parameter is not modified, even though the spec suggests that it might
4762 be.
4763
4764 @node Pragma Unreferenced
4765 @unnumberedsec Pragma Unreferenced
4766 @findex Unreferenced
4767 @cindex Warnings, unreferenced
4768 @noindent
4769 Syntax:
4770
4771 @smallexample @c ada
4772 pragma Unreferenced (LOCAL_NAME @{, LOCAL_NAME@});
4773 pragma Unreferenced (library_unit_NAME @{, library_unit_NAME@});
4774 @end smallexample
4775
4776 @noindent
4777 This pragma signals that the entities whose names are listed are
4778 deliberately not referenced in the current source unit. This
4779 suppresses warnings about the
4780 entities being unreferenced, and in addition a warning will be
4781 generated if one of these entities is in fact referenced in the
4782 same unit as the pragma (or in the corresponding body, or one
4783 of its subunits).
4784
4785 This is particularly useful for clearly signaling that a particular
4786 parameter is not referenced in some particular subprogram implementation
4787 and that this is deliberate. It can also be useful in the case of
4788 objects declared only for their initialization or finalization side
4789 effects.
4790
4791 If @code{LOCAL_NAME} identifies more than one matching homonym in the
4792 current scope, then the entity most recently declared is the one to which
4793 the pragma applies. Note that in the case of accept formals, the pragma
4794 Unreferenced may appear immediately after the keyword @code{do} which
4795 allows the indication of whether or not accept formals are referenced
4796 or not to be given individually for each accept statement.
4797
4798 The left hand side of an assignment does not count as a reference for the
4799 purpose of this pragma. Thus it is fine to assign to an entity for which
4800 pragma Unreferenced is given.
4801
4802 Note that if a warning is desired for all calls to a given subprogram,
4803 regardless of whether they occur in the same unit as the subprogram
4804 declaration, then this pragma should not be used (calls from another
4805 unit would not be flagged); pragma Obsolescent can be used instead
4806 for this purpose, see @xref{Pragma Obsolescent}.
4807
4808 The second form of pragma @code{Unreferenced} is used within a context
4809 clause. In this case the arguments must be unit names of units previously
4810 mentioned in @code{with} clauses (similar to the usage of pragma
4811 @code{Elaborate_All}. The effect is to suppress warnings about unreferenced
4812 units and unreferenced entities within these units.
4813
4814 @node Pragma Unreferenced_Objects
4815 @unnumberedsec Pragma Unreferenced_Objects
4816 @findex Unreferenced_Objects
4817 @cindex Warnings, unreferenced
4818 @noindent
4819 Syntax:
4820
4821 @smallexample @c ada
4822 pragma Unreferenced_Objects (local_subtype_NAME @{, local_subtype_NAME@});
4823 @end smallexample
4824
4825 @noindent
4826 This pragma signals that for the types or subtypes whose names are
4827 listed, objects which are declared with one of these types or subtypes may
4828 not be referenced, and if no references appear, no warnings are given.
4829
4830 This is particularly useful for objects which are declared solely for their
4831 initialization and finalization effect. Such variables are sometimes referred
4832 to as RAII variables (Resource Acquisition Is Initialization). Using this
4833 pragma on the relevant type (most typically a limited controlled type), the
4834 compiler will automatically suppress unwanted warnings about these variables
4835 not being referenced.
4836
4837 @node Pragma Unreserve_All_Interrupts
4838 @unnumberedsec Pragma Unreserve_All_Interrupts
4839 @findex Unreserve_All_Interrupts
4840 @noindent
4841 Syntax:
4842
4843 @smallexample @c ada
4844 pragma Unreserve_All_Interrupts;
4845 @end smallexample
4846
4847 @noindent
4848 Normally certain interrupts are reserved to the implementation.  Any attempt
4849 to attach an interrupt causes Program_Error to be raised, as described in
4850 RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
4851 many systems for a @kbd{Ctrl-C} interrupt.  Normally this interrupt is
4852 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
4853 interrupt execution.
4854
4855 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
4856 a program, then all such interrupts are unreserved.  This allows the
4857 program to handle these interrupts, but disables their standard
4858 functions.  For example, if this pragma is used, then pressing
4859 @kbd{Ctrl-C} will not automatically interrupt execution.  However,
4860 a program can then handle the @code{SIGINT} interrupt as it chooses.
4861
4862 For a full list of the interrupts handled in a specific implementation,
4863 see the source code for the spec of @code{Ada.Interrupts.Names} in
4864 file @file{a-intnam.ads}.  This is a target dependent file that contains the
4865 list of interrupts recognized for a given target.  The documentation in
4866 this file also specifies what interrupts are affected by the use of
4867 the @code{Unreserve_All_Interrupts} pragma.
4868
4869 For a more general facility for controlling what interrupts can be
4870 handled, see pragma @code{Interrupt_State}, which subsumes the functionality
4871 of the @code{Unreserve_All_Interrupts} pragma.
4872
4873 @node Pragma Unsuppress
4874 @unnumberedsec Pragma Unsuppress
4875 @findex Unsuppress
4876 @noindent
4877 Syntax:
4878
4879 @smallexample @c ada
4880 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
4881 @end smallexample
4882
4883 @noindent
4884 This pragma undoes the effect of a previous pragma @code{Suppress}.  If
4885 there is no corresponding pragma @code{Suppress} in effect, it has no
4886 effect.  The range of the effect is the same as for pragma
4887 @code{Suppress}.  The meaning of the arguments is identical to that used
4888 in pragma @code{Suppress}.
4889
4890 One important application is to ensure that checks are on in cases where
4891 code depends on the checks for its correct functioning, so that the code
4892 will compile correctly even if the compiler switches are set to suppress
4893 checks.
4894
4895 @node Pragma Use_VADS_Size
4896 @unnumberedsec Pragma Use_VADS_Size
4897 @cindex @code{Size}, VADS compatibility
4898 @findex Use_VADS_Size
4899 @noindent
4900 Syntax:
4901
4902 @smallexample @c ada
4903 pragma Use_VADS_Size;
4904 @end smallexample
4905
4906 @noindent
4907 This is a configuration pragma.  In a unit to which it applies, any use
4908 of the 'Size attribute is automatically interpreted as a use of the
4909 'VADS_Size attribute.  Note that this may result in incorrect semantic
4910 processing of valid Ada 95 or Ada 2005 programs.  This is intended to aid in
4911 the handling of existing code which depends on the interpretation of Size
4912 as implemented in the VADS compiler.  See description of the VADS_Size
4913 attribute for further details.
4914
4915 @node Pragma Validity_Checks
4916 @unnumberedsec Pragma Validity_Checks
4917 @findex Validity_Checks
4918 @noindent
4919 Syntax:
4920
4921 @smallexample @c ada
4922 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
4923 @end smallexample
4924
4925 @noindent
4926 This pragma is used in conjunction with compiler switches to control the
4927 built-in validity checking provided by GNAT@.  The compiler switches, if set
4928 provide an initial setting for the switches, and this pragma may be used
4929 to modify these settings, or the settings may be provided entirely by
4930 the use of the pragma.  This pragma can be used anywhere that a pragma
4931 is legal, including use as a configuration pragma (including use in
4932 the @file{gnat.adc} file).
4933
4934 The form with a string literal specifies which validity options are to be
4935 activated.  The validity checks are first set to include only the default
4936 reference manual settings, and then a string of letters in the string
4937 specifies the exact set of options required.  The form of this string
4938 is exactly as described for the @option{-gnatVx} compiler switch (see the
4939 GNAT users guide for details).  For example the following two methods
4940 can be used to enable validity checking for mode @code{in} and
4941 @code{in out} subprogram parameters:
4942
4943 @itemize @bullet
4944 @item
4945 @smallexample @c ada
4946 pragma Validity_Checks ("im");
4947 @end smallexample
4948
4949 @item
4950 @smallexample
4951 gcc -c -gnatVim @dots{}
4952 @end smallexample
4953 @end itemize
4954
4955 @noindent
4956 The form ALL_CHECKS activates all standard checks (its use is equivalent
4957 to the use of the @code{gnatva} switch.
4958
4959 The forms with @code{Off} and @code{On}
4960 can be used to temporarily disable validity checks
4961 as shown in the following example:
4962
4963 @smallexample @c ada
4964 @iftex
4965 @leftskip=0cm
4966 @end iftex
4967 pragma Validity_Checks ("c"); -- validity checks for copies
4968 pragma Validity_Checks (Off); -- turn off validity checks
4969 A := B;                       -- B will not be validity checked
4970 pragma Validity_Checks (On);  -- turn validity checks back on
4971 A := C;                       -- C will be validity checked
4972 @end smallexample
4973
4974 @node Pragma Volatile
4975 @unnumberedsec Pragma Volatile
4976 @findex Volatile
4977 @noindent
4978 Syntax:
4979
4980 @smallexample @c ada
4981 pragma Volatile (LOCAL_NAME);
4982 @end smallexample
4983
4984 @noindent
4985 This pragma is defined by the Ada Reference Manual, and the GNAT
4986 implementation is fully conformant with this definition.  The reason it
4987 is mentioned in this section is that a pragma of the same name was supplied
4988 in some Ada 83 compilers, including DEC Ada 83.  The Ada 95 / Ada 2005
4989 implementation of pragma Volatile is upwards compatible with the
4990 implementation in DEC Ada 83.
4991
4992 @node Pragma Warnings
4993 @unnumberedsec Pragma Warnings
4994 @findex Warnings
4995 @noindent
4996 Syntax:
4997
4998 @smallexample @c ada
4999 pragma Warnings (On | Off);
5000 pragma Warnings (On | Off, LOCAL_NAME);
5001 pragma Warnings (static_string_EXPRESSION);
5002 pragma Warnings (On | Off, static_string_EXPRESSION);
5003 @end smallexample
5004
5005 @noindent
5006 Normally warnings are enabled, with the output being controlled by
5007 the command line switch.  Warnings (@code{Off}) turns off generation of
5008 warnings until a Warnings (@code{On}) is encountered or the end of the
5009 current unit.  If generation of warnings is turned off using this
5010 pragma, then no warning messages are output, regardless of the
5011 setting of the command line switches.
5012
5013 The form with a single argument may be used as a configuration pragma.
5014
5015 If the @var{LOCAL_NAME} parameter is present, warnings are suppressed for
5016 the specified entity.  This suppression is effective from the point where
5017 it occurs till the end of the extended scope of the variable (similar to
5018 the scope of @code{Suppress}).
5019
5020 The form with a single static_string_EXPRESSION argument provides more precise
5021 control over which warnings are active. The string is a list of letters
5022 specifying which warnings are to be activated and which deactivated. The
5023 code for these letters is the same as the string used in the command
5024 line switch controlling warnings. The following is a brief summary. For
5025 full details see @ref{Warning Message Control,,, gnat_ugn, @value{EDITION}
5026 User's Guide}.
5027
5028 @smallexample
5029 a    turn on all optional warnings (except d h l .o)
5030 A    turn off all optional warnings
5031 .a*  turn on warnings for failing assertions
5032 .A   turn off warnings for failing assertions
5033 b    turn on warnings for bad fixed value (not multiple of small)
5034 B*   turn off warnings for bad fixed value (not multiple of small)
5035 c    turn on warnings for constant conditional
5036 C*   turn off warnings for constant conditional
5037 .c   turn on warnings for unrepped components
5038 .C*  turn off warnings for unrepped components
5039 d    turn on warnings for implicit dereference
5040 D*   turn off warnings for implicit dereference
5041 e    treat all warnings as errors
5042 f    turn on warnings for unreferenced formal
5043 F*   turn off warnings for unreferenced formal
5044 g*   turn on warnings for unrecognized pragma
5045 G    turn off warnings for unrecognized pragma
5046 h    turn on warnings for hiding variable
5047 H*   turn off warnings for hiding variable
5048 i*   turn on warnings for implementation unit
5049 I    turn off warnings for implementation unit
5050 j    turn on warnings for obsolescent (annex J) feature
5051 J*   turn off warnings for obsolescent (annex J) feature
5052 k    turn on warnings on constant variable
5053 K*   turn off warnings on constant variable
5054 l    turn on warnings for missing elaboration pragma
5055 L*   turn off warnings for missing elaboration pragma
5056 m    turn on warnings for variable assigned but not read
5057 M*   turn off warnings for variable assigned but not read
5058 n*   normal warning mode (cancels -gnatws/-gnatwe)
5059 o*   turn on warnings for address clause overlay
5060 O    turn off warnings for address clause overlay
5061 .o   turn on warnings for out parameters assigned but not read
5062 .O*  turn off warnings for out parameters assigned but not read
5063 p    turn on warnings for ineffective pragma Inline in frontend
5064 P*   turn off warnings for ineffective pragma Inline in frontend
5065 q*   turn on warnings for questionable missing parentheses
5066 Q    turn off warnings for questionable missing parentheses
5067 r    turn on warnings for redundant construct
5068 R*   turn off warnings for redundant construct
5069 .r   turn on warnings for object renaming function
5070 .R*  turn off warnings for object renaming function
5071 s    suppress all warnings
5072 t    turn on warnings for tracking deleted code
5073 T*   turn off warnings for tracking deleted code
5074 u    turn on warnings for unused entity
5075 U*   turn off warnings for unused entity
5076 v*   turn on warnings for unassigned variable
5077 V    turn off warnings for unassigned variable
5078 w*   turn on warnings for wrong low bound assumption
5079 W    turn off warnings for wrong low bound assumption
5080 x*   turn on warnings for export/import
5081 X    turn off warnings for export/import
5082 .x   turn on warnings for non-local exceptions
5083 .X*  turn off warnings for non-local exceptions
5084 y*   turn on warnings for Ada 2005 incompatibility
5085 Y    turn off warnings for Ada 2005 incompatibility
5086 z*   turn on convention/size/align warnings for unchecked conversion
5087 Z    turn off convention/size/align warnings for unchecked conversion
5088 *    indicates default in above list
5089 @end smallexample
5090
5091 @noindent
5092 The specified warnings will be in effect until the end of the program
5093 or another pragma Warnings is encountered. The effect of the pragma is
5094 cumulative. Initially the set of warnings is the standard default set
5095 as possibly modified by compiler switches. Then each pragma Warning
5096 modifies this set of warnings as specified. This form of the pragma may
5097 also be used as a configuration pragma.
5098
5099 The fourth form, with an On|Off parameter and a string, is used to
5100 control individual messages, based on their text. The string argument
5101 is a pattern that is used to match against the text of individual
5102 warning messages (not including the initial "warnings: " tag).
5103
5104 The pattern may contain asterisks which match zero or more characters in
5105 the message. For example, you can use
5106 @code{pragma Warnings (Off, "*bits of*unused")} to suppress the warning
5107 message @code{warning: 960 bits of "a" unused}. No other regular
5108 expression notations are permitted. All characters other than asterisk in
5109 these three specific cases are treated as literal characters in the match.
5110
5111 There are two ways to use this pragma. The OFF form can be used as a
5112 configuration pragma. The effect is to suppress all warnings (if any)
5113 that match the pattern string throughout the compilation.
5114
5115 The second usage is to suppress a warning locally, and in this case, two
5116 pragmas must appear in sequence:
5117
5118 @smallexample @c ada
5119 pragma Warnings (Off, Pattern);
5120 @dots{} code where given warning is to be suppressed
5121 pragma Warnings (On, Pattern);
5122 @end smallexample
5123
5124 @noindent
5125 In this usage, the pattern string must match in the Off and On pragmas,
5126 and at least one matching warning must be suppressed.
5127
5128 @node Pragma Weak_External
5129 @unnumberedsec Pragma Weak_External
5130 @findex Weak_External
5131 @noindent
5132 Syntax:
5133
5134 @smallexample @c ada
5135 pragma Weak_External ([Entity =>] LOCAL_NAME);
5136 @end smallexample
5137
5138 @noindent
5139 @var{LOCAL_NAME} must refer to an object that is declared at the library
5140 level. This pragma specifies that the given entity should be marked as a
5141 weak symbol for the linker. It is equivalent to @code{__attribute__((weak))}
5142 in GNU C and causes @var{LOCAL_NAME} to be emitted as a weak symbol instead
5143 of a regular symbol, that is to say a symbol that does not have to be
5144 resolved by the linker if used in conjunction with a pragma Import.
5145
5146 When a weak symbol is not resolved by the linker, its address is set to
5147 zero. This is useful in writing interfaces to external modules that may
5148 or may not be linked in the final executable, for example depending on
5149 configuration settings.
5150
5151 If a program references at run time an entity to which this pragma has been
5152 applied, and the corresponding symbol was not resolved at link time, then
5153 the execution of the program is erroneous. It is not erroneous to take the
5154 Address of such an entity, for example to guard potential references,
5155 as shown in the example below.
5156
5157 Some file formats do not support weak symbols so not all target machines
5158 support this pragma.
5159
5160 @smallexample @c ada
5161 --  Example of the use of pragma Weak_External
5162
5163 package External_Module is
5164   key : Integer;
5165   pragma Import (C, key);
5166   pragma Weak_External (key);
5167   function Present return boolean;
5168 end External_Module;
5169
5170 with System; use System;
5171 package body External_Module is
5172   function Present return boolean is
5173   begin
5174     return key'Address /= System.Null_Address;
5175   end Present;
5176 end External_Module;
5177 @end smallexample
5178
5179 @node Pragma Wide_Character_Encoding
5180 @unnumberedsec Pragma Wide_Character_Encoding
5181 @findex Wide_Character_Encoding
5182 @noindent
5183 Syntax:
5184
5185 @smallexample @c ada
5186 pragma Wide_Character_Encoding (IDENTIFIER | CHARACTER_LITERAL);
5187 @end smallexample
5188
5189 @noindent
5190 This pragma specifies the wide character encoding to be used in program
5191 source text appearing subsequently. It is a configuration pragma, but may
5192 also be used at any point that a pragma is allowed, and it is permissible
5193 to have more than one such pragma in a file, allowing multiple encodings
5194 to appear within the same file.
5195
5196 The argument can be an identifier or a character literal. In the identifier
5197 case, it is one of @code{HEX}, @code{UPPER}, @code{SHIFT_JIS},
5198 @code{EUC}, @code{UTF8}, or @code{BRACKETS}. In the character literal
5199 case it is correspondingly one of the characters @samp{h}, @samp{u},
5200 @samp{s}, @samp{e}, @samp{8}, or @samp{b}.
5201
5202 Note that when the pragma is used within a file, it affects only the
5203 encoding within that file, and does not affect withed units, specs,
5204 or subunits.
5205
5206 @node Implementation Defined Attributes
5207 @chapter Implementation Defined Attributes
5208 Ada defines (throughout the Ada reference manual,
5209 summarized in Annex K),
5210 a set of attributes that provide useful additional functionality in all
5211 areas of the language.  These language defined attributes are implemented
5212 in GNAT and work as described in the Ada Reference Manual.
5213
5214 In addition, Ada allows implementations to define additional
5215 attributes whose meaning is defined by the implementation.  GNAT provides
5216 a number of these implementation-dependent attributes which can be used
5217 to extend and enhance the functionality of the compiler.  This section of
5218 the GNAT reference manual describes these additional attributes.
5219
5220 Note that any program using these attributes may not be portable to
5221 other compilers (although GNAT implements this set of attributes on all
5222 platforms).  Therefore if portability to other compilers is an important
5223 consideration, you should minimize the use of these attributes.
5224
5225 @menu
5226 * Abort_Signal::
5227 * Address_Size::
5228 * Asm_Input::
5229 * Asm_Output::
5230 * AST_Entry::
5231 * Bit::
5232 * Bit_Position::
5233 * Code_Address::
5234 * Default_Bit_Order::
5235 * Elaborated::
5236 * Elab_Body::
5237 * Elab_Spec::
5238 * Emax::
5239 * Enabled::
5240 * Enum_Rep::
5241 * Enum_Val::
5242 * Epsilon::
5243 * Fixed_Value::
5244 * Has_Access_Values::
5245 * Has_Discriminants::
5246 * Img::
5247 * Integer_Value::
5248 * Invalid_Value::
5249 * Large::
5250 * Machine_Size::
5251 * Mantissa::
5252 * Max_Interrupt_Priority::
5253 * Max_Priority::
5254 * Maximum_Alignment::
5255 * Mechanism_Code::
5256 * Null_Parameter::
5257 * Object_Size::
5258 * Old::
5259 * Passed_By_Reference::
5260 * Pool_Address::
5261 * Range_Length::
5262 * Safe_Emax::
5263 * Safe_Large::
5264 * Small::
5265 * Storage_Unit::
5266 * Stub_Type::
5267 * Target_Name::
5268 * Tick::
5269 * To_Address::
5270 * Type_Class::
5271 * UET_Address::
5272 * Unconstrained_Array::
5273 * Universal_Literal_String::
5274 * Unrestricted_Access::
5275 * VADS_Size::
5276 * Value_Size::
5277 * Wchar_T_Size::
5278 * Word_Size::
5279 @end menu
5280
5281 @node Abort_Signal
5282 @unnumberedsec Abort_Signal
5283 @findex Abort_Signal
5284 @noindent
5285 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
5286 prefix) provides the entity for the special exception used to signal
5287 task abort or asynchronous transfer of control.  Normally this attribute
5288 should only be used in the tasking runtime (it is highly peculiar, and
5289 completely outside the normal semantics of Ada, for a user program to
5290 intercept the abort exception).
5291
5292 @node Address_Size
5293 @unnumberedsec Address_Size
5294 @cindex Size of @code{Address}
5295 @findex Address_Size
5296 @noindent
5297 @code{Standard'Address_Size} (@code{Standard} is the only allowed
5298 prefix) is a static constant giving the number of bits in an
5299 @code{Address}. It is the same value as System.Address'Size,
5300 but has the advantage of being static, while a direct
5301 reference to System.Address'Size is non-static because Address
5302 is a private type.
5303
5304 @node Asm_Input
5305 @unnumberedsec Asm_Input
5306 @findex Asm_Input
5307 @noindent
5308 The @code{Asm_Input} attribute denotes a function that takes two
5309 parameters.  The first is a string, the second is an expression of the
5310 type designated by the prefix.  The first (string) argument is required
5311 to be a static expression, and is the constraint for the parameter,
5312 (e.g.@: what kind of register is required).  The second argument is the
5313 value to be used as the input argument.  The possible values for the
5314 constant are the same as those used in the RTL, and are dependent on
5315 the configuration file used to built the GCC back end.
5316 @ref{Machine Code Insertions}
5317
5318 @node Asm_Output
5319 @unnumberedsec Asm_Output
5320 @findex Asm_Output
5321 @noindent
5322 The @code{Asm_Output} attribute denotes a function that takes two
5323 parameters.  The first is a string, the second is the name of a variable
5324 of the type designated by the attribute prefix.  The first (string)
5325 argument is required to be a static expression and designates the
5326 constraint for the parameter (e.g.@: what kind of register is
5327 required).  The second argument is the variable to be updated with the
5328 result.  The possible values for constraint are the same as those used in
5329 the RTL, and are dependent on the configuration file used to build the
5330 GCC back end.  If there are no output operands, then this argument may
5331 either be omitted, or explicitly given as @code{No_Output_Operands}.
5332 @ref{Machine Code Insertions}
5333
5334 @node AST_Entry
5335 @unnumberedsec AST_Entry
5336 @cindex OpenVMS
5337 @findex AST_Entry
5338 @noindent
5339 This attribute is implemented only in OpenVMS versions of GNAT@.  Applied to
5340 the name of an entry, it yields a value of the predefined type AST_Handler
5341 (declared in the predefined package System, as extended by the use of
5342 pragma @code{Extend_System (Aux_DEC)}).  This value enables the given entry to
5343 be called when an AST occurs.  For further details, refer to the @cite{DEC Ada
5344 Language Reference Manual}, section 9.12a.
5345
5346 @node Bit
5347 @unnumberedsec Bit
5348 @findex Bit
5349 @code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
5350 offset within the storage unit (byte) that contains the first bit of
5351 storage allocated for the object.  The value of this attribute is of the
5352 type @code{Universal_Integer}, and is always a non-negative number not
5353 exceeding the value of @code{System.Storage_Unit}.
5354
5355 For an object that is a variable or a constant allocated in a register,
5356 the value is zero.  (The use of this attribute does not force the
5357 allocation of a variable to memory).
5358
5359 For an object that is a formal parameter, this attribute applies
5360 to either the matching actual parameter or to a copy of the
5361 matching actual parameter.
5362
5363 For an access object the value is zero.  Note that
5364 @code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
5365 designated object.  Similarly for a record component
5366 @code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
5367 @code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
5368 are subject to index checks.
5369
5370 This attribute is designed to be compatible with the DEC Ada 83 definition
5371 and implementation of the @code{Bit} attribute.
5372
5373 @node Bit_Position
5374 @unnumberedsec Bit_Position
5375 @findex Bit_Position
5376 @noindent
5377 @code{@var{R.C}'Bit}, where @var{R} is a record object and C is one
5378 of the fields of the record type, yields the bit
5379 offset within the record contains the first bit of
5380 storage allocated for the object.  The value of this attribute is of the
5381 type @code{Universal_Integer}.  The value depends only on the field
5382 @var{C} and is independent of the alignment of
5383 the containing record @var{R}.
5384
5385 @node Code_Address
5386 @unnumberedsec Code_Address
5387 @findex Code_Address
5388 @cindex Subprogram address
5389 @cindex Address of subprogram code
5390 @noindent
5391 The @code{'Address}
5392 attribute may be applied to subprograms in Ada 95 and Ada 2005, but the
5393 intended effect seems to be to provide
5394 an address value which can be used to call the subprogram by means of
5395 an address clause as in the following example:
5396
5397 @smallexample @c ada
5398 procedure K is @dots{}
5399
5400 procedure L;
5401 for L'Address use K'Address;
5402 pragma Import (Ada, L);
5403 @end smallexample
5404
5405 @noindent
5406 A call to @code{L} is then expected to result in a call to @code{K}@.
5407 In Ada 83, where there were no access-to-subprogram values, this was
5408 a common work-around for getting the effect of an indirect call.
5409 GNAT implements the above use of @code{Address} and the technique
5410 illustrated by the example code works correctly.
5411
5412 However, for some purposes, it is useful to have the address of the start
5413 of the generated code for the subprogram.  On some architectures, this is
5414 not necessarily the same as the @code{Address} value described above.
5415 For example, the @code{Address} value may reference a subprogram
5416 descriptor rather than the subprogram itself.
5417
5418 The @code{'Code_Address} attribute, which can only be applied to
5419 subprogram entities, always returns the address of the start of the
5420 generated code of the specified subprogram, which may or may not be
5421 the same value as is returned by the corresponding @code{'Address}
5422 attribute.
5423
5424 @node Default_Bit_Order
5425 @unnumberedsec Default_Bit_Order
5426 @cindex Big endian
5427 @cindex Little endian
5428 @findex Default_Bit_Order
5429 @noindent
5430 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
5431 permissible prefix), provides the value @code{System.Default_Bit_Order}
5432 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
5433 @code{Low_Order_First}).  This is used to construct the definition of
5434 @code{Default_Bit_Order} in package @code{System}.
5435
5436 @node Elaborated
5437 @unnumberedsec Elaborated
5438 @findex Elaborated
5439 @noindent
5440 The prefix of the @code{'Elaborated} attribute must be a unit name.  The
5441 value is a Boolean which indicates whether or not the given unit has been
5442 elaborated.  This attribute is primarily intended for internal use by the
5443 generated code for dynamic elaboration checking, but it can also be used
5444 in user programs.  The value will always be True once elaboration of all
5445 units has been completed.  An exception is for units which need no
5446 elaboration, the value is always False for such units.
5447
5448 @node Elab_Body
5449 @unnumberedsec Elab_Body
5450 @findex Elab_Body
5451 @noindent
5452 This attribute can only be applied to a program unit name.  It returns
5453 the entity for the corresponding elaboration procedure for elaborating
5454 the body of the referenced unit.  This is used in the main generated
5455 elaboration procedure by the binder and is not normally used in any
5456 other context.  However, there may be specialized situations in which it
5457 is useful to be able to call this elaboration procedure from Ada code,
5458 e.g.@: if it is necessary to do selective re-elaboration to fix some
5459 error.
5460
5461 @node Elab_Spec
5462 @unnumberedsec Elab_Spec
5463 @findex Elab_Spec
5464 @noindent
5465 This attribute can only be applied to a program unit name.  It returns
5466 the entity for the corresponding elaboration procedure for elaborating
5467 the spec of the referenced unit.  This is used in the main
5468 generated elaboration procedure by the binder and is not normally used
5469 in any other context.  However, there may be specialized situations in
5470 which it is useful to be able to call this elaboration procedure from
5471 Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
5472 some error.
5473
5474 @node Emax
5475 @unnumberedsec Emax
5476 @cindex Ada 83 attributes
5477 @findex Emax
5478 @noindent
5479 The @code{Emax} attribute is provided for compatibility with Ada 83.  See
5480 the Ada 83 reference manual for an exact description of the semantics of
5481 this attribute.
5482
5483 @node Enabled
5484 @unnumberedsec Enabled
5485 @findex Enabled
5486 @noindent
5487 The @code{Enabled} attribute allows an application program to check at compile
5488 time to see if the designated check is currently enabled. The prefix is a
5489 simple identifier, referencing any predefined check name (other than
5490 @code{All_Checks}) or a check name introduced by pragma Check_Name. If
5491 no argument is given for the attribute, the check is for the general state
5492 of the check, if an argument is given, then it is an entity name, and the
5493 check indicates whether an @code{Suppress} or @code{Unsuppress} has been
5494 given naming the entity (if not, then the argument is ignored).
5495
5496 Note that instantiations inherit the check status at the point of the
5497 instantiation, so a useful idiom is to have a library package that
5498 introduces a check name with @code{pragma Check_Name}, and then contains
5499 generic packages or subprograms which use the @code{Enabled} attribute
5500 to see if the check is enabled. A user of this package can then issue
5501 a @code{pragma Suppress} or @code{pragma Unsuppress} before instantiating
5502 the package or subprogram, controlling whether the check will be present.
5503
5504 @node Enum_Rep
5505 @unnumberedsec Enum_Rep
5506 @cindex Representation of enums
5507 @findex Enum_Rep
5508 @noindent
5509 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
5510 function with the following spec:
5511
5512 @smallexample @c ada
5513 function @var{S}'Enum_Rep (Arg : @var{S}'Base)
5514   return @i{Universal_Integer};
5515 @end smallexample
5516
5517 @noindent
5518 It is also allowable to apply @code{Enum_Rep} directly to an object of an
5519 enumeration type or to a non-overloaded enumeration
5520 literal.  In this case @code{@var{S}'Enum_Rep} is equivalent to
5521 @code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
5522 enumeration literal or object.
5523
5524 The function returns the representation value for the given enumeration
5525 value.  This will be equal to value of the @code{Pos} attribute in the
5526 absence of an enumeration representation clause.  This is a static
5527 attribute (i.e.@: the result is static if the argument is static).
5528
5529 @code{@var{S}'Enum_Rep} can also be used with integer types and objects,
5530 in which case it simply returns the integer value.  The reason for this
5531 is to allow it to be used for @code{(<>)} discrete formal arguments in
5532 a generic unit that can be instantiated with either enumeration types
5533 or integer types.  Note that if @code{Enum_Rep} is used on a modular
5534 type whose upper bound exceeds the upper bound of the largest signed
5535 integer type, and the argument is a variable, so that the universal
5536 integer calculation is done at run time, then the call to @code{Enum_Rep}
5537 may raise @code{Constraint_Error}.
5538
5539 @node Enum_Val
5540 @unnumberedsec Enum_Val
5541 @cindex Representation of enums
5542 @findex Enum_Val
5543 @noindent
5544 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
5545 function with the following spec:
5546
5547 @smallexample @c ada
5548 function @var{S}'Enum_Rep (Arg : @i{Universal_Integer)
5549   return @var{S}'Base};
5550 @end smallexample
5551
5552 @noindent
5553 The function returns the enumeration value whose representation matches the
5554 argument, or raises Constraint_Error if no enumeration literal of the type
5555 has the matching value.
5556 This will be equal to value of the @code{Val} attribute in the
5557 absence of an enumeration representation clause.  This is a static
5558 attribute (i.e.@: the result is static if the argument is static).
5559
5560 @node Epsilon
5561 @unnumberedsec Epsilon
5562 @cindex Ada 83 attributes
5563 @findex Epsilon
5564 @noindent
5565 The @code{Epsilon} attribute is provided for compatibility with Ada 83.  See
5566 the Ada 83 reference manual for an exact description of the semantics of
5567 this attribute.
5568
5569 @node Fixed_Value
5570 @unnumberedsec Fixed_Value
5571 @findex Fixed_Value
5572 @noindent
5573 For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
5574 function with the following specification:
5575
5576 @smallexample @c ada
5577 function @var{S}'Fixed_Value (Arg : @i{Universal_Integer})
5578   return @var{S};
5579 @end smallexample
5580
5581 @noindent
5582 The value returned is the fixed-point value @var{V} such that
5583
5584 @smallexample @c ada
5585 @var{V} = Arg * @var{S}'Small
5586 @end smallexample
5587
5588 @noindent
5589 The effect is thus similar to first converting the argument to the
5590 integer type used to represent @var{S}, and then doing an unchecked
5591 conversion to the fixed-point type.  The difference is
5592 that there are full range checks, to ensure that the result is in range.
5593 This attribute is primarily intended for use in implementation of the
5594 input-output functions for fixed-point values.
5595
5596 @node Has_Access_Values
5597 @unnumberedsec Has_Access_Values
5598 @cindex Access values, testing for
5599 @findex Has_Access_Values
5600 @noindent
5601 The prefix of the @code{Has_Access_Values} attribute is a type.  The result
5602 is a Boolean value which is True if the is an access type, or is a composite
5603 type with a component (at any nesting depth) that is an access type, and is
5604 False otherwise.
5605 The intended use of this attribute is in conjunction with generic
5606 definitions.  If the attribute is applied to a generic private type, it
5607 indicates whether or not the corresponding actual type has access values.
5608
5609 @node Has_Discriminants
5610 @unnumberedsec Has_Discriminants
5611 @cindex Discriminants, testing for
5612 @findex Has_Discriminants
5613 @noindent
5614 The prefix of the @code{Has_Discriminants} attribute is a type.  The result
5615 is a Boolean value which is True if the type has discriminants, and False
5616 otherwise.  The intended use of this attribute is in conjunction with generic
5617 definitions.  If the attribute is applied to a generic private type, it
5618 indicates whether or not the corresponding actual type has discriminants.
5619
5620 @node Img
5621 @unnumberedsec Img
5622 @findex Img
5623 @noindent
5624 The @code{Img} attribute differs from @code{Image} in that it may be
5625 applied to objects as well as types, in which case it gives the
5626 @code{Image} for the subtype of the object.  This is convenient for
5627 debugging:
5628
5629 @smallexample @c ada
5630 Put_Line ("X = " & X'Img);
5631 @end smallexample
5632
5633 @noindent
5634 has the same meaning as the more verbose:
5635
5636 @smallexample @c ada
5637 Put_Line ("X = " & @var{T}'Image (X));
5638 @end smallexample
5639
5640 @noindent
5641 where @var{T} is the (sub)type of the object @code{X}.
5642
5643 @node Integer_Value
5644 @unnumberedsec Integer_Value
5645 @findex Integer_Value
5646 @noindent
5647 For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
5648 function with the following spec:
5649
5650 @smallexample @c ada
5651 function @var{S}'Integer_Value (Arg : @i{Universal_Fixed})
5652   return @var{S};
5653 @end smallexample
5654
5655 @noindent
5656 The value returned is the integer value @var{V}, such that
5657
5658 @smallexample @c ada
5659 Arg = @var{V} * @var{T}'Small
5660 @end smallexample
5661
5662 @noindent
5663 where @var{T} is the type of @code{Arg}.
5664 The effect is thus similar to first doing an unchecked conversion from
5665 the fixed-point type to its corresponding implementation type, and then
5666 converting the result to the target integer type.  The difference is
5667 that there are full range checks, to ensure that the result is in range.
5668 This attribute is primarily intended for use in implementation of the
5669 standard input-output functions for fixed-point values.
5670
5671 @node Invalid_Value
5672 @unnumberedsec Invalid_Value
5673 @findex Invalid_Value
5674 @noindent
5675 For every scalar type S, S'Invalid_Value returns an undefined value of the
5676 type. If possible this value is an invalid representation for the type. The
5677 value returned is identical to the value used to initialize an otherwise
5678 uninitialized value of the type if pragma Initialize_Scalars is used,
5679 including the ability to modify the value with the binder -Sxx flag and
5680 relevant environment variables at run time.
5681
5682 @node Large
5683 @unnumberedsec Large
5684 @cindex Ada 83 attributes
5685 @findex Large
5686 @noindent
5687 The @code{Large} attribute is provided for compatibility with Ada 83.  See
5688 the Ada 83 reference manual for an exact description of the semantics of
5689 this attribute.
5690
5691 @node Machine_Size
5692 @unnumberedsec Machine_Size
5693 @findex Machine_Size
5694 @noindent
5695 This attribute is identical to the @code{Object_Size} attribute.  It is
5696 provided for compatibility with the DEC Ada 83 attribute of this name.
5697
5698 @node Mantissa
5699 @unnumberedsec Mantissa
5700 @cindex Ada 83 attributes
5701 @findex Mantissa
5702 @noindent
5703 The @code{Mantissa} attribute is provided for compatibility with Ada 83.  See
5704 the Ada 83 reference manual for an exact description of the semantics of
5705 this attribute.
5706
5707 @node Max_Interrupt_Priority
5708 @unnumberedsec Max_Interrupt_Priority
5709 @cindex Interrupt priority, maximum
5710 @findex Max_Interrupt_Priority
5711 @noindent
5712 @code{Standard'Max_Interrupt_Priority} (@code{Standard} is the only
5713 permissible prefix), provides the same value as
5714 @code{System.Max_Interrupt_Priority}.
5715
5716 @node Max_Priority
5717 @unnumberedsec Max_Priority
5718 @cindex Priority, maximum
5719 @findex Max_Priority
5720 @noindent
5721 @code{Standard'Max_Priority} (@code{Standard} is the only permissible
5722 prefix) provides the same value as @code{System.Max_Priority}.
5723
5724 @node Maximum_Alignment
5725 @unnumberedsec Maximum_Alignment
5726 @cindex Alignment, maximum
5727 @findex Maximum_Alignment
5728 @noindent
5729 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
5730 permissible prefix) provides the maximum useful alignment value for the
5731 target.  This is a static value that can be used to specify the alignment
5732 for an object, guaranteeing that it is properly aligned in all
5733 cases.
5734
5735 @node Mechanism_Code
5736 @unnumberedsec Mechanism_Code
5737 @cindex Return values, passing mechanism
5738 @cindex Parameters, passing mechanism
5739 @findex Mechanism_Code
5740 @noindent
5741 @code{@var{function}'Mechanism_Code} yields an integer code for the
5742 mechanism used for the result of function, and
5743 @code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
5744 used for formal parameter number @var{n} (a static integer value with 1
5745 meaning the first parameter) of @var{subprogram}.  The code returned is:
5746
5747 @table @asis
5748 @item 1
5749 by copy (value)
5750 @item 2
5751 by reference
5752 @item 3
5753 by descriptor (default descriptor class)
5754 @item 4
5755 by descriptor (UBS: unaligned bit string)
5756 @item 5
5757 by descriptor (UBSB: aligned bit string with arbitrary bounds)
5758 @item 6
5759 by descriptor (UBA: unaligned bit array)
5760 @item 7
5761 by descriptor (S: string, also scalar access type parameter)
5762 @item 8
5763 by descriptor (SB: string with arbitrary bounds)
5764 @item 9
5765 by descriptor (A: contiguous array)
5766 @item 10
5767 by descriptor (NCA: non-contiguous array)
5768 @end table
5769
5770 @noindent
5771 Values from 3 through 10 are only relevant to Digital OpenVMS implementations.
5772 @cindex OpenVMS
5773
5774 @node Null_Parameter
5775 @unnumberedsec Null_Parameter
5776 @cindex Zero address, passing
5777 @findex Null_Parameter
5778 @noindent
5779 A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
5780 type or subtype @var{T} allocated at machine address zero.  The attribute
5781 is allowed only as the default expression of a formal parameter, or as
5782 an actual expression of a subprogram call.  In either case, the
5783 subprogram must be imported.
5784
5785 The identity of the object is represented by the address zero in the
5786 argument list, independent of the passing mechanism (explicit or
5787 default).
5788
5789 This capability is needed to specify that a zero address should be
5790 passed for a record or other composite object passed by reference.
5791 There is no way of indicating this without the @code{Null_Parameter}
5792 attribute.
5793
5794 @node Object_Size
5795 @unnumberedsec Object_Size
5796 @cindex Size, used for objects
5797 @findex Object_Size
5798 @noindent
5799 The size of an object is not necessarily the same as the size of the type
5800 of an object.  This is because by default object sizes are increased to be
5801 a multiple of the alignment of the object.  For example,
5802 @code{Natural'Size} is
5803 31, but by default objects of type @code{Natural} will have a size of 32 bits.
5804 Similarly, a record containing an integer and a character:
5805
5806 @smallexample @c ada
5807 type Rec is record
5808    I : Integer;
5809    C : Character;
5810 end record;
5811 @end smallexample
5812
5813 @noindent
5814 will have a size of 40 (that is @code{Rec'Size} will be 40.  The
5815 alignment will be 4, because of the
5816 integer field, and so the default size of record objects for this type
5817 will be 64 (8 bytes).
5818
5819 @node Old
5820 @unnumberedsec Old
5821 @cindex Capturing Old values
5822 @cindex Postconditions
5823 @noindent
5824 The attribute Prefix'Old can be used within a
5825 subprogram to refer to the value of the prefix on entry. So for
5826 example if you have an argument of a record type X called Arg1,
5827 you can refer to Arg1.Field'Old which yields the value of
5828 Arg1.Field on entry. The implementation simply involves generating
5829 an object declaration which captures the value on entry. Any
5830 prefix is allowed except one of a limited type (since limited
5831 types cannot be copied to capture their values) or a local variable
5832 (since it does not exist at subprogram entry time).
5833
5834 The following example shows the use of 'Old to implement
5835 a test of a postcondition:
5836
5837 @smallexample @c ada
5838 with Old_Pkg;
5839 procedure Old is
5840 begin
5841    Old_Pkg.Incr;
5842 end Old;
5843
5844 package Old_Pkg is
5845    procedure Incr;
5846 end Old_Pkg;
5847
5848 package body Old_Pkg is
5849    Count : Natural := 0;
5850
5851    procedure Incr is
5852    begin
5853       ... code manipulating the value of Count
5854
5855       pragma Assert (Count = Count'Old + 1);
5856    end Incr;
5857 end Old_Pkg;
5858 @end smallexample
5859
5860 @noindent
5861 Note that it is allowed to apply 'Old to a constant entity, but this will
5862 result in a warning, since the old and new values will always be the same.
5863
5864 @node Passed_By_Reference
5865 @unnumberedsec Passed_By_Reference
5866 @cindex Parameters, when passed by reference
5867 @findex Passed_By_Reference
5868 @noindent
5869 @code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
5870 a value of type @code{Boolean} value that is @code{True} if the type is
5871 normally passed by reference and @code{False} if the type is normally
5872 passed by copy in calls.  For scalar types, the result is always @code{False}
5873 and is static.  For non-scalar types, the result is non-static.
5874
5875 @node Pool_Address
5876 @unnumberedsec Pool_Address
5877 @cindex Parameters, when passed by reference
5878 @findex Pool_Address
5879 @noindent
5880 @code{@var{X}'Pool_Address} for any object @var{X} returns the address
5881 of X within its storage pool. This is the same as
5882 @code{@var{X}'Address}, except that for an unconstrained array whose
5883 bounds are allocated just before the first component,
5884 @code{@var{X}'Pool_Address} returns the address of those bounds,
5885 whereas @code{@var{X}'Address} returns the address of the first
5886 component.
5887
5888 Here, we are interpreting ``storage pool'' broadly to mean ``wherever
5889 the object is allocated'', which could be a user-defined storage pool,
5890 the global heap, on the stack, or in a static memory area. For an
5891 object created by @code{new}, @code{@var{Ptr.all}'Pool_Address} is
5892 what is passed to @code{Allocate} and returned from @code{Deallocate}.
5893
5894 @node Range_Length
5895 @unnumberedsec Range_Length
5896 @findex Range_Length
5897 @noindent
5898 @code{@var{type}'Range_Length} for any discrete type @var{type} yields
5899 the number of values represented by the subtype (zero for a null
5900 range).  The result is static for static subtypes.  @code{Range_Length}
5901 applied to the index subtype of a one dimensional array always gives the
5902 same result as @code{Range} applied to the array itself.
5903
5904 @node Safe_Emax
5905 @unnumberedsec Safe_Emax
5906 @cindex Ada 83 attributes
5907 @findex Safe_Emax
5908 @noindent
5909 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83.  See
5910 the Ada 83 reference manual for an exact description of the semantics of
5911 this attribute.
5912
5913 @node Safe_Large
5914 @unnumberedsec Safe_Large
5915 @cindex Ada 83 attributes
5916 @findex Safe_Large
5917 @noindent
5918 The @code{Safe_Large} attribute is provided for compatibility with Ada 83.  See
5919 the Ada 83 reference manual for an exact description of the semantics of
5920 this attribute.
5921
5922 @node Small
5923 @unnumberedsec Small
5924 @cindex Ada 83 attributes
5925 @findex Small
5926 @noindent
5927 The @code{Small} attribute is defined in Ada 95 (and Ada 2005) only for
5928 fixed-point types.
5929 GNAT also allows this attribute to be applied to floating-point types
5930 for compatibility with Ada 83.  See
5931 the Ada 83 reference manual for an exact description of the semantics of
5932 this attribute when applied to floating-point types.
5933
5934 @node Storage_Unit
5935 @unnumberedsec Storage_Unit
5936 @findex Storage_Unit
5937 @noindent
5938 @code{Standard'Storage_Unit} (@code{Standard} is the only permissible
5939 prefix) provides the same value as @code{System.Storage_Unit}.
5940
5941 @node Stub_Type
5942 @unnumberedsec Stub_Type
5943 @findex Stub_Type
5944 @noindent
5945 The GNAT implementation of remote access-to-classwide types is
5946 organized as described in AARM section E.4 (20.t): a value of an RACW type
5947 (designating a remote object) is represented as a normal access
5948 value, pointing to a "stub" object which in turn contains the
5949 necessary information to contact the designated remote object. A
5950 call on any dispatching operation of such a stub object does the
5951 remote call, if necessary, using the information in the stub object
5952 to locate the target partition, etc.
5953
5954 For a prefix @code{T} that denotes a remote access-to-classwide type,
5955 @code{T'Stub_Type} denotes the type of the corresponding stub objects.
5956
5957 By construction, the layout of @code{T'Stub_Type} is identical to that of
5958 type @code{RACW_Stub_Type} declared in the internal implementation-defined
5959 unit @code{System.Partition_Interface}. Use of this attribute will create
5960 an implicit dependency on this unit.
5961
5962 @node Target_Name
5963 @unnumberedsec Target_Name
5964 @findex Target_Name
5965 @noindent
5966 @code{Standard'Target_Name} (@code{Standard} is the only permissible
5967 prefix) provides a static string value that identifies the target
5968 for the current compilation. For GCC implementations, this is the
5969 standard gcc target name without the terminating slash (for
5970 example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
5971
5972 @node Tick
5973 @unnumberedsec Tick
5974 @findex Tick
5975 @noindent
5976 @code{Standard'Tick} (@code{Standard} is the only permissible prefix)
5977 provides the same value as @code{System.Tick},
5978
5979 @node To_Address
5980 @unnumberedsec To_Address
5981 @findex To_Address
5982 @noindent
5983 The @code{System'To_Address}
5984 (@code{System} is the only permissible prefix)
5985 denotes a function identical to
5986 @code{System.Storage_Elements.To_Address} except that
5987 it is a static attribute.  This means that if its argument is
5988 a static expression, then the result of the attribute is a
5989 static expression.  The result is that such an expression can be
5990 used in contexts (e.g.@: preelaborable packages) which require a
5991 static expression and where the function call could not be used
5992 (since the function call is always non-static, even if its
5993 argument is static).
5994
5995 @node Type_Class
5996 @unnumberedsec Type_Class
5997 @findex Type_Class
5998 @noindent
5999 @code{@var{type}'Type_Class} for any type or subtype @var{type} yields
6000 the value of the type class for the full type of @var{type}.  If
6001 @var{type} is a generic formal type, the value is the value for the
6002 corresponding actual subtype.  The value of this attribute is of type
6003 @code{System.Aux_DEC.Type_Class}, which has the following definition:
6004
6005 @smallexample @c ada
6006   type Type_Class is
6007     (Type_Class_Enumeration,
6008      Type_Class_Integer,
6009      Type_Class_Fixed_Point,
6010      Type_Class_Floating_Point,
6011      Type_Class_Array,
6012      Type_Class_Record,
6013      Type_Class_Access,
6014      Type_Class_Task,
6015      Type_Class_Address);
6016 @end smallexample
6017
6018 @noindent
6019 Protected types yield the value @code{Type_Class_Task}, which thus
6020 applies to all concurrent types.  This attribute is designed to
6021 be compatible with the DEC Ada 83 attribute of the same name.
6022
6023 @node UET_Address
6024 @unnumberedsec UET_Address
6025 @findex UET_Address
6026 @noindent
6027 The @code{UET_Address} attribute can only be used for a prefix which
6028 denotes a library package.  It yields the address of the unit exception
6029 table when zero cost exception handling is used.  This attribute is
6030 intended only for use within the GNAT implementation.  See the unit
6031 @code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb}
6032 for details on how this attribute is used in the implementation.
6033
6034 @node Unconstrained_Array
6035 @unnumberedsec Unconstrained_Array
6036 @findex Unconstrained_Array
6037 @noindent
6038 The @code{Unconstrained_Array} attribute can be used with a prefix that
6039 denotes any type or subtype. It is a static attribute that yields
6040 @code{True} if the prefix designates an unconstrained array,
6041 and @code{False} otherwise. In a generic instance, the result is
6042 still static, and yields the result of applying this test to the
6043 generic actual.
6044
6045 @node Universal_Literal_String
6046 @unnumberedsec Universal_Literal_String
6047 @cindex Named numbers, representation of
6048 @findex Universal_Literal_String
6049 @noindent
6050 The prefix of @code{Universal_Literal_String} must be a named
6051 number.  The static result is the string consisting of the characters of
6052 the number as defined in the original source.  This allows the user
6053 program to access the actual text of named numbers without intermediate
6054 conversions and without the need to enclose the strings in quotes (which
6055 would preclude their use as numbers).  This is used internally for the
6056 construction of values of the floating-point attributes from the file
6057 @file{ttypef.ads}, but may also be used by user programs.
6058
6059 For example, the following program prints the first 50 digits of pi:
6060
6061 @smallexample @c ada
6062 with Text_IO; use Text_IO;
6063 with Ada.Numerics;
6064 procedure Pi is
6065 begin
6066    Put (Ada.Numerics.Pi'Universal_Literal_String);
6067 end;
6068 @end smallexample
6069
6070 @node Unrestricted_Access
6071 @unnumberedsec Unrestricted_Access
6072 @cindex @code{Access}, unrestricted
6073 @findex Unrestricted_Access
6074 @noindent
6075 The @code{Unrestricted_Access} attribute is similar to @code{Access}
6076 except that all accessibility and aliased view checks are omitted.  This
6077 is a user-beware attribute.  It is similar to
6078 @code{Address}, for which it is a desirable replacement where the value
6079 desired is an access type.  In other words, its effect is identical to
6080 first applying the @code{Address} attribute and then doing an unchecked
6081 conversion to a desired access type.  In GNAT, but not necessarily in
6082 other implementations, the use of static chains for inner level
6083 subprograms means that @code{Unrestricted_Access} applied to a
6084 subprogram yields a value that can be called as long as the subprogram
6085 is in scope (normal Ada accessibility rules restrict this usage).
6086
6087 It is possible to use @code{Unrestricted_Access} for any type, but care
6088 must be exercised if it is used to create pointers to unconstrained
6089 objects. In this case, the resulting pointer has the same scope as the
6090 context of the attribute, and may not be returned to some enclosing
6091 scope. For instance, a function cannot use @code{Unrestricted_Access}
6092 to create a unconstrained pointer and then return that value to the
6093 caller.
6094
6095 @node VADS_Size
6096 @unnumberedsec VADS_Size
6097 @cindex @code{Size}, VADS compatibility
6098 @findex VADS_Size
6099 @noindent
6100 The @code{'VADS_Size} attribute is intended to make it easier to port
6101 legacy code which relies on the semantics of @code{'Size} as implemented
6102 by the VADS Ada 83 compiler.  GNAT makes a best effort at duplicating the
6103 same semantic interpretation.  In particular, @code{'VADS_Size} applied
6104 to a predefined or other primitive type with no Size clause yields the
6105 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
6106 typical machines).  In addition @code{'VADS_Size} applied to an object
6107 gives the result that would be obtained by applying the attribute to
6108 the corresponding type.
6109
6110 @node Value_Size
6111 @unnumberedsec Value_Size
6112 @cindex @code{Size}, setting for not-first subtype
6113 @findex Value_Size
6114 @code{@var{type}'Value_Size} is the number of bits required to represent
6115 a value of the given subtype.  It is the same as @code{@var{type}'Size},
6116 but, unlike @code{Size}, may be set for non-first subtypes.
6117
6118 @node Wchar_T_Size
6119 @unnumberedsec Wchar_T_Size
6120 @findex Wchar_T_Size
6121 @code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
6122 prefix) provides the size in bits of the C @code{wchar_t} type
6123 primarily for constructing the definition of this type in
6124 package @code{Interfaces.C}.
6125
6126 @node Word_Size
6127 @unnumberedsec Word_Size
6128 @findex Word_Size
6129 @code{Standard'Word_Size} (@code{Standard} is the only permissible
6130 prefix) provides the value @code{System.Word_Size}.
6131
6132 @c ------------------------
6133 @node Implementation Advice
6134 @chapter Implementation Advice
6135 @noindent
6136 The main text of the Ada Reference Manual describes the required
6137 behavior of all Ada compilers, and the GNAT compiler conforms to
6138 these requirements.
6139
6140 In addition, there are sections throughout the Ada Reference Manual headed
6141 by the phrase ``Implementation advice''.  These sections are not normative,
6142 i.e., they do not specify requirements that all compilers must
6143 follow.  Rather they provide advice on generally desirable behavior.  You
6144 may wonder why they are not requirements.  The most typical answer is
6145 that they describe behavior that seems generally desirable, but cannot
6146 be provided on all systems, or which may be undesirable on some systems.
6147
6148 As far as practical, GNAT follows the implementation advice sections in
6149 the Ada Reference Manual.  This chapter contains a table giving the
6150 reference manual section number, paragraph number and several keywords
6151 for each advice.  Each entry consists of the text of the advice followed
6152 by the GNAT interpretation of this advice.  Most often, this simply says
6153 ``followed'', which means that GNAT follows the advice.  However, in a
6154 number of cases, GNAT deliberately deviates from this advice, in which
6155 case the text describes what GNAT does and why.
6156
6157 @cindex Error detection
6158 @unnumberedsec 1.1.3(20): Error Detection
6159 @sp 1
6160 @cartouche
6161 If an implementation detects the use of an unsupported Specialized Needs
6162 Annex feature at run time, it should raise @code{Program_Error} if
6163 feasible.
6164 @end cartouche
6165 Not relevant.  All specialized needs annex features are either supported,
6166 or diagnosed at compile time.
6167
6168 @cindex Child Units
6169 @unnumberedsec 1.1.3(31): Child Units
6170 @sp 1
6171 @cartouche
6172 If an implementation wishes to provide implementation-defined
6173 extensions to the functionality of a language-defined library unit, it
6174 should normally do so by adding children to the library unit.
6175 @end cartouche
6176 Followed.
6177
6178 @cindex Bounded errors
6179 @unnumberedsec 1.1.5(12): Bounded Errors
6180 @sp 1
6181 @cartouche
6182 If an implementation detects a bounded error or erroneous
6183 execution, it should raise @code{Program_Error}.
6184 @end cartouche
6185 Followed in all cases in which the implementation detects a bounded
6186 error or erroneous execution.  Not all such situations are detected at
6187 runtime.
6188
6189 @cindex Pragmas
6190 @unnumberedsec 2.8(16): Pragmas
6191 @sp 1
6192 @cartouche
6193 Normally, implementation-defined pragmas should have no semantic effect
6194 for error-free programs; that is, if the implementation-defined pragmas
6195 are removed from a working program, the program should still be legal,
6196 and should still have the same semantics.
6197 @end cartouche
6198 The following implementation defined pragmas are exceptions to this
6199 rule:
6200
6201 @table @code
6202 @item Abort_Defer
6203 Affects semantics
6204 @item Ada_83
6205 Affects legality
6206 @item Assert
6207 Affects semantics
6208 @item CPP_Class
6209 Affects semantics
6210 @item CPP_Constructor
6211 Affects semantics
6212 @item Debug
6213 Affects semantics
6214 @item Interface_Name
6215 Affects semantics
6216 @item Machine_Attribute
6217 Affects semantics
6218 @item Unimplemented_Unit
6219 Affects legality
6220 @item Unchecked_Union
6221 Affects semantics
6222 @end table
6223
6224 @noindent
6225 In each of the above cases, it is essential to the purpose of the pragma
6226 that this advice not be followed.  For details see the separate section
6227 on implementation defined pragmas.
6228
6229 @unnumberedsec 2.8(17-19): Pragmas
6230 @sp 1
6231 @cartouche
6232 Normally, an implementation should not define pragmas that can
6233 make an illegal program legal, except as follows:
6234 @end cartouche
6235 @sp 1
6236 @cartouche
6237 A pragma used to complete a declaration, such as a pragma @code{Import};
6238 @end cartouche
6239 @sp 1
6240 @cartouche
6241 A pragma used to configure the environment by adding, removing, or
6242 replacing @code{library_items}.
6243 @end cartouche
6244 See response to paragraph 16 of this same section.
6245
6246 @cindex Character Sets
6247 @cindex Alternative Character Sets
6248 @unnumberedsec 3.5.2(5): Alternative Character Sets
6249 @sp 1
6250 @cartouche
6251 If an implementation supports a mode with alternative interpretations
6252 for @code{Character} and @code{Wide_Character}, the set of graphic
6253 characters of @code{Character} should nevertheless remain a proper
6254 subset of the set of graphic characters of @code{Wide_Character}.  Any
6255 character set ``localizations'' should be reflected in the results of
6256 the subprograms defined in the language-defined package
6257 @code{Characters.Handling} (see A.3) available in such a mode.  In a mode with
6258 an alternative interpretation of @code{Character}, the implementation should
6259 also support a corresponding change in what is a legal
6260 @code{identifier_letter}.
6261 @end cartouche
6262 Not all wide character modes follow this advice, in particular the JIS
6263 and IEC modes reflect standard usage in Japan, and in these encoding,
6264 the upper half of the Latin-1 set is not part of the wide-character
6265 subset, since the most significant bit is used for wide character
6266 encoding.  However, this only applies to the external forms.  Internally
6267 there is no such restriction.
6268
6269 @cindex Integer types
6270 @unnumberedsec 3.5.4(28): Integer Types
6271
6272 @sp 1
6273 @cartouche
6274 An implementation should support @code{Long_Integer} in addition to
6275 @code{Integer} if the target machine supports 32-bit (or longer)
6276 arithmetic.  No other named integer subtypes are recommended for package
6277 @code{Standard}.  Instead, appropriate named integer subtypes should be
6278 provided in the library package @code{Interfaces} (see B.2).
6279 @end cartouche
6280 @code{Long_Integer} is supported.  Other standard integer types are supported
6281 so this advice is not fully followed.  These types
6282 are supported for convenient interface to C, and so that all hardware
6283 types of the machine are easily available.
6284 @unnumberedsec 3.5.4(29): Integer Types
6285
6286 @sp 1
6287 @cartouche
6288 An implementation for a two's complement machine should support
6289 modular types with a binary modulus up to @code{System.Max_Int*2+2}.  An
6290 implementation should support a non-binary modules up to @code{Integer'Last}.
6291 @end cartouche
6292 Followed.
6293
6294 @cindex Enumeration values
6295 @unnumberedsec 3.5.5(8): Enumeration Values
6296 @sp 1
6297 @cartouche
6298 For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
6299 subtype, if the value of the operand does not correspond to the internal
6300 code for any enumeration literal of its type (perhaps due to an
6301 un-initialized variable), then the implementation should raise
6302 @code{Program_Error}.  This is particularly important for enumeration
6303 types with noncontiguous internal codes specified by an
6304 enumeration_representation_clause.
6305 @end cartouche
6306 Followed.
6307
6308 @cindex Float types
6309 @unnumberedsec 3.5.7(17): Float Types
6310 @sp 1
6311 @cartouche
6312 An implementation should support @code{Long_Float} in addition to
6313 @code{Float} if the target machine supports 11 or more digits of
6314 precision.  No other named floating point subtypes are recommended for
6315 package @code{Standard}.  Instead, appropriate named floating point subtypes
6316 should be provided in the library package @code{Interfaces} (see B.2).
6317 @end cartouche
6318 @code{Short_Float} and @code{Long_Long_Float} are also provided.  The
6319 former provides improved compatibility with other implementations
6320 supporting this type.  The latter corresponds to the highest precision
6321 floating-point type supported by the hardware.  On most machines, this
6322 will be the same as @code{Long_Float}, but on some machines, it will
6323 correspond to the IEEE extended form.  The notable case is all ia32
6324 (x86) implementations, where @code{Long_Long_Float} corresponds to
6325 the 80-bit extended precision format supported in hardware on this
6326 processor.  Note that the 128-bit format on SPARC is not supported,
6327 since this is a software rather than a hardware format.
6328
6329 @cindex Multidimensional arrays
6330 @cindex Arrays, multidimensional
6331 @unnumberedsec 3.6.2(11): Multidimensional Arrays
6332 @sp 1
6333 @cartouche
6334 An implementation should normally represent multidimensional arrays in
6335 row-major order, consistent with the notation used for multidimensional
6336 array aggregates (see 4.3.3).  However, if a pragma @code{Convention}
6337 (@code{Fortran}, @dots{}) applies to a multidimensional array type, then
6338 column-major order should be used instead (see B.5, ``Interfacing with
6339 Fortran'').
6340 @end cartouche
6341 Followed.
6342
6343 @findex Duration'Small
6344 @unnumberedsec 9.6(30-31): Duration'Small
6345 @sp 1
6346 @cartouche
6347 Whenever possible in an implementation, the value of @code{Duration'Small}
6348 should be no greater than 100 microseconds.
6349 @end cartouche
6350 Followed.  (@code{Duration'Small} = 10**(@minus{}9)).
6351
6352 @sp 1
6353 @cartouche
6354 The time base for @code{delay_relative_statements} should be monotonic;
6355 it need not be the same time base as used for @code{Calendar.Clock}.
6356 @end cartouche
6357 Followed.
6358
6359 @unnumberedsec 10.2.1(12): Consistent Representation
6360 @sp 1
6361 @cartouche
6362 In an implementation, a type declared in a pre-elaborated package should
6363 have the same representation in every elaboration of a given version of
6364 the package, whether the elaborations occur in distinct executions of
6365 the same program, or in executions of distinct programs or partitions
6366 that include the given version.
6367 @end cartouche
6368 Followed, except in the case of tagged types.  Tagged types involve
6369 implicit pointers to a local copy of a dispatch table, and these pointers
6370 have representations which thus depend on a particular elaboration of the
6371 package.  It is not easy to see how it would be possible to follow this
6372 advice without severely impacting efficiency of execution.
6373
6374 @cindex Exception information
6375 @unnumberedsec 11.4.1(19): Exception Information
6376 @sp 1
6377 @cartouche
6378 @code{Exception_Message} by default and @code{Exception_Information}
6379 should produce information useful for
6380 debugging.  @code{Exception_Message} should be short, about one
6381 line.  @code{Exception_Information} can be long.  @code{Exception_Message}
6382 should not include the
6383 @code{Exception_Name}.  @code{Exception_Information} should include both
6384 the @code{Exception_Name} and the @code{Exception_Message}.
6385 @end cartouche
6386 Followed.  For each exception that doesn't have a specified
6387 @code{Exception_Message}, the compiler generates one containing the location
6388 of the raise statement.  This location has the form ``file:line'', where
6389 file is the short file name (without path information) and line is the line
6390 number in the file.  Note that in the case of the Zero Cost Exception
6391 mechanism, these messages become redundant with the Exception_Information that
6392 contains a full backtrace of the calling sequence, so they are disabled.
6393 To disable explicitly the generation of the source location message, use the
6394 Pragma @code{Discard_Names}.
6395
6396 @cindex Suppression of checks
6397 @cindex Checks, suppression of
6398 @unnumberedsec 11.5(28): Suppression of Checks
6399 @sp 1
6400 @cartouche
6401 The implementation should minimize the code executed for checks that
6402 have been suppressed.
6403 @end cartouche
6404 Followed.
6405
6406 @cindex Representation clauses
6407 @unnumberedsec 13.1 (21-24): Representation Clauses
6408 @sp 1
6409 @cartouche
6410 The recommended level of support for all representation items is
6411 qualified as follows:
6412 @end cartouche
6413 @sp 1
6414 @cartouche
6415 An implementation need not support representation items containing
6416 non-static expressions, except that an implementation should support a
6417 representation item for a given entity if each non-static expression in
6418 the representation item is a name that statically denotes a constant
6419 declared before the entity.
6420 @end cartouche
6421 Followed.  In fact, GNAT goes beyond the recommended level of support
6422 by allowing nonstatic expressions in some representation clauses even
6423 without the need to declare constants initialized with the values of
6424 such expressions.
6425 For example:
6426
6427 @smallexample @c ada
6428   X : Integer;
6429   Y : Float;
6430   for Y'Address use X'Address;>>
6431 @end smallexample
6432
6433
6434 @sp 1
6435 @cartouche
6436 An implementation need not support a specification for the @code{Size}
6437 for a given composite subtype, nor the size or storage place for an
6438 object (including a component) of a given composite subtype, unless the
6439 constraints on the subtype and its composite subcomponents (if any) are
6440 all static constraints.
6441 @end cartouche
6442 Followed.  Size Clauses are not permitted on non-static components, as
6443 described above.
6444
6445 @sp 1
6446 @cartouche
6447 An aliased component, or a component whose type is by-reference, should
6448 always be allocated at an addressable location.
6449 @end cartouche
6450 Followed.
6451
6452 @cindex Packed types
6453 @unnumberedsec 13.2(6-8): Packed Types
6454 @sp 1
6455 @cartouche
6456 If a type is packed, then the implementation should try to minimize
6457 storage allocated to objects of the type, possibly at the expense of
6458 speed of accessing components, subject to reasonable complexity in
6459 addressing calculations.
6460 @end cartouche
6461 @sp 1
6462 @cartouche
6463 The recommended level of support pragma @code{Pack} is:
6464
6465 For a packed record type, the components should be packed as tightly as
6466 possible subject to the Sizes of the component subtypes, and subject to
6467 any @code{record_representation_clause} that applies to the type; the
6468 implementation may, but need not, reorder components or cross aligned
6469 word boundaries to improve the packing.  A component whose @code{Size} is
6470 greater than the word size may be allocated an integral number of words.
6471 @end cartouche
6472 Followed.  Tight packing of arrays is supported for all component sizes
6473 up to 64-bits. If the array component size is 1 (that is to say, if
6474 the component is a boolean type or an enumeration type with two values)
6475 then values of the type are implicitly initialized to zero. This
6476 happens both for objects of the packed type, and for objects that have a
6477 subcomponent of the packed type.
6478
6479 @sp 1
6480 @cartouche
6481 An implementation should support Address clauses for imported
6482 subprograms.
6483 @end cartouche
6484 Followed.
6485 @cindex @code{Address} clauses
6486 @unnumberedsec 13.3(14-19): Address Clauses
6487
6488 @sp 1
6489 @cartouche
6490 For an array @var{X}, @code{@var{X}'Address} should point at the first
6491 component of the array, and not at the array bounds.
6492 @end cartouche
6493 Followed.
6494
6495 @sp 1
6496 @cartouche
6497 The recommended level of support for the @code{Address} attribute is:
6498
6499 @code{@var{X}'Address} should produce a useful result if @var{X} is an
6500 object that is aliased or of a by-reference type, or is an entity whose
6501 @code{Address} has been specified.
6502 @end cartouche
6503 Followed.  A valid address will be produced even if none of those
6504 conditions have been met.  If necessary, the object is forced into
6505 memory to ensure the address is valid.
6506
6507 @sp 1
6508 @cartouche
6509 An implementation should support @code{Address} clauses for imported
6510 subprograms.
6511 @end cartouche
6512 Followed.
6513
6514 @sp 1
6515 @cartouche
6516 Objects (including subcomponents) that are aliased or of a by-reference
6517 type should be allocated on storage element boundaries.
6518 @end cartouche
6519 Followed.
6520
6521 @sp 1
6522 @cartouche
6523 If the @code{Address} of an object is specified, or it is imported or exported,
6524 then the implementation should not perform optimizations based on
6525 assumptions of no aliases.
6526 @end cartouche
6527 Followed.
6528
6529 @cindex @code{Alignment} clauses
6530 @unnumberedsec 13.3(29-35): Alignment Clauses
6531 @sp 1
6532 @cartouche
6533 The recommended level of support for the @code{Alignment} attribute for
6534 subtypes is:
6535
6536 An implementation should support specified Alignments that are factors
6537 and multiples of the number of storage elements per word, subject to the
6538 following:
6539 @end cartouche
6540 Followed.
6541
6542 @sp 1
6543 @cartouche
6544 An implementation need not support specified @code{Alignment}s for
6545 combinations of @code{Size}s and @code{Alignment}s that cannot be easily
6546 loaded and stored by available machine instructions.
6547 @end cartouche
6548 Followed.
6549
6550 @sp 1
6551 @cartouche
6552 An implementation need not support specified @code{Alignment}s that are
6553 greater than the maximum @code{Alignment} the implementation ever returns by
6554 default.
6555 @end cartouche
6556 Followed.
6557
6558 @sp 1
6559 @cartouche
6560 The recommended level of support for the @code{Alignment} attribute for
6561 objects is:
6562
6563 Same as above, for subtypes, but in addition:
6564 @end cartouche
6565 Followed.
6566
6567 @sp 1
6568 @cartouche
6569 For stand-alone library-level objects of statically constrained
6570 subtypes, the implementation should support all @code{Alignment}s
6571 supported by the target linker.  For example, page alignment is likely to
6572 be supported for such objects, but not for subtypes.
6573 @end cartouche
6574 Followed.
6575
6576 @cindex @code{Size} clauses
6577 @unnumberedsec 13.3(42-43): Size Clauses
6578 @sp 1
6579 @cartouche
6580 The recommended level of support for the @code{Size} attribute of
6581 objects is:
6582
6583 A @code{Size} clause should be supported for an object if the specified
6584 @code{Size} is at least as large as its subtype's @code{Size}, and
6585 corresponds to a size in storage elements that is a multiple of the
6586 object's @code{Alignment} (if the @code{Alignment} is nonzero).
6587 @end cartouche
6588 Followed.
6589
6590 @unnumberedsec 13.3(50-56): Size Clauses
6591 @sp 1
6592 @cartouche
6593 If the @code{Size} of a subtype is specified, and allows for efficient
6594 independent addressability (see 9.10) on the target architecture, then
6595 the @code{Size} of the following objects of the subtype should equal the
6596 @code{Size} of the subtype:
6597
6598 Aliased objects (including components).
6599 @end cartouche
6600 Followed.
6601
6602 @sp 1
6603 @cartouche
6604 @code{Size} clause on a composite subtype should not affect the
6605 internal layout of components.
6606 @end cartouche
6607 Followed. But note that this can be overridden by use of the implementation
6608 pragma Implicit_Packing in the case of packed arrays.
6609
6610 @sp 1
6611 @cartouche
6612 The recommended level of support for the @code{Size} attribute of subtypes is:
6613 @end cartouche
6614 @sp 1
6615 @cartouche
6616 The @code{Size} (if not specified) of a static discrete or fixed point
6617 subtype should be the number of bits needed to represent each value
6618 belonging to the subtype using an unbiased representation, leaving space
6619 for a sign bit only if the subtype contains negative values.  If such a
6620 subtype is a first subtype, then an implementation should support a
6621 specified @code{Size} for it that reflects this representation.
6622 @end cartouche
6623 Followed.
6624
6625 @sp 1
6626 @cartouche
6627 For a subtype implemented with levels of indirection, the @code{Size}
6628 should include the size of the pointers, but not the size of what they
6629 point at.
6630 @end cartouche
6631 Followed.
6632
6633 @cindex @code{Component_Size} clauses
6634 @unnumberedsec 13.3(71-73): Component Size Clauses
6635 @sp 1
6636 @cartouche
6637 The recommended level of support for the @code{Component_Size}
6638 attribute is:
6639 @end cartouche
6640 @sp 1
6641 @cartouche
6642 An implementation need not support specified @code{Component_Sizes} that are
6643 less than the @code{Size} of the component subtype.
6644 @end cartouche
6645 Followed.
6646
6647 @sp 1
6648 @cartouche
6649 An implementation should support specified @code{Component_Size}s that
6650 are factors and multiples of the word size.  For such
6651 @code{Component_Size}s, the array should contain no gaps between
6652 components.  For other @code{Component_Size}s (if supported), the array
6653 should contain no gaps between components when packing is also
6654 specified; the implementation should forbid this combination in cases
6655 where it cannot support a no-gaps representation.
6656 @end cartouche
6657 Followed.
6658
6659 @cindex Enumeration representation clauses
6660 @cindex Representation clauses, enumeration
6661 @unnumberedsec 13.4(9-10): Enumeration Representation Clauses
6662 @sp 1
6663 @cartouche
6664 The recommended level of support for enumeration representation clauses
6665 is:
6666
6667 An implementation need not support enumeration representation clauses
6668 for boolean types, but should at minimum support the internal codes in
6669 the range @code{System.Min_Int.System.Max_Int}.
6670 @end cartouche
6671 Followed.
6672
6673 @cindex Record representation clauses
6674 @cindex Representation clauses, records
6675 @unnumberedsec 13.5.1(17-22): Record Representation Clauses
6676 @sp 1
6677 @cartouche
6678 The recommended level of support for
6679 @*@code{record_representation_clauses} is:
6680
6681 An implementation should support storage places that can be extracted
6682 with a load, mask, shift sequence of machine code, and set with a load,
6683 shift, mask, store sequence, given the available machine instructions
6684 and run-time model.
6685 @end cartouche
6686 Followed.
6687
6688 @sp 1
6689 @cartouche
6690 A storage place should be supported if its size is equal to the
6691 @code{Size} of the component subtype, and it starts and ends on a
6692 boundary that obeys the @code{Alignment} of the component subtype.
6693 @end cartouche
6694 Followed.
6695
6696 @sp 1
6697 @cartouche
6698 If the default bit ordering applies to the declaration of a given type,
6699 then for a component whose subtype's @code{Size} is less than the word
6700 size, any storage place that does not cross an aligned word boundary
6701 should be supported.
6702 @end cartouche
6703 Followed.
6704
6705 @sp 1
6706 @cartouche
6707 An implementation may reserve a storage place for the tag field of a
6708 tagged type, and disallow other components from overlapping that place.
6709 @end cartouche
6710 Followed.  The storage place for the tag field is the beginning of the tagged
6711 record, and its size is Address'Size.  GNAT will reject an explicit component
6712 clause for the tag field.
6713
6714 @sp 1
6715 @cartouche
6716 An implementation need not support a @code{component_clause} for a
6717 component of an extension part if the storage place is not after the
6718 storage places of all components of the parent type, whether or not
6719 those storage places had been specified.
6720 @end cartouche
6721 Followed.  The above advice on record representation clauses is followed,
6722 and all mentioned features are implemented.
6723
6724 @cindex Storage place attributes
6725 @unnumberedsec 13.5.2(5): Storage Place Attributes
6726 @sp 1
6727 @cartouche
6728 If a component is represented using some form of pointer (such as an
6729 offset) to the actual data of the component, and this data is contiguous
6730 with the rest of the object, then the storage place attributes should
6731 reflect the place of the actual data, not the pointer.  If a component is
6732 allocated discontinuously from the rest of the object, then a warning
6733 should be generated upon reference to one of its storage place
6734 attributes.
6735 @end cartouche
6736 Followed.  There are no such components in GNAT@.
6737
6738 @cindex Bit ordering
6739 @unnumberedsec 13.5.3(7-8): Bit Ordering
6740 @sp 1
6741 @cartouche
6742 The recommended level of support for the non-default bit ordering is:
6743 @end cartouche
6744 @sp 1
6745 @cartouche
6746 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
6747 should support the non-default bit ordering in addition to the default
6748 bit ordering.
6749 @end cartouche
6750 Followed.  Word size does not equal storage size in this implementation.
6751 Thus non-default bit ordering is not supported.
6752
6753 @cindex @code{Address}, as private type
6754 @unnumberedsec 13.7(37): Address as Private
6755 @sp 1
6756 @cartouche
6757 @code{Address} should be of a private type.
6758 @end cartouche
6759 Followed.
6760
6761 @cindex Operations, on @code{Address}
6762 @cindex @code{Address}, operations of
6763 @unnumberedsec 13.7.1(16): Address Operations
6764 @sp 1
6765 @cartouche
6766 Operations in @code{System} and its children should reflect the target
6767 environment semantics as closely as is reasonable.  For example, on most
6768 machines, it makes sense for address arithmetic to ``wrap around''.
6769 Operations that do not make sense should raise @code{Program_Error}.
6770 @end cartouche
6771 Followed.  Address arithmetic is modular arithmetic that wraps around.  No
6772 operation raises @code{Program_Error}, since all operations make sense.
6773
6774 @cindex Unchecked conversion
6775 @unnumberedsec 13.9(14-17): Unchecked Conversion
6776 @sp 1
6777 @cartouche
6778 The @code{Size} of an array object should not include its bounds; hence,
6779 the bounds should not be part of the converted data.
6780 @end cartouche
6781 Followed.
6782
6783 @sp 1
6784 @cartouche
6785 The implementation should not generate unnecessary run-time checks to
6786 ensure that the representation of @var{S} is a representation of the
6787 target type.  It should take advantage of the permission to return by
6788 reference when possible.  Restrictions on unchecked conversions should be
6789 avoided unless required by the target environment.
6790 @end cartouche
6791 Followed.  There are no restrictions on unchecked conversion.  A warning is
6792 generated if the source and target types do not have the same size since
6793 the semantics in this case may be target dependent.
6794
6795 @sp 1
6796 @cartouche
6797 The recommended level of support for unchecked conversions is:
6798 @end cartouche
6799 @sp 1
6800 @cartouche
6801 Unchecked conversions should be supported and should be reversible in
6802 the cases where this clause defines the result.  To enable meaningful use
6803 of unchecked conversion, a contiguous representation should be used for
6804 elementary subtypes, for statically constrained array subtypes whose
6805 component subtype is one of the subtypes described in this paragraph,
6806 and for record subtypes without discriminants whose component subtypes
6807 are described in this paragraph.
6808 @end cartouche
6809 Followed.
6810
6811 @cindex Heap usage, implicit
6812 @unnumberedsec 13.11(23-25): Implicit Heap Usage
6813 @sp 1
6814 @cartouche
6815 An implementation should document any cases in which it dynamically
6816 allocates heap storage for a purpose other than the evaluation of an
6817 allocator.
6818 @end cartouche
6819 Followed, the only other points at which heap storage is dynamically
6820 allocated are as follows:
6821
6822 @itemize @bullet
6823 @item
6824 At initial elaboration time, to allocate dynamically sized global
6825 objects.
6826
6827 @item
6828 To allocate space for a task when a task is created.
6829
6830 @item
6831 To extend the secondary stack dynamically when needed.  The secondary
6832 stack is used for returning variable length results.
6833 @end itemize
6834
6835 @sp 1
6836 @cartouche
6837 A default (implementation-provided) storage pool for an
6838 access-to-constant type should not have overhead to support deallocation of
6839 individual objects.
6840 @end cartouche
6841 Followed.
6842
6843 @sp 1
6844 @cartouche
6845 A storage pool for an anonymous access type should be created at the
6846 point of an allocator for the type, and be reclaimed when the designated
6847 object becomes inaccessible.
6848 @end cartouche
6849 Followed.
6850
6851 @cindex Unchecked deallocation
6852 @unnumberedsec 13.11.2(17): Unchecked De-allocation
6853 @sp 1
6854 @cartouche
6855 For a standard storage pool, @code{Free} should actually reclaim the
6856 storage.
6857 @end cartouche
6858 Followed.
6859
6860 @cindex Stream oriented attributes
6861 @unnumberedsec 13.13.2(17): Stream Oriented Attributes
6862 @sp 1
6863 @cartouche
6864 If a stream element is the same size as a storage element, then the
6865 normal in-memory representation should be used by @code{Read} and
6866 @code{Write} for scalar objects.  Otherwise, @code{Read} and @code{Write}
6867 should use the smallest number of stream elements needed to represent
6868 all values in the base range of the scalar type.
6869 @end cartouche
6870
6871 Followed.  By default, GNAT uses the interpretation suggested by AI-195,
6872 which specifies using the size of the first subtype.
6873 However, such an implementation is based on direct binary
6874 representations and is therefore target- and endianness-dependent.
6875 To address this issue, GNAT also supplies an alternate implementation
6876 of the stream attributes @code{Read} and @code{Write},
6877 which uses the target-independent XDR standard representation
6878 for scalar types.
6879 @cindex XDR representation
6880 @cindex @code{Read} attribute
6881 @cindex @code{Write} attribute
6882 @cindex Stream oriented attributes
6883 The XDR implementation is provided as an alternative body of the
6884 @code{System.Stream_Attributes} package, in the file
6885 @file{s-strxdr.adb} in the GNAT library.
6886 There is no @file{s-strxdr.ads} file.
6887 In order to install the XDR implementation, do the following:
6888 @enumerate
6889 @item Replace the default implementation of the
6890 @code{System.Stream_Attributes} package with the XDR implementation.
6891 For example on a Unix platform issue the commands:
6892 @smallexample
6893 $ mv s-stratt.adb s-strold.adb
6894 $ mv s-strxdr.adb s-stratt.adb
6895 @end smallexample
6896
6897 @item
6898 Rebuild the GNAT run-time library as documented in
6899 @ref{GNAT and Libraries,,, gnat_ugn, @value{EDITION} User's Guide}.
6900 @end enumerate
6901
6902 @unnumberedsec A.1(52): Names of Predefined Numeric Types
6903 @sp 1
6904 @cartouche
6905 If an implementation provides additional named predefined integer types,
6906 then the names should end with @samp{Integer} as in
6907 @samp{Long_Integer}.  If an implementation provides additional named
6908 predefined floating point types, then the names should end with
6909 @samp{Float} as in @samp{Long_Float}.
6910 @end cartouche
6911 Followed.
6912
6913 @findex Ada.Characters.Handling
6914 @unnumberedsec A.3.2(49): @code{Ada.Characters.Handling}
6915 @sp 1
6916 @cartouche
6917 If an implementation provides a localized definition of @code{Character}
6918 or @code{Wide_Character}, then the effects of the subprograms in
6919 @code{Characters.Handling} should reflect the localizations.  See also
6920 3.5.2.
6921 @end cartouche
6922 Followed.  GNAT provides no such localized definitions.
6923
6924 @cindex Bounded-length strings
6925 @unnumberedsec A.4.4(106): Bounded-Length String Handling
6926 @sp 1
6927 @cartouche
6928 Bounded string objects should not be implemented by implicit pointers
6929 and dynamic allocation.
6930 @end cartouche
6931 Followed.  No implicit pointers or dynamic allocation are used.
6932
6933 @cindex Random number generation
6934 @unnumberedsec A.5.2(46-47): Random Number Generation
6935 @sp 1
6936 @cartouche
6937 Any storage associated with an object of type @code{Generator} should be
6938 reclaimed on exit from the scope of the object.
6939 @end cartouche
6940 Followed.
6941
6942 @sp 1
6943 @cartouche
6944 If the generator period is sufficiently long in relation to the number
6945 of distinct initiator values, then each possible value of
6946 @code{Initiator} passed to @code{Reset} should initiate a sequence of
6947 random numbers that does not, in a practical sense, overlap the sequence
6948 initiated by any other value.  If this is not possible, then the mapping
6949 between initiator values and generator states should be a rapidly
6950 varying function of the initiator value.
6951 @end cartouche
6952 Followed.  The generator period is sufficiently long for the first
6953 condition here to hold true.
6954
6955 @findex Get_Immediate
6956 @unnumberedsec A.10.7(23): @code{Get_Immediate}
6957 @sp 1
6958 @cartouche
6959 The @code{Get_Immediate} procedures should be implemented with
6960 unbuffered input.  For a device such as a keyboard, input should be
6961 @dfn{available} if a key has already been typed, whereas for a disk
6962 file, input should always be available except at end of file.  For a file
6963 associated with a keyboard-like device, any line-editing features of the
6964 underlying operating system should be disabled during the execution of
6965 @code{Get_Immediate}.
6966 @end cartouche
6967 Followed on all targets except VxWorks. For VxWorks, there is no way to
6968 provide this functionality that does not result in the input buffer being
6969 flushed before the @code{Get_Immediate} call. A special unit
6970 @code{Interfaces.Vxworks.IO} is provided that contains routines to enable
6971 this functionality.
6972
6973 @findex Export
6974 @unnumberedsec B.1(39-41): Pragma @code{Export}
6975 @sp 1
6976 @cartouche
6977 If an implementation supports pragma @code{Export} to a given language,
6978 then it should also allow the main subprogram to be written in that
6979 language.  It should support some mechanism for invoking the elaboration
6980 of the Ada library units included in the system, and for invoking the
6981 finalization of the environment task.  On typical systems, the
6982 recommended mechanism is to provide two subprograms whose link names are
6983 @code{adainit} and @code{adafinal}.  @code{adainit} should contain the
6984 elaboration code for library units.  @code{adafinal} should contain the
6985 finalization code.  These subprograms should have no effect the second
6986 and subsequent time they are called.
6987 @end cartouche
6988 Followed.
6989
6990 @sp 1
6991 @cartouche
6992 Automatic elaboration of pre-elaborated packages should be
6993 provided when pragma @code{Export} is supported.
6994 @end cartouche
6995 Followed when the main program is in Ada.  If the main program is in a
6996 foreign language, then
6997 @code{adainit} must be called to elaborate pre-elaborated
6998 packages.
6999
7000 @sp 1
7001 @cartouche
7002 For each supported convention @var{L} other than @code{Intrinsic}, an
7003 implementation should support @code{Import} and @code{Export} pragmas
7004 for objects of @var{L}-compatible types and for subprograms, and pragma
7005 @code{Convention} for @var{L}-eligible types and for subprograms,
7006 presuming the other language has corresponding features.  Pragma
7007 @code{Convention} need not be supported for scalar types.
7008 @end cartouche
7009 Followed.
7010
7011 @cindex Package @code{Interfaces}
7012 @findex Interfaces
7013 @unnumberedsec B.2(12-13): Package @code{Interfaces}
7014 @sp 1
7015 @cartouche
7016 For each implementation-defined convention identifier, there should be a
7017 child package of package Interfaces with the corresponding name.  This
7018 package should contain any declarations that would be useful for
7019 interfacing to the language (implementation) represented by the
7020 convention.  Any declarations useful for interfacing to any language on
7021 the given hardware architecture should be provided directly in
7022 @code{Interfaces}.
7023 @end cartouche
7024 Followed. An additional package not defined
7025 in the Ada Reference Manual is @code{Interfaces.CPP}, used
7026 for interfacing to C++.
7027
7028 @sp 1
7029 @cartouche
7030 An implementation supporting an interface to C, COBOL, or Fortran should
7031 provide the corresponding package or packages described in the following
7032 clauses.
7033 @end cartouche
7034 Followed.  GNAT provides all the packages described in this section.
7035
7036 @cindex C, interfacing with
7037 @unnumberedsec B.3(63-71): Interfacing with C
7038 @sp 1
7039 @cartouche
7040 An implementation should support the following interface correspondences
7041 between Ada and C@.
7042 @end cartouche
7043 Followed.
7044
7045 @sp 1
7046 @cartouche
7047 An Ada procedure corresponds to a void-returning C function.
7048 @end cartouche
7049 Followed.
7050
7051 @sp 1
7052 @cartouche
7053 An Ada function corresponds to a non-void C function.
7054 @end cartouche
7055 Followed.
7056
7057 @sp 1
7058 @cartouche
7059 An Ada @code{in} scalar parameter is passed as a scalar argument to a C
7060 function.
7061 @end cartouche
7062 Followed.
7063
7064 @sp 1
7065 @cartouche
7066 An Ada @code{in} parameter of an access-to-object type with designated
7067 type @var{T} is passed as a @code{@var{t}*} argument to a C function,
7068 where @var{t} is the C type corresponding to the Ada type @var{T}.
7069 @end cartouche
7070 Followed.
7071
7072 @sp 1
7073 @cartouche
7074 An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
7075 parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
7076 argument to a C function, where @var{t} is the C type corresponding to
7077 the Ada type @var{T}.  In the case of an elementary @code{out} or
7078 @code{in out} parameter, a pointer to a temporary copy is used to
7079 preserve by-copy semantics.
7080 @end cartouche
7081 Followed.
7082
7083 @sp 1
7084 @cartouche
7085 An Ada parameter of a record type @var{T}, of any mode, is passed as a
7086 @code{@var{t}*} argument to a C function, where @var{t} is the C
7087 structure corresponding to the Ada type @var{T}.
7088 @end cartouche
7089 Followed.  This convention may be overridden by the use of the C_Pass_By_Copy
7090 pragma, or Convention, or by explicitly specifying the mechanism for a given
7091 call using an extended import or export pragma.
7092
7093 @sp 1
7094 @cartouche
7095 An Ada parameter of an array type with component type @var{T}, of any
7096 mode, is passed as a @code{@var{t}*} argument to a C function, where
7097 @var{t} is the C type corresponding to the Ada type @var{T}.
7098 @end cartouche
7099 Followed.
7100
7101 @sp 1
7102 @cartouche
7103 An Ada parameter of an access-to-subprogram type is passed as a pointer
7104 to a C function whose prototype corresponds to the designated
7105 subprogram's specification.
7106 @end cartouche
7107 Followed.
7108
7109 @cindex COBOL, interfacing with
7110 @unnumberedsec B.4(95-98): Interfacing with COBOL
7111 @sp 1
7112 @cartouche
7113 An Ada implementation should support the following interface
7114 correspondences between Ada and COBOL@.
7115 @end cartouche
7116 Followed.
7117
7118 @sp 1
7119 @cartouche
7120 An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of
7121 the COBOL type corresponding to @var{T}.
7122 @end cartouche
7123 Followed.
7124
7125 @sp 1
7126 @cartouche
7127 An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of
7128 the corresponding COBOL type.
7129 @end cartouche
7130 Followed.
7131
7132 @sp 1
7133 @cartouche
7134 Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the
7135 COBOL type corresponding to the Ada parameter type; for scalars, a local
7136 copy is used if necessary to ensure by-copy semantics.
7137 @end cartouche
7138 Followed.
7139
7140 @cindex Fortran, interfacing with
7141 @unnumberedsec B.5(22-26): Interfacing with Fortran
7142 @sp 1
7143 @cartouche
7144 An Ada implementation should support the following interface
7145 correspondences between Ada and Fortran:
7146 @end cartouche
7147 Followed.
7148
7149 @sp 1
7150 @cartouche
7151 An Ada procedure corresponds to a Fortran subroutine.
7152 @end cartouche
7153 Followed.
7154
7155 @sp 1
7156 @cartouche
7157 An Ada function corresponds to a Fortran function.
7158 @end cartouche
7159 Followed.
7160
7161 @sp 1
7162 @cartouche
7163 An Ada parameter of an elementary, array, or record type @var{T} is
7164 passed as a @var{T} argument to a Fortran procedure, where @var{T} is
7165 the Fortran type corresponding to the Ada type @var{T}, and where the
7166 INTENT attribute of the corresponding dummy argument matches the Ada
7167 formal parameter mode; the Fortran implementation's parameter passing
7168 conventions are used.  For elementary types, a local copy is used if
7169 necessary to ensure by-copy semantics.
7170 @end cartouche
7171 Followed.
7172
7173 @sp 1
7174 @cartouche
7175 An Ada parameter of an access-to-subprogram type is passed as a
7176 reference to a Fortran procedure whose interface corresponds to the
7177 designated subprogram's specification.
7178 @end cartouche
7179 Followed.
7180
7181 @cindex Machine operations
7182 @unnumberedsec C.1(3-5): Access to Machine Operations
7183 @sp 1
7184 @cartouche
7185 The machine code or intrinsic support should allow access to all
7186 operations normally available to assembly language programmers for the
7187 target environment, including privileged instructions, if any.
7188 @end cartouche
7189 Followed.
7190
7191 @sp 1
7192 @cartouche
7193 The interfacing pragmas (see Annex B) should support interface to
7194 assembler; the default assembler should be associated with the
7195 convention identifier @code{Assembler}.
7196 @end cartouche
7197 Followed.
7198
7199 @sp 1
7200 @cartouche
7201 If an entity is exported to assembly language, then the implementation
7202 should allocate it at an addressable location, and should ensure that it
7203 is retained by the linking process, even if not otherwise referenced
7204 from the Ada code.  The implementation should assume that any call to a
7205 machine code or assembler subprogram is allowed to read or update every
7206 object that is specified as exported.
7207 @end cartouche
7208 Followed.
7209
7210 @unnumberedsec C.1(10-16): Access to Machine Operations
7211 @sp 1
7212 @cartouche
7213 The implementation should ensure that little or no overhead is
7214 associated with calling intrinsic and machine-code subprograms.
7215 @end cartouche
7216 Followed for both intrinsics and machine-code subprograms.
7217
7218 @sp 1
7219 @cartouche
7220 It is recommended that intrinsic subprograms be provided for convenient
7221 access to any machine operations that provide special capabilities or
7222 efficiency and that are not otherwise available through the language
7223 constructs.
7224 @end cartouche
7225 Followed.  A full set of machine operation intrinsic subprograms is provided.
7226
7227 @sp 1
7228 @cartouche
7229 Atomic read-modify-write operations---e.g.@:, test and set, compare and
7230 swap, decrement and test, enqueue/dequeue.
7231 @end cartouche
7232 Followed on any target supporting such operations.
7233
7234 @sp 1
7235 @cartouche
7236 Standard numeric functions---e.g.@:, sin, log.
7237 @end cartouche
7238 Followed on any target supporting such operations.
7239
7240 @sp 1
7241 @cartouche
7242 String manipulation operations---e.g.@:, translate and test.
7243 @end cartouche
7244 Followed on any target supporting such operations.
7245
7246 @sp 1
7247 @cartouche
7248 Vector operations---e.g.@:, compare vector against thresholds.
7249 @end cartouche
7250 Followed on any target supporting such operations.
7251
7252 @sp 1
7253 @cartouche
7254 Direct operations on I/O ports.
7255 @end cartouche
7256 Followed on any target supporting such operations.
7257
7258 @cindex Interrupt support
7259 @unnumberedsec C.3(28): Interrupt Support
7260 @sp 1
7261 @cartouche
7262 If the @code{Ceiling_Locking} policy is not in effect, the
7263 implementation should provide means for the application to specify which
7264 interrupts are to be blocked during protected actions, if the underlying
7265 system allows for a finer-grain control of interrupt blocking.
7266 @end cartouche
7267 Followed.  The underlying system does not allow for finer-grain control
7268 of interrupt blocking.
7269
7270 @cindex Protected procedure handlers
7271 @unnumberedsec C.3.1(20-21): Protected Procedure Handlers
7272 @sp 1
7273 @cartouche
7274 Whenever possible, the implementation should allow interrupt handlers to
7275 be called directly by the hardware.
7276 @end cartouche
7277 @c SGI info:
7278 @ignore
7279 This is never possible under IRIX, so this is followed by default.
7280 @end ignore
7281 Followed on any target where the underlying operating system permits
7282 such direct calls.
7283
7284 @sp 1
7285 @cartouche
7286 Whenever practical, violations of any
7287 implementation-defined restrictions should be detected before run time.
7288 @end cartouche
7289 Followed.  Compile time warnings are given when possible.
7290
7291 @cindex Package @code{Interrupts}
7292 @findex Interrupts
7293 @unnumberedsec C.3.2(25): Package @code{Interrupts}
7294
7295 @sp 1
7296 @cartouche
7297 If implementation-defined forms of interrupt handler procedures are
7298 supported, such as protected procedures with parameters, then for each
7299 such form of a handler, a type analogous to @code{Parameterless_Handler}
7300 should be specified in a child package of @code{Interrupts}, with the
7301 same operations as in the predefined package Interrupts.
7302 @end cartouche
7303 Followed.
7304
7305 @cindex Pre-elaboration requirements
7306 @unnumberedsec C.4(14): Pre-elaboration Requirements
7307 @sp 1
7308 @cartouche
7309 It is recommended that pre-elaborated packages be implemented in such a
7310 way that there should be little or no code executed at run time for the
7311 elaboration of entities not already covered by the Implementation
7312 Requirements.
7313 @end cartouche
7314 Followed.  Executable code is generated in some cases, e.g.@: loops
7315 to initialize large arrays.
7316
7317 @unnumberedsec C.5(8): Pragma @code{Discard_Names}
7318
7319 @sp 1
7320 @cartouche
7321 If the pragma applies to an entity, then the implementation should
7322 reduce the amount of storage used for storing names associated with that
7323 entity.
7324 @end cartouche
7325 Followed.
7326
7327 @cindex Package @code{Task_Attributes}
7328 @findex Task_Attributes
7329 @unnumberedsec C.7.2(30): The Package Task_Attributes
7330 @sp 1
7331 @cartouche
7332 Some implementations are targeted to domains in which memory use at run
7333 time must be completely deterministic.  For such implementations, it is
7334 recommended that the storage for task attributes will be pre-allocated
7335 statically and not from the heap.  This can be accomplished by either
7336 placing restrictions on the number and the size of the task's
7337 attributes, or by using the pre-allocated storage for the first @var{N}
7338 attribute objects, and the heap for the others.  In the latter case,
7339 @var{N} should be documented.
7340 @end cartouche
7341 Not followed.  This implementation is not targeted to such a domain.
7342
7343 @cindex Locking Policies
7344 @unnumberedsec D.3(17): Locking Policies
7345
7346 @sp 1
7347 @cartouche
7348 The implementation should use names that end with @samp{_Locking} for
7349 locking policies defined by the implementation.
7350 @end cartouche
7351 Followed.  A single implementation-defined locking policy is defined,
7352 whose name (@code{Inheritance_Locking}) follows this suggestion.
7353
7354 @cindex Entry queuing policies
7355 @unnumberedsec D.4(16): Entry Queuing Policies
7356 @sp 1
7357 @cartouche
7358 Names that end with @samp{_Queuing} should be used
7359 for all implementation-defined queuing policies.
7360 @end cartouche
7361 Followed.  No such implementation-defined queuing policies exist.
7362
7363 @cindex Preemptive abort
7364 @unnumberedsec D.6(9-10): Preemptive Abort
7365 @sp 1
7366 @cartouche
7367 Even though the @code{abort_statement} is included in the list of
7368 potentially blocking operations (see 9.5.1), it is recommended that this
7369 statement be implemented in a way that never requires the task executing
7370 the @code{abort_statement} to block.
7371 @end cartouche
7372 Followed.
7373
7374 @sp 1
7375 @cartouche
7376 On a multi-processor, the delay associated with aborting a task on
7377 another processor should be bounded; the implementation should use
7378 periodic polling, if necessary, to achieve this.
7379 @end cartouche
7380 Followed.
7381
7382 @cindex Tasking restrictions
7383 @unnumberedsec D.7(21): Tasking Restrictions
7384 @sp 1
7385 @cartouche
7386 When feasible, the implementation should take advantage of the specified
7387 restrictions to produce a more efficient implementation.
7388 @end cartouche
7389 GNAT currently takes advantage of these restrictions by providing an optimized
7390 run time when the Ravenscar profile and the GNAT restricted run time set
7391 of restrictions are specified.  See pragma @code{Profile (Ravenscar)} and
7392 pragma @code{Profile (Restricted)} for more details.
7393
7394 @cindex Time, monotonic
7395 @unnumberedsec D.8(47-49): Monotonic Time
7396 @sp 1
7397 @cartouche
7398 When appropriate, implementations should provide configuration
7399 mechanisms to change the value of @code{Tick}.
7400 @end cartouche
7401 Such configuration mechanisms are not appropriate to this implementation
7402 and are thus not supported.
7403
7404 @sp 1
7405 @cartouche
7406 It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
7407 be implemented as transformations of the same time base.
7408 @end cartouche
7409 Followed.
7410
7411 @sp 1
7412 @cartouche
7413 It is recommended that the @dfn{best} time base which exists in
7414 the underlying system be available to the application through
7415 @code{Clock}.  @dfn{Best} may mean highest accuracy or largest range.
7416 @end cartouche
7417 Followed.
7418
7419 @cindex Partition communication subsystem
7420 @cindex PCS
7421 @unnumberedsec E.5(28-29): Partition Communication Subsystem
7422 @sp 1
7423 @cartouche
7424 Whenever possible, the PCS on the called partition should allow for
7425 multiple tasks to call the RPC-receiver with different messages and
7426 should allow them to block until the corresponding subprogram body
7427 returns.
7428 @end cartouche
7429 Followed by GLADE, a separately supplied PCS that can be used with
7430 GNAT.
7431
7432 @sp 1
7433 @cartouche
7434 The @code{Write} operation on a stream of type @code{Params_Stream_Type}
7435 should raise @code{Storage_Error} if it runs out of space trying to
7436 write the @code{Item} into the stream.
7437 @end cartouche
7438 Followed by GLADE, a separately supplied PCS that can be used with
7439 GNAT@.
7440
7441 @cindex COBOL support
7442 @unnumberedsec F(7): COBOL Support
7443 @sp 1
7444 @cartouche
7445 If COBOL (respectively, C) is widely supported in the target
7446 environment, implementations supporting the Information Systems Annex
7447 should provide the child package @code{Interfaces.COBOL} (respectively,
7448 @code{Interfaces.C}) specified in Annex B and should support a
7449 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
7450 pragmas (see Annex B), thus allowing Ada programs to interface with
7451 programs written in that language.
7452 @end cartouche
7453 Followed.
7454
7455 @cindex Decimal radix support
7456 @unnumberedsec F.1(2): Decimal Radix Support
7457 @sp 1
7458 @cartouche
7459 Packed decimal should be used as the internal representation for objects
7460 of subtype @var{S} when @var{S}'Machine_Radix = 10.
7461 @end cartouche
7462 Not followed.  GNAT ignores @var{S}'Machine_Radix and always uses binary
7463 representations.
7464
7465 @cindex Numerics
7466 @unnumberedsec G: Numerics
7467 @sp 2
7468 @cartouche
7469 If Fortran (respectively, C) is widely supported in the target
7470 environment, implementations supporting the Numerics Annex
7471 should provide the child package @code{Interfaces.Fortran} (respectively,
7472 @code{Interfaces.C}) specified in Annex B and should support a
7473 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
7474 pragmas (see Annex B), thus allowing Ada programs to interface with
7475 programs written in that language.
7476 @end cartouche
7477 Followed.
7478
7479 @cindex Complex types
7480 @unnumberedsec G.1.1(56-58): Complex Types
7481 @sp 2
7482 @cartouche
7483 Because the usual mathematical meaning of multiplication of a complex
7484 operand and a real operand is that of the scaling of both components of
7485 the former by the latter, an implementation should not perform this
7486 operation by first promoting the real operand to complex type and then
7487 performing a full complex multiplication.  In systems that, in the
7488 future, support an Ada binding to IEC 559:1989, the latter technique
7489 will not generate the required result when one of the components of the
7490 complex operand is infinite.  (Explicit multiplication of the infinite
7491 component by the zero component obtained during promotion yields a NaN
7492 that propagates into the final result.) Analogous advice applies in the
7493 case of multiplication of a complex operand and a pure-imaginary
7494 operand, and in the case of division of a complex operand by a real or
7495 pure-imaginary operand.
7496 @end cartouche
7497 Not followed.
7498
7499 @sp 1
7500 @cartouche
7501 Similarly, because the usual mathematical meaning of addition of a
7502 complex operand and a real operand is that the imaginary operand remains
7503 unchanged, an implementation should not perform this operation by first
7504 promoting the real operand to complex type and then performing a full
7505 complex addition.  In implementations in which the @code{Signed_Zeros}
7506 attribute of the component type is @code{True} (and which therefore
7507 conform to IEC 559:1989 in regard to the handling of the sign of zero in
7508 predefined arithmetic operations), the latter technique will not
7509 generate the required result when the imaginary component of the complex
7510 operand is a negatively signed zero.  (Explicit addition of the negative
7511 zero to the zero obtained during promotion yields a positive zero.)
7512 Analogous advice applies in the case of addition of a complex operand
7513 and a pure-imaginary operand, and in the case of subtraction of a
7514 complex operand and a real or pure-imaginary operand.
7515 @end cartouche
7516 Not followed.
7517
7518 @sp 1
7519 @cartouche
7520 Implementations in which @code{Real'Signed_Zeros} is @code{True} should
7521 attempt to provide a rational treatment of the signs of zero results and
7522 result components.  As one example, the result of the @code{Argument}
7523 function should have the sign of the imaginary component of the
7524 parameter @code{X} when the point represented by that parameter lies on
7525 the positive real axis; as another, the sign of the imaginary component
7526 of the @code{Compose_From_Polar} function should be the same as
7527 (respectively, the opposite of) that of the @code{Argument} parameter when that
7528 parameter has a value of zero and the @code{Modulus} parameter has a
7529 nonnegative (respectively, negative) value.
7530 @end cartouche
7531 Followed.
7532
7533 @cindex Complex elementary functions
7534 @unnumberedsec G.1.2(49): Complex Elementary Functions
7535 @sp 1
7536 @cartouche
7537 Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
7538 @code{True} should attempt to provide a rational treatment of the signs
7539 of zero results and result components.  For example, many of the complex
7540 elementary functions have components that are odd functions of one of
7541 the parameter components; in these cases, the result component should
7542 have the sign of the parameter component at the origin.  Other complex
7543 elementary functions have zero components whose sign is opposite that of
7544 a parameter component at the origin, or is always positive or always
7545 negative.
7546 @end cartouche
7547 Followed.
7548
7549 @cindex Accuracy requirements
7550 @unnumberedsec G.2.4(19): Accuracy Requirements
7551 @sp 1
7552 @cartouche
7553 The versions of the forward trigonometric functions without a
7554 @code{Cycle} parameter should not be implemented by calling the
7555 corresponding version with a @code{Cycle} parameter of
7556 @code{2.0*Numerics.Pi}, since this will not provide the required
7557 accuracy in some portions of the domain.  For the same reason, the
7558 version of @code{Log} without a @code{Base} parameter should not be
7559 implemented by calling the corresponding version with a @code{Base}
7560 parameter of @code{Numerics.e}.
7561 @end cartouche
7562 Followed.
7563
7564 @cindex Complex arithmetic accuracy
7565 @cindex Accuracy, complex arithmetic
7566 @unnumberedsec G.2.6(15): Complex Arithmetic Accuracy
7567
7568 @sp 1
7569 @cartouche
7570 The version of the @code{Compose_From_Polar} function without a
7571 @code{Cycle} parameter should not be implemented by calling the
7572 corresponding version with a @code{Cycle} parameter of
7573 @code{2.0*Numerics.Pi}, since this will not provide the required
7574 accuracy in some portions of the domain.
7575 @end cartouche
7576 Followed.
7577
7578 @c -----------------------------------------
7579 @node Implementation Defined Characteristics
7580 @chapter Implementation Defined Characteristics
7581
7582 @noindent
7583 In addition to the implementation dependent pragmas and attributes, and
7584 the implementation advice, there are a number of other Ada features
7585 that are potentially implementation dependent.  These are mentioned
7586 throughout the Ada Reference Manual, and are summarized in annex M@.
7587
7588 A requirement for conforming Ada compilers is that they provide
7589 documentation describing how the implementation deals with each of these
7590 issues.  In this chapter, you will find each point in annex M listed
7591 followed by a description in italic font of how GNAT
7592 @c SGI info:
7593 @ignore
7594 in the ProDev Ada
7595 implementation on IRIX 5.3 operating system or greater
7596 @end ignore
7597 handles the implementation dependence.
7598
7599 You can use this chapter as a guide to minimizing implementation
7600 dependent features in your programs if portability to other compilers
7601 and other operating systems is an important consideration.  The numbers
7602 in each section below correspond to the paragraph number in the Ada
7603 Reference Manual.
7604
7605 @sp 1
7606 @cartouche
7607 @noindent
7608 @strong{2}.  Whether or not each recommendation given in Implementation
7609 Advice is followed.  See 1.1.2(37).
7610 @end cartouche
7611 @noindent
7612 @xref{Implementation Advice}.
7613
7614 @sp 1
7615 @cartouche
7616 @noindent
7617 @strong{3}.  Capacity limitations of the implementation.  See 1.1.3(3).
7618 @end cartouche
7619 @noindent
7620 The complexity of programs that can be processed is limited only by the
7621 total amount of available virtual memory, and disk space for the
7622 generated object files.
7623
7624 @sp 1
7625 @cartouche
7626 @noindent
7627 @strong{4}.  Variations from the standard that are impractical to avoid
7628 given the implementation's execution environment.  See 1.1.3(6).
7629 @end cartouche
7630 @noindent
7631 There are no variations from the standard.
7632
7633 @sp 1
7634 @cartouche
7635 @noindent
7636 @strong{5}.  Which @code{code_statement}s cause external
7637 interactions.  See 1.1.3(10).
7638 @end cartouche
7639 @noindent
7640 Any @code{code_statement} can potentially cause external interactions.
7641
7642 @sp 1
7643 @cartouche
7644 @noindent
7645 @strong{6}.  The coded representation for the text of an Ada
7646 program.  See 2.1(4).
7647 @end cartouche
7648 @noindent
7649 See separate section on source representation.
7650
7651 @sp 1
7652 @cartouche
7653 @noindent
7654 @strong{7}.  The control functions allowed in comments.  See 2.1(14).
7655 @end cartouche
7656 @noindent
7657 See separate section on source representation.
7658
7659 @sp 1
7660 @cartouche
7661 @noindent
7662 @strong{8}.  The representation for an end of line.  See 2.2(2).
7663 @end cartouche
7664 @noindent
7665 See separate section on source representation.
7666
7667 @sp 1
7668 @cartouche
7669 @noindent
7670 @strong{9}.  Maximum supported line length and lexical element
7671 length.  See 2.2(15).
7672 @end cartouche
7673 @noindent
7674 The maximum line length is 255 characters and the maximum length of a
7675 lexical element is also 255 characters.
7676
7677 @sp 1
7678 @cartouche
7679 @noindent
7680 @strong{10}.  Implementation defined pragmas.  See 2.8(14).
7681 @end cartouche
7682 @noindent
7683
7684 @xref{Implementation Defined Pragmas}.
7685
7686 @sp 1
7687 @cartouche
7688 @noindent
7689 @strong{11}.  Effect of pragma @code{Optimize}.  See 2.8(27).
7690 @end cartouche
7691 @noindent
7692 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
7693 parameter, checks that the optimization flag is set, and aborts if it is
7694 not.
7695
7696 @sp 1
7697 @cartouche
7698 @noindent
7699 @strong{12}.  The sequence of characters of the value returned by
7700 @code{@var{S}'Image} when some of the graphic characters of
7701 @code{@var{S}'Wide_Image} are not defined in @code{Character}.  See
7702 3.5(37).
7703 @end cartouche
7704 @noindent
7705 The sequence of characters is as defined by the wide character encoding
7706 method used for the source.  See section on source representation for
7707 further details.
7708
7709 @sp 1
7710 @cartouche
7711 @noindent
7712 @strong{13}.  The predefined integer types declared in
7713 @code{Standard}.  See 3.5.4(25).
7714 @end cartouche
7715 @noindent
7716 @table @code
7717 @item Short_Short_Integer
7718 8 bit signed
7719 @item Short_Integer
7720 (Short) 16 bit signed
7721 @item Integer
7722 32 bit signed
7723 @item Long_Integer
7724 64 bit signed (Alpha OpenVMS only)
7725 32 bit signed (all other targets)
7726 @item Long_Long_Integer
7727 64 bit signed
7728 @end table
7729
7730 @sp 1
7731 @cartouche
7732 @noindent
7733 @strong{14}.  Any nonstandard integer types and the operators defined
7734 for them.  See 3.5.4(26).
7735 @end cartouche
7736 @noindent
7737 There are no nonstandard integer types.
7738
7739 @sp 1
7740 @cartouche
7741 @noindent
7742 @strong{15}.  Any nonstandard real types and the operators defined for
7743 them.  See 3.5.6(8).
7744 @end cartouche
7745 @noindent
7746 There are no nonstandard real types.
7747
7748 @sp 1
7749 @cartouche
7750 @noindent
7751 @strong{16}.  What combinations of requested decimal precision and range
7752 are supported for floating point types.  See 3.5.7(7).
7753 @end cartouche
7754 @noindent
7755 The precision and range is as defined by the IEEE standard.
7756
7757 @sp 1
7758 @cartouche
7759 @noindent
7760 @strong{17}.  The predefined floating point types declared in
7761 @code{Standard}.  See 3.5.7(16).
7762 @end cartouche
7763 @noindent
7764 @table @code
7765 @item Short_Float
7766 32 bit IEEE short
7767 @item Float
7768 (Short) 32 bit IEEE short
7769 @item Long_Float
7770 64 bit IEEE long
7771 @item Long_Long_Float
7772 64 bit IEEE long (80 bit IEEE long on x86 processors)
7773 @end table
7774
7775 @sp 1
7776 @cartouche
7777 @noindent
7778 @strong{18}.  The small of an ordinary fixed point type.  See 3.5.9(8).
7779 @end cartouche
7780 @noindent
7781 @code{Fine_Delta} is 2**(@minus{}63)
7782
7783 @sp 1
7784 @cartouche
7785 @noindent
7786 @strong{19}.  What combinations of small, range, and digits are
7787 supported for fixed point types.  See 3.5.9(10).
7788 @end cartouche
7789 @noindent
7790 Any combinations are permitted that do not result in a small less than
7791 @code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
7792 If the mantissa is larger than 53 bits on machines where Long_Long_Float
7793 is 64 bits (true of all architectures except ia32), then the output from
7794 Text_IO is accurate to only 53 bits, rather than the full mantissa.  This
7795 is because floating-point conversions are used to convert fixed point.
7796
7797 @sp 1
7798 @cartouche
7799 @noindent
7800 @strong{20}.  The result of @code{Tags.Expanded_Name} for types declared
7801 within an unnamed @code{block_statement}.  See 3.9(10).
7802 @end cartouche
7803 @noindent
7804 Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
7805 decimal integer are allocated.
7806
7807 @sp 1
7808 @cartouche
7809 @noindent
7810 @strong{21}.  Implementation-defined attributes.  See 4.1.4(12).
7811 @end cartouche
7812 @noindent
7813 @xref{Implementation Defined Attributes}.
7814
7815 @sp 1
7816 @cartouche
7817 @noindent
7818 @strong{22}.  Any implementation-defined time types.  See 9.6(6).
7819 @end cartouche
7820 @noindent
7821 There are no implementation-defined time types.
7822
7823 @sp 1
7824 @cartouche
7825 @noindent
7826 @strong{23}.  The time base associated with relative delays.
7827 @end cartouche
7828 @noindent
7829 See 9.6(20).  The time base used is that provided by the C library
7830 function @code{gettimeofday}.
7831
7832 @sp 1
7833 @cartouche
7834 @noindent
7835 @strong{24}.  The time base of the type @code{Calendar.Time}.  See
7836 9.6(23).
7837 @end cartouche
7838 @noindent
7839 The time base used is that provided by the C library function
7840 @code{gettimeofday}.
7841
7842 @sp 1
7843 @cartouche
7844 @noindent
7845 @strong{25}.  The time zone used for package @code{Calendar}
7846 operations.  See 9.6(24).
7847 @end cartouche
7848 @noindent
7849 The time zone used by package @code{Calendar} is the current system time zone
7850 setting for local time, as accessed by the C library function
7851 @code{localtime}.
7852
7853 @sp 1
7854 @cartouche
7855 @noindent
7856 @strong{26}.  Any limit on @code{delay_until_statements} of
7857 @code{select_statements}.  See 9.6(29).
7858 @end cartouche
7859 @noindent
7860 There are no such limits.
7861
7862 @sp 1
7863 @cartouche
7864 @noindent
7865 @strong{27}.  Whether or not two non-overlapping parts of a composite
7866 object are independently addressable, in the case where packing, record
7867 layout, or @code{Component_Size} is specified for the object.  See
7868 9.10(1).
7869 @end cartouche
7870 @noindent
7871 Separate components are independently addressable if they do not share
7872 overlapping storage units.
7873
7874 @sp 1
7875 @cartouche
7876 @noindent
7877 @strong{28}.  The representation for a compilation.  See 10.1(2).
7878 @end cartouche
7879 @noindent
7880 A compilation is represented by a sequence of files presented to the
7881 compiler in a single invocation of the @command{gcc} command.
7882
7883 @sp 1
7884 @cartouche
7885 @noindent
7886 @strong{29}.  Any restrictions on compilations that contain multiple
7887 compilation_units.  See 10.1(4).
7888 @end cartouche
7889 @noindent
7890 No single file can contain more than one compilation unit, but any
7891 sequence of files can be presented to the compiler as a single
7892 compilation.
7893
7894 @sp 1
7895 @cartouche
7896 @noindent
7897 @strong{30}.  The mechanisms for creating an environment and for adding
7898 and replacing compilation units.  See 10.1.4(3).
7899 @end cartouche
7900 @noindent
7901 See separate section on compilation model.
7902
7903 @sp 1
7904 @cartouche
7905 @noindent
7906 @strong{31}.  The manner of explicitly assigning library units to a
7907 partition.  See 10.2(2).
7908 @end cartouche
7909 @noindent
7910 If a unit contains an Ada main program, then the Ada units for the partition
7911 are determined by recursive application of the rules in the Ada Reference
7912 Manual section 10.2(2-6).  In other words, the Ada units will be those that
7913 are needed by the main program, and then this definition of need is applied
7914 recursively to those units, and the partition contains the transitive
7915 closure determined by this relationship.  In short, all the necessary units
7916 are included, with no need to explicitly specify the list.  If additional
7917 units are required, e.g.@: by foreign language units, then all units must be
7918 mentioned in the context clause of one of the needed Ada units.
7919
7920 If the partition contains no main program, or if the main program is in
7921 a language other than Ada, then GNAT
7922 provides the binder options @option{-z} and @option{-n} respectively, and in
7923 this case a list of units can be explicitly supplied to the binder for
7924 inclusion in the partition (all units needed by these units will also
7925 be included automatically).  For full details on the use of these
7926 options, refer to @ref{The GNAT Make Program gnatmake,,, gnat_ugn,
7927 @value{EDITION} User's Guide}.
7928
7929 @sp 1
7930 @cartouche
7931 @noindent
7932 @strong{32}.  The implementation-defined means, if any, of specifying
7933 which compilation units are needed by a given compilation unit.  See
7934 10.2(2).
7935 @end cartouche
7936 @noindent
7937 The units needed by a given compilation unit are as defined in
7938 the Ada Reference Manual section 10.2(2-6).  There are no
7939 implementation-defined pragmas or other implementation-defined
7940 means for specifying needed units.
7941
7942 @sp 1
7943 @cartouche
7944 @noindent
7945 @strong{33}.  The manner of designating the main subprogram of a
7946 partition.  See 10.2(7).
7947 @end cartouche
7948 @noindent
7949 The main program is designated by providing the name of the
7950 corresponding @file{ALI} file as the input parameter to the binder.
7951
7952 @sp 1
7953 @cartouche
7954 @noindent
7955 @strong{34}.  The order of elaboration of @code{library_items}.  See
7956 10.2(18).
7957 @end cartouche
7958 @noindent
7959 The first constraint on ordering is that it meets the requirements of
7960 Chapter 10 of the Ada Reference Manual.  This still leaves some
7961 implementation dependent choices, which are resolved by first
7962 elaborating bodies as early as possible (i.e., in preference to specs
7963 where there is a choice), and second by evaluating the immediate with
7964 clauses of a unit to determine the probably best choice, and
7965 third by elaborating in alphabetical order of unit names
7966 where a choice still remains.
7967
7968 @sp 1
7969 @cartouche
7970 @noindent
7971 @strong{35}.  Parameter passing and function return for the main
7972 subprogram.  See 10.2(21).
7973 @end cartouche
7974 @noindent
7975 The main program has no parameters.  It may be a procedure, or a function
7976 returning an integer type.  In the latter case, the returned integer
7977 value is the return code of the program (overriding any value that
7978 may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
7979
7980 @sp 1
7981 @cartouche
7982 @noindent
7983 @strong{36}.  The mechanisms for building and running partitions.  See
7984 10.2(24).
7985 @end cartouche
7986 @noindent
7987 GNAT itself supports programs with only a single partition.  The GNATDIST
7988 tool provided with the GLADE package (which also includes an implementation
7989 of the PCS) provides a completely flexible method for building and running
7990 programs consisting of multiple partitions.  See the separate GLADE manual
7991 for details.
7992
7993 @sp 1
7994 @cartouche
7995 @noindent
7996 @strong{37}.  The details of program execution, including program
7997 termination.  See 10.2(25).
7998 @end cartouche
7999 @noindent
8000 See separate section on compilation model.
8001
8002 @sp 1
8003 @cartouche
8004 @noindent
8005 @strong{38}.  The semantics of any non-active partitions supported by the
8006 implementation.  See 10.2(28).
8007 @end cartouche
8008 @noindent
8009 Passive partitions are supported on targets where shared memory is
8010 provided by the operating system.  See the GLADE reference manual for
8011 further details.
8012
8013 @sp 1
8014 @cartouche
8015 @noindent
8016 @strong{39}.  The information returned by @code{Exception_Message}.  See
8017 11.4.1(10).
8018 @end cartouche
8019 @noindent
8020 Exception message returns the null string unless a specific message has
8021 been passed by the program.
8022
8023 @sp 1
8024 @cartouche
8025 @noindent
8026 @strong{40}.  The result of @code{Exceptions.Exception_Name} for types
8027 declared within an unnamed @code{block_statement}.  See 11.4.1(12).
8028 @end cartouche
8029 @noindent
8030 Blocks have implementation defined names of the form @code{B@var{nnn}}
8031 where @var{nnn} is an integer.
8032
8033 @sp 1
8034 @cartouche
8035 @noindent
8036 @strong{41}.  The information returned by
8037 @code{Exception_Information}.  See 11.4.1(13).
8038 @end cartouche
8039 @noindent
8040 @code{Exception_Information} returns a string in the following format:
8041
8042 @smallexample
8043 @emph{Exception_Name:} nnnnn
8044 @emph{Message:} mmmmm
8045 @emph{PID:} ppp
8046 @emph{Call stack traceback locations:}
8047 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
8048 @end smallexample
8049
8050 @noindent
8051 where
8052
8053 @itemize @bullet
8054 @item
8055 @code{nnnn} is the fully qualified name of the exception in all upper
8056 case letters. This line is always present.
8057
8058 @item
8059 @code{mmmm} is the message (this line present only if message is non-null)
8060
8061 @item
8062 @code{ppp} is the Process Id value as a decimal integer (this line is
8063 present only if the Process Id is nonzero). Currently we are
8064 not making use of this field.
8065
8066 @item
8067 The Call stack traceback locations line and the following values
8068 are present only if at least one traceback location was recorded.
8069 The values are given in C style format, with lower case letters
8070 for a-f, and only as many digits present as are necessary.
8071 @end itemize
8072
8073 @noindent
8074 The line terminator sequence at the end of each line, including
8075 the last line is a single @code{LF} character (@code{16#0A#}).
8076
8077 @sp 1
8078 @cartouche
8079 @noindent
8080 @strong{42}.  Implementation-defined check names.  See 11.5(27).
8081 @end cartouche
8082 @noindent
8083 The implementation defined check name Alignment_Check controls checking of
8084 address clause values for proper alignment (that is, the address supplied
8085 must be consistent with the alignment of the type).
8086
8087 In addition, a user program can add implementation-defined check names
8088 by means of the pragma Check_Name.
8089
8090 @sp 1
8091 @cartouche
8092 @noindent
8093 @strong{43}.  The interpretation of each aspect of representation.  See
8094 13.1(20).
8095 @end cartouche
8096 @noindent
8097 See separate section on data representations.
8098
8099 @sp 1
8100 @cartouche
8101 @noindent
8102 @strong{44}.  Any restrictions placed upon representation items.  See
8103 13.1(20).
8104 @end cartouche
8105 @noindent
8106 See separate section on data representations.
8107
8108 @sp 1
8109 @cartouche
8110 @noindent
8111 @strong{45}.  The meaning of @code{Size} for indefinite subtypes.  See
8112 13.3(48).
8113 @end cartouche
8114 @noindent
8115 Size for an indefinite subtype is the maximum possible size, except that
8116 for the case of a subprogram parameter, the size of the parameter object
8117 is the actual size.
8118
8119 @sp 1
8120 @cartouche
8121 @noindent
8122 @strong{46}.  The default external representation for a type tag.  See
8123 13.3(75).
8124 @end cartouche
8125 @noindent
8126 The default external representation for a type tag is the fully expanded
8127 name of the type in upper case letters.
8128
8129 @sp 1
8130 @cartouche
8131 @noindent
8132 @strong{47}.  What determines whether a compilation unit is the same in
8133 two different partitions.  See 13.3(76).
8134 @end cartouche
8135 @noindent
8136 A compilation unit is the same in two different partitions if and only
8137 if it derives from the same source file.
8138
8139 @sp 1
8140 @cartouche
8141 @noindent
8142 @strong{48}.  Implementation-defined components.  See 13.5.1(15).
8143 @end cartouche
8144 @noindent
8145 The only implementation defined component is the tag for a tagged type,
8146 which contains a pointer to the dispatching table.
8147
8148 @sp 1
8149 @cartouche
8150 @noindent
8151 @strong{49}.  If @code{Word_Size} = @code{Storage_Unit}, the default bit
8152 ordering.  See 13.5.3(5).
8153 @end cartouche
8154 @noindent
8155 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
8156 implementation, so no non-default bit ordering is supported.  The default
8157 bit ordering corresponds to the natural endianness of the target architecture.
8158
8159 @sp 1
8160 @cartouche
8161 @noindent
8162 @strong{50}.  The contents of the visible part of package @code{System}
8163 and its language-defined children.  See 13.7(2).
8164 @end cartouche
8165 @noindent
8166 See the definition of these packages in files @file{system.ads} and
8167 @file{s-stoele.ads}.
8168
8169 @sp 1
8170 @cartouche
8171 @noindent
8172 @strong{51}.  The contents of the visible part of package
8173 @code{System.Machine_Code}, and the meaning of
8174 @code{code_statements}.  See 13.8(7).
8175 @end cartouche
8176 @noindent
8177 See the definition and documentation in file @file{s-maccod.ads}.
8178
8179 @sp 1
8180 @cartouche
8181 @noindent
8182 @strong{52}.  The effect of unchecked conversion.  See 13.9(11).
8183 @end cartouche
8184 @noindent
8185 Unchecked conversion between types of the same size
8186 results in an uninterpreted transmission of the bits from one type
8187 to the other.  If the types are of unequal sizes, then in the case of
8188 discrete types, a shorter source is first zero or sign extended as
8189 necessary, and a shorter target is simply truncated on the left.
8190 For all non-discrete types, the source is first copied if necessary
8191 to ensure that the alignment requirements of the target are met, then
8192 a pointer is constructed to the source value, and the result is obtained
8193 by dereferencing this pointer after converting it to be a pointer to the
8194 target type. Unchecked conversions where the target subtype is an
8195 unconstrained array are not permitted. If the target alignment is
8196 greater than the source alignment, then a copy of the result is
8197 made with appropriate alignment
8198
8199 @sp 1
8200 @cartouche
8201 @noindent
8202 @strong{53}.  The manner of choosing a storage pool for an access type
8203 when @code{Storage_Pool} is not specified for the type.  See 13.11(17).
8204 @end cartouche
8205 @noindent
8206 There are 3 different standard pools used by the compiler when
8207 @code{Storage_Pool} is not specified depending whether the type is local
8208 to a subprogram or defined at the library level and whether
8209 @code{Storage_Size}is specified or not.  See documentation in the runtime
8210 library units @code{System.Pool_Global}, @code{System.Pool_Size} and
8211 @code{System.Pool_Local} in files @file{s-poosiz.ads},
8212 @file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
8213 default pools used.
8214
8215 @sp 1
8216 @cartouche
8217 @noindent
8218 @strong{54}.  Whether or not the implementation provides user-accessible
8219 names for the standard pool type(s).  See 13.11(17).
8220 @end cartouche
8221 @noindent
8222
8223 See documentation in the sources of the run time mentioned in paragraph
8224 @strong{53} .  All these pools are accessible by means of @code{with}'ing
8225 these units.
8226
8227 @sp 1
8228 @cartouche
8229 @noindent
8230 @strong{55}.  The meaning of @code{Storage_Size}.  See 13.11(18).
8231 @end cartouche
8232 @noindent
8233 @code{Storage_Size} is measured in storage units, and refers to the
8234 total space available for an access type collection, or to the primary
8235 stack space for a task.
8236
8237 @sp 1
8238 @cartouche
8239 @noindent
8240 @strong{56}.  Implementation-defined aspects of storage pools.  See
8241 13.11(22).
8242 @end cartouche
8243 @noindent
8244 See documentation in the sources of the run time mentioned in paragraph
8245 @strong{53} for details on GNAT-defined aspects of storage pools.
8246
8247 @sp 1
8248 @cartouche
8249 @noindent
8250 @strong{57}.  The set of restrictions allowed in a pragma
8251 @code{Restrictions}.  See 13.12(7).
8252 @end cartouche
8253 @noindent
8254 All RM defined Restriction identifiers are implemented.  The following
8255 additional restriction identifiers are provided.  There are two separate
8256 lists of implementation dependent restriction identifiers.  The first
8257 set requires consistency throughout a partition (in other words, if the
8258 restriction identifier is used for any compilation unit in the partition,
8259 then all compilation units in the partition must obey the restriction.
8260
8261 @table @code
8262
8263 @item Simple_Barriers
8264 @findex Simple_Barriers
8265 This restriction ensures at compile time that barriers in entry declarations
8266 for protected types are restricted to either static boolean expressions or
8267 references to simple boolean variables defined in the private part of the
8268 protected type.  No other form of entry barriers is permitted.  This is one
8269 of the restrictions of the Ravenscar profile for limited tasking (see also
8270 pragma @code{Profile (Ravenscar)}).
8271
8272 @item Max_Entry_Queue_Length => Expr
8273 @findex Max_Entry_Queue_Length
8274 This restriction is a declaration that any protected entry compiled in
8275 the scope of the restriction has at most the specified number of
8276 tasks waiting on the entry
8277 at any one time, and so no queue is required.  This restriction is not
8278 checked at compile time.  A program execution is erroneous if an attempt
8279 is made to queue more than the specified number of tasks on such an entry.
8280
8281 @item No_Calendar
8282 @findex No_Calendar
8283 This restriction ensures at compile time that there is no implicit or
8284 explicit dependence on the package @code{Ada.Calendar}.
8285
8286 @item No_Default_Initialization
8287 @findex No_Default_Initialization
8288
8289 This restriction prohibits any instance of default initialization of variables.
8290 The binder implements a consistency rule which prevents any unit compiled
8291 without the restriction from with'ing a unit with the restriction (this allows
8292 the generation of initialization procedures to be skipped, since you can be
8293 sure that no call is ever generated to an initialization procedure in a unit
8294 with the restriction active). If used in conjunction with Initialize_Scalars or
8295 Normalize_Scalars, the effect is to prohibit all cases of variables declared
8296 without a specific initializer (including the case of OUT scalar parameters).
8297
8298 @item No_Direct_Boolean_Operators
8299 @findex No_Direct_Boolean_Operators
8300 This restriction ensures that no logical (and/or/xor) or comparison
8301 operators are used on operands of type Boolean (or any type derived
8302 from Boolean). This is intended for use in safety critical programs
8303 where the certification protocol requires the use of short-circuit
8304 (and then, or else) forms for all composite boolean operations.
8305
8306 @item No_Dispatching_Calls
8307 @findex No_Dispatching_Calls
8308 This restriction ensures at compile time that the code generated by the
8309 compiler involves no dispatching calls. The use of this restriction allows the
8310 safe use of record extensions, classwide membership tests and other classwide
8311 features not involving implicit dispatching. This restriction ensures that
8312 the code contains no indirect calls through a dispatching mechanism. Note that
8313 this includes internally-generated calls created by the compiler, for example
8314 in the implementation of class-wide objects assignments. The
8315 membership test is allowed in the presence of this restriction, because its
8316 implementation requires no dispatching.
8317 This restriction is comparable to the official Ada restriction
8318 @code{No_Dispatch} except that it is a bit less restrictive in that it allows
8319 all classwide constructs that do not imply dispatching.
8320 The following example indicates constructs that violate this restriction.
8321
8322 @smallexample
8323 package Pkg is
8324   type T is tagged record
8325     Data : Natural;
8326   end record;
8327   procedure P (X : T);
8328
8329   type DT is new T with record
8330     More_Data : Natural;
8331   end record;
8332   procedure Q (X : DT);
8333 end Pkg;
8334
8335 with Pkg; use Pkg;
8336 procedure Example is
8337   procedure Test (O : T'Class) is
8338     N : Natural  := O'Size;--  Error: Dispatching call
8339     C : T'Class := O;      --  Error: implicit Dispatching Call
8340   begin
8341     if O in DT'Class then  --  OK   : Membership test
8342        Q (DT (O));         --  OK   : Type conversion plus direct call
8343     else
8344        P (O);              --  Error: Dispatching call
8345     end if;
8346   end Test;
8347
8348   Obj : DT;
8349 begin
8350   P (Obj);                 --  OK   : Direct call
8351   P (T (Obj));             --  OK   : Type conversion plus direct call
8352   P (T'Class (Obj));       --  Error: Dispatching call
8353
8354   Test (Obj);              --  OK   : Type conversion
8355
8356   if Obj in T'Class then   --  OK   : Membership test
8357      null;
8358   end if;
8359 end Example;
8360 @end smallexample
8361
8362 @item No_Dynamic_Attachment
8363 @findex No_Dynamic_Attachment
8364 This restriction ensures that there is no call to any of the operations
8365 defined in package Ada.Interrupts.
8366
8367 @item No_Enumeration_Maps
8368 @findex No_Enumeration_Maps
8369 This restriction ensures at compile time that no operations requiring
8370 enumeration maps are used (that is Image and Value attributes applied
8371 to enumeration types).
8372
8373 @item No_Entry_Calls_In_Elaboration_Code
8374 @findex No_Entry_Calls_In_Elaboration_Code
8375 This restriction ensures at compile time that no task or protected entry
8376 calls are made during elaboration code.  As a result of the use of this
8377 restriction, the compiler can assume that no code past an accept statement
8378 in a task can be executed at elaboration time.
8379
8380 @item No_Exception_Handlers
8381 @findex No_Exception_Handlers
8382 This restriction ensures at compile time that there are no explicit
8383 exception handlers. It also indicates that no exception propagation will
8384 be provided. In this mode, exceptions may be raised but will result in
8385 an immediate call to the last chance handler, a routine that the user
8386 must define with the following profile:
8387
8388 @smallexample @c ada
8389 procedure Last_Chance_Handler
8390   (Source_Location : System.Address; Line : Integer);
8391 pragma Export (C, Last_Chance_Handler,
8392                "__gnat_last_chance_handler");
8393 @end smallexample
8394
8395 The parameter is a C null-terminated string representing a message to be
8396 associated with the exception (typically the source location of the raise
8397 statement generated by the compiler). The Line parameter when nonzero
8398 represents the line number in the source program where the raise occurs.
8399
8400 @item No_Exception_Propagation
8401 @findex No_Exception_Propagation
8402 This restriction guarantees that exceptions are never propagated to an outer
8403 subprogram scope). The only case in which an exception may be raised is when
8404 the handler is statically in the same subprogram, so that the effect of a raise
8405 is essentially like a goto statement. Any other raise statement (implicit or
8406 explicit) will be considered unhandled. Exception handlers are allowed, but may
8407 not contain an exception occurrence identifier (exception choice). In addition
8408 use of the package GNAT.Current_Exception is not permitted, and reraise
8409 statements (raise with no operand) are not permitted.
8410
8411 @item No_Exception_Registration
8412 @findex No_Exception_Registration
8413 This restriction ensures at compile time that no stream operations for
8414 types Exception_Id or Exception_Occurrence are used. This also makes it
8415 impossible to pass exceptions to or from a partition with this restriction
8416 in a distributed environment. If this exception is active, then the generated
8417 code is simplified by omitting the otherwise-required global registration
8418 of exceptions when they are declared.
8419
8420 @item No_Implicit_Conditionals
8421 @findex No_Implicit_Conditionals
8422 This restriction ensures that the generated code does not contain any
8423 implicit conditionals, either by modifying the generated code where possible,
8424 or by rejecting any construct that would otherwise generate an implicit
8425 conditional. Note that this check does not include run time constraint
8426 checks, which on some targets may generate implicit conditionals as
8427 well. To control the latter, constraint checks can be suppressed in the
8428 normal manner. Constructs generating implicit conditionals include comparisons
8429 of composite objects and the Max/Min attributes.
8430
8431 @item No_Implicit_Dynamic_Code
8432 @findex No_Implicit_Dynamic_Code
8433 @cindex trampoline
8434 This restriction prevents the compiler from building ``trampolines''.
8435 This is a structure that is built on the stack and contains dynamic
8436 code to be executed at run time. On some targets, a trampoline is
8437 built for the following features: @code{Access},
8438 @code{Unrestricted_Access}, or @code{Address} of a nested subprogram;
8439 nested task bodies; primitive operations of nested tagged types.
8440 Trampolines do not work on machines that prevent execution of stack
8441 data. For example, on windows systems, enabling DEP (data execution
8442 protection) will cause trampolines to raise an exception.
8443 Trampolines are also quite slow at run time.
8444
8445 On many targets, trampolines have been largely eliminated. Look at the
8446 version of system.ads for your target --- if it has
8447 Always_Compatible_Rep equal to False, then trampolines are largely
8448 eliminated. In particular, a trampoline is built for the following
8449 features: @code{Address} of a nested subprogram;
8450 @code{Access} or @code{Unrestricted_Access} of a nested subprogram,
8451 but only if pragma Favor_Top_Level applies, or the access type has a
8452 foreign-language convention; primitive operations of nested tagged
8453 types.
8454
8455 @item No_Implicit_Loops
8456 @findex No_Implicit_Loops
8457 This restriction ensures that the generated code does not contain any
8458 implicit @code{for} loops, either by modifying
8459 the generated code where possible,
8460 or by rejecting any construct that would otherwise generate an implicit
8461 @code{for} loop. If this restriction is active, it is possible to build
8462 large array aggregates with all static components without generating an
8463 intermediate temporary, and without generating a loop to initialize individual
8464 components. Otherwise, a loop is created for arrays larger than about 5000
8465 scalar components.
8466
8467 @item No_Initialize_Scalars
8468 @findex No_Initialize_Scalars
8469 This restriction ensures that no unit in the partition is compiled with
8470 pragma Initialize_Scalars. This allows the generation of more efficient
8471 code, and in particular eliminates dummy null initialization routines that
8472 are otherwise generated for some record and array types.
8473
8474 @item No_Local_Protected_Objects
8475 @findex No_Local_Protected_Objects
8476 This restriction ensures at compile time that protected objects are
8477 only declared at the library level.
8478
8479 @item No_Protected_Type_Allocators
8480 @findex No_Protected_Type_Allocators
8481 This restriction ensures at compile time that there are no allocator
8482 expressions that attempt to allocate protected objects.
8483
8484 @item No_Secondary_Stack
8485 @findex No_Secondary_Stack
8486 This restriction ensures at compile time that the generated code does not
8487 contain any reference to the secondary stack.  The secondary stack is used
8488 to implement functions returning unconstrained objects (arrays or records)
8489 on some targets.
8490
8491 @item No_Select_Statements
8492 @findex No_Select_Statements
8493 This restriction ensures at compile time no select statements of any kind
8494 are permitted, that is the keyword @code{select} may not appear.
8495 This is one of the restrictions of the Ravenscar
8496 profile for limited tasking (see also pragma @code{Profile (Ravenscar)}).
8497
8498 @item No_Standard_Storage_Pools
8499 @findex No_Standard_Storage_Pools
8500 This restriction ensures at compile time that no access types
8501 use the standard default storage pool.  Any access type declared must
8502 have an explicit Storage_Pool attribute defined specifying a
8503 user-defined storage pool.
8504
8505 @item No_Streams
8506 @findex No_Streams
8507 This restriction ensures at compile/bind time that there are no
8508 stream objects created (and therefore no actual stream operations).
8509 This restriction does not forbid dependences on the package
8510 @code{Ada.Streams}. So it is permissible to with
8511 @code{Ada.Streams} (or another package that does so itself)
8512 as long as no actual stream objects are created.
8513
8514 @item No_Task_Attributes_Package
8515 @findex No_Task_Attributes_Package
8516 This restriction ensures at compile time that there are no implicit or
8517 explicit dependencies on the package @code{Ada.Task_Attributes}.
8518
8519 @item No_Task_Termination
8520 @findex No_Task_Termination
8521 This restriction ensures at compile time that no terminate alternatives
8522 appear in any task body.
8523
8524 @item No_Tasking
8525 @findex No_Tasking
8526 This restriction prevents the declaration of tasks or task types throughout
8527 the partition.  It is similar in effect to the use of @code{Max_Tasks => 0}
8528 except that violations are caught at compile time and cause an error message
8529 to be output either by the compiler or binder.
8530
8531 @item Static_Priorities
8532 @findex Static_Priorities
8533 This restriction ensures at compile time that all priority expressions
8534 are static, and that there are no dependencies on the package
8535 @code{Ada.Dynamic_Priorities}.
8536
8537 @item Static_Storage_Size
8538 @findex Static_Storage_Size
8539 This restriction ensures at compile time that any expression appearing
8540 in a Storage_Size pragma or attribute definition clause is static.
8541
8542 @end table
8543
8544 @noindent
8545 The second set of implementation dependent restriction identifiers
8546 does not require partition-wide consistency.
8547 The restriction may be enforced for a single
8548 compilation unit without any effect on any of the
8549 other compilation units in the partition.
8550
8551 @table @code
8552
8553 @item No_Elaboration_Code
8554 @findex No_Elaboration_Code
8555 This restriction ensures at compile time that no elaboration code is
8556 generated.  Note that this is not the same condition as is enforced
8557 by pragma @code{Preelaborate}.  There are cases in which pragma
8558 @code{Preelaborate} still permits code to be generated (e.g.@: code
8559 to initialize a large array to all zeroes), and there are cases of units
8560 which do not meet the requirements for pragma @code{Preelaborate},
8561 but for which no elaboration code is generated.  Generally, it is
8562 the case that preelaborable units will meet the restrictions, with
8563 the exception of large aggregates initialized with an others_clause,
8564 and exception declarations (which generate calls to a run-time
8565 registry procedure).  This restriction is enforced on
8566 a unit by unit basis, it need not be obeyed consistently
8567 throughout a partition.
8568
8569 In the case of aggregates with others, if the aggregate has a dynamic
8570 size, there is no way to eliminate the elaboration code (such dynamic
8571 bounds would be incompatible with @code{Preelaborate} in any case). If
8572 the bounds are static, then use of this restriction actually modifies
8573 the code choice of the compiler to avoid generating a loop, and instead
8574 generate the aggregate statically if possible, no matter how many times
8575 the data for the others clause must be repeatedly generated.
8576
8577 It is not possible to precisely document
8578 the constructs which are compatible with this restriction, since,
8579 unlike most other restrictions, this is not a restriction on the
8580 source code, but a restriction on the generated object code. For
8581 example, if the source contains a declaration:
8582
8583 @smallexample
8584    Val : constant Integer := X;
8585 @end smallexample
8586
8587 @noindent
8588 where X is not a static constant, it may be possible, depending
8589 on complex optimization circuitry, for the compiler to figure
8590 out the value of X at compile time, in which case this initialization
8591 can be done by the loader, and requires no initialization code. It
8592 is not possible to document the precise conditions under which the
8593 optimizer can figure this out.
8594
8595 Note that this the implementation of this restriction requires full
8596 code generation. If it is used in conjunction with "semantics only"
8597 checking, then some cases of violations may be missed.
8598
8599 @item No_Entry_Queue
8600 @findex No_Entry_Queue
8601 This restriction is a declaration that any protected entry compiled in
8602 the scope of the restriction has at most one task waiting on the entry
8603 at any one time, and so no queue is required.  This restriction is not
8604 checked at compile time.  A program execution is erroneous if an attempt
8605 is made to queue a second task on such an entry.
8606
8607 @item No_Implementation_Attributes
8608 @findex No_Implementation_Attributes
8609 This restriction checks at compile time that no GNAT-defined attributes
8610 are present.  With this restriction, the only attributes that can be used
8611 are those defined in the Ada Reference Manual.
8612
8613 @item No_Implementation_Pragmas
8614 @findex No_Implementation_Pragmas
8615 This restriction checks at compile time that no GNAT-defined pragmas
8616 are present.  With this restriction, the only pragmas that can be used
8617 are those defined in the Ada Reference Manual.
8618
8619 @item No_Implementation_Restrictions
8620 @findex No_Implementation_Restrictions
8621 This restriction checks at compile time that no GNAT-defined restriction
8622 identifiers (other than @code{No_Implementation_Restrictions} itself)
8623 are present.  With this restriction, the only other restriction identifiers
8624 that can be used are those defined in the Ada Reference Manual.
8625
8626 @item No_Wide_Characters
8627 @findex No_Wide_Characters
8628 This restriction ensures at compile time that no uses of the types
8629 @code{Wide_Character} or @code{Wide_String} or corresponding wide
8630 wide types
8631 appear, and that no wide or wide wide string or character literals
8632 appear in the program (that is literals representing characters not in
8633 type @code{Character}.
8634
8635 @end table
8636
8637 @sp 1
8638 @cartouche
8639 @noindent
8640 @strong{58}.  The consequences of violating limitations on
8641 @code{Restrictions} pragmas.  See 13.12(9).
8642 @end cartouche
8643 @noindent
8644 Restrictions that can be checked at compile time result in illegalities
8645 if violated.  Currently there are no other consequences of violating
8646 restrictions.
8647
8648 @sp 1
8649 @cartouche
8650 @noindent
8651 @strong{59}.  The representation used by the @code{Read} and
8652 @code{Write} attributes of elementary types in terms of stream
8653 elements.  See 13.13.2(9).
8654 @end cartouche
8655 @noindent
8656 The representation is the in-memory representation of the base type of
8657 the type, using the number of bits corresponding to the
8658 @code{@var{type}'Size} value, and the natural ordering of the machine.
8659
8660 @sp 1
8661 @cartouche
8662 @noindent
8663 @strong{60}.  The names and characteristics of the numeric subtypes
8664 declared in the visible part of package @code{Standard}.  See A.1(3).
8665 @end cartouche
8666 @noindent
8667 See items describing the integer and floating-point types supported.
8668
8669 @sp 1
8670 @cartouche
8671 @noindent
8672 @strong{61}.  The accuracy actually achieved by the elementary
8673 functions.  See A.5.1(1).
8674 @end cartouche
8675 @noindent
8676 The elementary functions correspond to the functions available in the C
8677 library.  Only fast math mode is implemented.
8678
8679 @sp 1
8680 @cartouche
8681 @noindent
8682 @strong{62}.  The sign of a zero result from some of the operators or
8683 functions in @code{Numerics.Generic_Elementary_Functions}, when
8684 @code{Float_Type'Signed_Zeros} is @code{True}.  See A.5.1(46).
8685 @end cartouche
8686 @noindent
8687 The sign of zeroes follows the requirements of the IEEE 754 standard on
8688 floating-point.
8689
8690 @sp 1
8691 @cartouche
8692 @noindent
8693 @strong{63}.  The value of
8694 @code{Numerics.Float_Random.Max_Image_Width}.  See A.5.2(27).
8695 @end cartouche
8696 @noindent
8697 Maximum image width is 649, see library file @file{a-numran.ads}.
8698
8699 @sp 1
8700 @cartouche
8701 @noindent
8702 @strong{64}.  The value of
8703 @code{Numerics.Discrete_Random.Max_Image_Width}.  See A.5.2(27).
8704 @end cartouche
8705 @noindent
8706 Maximum image width is 80, see library file @file{a-nudira.ads}.
8707
8708 @sp 1
8709 @cartouche
8710 @noindent
8711 @strong{65}.  The algorithms for random number generation.  See
8712 A.5.2(32).
8713 @end cartouche
8714 @noindent
8715 The algorithm is documented in the source files @file{a-numran.ads} and
8716 @file{a-numran.adb}.
8717
8718 @sp 1
8719 @cartouche
8720 @noindent
8721 @strong{66}.  The string representation of a random number generator's
8722 state.  See A.5.2(38).
8723 @end cartouche
8724 @noindent
8725 See the documentation contained in the file @file{a-numran.adb}.
8726
8727 @sp 1
8728 @cartouche
8729 @noindent
8730 @strong{67}.  The minimum time interval between calls to the
8731 time-dependent Reset procedure that are guaranteed to initiate different
8732 random number sequences.  See A.5.2(45).
8733 @end cartouche
8734 @noindent
8735 The minimum period between reset calls to guarantee distinct series of
8736 random numbers is one microsecond.
8737
8738 @sp 1
8739 @cartouche
8740 @noindent
8741 @strong{68}.  The values of the @code{Model_Mantissa},
8742 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
8743 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
8744 Annex is not supported.  See A.5.3(72).
8745 @end cartouche
8746 @noindent
8747 See the source file @file{ttypef.ads} for the values of all numeric
8748 attributes.
8749
8750 @sp 1
8751 @cartouche
8752 @noindent
8753 @strong{69}.  Any implementation-defined characteristics of the
8754 input-output packages.  See A.7(14).
8755 @end cartouche
8756 @noindent
8757 There are no special implementation defined characteristics for these
8758 packages.
8759
8760 @sp 1
8761 @cartouche
8762 @noindent
8763 @strong{70}.  The value of @code{Buffer_Size} in @code{Storage_IO}.  See
8764 A.9(10).
8765 @end cartouche
8766 @noindent
8767 All type representations are contiguous, and the @code{Buffer_Size} is
8768 the value of @code{@var{type}'Size} rounded up to the next storage unit
8769 boundary.
8770
8771 @sp 1
8772 @cartouche
8773 @noindent
8774 @strong{71}.  External files for standard input, standard output, and
8775 standard error See A.10(5).
8776 @end cartouche
8777 @noindent
8778 These files are mapped onto the files provided by the C streams
8779 libraries.  See source file @file{i-cstrea.ads} for further details.
8780
8781 @sp 1
8782 @cartouche
8783 @noindent
8784 @strong{72}.  The accuracy of the value produced by @code{Put}.  See
8785 A.10.9(36).
8786 @end cartouche
8787 @noindent
8788 If more digits are requested in the output than are represented by the
8789 precision of the value, zeroes are output in the corresponding least
8790 significant digit positions.
8791
8792 @sp 1
8793 @cartouche
8794 @noindent
8795 @strong{73}.  The meaning of @code{Argument_Count}, @code{Argument}, and
8796 @code{Command_Name}.  See A.15(1).
8797 @end cartouche
8798 @noindent
8799 These are mapped onto the @code{argv} and @code{argc} parameters of the
8800 main program in the natural manner.
8801
8802 @sp 1
8803 @cartouche
8804 @noindent
8805 @strong{74}.  Implementation-defined convention names.  See B.1(11).
8806 @end cartouche
8807 @noindent
8808 The following convention names are supported
8809
8810 @table @code
8811 @item  Ada
8812 Ada
8813 @item Assembler
8814 Assembly language
8815 @item Asm
8816 Synonym for Assembler
8817 @item Assembly
8818 Synonym for Assembler
8819 @item C
8820 C
8821 @item C_Pass_By_Copy
8822 Allowed only for record types, like C, but also notes that record
8823 is to be passed by copy rather than reference.
8824 @item COBOL
8825 COBOL
8826 @item C_Plus_Plus (or CPP)
8827 C++
8828 @item Default
8829 Treated the same as C
8830 @item External
8831 Treated the same as C
8832 @item Fortran
8833 Fortran
8834 @item Intrinsic
8835 For support of pragma @code{Import} with convention Intrinsic, see
8836 separate section on Intrinsic Subprograms.
8837 @item Stdcall
8838 Stdcall (used for Windows implementations only).  This convention correspond
8839 to the WINAPI (previously called Pascal convention) C/C++ convention under
8840 Windows.  A function with this convention cleans the stack before exit.
8841 @item DLL
8842 Synonym for Stdcall
8843 @item Win32
8844 Synonym for Stdcall
8845 @item Stubbed
8846 Stubbed is a special convention used to indicate that the body of the
8847 subprogram will be entirely ignored.  Any call to the subprogram
8848 is converted into a raise of the @code{Program_Error} exception.  If a
8849 pragma @code{Import} specifies convention @code{stubbed} then no body need
8850 be present at all.  This convention is useful during development for the
8851 inclusion of subprograms whose body has not yet been written.
8852
8853 @end table
8854 @noindent
8855 In addition, all otherwise unrecognized convention names are also
8856 treated as being synonymous with convention C@.  In all implementations
8857 except for VMS, use of such other names results in a warning.  In VMS
8858 implementations, these names are accepted silently.
8859
8860 @sp 1
8861 @cartouche
8862 @noindent
8863 @strong{75}.  The meaning of link names.  See B.1(36).
8864 @end cartouche
8865 @noindent
8866 Link names are the actual names used by the linker.
8867
8868 @sp 1
8869 @cartouche
8870 @noindent
8871 @strong{76}.  The manner of choosing link names when neither the link
8872 name nor the address of an imported or exported entity is specified.  See
8873 B.1(36).
8874 @end cartouche
8875 @noindent
8876 The default linker name is that which would be assigned by the relevant
8877 external language, interpreting the Ada name as being in all lower case
8878 letters.
8879
8880 @sp 1
8881 @cartouche
8882 @noindent
8883 @strong{77}.  The effect of pragma @code{Linker_Options}.  See B.1(37).
8884 @end cartouche
8885 @noindent
8886 The string passed to @code{Linker_Options} is presented uninterpreted as
8887 an argument to the link command, unless it contains ASCII.NUL characters.
8888 NUL characters if they appear act as argument separators, so for example
8889
8890 @smallexample @c ada
8891 pragma Linker_Options ("-labc" & ASCII.NUL & "-ldef");
8892 @end smallexample
8893
8894 @noindent
8895 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
8896 linker. The order of linker options is preserved for a given unit. The final
8897 list of options passed to the linker is in reverse order of the elaboration
8898 order. For example, linker options for a body always appear before the options
8899 from the corresponding package spec.
8900
8901 @sp 1
8902 @cartouche
8903 @noindent
8904 @strong{78}.  The contents of the visible part of package
8905 @code{Interfaces} and its language-defined descendants.  See B.2(1).
8906 @end cartouche
8907 @noindent
8908 See files with prefix @file{i-} in the distributed library.
8909
8910 @sp 1
8911 @cartouche
8912 @noindent
8913 @strong{79}.  Implementation-defined children of package
8914 @code{Interfaces}.  The contents of the visible part of package
8915 @code{Interfaces}.  See B.2(11).
8916 @end cartouche
8917 @noindent
8918 See files with prefix @file{i-} in the distributed library.
8919
8920 @sp 1
8921 @cartouche
8922 @noindent
8923 @strong{80}.  The types @code{Floating}, @code{Long_Floating},
8924 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
8925 @code{COBOL_Character}; and the initialization of the variables
8926 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
8927 @code{Interfaces.COBOL}.  See B.4(50).
8928 @end cartouche
8929 @noindent
8930 @table @code
8931 @item Floating
8932 Float
8933 @item Long_Floating
8934 (Floating) Long_Float
8935 @item Binary
8936 Integer
8937 @item Long_Binary
8938 Long_Long_Integer
8939 @item Decimal_Element
8940 Character
8941 @item COBOL_Character
8942 Character
8943 @end table
8944
8945 @noindent
8946 For initialization, see the file @file{i-cobol.ads} in the distributed library.
8947
8948 @sp 1
8949 @cartouche
8950 @noindent
8951 @strong{81}.  Support for access to machine instructions.  See C.1(1).
8952 @end cartouche
8953 @noindent
8954 See documentation in file @file{s-maccod.ads} in the distributed library.
8955
8956 @sp 1
8957 @cartouche
8958 @noindent
8959 @strong{82}.  Implementation-defined aspects of access to machine
8960 operations.  See C.1(9).
8961 @end cartouche
8962 @noindent
8963 See documentation in file @file{s-maccod.ads} in the distributed library.
8964
8965 @sp 1
8966 @cartouche
8967 @noindent
8968 @strong{83}.  Implementation-defined aspects of interrupts.  See C.3(2).
8969 @end cartouche
8970 @noindent
8971 Interrupts are mapped to signals or conditions as appropriate.  See
8972 definition of unit
8973 @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
8974 on the interrupts supported on a particular target.
8975
8976 @sp 1
8977 @cartouche
8978 @noindent
8979 @strong{84}.  Implementation-defined aspects of pre-elaboration.  See
8980 C.4(13).
8981 @end cartouche
8982 @noindent
8983 GNAT does not permit a partition to be restarted without reloading,
8984 except under control of the debugger.
8985
8986 @sp 1
8987 @cartouche
8988 @noindent
8989 @strong{85}.  The semantics of pragma @code{Discard_Names}.  See C.5(7).
8990 @end cartouche
8991 @noindent
8992 Pragma @code{Discard_Names} causes names of enumeration literals to
8993 be suppressed.  In the presence of this pragma, the Image attribute
8994 provides the image of the Pos of the literal, and Value accepts
8995 Pos values.
8996
8997 @sp 1
8998 @cartouche
8999 @noindent
9000 @strong{86}.  The result of the @code{Task_Identification.Image}
9001 attribute.  See C.7.1(7).
9002 @end cartouche
9003 @noindent
9004 The result of this attribute is a string that identifies
9005 the object or component that denotes a given task. If a variable @code{Var}
9006 has a task type, the image for this task will have the form @code{Var_@var{XXXXXXXX}},
9007 where the suffix
9008 is the hexadecimal representation of the virtual address of the corresponding
9009 task control block. If the variable is an array of tasks, the image of each
9010 task will have the form of an indexed component indicating the position of a
9011 given task in the array, e.g.@: @code{Group(5)_@var{XXXXXXX}}. If the task is a
9012 component of a record, the image of the task will have the form of a selected
9013 component. These rules are fully recursive, so that the image of a task that
9014 is a subcomponent of a composite object corresponds to the expression that
9015 designates this task.
9016 @noindent
9017 If a task is created by an allocator, its image depends on the context. If the
9018 allocator is part of an object declaration, the rules described above are used
9019 to construct its image, and this image is not affected by subsequent
9020 assignments. If the allocator appears within an expression, the image
9021 includes only the name of the task type.
9022 @noindent
9023 If the configuration pragma Discard_Names is present, or if the restriction
9024 No_Implicit_Heap_Allocation is in effect,  the image reduces to
9025 the numeric suffix, that is to say the hexadecimal representation of the
9026 virtual address of the control block of the task.
9027 @sp 1
9028 @cartouche
9029 @noindent
9030 @strong{87}.  The value of @code{Current_Task} when in a protected entry
9031 or interrupt handler.  See C.7.1(17).
9032 @end cartouche
9033 @noindent
9034 Protected entries or interrupt handlers can be executed by any
9035 convenient thread, so the value of @code{Current_Task} is undefined.
9036
9037 @sp 1
9038 @cartouche
9039 @noindent
9040 @strong{88}.  The effect of calling @code{Current_Task} from an entry
9041 body or interrupt handler.  See C.7.1(19).
9042 @end cartouche
9043 @noindent
9044 The effect of calling @code{Current_Task} from an entry body or
9045 interrupt handler is to return the identification of the task currently
9046 executing the code.
9047
9048 @sp 1
9049 @cartouche
9050 @noindent
9051 @strong{89}.  Implementation-defined aspects of
9052 @code{Task_Attributes}.  See C.7.2(19).
9053 @end cartouche
9054 @noindent
9055 There are no implementation-defined aspects of @code{Task_Attributes}.
9056
9057 @sp 1
9058 @cartouche
9059 @noindent
9060 @strong{90}.  Values of all @code{Metrics}.  See D(2).
9061 @end cartouche
9062 @noindent
9063 The metrics information for GNAT depends on the performance of the
9064 underlying operating system.  The sources of the run-time for tasking
9065 implementation, together with the output from @option{-gnatG} can be
9066 used to determine the exact sequence of operating systems calls made
9067 to implement various tasking constructs.  Together with appropriate
9068 information on the performance of the underlying operating system,
9069 on the exact target in use, this information can be used to determine
9070 the required metrics.
9071
9072 @sp 1
9073 @cartouche
9074 @noindent
9075 @strong{91}.  The declarations of @code{Any_Priority} and
9076 @code{Priority}.  See D.1(11).
9077 @end cartouche
9078 @noindent
9079 See declarations in file @file{system.ads}.
9080
9081 @sp 1
9082 @cartouche
9083 @noindent
9084 @strong{92}.  Implementation-defined execution resources.  See D.1(15).
9085 @end cartouche
9086 @noindent
9087 There are no implementation-defined execution resources.
9088
9089 @sp 1
9090 @cartouche
9091 @noindent
9092 @strong{93}.  Whether, on a multiprocessor, a task that is waiting for
9093 access to a protected object keeps its processor busy.  See D.2.1(3).
9094 @end cartouche
9095 @noindent
9096 On a multi-processor, a task that is waiting for access to a protected
9097 object does not keep its processor busy.
9098
9099 @sp 1
9100 @cartouche
9101 @noindent
9102 @strong{94}.  The affect of implementation defined execution resources
9103 on task dispatching.  See D.2.1(9).
9104 @end cartouche
9105 @noindent
9106 @c SGI info
9107 @ignore
9108 Tasks map to IRIX threads, and the dispatching policy is as defined by
9109 the IRIX implementation of threads.
9110 @end ignore
9111 Tasks map to threads in the threads package used by GNAT@.  Where possible
9112 and appropriate, these threads correspond to native threads of the
9113 underlying operating system.
9114
9115 @sp 1
9116 @cartouche
9117 @noindent
9118 @strong{95}.  Implementation-defined @code{policy_identifiers} allowed
9119 in a pragma @code{Task_Dispatching_Policy}.  See D.2.2(3).
9120 @end cartouche
9121 @noindent
9122 There are no implementation-defined policy-identifiers allowed in this
9123 pragma.
9124
9125 @sp 1
9126 @cartouche
9127 @noindent
9128 @strong{96}.  Implementation-defined aspects of priority inversion.  See
9129 D.2.2(16).
9130 @end cartouche
9131 @noindent
9132 Execution of a task cannot be preempted by the implementation processing
9133 of delay expirations for lower priority tasks.
9134
9135 @sp 1
9136 @cartouche
9137 @noindent
9138 @strong{97}.  Implementation defined task dispatching.  See D.2.2(18).
9139 @end cartouche
9140 @noindent
9141 @c SGI info:
9142 @ignore
9143 Tasks map to IRIX threads, and the dispatching policy is as defined by
9144 the IRIX implementation of threads.
9145 @end ignore
9146 The policy is the same as that of the underlying threads implementation.
9147
9148 @sp 1
9149 @cartouche
9150 @noindent
9151 @strong{98}.  Implementation-defined @code{policy_identifiers} allowed
9152 in a pragma @code{Locking_Policy}.  See D.3(4).
9153 @end cartouche
9154 @noindent
9155 The only implementation defined policy permitted in GNAT is
9156 @code{Inheritance_Locking}.  On targets that support this policy, locking
9157 is implemented by inheritance, i.e.@: the task owning the lock operates
9158 at a priority equal to the highest priority of any task currently
9159 requesting the lock.
9160
9161 @sp 1
9162 @cartouche
9163 @noindent
9164 @strong{99}.  Default ceiling priorities.  See D.3(10).
9165 @end cartouche
9166 @noindent
9167 The ceiling priority of protected objects of the type
9168 @code{System.Interrupt_Priority'Last} as described in the Ada
9169 Reference Manual D.3(10),
9170
9171 @sp 1
9172 @cartouche
9173 @noindent
9174 @strong{100}.  The ceiling of any protected object used internally by
9175 the implementation.  See D.3(16).
9176 @end cartouche
9177 @noindent
9178 The ceiling priority of internal protected objects is
9179 @code{System.Priority'Last}.
9180
9181 @sp 1
9182 @cartouche
9183 @noindent
9184 @strong{101}.  Implementation-defined queuing policies.  See D.4(1).
9185 @end cartouche
9186 @noindent
9187 There are no implementation-defined queuing policies.
9188
9189 @sp 1
9190 @cartouche
9191 @noindent
9192 @strong{102}.  On a multiprocessor, any conditions that cause the
9193 completion of an aborted construct to be delayed later than what is
9194 specified for a single processor.  See D.6(3).
9195 @end cartouche
9196 @noindent
9197 The semantics for abort on a multi-processor is the same as on a single
9198 processor, there are no further delays.
9199
9200 @sp 1
9201 @cartouche
9202 @noindent
9203 @strong{103}.  Any operations that implicitly require heap storage
9204 allocation.  See D.7(8).
9205 @end cartouche
9206 @noindent
9207 The only operation that implicitly requires heap storage allocation is
9208 task creation.
9209
9210 @sp 1
9211 @cartouche
9212 @noindent
9213 @strong{104}.  Implementation-defined aspects of pragma
9214 @code{Restrictions}.  See D.7(20).
9215 @end cartouche
9216 @noindent
9217 There are no such implementation-defined aspects.
9218
9219 @sp 1
9220 @cartouche
9221 @noindent
9222 @strong{105}.  Implementation-defined aspects of package
9223 @code{Real_Time}.  See D.8(17).
9224 @end cartouche
9225 @noindent
9226 There are no implementation defined aspects of package @code{Real_Time}.
9227
9228 @sp 1
9229 @cartouche
9230 @noindent
9231 @strong{106}.  Implementation-defined aspects of
9232 @code{delay_statements}.  See D.9(8).
9233 @end cartouche
9234 @noindent
9235 Any difference greater than one microsecond will cause the task to be
9236 delayed (see D.9(7)).
9237
9238 @sp 1
9239 @cartouche
9240 @noindent
9241 @strong{107}.  The upper bound on the duration of interrupt blocking
9242 caused by the implementation.  See D.12(5).
9243 @end cartouche
9244 @noindent
9245 The upper bound is determined by the underlying operating system.  In
9246 no cases is it more than 10 milliseconds.
9247
9248 @sp 1
9249 @cartouche
9250 @noindent
9251 @strong{108}.  The means for creating and executing distributed
9252 programs.  See E(5).
9253 @end cartouche
9254 @noindent
9255 The GLADE package provides a utility GNATDIST for creating and executing
9256 distributed programs.  See the GLADE reference manual for further details.
9257
9258 @sp 1
9259 @cartouche
9260 @noindent
9261 @strong{109}.  Any events that can result in a partition becoming
9262 inaccessible.  See E.1(7).
9263 @end cartouche
9264 @noindent
9265 See the GLADE reference manual for full details on such events.
9266
9267 @sp 1
9268 @cartouche
9269 @noindent
9270 @strong{110}.  The scheduling policies, treatment of priorities, and
9271 management of shared resources between partitions in certain cases.  See
9272 E.1(11).
9273 @end cartouche
9274 @noindent
9275 See the GLADE reference manual for full details on these aspects of
9276 multi-partition execution.
9277
9278 @sp 1
9279 @cartouche
9280 @noindent
9281 @strong{111}.  Events that cause the version of a compilation unit to
9282 change.  See E.3(5).
9283 @end cartouche
9284 @noindent
9285 Editing the source file of a compilation unit, or the source files of
9286 any units on which it is dependent in a significant way cause the version
9287 to change.  No other actions cause the version number to change.  All changes
9288 are significant except those which affect only layout, capitalization or
9289 comments.
9290
9291 @sp 1
9292 @cartouche
9293 @noindent
9294 @strong{112}.  Whether the execution of the remote subprogram is
9295 immediately aborted as a result of cancellation.  See E.4(13).
9296 @end cartouche
9297 @noindent
9298 See the GLADE reference manual for details on the effect of abort in
9299 a distributed application.
9300
9301 @sp 1
9302 @cartouche
9303 @noindent
9304 @strong{113}.  Implementation-defined aspects of the PCS@.  See E.5(25).
9305 @end cartouche
9306 @noindent
9307 See the GLADE reference manual for a full description of all implementation
9308 defined aspects of the PCS@.
9309
9310 @sp 1
9311 @cartouche
9312 @noindent
9313 @strong{114}.  Implementation-defined interfaces in the PCS@.  See
9314 E.5(26).
9315 @end cartouche
9316 @noindent
9317 See the GLADE reference manual for a full description of all
9318 implementation defined interfaces.
9319
9320 @sp 1
9321 @cartouche
9322 @noindent
9323 @strong{115}.  The values of named numbers in the package
9324 @code{Decimal}.  See F.2(7).
9325 @end cartouche
9326 @noindent
9327 @table @code
9328 @item Max_Scale
9329 +18
9330 @item Min_Scale
9331 -18
9332 @item Min_Delta
9333 1.0E-18
9334 @item Max_Delta
9335 1.0E+18
9336 @item Max_Decimal_Digits
9337 18
9338 @end table
9339
9340 @sp 1
9341 @cartouche
9342 @noindent
9343 @strong{116}.  The value of @code{Max_Picture_Length} in the package
9344 @code{Text_IO.Editing}.  See F.3.3(16).
9345 @end cartouche
9346 @noindent
9347 64
9348
9349 @sp 1
9350 @cartouche
9351 @noindent
9352 @strong{117}.  The value of @code{Max_Picture_Length} in the package
9353 @code{Wide_Text_IO.Editing}.  See F.3.4(5).
9354 @end cartouche
9355 @noindent
9356 64
9357
9358 @sp 1
9359 @cartouche
9360 @noindent
9361 @strong{118}.  The accuracy actually achieved by the complex elementary
9362 functions and by other complex arithmetic operations.  See G.1(1).
9363 @end cartouche
9364 @noindent
9365 Standard library functions are used for the complex arithmetic
9366 operations.  Only fast math mode is currently supported.
9367
9368 @sp 1
9369 @cartouche
9370 @noindent
9371 @strong{119}.  The sign of a zero result (or a component thereof) from
9372 any operator or function in @code{Numerics.Generic_Complex_Types}, when
9373 @code{Real'Signed_Zeros} is True.  See G.1.1(53).
9374 @end cartouche
9375 @noindent
9376 The signs of zero values are as recommended by the relevant
9377 implementation advice.
9378
9379 @sp 1
9380 @cartouche
9381 @noindent
9382 @strong{120}.  The sign of a zero result (or a component thereof) from
9383 any operator or function in
9384 @code{Numerics.Generic_Complex_Elementary_Functions}, when
9385 @code{Real'Signed_Zeros} is @code{True}.  See G.1.2(45).
9386 @end cartouche
9387 @noindent
9388 The signs of zero values are as recommended by the relevant
9389 implementation advice.
9390
9391 @sp 1
9392 @cartouche
9393 @noindent
9394 @strong{121}.  Whether the strict mode or the relaxed mode is the
9395 default.  See G.2(2).
9396 @end cartouche
9397 @noindent
9398 The strict mode is the default.  There is no separate relaxed mode.  GNAT
9399 provides a highly efficient implementation of strict mode.
9400
9401 @sp 1
9402 @cartouche
9403 @noindent
9404 @strong{122}.  The result interval in certain cases of fixed-to-float
9405 conversion.  See G.2.1(10).
9406 @end cartouche
9407 @noindent
9408 For cases where the result interval is implementation dependent, the
9409 accuracy is that provided by performing all operations in 64-bit IEEE
9410 floating-point format.
9411
9412 @sp 1
9413 @cartouche
9414 @noindent
9415 @strong{123}.  The result of a floating point arithmetic operation in
9416 overflow situations, when the @code{Machine_Overflows} attribute of the
9417 result type is @code{False}.  See G.2.1(13).
9418 @end cartouche
9419 @noindent
9420 Infinite and NaN values are produced as dictated by the IEEE
9421 floating-point standard.
9422
9423 Note that on machines that are not fully compliant with the IEEE
9424 floating-point standard, such as Alpha, the @option{-mieee} compiler flag
9425 must be used for achieving IEEE confirming behavior (although at the cost
9426 of a significant performance penalty), so infinite and NaN values are
9427 properly generated.
9428
9429 @sp 1
9430 @cartouche
9431 @noindent
9432 @strong{124}.  The result interval for division (or exponentiation by a
9433 negative exponent), when the floating point hardware implements division
9434 as multiplication by a reciprocal.  See G.2.1(16).
9435 @end cartouche
9436 @noindent
9437 Not relevant, division is IEEE exact.
9438
9439 @sp 1
9440 @cartouche
9441 @noindent
9442 @strong{125}.  The definition of close result set, which determines the
9443 accuracy of certain fixed point multiplications and divisions.  See
9444 G.2.3(5).
9445 @end cartouche
9446 @noindent
9447 Operations in the close result set are performed using IEEE long format
9448 floating-point arithmetic.  The input operands are converted to
9449 floating-point, the operation is done in floating-point, and the result
9450 is converted to the target type.
9451
9452 @sp 1
9453 @cartouche
9454 @noindent
9455 @strong{126}.  Conditions on a @code{universal_real} operand of a fixed
9456 point multiplication or division for which the result shall be in the
9457 perfect result set.  See G.2.3(22).
9458 @end cartouche
9459 @noindent
9460 The result is only defined to be in the perfect result set if the result
9461 can be computed by a single scaling operation involving a scale factor
9462 representable in 64-bits.
9463
9464 @sp 1
9465 @cartouche
9466 @noindent
9467 @strong{127}.  The result of a fixed point arithmetic operation in
9468 overflow situations, when the @code{Machine_Overflows} attribute of the
9469 result type is @code{False}.  See G.2.3(27).
9470 @end cartouche
9471 @noindent
9472 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
9473 types.
9474
9475 @sp 1
9476 @cartouche
9477 @noindent
9478 @strong{128}.  The result of an elementary function reference in
9479 overflow situations, when the @code{Machine_Overflows} attribute of the
9480 result type is @code{False}.  See G.2.4(4).
9481 @end cartouche
9482 @noindent
9483 IEEE infinite and Nan values are produced as appropriate.
9484
9485 @sp 1
9486 @cartouche
9487 @noindent
9488 @strong{129}.  The value of the angle threshold, within which certain
9489 elementary functions, complex arithmetic operations, and complex
9490 elementary functions yield results conforming to a maximum relative
9491 error bound.  See G.2.4(10).
9492 @end cartouche
9493 @noindent
9494 Information on this subject is not yet available.
9495
9496 @sp 1
9497 @cartouche
9498 @noindent
9499 @strong{130}.  The accuracy of certain elementary functions for
9500 parameters beyond the angle threshold.  See G.2.4(10).
9501 @end cartouche
9502 @noindent
9503 Information on this subject is not yet available.
9504
9505 @sp 1
9506 @cartouche
9507 @noindent
9508 @strong{131}.  The result of a complex arithmetic operation or complex
9509 elementary function reference in overflow situations, when the
9510 @code{Machine_Overflows} attribute of the corresponding real type is
9511 @code{False}.  See G.2.6(5).
9512 @end cartouche
9513 @noindent
9514 IEEE infinite and Nan values are produced as appropriate.
9515
9516 @sp 1
9517 @cartouche
9518 @noindent
9519 @strong{132}.  The accuracy of certain complex arithmetic operations and
9520 certain complex elementary functions for parameters (or components
9521 thereof) beyond the angle threshold.  See G.2.6(8).
9522 @end cartouche
9523 @noindent
9524 Information on those subjects is not yet available.
9525
9526 @sp 1
9527 @cartouche
9528 @noindent
9529 @strong{133}.  Information regarding bounded errors and erroneous
9530 execution.  See H.2(1).
9531 @end cartouche
9532 @noindent
9533 Information on this subject is not yet available.
9534
9535 @sp 1
9536 @cartouche
9537 @noindent
9538 @strong{134}.  Implementation-defined aspects of pragma
9539 @code{Inspection_Point}.  See H.3.2(8).
9540 @end cartouche
9541 @noindent
9542 Pragma @code{Inspection_Point} ensures that the variable is live and can
9543 be examined by the debugger at the inspection point.
9544
9545 @sp 1
9546 @cartouche
9547 @noindent
9548 @strong{135}.  Implementation-defined aspects of pragma
9549 @code{Restrictions}.  See H.4(25).
9550 @end cartouche
9551 @noindent
9552 There are no implementation-defined aspects of pragma @code{Restrictions}.  The
9553 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
9554 generated code.  Checks must suppressed by use of pragma @code{Suppress}.
9555
9556 @sp 1
9557 @cartouche
9558 @noindent
9559 @strong{136}.  Any restrictions on pragma @code{Restrictions}.  See
9560 H.4(27).
9561 @end cartouche
9562 @noindent
9563 There are no restrictions on pragma @code{Restrictions}.
9564
9565 @node Intrinsic Subprograms
9566 @chapter Intrinsic Subprograms
9567 @cindex Intrinsic Subprograms
9568
9569 @menu
9570 * Intrinsic Operators::
9571 * Enclosing_Entity::
9572 * Exception_Information::
9573 * Exception_Message::
9574 * Exception_Name::
9575 * File::
9576 * Line::
9577 * Rotate_Left::
9578 * Rotate_Right::
9579 * Shift_Left::
9580 * Shift_Right::
9581 * Shift_Right_Arithmetic::
9582 * Source_Location::
9583 @end menu
9584
9585 @noindent
9586 GNAT allows a user application program to write the declaration:
9587
9588 @smallexample @c ada
9589    pragma Import (Intrinsic, name);
9590 @end smallexample
9591
9592 @noindent
9593 providing that the name corresponds to one of the implemented intrinsic
9594 subprograms in GNAT, and that the parameter profile of the referenced
9595 subprogram meets the requirements.  This chapter describes the set of
9596 implemented intrinsic subprograms, and the requirements on parameter profiles.
9597 Note that no body is supplied; as with other uses of pragma Import, the
9598 body is supplied elsewhere (in this case by the compiler itself).  Note
9599 that any use of this feature is potentially non-portable, since the
9600 Ada standard does not require Ada compilers to implement this feature.
9601
9602 @node Intrinsic Operators
9603 @section Intrinsic Operators
9604 @cindex Intrinsic operator
9605
9606 @noindent
9607 All the predefined numeric operators in package Standard
9608 in @code{pragma Import (Intrinsic,..)}
9609 declarations.  In the binary operator case, the operands must have the same
9610 size.  The operand or operands must also be appropriate for
9611 the operator.  For example, for addition, the operands must
9612 both be floating-point or both be fixed-point, and the
9613 right operand for @code{"**"} must have a root type of
9614 @code{Standard.Integer'Base}.
9615 You can use an intrinsic operator declaration as in the following example:
9616
9617 @smallexample @c ada
9618    type Int1 is new Integer;
9619    type Int2 is new Integer;
9620
9621    function "+" (X1 : Int1; X2 : Int2) return Int1;
9622    function "+" (X1 : Int1; X2 : Int2) return Int2;
9623    pragma Import (Intrinsic, "+");
9624 @end smallexample
9625
9626 @noindent
9627 This declaration would permit ``mixed mode'' arithmetic on items
9628 of the differing types @code{Int1} and @code{Int2}.
9629 It is also possible to specify such operators for private types, if the
9630 full views are appropriate arithmetic types.
9631
9632 @node Enclosing_Entity
9633 @section Enclosing_Entity
9634 @cindex Enclosing_Entity
9635 @noindent
9636 This intrinsic subprogram is used in the implementation of the
9637 library routine @code{GNAT.Source_Info}.  The only useful use of the
9638 intrinsic import in this case is the one in this unit, so an
9639 application program should simply call the function
9640 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
9641 the current subprogram, package, task, entry, or protected subprogram.
9642
9643 @node Exception_Information
9644 @section Exception_Information
9645 @cindex Exception_Information'
9646 @noindent
9647 This intrinsic subprogram is used in the implementation of the
9648 library routine @code{GNAT.Current_Exception}.  The only useful
9649 use of the intrinsic import in this case is the one in this unit,
9650 so an application program should simply call the function
9651 @code{GNAT.Current_Exception.Exception_Information} to obtain
9652 the exception information associated with the current exception.
9653
9654 @node Exception_Message
9655 @section Exception_Message
9656 @cindex Exception_Message
9657 @noindent
9658 This intrinsic subprogram is used in the implementation of the
9659 library routine @code{GNAT.Current_Exception}.  The only useful
9660 use of the intrinsic import in this case is the one in this unit,
9661 so an application program should simply call the function
9662 @code{GNAT.Current_Exception.Exception_Message} to obtain
9663 the message associated with the current exception.
9664
9665 @node Exception_Name
9666 @section Exception_Name
9667 @cindex Exception_Name
9668 @noindent
9669 This intrinsic subprogram is used in the implementation of the
9670 library routine @code{GNAT.Current_Exception}.  The only useful
9671 use of the intrinsic import in this case is the one in this unit,
9672 so an application program should simply call the function
9673 @code{GNAT.Current_Exception.Exception_Name} to obtain
9674 the name of the current exception.
9675
9676 @node File
9677 @section File
9678 @cindex File
9679 @noindent
9680 This intrinsic subprogram is used in the implementation of the
9681 library routine @code{GNAT.Source_Info}.  The only useful use of the
9682 intrinsic import in this case is the one in this unit, so an
9683 application program should simply call the function
9684 @code{GNAT.Source_Info.File} to obtain the name of the current
9685 file.
9686
9687 @node Line
9688 @section Line
9689 @cindex Line
9690 @noindent
9691 This intrinsic subprogram is used in the implementation of the
9692 library routine @code{GNAT.Source_Info}.  The only useful use of the
9693 intrinsic import in this case is the one in this unit, so an
9694 application program should simply call the function
9695 @code{GNAT.Source_Info.Line} to obtain the number of the current
9696 source line.
9697
9698 @node Rotate_Left
9699 @section Rotate_Left
9700 @cindex Rotate_Left
9701 @noindent
9702 In standard Ada, the @code{Rotate_Left} function is available only
9703 for the predefined modular types in package @code{Interfaces}.  However, in
9704 GNAT it is possible to define a Rotate_Left function for a user
9705 defined modular type or any signed integer type as in this example:
9706
9707 @smallexample @c ada
9708    function Shift_Left
9709      (Value  : My_Modular_Type;
9710       Amount : Natural)
9711       return   My_Modular_Type;
9712 @end smallexample
9713
9714 @noindent
9715 The requirements are that the profile be exactly as in the example
9716 above.  The only modifications allowed are in the formal parameter
9717 names, and in the type of @code{Value} and the return type, which
9718 must be the same, and must be either a signed integer type, or
9719 a modular integer type with a binary modulus, and the size must
9720 be 8.  16, 32 or 64 bits.
9721
9722 @node Rotate_Right
9723 @section Rotate_Right
9724 @cindex Rotate_Right
9725 @noindent
9726 A @code{Rotate_Right} function can be defined for any user defined
9727 binary modular integer type, or signed integer type, as described
9728 above for @code{Rotate_Left}.
9729
9730 @node Shift_Left
9731 @section Shift_Left
9732 @cindex Shift_Left
9733 @noindent
9734 A @code{Shift_Left} function can be defined for any user defined
9735 binary modular integer type, or signed integer type, as described
9736 above for @code{Rotate_Left}.
9737
9738 @node Shift_Right
9739 @section Shift_Right
9740 @cindex Shift_Right
9741 @noindent
9742 A @code{Shift_Right} function can be defined for any user defined
9743 binary modular integer type, or signed integer type, as described
9744 above for @code{Rotate_Left}.
9745
9746 @node Shift_Right_Arithmetic
9747 @section Shift_Right_Arithmetic
9748 @cindex Shift_Right_Arithmetic
9749 @noindent
9750 A @code{Shift_Right_Arithmetic} function can be defined for any user
9751 defined binary modular integer type, or signed integer type, as described
9752 above for @code{Rotate_Left}.
9753
9754 @node Source_Location
9755 @section Source_Location
9756 @cindex Source_Location
9757 @noindent
9758 This intrinsic subprogram is used in the implementation of the
9759 library routine @code{GNAT.Source_Info}.  The only useful use of the
9760 intrinsic import in this case is the one in this unit, so an
9761 application program should simply call the function
9762 @code{GNAT.Source_Info.Source_Location} to obtain the current
9763 source file location.
9764
9765 @node Representation Clauses and Pragmas
9766 @chapter Representation Clauses and Pragmas
9767 @cindex Representation Clauses
9768
9769 @menu
9770 * Alignment Clauses::
9771 * Size Clauses::
9772 * Storage_Size Clauses::
9773 * Size of Variant Record Objects::
9774 * Biased Representation ::
9775 * Value_Size and Object_Size Clauses::
9776 * Component_Size Clauses::
9777 * Bit_Order Clauses::
9778 * Effect of Bit_Order on Byte Ordering::
9779 * Pragma Pack for Arrays::
9780 * Pragma Pack for Records::
9781 * Record Representation Clauses::
9782 * Enumeration Clauses::
9783 * Address Clauses::
9784 * Effect of Convention on Representation::
9785 * Determining the Representations chosen by GNAT::
9786 @end menu
9787
9788 @noindent
9789 @cindex Representation Clause
9790 @cindex Representation Pragma
9791 @cindex Pragma, representation
9792 This section describes the representation clauses accepted by GNAT, and
9793 their effect on the representation of corresponding data objects.
9794
9795 GNAT fully implements Annex C (Systems Programming).  This means that all
9796 the implementation advice sections in chapter 13 are fully implemented.
9797 However, these sections only require a minimal level of support for
9798 representation clauses.  GNAT provides much more extensive capabilities,
9799 and this section describes the additional capabilities provided.
9800
9801 @node Alignment Clauses
9802 @section Alignment Clauses
9803 @cindex Alignment Clause
9804
9805 @noindent
9806 GNAT requires that all alignment clauses specify a power of 2, and all
9807 default alignments are always a power of 2.  The default alignment
9808 values are as follows:
9809
9810 @itemize @bullet
9811 @item @emph{Primitive Types}.
9812 For primitive types, the alignment is the minimum of the actual size of
9813 objects of the type divided by @code{Storage_Unit},
9814 and the maximum alignment supported by the target.
9815 (This maximum alignment is given by the GNAT-specific attribute
9816 @code{Standard'Maximum_Alignment}; see @ref{Maximum_Alignment}.)
9817 @cindex @code{Maximum_Alignment} attribute
9818 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
9819 default alignment will be 8 on any target that supports alignments
9820 this large, but on some targets, the maximum alignment may be smaller
9821 than 8, in which case objects of type @code{Long_Float} will be maximally
9822 aligned.
9823
9824 @item @emph{Arrays}.
9825 For arrays, the alignment is equal to the alignment of the component type
9826 for the normal case where no packing or component size is given.  If the
9827 array is packed, and the packing is effective (see separate section on
9828 packed arrays), then the alignment will be one for long packed arrays,
9829 or arrays whose length is not known at compile time.  For short packed
9830 arrays, which are handled internally as modular types, the alignment
9831 will be as described for primitive types, e.g.@: a packed array of length
9832 31 bits will have an object size of four bytes, and an alignment of 4.
9833
9834 @item @emph{Records}.
9835 For the normal non-packed case, the alignment of a record is equal to
9836 the maximum alignment of any of its components.  For tagged records, this
9837 includes the implicit access type used for the tag.  If a pragma @code{Pack}
9838 is used and all components are packable (see separate section on pragma
9839 @code{Pack}), then the resulting alignment is 1, unless the layout of the
9840 record makes it profitable to increase it.
9841
9842 A special case is when:
9843 @itemize @bullet
9844 @item
9845 the size of the record is given explicitly, or a
9846 full record representation clause is given, and
9847 @item
9848 the size of the record is 2, 4, or 8 bytes.
9849 @end itemize
9850 @noindent
9851 In this case, an alignment is chosen to match the
9852 size of the record. For example, if we have:
9853
9854 @smallexample @c ada
9855    type Small is record
9856       A, B : Character;
9857    end record;
9858    for Small'Size use 16;
9859 @end smallexample
9860
9861 @noindent
9862 then the default alignment of the record type @code{Small} is 2, not 1. This
9863 leads to more efficient code when the record is treated as a unit, and also
9864 allows the type to specified as @code{Atomic} on architectures requiring
9865 strict alignment.
9866
9867 @end itemize
9868
9869 @noindent
9870 An alignment clause may specify a larger alignment than the default value
9871 up to some maximum value dependent on the target (obtainable by using the
9872 attribute reference @code{Standard'Maximum_Alignment}). It may also specify
9873 a smaller alignment than the default value for enumeration, integer and
9874 fixed point types, as well as for record types, for example
9875
9876 @smallexample @c ada
9877   type V is record
9878      A : Integer;
9879   end record;
9880
9881   for V'alignment use 1;
9882 @end smallexample
9883
9884 @noindent
9885 @cindex Alignment, default
9886 The default alignment for the type @code{V} is 4, as a result of the
9887 Integer field in the record, but it is permissible, as shown, to
9888 override the default alignment of the record with a smaller value.
9889
9890 @node Size Clauses
9891 @section Size Clauses
9892 @cindex Size Clause
9893
9894 @noindent
9895 The default size for a type @code{T} is obtainable through the
9896 language-defined attribute @code{T'Size} and also through the
9897 equivalent GNAT-defined attribute @code{T'Value_Size}.
9898 For objects of type @code{T}, GNAT will generally increase the type size
9899 so that the object size (obtainable through the GNAT-defined attribute
9900 @code{T'Object_Size})
9901 is a multiple of @code{T'Alignment * Storage_Unit}.
9902 For example
9903
9904 @smallexample @c ada
9905    type Smallint is range 1 .. 6;
9906
9907    type Rec is record
9908       Y1 : integer;
9909       Y2 : boolean;
9910    end record;
9911 @end smallexample
9912
9913 @noindent
9914 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
9915 as specified by the RM rules,
9916 but objects of this type will have a size of 8
9917 (@code{Smallint'Object_Size} = 8),
9918 since objects by default occupy an integral number
9919 of storage units.  On some targets, notably older
9920 versions of the Digital Alpha, the size of stand
9921 alone objects of this type may be 32, reflecting
9922 the inability of the hardware to do byte load/stores.
9923
9924 Similarly, the size of type @code{Rec} is 40 bits
9925 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
9926 the alignment is 4, so objects of this type will have
9927 their size increased to 64 bits so that it is a multiple
9928 of the alignment (in bits).  This decision is
9929 in accordance with the specific Implementation Advice in RM 13.3(43):
9930
9931 @quotation
9932 A @code{Size} clause should be supported for an object if the specified
9933 @code{Size} is at least as large as its subtype's @code{Size}, and corresponds
9934 to a size in storage elements that is a multiple of the object's
9935 @code{Alignment} (if the @code{Alignment} is nonzero).
9936 @end quotation
9937
9938 @noindent
9939 An explicit size clause may be used to override the default size by
9940 increasing it.  For example, if we have:
9941
9942 @smallexample @c ada
9943    type My_Boolean is new Boolean;
9944    for My_Boolean'Size use 32;
9945 @end smallexample
9946
9947 @noindent
9948 then values of this type will always be 32 bits long.  In the case of
9949 discrete types, the size can be increased up to 64 bits, with the effect
9950 that the entire specified field is used to hold the value, sign- or
9951 zero-extended as appropriate.  If more than 64 bits is specified, then
9952 padding space is allocated after the value, and a warning is issued that
9953 there are unused bits.
9954
9955 Similarly the size of records and arrays may be increased, and the effect
9956 is to add padding bits after the value.  This also causes a warning message
9957 to be generated.
9958
9959 The largest Size value permitted in GNAT is 2**31@minus{}1.  Since this is a
9960 Size in bits, this corresponds to an object of size 256 megabytes (minus
9961 one).  This limitation is true on all targets.  The reason for this
9962 limitation is that it improves the quality of the code in many cases
9963 if it is known that a Size value can be accommodated in an object of
9964 type Integer.
9965
9966 @node Storage_Size Clauses
9967 @section Storage_Size Clauses
9968 @cindex Storage_Size Clause
9969
9970 @noindent
9971 For tasks, the @code{Storage_Size} clause specifies the amount of space
9972 to be allocated for the task stack.  This cannot be extended, and if the
9973 stack is exhausted, then @code{Storage_Error} will be raised (if stack
9974 checking is enabled).  Use a @code{Storage_Size} attribute definition clause,
9975 or a @code{Storage_Size} pragma in the task definition to set the
9976 appropriate required size.  A useful technique is to include in every
9977 task definition a pragma of the form:
9978
9979 @smallexample @c ada
9980    pragma Storage_Size (Default_Stack_Size);
9981 @end smallexample
9982
9983 @noindent
9984 Then @code{Default_Stack_Size} can be defined in a global package, and
9985 modified as required. Any tasks requiring stack sizes different from the
9986 default can have an appropriate alternative reference in the pragma.
9987
9988 You can also use the @option{-d} binder switch to modify the default stack
9989 size.
9990
9991 For access types, the @code{Storage_Size} clause specifies the maximum
9992 space available for allocation of objects of the type.  If this space is
9993 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
9994 In the case where the access type is declared local to a subprogram, the
9995 use of a @code{Storage_Size} clause triggers automatic use of a special
9996 predefined storage pool (@code{System.Pool_Size}) that ensures that all
9997 space for the pool is automatically reclaimed on exit from the scope in
9998 which the type is declared.
9999
10000 A special case recognized by the compiler is the specification of a
10001 @code{Storage_Size} of zero for an access type.  This means that no
10002 items can be allocated from the pool, and this is recognized at compile
10003 time, and all the overhead normally associated with maintaining a fixed
10004 size storage pool is eliminated.  Consider the following example:
10005
10006 @smallexample @c ada
10007    procedure p is
10008       type R is array (Natural) of Character;
10009       type P is access all R;
10010       for P'Storage_Size use 0;
10011       --  Above access type intended only for interfacing purposes
10012
10013       y : P;
10014
10015       procedure g (m : P);
10016       pragma Import (C, g);
10017
10018       --  @dots{}
10019
10020    begin
10021       --  @dots{}
10022       y := new R;
10023    end;
10024 @end smallexample
10025
10026 @noindent
10027 As indicated in this example, these dummy storage pools are often useful in
10028 connection with interfacing where no object will ever be allocated.  If you
10029 compile the above example, you get the warning:
10030
10031 @smallexample
10032    p.adb:16:09: warning: allocation from empty storage pool
10033    p.adb:16:09: warning: Storage_Error will be raised at run time
10034 @end smallexample
10035
10036 @noindent
10037 Of course in practice, there will not be any explicit allocators in the
10038 case of such an access declaration.
10039
10040 @node Size of Variant Record Objects
10041 @section Size of Variant Record Objects
10042 @cindex Size, variant record objects
10043 @cindex Variant record objects, size
10044
10045 @noindent
10046 In the case of variant record objects, there is a question whether Size gives
10047 information about a particular variant, or the maximum size required
10048 for any variant.  Consider the following program
10049
10050 @smallexample @c ada
10051 with Text_IO; use Text_IO;
10052 procedure q is
10053    type R1 (A : Boolean := False) is record
10054      case A is
10055        when True  => X : Character;
10056        when False => null;
10057      end case;
10058    end record;
10059
10060    V1 : R1 (False);
10061    V2 : R1;
10062
10063 begin
10064    Put_Line (Integer'Image (V1'Size));
10065    Put_Line (Integer'Image (V2'Size));
10066 end q;
10067 @end smallexample
10068
10069 @noindent
10070 Here we are dealing with a variant record, where the True variant
10071 requires 16 bits, and the False variant requires 8 bits.
10072 In the above example, both V1 and V2 contain the False variant,
10073 which is only 8 bits long.  However, the result of running the
10074 program is:
10075
10076 @smallexample
10077 8
10078 16
10079 @end smallexample
10080
10081 @noindent
10082 The reason for the difference here is that the discriminant value of
10083 V1 is fixed, and will always be False.  It is not possible to assign
10084 a True variant value to V1, therefore 8 bits is sufficient.  On the
10085 other hand, in the case of V2, the initial discriminant value is
10086 False (from the default), but it is possible to assign a True
10087 variant value to V2, therefore 16 bits must be allocated for V2
10088 in the general case, even fewer bits may be needed at any particular
10089 point during the program execution.
10090
10091 As can be seen from the output of this program, the @code{'Size}
10092 attribute applied to such an object in GNAT gives the actual allocated
10093 size of the variable, which is the largest size of any of the variants.
10094 The Ada Reference Manual is not completely clear on what choice should
10095 be made here, but the GNAT behavior seems most consistent with the
10096 language in the RM@.
10097
10098 In some cases, it may be desirable to obtain the size of the current
10099 variant, rather than the size of the largest variant.  This can be
10100 achieved in GNAT by making use of the fact that in the case of a
10101 subprogram parameter, GNAT does indeed return the size of the current
10102 variant (because a subprogram has no way of knowing how much space
10103 is actually allocated for the actual).
10104
10105 Consider the following modified version of the above program:
10106
10107 @smallexample @c ada
10108 with Text_IO; use Text_IO;
10109 procedure q is
10110    type R1 (A : Boolean := False) is record
10111      case A is
10112        when True  => X : Character;
10113        when False => null;
10114      end case;
10115    end record;
10116
10117    V2 : R1;
10118
10119    function Size (V : R1) return Integer is
10120    begin
10121       return V'Size;
10122    end Size;
10123
10124 begin
10125    Put_Line (Integer'Image (V2'Size));
10126    Put_Line (Integer'IMage (Size (V2)));
10127    V2 := (True, 'x');
10128    Put_Line (Integer'Image (V2'Size));
10129    Put_Line (Integer'IMage (Size (V2)));
10130 end q;
10131 @end smallexample
10132
10133 @noindent
10134 The output from this program is
10135
10136 @smallexample
10137 16
10138 8
10139 16
10140 16
10141 @end smallexample
10142
10143 @noindent
10144 Here we see that while the @code{'Size} attribute always returns
10145 the maximum size, regardless of the current variant value, the
10146 @code{Size} function does indeed return the size of the current
10147 variant value.
10148
10149 @node Biased Representation
10150 @section Biased Representation
10151 @cindex Size for biased representation
10152 @cindex Biased representation
10153
10154 @noindent
10155 In the case of scalars with a range starting at other than zero, it is
10156 possible in some cases to specify a size smaller than the default minimum
10157 value, and in such cases, GNAT uses an unsigned biased representation,
10158 in which zero is used to represent the lower bound, and successive values
10159 represent successive values of the type.
10160
10161 For example, suppose we have the declaration:
10162
10163 @smallexample @c ada
10164    type Small is range -7 .. -4;
10165    for Small'Size use 2;
10166 @end smallexample
10167
10168 @noindent
10169 Although the default size of type @code{Small} is 4, the @code{Size}
10170 clause is accepted by GNAT and results in the following representation
10171 scheme:
10172
10173 @smallexample
10174   -7 is represented as 2#00#
10175   -6 is represented as 2#01#
10176   -5 is represented as 2#10#
10177   -4 is represented as 2#11#
10178 @end smallexample
10179
10180 @noindent
10181 Biased representation is only used if the specified @code{Size} clause
10182 cannot be accepted in any other manner.  These reduced sizes that force
10183 biased representation can be used for all discrete types except for
10184 enumeration types for which a representation clause is given.
10185
10186 @node Value_Size and Object_Size Clauses
10187 @section Value_Size and Object_Size Clauses
10188 @findex Value_Size
10189 @findex Object_Size
10190 @cindex Size, of objects
10191
10192 @noindent
10193 In Ada 95 and Ada 2005, @code{T'Size} for a type @code{T} is the minimum
10194 number of bits required to hold values of type @code{T}.
10195 Although this interpretation was allowed in Ada 83, it was not required,
10196 and this requirement in practice can cause some significant difficulties.
10197 For example, in most Ada 83 compilers, @code{Natural'Size} was 32.
10198 However, in Ada 95 and Ada 2005,
10199 @code{Natural'Size} is
10200 typically 31.  This means that code may change in behavior when moving
10201 from Ada 83 to Ada 95 or Ada 2005.  For example, consider:
10202
10203 @smallexample @c ada
10204    type Rec is record;
10205       A : Natural;
10206       B : Natural;
10207    end record;
10208
10209    for Rec use record
10210       at 0  range 0 .. Natural'Size - 1;
10211       at 0  range Natural'Size .. 2 * Natural'Size - 1;
10212    end record;
10213 @end smallexample
10214
10215 @noindent
10216 In the above code, since the typical size of @code{Natural} objects
10217 is 32 bits and @code{Natural'Size} is 31, the above code can cause
10218 unexpected inefficient packing in Ada 95 and Ada 2005, and in general
10219 there are cases where the fact that the object size can exceed the
10220 size of the type causes surprises.
10221
10222 To help get around this problem GNAT provides two implementation
10223 defined attributes, @code{Value_Size} and @code{Object_Size}.  When
10224 applied to a type, these attributes yield the size of the type
10225 (corresponding to the RM defined size attribute), and the size of
10226 objects of the type respectively.
10227
10228 The @code{Object_Size} is used for determining the default size of
10229 objects and components.  This size value can be referred to using the
10230 @code{Object_Size} attribute.  The phrase ``is used'' here means that it is
10231 the basis of the determination of the size.  The backend is free to
10232 pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
10233 character might be stored in 32 bits on a machine with no efficient
10234 byte access instructions such as the Alpha.
10235
10236 The default rules for the value of @code{Object_Size} for
10237 discrete types are as follows:
10238
10239 @itemize @bullet
10240 @item
10241 The @code{Object_Size} for base subtypes reflect the natural hardware
10242 size in bits (run the compiler with @option{-gnatS} to find those values
10243 for numeric types). Enumeration types and fixed-point base subtypes have
10244 8, 16, 32 or 64 bits for this size, depending on the range of values
10245 to be stored.
10246
10247 @item
10248 The @code{Object_Size} of a subtype is the same as the
10249 @code{Object_Size} of
10250 the type from which it is obtained.
10251
10252 @item
10253 The @code{Object_Size} of a derived base type is copied from the parent
10254 base type, and the @code{Object_Size} of a derived first subtype is copied
10255 from the parent first subtype.
10256 @end itemize
10257
10258 @noindent
10259 The @code{Value_Size} attribute
10260 is the (minimum) number of bits required to store a value
10261 of the type.
10262 This value is used to determine how tightly to pack
10263 records or arrays with components of this type, and also affects
10264 the semantics of unchecked conversion (unchecked conversions where
10265 the @code{Value_Size} values differ generate a warning, and are potentially
10266 target dependent).
10267
10268 The default rules for the value of @code{Value_Size} are as follows:
10269
10270 @itemize @bullet
10271 @item
10272 The @code{Value_Size} for a base subtype is the minimum number of bits
10273 required to store all values of the type (including the sign bit
10274 only if negative values are possible).
10275
10276 @item
10277 If a subtype statically matches the first subtype of a given type, then it has
10278 by default the same @code{Value_Size} as the first subtype.  This is a
10279 consequence of RM 13.1(14) (``if two subtypes statically match,
10280 then their subtype-specific aspects are the same''.)
10281
10282 @item
10283 All other subtypes have a @code{Value_Size} corresponding to the minimum
10284 number of bits required to store all values of the subtype.  For
10285 dynamic bounds, it is assumed that the value can range down or up
10286 to the corresponding bound of the ancestor
10287 @end itemize
10288
10289 @noindent
10290 The RM defined attribute @code{Size} corresponds to the
10291 @code{Value_Size} attribute.
10292
10293 The @code{Size} attribute may be defined for a first-named subtype.  This sets
10294 the @code{Value_Size} of
10295 the first-named subtype to the given value, and the
10296 @code{Object_Size} of this first-named subtype to the given value padded up
10297 to an appropriate boundary.  It is a consequence of the default rules
10298 above that this @code{Object_Size} will apply to all further subtypes.  On the
10299 other hand, @code{Value_Size} is affected only for the first subtype, any
10300 dynamic subtypes obtained from it directly, and any statically matching
10301 subtypes.  The @code{Value_Size} of any other static subtypes is not affected.
10302
10303 @code{Value_Size} and
10304 @code{Object_Size} may be explicitly set for any subtype using
10305 an attribute definition clause.  Note that the use of these attributes
10306 can cause the RM 13.1(14) rule to be violated.  If two access types
10307 reference aliased objects whose subtypes have differing @code{Object_Size}
10308 values as a result of explicit attribute definition clauses, then it
10309 is erroneous to convert from one access subtype to the other.
10310
10311 At the implementation level, Esize stores the Object_Size and the
10312 RM_Size field stores the @code{Value_Size} (and hence the value of the
10313 @code{Size} attribute,
10314 which, as noted above, is equivalent to @code{Value_Size}).
10315
10316 To get a feel for the difference, consider the following examples (note
10317 that in each case the base is @code{Short_Short_Integer} with a size of 8):
10318
10319 @smallexample
10320                                        Object_Size     Value_Size
10321
10322 type x1 is range 0 .. 5;                    8               3
10323
10324 type x2 is range 0 .. 5;
10325 for x2'size use 12;                        16              12
10326
10327 subtype x3 is x2 range 0 .. 3;             16               2
10328
10329 subtype x4 is x2'base range 0 .. 10;        8               4
10330
10331 subtype x5 is x2 range 0 .. dynamic;       16               3*
10332
10333 subtype x6 is x2'base range 0 .. dynamic;   8               3*
10334
10335 @end smallexample
10336
10337 @noindent
10338 Note: the entries marked ``3*'' are not actually specified by the Ada
10339 Reference Manual, but it seems in the spirit of the RM rules to allocate
10340 the minimum number of bits (here 3, given the range for @code{x2})
10341 known to be large enough to hold the given range of values.
10342
10343 So far, so good, but GNAT has to obey the RM rules, so the question is
10344 under what conditions must the RM @code{Size} be used.
10345 The following is a list
10346 of the occasions on which the RM @code{Size} must be used:
10347
10348 @itemize @bullet
10349 @item
10350 Component size for packed arrays or records
10351
10352 @item
10353 Value of the attribute @code{Size} for a type
10354
10355 @item
10356 Warning about sizes not matching for unchecked conversion
10357 @end itemize
10358
10359 @noindent
10360 For record types, the @code{Object_Size} is always a multiple of the
10361 alignment of the type (this is true for all types). In some cases the
10362 @code{Value_Size} can be smaller. Consider:
10363
10364 @smallexample
10365    type R is record
10366      X : Integer;
10367      Y : Character;
10368    end record;
10369 @end smallexample
10370
10371 @noindent
10372 On a typical 32-bit architecture, the X component will be four bytes, and
10373 require four-byte alignment, and the Y component will be one byte. In this
10374 case @code{R'Value_Size} will be 40 (bits) since this is the minimum size
10375 required to store a value of this type, and for example, it is permissible
10376 to have a component of type R in an outer record whose component size is
10377 specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits),
10378 since it must be rounded up so that this value is a multiple of the
10379 alignment (4 bytes = 32 bits).
10380
10381 @noindent
10382 For all other types, the @code{Object_Size}
10383 and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
10384 Only @code{Size} may be specified for such types.
10385
10386 @node Component_Size Clauses
10387 @section Component_Size Clauses
10388 @cindex Component_Size Clause
10389
10390 @noindent
10391 Normally, the value specified in a component size clause must be consistent
10392 with the subtype of the array component with regard to size and alignment.
10393 In other words, the value specified must be at least equal to the size
10394 of this subtype, and must be a multiple of the alignment value.
10395
10396 In addition, component size clauses are allowed which cause the array
10397 to be packed, by specifying a smaller value.  A first case is for
10398 component size values in the range 1 through 63.  The value specified
10399 must not be smaller than the Size of the subtype.  GNAT will accurately
10400 honor all packing requests in this range.  For example, if we have:
10401
10402 @smallexample @c ada
10403 type r is array (1 .. 8) of Natural;
10404 for r'Component_Size use 31;
10405 @end smallexample
10406
10407 @noindent
10408 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
10409 Of course access to the components of such an array is considerably
10410 less efficient than if the natural component size of 32 is used.
10411 A second case is when the subtype of the component is a record type
10412 padded because of its default alignment.  For example, if we have:
10413
10414 @smallexample @c ada
10415 type r is record
10416   i : Integer;
10417   j : Integer;
10418   b : Boolean;
10419 end record;
10420
10421 type a is array (1 .. 8) of r;
10422 for a'Component_Size use 72;
10423 @end smallexample
10424
10425 @noindent
10426 then the resulting array has a length of 72 bytes, instead of 96 bytes
10427 if the alignment of the record (4) was obeyed.
10428
10429 Note that there is no point in giving both a component size clause
10430 and a pragma Pack for the same array type. if such duplicate
10431 clauses are given, the pragma Pack will be ignored.
10432
10433 @node Bit_Order Clauses
10434 @section Bit_Order Clauses
10435 @cindex Bit_Order Clause
10436 @cindex bit ordering
10437 @cindex ordering, of bits
10438
10439 @noindent
10440 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
10441 attribute.  The specification may either correspond to the default bit
10442 order for the target, in which case the specification has no effect and
10443 places no additional restrictions, or it may be for the non-standard
10444 setting (that is the opposite of the default).
10445
10446 In the case where the non-standard value is specified, the effect is
10447 to renumber bits within each byte, but the ordering of bytes is not
10448 affected.  There are certain
10449 restrictions placed on component clauses as follows:
10450
10451 @itemize @bullet
10452
10453 @item Components fitting within a single storage unit.
10454 @noindent
10455 These are unrestricted, and the effect is merely to renumber bits.  For
10456 example if we are on a little-endian machine with @code{Low_Order_First}
10457 being the default, then the following two declarations have exactly
10458 the same effect:
10459
10460 @smallexample @c ada
10461    type R1 is record
10462       A : Boolean;
10463       B : Integer range 1 .. 120;
10464    end record;
10465
10466    for R1 use record
10467       A at 0 range 0 .. 0;
10468       B at 0 range 1 .. 7;
10469    end record;
10470
10471    type R2 is record
10472       A : Boolean;
10473       B : Integer range 1 .. 120;
10474    end record;
10475
10476    for R2'Bit_Order use High_Order_First;
10477
10478    for R2 use record
10479       A at 0 range 7 .. 7;
10480       B at 0 range 0 .. 6;
10481    end record;
10482 @end smallexample
10483
10484 @noindent
10485 The useful application here is to write the second declaration with the
10486 @code{Bit_Order} attribute definition clause, and know that it will be treated
10487 the same, regardless of whether the target is little-endian or big-endian.
10488
10489 @item Components occupying an integral number of bytes.
10490 @noindent
10491 These are components that exactly fit in two or more bytes.  Such component
10492 declarations are allowed, but have no effect, since it is important to realize
10493 that the @code{Bit_Order} specification does not affect the ordering of bytes.
10494 In particular, the following attempt at getting an endian-independent integer
10495 does not work:
10496
10497 @smallexample @c ada
10498    type R2 is record
10499       A : Integer;
10500    end record;
10501
10502    for R2'Bit_Order use High_Order_First;
10503
10504    for R2 use record
10505       A at 0 range 0 .. 31;
10506    end record;
10507 @end smallexample
10508
10509 @noindent
10510 This declaration will result in a little-endian integer on a
10511 little-endian machine, and a big-endian integer on a big-endian machine.
10512 If byte flipping is required for interoperability between big- and
10513 little-endian machines, this must be explicitly programmed.  This capability
10514 is not provided by @code{Bit_Order}.
10515
10516 @item Components that are positioned across byte boundaries
10517 @noindent
10518 but do not occupy an integral number of bytes.  Given that bytes are not
10519 reordered, such fields would occupy a non-contiguous sequence of bits
10520 in memory, requiring non-trivial code to reassemble.  They are for this
10521 reason not permitted, and any component clause specifying such a layout
10522 will be flagged as illegal by GNAT@.
10523
10524 @end itemize
10525
10526 @noindent
10527 Since the misconception that Bit_Order automatically deals with all
10528 endian-related incompatibilities is a common one, the specification of
10529 a component field that is an integral number of bytes will always
10530 generate a warning.  This warning may be suppressed using @code{pragma
10531 Warnings (Off)} if desired.  The following section contains additional
10532 details regarding the issue of byte ordering.
10533
10534 @node Effect of Bit_Order on Byte Ordering
10535 @section Effect of Bit_Order on Byte Ordering
10536 @cindex byte ordering
10537 @cindex ordering, of bytes
10538
10539 @noindent
10540 In this section we will review the effect of the @code{Bit_Order} attribute
10541 definition clause on byte ordering.  Briefly, it has no effect at all, but
10542 a detailed example will be helpful.  Before giving this
10543 example, let us review the precise
10544 definition of the effect of defining @code{Bit_Order}.  The effect of a
10545 non-standard bit order is described in section 15.5.3 of the Ada
10546 Reference Manual:
10547
10548 @quotation
10549 2   A bit ordering is a method of interpreting the meaning of
10550 the storage place attributes.
10551 @end quotation
10552
10553 @noindent
10554 To understand the precise definition of storage place attributes in
10555 this context, we visit section 13.5.1 of the manual:
10556
10557 @quotation
10558 13   A record_representation_clause (without the mod_clause)
10559 specifies the layout.  The storage place attributes (see 13.5.2)
10560 are taken from the values of the position, first_bit, and last_bit
10561 expressions after normalizing those values so that first_bit is
10562 less than Storage_Unit.
10563 @end quotation
10564
10565 @noindent
10566 The critical point here is that storage places are taken from
10567 the values after normalization, not before.  So the @code{Bit_Order}
10568 interpretation applies to normalized values.  The interpretation
10569 is described in the later part of the 15.5.3 paragraph:
10570
10571 @quotation
10572 2   A bit ordering is a method of interpreting the meaning of
10573 the storage place attributes.  High_Order_First (known in the
10574 vernacular as ``big endian'') means that the first bit of a
10575 storage element (bit 0) is the most significant bit (interpreting
10576 the sequence of bits that represent a component as an unsigned
10577 integer value).  Low_Order_First (known in the vernacular as
10578 ``little endian'') means the opposite: the first bit is the
10579 least significant.
10580 @end quotation
10581
10582 @noindent
10583 Note that the numbering is with respect to the bits of a storage
10584 unit.  In other words, the specification affects only the numbering
10585 of bits within a single storage unit.
10586
10587 We can make the effect clearer by giving an example.
10588
10589 Suppose that we have an external device which presents two bytes, the first
10590 byte presented, which is the first (low addressed byte) of the two byte
10591 record is called Master, and the second byte is called Slave.
10592
10593 The left most (most significant bit is called Control for each byte, and
10594 the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
10595 (least significant) bit.
10596
10597 On a big-endian machine, we can write the following representation clause
10598
10599 @smallexample @c ada
10600    type Data is record
10601       Master_Control : Bit;
10602       Master_V1      : Bit;
10603       Master_V2      : Bit;
10604       Master_V3      : Bit;
10605       Master_V4      : Bit;
10606       Master_V5      : Bit;
10607       Master_V6      : Bit;
10608       Master_V7      : Bit;
10609       Slave_Control  : Bit;
10610       Slave_V1       : Bit;
10611       Slave_V2       : Bit;
10612       Slave_V3       : Bit;
10613       Slave_V4       : Bit;
10614       Slave_V5       : Bit;
10615       Slave_V6       : Bit;
10616       Slave_V7       : Bit;
10617    end record;
10618
10619    for Data use record
10620       Master_Control at 0 range 0 .. 0;
10621       Master_V1      at 0 range 1 .. 1;
10622       Master_V2      at 0 range 2 .. 2;
10623       Master_V3      at 0 range 3 .. 3;
10624       Master_V4      at 0 range 4 .. 4;
10625       Master_V5      at 0 range 5 .. 5;
10626       Master_V6      at 0 range 6 .. 6;
10627       Master_V7      at 0 range 7 .. 7;
10628       Slave_Control  at 1 range 0 .. 0;
10629       Slave_V1       at 1 range 1 .. 1;
10630       Slave_V2       at 1 range 2 .. 2;
10631       Slave_V3       at 1 range 3 .. 3;
10632       Slave_V4       at 1 range 4 .. 4;
10633       Slave_V5       at 1 range 5 .. 5;
10634       Slave_V6       at 1 range 6 .. 6;
10635       Slave_V7       at 1 range 7 .. 7;
10636    end record;
10637 @end smallexample
10638
10639 @noindent
10640 Now if we move this to a little endian machine, then the bit ordering within
10641 the byte is backwards, so we have to rewrite the record rep clause as:
10642
10643 @smallexample @c ada
10644    for Data use record
10645       Master_Control at 0 range 7 .. 7;
10646       Master_V1      at 0 range 6 .. 6;
10647       Master_V2      at 0 range 5 .. 5;
10648       Master_V3      at 0 range 4 .. 4;
10649       Master_V4      at 0 range 3 .. 3;
10650       Master_V5      at 0 range 2 .. 2;
10651       Master_V6      at 0 range 1 .. 1;
10652       Master_V7      at 0 range 0 .. 0;
10653       Slave_Control  at 1 range 7 .. 7;
10654       Slave_V1       at 1 range 6 .. 6;
10655       Slave_V2       at 1 range 5 .. 5;
10656       Slave_V3       at 1 range 4 .. 4;
10657       Slave_V4       at 1 range 3 .. 3;
10658       Slave_V5       at 1 range 2 .. 2;
10659       Slave_V6       at 1 range 1 .. 1;
10660       Slave_V7       at 1 range 0 .. 0;
10661    end record;
10662 @end smallexample
10663
10664 @noindent
10665 It is a nuisance to have to rewrite the clause, especially if
10666 the code has to be maintained on both machines.  However,
10667 this is a case that we can handle with the
10668 @code{Bit_Order} attribute if it is implemented.
10669 Note that the implementation is not required on byte addressed
10670 machines, but it is indeed implemented in GNAT.
10671 This means that we can simply use the
10672 first record clause, together with the declaration
10673
10674 @smallexample @c ada
10675    for Data'Bit_Order use High_Order_First;
10676 @end smallexample
10677
10678 @noindent
10679 and the effect is what is desired, namely the layout is exactly the same,
10680 independent of whether the code is compiled on a big-endian or little-endian
10681 machine.
10682
10683 The important point to understand is that byte ordering is not affected.
10684 A @code{Bit_Order} attribute definition never affects which byte a field
10685 ends up in, only where it ends up in that byte.
10686 To make this clear, let us rewrite the record rep clause of the previous
10687 example as:
10688
10689 @smallexample @c ada
10690    for Data'Bit_Order use High_Order_First;
10691    for Data use record
10692       Master_Control at 0 range  0 .. 0;
10693       Master_V1      at 0 range  1 .. 1;
10694       Master_V2      at 0 range  2 .. 2;
10695       Master_V3      at 0 range  3 .. 3;
10696       Master_V4      at 0 range  4 .. 4;
10697       Master_V5      at 0 range  5 .. 5;
10698       Master_V6      at 0 range  6 .. 6;
10699       Master_V7      at 0 range  7 .. 7;
10700       Slave_Control  at 0 range  8 .. 8;
10701       Slave_V1       at 0 range  9 .. 9;
10702       Slave_V2       at 0 range 10 .. 10;
10703       Slave_V3       at 0 range 11 .. 11;
10704       Slave_V4       at 0 range 12 .. 12;
10705       Slave_V5       at 0 range 13 .. 13;
10706       Slave_V6       at 0 range 14 .. 14;
10707       Slave_V7       at 0 range 15 .. 15;
10708    end record;
10709 @end smallexample
10710
10711 @noindent
10712 This is exactly equivalent to saying (a repeat of the first example):
10713
10714 @smallexample @c ada
10715    for Data'Bit_Order use High_Order_First;
10716    for Data use record
10717       Master_Control at 0 range 0 .. 0;
10718       Master_V1      at 0 range 1 .. 1;
10719       Master_V2      at 0 range 2 .. 2;
10720       Master_V3      at 0 range 3 .. 3;
10721       Master_V4      at 0 range 4 .. 4;
10722       Master_V5      at 0 range 5 .. 5;
10723       Master_V6      at 0 range 6 .. 6;
10724       Master_V7      at 0 range 7 .. 7;
10725       Slave_Control  at 1 range 0 .. 0;
10726       Slave_V1       at 1 range 1 .. 1;
10727       Slave_V2       at 1 range 2 .. 2;
10728       Slave_V3       at 1 range 3 .. 3;
10729       Slave_V4       at 1 range 4 .. 4;
10730       Slave_V5       at 1 range 5 .. 5;
10731       Slave_V6       at 1 range 6 .. 6;
10732       Slave_V7       at 1 range 7 .. 7;
10733    end record;
10734 @end smallexample
10735
10736 @noindent
10737 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
10738 field.  The storage place attributes are obtained by normalizing the
10739 values given so that the @code{First_Bit} value is less than 8.  After
10740 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
10741 we specified in the other case.
10742
10743 Now one might expect that the @code{Bit_Order} attribute might affect
10744 bit numbering within the entire record component (two bytes in this
10745 case, thus affecting which byte fields end up in), but that is not
10746 the way this feature is defined, it only affects numbering of bits,
10747 not which byte they end up in.
10748
10749 Consequently it never makes sense to specify a starting bit number
10750 greater than 7 (for a byte addressable field) if an attribute
10751 definition for @code{Bit_Order} has been given, and indeed it
10752 may be actively confusing to specify such a value, so the compiler
10753 generates a warning for such usage.
10754
10755 If you do need to control byte ordering then appropriate conditional
10756 values must be used.  If in our example, the slave byte came first on
10757 some machines we might write:
10758
10759 @smallexample @c ada
10760    Master_Byte_First constant Boolean := @dots{};
10761
10762    Master_Byte : constant Natural :=
10763                    1 - Boolean'Pos (Master_Byte_First);
10764    Slave_Byte  : constant Natural :=
10765                    Boolean'Pos (Master_Byte_First);
10766
10767    for Data'Bit_Order use High_Order_First;
10768    for Data use record
10769       Master_Control at Master_Byte range 0 .. 0;
10770       Master_V1      at Master_Byte range 1 .. 1;
10771       Master_V2      at Master_Byte range 2 .. 2;
10772       Master_V3      at Master_Byte range 3 .. 3;
10773       Master_V4      at Master_Byte range 4 .. 4;
10774       Master_V5      at Master_Byte range 5 .. 5;
10775       Master_V6      at Master_Byte range 6 .. 6;
10776       Master_V7      at Master_Byte range 7 .. 7;
10777       Slave_Control  at Slave_Byte  range 0 .. 0;
10778       Slave_V1       at Slave_Byte  range 1 .. 1;
10779       Slave_V2       at Slave_Byte  range 2 .. 2;
10780       Slave_V3       at Slave_Byte  range 3 .. 3;
10781       Slave_V4       at Slave_Byte  range 4 .. 4;
10782       Slave_V5       at Slave_Byte  range 5 .. 5;
10783       Slave_V6       at Slave_Byte  range 6 .. 6;
10784       Slave_V7       at Slave_Byte  range 7 .. 7;
10785    end record;
10786 @end smallexample
10787
10788 @noindent
10789 Now to switch between machines, all that is necessary is
10790 to set the boolean constant @code{Master_Byte_First} in
10791 an appropriate manner.
10792
10793 @node Pragma Pack for Arrays
10794 @section Pragma Pack for Arrays
10795 @cindex Pragma Pack (for arrays)
10796
10797 @noindent
10798 Pragma @code{Pack} applied to an array has no effect unless the component type
10799 is packable.  For a component type to be packable, it must be one of the
10800 following cases:
10801
10802 @itemize @bullet
10803 @item
10804 Any scalar type
10805 @item
10806 Any type whose size is specified with a size clause
10807 @item
10808 Any packed array type with a static size
10809 @item
10810 Any record type padded because of its default alignment
10811 @end itemize
10812
10813 @noindent
10814 For all these cases, if the component subtype size is in the range
10815 1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
10816 component size were specified giving the component subtype size.
10817 For example if we have:
10818
10819 @smallexample @c ada
10820    type r is range 0 .. 17;
10821
10822    type ar is array (1 .. 8) of r;
10823    pragma Pack (ar);
10824 @end smallexample
10825
10826 @noindent
10827 Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
10828 and the size of the array @code{ar} will be exactly 40 bits.
10829
10830 Note that in some cases this rather fierce approach to packing can produce
10831 unexpected effects.  For example, in Ada 95 and Ada 2005,
10832 subtype @code{Natural} typically has a size of 31, meaning that if you
10833 pack an array of @code{Natural}, you get 31-bit
10834 close packing, which saves a few bits, but results in far less efficient
10835 access.  Since many other Ada compilers will ignore such a packing request,
10836 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
10837 might not be what is intended.  You can easily remove this warning by
10838 using an explicit @code{Component_Size} setting instead, which never generates
10839 a warning, since the intention of the programmer is clear in this case.
10840
10841 GNAT treats packed arrays in one of two ways.  If the size of the array is
10842 known at compile time and is less than 64 bits, then internally the array
10843 is represented as a single modular type, of exactly the appropriate number
10844 of bits.  If the length is greater than 63 bits, or is not known at compile
10845 time, then the packed array is represented as an array of bytes, and the
10846 length is always a multiple of 8 bits.
10847
10848 Note that to represent a packed array as a modular type, the alignment must
10849 be suitable for the modular type involved. For example, on typical machines
10850 a 32-bit packed array will be represented by a 32-bit modular integer with
10851 an alignment of four bytes. If you explicitly override the default alignment
10852 with an alignment clause that is too small, the modular representation
10853 cannot be used. For example, consider the following set of declarations:
10854
10855 @smallexample @c ada
10856    type R is range 1 .. 3;
10857    type S is array (1 .. 31) of R;
10858    for S'Component_Size use 2;
10859    for S'Size use 62;
10860    for S'Alignment use 1;
10861 @end smallexample
10862
10863 @noindent
10864 If the alignment clause were not present, then a 62-bit modular
10865 representation would be chosen (typically with an alignment of 4 or 8
10866 bytes depending on the target). But the default alignment is overridden
10867 with the explicit alignment clause. This means that the modular
10868 representation cannot be used, and instead the array of bytes
10869 representation must be used, meaning that the length must be a multiple
10870 of 8. Thus the above set of declarations will result in a diagnostic
10871 rejecting the size clause and noting that the minimum size allowed is 64.
10872
10873 @cindex Pragma Pack (for type Natural)
10874 @cindex Pragma Pack warning
10875
10876 One special case that is worth noting occurs when the base type of the
10877 component size is 8/16/32 and the subtype is one bit less. Notably this
10878 occurs with subtype @code{Natural}. Consider:
10879
10880 @smallexample @c ada
10881    type Arr is array (1 .. 32) of Natural;
10882    pragma Pack (Arr);
10883 @end smallexample
10884
10885 @noindent
10886 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
10887 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
10888 Ada 83 compilers did not attempt 31 bit packing.
10889
10890 In Ada 95 and Ada 2005, @code{Natural'Size} is required to be 31. Furthermore,
10891 GNAT really does pack 31-bit subtype to 31 bits. This may result in a
10892 substantial unintended performance penalty when porting legacy Ada 83 code.
10893 To help prevent this, GNAT generates a warning in such cases. If you really
10894 want 31 bit packing in a case like this, you can set the component size
10895 explicitly:
10896
10897 @smallexample @c ada
10898    type Arr is array (1 .. 32) of Natural;
10899    for Arr'Component_Size use 31;
10900 @end smallexample
10901
10902 @noindent
10903 Here 31-bit packing is achieved as required, and no warning is generated,
10904 since in this case the programmer intention is clear.
10905
10906 @node Pragma Pack for Records
10907 @section Pragma Pack for Records
10908 @cindex Pragma Pack (for records)
10909
10910 @noindent
10911 Pragma @code{Pack} applied to a record will pack the components to reduce
10912 wasted space from alignment gaps and by reducing the amount of space
10913 taken by components.  We distinguish between @emph{packable} components and
10914 @emph{non-packable} components.
10915 Components of the following types are considered packable:
10916 @itemize @bullet
10917 @item
10918 All primitive types are packable.
10919
10920 @item
10921 Small packed arrays, whose size does not exceed 64 bits, and where the
10922 size is statically known at compile time, are represented internally
10923 as modular integers, and so they are also packable.
10924
10925 @end itemize
10926
10927 @noindent
10928 All packable components occupy the exact number of bits corresponding to
10929 their @code{Size} value, and are packed with no padding bits, i.e.@: they
10930 can start on an arbitrary bit boundary.
10931
10932 All other types are non-packable, they occupy an integral number of
10933 storage units, and
10934 are placed at a boundary corresponding to their alignment requirements.
10935
10936 For example, consider the record
10937
10938 @smallexample @c ada
10939    type Rb1 is array (1 .. 13) of Boolean;
10940    pragma Pack (rb1);
10941
10942    type Rb2 is array (1 .. 65) of Boolean;
10943    pragma Pack (rb2);
10944
10945    type x2 is record
10946       l1 : Boolean;
10947       l2 : Duration;
10948       l3 : Float;
10949       l4 : Boolean;
10950       l5 : Rb1;
10951       l6 : Rb2;
10952    end record;
10953    pragma Pack (x2);
10954 @end smallexample
10955
10956 @noindent
10957 The representation for the record x2 is as follows:
10958
10959 @smallexample @c ada
10960 for x2'Size use 224;
10961 for x2 use record
10962    l1 at  0 range  0 .. 0;
10963    l2 at  0 range  1 .. 64;
10964    l3 at 12 range  0 .. 31;
10965    l4 at 16 range  0 .. 0;
10966    l5 at 16 range  1 .. 13;
10967    l6 at 18 range  0 .. 71;
10968 end record;
10969 @end smallexample
10970
10971 @noindent
10972 Studying this example, we see that the packable fields @code{l1}
10973 and @code{l2} are
10974 of length equal to their sizes, and placed at specific bit boundaries (and
10975 not byte boundaries) to
10976 eliminate padding.  But @code{l3} is of a non-packable float type, so
10977 it is on the next appropriate alignment boundary.
10978
10979 The next two fields are fully packable, so @code{l4} and @code{l5} are
10980 minimally packed with no gaps.  However, type @code{Rb2} is a packed
10981 array that is longer than 64 bits, so it is itself non-packable.  Thus
10982 the @code{l6} field is aligned to the next byte boundary, and takes an
10983 integral number of bytes, i.e.@: 72 bits.
10984
10985 @node Record Representation Clauses
10986 @section Record Representation Clauses
10987 @cindex Record Representation Clause
10988
10989 @noindent
10990 Record representation clauses may be given for all record types, including
10991 types obtained by record extension.  Component clauses are allowed for any
10992 static component.  The restrictions on component clauses depend on the type
10993 of the component.
10994
10995 @cindex Component Clause
10996 For all components of an elementary type, the only restriction on component
10997 clauses is that the size must be at least the 'Size value of the type
10998 (actually the Value_Size).  There are no restrictions due to alignment,
10999 and such components may freely cross storage boundaries.
11000
11001 Packed arrays with a size up to and including 64 bits are represented
11002 internally using a modular type with the appropriate number of bits, and
11003 thus the same lack of restriction applies.  For example, if you declare:
11004
11005 @smallexample @c ada
11006    type R is array (1 .. 49) of Boolean;
11007    pragma Pack (R);
11008    for R'Size use 49;
11009 @end smallexample
11010
11011 @noindent
11012 then a component clause for a component of type R may start on any
11013 specified bit boundary, and may specify a value of 49 bits or greater.
11014
11015 For packed bit arrays that are longer than 64 bits, there are two
11016 cases. If the component size is a power of 2 (1,2,4,8,16,32 bits),
11017 including the important case of single bits or boolean values, then
11018 there are no limitations on placement of such components, and they
11019 may start and end at arbitrary bit boundaries.
11020
11021 If the component size is not a power of 2 (e.g.@: 3 or 5), then
11022 an array of this type longer than 64 bits must always be placed on
11023 on a storage unit (byte) boundary and occupy an integral number
11024 of storage units (bytes). Any component clause that does not
11025 meet this requirement will be rejected.
11026
11027 Any aliased component, or component of an aliased type, must
11028 have its normal alignment and size. A component clause that
11029 does not meet this requirement will be rejected.
11030
11031 The tag field of a tagged type always occupies an address sized field at
11032 the start of the record.  No component clause may attempt to overlay this
11033 tag. When a tagged type appears as a component, the tag field must have
11034 proper alignment
11035
11036 In the case of a record extension T1, of a type T, no component clause applied
11037 to the type T1 can specify a storage location that would overlap the first
11038 T'Size bytes of the record.
11039
11040 For all other component types, including non-bit-packed arrays,
11041 the component can be placed at an arbitrary bit boundary,
11042 so for example, the following is permitted:
11043
11044 @smallexample @c ada
11045    type R is array (1 .. 10) of Boolean;
11046    for R'Size use 80;
11047
11048    type Q is record
11049       G, H : Boolean;
11050       L, M : R;
11051    end record;
11052
11053    for Q use record
11054       G at 0 range  0 ..   0;
11055       H at 0 range  1 ..   1;
11056       L at 0 range  2 ..  81;
11057       R at 0 range 82 .. 161;
11058    end record;
11059 @end smallexample
11060
11061 @noindent
11062 Note: the above rules apply to recent releases of GNAT 5.
11063 In GNAT 3, there are more severe restrictions on larger components.
11064 For non-primitive types, including packed arrays with a size greater than
11065 64 bits, component clauses must respect the alignment requirement of the
11066 type, in particular, always starting on a byte boundary, and the length
11067 must be a multiple of the storage unit.
11068
11069 @node Enumeration Clauses
11070 @section Enumeration Clauses
11071
11072 The only restriction on enumeration clauses is that the range of values
11073 must be representable.  For the signed case, if one or more of the
11074 representation values are negative, all values must be in the range:
11075
11076 @smallexample @c ada
11077    System.Min_Int .. System.Max_Int
11078 @end smallexample
11079
11080 @noindent
11081 For the unsigned case, where all values are nonnegative, the values must
11082 be in the range:
11083
11084 @smallexample @c ada
11085    0 .. System.Max_Binary_Modulus;
11086 @end smallexample
11087
11088 @noindent
11089 A @emph{confirming} representation clause is one in which the values range
11090 from 0 in sequence, i.e.@: a clause that confirms the default representation
11091 for an enumeration type.
11092 Such a confirming representation
11093 is permitted by these rules, and is specially recognized by the compiler so
11094 that no extra overhead results from the use of such a clause.
11095
11096 If an array has an index type which is an enumeration type to which an
11097 enumeration clause has been applied, then the array is stored in a compact
11098 manner.  Consider the declarations:
11099
11100 @smallexample @c ada
11101    type r is (A, B, C);
11102    for r use (A => 1, B => 5, C => 10);
11103    type t is array (r) of Character;
11104 @end smallexample
11105
11106 @noindent
11107 The array type t corresponds to a vector with exactly three elements and
11108 has a default size equal to @code{3*Character'Size}.  This ensures efficient
11109 use of space, but means that accesses to elements of the array will incur
11110 the overhead of converting representation values to the corresponding
11111 positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
11112
11113 @node Address Clauses
11114 @section Address Clauses
11115 @cindex Address Clause
11116
11117 The reference manual allows a general restriction on representation clauses,
11118 as found in RM 13.1(22):
11119
11120 @quotation
11121 An implementation need not support representation
11122 items containing nonstatic expressions, except that
11123 an implementation should support a representation item
11124 for a given entity if each nonstatic expression in the
11125 representation item is a name that statically denotes
11126 a constant declared before the entity.
11127 @end quotation
11128
11129 @noindent
11130 In practice this is applicable only to address clauses, since this is the
11131 only case in which a non-static expression is permitted by the syntax.  As
11132 the AARM notes in sections 13.1 (22.a-22.h):
11133
11134 @display
11135   22.a   Reason: This is to avoid the following sort of thing:
11136
11137   22.b        X : Integer := F(@dots{});
11138               Y : Address := G(@dots{});
11139               for X'Address use Y;
11140
11141   22.c   In the above, we have to evaluate the
11142          initialization expression for X before we
11143          know where to put the result.  This seems
11144          like an unreasonable implementation burden.
11145
11146   22.d   The above code should instead be written
11147          like this:
11148
11149   22.e        Y : constant Address := G(@dots{});
11150               X : Integer := F(@dots{});
11151               for X'Address use Y;
11152
11153   22.f   This allows the expression ``Y'' to be safely
11154          evaluated before X is created.
11155
11156   22.g   The constant could be a formal parameter of mode in.
11157
11158   22.h   An implementation can support other nonstatic
11159          expressions if it wants to.  Expressions of type
11160          Address are hardly ever static, but their value
11161          might be known at compile time anyway in many
11162          cases.
11163 @end display
11164
11165 @noindent
11166 GNAT does indeed permit many additional cases of non-static expressions.  In
11167 particular, if the type involved is elementary there are no restrictions
11168 (since in this case, holding a temporary copy of the initialization value,
11169 if one is present, is inexpensive).  In addition, if there is no implicit or
11170 explicit initialization, then there are no restrictions.  GNAT will reject
11171 only the case where all three of these conditions hold:
11172
11173 @itemize @bullet
11174
11175 @item
11176 The type of the item is non-elementary (e.g.@: a record or array).
11177
11178 @item
11179 There is explicit or implicit initialization required for the object.
11180 Note that access values are always implicitly initialized, and also
11181 in GNAT, certain bit-packed arrays (those having a dynamic length or
11182 a length greater than 64) will also be implicitly initialized to zero.
11183
11184 @item
11185 The address value is non-static.  Here GNAT is more permissive than the
11186 RM, and allows the address value to be the address of a previously declared
11187 stand-alone variable, as long as it does not itself have an address clause.
11188
11189 @smallexample @c ada
11190            Anchor  : Some_Initialized_Type;
11191            Overlay : Some_Initialized_Type;
11192            for Overlay'Address use Anchor'Address;
11193 @end smallexample
11194
11195 @noindent
11196 However, the prefix of the address clause cannot be an array component, or
11197 a component of a discriminated record.
11198
11199 @end itemize
11200
11201 @noindent
11202 As noted above in section 22.h, address values are typically non-static.  In
11203 particular the To_Address function, even if applied to a literal value, is
11204 a non-static function call.  To avoid this minor annoyance, GNAT provides
11205 the implementation defined attribute 'To_Address.  The following two
11206 expressions have identical values:
11207
11208 @findex Attribute
11209 @findex To_Address
11210 @smallexample @c ada
11211    To_Address (16#1234_0000#)
11212    System'To_Address (16#1234_0000#);
11213 @end smallexample
11214
11215 @noindent
11216 except that the second form is considered to be a static expression, and
11217 thus when used as an address clause value is always permitted.
11218
11219 @noindent
11220 Additionally, GNAT treats as static an address clause that is an
11221 unchecked_conversion of a static integer value.  This simplifies the porting
11222 of legacy code, and provides a portable equivalent to the GNAT attribute
11223 @code{To_Address}.
11224
11225 Another issue with address clauses is the interaction with alignment
11226 requirements.  When an address clause is given for an object, the address
11227 value must be consistent with the alignment of the object (which is usually
11228 the same as the alignment of the type of the object).  If an address clause
11229 is given that specifies an inappropriately aligned address value, then the
11230 program execution is erroneous.
11231
11232 Since this source of erroneous behavior can have unfortunate effects, GNAT
11233 checks (at compile time if possible, generating a warning, or at execution
11234 time with a run-time check) that the alignment is appropriate.  If the
11235 run-time check fails, then @code{Program_Error} is raised.  This run-time
11236 check is suppressed if range checks are suppressed, or if the special GNAT
11237 check Alignment_Check is suppressed, or if
11238 @code{pragma Restrictions (No_Elaboration_Code)} is in effect.
11239
11240 Finally, GNAT does not permit overlaying of objects of controlled types or
11241 composite types containing a controlled component. In most cases, the compiler
11242 can detect an attempt at such overlays and will generate a warning at compile
11243 time and a Program_Error exception at run time.
11244
11245 @findex Export
11246 An address clause cannot be given for an exported object.  More
11247 understandably the real restriction is that objects with an address
11248 clause cannot be exported.  This is because such variables are not
11249 defined by the Ada program, so there is no external object to export.
11250
11251 @findex Import
11252 It is permissible to give an address clause and a pragma Import for the
11253 same object.  In this case, the variable is not really defined by the
11254 Ada program, so there is no external symbol to be linked.  The link name
11255 and the external name are ignored in this case.  The reason that we allow this
11256 combination is that it provides a useful idiom to avoid unwanted
11257 initializations on objects with address clauses.
11258
11259 When an address clause is given for an object that has implicit or
11260 explicit initialization, then by default initialization takes place.  This
11261 means that the effect of the object declaration is to overwrite the
11262 memory at the specified address.  This is almost always not what the
11263 programmer wants, so GNAT will output a warning:
11264
11265 @smallexample
11266   with System;
11267   package G is
11268      type R is record
11269         M : Integer := 0;
11270      end record;
11271
11272      Ext : R;
11273      for Ext'Address use System'To_Address (16#1234_1234#);
11274          |
11275   >>> warning: implicit initialization of "Ext" may
11276       modify overlaid storage
11277   >>> warning: use pragma Import for "Ext" to suppress
11278       initialization (RM B(24))
11279
11280   end G;
11281 @end smallexample
11282
11283 @noindent
11284 As indicated by the warning message, the solution is to use a (dummy) pragma
11285 Import to suppress this initialization.  The pragma tell the compiler that the
11286 object is declared and initialized elsewhere.  The following package compiles
11287 without warnings (and the initialization is suppressed):
11288
11289 @smallexample @c ada
11290    with System;
11291    package G is
11292       type R is record
11293          M : Integer := 0;
11294       end record;
11295
11296       Ext : R;
11297       for Ext'Address use System'To_Address (16#1234_1234#);
11298       pragma Import (Ada, Ext);
11299    end G;
11300 @end smallexample
11301
11302 @noindent
11303 A final issue with address clauses involves their use for overlaying
11304 variables, as in the following example:
11305 @cindex Overlaying of objects
11306
11307 @smallexample @c ada
11308   A : Integer;
11309   B : Integer;
11310   for B'Address use A'Address;
11311 @end smallexample
11312
11313 @noindent
11314 or alternatively, using the form recommended by the RM:
11315
11316 @smallexample @c ada
11317   A    : Integer;
11318   Addr : constant Address := A'Address;
11319   B    : Integer;
11320   for B'Address use Addr;
11321 @end smallexample
11322
11323 @noindent
11324 In both of these cases, @code{A}
11325 and @code{B} become aliased to one another via the
11326 address clause. This use of address clauses to overlay
11327 variables, achieving an effect similar to unchecked
11328 conversion was erroneous in Ada 83, but in Ada 95 and Ada 2005
11329 the effect is implementation defined. Furthermore, the
11330 Ada RM specifically recommends that in a situation
11331 like this, @code{B} should be subject to the following
11332 implementation advice (RM 13.3(19)):
11333
11334 @quotation
11335 19  If the Address of an object is specified, or it is imported
11336     or exported, then the implementation should not perform
11337     optimizations based on assumptions of no aliases.
11338 @end quotation
11339
11340 @noindent
11341 GNAT follows this recommendation, and goes further by also applying
11342 this recommendation to the overlaid variable (@code{A}
11343 in the above example) in this case. This means that the overlay
11344 works "as expected", in that a modification to one of the variables
11345 will affect the value of the other.
11346
11347 @node Effect of Convention on Representation
11348 @section Effect of Convention on Representation
11349 @cindex Convention, effect on representation
11350
11351 @noindent
11352 Normally the specification of a foreign language convention for a type or
11353 an object has no effect on the chosen representation.  In particular, the
11354 representation chosen for data in GNAT generally meets the standard system
11355 conventions, and for example records are laid out in a manner that is
11356 consistent with C@.  This means that specifying convention C (for example)
11357 has no effect.
11358
11359 There are four exceptions to this general rule:
11360
11361 @itemize @bullet
11362
11363 @item Convention Fortran and array subtypes
11364 If pragma Convention Fortran is specified for an array subtype, then in
11365 accordance with the implementation advice in section 3.6.2(11) of the
11366 Ada Reference Manual, the array will be stored in a Fortran-compatible
11367 column-major manner, instead of the normal default row-major order.
11368
11369 @item Convention C and enumeration types
11370 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
11371 to accommodate all values of the type.  For example, for the enumeration
11372 type declared by:
11373
11374 @smallexample @c ada
11375    type Color is (Red, Green, Blue);
11376 @end smallexample
11377
11378 @noindent
11379 8 bits is sufficient to store all values of the type, so by default, objects
11380 of type @code{Color} will be represented using 8 bits.  However, normal C
11381 convention is to use 32 bits for all enum values in C, since enum values
11382 are essentially of type int.  If pragma @code{Convention C} is specified for an
11383 Ada enumeration type, then the size is modified as necessary (usually to
11384 32 bits) to be consistent with the C convention for enum values.
11385
11386 Note that this treatment applies only to types. If Convention C is given for
11387 an enumeration object, where the enumeration type is not Convention C, then
11388 Object_Size bits are allocated. For example, for a normal enumeration type,
11389 with less than 256 elements, only 8 bits will be allocated for the object.
11390 Since this may be a surprise in terms of what C expects, GNAT will issue a
11391 warning in this situation. The warning can be suppressed by giving an explicit
11392 size clause specifying the desired size.
11393
11394 @item Convention C/Fortran and Boolean types
11395 In C, the usual convention for boolean values, that is values used for
11396 conditions, is that zero represents false, and nonzero values represent
11397 true.  In Ada, the normal convention is that two specific values, typically
11398 0/1, are used to represent false/true respectively.
11399
11400 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
11401 value represents true).
11402
11403 To accommodate the Fortran and C conventions, if a pragma Convention specifies
11404 C or Fortran convention for a derived Boolean, as in the following example:
11405
11406 @smallexample @c ada
11407    type C_Switch is new Boolean;
11408    pragma Convention (C, C_Switch);
11409 @end smallexample
11410
11411 @noindent
11412 then the GNAT generated code will treat any nonzero value as true.  For truth
11413 values generated by GNAT, the conventional value 1 will be used for True, but
11414 when one of these values is read, any nonzero value is treated as True.
11415
11416 @item Access types on OpenVMS
11417 For 64-bit OpenVMS systems, access types (other than those for unconstrained
11418 arrays) are 64-bits long. An exception to this rule is for the case of
11419 C-convention access types where there is no explicit size clause present (or
11420 inherited for derived types). In this case, GNAT chooses to make these
11421 pointers 32-bits, which provides an easier path for migration of 32-bit legacy
11422 code. size clause specifying 64-bits must be used to obtain a 64-bit pointer.
11423
11424 @end itemize
11425
11426 @node Determining the Representations chosen by GNAT
11427 @section Determining the Representations chosen by GNAT
11428 @cindex Representation, determination of
11429 @cindex @option{-gnatR} switch
11430
11431 @noindent
11432 Although the descriptions in this section are intended to be complete, it is
11433 often easier to simply experiment to see what GNAT accepts and what the
11434 effect is on the layout of types and objects.
11435
11436 As required by the Ada RM, if a representation clause is not accepted, then
11437 it must be rejected as illegal by the compiler.  However, when a
11438 representation clause or pragma is accepted, there can still be questions
11439 of what the compiler actually does.  For example, if a partial record
11440 representation clause specifies the location of some components and not
11441 others, then where are the non-specified components placed? Or if pragma
11442 @code{Pack} is used on a record, then exactly where are the resulting
11443 fields placed? The section on pragma @code{Pack} in this chapter can be
11444 used to answer the second question, but it is often easier to just see
11445 what the compiler does.
11446
11447 For this purpose, GNAT provides the option @option{-gnatR}.  If you compile
11448 with this option, then the compiler will output information on the actual
11449 representations chosen, in a format similar to source representation
11450 clauses.  For example, if we compile the package:
11451
11452 @smallexample @c ada
11453 package q is
11454    type r (x : boolean) is tagged record
11455       case x is
11456          when True => S : String (1 .. 100);
11457          when False => null;
11458       end case;
11459    end record;
11460
11461    type r2 is new r (false) with record
11462       y2 : integer;
11463    end record;
11464
11465    for r2 use record
11466       y2 at 16 range 0 .. 31;
11467    end record;
11468
11469    type x is record
11470       y : character;
11471    end record;
11472
11473    type x1 is array (1 .. 10) of x;
11474    for x1'component_size use 11;
11475
11476    type ia is access integer;
11477
11478    type Rb1 is array (1 .. 13) of Boolean;
11479    pragma Pack (rb1);
11480
11481    type Rb2 is array (1 .. 65) of Boolean;
11482    pragma Pack (rb2);
11483
11484    type x2 is record
11485       l1 : Boolean;
11486       l2 : Duration;
11487       l3 : Float;
11488       l4 : Boolean;
11489       l5 : Rb1;
11490       l6 : Rb2;
11491    end record;
11492    pragma Pack (x2);
11493 end q;
11494 @end smallexample
11495
11496 @noindent
11497 using the switch @option{-gnatR} we obtain the following output:
11498
11499 @smallexample
11500 Representation information for unit q
11501 -------------------------------------
11502
11503 for r'Size use ??;
11504 for r'Alignment use 4;
11505 for r use record
11506    x    at 4 range  0 .. 7;
11507    _tag at 0 range  0 .. 31;
11508    s    at 5 range  0 .. 799;
11509 end record;
11510
11511 for r2'Size use 160;
11512 for r2'Alignment use 4;
11513 for r2 use record
11514    x       at  4 range  0 .. 7;
11515    _tag    at  0 range  0 .. 31;
11516    _parent at  0 range  0 .. 63;
11517    y2      at 16 range  0 .. 31;
11518 end record;
11519
11520 for x'Size use 8;
11521 for x'Alignment use 1;
11522 for x use record
11523    y at 0 range  0 .. 7;
11524 end record;
11525
11526 for x1'Size use 112;
11527 for x1'Alignment use 1;
11528 for x1'Component_Size use 11;
11529
11530 for rb1'Size use 13;
11531 for rb1'Alignment use 2;
11532 for rb1'Component_Size use 1;
11533
11534 for rb2'Size use 72;
11535 for rb2'Alignment use 1;
11536 for rb2'Component_Size use 1;
11537
11538 for x2'Size use 224;
11539 for x2'Alignment use 4;
11540 for x2 use record
11541    l1 at  0 range  0 .. 0;
11542    l2 at  0 range  1 .. 64;
11543    l3 at 12 range  0 .. 31;
11544    l4 at 16 range  0 .. 0;
11545    l5 at 16 range  1 .. 13;
11546    l6 at 18 range  0 .. 71;
11547 end record;
11548 @end smallexample
11549
11550 @noindent
11551 The Size values are actually the Object_Size, i.e.@: the default size that
11552 will be allocated for objects of the type.
11553 The ?? size for type r indicates that we have a variant record, and the
11554 actual size of objects will depend on the discriminant value.
11555
11556 The Alignment values show the actual alignment chosen by the compiler
11557 for each record or array type.
11558
11559 The record representation clause for type r shows where all fields
11560 are placed, including the compiler generated tag field (whose location
11561 cannot be controlled by the programmer).
11562
11563 The record representation clause for the type extension r2 shows all the
11564 fields present, including the parent field, which is a copy of the fields
11565 of the parent type of r2, i.e.@: r1.
11566
11567 The component size and size clauses for types rb1 and rb2 show
11568 the exact effect of pragma @code{Pack} on these arrays, and the record
11569 representation clause for type x2 shows how pragma @code{Pack} affects
11570 this record type.
11571
11572 In some cases, it may be useful to cut and paste the representation clauses
11573 generated by the compiler into the original source to fix and guarantee
11574 the actual representation to be used.
11575
11576 @node Standard Library Routines
11577 @chapter Standard Library Routines
11578
11579 @noindent
11580 The Ada Reference Manual contains in Annex A a full description of an
11581 extensive set of standard library routines that can be used in any Ada
11582 program, and which must be provided by all Ada compilers.  They are
11583 analogous to the standard C library used by C programs.
11584
11585 GNAT implements all of the facilities described in annex A, and for most
11586 purposes the description in the Ada Reference Manual, or appropriate Ada
11587 text book, will be sufficient for making use of these facilities.
11588
11589 In the case of the input-output facilities,
11590 @xref{The Implementation of Standard I/O},
11591 gives details on exactly how GNAT interfaces to the
11592 file system.  For the remaining packages, the Ada Reference Manual
11593 should be sufficient.  The following is a list of the packages included,
11594 together with a brief description of the functionality that is provided.
11595
11596 For completeness, references are included to other predefined library
11597 routines defined in other sections of the Ada Reference Manual (these are
11598 cross-indexed from Annex A).
11599
11600 @table @code
11601 @item Ada (A.2)
11602 This is a parent package for all the standard library packages.  It is
11603 usually included implicitly in your program, and itself contains no
11604 useful data or routines.
11605
11606 @item Ada.Calendar (9.6)
11607 @code{Calendar} provides time of day access, and routines for
11608 manipulating times and durations.
11609
11610 @item Ada.Characters (A.3.1)
11611 This is a dummy parent package that contains no useful entities
11612
11613 @item Ada.Characters.Handling (A.3.2)
11614 This package provides some basic character handling capabilities,
11615 including classification functions for classes of characters (e.g.@: test
11616 for letters, or digits).
11617
11618 @item Ada.Characters.Latin_1 (A.3.3)
11619 This package includes a complete set of definitions of the characters
11620 that appear in type CHARACTER@.  It is useful for writing programs that
11621 will run in international environments.  For example, if you want an
11622 upper case E with an acute accent in a string, it is often better to use
11623 the definition of @code{UC_E_Acute} in this package.  Then your program
11624 will print in an understandable manner even if your environment does not
11625 support these extended characters.
11626
11627 @item Ada.Command_Line (A.15)
11628 This package provides access to the command line parameters and the name
11629 of the current program (analogous to the use of @code{argc} and @code{argv}
11630 in C), and also allows the exit status for the program to be set in a
11631 system-independent manner.
11632
11633 @item Ada.Decimal (F.2)
11634 This package provides constants describing the range of decimal numbers
11635 implemented, and also a decimal divide routine (analogous to the COBOL
11636 verb DIVIDE @dots{} GIVING @dots{} REMAINDER @dots{})
11637
11638 @item Ada.Direct_IO (A.8.4)
11639 This package provides input-output using a model of a set of records of
11640 fixed-length, containing an arbitrary definite Ada type, indexed by an
11641 integer record number.
11642
11643 @item Ada.Dynamic_Priorities (D.5)
11644 This package allows the priorities of a task to be adjusted dynamically
11645 as the task is running.
11646
11647 @item Ada.Exceptions (11.4.1)
11648 This package provides additional information on exceptions, and also
11649 contains facilities for treating exceptions as data objects, and raising
11650 exceptions with associated messages.
11651
11652 @item Ada.Finalization (7.6)
11653 This package contains the declarations and subprograms to support the
11654 use of controlled types, providing for automatic initialization and
11655 finalization (analogous to the constructors and destructors of C++)
11656
11657 @item Ada.Interrupts (C.3.2)
11658 This package provides facilities for interfacing to interrupts, which
11659 includes the set of signals or conditions that can be raised and
11660 recognized as interrupts.
11661
11662 @item Ada.Interrupts.Names (C.3.2)
11663 This package provides the set of interrupt names (actually signal
11664 or condition names) that can be handled by GNAT@.
11665
11666 @item Ada.IO_Exceptions (A.13)
11667 This package defines the set of exceptions that can be raised by use of
11668 the standard IO packages.
11669
11670 @item Ada.Numerics
11671 This package contains some standard constants and exceptions used
11672 throughout the numerics packages.  Note that the constants pi and e are
11673 defined here, and it is better to use these definitions than rolling
11674 your own.
11675
11676 @item Ada.Numerics.Complex_Elementary_Functions
11677 Provides the implementation of standard elementary functions (such as
11678 log and trigonometric functions) operating on complex numbers using the
11679 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
11680 created by the package @code{Numerics.Complex_Types}.
11681
11682 @item Ada.Numerics.Complex_Types
11683 This is a predefined instantiation of
11684 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
11685 build the type @code{Complex} and @code{Imaginary}.
11686
11687 @item Ada.Numerics.Discrete_Random
11688 This package provides a random number generator suitable for generating
11689 random integer values from a specified range.
11690
11691 @item Ada.Numerics.Float_Random
11692 This package provides a random number generator suitable for generating
11693 uniformly distributed floating point values.
11694
11695 @item Ada.Numerics.Generic_Complex_Elementary_Functions
11696 This is a generic version of the package that provides the
11697 implementation of standard elementary functions (such as log and
11698 trigonometric functions) for an arbitrary complex type.
11699
11700 The following predefined instantiations of this package are provided:
11701
11702 @table @code
11703 @item Short_Float
11704 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
11705 @item Float
11706 @code{Ada.Numerics.Complex_Elementary_Functions}
11707 @item Long_Float
11708 @code{Ada.Numerics.Long_Complex_Elementary_Functions}
11709 @end table
11710
11711 @item Ada.Numerics.Generic_Complex_Types
11712 This is a generic package that allows the creation of complex types,
11713 with associated complex arithmetic operations.
11714
11715 The following predefined instantiations of this package exist
11716 @table @code
11717 @item Short_Float
11718 @code{Ada.Numerics.Short_Complex_Complex_Types}
11719 @item Float
11720 @code{Ada.Numerics.Complex_Complex_Types}
11721 @item Long_Float
11722 @code{Ada.Numerics.Long_Complex_Complex_Types}
11723 @end table
11724
11725 @item Ada.Numerics.Generic_Elementary_Functions
11726 This is a generic package that provides the implementation of standard
11727 elementary functions (such as log an trigonometric functions) for an
11728 arbitrary float type.
11729
11730 The following predefined instantiations of this package exist
11731
11732 @table @code
11733 @item Short_Float
11734 @code{Ada.Numerics.Short_Elementary_Functions}
11735 @item Float
11736 @code{Ada.Numerics.Elementary_Functions}
11737 @item Long_Float
11738 @code{Ada.Numerics.Long_Elementary_Functions}
11739 @end table
11740
11741 @item Ada.Real_Time (D.8)
11742 This package provides facilities similar to those of @code{Calendar}, but
11743 operating with a finer clock suitable for real time control. Note that
11744 annex D requires that there be no backward clock jumps, and GNAT generally
11745 guarantees this behavior, but of course if the external clock on which
11746 the GNAT runtime depends is deliberately reset by some external event,
11747 then such a backward jump may occur.
11748
11749 @item Ada.Sequential_IO (A.8.1)
11750 This package provides input-output facilities for sequential files,
11751 which can contain a sequence of values of a single type, which can be
11752 any Ada type, including indefinite (unconstrained) types.
11753
11754 @item Ada.Storage_IO (A.9)
11755 This package provides a facility for mapping arbitrary Ada types to and
11756 from a storage buffer.  It is primarily intended for the creation of new
11757 IO packages.
11758
11759 @item Ada.Streams (13.13.1)
11760 This is a generic package that provides the basic support for the
11761 concept of streams as used by the stream attributes (@code{Input},
11762 @code{Output}, @code{Read} and @code{Write}).
11763
11764 @item Ada.Streams.Stream_IO (A.12.1)
11765 This package is a specialization of the type @code{Streams} defined in
11766 package @code{Streams} together with a set of operations providing
11767 Stream_IO capability.  The Stream_IO model permits both random and
11768 sequential access to a file which can contain an arbitrary set of values
11769 of one or more Ada types.
11770
11771 @item Ada.Strings (A.4.1)
11772 This package provides some basic constants used by the string handling
11773 packages.
11774
11775 @item Ada.Strings.Bounded (A.4.4)
11776 This package provides facilities for handling variable length
11777 strings.  The bounded model requires a maximum length.  It is thus
11778 somewhat more limited than the unbounded model, but avoids the use of
11779 dynamic allocation or finalization.
11780
11781 @item Ada.Strings.Fixed (A.4.3)
11782 This package provides facilities for handling fixed length strings.
11783
11784 @item Ada.Strings.Maps (A.4.2)
11785 This package provides facilities for handling character mappings and
11786 arbitrarily defined subsets of characters.  For instance it is useful in
11787 defining specialized translation tables.
11788
11789 @item Ada.Strings.Maps.Constants (A.4.6)
11790 This package provides a standard set of predefined mappings and
11791 predefined character sets.  For example, the standard upper to lower case
11792 conversion table is found in this package.  Note that upper to lower case
11793 conversion is non-trivial if you want to take the entire set of
11794 characters, including extended characters like E with an acute accent,
11795 into account.  You should use the mappings in this package (rather than
11796 adding 32 yourself) to do case mappings.
11797
11798 @item Ada.Strings.Unbounded (A.4.5)
11799 This package provides facilities for handling variable length
11800 strings.  The unbounded model allows arbitrary length strings, but
11801 requires the use of dynamic allocation and finalization.
11802
11803 @item Ada.Strings.Wide_Bounded (A.4.7)
11804 @itemx Ada.Strings.Wide_Fixed (A.4.7)
11805 @itemx Ada.Strings.Wide_Maps (A.4.7)
11806 @itemx Ada.Strings.Wide_Maps.Constants (A.4.7)
11807 @itemx Ada.Strings.Wide_Unbounded (A.4.7)
11808 These packages provide analogous capabilities to the corresponding
11809 packages without @samp{Wide_} in the name, but operate with the types
11810 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
11811 and @code{Character}.
11812
11813 @item Ada.Strings.Wide_Wide_Bounded (A.4.7)
11814 @itemx Ada.Strings.Wide_Wide_Fixed (A.4.7)
11815 @itemx Ada.Strings.Wide_Wide_Maps (A.4.7)
11816 @itemx Ada.Strings.Wide_Wide_Maps.Constants (A.4.7)
11817 @itemx Ada.Strings.Wide_Wide_Unbounded (A.4.7)
11818 These packages provide analogous capabilities to the corresponding
11819 packages without @samp{Wide_} in the name, but operate with the types
11820 @code{Wide_Wide_String} and @code{Wide_Wide_Character} instead
11821 of @code{String} and @code{Character}.
11822
11823 @item Ada.Synchronous_Task_Control (D.10)
11824 This package provides some standard facilities for controlling task
11825 communication in a synchronous manner.
11826
11827 @item Ada.Tags
11828 This package contains definitions for manipulation of the tags of tagged
11829 values.
11830
11831 @item Ada.Task_Attributes
11832 This package provides the capability of associating arbitrary
11833 task-specific data with separate tasks.
11834
11835 @item Ada.Text_IO
11836 This package provides basic text input-output capabilities for
11837 character, string and numeric data.  The subpackages of this
11838 package are listed next.
11839
11840 @item Ada.Text_IO.Decimal_IO
11841 Provides input-output facilities for decimal fixed-point types
11842
11843 @item Ada.Text_IO.Enumeration_IO
11844 Provides input-output facilities for enumeration types.
11845
11846 @item Ada.Text_IO.Fixed_IO
11847 Provides input-output facilities for ordinary fixed-point types.
11848
11849 @item Ada.Text_IO.Float_IO
11850 Provides input-output facilities for float types.  The following
11851 predefined instantiations of this generic package are available:
11852
11853 @table @code
11854 @item Short_Float
11855 @code{Short_Float_Text_IO}
11856 @item Float
11857 @code{Float_Text_IO}
11858 @item Long_Float
11859 @code{Long_Float_Text_IO}
11860 @end table
11861
11862 @item Ada.Text_IO.Integer_IO
11863 Provides input-output facilities for integer types.  The following
11864 predefined instantiations of this generic package are available:
11865
11866 @table @code
11867 @item Short_Short_Integer
11868 @code{Ada.Short_Short_Integer_Text_IO}
11869 @item Short_Integer
11870 @code{Ada.Short_Integer_Text_IO}
11871 @item Integer
11872 @code{Ada.Integer_Text_IO}
11873 @item Long_Integer
11874 @code{Ada.Long_Integer_Text_IO}
11875 @item Long_Long_Integer
11876 @code{Ada.Long_Long_Integer_Text_IO}
11877 @end table
11878
11879 @item Ada.Text_IO.Modular_IO
11880 Provides input-output facilities for modular (unsigned) types
11881
11882 @item Ada.Text_IO.Complex_IO (G.1.3)
11883 This package provides basic text input-output capabilities for complex
11884 data.
11885
11886 @item Ada.Text_IO.Editing (F.3.3)
11887 This package contains routines for edited output, analogous to the use
11888 of pictures in COBOL@.  The picture formats used by this package are a
11889 close copy of the facility in COBOL@.
11890
11891 @item Ada.Text_IO.Text_Streams (A.12.2)
11892 This package provides a facility that allows Text_IO files to be treated
11893 as streams, so that the stream attributes can be used for writing
11894 arbitrary data, including binary data, to Text_IO files.
11895
11896 @item Ada.Unchecked_Conversion (13.9)
11897 This generic package allows arbitrary conversion from one type to
11898 another of the same size, providing for breaking the type safety in
11899 special circumstances.
11900
11901 If the types have the same Size (more accurately the same Value_Size),
11902 then the effect is simply to transfer the bits from the source to the
11903 target type without any modification.  This usage is well defined, and
11904 for simple types whose representation is typically the same across
11905 all implementations, gives a portable method of performing such
11906 conversions.
11907
11908 If the types do not have the same size, then the result is implementation
11909 defined, and thus may be non-portable.  The following describes how GNAT
11910 handles such unchecked conversion cases.
11911
11912 If the types are of different sizes, and are both discrete types, then
11913 the effect is of a normal type conversion without any constraint checking.
11914 In particular if the result type has a larger size, the result will be
11915 zero or sign extended.  If the result type has a smaller size, the result
11916 will be truncated by ignoring high order bits.
11917
11918 If the types are of different sizes, and are not both discrete types,
11919 then the conversion works as though pointers were created to the source
11920 and target, and the pointer value is converted.  The effect is that bits
11921 are copied from successive low order storage units and bits of the source
11922 up to the length of the target type.
11923
11924 A warning is issued if the lengths differ, since the effect in this
11925 case is implementation dependent, and the above behavior may not match
11926 that of some other compiler.
11927
11928 A pointer to one type may be converted to a pointer to another type using
11929 unchecked conversion.  The only case in which the effect is undefined is
11930 when one or both pointers are pointers to unconstrained array types.  In
11931 this case, the bounds information may get incorrectly transferred, and in
11932 particular, GNAT uses double size pointers for such types, and it is
11933 meaningless to convert between such pointer types.  GNAT will issue a
11934 warning if the alignment of the target designated type is more strict
11935 than the alignment of the source designated type (since the result may
11936 be unaligned in this case).
11937
11938 A pointer other than a pointer to an unconstrained array type may be
11939 converted to and from System.Address.  Such usage is common in Ada 83
11940 programs, but note that Ada.Address_To_Access_Conversions is the
11941 preferred method of performing such conversions in Ada 95 and Ada 2005.
11942 Neither
11943 unchecked conversion nor Ada.Address_To_Access_Conversions should be
11944 used in conjunction with pointers to unconstrained objects, since
11945 the bounds information cannot be handled correctly in this case.
11946
11947 @item Ada.Unchecked_Deallocation (13.11.2)
11948 This generic package allows explicit freeing of storage previously
11949 allocated by use of an allocator.
11950
11951 @item Ada.Wide_Text_IO (A.11)
11952 This package is similar to @code{Ada.Text_IO}, except that the external
11953 file supports wide character representations, and the internal types are
11954 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
11955 and @code{String}.  It contains generic subpackages listed next.
11956
11957 @item Ada.Wide_Text_IO.Decimal_IO
11958 Provides input-output facilities for decimal fixed-point types
11959
11960 @item Ada.Wide_Text_IO.Enumeration_IO
11961 Provides input-output facilities for enumeration types.
11962
11963 @item Ada.Wide_Text_IO.Fixed_IO
11964 Provides input-output facilities for ordinary fixed-point types.
11965
11966 @item Ada.Wide_Text_IO.Float_IO
11967 Provides input-output facilities for float types.  The following
11968 predefined instantiations of this generic package are available:
11969
11970 @table @code
11971 @item Short_Float
11972 @code{Short_Float_Wide_Text_IO}
11973 @item Float
11974 @code{Float_Wide_Text_IO}
11975 @item Long_Float
11976 @code{Long_Float_Wide_Text_IO}
11977 @end table
11978
11979 @item Ada.Wide_Text_IO.Integer_IO
11980 Provides input-output facilities for integer types.  The following
11981 predefined instantiations of this generic package are available:
11982
11983 @table @code
11984 @item Short_Short_Integer
11985 @code{Ada.Short_Short_Integer_Wide_Text_IO}
11986 @item Short_Integer
11987 @code{Ada.Short_Integer_Wide_Text_IO}
11988 @item Integer
11989 @code{Ada.Integer_Wide_Text_IO}
11990 @item Long_Integer
11991 @code{Ada.Long_Integer_Wide_Text_IO}
11992 @item Long_Long_Integer
11993 @code{Ada.Long_Long_Integer_Wide_Text_IO}
11994 @end table
11995
11996 @item Ada.Wide_Text_IO.Modular_IO
11997 Provides input-output facilities for modular (unsigned) types
11998
11999 @item Ada.Wide_Text_IO.Complex_IO (G.1.3)
12000 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
12001 external file supports wide character representations.
12002
12003 @item Ada.Wide_Text_IO.Editing (F.3.4)
12004 This package is similar to @code{Ada.Text_IO.Editing}, except that the
12005 types are @code{Wide_Character} and @code{Wide_String} instead of
12006 @code{Character} and @code{String}.
12007
12008 @item Ada.Wide_Text_IO.Streams (A.12.3)
12009 This package is similar to @code{Ada.Text_IO.Streams}, except that the
12010 types are @code{Wide_Character} and @code{Wide_String} instead of
12011 @code{Character} and @code{String}.
12012
12013 @item Ada.Wide_Wide_Text_IO (A.11)
12014 This package is similar to @code{Ada.Text_IO}, except that the external
12015 file supports wide character representations, and the internal types are
12016 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
12017 and @code{String}.  It contains generic subpackages listed next.
12018
12019 @item Ada.Wide_Wide_Text_IO.Decimal_IO
12020 Provides input-output facilities for decimal fixed-point types
12021
12022 @item Ada.Wide_Wide_Text_IO.Enumeration_IO
12023 Provides input-output facilities for enumeration types.
12024
12025 @item Ada.Wide_Wide_Text_IO.Fixed_IO
12026 Provides input-output facilities for ordinary fixed-point types.
12027
12028 @item Ada.Wide_Wide_Text_IO.Float_IO
12029 Provides input-output facilities for float types.  The following
12030 predefined instantiations of this generic package are available:
12031
12032 @table @code
12033 @item Short_Float
12034 @code{Short_Float_Wide_Wide_Text_IO}
12035 @item Float
12036 @code{Float_Wide_Wide_Text_IO}
12037 @item Long_Float
12038 @code{Long_Float_Wide_Wide_Text_IO}
12039 @end table
12040
12041 @item Ada.Wide_Wide_Text_IO.Integer_IO
12042 Provides input-output facilities for integer types.  The following
12043 predefined instantiations of this generic package are available:
12044
12045 @table @code
12046 @item Short_Short_Integer
12047 @code{Ada.Short_Short_Integer_Wide_Wide_Text_IO}
12048 @item Short_Integer
12049 @code{Ada.Short_Integer_Wide_Wide_Text_IO}
12050 @item Integer
12051 @code{Ada.Integer_Wide_Wide_Text_IO}
12052 @item Long_Integer
12053 @code{Ada.Long_Integer_Wide_Wide_Text_IO}
12054 @item Long_Long_Integer
12055 @code{Ada.Long_Long_Integer_Wide_Wide_Text_IO}
12056 @end table
12057
12058 @item Ada.Wide_Wide_Text_IO.Modular_IO
12059 Provides input-output facilities for modular (unsigned) types
12060
12061 @item Ada.Wide_Wide_Text_IO.Complex_IO (G.1.3)
12062 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
12063 external file supports wide character representations.
12064
12065 @item Ada.Wide_Wide_Text_IO.Editing (F.3.4)
12066 This package is similar to @code{Ada.Text_IO.Editing}, except that the
12067 types are @code{Wide_Character} and @code{Wide_String} instead of
12068 @code{Character} and @code{String}.
12069
12070 @item Ada.Wide_Wide_Text_IO.Streams (A.12.3)
12071 This package is similar to @code{Ada.Text_IO.Streams}, except that the
12072 types are @code{Wide_Character} and @code{Wide_String} instead of
12073 @code{Character} and @code{String}.
12074 @end table
12075
12076
12077
12078 @node The Implementation of Standard I/O
12079 @chapter The Implementation of Standard I/O
12080
12081 @noindent
12082 GNAT implements all the required input-output facilities described in
12083 A.6 through A.14.  These sections of the Ada Reference Manual describe the
12084 required behavior of these packages from the Ada point of view, and if
12085 you are writing a portable Ada program that does not need to know the
12086 exact manner in which Ada maps to the outside world when it comes to
12087 reading or writing external files, then you do not need to read this
12088 chapter.  As long as your files are all regular files (not pipes or
12089 devices), and as long as you write and read the files only from Ada, the
12090 description in the Ada Reference Manual is sufficient.
12091
12092 However, if you want to do input-output to pipes or other devices, such
12093 as the keyboard or screen, or if the files you are dealing with are
12094 either generated by some other language, or to be read by some other
12095 language, then you need to know more about the details of how the GNAT
12096 implementation of these input-output facilities behaves.
12097
12098 In this chapter we give a detailed description of exactly how GNAT
12099 interfaces to the file system.  As always, the sources of the system are
12100 available to you for answering questions at an even more detailed level,
12101 but for most purposes the information in this chapter will suffice.
12102
12103 Another reason that you may need to know more about how input-output is
12104 implemented arises when you have a program written in mixed languages
12105 where, for example, files are shared between the C and Ada sections of
12106 the same program.  GNAT provides some additional facilities, in the form
12107 of additional child library packages, that facilitate this sharing, and
12108 these additional facilities are also described in this chapter.
12109
12110 @menu
12111 * Standard I/O Packages::
12112 * FORM Strings::
12113 * Direct_IO::
12114 * Sequential_IO::
12115 * Text_IO::
12116 * Wide_Text_IO::
12117 * Wide_Wide_Text_IO::
12118 * Stream_IO::
12119 * Shared Files::
12120 * Filenames encoding::
12121 * Open Modes::
12122 * Operations on C Streams::
12123 * Interfacing to C Streams::
12124 @end menu
12125
12126 @node Standard I/O Packages
12127 @section Standard I/O Packages
12128
12129 @noindent
12130 The Standard I/O packages described in Annex A for
12131
12132 @itemize @bullet
12133 @item
12134 Ada.Text_IO
12135 @item
12136 Ada.Text_IO.Complex_IO
12137 @item
12138 Ada.Text_IO.Text_Streams
12139 @item
12140 Ada.Wide_Text_IO
12141 @item
12142 Ada.Wide_Text_IO.Complex_IO
12143 @item
12144 Ada.Wide_Text_IO.Text_Streams
12145 @item
12146 Ada.Wide_Wide_Text_IO
12147 @item
12148 Ada.Wide_Wide_Text_IO.Complex_IO
12149 @item
12150 Ada.Wide_Wide_Text_IO.Text_Streams
12151 @item
12152 Ada.Stream_IO
12153 @item
12154 Ada.Sequential_IO
12155 @item
12156 Ada.Direct_IO
12157 @end itemize
12158
12159 @noindent
12160 are implemented using the C
12161 library streams facility; where
12162
12163 @itemize @bullet
12164 @item
12165 All files are opened using @code{fopen}.
12166 @item
12167 All input/output operations use @code{fread}/@code{fwrite}.
12168 @end itemize
12169
12170 @noindent
12171 There is no internal buffering of any kind at the Ada library level. The only
12172 buffering is that provided at the system level in the implementation of the
12173 library routines that support streams. This facilitates shared use of these
12174 streams by mixed language programs. Note though that system level buffering is
12175 explicitly enabled at elaboration of the standard I/O packages and that can
12176 have an impact on mixed language programs, in particular those using I/O before
12177 calling the Ada elaboration routine (e.g.@: adainit). It is recommended to call
12178 the Ada elaboration routine before performing any I/O or when impractical,
12179 flush the common I/O streams and in particular Standard_Output before
12180 elaborating the Ada code.
12181
12182 @node FORM Strings
12183 @section FORM Strings
12184
12185 @noindent
12186 The format of a FORM string in GNAT is:
12187
12188 @smallexample
12189 "keyword=value,keyword=value,@dots{},keyword=value"
12190 @end smallexample
12191
12192 @noindent
12193 where letters may be in upper or lower case, and there are no spaces
12194 between values.  The order of the entries is not important.  Currently
12195 there are two keywords defined.
12196
12197 @smallexample
12198 SHARED=[YES|NO]
12199 WCEM=[n|h|u|s|e|8|b]
12200 @end smallexample
12201
12202 @noindent
12203 The use of these parameters is described later in this section.
12204
12205 @node Direct_IO
12206 @section Direct_IO
12207
12208 @noindent
12209 Direct_IO can only be instantiated for definite types.  This is a
12210 restriction of the Ada language, which means that the records are fixed
12211 length (the length being determined by @code{@var{type}'Size}, rounded
12212 up to the next storage unit boundary if necessary).
12213
12214 The records of a Direct_IO file are simply written to the file in index
12215 sequence, with the first record starting at offset zero, and subsequent
12216 records following.  There is no control information of any kind.  For
12217 example, if 32-bit integers are being written, each record takes
12218 4-bytes, so the record at index @var{K} starts at offset
12219 (@var{K}@minus{}1)*4.
12220
12221 There is no limit on the size of Direct_IO files, they are expanded as
12222 necessary to accommodate whatever records are written to the file.
12223
12224 @node Sequential_IO
12225 @section Sequential_IO
12226
12227 @noindent
12228 Sequential_IO may be instantiated with either a definite (constrained)
12229 or indefinite (unconstrained) type.
12230
12231 For the definite type case, the elements written to the file are simply
12232 the memory images of the data values with no control information of any
12233 kind.  The resulting file should be read using the same type, no validity
12234 checking is performed on input.
12235
12236 For the indefinite type case, the elements written consist of two
12237 parts.  First is the size of the data item, written as the memory image
12238 of a @code{Interfaces.C.size_t} value, followed by the memory image of
12239 the data value.  The resulting file can only be read using the same
12240 (unconstrained) type.  Normal assignment checks are performed on these
12241 read operations, and if these checks fail, @code{Data_Error} is
12242 raised.  In particular, in the array case, the lengths must match, and in
12243 the variant record case, if the variable for a particular read operation
12244 is constrained, the discriminants must match.
12245
12246 Note that it is not possible to use Sequential_IO to write variable
12247 length array items, and then read the data back into different length
12248 arrays.  For example, the following will raise @code{Data_Error}:
12249
12250 @smallexample @c ada
12251  package IO is new Sequential_IO (String);
12252  F : IO.File_Type;
12253  S : String (1..4);
12254  @dots{}
12255  IO.Create (F)
12256  IO.Write (F, "hello!")
12257  IO.Reset (F, Mode=>In_File);
12258  IO.Read (F, S);
12259  Put_Line (S);
12260
12261 @end smallexample
12262
12263 @noindent
12264 On some Ada implementations, this will print @code{hell}, but the program is
12265 clearly incorrect, since there is only one element in the file, and that
12266 element is the string @code{hello!}.
12267
12268 In Ada 95 and Ada 2005, this kind of behavior can be legitimately achieved
12269 using Stream_IO, and this is the preferred mechanism.  In particular, the
12270 above program fragment rewritten to use Stream_IO will work correctly.
12271
12272 @node Text_IO
12273 @section Text_IO
12274
12275 @noindent
12276 Text_IO files consist of a stream of characters containing the following
12277 special control characters:
12278
12279 @smallexample
12280 LF (line feed, 16#0A#) Line Mark
12281 FF (form feed, 16#0C#) Page Mark
12282 @end smallexample
12283
12284 @noindent
12285 A canonical Text_IO file is defined as one in which the following
12286 conditions are met:
12287
12288 @itemize @bullet
12289 @item
12290 The character @code{LF} is used only as a line mark, i.e.@: to mark the end
12291 of the line.
12292
12293 @item
12294 The character @code{FF} is used only as a page mark, i.e.@: to mark the
12295 end of a page and consequently can appear only immediately following a
12296 @code{LF} (line mark) character.
12297
12298 @item
12299 The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
12300 (line mark, page mark).  In the former case, the page mark is implicitly
12301 assumed to be present.
12302 @end itemize
12303
12304 @noindent
12305 A file written using Text_IO will be in canonical form provided that no
12306 explicit @code{LF} or @code{FF} characters are written using @code{Put}
12307 or @code{Put_Line}.  There will be no @code{FF} character at the end of
12308 the file unless an explicit @code{New_Page} operation was performed
12309 before closing the file.
12310
12311 A canonical Text_IO file that is a regular file (i.e., not a device or a
12312 pipe) can be read using any of the routines in Text_IO@.  The
12313 semantics in this case will be exactly as defined in the Ada Reference
12314 Manual, and all the routines in Text_IO are fully implemented.
12315
12316 A text file that does not meet the requirements for a canonical Text_IO
12317 file has one of the following:
12318
12319 @itemize @bullet
12320 @item
12321 The file contains @code{FF} characters not immediately following a
12322 @code{LF} character.
12323
12324 @item
12325 The file contains @code{LF} or @code{FF} characters written by
12326 @code{Put} or @code{Put_Line}, which are not logically considered to be
12327 line marks or page marks.
12328
12329 @item
12330 The file ends in a character other than @code{LF} or @code{FF},
12331 i.e.@: there is no explicit line mark or page mark at the end of the file.
12332 @end itemize
12333
12334 @noindent
12335 Text_IO can be used to read such non-standard text files but subprograms
12336 to do with line or page numbers do not have defined meanings.  In
12337 particular, a @code{FF} character that does not follow a @code{LF}
12338 character may or may not be treated as a page mark from the point of
12339 view of page and line numbering.  Every @code{LF} character is considered
12340 to end a line, and there is an implied @code{LF} character at the end of
12341 the file.
12342
12343 @menu
12344 * Text_IO Stream Pointer Positioning::
12345 * Text_IO Reading and Writing Non-Regular Files::
12346 * Get_Immediate::
12347 * Treating Text_IO Files as Streams::
12348 * Text_IO Extensions::
12349 * Text_IO Facilities for Unbounded Strings::
12350 @end menu
12351
12352 @node Text_IO Stream Pointer Positioning
12353 @subsection Stream Pointer Positioning
12354
12355 @noindent
12356 @code{Ada.Text_IO} has a definition of current position for a file that
12357 is being read.  No internal buffering occurs in Text_IO, and usually the
12358 physical position in the stream used to implement the file corresponds
12359 to this logical position defined by Text_IO@.  There are two exceptions:
12360
12361 @itemize @bullet
12362 @item
12363 After a call to @code{End_Of_Page} that returns @code{True}, the stream
12364 is positioned past the @code{LF} (line mark) that precedes the page
12365 mark.  Text_IO maintains an internal flag so that subsequent read
12366 operations properly handle the logical position which is unchanged by
12367 the @code{End_Of_Page} call.
12368
12369 @item
12370 After a call to @code{End_Of_File} that returns @code{True}, if the
12371 Text_IO file was positioned before the line mark at the end of file
12372 before the call, then the logical position is unchanged, but the stream
12373 is physically positioned right at the end of file (past the line mark,
12374 and past a possible page mark following the line mark.  Again Text_IO
12375 maintains internal flags so that subsequent read operations properly
12376 handle the logical position.
12377 @end itemize
12378
12379 @noindent
12380 These discrepancies have no effect on the observable behavior of
12381 Text_IO, but if a single Ada stream is shared between a C program and
12382 Ada program, or shared (using @samp{shared=yes} in the form string)
12383 between two Ada files, then the difference may be observable in some
12384 situations.
12385
12386 @node Text_IO Reading and Writing Non-Regular Files
12387 @subsection Reading and Writing Non-Regular Files
12388
12389 @noindent
12390 A non-regular file is a device (such as a keyboard), or a pipe.  Text_IO
12391 can be used for reading and writing.  Writing is not affected and the
12392 sequence of characters output is identical to the normal file case, but
12393 for reading, the behavior of Text_IO is modified to avoid undesirable
12394 look-ahead as follows:
12395
12396 An input file that is not a regular file is considered to have no page
12397 marks.  Any @code{Ascii.FF} characters (the character normally used for a
12398 page mark) appearing in the file are considered to be data
12399 characters.  In particular:
12400
12401 @itemize @bullet
12402 @item
12403 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
12404 following a line mark.  If a page mark appears, it will be treated as a
12405 data character.
12406
12407 @item
12408 This avoids the need to wait for an extra character to be typed or
12409 entered from the pipe to complete one of these operations.
12410
12411 @item
12412 @code{End_Of_Page} always returns @code{False}
12413
12414 @item
12415 @code{End_Of_File} will return @code{False} if there is a page mark at
12416 the end of the file.
12417 @end itemize
12418
12419 @noindent
12420 Output to non-regular files is the same as for regular files.  Page marks
12421 may be written to non-regular files using @code{New_Page}, but as noted
12422 above they will not be treated as page marks on input if the output is
12423 piped to another Ada program.
12424
12425 Another important discrepancy when reading non-regular files is that the end
12426 of file indication is not ``sticky''.  If an end of file is entered, e.g.@: by
12427 pressing the @key{EOT} key,
12428 then end of file
12429 is signaled once (i.e.@: the test @code{End_Of_File}
12430 will yield @code{True}, or a read will
12431 raise @code{End_Error}), but then reading can resume
12432 to read data past that end of
12433 file indication, until another end of file indication is entered.
12434
12435 @node Get_Immediate
12436 @subsection Get_Immediate
12437 @cindex Get_Immediate
12438
12439 @noindent
12440 Get_Immediate returns the next character (including control characters)
12441 from the input file.  In particular, Get_Immediate will return LF or FF
12442 characters used as line marks or page marks.  Such operations leave the
12443 file positioned past the control character, and it is thus not treated
12444 as having its normal function.  This means that page, line and column
12445 counts after this kind of Get_Immediate call are set as though the mark
12446 did not occur.  In the case where a Get_Immediate leaves the file
12447 positioned between the line mark and page mark (which is not normally
12448 possible), it is undefined whether the FF character will be treated as a
12449 page mark.
12450
12451 @node Treating Text_IO Files as Streams
12452 @subsection Treating Text_IO Files as Streams
12453 @cindex Stream files
12454
12455 @noindent
12456 The package @code{Text_IO.Streams} allows a Text_IO file to be treated
12457 as a stream.  Data written to a Text_IO file in this stream mode is
12458 binary data.  If this binary data contains bytes 16#0A# (@code{LF}) or
12459 16#0C# (@code{FF}), the resulting file may have non-standard
12460 format.  Similarly if read operations are used to read from a Text_IO
12461 file treated as a stream, then @code{LF} and @code{FF} characters may be
12462 skipped and the effect is similar to that described above for
12463 @code{Get_Immediate}.
12464
12465 @node Text_IO Extensions
12466 @subsection Text_IO Extensions
12467 @cindex Text_IO extensions
12468
12469 @noindent
12470 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
12471 to the standard @code{Text_IO} package:
12472
12473 @itemize @bullet
12474 @item function File_Exists (Name : String) return Boolean;
12475 Determines if a file of the given name exists.
12476
12477 @item function Get_Line return String;
12478 Reads a string from the standard input file.  The value returned is exactly
12479 the length of the line that was read.
12480
12481 @item function Get_Line (File : Ada.Text_IO.File_Type) return String;
12482 Similar, except that the parameter File specifies the file from which
12483 the string is to be read.
12484
12485 @end itemize
12486
12487 @node Text_IO Facilities for Unbounded Strings
12488 @subsection Text_IO Facilities for Unbounded Strings
12489 @cindex Text_IO for unbounded strings
12490 @cindex Unbounded_String, Text_IO operations
12491
12492 @noindent
12493 The package @code{Ada.Strings.Unbounded.Text_IO}
12494 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
12495 subprograms useful for Text_IO operations on unbounded strings:
12496
12497 @itemize @bullet
12498
12499 @item function Get_Line (File : File_Type) return Unbounded_String;
12500 Reads a line from the specified file
12501 and returns the result as an unbounded string.
12502
12503 @item procedure Put (File : File_Type; U : Unbounded_String);
12504 Writes the value of the given unbounded string to the specified file
12505 Similar to the effect of
12506 @code{Put (To_String (U))} except that an extra copy is avoided.
12507
12508 @item procedure Put_Line (File : File_Type; U : Unbounded_String);
12509 Writes the value of the given unbounded string to the specified file,
12510 followed by a @code{New_Line}.
12511 Similar to the effect of @code{Put_Line (To_String (U))} except
12512 that an extra copy is avoided.
12513 @end itemize
12514
12515 @noindent
12516 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
12517 and is optional.  If the parameter is omitted, then the standard input or
12518 output file is referenced as appropriate.
12519
12520 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
12521 files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended
12522 @code{Wide_Text_IO} functionality for unbounded wide strings.
12523
12524 The package @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} in library
12525 files @file{a-szuzti.ads} and @file{a-szuzti.adb} provides similar extended
12526 @code{Wide_Wide_Text_IO} functionality for unbounded wide wide strings.
12527
12528 @node Wide_Text_IO
12529 @section Wide_Text_IO
12530
12531 @noindent
12532 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
12533 both input and output files may contain special sequences that represent
12534 wide character values.  The encoding scheme for a given file may be
12535 specified using a FORM parameter:
12536
12537 @smallexample
12538 WCEM=@var{x}
12539 @end smallexample
12540
12541 @noindent
12542 as part of the FORM string (WCEM = wide character encoding method),
12543 where @var{x} is one of the following characters
12544
12545 @table @samp
12546 @item h
12547 Hex ESC encoding
12548 @item u
12549 Upper half encoding
12550 @item s
12551 Shift-JIS encoding
12552 @item e
12553 EUC Encoding
12554 @item 8
12555 UTF-8 encoding
12556 @item b
12557 Brackets encoding
12558 @end table
12559
12560 @noindent
12561 The encoding methods match those that
12562 can be used in a source
12563 program, but there is no requirement that the encoding method used for
12564 the source program be the same as the encoding method used for files,
12565 and different files may use different encoding methods.
12566
12567 The default encoding method for the standard files, and for opened files
12568 for which no WCEM parameter is given in the FORM string matches the
12569 wide character encoding specified for the main program (the default
12570 being brackets encoding if no coding method was specified with -gnatW).
12571
12572 @table @asis
12573 @item Hex Coding
12574 In this encoding, a wide character is represented by a five character
12575 sequence:
12576
12577 @smallexample
12578 ESC a b c d
12579 @end smallexample
12580
12581 @noindent
12582 where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
12583 characters (using upper case letters) of the wide character code.  For
12584 example, ESC A345 is used to represent the wide character with code
12585 16#A345#.  This scheme is compatible with use of the full
12586 @code{Wide_Character} set.
12587
12588 @item Upper Half Coding
12589 The wide character with encoding 16#abcd#, where the upper bit is on
12590 (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
12591 16#cd#.  The second byte may never be a format control character, but is
12592 not required to be in the upper half.  This method can be also used for
12593 shift-JIS or EUC where the internal coding matches the external coding.
12594
12595 @item Shift JIS Coding
12596 A wide character is represented by a two character sequence 16#ab# and
12597 16#cd#, with the restrictions described for upper half encoding as
12598 described above.  The internal character code is the corresponding JIS
12599 character according to the standard algorithm for Shift-JIS
12600 conversion.  Only characters defined in the JIS code set table can be
12601 used with this encoding method.
12602
12603 @item EUC Coding
12604 A wide character is represented by a two character sequence 16#ab# and
12605 16#cd#, with both characters being in the upper half.  The internal
12606 character code is the corresponding JIS character according to the EUC
12607 encoding algorithm.  Only characters defined in the JIS code set table
12608 can be used with this encoding method.
12609
12610 @item UTF-8 Coding
12611 A wide character is represented using
12612 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
12613 10646-1/Am.2.  Depending on the character value, the representation
12614 is a one, two, or three byte sequence:
12615
12616 @smallexample
12617 16#0000#-16#007f#: 2#0xxxxxxx#
12618 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
12619 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
12620 @end smallexample
12621
12622 @noindent
12623 where the @var{xxx} bits correspond to the left-padded bits of the
12624 16-bit character value.  Note that all lower half ASCII characters
12625 are represented as ASCII bytes and all upper half characters and
12626 other wide characters are represented as sequences of upper-half
12627 (The full UTF-8 scheme allows for encoding 31-bit characters as
12628 6-byte sequences, but in this implementation, all UTF-8 sequences
12629 of four or more bytes length will raise a Constraint_Error, as
12630 will all invalid UTF-8 sequences.)
12631
12632 @item Brackets Coding
12633 In this encoding, a wide character is represented by the following eight
12634 character sequence:
12635
12636 @smallexample
12637 [ " a b c d " ]
12638 @end smallexample
12639
12640 @noindent
12641 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
12642 characters (using uppercase letters) of the wide character code.  For
12643 example, @code{["A345"]} is used to represent the wide character with code
12644 @code{16#A345#}.
12645 This scheme is compatible with use of the full Wide_Character set.
12646 On input, brackets coding can also be used for upper half characters,
12647 e.g.@: @code{["C1"]} for lower case a.  However, on output, brackets notation
12648 is only used for wide characters with a code greater than @code{16#FF#}.
12649
12650 Note that brackets coding is not normally used in the context of
12651 Wide_Text_IO or Wide_Wide_Text_IO, since it is really just designed as
12652 a portable way of encoding source files. In the context of Wide_Text_IO
12653 or Wide_Wide_Text_IO, it can only be used if the file does not contain
12654 any instance of the left bracket character other than to encode wide
12655 character values using the brackets encoding method. In practice it is
12656 expected that some standard wide character encoding method such
12657 as UTF-8 will be used for text input output.
12658
12659 If brackets notation is used, then any occurrence of a left bracket
12660 in the input file which is not the start of a valid wide character
12661 sequence will cause Constraint_Error to be raised. It is possible to
12662 encode a left bracket as ["5B"] and Wide_Text_IO and Wide_Wide_Text_IO
12663 input will interpret this as a left bracket.
12664
12665 However, when a left bracket is output, it will be output as a left bracket
12666 and not as ["5B"]. We make this decision because for normal use of
12667 Wide_Text_IO for outputting messages, it is unpleasant to clobber left
12668 brackets. For example, if we write:
12669
12670 @smallexample
12671    Put_Line ("Start of output [first run]");
12672 @end smallexample
12673
12674 @noindent
12675 we really do not want to have the left bracket in this message clobbered so
12676 that the output reads:
12677
12678 @smallexample
12679    Start of output ["5B"]first run]
12680 @end smallexample
12681
12682 @noindent
12683 In practice brackets encoding is reasonably useful for normal Put_Line use
12684 since we won't get confused between left brackets and wide character
12685 sequences in the output. But for input, or when files are written out
12686 and read back in, it really makes better sense to use one of the standard
12687 encoding methods such as UTF-8.
12688
12689 @end table
12690
12691 @noindent
12692 For the coding schemes other than UTF-8, Hex, or Brackets encoding,
12693 not all wide character
12694 values can be represented.  An attempt to output a character that cannot
12695 be represented using the encoding scheme for the file causes
12696 Constraint_Error to be raised.  An invalid wide character sequence on
12697 input also causes Constraint_Error to be raised.
12698
12699 @menu
12700 * Wide_Text_IO Stream Pointer Positioning::
12701 * Wide_Text_IO Reading and Writing Non-Regular Files::
12702 @end menu
12703
12704 @node Wide_Text_IO Stream Pointer Positioning
12705 @subsection Stream Pointer Positioning
12706
12707 @noindent
12708 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
12709 of stream pointer positioning (@pxref{Text_IO}).  There is one additional
12710 case:
12711
12712 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
12713 normal lower ASCII set (i.e.@: a character in the range:
12714
12715 @smallexample @c ada
12716 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
12717 @end smallexample
12718
12719 @noindent
12720 then although the logical position of the file pointer is unchanged by
12721 the @code{Look_Ahead} call, the stream is physically positioned past the
12722 wide character sequence.  Again this is to avoid the need for buffering
12723 or backup, and all @code{Wide_Text_IO} routines check the internal
12724 indication that this situation has occurred so that this is not visible
12725 to a normal program using @code{Wide_Text_IO}.  However, this discrepancy
12726 can be observed if the wide text file shares a stream with another file.
12727
12728 @node Wide_Text_IO Reading and Writing Non-Regular Files
12729 @subsection Reading and Writing Non-Regular Files
12730
12731 @noindent
12732 As in the case of Text_IO, when a non-regular file is read, it is
12733 assumed that the file contains no page marks (any form characters are
12734 treated as data characters), and @code{End_Of_Page} always returns
12735 @code{False}.  Similarly, the end of file indication is not sticky, so
12736 it is possible to read beyond an end of file.
12737
12738 @node Wide_Wide_Text_IO
12739 @section Wide_Wide_Text_IO
12740
12741 @noindent
12742 @code{Wide_Wide_Text_IO} is similar in most respects to Text_IO, except that
12743 both input and output files may contain special sequences that represent
12744 wide wide character values.  The encoding scheme for a given file may be
12745 specified using a FORM parameter:
12746
12747 @smallexample
12748 WCEM=@var{x}
12749 @end smallexample
12750
12751 @noindent
12752 as part of the FORM string (WCEM = wide character encoding method),
12753 where @var{x} is one of the following characters
12754
12755 @table @samp
12756 @item h
12757 Hex ESC encoding
12758 @item u
12759 Upper half encoding
12760 @item s
12761 Shift-JIS encoding
12762 @item e
12763 EUC Encoding
12764 @item 8
12765 UTF-8 encoding
12766 @item b
12767 Brackets encoding
12768 @end table
12769
12770 @noindent
12771 The encoding methods match those that
12772 can be used in a source
12773 program, but there is no requirement that the encoding method used for
12774 the source program be the same as the encoding method used for files,
12775 and different files may use different encoding methods.
12776
12777 The default encoding method for the standard files, and for opened files
12778 for which no WCEM parameter is given in the FORM string matches the
12779 wide character encoding specified for the main program (the default
12780 being brackets encoding if no coding method was specified with -gnatW).
12781
12782 @table @asis
12783
12784 @item UTF-8 Coding
12785 A wide character is represented using
12786 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
12787 10646-1/Am.2.  Depending on the character value, the representation
12788 is a one, two, three, or four byte sequence:
12789
12790 @smallexample
12791 16#000000#-16#00007f#: 2#0xxxxxxx#
12792 16#000080#-16#0007ff#: 2#110xxxxx# 2#10xxxxxx#
12793 16#000800#-16#00ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
12794 16#010000#-16#10ffff#: 2#11110xxx# 2#10xxxxxx# 2#10xxxxxx# 2#10xxxxxx#
12795 @end smallexample
12796
12797 @noindent
12798 where the @var{xxx} bits correspond to the left-padded bits of the
12799 21-bit character value.  Note that all lower half ASCII characters
12800 are represented as ASCII bytes and all upper half characters and
12801 other wide characters are represented as sequences of upper-half
12802 characters.
12803
12804 @item Brackets Coding
12805 In this encoding, a wide wide character is represented by the following eight
12806 character sequence if is in wide character range
12807
12808 @smallexample
12809 [ " a b c d " ]
12810 @end smallexample
12811
12812 and by the following ten character sequence if not
12813
12814 @smallexample
12815 [ " a b c d e f " ]
12816 @end smallexample
12817
12818 @noindent
12819 where @code{a}, @code{b}, @code{c}, @code{d}, @code{e}, and @code{f}
12820 are the four or six hexadecimal
12821 characters (using uppercase letters) of the wide wide character code.  For
12822 example, @code{["01A345"]} is used to represent the wide wide character
12823 with code @code{16#01A345#}.
12824
12825 This scheme is compatible with use of the full Wide_Wide_Character set.
12826 On input, brackets coding can also be used for upper half characters,
12827 e.g.@: @code{["C1"]} for lower case a.  However, on output, brackets notation
12828 is only used for wide characters with a code greater than @code{16#FF#}.
12829
12830 @end table
12831
12832 @noindent
12833 If is also possible to use the other Wide_Character encoding methods,
12834 such as Shift-JIS, but the other schemes cannot support the full range
12835 of wide wide characters.
12836 An attempt to output a character that cannot
12837 be represented using the encoding scheme for the file causes
12838 Constraint_Error to be raised.  An invalid wide character sequence on
12839 input also causes Constraint_Error to be raised.
12840
12841 @menu
12842 * Wide_Wide_Text_IO Stream Pointer Positioning::
12843 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
12844 @end menu
12845
12846 @node Wide_Wide_Text_IO Stream Pointer Positioning
12847 @subsection Stream Pointer Positioning
12848
12849 @noindent
12850 @code{Ada.Wide_Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
12851 of stream pointer positioning (@pxref{Text_IO}).  There is one additional
12852 case:
12853
12854 If @code{Ada.Wide_Wide_Text_IO.Look_Ahead} reads a character outside the
12855 normal lower ASCII set (i.e.@: a character in the range:
12856
12857 @smallexample @c ada
12858 Wide_Wide_Character'Val (16#0080#) .. Wide_Wide_Character'Val (16#10FFFF#)
12859 @end smallexample
12860
12861 @noindent
12862 then although the logical position of the file pointer is unchanged by
12863 the @code{Look_Ahead} call, the stream is physically positioned past the
12864 wide character sequence.  Again this is to avoid the need for buffering
12865 or backup, and all @code{Wide_Wide_Text_IO} routines check the internal
12866 indication that this situation has occurred so that this is not visible
12867 to a normal program using @code{Wide_Wide_Text_IO}.  However, this discrepancy
12868 can be observed if the wide text file shares a stream with another file.
12869
12870 @node Wide_Wide_Text_IO Reading and Writing Non-Regular Files
12871 @subsection Reading and Writing Non-Regular Files
12872
12873 @noindent
12874 As in the case of Text_IO, when a non-regular file is read, it is
12875 assumed that the file contains no page marks (any form characters are
12876 treated as data characters), and @code{End_Of_Page} always returns
12877 @code{False}.  Similarly, the end of file indication is not sticky, so
12878 it is possible to read beyond an end of file.
12879
12880 @node Stream_IO
12881 @section Stream_IO
12882
12883 @noindent
12884 A stream file is a sequence of bytes, where individual elements are
12885 written to the file as described in the Ada Reference Manual.  The type
12886 @code{Stream_Element} is simply a byte.  There are two ways to read or
12887 write a stream file.
12888
12889 @itemize @bullet
12890 @item
12891 The operations @code{Read} and @code{Write} directly read or write a
12892 sequence of stream elements with no control information.
12893
12894 @item
12895 The stream attributes applied to a stream file transfer data in the
12896 manner described for stream attributes.
12897 @end itemize
12898
12899 @node Shared Files
12900 @section Shared Files
12901
12902 @noindent
12903 Section A.14 of the Ada Reference Manual allows implementations to
12904 provide a wide variety of behavior if an attempt is made to access the
12905 same external file with two or more internal files.
12906
12907 To provide a full range of functionality, while at the same time
12908 minimizing the problems of portability caused by this implementation
12909 dependence, GNAT handles file sharing as follows:
12910
12911 @itemize @bullet
12912 @item
12913 In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
12914 to open two or more files with the same full name is considered an error
12915 and is not supported.  The exception @code{Use_Error} will be
12916 raised.  Note that a file that is not explicitly closed by the program
12917 remains open until the program terminates.
12918
12919 @item
12920 If the form parameter @samp{shared=no} appears in the form string, the
12921 file can be opened or created with its own separate stream identifier,
12922 regardless of whether other files sharing the same external file are
12923 opened.  The exact effect depends on how the C stream routines handle
12924 multiple accesses to the same external files using separate streams.
12925
12926 @item
12927 If the form parameter @samp{shared=yes} appears in the form string for
12928 each of two or more files opened using the same full name, the same
12929 stream is shared between these files, and the semantics are as described
12930 in Ada Reference Manual, Section A.14.
12931 @end itemize
12932
12933 @noindent
12934 When a program that opens multiple files with the same name is ported
12935 from another Ada compiler to GNAT, the effect will be that
12936 @code{Use_Error} is raised.
12937
12938 The documentation of the original compiler and the documentation of the
12939 program should then be examined to determine if file sharing was
12940 expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
12941 and @code{Create} calls as required.
12942
12943 When a program is ported from GNAT to some other Ada compiler, no
12944 special attention is required unless the @samp{shared=@var{xxx}} form
12945 parameter is used in the program.  In this case, you must examine the
12946 documentation of the new compiler to see if it supports the required
12947 file sharing semantics, and form strings modified appropriately.  Of
12948 course it may be the case that the program cannot be ported if the
12949 target compiler does not support the required functionality.  The best
12950 approach in writing portable code is to avoid file sharing (and hence
12951 the use of the @samp{shared=@var{xxx}} parameter in the form string)
12952 completely.
12953
12954 One common use of file sharing in Ada 83 is the use of instantiations of
12955 Sequential_IO on the same file with different types, to achieve
12956 heterogeneous input-output.  Although this approach will work in GNAT if
12957 @samp{shared=yes} is specified, it is preferable in Ada to use Stream_IO
12958 for this purpose (using the stream attributes)
12959
12960 @node Filenames encoding
12961 @section Filenames encoding
12962
12963 @noindent
12964 An encoding form parameter can be used to specify the filename
12965 encoding @samp{encoding=@var{xxx}}.
12966
12967 @itemize @bullet
12968 @item
12969 If the form parameter @samp{encoding=utf8} appears in the form string, the
12970 filename must be encoded in UTF-8.
12971
12972 @item
12973 If the form parameter @samp{encoding=8bits} appears in the form
12974 string, the filename must be a standard 8bits string.
12975 @end itemize
12976
12977 In the absence of a @samp{encoding=@var{xxx}} form parameter, the
12978 value UTF-8 is used. This encoding form parameter is only supported on
12979 the Windows platform. On the other Operating Systems the runtime is
12980 supporting UTF-8 natively.
12981
12982 @node Open Modes
12983 @section Open Modes
12984
12985 @noindent
12986 @code{Open} and @code{Create} calls result in a call to @code{fopen}
12987 using the mode shown in the following table:
12988
12989 @sp 2
12990 @center @code{Open} and @code{Create} Call Modes
12991 @smallexample
12992                                @b{OPEN }           @b{CREATE}
12993 Append_File                    "r+"             "w+"
12994 In_File                        "r"              "w+"
12995 Out_File (Direct_IO)           "r+"             "w"
12996 Out_File (all other cases)     "w"              "w"
12997 Inout_File                     "r+"             "w+"
12998 @end smallexample
12999
13000 @noindent
13001 If text file translation is required, then either @samp{b} or @samp{t}
13002 is added to the mode, depending on the setting of Text.  Text file
13003 translation refers to the mapping of CR/LF sequences in an external file
13004 to LF characters internally.  This mapping only occurs in DOS and
13005 DOS-like systems, and is not relevant to other systems.
13006
13007 A special case occurs with Stream_IO@.  As shown in the above table, the
13008 file is initially opened in @samp{r} or @samp{w} mode for the
13009 @code{In_File} and @code{Out_File} cases.  If a @code{Set_Mode} operation
13010 subsequently requires switching from reading to writing or vice-versa,
13011 then the file is reopened in @samp{r+} mode to permit the required operation.
13012
13013 @node Operations on C Streams
13014 @section Operations on C Streams
13015 The package @code{Interfaces.C_Streams} provides an Ada program with direct
13016 access to the C library functions for operations on C streams:
13017
13018 @smallexample @c adanocomment
13019 package Interfaces.C_Streams is
13020   -- Note: the reason we do not use the types that are in
13021   -- Interfaces.C is that we want to avoid dragging in the
13022   -- code in this unit if possible.
13023   subtype chars is System.Address;
13024   -- Pointer to null-terminated array of characters
13025   subtype FILEs is System.Address;
13026   -- Corresponds to the C type FILE*
13027   subtype voids is System.Address;
13028   -- Corresponds to the C type void*
13029   subtype int is Integer;
13030   subtype long is Long_Integer;
13031   -- Note: the above types are subtypes deliberately, and it
13032   -- is part of this spec that the above correspondences are
13033   -- guaranteed.  This means that it is legitimate to, for
13034   -- example, use Integer instead of int.  We provide these
13035   -- synonyms for clarity, but in some cases it may be
13036   -- convenient to use the underlying types (for example to
13037   -- avoid an unnecessary dependency of a spec on the spec
13038   -- of this unit).
13039   type size_t is mod 2 ** Standard'Address_Size;
13040   NULL_Stream : constant FILEs;
13041   -- Value returned (NULL in C) to indicate an
13042   -- fdopen/fopen/tmpfile error
13043   ----------------------------------
13044   -- Constants Defined in stdio.h --
13045   ----------------------------------
13046   EOF : constant int;
13047   -- Used by a number of routines to indicate error or
13048   -- end of file
13049   IOFBF : constant int;
13050   IOLBF : constant int;
13051   IONBF : constant int;
13052   -- Used to indicate buffering mode for setvbuf call
13053   SEEK_CUR : constant int;
13054   SEEK_END : constant int;
13055   SEEK_SET : constant int;
13056   -- Used to indicate origin for fseek call
13057   function stdin return FILEs;
13058   function stdout return FILEs;
13059   function stderr return FILEs;
13060   -- Streams associated with standard files
13061   --------------------------
13062   -- Standard C functions --
13063   --------------------------
13064   -- The functions selected below are ones that are
13065   -- available in DOS, OS/2, UNIX and Xenix (but not
13066   -- necessarily in ANSI C).  These are very thin interfaces
13067   -- which copy exactly the C headers.  For more
13068   -- documentation on these functions, see the Microsoft C
13069   -- "Run-Time Library Reference" (Microsoft Press, 1990,
13070   -- ISBN 1-55615-225-6), which includes useful information
13071   -- on system compatibility.
13072   procedure clearerr (stream : FILEs);
13073   function fclose (stream : FILEs) return int;
13074   function fdopen (handle : int; mode : chars) return FILEs;
13075   function feof (stream : FILEs) return int;
13076   function ferror (stream : FILEs) return int;
13077   function fflush (stream : FILEs) return int;
13078   function fgetc (stream : FILEs) return int;
13079   function fgets (strng : chars; n : int; stream : FILEs)
13080       return chars;
13081   function fileno (stream : FILEs) return int;
13082   function fopen (filename : chars; Mode : chars)
13083       return FILEs;
13084   -- Note: to maintain target independence, use
13085   -- text_translation_required, a boolean variable defined in
13086   -- a-sysdep.c to deal with the target dependent text
13087   -- translation requirement.  If this variable is set,
13088   -- then  b/t should be appended to the standard mode
13089   -- argument to set the text translation mode off or on
13090   -- as required.
13091   function fputc (C : int; stream : FILEs) return int;
13092   function fputs (Strng : chars; Stream : FILEs) return int;
13093   function fread
13094      (buffer : voids;
13095       size : size_t;
13096       count : size_t;
13097       stream : FILEs)
13098       return size_t;
13099   function freopen
13100      (filename : chars;
13101       mode : chars;
13102       stream : FILEs)
13103       return FILEs;
13104   function fseek
13105      (stream : FILEs;
13106       offset : long;
13107       origin : int)
13108       return int;
13109   function ftell (stream : FILEs) return long;
13110   function fwrite
13111      (buffer : voids;
13112       size : size_t;
13113       count : size_t;
13114       stream : FILEs)
13115       return size_t;
13116   function isatty (handle : int) return int;
13117   procedure mktemp (template : chars);
13118   -- The return value (which is just a pointer to template)
13119   -- is discarded
13120   procedure rewind (stream : FILEs);
13121   function rmtmp return int;
13122   function setvbuf
13123      (stream : FILEs;
13124       buffer : chars;
13125       mode : int;
13126       size : size_t)
13127       return int;
13128
13129   function tmpfile return FILEs;
13130   function ungetc (c : int; stream : FILEs) return int;
13131   function unlink (filename : chars) return int;
13132   ---------------------
13133   -- Extra functions --
13134   ---------------------
13135   -- These functions supply slightly thicker bindings than
13136   -- those above.  They are derived from functions in the
13137   -- C Run-Time Library, but may do a bit more work than
13138   -- just directly calling one of the Library functions.
13139   function is_regular_file (handle : int) return int;
13140   -- Tests if given handle is for a regular file (result 1)
13141   -- or for a non-regular file (pipe or device, result 0).
13142   ---------------------------------
13143   -- Control of Text/Binary Mode --
13144   ---------------------------------
13145   -- If text_translation_required is true, then the following
13146   -- functions may be used to dynamically switch a file from
13147   -- binary to text mode or vice versa.  These functions have
13148   -- no effect if text_translation_required is false (i.e.@: in
13149   -- normal UNIX mode).  Use fileno to get a stream handle.
13150   procedure set_binary_mode (handle : int);
13151   procedure set_text_mode (handle : int);
13152   ----------------------------
13153   -- Full Path Name support --
13154   ----------------------------
13155   procedure full_name (nam : chars; buffer : chars);
13156   -- Given a NUL terminated string representing a file
13157   -- name, returns in buffer a NUL terminated string
13158   -- representing the full path name for the file name.
13159   -- On systems where it is relevant the   drive is also
13160   -- part of the full path name.  It is the responsibility
13161   -- of the caller to pass an actual parameter for buffer
13162   -- that is big enough for any full path name.  Use
13163   -- max_path_len given below as the size of buffer.
13164   max_path_len : integer;
13165   -- Maximum length of an allowable full path name on the
13166   -- system, including a terminating NUL character.
13167 end Interfaces.C_Streams;
13168 @end smallexample
13169
13170 @node Interfacing to C Streams
13171 @section Interfacing to C Streams
13172
13173 @noindent
13174 The packages in this section permit interfacing Ada files to C Stream
13175 operations.
13176
13177 @smallexample @c ada
13178  with Interfaces.C_Streams;
13179  package Ada.Sequential_IO.C_Streams is
13180     function C_Stream (F : File_Type)
13181        return Interfaces.C_Streams.FILEs;
13182     procedure Open
13183       (File : in out File_Type;
13184        Mode : in File_Mode;
13185        C_Stream : in Interfaces.C_Streams.FILEs;
13186        Form : in String := "");
13187  end Ada.Sequential_IO.C_Streams;
13188
13189   with Interfaces.C_Streams;
13190   package Ada.Direct_IO.C_Streams is
13191      function C_Stream (F : File_Type)
13192         return Interfaces.C_Streams.FILEs;
13193      procedure Open
13194        (File : in out File_Type;
13195         Mode : in File_Mode;
13196         C_Stream : in Interfaces.C_Streams.FILEs;
13197         Form : in String := "");
13198   end Ada.Direct_IO.C_Streams;
13199
13200   with Interfaces.C_Streams;
13201   package Ada.Text_IO.C_Streams is
13202      function C_Stream (F : File_Type)
13203         return Interfaces.C_Streams.FILEs;
13204      procedure Open
13205        (File : in out File_Type;
13206         Mode : in File_Mode;
13207         C_Stream : in Interfaces.C_Streams.FILEs;
13208         Form : in String := "");
13209   end Ada.Text_IO.C_Streams;
13210
13211   with Interfaces.C_Streams;
13212   package Ada.Wide_Text_IO.C_Streams is
13213      function C_Stream (F : File_Type)
13214         return Interfaces.C_Streams.FILEs;
13215      procedure Open
13216        (File : in out File_Type;
13217         Mode : in File_Mode;
13218         C_Stream : in Interfaces.C_Streams.FILEs;
13219         Form : in String := "");
13220  end Ada.Wide_Text_IO.C_Streams;
13221
13222   with Interfaces.C_Streams;
13223   package Ada.Wide_Wide_Text_IO.C_Streams is
13224      function C_Stream (F : File_Type)
13225         return Interfaces.C_Streams.FILEs;
13226      procedure Open
13227        (File : in out File_Type;
13228         Mode : in File_Mode;
13229         C_Stream : in Interfaces.C_Streams.FILEs;
13230         Form : in String := "");
13231  end Ada.Wide_Wide_Text_IO.C_Streams;
13232
13233  with Interfaces.C_Streams;
13234  package Ada.Stream_IO.C_Streams is
13235     function C_Stream (F : File_Type)
13236        return Interfaces.C_Streams.FILEs;
13237     procedure Open
13238       (File : in out File_Type;
13239        Mode : in File_Mode;
13240        C_Stream : in Interfaces.C_Streams.FILEs;
13241        Form : in String := "");
13242  end Ada.Stream_IO.C_Streams;
13243 @end smallexample
13244
13245 @noindent
13246 In each of these six packages, the @code{C_Stream} function obtains the
13247 @code{FILE} pointer from a currently opened Ada file.  It is then
13248 possible to use the @code{Interfaces.C_Streams} package to operate on
13249 this stream, or the stream can be passed to a C program which can
13250 operate on it directly.  Of course the program is responsible for
13251 ensuring that only appropriate sequences of operations are executed.
13252
13253 One particular use of relevance to an Ada program is that the
13254 @code{setvbuf} function can be used to control the buffering of the
13255 stream used by an Ada file.  In the absence of such a call the standard
13256 default buffering is used.
13257
13258 The @code{Open} procedures in these packages open a file giving an
13259 existing C Stream instead of a file name.  Typically this stream is
13260 imported from a C program, allowing an Ada file to operate on an
13261 existing C file.
13262
13263 @node The GNAT Library
13264 @chapter The GNAT Library
13265
13266 @noindent
13267 The GNAT library contains a number of general and special purpose packages.
13268 It represents functionality that the GNAT developers have found useful, and
13269 which is made available to GNAT users.  The packages described here are fully
13270 supported, and upwards compatibility will be maintained in future releases,
13271 so you can use these facilities with the confidence that the same functionality
13272 will be available in future releases.
13273
13274 The chapter here simply gives a brief summary of the facilities available.
13275 The full documentation is found in the spec file for the package.  The full
13276 sources of these library packages, including both spec and body, are provided
13277 with all GNAT releases.  For example, to find out the full specifications of
13278 the SPITBOL pattern matching capability, including a full tutorial and
13279 extensive examples, look in the @file{g-spipat.ads} file in the library.
13280
13281 For each entry here, the package name (as it would appear in a @code{with}
13282 clause) is given, followed by the name of the corresponding spec file in
13283 parentheses.  The packages are children in four hierarchies, @code{Ada},
13284 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
13285 GNAT-specific hierarchy.
13286
13287 Note that an application program should only use packages in one of these
13288 four hierarchies if the package is defined in the Ada Reference Manual,
13289 or is listed in this section of the GNAT Programmers Reference Manual.
13290 All other units should be considered internal implementation units and
13291 should not be directly @code{with}'ed by application code.  The use of
13292 a @code{with} statement that references one of these internal implementation
13293 units makes an application potentially dependent on changes in versions
13294 of GNAT, and will generate a warning message.
13295
13296 @menu
13297 * Ada.Characters.Latin_9 (a-chlat9.ads)::
13298 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
13299 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
13300 * Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)::
13301 * Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)::
13302 * Ada.Command_Line.Environment (a-colien.ads)::
13303 * Ada.Command_Line.Remove (a-colire.ads)::
13304 * Ada.Command_Line.Response_File (a-clrefi.ads)::
13305 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
13306 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
13307 * Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)::
13308 * Ada.Exceptions.Traceback (a-exctra.ads)::
13309 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
13310 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
13311 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
13312 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
13313 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
13314 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
13315 * Ada.Wide_Characters.Unicode (a-wichun.ads)::
13316 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
13317 * Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)::
13318 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
13319 * GNAT.Altivec (g-altive.ads)::
13320 * GNAT.Altivec.Conversions (g-altcon.ads)::
13321 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
13322 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
13323 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
13324 * GNAT.Array_Split (g-arrspl.ads)::
13325 * GNAT.AWK (g-awk.ads)::
13326 * GNAT.Bounded_Buffers (g-boubuf.ads)::
13327 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
13328 * GNAT.Bubble_Sort (g-bubsor.ads)::
13329 * GNAT.Bubble_Sort_A (g-busora.ads)::
13330 * GNAT.Bubble_Sort_G (g-busorg.ads)::
13331 * GNAT.Byte_Order_Mark (g-byorma.ads)::
13332 * GNAT.Byte_Swapping (g-bytswa.ads)::
13333 * GNAT.Calendar (g-calend.ads)::
13334 * GNAT.Calendar.Time_IO (g-catiio.ads)::
13335 * GNAT.Case_Util (g-casuti.ads)::
13336 * GNAT.CGI (g-cgi.ads)::
13337 * GNAT.CGI.Cookie (g-cgicoo.ads)::
13338 * GNAT.CGI.Debug (g-cgideb.ads)::
13339 * GNAT.Command_Line (g-comlin.ads)::
13340 * GNAT.Compiler_Version (g-comver.ads)::
13341 * GNAT.Ctrl_C (g-ctrl_c.ads)::
13342 * GNAT.CRC32 (g-crc32.ads)::
13343 * GNAT.Current_Exception (g-curexc.ads)::
13344 * GNAT.Debug_Pools (g-debpoo.ads)::
13345 * GNAT.Debug_Utilities (g-debuti.ads)::
13346 * GNAT.Decode_String (g-decstr.ads)::
13347 * GNAT.Decode_UTF8_String (g-deutst.ads)::
13348 * GNAT.Directory_Operations (g-dirope.ads)::
13349 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
13350 * GNAT.Dynamic_HTables (g-dynhta.ads)::
13351 * GNAT.Dynamic_Tables (g-dyntab.ads)::
13352 * GNAT.Encode_String (g-encstr.ads)::
13353 * GNAT.Encode_UTF8_String (g-enutst.ads)::
13354 * GNAT.Exception_Actions (g-excact.ads)::
13355 * GNAT.Exception_Traces (g-exctra.ads)::
13356 * GNAT.Exceptions (g-except.ads)::
13357 * GNAT.Expect (g-expect.ads)::
13358 * GNAT.Float_Control (g-flocon.ads)::
13359 * GNAT.Heap_Sort (g-heasor.ads)::
13360 * GNAT.Heap_Sort_A (g-hesora.ads)::
13361 * GNAT.Heap_Sort_G (g-hesorg.ads)::
13362 * GNAT.HTable (g-htable.ads)::
13363 * GNAT.IO (g-io.ads)::
13364 * GNAT.IO_Aux (g-io_aux.ads)::
13365 * GNAT.Lock_Files (g-locfil.ads)::
13366 * GNAT.MD5 (g-md5.ads)::
13367 * GNAT.Memory_Dump (g-memdum.ads)::
13368 * GNAT.Most_Recent_Exception (g-moreex.ads)::
13369 * GNAT.OS_Lib (g-os_lib.ads)::
13370 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
13371 * GNAT.Random_Numbers (g-rannum.ads)::
13372 * GNAT.Regexp (g-regexp.ads)::
13373 * GNAT.Registry (g-regist.ads)::
13374 * GNAT.Regpat (g-regpat.ads)::
13375 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
13376 * GNAT.Semaphores (g-semaph.ads)::
13377 * GNAT.Serial_Communications (g-sercom.ads)::
13378 * GNAT.SHA1 (g-sha1.ads)::
13379 * GNAT.Signals (g-signal.ads)::
13380 * GNAT.Sockets (g-socket.ads)::
13381 * GNAT.Source_Info (g-souinf.ads)::
13382 * GNAT.Spelling_Checker (g-speche.ads)::
13383 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
13384 * GNAT.Spitbol.Patterns (g-spipat.ads)::
13385 * GNAT.Spitbol (g-spitbo.ads)::
13386 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
13387 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
13388 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
13389 * GNAT.Strings (g-string.ads)::
13390 * GNAT.String_Split (g-strspl.ads)::
13391 * GNAT.Table (g-table.ads)::
13392 * GNAT.Task_Lock (g-tasloc.ads)::
13393 * GNAT.Threads (g-thread.ads)::
13394 * GNAT.Time_Stamp (g-timsta.ads)::
13395 * GNAT.Traceback (g-traceb.ads)::
13396 * GNAT.Traceback.Symbolic (g-trasym.ads)::
13397 * GNAT.UTF_32 (g-utf_32.ads)::
13398 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
13399 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
13400 * GNAT.Wide_String_Split (g-wistsp.ads)::
13401 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
13402 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
13403 * Interfaces.C.Extensions (i-cexten.ads)::
13404 * Interfaces.C.Streams (i-cstrea.ads)::
13405 * Interfaces.CPP (i-cpp.ads)::
13406 * Interfaces.Packed_Decimal (i-pacdec.ads)::
13407 * Interfaces.VxWorks (i-vxwork.ads)::
13408 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
13409 * System.Address_Image (s-addima.ads)::
13410 * System.Assertions (s-assert.ads)::
13411 * System.Memory (s-memory.ads)::
13412 * System.Partition_Interface (s-parint.ads)::
13413 * System.Pool_Global (s-pooglo.ads)::
13414 * System.Pool_Local (s-pooloc.ads)::
13415 * System.Restrictions (s-restri.ads)::
13416 * System.Rident (s-rident.ads)::
13417 * System.Task_Info (s-tasinf.ads)::
13418 * System.Wch_Cnv (s-wchcnv.ads)::
13419 * System.Wch_Con (s-wchcon.ads)::
13420 @end menu
13421
13422 @node Ada.Characters.Latin_9 (a-chlat9.ads)
13423 @section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
13424 @cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
13425 @cindex Latin_9 constants for Character
13426
13427 @noindent
13428 This child of @code{Ada.Characters}
13429 provides a set of definitions corresponding to those in the
13430 RM-defined package @code{Ada.Characters.Latin_1} but with the
13431 few modifications required for @code{Latin-9}
13432 The provision of such a package
13433 is specifically authorized by the Ada Reference Manual
13434 (RM A.3.3(27)).
13435
13436 @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
13437 @section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
13438 @cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
13439 @cindex Latin_1 constants for Wide_Character
13440
13441 @noindent
13442 This child of @code{Ada.Characters}
13443 provides a set of definitions corresponding to those in the
13444 RM-defined package @code{Ada.Characters.Latin_1} but with the
13445 types of the constants being @code{Wide_Character}
13446 instead of @code{Character}.  The provision of such a package
13447 is specifically authorized by the Ada Reference Manual
13448 (RM A.3.3(27)).
13449
13450 @node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
13451 @section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
13452 @cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
13453 @cindex Latin_9 constants for Wide_Character
13454
13455 @noindent
13456 This child of @code{Ada.Characters}
13457 provides a set of definitions corresponding to those in the
13458 GNAT defined package @code{Ada.Characters.Latin_9} but with the
13459 types of the constants being @code{Wide_Character}
13460 instead of @code{Character}.  The provision of such a package
13461 is specifically authorized by the Ada Reference Manual
13462 (RM A.3.3(27)).
13463
13464 @node Ada.Characters.Wide_Wide_Latin_1 (a-chzla1.ads)
13465 @section @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
13466 @cindex @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-chzla1.ads})
13467 @cindex Latin_1 constants for Wide_Wide_Character
13468
13469 @noindent
13470 This child of @code{Ada.Characters}
13471 provides a set of definitions corresponding to those in the
13472 RM-defined package @code{Ada.Characters.Latin_1} but with the
13473 types of the constants being @code{Wide_Wide_Character}
13474 instead of @code{Character}.  The provision of such a package
13475 is specifically authorized by the Ada Reference Manual
13476 (RM A.3.3(27)).
13477
13478 @node Ada.Characters.Wide_Wide_Latin_9 (a-chzla9.ads)
13479 @section @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
13480 @cindex @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-chzla9.ads})
13481 @cindex Latin_9 constants for Wide_Wide_Character
13482
13483 @noindent
13484 This child of @code{Ada.Characters}
13485 provides a set of definitions corresponding to those in the
13486 GNAT defined package @code{Ada.Characters.Latin_9} but with the
13487 types of the constants being @code{Wide_Wide_Character}
13488 instead of @code{Character}.  The provision of such a package
13489 is specifically authorized by the Ada Reference Manual
13490 (RM A.3.3(27)).
13491
13492 @node Ada.Command_Line.Environment (a-colien.ads)
13493 @section @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
13494 @cindex @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
13495 @cindex Environment entries
13496
13497 @noindent
13498 This child of @code{Ada.Command_Line}
13499 provides a mechanism for obtaining environment values on systems
13500 where this concept makes sense.
13501
13502 @node Ada.Command_Line.Remove (a-colire.ads)
13503 @section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
13504 @cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
13505 @cindex Removing command line arguments
13506 @cindex Command line, argument removal
13507
13508 @noindent
13509 This child of @code{Ada.Command_Line}
13510 provides a mechanism for logically removing
13511 arguments from the argument list.  Once removed, an argument is not visible
13512 to further calls on the subprograms in @code{Ada.Command_Line} will not
13513 see the removed argument.
13514
13515 @node Ada.Command_Line.Response_File (a-clrefi.ads)
13516 @section @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
13517 @cindex @code{Ada.Command_Line.Response_File} (@file{a-clrefi.ads})
13518 @cindex Response file for command line
13519 @cindex Command line, response file
13520 @cindex Command line, handling long command lines
13521
13522 @noindent
13523 This child of @code{Ada.Command_Line} provides a mechanism facilities for
13524 getting command line arguments from a text file, called a "response file".
13525 Using a response file allow passing a set of arguments to an executable longer
13526 than the maximum allowed by the system on the command line.
13527
13528 @node Ada.Direct_IO.C_Streams (a-diocst.ads)
13529 @section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
13530 @cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
13531 @cindex C Streams, Interfacing with Direct_IO
13532
13533 @noindent
13534 This package provides subprograms that allow interfacing between
13535 C streams and @code{Direct_IO}.  The stream identifier can be
13536 extracted from a file opened on the Ada side, and an Ada file
13537 can be constructed from a stream opened on the C side.
13538
13539 @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
13540 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
13541 @cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
13542 @cindex Null_Occurrence, testing for
13543
13544 @noindent
13545 This child subprogram provides a way of testing for the null
13546 exception occurrence (@code{Null_Occurrence}) without raising
13547 an exception.
13548
13549 @node Ada.Exceptions.Last_Chance_Handler (a-elchha.ads)
13550 @section @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
13551 @cindex @code{Ada.Exceptions.Last_Chance_Handler} (@file{a-elchha.ads})
13552 @cindex Null_Occurrence, testing for
13553
13554 @noindent
13555 This child subprogram is used for handling otherwise unhandled
13556 exceptions (hence the name last chance), and perform clean ups before
13557 terminating the program. Note that this subprogram never returns.
13558
13559 @node Ada.Exceptions.Traceback (a-exctra.ads)
13560 @section @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
13561 @cindex @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
13562 @cindex Traceback for Exception Occurrence
13563
13564 @noindent
13565 This child package provides the subprogram (@code{Tracebacks}) to
13566 give a traceback array of addresses based on an exception
13567 occurrence.
13568
13569 @node Ada.Sequential_IO.C_Streams (a-siocst.ads)
13570 @section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
13571 @cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
13572 @cindex C Streams, Interfacing with Sequential_IO
13573
13574 @noindent
13575 This package provides subprograms that allow interfacing between
13576 C streams and @code{Sequential_IO}.  The stream identifier can be
13577 extracted from a file opened on the Ada side, and an Ada file
13578 can be constructed from a stream opened on the C side.
13579
13580 @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
13581 @section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
13582 @cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
13583 @cindex C Streams, Interfacing with Stream_IO
13584
13585 @noindent
13586 This package provides subprograms that allow interfacing between
13587 C streams and @code{Stream_IO}.  The stream identifier can be
13588 extracted from a file opened on the Ada side, and an Ada file
13589 can be constructed from a stream opened on the C side.
13590
13591 @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
13592 @section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
13593 @cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
13594 @cindex @code{Unbounded_String}, IO support
13595 @cindex @code{Text_IO}, extensions for unbounded strings
13596
13597 @noindent
13598 This package provides subprograms for Text_IO for unbounded
13599 strings, avoiding the necessity for an intermediate operation
13600 with ordinary strings.
13601
13602 @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
13603 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
13604 @cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
13605 @cindex @code{Unbounded_Wide_String}, IO support
13606 @cindex @code{Text_IO}, extensions for unbounded wide strings
13607
13608 @noindent
13609 This package provides subprograms for Text_IO for unbounded
13610 wide strings, avoiding the necessity for an intermediate operation
13611 with ordinary wide strings.
13612
13613 @node Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)
13614 @section @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
13615 @cindex @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
13616 @cindex @code{Unbounded_Wide_Wide_String}, IO support
13617 @cindex @code{Text_IO}, extensions for unbounded wide wide strings
13618
13619 @noindent
13620 This package provides subprograms for Text_IO for unbounded
13621 wide wide strings, avoiding the necessity for an intermediate operation
13622 with ordinary wide wide strings.
13623
13624 @node Ada.Text_IO.C_Streams (a-tiocst.ads)
13625 @section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
13626 @cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
13627 @cindex C Streams, Interfacing with @code{Text_IO}
13628
13629 @noindent
13630 This package provides subprograms that allow interfacing between
13631 C streams and @code{Text_IO}.  The stream identifier can be
13632 extracted from a file opened on the Ada side, and an Ada file
13633 can be constructed from a stream opened on the C side.
13634
13635 @node Ada.Wide_Characters.Unicode (a-wichun.ads)
13636 @section @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
13637 @cindex @code{Ada.Wide_Characters.Unicode} (@file{a-wichun.ads})
13638 @cindex Unicode categorization, Wide_Character
13639
13640 @noindent
13641 This package provides subprograms that allow categorization of
13642 Wide_Character values according to Unicode categories.
13643
13644 @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
13645 @section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
13646 @cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
13647 @cindex C Streams, Interfacing with @code{Wide_Text_IO}
13648
13649 @noindent
13650 This package provides subprograms that allow interfacing between
13651 C streams and @code{Wide_Text_IO}.  The stream identifier can be
13652 extracted from a file opened on the Ada side, and an Ada file
13653 can be constructed from a stream opened on the C side.
13654
13655 @node Ada.Wide_Wide_Characters.Unicode (a-zchuni.ads)
13656 @section @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
13657 @cindex @code{Ada.Wide_Wide_Characters.Unicode} (@file{a-zchuni.ads})
13658 @cindex Unicode categorization, Wide_Wide_Character
13659
13660 @noindent
13661 This package provides subprograms that allow categorization of
13662 Wide_Wide_Character values according to Unicode categories.
13663
13664 @node Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)
13665 @section @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
13666 @cindex @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
13667 @cindex C Streams, Interfacing with @code{Wide_Wide_Text_IO}
13668
13669 @noindent
13670 This package provides subprograms that allow interfacing between
13671 C streams and @code{Wide_Wide_Text_IO}.  The stream identifier can be
13672 extracted from a file opened on the Ada side, and an Ada file
13673 can be constructed from a stream opened on the C side.
13674
13675 @node GNAT.Altivec (g-altive.ads)
13676 @section @code{GNAT.Altivec} (@file{g-altive.ads})
13677 @cindex @code{GNAT.Altivec} (@file{g-altive.ads})
13678 @cindex AltiVec
13679
13680 @noindent
13681 This is the root package of the GNAT AltiVec binding. It provides
13682 definitions of constants and types common to all the versions of the
13683 binding.
13684
13685 @node GNAT.Altivec.Conversions (g-altcon.ads)
13686 @section @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
13687 @cindex @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
13688 @cindex AltiVec
13689
13690 @noindent
13691 This package provides the Vector/View conversion routines.
13692
13693 @node GNAT.Altivec.Vector_Operations (g-alveop.ads)
13694 @section @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
13695 @cindex @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
13696 @cindex AltiVec
13697
13698 @noindent
13699 This package exposes the Ada interface to the AltiVec operations on
13700 vector objects. A soft emulation is included by default in the GNAT
13701 library. The hard binding is provided as a separate package. This unit
13702 is common to both bindings.
13703
13704 @node GNAT.Altivec.Vector_Types (g-alvety.ads)
13705 @section @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
13706 @cindex @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
13707 @cindex AltiVec
13708
13709 @noindent
13710 This package exposes the various vector types part of the Ada binding
13711 to AltiVec facilities.
13712
13713 @node GNAT.Altivec.Vector_Views (g-alvevi.ads)
13714 @section @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
13715 @cindex @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
13716 @cindex AltiVec
13717
13718 @noindent
13719 This package provides public 'View' data types from/to which private
13720 vector representations can be converted via
13721 GNAT.Altivec.Conversions. This allows convenient access to individual
13722 vector elements and provides a simple way to initialize vector
13723 objects.
13724
13725 @node GNAT.Array_Split (g-arrspl.ads)
13726 @section @code{GNAT.Array_Split} (@file{g-arrspl.ads})
13727 @cindex @code{GNAT.Array_Split} (@file{g-arrspl.ads})
13728 @cindex Array splitter
13729
13730 @noindent
13731 Useful array-manipulation routines: given a set of separators, split
13732 an array wherever the separators appear, and provide direct access
13733 to the resulting slices.
13734
13735 @node GNAT.AWK (g-awk.ads)
13736 @section @code{GNAT.AWK} (@file{g-awk.ads})
13737 @cindex @code{GNAT.AWK} (@file{g-awk.ads})
13738 @cindex Parsing
13739 @cindex AWK
13740
13741 @noindent
13742 Provides AWK-like parsing functions, with an easy interface for parsing one
13743 or more files containing formatted data.  The file is viewed as a database
13744 where each record is a line and a field is a data element in this line.
13745
13746 @node GNAT.Bounded_Buffers (g-boubuf.ads)
13747 @section @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
13748 @cindex @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
13749 @cindex Parsing
13750 @cindex Bounded Buffers
13751
13752 @noindent
13753 Provides a concurrent generic bounded buffer abstraction.  Instances are
13754 useful directly or as parts of the implementations of other abstractions,
13755 such as mailboxes.
13756
13757 @node GNAT.Bounded_Mailboxes (g-boumai.ads)
13758 @section @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
13759 @cindex @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
13760 @cindex Parsing
13761 @cindex Mailboxes
13762
13763 @noindent
13764 Provides a thread-safe asynchronous intertask mailbox communication facility.
13765
13766 @node GNAT.Bubble_Sort (g-bubsor.ads)
13767 @section @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
13768 @cindex @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
13769 @cindex Sorting
13770 @cindex Bubble sort
13771
13772 @noindent
13773 Provides a general implementation of bubble sort usable for sorting arbitrary
13774 data items.  Exchange and comparison procedures are provided by passing
13775 access-to-procedure values.
13776
13777 @node GNAT.Bubble_Sort_A (g-busora.ads)
13778 @section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
13779 @cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
13780 @cindex Sorting
13781 @cindex Bubble sort
13782
13783 @noindent
13784 Provides a general implementation of bubble sort usable for sorting arbitrary
13785 data items.  Move and comparison procedures are provided by passing
13786 access-to-procedure values. This is an older version, retained for
13787 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
13788
13789 @node GNAT.Bubble_Sort_G (g-busorg.ads)
13790 @section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
13791 @cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
13792 @cindex Sorting
13793 @cindex Bubble sort
13794
13795 @noindent
13796 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
13797 are provided as generic parameters, this improves efficiency, especially
13798 if the procedures can be inlined, at the expense of duplicating code for
13799 multiple instantiations.
13800
13801 @node GNAT.Byte_Order_Mark (g-byorma.ads)
13802 @section @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
13803 @cindex @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
13804 @cindex UTF-8 representation
13805 @cindex Wide characte representations
13806
13807 @noindent
13808 Provides a routine which given a string, reads the start of the string to
13809 see whether it is one of the standard byte order marks (BOM's) which signal
13810 the encoding of the string. The routine includes detection of special XML
13811 sequences for various UCS input formats.
13812
13813 @node GNAT.Byte_Swapping (g-bytswa.ads)
13814 @section @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
13815 @cindex @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
13816 @cindex Byte swapping
13817 @cindex Endian
13818
13819 @noindent
13820 General routines for swapping the bytes in 2-, 4-, and 8-byte quantities.
13821 Machine-specific implementations are available in some cases.
13822
13823 @node GNAT.Calendar (g-calend.ads)
13824 @section @code{GNAT.Calendar} (@file{g-calend.ads})
13825 @cindex @code{GNAT.Calendar} (@file{g-calend.ads})
13826 @cindex @code{Calendar}
13827
13828 @noindent
13829 Extends the facilities provided by @code{Ada.Calendar} to include handling
13830 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
13831 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
13832 C @code{timeval} format.
13833
13834 @node GNAT.Calendar.Time_IO (g-catiio.ads)
13835 @section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
13836 @cindex @code{Calendar}
13837 @cindex Time
13838 @cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
13839
13840 @node GNAT.CRC32 (g-crc32.ads)
13841 @section @code{GNAT.CRC32} (@file{g-crc32.ads})
13842 @cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
13843 @cindex CRC32
13844 @cindex Cyclic Redundancy Check
13845
13846 @noindent
13847 This package implements the CRC-32 algorithm.  For a full description
13848 of this algorithm see
13849 ``Computation of Cyclic Redundancy Checks via Table Look-Up'',
13850 @cite{Communications of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013,
13851 Aug.@: 1988.  Sarwate, D.V@.
13852
13853 @node GNAT.Case_Util (g-casuti.ads)
13854 @section @code{GNAT.Case_Util} (@file{g-casuti.ads})
13855 @cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
13856 @cindex Casing utilities
13857 @cindex Character handling (@code{GNAT.Case_Util})
13858
13859 @noindent
13860 A set of simple routines for handling upper and lower casing of strings
13861 without the overhead of the full casing tables
13862 in @code{Ada.Characters.Handling}.
13863
13864 @node GNAT.CGI (g-cgi.ads)
13865 @section @code{GNAT.CGI} (@file{g-cgi.ads})
13866 @cindex @code{GNAT.CGI} (@file{g-cgi.ads})
13867 @cindex CGI (Common Gateway Interface)
13868
13869 @noindent
13870 This is a package for interfacing a GNAT program with a Web server via the
13871 Common Gateway Interface (CGI)@.  Basically this package parses the CGI
13872 parameters, which are a set of key/value pairs sent by the Web server.  It
13873 builds a table whose index is the key and provides some services to deal
13874 with this table.
13875
13876 @node GNAT.CGI.Cookie (g-cgicoo.ads)
13877 @section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
13878 @cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
13879 @cindex CGI (Common Gateway Interface) cookie support
13880 @cindex Cookie support in CGI
13881
13882 @noindent
13883 This is a package to interface a GNAT program with a Web server via the
13884 Common Gateway Interface (CGI).  It exports services to deal with Web
13885 cookies (piece of information kept in the Web client software).
13886
13887 @node GNAT.CGI.Debug (g-cgideb.ads)
13888 @section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
13889 @cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
13890 @cindex CGI (Common Gateway Interface) debugging
13891
13892 @noindent
13893 This is a package to help debugging CGI (Common Gateway Interface)
13894 programs written in Ada.
13895
13896 @node GNAT.Command_Line (g-comlin.ads)
13897 @section @code{GNAT.Command_Line} (@file{g-comlin.ads})
13898 @cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
13899 @cindex Command line
13900
13901 @noindent
13902 Provides a high level interface to @code{Ada.Command_Line} facilities,
13903 including the ability to scan for named switches with optional parameters
13904 and expand file names using wild card notations.
13905
13906 @node GNAT.Compiler_Version (g-comver.ads)
13907 @section @code{GNAT.Compiler_Version} (@file{g-comver.ads})
13908 @cindex @code{GNAT.Compiler_Version} (@file{g-comver.ads})
13909 @cindex Compiler Version
13910 @cindex Version, of compiler
13911
13912 @noindent
13913 Provides a routine for obtaining the version of the compiler used to
13914 compile the program. More accurately this is the version of the binder
13915 used to bind the program (this will normally be the same as the version
13916 of the compiler if a consistent tool set is used to compile all units
13917 of a partition).
13918
13919 @node GNAT.Ctrl_C (g-ctrl_c.ads)
13920 @section @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
13921 @cindex @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
13922 @cindex Interrupt
13923
13924 @noindent
13925 Provides a simple interface to handle Ctrl-C keyboard events.
13926
13927 @node GNAT.Current_Exception (g-curexc.ads)
13928 @section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
13929 @cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
13930 @cindex Current exception
13931 @cindex Exception retrieval
13932
13933 @noindent
13934 Provides access to information on the current exception that has been raised
13935 without the need for using the Ada 95 / Ada 2005 exception choice parameter
13936 specification syntax.
13937 This is particularly useful in simulating typical facilities for
13938 obtaining information about exceptions provided by Ada 83 compilers.
13939
13940 @node GNAT.Debug_Pools (g-debpoo.ads)
13941 @section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
13942 @cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
13943 @cindex Debugging
13944 @cindex Debug pools
13945 @cindex Memory corruption debugging
13946
13947 @noindent
13948 Provide a debugging storage pools that helps tracking memory corruption
13949 problems.  @xref{The GNAT Debug Pool Facility,,, gnat_ugn,
13950 @value{EDITION} User's Guide}.
13951
13952 @node GNAT.Debug_Utilities (g-debuti.ads)
13953 @section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
13954 @cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
13955 @cindex Debugging
13956
13957 @noindent
13958 Provides a few useful utilities for debugging purposes, including conversion
13959 to and from string images of address values. Supports both C and Ada formats
13960 for hexadecimal literals.
13961
13962 @node GNAT.Decode_String (g-decstr.ads)
13963 @section @code{GNAT.Decode_String} (@file{g-decstr.ads})
13964 @cindex @code{GNAT.Decode_String} (@file{g-decstr.ads})
13965 @cindex Decoding strings
13966 @cindex String decoding
13967 @cindex Wide character encoding
13968 @cindex UTF-8
13969 @cindex Unicode
13970
13971 @noindent
13972 A generic package providing routines for decoding wide character and wide wide
13973 character strings encoded as sequences of 8-bit characters using a specified
13974 encoding method. Includes validation routines, and also routines for stepping
13975 to next or previous encoded character in an encoded string.
13976 Useful in conjunction with Unicode character coding. Note there is a
13977 preinstantiation for UTF-8. See next entry.
13978
13979 @node GNAT.Decode_UTF8_String (g-deutst.ads)
13980 @section @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
13981 @cindex @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
13982 @cindex Decoding strings
13983 @cindex Decoding UTF-8 strings
13984 @cindex UTF-8 string decoding
13985 @cindex Wide character decoding
13986 @cindex UTF-8
13987 @cindex Unicode
13988
13989 @noindent
13990 A preinstantiation of GNAT.Decode_Strings for UTF-8 encoding.
13991
13992 @node GNAT.Directory_Operations (g-dirope.ads)
13993 @section @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
13994 @cindex @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
13995 @cindex Directory operations
13996
13997 @noindent
13998 Provides a set of routines for manipulating directories, including changing
13999 the current directory, making new directories, and scanning the files in a
14000 directory.
14001
14002 @node GNAT.Directory_Operations.Iteration (g-diopit.ads)
14003 @section @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
14004 @cindex @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
14005 @cindex Directory operations iteration
14006
14007 @noindent
14008 A child unit of GNAT.Directory_Operations providing additional operations
14009 for iterating through directories.
14010
14011 @node GNAT.Dynamic_HTables (g-dynhta.ads)
14012 @section @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
14013 @cindex @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
14014 @cindex Hash tables
14015
14016 @noindent
14017 A generic implementation of hash tables that can be used to hash arbitrary
14018 data.  Provided in two forms, a simple form with built in hash functions,
14019 and a more complex form in which the hash function is supplied.
14020
14021 @noindent
14022 This package provides a facility similar to that of @code{GNAT.HTable},
14023 except that this package declares a type that can be used to define
14024 dynamic instances of the hash table, while an instantiation of
14025 @code{GNAT.HTable} creates a single instance of the hash table.
14026
14027 @node GNAT.Dynamic_Tables (g-dyntab.ads)
14028 @section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
14029 @cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
14030 @cindex Table implementation
14031 @cindex Arrays, extendable
14032
14033 @noindent
14034 A generic package providing a single dimension array abstraction where the
14035 length of the array can be dynamically modified.
14036
14037 @noindent
14038 This package provides a facility similar to that of @code{GNAT.Table},
14039 except that this package declares a type that can be used to define
14040 dynamic instances of the table, while an instantiation of
14041 @code{GNAT.Table} creates a single instance of the table type.
14042
14043 @node GNAT.Encode_String (g-encstr.ads)
14044 @section @code{GNAT.Encode_String} (@file{g-encstr.ads})
14045 @cindex @code{GNAT.Encode_String} (@file{g-encstr.ads})
14046 @cindex Encoding strings
14047 @cindex String encoding
14048 @cindex Wide character encoding
14049 @cindex UTF-8
14050 @cindex Unicode
14051
14052 @noindent
14053 A generic package providing routines for encoding wide character and wide
14054 wide character strings as sequences of 8-bit characters using a specified
14055 encoding method. Useful in conjunction with Unicode character coding.
14056 Note there is a preinstantiation for UTF-8. See next entry.
14057
14058 @node GNAT.Encode_UTF8_String (g-enutst.ads)
14059 @section @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
14060 @cindex @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
14061 @cindex Encoding strings
14062 @cindex Encoding UTF-8 strings
14063 @cindex UTF-8 string encoding
14064 @cindex Wide character encoding
14065 @cindex UTF-8
14066 @cindex Unicode
14067
14068 @noindent
14069 A preinstantiation of GNAT.Encode_Strings for UTF-8 encoding.
14070
14071 @node GNAT.Exception_Actions (g-excact.ads)
14072 @section @code{GNAT.Exception_Actions} (@file{g-excact.ads})
14073 @cindex @code{GNAT.Exception_Actions} (@file{g-excact.ads})
14074 @cindex Exception actions
14075
14076 @noindent
14077 Provides callbacks when an exception is raised. Callbacks can be registered
14078 for specific exceptions, or when any exception is raised. This
14079 can be used for instance to force a core dump to ease debugging.
14080
14081 @node GNAT.Exception_Traces (g-exctra.ads)
14082 @section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
14083 @cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
14084 @cindex Exception traces
14085 @cindex Debugging
14086
14087 @noindent
14088 Provides an interface allowing to control automatic output upon exception
14089 occurrences.
14090
14091 @node GNAT.Exceptions (g-except.ads)
14092 @section @code{GNAT.Exceptions} (@file{g-expect.ads})
14093 @cindex @code{GNAT.Exceptions} (@file{g-expect.ads})
14094 @cindex Exceptions, Pure
14095 @cindex Pure packages, exceptions
14096
14097 @noindent
14098 Normally it is not possible to raise an exception with
14099 a message from a subprogram in a pure package, since the
14100 necessary types and subprograms are in @code{Ada.Exceptions}
14101 which is not a pure unit. @code{GNAT.Exceptions} provides a
14102 facility for getting around this limitation for a few
14103 predefined exceptions, and for example allow raising
14104 @code{Constraint_Error} with a message from a pure subprogram.
14105
14106 @node GNAT.Expect (g-expect.ads)
14107 @section @code{GNAT.Expect} (@file{g-expect.ads})
14108 @cindex @code{GNAT.Expect} (@file{g-expect.ads})
14109
14110 @noindent
14111 Provides a set of subprograms similar to what is available
14112 with the standard Tcl Expect tool.
14113 It allows you to easily spawn and communicate with an external process.
14114 You can send commands or inputs to the process, and compare the output
14115 with some expected regular expression. Currently @code{GNAT.Expect}
14116 is implemented on all native GNAT ports except for OpenVMS@.
14117 It is not implemented for cross ports, and in particular is not
14118 implemented for VxWorks or LynxOS@.
14119
14120 @node GNAT.Float_Control (g-flocon.ads)
14121 @section @code{GNAT.Float_Control} (@file{g-flocon.ads})
14122 @cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
14123 @cindex Floating-Point Processor
14124
14125 @noindent
14126 Provides an interface for resetting the floating-point processor into the
14127 mode required for correct semantic operation in Ada.  Some third party
14128 library calls may cause this mode to be modified, and the Reset procedure
14129 in this package can be used to reestablish the required mode.
14130
14131 @node GNAT.Heap_Sort (g-heasor.ads)
14132 @section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
14133 @cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
14134 @cindex Sorting
14135
14136 @noindent
14137 Provides a general implementation of heap sort usable for sorting arbitrary
14138 data items. Exchange and comparison procedures are provided by passing
14139 access-to-procedure values.  The algorithm used is a modified heap sort
14140 that performs approximately N*log(N) comparisons in the worst case.
14141
14142 @node GNAT.Heap_Sort_A (g-hesora.ads)
14143 @section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
14144 @cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
14145 @cindex Sorting
14146
14147 @noindent
14148 Provides a general implementation of heap sort usable for sorting arbitrary
14149 data items. Move and comparison procedures are provided by passing
14150 access-to-procedure values.  The algorithm used is a modified heap sort
14151 that performs approximately N*log(N) comparisons in the worst case.
14152 This differs from @code{GNAT.Heap_Sort} in having a less convenient
14153 interface, but may be slightly more efficient.
14154
14155 @node GNAT.Heap_Sort_G (g-hesorg.ads)
14156 @section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
14157 @cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
14158 @cindex Sorting
14159
14160 @noindent
14161 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
14162 are provided as generic parameters, this improves efficiency, especially
14163 if the procedures can be inlined, at the expense of duplicating code for
14164 multiple instantiations.
14165
14166 @node GNAT.HTable (g-htable.ads)
14167 @section @code{GNAT.HTable} (@file{g-htable.ads})
14168 @cindex @code{GNAT.HTable} (@file{g-htable.ads})
14169 @cindex Hash tables
14170
14171 @noindent
14172 A generic implementation of hash tables that can be used to hash arbitrary
14173 data.  Provides two approaches, one a simple static approach, and the other
14174 allowing arbitrary dynamic hash tables.
14175
14176 @node GNAT.IO (g-io.ads)
14177 @section @code{GNAT.IO} (@file{g-io.ads})
14178 @cindex @code{GNAT.IO} (@file{g-io.ads})
14179 @cindex Simple I/O
14180 @cindex Input/Output facilities
14181
14182 @noindent
14183 A simple preelaborable input-output package that provides a subset of
14184 simple Text_IO functions for reading characters and strings from
14185 Standard_Input, and writing characters, strings and integers to either
14186 Standard_Output or Standard_Error.
14187
14188 @node GNAT.IO_Aux (g-io_aux.ads)
14189 @section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
14190 @cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
14191 @cindex Text_IO
14192 @cindex Input/Output facilities
14193
14194 Provides some auxiliary functions for use with Text_IO, including a test
14195 for whether a file exists, and functions for reading a line of text.
14196
14197 @node GNAT.Lock_Files (g-locfil.ads)
14198 @section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
14199 @cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
14200 @cindex File locking
14201 @cindex Locking using files
14202
14203 @noindent
14204 Provides a general interface for using files as locks.  Can be used for
14205 providing program level synchronization.
14206
14207 @node GNAT.MD5 (g-md5.ads)
14208 @section @code{GNAT.MD5} (@file{g-md5.ads})
14209 @cindex @code{GNAT.MD5} (@file{g-md5.ads})
14210 @cindex Message Digest MD5
14211
14212 @noindent
14213 Implements the MD5 Message-Digest Algorithm as described in RFC 1321.
14214
14215 @node GNAT.Memory_Dump (g-memdum.ads)
14216 @section @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
14217 @cindex @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
14218 @cindex Dump Memory
14219
14220 @noindent
14221 Provides a convenient routine for dumping raw memory to either the
14222 standard output or standard error files. Uses GNAT.IO for actual
14223 output.
14224
14225 @node GNAT.Most_Recent_Exception (g-moreex.ads)
14226 @section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
14227 @cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
14228 @cindex Exception, obtaining most recent
14229
14230 @noindent
14231 Provides access to the most recently raised exception.  Can be used for
14232 various logging purposes, including duplicating functionality of some
14233 Ada 83 implementation dependent extensions.
14234
14235 @node GNAT.OS_Lib (g-os_lib.ads)
14236 @section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
14237 @cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
14238 @cindex Operating System interface
14239 @cindex Spawn capability
14240
14241 @noindent
14242 Provides a range of target independent operating system interface functions,
14243 including time/date management, file operations, subprocess management,
14244 including a portable spawn procedure, and access to environment variables
14245 and error return codes.
14246
14247 @node GNAT.Perfect_Hash_Generators (g-pehage.ads)
14248 @section @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
14249 @cindex @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
14250 @cindex Hash functions
14251
14252 @noindent
14253 Provides a generator of static minimal perfect hash functions. No
14254 collisions occur and each item can be retrieved from the table in one
14255 probe (perfect property). The hash table size corresponds to the exact
14256 size of the key set and no larger (minimal property). The key set has to
14257 be know in advance (static property). The hash functions are also order
14258 preserving. If w2 is inserted after w1 in the generator, their
14259 hashcode are in the same order. These hashing functions are very
14260 convenient for use with realtime applications.
14261
14262 @node GNAT.Random_Numbers (g-rannum.ads)
14263 @section @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
14264 @cindex @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
14265 @cindex Random number generation
14266
14267 @noindent
14268 Provides random number capabilities which extend those available in the
14269 standard Ada library and are more convenient to use.
14270
14271 @node GNAT.Regexp (g-regexp.ads)
14272 @section @code{GNAT.Regexp} (@file{g-regexp.ads})
14273 @cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
14274 @cindex Regular expressions
14275 @cindex Pattern matching
14276
14277 @noindent
14278 A simple implementation of regular expressions, using a subset of regular
14279 expression syntax copied from familiar Unix style utilities.  This is the
14280 simples of the three pattern matching packages provided, and is particularly
14281 suitable for ``file globbing'' applications.
14282
14283 @node GNAT.Registry (g-regist.ads)
14284 @section @code{GNAT.Registry} (@file{g-regist.ads})
14285 @cindex @code{GNAT.Registry} (@file{g-regist.ads})
14286 @cindex Windows Registry
14287
14288 @noindent
14289 This is a high level binding to the Windows registry.  It is possible to
14290 do simple things like reading a key value, creating a new key.  For full
14291 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
14292 package provided with the Win32Ada binding
14293
14294 @node GNAT.Regpat (g-regpat.ads)
14295 @section @code{GNAT.Regpat} (@file{g-regpat.ads})
14296 @cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
14297 @cindex Regular expressions
14298 @cindex Pattern matching
14299
14300 @noindent
14301 A complete implementation of Unix-style regular expression matching, copied
14302 from the original V7 style regular expression library written in C by
14303 Henry Spencer (and binary compatible with this C library).
14304
14305 @node GNAT.Secondary_Stack_Info (g-sestin.ads)
14306 @section @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
14307 @cindex @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
14308 @cindex Secondary Stack Info
14309
14310 @noindent
14311 Provide the capability to query the high water mark of the current task's
14312 secondary stack.
14313
14314 @node GNAT.Semaphores (g-semaph.ads)
14315 @section @code{GNAT.Semaphores} (@file{g-semaph.ads})
14316 @cindex @code{GNAT.Semaphores} (@file{g-semaph.ads})
14317 @cindex Semaphores
14318
14319 @noindent
14320 Provides classic counting and binary semaphores using protected types.
14321
14322 @node GNAT.Serial_Communications (g-sercom.ads)
14323 @section @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
14324 @cindex @code{GNAT.Serial_Communications} (@file{g-sercom.ads})
14325 @cindex Serial_Communications
14326
14327 @noindent
14328 Provides a simple interface to send and receive data over a serial
14329 port. This is only supported on GNU/Linux and Windows.
14330
14331 @node GNAT.SHA1 (g-sha1.ads)
14332 @section @code{GNAT.SHA1} (@file{g-sha1.ads})
14333 @cindex @code{GNAT.SHA1} (@file{g-sha1.ads})
14334 @cindex Secure Hash Algorithm SHA-1
14335
14336 @noindent
14337 Implements the SHA-1 Secure Hash Algorithm as described in RFC 3174.
14338
14339 @node GNAT.Signals (g-signal.ads)
14340 @section @code{GNAT.Signals} (@file{g-signal.ads})
14341 @cindex @code{GNAT.Signals} (@file{g-signal.ads})
14342 @cindex Signals
14343
14344 @noindent
14345 Provides the ability to manipulate the blocked status of signals on supported
14346 targets.
14347
14348 @node GNAT.Sockets (g-socket.ads)
14349 @section @code{GNAT.Sockets} (@file{g-socket.ads})
14350 @cindex @code{GNAT.Sockets} (@file{g-socket.ads})
14351 @cindex Sockets
14352
14353 @noindent
14354 A high level and portable interface to develop sockets based applications.
14355 This package is based on the sockets thin binding found in
14356 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
14357 on all native GNAT ports except for OpenVMS@.  It is not implemented
14358 for the LynxOS@ cross port.
14359
14360 @node GNAT.Source_Info (g-souinf.ads)
14361 @section @code{GNAT.Source_Info} (@file{g-souinf.ads})
14362 @cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
14363 @cindex Source Information
14364
14365 @noindent
14366 Provides subprograms that give access to source code information known at
14367 compile time, such as the current file name and line number.
14368
14369 @node GNAT.Spelling_Checker (g-speche.ads)
14370 @section @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
14371 @cindex @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
14372 @cindex Spell checking
14373
14374 @noindent
14375 Provides a function for determining whether one string is a plausible
14376 near misspelling of another string.
14377
14378 @node GNAT.Spelling_Checker_Generic (g-spchge.ads)
14379 @section @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
14380 @cindex @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
14381 @cindex Spell checking
14382
14383 @noindent
14384 Provides a generic function that can be instantiated with a string type for
14385 determining whether one string is a plausible near misspelling of another
14386 string.
14387
14388 @node GNAT.Spitbol.Patterns (g-spipat.ads)
14389 @section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
14390 @cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
14391 @cindex SPITBOL pattern matching
14392 @cindex Pattern matching
14393
14394 @noindent
14395 A complete implementation of SNOBOL4 style pattern matching.  This is the
14396 most elaborate of the pattern matching packages provided.  It fully duplicates
14397 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
14398 efficient algorithm developed by Robert Dewar for the SPITBOL system.
14399
14400 @node GNAT.Spitbol (g-spitbo.ads)
14401 @section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
14402 @cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
14403 @cindex SPITBOL interface
14404
14405 @noindent
14406 The top level package of the collection of SPITBOL-style functionality, this
14407 package provides basic SNOBOL4 string manipulation functions, such as
14408 Pad, Reverse, Trim, Substr capability, as well as a generic table function
14409 useful for constructing arbitrary mappings from strings in the style of
14410 the SNOBOL4 TABLE function.
14411
14412 @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
14413 @section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
14414 @cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
14415 @cindex Sets of strings
14416 @cindex SPITBOL Tables
14417
14418 @noindent
14419 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
14420 for type @code{Standard.Boolean}, giving an implementation of sets of
14421 string values.
14422
14423 @node GNAT.Spitbol.Table_Integer (g-sptain.ads)
14424 @section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
14425 @cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
14426 @cindex Integer maps
14427 @cindex Maps
14428 @cindex SPITBOL Tables
14429
14430 @noindent
14431 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
14432 for type @code{Standard.Integer}, giving an implementation of maps
14433 from string to integer values.
14434
14435 @node GNAT.Spitbol.Table_VString (g-sptavs.ads)
14436 @section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
14437 @cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
14438 @cindex String maps
14439 @cindex Maps
14440 @cindex SPITBOL Tables
14441
14442 @noindent
14443 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
14444 a variable length string type, giving an implementation of general
14445 maps from strings to strings.
14446
14447 @node GNAT.Strings (g-string.ads)
14448 @section @code{GNAT.Strings} (@file{g-string.ads})
14449 @cindex @code{GNAT.Strings} (@file{g-string.ads})
14450
14451 @noindent
14452 Common String access types and related subprograms. Basically it
14453 defines a string access and an array of string access types.
14454
14455 @node GNAT.String_Split (g-strspl.ads)
14456 @section @code{GNAT.String_Split} (@file{g-strspl.ads})
14457 @cindex @code{GNAT.String_Split} (@file{g-strspl.ads})
14458 @cindex String splitter
14459
14460 @noindent
14461 Useful string manipulation routines: given a set of separators, split
14462 a string wherever the separators appear, and provide direct access
14463 to the resulting slices. This package is instantiated from
14464 @code{GNAT.Array_Split}.
14465
14466 @node GNAT.Table (g-table.ads)
14467 @section @code{GNAT.Table} (@file{g-table.ads})
14468 @cindex @code{GNAT.Table} (@file{g-table.ads})
14469 @cindex Table implementation
14470 @cindex Arrays, extendable
14471
14472 @noindent
14473 A generic package providing a single dimension array abstraction where the
14474 length of the array can be dynamically modified.
14475
14476 @noindent
14477 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
14478 except that this package declares a single instance of the table type,
14479 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
14480 used to define dynamic instances of the table.
14481
14482 @node GNAT.Task_Lock (g-tasloc.ads)
14483 @section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
14484 @cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
14485 @cindex Task synchronization
14486 @cindex Task locking
14487 @cindex Locking
14488
14489 @noindent
14490 A very simple facility for locking and unlocking sections of code using a
14491 single global task lock.  Appropriate for use in situations where contention
14492 between tasks is very rarely expected.
14493
14494 @node GNAT.Time_Stamp (g-timsta.ads)
14495 @section @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
14496 @cindex @code{GNAT.Time_Stamp} (@file{g-timsta.ads})
14497 @cindex Time stamp
14498 @cindex Current time
14499
14500 @noindent
14501 Provides a simple function that returns a string YYYY-MM-DD HH:MM:SS.SS that
14502 represents the current date and time in ISO 8601 format. This is a very simple
14503 routine with minimal code and there are no dependencies on any other unit.
14504
14505 @node GNAT.Threads (g-thread.ads)
14506 @section @code{GNAT.Threads} (@file{g-thread.ads})
14507 @cindex @code{GNAT.Threads} (@file{g-thread.ads})
14508 @cindex Foreign threads
14509 @cindex Threads, foreign
14510
14511 @noindent
14512 Provides facilities for dealing with foreign threads which need to be known
14513 by the GNAT run-time system. Consult the documentation of this package for
14514 further details if your program has threads that are created by a non-Ada
14515 environment which then accesses Ada code.
14516
14517 @node GNAT.Traceback (g-traceb.ads)
14518 @section @code{GNAT.Traceback} (@file{g-traceb.ads})
14519 @cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
14520 @cindex Trace back facilities
14521
14522 @noindent
14523 Provides a facility for obtaining non-symbolic traceback information, useful
14524 in various debugging situations.
14525
14526 @node GNAT.Traceback.Symbolic (g-trasym.ads)
14527 @section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
14528 @cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
14529 @cindex Trace back facilities
14530
14531 @node GNAT.UTF_32 (g-utf_32.ads)
14532 @section @code{GNAT.UTF_32} (@file{g-table.ads})
14533 @cindex @code{GNAT.UTF_32} (@file{g-table.ads})
14534 @cindex Wide character codes
14535
14536 @noindent
14537 This is a package intended to be used in conjunction with the
14538 @code{Wide_Character} type in Ada 95 and the
14539 @code{Wide_Wide_Character} type in Ada 2005 (available
14540 in @code{GNAT} in Ada 2005 mode). This package contains
14541 Unicode categorization routines, as well as lexical
14542 categorization routines corresponding to the Ada 2005
14543 lexical rules for identifiers and strings, and also a
14544 lower case to upper case fold routine corresponding to
14545 the Ada 2005 rules for identifier equivalence.
14546
14547 @node GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)
14548 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
14549 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
14550 @cindex Spell checking
14551
14552 @noindent
14553 Provides a function for determining whether one wide wide string is a plausible
14554 near misspelling of another wide wide string, where the strings are represented
14555 using the UTF_32_String type defined in System.Wch_Cnv.
14556
14557 @node GNAT.Wide_Spelling_Checker (g-wispch.ads)
14558 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
14559 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
14560 @cindex Spell checking
14561
14562 @noindent
14563 Provides a function for determining whether one wide string is a plausible
14564 near misspelling of another wide string.
14565
14566 @node GNAT.Wide_String_Split (g-wistsp.ads)
14567 @section @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
14568 @cindex @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
14569 @cindex Wide_String splitter
14570
14571 @noindent
14572 Useful wide string manipulation routines: given a set of separators, split
14573 a wide string wherever the separators appear, and provide direct access
14574 to the resulting slices. This package is instantiated from
14575 @code{GNAT.Array_Split}.
14576
14577 @node GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)
14578 @section @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
14579 @cindex @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
14580 @cindex Spell checking
14581
14582 @noindent
14583 Provides a function for determining whether one wide wide string is a plausible
14584 near misspelling of another wide wide string.
14585
14586 @node GNAT.Wide_Wide_String_Split (g-zistsp.ads)
14587 @section @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
14588 @cindex @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
14589 @cindex Wide_Wide_String splitter
14590
14591 @noindent
14592 Useful wide wide string manipulation routines: given a set of separators, split
14593 a wide wide string wherever the separators appear, and provide direct access
14594 to the resulting slices. This package is instantiated from
14595 @code{GNAT.Array_Split}.
14596
14597 @node Interfaces.C.Extensions (i-cexten.ads)
14598 @section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
14599 @cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
14600
14601 @noindent
14602 This package contains additional C-related definitions, intended
14603 for use with either manually or automatically generated bindings
14604 to C libraries.
14605
14606 @node Interfaces.C.Streams (i-cstrea.ads)
14607 @section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
14608 @cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
14609 @cindex  C streams, interfacing
14610
14611 @noindent
14612 This package is a binding for the most commonly used operations
14613 on C streams.
14614
14615 @node Interfaces.CPP (i-cpp.ads)
14616 @section @code{Interfaces.CPP} (@file{i-cpp.ads})
14617 @cindex @code{Interfaces.CPP} (@file{i-cpp.ads})
14618 @cindex  C++ interfacing
14619 @cindex  Interfacing, to C++
14620
14621 @noindent
14622 This package provides facilities for use in interfacing to C++.  It
14623 is primarily intended to be used in connection with automated tools
14624 for the generation of C++ interfaces.
14625
14626 @node Interfaces.Packed_Decimal (i-pacdec.ads)
14627 @section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
14628 @cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
14629 @cindex  IBM Packed Format
14630 @cindex  Packed Decimal
14631
14632 @noindent
14633 This package provides a set of routines for conversions to and
14634 from a packed decimal format compatible with that used on IBM
14635 mainframes.
14636
14637 @node Interfaces.VxWorks (i-vxwork.ads)
14638 @section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
14639 @cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
14640 @cindex Interfacing to VxWorks
14641 @cindex VxWorks, interfacing
14642
14643 @noindent
14644 This package provides a limited binding to the VxWorks API.
14645 In particular, it interfaces with the
14646 VxWorks hardware interrupt facilities.
14647
14648 @node Interfaces.VxWorks.IO (i-vxwoio.ads)
14649 @section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
14650 @cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
14651 @cindex Interfacing to VxWorks' I/O
14652 @cindex VxWorks, I/O interfacing
14653 @cindex VxWorks, Get_Immediate
14654 @cindex Get_Immediate, VxWorks
14655
14656 @noindent
14657 This package provides a binding to the ioctl (IO/Control)
14658 function of VxWorks, defining a set of option values and
14659 function codes. A particular use of this package is
14660 to enable the use of Get_Immediate under VxWorks.
14661
14662 @node System.Address_Image (s-addima.ads)
14663 @section @code{System.Address_Image} (@file{s-addima.ads})
14664 @cindex @code{System.Address_Image} (@file{s-addima.ads})
14665 @cindex Address image
14666 @cindex Image, of an address
14667
14668 @noindent
14669 This function provides a useful debugging
14670 function that gives an (implementation dependent)
14671 string which identifies an address.
14672
14673 @node System.Assertions (s-assert.ads)
14674 @section @code{System.Assertions} (@file{s-assert.ads})
14675 @cindex @code{System.Assertions} (@file{s-assert.ads})
14676 @cindex Assertions
14677 @cindex Assert_Failure, exception
14678
14679 @noindent
14680 This package provides the declaration of the exception raised
14681 by an run-time assertion failure, as well as the routine that
14682 is used internally to raise this assertion.
14683
14684 @node System.Memory (s-memory.ads)
14685 @section @code{System.Memory} (@file{s-memory.ads})
14686 @cindex @code{System.Memory} (@file{s-memory.ads})
14687 @cindex Memory allocation
14688
14689 @noindent
14690 This package provides the interface to the low level routines used
14691 by the generated code for allocation and freeing storage for the
14692 default storage pool (analogous to the C routines malloc and free.
14693 It also provides a reallocation interface analogous to the C routine
14694 realloc. The body of this unit may be modified to provide alternative
14695 allocation mechanisms for the default pool, and in addition, direct
14696 calls to this unit may be made for low level allocation uses (for
14697 example see the body of @code{GNAT.Tables}).
14698
14699 @node System.Partition_Interface (s-parint.ads)
14700 @section @code{System.Partition_Interface} (@file{s-parint.ads})
14701 @cindex @code{System.Partition_Interface} (@file{s-parint.ads})
14702 @cindex Partition interfacing functions
14703
14704 @noindent
14705 This package provides facilities for partition interfacing.  It
14706 is used primarily in a distribution context when using Annex E
14707 with @code{GLADE}.
14708
14709 @node System.Pool_Global (s-pooglo.ads)
14710 @section @code{System.Pool_Global} (@file{s-pooglo.ads})
14711 @cindex @code{System.Pool_Global} (@file{s-pooglo.ads})
14712 @cindex Storage pool, global
14713 @cindex Global storage pool
14714
14715 @noindent
14716 This package provides a storage pool that is equivalent to the default
14717 storage pool used for access types for which no pool is specifically
14718 declared. It uses malloc/free to allocate/free and does not attempt to
14719 do any automatic reclamation.
14720
14721 @node System.Pool_Local (s-pooloc.ads)
14722 @section @code{System.Pool_Local} (@file{s-pooloc.ads})
14723 @cindex @code{System.Pool_Local} (@file{s-pooloc.ads})
14724 @cindex Storage pool, local
14725 @cindex Local storage pool
14726
14727 @noindent
14728 This package provides a storage pool that is intended for use with locally
14729 defined access types. It uses malloc/free for allocate/free, and maintains
14730 a list of allocated blocks, so that all storage allocated for the pool can
14731 be freed automatically when the pool is finalized.
14732
14733 @node System.Restrictions (s-restri.ads)
14734 @section @code{System.Restrictions} (@file{s-restri.ads})
14735 @cindex @code{System.Restrictions} (@file{s-restri.ads})
14736 @cindex Run-time restrictions access
14737
14738 @noindent
14739 This package provides facilities for accessing at run time
14740 the status of restrictions specified at compile time for
14741 the partition. Information is available both with regard
14742 to actual restrictions specified, and with regard to
14743 compiler determined information on which restrictions
14744 are violated by one or more packages in the partition.
14745
14746 @node System.Rident (s-rident.ads)
14747 @section @code{System.Rident} (@file{s-rident.ads})
14748 @cindex @code{System.Rident} (@file{s-rident.ads})
14749 @cindex Restrictions definitions
14750
14751 @noindent
14752 This package provides definitions of the restrictions
14753 identifiers supported by GNAT, and also the format of
14754 the restrictions provided in package System.Restrictions.
14755 It is not normally necessary to @code{with} this generic package
14756 since the necessary instantiation is included in
14757 package System.Restrictions.
14758
14759 @node System.Task_Info (s-tasinf.ads)
14760 @section @code{System.Task_Info} (@file{s-tasinf.ads})
14761 @cindex @code{System.Task_Info} (@file{s-tasinf.ads})
14762 @cindex Task_Info pragma
14763
14764 @noindent
14765 This package provides target dependent functionality that is used
14766 to support the @code{Task_Info} pragma
14767
14768 @node System.Wch_Cnv (s-wchcnv.ads)
14769 @section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
14770 @cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
14771 @cindex Wide Character, Representation
14772 @cindex Wide String, Conversion
14773 @cindex Representation of wide characters
14774
14775 @noindent
14776 This package provides routines for converting between
14777 wide and wide wide characters and a representation as a value of type
14778 @code{Standard.String}, using a specified wide character
14779 encoding method.  It uses definitions in
14780 package @code{System.Wch_Con}.
14781
14782 @node System.Wch_Con (s-wchcon.ads)
14783 @section @code{System.Wch_Con} (@file{s-wchcon.ads})
14784 @cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
14785
14786 @noindent
14787 This package provides definitions and descriptions of
14788 the various methods used for encoding wide characters
14789 in ordinary strings.  These definitions are used by
14790 the package @code{System.Wch_Cnv}.
14791
14792 @node Interfacing to Other Languages
14793 @chapter Interfacing to Other Languages
14794 @noindent
14795 The facilities in annex B of the Ada Reference Manual are fully
14796 implemented in GNAT, and in addition, a full interface to C++ is
14797 provided.
14798
14799 @menu
14800 * Interfacing to C::
14801 * Interfacing to C++::
14802 * Interfacing to COBOL::
14803 * Interfacing to Fortran::
14804 * Interfacing to non-GNAT Ada code::
14805 @end menu
14806
14807 @node Interfacing to C
14808 @section Interfacing to C
14809
14810 @noindent
14811 Interfacing to C with GNAT can use one of two approaches:
14812
14813 @itemize @bullet
14814 @item
14815 The types in the package @code{Interfaces.C} may be used.
14816 @item
14817 Standard Ada types may be used directly.  This may be less portable to
14818 other compilers, but will work on all GNAT compilers, which guarantee
14819 correspondence between the C and Ada types.
14820 @end itemize
14821
14822 @noindent
14823 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
14824 effect, since this is the default.  The following table shows the
14825 correspondence between Ada scalar types and the corresponding C types.
14826
14827 @table @code
14828 @item Integer
14829 @code{int}
14830 @item Short_Integer
14831 @code{short}
14832 @item Short_Short_Integer
14833 @code{signed char}
14834 @item Long_Integer
14835 @code{long}
14836 @item Long_Long_Integer
14837 @code{long long}
14838 @item Short_Float
14839 @code{float}
14840 @item Float
14841 @code{float}
14842 @item Long_Float
14843 @code{double}
14844 @item Long_Long_Float
14845 This is the longest floating-point type supported by the hardware.
14846 @end table
14847
14848 @noindent
14849 Additionally, there are the following general correspondences between Ada
14850 and C types:
14851 @itemize @bullet
14852 @item
14853 Ada enumeration types map to C enumeration types directly if pragma
14854 @code{Convention C} is specified, which causes them to have int
14855 length.  Without pragma @code{Convention C}, Ada enumeration types map to
14856 8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short},
14857 @code{int}, respectively) depending on the number of values passed.
14858 This is the only case in which pragma @code{Convention C} affects the
14859 representation of an Ada type.
14860
14861 @item
14862 Ada access types map to C pointers, except for the case of pointers to
14863 unconstrained types in Ada, which have no direct C equivalent.
14864
14865 @item
14866 Ada arrays map directly to C arrays.
14867
14868 @item
14869 Ada records map directly to C structures.
14870
14871 @item
14872 Packed Ada records map to C structures where all members are bit fields
14873 of the length corresponding to the @code{@var{type}'Size} value in Ada.
14874 @end itemize
14875
14876 @node Interfacing to C++
14877 @section Interfacing to C++
14878
14879 @noindent
14880 The interface to C++ makes use of the following pragmas, which are
14881 primarily intended to be constructed automatically using a binding generator
14882 tool, although it is possible to construct them by hand.  No suitable binding
14883 generator tool is supplied with GNAT though.
14884
14885 Using these pragmas it is possible to achieve complete
14886 inter-operability between Ada tagged types and C++ class definitions.
14887 See @ref{Implementation Defined Pragmas}, for more details.
14888
14889 @table @code
14890 @item pragma CPP_Class ([Entity =>] @var{LOCAL_NAME})
14891 The argument denotes an entity in the current declarative region that is
14892 declared as a tagged or untagged record type. It indicates that the type
14893 corresponds to an externally declared C++ class type, and is to be laid
14894 out the same way that C++ would lay out the type.
14895
14896 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
14897 for backward compatibility but its functionality is available
14898 using pragma @code{Import} with @code{Convention} = @code{CPP}.
14899
14900 @item pragma CPP_Constructor ([Entity =>] @var{LOCAL_NAME})
14901 This pragma identifies an imported function (imported in the usual way
14902 with pragma @code{Import}) as corresponding to a C++ constructor.
14903 @end table
14904
14905 @node Interfacing to COBOL
14906 @section Interfacing to COBOL
14907
14908 @noindent
14909 Interfacing to COBOL is achieved as described in section B.4 of
14910 the Ada Reference Manual.
14911
14912 @node Interfacing to Fortran
14913 @section Interfacing to Fortran
14914
14915 @noindent
14916 Interfacing to Fortran is achieved as described in section B.5 of the
14917 Ada Reference Manual.  The pragma @code{Convention Fortran}, applied to a
14918 multi-dimensional array causes the array to be stored in column-major
14919 order as required for convenient interface to Fortran.
14920
14921 @node Interfacing to non-GNAT Ada code
14922 @section Interfacing to non-GNAT Ada code
14923
14924 It is possible to specify the convention @code{Ada} in a pragma
14925 @code{Import} or pragma @code{Export}.  However this refers to
14926 the calling conventions used by GNAT, which may or may not be
14927 similar enough to those used by some other Ada 83 / Ada 95 / Ada 2005
14928 compiler to allow interoperation.
14929
14930 If arguments types are kept simple, and if the foreign compiler generally
14931 follows system calling conventions, then it may be possible to integrate
14932 files compiled by other Ada compilers, provided that the elaboration
14933 issues are adequately addressed (for example by eliminating the
14934 need for any load time elaboration).
14935
14936 In particular, GNAT running on VMS is designed to
14937 be highly compatible with the DEC Ada 83 compiler, so this is one
14938 case in which it is possible to import foreign units of this type,
14939 provided that the data items passed are restricted to simple scalar
14940 values or simple record types without variants, or simple array
14941 types with fixed bounds.
14942
14943 @node Specialized Needs Annexes
14944 @chapter Specialized Needs Annexes
14945
14946 @noindent
14947 Ada 95 and Ada 2005 define a number of Specialized Needs Annexes, which are not
14948 required in all implementations.  However, as described in this chapter,
14949 GNAT implements all of these annexes:
14950
14951 @table @asis
14952 @item Systems Programming (Annex C)
14953 The Systems Programming Annex is fully implemented.
14954
14955 @item Real-Time Systems (Annex D)
14956 The Real-Time Systems Annex is fully implemented.
14957
14958 @item Distributed Systems (Annex E)
14959 Stub generation is fully implemented in the GNAT compiler.  In addition,
14960 a complete compatible PCS is available as part of the GLADE system,
14961 a separate product.  When the two
14962 products are used in conjunction, this annex is fully implemented.
14963
14964 @item Information Systems (Annex F)
14965 The Information Systems annex is fully implemented.
14966
14967 @item Numerics (Annex G)
14968 The Numerics Annex is fully implemented.
14969
14970 @item Safety and Security / High-Integrity Systems (Annex H)
14971 The Safety and Security Annex (termed the High-Integrity Systems Annex
14972 in Ada 2005) is fully implemented.
14973 @end table
14974
14975 @node Implementation of Specific Ada Features
14976 @chapter Implementation of Specific Ada Features
14977
14978 @noindent
14979 This chapter describes the GNAT implementation of several Ada language
14980 facilities.
14981
14982 @menu
14983 * Machine Code Insertions::
14984 * GNAT Implementation of Tasking::
14985 * GNAT Implementation of Shared Passive Packages::
14986 * Code Generation for Array Aggregates::
14987 * The Size of Discriminated Records with Default Discriminants::
14988 * Strict Conformance to the Ada Reference Manual::
14989 @end menu
14990
14991 @node Machine Code Insertions
14992 @section Machine Code Insertions
14993 @cindex Machine Code insertions
14994
14995 @noindent
14996 Package @code{Machine_Code} provides machine code support as described
14997 in the Ada Reference Manual in two separate forms:
14998 @itemize @bullet
14999 @item
15000 Machine code statements, consisting of qualified expressions that
15001 fit the requirements of RM section 13.8.
15002 @item
15003 An intrinsic callable procedure, providing an alternative mechanism of
15004 including machine instructions in a subprogram.
15005 @end itemize
15006
15007 @noindent
15008 The two features are similar, and both are closely related to the mechanism
15009 provided by the asm instruction in the GNU C compiler.  Full understanding
15010 and use of the facilities in this package requires understanding the asm
15011 instruction, see @ref{Extended Asm,, Assembler Instructions with C Expression
15012 Operands, gcc, Using the GNU Compiler Collection (GCC)}.
15013
15014 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
15015 semantic restrictions and effects as described below.  Both are provided so
15016 that the procedure call can be used as a statement, and the function call
15017 can be used to form a code_statement.
15018
15019 The first example given in the GCC documentation is the C @code{asm}
15020 instruction:
15021 @smallexample
15022    asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
15023 @end smallexample
15024
15025 @noindent
15026 The equivalent can be written for GNAT as:
15027
15028 @smallexample @c ada
15029 Asm ("fsinx %1 %0",
15030      My_Float'Asm_Output ("=f", result),
15031      My_Float'Asm_Input  ("f",  angle));
15032 @end smallexample
15033
15034 @noindent
15035 The first argument to @code{Asm} is the assembler template, and is
15036 identical to what is used in GNU C@.  This string must be a static
15037 expression.  The second argument is the output operand list.  It is
15038 either a single @code{Asm_Output} attribute reference, or a list of such
15039 references enclosed in parentheses (technically an array aggregate of
15040 such references).
15041
15042 The @code{Asm_Output} attribute denotes a function that takes two
15043 parameters.  The first is a string, the second is the name of a variable
15044 of the type designated by the attribute prefix.  The first (string)
15045 argument is required to be a static expression and designates the
15046 constraint for the parameter (e.g.@: what kind of register is
15047 required).  The second argument is the variable to be updated with the
15048 result.  The possible values for constraint are the same as those used in
15049 the RTL, and are dependent on the configuration file used to build the
15050 GCC back end.  If there are no output operands, then this argument may
15051 either be omitted, or explicitly given as @code{No_Output_Operands}.
15052
15053 The second argument of @code{@var{my_float}'Asm_Output} functions as
15054 though it were an @code{out} parameter, which is a little curious, but
15055 all names have the form of expressions, so there is no syntactic
15056 irregularity, even though normally functions would not be permitted
15057 @code{out} parameters.  The third argument is the list of input
15058 operands.  It is either a single @code{Asm_Input} attribute reference, or
15059 a list of such references enclosed in parentheses (technically an array
15060 aggregate of such references).
15061
15062 The @code{Asm_Input} attribute denotes a function that takes two
15063 parameters.  The first is a string, the second is an expression of the
15064 type designated by the prefix.  The first (string) argument is required
15065 to be a static expression, and is the constraint for the parameter,
15066 (e.g.@: what kind of register is required).  The second argument is the
15067 value to be used as the input argument.  The possible values for the
15068 constant are the same as those used in the RTL, and are dependent on
15069 the configuration file used to built the GCC back end.
15070
15071 If there are no input operands, this argument may either be omitted, or
15072 explicitly given as @code{No_Input_Operands}.  The fourth argument, not
15073 present in the above example, is a list of register names, called the
15074 @dfn{clobber} argument.  This argument, if given, must be a static string
15075 expression, and is a space or comma separated list of names of registers
15076 that must be considered destroyed as a result of the @code{Asm} call.  If
15077 this argument is the null string (the default value), then the code
15078 generator assumes that no additional registers are destroyed.
15079
15080 The fifth argument, not present in the above example, called the
15081 @dfn{volatile} argument, is by default @code{False}.  It can be set to
15082 the literal value @code{True} to indicate to the code generator that all
15083 optimizations with respect to the instruction specified should be
15084 suppressed, and that in particular, for an instruction that has outputs,
15085 the instruction will still be generated, even if none of the outputs are
15086 used.  @xref{Extended Asm,, Assembler Instructions with C Expression Operands,
15087 gcc, Using the GNU Compiler Collection (GCC)}, for the full description.
15088 Generally it is strongly advisable to use Volatile for any ASM statement
15089 that is missing either input or output operands, or when two or more ASM
15090 statements appear in sequence, to avoid unwanted optimizations. A warning
15091 is generated if this advice is not followed.
15092
15093 The @code{Asm} subprograms may be used in two ways.  First the procedure
15094 forms can be used anywhere a procedure call would be valid, and
15095 correspond to what the RM calls ``intrinsic'' routines.  Such calls can
15096 be used to intersperse machine instructions with other Ada statements.
15097 Second, the function forms, which return a dummy value of the limited
15098 private type @code{Asm_Insn}, can be used in code statements, and indeed
15099 this is the only context where such calls are allowed.  Code statements
15100 appear as aggregates of the form:
15101
15102 @smallexample @c ada
15103 Asm_Insn'(Asm (@dots{}));
15104 Asm_Insn'(Asm_Volatile (@dots{}));
15105 @end smallexample
15106
15107 @noindent
15108 In accordance with RM rules, such code statements are allowed only
15109 within subprograms whose entire body consists of such statements.  It is
15110 not permissible to intermix such statements with other Ada statements.
15111
15112 Typically the form using intrinsic procedure calls is more convenient
15113 and more flexible.  The code statement form is provided to meet the RM
15114 suggestion that such a facility should be made available.  The following
15115 is the exact syntax of the call to @code{Asm}. As usual, if named notation
15116 is used, the arguments may be given in arbitrary order, following the
15117 normal rules for use of positional and named arguments)
15118
15119 @smallexample
15120 ASM_CALL ::= Asm (
15121                  [Template =>] static_string_EXPRESSION
15122                [,[Outputs  =>] OUTPUT_OPERAND_LIST      ]
15123                [,[Inputs   =>] INPUT_OPERAND_LIST       ]
15124                [,[Clobber  =>] static_string_EXPRESSION ]
15125                [,[Volatile =>] static_boolean_EXPRESSION] )
15126
15127 OUTPUT_OPERAND_LIST ::=
15128   [PREFIX.]No_Output_Operands
15129 | OUTPUT_OPERAND_ATTRIBUTE
15130 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
15131
15132 OUTPUT_OPERAND_ATTRIBUTE ::=
15133   SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
15134
15135 INPUT_OPERAND_LIST ::=
15136   [PREFIX.]No_Input_Operands
15137 | INPUT_OPERAND_ATTRIBUTE
15138 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
15139
15140 INPUT_OPERAND_ATTRIBUTE ::=
15141   SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
15142 @end smallexample
15143
15144 @noindent
15145 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
15146 are declared in the package @code{Machine_Code} and must be referenced
15147 according to normal visibility rules. In particular if there is no
15148 @code{use} clause for this package, then appropriate package name
15149 qualification is required.
15150
15151 @node GNAT Implementation of Tasking
15152 @section GNAT Implementation of Tasking
15153
15154 @noindent
15155 This chapter outlines the basic GNAT approach to tasking (in particular,
15156 a multi-layered library for portability) and discusses issues related
15157 to compliance with the Real-Time Systems Annex.
15158
15159 @menu
15160 * Mapping Ada Tasks onto the Underlying Kernel Threads::
15161 * Ensuring Compliance with the Real-Time Annex::
15162 @end menu
15163
15164 @node Mapping Ada Tasks onto the Underlying Kernel Threads
15165 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
15166
15167 @noindent
15168 GNAT's run-time support comprises two layers:
15169
15170 @itemize @bullet
15171 @item GNARL (GNAT Run-time Layer)
15172 @item GNULL (GNAT Low-level Library)
15173 @end itemize
15174
15175 @noindent
15176 In GNAT, Ada's tasking services rely on a platform and OS independent
15177 layer known as GNARL@.  This code is responsible for implementing the
15178 correct semantics of Ada's task creation, rendezvous, protected
15179 operations etc.
15180
15181 GNARL decomposes Ada's tasking semantics into simpler lower level
15182 operations such as create a thread, set the priority of a thread,
15183 yield, create a lock, lock/unlock, etc.  The spec for these low-level
15184 operations constitutes GNULLI, the GNULL Interface.  This interface is
15185 directly inspired from the POSIX real-time API@.
15186
15187 If the underlying executive or OS implements the POSIX standard
15188 faithfully, the GNULL Interface maps as is to the services offered by
15189 the underlying kernel.  Otherwise, some target dependent glue code maps
15190 the services offered by the underlying kernel to the semantics expected
15191 by GNARL@.
15192
15193 Whatever the underlying OS (VxWorks, UNIX, OS/2, Windows NT, etc.) the
15194 key point is that each Ada task is mapped on a thread in the underlying
15195 kernel.  For example, in the case of VxWorks, one Ada task = one VxWorks task.
15196
15197 In addition Ada task priorities map onto the underlying thread priorities.
15198 Mapping Ada tasks onto the underlying kernel threads has several advantages:
15199
15200 @itemize @bullet
15201 @item
15202 The underlying scheduler is used to schedule the Ada tasks.  This
15203 makes Ada tasks as efficient as kernel threads from a scheduling
15204 standpoint.
15205
15206 @item
15207 Interaction with code written in C containing threads is eased
15208 since at the lowest level Ada tasks and C threads map onto the same
15209 underlying kernel concept.
15210
15211 @item
15212 When an Ada task is blocked during I/O the remaining Ada tasks are
15213 able to proceed.
15214
15215 @item
15216 On multiprocessor systems Ada tasks can execute in parallel.
15217 @end itemize
15218
15219 @noindent
15220 Some threads libraries offer a mechanism to fork a new process, with the
15221 child process duplicating the threads from the parent.
15222 GNAT does not
15223 support this functionality when the parent contains more than one task.
15224 @cindex Forking a new process
15225
15226 @node Ensuring Compliance with the Real-Time Annex
15227 @subsection Ensuring Compliance with the Real-Time Annex
15228 @cindex Real-Time Systems Annex compliance
15229
15230 @noindent
15231 Although mapping Ada tasks onto
15232 the underlying threads has significant advantages, it does create some
15233 complications when it comes to respecting the scheduling semantics
15234 specified in the real-time annex (Annex D).
15235
15236 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
15237 scheduling policy states:
15238
15239 @quotation
15240 @emph{When the active priority of a ready task that is not running
15241 changes, or the setting of its base priority takes effect, the
15242 task is removed from the ready queue for its old active priority
15243 and is added at the tail of the ready queue for its new active
15244 priority, except in the case where the active priority is lowered
15245 due to the loss of inherited priority, in which case the task is
15246 added at the head of the ready queue for its new active priority.}
15247 @end quotation
15248
15249 @noindent
15250 While most kernels do put tasks at the end of the priority queue when
15251 a task changes its priority, (which respects the main
15252 FIFO_Within_Priorities requirement), almost none keep a thread at the
15253 beginning of its priority queue when its priority drops from the loss
15254 of inherited priority.
15255
15256 As a result most vendors have provided incomplete Annex D implementations.
15257
15258 The GNAT run-time, has a nice cooperative solution to this problem
15259 which ensures that accurate FIFO_Within_Priorities semantics are
15260 respected.
15261
15262 The principle is as follows.  When an Ada task T is about to start
15263 running, it checks whether some other Ada task R with the same
15264 priority as T has been suspended due to the loss of priority
15265 inheritance.  If this is the case, T yields and is placed at the end of
15266 its priority queue.  When R arrives at the front of the queue it
15267 executes.
15268
15269 Note that this simple scheme preserves the relative order of the tasks
15270 that were ready to execute in the priority queue where R has been
15271 placed at the end.
15272
15273 @node GNAT Implementation of Shared Passive Packages
15274 @section GNAT Implementation of Shared Passive Packages
15275 @cindex Shared passive packages
15276
15277 @noindent
15278 GNAT fully implements the pragma @code{Shared_Passive} for
15279 @cindex pragma @code{Shared_Passive}
15280 the purpose of designating shared passive packages.
15281 This allows the use of passive partitions in the
15282 context described in the Ada Reference Manual; i.e., for communication
15283 between separate partitions of a distributed application using the
15284 features in Annex E.
15285 @cindex Annex E
15286 @cindex Distribution Systems Annex
15287
15288 However, the implementation approach used by GNAT provides for more
15289 extensive usage as follows:
15290
15291 @table @emph
15292 @item Communication between separate programs
15293
15294 This allows separate programs to access the data in passive
15295 partitions, using protected objects for synchronization where
15296 needed. The only requirement is that the two programs have a
15297 common shared file system. It is even possible for programs
15298 running on different machines with different architectures
15299 (e.g.@: different endianness) to communicate via the data in
15300 a passive partition.
15301
15302 @item Persistence between program runs
15303
15304 The data in a passive package can persist from one run of a
15305 program to another, so that a later program sees the final
15306 values stored by a previous run of the same program.
15307
15308 @end table
15309
15310 @noindent
15311 The implementation approach used is to store the data in files. A
15312 separate stream file is created for each object in the package, and
15313 an access to an object causes the corresponding file to be read or
15314 written.
15315
15316 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
15317 @cindex @code{SHARED_MEMORY_DIRECTORY} environment variable
15318 set to the directory to be used for these files.
15319 The files in this directory
15320 have names that correspond to their fully qualified names. For
15321 example, if we have the package
15322
15323 @smallexample @c ada
15324 package X is
15325   pragma Shared_Passive (X);
15326   Y : Integer;
15327   Z : Float;
15328 end X;
15329 @end smallexample
15330
15331 @noindent
15332 and the environment variable is set to @code{/stemp/}, then the files created
15333 will have the names:
15334
15335 @smallexample
15336 /stemp/x.y
15337 /stemp/x.z
15338 @end smallexample
15339
15340 @noindent
15341 These files are created when a value is initially written to the object, and
15342 the files are retained until manually deleted. This provides the persistence
15343 semantics. If no file exists, it means that no partition has assigned a value
15344 to the variable; in this case the initial value declared in the package
15345 will be used. This model ensures that there are no issues in synchronizing
15346 the elaboration process, since elaboration of passive packages elaborates the
15347 initial values, but does not create the files.
15348
15349 The files are written using normal @code{Stream_IO} access.
15350 If you want to be able
15351 to communicate between programs or partitions running on different
15352 architectures, then you should use the XDR versions of the stream attribute
15353 routines, since these are architecture independent.
15354
15355 If active synchronization is required for access to the variables in the
15356 shared passive package, then as described in the Ada Reference Manual, the
15357 package may contain protected objects used for this purpose. In this case
15358 a lock file (whose name is @file{___lock} (three underscores)
15359 is created in the shared memory directory.
15360 @cindex @file{___lock} file (for shared passive packages)
15361 This is used to provide the required locking
15362 semantics for proper protected object synchronization.
15363
15364 As of January 2003, GNAT supports shared passive packages on all platforms
15365 except for OpenVMS.
15366
15367 @node Code Generation for Array Aggregates
15368 @section Code Generation for Array Aggregates
15369
15370 @menu
15371 * Static constant aggregates with static bounds::
15372 * Constant aggregates with unconstrained nominal types::
15373 * Aggregates with static bounds::
15374 * Aggregates with non-static bounds::
15375 * Aggregates in assignment statements::
15376 @end menu
15377
15378 @noindent
15379 Aggregates have a rich syntax and allow the user to specify the values of
15380 complex data structures by means of a single construct.  As a result, the
15381 code generated for aggregates can be quite complex and involve loops, case
15382 statements and multiple assignments.  In the simplest cases, however, the
15383 compiler will recognize aggregates whose components and constraints are
15384 fully static, and in those cases the compiler will generate little or no
15385 executable code.  The following is an outline of the code that GNAT generates
15386 for various aggregate constructs.  For further details, you will find it
15387 useful to examine the output produced by the -gnatG flag to see the expanded
15388 source that is input to the code generator.  You may also want to examine
15389 the assembly code generated at various levels of optimization.
15390
15391 The code generated for aggregates depends on the context, the component values,
15392 and the type.  In the context of an object declaration the code generated is
15393 generally simpler than in the case of an assignment.  As a general rule, static
15394 component values and static subtypes also lead to simpler code.
15395
15396 @node Static constant aggregates with static bounds
15397 @subsection Static constant aggregates with static bounds
15398
15399 @noindent
15400 For the declarations:
15401 @smallexample @c ada
15402     type One_Dim is array (1..10) of integer;
15403     ar0 : constant One_Dim := (1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
15404 @end smallexample
15405
15406 @noindent
15407 GNAT generates no executable code: the constant ar0 is placed in static memory.
15408 The same is true for constant aggregates with named associations:
15409
15410 @smallexample @c ada
15411     Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1 => 1, 5 .. 10 => 0);
15412     Cr3 : constant One_Dim := (others => 7777);
15413 @end smallexample
15414
15415 @noindent
15416 The same is true for multidimensional constant arrays such as:
15417
15418 @smallexample @c ada
15419     type two_dim is array (1..3, 1..3) of integer;
15420     Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
15421 @end smallexample
15422
15423 @noindent
15424 The same is true for arrays of one-dimensional arrays: the following are
15425 static:
15426
15427 @smallexample @c ada
15428 type ar1b  is array (1..3) of boolean;
15429 type ar_ar is array (1..3) of ar1b;
15430 None  : constant ar1b := (others => false);     --  fully static
15431 None2 : constant ar_ar := (1..3 => None);       --  fully static
15432 @end smallexample
15433
15434 @noindent
15435 However, for multidimensional aggregates with named associations, GNAT will
15436 generate assignments and loops, even if all associations are static.  The
15437 following two declarations generate a loop for the first dimension, and
15438 individual component assignments for the second dimension:
15439
15440 @smallexample @c ada
15441 Zero1: constant two_dim := (1..3 => (1..3 => 0));
15442 Zero2: constant two_dim := (others => (others => 0));
15443 @end smallexample
15444
15445 @node Constant aggregates with unconstrained nominal types
15446 @subsection Constant aggregates with unconstrained nominal types
15447
15448 @noindent
15449 In such cases the aggregate itself establishes the subtype, so that
15450 associations with @code{others} cannot be used.  GNAT determines the
15451 bounds for the actual subtype of the aggregate, and allocates the
15452 aggregate statically as well.  No code is generated for the following:
15453
15454 @smallexample @c ada
15455     type One_Unc is array (natural range <>) of integer;
15456     Cr_Unc : constant One_Unc := (12,24,36);
15457 @end smallexample
15458
15459 @node Aggregates with static bounds
15460 @subsection Aggregates with static bounds
15461
15462 @noindent
15463 In all previous examples the aggregate was the initial (and immutable) value
15464 of a constant.  If the aggregate initializes a variable, then code is generated
15465 for it as a combination of individual assignments and loops over the target
15466 object.  The declarations
15467
15468 @smallexample @c ada
15469        Cr_Var1 : One_Dim := (2, 5, 7, 11, 0, 0, 0, 0, 0, 0);
15470        Cr_Var2 : One_Dim := (others > -1);
15471 @end smallexample
15472
15473 @noindent
15474 generate the equivalent of
15475
15476 @smallexample @c ada
15477        Cr_Var1 (1) := 2;
15478        Cr_Var1 (2) := 3;
15479        Cr_Var1 (3) := 5;
15480        Cr_Var1 (4) := 11;
15481
15482        for I in Cr_Var2'range loop
15483           Cr_Var2 (I) := -1;
15484        end loop;
15485 @end smallexample
15486
15487 @node Aggregates with non-static bounds
15488 @subsection Aggregates with non-static bounds
15489
15490 @noindent
15491 If the bounds of the aggregate are not statically compatible with the bounds
15492 of the nominal subtype  of the target, then constraint checks have to be
15493 generated on the bounds.  For a multidimensional array, constraint checks may
15494 have to be applied to sub-arrays individually, if they do not have statically
15495 compatible subtypes.
15496
15497 @node Aggregates in assignment statements
15498 @subsection Aggregates in assignment statements
15499
15500 @noindent
15501 In general, aggregate assignment requires the construction of a temporary,
15502 and a copy from the temporary to the target of the assignment.  This is because
15503 it is not always possible to convert the assignment into a series of individual
15504 component assignments.  For example, consider the simple case:
15505
15506 @smallexample @c ada
15507         A := (A(2), A(1));
15508 @end smallexample
15509
15510 @noindent
15511 This cannot be converted into:
15512
15513 @smallexample @c ada
15514         A(1) := A(2);
15515         A(2) := A(1);
15516 @end smallexample
15517
15518 @noindent
15519 So the aggregate has to be built first in a separate location, and then
15520 copied into the target.  GNAT recognizes simple cases where this intermediate
15521 step is not required, and the assignments can be performed in place, directly
15522 into the target.  The following sufficient criteria are applied:
15523
15524 @itemize @bullet
15525 @item
15526 The bounds of the aggregate are static, and the associations are static.
15527 @item
15528 The components of the aggregate are static constants, names of
15529 simple variables that are not renamings, or expressions not involving
15530 indexed components whose operands obey these rules.
15531 @end itemize
15532
15533 @noindent
15534 If any of these conditions are violated, the aggregate will be built in
15535 a temporary (created either by the front-end or the code generator) and then
15536 that temporary will be copied onto the target.
15537
15538
15539 @node The Size of Discriminated Records with Default Discriminants
15540 @section The Size of Discriminated Records with Default Discriminants
15541
15542 @noindent
15543 If a discriminated type @code{T} has discriminants with default values, it is
15544 possible to declare an object of this type without providing an explicit
15545 constraint:
15546
15547 @smallexample @c ada
15548 @group
15549 type Size is range 1..100;
15550
15551 type Rec (D : Size := 15) is record
15552    Name : String (1..D);
15553 end T;
15554
15555 Word : Rec;
15556 @end group
15557 @end smallexample
15558
15559 @noindent
15560 Such an object is said to be @emph{unconstrained}.
15561 The discriminant of the object
15562 can be modified by a full assignment to the object, as long as it preserves the
15563 relation between the value of the discriminant, and the value of the components
15564 that depend on it:
15565
15566 @smallexample @c ada
15567 @group
15568 Word := (3, "yes");
15569
15570 Word := (5, "maybe");
15571
15572 Word := (5, "no"); -- raises Constraint_Error
15573 @end group
15574 @end smallexample
15575
15576 @noindent
15577 In order to support this behavior efficiently, an unconstrained object is
15578 given the maximum size that any value of the type requires. In the case
15579 above, @code{Word} has storage for the discriminant and for
15580 a @code{String} of length 100.
15581 It is important to note that unconstrained objects do not require dynamic
15582 allocation. It would be an improper implementation to place on the heap those
15583 components whose size depends on discriminants. (This improper implementation
15584 was used by some Ada83 compilers, where the @code{Name} component above
15585 would have
15586 been stored as a pointer to a dynamic string). Following the principle that
15587 dynamic storage management should never be introduced implicitly,
15588 an Ada compiler should reserve the full size for an unconstrained declared
15589 object, and place it on the stack.
15590
15591 This maximum size approach
15592 has been a source of surprise to some users, who expect the default
15593 values of the discriminants to determine the size reserved for an
15594 unconstrained object: ``If the default is 15, why should the object occupy
15595 a larger size?''
15596 The answer, of course, is that the discriminant may be later modified,
15597 and its full range of values must be taken into account. This is why the
15598 declaration:
15599
15600 @smallexample
15601 @group
15602 type Rec (D : Positive := 15) is record
15603    Name : String (1..D);
15604 end record;
15605
15606 Too_Large : Rec;
15607 @end group
15608 @end smallexample
15609
15610 @noindent
15611 is flagged by the compiler with a warning:
15612 an attempt to create @code{Too_Large} will raise @code{Storage_Error},
15613 because the required size includes @code{Positive'Last}
15614 bytes. As the first example indicates, the proper approach is to declare an
15615 index type of ``reasonable'' range so that unconstrained objects are not too
15616 large.
15617
15618 One final wrinkle: if the object is declared to be @code{aliased}, or if it is
15619 created in the heap by means of an allocator, then it is @emph{not}
15620 unconstrained:
15621 it is constrained by the default values of the discriminants, and those values
15622 cannot be modified by full assignment. This is because in the presence of
15623 aliasing all views of the object (which may be manipulated by different tasks,
15624 say) must be consistent, so it is imperative that the object, once created,
15625 remain invariant.
15626
15627 @node Strict Conformance to the Ada Reference Manual
15628 @section Strict Conformance to the Ada Reference Manual
15629
15630 @noindent
15631 The dynamic semantics defined by the Ada Reference Manual impose a set of
15632 run-time checks to be generated. By default, the GNAT compiler will insert many
15633 run-time checks into the compiled code, including most of those required by the
15634 Ada Reference Manual. However, there are three checks that are not enabled
15635 in the default mode for efficiency reasons: arithmetic overflow checking for
15636 integer operations (including division by zero), checks for access before
15637 elaboration on subprogram calls, and stack overflow checking (most operating
15638 systems do not perform this check by default).
15639
15640 Strict conformance to the Ada Reference Manual can be achieved by adding
15641 three compiler options for overflow checking for integer operations
15642 (@option{-gnato}), dynamic checks for access-before-elaboration on subprogram
15643 calls and generic instantiations (@option{-gnatE}), and stack overflow
15644 checking (@option{-fstack-check}).
15645
15646 Note that the result of a floating point arithmetic operation in overflow and
15647 invalid situations, when the @code{Machine_Overflows} attribute of the result
15648 type is @code{False}, is to generate IEEE NaN and infinite values. This is the
15649 case for machines compliant with the IEEE floating-point standard, but on
15650 machines that are not fully compliant with this standard, such as Alpha, the
15651 @option{-mieee} compiler flag must be used for achieving IEEE confirming
15652 behavior (although at the cost of a significant performance penalty), so
15653 infinite and and NaN values are properly generated.
15654
15655
15656 @node Project File Reference
15657 @chapter Project File Reference
15658
15659 @noindent
15660 This chapter describes the syntax and semantics of project files.
15661 Project files specify the options to be used when building a system.
15662 Project files can specify global settings for all tools,
15663 as well as tool-specific settings.
15664 @xref{Examples of Project Files,,, gnat_ugn, @value{EDITION} User's Guide},
15665 for examples of use.
15666
15667 @menu
15668 * Reserved Words::
15669 * Lexical Elements::
15670 * Declarations::
15671 * Empty declarations::
15672 * Typed string declarations::
15673 * Variables::
15674 * Expressions::
15675 * Attributes::
15676 * Project Attributes::
15677 * Attribute References::
15678 * External Values::
15679 * Case Construction::
15680 * Packages::
15681 * Package Renamings::
15682 * Projects::
15683 * Project Extensions::
15684 * Project File Elaboration::
15685 @end menu
15686
15687 @node Reserved Words
15688 @section Reserved Words
15689
15690 @noindent
15691 All Ada reserved words are reserved in project files, and cannot be used
15692 as variable names or project names. In addition, the following are
15693 also reserved in project files:
15694
15695 @itemize
15696 @item @code{extends}
15697
15698 @item @code{external}
15699
15700 @item @code{project}
15701
15702 @end itemize
15703
15704 @node Lexical Elements
15705 @section Lexical Elements
15706
15707 @noindent
15708 Rules for identifiers are the same as in Ada. Identifiers
15709 are case-insensitive.  Strings are case sensitive, except where noted.
15710 Comments have the same form as in Ada.
15711
15712 @noindent
15713 Syntax:
15714
15715 @smallexample
15716 simple_name ::=
15717   identifier
15718
15719 name ::=
15720   simple_name @{. simple_name@}
15721 @end smallexample
15722
15723 @node Declarations
15724 @section Declarations
15725
15726 @noindent
15727 Declarations introduce new entities that denote types, variables, attributes,
15728 and packages. Some declarations can only appear immediately within a project
15729 declaration. Others can appear within a project or within a package.
15730
15731 Syntax:
15732 @smallexample
15733 declarative_item ::=
15734   simple_declarative_item |
15735   typed_string_declaration |
15736   package_declaration
15737
15738 simple_declarative_item ::=
15739   variable_declaration |
15740   typed_variable_declaration |
15741   attribute_declaration |
15742   case_construction |
15743   empty_declaration
15744 @end smallexample
15745
15746 @node Empty declarations
15747 @section Empty declarations
15748
15749 @smallexample
15750 empty_declaration ::=
15751   @b{null} ;
15752 @end smallexample
15753
15754 An empty declaration is allowed anywhere a declaration is allowed.
15755 It has no effect.
15756
15757 @node Typed string declarations
15758 @section Typed string declarations
15759
15760 @noindent
15761 Typed strings are sequences of string literals. Typed strings are the only
15762 named types in project files. They are used in case constructions, where they
15763 provide support for conditional attribute definitions.
15764
15765 Syntax:
15766 @smallexample
15767 typed_string_declaration ::=
15768   @b{type} <typed_string_>_simple_name @b{is}
15769    ( string_literal @{, string_literal@} );
15770 @end smallexample
15771
15772 @noindent
15773 A typed string declaration can only appear immediately within a project
15774 declaration.
15775
15776 All the string literals in a typed string declaration must be distinct.
15777
15778 @node Variables
15779 @section Variables
15780
15781 @noindent
15782 Variables denote values, and appear as constituents of expressions.
15783
15784 @smallexample
15785 typed_variable_declaration ::=
15786   <typed_variable_>simple_name : <typed_string_>name :=  string_expression ;
15787
15788 variable_declaration ::=
15789   <variable_>simple_name := expression;
15790 @end smallexample
15791
15792 @noindent
15793 The elaboration of a variable declaration introduces the variable and
15794 assigns to it the value of the expression. The name of the variable is
15795 available after the assignment symbol.
15796
15797 @noindent
15798 A typed_variable can only be declare once.
15799
15800 @noindent
15801 a non-typed variable can be declared multiple times.
15802
15803 @noindent
15804 Before the completion of its first declaration, the value of variable
15805 is the null string.
15806
15807 @node Expressions
15808 @section Expressions
15809
15810 @noindent
15811 An expression is a formula that defines a computation or retrieval of a value.
15812 In a project file the value of an expression is either a string or a list
15813 of strings. A string value in an expression is either a literal, the current
15814 value of a variable, an external value, an attribute reference, or a
15815 concatenation operation.
15816
15817 Syntax:
15818
15819 @smallexample
15820 expression ::=
15821   term @{& term@}
15822
15823 term ::=
15824   string_literal |
15825   string_list |
15826   <variable_>name |
15827   external_value |
15828   attribute_reference
15829
15830 string_literal ::=
15831   (same as Ada)
15832
15833 string_list ::=
15834   ( <string_>expression @{ , <string_>expression @} )
15835 @end smallexample
15836
15837 @subsection Concatenation
15838 @noindent
15839 The following concatenation functions are defined:
15840
15841 @smallexample @c ada
15842   function "&" (X : String;      Y : String)      return String;
15843   function "&" (X : String_List; Y : String)      return String_List;
15844   function "&" (X : String_List; Y : String_List) return String_List;
15845 @end smallexample
15846
15847 @node Attributes
15848 @section Attributes
15849
15850 @noindent
15851 An attribute declaration defines a property of a project or package. This
15852 property can later be queried by means of an attribute reference.
15853 Attribute values are strings or string lists.
15854
15855 Some attributes are associative arrays. These attributes are mappings whose
15856 domain is a set of strings. These attributes are declared one association
15857 at a time, by specifying a point in the domain and the corresponding image
15858 of the attribute. They may also be declared as a full associative array,
15859 getting the same associations as the corresponding attribute in an imported
15860 or extended project.
15861
15862 Attributes that are not associative arrays are called simple attributes.
15863
15864 Syntax:
15865 @smallexample
15866 attribute_declaration ::=
15867   full_associative_array_declaration |
15868   @b{for} attribute_designator @b{use} expression ;
15869
15870 full_associative_array_declaration ::=
15871   @b{for} <associative_array_attribute_>simple_name @b{use}
15872   <project_>simple_name [ . <package_>simple_Name ] ' <attribute_>simple_name ;
15873
15874 attribute_designator ::=
15875   <simple_attribute_>simple_name |
15876   <associative_array_attribute_>simple_name ( string_literal )
15877 @end smallexample
15878
15879 @noindent
15880 Some attributes are project-specific, and can only appear immediately within
15881 a project declaration. Others are package-specific, and can only appear within
15882 the proper package.
15883
15884 The expression in an attribute definition must be a string or a string_list.
15885 The string literal appearing in the attribute_designator of an associative
15886 array attribute is case-insensitive.
15887
15888 @node Project Attributes
15889 @section Project Attributes
15890
15891 @noindent
15892 The following attributes apply to a project. All of them are simple
15893 attributes.
15894
15895 @table @code
15896 @item   Object_Dir
15897 Expression must be a path name. The attribute defines the
15898 directory in which the object files created by the build are to be placed. If
15899 not specified, object files are placed in the project directory.
15900
15901 @item   Exec_Dir
15902 Expression must be a path name. The attribute defines the
15903 directory in which the executables created by the build are to be placed.
15904 If not specified, executables are placed in the object directory.
15905
15906 @item  Source_Dirs
15907 Expression must be a list of path names. The attribute
15908 defines the directories in which the source files for the project are to be
15909 found. If not specified, source files are found in the project directory.
15910 If a string in the list ends with "/**", then the directory that precedes
15911 "/**" and all of its subdirectories (recursively) are included in the list
15912 of source directories.
15913
15914 @item  Excluded_Source_Dirs
15915 Expression must be a list of strings. Each entry designates a directory that
15916 is not to be included in the list of source directories of the project.
15917 This is normally used when there are strings ending with "/**" in the value
15918 of attribute Source_Dirs.
15919
15920 @item  Source_Files
15921 Expression must be a list of file names. The attribute
15922 defines the individual files, in the project directory, which are to be used
15923 as sources for the project. File names are path_names that contain no directory
15924 information. If the project has no sources the attribute must be declared
15925 explicitly with an empty list.
15926
15927 @item  Excluded_Source_Files (Locally_Removed_Files)
15928 Expression must be a list of strings that are legal file names.
15929 Each file name must designate a source that would normally be a source file
15930 in the source directories of the project or, if the project file is an
15931 extending project file, inherited by the current project file. It cannot
15932 designate an immediate source that is not inherited. Each of the source files
15933 in the list are not considered to be sources of the project file: they are not
15934 inherited. Attribute Locally_Removed_Files is obsolescent, attribute
15935 Excluded_Source_Files is preferred.
15936
15937 @item  Source_List_File
15938 Expression must a single path name. The attribute
15939 defines a text file that contains a list of source file names to be used
15940 as sources for the project
15941
15942 @item  Library_Dir
15943 Expression must be a path name. The attribute defines the
15944 directory in which a  library is to be built.  The directory must exist, must
15945 be distinct from the project's object directory, and must be writable.
15946
15947 @item  Library_Name
15948 Expression must be a string that is a legal file name,
15949 without extension. The attribute defines a string that is used to generate
15950 the name of the library to be built by the project.
15951
15952 @item  Library_Kind
15953 Argument must be a string value that must be one of the
15954 following @code{"static"}, @code{"dynamic"} or @code{"relocatable"}. This
15955 string is case-insensitive. If this attribute is not specified, the library is
15956 a static library. Otherwise, the library may be dynamic or relocatable. This
15957 distinction is operating-system dependent.
15958
15959 @item  Library_Version
15960 Expression must be a string value whose interpretation
15961 is platform dependent. On UNIX, it is used only for dynamic/relocatable
15962 libraries as the internal name of the library (the @code{"soname"}). If the
15963 library file name (built from the @code{Library_Name}) is different from the
15964 @code{Library_Version}, then the library file will be a symbolic link to the
15965 actual file whose name will be @code{Library_Version}.
15966
15967 @item Library_Interface
15968 Expression must be a string list. Each element of the string list
15969 must designate a unit of the project.
15970 If this attribute is present in a Library Project File, then the project
15971 file is a Stand-alone Library_Project_File.
15972
15973 @item Library_Auto_Init
15974 Expression must be a single string "true" or "false", case-insensitive.
15975 If this attribute is present in a Stand-alone Library Project File,
15976 it indicates if initialization is automatic when the dynamic library
15977 is loaded.
15978
15979 @item Library_Options
15980 Expression must be a string list. Indicates additional switches that
15981 are to be used when building a shared library.
15982
15983 @item Library_GCC
15984 Expression must be a single string. Designates an alternative to "gcc"
15985 for building shared libraries.
15986
15987 @item  Library_Src_Dir
15988 Expression must be a path name. The attribute defines the
15989 directory in which the sources of the interfaces of a Stand-alone Library will
15990 be copied.  The directory must exist, must be distinct from the project's
15991 object directory and source directories of all projects in the project tree,
15992 and must be writable.
15993
15994 @item  Library_Src_Dir
15995 Expression must be a path name. The attribute defines the
15996 directory in which the ALI files of a Library will
15997 be copied.  The directory must exist, must be distinct from the project's
15998 object directory and source directories of all projects in the project tree,
15999 and must be writable.
16000
16001 @item  Library_Symbol_File
16002 Expression must be a single string. Its value is the single file name of a
16003 symbol file to be created when building a stand-alone library when the
16004 symbol policy is either "compliant", "controlled" or "restricted",
16005 on platforms that support symbol control, such as VMS. When symbol policy
16006 is "direct", then a file with this name must exist in the object directory.
16007
16008 @item   Library_Reference_Symbol_File
16009 Expression must be a single string. Its value is the path name of a
16010 reference symbol file that is read when the symbol policy is either
16011 "compliant" or "controlled", on platforms that support symbol control,
16012 such as VMS, when building a stand-alone library. The path may be an absolute
16013 path or a path relative to the project directory.
16014
16015 @item  Library_Symbol_Policy
16016 Expression must be a single string. Its case-insensitive value can only be
16017 "autonomous", "default", "compliant", "controlled", "restricted" or "direct".
16018
16019 This attribute is not taken into account on all platforms. It controls the
16020 policy for exported symbols and, on some platforms (like VMS) that have the
16021 notions of major and minor IDs built in the library files, it controls
16022 the setting of these IDs.
16023
16024 "autonomous" or "default": exported symbols are not controlled.
16025
16026 "compliant": if attribute Library_Reference_Symbol_File is not defined, then
16027 it is equivalent to policy "autonomous". If there are exported symbols in
16028 the reference symbol file that are not in the object files of the interfaces,
16029 the major ID of the library is increased. If there are symbols in the
16030 object files of the interfaces that are not in the reference symbol file,
16031 these symbols are put at the end of the list in the newly created symbol file
16032 and the minor ID is increased.
16033
16034 "controlled": the attribute Library_Reference_Symbol_File must be defined.
16035 The library will fail to build if the exported symbols in the object files of
16036 the interfaces do not match exactly the symbol in the symbol file.
16037
16038 "restricted": The attribute Library_Symbol_File must be defined. The library
16039 will fail to build if there are symbols in the symbol file that are not in
16040 the exported symbols of the object files of the interfaces. Additional symbols
16041 in the object files are not added to the symbol file.
16042
16043 "direct": The attribute Library_Symbol_File must be defined and must designate
16044 an existing file in the object directory. This symbol file is passed directly
16045 to the underlying linker without any symbol processing.
16046
16047 @item  Main
16048 Expression must be a list of strings that are legal file names.
16049 These file names designate existing compilation units in the source directory
16050 that are legal main subprograms.
16051
16052 When a project file is elaborated, as part of the execution of a gnatmake
16053 command, one or several executables are built and placed in the Exec_Dir.
16054 If the gnatmake command does not include explicit file names, the executables
16055 that are built correspond to the files specified by this attribute.
16056
16057 @item  Externally_Built
16058 Expression must be a single string. Its value must be either "true" of "false",
16059 case-insensitive. The default is "false". When the value of this attribute is
16060 "true", no attempt is made to compile the sources or to build the library,
16061 when the project is a library project.
16062
16063 @item Main_Language
16064 This is a simple attribute. Its value is a string that specifies the
16065 language of the main program.
16066
16067 @item  Languages
16068 Expression must be a string list. Each string designates
16069 a programming language that is known to GNAT. The strings are case-insensitive.
16070
16071 @end table
16072
16073 @node Attribute References
16074 @section Attribute References
16075
16076 @noindent
16077 Attribute references are used to retrieve the value of previously defined
16078 attribute for a package or project.
16079 Syntax:
16080 @smallexample
16081 attribute_reference ::=
16082   attribute_prefix ' <simple_attribute_>simple_name [ ( string_literal ) ]
16083
16084 attribute_prefix ::=
16085   @b{project} |
16086   <project_simple_name | package_identifier |
16087   <project_>simple_name . package_identifier
16088 @end smallexample
16089
16090 @noindent
16091 If an attribute has not been specified for a given package or project, its
16092 value is the null string or the empty list.
16093
16094 @node External Values
16095 @section External Values
16096
16097 @noindent
16098 An external value is an expression whose value is obtained from the command
16099 that invoked the processing of the current project file (typically a
16100 gnatmake command).
16101
16102 Syntax:
16103 @smallexample
16104 external_value ::=
16105   @b{external} ( string_literal [, string_literal] )
16106 @end smallexample
16107
16108 @noindent
16109 The first string_literal is the string to be used on the command line or
16110 in the environment to specify the external value. The second string_literal,
16111 if present, is the default to use if there is no specification for this
16112 external value either on the command line or in the environment.
16113
16114 @node Case Construction
16115 @section Case Construction
16116
16117 @noindent
16118 A case construction supports attribute and variable declarations that depend
16119 on the value of a previously declared variable.
16120
16121 Syntax:
16122 @smallexample
16123 case_construction ::=
16124   @b{case} <typed_variable_>name @b{is}
16125     @{case_item@}
16126   @b{end case} ;
16127
16128 case_item ::=
16129   @b{when} discrete_choice_list =>
16130     @{case_construction |
16131       attribute_declaration |
16132       variable_declaration |
16133       empty_declaration@}
16134
16135 discrete_choice_list ::=
16136   string_literal @{| string_literal@} |
16137     @b{others}
16138 @end smallexample
16139
16140 @noindent
16141 Inside a case construction, variable declarations must be for variables that
16142 have already been declared before the case construction.
16143
16144 All choices in a choice list must be distinct. The choice lists of two
16145 distinct alternatives must be disjoint. Unlike Ada, the choice lists of all
16146 alternatives do not need to include all values of the type. An @code{others}
16147 choice must appear last in the list of alternatives.
16148
16149 @node Packages
16150 @section Packages
16151
16152 @noindent
16153 A package provides a grouping of variable declarations and attribute
16154 declarations to be used when invoking various GNAT tools. The name of
16155 the package indicates the tool(s) to which it applies.
16156 Syntax:
16157
16158 @smallexample
16159 package_declaration ::=
16160   package_spec | package_renaming
16161
16162 package_spec ::=
16163   @b{package} package_identifier @b{is}
16164     @{simple_declarative_item@}
16165   @b{end} package_identifier ;
16166
16167 package_identifier ::=
16168   @code{Naming} | @code{Builder} | @code{Compiler} | @code{Binder} |
16169   @code{Linker} | @code{Finder}  | @code{Cross_Reference} |
16170   @code{gnatls} | @code{IDE}     | @code{Pretty_Printer}
16171 @end smallexample
16172
16173 @subsection Package Naming
16174
16175 @noindent
16176 The attributes of a @code{Naming} package specifies the naming conventions
16177 that apply to the source files in a project. When invoking other GNAT tools,
16178 they will use the sources in the source directories that satisfy these
16179 naming conventions.
16180
16181 The following attributes apply to a @code{Naming} package:
16182
16183 @table @code
16184 @item Casing
16185 This is a simple attribute whose value is a string. Legal values of this
16186 string are @code{"lowercase"}, @code{"uppercase"} or @code{"mixedcase"}.
16187 These strings are themselves case insensitive.
16188
16189 @noindent
16190 If @code{Casing} is not specified, then the default is @code{"lowercase"}.
16191
16192 @item Dot_Replacement
16193 This is a simple attribute whose string value satisfies the following
16194 requirements:
16195
16196 @itemize @bullet
16197 @item It must not be empty
16198 @item It cannot start or end with an alphanumeric character
16199 @item It cannot be a single underscore
16200 @item It cannot start with an underscore followed by an alphanumeric
16201 @item It cannot contain a dot @code{'.'} if longer than one character
16202 @end itemize
16203
16204 @noindent
16205 If @code{Dot_Replacement} is not specified, then the default is @code{"-"}.
16206
16207 @item Spec_Suffix
16208 This is an associative array attribute, defined on language names,
16209 whose image is a string that must satisfy the following
16210 conditions:
16211
16212 @itemize @bullet
16213 @item It must not be empty
16214 @item It cannot start with an alphanumeric character
16215 @item It cannot start with an underscore followed by an alphanumeric character
16216 @end itemize
16217
16218 @noindent
16219 For Ada, the attribute denotes the suffix used in file names that contain
16220 library unit declarations, that is to say units that are package and
16221 subprogram declarations. If @code{Spec_Suffix ("Ada")} is not
16222 specified, then the default is @code{".ads"}.
16223
16224 For C and C++, the attribute denotes the suffix used in file names that
16225 contain prototypes.
16226
16227 @item Body_Suffix
16228 This is an associative array attribute defined on language names,
16229 whose image is a string that must satisfy the following
16230 conditions:
16231
16232 @itemize @bullet
16233 @item It must not be empty
16234 @item It cannot start with an alphanumeric character
16235 @item It cannot start with an underscore followed by an alphanumeric character
16236 @item It cannot be a suffix of @code{Spec_Suffix}
16237 @end itemize
16238
16239 @noindent
16240 For Ada, the attribute denotes the suffix used in file names that contain
16241 library bodies, that is to say units that are package and subprogram bodies.
16242 If @code{Body_Suffix ("Ada")} is not specified, then the default is
16243 @code{".adb"}.
16244
16245 For C and C++, the attribute denotes the suffix used in file names that contain
16246 source code.
16247
16248 @item Separate_Suffix
16249 This is a simple attribute whose value satisfies the same conditions as
16250 @code{Body_Suffix}.
16251
16252 This attribute is specific to Ada. It denotes the suffix used in file names
16253 that contain separate bodies. If it is not specified, then it defaults to same
16254 value as @code{Body_Suffix ("Ada")}.
16255
16256 @item Spec
16257 This is an associative array attribute, specific to Ada, defined over
16258 compilation unit names. The image is a string that is the name of the file
16259 that contains that library unit. The file name is case sensitive if the
16260 conventions of the host operating system require it.
16261
16262 @item Body
16263 This is an associative array attribute, specific to Ada, defined over
16264 compilation unit names. The image is a string that is the name of the file
16265 that contains the library unit body for the named unit. The file name is case
16266 sensitive if the conventions of the host operating system require it.
16267
16268 @item Specification_Exceptions
16269 This is an associative array attribute defined on language names,
16270 whose value is a list of strings.
16271
16272 This attribute is not significant for Ada.
16273
16274 For C and C++, each string in the list denotes the name of a file that
16275 contains prototypes, but whose suffix is not necessarily the
16276 @code{Spec_Suffix} for the language.
16277
16278 @item Implementation_Exceptions
16279 This is an associative array attribute defined on language names,
16280 whose value is a list of strings.
16281
16282 This attribute is not significant for Ada.
16283
16284 For C and C++, each string in the list denotes the name of a file that
16285 contains source code, but whose suffix is not necessarily the
16286 @code{Body_Suffix} for the language.
16287 @end table
16288
16289 The following attributes of package @code{Naming} are obsolescent. They are
16290 kept as synonyms of other attributes for compatibility with previous versions
16291 of the Project Manager.
16292
16293 @table @code
16294 @item Specification_Suffix
16295 This is a synonym of @code{Spec_Suffix}.
16296
16297 @item Implementation_Suffix
16298 This is a synonym of @code{Body_Suffix}.
16299
16300 @item Specification
16301 This is a synonym of @code{Spec}.
16302
16303 @item Implementation
16304 This is a synonym of @code{Body}.
16305 @end table
16306
16307 @subsection package Compiler
16308
16309 @noindent
16310 The attributes of the @code{Compiler} package specify the compilation options
16311 to be used by the underlying compiler.
16312
16313 @table @code
16314 @item  Default_Switches
16315 This is an associative array attribute. Its
16316 domain is a set of language names. Its range is a string list that
16317 specifies the compilation options to be used when compiling a component
16318 written in that language, for which no file-specific switches have been
16319 specified.
16320
16321 @item  Switches
16322 This is an associative array attribute. Its domain is
16323 a set of file names. Its range is a string list that specifies the
16324 compilation options to be used when compiling the named file. If a file
16325 is not specified in the Switches attribute, it is compiled with the
16326 options specified by Default_Switches of its language, if defined.
16327
16328 @item  Local_Configuration_Pragmas.
16329 This is a simple attribute, whose
16330 value is a path name that designates a file containing configuration pragmas
16331 to be used for all invocations of the compiler for immediate sources of the
16332 project.
16333 @end table
16334
16335 @subsection package Builder
16336
16337 @noindent
16338 The attributes of package @code{Builder} specify the compilation, binding, and
16339 linking options to be used when building an executable for a project. The
16340 following attributes apply to package @code{Builder}:
16341
16342 @table @code
16343 @item Default_Switches
16344 This is an associative array attribute. Its
16345 domain is a set of language names. Its range is a string list that
16346 specifies options to be used when building a main
16347 written in that language, for which no file-specific switches have been
16348 specified.
16349
16350 @item Switches
16351 This is an associative array attribute. Its domain is
16352 a set of file names. Its range is a string list that specifies
16353 options to be used when building the named main file. If a main file
16354 is not specified in the Switches attribute, it is built with the
16355 options specified by Default_Switches of its language, if defined.
16356
16357 @item Global_Configuration_Pragmas
16358 This is a simple attribute, whose
16359 value is a path name that designates a file that contains configuration pragmas
16360 to be used in every build of an executable. If both local and global
16361 configuration pragmas are specified, a compilation makes use of both sets.
16362
16363
16364 @item Executable
16365 This is an associative array attribute. Its domain is
16366 a set of main source file names. Its range is a simple string that specifies
16367 the executable file name to be used when linking the specified main source.
16368 If a main source is not specified in the Executable attribute, the executable
16369 file name is deducted from the main source file name.
16370 This attribute has no effect if its value is the empty string.
16371
16372 @item Executable_Suffix
16373 This is a simple attribute whose value is the suffix to be added to
16374 the executables that don't have an attribute Executable specified.
16375 @end table
16376
16377 @subsection package Gnatls
16378
16379 @noindent
16380 The attributes of package @code{Gnatls} specify the tool options to be used
16381 when invoking the library browser @command{gnatls}.
16382 The following attributes apply to package @code{Gnatls}:
16383
16384 @table @code
16385 @item Switches
16386 This is a single attribute with a string list value. Each nonempty string
16387 in the list is an option when invoking @code{gnatls}.
16388 @end table
16389
16390 @subsection package Binder
16391
16392 @noindent
16393 The attributes of package @code{Binder} specify the options to be used
16394 when invoking the binder in the construction of an executable.
16395 The following attributes apply to package @code{Binder}:
16396
16397 @table @code
16398 @item     Default_Switches
16399 This is an associative array attribute. Its
16400 domain is a set of language names. Its range is a string list that
16401 specifies options to be used when binding a main
16402 written in that language, for which no file-specific switches have been
16403 specified.
16404
16405 @item Switches
16406 This is an associative array attribute. Its domain is
16407 a set of file names. Its range is a string list that specifies
16408 options to be used when binding the named main file. If a main file
16409 is not specified in the Switches attribute, it is bound with the
16410 options specified by Default_Switches of its language, if defined.
16411 @end table
16412
16413 @subsection package Linker
16414
16415 @noindent
16416 The attributes of package @code{Linker} specify the options to be used when
16417 invoking the linker in the construction of an executable.
16418 The following attributes apply to package @code{Linker}:
16419
16420 @table @code
16421 @item     Default_Switches
16422 This is an associative array attribute. Its
16423 domain is a set of language names. Its range is a string list that
16424 specifies options to be used when linking a main
16425 written in that language, for which no file-specific switches have been
16426 specified.
16427
16428 @item Switches
16429 This is an associative array attribute. Its domain is
16430 a set of file names. Its range is a string list that specifies
16431 options to be used when linking the named main file. If a main file
16432 is not specified in the Switches attribute, it is linked with the
16433 options specified by Default_Switches of its language, if defined.
16434
16435 @item  Linker_Options
16436 This is a string list attribute. Its value specifies additional options that
16437 be given to the linker when linking an executable. This attribute is not
16438 used in the main project, only in projects imported directly or indirectly.
16439
16440 @end table
16441
16442 @subsection package Cross_Reference
16443
16444 @noindent
16445 The attributes of package @code{Cross_Reference} specify the tool options
16446 to be used
16447 when invoking the library tool @command{gnatxref}.
16448 The following attributes apply to package @code{Cross_Reference}:
16449
16450 @table @code
16451 @item     Default_Switches
16452 This is an associative array attribute. Its
16453 domain is a set of language names. Its range is a string list that
16454 specifies options to be used when calling @command{gnatxref} on a source
16455 written in that language, for which no file-specific switches have been
16456 specified.
16457
16458 @item Switches
16459 This is an associative array attribute. Its domain is
16460 a set of file names. Its range is a string list that specifies
16461 options to be used when calling @command{gnatxref} on the named main source.
16462 If a source is not specified in the Switches attribute, @command{gnatxref} will
16463 be called with the options specified by Default_Switches of its language,
16464 if defined.
16465 @end table
16466
16467 @subsection package   Finder
16468
16469 @noindent
16470 The attributes of package @code{Finder} specify the tool options to be used
16471 when invoking the search tool @command{gnatfind}.
16472 The following attributes apply to package @code{Finder}:
16473
16474 @table @code
16475 @item     Default_Switches
16476 This is an associative array attribute. Its
16477 domain is a set of language names. Its range is a string list that
16478 specifies options to be used when calling @command{gnatfind} on a source
16479 written in that language, for which no file-specific switches have been
16480 specified.
16481
16482 @item Switches
16483 This is an associative array attribute. Its domain is
16484 a set of file names. Its range is a string list that specifies
16485 options to be used when calling @command{gnatfind} on the named main source.
16486 If a source is not specified in the Switches attribute, @command{gnatfind} will
16487 be called with the options specified by Default_Switches of its language,
16488 if defined.
16489 @end table
16490
16491 @subsection package Pretty_Printer
16492
16493 @noindent
16494 The attributes of package @code{Pretty_Printer}
16495 specify the tool options to be used
16496 when invoking the formatting tool @command{gnatpp}.
16497 The following attributes apply to package @code{Pretty_Printer}:
16498
16499 @table @code
16500 @item     Default_switches
16501 This is an associative array attribute. Its
16502 domain is a set of language names. Its range is a string list that
16503 specifies options to be used when calling @command{gnatpp} on a source
16504 written in that language, for which no file-specific switches have been
16505 specified.
16506
16507 @item Switches
16508 This is an associative array attribute. Its domain is
16509 a set of file names. Its range is a string list that specifies
16510 options to be used when calling @command{gnatpp} on the named main source.
16511 If a source is not specified in the Switches attribute, @command{gnatpp} will
16512 be called with the options specified by Default_Switches of its language,
16513 if defined.
16514 @end table
16515
16516 @subsection package gnatstub
16517
16518 @noindent
16519 The attributes of package @code{gnatstub}
16520 specify the tool options to be used
16521 when invoking the tool @command{gnatstub}.
16522 The following attributes apply to package @code{gnatstub}:
16523
16524 @table @code
16525 @item     Default_switches
16526 This is an associative array attribute. Its
16527 domain is a set of language names. Its range is a string list that
16528 specifies options to be used when calling @command{gnatstub} on a source
16529 written in that language, for which no file-specific switches have been
16530 specified.
16531
16532 @item Switches
16533 This is an associative array attribute. Its domain is
16534 a set of file names. Its range is a string list that specifies
16535 options to be used when calling @command{gnatstub} on the named main source.
16536 If a source is not specified in the Switches attribute, @command{gnatpp} will
16537 be called with the options specified by Default_Switches of its language,
16538 if defined.
16539 @end table
16540
16541 @subsection package Eliminate
16542
16543 @noindent
16544 The attributes of package @code{Eliminate}
16545 specify the tool options to be used
16546 when invoking the tool @command{gnatelim}.
16547 The following attributes apply to package @code{Eliminate}:
16548
16549 @table @code
16550 @item     Default_switches
16551 This is an associative array attribute. Its
16552 domain is a set of language names. Its range is a string list that
16553 specifies options to be used when calling @command{gnatelim} on a source
16554 written in that language, for which no file-specific switches have been
16555 specified.
16556
16557 @item Switches
16558 This is an associative array attribute. Its domain is
16559 a set of file names. Its range is a string list that specifies
16560 options to be used when calling @command{gnatelim} on the named main source.
16561 If a source is not specified in the Switches attribute, @command{gnatelim} will
16562 be called with the options specified by Default_Switches of its language,
16563 if defined.
16564 @end table
16565
16566 @subsection package Metrics
16567
16568 @noindent
16569 The attributes of package @code{Metrics}
16570 specify the tool options to be used
16571 when invoking the tool @command{gnatmetric}.
16572 The following attributes apply to package @code{Metrics}:
16573
16574 @table @code
16575 @item     Default_switches
16576 This is an associative array attribute. Its
16577 domain is a set of language names. Its range is a string list that
16578 specifies options to be used when calling @command{gnatmetric} on a source
16579 written in that language, for which no file-specific switches have been
16580 specified.
16581
16582 @item Switches
16583 This is an associative array attribute. Its domain is
16584 a set of file names. Its range is a string list that specifies
16585 options to be used when calling @command{gnatmetric} on the named main source.
16586 If a source is not specified in the Switches attribute, @command{gnatmetric}
16587 will be called with the options specified by Default_Switches of its language,
16588 if defined.
16589 @end table
16590
16591 @subsection  package IDE
16592
16593 @noindent
16594 The attributes of package @code{IDE} specify the options to be used when using
16595 an Integrated Development Environment such as @command{GPS}.
16596
16597 @table @code
16598 @item Remote_Host
16599 This is a simple attribute. Its value is a string that designates the remote
16600 host in a cross-compilation environment, to be used for remote compilation and
16601 debugging. This field should not be specified when running on the local
16602 machine.
16603
16604 @item Program_Host
16605 This is a simple attribute. Its value is a string that specifies the
16606 name of IP address of the embedded target in a cross-compilation environment,
16607 on which the program should execute.
16608
16609 @item Communication_Protocol
16610 This is a simple string attribute. Its value is the name of the protocol
16611 to use to communicate with the target in a cross-compilation environment,
16612 e.g.@: @code{"wtx"} or @code{"vxworks"}.
16613
16614 @item Compiler_Command
16615 This is an associative array attribute, whose domain is a language name. Its
16616 value is  string that denotes the command to be used to invoke the compiler.
16617 The value of @code{Compiler_Command ("Ada")} is expected to be compatible with
16618 gnatmake, in particular in the handling of switches.
16619
16620 @item Debugger_Command
16621 This is simple attribute, Its value is a string that specifies the name of
16622 the debugger to be used, such as gdb, powerpc-wrs-vxworks-gdb or gdb-4.
16623
16624 @item Default_Switches
16625 This is an associative array attribute. Its indexes are the name of the
16626 external tools that the GNAT Programming System (GPS) is supporting. Its
16627 value is a list of switches to use when invoking that tool.
16628
16629 @item  Gnatlist
16630 This is a simple attribute.  Its value is a string that specifies the name
16631 of the @command{gnatls} utility to be used to retrieve information about the
16632 predefined path; e.g., @code{"gnatls"}, @code{"powerpc-wrs-vxworks-gnatls"}.
16633
16634 @item VCS_Kind
16635 This is a simple attribute. Its value is a string used to specify the
16636 Version Control System (VCS) to be used for this project, e.g.@: CVS, RCS
16637 ClearCase or Perforce.
16638
16639 @item VCS_File_Check
16640 This is a simple attribute. Its value is a string that specifies the
16641 command used by the VCS to check the validity of a file, either
16642 when the user explicitly asks for a check, or as a sanity check before
16643 doing the check-in.
16644
16645 @item VCS_Log_Check
16646 This is a simple attribute. Its value is a string that specifies
16647 the command used by the VCS to check the validity of a log file.
16648
16649 @item VCS_Repository_Root
16650 The VCS repository root path. This is used to create tags or branches
16651 of the repository. For subversion the value should be the @code{URL}
16652 as specified to check-out the working copy of the repository.
16653
16654 @item VCS_Patch_Root
16655 The local root directory to use for building patch file. All patch chunks
16656 will be relative to this path. The root project directory is used if
16657 this value is not defined.
16658
16659 @end table
16660
16661 @node Package Renamings
16662 @section Package Renamings
16663
16664 @noindent
16665 A package can be defined by a renaming declaration. The new package renames
16666 a package declared in a different project file, and has the same attributes
16667 as the package it renames.
16668 Syntax:
16669 @smallexample
16670 package_renaming ::==
16671   @b{package} package_identifier @b{renames}
16672        <project_>simple_name.package_identifier ;
16673 @end smallexample
16674
16675 @noindent
16676 The package_identifier of the renamed package must be the same as the
16677 package_identifier. The project whose name is the prefix of the renamed
16678 package must contain a package declaration with this name. This project
16679 must appear in the context_clause of the enclosing project declaration,
16680 or be the parent project of the enclosing child project.
16681
16682 @node Projects
16683 @section Projects
16684
16685 @noindent
16686 A project file specifies a set of rules for constructing a software system.
16687 A project file can be self-contained, or depend on other project files.
16688 Dependencies are expressed through a context clause that names other projects.
16689
16690 Syntax:
16691
16692 @smallexample
16693 project ::=
16694   context_clause project_declaration
16695
16696 project_declaration ::=
16697   simple_project_declaration | project_extension
16698
16699 simple_project_declaration ::=
16700   @b{project} <project_>simple_name @b{is}
16701     @{declarative_item@}
16702   @b{end} <project_>simple_name;
16703
16704 context_clause ::=
16705   @{with_clause@}
16706
16707 with_clause ::=
16708   [@b{limited}] @b{with} path_name @{ , path_name @} ;
16709
16710 path_name ::=
16711    string_literal
16712 @end smallexample
16713
16714 @noindent
16715 A path name denotes a project file. A path name can be absolute or relative.
16716 An absolute path name includes a sequence of directories, in the syntax of
16717 the host operating system, that identifies uniquely the project file in the
16718 file system. A relative path name identifies the project file, relative
16719 to the directory that contains the current project, or relative to a
16720 directory listed in the environment variable ADA_PROJECT_PATH.
16721 Path names are case sensitive if file names in the host operating system
16722 are case sensitive.
16723
16724 The syntax of the environment variable ADA_PROJECT_PATH is a list of
16725 directory names separated by colons (semicolons on Windows).
16726
16727 A given project name can appear only once in a context_clause.
16728
16729 It is illegal for a project imported by a context clause to refer, directly
16730 or indirectly, to the project in which this context clause appears (the
16731 dependency graph cannot contain cycles), except when one of the with_clause
16732 in the cycle is a @code{limited with}.
16733
16734 @node Project Extensions
16735 @section Project Extensions
16736
16737 @noindent
16738 A project extension introduces a new project, which inherits the declarations
16739 of another project.
16740 Syntax:
16741 @smallexample
16742
16743 project_extension ::=
16744   @b{project} <project_>simple_name  @b{extends} path_name @b{is}
16745     @{declarative_item@}
16746   @b{end} <project_>simple_name;
16747 @end smallexample
16748
16749 @noindent
16750 The project extension declares a child project. The child project inherits
16751 all the declarations and all the files of the parent project, These inherited
16752 declaration can be overridden in the child project, by means of suitable
16753 declarations.
16754
16755 @node Project File Elaboration
16756 @section Project File Elaboration
16757
16758 @noindent
16759 A project file is processed as part of the invocation of a gnat tool that
16760 uses the project option. Elaboration of the process file consists in the
16761 sequential elaboration of all its declarations. The computed values of
16762 attributes and variables in the project are then used to establish the
16763 environment in which the gnat tool will execute.
16764
16765 @node Obsolescent Features
16766 @chapter Obsolescent Features
16767
16768 @noindent
16769 This chapter describes features that are provided by GNAT, but are
16770 considered obsolescent since there are preferred ways of achieving
16771 the same effect. These features are provided solely for historical
16772 compatibility purposes.
16773
16774 @menu
16775 * pragma No_Run_Time::
16776 * pragma Ravenscar::
16777 * pragma Restricted_Run_Time::
16778 @end menu
16779
16780 @node pragma No_Run_Time
16781 @section pragma No_Run_Time
16782
16783 The pragma @code{No_Run_Time} is used to achieve an affect similar
16784 to the use of the "Zero Foot Print" configurable run time, but without
16785 requiring a specially configured run time. The result of using this
16786 pragma, which must be used for all units in a partition, is to restrict
16787 the use of any language features requiring run-time support code. The
16788 preferred usage is to use an appropriately configured run-time that
16789 includes just those features that are to be made accessible.
16790
16791 @node pragma Ravenscar
16792 @section pragma Ravenscar
16793
16794 The pragma @code{Ravenscar} has exactly the same effect as pragma
16795 @code{Profile (Ravenscar)}. The latter usage is preferred since it
16796 is part of the new Ada 2005 standard.
16797
16798 @node pragma Restricted_Run_Time
16799 @section pragma Restricted_Run_Time
16800
16801 The pragma @code{Restricted_Run_Time} has exactly the same effect as
16802 pragma @code{Profile (Restricted)}. The latter usage is
16803 preferred since the Ada 2005 pragma @code{Profile} is intended for
16804 this kind of implementation dependent addition.
16805
16806 @include fdl.texi
16807 @c GNU Free Documentation License
16808
16809 @node Index,,GNU Free Documentation License, Top
16810 @unnumbered Index
16811
16812 @printindex cp
16813
16814 @contents
16815
16816 @bye