OSDN Git Service

* gnat_ugn.texi (Conventions): List environment variables and
[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              Copyright (C) 1995-2007, Free Software Foundation             o
12 @c                                                                            o
13 @c                                                                            o
14 @c  GNAT is maintained by Ada Core Technologies Inc (http://www.gnat.com).    o
15 @c                                                                            o
16 @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
17
18 @setfilename gnat_rm.info
19
20 @set EDITION GNAT
21 @set DEFAULTLANGUAGEVERSION Ada 2005
22 @set NONDEFAULTLANGUAGEVERSION Ada 95
23
24 @settitle GNAT Reference Manual
25
26 @setchapternewpage odd
27 @syncodeindex fn cp
28
29 @include gcc-common.texi
30
31 @dircategory GNU Ada tools
32 @direntry
33 * GNAT Reference Manual: (gnat_rm).  Reference Manual for GNU Ada tools.
34 @end direntry
35
36 @copying
37 Copyright @copyright{} 1995-2007, 2008 Free Software Foundation, Inc.
38
39 Permission is granted to copy, distribute and/or modify this document
40 under the terms of the GNU Free Documentation License, Version 1.2
41 or any later version published by the Free Software Foundation;
42 with the Invariant Sections being ``GNU Free Documentation License'',
43 with the Front-Cover Texts being ``GNAT Reference Manual'', and with
44 no Back-Cover Texts. A copy of the license is included in the section
45 entitled ``GNU Free Documentation License''.
46 @end copying
47
48 @titlepage
49 @title GNAT Reference Manual
50 @subtitle GNAT, The GNU Ada Compiler
51 @versionsubtitle
52 @author AdaCore
53 @page
54 @vskip 0pt plus 1filll
55
56 @insertcopying
57
58 @end titlepage
59
60 @ifnottex
61 @node Top, About This Guide, (dir), (dir)
62 @top GNAT Reference Manual
63
64 @noindent
65 GNAT Reference Manual
66
67 @noindent
68 GNAT, The GNU Ada Compiler@*
69 GCC version @value{version-GCC}@*
70
71 @noindent
72 AdaCore
73
74 @menu
75 * About This Guide::
76 * Implementation Defined Pragmas::
77 * Implementation Defined Attributes::
78 * Implementation Advice::
79 * Implementation Defined Characteristics::
80 * Intrinsic Subprograms::
81 * Representation Clauses and Pragmas::
82 * Standard Library Routines::
83 * The Implementation of Standard I/O::
84 * The GNAT Library::
85 * Interfacing to Other Languages::
86 * Specialized Needs Annexes::
87 * Implementation of Specific Ada Features::
88 * Project File Reference::
89 * Obsolescent Features::
90 * GNU Free Documentation License::
91 * Index::
92
93  --- The Detailed Node Listing ---
94
95 About This Guide
96
97 * What This Reference Manual Contains::
98 * Related Information::
99
100 Implementation Defined Pragmas
101
102 * Pragma Abort_Defer::
103 * Pragma Ada_83::
104 * Pragma Ada_95::
105 * Pragma Ada_05::
106 * Pragma Ada_2005::
107 * Pragma Annotate::
108 * Pragma Assert::
109 * Pragma Ast_Entry::
110 * Pragma C_Pass_By_Copy::
111 * Pragma Check_Name::
112 * Pragma Comment::
113 * Pragma Common_Object::
114 * Pragma Compile_Time_Error::
115 * Pragma Compile_Time_Warning::
116 * Pragma Complete_Representation::
117 * Pragma Complex_Representation::
118 * Pragma Component_Alignment::
119 * Pragma Convention_Identifier::
120 * Pragma CPP_Class::
121 * Pragma CPP_Constructor::
122 * Pragma CPP_Virtual::
123 * Pragma CPP_Vtable::
124 * Pragma Debug::
125 * Pragma Debug_Policy::
126 * Pragma Detect_Blocking::
127 * Pragma Elaboration_Checks::
128 * Pragma Eliminate::
129 * Pragma Export_Exception::
130 * Pragma Export_Function::
131 * Pragma Export_Object::
132 * Pragma Export_Procedure::
133 * Pragma Export_Value::
134 * Pragma Export_Valued_Procedure::
135 * Pragma Extend_System::
136 * Pragma External::
137 * Pragma External_Name_Casing::
138 * Pragma Fast_Math::
139 * Pragma Favor_Top_Level::
140 * Pragma Finalize_Storage_Only::
141 * Pragma Float_Representation::
142 * Pragma Ident::
143 * Pragma Implemented_By_Entry::
144 * Pragma Implicit_Packing::
145 * Pragma Import_Exception::
146 * Pragma Import_Function::
147 * Pragma Import_Object::
148 * Pragma Import_Procedure::
149 * Pragma Import_Valued_Procedure::
150 * Pragma Initialize_Scalars::
151 * Pragma Inline_Always::
152 * Pragma Inline_Generic::
153 * Pragma Interface::
154 * Pragma Interface_Name::
155 * Pragma Interrupt_Handler::
156 * Pragma Interrupt_State::
157 * Pragma Keep_Names::
158 * Pragma License::
159 * Pragma Link_With::
160 * Pragma Linker_Alias::
161 * Pragma Linker_Constructor::
162 * Pragma Linker_Destructor::
163 * Pragma Linker_Section::
164 * Pragma Long_Float::
165 * Pragma Machine_Attribute::
166 * Pragma Main::
167 * Pragma Main_Storage::
168 * Pragma No_Body::
169 * Pragma No_Return::
170 * Pragma No_Strict_Aliasing ::
171 * Pragma Normalize_Scalars::
172 * Pragma Obsolescent::
173 * Pragma Passive::
174 * Pragma Persistent_BSS::
175 * Pragma Polling::
176 * Pragma Profile (Ravenscar)::
177 * Pragma Profile (Restricted)::
178 * Pragma Psect_Object::
179 * Pragma Pure_Function::
180 * Pragma Restriction_Warnings::
181 * Pragma Shared::
182 * Pragma Source_File_Name::
183 * Pragma Source_File_Name_Project::
184 * Pragma Source_Reference::
185 * Pragma Stream_Convert::
186 * Pragma Style_Checks::
187 * Pragma Subtitle::
188 * Pragma Suppress::
189 * Pragma Suppress_All::
190 * Pragma Suppress_Exception_Locations::
191 * Pragma Suppress_Initialization::
192 * Pragma Task_Info::
193 * Pragma Task_Name::
194 * Pragma Task_Storage::
195 * Pragma Time_Slice::
196 * Pragma Title::
197 * Pragma Unchecked_Union::
198 * Pragma Unimplemented_Unit::
199 * Pragma Universal_Aliasing ::
200 * Pragma Universal_Data::
201 * Pragma Unreferenced::
202 * Pragma Unreferenced_Objects::
203 * Pragma Unreserve_All_Interrupts::
204 * Pragma Unsuppress::
205 * Pragma Use_VADS_Size::
206 * Pragma Validity_Checks::
207 * Pragma Volatile::
208 * Pragma Warnings::
209 * Pragma Weak_External::
210 * Pragma Wide_Character_Encoding::
211
212 Implementation Defined Attributes
213
214 * Abort_Signal::
215 * Address_Size::
216 * Asm_Input::
217 * Asm_Output::
218 * AST_Entry::
219 * Bit::
220 * Bit_Position::
221 * Code_Address::
222 * Default_Bit_Order::
223 * Elaborated::
224 * Elab_Body::
225 * Elab_Spec::
226 * Emax::
227 * Enabled::
228 * Enum_Rep::
229 * Epsilon::
230 * Fixed_Value::
231 * Has_Access_Values::
232 * Has_Discriminants::
233 * Img::
234 * Integer_Value::
235 * Large::
236 * Machine_Size::
237 * Mantissa::
238 * Max_Interrupt_Priority::
239 * Max_Priority::
240 * Maximum_Alignment::
241 * Mechanism_Code::
242 * Null_Parameter::
243 * Object_Size::
244 * Passed_By_Reference::
245 * Pool_Address::
246 * Range_Length::
247 * Safe_Emax::
248 * Safe_Large::
249 * Small::
250 * Storage_Unit::
251 * Stub_Type::
252 * Target_Name::
253 * Tick::
254 * To_Address::
255 * Type_Class::
256 * UET_Address::
257 * Unconstrained_Array::
258 * Universal_Literal_String::
259 * Unrestricted_Access::
260 * VADS_Size::
261 * Value_Size::
262 * Wchar_T_Size::
263 * Word_Size::
264
265 The Implementation of Standard I/O
266
267 * Standard I/O Packages::
268 * FORM Strings::
269 * Direct_IO::
270 * Sequential_IO::
271 * Text_IO::
272 * Wide_Text_IO::
273 * Wide_Wide_Text_IO::
274 * Stream_IO::
275 * Shared Files::
276 * Filenames encoding::
277 * Open Modes::
278 * Operations on C Streams::
279 * Interfacing to C Streams::
280
281 The GNAT Library
282
283 * Ada.Characters.Latin_9 (a-chlat9.ads)::
284 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
285 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
286 * Ada.Characters.Wide_Wide_Latin_1 (a-czila1.ads)::
287 * Ada.Characters.Wide_Wide_Latin_9 (a-czila9.ads)::
288 * Ada.Command_Line.Remove (a-colire.ads)::
289 * Ada.Command_Line.Environment (a-colien.ads)::
290 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
291 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
292 * Ada.Exceptions.Traceback (a-exctra.ads)::
293 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
294 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
295 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
296 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
297 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
298 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
299 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
300 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
301 * GNAT.Altivec (g-altive.ads)::
302 * GNAT.Altivec.Conversions (g-altcon.ads)::
303 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
304 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
305 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
306 * GNAT.Array_Split (g-arrspl.ads)::
307 * GNAT.AWK (g-awk.ads)::
308 * GNAT.Bounded_Buffers (g-boubuf.ads)::
309 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
310 * GNAT.Bubble_Sort (g-bubsor.ads)::
311 * GNAT.Bubble_Sort_A (g-busora.ads)::
312 * GNAT.Bubble_Sort_G (g-busorg.ads)::
313 * GNAT.Byte_Order_Mark (g-byorma.ads)::
314 * GNAT.Byte_Swapping (g-bytswa.ads)::
315 * GNAT.Calendar (g-calend.ads)::
316 * GNAT.Calendar.Time_IO (g-catiio.ads)::
317 * GNAT.Case_Util (g-casuti.ads)::
318 * GNAT.CGI (g-cgi.ads)::
319 * GNAT.CGI.Cookie (g-cgicoo.ads)::
320 * GNAT.CGI.Debug (g-cgideb.ads)::
321 * GNAT.Command_Line (g-comlin.ads)::
322 * GNAT.Compiler_Version (g-comver.ads)::
323 * GNAT.Ctrl_C (g-ctrl_c.ads)::
324 * GNAT.CRC32 (g-crc32.ads)::
325 * GNAT.Current_Exception (g-curexc.ads)::
326 * GNAT.Debug_Pools (g-debpoo.ads)::
327 * GNAT.Debug_Utilities (g-debuti.ads)::
328 * GNAT.Decode_String (g-decstr.ads)::
329 * GNAT.Decode_UTF8_String (g-deutst.ads)::
330 * GNAT.Directory_Operations (g-dirope.ads)::
331 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
332 * GNAT.Dynamic_HTables (g-dynhta.ads)::
333 * GNAT.Dynamic_Tables (g-dyntab.ads)::
334 * GNAT.Encode_String (g-encstr.ads)::
335 * GNAT.Encode_UTF8_String (g-enutst.ads)::
336 * GNAT.Exception_Actions (g-excact.ads)::
337 * GNAT.Exception_Traces (g-exctra.ads)::
338 * GNAT.Exceptions (g-except.ads)::
339 * GNAT.Expect (g-expect.ads)::
340 * GNAT.Float_Control (g-flocon.ads)::
341 * GNAT.Heap_Sort (g-heasor.ads)::
342 * GNAT.Heap_Sort_A (g-hesora.ads)::
343 * GNAT.Heap_Sort_G (g-hesorg.ads)::
344 * GNAT.HTable (g-htable.ads)::
345 * GNAT.IO (g-io.ads)::
346 * GNAT.IO_Aux (g-io_aux.ads)::
347 * GNAT.Lock_Files (g-locfil.ads)::
348 * GNAT.MD5 (g-md5.ads)::
349 * GNAT.Memory_Dump (g-memdum.ads)::
350 * GNAT.Most_Recent_Exception (g-moreex.ads)::
351 * GNAT.OS_Lib (g-os_lib.ads)::
352 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
353 * GNAT.Random_Numbers (g-rannum.ads)
354 * GNAT.Regexp (g-regexp.ads)::
355 * GNAT.Registry (g-regist.ads)::
356 * GNAT.Regpat (g-regpat.ads)::
357 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
358 * GNAT.Semaphores (g-semaph.ads)::
359 * GNAT.SHA1 (g-sha1.ads)::
360 * GNAT.Signals (g-signal.ads)::
361 * GNAT.Sockets (g-socket.ads)::
362 * GNAT.Source_Info (g-souinf.ads)::
363 * GNAT.Spelling_Checker (g-speche.ads)::
364 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
365 * GNAT.Spitbol.Patterns (g-spipat.ads)::
366 * GNAT.Spitbol (g-spitbo.ads)::
367 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
368 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
369 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
370 * GNAT.Strings (g-string.ads)::
371 * GNAT.String_Split (g-strspl.ads)::
372 * GNAT.Table (g-table.ads)::
373 * GNAT.Task_Lock (g-tasloc.ads)::
374 * GNAT.Threads (g-thread.ads)::
375 * GNAT.Traceback (g-traceb.ads)::
376 * GNAT.Traceback.Symbolic (g-trasym.ads)::
377 * GNAT.UTF_32 (g-utf_32.ads)::
378 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
379 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
380 * GNAT.Wide_String_Split (g-wistsp.ads)::
381 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
382 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
383 * Interfaces.C.Extensions (i-cexten.ads)::
384 * Interfaces.C.Streams (i-cstrea.ads)::
385 * Interfaces.CPP (i-cpp.ads)::
386 * Interfaces.Os2lib (i-os2lib.ads)::
387 * Interfaces.Os2lib.Errors (i-os2err.ads)::
388 * Interfaces.Os2lib.Synchronization (i-os2syn.ads)::
389 * Interfaces.Os2lib.Threads (i-os2thr.ads)::
390 * Interfaces.Packed_Decimal (i-pacdec.ads)::
391 * Interfaces.VxWorks (i-vxwork.ads)::
392 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
393 * System.Address_Image (s-addima.ads)::
394 * System.Assertions (s-assert.ads)::
395 * System.Memory (s-memory.ads)::
396 * System.Partition_Interface (s-parint.ads)::
397 * System.Restrictions (s-restri.ads)::
398 * System.Rident (s-rident.ads)::
399 * System.Task_Info (s-tasinf.ads)::
400 * System.Wch_Cnv (s-wchcnv.ads)::
401 * System.Wch_Con (s-wchcon.ads)::
402
403 Text_IO
404
405 * Text_IO Stream Pointer Positioning::
406 * Text_IO Reading and Writing Non-Regular Files::
407 * Get_Immediate::
408 * Treating Text_IO Files as Streams::
409 * Text_IO Extensions::
410 * Text_IO Facilities for Unbounded Strings::
411
412 Wide_Text_IO
413
414 * Wide_Text_IO Stream Pointer Positioning::
415 * Wide_Text_IO Reading and Writing Non-Regular Files::
416
417 Wide_Wide_Text_IO
418
419 * Wide_Wide_Text_IO Stream Pointer Positioning::
420 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
421
422 Interfacing to Other Languages
423
424 * Interfacing to C::
425 * Interfacing to C++::
426 * Interfacing to COBOL::
427 * Interfacing to Fortran::
428 * Interfacing to non-GNAT Ada code::
429
430 Specialized Needs Annexes
431
432 Implementation of Specific Ada Features
433 * Machine Code Insertions::
434 * GNAT Implementation of Tasking::
435 * GNAT Implementation of Shared Passive Packages::
436 * Code Generation for Array Aggregates::
437 * The Size of Discriminated Records with Default Discriminants::
438 * Strict Conformance to the Ada Reference Manual::
439
440 Project File Reference
441
442 Obsolescent Features
443
444 GNU Free Documentation License
445
446 Index
447 @end menu
448
449 @end ifnottex
450
451 @node About This Guide
452 @unnumbered About This Guide
453
454 @noindent
455 This manual contains useful information in writing programs using the
456 @value{EDITION} compiler.  It includes information on implementation dependent
457 characteristics of @value{EDITION}, including all the information required by
458 Annex M of the Ada language standard.
459
460 @value{EDITION} implements Ada 95 and Ada 2005, and it may also be invoked in
461 Ada 83 compatibility mode.
462 By default, @value{EDITION} assumes @value{DEFAULTLANGUAGEVERSION},
463 but you can override with a compiler switch
464 to explicitly specify the language version.
465 (Please refer to the section ``Compiling Different Versions of Ada'', in
466 @cite{@value{EDITION} User's Guide}, for details on these switches.)
467 Throughout this manual, references to ``Ada'' without a year suffix
468 apply to both the Ada 95 and Ada 2005 versions of the language.
469
470 Ada is designed to be highly portable.
471 In general, a program will have the same effect even when compiled by
472 different compilers on different platforms.
473 However, since Ada is designed to be used in a
474 wide variety of applications, it also contains a number of system
475 dependent features to be used in interfacing to the external world.
476 @cindex Implementation-dependent features
477 @cindex Portability
478
479 Note: Any program that makes use of implementation-dependent features
480 may be non-portable.  You should follow good programming practice and
481 isolate and clearly document any sections of your program that make use
482 of these features in a non-portable manner.
483
484 @ifset PROEDITION
485 For ease of exposition, ``GNAT Pro'' will be referred to simply as
486 ``GNAT'' in the remainder of this document.
487 @end ifset
488
489 @menu
490 * What This Reference Manual Contains::
491 * Conventions::
492 * Related Information::
493 @end menu
494
495 @node What This Reference Manual Contains
496 @unnumberedsec What This Reference Manual Contains
497
498 @noindent
499 This reference manual contains the following chapters:
500
501 @itemize @bullet
502 @item
503 @ref{Implementation Defined Pragmas}, lists GNAT implementation-dependent
504 pragmas, which can be used to extend and enhance the functionality of the
505 compiler.
506
507 @item
508 @ref{Implementation Defined Attributes}, lists GNAT
509 implementation-dependent attributes which can be used to extend and
510 enhance the functionality of the compiler.
511
512 @item
513 @ref{Implementation Advice}, provides information on generally
514 desirable behavior which are not requirements that all compilers must
515 follow since it cannot be provided on all systems, or which may be
516 undesirable on some systems.
517
518 @item
519 @ref{Implementation Defined Characteristics}, provides a guide to
520 minimizing implementation dependent features.
521
522 @item
523 @ref{Intrinsic Subprograms}, describes the intrinsic subprograms
524 implemented by GNAT, and how they can be imported into user
525 application programs.
526
527 @item
528 @ref{Representation Clauses and Pragmas}, describes in detail the
529 way that GNAT represents data, and in particular the exact set
530 of representation clauses and pragmas that is accepted.
531
532 @item
533 @ref{Standard Library Routines}, provides a listing of packages and a
534 brief description of the functionality that is provided by Ada's
535 extensive set of standard library routines as implemented by GNAT@.
536
537 @item
538 @ref{The Implementation of Standard I/O}, details how the GNAT
539 implementation of the input-output facilities.
540
541 @item
542 @ref{The GNAT Library}, is a catalog of packages that complement
543 the Ada predefined library.
544
545 @item
546 @ref{Interfacing to Other Languages}, describes how programs
547 written in Ada using GNAT can be interfaced to other programming
548 languages.
549
550 @ref{Specialized Needs Annexes}, describes the GNAT implementation of all
551 of the specialized needs annexes.
552
553 @item
554 @ref{Implementation of Specific Ada Features}, discusses issues related
555 to GNAT's implementation of machine code insertions, tasking, and several
556 other features.
557
558 @item
559 @ref{Project File Reference}, presents the syntax and semantics
560 of project files.
561
562 @item
563 @ref{Obsolescent Features} documents implementation dependent features,
564 including pragmas and attributes, which are considered obsolescent, since
565 there are other preferred ways of achieving the same results. These
566 obsolescent forms are retained for backwards compatibility.
567
568 @end itemize
569
570 @cindex Ada 95 Language Reference Manual
571 @cindex Ada 2005 Language Reference Manual
572 @noindent
573 This reference manual assumes a basic familiarity with the Ada 95 language, as
574 described in the International Standard ANSI/ISO/IEC-8652:1995,
575 January 1995.
576 It does not require knowledge of the new features introduced by Ada 2005,
577 (officially known as ISO/IEC 8652:1995 with Technical Corrigendum 1
578 and Amendment 1).
579 Both reference manuals are included in the GNAT documentation
580 package.
581
582 @node Conventions
583 @unnumberedsec Conventions
584 @cindex Conventions, typographical
585 @cindex Typographical conventions
586
587 @noindent
588 Following are examples of the typographical and graphic conventions used
589 in this guide:
590
591 @itemize @bullet
592 @item
593 @code{Functions}, @code{utility program names}, @code{standard names},
594 and @code{classes}.
595
596 @item
597 @code{Option flags}
598
599 @item
600 @file{File names}, @samp{button names}, and @samp{field names}.
601
602 @item
603 @code{Variables}, @env{environment variables}, and @var{metasyntactic
604 variables}.
605
606 @item
607 @emph{Emphasis}.
608
609 @item
610 [optional information or parameters]
611
612 @item
613 Examples are described by text
614 @smallexample
615 and then shown this way.
616 @end smallexample
617 @end itemize
618
619 @noindent
620 Commands that are entered by the user are preceded in this manual by the
621 characters @samp{$ } (dollar sign followed by space).  If your system uses this
622 sequence as a prompt, then the commands will appear exactly as you see them
623 in the manual.  If your system uses some other prompt, then the command will
624 appear with the @samp{$} replaced by whatever prompt character you are using.
625
626 @node Related Information
627 @unnumberedsec Related Information
628 @noindent
629 See the following documents for further information on GNAT:
630
631 @itemize @bullet
632 @item
633 @cite{GNAT User's Guide}, which provides information on how to use
634 the GNAT compiler system.
635
636 @item
637 @cite{Ada 95 Reference Manual}, which contains all reference
638 material for the Ada 95 programming language.
639
640 @item
641 @cite{Ada 95 Annotated Reference Manual}, which is an annotated version
642 of the Ada 95 standard.  The annotations describe
643 detailed aspects of the design decision, and in particular contain useful
644 sections on Ada 83 compatibility.
645
646 @item
647 @cite{Ada 2005 Reference Manual}, which contains all reference
648 material for the Ada 2005 programming language.
649
650 @item
651 @cite{Ada 2005 Annotated Reference Manual}, which is an annotated version
652 of the Ada 2005 standard.  The annotations describe
653 detailed aspects of the design decision, and in particular contain useful
654 sections on Ada 83 and Ada 95 compatibility.
655
656 @item
657 @cite{DEC Ada, Technical Overview and Comparison on DIGITAL Platforms},
658 which contains specific information on compatibility between GNAT and
659 DEC Ada 83 systems.
660
661 @item
662 @cite{DEC Ada, Language Reference Manual, part number AA-PYZAB-TK} which
663 describes in detail the pragmas and attributes provided by the DEC Ada 83
664 compiler system.
665
666 @end itemize
667
668 @node Implementation Defined Pragmas
669 @chapter Implementation Defined Pragmas
670
671 @noindent
672 Ada defines a set of pragmas that can be used to supply additional
673 information to the compiler.  These language defined pragmas are
674 implemented in GNAT and work as described in the Ada Reference
675 Manual.
676
677 In addition, Ada allows implementations to define additional pragmas
678 whose meaning is defined by the implementation.  GNAT provides a number
679 of these implementation-defined pragmas, which can be used to extend
680 and enhance the functionality of the compiler.  This section of the GNAT
681 Reference Manual describes these additional pragmas.
682
683 Note that any program using these pragmas might not be portable to other
684 compilers (although GNAT implements this set of pragmas on all
685 platforms).  Therefore if portability to other compilers is an important
686 consideration, the use of these pragmas should be minimized.
687
688 @menu
689 * Pragma Abort_Defer::
690 * Pragma Ada_83::
691 * Pragma Ada_95::
692 * Pragma Ada_05::
693 * Pragma Ada_2005::
694 * Pragma Annotate::
695 * Pragma Assert::
696 * Pragma Ast_Entry::
697 * Pragma C_Pass_By_Copy::
698 * Pragma Check_Name::
699 * Pragma Comment::
700 * Pragma Common_Object::
701 * Pragma Compile_Time_Error::
702 * Pragma Compile_Time_Warning::
703 * Pragma Complete_Representation::
704 * Pragma Complex_Representation::
705 * Pragma Component_Alignment::
706 * Pragma Convention_Identifier::
707 * Pragma CPP_Class::
708 * Pragma CPP_Constructor::
709 * Pragma CPP_Virtual::
710 * Pragma CPP_Vtable::
711 * Pragma Debug::
712 * Pragma Debug_Policy::
713 * Pragma Detect_Blocking::
714 * Pragma Elaboration_Checks::
715 * Pragma Eliminate::
716 * Pragma Export_Exception::
717 * Pragma Export_Function::
718 * Pragma Export_Object::
719 * Pragma Export_Procedure::
720 * Pragma Export_Value::
721 * Pragma Export_Valued_Procedure::
722 * Pragma Extend_System::
723 * Pragma External::
724 * Pragma External_Name_Casing::
725 * Pragma Fast_Math::
726 * Pragma Favor_Top_Level::
727 * Pragma Finalize_Storage_Only::
728 * Pragma Float_Representation::
729 * Pragma Ident::
730 * Pragma Implemented_By_Entry::
731 * Pragma Implicit_Packing::
732 * Pragma Import_Exception::
733 * Pragma Import_Function::
734 * Pragma Import_Object::
735 * Pragma Import_Procedure::
736 * Pragma Import_Valued_Procedure::
737 * Pragma Initialize_Scalars::
738 * Pragma Inline_Always::
739 * Pragma Inline_Generic::
740 * Pragma Interface::
741 * Pragma Interface_Name::
742 * Pragma Interrupt_Handler::
743 * Pragma Interrupt_State::
744 * Pragma Keep_Names::
745 * Pragma License::
746 * Pragma Link_With::
747 * Pragma Linker_Alias::
748 * Pragma Linker_Constructor::
749 * Pragma Linker_Destructor::
750 * Pragma Linker_Section::
751 * Pragma Long_Float::
752 * Pragma Machine_Attribute::
753 * Pragma Main::
754 * Pragma Main_Storage::
755 * Pragma No_Body::
756 * Pragma No_Return::
757 * Pragma No_Strict_Aliasing::
758 * Pragma Normalize_Scalars::
759 * Pragma Obsolescent::
760 * Pragma Passive::
761 * Pragma Persistent_BSS::
762 * Pragma Polling::
763 * Pragma Profile (Ravenscar)::
764 * Pragma Profile (Restricted)::
765 * Pragma Psect_Object::
766 * Pragma Pure_Function::
767 * Pragma Restriction_Warnings::
768 * Pragma Shared::
769 * Pragma Source_File_Name::
770 * Pragma Source_File_Name_Project::
771 * Pragma Source_Reference::
772 * Pragma Stream_Convert::
773 * Pragma Style_Checks::
774 * Pragma Subtitle::
775 * Pragma Suppress::
776 * Pragma Suppress_All::
777 * Pragma Suppress_Exception_Locations::
778 * Pragma Suppress_Initialization::
779 * Pragma Task_Info::
780 * Pragma Task_Name::
781 * Pragma Task_Storage::
782 * Pragma Time_Slice::
783 * Pragma Title::
784 * Pragma Unchecked_Union::
785 * Pragma Unimplemented_Unit::
786 * Pragma Universal_Aliasing ::
787 * Pragma Universal_Data::
788 * Pragma Unreferenced::
789 * Pragma Unreferenced_Objects::
790 * Pragma Unreserve_All_Interrupts::
791 * Pragma Unsuppress::
792 * Pragma Use_VADS_Size::
793 * Pragma Validity_Checks::
794 * Pragma Volatile::
795 * Pragma Warnings::
796 * Pragma Weak_External::
797 * Pragma Wide_Character_Encoding::
798 @end menu
799
800 @node Pragma Abort_Defer
801 @unnumberedsec Pragma Abort_Defer
802 @findex Abort_Defer
803 @cindex Deferring aborts
804 @noindent
805 Syntax:
806 @smallexample
807 pragma Abort_Defer;
808 @end smallexample
809
810 @noindent
811 This pragma must appear at the start of the statement sequence of a
812 handled sequence of statements (right after the @code{begin}).  It has
813 the effect of deferring aborts for the sequence of statements (but not
814 for the declarations or handlers, if any, associated with this statement
815 sequence).
816
817 @node Pragma Ada_83
818 @unnumberedsec Pragma Ada_83
819 @findex Ada_83
820 @noindent
821 Syntax:
822 @smallexample @c ada
823 pragma Ada_83;
824 @end smallexample
825
826 @noindent
827 A configuration pragma that establishes Ada 83 mode for the unit to
828 which it applies, regardless of the mode set by the command line
829 switches.  In Ada 83 mode, GNAT attempts to be as compatible with
830 the syntax and semantics of Ada 83, as defined in the original Ada
831 83 Reference Manual as possible.  In particular, the keywords added by Ada 95
832 and Ada 2005 are not recognized, optional package bodies are allowed,
833 and generics may name types with unknown discriminants without using
834 the @code{(<>)} notation.  In addition, some but not all of the additional
835 restrictions of Ada 83 are enforced.
836
837 Ada 83 mode is intended for two purposes.  Firstly, it allows existing
838 Ada 83 code to be compiled and adapted to GNAT with less effort.
839 Secondly, it aids in keeping code backwards compatible with Ada 83.
840 However, there is no guarantee that code that is processed correctly
841 by GNAT in Ada 83 mode will in fact compile and execute with an Ada
842 83 compiler, since GNAT does not enforce all the additional checks
843 required by Ada 83.
844
845 @node Pragma Ada_95
846 @unnumberedsec Pragma Ada_95
847 @findex Ada_95
848 @noindent
849 Syntax:
850 @smallexample @c ada
851 pragma Ada_95;
852 @end smallexample
853
854 @noindent
855 A configuration pragma that establishes Ada 95 mode for the unit to which
856 it applies, regardless of the mode set by the command line switches.
857 This mode is set automatically for the @code{Ada} and @code{System}
858 packages and their children, so you need not specify it in these
859 contexts.  This pragma is useful when writing a reusable component that
860 itself uses Ada 95 features, but which is intended to be usable from
861 either Ada 83 or Ada 95 programs.
862
863 @node Pragma Ada_05
864 @unnumberedsec Pragma Ada_05
865 @findex Ada_05
866 @noindent
867 Syntax:
868 @smallexample @c ada
869 pragma Ada_05;
870 @end smallexample
871
872 @noindent
873 A configuration pragma that establishes Ada 2005 mode for the unit to which
874 it applies, regardless of the mode set by the command line switches.
875 This mode is set automatically for the @code{Ada} and @code{System}
876 packages and their children, so you need not specify it in these
877 contexts.  This pragma is useful when writing a reusable component that
878 itself uses Ada 2005 features, but which is intended to be usable from
879 either Ada 83 or Ada 95 programs.
880
881 @node Pragma Ada_2005
882 @unnumberedsec Pragma Ada_2005
883 @findex Ada_2005
884 @noindent
885 Syntax:
886 @smallexample @c ada
887 pragma Ada_2005;
888 @end smallexample
889
890 @noindent
891 This configuration pragma is a synonym for pragma Ada_05 and has the
892 same syntax and effect.
893
894 @node Pragma Annotate
895 @unnumberedsec Pragma Annotate
896 @findex Annotate
897 @noindent
898 Syntax:
899 @smallexample @c ada
900 pragma Annotate (IDENTIFIER @{, ARG@});
901
902 ARG ::= NAME | EXPRESSION
903 @end smallexample
904
905 @noindent
906 This pragma is used to annotate programs.  @var{identifier} identifies
907 the type of annotation.  GNAT verifies that it is an identifier, but does
908 not otherwise analyze it.  The @var{arg} argument
909 can be either a string literal or an
910 expression.  String literals are assumed to be of type
911 @code{Standard.String}.  Names of entities are simply analyzed as entity
912 names.  All other expressions are analyzed as expressions, and must be
913 unambiguous.
914
915 The analyzed pragma is retained in the tree, but not otherwise processed
916 by any part of the GNAT compiler.  This pragma is intended for use by
917 external tools, including ASIS@.
918
919 @node Pragma Assert
920 @unnumberedsec Pragma Assert
921 @findex Assert
922 @noindent
923 Syntax:
924 @smallexample @c ada
925 pragma Assert (
926   boolean_EXPRESSION
927   [, static_string_EXPRESSION]);
928 @end smallexample
929
930 @noindent
931 The effect of this pragma depends on whether the corresponding command
932 line switch is set to activate assertions.  The pragma expands into code
933 equivalent to the following:
934
935 @smallexample @c ada
936 if assertions-enabled then
937    if not boolean_EXPRESSION then
938       System.Assertions.Raise_Assert_Failure
939         (string_EXPRESSION);
940    end if;
941 end if;
942 @end smallexample
943
944 @noindent
945 The string argument, if given, is the message that will be associated
946 with the exception occurrence if the exception is raised.  If no second
947 argument is given, the default message is @samp{@var{file}:@var{nnn}},
948 where @var{file} is the name of the source file containing the assert,
949 and @var{nnn} is the line number of the assert.  A pragma is not a
950 statement, so if a statement sequence contains nothing but a pragma
951 assert, then a null statement is required in addition, as in:
952
953 @smallexample @c ada
954 @dots{}
955 if J > 3 then
956    pragma Assert (K > 3, "Bad value for K");
957    null;
958 end if;
959 @end smallexample
960
961 @noindent
962 Note that, as with the @code{if} statement to which it is equivalent, the
963 type of the expression is either @code{Standard.Boolean}, or any type derived
964 from this standard type.
965
966 If assertions are disabled (switch @option{-gnata} not used), then there
967 is no run-time effect (and in particular, any side effects from the
968 expression will not occur at run time).  (The expression is still
969 analyzed at compile time, and may cause types to be frozen if they are
970 mentioned here for the first time).
971
972 If assertions are enabled, then the given expression is tested, and if
973 it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
974 which results in the raising of @code{Assert_Failure} with the given message.
975
976 You should generally avoid side effects in the expression arguments of
977 this pragma, because these side effects will turn on and off with the
978 setting of the assertions mode, resulting in assertions that have an
979 effect on the program.  However, the expressions are analyzed for
980 semantic correctness whether or not assertions are enabled, so turning
981 assertions on and off cannot affect the legality of a program.
982
983 @node Pragma Ast_Entry
984 @unnumberedsec Pragma Ast_Entry
985 @cindex OpenVMS
986 @findex Ast_Entry
987 @noindent
988 Syntax:
989 @smallexample @c ada
990 pragma AST_Entry (entry_IDENTIFIER);
991 @end smallexample
992
993 @noindent
994 This pragma is implemented only in the OpenVMS implementation of GNAT@.  The
995 argument is the simple name of a single entry; at most one @code{AST_Entry}
996 pragma is allowed for any given entry.  This pragma must be used in
997 conjunction with the @code{AST_Entry} attribute, and is only allowed after
998 the entry declaration and in the same task type specification or single task
999 as the entry to which it applies.  This pragma specifies that the given entry
1000 may be used to handle an OpenVMS asynchronous system trap (@code{AST})
1001 resulting from an OpenVMS system service call.  The pragma does not affect
1002 normal use of the entry.  For further details on this pragma, see the
1003 DEC Ada Language Reference Manual, section 9.12a.
1004
1005 @node Pragma C_Pass_By_Copy
1006 @unnumberedsec Pragma C_Pass_By_Copy
1007 @cindex Passing by copy
1008 @findex C_Pass_By_Copy
1009 @noindent
1010 Syntax:
1011 @smallexample @c ada
1012 pragma C_Pass_By_Copy
1013   ([Max_Size =>] static_integer_EXPRESSION);
1014 @end smallexample
1015
1016 @noindent
1017 Normally the default mechanism for passing C convention records to C
1018 convention subprograms is to pass them by reference, as suggested by RM
1019 B.3(69).  Use the configuration pragma @code{C_Pass_By_Copy} to change
1020 this default, by requiring that record formal parameters be passed by
1021 copy if all of the following conditions are met:
1022
1023 @itemize @bullet
1024 @item
1025 The size of the record type does not exceed the value specified for
1026 @code{Max_Size}.
1027 @item
1028 The record type has @code{Convention C}.
1029 @item
1030 The formal parameter has this record type, and the subprogram has a
1031 foreign (non-Ada) convention.
1032 @end itemize
1033
1034 @noindent
1035 If these conditions are met the argument is passed by copy, i.e.@: in a
1036 manner consistent with what C expects if the corresponding formal in the
1037 C prototype is a struct (rather than a pointer to a struct).
1038
1039 You can also pass records by copy by specifying the convention
1040 @code{C_Pass_By_Copy} for the record type, or by using the extended
1041 @code{Import} and @code{Export} pragmas, which allow specification of
1042 passing mechanisms on a parameter by parameter basis.
1043
1044 @node Pragma Check_Name
1045 @unnumberedsec Pragma Check_Name
1046 @cindex Defining check names
1047 @cindex Check names, defining
1048 @findex Check_Name
1049 @noindent
1050 Syntax:
1051 @smallexample @c ada
1052 pragma Check_Name (check_name_IDENTIFIER);
1053 @end smallexample
1054
1055 @noindent
1056 This is a configuration pragma that defines a new implementation
1057 defined check name (unless IDENTIFIER matches one of the predefined
1058 check names, in which case the pragma has no effect). Check names
1059 are global to a partition, so if two more more configuration pragmas
1060 are present in a partition mentioning the same name, only one new
1061 check name is introduced.
1062
1063 An implementation defined check name introduced with this pragma may
1064 be used in only three contexts: @code{pragma Suppress},
1065 @code{pragma Unsuppress},
1066 and as the prefix of a @code{Check_Name'Enabled} attribute reference. For
1067 any of these three cases, the check name must be visible. A check
1068 name is visible if it is in the configuration pragmas applying to
1069 the current unit, or if it appears at the start of any unit that
1070 is part of the dependency set of the current unit (e.g. units that
1071 are mentioned in @code{with} clauses.
1072
1073 @node Pragma Comment
1074 @unnumberedsec Pragma Comment
1075 @findex Comment
1076 @noindent
1077 Syntax:
1078
1079 @smallexample @c ada
1080 pragma Comment (static_string_EXPRESSION);
1081 @end smallexample
1082
1083 @noindent
1084 This is almost identical in effect to pragma @code{Ident}.  It allows the
1085 placement of a comment into the object file and hence into the
1086 executable file if the operating system permits such usage.  The
1087 difference is that @code{Comment}, unlike @code{Ident}, has
1088 no limitations on placement of the pragma (it can be placed
1089 anywhere in the main source unit), and if more than one pragma
1090 is used, all comments are retained.
1091
1092 @node Pragma Common_Object
1093 @unnumberedsec Pragma Common_Object
1094 @findex Common_Object
1095 @noindent
1096 Syntax:
1097
1098 @smallexample @c ada
1099 pragma Common_Object (
1100      [Internal =>] LOCAL_NAME
1101   [, [External =>] EXTERNAL_SYMBOL]
1102   [, [Size     =>] EXTERNAL_SYMBOL] );
1103
1104 EXTERNAL_SYMBOL ::=
1105   IDENTIFIER
1106 | static_string_EXPRESSION
1107 @end smallexample
1108
1109 @noindent
1110 This pragma enables the shared use of variables stored in overlaid
1111 linker areas corresponding to the use of @code{COMMON}
1112 in Fortran.  The single
1113 object @var{LOCAL_NAME} is assigned to the area designated by
1114 the @var{External} argument.
1115 You may define a record to correspond to a series
1116 of fields.  The @var{Size} argument
1117 is syntax checked in GNAT, but otherwise ignored.
1118
1119 @code{Common_Object} is not supported on all platforms.  If no
1120 support is available, then the code generator will issue a message
1121 indicating that the necessary attribute for implementation of this
1122 pragma is not available.
1123
1124 @node Pragma Compile_Time_Error
1125 @unnumberedsec Pragma Compile_Time_Error
1126 @findex Compile_Time_Error
1127 @noindent
1128 Syntax:
1129
1130 @smallexample @c ada
1131 pragma Compile_Time_Error
1132          (boolean_EXPRESSION, static_string_EXPRESSION);
1133 @end smallexample
1134
1135 @noindent
1136 This pragma can be used to generate additional compile time
1137 error messages. It
1138 is particularly useful in generics, where errors can be issued for
1139 specific problematic instantiations. The first parameter is a boolean
1140 expression. The pragma is effective only if the value of this expression
1141 is known at compile time, and has the value True. The set of expressions
1142 whose values are known at compile time includes all static boolean
1143 expressions, and also other values which the compiler can determine
1144 at compile time (e.g. the size of a record type set by an explicit
1145 size representation clause, or the value of a variable which was
1146 initialized to a constant and is known not to have been modified).
1147 If these conditions are met, an error message is generated using
1148 the value given as the second argument. This string value may contain
1149 embedded ASCII.LF characters to break the message into multiple lines.
1150
1151 @node Pragma Compile_Time_Warning
1152 @unnumberedsec Pragma Compile_Time_Warning
1153 @findex Compile_Time_Warning
1154 @noindent
1155 Syntax:
1156
1157 @smallexample @c ada
1158 pragma Compile_Time_Warning
1159          (boolean_EXPRESSION, static_string_EXPRESSION);
1160 @end smallexample
1161
1162 @noindent
1163 Same as pragma Compile_Time_Error, except a warning is issued instead
1164 of an error message.
1165
1166 @node Pragma Complete_Representation
1167 @unnumberedsec Pragma Complete_Representation
1168 @findex Complete_Representation
1169 @noindent
1170 Syntax:
1171
1172 @smallexample @c ada
1173 pragma Complete_Representation;
1174 @end smallexample
1175
1176 @noindent
1177 This pragma must appear immediately within a record representation
1178 clause. Typical placements are before the first component clause
1179 or after the last component clause. The effect is to give an error
1180 message if any component is missing a component clause. This pragma
1181 may be used to ensure that a record representation clause is
1182 complete, and that this invariant is maintained if fields are
1183 added to the record in the future.
1184
1185 @node Pragma Complex_Representation
1186 @unnumberedsec Pragma Complex_Representation
1187 @findex Complex_Representation
1188 @noindent
1189 Syntax:
1190
1191 @smallexample @c ada
1192 pragma Complex_Representation
1193         ([Entity =>] LOCAL_NAME);
1194 @end smallexample
1195
1196 @noindent
1197 The @var{Entity} argument must be the name of a record type which has
1198 two fields of the same floating-point type.  The effect of this pragma is
1199 to force gcc to use the special internal complex representation form for
1200 this record, which may be more efficient.  Note that this may result in
1201 the code for this type not conforming to standard ABI (application
1202 binary interface) requirements for the handling of record types.  For
1203 example, in some environments, there is a requirement for passing
1204 records by pointer, and the use of this pragma may result in passing
1205 this type in floating-point registers.
1206
1207 @node Pragma Component_Alignment
1208 @unnumberedsec Pragma Component_Alignment
1209 @cindex Alignments of components
1210 @findex Component_Alignment
1211 @noindent
1212 Syntax:
1213
1214 @smallexample @c ada
1215 pragma Component_Alignment (
1216      [Form =>] ALIGNMENT_CHOICE
1217   [, [Name =>] type_LOCAL_NAME]);
1218
1219 ALIGNMENT_CHOICE ::=
1220   Component_Size
1221 | Component_Size_4
1222 | Storage_Unit
1223 | Default
1224 @end smallexample
1225
1226 @noindent
1227 Specifies the alignment of components in array or record types.
1228 The meaning of the @var{Form} argument is as follows:
1229
1230 @table @code
1231 @findex Component_Size
1232 @item Component_Size
1233 Aligns scalar components and subcomponents of the array or record type
1234 on boundaries appropriate to their inherent size (naturally
1235 aligned).  For example, 1-byte components are aligned on byte boundaries,
1236 2-byte integer components are aligned on 2-byte boundaries, 4-byte
1237 integer components are aligned on 4-byte boundaries and so on.  These
1238 alignment rules correspond to the normal rules for C compilers on all
1239 machines except the VAX@.
1240
1241 @findex Component_Size_4
1242 @item Component_Size_4
1243 Naturally aligns components with a size of four or fewer
1244 bytes.  Components that are larger than 4 bytes are placed on the next
1245 4-byte boundary.
1246
1247 @findex Storage_Unit
1248 @item Storage_Unit
1249 Specifies that array or record components are byte aligned, i.e.@:
1250 aligned on boundaries determined by the value of the constant
1251 @code{System.Storage_Unit}.
1252
1253 @cindex OpenVMS
1254 @item Default
1255 Specifies that array or record components are aligned on default
1256 boundaries, appropriate to the underlying hardware or operating system or
1257 both.  For OpenVMS VAX systems, the @code{Default} choice is the same as
1258 the @code{Storage_Unit} choice (byte alignment).  For all other systems,
1259 the @code{Default} choice is the same as @code{Component_Size} (natural
1260 alignment).
1261 @end table
1262
1263 @noindent
1264 If the @code{Name} parameter is present, @var{type_LOCAL_NAME} must
1265 refer to a local record or array type, and the specified alignment
1266 choice applies to the specified type.  The use of
1267 @code{Component_Alignment} together with a pragma @code{Pack} causes the
1268 @code{Component_Alignment} pragma to be ignored.  The use of
1269 @code{Component_Alignment} together with a record representation clause
1270 is only effective for fields not specified by the representation clause.
1271
1272 If the @code{Name} parameter is absent, the pragma can be used as either
1273 a configuration pragma, in which case it applies to one or more units in
1274 accordance with the normal rules for configuration pragmas, or it can be
1275 used within a declarative part, in which case it applies to types that
1276 are declared within this declarative part, or within any nested scope
1277 within this declarative part.  In either case it specifies the alignment
1278 to be applied to any record or array type which has otherwise standard
1279 representation.
1280
1281 If the alignment for a record or array type is not specified (using
1282 pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
1283 clause), the GNAT uses the default alignment as described previously.
1284
1285 @node Pragma Convention_Identifier
1286 @unnumberedsec Pragma Convention_Identifier
1287 @findex Convention_Identifier
1288 @cindex Conventions, synonyms
1289 @noindent
1290 Syntax:
1291
1292 @smallexample @c ada
1293 pragma Convention_Identifier (
1294          [Name =>]       IDENTIFIER,
1295          [Convention =>] convention_IDENTIFIER);
1296 @end smallexample
1297
1298 @noindent
1299 This pragma provides a mechanism for supplying synonyms for existing
1300 convention identifiers. The @code{Name} identifier can subsequently
1301 be used as a synonym for the given convention in other pragmas (including
1302 for example pragma @code{Import} or another @code{Convention_Identifier}
1303 pragma). As an example of the use of this, suppose you had legacy code
1304 which used Fortran77 as the identifier for Fortran. Then the pragma:
1305
1306 @smallexample @c ada
1307 pragma Convention_Identifier (Fortran77, Fortran);
1308 @end smallexample
1309
1310 @noindent
1311 would allow the use of the convention identifier @code{Fortran77} in
1312 subsequent code, avoiding the need to modify the sources. As another
1313 example, you could use this to parametrize convention requirements
1314 according to systems. Suppose you needed to use @code{Stdcall} on
1315 windows systems, and @code{C} on some other system, then you could
1316 define a convention identifier @code{Library} and use a single
1317 @code{Convention_Identifier} pragma to specify which convention
1318 would be used system-wide.
1319
1320 @node Pragma CPP_Class
1321 @unnumberedsec Pragma CPP_Class
1322 @findex CPP_Class
1323 @cindex Interfacing with C++
1324 @noindent
1325 Syntax:
1326
1327 @smallexample @c ada
1328 pragma CPP_Class ([Entity =>] LOCAL_NAME);
1329 @end smallexample
1330
1331 @noindent
1332 The argument denotes an entity in the current declarative region that is
1333 declared as a tagged record type. It indicates that the type corresponds
1334 to an externally declared C++ class type, and is to be laid out the same
1335 way that C++ would lay out the type.
1336
1337 Types for which @code{CPP_Class} is specified do not have assignment or
1338 equality operators defined (such operations can be imported or declared
1339 as subprograms as required). Initialization is allowed only by constructor
1340 functions (see pragma @code{CPP_Constructor}). Such types are implicitly
1341 limited if not explicitly declared as limited or derived from a limited
1342 type, and a warning is issued in that case.
1343
1344 Pragma @code{CPP_Class} is intended primarily for automatic generation
1345 using an automatic binding generator tool.
1346 See @ref{Interfacing to C++} for related information.
1347
1348 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
1349 for backward compatibility but its functionality is available
1350 using pragma @code{Import} with @code{Convention} = @code{CPP}.
1351
1352 @node Pragma CPP_Constructor
1353 @unnumberedsec Pragma CPP_Constructor
1354 @cindex Interfacing with C++
1355 @findex CPP_Constructor
1356 @noindent
1357 Syntax:
1358
1359 @smallexample @c ada
1360 pragma CPP_Constructor ([Entity =>] LOCAL_NAME
1361   [, [External_Name =>] static_string_EXPRESSION ]
1362   [, [Link_Name     =>] static_string_EXPRESSION ]);
1363 @end smallexample
1364
1365 @noindent
1366 This pragma identifies an imported function (imported in the usual way
1367 with pragma @code{Import}) as corresponding to a C++ constructor. If
1368 @code{External_Name} and @code{Link_Name} are not specified then the
1369 @code{Entity} argument is a name that must have been previously mentioned
1370 in a pragma @code{Import} with @code{Convention} = @code{CPP}. Such name
1371 must be of one of the following forms:
1372
1373 @itemize @bullet
1374 @item
1375 @code{function @var{Fname} return @var{T}'Class}
1376
1377 @item
1378 @code{function @var{Fname} (@dots{}) return @var{T}'Class}
1379 @end itemize
1380
1381 @noindent
1382 where @var{T} is a tagged type to which the pragma @code{CPP_Class} applies.
1383
1384 The first form is the default constructor, used when an object of type
1385 @var{T} is created on the Ada side with no explicit constructor.  Other
1386 constructors (including the copy constructor, which is simply a special
1387 case of the second form in which the one and only argument is of type
1388 @var{T}), can only appear in two contexts:
1389
1390 @itemize @bullet
1391 @item
1392 On the right side of an initialization of an object of type @var{T}.
1393 @item
1394 In an extension aggregate for an object of a type derived from @var{T}.
1395 @end itemize
1396
1397 @noindent
1398 Although the constructor is described as a function that returns a value
1399 on the Ada side, it is typically a procedure with an extra implicit
1400 argument (the object being initialized) at the implementation
1401 level.  GNAT issues the appropriate call, whatever it is, to get the
1402 object properly initialized.
1403
1404 In the case of derived objects, you may use one of two possible forms
1405 for declaring and creating an object:
1406
1407 @itemize @bullet
1408 @item @code{New_Object : Derived_T}
1409 @item @code{New_Object : Derived_T := (@var{constructor-call with} @dots{})}
1410 @end itemize
1411
1412 @noindent
1413 In the first case the default constructor is called and extension fields
1414 if any are initialized according to the default initialization
1415 expressions in the Ada declaration.  In the second case, the given
1416 constructor is called and the extension aggregate indicates the explicit
1417 values of the extension fields.
1418
1419 If no constructors are imported, it is impossible to create any objects
1420 on the Ada side.  If no default constructor is imported, only the
1421 initialization forms using an explicit call to a constructor are
1422 permitted.
1423
1424 Pragma @code{CPP_Constructor} is intended primarily for automatic generation
1425 using an automatic binding generator tool.
1426 See @ref{Interfacing to C++} for more related information.
1427
1428 @node Pragma CPP_Virtual
1429 @unnumberedsec Pragma CPP_Virtual
1430 @cindex Interfacing to C++
1431 @findex CPP_Virtual
1432 @noindent
1433 This pragma is now obsolete has has no effect because GNAT generates
1434 the same object layout than the G++ compiler.
1435
1436 See @ref{Interfacing to C++} for related information.
1437
1438 @node Pragma CPP_Vtable
1439 @unnumberedsec Pragma CPP_Vtable
1440 @cindex Interfacing with C++
1441 @findex CPP_Vtable
1442 @noindent
1443 This pragma is now obsolete has has no effect because GNAT generates
1444 the same object layout than the G++ compiler.
1445
1446 See @ref{Interfacing to C++} for related information.
1447
1448 @node Pragma Debug
1449 @unnumberedsec Pragma Debug
1450 @findex Debug
1451 @noindent
1452 Syntax:
1453
1454 @smallexample @c ada
1455 pragma Debug ([CONDITION, ]PROCEDURE_CALL_WITHOUT_SEMICOLON);
1456
1457 PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
1458   PROCEDURE_NAME
1459 | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
1460 @end smallexample
1461
1462 @noindent
1463 The procedure call argument has the syntactic form of an expression, meeting
1464 the syntactic requirements for pragmas.
1465
1466 If debug pragmas are not enabled or if the condition is present and evaluates
1467 to False, this pragma has no effect. If debug pragmas are enabled, the
1468 semantics of the pragma is exactly equivalent to the procedure call statement
1469 corresponding to the argument with a terminating semicolon. Pragmas are
1470 permitted in sequences of declarations, so you can use pragma @code{Debug} to
1471 intersperse calls to debug procedures in the middle of declarations. Debug
1472 pragmas can be enabled either by use of the command line switch @option{-gnata}
1473 or by use of the configuration pragma @code{Debug_Policy}.
1474
1475 @node Pragma Debug_Policy
1476 @unnumberedsec Pragma Debug_Policy
1477 @findex Debug_Policy
1478 @noindent
1479 Syntax:
1480
1481 @smallexample @c ada
1482 pragma Debug_Policy (CHECK | IGNORE);
1483 @end smallexample
1484
1485 @noindent
1486 If the argument is @code{CHECK}, then pragma @code{DEBUG} is enabled.
1487 If the argument is @code{IGNORE}, then pragma @code{DEBUG} is ignored.
1488 This pragma overrides the effect of the @option{-gnata} switch on the
1489 command line.
1490
1491 @node Pragma Detect_Blocking
1492 @unnumberedsec Pragma Detect_Blocking
1493 @findex Detect_Blocking
1494 @noindent
1495 Syntax:
1496
1497 @smallexample @c ada
1498 pragma Detect_Blocking;
1499 @end smallexample
1500
1501 @noindent
1502 This is a configuration pragma that forces the detection of potentially
1503 blocking operations within a protected operation, and to raise Program_Error
1504 if that happens.
1505
1506 @node Pragma Elaboration_Checks
1507 @unnumberedsec Pragma Elaboration_Checks
1508 @cindex Elaboration control
1509 @findex Elaboration_Checks
1510 @noindent
1511 Syntax:
1512
1513 @smallexample @c ada
1514 pragma Elaboration_Checks (Dynamic | Static);
1515 @end smallexample
1516
1517 @noindent
1518 This is a configuration pragma that provides control over the
1519 elaboration model used by the compilation affected by the
1520 pragma.  If the parameter is @code{Dynamic},
1521 then the dynamic elaboration
1522 model described in the Ada Reference Manual is used, as though
1523 the @option{-gnatE} switch had been specified on the command
1524 line.  If the parameter is @code{Static}, then the default GNAT static
1525 model is used.  This configuration pragma overrides the setting
1526 of the command line.  For full details on the elaboration models
1527 used by the GNAT compiler, see section ``Elaboration Order
1528 Handling in GNAT'' in the @cite{GNAT User's Guide}.
1529
1530 @node Pragma Eliminate
1531 @unnumberedsec Pragma Eliminate
1532 @cindex Elimination of unused subprograms
1533 @findex Eliminate
1534 @noindent
1535 Syntax:
1536
1537 @smallexample @c ada
1538 pragma Eliminate (
1539     [Unit_Name =>] IDENTIFIER |
1540                    SELECTED_COMPONENT);
1541
1542 pragma Eliminate (
1543     [Unit_Name       =>]  IDENTIFIER |
1544                           SELECTED_COMPONENT,
1545     [Entity          =>]  IDENTIFIER |
1546                           SELECTED_COMPONENT |
1547                           STRING_LITERAL
1548     [,OVERLOADING_RESOLUTION]);
1549
1550 OVERLOADING_RESOLUTION ::= PARAMETER_AND_RESULT_TYPE_PROFILE |
1551                            SOURCE_LOCATION
1552
1553 PARAMETER_AND_RESULT_TYPE_PROFILE ::= PROCEDURE_PROFILE |
1554                                       FUNCTION_PROFILE
1555
1556 PROCEDURE_PROFILE ::= Parameter_Types => PARAMETER_TYPES
1557
1558 FUNCTION_PROFILE ::= [Parameter_Types => PARAMETER_TYPES,]
1559                       Result_Type => result_SUBTYPE_NAME]
1560
1561 PARAMETER_TYPES ::= (SUBTYPE_NAME @{, SUBTYPE_NAME@})
1562 SUBTYPE_NAME    ::= STRING_VALUE
1563
1564 SOURCE_LOCATION ::= Source_Location => SOURCE_TRACE
1565 SOURCE_TRACE    ::= STRING_VALUE
1566
1567 STRING_VALUE ::= STRING_LITERAL @{& STRING_LITERAL@}
1568 @end smallexample
1569
1570 @noindent
1571 This pragma indicates that the given entity is not used outside the
1572 compilation unit it is defined in. The entity must be an explicitly declared
1573 subprogram; this includes  generic subprogram instances and
1574 subprograms declared in generic package instances.
1575
1576 If the entity to be eliminated is a library level subprogram, then
1577 the first form of pragma @code{Eliminate} is used with only a single argument.
1578 In this form, the @code{Unit_Name} argument specifies the name of the
1579 library  level unit to be eliminated.
1580
1581 In all other cases, both @code{Unit_Name} and @code{Entity} arguments
1582 are required. If item is an entity of a library package, then the first
1583 argument specifies the unit name, and the second argument specifies
1584 the particular entity.  If the second argument is in string form, it must
1585 correspond to the internal manner in which GNAT stores entity names (see
1586 compilation unit Namet in the compiler sources for details).
1587
1588 The remaining parameters (OVERLOADING_RESOLUTION) are optionally used
1589 to distinguish between overloaded subprograms. If a pragma does not contain
1590 the OVERLOADING_RESOLUTION parameter(s), it is applied to all the overloaded
1591 subprograms denoted by the first two parameters.
1592
1593 Use PARAMETER_AND_RESULT_TYPE_PROFILE to specify the profile of the subprogram
1594 to be eliminated in a manner similar to that used for the extended
1595 @code{Import} and @code{Export} pragmas, except that the subtype names are
1596 always given as strings. At the moment, this form of distinguishing
1597 overloaded subprograms is implemented only partially, so we do not recommend
1598 using it for practical subprogram elimination.
1599
1600 Note that in case of a parameterless procedure its profile is represented
1601 as @code{Parameter_Types => ("")}
1602
1603 Alternatively, the @code{Source_Location} parameter is used to specify
1604 which overloaded alternative is to be eliminated by pointing to the
1605 location of the DEFINING_PROGRAM_UNIT_NAME of this subprogram in the
1606 source text. The string literal (or concatenation of string literals)
1607 given as SOURCE_TRACE must have the following format:
1608
1609 @smallexample @c ada
1610 SOURCE_TRACE ::= SOURCE_LOCATION@{LBRACKET SOURCE_LOCATION RBRACKET@}
1611
1612 LBRACKET ::= [
1613 RBRACKET ::= ]
1614
1615 SOURCE_LOCATION ::= FILE_NAME:LINE_NUMBER
1616 FILE_NAME       ::= STRING_LITERAL
1617 LINE_NUMBER     ::= DIGIT @{DIGIT@}
1618 @end smallexample
1619
1620 SOURCE_TRACE should be the short name of the source file (with no directory
1621 information), and LINE_NUMBER is supposed to point to the line where the
1622 defining name of the subprogram is located.
1623
1624 For the subprograms that are not a part of generic instantiations, only one
1625 SOURCE_LOCATION is used. If a subprogram is declared in a package
1626 instantiation, SOURCE_TRACE contains two SOURCE_LOCATIONs, the first one is
1627 the location of the (DEFINING_PROGRAM_UNIT_NAME of the) instantiation, and the
1628 second one denotes the declaration of the corresponding subprogram in the
1629 generic package. This approach is recursively used to create SOURCE_LOCATIONs
1630 in case of nested instantiations.
1631
1632 The effect of the pragma is to allow the compiler to eliminate
1633 the code or data associated with the named entity.  Any reference to
1634 an eliminated entity outside the compilation unit it is defined in,
1635 causes a compile time or link time error.
1636
1637 The intention of pragma @code{Eliminate} is to allow a program to be compiled
1638 in a system independent manner, with unused entities eliminated, without
1639 the requirement of modifying the source text.  Normally the required set
1640 of @code{Eliminate} pragmas is constructed automatically using the gnatelim
1641 tool. Elimination of unused entities local to a compilation unit is
1642 automatic, without requiring the use of pragma @code{Eliminate}.
1643
1644 Note that the reason this pragma takes string literals where names might
1645 be expected is that a pragma @code{Eliminate} can appear in a context where the
1646 relevant names are not visible.
1647
1648 Note that any change in the source files that includes removing, splitting of
1649 adding lines may make the set of Eliminate pragmas using SOURCE_LOCATION
1650 parameter illegal.
1651
1652 It is legal to use pragma Eliminate where the referenced entity is a
1653 dispatching operation, but it is not clear what this would mean, since
1654 in general the call does not know which entity is actually being called.
1655 Consequently, a pragma Eliminate for a dispatching operation is ignored.
1656
1657 @node Pragma Export_Exception
1658 @unnumberedsec Pragma Export_Exception
1659 @cindex OpenVMS
1660 @findex Export_Exception
1661 @noindent
1662 Syntax:
1663
1664 @smallexample @c ada
1665 pragma Export_Exception (
1666      [Internal =>] LOCAL_NAME
1667   [, [External =>] EXTERNAL_SYMBOL]
1668   [, [Form     =>] Ada | VMS]
1669   [, [Code     =>] static_integer_EXPRESSION]);
1670
1671 EXTERNAL_SYMBOL ::=
1672   IDENTIFIER
1673 | static_string_EXPRESSION
1674 @end smallexample
1675
1676 @noindent
1677 This pragma is implemented only in the OpenVMS implementation of GNAT@.  It
1678 causes the specified exception to be propagated outside of the Ada program,
1679 so that it can be handled by programs written in other OpenVMS languages.
1680 This pragma establishes an external name for an Ada exception and makes the
1681 name available to the OpenVMS Linker as a global symbol.  For further details
1682 on this pragma, see the
1683 DEC Ada Language Reference Manual, section 13.9a3.2.
1684
1685 @node Pragma Export_Function
1686 @unnumberedsec Pragma Export_Function
1687 @cindex Argument passing mechanisms
1688 @findex Export_Function
1689
1690 @noindent
1691 Syntax:
1692
1693 @smallexample @c ada
1694 pragma Export_Function (
1695      [Internal         =>] LOCAL_NAME
1696   [, [External         =>] EXTERNAL_SYMBOL]
1697   [, [Parameter_Types  =>] PARAMETER_TYPES]
1698   [, [Result_Type      =>] result_SUBTYPE_MARK]
1699   [, [Mechanism        =>] MECHANISM]
1700   [, [Result_Mechanism =>] MECHANISM_NAME]);
1701
1702 EXTERNAL_SYMBOL ::=
1703   IDENTIFIER
1704 | static_string_EXPRESSION
1705 | ""
1706
1707 PARAMETER_TYPES ::=
1708   null
1709 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1710
1711 TYPE_DESIGNATOR ::=
1712   subtype_NAME
1713 | subtype_Name ' Access
1714
1715 MECHANISM ::=
1716   MECHANISM_NAME
1717 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1718
1719 MECHANISM_ASSOCIATION ::=
1720   [formal_parameter_NAME =>] MECHANISM_NAME
1721
1722 MECHANISM_NAME ::=
1723   Value
1724 | Reference
1725 | Descriptor [([Class =>] CLASS_NAME)]
1726
1727 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
1728 @end smallexample
1729
1730 @noindent
1731 Use this pragma to make a function externally callable and optionally
1732 provide information on mechanisms to be used for passing parameter and
1733 result values.  We recommend, for the purposes of improving portability,
1734 this pragma always be used in conjunction with a separate pragma
1735 @code{Export}, which must precede the pragma @code{Export_Function}.
1736 GNAT does not require a separate pragma @code{Export}, but if none is
1737 present, @code{Convention Ada} is assumed, which is usually
1738 not what is wanted, so it is usually appropriate to use this
1739 pragma in conjunction with a @code{Export} or @code{Convention}
1740 pragma that specifies the desired foreign convention.
1741 Pragma @code{Export_Function}
1742 (and @code{Export}, if present) must appear in the same declarative
1743 region as the function to which they apply.
1744
1745 @var{internal_name} must uniquely designate the function to which the
1746 pragma applies.  If more than one function name exists of this name in
1747 the declarative part you must use the @code{Parameter_Types} and
1748 @code{Result_Type} parameters is mandatory to achieve the required
1749 unique designation.  @var{subtype_mark}s in these parameters must
1750 exactly match the subtypes in the corresponding function specification,
1751 using positional notation to match parameters with subtype marks.
1752 The form with an @code{'Access} attribute can be used to match an
1753 anonymous access parameter.
1754
1755 @cindex OpenVMS
1756 @cindex Passing by descriptor
1757 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
1758
1759 @cindex Suppressing external name
1760 Special treatment is given if the EXTERNAL is an explicit null
1761 string or a static string expressions that evaluates to the null
1762 string. In this case, no external name is generated. This form
1763 still allows the specification of parameter mechanisms.
1764
1765 @node Pragma Export_Object
1766 @unnumberedsec Pragma Export_Object
1767 @findex Export_Object
1768 @noindent
1769 Syntax:
1770
1771 @smallexample @c ada
1772 pragma Export_Object
1773       [Internal =>] LOCAL_NAME
1774    [, [External =>] EXTERNAL_SYMBOL]
1775    [, [Size     =>] EXTERNAL_SYMBOL]
1776
1777 EXTERNAL_SYMBOL ::=
1778   IDENTIFIER
1779 | static_string_EXPRESSION
1780 @end smallexample
1781
1782 @noindent
1783 This pragma designates an object as exported, and apart from the
1784 extended rules for external symbols, is identical in effect to the use of
1785 the normal @code{Export} pragma applied to an object.  You may use a
1786 separate Export pragma (and you probably should from the point of view
1787 of portability), but it is not required.  @var{Size} is syntax checked,
1788 but otherwise ignored by GNAT@.
1789
1790 @node Pragma Export_Procedure
1791 @unnumberedsec Pragma Export_Procedure
1792 @findex Export_Procedure
1793 @noindent
1794 Syntax:
1795
1796 @smallexample @c ada
1797 pragma Export_Procedure (
1798      [Internal        =>] LOCAL_NAME
1799   [, [External        =>] EXTERNAL_SYMBOL]
1800   [, [Parameter_Types =>] PARAMETER_TYPES]
1801   [, [Mechanism       =>] MECHANISM]);
1802
1803 EXTERNAL_SYMBOL ::=
1804   IDENTIFIER
1805 | static_string_EXPRESSION
1806 | ""
1807
1808 PARAMETER_TYPES ::=
1809   null
1810 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1811
1812 TYPE_DESIGNATOR ::=
1813   subtype_NAME
1814 | subtype_Name ' Access
1815
1816 MECHANISM ::=
1817   MECHANISM_NAME
1818 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1819
1820 MECHANISM_ASSOCIATION ::=
1821   [formal_parameter_NAME =>] MECHANISM_NAME
1822
1823 MECHANISM_NAME ::=
1824   Value
1825 | Reference
1826 | Descriptor [([Class =>] CLASS_NAME)]
1827
1828 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
1829 @end smallexample
1830
1831 @noindent
1832 This pragma is identical to @code{Export_Function} except that it
1833 applies to a procedure rather than a function and the parameters
1834 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
1835 GNAT does not require a separate pragma @code{Export}, but if none is
1836 present, @code{Convention Ada} is assumed, which is usually
1837 not what is wanted, so it is usually appropriate to use this
1838 pragma in conjunction with a @code{Export} or @code{Convention}
1839 pragma that specifies the desired foreign convention.
1840
1841 @cindex OpenVMS
1842 @cindex Passing by descriptor
1843 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
1844
1845 @cindex Suppressing external name
1846 Special treatment is given if the EXTERNAL is an explicit null
1847 string or a static string expressions that evaluates to the null
1848 string. In this case, no external name is generated. This form
1849 still allows the specification of parameter mechanisms.
1850
1851 @node Pragma Export_Value
1852 @unnumberedsec Pragma Export_Value
1853 @findex Export_Value
1854 @noindent
1855 Syntax:
1856
1857 @smallexample @c ada
1858 pragma Export_Value (
1859   [Value     =>] static_integer_EXPRESSION,
1860   [Link_Name =>] static_string_EXPRESSION);
1861 @end smallexample
1862
1863 @noindent
1864 This pragma serves to export a static integer value for external use.
1865 The first argument specifies the value to be exported. The Link_Name
1866 argument specifies the symbolic name to be associated with the integer
1867 value. This pragma is useful for defining a named static value in Ada
1868 that can be referenced in assembly language units to be linked with
1869 the application. This pragma is currently supported only for the
1870 AAMP target and is ignored for other targets.
1871
1872 @node Pragma Export_Valued_Procedure
1873 @unnumberedsec Pragma Export_Valued_Procedure
1874 @findex Export_Valued_Procedure
1875 @noindent
1876 Syntax:
1877
1878 @smallexample @c ada
1879 pragma Export_Valued_Procedure (
1880      [Internal        =>] LOCAL_NAME
1881   [, [External        =>] EXTERNAL_SYMBOL]
1882   [, [Parameter_Types =>] PARAMETER_TYPES]
1883   [, [Mechanism       =>] MECHANISM]);
1884
1885 EXTERNAL_SYMBOL ::=
1886   IDENTIFIER
1887 | static_string_EXPRESSION
1888 | ""
1889
1890 PARAMETER_TYPES ::=
1891   null
1892 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1893
1894 TYPE_DESIGNATOR ::=
1895   subtype_NAME
1896 | subtype_Name ' Access
1897
1898 MECHANISM ::=
1899   MECHANISM_NAME
1900 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1901
1902 MECHANISM_ASSOCIATION ::=
1903   [formal_parameter_NAME =>] MECHANISM_NAME
1904
1905 MECHANISM_NAME ::=
1906   Value
1907 | Reference
1908 | Descriptor [([Class =>] CLASS_NAME)]
1909
1910 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
1911 @end smallexample
1912
1913 @noindent
1914 This pragma is identical to @code{Export_Procedure} except that the
1915 first parameter of @var{LOCAL_NAME}, which must be present, must be of
1916 mode @code{OUT}, and externally the subprogram is treated as a function
1917 with this parameter as the result of the function.  GNAT provides for
1918 this capability to allow the use of @code{OUT} and @code{IN OUT}
1919 parameters in interfacing to external functions (which are not permitted
1920 in Ada functions).
1921 GNAT does not require a separate pragma @code{Export}, but if none is
1922 present, @code{Convention Ada} is assumed, which is almost certainly
1923 not what is wanted since the whole point of this pragma is to interface
1924 with foreign language functions, so it is usually appropriate to use this
1925 pragma in conjunction with a @code{Export} or @code{Convention}
1926 pragma that specifies the desired foreign convention.
1927
1928 @cindex OpenVMS
1929 @cindex Passing by descriptor
1930 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
1931
1932 @cindex Suppressing external name
1933 Special treatment is given if the EXTERNAL is an explicit null
1934 string or a static string expressions that evaluates to the null
1935 string. In this case, no external name is generated. This form
1936 still allows the specification of parameter mechanisms.
1937
1938 @node Pragma Extend_System
1939 @unnumberedsec Pragma Extend_System
1940 @cindex @code{system}, extending
1941 @cindex Dec Ada 83
1942 @findex Extend_System
1943 @noindent
1944 Syntax:
1945
1946 @smallexample @c ada
1947 pragma Extend_System ([Name =>] IDENTIFIER);
1948 @end smallexample
1949
1950 @noindent
1951 This pragma is used to provide backwards compatibility with other
1952 implementations that extend the facilities of package @code{System}.  In
1953 GNAT, @code{System} contains only the definitions that are present in
1954 the Ada RM@.  However, other implementations, notably the DEC Ada 83
1955 implementation, provide many extensions to package @code{System}.
1956
1957 For each such implementation accommodated by this pragma, GNAT provides a
1958 package @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83
1959 implementation, which provides the required additional definitions.  You
1960 can use this package in two ways.  You can @code{with} it in the normal
1961 way and access entities either by selection or using a @code{use}
1962 clause.  In this case no special processing is required.
1963
1964 However, if existing code contains references such as
1965 @code{System.@var{xxx}} where @var{xxx} is an entity in the extended
1966 definitions provided in package @code{System}, you may use this pragma
1967 to extend visibility in @code{System} in a non-standard way that
1968 provides greater compatibility with the existing code.  Pragma
1969 @code{Extend_System} is a configuration pragma whose single argument is
1970 the name of the package containing the extended definition
1971 (e.g.@: @code{Aux_DEC} for the DEC Ada case).  A unit compiled under
1972 control of this pragma will be processed using special visibility
1973 processing that looks in package @code{System.Aux_@var{xxx}} where
1974 @code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
1975 package @code{System}, but not found in package @code{System}.
1976
1977 You can use this pragma either to access a predefined @code{System}
1978 extension supplied with the compiler, for example @code{Aux_DEC} or
1979 you can construct your own extension unit following the above
1980 definition.  Note that such a package is a child of @code{System}
1981 and thus is considered part of the implementation.  To compile
1982 it you will have to use the appropriate switch for compiling
1983 system units.  See the GNAT User's Guide for details.
1984
1985 @node Pragma External
1986 @unnumberedsec Pragma External
1987 @findex External
1988 @noindent
1989 Syntax:
1990
1991 @smallexample @c ada
1992 pragma External (
1993   [   Convention    =>] convention_IDENTIFIER,
1994   [   Entity        =>] LOCAL_NAME
1995   [, [External_Name =>] static_string_EXPRESSION ]
1996   [, [Link_Name     =>] static_string_EXPRESSION ]);
1997 @end smallexample
1998
1999 @noindent
2000 This pragma is identical in syntax and semantics to pragma
2001 @code{Export} as defined in the Ada Reference Manual.  It is
2002 provided for compatibility with some Ada 83 compilers that
2003 used this pragma for exactly the same purposes as pragma
2004 @code{Export} before the latter was standardized.
2005
2006 @node Pragma External_Name_Casing
2007 @unnumberedsec Pragma External_Name_Casing
2008 @cindex Dec Ada 83 casing compatibility
2009 @cindex External Names, casing
2010 @cindex Casing of External names
2011 @findex External_Name_Casing
2012 @noindent
2013 Syntax:
2014
2015 @smallexample @c ada
2016 pragma External_Name_Casing (
2017   Uppercase | Lowercase
2018   [, Uppercase | Lowercase | As_Is]);
2019 @end smallexample
2020
2021 @noindent
2022 This pragma provides control over the casing of external names associated
2023 with Import and Export pragmas.  There are two cases to consider:
2024
2025 @table @asis
2026 @item Implicit external names
2027 Implicit external names are derived from identifiers.  The most common case
2028 arises when a standard Ada Import or Export pragma is used with only two
2029 arguments, as in:
2030
2031 @smallexample @c ada
2032    pragma Import (C, C_Routine);
2033 @end smallexample
2034
2035 @noindent
2036 Since Ada is a case-insensitive language, the spelling of the identifier in
2037 the Ada source program does not provide any information on the desired
2038 casing of the external name, and so a convention is needed.  In GNAT the
2039 default treatment is that such names are converted to all lower case
2040 letters.  This corresponds to the normal C style in many environments.
2041 The first argument of pragma @code{External_Name_Casing} can be used to
2042 control this treatment.  If @code{Uppercase} is specified, then the name
2043 will be forced to all uppercase letters.  If @code{Lowercase} is specified,
2044 then the normal default of all lower case letters will be used.
2045
2046 This same implicit treatment is also used in the case of extended DEC Ada 83
2047 compatible Import and Export pragmas where an external name is explicitly
2048 specified using an identifier rather than a string.
2049
2050 @item Explicit external names
2051 Explicit external names are given as string literals.  The most common case
2052 arises when a standard Ada Import or Export pragma is used with three
2053 arguments, as in:
2054
2055 @smallexample @c ada
2056 pragma Import (C, C_Routine, "C_routine");
2057 @end smallexample
2058
2059 @noindent
2060 In this case, the string literal normally provides the exact casing required
2061 for the external name.  The second argument of pragma
2062 @code{External_Name_Casing} may be used to modify this behavior.
2063 If @code{Uppercase} is specified, then the name
2064 will be forced to all uppercase letters.  If @code{Lowercase} is specified,
2065 then the name will be forced to all lowercase letters.  A specification of
2066 @code{As_Is} provides the normal default behavior in which the casing is
2067 taken from the string provided.
2068 @end table
2069
2070 @noindent
2071 This pragma may appear anywhere that a pragma is valid.  In particular, it
2072 can be used as a configuration pragma in the @file{gnat.adc} file, in which
2073 case it applies to all subsequent compilations, or it can be used as a program
2074 unit pragma, in which case it only applies to the current unit, or it can
2075 be used more locally to control individual Import/Export pragmas.
2076
2077 It is primarily intended for use with OpenVMS systems, where many
2078 compilers convert all symbols to upper case by default.  For interfacing to
2079 such compilers (e.g.@: the DEC C compiler), it may be convenient to use
2080 the pragma:
2081
2082 @smallexample @c ada
2083 pragma External_Name_Casing (Uppercase, Uppercase);
2084 @end smallexample
2085
2086 @noindent
2087 to enforce the upper casing of all external symbols.
2088
2089 @node Pragma Fast_Math
2090 @unnumberedsec Pragma Fast_Math
2091 @findex Fast_Math
2092 @noindent
2093 Syntax:
2094
2095 @smallexample @c ada
2096 pragma Fast_Math;
2097 @end smallexample
2098
2099 @noindent
2100 This is a configuration pragma which activates a mode in which speed is
2101 considered more important for floating-point operations than absolutely
2102 accurate adherence to the requirements of the standard. Currently the
2103 following operations are affected:
2104
2105 @table @asis
2106 @item Complex Multiplication
2107 The normal simple formula for complex multiplication can result in intermediate
2108 overflows for numbers near the end of the range. The Ada standard requires that
2109 this situation be detected and corrected by scaling, but in Fast_Math mode such
2110 cases will simply result in overflow. Note that to take advantage of this you
2111 must instantiate your own version of @code{Ada.Numerics.Generic_Complex_Types}
2112 under control of the pragma, rather than use the preinstantiated versions.
2113 @end table
2114
2115 @node Pragma Favor_Top_Level
2116 @unnumberedsec Pragma Favor_Top_Level
2117 @findex Favor_Top_Level
2118 @noindent
2119 Syntax:
2120
2121 @smallexample @c ada
2122 pragma Favor_Top_Level (type_NAME);
2123 @end smallexample
2124
2125 @noindent
2126 The named type must be an access-to-subprogram type. This pragma is an
2127 efficiency hint to the compiler, regarding the use of 'Access or
2128 'Unrestricted_Access on nested (non-library-level) subprograms. The
2129 pragma means that nested subprograms are not used with this type, or
2130 are rare, so that the generated code should be efficient in the
2131 top-level case. When this pragma is used, dynamically generated
2132 trampolines may be used on some targets for nested subprograms.
2133 See also the No_Implicit_Dynamic_Code restriction.
2134
2135 @node Pragma Finalize_Storage_Only
2136 @unnumberedsec Pragma Finalize_Storage_Only
2137 @findex Finalize_Storage_Only
2138 @noindent
2139 Syntax:
2140
2141 @smallexample @c ada
2142 pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
2143 @end smallexample
2144
2145 @noindent
2146 This pragma allows the compiler not to emit a Finalize call for objects
2147 defined at the library level.  This is mostly useful for types where
2148 finalization is only used to deal with storage reclamation since in most
2149 environments it is not necessary to reclaim memory just before terminating
2150 execution, hence the name.
2151
2152 @node Pragma Float_Representation
2153 @unnumberedsec Pragma Float_Representation
2154 @cindex OpenVMS
2155 @findex Float_Representation
2156 @noindent
2157 Syntax:
2158
2159 @smallexample @c ada
2160 pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
2161
2162 FLOAT_REP ::= VAX_Float | IEEE_Float
2163 @end smallexample
2164
2165 @noindent
2166 In the one argument form, this pragma is a configuration pragma which
2167 allows control over the internal representation chosen for the predefined
2168 floating point types declared in the packages @code{Standard} and
2169 @code{System}. On all systems other than OpenVMS, the argument must
2170 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2171 argument may be @code{VAX_Float} to specify the use of the VAX float
2172 format for the floating-point types in Standard. This requires that
2173 the standard runtime libraries be recompiled. See the
2174 description of the @code{GNAT LIBRARY} command in the OpenVMS version
2175 of the GNAT Users Guide for details on the use of this command.
2176
2177 The two argument form specifies the representation to be used for
2178 the specified floating-point type. On all systems other than OpenVMS,
2179 the argument must
2180 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2181 argument may be @code{VAX_Float} to specify the use of the VAX float
2182 format, as follows:
2183
2184 @itemize @bullet
2185 @item
2186 For digits values up to 6, F float format will be used.
2187 @item
2188 For digits values from 7 to 9, G float format will be used.
2189 @item
2190 For digits values from 10 to 15, F float format will be used.
2191 @item
2192 Digits values above 15 are not allowed.
2193 @end itemize
2194
2195 @node Pragma Ident
2196 @unnumberedsec Pragma Ident
2197 @findex Ident
2198 @noindent
2199 Syntax:
2200
2201 @smallexample @c ada
2202 pragma Ident (static_string_EXPRESSION);
2203 @end smallexample
2204
2205 @noindent
2206 This pragma provides a string identification in the generated object file,
2207 if the system supports the concept of this kind of identification string.
2208 This pragma is allowed only in the outermost declarative part or
2209 declarative items of a compilation unit. If more than one @code{Ident}
2210 pragma is given, only the last one processed is effective.
2211 @cindex OpenVMS
2212 On OpenVMS systems, the effect of the pragma is identical to the effect of
2213 the DEC Ada 83 pragma of the same name. Note that in DEC Ada 83, the
2214 maximum allowed length is 31 characters, so if it is important to
2215 maintain compatibility with this compiler, you should obey this length
2216 limit.
2217
2218 @node Pragma Implemented_By_Entry
2219 @unnumberedsec Pragma Implemented_By_Entry
2220 @findex Implemented_By_Entry
2221 @noindent
2222 Syntax:
2223
2224 @smallexample @c ada
2225 pragma Implemented_By_Entry (LOCAL_NAME);
2226 @end smallexample
2227
2228 @noindent
2229 This is a representation pragma which applies to protected, synchronized and
2230 task interface primitives. If the pragma is applied to primitive operation Op
2231 of interface Iface, it is illegal to override Op in a type that implements
2232 Iface, with anything other than an entry.
2233
2234 @smallexample @c ada
2235 type Iface is protected interface;
2236 procedure Do_Something (Object : in out Iface) is abstract;
2237 pragma Implemented_By_Entry (Do_Something);
2238
2239 protected type P is new Iface with
2240    procedure Do_Something;  --  Illegal
2241 end P;
2242
2243 task type T is new Iface with
2244    entry Do_Something;      --  Legal
2245 end T;
2246 @end smallexample
2247
2248 @noindent
2249 NOTE: The pragma is still in its design stage by the Ada Rapporteur Group. It
2250 is intended to be used in conjunction with dispatching requeue statements as
2251 described in AI05-0030. Should the ARG decide on an official name and syntax,
2252 this pragma will become language-defined rather than GNAT-specific.
2253
2254 @node Pragma Implicit_Packing
2255 @unnumberedsec Pragma Implicit_Packing
2256 @findex Implicit_Packing
2257 @noindent
2258 Syntax:
2259
2260 @smallexample @c ada
2261 pragma Implicit_Packing;
2262 @end smallexample
2263
2264 @noindent
2265 This is a configuration pragma that requests implicit packing for packed
2266 arrays for which a size clause is given but no explicit pragma Pack or
2267 specification of Component_Size is present. Consider this example:
2268
2269 @smallexample @c ada
2270 type R is array (0 .. 7) of Boolean;
2271 for R'Size use 8;
2272 @end smallexample
2273
2274 @noindent
2275 In accordance with the recommendation in the RM (RM 13.3(53)), a Size clause
2276 does not change the layout of a composite object. So the Size clause in the
2277 above example is normally rejected, since the default layout of the array uses
2278 8-bit components, and thus the array requires a minimum of 64 bits.
2279
2280 If this declaration is compiled in a region of code covered by an occurrence
2281 of the configuration pragma Implicit_Packing, then the Size clause in this
2282 and similar examples will cause implicit packing and thus be accepted. For
2283 this implicit packing to occur, the type in question must be an array of small
2284 components whose size is known at compile time, and the Size clause must
2285 specify the exact size that corresponds to the length of the array multiplied
2286 by the size in bits of the component type.
2287 @cindex Array packing
2288
2289 @node Pragma Import_Exception
2290 @unnumberedsec Pragma Import_Exception
2291 @cindex OpenVMS
2292 @findex Import_Exception
2293 @noindent
2294 Syntax:
2295
2296 @smallexample @c ada
2297 pragma Import_Exception (
2298      [Internal =>] LOCAL_NAME
2299   [, [External =>] EXTERNAL_SYMBOL]
2300   [, [Form     =>] Ada | VMS]
2301   [, [Code     =>] static_integer_EXPRESSION]);
2302
2303 EXTERNAL_SYMBOL ::=
2304   IDENTIFIER
2305 | static_string_EXPRESSION
2306 @end smallexample
2307
2308 @noindent
2309 This pragma is implemented only in the OpenVMS implementation of GNAT@.
2310 It allows OpenVMS conditions (for example, from OpenVMS system services or
2311 other OpenVMS languages) to be propagated to Ada programs as Ada exceptions.
2312 The pragma specifies that the exception associated with an exception
2313 declaration in an Ada program be defined externally (in non-Ada code).
2314 For further details on this pragma, see the
2315 DEC Ada Language Reference Manual, section 13.9a.3.1.
2316
2317 @node Pragma Import_Function
2318 @unnumberedsec Pragma Import_Function
2319 @findex Import_Function
2320 @noindent
2321 Syntax:
2322
2323 @smallexample @c ada
2324 pragma Import_Function (
2325      [Internal                 =>] LOCAL_NAME,
2326   [, [External                 =>] EXTERNAL_SYMBOL]
2327   [, [Parameter_Types          =>] PARAMETER_TYPES]
2328   [, [Result_Type              =>] SUBTYPE_MARK]
2329   [, [Mechanism                =>] MECHANISM]
2330   [, [Result_Mechanism         =>] MECHANISM_NAME]
2331   [, [First_Optional_Parameter =>] IDENTIFIER]);
2332
2333 EXTERNAL_SYMBOL ::=
2334   IDENTIFIER
2335 | static_string_EXPRESSION
2336
2337 PARAMETER_TYPES ::=
2338   null
2339 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2340
2341 TYPE_DESIGNATOR ::=
2342   subtype_NAME
2343 | subtype_Name ' Access
2344
2345 MECHANISM ::=
2346   MECHANISM_NAME
2347 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2348
2349 MECHANISM_ASSOCIATION ::=
2350   [formal_parameter_NAME =>] MECHANISM_NAME
2351
2352 MECHANISM_NAME ::=
2353   Value
2354 | Reference
2355 | Descriptor [([Class =>] CLASS_NAME)]
2356
2357 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2358 @end smallexample
2359
2360 @noindent
2361 This pragma is used in conjunction with a pragma @code{Import} to
2362 specify additional information for an imported function.  The pragma
2363 @code{Import} (or equivalent pragma @code{Interface}) must precede the
2364 @code{Import_Function} pragma and both must appear in the same
2365 declarative part as the function specification.
2366
2367 The @var{Internal} argument must uniquely designate
2368 the function to which the
2369 pragma applies.  If more than one function name exists of this name in
2370 the declarative part you must use the @code{Parameter_Types} and
2371 @var{Result_Type} parameters to achieve the required unique
2372 designation.  Subtype marks in these parameters must exactly match the
2373 subtypes in the corresponding function specification, using positional
2374 notation to match parameters with subtype marks.
2375 The form with an @code{'Access} attribute can be used to match an
2376 anonymous access parameter.
2377
2378 You may optionally use the @var{Mechanism} and @var{Result_Mechanism}
2379 parameters to specify passing mechanisms for the
2380 parameters and result.  If you specify a single mechanism name, it
2381 applies to all parameters.  Otherwise you may specify a mechanism on a
2382 parameter by parameter basis using either positional or named
2383 notation.  If the mechanism is not specified, the default mechanism
2384 is used.
2385
2386 @cindex OpenVMS
2387 @cindex Passing by descriptor
2388 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2389
2390 @code{First_Optional_Parameter} applies only to OpenVMS ports of GNAT@.
2391 It specifies that the designated parameter and all following parameters
2392 are optional, meaning that they are not passed at the generated code
2393 level (this is distinct from the notion of optional parameters in Ada
2394 where the parameters are passed anyway with the designated optional
2395 parameters).  All optional parameters must be of mode @code{IN} and have
2396 default parameter values that are either known at compile time
2397 expressions, or uses of the @code{'Null_Parameter} attribute.
2398
2399 @node Pragma Import_Object
2400 @unnumberedsec Pragma Import_Object
2401 @findex Import_Object
2402 @noindent
2403 Syntax:
2404
2405 @smallexample @c ada
2406 pragma Import_Object
2407      [Internal =>] LOCAL_NAME
2408   [, [External =>] EXTERNAL_SYMBOL]
2409   [, [Size     =>] EXTERNAL_SYMBOL]);
2410
2411 EXTERNAL_SYMBOL ::=
2412   IDENTIFIER
2413 | static_string_EXPRESSION
2414 @end smallexample
2415
2416 @noindent
2417 This pragma designates an object as imported, and apart from the
2418 extended rules for external symbols, is identical in effect to the use of
2419 the normal @code{Import} pragma applied to an object.  Unlike the
2420 subprogram case, you need not use a separate @code{Import} pragma,
2421 although you may do so (and probably should do so from a portability
2422 point of view).  @var{size} is syntax checked, but otherwise ignored by
2423 GNAT@.
2424
2425 @node Pragma Import_Procedure
2426 @unnumberedsec Pragma Import_Procedure
2427 @findex Import_Procedure
2428 @noindent
2429 Syntax:
2430
2431 @smallexample @c ada
2432 pragma Import_Procedure (
2433      [Internal                 =>] LOCAL_NAME
2434   [, [External                 =>] EXTERNAL_SYMBOL]
2435   [, [Parameter_Types          =>] PARAMETER_TYPES]
2436   [, [Mechanism                =>] MECHANISM]
2437   [, [First_Optional_Parameter =>] IDENTIFIER]);
2438
2439 EXTERNAL_SYMBOL ::=
2440   IDENTIFIER
2441 | static_string_EXPRESSION
2442
2443 PARAMETER_TYPES ::=
2444   null
2445 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2446
2447 TYPE_DESIGNATOR ::=
2448   subtype_NAME
2449 | subtype_Name ' Access
2450
2451 MECHANISM ::=
2452   MECHANISM_NAME
2453 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2454
2455 MECHANISM_ASSOCIATION ::=
2456   [formal_parameter_NAME =>] MECHANISM_NAME
2457
2458 MECHANISM_NAME ::=
2459   Value
2460 | Reference
2461 | Descriptor [([Class =>] CLASS_NAME)]
2462
2463 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2464 @end smallexample
2465
2466 @noindent
2467 This pragma is identical to @code{Import_Function} except that it
2468 applies to a procedure rather than a function and the parameters
2469 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2470
2471 @node Pragma Import_Valued_Procedure
2472 @unnumberedsec Pragma Import_Valued_Procedure
2473 @findex Import_Valued_Procedure
2474 @noindent
2475 Syntax:
2476
2477 @smallexample @c ada
2478 pragma Import_Valued_Procedure (
2479      [Internal                 =>] LOCAL_NAME
2480   [, [External                 =>] EXTERNAL_SYMBOL]
2481   [, [Parameter_Types          =>] PARAMETER_TYPES]
2482   [, [Mechanism                =>] MECHANISM]
2483   [, [First_Optional_Parameter =>] IDENTIFIER]);
2484
2485 EXTERNAL_SYMBOL ::=
2486   IDENTIFIER
2487 | static_string_EXPRESSION
2488
2489 PARAMETER_TYPES ::=
2490   null
2491 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2492
2493 TYPE_DESIGNATOR ::=
2494   subtype_NAME
2495 | subtype_Name ' Access
2496
2497 MECHANISM ::=
2498   MECHANISM_NAME
2499 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2500
2501 MECHANISM_ASSOCIATION ::=
2502   [formal_parameter_NAME =>] MECHANISM_NAME
2503
2504 MECHANISM_NAME ::=
2505   Value
2506 | Reference
2507 | Descriptor [([Class =>] CLASS_NAME)]
2508
2509 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2510 @end smallexample
2511
2512 @noindent
2513 This pragma is identical to @code{Import_Procedure} except that the
2514 first parameter of @var{LOCAL_NAME}, which must be present, must be of
2515 mode @code{OUT}, and externally the subprogram is treated as a function
2516 with this parameter as the result of the function.  The purpose of this
2517 capability is to allow the use of @code{OUT} and @code{IN OUT}
2518 parameters in interfacing to external functions (which are not permitted
2519 in Ada functions).  You may optionally use the @code{Mechanism}
2520 parameters to specify passing mechanisms for the parameters.
2521 If you specify a single mechanism name, it applies to all parameters.
2522 Otherwise you may specify a mechanism on a parameter by parameter
2523 basis using either positional or named notation.  If the mechanism is not
2524 specified, the default mechanism is used.
2525
2526 Note that it is important to use this pragma in conjunction with a separate
2527 pragma Import that specifies the desired convention, since otherwise the
2528 default convention is Ada, which is almost certainly not what is required.
2529
2530 @node Pragma Initialize_Scalars
2531 @unnumberedsec Pragma Initialize_Scalars
2532 @findex Initialize_Scalars
2533 @cindex debugging with Initialize_Scalars
2534 @noindent
2535 Syntax:
2536
2537 @smallexample @c ada
2538 pragma Initialize_Scalars;
2539 @end smallexample
2540
2541 @noindent
2542 This pragma is similar to @code{Normalize_Scalars} conceptually but has
2543 two important differences.  First, there is no requirement for the pragma
2544 to be used uniformly in all units of a partition, in particular, it is fine
2545 to use this just for some or all of the application units of a partition,
2546 without needing to recompile the run-time library.
2547
2548 In the case where some units are compiled with the pragma, and some without,
2549 then a declaration of a variable where the type is defined in package
2550 Standard or is locally declared will always be subject to initialization,
2551 as will any declaration of a scalar variable.  For composite variables,
2552 whether the variable is initialized may also depend on whether the package
2553 in which the type of the variable is declared is compiled with the pragma.
2554
2555 The other important difference is that you can control the value used
2556 for initializing scalar objects.  At bind time, you can select several
2557 options for initialization. You can
2558 initialize with invalid values (similar to Normalize_Scalars, though for
2559 Initialize_Scalars it is not always possible to determine the invalid
2560 values in complex cases like signed component fields with non-standard
2561 sizes). You can also initialize with high or
2562 low values, or with a specified bit pattern.  See the users guide for binder
2563 options for specifying these cases.
2564
2565 This means that you can compile a program, and then without having to
2566 recompile the program, you can run it with different values being used
2567 for initializing otherwise uninitialized values, to test if your program
2568 behavior depends on the choice.  Of course the behavior should not change,
2569 and if it does, then most likely you have an erroneous reference to an
2570 uninitialized value.
2571
2572 It is even possible to change the value at execution time eliminating even
2573 the need to rebind with a different switch using an environment variable.
2574 See the GNAT users guide for details.
2575
2576 Note that pragma @code{Initialize_Scalars} is particularly useful in
2577 conjunction with the enhanced validity checking that is now provided
2578 in GNAT, which checks for invalid values under more conditions.
2579 Using this feature (see description of the @option{-gnatV} flag in the
2580 users guide) in conjunction with pragma @code{Initialize_Scalars}
2581 provides a powerful new tool to assist in the detection of problems
2582 caused by uninitialized variables.
2583
2584 Note: the use of @code{Initialize_Scalars} has a fairly extensive
2585 effect on the generated code. This may cause your code to be
2586 substantially larger. It may also cause an increase in the amount
2587 of stack required, so it is probably a good idea to turn on stack
2588 checking (see description of stack checking in the GNAT users guide)
2589 when using this pragma.
2590
2591 @node Pragma Inline_Always
2592 @unnumberedsec Pragma Inline_Always
2593 @findex Inline_Always
2594 @noindent
2595 Syntax:
2596
2597 @smallexample @c ada
2598 pragma Inline_Always (NAME [, NAME]);
2599 @end smallexample
2600
2601 @noindent
2602 Similar to pragma @code{Inline} except that inlining is not subject to
2603 the use of option @option{-gnatn} and the inlining happens regardless of
2604 whether this option is used.
2605
2606 @node Pragma Inline_Generic
2607 @unnumberedsec Pragma Inline_Generic
2608 @findex Inline_Generic
2609 @noindent
2610 Syntax:
2611
2612 @smallexample @c ada
2613 pragma Inline_Generic (generic_package_NAME);
2614 @end smallexample
2615
2616 @noindent
2617 This is implemented for compatibility with DEC Ada 83 and is recognized,
2618 but otherwise ignored, by GNAT@.  All generic instantiations are inlined
2619 by default when using GNAT@.
2620
2621 @node Pragma Interface
2622 @unnumberedsec Pragma Interface
2623 @findex Interface
2624 @noindent
2625 Syntax:
2626
2627 @smallexample @c ada
2628 pragma Interface (
2629      [Convention    =>] convention_identifier,
2630      [Entity        =>] local_NAME
2631   [, [External_Name =>] static_string_expression]
2632   [, [Link_Name     =>] static_string_expression]);
2633 @end smallexample
2634
2635 @noindent
2636 This pragma is identical in syntax and semantics to
2637 the standard Ada pragma @code{Import}.  It is provided for compatibility
2638 with Ada 83.  The definition is upwards compatible both with pragma
2639 @code{Interface} as defined in the Ada 83 Reference Manual, and also
2640 with some extended implementations of this pragma in certain Ada 83
2641 implementations.
2642
2643 @node Pragma Interface_Name
2644 @unnumberedsec Pragma Interface_Name
2645 @findex Interface_Name
2646 @noindent
2647 Syntax:
2648
2649 @smallexample @c ada
2650 pragma Interface_Name (
2651      [Entity        =>] LOCAL_NAME
2652   [, [External_Name =>] static_string_EXPRESSION]
2653   [, [Link_Name     =>] static_string_EXPRESSION]);
2654 @end smallexample
2655
2656 @noindent
2657 This pragma provides an alternative way of specifying the interface name
2658 for an interfaced subprogram, and is provided for compatibility with Ada
2659 83 compilers that use the pragma for this purpose.  You must provide at
2660 least one of @var{External_Name} or @var{Link_Name}.
2661
2662 @node Pragma Interrupt_Handler
2663 @unnumberedsec Pragma Interrupt_Handler
2664 @findex Interrupt_Handler
2665 @noindent
2666 Syntax:
2667
2668 @smallexample @c ada
2669 pragma Interrupt_Handler (procedure_LOCAL_NAME);
2670 @end smallexample
2671
2672 @noindent
2673 This program unit pragma is supported for parameterless protected procedures
2674 as described in Annex C of the Ada Reference Manual. On the AAMP target
2675 the pragma can also be specified for nonprotected parameterless procedures
2676 that are declared at the library level (which includes procedures
2677 declared at the top level of a library package). In the case of AAMP,
2678 when this pragma is applied to a nonprotected procedure, the instruction
2679 @code{IERET} is generated for returns from the procedure, enabling
2680 maskable interrupts, in place of the normal return instruction.
2681
2682 @node Pragma Interrupt_State
2683 @unnumberedsec Pragma Interrupt_State
2684 @findex Interrupt_State
2685 @noindent
2686 Syntax:
2687
2688 @smallexample @c ada
2689 pragma Interrupt_State (Name => value, State => SYSTEM | RUNTIME | USER);
2690 @end smallexample
2691
2692 @noindent
2693 Normally certain interrupts are reserved to the implementation.  Any attempt
2694 to attach an interrupt causes Program_Error to be raised, as described in
2695 RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
2696 many systems for an @kbd{Ctrl-C} interrupt.  Normally this interrupt is
2697 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
2698 interrupt execution.  Additionally, signals such as @code{SIGSEGV},
2699 @code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
2700 Ada exceptions, or used to implement run-time functions such as the
2701 @code{abort} statement and stack overflow checking.
2702
2703 Pragma @code{Interrupt_State} provides a general mechanism for overriding
2704 such uses of interrupts.  It subsumes the functionality of pragma
2705 @code{Unreserve_All_Interrupts}.  Pragma @code{Interrupt_State} is not
2706 available on OS/2, Windows or VMS.  On all other platforms than VxWorks,
2707 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
2708 and may be used to mark interrupts required by the board support package
2709 as reserved.
2710
2711 Interrupts can be in one of three states:
2712 @itemize @bullet
2713 @item System
2714
2715 The interrupt is reserved (no Ada handler can be installed), and the
2716 Ada run-time may not install a handler. As a result you are guaranteed
2717 standard system default action if this interrupt is raised.
2718
2719 @item Runtime
2720
2721 The interrupt is reserved (no Ada handler can be installed). The run time
2722 is allowed to install a handler for internal control purposes, but is
2723 not required to do so.
2724
2725 @item User
2726
2727 The interrupt is unreserved.  The user may install a handler to provide
2728 some other action.
2729 @end itemize
2730
2731 @noindent
2732 These states are the allowed values of the @code{State} parameter of the
2733 pragma.  The @code{Name} parameter is a value of the type
2734 @code{Ada.Interrupts.Interrupt_ID}.  Typically, it is a name declared in
2735 @code{Ada.Interrupts.Names}.
2736
2737 This is a configuration pragma, and the binder will check that there
2738 are no inconsistencies between different units in a partition in how a
2739 given interrupt is specified. It may appear anywhere a pragma is legal.
2740
2741 The effect is to move the interrupt to the specified state.
2742
2743 By declaring interrupts to be SYSTEM, you guarantee the standard system
2744 action, such as a core dump.
2745
2746 By declaring interrupts to be USER, you guarantee that you can install
2747 a handler.
2748
2749 Note that certain signals on many operating systems cannot be caught and
2750 handled by applications.  In such cases, the pragma is ignored.  See the
2751 operating system documentation, or the value of the array @code{Reserved}
2752 declared in the specification of package @code{System.OS_Interface}.
2753
2754 Overriding the default state of signals used by the Ada runtime may interfere
2755 with an application's runtime behavior in the cases of the synchronous signals,
2756 and in the case of the signal used to implement the @code{abort} statement.
2757
2758 @node Pragma Keep_Names
2759 @unnumberedsec Pragma Keep_Names
2760 @findex Keep_Names
2761 @noindent
2762 Syntax:
2763
2764 @smallexample @c ada
2765 pragma Keep_Names ([On =>] enumeration_first_subtype_LOCAL_NAME);
2766 @end smallexample
2767
2768 @noindent
2769 The @var{LOCAL_NAME} argument
2770 must refer to an enumeration first subtype
2771 in the current declarative part. The effect is to retain the enumeration
2772 literal names for use by @code{Image} and @code{Value} even if a global
2773 @code{Discard_Names} pragma applies. This is useful when you want to
2774 generally suppress enumeration literal names and for example you therefore
2775 use a @code{Discard_Names} pragma in the @file{gnat.adc} file, but you
2776 want to retain the names for specific enumeration types.
2777
2778 @node Pragma License
2779 @unnumberedsec Pragma License
2780 @findex License
2781 @cindex License checking
2782 @noindent
2783 Syntax:
2784
2785 @smallexample @c ada
2786 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
2787 @end smallexample
2788
2789 @noindent
2790 This pragma is provided to allow automated checking for appropriate license
2791 conditions with respect to the standard and modified GPL@.  A pragma
2792 @code{License}, which is a configuration pragma that typically appears at
2793 the start of a source file or in a separate @file{gnat.adc} file, specifies
2794 the licensing conditions of a unit as follows:
2795
2796 @itemize @bullet
2797 @item Unrestricted
2798 This is used for a unit that can be freely used with no license restrictions.
2799 Examples of such units are public domain units, and units from the Ada
2800 Reference Manual.
2801
2802 @item GPL
2803 This is used for a unit that is licensed under the unmodified GPL, and which
2804 therefore cannot be @code{with}'ed by a restricted unit.
2805
2806 @item Modified_GPL
2807 This is used for a unit licensed under the GNAT modified GPL that includes
2808 a special exception paragraph that specifically permits the inclusion of
2809 the unit in programs without requiring the entire program to be released
2810 under the GPL@.
2811
2812 @item Restricted
2813 This is used for a unit that is restricted in that it is not permitted to
2814 depend on units that are licensed under the GPL@.  Typical examples are
2815 proprietary code that is to be released under more restrictive license
2816 conditions.  Note that restricted units are permitted to @code{with} units
2817 which are licensed under the modified GPL (this is the whole point of the
2818 modified GPL).
2819
2820 @end itemize
2821
2822 @noindent
2823 Normally a unit with no @code{License} pragma is considered to have an
2824 unknown license, and no checking is done.  However, standard GNAT headers
2825 are recognized, and license information is derived from them as follows.
2826
2827 @itemize @bullet
2828
2829 A GNAT license header starts with a line containing 78 hyphens.  The following
2830 comment text is searched for the appearance of any of the following strings.
2831
2832 If the string ``GNU General Public License'' is found, then the unit is assumed
2833 to have GPL license, unless the string ``As a special exception'' follows, in
2834 which case the license is assumed to be modified GPL@.
2835
2836 If one of the strings
2837 ``This specification is adapted from the Ada Semantic Interface'' or
2838 ``This specification is derived from the Ada Reference Manual'' is found
2839 then the unit is assumed to be unrestricted.
2840 @end itemize
2841
2842 @noindent
2843 These default actions means that a program with a restricted license pragma
2844 will automatically get warnings if a GPL unit is inappropriately
2845 @code{with}'ed.  For example, the program:
2846
2847 @smallexample @c ada
2848 with Sem_Ch3;
2849 with GNAT.Sockets;
2850 procedure Secret_Stuff is
2851   @dots{}
2852 end Secret_Stuff
2853 @end smallexample
2854
2855 @noindent
2856 if compiled with pragma @code{License} (@code{Restricted}) in a
2857 @file{gnat.adc} file will generate the warning:
2858
2859 @smallexample
2860 1.  with Sem_Ch3;
2861         |
2862    >>> license of withed unit "Sem_Ch3" is incompatible
2863
2864 2.  with GNAT.Sockets;
2865 3.  procedure Secret_Stuff is
2866 @end smallexample
2867
2868 @noindent
2869 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
2870 compiler and is licensed under the
2871 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
2872 run time, and is therefore licensed under the modified GPL@.
2873
2874 @node Pragma Link_With
2875 @unnumberedsec Pragma Link_With
2876 @findex Link_With
2877 @noindent
2878 Syntax:
2879
2880 @smallexample @c ada
2881 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
2882 @end smallexample
2883
2884 @noindent
2885 This pragma is provided for compatibility with certain Ada 83 compilers.
2886 It has exactly the same effect as pragma @code{Linker_Options} except
2887 that spaces occurring within one of the string expressions are treated
2888 as separators. For example, in the following case:
2889
2890 @smallexample @c ada
2891 pragma Link_With ("-labc -ldef");
2892 @end smallexample
2893
2894 @noindent
2895 results in passing the strings @code{-labc} and @code{-ldef} as two
2896 separate arguments to the linker. In addition pragma Link_With allows
2897 multiple arguments, with the same effect as successive pragmas.
2898
2899 @node Pragma Linker_Alias
2900 @unnumberedsec Pragma Linker_Alias
2901 @findex Linker_Alias
2902 @noindent
2903 Syntax:
2904
2905 @smallexample @c ada
2906 pragma Linker_Alias (
2907   [Entity =>] LOCAL_NAME,
2908   [Target =>] static_string_EXPRESSION);
2909 @end smallexample
2910
2911 @noindent
2912 @var{LOCAL_NAME} must refer to an object that is declared at the library
2913 level. This pragma establishes the given entity as a linker alias for the
2914 given target. It is equivalent to @code{__attribute__((alias))} in GNU C
2915 and causes @var{LOCAL_NAME} to be emitted as an alias for the symbol
2916 @var{static_string_EXPRESSION} in the object file, that is to say no space
2917 is reserved for @var{LOCAL_NAME} by the assembler and it will be resolved
2918 to the same address as @var{static_string_EXPRESSION} by the linker.
2919
2920 The actual linker name for the target must be used (e.g. the fully
2921 encoded name with qualification in Ada, or the mangled name in C++),
2922 or it must be declared using the C convention with @code{pragma Import}
2923 or @code{pragma Export}.
2924
2925 Not all target machines support this pragma. On some of them it is accepted
2926 only if @code{pragma Weak_External} has been applied to @var{LOCAL_NAME}.
2927
2928 @smallexample @c ada
2929 --  Example of the use of pragma Linker_Alias
2930
2931 package p is
2932   i : Integer := 1;
2933   pragma Export (C, i);
2934
2935   new_name_for_i : Integer;
2936   pragma Linker_Alias (new_name_for_i, "i");
2937 end p;
2938 @end smallexample
2939
2940 @node Pragma Linker_Constructor
2941 @unnumberedsec Pragma Linker_Constructor
2942 @findex Linker_Constructor
2943 @noindent
2944 Syntax:
2945
2946 @smallexample @c ada
2947 pragma Linker_Constructor (procedure_LOCAL_NAME);
2948 @end smallexample
2949
2950 @noindent
2951 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
2952 is declared at the library level. A procedure to which this pragma is
2953 applied will be treated as an initialization routine by the linker.
2954 It is equivalent to @code{__attribute__((constructor))} in GNU C and
2955 causes @var{procedure_LOCAL_NAME} to be invoked before the entry point
2956 of the executable is called (or immediately after the shared library is
2957 loaded if the procedure is linked in a shared library), in particular
2958 before the Ada run-time environment is set up.
2959
2960 Because of these specific contexts, the set of operations such a procedure
2961 can perform is very limited and the type of objects it can manipulate is
2962 essentially restricted to the elementary types. In particular, it must only
2963 contain code to which pragma Restrictions (No_Elaboration_Code) applies.
2964
2965 This pragma is used by GNAT to implement auto-initialization of shared Stand
2966 Alone Libraries, which provides a related capability without the restrictions
2967 listed above. Where possible, the use of Stand Alone Libraries is preferable
2968 to the use of this pragma.
2969
2970 @node Pragma Linker_Destructor
2971 @unnumberedsec Pragma Linker_Destructor
2972 @findex Linker_Destructor
2973 @noindent
2974 Syntax:
2975
2976 @smallexample @c ada
2977 pragma Linker_Destructor (procedure_LOCAL_NAME);
2978 @end smallexample
2979
2980 @noindent
2981 @var{procedure_LOCAL_NAME} must refer to a parameterless procedure that
2982 is declared at the library level. A procedure to which this pragma is
2983 applied will be treated as a finalization routine by the linker.
2984 It is equivalent to @code{__attribute__((destructor))} in GNU C and
2985 causes @var{procedure_LOCAL_NAME} to be invoked after the entry point
2986 of the executable has exited (or immediately before the shared library
2987 is unloaded if the procedure is linked in a shared library), in particular
2988 after the Ada run-time environment is shut down.
2989
2990 See @code{pragma Linker_Constructor} for the set of restrictions that apply
2991 because of these specific contexts.
2992
2993 @node Pragma Linker_Section
2994 @unnumberedsec Pragma Linker_Section
2995 @findex Linker_Section
2996 @noindent
2997 Syntax:
2998
2999 @smallexample @c ada
3000 pragma Linker_Section (
3001   [Entity  =>] LOCAL_NAME,
3002   [Section =>] static_string_EXPRESSION);
3003 @end smallexample
3004
3005 @noindent
3006 @var{LOCAL_NAME} must refer to an object that is declared at the library
3007 level. This pragma specifies the name of the linker section for the given
3008 entity. It is equivalent to @code{__attribute__((section))} in GNU C and
3009 causes @var{LOCAL_NAME} to be placed in the @var{static_string_EXPRESSION}
3010 section of the executable (assuming the linker doesn't rename the section).
3011
3012 The compiler normally places library-level objects in standard sections
3013 depending on their type: procedures and functions generally go in the
3014 @code{.text} section, initialized variables in the @code{.data} section
3015 and uninitialized variables in the @code{.bss} section.
3016
3017 Other, special sections may exist on given target machines to map special
3018 hardware, for example I/O ports or flash memory. This pragma is a means to
3019 defer the final layout of the executable to the linker, thus fully working
3020 at the symbolic level with the compiler.
3021
3022 Some file formats do not support arbitrary sections so not all target
3023 machines support this pragma. The use of this pragma may cause a program
3024 execution to be erroneous if it is used to place an entity into an
3025 inappropriate section (e.g. a modified variable into the @code{.text}
3026 section). See also @code{pragma Persistent_BSS}.
3027
3028 @smallexample @c ada
3029 --  Example of the use of pragma Linker_Section
3030
3031 package IO_Card is
3032   Port_A : Integer;
3033   pragma Volatile (Port_A);
3034   pragma Linker_Section (Port_A, ".bss.port_a");
3035
3036   Port_B : Integer;
3037   pragma Volatile (Port_B);
3038   pragma Linker_Section (Port_B, ".bss.port_b");
3039 end IO_Card;
3040 @end smallexample
3041
3042 @node Pragma Long_Float
3043 @unnumberedsec Pragma Long_Float
3044 @cindex OpenVMS
3045 @findex Long_Float
3046 @noindent
3047 Syntax:
3048
3049 @smallexample @c ada
3050 pragma Long_Float (FLOAT_FORMAT);
3051
3052 FLOAT_FORMAT ::= D_Float | G_Float
3053 @end smallexample
3054
3055 @noindent
3056 This pragma is implemented only in the OpenVMS implementation of GNAT@.
3057 It allows control over the internal representation chosen for the predefined
3058 type @code{Long_Float} and for floating point type representations with
3059 @code{digits} specified in the range 7 through 15.
3060 For further details on this pragma, see the
3061 @cite{DEC Ada Language Reference Manual}, section 3.5.7b.  Note that to use
3062 this pragma, the standard runtime libraries must be recompiled.  See the
3063 description of the @code{GNAT LIBRARY} command in the OpenVMS version
3064 of the GNAT User's Guide for details on the use of this command.
3065
3066 @node Pragma Machine_Attribute
3067 @unnumberedsec Pragma Machine_Attribute
3068 @findex Machine_Attribute
3069 @noindent
3070 Syntax:
3071
3072 @smallexample @c ada
3073 pragma Machine_Attribute (
3074      [Entity         =>] LOCAL_NAME,
3075      [Attribute_Name =>] static_string_EXPRESSION
3076   [, [Info           =>] static_string_EXPRESSION] );
3077 @end smallexample
3078
3079 @noindent
3080 Machine-dependent attributes can be specified for types and/or
3081 declarations.  This pragma is semantically equivalent to
3082 @code{__attribute__((@var{attribute_name}))} (if @var{info} is not
3083 specified) or @code{__attribute__((@var{attribute_name}(@var{info})))}
3084 in GNU C, where @code{@var{attribute_name}} is recognized by the
3085 target macro @code{TARGET_ATTRIBUTE_TABLE} which is defined for each
3086 machine.  The optional parameter @var{info} is transformed into an
3087 identifier, which may make this pragma unusable for some attributes
3088 (parameter of some attributes must be a number or a string). See the
3089 GCC manual for further information.  It is not possible to specify
3090 attributes defined by other languages, only attributes defined by the
3091 machine the code is intended to run on.
3092
3093 @node Pragma Main
3094 @unnumberedsec Pragma Main
3095 @cindex OpenVMS
3096 @findex Main
3097 @noindent
3098 Syntax:
3099
3100 @smallexample @c ada
3101 pragma Main
3102  (MAIN_OPTION [, MAIN_OPTION]);
3103
3104 MAIN_OPTION ::=
3105   [STACK_SIZE              =>] static_integer_EXPRESSION
3106 | [TASK_STACK_SIZE_DEFAULT =>] static_integer_EXPRESSION
3107 | [TIME_SLICING_ENABLED    =>] static_boolean_EXPRESSION
3108 @end smallexample
3109
3110 @noindent
3111 This pragma is provided for compatibility with OpenVMS VAX Systems.  It has
3112 no effect in GNAT, other than being syntax checked.
3113
3114 @node Pragma Main_Storage
3115 @unnumberedsec Pragma Main_Storage
3116 @cindex OpenVMS
3117 @findex Main_Storage
3118 @noindent
3119 Syntax:
3120
3121 @smallexample @c ada
3122 pragma Main_Storage
3123   (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
3124
3125 MAIN_STORAGE_OPTION ::=
3126   [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
3127 | [TOP_GUARD       =>] static_SIMPLE_EXPRESSION
3128 @end smallexample
3129
3130 @noindent
3131 This pragma is provided for compatibility with OpenVMS VAX Systems.  It has
3132 no effect in GNAT, other than being syntax checked.  Note that the pragma
3133 also has no effect in DEC Ada 83 for OpenVMS Alpha Systems.
3134
3135 @node Pragma No_Body
3136 @unnumberedsec Pragma No_Body
3137 @findex No_Body
3138 @noindent
3139 Syntax:
3140
3141 @smallexample @c ada
3142 pragma No_Body;
3143 @end smallexample
3144
3145 @noindent
3146 There are a number of cases in which a package spec does not require a body,
3147 and in fact a body is not permitted. GNAT will not permit the spec to be
3148 compiled if there is a body around. The pragma No_Body allows you to provide
3149 a body file, even in a case where no body is allowed. The body file must
3150 contain only comments and a single No_Body pragma. This is recognized by
3151 the compiler as indicating that no body is logically present.
3152
3153 This is particularly useful during maintenance when a package is modified in
3154 such a way that a body needed before is no longer needed. The provision of a
3155 dummy body with a No_Body pragma ensures that there is no interference from
3156 earlier versions of the package body.
3157
3158 @node Pragma No_Return
3159 @unnumberedsec Pragma No_Return
3160 @findex No_Return
3161 @noindent
3162 Syntax:
3163
3164 @smallexample @c ada
3165 pragma No_Return (procedure_LOCAL_NAME @{, procedure_LOCAL_NAME@});
3166 @end smallexample
3167
3168 @noindent
3169 Each @var{procedure_LOCAL_NAME} argument must refer to one or more procedure
3170 declarations in the current declarative part.  A procedure to which this
3171 pragma is applied may not contain any explicit @code{return} statements.
3172 In addition, if the procedure contains any implicit returns from falling
3173 off the end of a statement sequence, then execution of that implicit
3174 return will cause Program_Error to be raised.
3175
3176 One use of this pragma is to identify procedures whose only purpose is to raise
3177 an exception. Another use of this pragma is to suppress incorrect warnings
3178 about missing returns in functions, where the last statement of a function
3179 statement sequence is a call to such a procedure.
3180
3181 Note that in Ada 2005 mode, this pragma is part of the language, and is
3182 identical in effect to the pragma as implemented in Ada 95 mode.
3183
3184 @node Pragma No_Strict_Aliasing
3185 @unnumberedsec Pragma No_Strict_Aliasing
3186 @findex No_Strict_Aliasing
3187 @noindent
3188 Syntax:
3189
3190 @smallexample @c ada
3191 pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
3192 @end smallexample
3193
3194 @noindent
3195 @var{type_LOCAL_NAME} must refer to an access type
3196 declaration in the current declarative part.  The effect is to inhibit
3197 strict aliasing optimization for the given type.  The form with no
3198 arguments is a configuration pragma which applies to all access types
3199 declared in units to which the pragma applies. For a detailed
3200 description of the strict aliasing optimization, and the situations
3201 in which it must be suppressed, see section
3202 ``Optimization and Strict Aliasing'' in the @value{EDITION} User's Guide.
3203
3204 @node Pragma Normalize_Scalars
3205 @unnumberedsec Pragma Normalize_Scalars
3206 @findex Normalize_Scalars
3207 @noindent
3208 Syntax:
3209
3210 @smallexample @c ada
3211 pragma Normalize_Scalars;
3212 @end smallexample
3213
3214 @noindent
3215 This is a language defined pragma which is fully implemented in GNAT@.  The
3216 effect is to cause all scalar objects that are not otherwise initialized
3217 to be initialized.  The initial values are implementation dependent and
3218 are as follows:
3219
3220 @table @code
3221 @item Standard.Character
3222 @noindent
3223 Objects whose root type is Standard.Character are initialized to
3224 Character'Last unless the subtype range excludes NUL (in which case
3225 NUL is used). This choice will always generate an invalid value if
3226 one exists.
3227
3228 @item Standard.Wide_Character
3229 @noindent
3230 Objects whose root type is Standard.Wide_Character are initialized to
3231 Wide_Character'Last unless the subtype range excludes NUL (in which case
3232 NUL is used). This choice will always generate an invalid value if
3233 one exists.
3234
3235 @item Standard.Wide_Wide_Character
3236 @noindent
3237 Objects whose root type is Standard.Wide_Wide_Character are initialized to
3238 the invalid value 16#FFFF_FFFF# unless the subtype range excludes NUL (in
3239 which case NUL is used). This choice will always generate an invalid value if
3240 one exists.
3241
3242 @item Integer types
3243 @noindent
3244 Objects of an integer type are treated differently depending on whether
3245 negative values are present in the subtype. If no negative values are
3246 present, then all one bits is used as the initial value except in the
3247 special case where zero is excluded from the subtype, in which case
3248 all zero bits are used. This choice will always generate an invalid
3249 value if one exists.
3250
3251 For subtypes with negative values present, the largest negative number
3252 is used, except in the unusual case where this largest negative number
3253 is in the subtype, and the largest positive number is not, in which case
3254 the largest positive value is used. This choice will always generate
3255 an invalid value if one exists.
3256
3257 @item Floating-Point Types
3258 Objects of all floating-point types are initialized to all 1-bits. For
3259 standard IEEE format, this corresponds to a NaN (not a number) which is
3260 indeed an invalid value.
3261
3262 @item Fixed-Point Types
3263 Objects of all fixed-point types are treated as described above for integers,
3264 with the rules applying to the underlying integer value used to represent
3265 the fixed-point value.
3266
3267 @item Modular types
3268 Objects of a modular type are initialized to all one bits, except in
3269 the special case where zero is excluded from the subtype, in which
3270 case all zero bits are used. This choice will always generate an
3271 invalid value if one exists.
3272
3273 @item Enumeration types
3274 Objects of an enumeration type are initialized to all one-bits, i.e.@: to
3275 the value @code{2 ** typ'Size - 1} unless the subtype excludes the literal
3276 whose Pos value is zero, in which case a code of zero is used. This choice
3277 will always generate an invalid value if one exists.
3278
3279 @end table
3280
3281 @node Pragma Obsolescent
3282 @unnumberedsec Pragma Obsolescent
3283 @findex Obsolescent
3284 @noindent
3285 Syntax:
3286
3287 @smallexample @c ada
3288 pragma Obsolescent
3289   (Entity => NAME [, static_string_EXPRESSION [,Ada_05]]);
3290 @end smallexample
3291
3292 @noindent
3293 This pragma can occur immediately following a declaration of an entity,
3294 including the case of a record component, and usually the Entity name
3295 must match the name of the entity declared by this declaration.
3296 Alternatively, the pragma can immediately follow an
3297 enumeration type declaration, where the entity argument names one of the
3298 enumeration literals.
3299
3300 This pragma is used to indicate that the named entity
3301 is considered obsolescent and should not be used. Typically this is
3302 used when an API must be modified by eventually removing or modifying
3303 existing subprograms or other entities. The pragma can be used at an
3304 intermediate stage when the entity is still present, but will be
3305 removed later.
3306
3307 The effect of this pragma is to output a warning message on
3308 a call to a program thus marked that the
3309 subprogram is obsolescent if the appropriate warning option in the
3310 compiler is activated. If the string parameter is present, then a second
3311 warning message is given containing this text.
3312 In addition, a call to such a program is considered a violation of
3313 pragma Restrictions (No_Obsolescent_Features).
3314
3315 This pragma can also be used as a program unit pragma for a package,
3316 in which case the entity name is the name of the package, and the
3317 pragma indicates that the entire package is considered
3318 obsolescent. In this case a client @code{with}'ing such a package
3319 violates the restriction, and the @code{with} statement is
3320 flagged with warnings if the warning option is set.
3321
3322 If the optional third parameter is present (which must be exactly
3323 the identifier Ada_05, no other argument is allowed), then the
3324 indication of obsolescence applies only when compiling in Ada 2005
3325 mode. This is primarily intended for dealing with the situations
3326 in the predefined library where subprograms or packages
3327 have become defined as obsolescent in Ada 2005
3328 (e.g. in Ada.Characters.Handling), but may be used anywhere.
3329
3330 The following examples show typical uses of this pragma:
3331
3332 @smallexample @c ada
3333 package p is
3334    pragma Obsolescent
3335      (Entity => p, "use pp instead of p");
3336 end p;
3337
3338 package q is
3339    procedure q2;
3340    pragma Obsolescent
3341      (Entity => q2, "use q2new instead");
3342
3343    type R is new integer;
3344    pragma Obsolescent
3345      (Entity => R, "use RR in Ada 2005", Ada_05);
3346
3347    type M is record
3348       F1 : Integer;
3349       F2 : Integer;
3350       pragma Obsolescent (Entity => F2);
3351       F3 : Integer;
3352    end record;
3353
3354    type E is (a, bc, 'd', quack);
3355    pragma Obsolescent (Entity => bc)
3356    pragma Obsolescent (Entity => 'd')
3357
3358    function "+"
3359      (a, b : character) return character;
3360    pragma Obsolescent (Entity => "+");
3361 end;
3362 @end smallexample
3363
3364 @noindent
3365 In an earlier version of GNAT, the Entity parameter was not required,
3366 and this form is still accepted for compatibility purposes. If the
3367 Entity parameter is omitted, then the pragma applies to the declaration
3368 immediately preceding the pragma (this form cannot be used for the
3369 enumeration literal case).
3370
3371 @node Pragma Passive
3372 @unnumberedsec Pragma Passive
3373 @findex Passive
3374 @noindent
3375 Syntax:
3376
3377 @smallexample @c ada
3378 pragma Passive [(Semaphore | No)];
3379 @end smallexample
3380
3381 @noindent
3382 Syntax checked, but otherwise ignored by GNAT@.  This is recognized for
3383 compatibility with DEC Ada 83 implementations, where it is used within a
3384 task definition to request that a task be made passive.  If the argument
3385 @code{Semaphore} is present, or the argument is omitted, then DEC Ada 83
3386 treats the pragma as an assertion that the containing task is passive
3387 and that optimization of context switch with this task is permitted and
3388 desired.  If the argument @code{No} is present, the task must not be
3389 optimized.  GNAT does not attempt to optimize any tasks in this manner
3390 (since protected objects are available in place of passive tasks).
3391
3392 @node Pragma Persistent_BSS
3393 @unnumberedsec Pragma Persistent_BSS
3394 @findex Persistent_BSS
3395 @noindent
3396 Syntax:
3397
3398 @smallexample @c ada
3399 pragma Persistent_BSS [(LOCAL_NAME)]
3400 @end smallexample
3401
3402 @noindent
3403 This pragma allows selected objects to be placed in the @code{.persistent_bss}
3404 section. On some targets the linker and loader provide for special
3405 treatment of this section, allowing a program to be reloaded without
3406 affecting the contents of this data (hence the name persistent).
3407
3408 There are two forms of usage. If an argument is given, it must be the
3409 local name of a library level object, with no explicit initialization
3410 and whose type is potentially persistent. If no argument is given, then
3411 the pragma is a configuration pragma, and applies to all library level
3412 objects with no explicit initialization of potentially persistent types.
3413
3414 A potentially persistent type is a scalar type, or a non-tagged,
3415 non-discriminated record, all of whose components have no explicit
3416 initialization and are themselves of a potentially persistent type,
3417 or an array, all of whose constraints are static, and whose component
3418 type is potentially persistent.
3419
3420 If this pragma is used on a target where this feature is not supported,
3421 then the pragma will be ignored. See also @code{pragma Linker_Section}.
3422
3423 @node Pragma Polling
3424 @unnumberedsec Pragma Polling
3425 @findex Polling
3426 @noindent
3427 Syntax:
3428
3429 @smallexample @c ada
3430 pragma Polling (ON | OFF);
3431 @end smallexample
3432
3433 @noindent
3434 This pragma controls the generation of polling code.  This is normally off.
3435 If @code{pragma Polling (ON)} is used then periodic calls are generated to
3436 the routine @code{Ada.Exceptions.Poll}.  This routine is a separate unit in the
3437 runtime library, and can be found in file @file{a-excpol.adb}.
3438
3439 Pragma @code{Polling} can appear as a configuration pragma (for example it
3440 can be placed in the @file{gnat.adc} file) to enable polling globally, or it
3441 can be used in the statement or declaration sequence to control polling
3442 more locally.
3443
3444 A call to the polling routine is generated at the start of every loop and
3445 at the start of every subprogram call.  This guarantees that the @code{Poll}
3446 routine is called frequently, and places an upper bound (determined by
3447 the complexity of the code) on the period between two @code{Poll} calls.
3448
3449 The primary purpose of the polling interface is to enable asynchronous
3450 aborts on targets that cannot otherwise support it (for example Windows
3451 NT), but it may be used for any other purpose requiring periodic polling.
3452 The standard version is null, and can be replaced by a user program.  This
3453 will require re-compilation of the @code{Ada.Exceptions} package that can
3454 be found in files @file{a-except.ads} and @file{a-except.adb}.
3455
3456 A standard alternative unit (in file @file{4wexcpol.adb} in the standard GNAT
3457 distribution) is used to enable the asynchronous abort capability on
3458 targets that do not normally support the capability.  The version of
3459 @code{Poll} in this file makes a call to the appropriate runtime routine
3460 to test for an abort condition.
3461
3462 Note that polling can also be enabled by use of the @option{-gnatP} switch.  See
3463 the @cite{GNAT User's Guide} for details.
3464
3465 @node Pragma Profile (Ravenscar)
3466 @unnumberedsec Pragma Profile (Ravenscar)
3467 @findex Ravenscar
3468 @noindent
3469 Syntax:
3470
3471 @smallexample @c ada
3472 pragma Profile (Ravenscar);
3473 @end smallexample
3474
3475 @noindent
3476 A configuration pragma that establishes the following set of configuration
3477 pragmas:
3478
3479 @table @code
3480 @item Task_Dispatching_Policy (FIFO_Within_Priorities)
3481 [RM D.2.2] Tasks are dispatched following a preemptive
3482 priority-ordered scheduling policy.
3483
3484 @item Locking_Policy (Ceiling_Locking)
3485 [RM D.3] While tasks and interrupts execute a protected action, they inherit
3486 the ceiling priority of the corresponding protected object.
3487 @c
3488 @c @item Detect_Blocking
3489 @c This pragma forces the detection of potentially blocking operations within a
3490 @c protected operation, and to raise Program_Error if that happens.
3491 @end table
3492 @noindent
3493
3494 plus the following set of restrictions:
3495
3496 @table @code
3497 @item Max_Entry_Queue_Length = 1
3498 Defines the maximum number of calls that are queued on a (protected) entry.
3499 Note that this restrictions is checked at run time. Violation of this
3500 restriction results in the raising of Program_Error exception at the point of
3501 the call. For the Profile (Ravenscar) the value of Max_Entry_Queue_Length is
3502 always 1 and hence no task can be queued on a protected entry.
3503
3504 @item Max_Protected_Entries = 1
3505 [RM D.7] Specifies the maximum number of entries per protected type. The
3506 bounds of every entry family of a protected unit shall be static, or shall be
3507 defined by a discriminant of a subtype whose corresponding bound is static.
3508 For the Profile (Ravenscar) the value of Max_Protected_Entries is always 1.
3509
3510 @item Max_Task_Entries = 0
3511 [RM D.7] Specifies the maximum number of entries
3512 per task.  The bounds of every entry family
3513 of a task unit shall be static, or shall be
3514 defined by a discriminant of a subtype whose
3515 corresponding bound is static.  A value of zero
3516 indicates that no rendezvous are possible.  For
3517 the Profile (Ravenscar), the value of Max_Task_Entries is always
3518 0 (zero).
3519
3520 @item No_Abort_Statements
3521 [RM D.7] There are no abort_statements, and there are
3522 no calls to Task_Identification.Abort_Task.
3523
3524 @item No_Asynchronous_Control
3525 [RM D.7] There are no semantic dependences on the package
3526 Asynchronous_Task_Control.
3527
3528 @item No_Calendar
3529 There are no semantic dependencies on the package Ada.Calendar.
3530
3531 @item No_Dynamic_Attachment
3532 There is no call to any of the operations defined in package Ada.Interrupts
3533 (Is_Reserved, Is_Attached, Current_Handler, Attach_Handler, Exchange_Handler,
3534 Detach_Handler, and Reference).
3535
3536 @item No_Dynamic_Priorities
3537 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
3538
3539 @item No_Implicit_Heap_Allocations
3540 [RM D.7] No constructs are allowed to cause implicit heap allocation.
3541
3542 @item No_Local_Protected_Objects
3543 Protected objects and access types that designate
3544 such objects shall be declared only at library level.
3545
3546 @item No_Protected_Type_Allocators
3547 There are no allocators for protected types or
3548 types containing protected subcomponents.
3549
3550 @item No_Relative_Delay
3551 There are no delay_relative statements.
3552
3553 @item No_Requeue_Statements
3554 Requeue statements are not allowed.
3555
3556 @item No_Select_Statements
3557 There are no select_statements.
3558
3559 @item No_Task_Allocators
3560 [RM D.7] There are no allocators for task types
3561 or types containing task subcomponents.
3562
3563 @item No_Task_Attributes_Package
3564 There are no semantic dependencies on the Ada.Task_Attributes package.
3565
3566 @item No_Task_Hierarchy
3567 [RM D.7] All (non-environment) tasks depend
3568 directly on the environment task of the partition.
3569
3570 @item No_Task_Termination
3571 Tasks which terminate are erroneous.
3572
3573 @item Simple_Barriers
3574 Entry barrier condition expressions shall be either static
3575 boolean expressions or boolean objects which are declared in
3576 the protected type which contains the entry.
3577 @end table
3578
3579 @noindent
3580 This set of configuration pragmas and restrictions correspond to the
3581 definition of the ``Ravenscar Profile'' for limited tasking, devised and
3582 published by the @cite{International Real-Time Ada Workshop}, 1997,
3583 and whose most recent description is available at
3584 @url{http://www-users.cs.york.ac.uk/~burns/ravenscar.ps}.
3585
3586 The original definition of the profile was revised at subsequent IRTAW
3587 meetings. It has been included in the ISO
3588 @cite{Guide for the Use of the Ada Programming Language in High
3589 Integrity Systems}, and has been approved by ISO/IEC/SC22/WG9 for inclusion in
3590 the next revision of the standard. The formal definition given by
3591 the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
3592 AI-305) available at
3593 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00249.TXT} and
3594 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00305.TXT}
3595 respectively.
3596
3597 The above set is a superset of the restrictions provided by pragma
3598 @code{Profile (Restricted)}, it includes six additional restrictions
3599 (@code{Simple_Barriers}, @code{No_Select_Statements},
3600 @code{No_Calendar}, @code{No_Implicit_Heap_Allocations},
3601 @code{No_Relative_Delay} and @code{No_Task_Termination}).  This means
3602 that pragma @code{Profile (Ravenscar)}, like the pragma
3603 @code{Profile (Restricted)},
3604 automatically causes the use of a simplified,
3605 more efficient version of the tasking run-time system.
3606
3607 @node Pragma Profile (Restricted)
3608 @unnumberedsec Pragma Profile (Restricted)
3609 @findex Restricted Run Time
3610 @noindent
3611 Syntax:
3612
3613 @smallexample @c ada
3614 pragma Profile (Restricted);
3615 @end smallexample
3616
3617 @noindent
3618 A configuration pragma that establishes the following set of restrictions:
3619
3620 @itemize @bullet
3621 @item No_Abort_Statements
3622 @item No_Entry_Queue
3623 @item No_Task_Hierarchy
3624 @item No_Task_Allocators
3625 @item No_Dynamic_Priorities
3626 @item No_Terminate_Alternatives
3627 @item No_Dynamic_Attachment
3628 @item No_Protected_Type_Allocators
3629 @item No_Local_Protected_Objects
3630 @item No_Requeue_Statements
3631 @item No_Task_Attributes_Package
3632 @item Max_Asynchronous_Select_Nesting =  0
3633 @item Max_Task_Entries =  0
3634 @item Max_Protected_Entries = 1
3635 @item Max_Select_Alternatives = 0
3636 @end itemize
3637
3638 @noindent
3639 This set of restrictions causes the automatic selection of a simplified
3640 version of the run time that provides improved performance for the
3641 limited set of tasking functionality permitted by this set of restrictions.
3642
3643 @node Pragma Psect_Object
3644 @unnumberedsec Pragma Psect_Object
3645 @findex Psect_Object
3646 @noindent
3647 Syntax:
3648
3649 @smallexample @c ada
3650 pragma Psect_Object (
3651      [Internal =>] LOCAL_NAME,
3652   [, [External =>] EXTERNAL_SYMBOL]
3653   [, [Size     =>] EXTERNAL_SYMBOL]);
3654
3655 EXTERNAL_SYMBOL ::=
3656   IDENTIFIER
3657 | static_string_EXPRESSION
3658 @end smallexample
3659
3660 @noindent
3661 This pragma is identical in effect to pragma @code{Common_Object}.
3662
3663 @node Pragma Pure_Function
3664 @unnumberedsec Pragma Pure_Function
3665 @findex Pure_Function
3666 @noindent
3667 Syntax:
3668
3669 @smallexample @c ada
3670 pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
3671 @end smallexample
3672
3673 @noindent
3674 This pragma appears in the same declarative part as a function
3675 declaration (or a set of function declarations if more than one
3676 overloaded declaration exists, in which case the pragma applies
3677 to all entities).  It specifies that the function @code{Entity} is
3678 to be considered pure for the purposes of code generation.  This means
3679 that the compiler can assume that there are no side effects, and
3680 in particular that two calls with identical arguments produce the
3681 same result.  It also means that the function can be used in an
3682 address clause.
3683
3684 Note that, quite deliberately, there are no static checks to try
3685 to ensure that this promise is met, so @code{Pure_Function} can be used
3686 with functions that are conceptually pure, even if they do modify
3687 global variables.  For example, a square root function that is
3688 instrumented to count the number of times it is called is still
3689 conceptually pure, and can still be optimized, even though it
3690 modifies a global variable (the count).  Memo functions are another
3691 example (where a table of previous calls is kept and consulted to
3692 avoid re-computation).
3693
3694 @findex Pure
3695 Note: Most functions in a @code{Pure} package are automatically pure, and
3696 there is no need to use pragma @code{Pure_Function} for such functions.  One
3697 exception is any function that has at least one formal of type
3698 @code{System.Address} or a type derived from it.  Such functions are not
3699 considered pure by default, since the compiler assumes that the
3700 @code{Address} parameter may be functioning as a pointer and that the
3701 referenced data may change even if the address value does not.
3702 Similarly, imported functions are not considered to be pure by default,
3703 since there is no way of checking that they are in fact pure.  The use
3704 of pragma @code{Pure_Function} for such a function will override these default
3705 assumption, and cause the compiler to treat a designated subprogram as pure
3706 in these cases.
3707
3708 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
3709 applies to the underlying renamed function.  This can be used to
3710 disambiguate cases of overloading where some but not all functions
3711 in a set of overloaded functions are to be designated as pure.
3712
3713 If pragma @code{Pure_Function} is applied to a library level function, the
3714 function is also considered pure from an optimization point of view, but the
3715 unit is not a Pure unit in the categorization sense. So for example, a function
3716 thus marked is free to @code{with} non-pure units.
3717
3718 @node Pragma Restriction_Warnings
3719 @unnumberedsec Pragma Restriction_Warnings
3720 @findex Restriction_Warnings
3721 @noindent
3722 Syntax:
3723
3724 @smallexample @c ada
3725 pragma Restriction_Warnings
3726   (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
3727 @end smallexample
3728
3729 @noindent
3730 This pragma allows a series of restriction identifiers to be
3731 specified (the list of allowed identifiers is the same as for
3732 pragma @code{Restrictions}). For each of these identifiers
3733 the compiler checks for violations of the restriction, but
3734 generates a warning message rather than an error message
3735 if the restriction is violated.
3736
3737 @node Pragma Shared
3738 @unnumberedsec Pragma Shared
3739 @findex Shared
3740
3741 @noindent
3742 This pragma is provided for compatibility with Ada 83. The syntax and
3743 semantics are identical to pragma Atomic.
3744
3745 @node Pragma Source_File_Name
3746 @unnumberedsec Pragma Source_File_Name
3747 @findex Source_File_Name
3748 @noindent
3749 Syntax:
3750
3751 @smallexample @c ada
3752 pragma Source_File_Name (
3753   [Unit_Name   =>] unit_NAME,
3754   Spec_File_Name =>  STRING_LITERAL);
3755
3756 pragma Source_File_Name (
3757   [Unit_Name   =>] unit_NAME,
3758   Body_File_Name =>  STRING_LITERAL);
3759 @end smallexample
3760
3761 @noindent
3762 Use this to override the normal naming convention.  It is a configuration
3763 pragma, and so has the usual applicability of configuration pragmas
3764 (i.e.@: it applies to either an entire partition, or to all units in a
3765 compilation, or to a single unit, depending on how it is used.
3766 @var{unit_name} is mapped to @var{file_name_literal}.  The identifier for
3767 the second argument is required, and indicates whether this is the file
3768 name for the spec or for the body.
3769
3770 Another form of the @code{Source_File_Name} pragma allows
3771 the specification of patterns defining alternative file naming schemes
3772 to apply to all files.
3773
3774 @smallexample @c ada
3775 pragma Source_File_Name
3776   (Spec_File_Name => STRING_LITERAL
3777    [,Casing => CASING_SPEC]
3778    [,Dot_Replacement => STRING_LITERAL]);
3779
3780 pragma Source_File_Name
3781   (Body_File_Name => STRING_LITERAL
3782    [,Casing => CASING_SPEC]
3783    [,Dot_Replacement => STRING_LITERAL]);
3784
3785 pragma Source_File_Name
3786   (Subunit_File_Name => STRING_LITERAL
3787    [,Casing => CASING_SPEC]
3788    [,Dot_Replacement => STRING_LITERAL]);
3789
3790 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
3791 @end smallexample
3792
3793 @noindent
3794 The first argument is a pattern that contains a single asterisk indicating
3795 the point at which the unit name is to be inserted in the pattern string
3796 to form the file name.  The second argument is optional.  If present it
3797 specifies the casing of the unit name in the resulting file name string.
3798 The default is lower case.  Finally the third argument allows for systematic
3799 replacement of any dots in the unit name by the specified string literal.
3800
3801 A pragma Source_File_Name cannot appear after a
3802 @ref{Pragma Source_File_Name_Project}.
3803
3804 For more details on the use of the @code{Source_File_Name} pragma,
3805 see the sections ``Using Other File Names'' and
3806 ``Alternative File Naming Schemes'' in the @cite{GNAT User's Guide}.
3807
3808 @node Pragma Source_File_Name_Project
3809 @unnumberedsec Pragma Source_File_Name_Project
3810 @findex Source_File_Name_Project
3811 @noindent
3812
3813 This pragma has the same syntax and semantics as pragma Source_File_Name.
3814 It is only allowed as a stand alone configuration pragma.
3815 It cannot appear after a @ref{Pragma Source_File_Name}, and
3816 most importantly, once pragma Source_File_Name_Project appears,
3817 no further Source_File_Name pragmas are allowed.
3818
3819 The intention is that Source_File_Name_Project pragmas are always
3820 generated by the Project Manager in a manner consistent with the naming
3821 specified in a project file, and when naming is controlled in this manner,
3822 it is not permissible to attempt to modify this naming scheme using
3823 Source_File_Name pragmas (which would not be known to the project manager).
3824
3825 @node Pragma Source_Reference
3826 @unnumberedsec Pragma Source_Reference
3827 @findex Source_Reference
3828 @noindent
3829 Syntax:
3830
3831 @smallexample @c ada
3832 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
3833 @end smallexample
3834
3835 @noindent
3836 This pragma must appear as the first line of a source file.
3837 @var{integer_literal} is the logical line number of the line following
3838 the pragma line (for use in error messages and debugging
3839 information).  @var{string_literal} is a static string constant that
3840 specifies the file name to be used in error messages and debugging
3841 information.  This is most notably used for the output of @code{gnatchop}
3842 with the @option{-r} switch, to make sure that the original unchopped
3843 source file is the one referred to.
3844
3845 The second argument must be a string literal, it cannot be a static
3846 string expression other than a string literal.  This is because its value
3847 is needed for error messages issued by all phases of the compiler.
3848
3849 @node Pragma Stream_Convert
3850 @unnumberedsec Pragma Stream_Convert
3851 @findex Stream_Convert
3852 @noindent
3853 Syntax:
3854
3855 @smallexample @c ada
3856 pragma Stream_Convert (
3857   [Entity =>] type_LOCAL_NAME,
3858   [Read   =>] function_NAME,
3859   [Write  =>] function_NAME);
3860 @end smallexample
3861
3862 @noindent
3863 This pragma provides an efficient way of providing stream functions for
3864 types defined in packages.  Not only is it simpler to use than declaring
3865 the necessary functions with attribute representation clauses, but more
3866 significantly, it allows the declaration to made in such a way that the
3867 stream packages are not loaded unless they are needed.  The use of
3868 the Stream_Convert pragma adds no overhead at all, unless the stream
3869 attributes are actually used on the designated type.
3870
3871 The first argument specifies the type for which stream functions are
3872 provided.  The second parameter provides a function used to read values
3873 of this type.  It must name a function whose argument type may be any
3874 subtype, and whose returned type must be the type given as the first
3875 argument to the pragma.
3876
3877 The meaning of the @var{Read}
3878 parameter is that if a stream attribute directly
3879 or indirectly specifies reading of the type given as the first parameter,
3880 then a value of the type given as the argument to the Read function is
3881 read from the stream, and then the Read function is used to convert this
3882 to the required target type.
3883
3884 Similarly the @var{Write} parameter specifies how to treat write attributes
3885 that directly or indirectly apply to the type given as the first parameter.
3886 It must have an input parameter of the type specified by the first parameter,
3887 and the return type must be the same as the input type of the Read function.
3888 The effect is to first call the Write function to convert to the given stream
3889 type, and then write the result type to the stream.
3890
3891 The Read and Write functions must not be overloaded subprograms.  If necessary
3892 renamings can be supplied to meet this requirement.
3893 The usage of this attribute is best illustrated by a simple example, taken
3894 from the GNAT implementation of package Ada.Strings.Unbounded:
3895
3896 @smallexample @c ada
3897 function To_Unbounded (S : String)
3898            return Unbounded_String
3899   renames To_Unbounded_String;
3900
3901 pragma Stream_Convert
3902   (Unbounded_String, To_Unbounded, To_String);
3903 @end smallexample
3904
3905 @noindent
3906 The specifications of the referenced functions, as given in the Ada
3907 Reference Manual are:
3908
3909 @smallexample @c ada
3910 function To_Unbounded_String (Source : String)
3911   return Unbounded_String;
3912
3913 function To_String (Source : Unbounded_String)
3914   return String;
3915 @end smallexample
3916
3917 @noindent
3918 The effect is that if the value of an unbounded string is written to a
3919 stream, then the representation of the item in the stream is in the same
3920 format used for @code{Standard.String}, and this same representation is
3921 expected when a value of this type is read from the stream.
3922
3923 @node Pragma Style_Checks
3924 @unnumberedsec Pragma Style_Checks
3925 @findex Style_Checks
3926 @noindent
3927 Syntax:
3928
3929 @smallexample @c ada
3930 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
3931                      On | Off [, LOCAL_NAME]);
3932 @end smallexample
3933
3934 @noindent
3935 This pragma is used in conjunction with compiler switches to control the
3936 built in style checking provided by GNAT@.  The compiler switches, if set,
3937 provide an initial setting for the switches, and this pragma may be used
3938 to modify these settings, or the settings may be provided entirely by
3939 the use of the pragma.  This pragma can be used anywhere that a pragma
3940 is legal, including use as a configuration pragma (including use in
3941 the @file{gnat.adc} file).
3942
3943 The form with a string literal specifies which style options are to be
3944 activated.  These are additive, so they apply in addition to any previously
3945 set style check options.  The codes for the options are the same as those
3946 used in the @option{-gnaty} switch to @command{gcc} or @command{gnatmake}.
3947 For example the following two methods can be used to enable
3948 layout checking:
3949
3950 @itemize @bullet
3951 @item
3952 @smallexample @c ada
3953 pragma Style_Checks ("l");
3954 @end smallexample
3955
3956 @item
3957 @smallexample
3958 gcc -c -gnatyl @dots{}
3959 @end smallexample
3960 @end itemize
3961
3962 @noindent
3963 The form ALL_CHECKS activates all standard checks (its use is equivalent
3964 to the use of the @code{gnaty} switch with no options.  See GNAT User's
3965 Guide for details.
3966
3967 The forms with @code{Off} and @code{On}
3968 can be used to temporarily disable style checks
3969 as shown in the following example:
3970
3971 @smallexample @c ada
3972 @iftex
3973 @leftskip=0cm
3974 @end iftex
3975 pragma Style_Checks ("k"); -- requires keywords in lower case
3976 pragma Style_Checks (Off); -- turn off style checks
3977 NULL;                      -- this will not generate an error message
3978 pragma Style_Checks (On);  -- turn style checks back on
3979 NULL;                      -- this will generate an error message
3980 @end smallexample
3981
3982 @noindent
3983 Finally the two argument form is allowed only if the first argument is
3984 @code{On} or @code{Off}.  The effect is to turn of semantic style checks
3985 for the specified entity, as shown in the following example:
3986
3987 @smallexample @c ada
3988 @iftex
3989 @leftskip=0cm
3990 @end iftex
3991 pragma Style_Checks ("r"); -- require consistency of identifier casing
3992 Arg : Integer;
3993 Rf1 : Integer := ARG;      -- incorrect, wrong case
3994 pragma Style_Checks (Off, Arg);
3995 Rf2 : Integer := ARG;      -- OK, no error
3996 @end smallexample
3997
3998 @node Pragma Subtitle
3999 @unnumberedsec Pragma Subtitle
4000 @findex Subtitle
4001 @noindent
4002 Syntax:
4003
4004 @smallexample @c ada
4005 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
4006 @end smallexample
4007
4008 @noindent
4009 This pragma is recognized for compatibility with other Ada compilers
4010 but is ignored by GNAT@.
4011
4012 @node Pragma Suppress
4013 @unnumberedsec Pragma Suppress
4014 @findex Suppress
4015 @noindent
4016 Syntax:
4017
4018 @smallexample @c ada
4019 pragma Suppress (Identifier [, [On =>] Name]);
4020 @end smallexample
4021
4022 @noindent
4023 This is a standard pragma, and supports all the check names required in
4024 the RM. It is included here because GNAT recognizes one additional check
4025 name: @code{Alignment_Check} which can be used to suppress alignment checks
4026 on addresses used in address clauses. Such checks can also be suppressed
4027 by suppressing range checks, but the specific use of @code{Alignment_Check}
4028 allows suppression of alignment checks without suppressing other range checks.
4029
4030 @node Pragma Suppress_All
4031 @unnumberedsec Pragma Suppress_All
4032 @findex Suppress_All
4033 @noindent
4034 Syntax:
4035
4036 @smallexample @c ada
4037 pragma Suppress_All;
4038 @end smallexample
4039
4040 @noindent
4041 This pragma can only appear immediately following a compilation
4042 unit.  The effect is to apply @code{Suppress (All_Checks)} to the unit
4043 which it follows.  This pragma is implemented for compatibility with DEC
4044 Ada 83 usage.  The use of pragma @code{Suppress (All_Checks)} as a normal
4045 configuration pragma is the preferred usage in GNAT@.
4046
4047 @node Pragma Suppress_Exception_Locations
4048 @unnumberedsec Pragma Suppress_Exception_Locations
4049 @findex Suppress_Exception_Locations
4050 @noindent
4051 Syntax:
4052
4053 @smallexample @c ada
4054 pragma Suppress_Exception_Locations;
4055 @end smallexample
4056
4057 @noindent
4058 In normal mode, a raise statement for an exception by default generates
4059 an exception message giving the file name and line number for the location
4060 of the raise. This is useful for debugging and logging purposes, but this
4061 entails extra space for the strings for the messages. The configuration
4062 pragma @code{Suppress_Exception_Locations} can be used to suppress the
4063 generation of these strings, with the result that space is saved, but the
4064 exception message for such raises is null. This configuration pragma may
4065 appear in a global configuration pragma file, or in a specific unit as
4066 usual. It is not required that this pragma be used consistently within
4067 a partition, so it is fine to have some units within a partition compiled
4068 with this pragma and others compiled in normal mode without it.
4069
4070 @node Pragma Suppress_Initialization
4071 @unnumberedsec Pragma Suppress_Initialization
4072 @findex Suppress_Initialization
4073 @cindex Suppressing initialization
4074 @cindex Initialization, suppression of
4075 @noindent
4076 Syntax:
4077
4078 @smallexample @c ada
4079 pragma Suppress_Initialization ([Entity =>] type_Name);
4080 @end smallexample
4081
4082 @noindent
4083 This pragma suppresses any implicit or explicit initialization
4084 associated with the given type name for all variables of this type.
4085
4086 @node Pragma Task_Info
4087 @unnumberedsec Pragma Task_Info
4088 @findex Task_Info
4089 @noindent
4090 Syntax
4091
4092 @smallexample @c ada
4093 pragma Task_Info (EXPRESSION);
4094 @end smallexample
4095
4096 @noindent
4097 This pragma appears within a task definition (like pragma
4098 @code{Priority}) and applies to the task in which it appears.  The
4099 argument must be of type @code{System.Task_Info.Task_Info_Type}.
4100 The @code{Task_Info} pragma provides system dependent control over
4101 aspects of tasking implementation, for example, the ability to map
4102 tasks to specific processors.  For details on the facilities available
4103 for the version of GNAT that you are using, see the documentation
4104 in the specification of package System.Task_Info in the runtime
4105 library.
4106
4107 @node Pragma Task_Name
4108 @unnumberedsec Pragma Task_Name
4109 @findex Task_Name
4110 @noindent
4111 Syntax
4112
4113 @smallexample @c ada
4114 pragma Task_Name (string_EXPRESSION);
4115 @end smallexample
4116
4117 @noindent
4118 This pragma appears within a task definition (like pragma
4119 @code{Priority}) and applies to the task in which it appears.  The
4120 argument must be of type String, and provides a name to be used for
4121 the task instance when the task is created.  Note that this expression
4122 is not required to be static, and in particular, it can contain
4123 references to task discriminants.  This facility can be used to
4124 provide different names for different tasks as they are created,
4125 as illustrated in the example below.
4126
4127 The task name is recorded internally in the run-time structures
4128 and is accessible to tools like the debugger.  In addition the
4129 routine @code{Ada.Task_Identification.Image} will return this
4130 string, with a unique task address appended.
4131
4132 @smallexample @c ada
4133 --  Example of the use of pragma Task_Name
4134
4135 with Ada.Task_Identification;
4136 use Ada.Task_Identification;
4137 with Text_IO; use Text_IO;
4138 procedure t3 is
4139
4140    type Astring is access String;
4141
4142    task type Task_Typ (Name : access String) is
4143       pragma Task_Name (Name.all);
4144    end Task_Typ;
4145
4146    task body Task_Typ is
4147       Nam : constant String := Image (Current_Task);
4148    begin
4149       Put_Line ("-->" & Nam (1 .. 14) & "<--");
4150    end Task_Typ;
4151
4152    type Ptr_Task is access Task_Typ;
4153    Task_Var : Ptr_Task;
4154
4155 begin
4156    Task_Var :=
4157      new Task_Typ (new String'("This is task 1"));
4158    Task_Var :=
4159      new Task_Typ (new String'("This is task 2"));
4160 end;
4161 @end smallexample
4162
4163 @node Pragma Task_Storage
4164 @unnumberedsec Pragma Task_Storage
4165 @findex Task_Storage
4166 Syntax:
4167
4168 @smallexample @c ada
4169 pragma Task_Storage (
4170   [Task_Type =>] LOCAL_NAME,
4171   [Top_Guard =>] static_integer_EXPRESSION);
4172 @end smallexample
4173
4174 @noindent
4175 This pragma specifies the length of the guard area for tasks.  The guard
4176 area is an additional storage area allocated to a task.  A value of zero
4177 means that either no guard area is created or a minimal guard area is
4178 created, depending on the target.  This pragma can appear anywhere a
4179 @code{Storage_Size} attribute definition clause is allowed for a task
4180 type.
4181
4182 @node Pragma Time_Slice
4183 @unnumberedsec Pragma Time_Slice
4184 @findex Time_Slice
4185 @noindent
4186 Syntax:
4187
4188 @smallexample @c ada
4189 pragma Time_Slice (static_duration_EXPRESSION);
4190 @end smallexample
4191
4192 @noindent
4193 For implementations of GNAT on operating systems where it is possible
4194 to supply a time slice value, this pragma may be used for this purpose.
4195 It is ignored if it is used in a system that does not allow this control,
4196 or if it appears in other than the main program unit.
4197 @cindex OpenVMS
4198 Note that the effect of this pragma is identical to the effect of the
4199 DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
4200
4201 @node Pragma Title
4202 @unnumberedsec Pragma Title
4203 @findex Title
4204 @noindent
4205 Syntax:
4206
4207 @smallexample @c ada
4208 pragma Title (TITLING_OPTION [, TITLING OPTION]);
4209
4210 TITLING_OPTION ::=
4211   [Title    =>] STRING_LITERAL,
4212 | [Subtitle =>] STRING_LITERAL
4213 @end smallexample
4214
4215 @noindent
4216 Syntax checked but otherwise ignored by GNAT@.  This is a listing control
4217 pragma used in DEC Ada 83 implementations to provide a title and/or
4218 subtitle for the program listing.  The program listing generated by GNAT
4219 does not have titles or subtitles.
4220
4221 Unlike other pragmas, the full flexibility of named notation is allowed
4222 for this pragma, i.e.@: the parameters may be given in any order if named
4223 notation is used, and named and positional notation can be mixed
4224 following the normal rules for procedure calls in Ada.
4225
4226 @node Pragma Unchecked_Union
4227 @unnumberedsec Pragma Unchecked_Union
4228 @cindex Unions in C
4229 @findex Unchecked_Union
4230 @noindent
4231 Syntax:
4232
4233 @smallexample @c ada
4234 pragma Unchecked_Union (first_subtype_LOCAL_NAME);
4235 @end smallexample
4236
4237 @noindent
4238 This pragma is used to specify a representation of a record type that is
4239 equivalent to a C union. It was introduced as a GNAT implementation defined
4240 pragma in the GNAT Ada 95 mode. Ada 2005 includes an extended version of this
4241 pragma, making it language defined, and GNAT fully implements this extended
4242 version in all language modes (Ada 83, Ada 95, and Ada 2005). For full
4243 details, consult the Ada 2005 Reference Manual, section B.3.3.
4244
4245 @node Pragma Unimplemented_Unit
4246 @unnumberedsec Pragma Unimplemented_Unit
4247 @findex Unimplemented_Unit
4248 @noindent
4249 Syntax:
4250
4251 @smallexample @c ada
4252 pragma Unimplemented_Unit;
4253 @end smallexample
4254
4255 @noindent
4256 If this pragma occurs in a unit that is processed by the compiler, GNAT
4257 aborts with the message @samp{@var{xxx} not implemented}, where
4258 @var{xxx} is the name of the current compilation unit.  This pragma is
4259 intended to allow the compiler to handle unimplemented library units in
4260 a clean manner.
4261
4262 The abort only happens if code is being generated.  Thus you can use
4263 specs of unimplemented packages in syntax or semantic checking mode.
4264
4265 @node Pragma Universal_Aliasing
4266 @unnumberedsec Pragma Universal_Aliasing
4267 @findex Universal_Aliasing
4268 @noindent
4269 Syntax:
4270
4271 @smallexample @c ada
4272 pragma Universal_Aliasing [([Entity =>] type_LOCAL_NAME)];
4273 @end smallexample
4274
4275 @noindent
4276 @var{type_LOCAL_NAME} must refer to a type declaration in the current
4277 declarative part.  The effect is to inhibit strict type-based aliasing
4278 optimization for the given type.  In other words, the effect is as though
4279 access types designating this type were subject to pragma No_Strict_Aliasing.
4280 For a detailed description of the strict aliasing optimization, and the
4281 situations in which it must be suppressed, see section
4282 ``Optimization and Strict Aliasing'' in the @value{EDITION} User's Guide.
4283
4284 @node Pragma Universal_Data
4285 @unnumberedsec Pragma Universal_Data
4286 @findex Universal_Data
4287 @noindent
4288 Syntax:
4289
4290 @smallexample @c ada
4291 pragma Universal_Data [(library_unit_Name)];
4292 @end smallexample
4293
4294 @noindent
4295 This pragma is supported only for the AAMP target and is ignored for
4296 other targets. The pragma specifies that all library-level objects
4297 (Counter 0 data) associated with the library unit are to be accessed
4298 and updated using universal addressing (24-bit addresses for AAMP5)
4299 rather than the default of 16-bit Data Environment (DENV) addressing.
4300 Use of this pragma will generally result in less efficient code for
4301 references to global data associated with the library unit, but
4302 allows such data to be located anywhere in memory. This pragma is
4303 a library unit pragma, but can also be used as a configuration pragma
4304 (including use in the @file{gnat.adc} file). The functionality
4305 of this pragma is also available by applying the -univ switch on the
4306 compilations of units where universal addressing of the data is desired.
4307
4308 @node Pragma Unreferenced
4309 @unnumberedsec Pragma Unreferenced
4310 @findex Unreferenced
4311 @cindex Warnings, unreferenced
4312 @noindent
4313 Syntax:
4314
4315 @smallexample @c ada
4316 pragma Unreferenced (LOCAL_NAME @{, LOCAL_NAME@});
4317 pragma Unreferenced (library_unit_NAME @{, library_unit_NAME@});
4318 @end smallexample
4319
4320 @noindent
4321 This pragma signals that the entities whose names are listed are
4322 deliberately not referenced in the current source unit. This
4323 suppresses warnings about the
4324 entities being unreferenced, and in addition a warning will be
4325 generated if one of these entities is in fact referenced in the
4326 same unit as the pragma (or in the corresponding body, or one
4327 of its subunits).
4328
4329 This is particularly useful for clearly signaling that a particular
4330 parameter is not referenced in some particular subprogram implementation
4331 and that this is deliberate. It can also be useful in the case of
4332 objects declared only for their initialization or finalization side
4333 effects.
4334
4335 If @code{LOCAL_NAME} identifies more than one matching homonym in the
4336 current scope, then the entity most recently declared is the one to which
4337 the pragma applies. Note that in the case of accept formals, the pragma
4338 Unreferenced may appear immediately after the keyword @code{do} which
4339 allows the indication of whether or not accept formals are referenced
4340 or not to be given individually for each accept statement.
4341
4342 The left hand side of an assignment does not count as a reference for the
4343 purpose of this pragma. Thus it is fine to assign to an entity for which
4344 pragma Unreferenced is given.
4345
4346 Note that if a warning is desired for all calls to a given subprogram,
4347 regardless of whether they occur in the same unit as the subprogram
4348 declaration, then this pragma should not be used (calls from another
4349 unit would not be flagged); pragma Obsolescent can be used instead
4350 for this purpose, see @xref{Pragma Obsolescent}.
4351
4352 The second form of pragma @code{Unreferenced} is used within a context
4353 clause. In this case the arguments must be unit names of units previously
4354 mentioned in @code{with} clauses (similar to the usage of pragma
4355 @code{Elaborate_All}. The effect is to suppress warnings about unreferenced
4356 units and unreferenced entities within these units.
4357
4358 @node Pragma Unreferenced_Objects
4359 @unnumberedsec Pragma Unreferenced_Objects
4360 @findex Unreferenced_Objects
4361 @cindex Warnings, unreferenced
4362 @noindent
4363 Syntax:
4364
4365 @smallexample @c ada
4366 pragma Unreferenced_Objects (local_subtype_NAME @{, local_subtype_NAME@});
4367 @end smallexample
4368
4369 @noindent
4370 This pragma signals that for the types or subtypes whose names are
4371 listed, objects which are declared with one of these types or subtypes may
4372 not be referenced, and if no references appear, no warnings are given.
4373
4374 This is particularly useful for objects which are declared solely for their
4375 initialization and finalization effect. Such variables are sometimes referred
4376 to as RAII variables (Resource Acquisition Is Initialization). Using this
4377 pragma on the relevant type (most typically a limited controlled type), the
4378 compiler will automatically suppress unwanted warnings about these variables
4379 not being referenced.
4380
4381 @node Pragma Unreserve_All_Interrupts
4382 @unnumberedsec Pragma Unreserve_All_Interrupts
4383 @findex Unreserve_All_Interrupts
4384 @noindent
4385 Syntax:
4386
4387 @smallexample @c ada
4388 pragma Unreserve_All_Interrupts;
4389 @end smallexample
4390
4391 @noindent
4392 Normally certain interrupts are reserved to the implementation.  Any attempt
4393 to attach an interrupt causes Program_Error to be raised, as described in
4394 RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
4395 many systems for a @kbd{Ctrl-C} interrupt.  Normally this interrupt is
4396 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
4397 interrupt execution.
4398
4399 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
4400 a program, then all such interrupts are unreserved.  This allows the
4401 program to handle these interrupts, but disables their standard
4402 functions.  For example, if this pragma is used, then pressing
4403 @kbd{Ctrl-C} will not automatically interrupt execution.  However,
4404 a program can then handle the @code{SIGINT} interrupt as it chooses.
4405
4406 For a full list of the interrupts handled in a specific implementation,
4407 see the source code for the specification of @code{Ada.Interrupts.Names} in
4408 file @file{a-intnam.ads}.  This is a target dependent file that contains the
4409 list of interrupts recognized for a given target.  The documentation in
4410 this file also specifies what interrupts are affected by the use of
4411 the @code{Unreserve_All_Interrupts} pragma.
4412
4413 For a more general facility for controlling what interrupts can be
4414 handled, see pragma @code{Interrupt_State}, which subsumes the functionality
4415 of the @code{Unreserve_All_Interrupts} pragma.
4416
4417 @node Pragma Unsuppress
4418 @unnumberedsec Pragma Unsuppress
4419 @findex Unsuppress
4420 @noindent
4421 Syntax:
4422
4423 @smallexample @c ada
4424 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
4425 @end smallexample
4426
4427 @noindent
4428 This pragma undoes the effect of a previous pragma @code{Suppress}.  If
4429 there is no corresponding pragma @code{Suppress} in effect, it has no
4430 effect.  The range of the effect is the same as for pragma
4431 @code{Suppress}.  The meaning of the arguments is identical to that used
4432 in pragma @code{Suppress}.
4433
4434 One important application is to ensure that checks are on in cases where
4435 code depends on the checks for its correct functioning, so that the code
4436 will compile correctly even if the compiler switches are set to suppress
4437 checks.
4438
4439 @node Pragma Use_VADS_Size
4440 @unnumberedsec Pragma Use_VADS_Size
4441 @cindex @code{Size}, VADS compatibility
4442 @findex Use_VADS_Size
4443 @noindent
4444 Syntax:
4445
4446 @smallexample @c ada
4447 pragma Use_VADS_Size;
4448 @end smallexample
4449
4450 @noindent
4451 This is a configuration pragma.  In a unit to which it applies, any use
4452 of the 'Size attribute is automatically interpreted as a use of the
4453 'VADS_Size attribute.  Note that this may result in incorrect semantic
4454 processing of valid Ada 95 or Ada 2005 programs.  This is intended to aid in
4455 the handling of existing code which depends on the interpretation of Size
4456 as implemented in the VADS compiler.  See description of the VADS_Size
4457 attribute for further details.
4458
4459 @node Pragma Validity_Checks
4460 @unnumberedsec Pragma Validity_Checks
4461 @findex Validity_Checks
4462 @noindent
4463 Syntax:
4464
4465 @smallexample @c ada
4466 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
4467 @end smallexample
4468
4469 @noindent
4470 This pragma is used in conjunction with compiler switches to control the
4471 built-in validity checking provided by GNAT@.  The compiler switches, if set
4472 provide an initial setting for the switches, and this pragma may be used
4473 to modify these settings, or the settings may be provided entirely by
4474 the use of the pragma.  This pragma can be used anywhere that a pragma
4475 is legal, including use as a configuration pragma (including use in
4476 the @file{gnat.adc} file).
4477
4478 The form with a string literal specifies which validity options are to be
4479 activated.  The validity checks are first set to include only the default
4480 reference manual settings, and then a string of letters in the string
4481 specifies the exact set of options required.  The form of this string
4482 is exactly as described for the @option{-gnatVx} compiler switch (see the
4483 GNAT users guide for details).  For example the following two methods
4484 can be used to enable validity checking for mode @code{in} and
4485 @code{in out} subprogram parameters:
4486
4487 @itemize @bullet
4488 @item
4489 @smallexample @c ada
4490 pragma Validity_Checks ("im");
4491 @end smallexample
4492
4493 @item
4494 @smallexample
4495 gcc -c -gnatVim @dots{}
4496 @end smallexample
4497 @end itemize
4498
4499 @noindent
4500 The form ALL_CHECKS activates all standard checks (its use is equivalent
4501 to the use of the @code{gnatva} switch.
4502
4503 The forms with @code{Off} and @code{On}
4504 can be used to temporarily disable validity checks
4505 as shown in the following example:
4506
4507 @smallexample @c ada
4508 @iftex
4509 @leftskip=0cm
4510 @end iftex
4511 pragma Validity_Checks ("c"); -- validity checks for copies
4512 pragma Validity_Checks (Off); -- turn off validity checks
4513 A := B;                       -- B will not be validity checked
4514 pragma Validity_Checks (On);  -- turn validity checks back on
4515 A := C;                       -- C will be validity checked
4516 @end smallexample
4517
4518 @node Pragma Volatile
4519 @unnumberedsec Pragma Volatile
4520 @findex Volatile
4521 @noindent
4522 Syntax:
4523
4524 @smallexample @c ada
4525 pragma Volatile (LOCAL_NAME);
4526 @end smallexample
4527
4528 @noindent
4529 This pragma is defined by the Ada Reference Manual, and the GNAT
4530 implementation is fully conformant with this definition.  The reason it
4531 is mentioned in this section is that a pragma of the same name was supplied
4532 in some Ada 83 compilers, including DEC Ada 83.  The Ada 95 / Ada 2005
4533 implementation of pragma Volatile is upwards compatible with the
4534 implementation in DEC Ada 83.
4535
4536 @node Pragma Warnings
4537 @unnumberedsec Pragma Warnings
4538 @findex Warnings
4539 @noindent
4540 Syntax:
4541
4542 @smallexample @c ada
4543 pragma Warnings (On | Off);
4544 pragma Warnings (On | Off, LOCAL_NAME);
4545 pragma Warnings (static_string_EXPRESSION);
4546 pragma Warnings (On | Off, static_string_EXPRESSION);
4547 @end smallexample
4548
4549 @noindent
4550 Normally warnings are enabled, with the output being controlled by
4551 the command line switch.  Warnings (@code{Off}) turns off generation of
4552 warnings until a Warnings (@code{On}) is encountered or the end of the
4553 current unit.  If generation of warnings is turned off using this
4554 pragma, then no warning messages are output, regardless of the
4555 setting of the command line switches.
4556
4557 The form with a single argument may be used as a configuration pragma.
4558
4559 If the @var{LOCAL_NAME} parameter is present, warnings are suppressed for
4560 the specified entity.  This suppression is effective from the point where
4561 it occurs till the end of the extended scope of the variable (similar to
4562 the scope of @code{Suppress}).
4563
4564 The form with a single static_string_EXPRESSION argument provides more precise
4565 control over which warnings are active. The string is a list of letters
4566 specifying which warnings are to be activated and which deactivated. The
4567 code for these letters is the same as the string used in the command
4568 line switch controlling warnings. The following is a brief summary. For
4569 full details see the GNAT Users Guide:
4570
4571 @smallexample
4572 a   turn on all optional warnings (except d,h,l)
4573 A   turn off all optional warnings
4574 b   turn on warnings for bad fixed value (not multiple of small)
4575 B   turn off warnings for bad fixed value (not multiple of small)
4576 c   turn on warnings for constant conditional
4577 C   turn off warnings for constant conditional
4578 d   turn on warnings for implicit dereference
4579 D   turn off warnings for implicit dereference
4580 e   treat all warnings as errors
4581 f   turn on warnings for unreferenced formal
4582 F   turn off warnings for unreferenced formal
4583 g   turn on warnings for unrecognized pragma
4584 G   turn off warnings for unrecognized pragma
4585 h   turn on warnings for hiding variable
4586 H   turn off warnings for hiding variable
4587 i   turn on warnings for implementation unit
4588 I   turn off warnings for implementation unit
4589 j   turn on warnings for obsolescent (annex J) feature
4590 J   turn off warnings for obsolescent (annex J) feature
4591 k   turn on warnings on constant variable
4592 K   turn off warnings on constant variable
4593 l   turn on warnings for missing elaboration pragma
4594 L   turn off warnings for missing elaboration pragma
4595 m   turn on warnings for variable assigned but not read
4596 M   turn off warnings for variable assigned but not read
4597 n   normal warning mode (cancels -gnatws/-gnatwe)
4598 o   turn on warnings for address clause overlay
4599 O   turn off warnings for address clause overlay
4600 p   turn on warnings for ineffective pragma Inline
4601 P   turn off warnings for ineffective pragma Inline
4602 q   turn on warnings for questionable missing parentheses
4603 Q   turn off warnings for questionable missing parentheses
4604 r   turn on warnings for redundant construct
4605 R   turn off warnings for redundant construct
4606 s   suppress all warnings
4607 t   turn on warnings for tracking deleted code
4608 T   turn off warnings for tracking deleted code
4609 u   turn on warnings for unused entity
4610 U   turn off warnings for unused entity
4611 v   turn on warnings for unassigned variable
4612 V   turn off warnings for unassigned variable
4613 w   turn on warnings for wrong low bound assumption
4614 W   turn off warnings for wrong low bound assumption
4615 x   turn on warnings for export/import
4616 X   turn off warnings for export/import
4617 y   turn on warnings for Ada 2005 incompatibility
4618 Y   turn off warnings for Ada 2005 incompatibility
4619 z   turn on size/align warnings for unchecked conversion
4620 Z   turn off size/align warnings for unchecked conversion
4621 @end smallexample
4622
4623 @noindent
4624 The specified warnings will be in effect until the end of the program
4625 or another pragma Warnings is encountered. The effect of the pragma is
4626 cumulative. Initially the set of warnings is the standard default set
4627 as possibly modified by compiler switches. Then each pragma Warning
4628 modifies this set of warnings as specified. This form of the pragma may
4629 also be used as a configuration pragma.
4630
4631 The fourth form, with an On|Off parameter and a string, is used to
4632 control individual messages, based on their text. The string argument
4633 is a pattern that is used to match against the text of individual
4634 warning messages (not including the initial "warnings: " tag).
4635
4636 The pattern may start with an asterisk, which matches otherwise unmatched
4637 characters at the start of the message, and it may also end with an asterisk
4638 which matches otherwise unmatched characters at the end of the message. For
4639 example, the string "*alignment*" could be used to match any warnings about
4640 alignment problems. Within the string, the sequence "*" can be used to match
4641 any sequence of characters enclosed in quotation marks. No other regular
4642 expression notations are permitted. All characters other than asterisk in
4643 these three specific cases are treated as literal characters in the match.
4644
4645 There are two ways to use this pragma. The OFF form can be used as a
4646 configuration pragma. The effect is to suppress all warnings (if any)
4647 that match the pattern string throughout the compilation.
4648
4649 The second usage is to suppress a warning locally, and in this case, two
4650 pragmas must appear in sequence:
4651
4652 @smallexample @c ada
4653 pragma Warnings (Off, Pattern);
4654 @dots{} code where given warning is to be suppressed
4655 pragma Warnings (On, Pattern);
4656 @end smallexample
4657
4658 @noindent
4659 In this usage, the pattern string must match in the Off and On pragmas,
4660 and at least one matching warning must be suppressed.
4661
4662 @node Pragma Weak_External
4663 @unnumberedsec Pragma Weak_External
4664 @findex Weak_External
4665 @noindent
4666 Syntax:
4667
4668 @smallexample @c ada
4669 pragma Weak_External ([Entity =>] LOCAL_NAME);
4670 @end smallexample
4671
4672 @noindent
4673 @var{LOCAL_NAME} must refer to an object that is declared at the library
4674 level. This pragma specifies that the given entity should be marked as a
4675 weak symbol for the linker. It is equivalent to @code{__attribute__((weak))}
4676 in GNU C and causes @var{LOCAL_NAME} to be emitted as a weak symbol instead
4677 of a regular symbol, that is to say a symbol that does not have to be
4678 resolved by the linker if used in conjunction with a pragma Import.
4679
4680 When a weak symbol is not resolved by the linker, its address is set to
4681 zero. This is useful in writing interfaces to external modules that may
4682 or may not be linked in the final executable, for example depending on
4683 configuration settings.
4684
4685 If a program references at run time an entity to which this pragma has been
4686 applied, and the corresponding symbol was not resolved at link time, then
4687 the execution of the program is erroneous. It is not erroneous to take the
4688 Address of such an entity, for example to guard potential references,
4689 as shown in the example below.
4690
4691 Some file formats do not support weak symbols so not all target machines
4692 support this pragma.
4693
4694 @smallexample @c ada
4695 --  Example of the use of pragma Weak_External
4696
4697 package External_Module is
4698   key : Integer;
4699   pragma Import (C, key);
4700   pragma Weak_External (key);
4701   function Present return boolean;
4702 end External_Module;
4703
4704 with System; use System;
4705 package body External_Module is
4706   function Present return boolean is
4707   begin
4708     return key'Address /= System.Null_Address;
4709   end Present;
4710 end External_Module;
4711 @end smallexample
4712
4713 @node Pragma Wide_Character_Encoding
4714 @unnumberedsec Pragma Wide_Character_Encoding
4715 @findex Wide_Character_Encoding
4716 @noindent
4717 Syntax:
4718
4719 @smallexample @c ada
4720 pragma Wide_Character_Encoding (IDENTIFIER | CHARACTER_LITERAL);
4721 @end smallexample
4722
4723 @noindent
4724 This pragma specifies the wide character encoding to be used in program
4725 source text appearing subsequently. It is a configuration pragma, but may
4726 also be used at any point that a pragma is allowed, and it is permissible
4727 to have more than one such pragma in a file, allowing multiple encodings
4728 to appear within the same file.
4729
4730 The argument can be an identifier or a character literal. In the identifier
4731 case, it is one of @code{HEX}, @code{UPPER}, @code{SHIFT_JIS},
4732 @code{EUC}, @code{UTF8}, or @code{BRACKETS}. In the character literal
4733 case it is correspondingly one of the characters h,u,s,e,8,b.
4734
4735 Note that when the pragma is used within a file, it affects only the
4736 encoding within that file, and does not affect withed units, specs,
4737 or subunits.
4738
4739 @node Implementation Defined Attributes
4740 @chapter Implementation Defined Attributes
4741 Ada defines (throughout the Ada reference manual,
4742 summarized in Annex K),
4743 a set of attributes that provide useful additional functionality in all
4744 areas of the language.  These language defined attributes are implemented
4745 in GNAT and work as described in the Ada Reference Manual.
4746
4747 In addition, Ada allows implementations to define additional
4748 attributes whose meaning is defined by the implementation.  GNAT provides
4749 a number of these implementation-dependent attributes which can be used
4750 to extend and enhance the functionality of the compiler.  This section of
4751 the GNAT reference manual describes these additional attributes.
4752
4753 Note that any program using these attributes may not be portable to
4754 other compilers (although GNAT implements this set of attributes on all
4755 platforms).  Therefore if portability to other compilers is an important
4756 consideration, you should minimize the use of these attributes.
4757
4758 @menu
4759 * Abort_Signal::
4760 * Address_Size::
4761 * Asm_Input::
4762 * Asm_Output::
4763 * AST_Entry::
4764 * Bit::
4765 * Bit_Position::
4766 * Code_Address::
4767 * Default_Bit_Order::
4768 * Elaborated::
4769 * Elab_Body::
4770 * Elab_Spec::
4771 * Emax::
4772 * Enabled::
4773 * Enum_Rep::
4774 * Epsilon::
4775 * Fixed_Value::
4776 * Has_Access_Values::
4777 * Has_Discriminants::
4778 * Img::
4779 * Integer_Value::
4780 * Large::
4781 * Machine_Size::
4782 * Mantissa::
4783 * Max_Interrupt_Priority::
4784 * Max_Priority::
4785 * Maximum_Alignment::
4786 * Mechanism_Code::
4787 * Null_Parameter::
4788 * Object_Size::
4789 * Passed_By_Reference::
4790 * Pool_Address::
4791 * Range_Length::
4792 * Safe_Emax::
4793 * Safe_Large::
4794 * Small::
4795 * Storage_Unit::
4796 * Stub_Type::
4797 * Target_Name::
4798 * Tick::
4799 * To_Address::
4800 * Type_Class::
4801 * UET_Address::
4802 * Unconstrained_Array::
4803 * Universal_Literal_String::
4804 * Unrestricted_Access::
4805 * VADS_Size::
4806 * Value_Size::
4807 * Wchar_T_Size::
4808 * Word_Size::
4809 @end menu
4810
4811 @node Abort_Signal
4812 @unnumberedsec Abort_Signal
4813 @findex Abort_Signal
4814 @noindent
4815 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
4816 prefix) provides the entity for the special exception used to signal
4817 task abort or asynchronous transfer of control.  Normally this attribute
4818 should only be used in the tasking runtime (it is highly peculiar, and
4819 completely outside the normal semantics of Ada, for a user program to
4820 intercept the abort exception).
4821
4822 @node Address_Size
4823 @unnumberedsec Address_Size
4824 @cindex Size of @code{Address}
4825 @findex Address_Size
4826 @noindent
4827 @code{Standard'Address_Size} (@code{Standard} is the only allowed
4828 prefix) is a static constant giving the number of bits in an
4829 @code{Address}. It is the same value as System.Address'Size,
4830 but has the advantage of being static, while a direct
4831 reference to System.Address'Size is non-static because Address
4832 is a private type.
4833
4834 @node Asm_Input
4835 @unnumberedsec Asm_Input
4836 @findex Asm_Input
4837 @noindent
4838 The @code{Asm_Input} attribute denotes a function that takes two
4839 parameters.  The first is a string, the second is an expression of the
4840 type designated by the prefix.  The first (string) argument is required
4841 to be a static expression, and is the constraint for the parameter,
4842 (e.g.@: what kind of register is required).  The second argument is the
4843 value to be used as the input argument.  The possible values for the
4844 constant are the same as those used in the RTL, and are dependent on
4845 the configuration file used to built the GCC back end.
4846 @ref{Machine Code Insertions}
4847
4848 @node Asm_Output
4849 @unnumberedsec Asm_Output
4850 @findex Asm_Output
4851 @noindent
4852 The @code{Asm_Output} attribute denotes a function that takes two
4853 parameters.  The first is a string, the second is the name of a variable
4854 of the type designated by the attribute prefix.  The first (string)
4855 argument is required to be a static expression and designates the
4856 constraint for the parameter (e.g.@: what kind of register is
4857 required).  The second argument is the variable to be updated with the
4858 result.  The possible values for constraint are the same as those used in
4859 the RTL, and are dependent on the configuration file used to build the
4860 GCC back end.  If there are no output operands, then this argument may
4861 either be omitted, or explicitly given as @code{No_Output_Operands}.
4862 @ref{Machine Code Insertions}
4863
4864 @node AST_Entry
4865 @unnumberedsec AST_Entry
4866 @cindex OpenVMS
4867 @findex AST_Entry
4868 @noindent
4869 This attribute is implemented only in OpenVMS versions of GNAT@.  Applied to
4870 the name of an entry, it yields a value of the predefined type AST_Handler
4871 (declared in the predefined package System, as extended by the use of
4872 pragma @code{Extend_System (Aux_DEC)}).  This value enables the given entry to
4873 be called when an AST occurs.  For further details, refer to the @cite{DEC Ada
4874 Language Reference Manual}, section 9.12a.
4875
4876 @node Bit
4877 @unnumberedsec Bit
4878 @findex Bit
4879 @code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
4880 offset within the storage unit (byte) that contains the first bit of
4881 storage allocated for the object.  The value of this attribute is of the
4882 type @code{Universal_Integer}, and is always a non-negative number not
4883 exceeding the value of @code{System.Storage_Unit}.
4884
4885 For an object that is a variable or a constant allocated in a register,
4886 the value is zero.  (The use of this attribute does not force the
4887 allocation of a variable to memory).
4888
4889 For an object that is a formal parameter, this attribute applies
4890 to either the matching actual parameter or to a copy of the
4891 matching actual parameter.
4892
4893 For an access object the value is zero.  Note that
4894 @code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
4895 designated object.  Similarly for a record component
4896 @code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
4897 @code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
4898 are subject to index checks.
4899
4900 This attribute is designed to be compatible with the DEC Ada 83 definition
4901 and implementation of the @code{Bit} attribute.
4902
4903 @node Bit_Position
4904 @unnumberedsec Bit_Position
4905 @findex Bit_Position
4906 @noindent
4907 @code{@var{R.C}'Bit}, where @var{R} is a record object and C is one
4908 of the fields of the record type, yields the bit
4909 offset within the record contains the first bit of
4910 storage allocated for the object.  The value of this attribute is of the
4911 type @code{Universal_Integer}.  The value depends only on the field
4912 @var{C} and is independent of the alignment of
4913 the containing record @var{R}.
4914
4915 @node Code_Address
4916 @unnumberedsec Code_Address
4917 @findex Code_Address
4918 @cindex Subprogram address
4919 @cindex Address of subprogram code
4920 @noindent
4921 The @code{'Address}
4922 attribute may be applied to subprograms in Ada 95 and Ada 2005, but the
4923 intended effect seems to be to provide
4924 an address value which can be used to call the subprogram by means of
4925 an address clause as in the following example:
4926
4927 @smallexample @c ada
4928 procedure K is @dots{}
4929
4930 procedure L;
4931 for L'Address use K'Address;
4932 pragma Import (Ada, L);
4933 @end smallexample
4934
4935 @noindent
4936 A call to @code{L} is then expected to result in a call to @code{K}@.
4937 In Ada 83, where there were no access-to-subprogram values, this was
4938 a common work-around for getting the effect of an indirect call.
4939 GNAT implements the above use of @code{Address} and the technique
4940 illustrated by the example code works correctly.
4941
4942 However, for some purposes, it is useful to have the address of the start
4943 of the generated code for the subprogram.  On some architectures, this is
4944 not necessarily the same as the @code{Address} value described above.
4945 For example, the @code{Address} value may reference a subprogram
4946 descriptor rather than the subprogram itself.
4947
4948 The @code{'Code_Address} attribute, which can only be applied to
4949 subprogram entities, always returns the address of the start of the
4950 generated code of the specified subprogram, which may or may not be
4951 the same value as is returned by the corresponding @code{'Address}
4952 attribute.
4953
4954 @node Default_Bit_Order
4955 @unnumberedsec Default_Bit_Order
4956 @cindex Big endian
4957 @cindex Little endian
4958 @findex Default_Bit_Order
4959 @noindent
4960 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
4961 permissible prefix), provides the value @code{System.Default_Bit_Order}
4962 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
4963 @code{Low_Order_First}).  This is used to construct the definition of
4964 @code{Default_Bit_Order} in package @code{System}.
4965
4966 @node Elaborated
4967 @unnumberedsec Elaborated
4968 @findex Elaborated
4969 @noindent
4970 The prefix of the @code{'Elaborated} attribute must be a unit name.  The
4971 value is a Boolean which indicates whether or not the given unit has been
4972 elaborated.  This attribute is primarily intended for internal use by the
4973 generated code for dynamic elaboration checking, but it can also be used
4974 in user programs.  The value will always be True once elaboration of all
4975 units has been completed.  An exception is for units which need no
4976 elaboration, the value is always False for such units.
4977
4978 @node Elab_Body
4979 @unnumberedsec Elab_Body
4980 @findex Elab_Body
4981 @noindent
4982 This attribute can only be applied to a program unit name.  It returns
4983 the entity for the corresponding elaboration procedure for elaborating
4984 the body of the referenced unit.  This is used in the main generated
4985 elaboration procedure by the binder and is not normally used in any
4986 other context.  However, there may be specialized situations in which it
4987 is useful to be able to call this elaboration procedure from Ada code,
4988 e.g.@: if it is necessary to do selective re-elaboration to fix some
4989 error.
4990
4991 @node Elab_Spec
4992 @unnumberedsec Elab_Spec
4993 @findex Elab_Spec
4994 @noindent
4995 This attribute can only be applied to a program unit name.  It returns
4996 the entity for the corresponding elaboration procedure for elaborating
4997 the specification of the referenced unit.  This is used in the main
4998 generated elaboration procedure by the binder and is not normally used
4999 in any other context.  However, there may be specialized situations in
5000 which it is useful to be able to call this elaboration procedure from
5001 Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
5002 some error.
5003
5004 @node Emax
5005 @unnumberedsec Emax
5006 @cindex Ada 83 attributes
5007 @findex Emax
5008 @noindent
5009 The @code{Emax} attribute is provided for compatibility with Ada 83.  See
5010 the Ada 83 reference manual for an exact description of the semantics of
5011 this attribute.
5012
5013 @node Enabled
5014 @unnumberedsec Enabled
5015 @findex Enabled
5016 @noindent
5017 The @code{Enabled} attribute allows an application program to check at compile
5018 time to see if the designated check is currently enabled. The prefix is a
5019 simple identifier, referencing any predefined check name (other than
5020 @code{All_Checks}) or a check name introduced by pragma Check_Name. If
5021 no argument is given for the attribute, the check is for the general state
5022 of the check, if an argument is given, then it is an entity name, and the
5023 check indicates whether an @code{Suppress} or @code{Unsuppress} has been
5024 given naming the entity (if not, then the argument is ignored).
5025
5026 Note that instantiations inherit the check status at the point of the
5027 instantiation, so a useful idiom is to have a library package that
5028 introduces a check name with @code{pragma Check_Name}, and then contains
5029 generic packages or subprograms which use the @code{Enabled} attribute
5030 to see if the check is enabled. A user of this package can then issue
5031 a @code{pragma Suppress} or @code{pragma Unsuppress} before instantiating
5032 the package or subprogram, controlling whether the check will be present.
5033
5034 @node Enum_Rep
5035 @unnumberedsec Enum_Rep
5036 @cindex Representation of enums
5037 @findex Enum_Rep
5038 @noindent
5039 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
5040 function with the following spec:
5041
5042 @smallexample @c ada
5043 function @var{S}'Enum_Rep (Arg : @var{S}'Base)
5044   return @i{Universal_Integer};
5045 @end smallexample
5046
5047 @noindent
5048 It is also allowable to apply @code{Enum_Rep} directly to an object of an
5049 enumeration type or to a non-overloaded enumeration
5050 literal.  In this case @code{@var{S}'Enum_Rep} is equivalent to
5051 @code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
5052 enumeration literal or object.
5053
5054 The function returns the representation value for the given enumeration
5055 value.  This will be equal to value of the @code{Pos} attribute in the
5056 absence of an enumeration representation clause.  This is a static
5057 attribute (i.e.@: the result is static if the argument is static).
5058
5059 @code{@var{S}'Enum_Rep} can also be used with integer types and objects,
5060 in which case it simply returns the integer value.  The reason for this
5061 is to allow it to be used for @code{(<>)} discrete formal arguments in
5062 a generic unit that can be instantiated with either enumeration types
5063 or integer types.  Note that if @code{Enum_Rep} is used on a modular
5064 type whose upper bound exceeds the upper bound of the largest signed
5065 integer type, and the argument is a variable, so that the universal
5066 integer calculation is done at run time, then the call to @code{Enum_Rep}
5067 may raise @code{Constraint_Error}.
5068
5069 @node Epsilon
5070 @unnumberedsec Epsilon
5071 @cindex Ada 83 attributes
5072 @findex Epsilon
5073 @noindent
5074 The @code{Epsilon} attribute is provided for compatibility with Ada 83.  See
5075 the Ada 83 reference manual for an exact description of the semantics of
5076 this attribute.
5077
5078 @node Fixed_Value
5079 @unnumberedsec Fixed_Value
5080 @findex Fixed_Value
5081 @noindent
5082 For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
5083 function with the following specification:
5084
5085 @smallexample @c ada
5086 function @var{S}'Fixed_Value (Arg : @i{Universal_Integer})
5087   return @var{S};
5088 @end smallexample
5089
5090 @noindent
5091 The value returned is the fixed-point value @var{V} such that
5092
5093 @smallexample @c ada
5094 @var{V} = Arg * @var{S}'Small
5095 @end smallexample
5096
5097 @noindent
5098 The effect is thus similar to first converting the argument to the
5099 integer type used to represent @var{S}, and then doing an unchecked
5100 conversion to the fixed-point type.  The difference is
5101 that there are full range checks, to ensure that the result is in range.
5102 This attribute is primarily intended for use in implementation of the
5103 input-output functions for fixed-point values.
5104
5105 @node Has_Access_Values
5106 @unnumberedsec Has_Access_Values
5107 @cindex Access values, testing for
5108 @findex Has_Access_Values
5109 @noindent
5110 The prefix of the @code{Has_Access_Values} attribute is a type.  The result
5111 is a Boolean value which is True if the is an access type, or is a composite
5112 type with a component (at any nesting depth) that is an access type, and is
5113 False otherwise.
5114 The intended use of this attribute is in conjunction with generic
5115 definitions.  If the attribute is applied to a generic private type, it
5116 indicates whether or not the corresponding actual type has access values.
5117
5118 @node Has_Discriminants
5119 @unnumberedsec Has_Discriminants
5120 @cindex Discriminants, testing for
5121 @findex Has_Discriminants
5122 @noindent
5123 The prefix of the @code{Has_Discriminants} attribute is a type.  The result
5124 is a Boolean value which is True if the type has discriminants, and False
5125 otherwise.  The intended use of this attribute is in conjunction with generic
5126 definitions.  If the attribute is applied to a generic private type, it
5127 indicates whether or not the corresponding actual type has discriminants.
5128
5129 @node Img
5130 @unnumberedsec Img
5131 @findex Img
5132 @noindent
5133 The @code{Img} attribute differs from @code{Image} in that it may be
5134 applied to objects as well as types, in which case it gives the
5135 @code{Image} for the subtype of the object.  This is convenient for
5136 debugging:
5137
5138 @smallexample @c ada
5139 Put_Line ("X = " & X'Img);
5140 @end smallexample
5141
5142 @noindent
5143 has the same meaning as the more verbose:
5144
5145 @smallexample @c ada
5146 Put_Line ("X = " & @var{T}'Image (X));
5147 @end smallexample
5148
5149 @noindent
5150 where @var{T} is the (sub)type of the object @code{X}.
5151
5152 @node Integer_Value
5153 @unnumberedsec Integer_Value
5154 @findex Integer_Value
5155 @noindent
5156 For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
5157 function with the following spec:
5158
5159 @smallexample @c ada
5160 function @var{S}'Integer_Value (Arg : @i{Universal_Fixed})
5161   return @var{S};
5162 @end smallexample
5163
5164 @noindent
5165 The value returned is the integer value @var{V}, such that
5166
5167 @smallexample @c ada
5168 Arg = @var{V} * @var{T}'Small
5169 @end smallexample
5170
5171 @noindent
5172 where @var{T} is the type of @code{Arg}.
5173 The effect is thus similar to first doing an unchecked conversion from
5174 the fixed-point type to its corresponding implementation type, and then
5175 converting the result to the target integer type.  The difference is
5176 that there are full range checks, to ensure that the result is in range.
5177 This attribute is primarily intended for use in implementation of the
5178 standard input-output functions for fixed-point values.
5179
5180 @node Large
5181 @unnumberedsec Large
5182 @cindex Ada 83 attributes
5183 @findex Large
5184 @noindent
5185 The @code{Large} attribute is provided for compatibility with Ada 83.  See
5186 the Ada 83 reference manual for an exact description of the semantics of
5187 this attribute.
5188
5189 @node Machine_Size
5190 @unnumberedsec Machine_Size
5191 @findex Machine_Size
5192 @noindent
5193 This attribute is identical to the @code{Object_Size} attribute.  It is
5194 provided for compatibility with the DEC Ada 83 attribute of this name.
5195
5196 @node Mantissa
5197 @unnumberedsec Mantissa
5198 @cindex Ada 83 attributes
5199 @findex Mantissa
5200 @noindent
5201 The @code{Mantissa} attribute is provided for compatibility with Ada 83.  See
5202 the Ada 83 reference manual for an exact description of the semantics of
5203 this attribute.
5204
5205 @node Max_Interrupt_Priority
5206 @unnumberedsec Max_Interrupt_Priority
5207 @cindex Interrupt priority, maximum
5208 @findex Max_Interrupt_Priority
5209 @noindent
5210 @code{Standard'Max_Interrupt_Priority} (@code{Standard} is the only
5211 permissible prefix), provides the same value as
5212 @code{System.Max_Interrupt_Priority}.
5213
5214 @node Max_Priority
5215 @unnumberedsec Max_Priority
5216 @cindex Priority, maximum
5217 @findex Max_Priority
5218 @noindent
5219 @code{Standard'Max_Priority} (@code{Standard} is the only permissible
5220 prefix) provides the same value as @code{System.Max_Priority}.
5221
5222 @node Maximum_Alignment
5223 @unnumberedsec Maximum_Alignment
5224 @cindex Alignment, maximum
5225 @findex Maximum_Alignment
5226 @noindent
5227 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
5228 permissible prefix) provides the maximum useful alignment value for the
5229 target.  This is a static value that can be used to specify the alignment
5230 for an object, guaranteeing that it is properly aligned in all
5231 cases.
5232
5233 @node Mechanism_Code
5234 @unnumberedsec Mechanism_Code
5235 @cindex Return values, passing mechanism
5236 @cindex Parameters, passing mechanism
5237 @findex Mechanism_Code
5238 @noindent
5239 @code{@var{function}'Mechanism_Code} yields an integer code for the
5240 mechanism used for the result of function, and
5241 @code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
5242 used for formal parameter number @var{n} (a static integer value with 1
5243 meaning the first parameter) of @var{subprogram}.  The code returned is:
5244
5245 @table @asis
5246 @item 1
5247 by copy (value)
5248 @item 2
5249 by reference
5250 @item 3
5251 by descriptor (default descriptor class)
5252 @item 4
5253 by descriptor (UBS: unaligned bit string)
5254 @item 5
5255 by descriptor (UBSB: aligned bit string with arbitrary bounds)
5256 @item 6
5257 by descriptor (UBA: unaligned bit array)
5258 @item 7
5259 by descriptor (S: string, also scalar access type parameter)
5260 @item 8
5261 by descriptor (SB: string with arbitrary bounds)
5262 @item 9
5263 by descriptor (A: contiguous array)
5264 @item 10
5265 by descriptor (NCA: non-contiguous array)
5266 @end table
5267
5268 @noindent
5269 Values from 3 through 10 are only relevant to Digital OpenVMS implementations.
5270 @cindex OpenVMS
5271
5272 @node Null_Parameter
5273 @unnumberedsec Null_Parameter
5274 @cindex Zero address, passing
5275 @findex Null_Parameter
5276 @noindent
5277 A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
5278 type or subtype @var{T} allocated at machine address zero.  The attribute
5279 is allowed only as the default expression of a formal parameter, or as
5280 an actual expression of a subprogram call.  In either case, the
5281 subprogram must be imported.
5282
5283 The identity of the object is represented by the address zero in the
5284 argument list, independent of the passing mechanism (explicit or
5285 default).
5286
5287 This capability is needed to specify that a zero address should be
5288 passed for a record or other composite object passed by reference.
5289 There is no way of indicating this without the @code{Null_Parameter}
5290 attribute.
5291
5292 @node Object_Size
5293 @unnumberedsec Object_Size
5294 @cindex Size, used for objects
5295 @findex Object_Size
5296 @noindent
5297 The size of an object is not necessarily the same as the size of the type
5298 of an object.  This is because by default object sizes are increased to be
5299 a multiple of the alignment of the object.  For example,
5300 @code{Natural'Size} is
5301 31, but by default objects of type @code{Natural} will have a size of 32 bits.
5302 Similarly, a record containing an integer and a character:
5303
5304 @smallexample @c ada
5305 type Rec is record
5306    I : Integer;
5307    C : Character;
5308 end record;
5309 @end smallexample
5310
5311 @noindent
5312 will have a size of 40 (that is @code{Rec'Size} will be 40.  The
5313 alignment will be 4, because of the
5314 integer field, and so the default size of record objects for this type
5315 will be 64 (8 bytes).
5316
5317 The @code{@var{type}'Object_Size} attribute
5318 has been added to GNAT to allow the
5319 default object size of a type to be easily determined.  For example,
5320 @code{Natural'Object_Size} is 32, and
5321 @code{Rec'Object_Size} (for the record type in the above example) will be
5322 64.  Note also that, unlike the situation with the
5323 @code{Size} attribute as defined in the Ada RM, the
5324 @code{Object_Size} attribute can be specified individually
5325 for different subtypes.  For example:
5326
5327 @smallexample @c ada
5328 type R is new Integer;
5329 subtype R1 is R range 1 .. 10;
5330 subtype R2 is R range 1 .. 10;
5331 for R2'Object_Size use 8;
5332 @end smallexample
5333
5334 @noindent
5335 In this example, @code{R'Object_Size} and @code{R1'Object_Size} are both
5336 32 since the default object size for a subtype is the same as the object size
5337 for the parent subtype.  This means that objects of type @code{R}
5338 or @code{R1} will
5339 by default be 32 bits (four bytes).  But objects of type
5340 @code{R2} will be only
5341 8 bits (one byte), since @code{R2'Object_Size} has been set to 8.
5342
5343 Although @code{Object_Size} does properly reflect the default object size
5344 value, it is not necessarily the case that all objects will be of this size
5345 in a case where it is not specified explicitly. The compiler is free to
5346 increase the size and alignment of stand alone objects to improve efficiency
5347 of the generated code and sometimes does so in the case of large composite
5348 objects. If the size of a stand alone object is critical to the
5349 application, it should be specified explicitly.
5350
5351 @node Passed_By_Reference
5352 @unnumberedsec Passed_By_Reference
5353 @cindex Parameters, when passed by reference
5354 @findex Passed_By_Reference
5355 @noindent
5356 @code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
5357 a value of type @code{Boolean} value that is @code{True} if the type is
5358 normally passed by reference and @code{False} if the type is normally
5359 passed by copy in calls.  For scalar types, the result is always @code{False}
5360 and is static.  For non-scalar types, the result is non-static.
5361
5362 @node Pool_Address
5363 @unnumberedsec Pool_Address
5364 @cindex Parameters, when passed by reference
5365 @findex Pool_Address
5366 @noindent
5367 @code{@var{X}'Pool_Address} for any object @var{X} returns the address
5368 of X within its storage pool. This is the same as
5369 @code{@var{X}'Address}, except that for an unconstrained array whose
5370 bounds are allocated just before the first component,
5371 @code{@var{X}'Pool_Address} returns the address of those bounds,
5372 whereas @code{@var{X}'Address} returns the address of the first
5373 component.
5374
5375 Here, we are interpreting ``storage pool'' broadly to mean ``wherever
5376 the object is allocated'', which could be a user-defined storage pool,
5377 the global heap, on the stack, or in a static memory area. For an
5378 object created by @code{new}, @code{@var{Ptr.all}'Pool_Address} is
5379 what is passed to @code{Allocate} and returned from @code{Deallocate}.
5380
5381 @node Range_Length
5382 @unnumberedsec Range_Length
5383 @findex Range_Length
5384 @noindent
5385 @code{@var{type}'Range_Length} for any discrete type @var{type} yields
5386 the number of values represented by the subtype (zero for a null
5387 range).  The result is static for static subtypes.  @code{Range_Length}
5388 applied to the index subtype of a one dimensional array always gives the
5389 same result as @code{Range} applied to the array itself.
5390
5391 @node Safe_Emax
5392 @unnumberedsec Safe_Emax
5393 @cindex Ada 83 attributes
5394 @findex Safe_Emax
5395 @noindent
5396 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83.  See
5397 the Ada 83 reference manual for an exact description of the semantics of
5398 this attribute.
5399
5400 @node Safe_Large
5401 @unnumberedsec Safe_Large
5402 @cindex Ada 83 attributes
5403 @findex Safe_Large
5404 @noindent
5405 The @code{Safe_Large} attribute is provided for compatibility with Ada 83.  See
5406 the Ada 83 reference manual for an exact description of the semantics of
5407 this attribute.
5408
5409 @node Small
5410 @unnumberedsec Small
5411 @cindex Ada 83 attributes
5412 @findex Small
5413 @noindent
5414 The @code{Small} attribute is defined in Ada 95 (and Ada 2005) only for
5415 fixed-point types.
5416 GNAT also allows this attribute to be applied to floating-point types
5417 for compatibility with Ada 83.  See
5418 the Ada 83 reference manual for an exact description of the semantics of
5419 this attribute when applied to floating-point types.
5420
5421 @node Storage_Unit
5422 @unnumberedsec Storage_Unit
5423 @findex Storage_Unit
5424 @noindent
5425 @code{Standard'Storage_Unit} (@code{Standard} is the only permissible
5426 prefix) provides the same value as @code{System.Storage_Unit}.
5427
5428 @node Stub_Type
5429 @unnumberedsec Stub_Type
5430 @findex Stub_Type
5431 @noindent
5432 The GNAT implementation of remote access-to-classwide types is
5433 organized as described in AARM section E.4 (20.t): a value of an RACW type
5434 (designating a remote object) is represented as a normal access
5435 value, pointing to a "stub" object which in turn contains the
5436 necessary information to contact the designated remote object. A
5437 call on any dispatching operation of such a stub object does the
5438 remote call, if necessary, using the information in the stub object
5439 to locate the target partition, etc.
5440
5441 For a prefix @code{T} that denotes a remote access-to-classwide type,
5442 @code{T'Stub_Type} denotes the type of the corresponding stub objects.
5443
5444 By construction, the layout of @code{T'Stub_Type} is identical to that of
5445 type @code{RACW_Stub_Type} declared in the internal implementation-defined
5446 unit @code{System.Partition_Interface}. Use of this attribute will create
5447 an implicit dependency on this unit.
5448
5449 @node Target_Name
5450 @unnumberedsec Target_Name
5451 @findex Target_Name
5452 @noindent
5453 @code{Standard'Target_Name} (@code{Standard} is the only permissible
5454 prefix) provides a static string value that identifies the target
5455 for the current compilation. For GCC implementations, this is the
5456 standard gcc target name without the terminating slash (for
5457 example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
5458
5459 @node Tick
5460 @unnumberedsec Tick
5461 @findex Tick
5462 @noindent
5463 @code{Standard'Tick} (@code{Standard} is the only permissible prefix)
5464 provides the same value as @code{System.Tick},
5465
5466 @node To_Address
5467 @unnumberedsec To_Address
5468 @findex To_Address
5469 @noindent
5470 The @code{System'To_Address}
5471 (@code{System} is the only permissible prefix)
5472 denotes a function identical to
5473 @code{System.Storage_Elements.To_Address} except that
5474 it is a static attribute.  This means that if its argument is
5475 a static expression, then the result of the attribute is a
5476 static expression.  The result is that such an expression can be
5477 used in contexts (e.g.@: preelaborable packages) which require a
5478 static expression and where the function call could not be used
5479 (since the function call is always non-static, even if its
5480 argument is static).
5481
5482 @node Type_Class
5483 @unnumberedsec Type_Class
5484 @findex Type_Class
5485 @noindent
5486 @code{@var{type}'Type_Class} for any type or subtype @var{type} yields
5487 the value of the type class for the full type of @var{type}.  If
5488 @var{type} is a generic formal type, the value is the value for the
5489 corresponding actual subtype.  The value of this attribute is of type
5490 @code{System.Aux_DEC.Type_Class}, which has the following definition:
5491
5492 @smallexample @c ada
5493   type Type_Class is
5494     (Type_Class_Enumeration,
5495      Type_Class_Integer,
5496      Type_Class_Fixed_Point,
5497      Type_Class_Floating_Point,
5498      Type_Class_Array,
5499      Type_Class_Record,
5500      Type_Class_Access,
5501      Type_Class_Task,
5502      Type_Class_Address);
5503 @end smallexample
5504
5505 @noindent
5506 Protected types yield the value @code{Type_Class_Task}, which thus
5507 applies to all concurrent types.  This attribute is designed to
5508 be compatible with the DEC Ada 83 attribute of the same name.
5509
5510 @node UET_Address
5511 @unnumberedsec UET_Address
5512 @findex UET_Address
5513 @noindent
5514 The @code{UET_Address} attribute can only be used for a prefix which
5515 denotes a library package.  It yields the address of the unit exception
5516 table when zero cost exception handling is used.  This attribute is
5517 intended only for use within the GNAT implementation.  See the unit
5518 @code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb}
5519 for details on how this attribute is used in the implementation.
5520
5521 @node Unconstrained_Array
5522 @unnumberedsec Unconstrained_Array
5523 @findex Unconstrained_Array
5524 @noindent
5525 The @code{Unconstrained_Array} attribute can be used with a prefix that
5526 denotes any type or subtype. It is a static attribute that yields
5527 @code{True} if the prefix designates an unconstrained array,
5528 and @code{False} otherwise. In a generic instance, the result is
5529 still static, and yields the result of applying this test to the
5530 generic actual.
5531
5532 @node Universal_Literal_String
5533 @unnumberedsec Universal_Literal_String
5534 @cindex Named numbers, representation of
5535 @findex Universal_Literal_String
5536 @noindent
5537 The prefix of @code{Universal_Literal_String} must be a named
5538 number.  The static result is the string consisting of the characters of
5539 the number as defined in the original source.  This allows the user
5540 program to access the actual text of named numbers without intermediate
5541 conversions and without the need to enclose the strings in quotes (which
5542 would preclude their use as numbers).  This is used internally for the
5543 construction of values of the floating-point attributes from the file
5544 @file{ttypef.ads}, but may also be used by user programs.
5545
5546 For example, the following program prints the first 50 digits of pi:
5547
5548 @smallexample @c ada
5549 with Text_IO; use Text_IO;
5550 with Ada.Numerics;
5551 procedure Pi is
5552 begin
5553    Put (Ada.Numerics.Pi'Universal_Literal_String);
5554 end;
5555 @end smallexample
5556
5557 @node Unrestricted_Access
5558 @unnumberedsec Unrestricted_Access
5559 @cindex @code{Access}, unrestricted
5560 @findex Unrestricted_Access
5561 @noindent
5562 The @code{Unrestricted_Access} attribute is similar to @code{Access}
5563 except that all accessibility and aliased view checks are omitted.  This
5564 is a user-beware attribute.  It is similar to
5565 @code{Address}, for which it is a desirable replacement where the value
5566 desired is an access type.  In other words, its effect is identical to
5567 first applying the @code{Address} attribute and then doing an unchecked
5568 conversion to a desired access type.  In GNAT, but not necessarily in
5569 other implementations, the use of static chains for inner level
5570 subprograms means that @code{Unrestricted_Access} applied to a
5571 subprogram yields a value that can be called as long as the subprogram
5572 is in scope (normal Ada accessibility rules restrict this usage).
5573
5574 It is possible to use @code{Unrestricted_Access} for any type, but care
5575 must be exercised if it is used to create pointers to unconstrained
5576 objects. In this case, the resulting pointer has the same scope as the
5577 context of the attribute, and may not be returned to some enclosing
5578 scope. For instance, a function cannot use @code{Unrestricted_Access}
5579 to create a unconstrained pointer and then return that value to the
5580 caller.
5581
5582 @node VADS_Size
5583 @unnumberedsec VADS_Size
5584 @cindex @code{Size}, VADS compatibility
5585 @findex VADS_Size
5586 @noindent
5587 The @code{'VADS_Size} attribute is intended to make it easier to port
5588 legacy code which relies on the semantics of @code{'Size} as implemented
5589 by the VADS Ada 83 compiler.  GNAT makes a best effort at duplicating the
5590 same semantic interpretation.  In particular, @code{'VADS_Size} applied
5591 to a predefined or other primitive type with no Size clause yields the
5592 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
5593 typical machines).  In addition @code{'VADS_Size} applied to an object
5594 gives the result that would be obtained by applying the attribute to
5595 the corresponding type.
5596
5597 @node Value_Size
5598 @unnumberedsec Value_Size
5599 @cindex @code{Size}, setting for not-first subtype
5600 @findex Value_Size
5601 @code{@var{type}'Value_Size} is the number of bits required to represent
5602 a value of the given subtype.  It is the same as @code{@var{type}'Size},
5603 but, unlike @code{Size}, may be set for non-first subtypes.
5604
5605 @node Wchar_T_Size
5606 @unnumberedsec Wchar_T_Size
5607 @findex Wchar_T_Size
5608 @code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
5609 prefix) provides the size in bits of the C @code{wchar_t} type
5610 primarily for constructing the definition of this type in
5611 package @code{Interfaces.C}.
5612
5613 @node Word_Size
5614 @unnumberedsec Word_Size
5615 @findex Word_Size
5616 @code{Standard'Word_Size} (@code{Standard} is the only permissible
5617 prefix) provides the value @code{System.Word_Size}.
5618
5619 @c ------------------------
5620 @node Implementation Advice
5621 @chapter Implementation Advice
5622 @noindent
5623 The main text of the Ada Reference Manual describes the required
5624 behavior of all Ada compilers, and the GNAT compiler conforms to
5625 these requirements.
5626
5627 In addition, there are sections throughout the Ada Reference Manual headed
5628 by the phrase ``Implementation advice''.  These sections are not normative,
5629 i.e., they do not specify requirements that all compilers must
5630 follow.  Rather they provide advice on generally desirable behavior.  You
5631 may wonder why they are not requirements.  The most typical answer is
5632 that they describe behavior that seems generally desirable, but cannot
5633 be provided on all systems, or which may be undesirable on some systems.
5634
5635 As far as practical, GNAT follows the implementation advice sections in
5636 the Ada Reference Manual.  This chapter contains a table giving the
5637 reference manual section number, paragraph number and several keywords
5638 for each advice.  Each entry consists of the text of the advice followed
5639 by the GNAT interpretation of this advice.  Most often, this simply says
5640 ``followed'', which means that GNAT follows the advice.  However, in a
5641 number of cases, GNAT deliberately deviates from this advice, in which
5642 case the text describes what GNAT does and why.
5643
5644 @cindex Error detection
5645 @unnumberedsec 1.1.3(20): Error Detection
5646 @sp 1
5647 @cartouche
5648 If an implementation detects the use of an unsupported Specialized Needs
5649 Annex feature at run time, it should raise @code{Program_Error} if
5650 feasible.
5651 @end cartouche
5652 Not relevant.  All specialized needs annex features are either supported,
5653 or diagnosed at compile time.
5654
5655 @cindex Child Units
5656 @unnumberedsec 1.1.3(31): Child Units
5657 @sp 1
5658 @cartouche
5659 If an implementation wishes to provide implementation-defined
5660 extensions to the functionality of a language-defined library unit, it
5661 should normally do so by adding children to the library unit.
5662 @end cartouche
5663 Followed.
5664
5665 @cindex Bounded errors
5666 @unnumberedsec 1.1.5(12): Bounded Errors
5667 @sp 1
5668 @cartouche
5669 If an implementation detects a bounded error or erroneous
5670 execution, it should raise @code{Program_Error}.
5671 @end cartouche
5672 Followed in all cases in which the implementation detects a bounded
5673 error or erroneous execution.  Not all such situations are detected at
5674 runtime.
5675
5676 @cindex Pragmas
5677 @unnumberedsec 2.8(16): Pragmas
5678 @sp 1
5679 @cartouche
5680 Normally, implementation-defined pragmas should have no semantic effect
5681 for error-free programs; that is, if the implementation-defined pragmas
5682 are removed from a working program, the program should still be legal,
5683 and should still have the same semantics.
5684 @end cartouche
5685 The following implementation defined pragmas are exceptions to this
5686 rule:
5687
5688 @table @code
5689 @item Abort_Defer
5690 Affects semantics
5691 @item Ada_83
5692 Affects legality
5693 @item Assert
5694 Affects semantics
5695 @item CPP_Class
5696 Affects semantics
5697 @item CPP_Constructor
5698 Affects semantics
5699 @item Debug
5700 Affects semantics
5701 @item Interface_Name
5702 Affects semantics
5703 @item Machine_Attribute
5704 Affects semantics
5705 @item Unimplemented_Unit
5706 Affects legality
5707 @item Unchecked_Union
5708 Affects semantics
5709 @end table
5710
5711 @noindent
5712 In each of the above cases, it is essential to the purpose of the pragma
5713 that this advice not be followed.  For details see the separate section
5714 on implementation defined pragmas.
5715
5716 @unnumberedsec 2.8(17-19): Pragmas
5717 @sp 1
5718 @cartouche
5719 Normally, an implementation should not define pragmas that can
5720 make an illegal program legal, except as follows:
5721 @end cartouche
5722 @sp 1
5723 @cartouche
5724 A pragma used to complete a declaration, such as a pragma @code{Import};
5725 @end cartouche
5726 @sp 1
5727 @cartouche
5728 A pragma used to configure the environment by adding, removing, or
5729 replacing @code{library_items}.
5730 @end cartouche
5731 See response to paragraph 16 of this same section.
5732
5733 @cindex Character Sets
5734 @cindex Alternative Character Sets
5735 @unnumberedsec 3.5.2(5): Alternative Character Sets
5736 @sp 1
5737 @cartouche
5738 If an implementation supports a mode with alternative interpretations
5739 for @code{Character} and @code{Wide_Character}, the set of graphic
5740 characters of @code{Character} should nevertheless remain a proper
5741 subset of the set of graphic characters of @code{Wide_Character}.  Any
5742 character set ``localizations'' should be reflected in the results of
5743 the subprograms defined in the language-defined package
5744 @code{Characters.Handling} (see A.3) available in such a mode.  In a mode with
5745 an alternative interpretation of @code{Character}, the implementation should
5746 also support a corresponding change in what is a legal
5747 @code{identifier_letter}.
5748 @end cartouche
5749 Not all wide character modes follow this advice, in particular the JIS
5750 and IEC modes reflect standard usage in Japan, and in these encoding,
5751 the upper half of the Latin-1 set is not part of the wide-character
5752 subset, since the most significant bit is used for wide character
5753 encoding.  However, this only applies to the external forms.  Internally
5754 there is no such restriction.
5755
5756 @cindex Integer types
5757 @unnumberedsec 3.5.4(28): Integer Types
5758
5759 @sp 1
5760 @cartouche
5761 An implementation should support @code{Long_Integer} in addition to
5762 @code{Integer} if the target machine supports 32-bit (or longer)
5763 arithmetic.  No other named integer subtypes are recommended for package
5764 @code{Standard}.  Instead, appropriate named integer subtypes should be
5765 provided in the library package @code{Interfaces} (see B.2).
5766 @end cartouche
5767 @code{Long_Integer} is supported.  Other standard integer types are supported
5768 so this advice is not fully followed.  These types
5769 are supported for convenient interface to C, and so that all hardware
5770 types of the machine are easily available.
5771 @unnumberedsec 3.5.4(29): Integer Types
5772
5773 @sp 1
5774 @cartouche
5775 An implementation for a two's complement machine should support
5776 modular types with a binary modulus up to @code{System.Max_Int*2+2}.  An
5777 implementation should support a non-binary modules up to @code{Integer'Last}.
5778 @end cartouche
5779 Followed.
5780
5781 @cindex Enumeration values
5782 @unnumberedsec 3.5.5(8): Enumeration Values
5783 @sp 1
5784 @cartouche
5785 For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
5786 subtype, if the value of the operand does not correspond to the internal
5787 code for any enumeration literal of its type (perhaps due to an
5788 un-initialized variable), then the implementation should raise
5789 @code{Program_Error}.  This is particularly important for enumeration
5790 types with noncontiguous internal codes specified by an
5791 enumeration_representation_clause.
5792 @end cartouche
5793 Followed.
5794
5795 @cindex Float types
5796 @unnumberedsec 3.5.7(17): Float Types
5797 @sp 1
5798 @cartouche
5799 An implementation should support @code{Long_Float} in addition to
5800 @code{Float} if the target machine supports 11 or more digits of
5801 precision.  No other named floating point subtypes are recommended for
5802 package @code{Standard}.  Instead, appropriate named floating point subtypes
5803 should be provided in the library package @code{Interfaces} (see B.2).
5804 @end cartouche
5805 @code{Short_Float} and @code{Long_Long_Float} are also provided.  The
5806 former provides improved compatibility with other implementations
5807 supporting this type.  The latter corresponds to the highest precision
5808 floating-point type supported by the hardware.  On most machines, this
5809 will be the same as @code{Long_Float}, but on some machines, it will
5810 correspond to the IEEE extended form.  The notable case is all ia32
5811 (x86) implementations, where @code{Long_Long_Float} corresponds to
5812 the 80-bit extended precision format supported in hardware on this
5813 processor.  Note that the 128-bit format on SPARC is not supported,
5814 since this is a software rather than a hardware format.
5815
5816 @cindex Multidimensional arrays
5817 @cindex Arrays, multidimensional
5818 @unnumberedsec 3.6.2(11): Multidimensional Arrays
5819 @sp 1
5820 @cartouche
5821 An implementation should normally represent multidimensional arrays in
5822 row-major order, consistent with the notation used for multidimensional
5823 array aggregates (see 4.3.3).  However, if a pragma @code{Convention}
5824 (@code{Fortran}, @dots{}) applies to a multidimensional array type, then
5825 column-major order should be used instead (see B.5, ``Interfacing with
5826 Fortran'').
5827 @end cartouche
5828 Followed.
5829
5830 @findex Duration'Small
5831 @unnumberedsec 9.6(30-31): Duration'Small
5832 @sp 1
5833 @cartouche
5834 Whenever possible in an implementation, the value of @code{Duration'Small}
5835 should be no greater than 100 microseconds.
5836 @end cartouche
5837 Followed.  (@code{Duration'Small} = 10**(@minus{}9)).
5838
5839 @sp 1
5840 @cartouche
5841 The time base for @code{delay_relative_statements} should be monotonic;
5842 it need not be the same time base as used for @code{Calendar.Clock}.
5843 @end cartouche
5844 Followed.
5845
5846 @unnumberedsec 10.2.1(12): Consistent Representation
5847 @sp 1
5848 @cartouche
5849 In an implementation, a type declared in a pre-elaborated package should
5850 have the same representation in every elaboration of a given version of
5851 the package, whether the elaborations occur in distinct executions of
5852 the same program, or in executions of distinct programs or partitions
5853 that include the given version.
5854 @end cartouche
5855 Followed, except in the case of tagged types.  Tagged types involve
5856 implicit pointers to a local copy of a dispatch table, and these pointers
5857 have representations which thus depend on a particular elaboration of the
5858 package.  It is not easy to see how it would be possible to follow this
5859 advice without severely impacting efficiency of execution.
5860
5861 @cindex Exception information
5862 @unnumberedsec 11.4.1(19): Exception Information
5863 @sp 1
5864 @cartouche
5865 @code{Exception_Message} by default and @code{Exception_Information}
5866 should produce information useful for
5867 debugging.  @code{Exception_Message} should be short, about one
5868 line.  @code{Exception_Information} can be long.  @code{Exception_Message}
5869 should not include the
5870 @code{Exception_Name}.  @code{Exception_Information} should include both
5871 the @code{Exception_Name} and the @code{Exception_Message}.
5872 @end cartouche
5873 Followed.  For each exception that doesn't have a specified
5874 @code{Exception_Message}, the compiler generates one containing the location
5875 of the raise statement.  This location has the form ``file:line'', where
5876 file is the short file name (without path information) and line is the line
5877 number in the file.  Note that in the case of the Zero Cost Exception
5878 mechanism, these messages become redundant with the Exception_Information that
5879 contains a full backtrace of the calling sequence, so they are disabled.
5880 To disable explicitly the generation of the source location message, use the
5881 Pragma @code{Discard_Names}.
5882
5883 @cindex Suppression of checks
5884 @cindex Checks, suppression of
5885 @unnumberedsec 11.5(28): Suppression of Checks
5886 @sp 1
5887 @cartouche
5888 The implementation should minimize the code executed for checks that
5889 have been suppressed.
5890 @end cartouche
5891 Followed.
5892
5893 @cindex Representation clauses
5894 @unnumberedsec 13.1 (21-24): Representation Clauses
5895 @sp 1
5896 @cartouche
5897 The recommended level of support for all representation items is
5898 qualified as follows:
5899 @end cartouche
5900 @sp 1
5901 @cartouche
5902 An implementation need not support representation items containing
5903 non-static expressions, except that an implementation should support a
5904 representation item for a given entity if each non-static expression in
5905 the representation item is a name that statically denotes a constant
5906 declared before the entity.
5907 @end cartouche
5908 Followed.  In fact, GNAT goes beyond the recommended level of support
5909 by allowing nonstatic expressions in some representation clauses even
5910 without the need to declare constants initialized with the values of
5911 such expressions.
5912 For example:
5913
5914 @smallexample @c ada
5915   X : Integer;
5916   Y : Float;
5917   for Y'Address use X'Address;>>
5918 @end smallexample
5919
5920
5921 @sp 1
5922 @cartouche
5923 An implementation need not support a specification for the @code{Size}
5924 for a given composite subtype, nor the size or storage place for an
5925 object (including a component) of a given composite subtype, unless the
5926 constraints on the subtype and its composite subcomponents (if any) are
5927 all static constraints.
5928 @end cartouche
5929 Followed.  Size Clauses are not permitted on non-static components, as
5930 described above.
5931
5932 @sp 1
5933 @cartouche
5934 An aliased component, or a component whose type is by-reference, should
5935 always be allocated at an addressable location.
5936 @end cartouche
5937 Followed.
5938
5939 @cindex Packed types
5940 @unnumberedsec 13.2(6-8): Packed Types
5941 @sp 1
5942 @cartouche
5943 If a type is packed, then the implementation should try to minimize
5944 storage allocated to objects of the type, possibly at the expense of
5945 speed of accessing components, subject to reasonable complexity in
5946 addressing calculations.
5947 @end cartouche
5948 @sp 1
5949 @cartouche
5950 The recommended level of support pragma @code{Pack} is:
5951
5952 For a packed record type, the components should be packed as tightly as
5953 possible subject to the Sizes of the component subtypes, and subject to
5954 any @code{record_representation_clause} that applies to the type; the
5955 implementation may, but need not, reorder components or cross aligned
5956 word boundaries to improve the packing.  A component whose @code{Size} is
5957 greater than the word size may be allocated an integral number of words.
5958 @end cartouche
5959 Followed.  Tight packing of arrays is supported for all component sizes
5960 up to 64-bits. If the array component size is 1 (that is to say, if
5961 the component is a boolean type or an enumeration type with two values)
5962 then values of the type are implicitly initialized to zero. This
5963 happens both for objects of the packed type, and for objects that have a
5964 subcomponent of the packed type.
5965
5966 @sp 1
5967 @cartouche
5968 An implementation should support Address clauses for imported
5969 subprograms.
5970 @end cartouche
5971 Followed.
5972 @cindex @code{Address} clauses
5973 @unnumberedsec 13.3(14-19): Address Clauses
5974
5975 @sp 1
5976 @cartouche
5977 For an array @var{X}, @code{@var{X}'Address} should point at the first
5978 component of the array, and not at the array bounds.
5979 @end cartouche
5980 Followed.
5981
5982 @sp 1
5983 @cartouche
5984 The recommended level of support for the @code{Address} attribute is:
5985
5986 @code{@var{X}'Address} should produce a useful result if @var{X} is an
5987 object that is aliased or of a by-reference type, or is an entity whose
5988 @code{Address} has been specified.
5989 @end cartouche
5990 Followed.  A valid address will be produced even if none of those
5991 conditions have been met.  If necessary, the object is forced into
5992 memory to ensure the address is valid.
5993
5994 @sp 1
5995 @cartouche
5996 An implementation should support @code{Address} clauses for imported
5997 subprograms.
5998 @end cartouche
5999 Followed.
6000
6001 @sp 1
6002 @cartouche
6003 Objects (including subcomponents) that are aliased or of a by-reference
6004 type should be allocated on storage element boundaries.
6005 @end cartouche
6006 Followed.
6007
6008 @sp 1
6009 @cartouche
6010 If the @code{Address} of an object is specified, or it is imported or exported,
6011 then the implementation should not perform optimizations based on
6012 assumptions of no aliases.
6013 @end cartouche
6014 Followed.
6015
6016 @cindex @code{Alignment} clauses
6017 @unnumberedsec 13.3(29-35): Alignment Clauses
6018 @sp 1
6019 @cartouche
6020 The recommended level of support for the @code{Alignment} attribute for
6021 subtypes is:
6022
6023 An implementation should support specified Alignments that are factors
6024 and multiples of the number of storage elements per word, subject to the
6025 following:
6026 @end cartouche
6027 Followed.
6028
6029 @sp 1
6030 @cartouche
6031 An implementation need not support specified @code{Alignment}s for
6032 combinations of @code{Size}s and @code{Alignment}s that cannot be easily
6033 loaded and stored by available machine instructions.
6034 @end cartouche
6035 Followed.
6036
6037 @sp 1
6038 @cartouche
6039 An implementation need not support specified @code{Alignment}s that are
6040 greater than the maximum @code{Alignment} the implementation ever returns by
6041 default.
6042 @end cartouche
6043 Followed.
6044
6045 @sp 1
6046 @cartouche
6047 The recommended level of support for the @code{Alignment} attribute for
6048 objects is:
6049
6050 Same as above, for subtypes, but in addition:
6051 @end cartouche
6052 Followed.
6053
6054 @sp 1
6055 @cartouche
6056 For stand-alone library-level objects of statically constrained
6057 subtypes, the implementation should support all @code{Alignment}s
6058 supported by the target linker.  For example, page alignment is likely to
6059 be supported for such objects, but not for subtypes.
6060 @end cartouche
6061 Followed.
6062
6063 @cindex @code{Size} clauses
6064 @unnumberedsec 13.3(42-43): Size Clauses
6065 @sp 1
6066 @cartouche
6067 The recommended level of support for the @code{Size} attribute of
6068 objects is:
6069
6070 A @code{Size} clause should be supported for an object if the specified
6071 @code{Size} is at least as large as its subtype's @code{Size}, and
6072 corresponds to a size in storage elements that is a multiple of the
6073 object's @code{Alignment} (if the @code{Alignment} is nonzero).
6074 @end cartouche
6075 Followed.
6076
6077 @unnumberedsec 13.3(50-56): Size Clauses
6078 @sp 1
6079 @cartouche
6080 If the @code{Size} of a subtype is specified, and allows for efficient
6081 independent addressability (see 9.10) on the target architecture, then
6082 the @code{Size} of the following objects of the subtype should equal the
6083 @code{Size} of the subtype:
6084
6085 Aliased objects (including components).
6086 @end cartouche
6087 Followed.
6088
6089 @sp 1
6090 @cartouche
6091 @code{Size} clause on a composite subtype should not affect the
6092 internal layout of components.
6093 @end cartouche
6094 Followed. But note that this can be overridden by use of the implementation
6095 pragma Implicit_Packing in the case of packed arrays.
6096
6097 @sp 1
6098 @cartouche
6099 The recommended level of support for the @code{Size} attribute of subtypes is:
6100 @end cartouche
6101 @sp 1
6102 @cartouche
6103 The @code{Size} (if not specified) of a static discrete or fixed point
6104 subtype should be the number of bits needed to represent each value
6105 belonging to the subtype using an unbiased representation, leaving space
6106 for a sign bit only if the subtype contains negative values.  If such a
6107 subtype is a first subtype, then an implementation should support a
6108 specified @code{Size} for it that reflects this representation.
6109 @end cartouche
6110 Followed.
6111
6112 @sp 1
6113 @cartouche
6114 For a subtype implemented with levels of indirection, the @code{Size}
6115 should include the size of the pointers, but not the size of what they
6116 point at.
6117 @end cartouche
6118 Followed.
6119
6120 @cindex @code{Component_Size} clauses
6121 @unnumberedsec 13.3(71-73): Component Size Clauses
6122 @sp 1
6123 @cartouche
6124 The recommended level of support for the @code{Component_Size}
6125 attribute is:
6126 @end cartouche
6127 @sp 1
6128 @cartouche
6129 An implementation need not support specified @code{Component_Sizes} that are
6130 less than the @code{Size} of the component subtype.
6131 @end cartouche
6132 Followed.
6133
6134 @sp 1
6135 @cartouche
6136 An implementation should support specified @code{Component_Size}s that
6137 are factors and multiples of the word size.  For such
6138 @code{Component_Size}s, the array should contain no gaps between
6139 components.  For other @code{Component_Size}s (if supported), the array
6140 should contain no gaps between components when packing is also
6141 specified; the implementation should forbid this combination in cases
6142 where it cannot support a no-gaps representation.
6143 @end cartouche
6144 Followed.
6145
6146 @cindex Enumeration representation clauses
6147 @cindex Representation clauses, enumeration
6148 @unnumberedsec 13.4(9-10): Enumeration Representation Clauses
6149 @sp 1
6150 @cartouche
6151 The recommended level of support for enumeration representation clauses
6152 is:
6153
6154 An implementation need not support enumeration representation clauses
6155 for boolean types, but should at minimum support the internal codes in
6156 the range @code{System.Min_Int.System.Max_Int}.
6157 @end cartouche
6158 Followed.
6159
6160 @cindex Record representation clauses
6161 @cindex Representation clauses, records
6162 @unnumberedsec 13.5.1(17-22): Record Representation Clauses
6163 @sp 1
6164 @cartouche
6165 The recommended level of support for
6166 @*@code{record_representation_clauses} is:
6167
6168 An implementation should support storage places that can be extracted
6169 with a load, mask, shift sequence of machine code, and set with a load,
6170 shift, mask, store sequence, given the available machine instructions
6171 and run-time model.
6172 @end cartouche
6173 Followed.
6174
6175 @sp 1
6176 @cartouche
6177 A storage place should be supported if its size is equal to the
6178 @code{Size} of the component subtype, and it starts and ends on a
6179 boundary that obeys the @code{Alignment} of the component subtype.
6180 @end cartouche
6181 Followed.
6182
6183 @sp 1
6184 @cartouche
6185 If the default bit ordering applies to the declaration of a given type,
6186 then for a component whose subtype's @code{Size} is less than the word
6187 size, any storage place that does not cross an aligned word boundary
6188 should be supported.
6189 @end cartouche
6190 Followed.
6191
6192 @sp 1
6193 @cartouche
6194 An implementation may reserve a storage place for the tag field of a
6195 tagged type, and disallow other components from overlapping that place.
6196 @end cartouche
6197 Followed.  The storage place for the tag field is the beginning of the tagged
6198 record, and its size is Address'Size.  GNAT will reject an explicit component
6199 clause for the tag field.
6200
6201 @sp 1
6202 @cartouche
6203 An implementation need not support a @code{component_clause} for a
6204 component of an extension part if the storage place is not after the
6205 storage places of all components of the parent type, whether or not
6206 those storage places had been specified.
6207 @end cartouche
6208 Followed.  The above advice on record representation clauses is followed,
6209 and all mentioned features are implemented.
6210
6211 @cindex Storage place attributes
6212 @unnumberedsec 13.5.2(5): Storage Place Attributes
6213 @sp 1
6214 @cartouche
6215 If a component is represented using some form of pointer (such as an
6216 offset) to the actual data of the component, and this data is contiguous
6217 with the rest of the object, then the storage place attributes should
6218 reflect the place of the actual data, not the pointer.  If a component is
6219 allocated discontinuously from the rest of the object, then a warning
6220 should be generated upon reference to one of its storage place
6221 attributes.
6222 @end cartouche
6223 Followed.  There are no such components in GNAT@.
6224
6225 @cindex Bit ordering
6226 @unnumberedsec 13.5.3(7-8): Bit Ordering
6227 @sp 1
6228 @cartouche
6229 The recommended level of support for the non-default bit ordering is:
6230 @end cartouche
6231 @sp 1
6232 @cartouche
6233 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
6234 should support the non-default bit ordering in addition to the default
6235 bit ordering.
6236 @end cartouche
6237 Followed.  Word size does not equal storage size in this implementation.
6238 Thus non-default bit ordering is not supported.
6239
6240 @cindex @code{Address}, as private type
6241 @unnumberedsec 13.7(37): Address as Private
6242 @sp 1
6243 @cartouche
6244 @code{Address} should be of a private type.
6245 @end cartouche
6246 Followed.
6247
6248 @cindex Operations, on @code{Address}
6249 @cindex @code{Address}, operations of
6250 @unnumberedsec 13.7.1(16): Address Operations
6251 @sp 1
6252 @cartouche
6253 Operations in @code{System} and its children should reflect the target
6254 environment semantics as closely as is reasonable.  For example, on most
6255 machines, it makes sense for address arithmetic to ``wrap around''.
6256 Operations that do not make sense should raise @code{Program_Error}.
6257 @end cartouche
6258 Followed.  Address arithmetic is modular arithmetic that wraps around.  No
6259 operation raises @code{Program_Error}, since all operations make sense.
6260
6261 @cindex Unchecked conversion
6262 @unnumberedsec 13.9(14-17): Unchecked Conversion
6263 @sp 1
6264 @cartouche
6265 The @code{Size} of an array object should not include its bounds; hence,
6266 the bounds should not be part of the converted data.
6267 @end cartouche
6268 Followed.
6269
6270 @sp 1
6271 @cartouche
6272 The implementation should not generate unnecessary run-time checks to
6273 ensure that the representation of @var{S} is a representation of the
6274 target type.  It should take advantage of the permission to return by
6275 reference when possible.  Restrictions on unchecked conversions should be
6276 avoided unless required by the target environment.
6277 @end cartouche
6278 Followed.  There are no restrictions on unchecked conversion.  A warning is
6279 generated if the source and target types do not have the same size since
6280 the semantics in this case may be target dependent.
6281
6282 @sp 1
6283 @cartouche
6284 The recommended level of support for unchecked conversions is:
6285 @end cartouche
6286 @sp 1
6287 @cartouche
6288 Unchecked conversions should be supported and should be reversible in
6289 the cases where this clause defines the result.  To enable meaningful use
6290 of unchecked conversion, a contiguous representation should be used for
6291 elementary subtypes, for statically constrained array subtypes whose
6292 component subtype is one of the subtypes described in this paragraph,
6293 and for record subtypes without discriminants whose component subtypes
6294 are described in this paragraph.
6295 @end cartouche
6296 Followed.
6297
6298 @cindex Heap usage, implicit
6299 @unnumberedsec 13.11(23-25): Implicit Heap Usage
6300 @sp 1
6301 @cartouche
6302 An implementation should document any cases in which it dynamically
6303 allocates heap storage for a purpose other than the evaluation of an
6304 allocator.
6305 @end cartouche
6306 Followed, the only other points at which heap storage is dynamically
6307 allocated are as follows:
6308
6309 @itemize @bullet
6310 @item
6311 At initial elaboration time, to allocate dynamically sized global
6312 objects.
6313
6314 @item
6315 To allocate space for a task when a task is created.
6316
6317 @item
6318 To extend the secondary stack dynamically when needed.  The secondary
6319 stack is used for returning variable length results.
6320 @end itemize
6321
6322 @sp 1
6323 @cartouche
6324 A default (implementation-provided) storage pool for an
6325 access-to-constant type should not have overhead to support deallocation of
6326 individual objects.
6327 @end cartouche
6328 Followed.
6329
6330 @sp 1
6331 @cartouche
6332 A storage pool for an anonymous access type should be created at the
6333 point of an allocator for the type, and be reclaimed when the designated
6334 object becomes inaccessible.
6335 @end cartouche
6336 Followed.
6337
6338 @cindex Unchecked deallocation
6339 @unnumberedsec 13.11.2(17): Unchecked De-allocation
6340 @sp 1
6341 @cartouche
6342 For a standard storage pool, @code{Free} should actually reclaim the
6343 storage.
6344 @end cartouche
6345 Followed.
6346
6347 @cindex Stream oriented attributes
6348 @unnumberedsec 13.13.2(17): Stream Oriented Attributes
6349 @sp 1
6350 @cartouche
6351 If a stream element is the same size as a storage element, then the
6352 normal in-memory representation should be used by @code{Read} and
6353 @code{Write} for scalar objects.  Otherwise, @code{Read} and @code{Write}
6354 should use the smallest number of stream elements needed to represent
6355 all values in the base range of the scalar type.
6356 @end cartouche
6357
6358 Followed.  By default, GNAT uses the interpretation suggested by AI-195,
6359 which specifies using the size of the first subtype.
6360 However, such an implementation is based on direct binary
6361 representations and is therefore target- and endianness-dependent.
6362 To address this issue, GNAT also supplies an alternate implementation
6363 of the stream attributes @code{Read} and @code{Write},
6364 which uses the target-independent XDR standard representation
6365 for scalar types.
6366 @cindex XDR representation
6367 @cindex @code{Read} attribute
6368 @cindex @code{Write} attribute
6369 @cindex Stream oriented attributes
6370 The XDR implementation is provided as an alternative body of the
6371 @code{System.Stream_Attributes} package, in the file
6372 @file{s-strxdr.adb} in the GNAT library.
6373 There is no @file{s-strxdr.ads} file.
6374 In order to install the XDR implementation, do the following:
6375 @enumerate
6376 @item Replace the default implementation of the
6377 @code{System.Stream_Attributes} package with the XDR implementation.
6378 For example on a Unix platform issue the commands:
6379 @smallexample
6380 $ mv s-stratt.adb s-strold.adb
6381 $ mv s-strxdr.adb s-stratt.adb
6382 @end smallexample
6383
6384 @item
6385 Rebuild the GNAT run-time library as documented in the
6386 @cite{GNAT User's Guide}
6387 @end enumerate
6388
6389 @unnumberedsec A.1(52): Names of Predefined Numeric Types
6390 @sp 1
6391 @cartouche
6392 If an implementation provides additional named predefined integer types,
6393 then the names should end with @samp{Integer} as in
6394 @samp{Long_Integer}.  If an implementation provides additional named
6395 predefined floating point types, then the names should end with
6396 @samp{Float} as in @samp{Long_Float}.
6397 @end cartouche
6398 Followed.
6399
6400 @findex Ada.Characters.Handling
6401 @unnumberedsec A.3.2(49): @code{Ada.Characters.Handling}
6402 @sp 1
6403 @cartouche
6404 If an implementation provides a localized definition of @code{Character}
6405 or @code{Wide_Character}, then the effects of the subprograms in
6406 @code{Characters.Handling} should reflect the localizations.  See also
6407 3.5.2.
6408 @end cartouche
6409 Followed.  GNAT provides no such localized definitions.
6410
6411 @cindex Bounded-length strings
6412 @unnumberedsec A.4.4(106): Bounded-Length String Handling
6413 @sp 1
6414 @cartouche
6415 Bounded string objects should not be implemented by implicit pointers
6416 and dynamic allocation.
6417 @end cartouche
6418 Followed.  No implicit pointers or dynamic allocation are used.
6419
6420 @cindex Random number generation
6421 @unnumberedsec A.5.2(46-47): Random Number Generation
6422 @sp 1
6423 @cartouche
6424 Any storage associated with an object of type @code{Generator} should be
6425 reclaimed on exit from the scope of the object.
6426 @end cartouche
6427 Followed.
6428
6429 @sp 1
6430 @cartouche
6431 If the generator period is sufficiently long in relation to the number
6432 of distinct initiator values, then each possible value of
6433 @code{Initiator} passed to @code{Reset} should initiate a sequence of
6434 random numbers that does not, in a practical sense, overlap the sequence
6435 initiated by any other value.  If this is not possible, then the mapping
6436 between initiator values and generator states should be a rapidly
6437 varying function of the initiator value.
6438 @end cartouche
6439 Followed.  The generator period is sufficiently long for the first
6440 condition here to hold true.
6441
6442 @findex Get_Immediate
6443 @unnumberedsec A.10.7(23): @code{Get_Immediate}
6444 @sp 1
6445 @cartouche
6446 The @code{Get_Immediate} procedures should be implemented with
6447 unbuffered input.  For a device such as a keyboard, input should be
6448 @dfn{available} if a key has already been typed, whereas for a disk
6449 file, input should always be available except at end of file.  For a file
6450 associated with a keyboard-like device, any line-editing features of the
6451 underlying operating system should be disabled during the execution of
6452 @code{Get_Immediate}.
6453 @end cartouche
6454 Followed on all targets except VxWorks. For VxWorks, there is no way to
6455 provide this functionality that does not result in the input buffer being
6456 flushed before the @code{Get_Immediate} call. A special unit
6457 @code{Interfaces.Vxworks.IO} is provided that contains routines to enable
6458 this functionality.
6459
6460 @findex Export
6461 @unnumberedsec B.1(39-41): Pragma @code{Export}
6462 @sp 1
6463 @cartouche
6464 If an implementation supports pragma @code{Export} to a given language,
6465 then it should also allow the main subprogram to be written in that
6466 language.  It should support some mechanism for invoking the elaboration
6467 of the Ada library units included in the system, and for invoking the
6468 finalization of the environment task.  On typical systems, the
6469 recommended mechanism is to provide two subprograms whose link names are
6470 @code{adainit} and @code{adafinal}.  @code{adainit} should contain the
6471 elaboration code for library units.  @code{adafinal} should contain the
6472 finalization code.  These subprograms should have no effect the second
6473 and subsequent time they are called.
6474 @end cartouche
6475 Followed.
6476
6477 @sp 1
6478 @cartouche
6479 Automatic elaboration of pre-elaborated packages should be
6480 provided when pragma @code{Export} is supported.
6481 @end cartouche
6482 Followed when the main program is in Ada.  If the main program is in a
6483 foreign language, then
6484 @code{adainit} must be called to elaborate pre-elaborated
6485 packages.
6486
6487 @sp 1
6488 @cartouche
6489 For each supported convention @var{L} other than @code{Intrinsic}, an
6490 implementation should support @code{Import} and @code{Export} pragmas
6491 for objects of @var{L}-compatible types and for subprograms, and pragma
6492 @code{Convention} for @var{L}-eligible types and for subprograms,
6493 presuming the other language has corresponding features.  Pragma
6494 @code{Convention} need not be supported for scalar types.
6495 @end cartouche
6496 Followed.
6497
6498 @cindex Package @code{Interfaces}
6499 @findex Interfaces
6500 @unnumberedsec B.2(12-13): Package @code{Interfaces}
6501 @sp 1
6502 @cartouche
6503 For each implementation-defined convention identifier, there should be a
6504 child package of package Interfaces with the corresponding name.  This
6505 package should contain any declarations that would be useful for
6506 interfacing to the language (implementation) represented by the
6507 convention.  Any declarations useful for interfacing to any language on
6508 the given hardware architecture should be provided directly in
6509 @code{Interfaces}.
6510 @end cartouche
6511 Followed. An additional package not defined
6512 in the Ada Reference Manual is @code{Interfaces.CPP}, used
6513 for interfacing to C++.
6514
6515 @sp 1
6516 @cartouche
6517 An implementation supporting an interface to C, COBOL, or Fortran should
6518 provide the corresponding package or packages described in the following
6519 clauses.
6520 @end cartouche
6521 Followed.  GNAT provides all the packages described in this section.
6522
6523 @cindex C, interfacing with
6524 @unnumberedsec B.3(63-71): Interfacing with C
6525 @sp 1
6526 @cartouche
6527 An implementation should support the following interface correspondences
6528 between Ada and C@.
6529 @end cartouche
6530 Followed.
6531
6532 @sp 1
6533 @cartouche
6534 An Ada procedure corresponds to a void-returning C function.
6535 @end cartouche
6536 Followed.
6537
6538 @sp 1
6539 @cartouche
6540 An Ada function corresponds to a non-void C function.
6541 @end cartouche
6542 Followed.
6543
6544 @sp 1
6545 @cartouche
6546 An Ada @code{in} scalar parameter is passed as a scalar argument to a C
6547 function.
6548 @end cartouche
6549 Followed.
6550
6551 @sp 1
6552 @cartouche
6553 An Ada @code{in} parameter of an access-to-object type with designated
6554 type @var{T} is passed as a @code{@var{t}*} argument to a C function,
6555 where @var{t} is the C type corresponding to the Ada type @var{T}.
6556 @end cartouche
6557 Followed.
6558
6559 @sp 1
6560 @cartouche
6561 An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
6562 parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
6563 argument to a C function, where @var{t} is the C type corresponding to
6564 the Ada type @var{T}.  In the case of an elementary @code{out} or
6565 @code{in out} parameter, a pointer to a temporary copy is used to
6566 preserve by-copy semantics.
6567 @end cartouche
6568 Followed.
6569
6570 @sp 1
6571 @cartouche
6572 An Ada parameter of a record type @var{T}, of any mode, is passed as a
6573 @code{@var{t}*} argument to a C function, where @var{t} is the C
6574 structure corresponding to the Ada type @var{T}.
6575 @end cartouche
6576 Followed.  This convention may be overridden by the use of the C_Pass_By_Copy
6577 pragma, or Convention, or by explicitly specifying the mechanism for a given
6578 call using an extended import or export pragma.
6579
6580 @sp 1
6581 @cartouche
6582 An Ada parameter of an array type with component type @var{T}, of any
6583 mode, is passed as a @code{@var{t}*} argument to a C function, where
6584 @var{t} is the C type corresponding to the Ada type @var{T}.
6585 @end cartouche
6586 Followed.
6587
6588 @sp 1
6589 @cartouche
6590 An Ada parameter of an access-to-subprogram type is passed as a pointer
6591 to a C function whose prototype corresponds to the designated
6592 subprogram's specification.
6593 @end cartouche
6594 Followed.
6595
6596 @cindex COBOL, interfacing with
6597 @unnumberedsec B.4(95-98): Interfacing with COBOL
6598 @sp 1
6599 @cartouche
6600 An Ada implementation should support the following interface
6601 correspondences between Ada and COBOL@.
6602 @end cartouche
6603 Followed.
6604
6605 @sp 1
6606 @cartouche
6607 An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of
6608 the COBOL type corresponding to @var{T}.
6609 @end cartouche
6610 Followed.
6611
6612 @sp 1
6613 @cartouche
6614 An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of
6615 the corresponding COBOL type.
6616 @end cartouche
6617 Followed.
6618
6619 @sp 1
6620 @cartouche
6621 Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the
6622 COBOL type corresponding to the Ada parameter type; for scalars, a local
6623 copy is used if necessary to ensure by-copy semantics.
6624 @end cartouche
6625 Followed.
6626
6627 @cindex Fortran, interfacing with
6628 @unnumberedsec B.5(22-26): Interfacing with Fortran
6629 @sp 1
6630 @cartouche
6631 An Ada implementation should support the following interface
6632 correspondences between Ada and Fortran:
6633 @end cartouche
6634 Followed.
6635
6636 @sp 1
6637 @cartouche
6638 An Ada procedure corresponds to a Fortran subroutine.
6639 @end cartouche
6640 Followed.
6641
6642 @sp 1
6643 @cartouche
6644 An Ada function corresponds to a Fortran function.
6645 @end cartouche
6646 Followed.
6647
6648 @sp 1
6649 @cartouche
6650 An Ada parameter of an elementary, array, or record type @var{T} is
6651 passed as a @var{T} argument to a Fortran procedure, where @var{T} is
6652 the Fortran type corresponding to the Ada type @var{T}, and where the
6653 INTENT attribute of the corresponding dummy argument matches the Ada
6654 formal parameter mode; the Fortran implementation's parameter passing
6655 conventions are used.  For elementary types, a local copy is used if
6656 necessary to ensure by-copy semantics.
6657 @end cartouche
6658 Followed.
6659
6660 @sp 1
6661 @cartouche
6662 An Ada parameter of an access-to-subprogram type is passed as a
6663 reference to a Fortran procedure whose interface corresponds to the
6664 designated subprogram's specification.
6665 @end cartouche
6666 Followed.
6667
6668 @cindex Machine operations
6669 @unnumberedsec C.1(3-5): Access to Machine Operations
6670 @sp 1
6671 @cartouche
6672 The machine code or intrinsic support should allow access to all
6673 operations normally available to assembly language programmers for the
6674 target environment, including privileged instructions, if any.
6675 @end cartouche
6676 Followed.
6677
6678 @sp 1
6679 @cartouche
6680 The interfacing pragmas (see Annex B) should support interface to
6681 assembler; the default assembler should be associated with the
6682 convention identifier @code{Assembler}.
6683 @end cartouche
6684 Followed.
6685
6686 @sp 1
6687 @cartouche
6688 If an entity is exported to assembly language, then the implementation
6689 should allocate it at an addressable location, and should ensure that it
6690 is retained by the linking process, even if not otherwise referenced
6691 from the Ada code.  The implementation should assume that any call to a
6692 machine code or assembler subprogram is allowed to read or update every
6693 object that is specified as exported.
6694 @end cartouche
6695 Followed.
6696
6697 @unnumberedsec C.1(10-16): Access to Machine Operations
6698 @sp 1
6699 @cartouche
6700 The implementation should ensure that little or no overhead is
6701 associated with calling intrinsic and machine-code subprograms.
6702 @end cartouche
6703 Followed for both intrinsics and machine-code subprograms.
6704
6705 @sp 1
6706 @cartouche
6707 It is recommended that intrinsic subprograms be provided for convenient
6708 access to any machine operations that provide special capabilities or
6709 efficiency and that are not otherwise available through the language
6710 constructs.
6711 @end cartouche
6712 Followed.  A full set of machine operation intrinsic subprograms is provided.
6713
6714 @sp 1
6715 @cartouche
6716 Atomic read-modify-write operations---e.g.@:, test and set, compare and
6717 swap, decrement and test, enqueue/dequeue.
6718 @end cartouche
6719 Followed on any target supporting such operations.
6720
6721 @sp 1
6722 @cartouche
6723 Standard numeric functions---e.g.@:, sin, log.
6724 @end cartouche
6725 Followed on any target supporting such operations.
6726
6727 @sp 1
6728 @cartouche
6729 String manipulation operations---e.g.@:, translate and test.
6730 @end cartouche
6731 Followed on any target supporting such operations.
6732
6733 @sp 1
6734 @cartouche
6735 Vector operations---e.g.@:, compare vector against thresholds.
6736 @end cartouche
6737 Followed on any target supporting such operations.
6738
6739 @sp 1
6740 @cartouche
6741 Direct operations on I/O ports.
6742 @end cartouche
6743 Followed on any target supporting such operations.
6744
6745 @cindex Interrupt support
6746 @unnumberedsec C.3(28): Interrupt Support
6747 @sp 1
6748 @cartouche
6749 If the @code{Ceiling_Locking} policy is not in effect, the
6750 implementation should provide means for the application to specify which
6751 interrupts are to be blocked during protected actions, if the underlying
6752 system allows for a finer-grain control of interrupt blocking.
6753 @end cartouche
6754 Followed.  The underlying system does not allow for finer-grain control
6755 of interrupt blocking.
6756
6757 @cindex Protected procedure handlers
6758 @unnumberedsec C.3.1(20-21): Protected Procedure Handlers
6759 @sp 1
6760 @cartouche
6761 Whenever possible, the implementation should allow interrupt handlers to
6762 be called directly by the hardware.
6763 @end cartouche
6764 @c SGI info:
6765 @ignore
6766 This is never possible under IRIX, so this is followed by default.
6767 @end ignore
6768 Followed on any target where the underlying operating system permits
6769 such direct calls.
6770
6771 @sp 1
6772 @cartouche
6773 Whenever practical, violations of any
6774 implementation-defined restrictions should be detected before run time.
6775 @end cartouche
6776 Followed.  Compile time warnings are given when possible.
6777
6778 @cindex Package @code{Interrupts}
6779 @findex Interrupts
6780 @unnumberedsec C.3.2(25): Package @code{Interrupts}
6781
6782 @sp 1
6783 @cartouche
6784 If implementation-defined forms of interrupt handler procedures are
6785 supported, such as protected procedures with parameters, then for each
6786 such form of a handler, a type analogous to @code{Parameterless_Handler}
6787 should be specified in a child package of @code{Interrupts}, with the
6788 same operations as in the predefined package Interrupts.
6789 @end cartouche
6790 Followed.
6791
6792 @cindex Pre-elaboration requirements
6793 @unnumberedsec C.4(14): Pre-elaboration Requirements
6794 @sp 1
6795 @cartouche
6796 It is recommended that pre-elaborated packages be implemented in such a
6797 way that there should be little or no code executed at run time for the
6798 elaboration of entities not already covered by the Implementation
6799 Requirements.
6800 @end cartouche
6801 Followed.  Executable code is generated in some cases, e.g.@: loops
6802 to initialize large arrays.
6803
6804 @unnumberedsec C.5(8): Pragma @code{Discard_Names}
6805
6806 @sp 1
6807 @cartouche
6808 If the pragma applies to an entity, then the implementation should
6809 reduce the amount of storage used for storing names associated with that
6810 entity.
6811 @end cartouche
6812 Followed.
6813
6814 @cindex Package @code{Task_Attributes}
6815 @findex Task_Attributes
6816 @unnumberedsec C.7.2(30): The Package Task_Attributes
6817 @sp 1
6818 @cartouche
6819 Some implementations are targeted to domains in which memory use at run
6820 time must be completely deterministic.  For such implementations, it is
6821 recommended that the storage for task attributes will be pre-allocated
6822 statically and not from the heap.  This can be accomplished by either
6823 placing restrictions on the number and the size of the task's
6824 attributes, or by using the pre-allocated storage for the first @var{N}
6825 attribute objects, and the heap for the others.  In the latter case,
6826 @var{N} should be documented.
6827 @end cartouche
6828 Not followed.  This implementation is not targeted to such a domain.
6829
6830 @cindex Locking Policies
6831 @unnumberedsec D.3(17): Locking Policies
6832
6833 @sp 1
6834 @cartouche
6835 The implementation should use names that end with @samp{_Locking} for
6836 locking policies defined by the implementation.
6837 @end cartouche
6838 Followed.  A single implementation-defined locking policy is defined,
6839 whose name (@code{Inheritance_Locking}) follows this suggestion.
6840
6841 @cindex Entry queuing policies
6842 @unnumberedsec D.4(16): Entry Queuing Policies
6843 @sp 1
6844 @cartouche
6845 Names that end with @samp{_Queuing} should be used
6846 for all implementation-defined queuing policies.
6847 @end cartouche
6848 Followed.  No such implementation-defined queuing policies exist.
6849
6850 @cindex Preemptive abort
6851 @unnumberedsec D.6(9-10): Preemptive Abort
6852 @sp 1
6853 @cartouche
6854 Even though the @code{abort_statement} is included in the list of
6855 potentially blocking operations (see 9.5.1), it is recommended that this
6856 statement be implemented in a way that never requires the task executing
6857 the @code{abort_statement} to block.
6858 @end cartouche
6859 Followed.
6860
6861 @sp 1
6862 @cartouche
6863 On a multi-processor, the delay associated with aborting a task on
6864 another processor should be bounded; the implementation should use
6865 periodic polling, if necessary, to achieve this.
6866 @end cartouche
6867 Followed.
6868
6869 @cindex Tasking restrictions
6870 @unnumberedsec D.7(21): Tasking Restrictions
6871 @sp 1
6872 @cartouche
6873 When feasible, the implementation should take advantage of the specified
6874 restrictions to produce a more efficient implementation.
6875 @end cartouche
6876 GNAT currently takes advantage of these restrictions by providing an optimized
6877 run time when the Ravenscar profile and the GNAT restricted run time set
6878 of restrictions are specified.  See pragma @code{Profile (Ravenscar)} and
6879 pragma @code{Profile (Restricted)} for more details.
6880
6881 @cindex Time, monotonic
6882 @unnumberedsec D.8(47-49): Monotonic Time
6883 @sp 1
6884 @cartouche
6885 When appropriate, implementations should provide configuration
6886 mechanisms to change the value of @code{Tick}.
6887 @end cartouche
6888 Such configuration mechanisms are not appropriate to this implementation
6889 and are thus not supported.
6890
6891 @sp 1
6892 @cartouche
6893 It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
6894 be implemented as transformations of the same time base.
6895 @end cartouche
6896 Followed.
6897
6898 @sp 1
6899 @cartouche
6900 It is recommended that the @dfn{best} time base which exists in
6901 the underlying system be available to the application through
6902 @code{Clock}.  @dfn{Best} may mean highest accuracy or largest range.
6903 @end cartouche
6904 Followed.
6905
6906 @cindex Partition communication subsystem
6907 @cindex PCS
6908 @unnumberedsec E.5(28-29): Partition Communication Subsystem
6909 @sp 1
6910 @cartouche
6911 Whenever possible, the PCS on the called partition should allow for
6912 multiple tasks to call the RPC-receiver with different messages and
6913 should allow them to block until the corresponding subprogram body
6914 returns.
6915 @end cartouche
6916 Followed by GLADE, a separately supplied PCS that can be used with
6917 GNAT.
6918
6919 @sp 1
6920 @cartouche
6921 The @code{Write} operation on a stream of type @code{Params_Stream_Type}
6922 should raise @code{Storage_Error} if it runs out of space trying to
6923 write the @code{Item} into the stream.
6924 @end cartouche
6925 Followed by GLADE, a separately supplied PCS that can be used with
6926 GNAT@.
6927
6928 @cindex COBOL support
6929 @unnumberedsec F(7): COBOL Support
6930 @sp 1
6931 @cartouche
6932 If COBOL (respectively, C) is widely supported in the target
6933 environment, implementations supporting the Information Systems Annex
6934 should provide the child package @code{Interfaces.COBOL} (respectively,
6935 @code{Interfaces.C}) specified in Annex B and should support a
6936 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
6937 pragmas (see Annex B), thus allowing Ada programs to interface with
6938 programs written in that language.
6939 @end cartouche
6940 Followed.
6941
6942 @cindex Decimal radix support
6943 @unnumberedsec F.1(2): Decimal Radix Support
6944 @sp 1
6945 @cartouche
6946 Packed decimal should be used as the internal representation for objects
6947 of subtype @var{S} when @var{S}'Machine_Radix = 10.
6948 @end cartouche
6949 Not followed.  GNAT ignores @var{S}'Machine_Radix and always uses binary
6950 representations.
6951
6952 @cindex Numerics
6953 @unnumberedsec G: Numerics
6954 @sp 2
6955 @cartouche
6956 If Fortran (respectively, C) is widely supported in the target
6957 environment, implementations supporting the Numerics Annex
6958 should provide the child package @code{Interfaces.Fortran} (respectively,
6959 @code{Interfaces.C}) specified in Annex B and should support a
6960 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
6961 pragmas (see Annex B), thus allowing Ada programs to interface with
6962 programs written in that language.
6963 @end cartouche
6964 Followed.
6965
6966 @cindex Complex types
6967 @unnumberedsec G.1.1(56-58): Complex Types
6968 @sp 2
6969 @cartouche
6970 Because the usual mathematical meaning of multiplication of a complex
6971 operand and a real operand is that of the scaling of both components of
6972 the former by the latter, an implementation should not perform this
6973 operation by first promoting the real operand to complex type and then
6974 performing a full complex multiplication.  In systems that, in the
6975 future, support an Ada binding to IEC 559:1989, the latter technique
6976 will not generate the required result when one of the components of the
6977 complex operand is infinite.  (Explicit multiplication of the infinite
6978 component by the zero component obtained during promotion yields a NaN
6979 that propagates into the final result.) Analogous advice applies in the
6980 case of multiplication of a complex operand and a pure-imaginary
6981 operand, and in the case of division of a complex operand by a real or
6982 pure-imaginary operand.
6983 @end cartouche
6984 Not followed.
6985
6986 @sp 1
6987 @cartouche
6988 Similarly, because the usual mathematical meaning of addition of a
6989 complex operand and a real operand is that the imaginary operand remains
6990 unchanged, an implementation should not perform this operation by first
6991 promoting the real operand to complex type and then performing a full
6992 complex addition.  In implementations in which the @code{Signed_Zeros}
6993 attribute of the component type is @code{True} (and which therefore
6994 conform to IEC 559:1989 in regard to the handling of the sign of zero in
6995 predefined arithmetic operations), the latter technique will not
6996 generate the required result when the imaginary component of the complex
6997 operand is a negatively signed zero.  (Explicit addition of the negative
6998 zero to the zero obtained during promotion yields a positive zero.)
6999 Analogous advice applies in the case of addition of a complex operand
7000 and a pure-imaginary operand, and in the case of subtraction of a
7001 complex operand and a real or pure-imaginary operand.
7002 @end cartouche
7003 Not followed.
7004
7005 @sp 1
7006 @cartouche
7007 Implementations in which @code{Real'Signed_Zeros} is @code{True} should
7008 attempt to provide a rational treatment of the signs of zero results and
7009 result components.  As one example, the result of the @code{Argument}
7010 function should have the sign of the imaginary component of the
7011 parameter @code{X} when the point represented by that parameter lies on
7012 the positive real axis; as another, the sign of the imaginary component
7013 of the @code{Compose_From_Polar} function should be the same as
7014 (respectively, the opposite of) that of the @code{Argument} parameter when that
7015 parameter has a value of zero and the @code{Modulus} parameter has a
7016 nonnegative (respectively, negative) value.
7017 @end cartouche
7018 Followed.
7019
7020 @cindex Complex elementary functions
7021 @unnumberedsec G.1.2(49): Complex Elementary Functions
7022 @sp 1
7023 @cartouche
7024 Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
7025 @code{True} should attempt to provide a rational treatment of the signs
7026 of zero results and result components.  For example, many of the complex
7027 elementary functions have components that are odd functions of one of
7028 the parameter components; in these cases, the result component should
7029 have the sign of the parameter component at the origin.  Other complex
7030 elementary functions have zero components whose sign is opposite that of
7031 a parameter component at the origin, or is always positive or always
7032 negative.
7033 @end cartouche
7034 Followed.
7035
7036 @cindex Accuracy requirements
7037 @unnumberedsec G.2.4(19): Accuracy Requirements
7038 @sp 1
7039 @cartouche
7040 The versions of the forward trigonometric functions without a
7041 @code{Cycle} parameter should not be implemented by calling the
7042 corresponding version with a @code{Cycle} parameter of
7043 @code{2.0*Numerics.Pi}, since this will not provide the required
7044 accuracy in some portions of the domain.  For the same reason, the
7045 version of @code{Log} without a @code{Base} parameter should not be
7046 implemented by calling the corresponding version with a @code{Base}
7047 parameter of @code{Numerics.e}.
7048 @end cartouche
7049 Followed.
7050
7051 @cindex Complex arithmetic accuracy
7052 @cindex Accuracy, complex arithmetic
7053 @unnumberedsec G.2.6(15): Complex Arithmetic Accuracy
7054
7055 @sp 1
7056 @cartouche
7057 The version of the @code{Compose_From_Polar} function without a
7058 @code{Cycle} parameter should not be implemented by calling the
7059 corresponding version with a @code{Cycle} parameter of
7060 @code{2.0*Numerics.Pi}, since this will not provide the required
7061 accuracy in some portions of the domain.
7062 @end cartouche
7063 Followed.
7064
7065 @c -----------------------------------------
7066 @node Implementation Defined Characteristics
7067 @chapter Implementation Defined Characteristics
7068
7069 @noindent
7070 In addition to the implementation dependent pragmas and attributes, and
7071 the implementation advice, there are a number of other Ada features
7072 that are potentially implementation dependent.  These are mentioned
7073 throughout the Ada Reference Manual, and are summarized in annex M@.
7074
7075 A requirement for conforming Ada compilers is that they provide
7076 documentation describing how the implementation deals with each of these
7077 issues.  In this chapter, you will find each point in annex M listed
7078 followed by a description in italic font of how GNAT
7079 @c SGI info:
7080 @ignore
7081 in the ProDev Ada
7082 implementation on IRIX 5.3 operating system or greater
7083 @end ignore
7084 handles the implementation dependence.
7085
7086 You can use this chapter as a guide to minimizing implementation
7087 dependent features in your programs if portability to other compilers
7088 and other operating systems is an important consideration.  The numbers
7089 in each section below correspond to the paragraph number in the Ada
7090 Reference Manual.
7091
7092 @sp 1
7093 @cartouche
7094 @noindent
7095 @strong{2}.  Whether or not each recommendation given in Implementation
7096 Advice is followed.  See 1.1.2(37).
7097 @end cartouche
7098 @noindent
7099 @xref{Implementation Advice}.
7100
7101 @sp 1
7102 @cartouche
7103 @noindent
7104 @strong{3}.  Capacity limitations of the implementation.  See 1.1.3(3).
7105 @end cartouche
7106 @noindent
7107 The complexity of programs that can be processed is limited only by the
7108 total amount of available virtual memory, and disk space for the
7109 generated object files.
7110
7111 @sp 1
7112 @cartouche
7113 @noindent
7114 @strong{4}.  Variations from the standard that are impractical to avoid
7115 given the implementation's execution environment.  See 1.1.3(6).
7116 @end cartouche
7117 @noindent
7118 There are no variations from the standard.
7119
7120 @sp 1
7121 @cartouche
7122 @noindent
7123 @strong{5}.  Which @code{code_statement}s cause external
7124 interactions.  See 1.1.3(10).
7125 @end cartouche
7126 @noindent
7127 Any @code{code_statement} can potentially cause external interactions.
7128
7129 @sp 1
7130 @cartouche
7131 @noindent
7132 @strong{6}.  The coded representation for the text of an Ada
7133 program.  See 2.1(4).
7134 @end cartouche
7135 @noindent
7136 See separate section on source representation.
7137
7138 @sp 1
7139 @cartouche
7140 @noindent
7141 @strong{7}.  The control functions allowed in comments.  See 2.1(14).
7142 @end cartouche
7143 @noindent
7144 See separate section on source representation.
7145
7146 @sp 1
7147 @cartouche
7148 @noindent
7149 @strong{8}.  The representation for an end of line.  See 2.2(2).
7150 @end cartouche
7151 @noindent
7152 See separate section on source representation.
7153
7154 @sp 1
7155 @cartouche
7156 @noindent
7157 @strong{9}.  Maximum supported line length and lexical element
7158 length.  See 2.2(15).
7159 @end cartouche
7160 @noindent
7161 The maximum line length is 255 characters and the maximum length of a
7162 lexical element is also 255 characters.
7163
7164 @sp 1
7165 @cartouche
7166 @noindent
7167 @strong{10}.  Implementation defined pragmas.  See 2.8(14).
7168 @end cartouche
7169 @noindent
7170
7171 @xref{Implementation Defined Pragmas}.
7172
7173 @sp 1
7174 @cartouche
7175 @noindent
7176 @strong{11}.  Effect of pragma @code{Optimize}.  See 2.8(27).
7177 @end cartouche
7178 @noindent
7179 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
7180 parameter, checks that the optimization flag is set, and aborts if it is
7181 not.
7182
7183 @sp 1
7184 @cartouche
7185 @noindent
7186 @strong{12}.  The sequence of characters of the value returned by
7187 @code{@var{S}'Image} when some of the graphic characters of
7188 @code{@var{S}'Wide_Image} are not defined in @code{Character}.  See
7189 3.5(37).
7190 @end cartouche
7191 @noindent
7192 The sequence of characters is as defined by the wide character encoding
7193 method used for the source.  See section on source representation for
7194 further details.
7195
7196 @sp 1
7197 @cartouche
7198 @noindent
7199 @strong{13}.  The predefined integer types declared in
7200 @code{Standard}.  See 3.5.4(25).
7201 @end cartouche
7202 @noindent
7203 @table @code
7204 @item Short_Short_Integer
7205 8 bit signed
7206 @item Short_Integer
7207 (Short) 16 bit signed
7208 @item Integer
7209 32 bit signed
7210 @item Long_Integer
7211 64 bit signed (Alpha OpenVMS only)
7212 32 bit signed (all other targets)
7213 @item Long_Long_Integer
7214 64 bit signed
7215 @end table
7216
7217 @sp 1
7218 @cartouche
7219 @noindent
7220 @strong{14}.  Any nonstandard integer types and the operators defined
7221 for them.  See 3.5.4(26).
7222 @end cartouche
7223 @noindent
7224 There are no nonstandard integer types.
7225
7226 @sp 1
7227 @cartouche
7228 @noindent
7229 @strong{15}.  Any nonstandard real types and the operators defined for
7230 them.  See 3.5.6(8).
7231 @end cartouche
7232 @noindent
7233 There are no nonstandard real types.
7234
7235 @sp 1
7236 @cartouche
7237 @noindent
7238 @strong{16}.  What combinations of requested decimal precision and range
7239 are supported for floating point types.  See 3.5.7(7).
7240 @end cartouche
7241 @noindent
7242 The precision and range is as defined by the IEEE standard.
7243
7244 @sp 1
7245 @cartouche
7246 @noindent
7247 @strong{17}.  The predefined floating point types declared in
7248 @code{Standard}.  See 3.5.7(16).
7249 @end cartouche
7250 @noindent
7251 @table @code
7252 @item Short_Float
7253 32 bit IEEE short
7254 @item Float
7255 (Short) 32 bit IEEE short
7256 @item Long_Float
7257 64 bit IEEE long
7258 @item Long_Long_Float
7259 64 bit IEEE long (80 bit IEEE long on x86 processors)
7260 @end table
7261
7262 @sp 1
7263 @cartouche
7264 @noindent
7265 @strong{18}.  The small of an ordinary fixed point type.  See 3.5.9(8).
7266 @end cartouche
7267 @noindent
7268 @code{Fine_Delta} is 2**(@minus{}63)
7269
7270 @sp 1
7271 @cartouche
7272 @noindent
7273 @strong{19}.  What combinations of small, range, and digits are
7274 supported for fixed point types.  See 3.5.9(10).
7275 @end cartouche
7276 @noindent
7277 Any combinations are permitted that do not result in a small less than
7278 @code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
7279 If the mantissa is larger than 53 bits on machines where Long_Long_Float
7280 is 64 bits (true of all architectures except ia32), then the output from
7281 Text_IO is accurate to only 53 bits, rather than the full mantissa.  This
7282 is because floating-point conversions are used to convert fixed point.
7283
7284 @sp 1
7285 @cartouche
7286 @noindent
7287 @strong{20}.  The result of @code{Tags.Expanded_Name} for types declared
7288 within an unnamed @code{block_statement}.  See 3.9(10).
7289 @end cartouche
7290 @noindent
7291 Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
7292 decimal integer are allocated.
7293
7294 @sp 1
7295 @cartouche
7296 @noindent
7297 @strong{21}.  Implementation-defined attributes.  See 4.1.4(12).
7298 @end cartouche
7299 @noindent
7300 @xref{Implementation Defined Attributes}.
7301
7302 @sp 1
7303 @cartouche
7304 @noindent
7305 @strong{22}.  Any implementation-defined time types.  See 9.6(6).
7306 @end cartouche
7307 @noindent
7308 There are no implementation-defined time types.
7309
7310 @sp 1
7311 @cartouche
7312 @noindent
7313 @strong{23}.  The time base associated with relative delays.
7314 @end cartouche
7315 @noindent
7316 See 9.6(20).  The time base used is that provided by the C library
7317 function @code{gettimeofday}.
7318
7319 @sp 1
7320 @cartouche
7321 @noindent
7322 @strong{24}.  The time base of the type @code{Calendar.Time}.  See
7323 9.6(23).
7324 @end cartouche
7325 @noindent
7326 The time base used is that provided by the C library function
7327 @code{gettimeofday}.
7328
7329 @sp 1
7330 @cartouche
7331 @noindent
7332 @strong{25}.  The time zone used for package @code{Calendar}
7333 operations.  See 9.6(24).
7334 @end cartouche
7335 @noindent
7336 The time zone used by package @code{Calendar} is the current system time zone
7337 setting for local time, as accessed by the C library function
7338 @code{localtime}.
7339
7340 @sp 1
7341 @cartouche
7342 @noindent
7343 @strong{26}.  Any limit on @code{delay_until_statements} of
7344 @code{select_statements}.  See 9.6(29).
7345 @end cartouche
7346 @noindent
7347 There are no such limits.
7348
7349 @sp 1
7350 @cartouche
7351 @noindent
7352 @strong{27}.  Whether or not two non overlapping parts of a composite
7353 object are independently addressable, in the case where packing, record
7354 layout, or @code{Component_Size} is specified for the object.  See
7355 9.10(1).
7356 @end cartouche
7357 @noindent
7358 Separate components are independently addressable if they do not share
7359 overlapping storage units.
7360
7361 @sp 1
7362 @cartouche
7363 @noindent
7364 @strong{28}.  The representation for a compilation.  See 10.1(2).
7365 @end cartouche
7366 @noindent
7367 A compilation is represented by a sequence of files presented to the
7368 compiler in a single invocation of the @command{gcc} command.
7369
7370 @sp 1
7371 @cartouche
7372 @noindent
7373 @strong{29}.  Any restrictions on compilations that contain multiple
7374 compilation_units.  See 10.1(4).
7375 @end cartouche
7376 @noindent
7377 No single file can contain more than one compilation unit, but any
7378 sequence of files can be presented to the compiler as a single
7379 compilation.
7380
7381 @sp 1
7382 @cartouche
7383 @noindent
7384 @strong{30}.  The mechanisms for creating an environment and for adding
7385 and replacing compilation units.  See 10.1.4(3).
7386 @end cartouche
7387 @noindent
7388 See separate section on compilation model.
7389
7390 @sp 1
7391 @cartouche
7392 @noindent
7393 @strong{31}.  The manner of explicitly assigning library units to a
7394 partition.  See 10.2(2).
7395 @end cartouche
7396 @noindent
7397 If a unit contains an Ada main program, then the Ada units for the partition
7398 are determined by recursive application of the rules in the Ada Reference
7399 Manual section 10.2(2-6).  In other words, the Ada units will be those that
7400 are needed by the main program, and then this definition of need is applied
7401 recursively to those units, and the partition contains the transitive
7402 closure determined by this relationship.  In short, all the necessary units
7403 are included, with no need to explicitly specify the list.  If additional
7404 units are required, e.g.@: by foreign language units, then all units must be
7405 mentioned in the context clause of one of the needed Ada units.
7406
7407 If the partition contains no main program, or if the main program is in
7408 a language other than Ada, then GNAT
7409 provides the binder options @option{-z} and @option{-n} respectively, and in
7410 this case a list of units can be explicitly supplied to the binder for
7411 inclusion in the partition (all units needed by these units will also
7412 be included automatically).  For full details on the use of these
7413 options, refer to the @cite{GNAT User's Guide} sections on Binding
7414 and Linking.
7415
7416 @sp 1
7417 @cartouche
7418 @noindent
7419 @strong{32}.  The implementation-defined means, if any, of specifying
7420 which compilation units are needed by a given compilation unit.  See
7421 10.2(2).
7422 @end cartouche
7423 @noindent
7424 The units needed by a given compilation unit are as defined in
7425 the Ada Reference Manual section 10.2(2-6).  There are no
7426 implementation-defined pragmas or other implementation-defined
7427 means for specifying needed units.
7428
7429 @sp 1
7430 @cartouche
7431 @noindent
7432 @strong{33}.  The manner of designating the main subprogram of a
7433 partition.  See 10.2(7).
7434 @end cartouche
7435 @noindent
7436 The main program is designated by providing the name of the
7437 corresponding @file{ALI} file as the input parameter to the binder.
7438
7439 @sp 1
7440 @cartouche
7441 @noindent
7442 @strong{34}.  The order of elaboration of @code{library_items}.  See
7443 10.2(18).
7444 @end cartouche
7445 @noindent
7446 The first constraint on ordering is that it meets the requirements of
7447 Chapter 10 of the Ada Reference Manual.  This still leaves some
7448 implementation dependent choices, which are resolved by first
7449 elaborating bodies as early as possible (i.e., in preference to specs
7450 where there is a choice), and second by evaluating the immediate with
7451 clauses of a unit to determine the probably best choice, and
7452 third by elaborating in alphabetical order of unit names
7453 where a choice still remains.
7454
7455 @sp 1
7456 @cartouche
7457 @noindent
7458 @strong{35}.  Parameter passing and function return for the main
7459 subprogram.  See 10.2(21).
7460 @end cartouche
7461 @noindent
7462 The main program has no parameters.  It may be a procedure, or a function
7463 returning an integer type.  In the latter case, the returned integer
7464 value is the return code of the program (overriding any value that
7465 may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
7466
7467 @sp 1
7468 @cartouche
7469 @noindent
7470 @strong{36}.  The mechanisms for building and running partitions.  See
7471 10.2(24).
7472 @end cartouche
7473 @noindent
7474 GNAT itself supports programs with only a single partition.  The GNATDIST
7475 tool provided with the GLADE package (which also includes an implementation
7476 of the PCS) provides a completely flexible method for building and running
7477 programs consisting of multiple partitions.  See the separate GLADE manual
7478 for details.
7479
7480 @sp 1
7481 @cartouche
7482 @noindent
7483 @strong{37}.  The details of program execution, including program
7484 termination.  See 10.2(25).
7485 @end cartouche
7486 @noindent
7487 See separate section on compilation model.
7488
7489 @sp 1
7490 @cartouche
7491 @noindent
7492 @strong{38}.  The semantics of any non-active partitions supported by the
7493 implementation.  See 10.2(28).
7494 @end cartouche
7495 @noindent
7496 Passive partitions are supported on targets where shared memory is
7497 provided by the operating system.  See the GLADE reference manual for
7498 further details.
7499
7500 @sp 1
7501 @cartouche
7502 @noindent
7503 @strong{39}.  The information returned by @code{Exception_Message}.  See
7504 11.4.1(10).
7505 @end cartouche
7506 @noindent
7507 Exception message returns the null string unless a specific message has
7508 been passed by the program.
7509
7510 @sp 1
7511 @cartouche
7512 @noindent
7513 @strong{40}.  The result of @code{Exceptions.Exception_Name} for types
7514 declared within an unnamed @code{block_statement}.  See 11.4.1(12).
7515 @end cartouche
7516 @noindent
7517 Blocks have implementation defined names of the form @code{B@var{nnn}}
7518 where @var{nnn} is an integer.
7519
7520 @sp 1
7521 @cartouche
7522 @noindent
7523 @strong{41}.  The information returned by
7524 @code{Exception_Information}.  See 11.4.1(13).
7525 @end cartouche
7526 @noindent
7527 @code{Exception_Information} returns a string in the following format:
7528
7529 @smallexample
7530 @emph{Exception_Name:} nnnnn
7531 @emph{Message:} mmmmm
7532 @emph{PID:} ppp
7533 @emph{Call stack traceback locations:}
7534 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
7535 @end smallexample
7536
7537 @noindent
7538 where
7539
7540 @itemize @bullet
7541 @item
7542 @code{nnnn} is the fully qualified name of the exception in all upper
7543 case letters. This line is always present.
7544
7545 @item
7546 @code{mmmm} is the message (this line present only if message is non-null)
7547
7548 @item
7549 @code{ppp} is the Process Id value as a decimal integer (this line is
7550 present only if the Process Id is nonzero). Currently we are
7551 not making use of this field.
7552
7553 @item
7554 The Call stack traceback locations line and the following values
7555 are present only if at least one traceback location was recorded.
7556 The values are given in C style format, with lower case letters
7557 for a-f, and only as many digits present as are necessary.
7558 @end itemize
7559
7560 @noindent
7561 The line terminator sequence at the end of each line, including
7562 the last line is a single @code{LF} character (@code{16#0A#}).
7563
7564 @sp 1
7565 @cartouche
7566 @noindent
7567 @strong{42}.  Implementation-defined check names.  See 11.5(27).
7568 @end cartouche
7569 @noindent
7570 The implementation defined check name Alignment_Check controls checking of
7571 address clause values for proper alignment (that is, the address supplied
7572 must be consistent with the alignment of the type).
7573
7574 In addition, a user program can add implementation-defined check names
7575 by means of the pragma Check_Name.
7576
7577 @sp 1
7578 @cartouche
7579 @noindent
7580 @strong{43}.  The interpretation of each aspect of representation.  See
7581 13.1(20).
7582 @end cartouche
7583 @noindent
7584 See separate section on data representations.
7585
7586 @sp 1
7587 @cartouche
7588 @noindent
7589 @strong{44}.  Any restrictions placed upon representation items.  See
7590 13.1(20).
7591 @end cartouche
7592 @noindent
7593 See separate section on data representations.
7594
7595 @sp 1
7596 @cartouche
7597 @noindent
7598 @strong{45}.  The meaning of @code{Size} for indefinite subtypes.  See
7599 13.3(48).
7600 @end cartouche
7601 @noindent
7602 Size for an indefinite subtype is the maximum possible size, except that
7603 for the case of a subprogram parameter, the size of the parameter object
7604 is the actual size.
7605
7606 @sp 1
7607 @cartouche
7608 @noindent
7609 @strong{46}.  The default external representation for a type tag.  See
7610 13.3(75).
7611 @end cartouche
7612 @noindent
7613 The default external representation for a type tag is the fully expanded
7614 name of the type in upper case letters.
7615
7616 @sp 1
7617 @cartouche
7618 @noindent
7619 @strong{47}.  What determines whether a compilation unit is the same in
7620 two different partitions.  See 13.3(76).
7621 @end cartouche
7622 @noindent
7623 A compilation unit is the same in two different partitions if and only
7624 if it derives from the same source file.
7625
7626 @sp 1
7627 @cartouche
7628 @noindent
7629 @strong{48}.  Implementation-defined components.  See 13.5.1(15).
7630 @end cartouche
7631 @noindent
7632 The only implementation defined component is the tag for a tagged type,
7633 which contains a pointer to the dispatching table.
7634
7635 @sp 1
7636 @cartouche
7637 @noindent
7638 @strong{49}.  If @code{Word_Size} = @code{Storage_Unit}, the default bit
7639 ordering.  See 13.5.3(5).
7640 @end cartouche
7641 @noindent
7642 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
7643 implementation, so no non-default bit ordering is supported.  The default
7644 bit ordering corresponds to the natural endianness of the target architecture.
7645
7646 @sp 1
7647 @cartouche
7648 @noindent
7649 @strong{50}.  The contents of the visible part of package @code{System}
7650 and its language-defined children.  See 13.7(2).
7651 @end cartouche
7652 @noindent
7653 See the definition of these packages in files @file{system.ads} and
7654 @file{s-stoele.ads}.
7655
7656 @sp 1
7657 @cartouche
7658 @noindent
7659 @strong{51}.  The contents of the visible part of package
7660 @code{System.Machine_Code}, and the meaning of
7661 @code{code_statements}.  See 13.8(7).
7662 @end cartouche
7663 @noindent
7664 See the definition and documentation in file @file{s-maccod.ads}.
7665
7666 @sp 1
7667 @cartouche
7668 @noindent
7669 @strong{52}.  The effect of unchecked conversion.  See 13.9(11).
7670 @end cartouche
7671 @noindent
7672 Unchecked conversion between types of the same size
7673 results in an uninterpreted transmission of the bits from one type
7674 to the other.  If the types are of unequal sizes, then in the case of
7675 discrete types, a shorter source is first zero or sign extended as
7676 necessary, and a shorter target is simply truncated on the left.
7677 For all non-discrete types, the source is first copied if necessary
7678 to ensure that the alignment requirements of the target are met, then
7679 a pointer is constructed to the source value, and the result is obtained
7680 by dereferencing this pointer after converting it to be a pointer to the
7681 target type. Unchecked conversions where the target subtype is an
7682 unconstrained array are not permitted. If the target alignment is
7683 greater than the source alignment, then a copy of the result is
7684 made with appropriate alignment
7685
7686 @sp 1
7687 @cartouche
7688 @noindent
7689 @strong{53}.  The manner of choosing a storage pool for an access type
7690 when @code{Storage_Pool} is not specified for the type.  See 13.11(17).
7691 @end cartouche
7692 @noindent
7693 There are 3 different standard pools used by the compiler when
7694 @code{Storage_Pool} is not specified depending whether the type is local
7695 to a subprogram or defined at the library level and whether
7696 @code{Storage_Size}is specified or not.  See documentation in the runtime
7697 library units @code{System.Pool_Global}, @code{System.Pool_Size} and
7698 @code{System.Pool_Local} in files @file{s-poosiz.ads},
7699 @file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
7700 default pools used.
7701
7702 @sp 1
7703 @cartouche
7704 @noindent
7705 @strong{54}.  Whether or not the implementation provides user-accessible
7706 names for the standard pool type(s).  See 13.11(17).
7707 @end cartouche
7708 @noindent
7709
7710 See documentation in the sources of the run time mentioned in paragraph
7711 @strong{53} .  All these pools are accessible by means of @code{with}'ing
7712 these units.
7713
7714 @sp 1
7715 @cartouche
7716 @noindent
7717 @strong{55}.  The meaning of @code{Storage_Size}.  See 13.11(18).
7718 @end cartouche
7719 @noindent
7720 @code{Storage_Size} is measured in storage units, and refers to the
7721 total space available for an access type collection, or to the primary
7722 stack space for a task.
7723
7724 @sp 1
7725 @cartouche
7726 @noindent
7727 @strong{56}.  Implementation-defined aspects of storage pools.  See
7728 13.11(22).
7729 @end cartouche
7730 @noindent
7731 See documentation in the sources of the run time mentioned in paragraph
7732 @strong{53} for details on GNAT-defined aspects of storage pools.
7733
7734 @sp 1
7735 @cartouche
7736 @noindent
7737 @strong{57}.  The set of restrictions allowed in a pragma
7738 @code{Restrictions}.  See 13.12(7).
7739 @end cartouche
7740 @noindent
7741 All RM defined Restriction identifiers are implemented.  The following
7742 additional restriction identifiers are provided.  There are two separate
7743 lists of implementation dependent restriction identifiers.  The first
7744 set requires consistency throughout a partition (in other words, if the
7745 restriction identifier is used for any compilation unit in the partition,
7746 then all compilation units in the partition must obey the restriction.
7747
7748 @table @code
7749
7750 @item Simple_Barriers
7751 @findex Simple_Barriers
7752 This restriction ensures at compile time that barriers in entry declarations
7753 for protected types are restricted to either static boolean expressions or
7754 references to simple boolean variables defined in the private part of the
7755 protected type.  No other form of entry barriers is permitted.  This is one
7756 of the restrictions of the Ravenscar profile for limited tasking (see also
7757 pragma @code{Profile (Ravenscar)}).
7758
7759 @item Max_Entry_Queue_Length => Expr
7760 @findex Max_Entry_Queue_Length
7761 This restriction is a declaration that any protected entry compiled in
7762 the scope of the restriction has at most the specified number of
7763 tasks waiting on the entry
7764 at any one time, and so no queue is required.  This restriction is not
7765 checked at compile time.  A program execution is erroneous if an attempt
7766 is made to queue more than the specified number of tasks on such an entry.
7767
7768 @item No_Calendar
7769 @findex No_Calendar
7770 This restriction ensures at compile time that there is no implicit or
7771 explicit dependence on the package @code{Ada.Calendar}.
7772
7773 @item No_Direct_Boolean_Operators
7774 @findex No_Direct_Boolean_Operators
7775 This restriction ensures that no logical (and/or/xor) or comparison
7776 operators are used on operands of type Boolean (or any type derived
7777 from Boolean). This is intended for use in safety critical programs
7778 where the certification protocol requires the use of short-circuit
7779 (and then, or else) forms for all composite boolean operations.
7780
7781 @item No_Dispatching_Calls
7782 @findex No_Dispatching_Calls
7783 This restriction ensures at compile time that the code generated by the
7784 compiler involves no dispatching calls. The use of this restriction allows the
7785 safe use of record extensions, classwide membership tests and other classwide
7786 features not involving implicit dispatching. This restriction ensures that
7787 the code contains no indirect calls through a dispatching mechanism. Note that
7788 this includes internally-generated calls created by the compiler, for example
7789 in the implementation of class-wide objects assignments. The
7790 membership test is allowed in the presence of this restriction, because its
7791 implementation requires no dispatching.
7792 This restriction is comparable to the official Ada restriction
7793 @code{No_Dispatch} except that it is a bit less restrictive in that it allows
7794 all classwide constructs that do not imply dispatching.
7795 The following example indicates constructs that violate this restriction.
7796
7797 @smallexample
7798 package Pkg is
7799   type T is tagged record
7800     Data : Natural;
7801   end record;
7802   procedure P (X : T);
7803
7804   type DT is new T with record
7805     More_Data : Natural;
7806   end record;
7807   procedure Q (X : DT);
7808 end Pkg;
7809
7810 with Pkg; use Pkg;
7811 procedure Example is
7812   procedure Test (O : T'Class) is
7813     N : Natural  := O'Size;--  Error: Dispatching call
7814     C : T'Class := O;      --  Error: implicit Dispatching Call
7815   begin
7816     if O in DT'Class then  --  OK   : Membership test
7817        Q (DT (O));         --  OK   : Type conversion plus direct call
7818     else
7819        P (O);              --  Error: Dispatching call
7820     end if;
7821   end Test;
7822
7823   Obj : DT;
7824 begin
7825   P (Obj);                 --  OK   : Direct call
7826   P (T (Obj));             --  OK   : Type conversion plus direct call
7827   P (T'Class (Obj));       --  Error: Dispatching call
7828
7829   Test (Obj);              --  OK   : Type conversion
7830
7831   if Obj in T'Class then   --  OK   : Membership test
7832      null;
7833   end if;
7834 end Example;
7835 @end smallexample
7836
7837 @item No_Dynamic_Attachment
7838 @findex No_Dynamic_Attachment
7839 This restriction ensures that there is no call to any of the operations
7840 defined in package Ada.Interrupts.
7841
7842 @item No_Enumeration_Maps
7843 @findex No_Enumeration_Maps
7844 This restriction ensures at compile time that no operations requiring
7845 enumeration maps are used (that is Image and Value attributes applied
7846 to enumeration types).
7847
7848 @item No_Entry_Calls_In_Elaboration_Code
7849 @findex No_Entry_Calls_In_Elaboration_Code
7850 This restriction ensures at compile time that no task or protected entry
7851 calls are made during elaboration code.  As a result of the use of this
7852 restriction, the compiler can assume that no code past an accept statement
7853 in a task can be executed at elaboration time.
7854
7855 @item No_Exception_Handlers
7856 @findex No_Exception_Handlers
7857 This restriction ensures at compile time that there are no explicit
7858 exception handlers. It also indicates that no exception propagation will
7859 be provided. In this mode, exceptions may be raised but will result in
7860 an immediate call to the last chance handler, a routine that the user
7861 must define with the following profile:
7862
7863    procedure Last_Chance_Handler
7864      (Source_Location : System.Address; Line : Integer);
7865    pragma Export (C, Last_Chance_Handler,
7866                   "__gnat_last_chance_handler");
7867
7868    The parameter is a C null-terminated string representing a message to be
7869    associated with the exception (typically the source location of the raise
7870    statement generated by the compiler). The Line parameter when nonzero
7871    represents the line number in the source program where the raise occurs.
7872
7873 @item No_Exception_Propagation
7874 @findex No_Exception_Propagation
7875 This restriction guarantees that exceptions are never propagated to an outer
7876 subprogram scope). The only case in which an exception may be raised is when
7877 the handler is statically in the same subprogram, so that the effect of a raise
7878 is essentially like a goto statement. Any other raise statement (implicit or
7879 explicit) will be considered unhandled. Exception handlers are allowed, but may
7880 not contain an exception occurrence identifier (exception choice). In addition
7881 use of the package GNAT.Current_Exception is not permitted, and reraise
7882 statements (raise with no operand) are not permitted.
7883
7884 @item No_Exception_Registration
7885 @findex No_Exception_Registration
7886 This restriction ensures at compile time that no stream operations for
7887 types Exception_Id or Exception_Occurrence are used. This also makes it
7888 impossible to pass exceptions to or from a partition with this restriction
7889 in a distributed environment. If this exception is active, then the generated
7890 code is simplified by omitting the otherwise-required global registration
7891 of exceptions when they are declared.
7892
7893 @item No_Implicit_Conditionals
7894 @findex No_Implicit_Conditionals
7895 This restriction ensures that the generated code does not contain any
7896 implicit conditionals, either by modifying the generated code where possible,
7897 or by rejecting any construct that would otherwise generate an implicit
7898 conditional. Note that this check does not include run time constraint
7899 checks, which on some targets may generate implicit conditionals as
7900 well. To control the latter, constraint checks can be suppressed in the
7901 normal manner. Constructs generating implicit conditionals include comparisons
7902 of composite objects and the Max/Min attributes.
7903
7904 @item No_Implicit_Dynamic_Code
7905 @findex No_Implicit_Dynamic_Code
7906 This restriction prevents the compiler from building ``trampolines''.
7907 This is a structure that is built on the stack and contains dynamic
7908 code to be executed at run time. On some targets, a trampoline is
7909 built for the following features: @code{Access},
7910 @code{Unrestricted_Access}, or @code{Address} of a nested subprogram;
7911 nested task bodies; primitive operations of nested tagged types.
7912 Trampolines do not work on machines that prevent execution of stack
7913 data. For example, on windows systems, enabling DEP (data execution
7914 protection) will cause trampolines to raise an exception.
7915
7916 @item No_Implicit_Loops
7917 @findex No_Implicit_Loops
7918 This restriction ensures that the generated code does not contain any
7919 implicit @code{for} loops, either by modifying
7920 the generated code where possible,
7921 or by rejecting any construct that would otherwise generate an implicit
7922 @code{for} loop. If this restriction is active, it is possible to build
7923 large array aggregates with all static components without generating an
7924 intermediate temporary, and without generating a loop to initialize individual
7925 components. Otherwise, a loop is created for arrays larger than about 5000
7926 scalar components.
7927
7928 @item No_Initialize_Scalars
7929 @findex No_Initialize_Scalars
7930 This restriction ensures that no unit in the partition is compiled with
7931 pragma Initialize_Scalars. This allows the generation of more efficient
7932 code, and in particular eliminates dummy null initialization routines that
7933 are otherwise generated for some record and array types.
7934
7935 @item No_Local_Protected_Objects
7936 @findex No_Local_Protected_Objects
7937 This restriction ensures at compile time that protected objects are
7938 only declared at the library level.
7939
7940 @item No_Protected_Type_Allocators
7941 @findex No_Protected_Type_Allocators
7942 This restriction ensures at compile time that there are no allocator
7943 expressions that attempt to allocate protected objects.
7944
7945 @item No_Secondary_Stack
7946 @findex No_Secondary_Stack
7947 This restriction ensures at compile time that the generated code does not
7948 contain any reference to the secondary stack.  The secondary stack is used
7949 to implement functions returning unconstrained objects (arrays or records)
7950 on some targets.
7951
7952 @item No_Select_Statements
7953 @findex No_Select_Statements
7954 This restriction ensures at compile time no select statements of any kind
7955 are permitted, that is the keyword @code{select} may not appear.
7956 This is one of the restrictions of the Ravenscar
7957 profile for limited tasking (see also pragma @code{Profile (Ravenscar)}).
7958
7959 @item No_Standard_Storage_Pools
7960 @findex No_Standard_Storage_Pools
7961 This restriction ensures at compile time that no access types
7962 use the standard default storage pool.  Any access type declared must
7963 have an explicit Storage_Pool attribute defined specifying a
7964 user-defined storage pool.
7965
7966 @item No_Streams
7967 @findex No_Streams
7968 This restriction ensures at compile/bind time that there are no
7969 stream objects created (and therefore no actual stream operations).
7970 This restriction does not forbid dependences on the package
7971 @code{Ada.Streams}. So it is permissible to with
7972 @code{Ada.Streams} (or another package that does so itself)
7973 as long as no actual stream objects are created.
7974
7975 @item No_Task_Attributes_Package
7976 @findex No_Task_Attributes_Package
7977 This restriction ensures at compile time that there are no implicit or
7978 explicit dependencies on the package @code{Ada.Task_Attributes}.
7979
7980 @item No_Task_Termination
7981 @findex No_Task_Termination
7982 This restriction ensures at compile time that no terminate alternatives
7983 appear in any task body.
7984
7985 @item No_Tasking
7986 @findex No_Tasking
7987 This restriction prevents the declaration of tasks or task types throughout
7988 the partition.  It is similar in effect to the use of @code{Max_Tasks => 0}
7989 except that violations are caught at compile time and cause an error message
7990 to be output either by the compiler or binder.
7991
7992 @item Static_Priorities
7993 @findex Static_Priorities
7994 This restriction ensures at compile time that all priority expressions
7995 are static, and that there are no dependencies on the package
7996 @code{Ada.Dynamic_Priorities}.
7997
7998 @item Static_Storage_Size
7999 @findex Static_Storage_Size
8000 This restriction ensures at compile time that any expression appearing
8001 in a Storage_Size pragma or attribute definition clause is static.
8002
8003 @end table
8004
8005 @noindent
8006 The second set of implementation dependent restriction identifiers
8007 does not require partition-wide consistency.
8008 The restriction may be enforced for a single
8009 compilation unit without any effect on any of the
8010 other compilation units in the partition.
8011
8012 @table @code
8013
8014 @item No_Elaboration_Code
8015 @findex No_Elaboration_Code
8016 This restriction ensures at compile time that no elaboration code is
8017 generated.  Note that this is not the same condition as is enforced
8018 by pragma @code{Preelaborate}.  There are cases in which pragma
8019 @code{Preelaborate} still permits code to be generated (e.g.@: code
8020 to initialize a large array to all zeroes), and there are cases of units
8021 which do not meet the requirements for pragma @code{Preelaborate},
8022 but for which no elaboration code is generated.  Generally, it is
8023 the case that preelaborable units will meet the restrictions, with
8024 the exception of large aggregates initialized with an others_clause,
8025 and exception declarations (which generate calls to a run-time
8026 registry procedure).  This restriction is enforced on
8027 a unit by unit basis, it need not be obeyed consistently
8028 throughout a partition.
8029
8030 In the case of aggregates with others, if the aggregate has a dynamic
8031 size, there is no way to eliminate the elaboration code (such dynamic
8032 bounds would be incompatible with @code{Preelaborate} in any case). If
8033 the bounds are static, then use of this restriction actually modifies
8034 the code choice of the compiler to avoid generating a loop, and instead
8035 generate the aggregate statically if possible, no matter how many times
8036 the data for the others clause must be repeatedly generated.
8037
8038 It is not possible to precisely document
8039 the constructs which are compatible with this restriction, since,
8040 unlike most other restrictions, this is not a restriction on the
8041 source code, but a restriction on the generated object code. For
8042 example, if the source contains a declaration:
8043
8044 @smallexample
8045    Val : constant Integer := X;
8046 @end smallexample
8047
8048 @noindent
8049 where X is not a static constant, it may be possible, depending
8050 on complex optimization circuitry, for the compiler to figure
8051 out the value of X at compile time, in which case this initialization
8052 can be done by the loader, and requires no initialization code. It
8053 is not possible to document the precise conditions under which the
8054 optimizer can figure this out.
8055
8056 Note that this the implementation of this restriction requires full
8057 code generation. If it is used in conjunction with "semantics only"
8058 checking, then some cases of violations may be missed.
8059
8060 @item No_Entry_Queue
8061 @findex No_Entry_Queue
8062 This restriction is a declaration that any protected entry compiled in
8063 the scope of the restriction has at most one task waiting on the entry
8064 at any one time, and so no queue is required.  This restriction is not
8065 checked at compile time.  A program execution is erroneous if an attempt
8066 is made to queue a second task on such an entry.
8067
8068 @item No_Implementation_Attributes
8069 @findex No_Implementation_Attributes
8070 This restriction checks at compile time that no GNAT-defined attributes
8071 are present.  With this restriction, the only attributes that can be used
8072 are those defined in the Ada Reference Manual.
8073
8074 @item No_Implementation_Pragmas
8075 @findex No_Implementation_Pragmas
8076 This restriction checks at compile time that no GNAT-defined pragmas
8077 are present.  With this restriction, the only pragmas that can be used
8078 are those defined in the Ada Reference Manual.
8079
8080 @item No_Implementation_Restrictions
8081 @findex No_Implementation_Restrictions
8082 This restriction checks at compile time that no GNAT-defined restriction
8083 identifiers (other than @code{No_Implementation_Restrictions} itself)
8084 are present.  With this restriction, the only other restriction identifiers
8085 that can be used are those defined in the Ada Reference Manual.
8086
8087 @item No_Wide_Characters
8088 @findex No_Wide_Characters
8089 This restriction ensures at compile time that no uses of the types
8090 @code{Wide_Character} or @code{Wide_String} or corresponding wide
8091 wide types
8092 appear, and that no wide or wide wide string or character literals
8093 appear in the program (that is literals representing characters not in
8094 type @code{Character}.
8095
8096 @end table
8097
8098 @sp 1
8099 @cartouche
8100 @noindent
8101 @strong{58}.  The consequences of violating limitations on
8102 @code{Restrictions} pragmas.  See 13.12(9).
8103 @end cartouche
8104 @noindent
8105 Restrictions that can be checked at compile time result in illegalities
8106 if violated.  Currently there are no other consequences of violating
8107 restrictions.
8108
8109 @sp 1
8110 @cartouche
8111 @noindent
8112 @strong{59}.  The representation used by the @code{Read} and
8113 @code{Write} attributes of elementary types in terms of stream
8114 elements.  See 13.13.2(9).
8115 @end cartouche
8116 @noindent
8117 The representation is the in-memory representation of the base type of
8118 the type, using the number of bits corresponding to the
8119 @code{@var{type}'Size} value, and the natural ordering of the machine.
8120
8121 @sp 1
8122 @cartouche
8123 @noindent
8124 @strong{60}.  The names and characteristics of the numeric subtypes
8125 declared in the visible part of package @code{Standard}.  See A.1(3).
8126 @end cartouche
8127 @noindent
8128 See items describing the integer and floating-point types supported.
8129
8130 @sp 1
8131 @cartouche
8132 @noindent
8133 @strong{61}.  The accuracy actually achieved by the elementary
8134 functions.  See A.5.1(1).
8135 @end cartouche
8136 @noindent
8137 The elementary functions correspond to the functions available in the C
8138 library.  Only fast math mode is implemented.
8139
8140 @sp 1
8141 @cartouche
8142 @noindent
8143 @strong{62}.  The sign of a zero result from some of the operators or
8144 functions in @code{Numerics.Generic_Elementary_Functions}, when
8145 @code{Float_Type'Signed_Zeros} is @code{True}.  See A.5.1(46).
8146 @end cartouche
8147 @noindent
8148 The sign of zeroes follows the requirements of the IEEE 754 standard on
8149 floating-point.
8150
8151 @sp 1
8152 @cartouche
8153 @noindent
8154 @strong{63}.  The value of
8155 @code{Numerics.Float_Random.Max_Image_Width}.  See A.5.2(27).
8156 @end cartouche
8157 @noindent
8158 Maximum image width is 649, see library file @file{a-numran.ads}.
8159
8160 @sp 1
8161 @cartouche
8162 @noindent
8163 @strong{64}.  The value of
8164 @code{Numerics.Discrete_Random.Max_Image_Width}.  See A.5.2(27).
8165 @end cartouche
8166 @noindent
8167 Maximum image width is 80, see library file @file{a-nudira.ads}.
8168
8169 @sp 1
8170 @cartouche
8171 @noindent
8172 @strong{65}.  The algorithms for random number generation.  See
8173 A.5.2(32).
8174 @end cartouche
8175 @noindent
8176 The algorithm is documented in the source files @file{a-numran.ads} and
8177 @file{a-numran.adb}.
8178
8179 @sp 1
8180 @cartouche
8181 @noindent
8182 @strong{66}.  The string representation of a random number generator's
8183 state.  See A.5.2(38).
8184 @end cartouche
8185 @noindent
8186 See the documentation contained in the file @file{a-numran.adb}.
8187
8188 @sp 1
8189 @cartouche
8190 @noindent
8191 @strong{67}.  The minimum time interval between calls to the
8192 time-dependent Reset procedure that are guaranteed to initiate different
8193 random number sequences.  See A.5.2(45).
8194 @end cartouche
8195 @noindent
8196 The minimum period between reset calls to guarantee distinct series of
8197 random numbers is one microsecond.
8198
8199 @sp 1
8200 @cartouche
8201 @noindent
8202 @strong{68}.  The values of the @code{Model_Mantissa},
8203 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
8204 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
8205 Annex is not supported.  See A.5.3(72).
8206 @end cartouche
8207 @noindent
8208 See the source file @file{ttypef.ads} for the values of all numeric
8209 attributes.
8210
8211 @sp 1
8212 @cartouche
8213 @noindent
8214 @strong{69}.  Any implementation-defined characteristics of the
8215 input-output packages.  See A.7(14).
8216 @end cartouche
8217 @noindent
8218 There are no special implementation defined characteristics for these
8219 packages.
8220
8221 @sp 1
8222 @cartouche
8223 @noindent
8224 @strong{70}.  The value of @code{Buffer_Size} in @code{Storage_IO}.  See
8225 A.9(10).
8226 @end cartouche
8227 @noindent
8228 All type representations are contiguous, and the @code{Buffer_Size} is
8229 the value of @code{@var{type}'Size} rounded up to the next storage unit
8230 boundary.
8231
8232 @sp 1
8233 @cartouche
8234 @noindent
8235 @strong{71}.  External files for standard input, standard output, and
8236 standard error See A.10(5).
8237 @end cartouche
8238 @noindent
8239 These files are mapped onto the files provided by the C streams
8240 libraries.  See source file @file{i-cstrea.ads} for further details.
8241
8242 @sp 1
8243 @cartouche
8244 @noindent
8245 @strong{72}.  The accuracy of the value produced by @code{Put}.  See
8246 A.10.9(36).
8247 @end cartouche
8248 @noindent
8249 If more digits are requested in the output than are represented by the
8250 precision of the value, zeroes are output in the corresponding least
8251 significant digit positions.
8252
8253 @sp 1
8254 @cartouche
8255 @noindent
8256 @strong{73}.  The meaning of @code{Argument_Count}, @code{Argument}, and
8257 @code{Command_Name}.  See A.15(1).
8258 @end cartouche
8259 @noindent
8260 These are mapped onto the @code{argv} and @code{argc} parameters of the
8261 main program in the natural manner.
8262
8263 @sp 1
8264 @cartouche
8265 @noindent
8266 @strong{74}.  Implementation-defined convention names.  See B.1(11).
8267 @end cartouche
8268 @noindent
8269 The following convention names are supported
8270
8271 @table @code
8272 @item  Ada
8273 Ada
8274 @item Assembler
8275 Assembly language
8276 @item Asm
8277 Synonym for Assembler
8278 @item Assembly
8279 Synonym for Assembler
8280 @item C
8281 C
8282 @item C_Pass_By_Copy
8283 Allowed only for record types, like C, but also notes that record
8284 is to be passed by copy rather than reference.
8285 @item COBOL
8286 COBOL
8287 @item C_Plus_Plus (or CPP)
8288 C++
8289 @item Default
8290 Treated the same as C
8291 @item External
8292 Treated the same as C
8293 @item Fortran
8294 Fortran
8295 @item Intrinsic
8296 For support of pragma @code{Import} with convention Intrinsic, see
8297 separate section on Intrinsic Subprograms.
8298 @item Stdcall
8299 Stdcall (used for Windows implementations only).  This convention correspond
8300 to the WINAPI (previously called Pascal convention) C/C++ convention under
8301 Windows.  A function with this convention cleans the stack before exit.
8302 @item DLL
8303 Synonym for Stdcall
8304 @item Win32
8305 Synonym for Stdcall
8306 @item Stubbed
8307 Stubbed is a special convention used to indicate that the body of the
8308 subprogram will be entirely ignored.  Any call to the subprogram
8309 is converted into a raise of the @code{Program_Error} exception.  If a
8310 pragma @code{Import} specifies convention @code{stubbed} then no body need
8311 be present at all.  This convention is useful during development for the
8312 inclusion of subprograms whose body has not yet been written.
8313
8314 @end table
8315 @noindent
8316 In addition, all otherwise unrecognized convention names are also
8317 treated as being synonymous with convention C@.  In all implementations
8318 except for VMS, use of such other names results in a warning.  In VMS
8319 implementations, these names are accepted silently.
8320
8321 @sp 1
8322 @cartouche
8323 @noindent
8324 @strong{75}.  The meaning of link names.  See B.1(36).
8325 @end cartouche
8326 @noindent
8327 Link names are the actual names used by the linker.
8328
8329 @sp 1
8330 @cartouche
8331 @noindent
8332 @strong{76}.  The manner of choosing link names when neither the link
8333 name nor the address of an imported or exported entity is specified.  See
8334 B.1(36).
8335 @end cartouche
8336 @noindent
8337 The default linker name is that which would be assigned by the relevant
8338 external language, interpreting the Ada name as being in all lower case
8339 letters.
8340
8341 @sp 1
8342 @cartouche
8343 @noindent
8344 @strong{77}.  The effect of pragma @code{Linker_Options}.  See B.1(37).
8345 @end cartouche
8346 @noindent
8347 The string passed to @code{Linker_Options} is presented uninterpreted as
8348 an argument to the link command, unless it contains Ascii.NUL characters.
8349 NUL characters if they appear act as argument separators, so for example
8350
8351 @smallexample @c ada
8352 pragma Linker_Options ("-labc" & ASCII.Nul & "-ldef");
8353 @end smallexample
8354
8355 @noindent
8356 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
8357 linker. The order of linker options is preserved for a given unit. The final
8358 list of options passed to the linker is in reverse order of the elaboration
8359 order. For example, linker options for a body always appear before the options
8360 from the corresponding package spec.
8361
8362 @sp 1
8363 @cartouche
8364 @noindent
8365 @strong{78}.  The contents of the visible part of package
8366 @code{Interfaces} and its language-defined descendants.  See B.2(1).
8367 @end cartouche
8368 @noindent
8369 See files with prefix @file{i-} in the distributed library.
8370
8371 @sp 1
8372 @cartouche
8373 @noindent
8374 @strong{79}.  Implementation-defined children of package
8375 @code{Interfaces}.  The contents of the visible part of package
8376 @code{Interfaces}.  See B.2(11).
8377 @end cartouche
8378 @noindent
8379 See files with prefix @file{i-} in the distributed library.
8380
8381 @sp 1
8382 @cartouche
8383 @noindent
8384 @strong{80}.  The types @code{Floating}, @code{Long_Floating},
8385 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
8386 @code{COBOL_Character}; and the initialization of the variables
8387 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
8388 @code{Interfaces.COBOL}.  See B.4(50).
8389 @end cartouche
8390 @noindent
8391 @table @code
8392 @item Floating
8393 Float
8394 @item Long_Floating
8395 (Floating) Long_Float
8396 @item Binary
8397 Integer
8398 @item Long_Binary
8399 Long_Long_Integer
8400 @item Decimal_Element
8401 Character
8402 @item COBOL_Character
8403 Character
8404 @end table
8405
8406 @noindent
8407 For initialization, see the file @file{i-cobol.ads} in the distributed library.
8408
8409 @sp 1
8410 @cartouche
8411 @noindent
8412 @strong{81}.  Support for access to machine instructions.  See C.1(1).
8413 @end cartouche
8414 @noindent
8415 See documentation in file @file{s-maccod.ads} in the distributed library.
8416
8417 @sp 1
8418 @cartouche
8419 @noindent
8420 @strong{82}.  Implementation-defined aspects of access to machine
8421 operations.  See C.1(9).
8422 @end cartouche
8423 @noindent
8424 See documentation in file @file{s-maccod.ads} in the distributed library.
8425
8426 @sp 1
8427 @cartouche
8428 @noindent
8429 @strong{83}.  Implementation-defined aspects of interrupts.  See C.3(2).
8430 @end cartouche
8431 @noindent
8432 Interrupts are mapped to signals or conditions as appropriate.  See
8433 definition of unit
8434 @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
8435 on the interrupts supported on a particular target.
8436
8437 @sp 1
8438 @cartouche
8439 @noindent
8440 @strong{84}.  Implementation-defined aspects of pre-elaboration.  See
8441 C.4(13).
8442 @end cartouche
8443 @noindent
8444 GNAT does not permit a partition to be restarted without reloading,
8445 except under control of the debugger.
8446
8447 @sp 1
8448 @cartouche
8449 @noindent
8450 @strong{85}.  The semantics of pragma @code{Discard_Names}.  See C.5(7).
8451 @end cartouche
8452 @noindent
8453 Pragma @code{Discard_Names} causes names of enumeration literals to
8454 be suppressed.  In the presence of this pragma, the Image attribute
8455 provides the image of the Pos of the literal, and Value accepts
8456 Pos values.
8457
8458 @sp 1
8459 @cartouche
8460 @noindent
8461 @strong{86}.  The result of the @code{Task_Identification.Image}
8462 attribute.  See C.7.1(7).
8463 @end cartouche
8464 @noindent
8465 The result of this attribute is a string that identifies
8466 the object or component that denotes a given task. If a variable Var has a task
8467 type, the image for this task will have the form Var_XXXXXXXX, where the
8468 suffix
8469 is the hexadecimal representation of the virtual address of the corresponding
8470 task control block. If the variable is an array of tasks, the image of each
8471 task will have the form of an indexed component indicating the position of a
8472 given task in the array, eg.  Group(5)_XXXXXXX. If the task is a
8473 component of a record, the image of the task will have the form of a selected
8474 component. These rules are fully recursive, so that the image of a task that
8475 is a subcomponent of a composite object corresponds to the expression that
8476 designates this task.
8477 @noindent
8478 If a task is created by an allocator, its image depends on the context. If the
8479 allocator is part of an object declaration, the rules described above are used
8480 to construct its image, and this image is not affected by subsequent
8481 assignments. If the allocator appears within an expression, the image
8482 includes only the name of the task type.
8483 @noindent
8484 If the configuration pragma Discard_Names is present, or if the restriction
8485 No_Implicit_Heap_Allocation is in effect,  the image reduces to
8486 the numeric suffix, that is to say the hexadecimal representation of the
8487 virtual address of the control block of the task.
8488 @sp 1
8489 @cartouche
8490 @noindent
8491 @strong{87}.  The value of @code{Current_Task} when in a protected entry
8492 or interrupt handler.  See C.7.1(17).
8493 @end cartouche
8494 @noindent
8495 Protected entries or interrupt handlers can be executed by any
8496 convenient thread, so the value of @code{Current_Task} is undefined.
8497
8498 @sp 1
8499 @cartouche
8500 @noindent
8501 @strong{88}.  The effect of calling @code{Current_Task} from an entry
8502 body or interrupt handler.  See C.7.1(19).
8503 @end cartouche
8504 @noindent
8505 The effect of calling @code{Current_Task} from an entry body or
8506 interrupt handler is to return the identification of the task currently
8507 executing the code.
8508
8509 @sp 1
8510 @cartouche
8511 @noindent
8512 @strong{89}.  Implementation-defined aspects of
8513 @code{Task_Attributes}.  See C.7.2(19).
8514 @end cartouche
8515 @noindent
8516 There are no implementation-defined aspects of @code{Task_Attributes}.
8517
8518 @sp 1
8519 @cartouche
8520 @noindent
8521 @strong{90}.  Values of all @code{Metrics}.  See D(2).
8522 @end cartouche
8523 @noindent
8524 The metrics information for GNAT depends on the performance of the
8525 underlying operating system.  The sources of the run-time for tasking
8526 implementation, together with the output from @option{-gnatG} can be
8527 used to determine the exact sequence of operating systems calls made
8528 to implement various tasking constructs.  Together with appropriate
8529 information on the performance of the underlying operating system,
8530 on the exact target in use, this information can be used to determine
8531 the required metrics.
8532
8533 @sp 1
8534 @cartouche
8535 @noindent
8536 @strong{91}.  The declarations of @code{Any_Priority} and
8537 @code{Priority}.  See D.1(11).
8538 @end cartouche
8539 @noindent
8540 See declarations in file @file{system.ads}.
8541
8542 @sp 1
8543 @cartouche
8544 @noindent
8545 @strong{92}.  Implementation-defined execution resources.  See D.1(15).
8546 @end cartouche
8547 @noindent
8548 There are no implementation-defined execution resources.
8549
8550 @sp 1
8551 @cartouche
8552 @noindent
8553 @strong{93}.  Whether, on a multiprocessor, a task that is waiting for
8554 access to a protected object keeps its processor busy.  See D.2.1(3).
8555 @end cartouche
8556 @noindent
8557 On a multi-processor, a task that is waiting for access to a protected
8558 object does not keep its processor busy.
8559
8560 @sp 1
8561 @cartouche
8562 @noindent
8563 @strong{94}.  The affect of implementation defined execution resources
8564 on task dispatching.  See D.2.1(9).
8565 @end cartouche
8566 @noindent
8567 @c SGI info
8568 @ignore
8569 Tasks map to IRIX threads, and the dispatching policy is as defined by
8570 the IRIX implementation of threads.
8571 @end ignore
8572 Tasks map to threads in the threads package used by GNAT@.  Where possible
8573 and appropriate, these threads correspond to native threads of the
8574 underlying operating system.
8575
8576 @sp 1
8577 @cartouche
8578 @noindent
8579 @strong{95}.  Implementation-defined @code{policy_identifiers} allowed
8580 in a pragma @code{Task_Dispatching_Policy}.  See D.2.2(3).
8581 @end cartouche
8582 @noindent
8583 There are no implementation-defined policy-identifiers allowed in this
8584 pragma.
8585
8586 @sp 1
8587 @cartouche
8588 @noindent
8589 @strong{96}.  Implementation-defined aspects of priority inversion.  See
8590 D.2.2(16).
8591 @end cartouche
8592 @noindent
8593 Execution of a task cannot be preempted by the implementation processing
8594 of delay expirations for lower priority tasks.
8595
8596 @sp 1
8597 @cartouche
8598 @noindent
8599 @strong{97}.  Implementation defined task dispatching.  See D.2.2(18).
8600 @end cartouche
8601 @noindent
8602 @c SGI info:
8603 @ignore
8604 Tasks map to IRIX threads, and the dispatching policy is as defined by
8605 the IRIX implementation of threads.
8606 @end ignore
8607 The policy is the same as that of the underlying threads implementation.
8608
8609 @sp 1
8610 @cartouche
8611 @noindent
8612 @strong{98}.  Implementation-defined @code{policy_identifiers} allowed
8613 in a pragma @code{Locking_Policy}.  See D.3(4).
8614 @end cartouche
8615 @noindent
8616 The only implementation defined policy permitted in GNAT is
8617 @code{Inheritance_Locking}.  On targets that support this policy, locking
8618 is implemented by inheritance, i.e.@: the task owning the lock operates
8619 at a priority equal to the highest priority of any task currently
8620 requesting the lock.
8621
8622 @sp 1
8623 @cartouche
8624 @noindent
8625 @strong{99}.  Default ceiling priorities.  See D.3(10).
8626 @end cartouche
8627 @noindent
8628 The ceiling priority of protected objects of the type
8629 @code{System.Interrupt_Priority'Last} as described in the Ada
8630 Reference Manual D.3(10),
8631
8632 @sp 1
8633 @cartouche
8634 @noindent
8635 @strong{100}.  The ceiling of any protected object used internally by
8636 the implementation.  See D.3(16).
8637 @end cartouche
8638 @noindent
8639 The ceiling priority of internal protected objects is
8640 @code{System.Priority'Last}.
8641
8642 @sp 1
8643 @cartouche
8644 @noindent
8645 @strong{101}.  Implementation-defined queuing policies.  See D.4(1).
8646 @end cartouche
8647 @noindent
8648 There are no implementation-defined queuing policies.
8649
8650 @sp 1
8651 @cartouche
8652 @noindent
8653 @strong{102}.  On a multiprocessor, any conditions that cause the
8654 completion of an aborted construct to be delayed later than what is
8655 specified for a single processor.  See D.6(3).
8656 @end cartouche
8657 @noindent
8658 The semantics for abort on a multi-processor is the same as on a single
8659 processor, there are no further delays.
8660
8661 @sp 1
8662 @cartouche
8663 @noindent
8664 @strong{103}.  Any operations that implicitly require heap storage
8665 allocation.  See D.7(8).
8666 @end cartouche
8667 @noindent
8668 The only operation that implicitly requires heap storage allocation is
8669 task creation.
8670
8671 @sp 1
8672 @cartouche
8673 @noindent
8674 @strong{104}.  Implementation-defined aspects of pragma
8675 @code{Restrictions}.  See D.7(20).
8676 @end cartouche
8677 @noindent
8678 There are no such implementation-defined aspects.
8679
8680 @sp 1
8681 @cartouche
8682 @noindent
8683 @strong{105}.  Implementation-defined aspects of package
8684 @code{Real_Time}.  See D.8(17).
8685 @end cartouche
8686 @noindent
8687 There are no implementation defined aspects of package @code{Real_Time}.
8688
8689 @sp 1
8690 @cartouche
8691 @noindent
8692 @strong{106}.  Implementation-defined aspects of
8693 @code{delay_statements}.  See D.9(8).
8694 @end cartouche
8695 @noindent
8696 Any difference greater than one microsecond will cause the task to be
8697 delayed (see D.9(7)).
8698
8699 @sp 1
8700 @cartouche
8701 @noindent
8702 @strong{107}.  The upper bound on the duration of interrupt blocking
8703 caused by the implementation.  See D.12(5).
8704 @end cartouche
8705 @noindent
8706 The upper bound is determined by the underlying operating system.  In
8707 no cases is it more than 10 milliseconds.
8708
8709 @sp 1
8710 @cartouche
8711 @noindent
8712 @strong{108}.  The means for creating and executing distributed
8713 programs.  See E(5).
8714 @end cartouche
8715 @noindent
8716 The GLADE package provides a utility GNATDIST for creating and executing
8717 distributed programs.  See the GLADE reference manual for further details.
8718
8719 @sp 1
8720 @cartouche
8721 @noindent
8722 @strong{109}.  Any events that can result in a partition becoming
8723 inaccessible.  See E.1(7).
8724 @end cartouche
8725 @noindent
8726 See the GLADE reference manual for full details on such events.
8727
8728 @sp 1
8729 @cartouche
8730 @noindent
8731 @strong{110}.  The scheduling policies, treatment of priorities, and
8732 management of shared resources between partitions in certain cases.  See
8733 E.1(11).
8734 @end cartouche
8735 @noindent
8736 See the GLADE reference manual for full details on these aspects of
8737 multi-partition execution.
8738
8739 @sp 1
8740 @cartouche
8741 @noindent
8742 @strong{111}.  Events that cause the version of a compilation unit to
8743 change.  See E.3(5).
8744 @end cartouche
8745 @noindent
8746 Editing the source file of a compilation unit, or the source files of
8747 any units on which it is dependent in a significant way cause the version
8748 to change.  No other actions cause the version number to change.  All changes
8749 are significant except those which affect only layout, capitalization or
8750 comments.
8751
8752 @sp 1
8753 @cartouche
8754 @noindent
8755 @strong{112}.  Whether the execution of the remote subprogram is
8756 immediately aborted as a result of cancellation.  See E.4(13).
8757 @end cartouche
8758 @noindent
8759 See the GLADE reference manual for details on the effect of abort in
8760 a distributed application.
8761
8762 @sp 1
8763 @cartouche
8764 @noindent
8765 @strong{113}.  Implementation-defined aspects of the PCS@.  See E.5(25).
8766 @end cartouche
8767 @noindent
8768 See the GLADE reference manual for a full description of all implementation
8769 defined aspects of the PCS@.
8770
8771 @sp 1
8772 @cartouche
8773 @noindent
8774 @strong{114}.  Implementation-defined interfaces in the PCS@.  See
8775 E.5(26).
8776 @end cartouche
8777 @noindent
8778 See the GLADE reference manual for a full description of all
8779 implementation defined interfaces.
8780
8781 @sp 1
8782 @cartouche
8783 @noindent
8784 @strong{115}.  The values of named numbers in the package
8785 @code{Decimal}.  See F.2(7).
8786 @end cartouche
8787 @noindent
8788 @table @code
8789 @item Max_Scale
8790 +18
8791 @item Min_Scale
8792 -18
8793 @item Min_Delta
8794 1.0E-18
8795 @item Max_Delta
8796 1.0E+18
8797 @item Max_Decimal_Digits
8798 18
8799 @end table
8800
8801 @sp 1
8802 @cartouche
8803 @noindent
8804 @strong{116}.  The value of @code{Max_Picture_Length} in the package
8805 @code{Text_IO.Editing}.  See F.3.3(16).
8806 @end cartouche
8807 @noindent
8808 64
8809
8810 @sp 1
8811 @cartouche
8812 @noindent
8813 @strong{117}.  The value of @code{Max_Picture_Length} in the package
8814 @code{Wide_Text_IO.Editing}.  See F.3.4(5).
8815 @end cartouche
8816 @noindent
8817 64
8818
8819 @sp 1
8820 @cartouche
8821 @noindent
8822 @strong{118}.  The accuracy actually achieved by the complex elementary
8823 functions and by other complex arithmetic operations.  See G.1(1).
8824 @end cartouche
8825 @noindent
8826 Standard library functions are used for the complex arithmetic
8827 operations.  Only fast math mode is currently supported.
8828
8829 @sp 1
8830 @cartouche
8831 @noindent
8832 @strong{119}.  The sign of a zero result (or a component thereof) from
8833 any operator or function in @code{Numerics.Generic_Complex_Types}, when
8834 @code{Real'Signed_Zeros} is True.  See G.1.1(53).
8835 @end cartouche
8836 @noindent
8837 The signs of zero values are as recommended by the relevant
8838 implementation advice.
8839
8840 @sp 1
8841 @cartouche
8842 @noindent
8843 @strong{120}.  The sign of a zero result (or a component thereof) from
8844 any operator or function in
8845 @code{Numerics.Generic_Complex_Elementary_Functions}, when
8846 @code{Real'Signed_Zeros} is @code{True}.  See G.1.2(45).
8847 @end cartouche
8848 @noindent
8849 The signs of zero values are as recommended by the relevant
8850 implementation advice.
8851
8852 @sp 1
8853 @cartouche
8854 @noindent
8855 @strong{121}.  Whether the strict mode or the relaxed mode is the
8856 default.  See G.2(2).
8857 @end cartouche
8858 @noindent
8859 The strict mode is the default.  There is no separate relaxed mode.  GNAT
8860 provides a highly efficient implementation of strict mode.
8861
8862 @sp 1
8863 @cartouche
8864 @noindent
8865 @strong{122}.  The result interval in certain cases of fixed-to-float
8866 conversion.  See G.2.1(10).
8867 @end cartouche
8868 @noindent
8869 For cases where the result interval is implementation dependent, the
8870 accuracy is that provided by performing all operations in 64-bit IEEE
8871 floating-point format.
8872
8873 @sp 1
8874 @cartouche
8875 @noindent
8876 @strong{123}.  The result of a floating point arithmetic operation in
8877 overflow situations, when the @code{Machine_Overflows} attribute of the
8878 result type is @code{False}.  See G.2.1(13).
8879 @end cartouche
8880 @noindent
8881 Infinite and NaN values are produced as dictated by the IEEE
8882 floating-point standard.
8883
8884 Note that on machines that are not fully compliant with the IEEE
8885 floating-point standard, such as Alpha, the @option{-mieee} compiler flag
8886 must be used for achieving IEEE confirming behavior (although at the cost
8887 of a significant performance penalty), so infinite and NaN values are
8888 properly generated.
8889
8890 @sp 1
8891 @cartouche
8892 @noindent
8893 @strong{124}.  The result interval for division (or exponentiation by a
8894 negative exponent), when the floating point hardware implements division
8895 as multiplication by a reciprocal.  See G.2.1(16).
8896 @end cartouche
8897 @noindent
8898 Not relevant, division is IEEE exact.
8899
8900 @sp 1
8901 @cartouche
8902 @noindent
8903 @strong{125}.  The definition of close result set, which determines the
8904 accuracy of certain fixed point multiplications and divisions.  See
8905 G.2.3(5).
8906 @end cartouche
8907 @noindent
8908 Operations in the close result set are performed using IEEE long format
8909 floating-point arithmetic.  The input operands are converted to
8910 floating-point, the operation is done in floating-point, and the result
8911 is converted to the target type.
8912
8913 @sp 1
8914 @cartouche
8915 @noindent
8916 @strong{126}.  Conditions on a @code{universal_real} operand of a fixed
8917 point multiplication or division for which the result shall be in the
8918 perfect result set.  See G.2.3(22).
8919 @end cartouche
8920 @noindent
8921 The result is only defined to be in the perfect result set if the result
8922 can be computed by a single scaling operation involving a scale factor
8923 representable in 64-bits.
8924
8925 @sp 1
8926 @cartouche
8927 @noindent
8928 @strong{127}.  The result of a fixed point arithmetic operation in
8929 overflow situations, when the @code{Machine_Overflows} attribute of the
8930 result type is @code{False}.  See G.2.3(27).
8931 @end cartouche
8932 @noindent
8933 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
8934 types.
8935
8936 @sp 1
8937 @cartouche
8938 @noindent
8939 @strong{128}.  The result of an elementary function reference in
8940 overflow situations, when the @code{Machine_Overflows} attribute of the
8941 result type is @code{False}.  See G.2.4(4).
8942 @end cartouche
8943 @noindent
8944 IEEE infinite and Nan values are produced as appropriate.
8945
8946 @sp 1
8947 @cartouche
8948 @noindent
8949 @strong{129}.  The value of the angle threshold, within which certain
8950 elementary functions, complex arithmetic operations, and complex
8951 elementary functions yield results conforming to a maximum relative
8952 error bound.  See G.2.4(10).
8953 @end cartouche
8954 @noindent
8955 Information on this subject is not yet available.
8956
8957 @sp 1
8958 @cartouche
8959 @noindent
8960 @strong{130}.  The accuracy of certain elementary functions for
8961 parameters beyond the angle threshold.  See G.2.4(10).
8962 @end cartouche
8963 @noindent
8964 Information on this subject is not yet available.
8965
8966 @sp 1
8967 @cartouche
8968 @noindent
8969 @strong{131}.  The result of a complex arithmetic operation or complex
8970 elementary function reference in overflow situations, when the
8971 @code{Machine_Overflows} attribute of the corresponding real type is
8972 @code{False}.  See G.2.6(5).
8973 @end cartouche
8974 @noindent
8975 IEEE infinite and Nan values are produced as appropriate.
8976
8977 @sp 1
8978 @cartouche
8979 @noindent
8980 @strong{132}.  The accuracy of certain complex arithmetic operations and
8981 certain complex elementary functions for parameters (or components
8982 thereof) beyond the angle threshold.  See G.2.6(8).
8983 @end cartouche
8984 @noindent
8985 Information on those subjects is not yet available.
8986
8987 @sp 1
8988 @cartouche
8989 @noindent
8990 @strong{133}.  Information regarding bounded errors and erroneous
8991 execution.  See H.2(1).
8992 @end cartouche
8993 @noindent
8994 Information on this subject is not yet available.
8995
8996 @sp 1
8997 @cartouche
8998 @noindent
8999 @strong{134}.  Implementation-defined aspects of pragma
9000 @code{Inspection_Point}.  See H.3.2(8).
9001 @end cartouche
9002 @noindent
9003 Pragma @code{Inspection_Point} ensures that the variable is live and can
9004 be examined by the debugger at the inspection point.
9005
9006 @sp 1
9007 @cartouche
9008 @noindent
9009 @strong{135}.  Implementation-defined aspects of pragma
9010 @code{Restrictions}.  See H.4(25).
9011 @end cartouche
9012 @noindent
9013 There are no implementation-defined aspects of pragma @code{Restrictions}.  The
9014 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
9015 generated code.  Checks must suppressed by use of pragma @code{Suppress}.
9016
9017 @sp 1
9018 @cartouche
9019 @noindent
9020 @strong{136}.  Any restrictions on pragma @code{Restrictions}.  See
9021 H.4(27).
9022 @end cartouche
9023 @noindent
9024 There are no restrictions on pragma @code{Restrictions}.
9025
9026 @node Intrinsic Subprograms
9027 @chapter Intrinsic Subprograms
9028 @cindex Intrinsic Subprograms
9029
9030 @menu
9031 * Intrinsic Operators::
9032 * Enclosing_Entity::
9033 * Exception_Information::
9034 * Exception_Message::
9035 * Exception_Name::
9036 * File::
9037 * Line::
9038 * Rotate_Left::
9039 * Rotate_Right::
9040 * Shift_Left::
9041 * Shift_Right::
9042 * Shift_Right_Arithmetic::
9043 * Source_Location::
9044 @end menu
9045
9046 @noindent
9047 GNAT allows a user application program to write the declaration:
9048
9049 @smallexample @c ada
9050    pragma Import (Intrinsic, name);
9051 @end smallexample
9052
9053 @noindent
9054 providing that the name corresponds to one of the implemented intrinsic
9055 subprograms in GNAT, and that the parameter profile of the referenced
9056 subprogram meets the requirements.  This chapter describes the set of
9057 implemented intrinsic subprograms, and the requirements on parameter profiles.
9058 Note that no body is supplied; as with other uses of pragma Import, the
9059 body is supplied elsewhere (in this case by the compiler itself).  Note
9060 that any use of this feature is potentially non-portable, since the
9061 Ada standard does not require Ada compilers to implement this feature.
9062
9063 @node Intrinsic Operators
9064 @section Intrinsic Operators
9065 @cindex Intrinsic operator
9066
9067 @noindent
9068 All the predefined numeric operators in package Standard
9069 in @code{pragma Import (Intrinsic,..)}
9070 declarations.  In the binary operator case, the operands must have the same
9071 size.  The operand or operands must also be appropriate for
9072 the operator.  For example, for addition, the operands must
9073 both be floating-point or both be fixed-point, and the
9074 right operand for @code{"**"} must have a root type of
9075 @code{Standard.Integer'Base}.
9076 You can use an intrinsic operator declaration as in the following example:
9077
9078 @smallexample @c ada
9079    type Int1 is new Integer;
9080    type Int2 is new Integer;
9081
9082    function "+" (X1 : Int1; X2 : Int2) return Int1;
9083    function "+" (X1 : Int1; X2 : Int2) return Int2;
9084    pragma Import (Intrinsic, "+");
9085 @end smallexample
9086
9087 @noindent
9088 This declaration would permit ``mixed mode'' arithmetic on items
9089 of the differing types @code{Int1} and @code{Int2}.
9090 It is also possible to specify such operators for private types, if the
9091 full views are appropriate arithmetic types.
9092
9093 @node Enclosing_Entity
9094 @section Enclosing_Entity
9095 @cindex Enclosing_Entity
9096 @noindent
9097 This intrinsic subprogram is used in the implementation of the
9098 library routine @code{GNAT.Source_Info}.  The only useful use of the
9099 intrinsic import in this case is the one in this unit, so an
9100 application program should simply call the function
9101 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
9102 the current subprogram, package, task, entry, or protected subprogram.
9103
9104 @node Exception_Information
9105 @section Exception_Information
9106 @cindex Exception_Information'
9107 @noindent
9108 This intrinsic subprogram is used in the implementation of the
9109 library routine @code{GNAT.Current_Exception}.  The only useful
9110 use of the intrinsic import in this case is the one in this unit,
9111 so an application program should simply call the function
9112 @code{GNAT.Current_Exception.Exception_Information} to obtain
9113 the exception information associated with the current exception.
9114
9115 @node Exception_Message
9116 @section Exception_Message
9117 @cindex Exception_Message
9118 @noindent
9119 This intrinsic subprogram is used in the implementation of the
9120 library routine @code{GNAT.Current_Exception}.  The only useful
9121 use of the intrinsic import in this case is the one in this unit,
9122 so an application program should simply call the function
9123 @code{GNAT.Current_Exception.Exception_Message} to obtain
9124 the message associated with the current exception.
9125
9126 @node Exception_Name
9127 @section Exception_Name
9128 @cindex Exception_Name
9129 @noindent
9130 This intrinsic subprogram is used in the implementation of the
9131 library routine @code{GNAT.Current_Exception}.  The only useful
9132 use of the intrinsic import in this case is the one in this unit,
9133 so an application program should simply call the function
9134 @code{GNAT.Current_Exception.Exception_Name} to obtain
9135 the name of the current exception.
9136
9137 @node File
9138 @section File
9139 @cindex File
9140 @noindent
9141 This intrinsic subprogram is used in the implementation of the
9142 library routine @code{GNAT.Source_Info}.  The only useful use of the
9143 intrinsic import in this case is the one in this unit, so an
9144 application program should simply call the function
9145 @code{GNAT.Source_Info.File} to obtain the name of the current
9146 file.
9147
9148 @node Line
9149 @section Line
9150 @cindex Line
9151 @noindent
9152 This intrinsic subprogram is used in the implementation of the
9153 library routine @code{GNAT.Source_Info}.  The only useful use of the
9154 intrinsic import in this case is the one in this unit, so an
9155 application program should simply call the function
9156 @code{GNAT.Source_Info.Line} to obtain the number of the current
9157 source line.
9158
9159 @node Rotate_Left
9160 @section Rotate_Left
9161 @cindex Rotate_Left
9162 @noindent
9163 In standard Ada, the @code{Rotate_Left} function is available only
9164 for the predefined modular types in package @code{Interfaces}.  However, in
9165 GNAT it is possible to define a Rotate_Left function for a user
9166 defined modular type or any signed integer type as in this example:
9167
9168 @smallexample @c ada
9169    function Shift_Left
9170      (Value  : My_Modular_Type;
9171       Amount : Natural)
9172       return   My_Modular_Type;
9173 @end smallexample
9174
9175 @noindent
9176 The requirements are that the profile be exactly as in the example
9177 above.  The only modifications allowed are in the formal parameter
9178 names, and in the type of @code{Value} and the return type, which
9179 must be the same, and must be either a signed integer type, or
9180 a modular integer type with a binary modulus, and the size must
9181 be 8.  16, 32 or 64 bits.
9182
9183 @node Rotate_Right
9184 @section Rotate_Right
9185 @cindex Rotate_Right
9186 @noindent
9187 A @code{Rotate_Right} function can be defined for any user defined
9188 binary modular integer type, or signed integer type, as described
9189 above for @code{Rotate_Left}.
9190
9191 @node Shift_Left
9192 @section Shift_Left
9193 @cindex Shift_Left
9194 @noindent
9195 A @code{Shift_Left} function can be defined for any user defined
9196 binary modular integer type, or signed integer type, as described
9197 above for @code{Rotate_Left}.
9198
9199 @node Shift_Right
9200 @section Shift_Right
9201 @cindex Shift_Right
9202 @noindent
9203 A @code{Shift_Right} function can be defined for any user defined
9204 binary modular integer type, or signed integer type, as described
9205 above for @code{Rotate_Left}.
9206
9207 @node Shift_Right_Arithmetic
9208 @section Shift_Right_Arithmetic
9209 @cindex Shift_Right_Arithmetic
9210 @noindent
9211 A @code{Shift_Right_Arithmetic} function can be defined for any user
9212 defined binary modular integer type, or signed integer type, as described
9213 above for @code{Rotate_Left}.
9214
9215 @node Source_Location
9216 @section Source_Location
9217 @cindex Source_Location
9218 @noindent
9219 This intrinsic subprogram is used in the implementation of the
9220 library routine @code{GNAT.Source_Info}.  The only useful use of the
9221 intrinsic import in this case is the one in this unit, so an
9222 application program should simply call the function
9223 @code{GNAT.Source_Info.Source_Location} to obtain the current
9224 source file location.
9225
9226 @node Representation Clauses and Pragmas
9227 @chapter Representation Clauses and Pragmas
9228 @cindex Representation Clauses
9229
9230 @menu
9231 * Alignment Clauses::
9232 * Size Clauses::
9233 * Storage_Size Clauses::
9234 * Size of Variant Record Objects::
9235 * Biased Representation ::
9236 * Value_Size and Object_Size Clauses::
9237 * Component_Size Clauses::
9238 * Bit_Order Clauses::
9239 * Effect of Bit_Order on Byte Ordering::
9240 * Pragma Pack for Arrays::
9241 * Pragma Pack for Records::
9242 * Record Representation Clauses::
9243 * Enumeration Clauses::
9244 * Address Clauses::
9245 * Effect of Convention on Representation::
9246 * Determining the Representations chosen by GNAT::
9247 @end menu
9248
9249 @noindent
9250 @cindex Representation Clause
9251 @cindex Representation Pragma
9252 @cindex Pragma, representation
9253 This section describes the representation clauses accepted by GNAT, and
9254 their effect on the representation of corresponding data objects.
9255
9256 GNAT fully implements Annex C (Systems Programming).  This means that all
9257 the implementation advice sections in chapter 13 are fully implemented.
9258 However, these sections only require a minimal level of support for
9259 representation clauses.  GNAT provides much more extensive capabilities,
9260 and this section describes the additional capabilities provided.
9261
9262 @node Alignment Clauses
9263 @section Alignment Clauses
9264 @cindex Alignment Clause
9265
9266 @noindent
9267 GNAT requires that all alignment clauses specify a power of 2, and all
9268 default alignments are always a power of 2.  The default alignment
9269 values are as follows:
9270
9271 @itemize @bullet
9272 @item @emph{Primitive Types}.
9273 For primitive types, the alignment is the minimum of the actual size of
9274 objects of the type divided by @code{Storage_Unit},
9275 and the maximum alignment supported by the target.
9276 (This maximum alignment is given by the GNAT-specific attribute
9277 @code{Standard'Maximum_Alignment}; see @ref{Maximum_Alignment}.)
9278 @cindex @code{Maximum_Alignment} attribute
9279 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
9280 default alignment will be 8 on any target that supports alignments
9281 this large, but on some targets, the maximum alignment may be smaller
9282 than 8, in which case objects of type @code{Long_Float} will be maximally
9283 aligned.
9284
9285 @item @emph{Arrays}.
9286 For arrays, the alignment is equal to the alignment of the component type
9287 for the normal case where no packing or component size is given.  If the
9288 array is packed, and the packing is effective (see separate section on
9289 packed arrays), then the alignment will be one for long packed arrays,
9290 or arrays whose length is not known at compile time.  For short packed
9291 arrays, which are handled internally as modular types, the alignment
9292 will be as described for primitive types, e.g.@: a packed array of length
9293 31 bits will have an object size of four bytes, and an alignment of 4.
9294
9295 @item @emph{Records}.
9296 For the normal non-packed case, the alignment of a record is equal to
9297 the maximum alignment of any of its components.  For tagged records, this
9298 includes the implicit access type used for the tag.  If a pragma @code{Pack} is
9299 used and all fields are packable (see separate section on pragma @code{Pack}),
9300 then the resulting alignment is 1.
9301
9302 A special case is when:
9303 @itemize @bullet
9304 @item
9305 the size of the record is given explicitly, or a
9306 full record representation clause is given, and
9307 @item
9308 the size of the record is 2, 4, or 8 bytes.
9309 @end itemize
9310 @noindent
9311 In this case, an alignment is chosen to match the
9312 size of the record. For example, if we have:
9313
9314 @smallexample @c ada
9315    type Small is record
9316       A, B : Character;
9317    end record;
9318    for Small'Size use 16;
9319 @end smallexample
9320
9321 @noindent
9322 then the default alignment of the record type @code{Small} is 2, not 1. This
9323 leads to more efficient code when the record is treated as a unit, and also
9324 allows the type to specified as @code{Atomic} on architectures requiring
9325 strict alignment.
9326
9327 @end itemize
9328
9329 @noindent
9330 An alignment clause may specify a larger alignment than the default value
9331 up to some maximum value dependent on the target (obtainable by using the
9332 attribute reference @code{Standard'Maximum_Alignment}). It may also specify
9333 a smaller alignment than the default value, for example
9334
9335 @smallexample @c ada
9336   type V is record
9337      A : Integer;
9338   end record;
9339
9340   for V'alignment use 1;
9341 @end smallexample
9342
9343 @noindent
9344 @cindex Alignment, default
9345 The default alignment for the type @code{V} is 4, as a result of the
9346 Integer field in the record, but it is permissible, as shown, to
9347 override the default alignment of the record with a smaller value.
9348
9349 @node Size Clauses
9350 @section Size Clauses
9351 @cindex Size Clause
9352
9353 @noindent
9354 The default size for a type @code{T} is obtainable through the
9355 language-defined attribute @code{T'Size} and also through the
9356 equivalent GNAT-defined attribute @code{T'Value_Size}.
9357 For objects of type @code{T}, GNAT will generally increase the type size
9358 so that the object size (obtainable through the GNAT-defined attribute
9359 @code{T'Object_Size})
9360 is a multiple of @code{T'Alignment * Storage_Unit}.
9361 For example
9362
9363 @smallexample @c ada
9364    type Smallint is range 1 .. 6;
9365
9366    type Rec is record
9367       Y1 : integer;
9368       Y2 : boolean;
9369    end record;
9370 @end smallexample
9371
9372 @noindent
9373 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
9374 as specified by the RM rules,
9375 but objects of this type will have a size of 8
9376 (@code{Smallint'Object_Size} = 8),
9377 since objects by default occupy an integral number
9378 of storage units.  On some targets, notably older
9379 versions of the Digital Alpha, the size of stand
9380 alone objects of this type may be 32, reflecting
9381 the inability of the hardware to do byte load/stores.
9382
9383 Similarly, the size of type @code{Rec} is 40 bits
9384 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
9385 the alignment is 4, so objects of this type will have
9386 their size increased to 64 bits so that it is a multiple
9387 of the alignment (in bits).  This decision is
9388 in accordance with the specific Implementation Advice in RM 13.3(43):
9389
9390 @quotation
9391 A @code{Size} clause should be supported for an object if the specified
9392 @code{Size} is at least as large as its subtype's @code{Size}, and corresponds
9393 to a size in storage elements that is a multiple of the object's
9394 @code{Alignment} (if the @code{Alignment} is nonzero).
9395 @end quotation
9396
9397 @noindent
9398 An explicit size clause may be used to override the default size by
9399 increasing it.  For example, if we have:
9400
9401 @smallexample @c ada
9402    type My_Boolean is new Boolean;
9403    for My_Boolean'Size use 32;
9404 @end smallexample
9405
9406 @noindent
9407 then values of this type will always be 32 bits long.  In the case of
9408 discrete types, the size can be increased up to 64 bits, with the effect
9409 that the entire specified field is used to hold the value, sign- or
9410 zero-extended as appropriate.  If more than 64 bits is specified, then
9411 padding space is allocated after the value, and a warning is issued that
9412 there are unused bits.
9413
9414 Similarly the size of records and arrays may be increased, and the effect
9415 is to add padding bits after the value.  This also causes a warning message
9416 to be generated.
9417
9418 The largest Size value permitted in GNAT is 2**31@minus{}1.  Since this is a
9419 Size in bits, this corresponds to an object of size 256 megabytes (minus
9420 one).  This limitation is true on all targets.  The reason for this
9421 limitation is that it improves the quality of the code in many cases
9422 if it is known that a Size value can be accommodated in an object of
9423 type Integer.
9424
9425 @node Storage_Size Clauses
9426 @section Storage_Size Clauses
9427 @cindex Storage_Size Clause
9428
9429 @noindent
9430 For tasks, the @code{Storage_Size} clause specifies the amount of space
9431 to be allocated for the task stack.  This cannot be extended, and if the
9432 stack is exhausted, then @code{Storage_Error} will be raised (if stack
9433 checking is enabled).  Use a @code{Storage_Size} attribute definition clause,
9434 or a @code{Storage_Size} pragma in the task definition to set the
9435 appropriate required size.  A useful technique is to include in every
9436 task definition a pragma of the form:
9437
9438 @smallexample @c ada
9439    pragma Storage_Size (Default_Stack_Size);
9440 @end smallexample
9441
9442 @noindent
9443 Then @code{Default_Stack_Size} can be defined in a global package, and
9444 modified as required. Any tasks requiring stack sizes different from the
9445 default can have an appropriate alternative reference in the pragma.
9446
9447 You can also use the @option{-d} binder switch to modify the default stack
9448 size.
9449
9450 For access types, the @code{Storage_Size} clause specifies the maximum
9451 space available for allocation of objects of the type.  If this space is
9452 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
9453 In the case where the access type is declared local to a subprogram, the
9454 use of a @code{Storage_Size} clause triggers automatic use of a special
9455 predefined storage pool (@code{System.Pool_Size}) that ensures that all
9456 space for the pool is automatically reclaimed on exit from the scope in
9457 which the type is declared.
9458
9459 A special case recognized by the compiler is the specification of a
9460 @code{Storage_Size} of zero for an access type.  This means that no
9461 items can be allocated from the pool, and this is recognized at compile
9462 time, and all the overhead normally associated with maintaining a fixed
9463 size storage pool is eliminated.  Consider the following example:
9464
9465 @smallexample @c ada
9466    procedure p is
9467       type R is array (Natural) of Character;
9468       type P is access all R;
9469       for P'Storage_Size use 0;
9470       --  Above access type intended only for interfacing purposes
9471
9472       y : P;
9473
9474       procedure g (m : P);
9475       pragma Import (C, g);
9476
9477       --  @dots{}
9478
9479    begin
9480       --  @dots{}
9481       y := new R;
9482    end;
9483 @end smallexample
9484
9485 @noindent
9486 As indicated in this example, these dummy storage pools are often useful in
9487 connection with interfacing where no object will ever be allocated.  If you
9488 compile the above example, you get the warning:
9489
9490 @smallexample
9491    p.adb:16:09: warning: allocation from empty storage pool
9492    p.adb:16:09: warning: Storage_Error will be raised at run time
9493 @end smallexample
9494
9495 @noindent
9496 Of course in practice, there will not be any explicit allocators in the
9497 case of such an access declaration.
9498
9499 @node Size of Variant Record Objects
9500 @section Size of Variant Record Objects
9501 @cindex Size, variant record objects
9502 @cindex Variant record objects, size
9503
9504 @noindent
9505 In the case of variant record objects, there is a question whether Size gives
9506 information about a particular variant, or the maximum size required
9507 for any variant.  Consider the following program
9508
9509 @smallexample @c ada
9510 with Text_IO; use Text_IO;
9511 procedure q is
9512    type R1 (A : Boolean := False) is record
9513      case A is
9514        when True  => X : Character;
9515        when False => null;
9516      end case;
9517    end record;
9518
9519    V1 : R1 (False);
9520    V2 : R1;
9521
9522 begin
9523    Put_Line (Integer'Image (V1'Size));
9524    Put_Line (Integer'Image (V2'Size));
9525 end q;
9526 @end smallexample
9527
9528 @noindent
9529 Here we are dealing with a variant record, where the True variant
9530 requires 16 bits, and the False variant requires 8 bits.
9531 In the above example, both V1 and V2 contain the False variant,
9532 which is only 8 bits long.  However, the result of running the
9533 program is:
9534
9535 @smallexample
9536 8
9537 16
9538 @end smallexample
9539
9540 @noindent
9541 The reason for the difference here is that the discriminant value of
9542 V1 is fixed, and will always be False.  It is not possible to assign
9543 a True variant value to V1, therefore 8 bits is sufficient.  On the
9544 other hand, in the case of V2, the initial discriminant value is
9545 False (from the default), but it is possible to assign a True
9546 variant value to V2, therefore 16 bits must be allocated for V2
9547 in the general case, even fewer bits may be needed at any particular
9548 point during the program execution.
9549
9550 As can be seen from the output of this program, the @code{'Size}
9551 attribute applied to such an object in GNAT gives the actual allocated
9552 size of the variable, which is the largest size of any of the variants.
9553 The Ada Reference Manual is not completely clear on what choice should
9554 be made here, but the GNAT behavior seems most consistent with the
9555 language in the RM@.
9556
9557 In some cases, it may be desirable to obtain the size of the current
9558 variant, rather than the size of the largest variant.  This can be
9559 achieved in GNAT by making use of the fact that in the case of a
9560 subprogram parameter, GNAT does indeed return the size of the current
9561 variant (because a subprogram has no way of knowing how much space
9562 is actually allocated for the actual).
9563
9564 Consider the following modified version of the above program:
9565
9566 @smallexample @c ada
9567 with Text_IO; use Text_IO;
9568 procedure q is
9569    type R1 (A : Boolean := False) is record
9570      case A is
9571        when True  => X : Character;
9572        when False => null;
9573      end case;
9574    end record;
9575
9576    V2 : R1;
9577
9578    function Size (V : R1) return Integer is
9579    begin
9580       return V'Size;
9581    end Size;
9582
9583 begin
9584    Put_Line (Integer'Image (V2'Size));
9585    Put_Line (Integer'IMage (Size (V2)));
9586    V2 := (True, 'x');
9587    Put_Line (Integer'Image (V2'Size));
9588    Put_Line (Integer'IMage (Size (V2)));
9589 end q;
9590 @end smallexample
9591
9592 @noindent
9593 The output from this program is
9594
9595 @smallexample
9596 16
9597 8
9598 16
9599 16
9600 @end smallexample
9601
9602 @noindent
9603 Here we see that while the @code{'Size} attribute always returns
9604 the maximum size, regardless of the current variant value, the
9605 @code{Size} function does indeed return the size of the current
9606 variant value.
9607
9608 @node Biased Representation
9609 @section Biased Representation
9610 @cindex Size for biased representation
9611 @cindex Biased representation
9612
9613 @noindent
9614 In the case of scalars with a range starting at other than zero, it is
9615 possible in some cases to specify a size smaller than the default minimum
9616 value, and in such cases, GNAT uses an unsigned biased representation,
9617 in which zero is used to represent the lower bound, and successive values
9618 represent successive values of the type.
9619
9620 For example, suppose we have the declaration:
9621
9622 @smallexample @c ada
9623    type Small is range -7 .. -4;
9624    for Small'Size use 2;
9625 @end smallexample
9626
9627 @noindent
9628 Although the default size of type @code{Small} is 4, the @code{Size}
9629 clause is accepted by GNAT and results in the following representation
9630 scheme:
9631
9632 @smallexample
9633   -7 is represented as 2#00#
9634   -6 is represented as 2#01#
9635   -5 is represented as 2#10#
9636   -4 is represented as 2#11#
9637 @end smallexample
9638
9639 @noindent
9640 Biased representation is only used if the specified @code{Size} clause
9641 cannot be accepted in any other manner.  These reduced sizes that force
9642 biased representation can be used for all discrete types except for
9643 enumeration types for which a representation clause is given.
9644
9645 @node Value_Size and Object_Size Clauses
9646 @section Value_Size and Object_Size Clauses
9647 @findex Value_Size
9648 @findex Object_Size
9649 @cindex Size, of objects
9650
9651 @noindent
9652 In Ada 95 and Ada 2005, @code{T'Size} for a type @code{T} is the minimum
9653 number of bits required to hold values of type @code{T}.
9654 Although this interpretation was allowed in Ada 83, it was not required,
9655 and this requirement in practice can cause some significant difficulties.
9656 For example, in most Ada 83 compilers, @code{Natural'Size} was 32.
9657 However, in Ada 95 and Ada 2005,
9658 @code{Natural'Size} is
9659 typically 31.  This means that code may change in behavior when moving
9660 from Ada 83 to Ada 95 or Ada 2005.  For example, consider:
9661
9662 @smallexample @c ada
9663    type Rec is record;
9664       A : Natural;
9665       B : Natural;
9666    end record;
9667
9668    for Rec use record
9669       at 0  range 0 .. Natural'Size - 1;
9670       at 0  range Natural'Size .. 2 * Natural'Size - 1;
9671    end record;
9672 @end smallexample
9673
9674 @noindent
9675 In the above code, since the typical size of @code{Natural} objects
9676 is 32 bits and @code{Natural'Size} is 31, the above code can cause
9677 unexpected inefficient packing in Ada 95 and Ada 2005, and in general
9678 there are cases where the fact that the object size can exceed the
9679 size of the type causes surprises.
9680
9681 To help get around this problem GNAT provides two implementation
9682 defined attributes, @code{Value_Size} and @code{Object_Size}.  When
9683 applied to a type, these attributes yield the size of the type
9684 (corresponding to the RM defined size attribute), and the size of
9685 objects of the type respectively.
9686
9687 The @code{Object_Size} is used for determining the default size of
9688 objects and components.  This size value can be referred to using the
9689 @code{Object_Size} attribute.  The phrase ``is used'' here means that it is
9690 the basis of the determination of the size.  The backend is free to
9691 pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
9692 character might be stored in 32 bits on a machine with no efficient
9693 byte access instructions such as the Alpha.
9694
9695 The default rules for the value of @code{Object_Size} for
9696 discrete types are as follows:
9697
9698 @itemize @bullet
9699 @item
9700 The @code{Object_Size} for base subtypes reflect the natural hardware
9701 size in bits (run the compiler with @option{-gnatS} to find those values
9702 for numeric types). Enumeration types and fixed-point base subtypes have
9703 8, 16, 32 or 64 bits for this size, depending on the range of values
9704 to be stored.
9705
9706 @item
9707 The @code{Object_Size} of a subtype is the same as the
9708 @code{Object_Size} of
9709 the type from which it is obtained.
9710
9711 @item
9712 The @code{Object_Size} of a derived base type is copied from the parent
9713 base type, and the @code{Object_Size} of a derived first subtype is copied
9714 from the parent first subtype.
9715 @end itemize
9716
9717 @noindent
9718 The @code{Value_Size} attribute
9719 is the (minimum) number of bits required to store a value
9720 of the type.
9721 This value is used to determine how tightly to pack
9722 records or arrays with components of this type, and also affects
9723 the semantics of unchecked conversion (unchecked conversions where
9724 the @code{Value_Size} values differ generate a warning, and are potentially
9725 target dependent).
9726
9727 The default rules for the value of @code{Value_Size} are as follows:
9728
9729 @itemize @bullet
9730 @item
9731 The @code{Value_Size} for a base subtype is the minimum number of bits
9732 required to store all values of the type (including the sign bit
9733 only if negative values are possible).
9734
9735 @item
9736 If a subtype statically matches the first subtype of a given type, then it has
9737 by default the same @code{Value_Size} as the first subtype.  This is a
9738 consequence of RM 13.1(14) (``if two subtypes statically match,
9739 then their subtype-specific aspects are the same''.)
9740
9741 @item
9742 All other subtypes have a @code{Value_Size} corresponding to the minimum
9743 number of bits required to store all values of the subtype.  For
9744 dynamic bounds, it is assumed that the value can range down or up
9745 to the corresponding bound of the ancestor
9746 @end itemize
9747
9748 @noindent
9749 The RM defined attribute @code{Size} corresponds to the
9750 @code{Value_Size} attribute.
9751
9752 The @code{Size} attribute may be defined for a first-named subtype.  This sets
9753 the @code{Value_Size} of
9754 the first-named subtype to the given value, and the
9755 @code{Object_Size} of this first-named subtype to the given value padded up
9756 to an appropriate boundary.  It is a consequence of the default rules
9757 above that this @code{Object_Size} will apply to all further subtypes.  On the
9758 other hand, @code{Value_Size} is affected only for the first subtype, any
9759 dynamic subtypes obtained from it directly, and any statically matching
9760 subtypes.  The @code{Value_Size} of any other static subtypes is not affected.
9761
9762 @code{Value_Size} and
9763 @code{Object_Size} may be explicitly set for any subtype using
9764 an attribute definition clause.  Note that the use of these attributes
9765 can cause the RM 13.1(14) rule to be violated.  If two access types
9766 reference aliased objects whose subtypes have differing @code{Object_Size}
9767 values as a result of explicit attribute definition clauses, then it
9768 is erroneous to convert from one access subtype to the other.
9769
9770 At the implementation level, Esize stores the Object_Size and the
9771 RM_Size field stores the @code{Value_Size} (and hence the value of the
9772 @code{Size} attribute,
9773 which, as noted above, is equivalent to @code{Value_Size}).
9774
9775 To get a feel for the difference, consider the following examples (note
9776 that in each case the base is @code{Short_Short_Integer} with a size of 8):
9777
9778 @smallexample
9779                                        Object_Size     Value_Size
9780
9781 type x1 is range 0 .. 5;                    8               3
9782
9783 type x2 is range 0 .. 5;
9784 for x2'size use 12;                        16              12
9785
9786 subtype x3 is x2 range 0 .. 3;             16               2
9787
9788 subtype x4 is x2'base range 0 .. 10;        8               4
9789
9790 subtype x5 is x2 range 0 .. dynamic;       16               3*
9791
9792 subtype x6 is x2'base range 0 .. dynamic;   8               3*
9793
9794 @end smallexample
9795
9796 @noindent
9797 Note: the entries marked ``3*'' are not actually specified by the Ada
9798 Reference Manual, but it seems in the spirit of the RM rules to allocate
9799 the minimum number of bits (here 3, given the range for @code{x2})
9800 known to be large enough to hold the given range of values.
9801
9802 So far, so good, but GNAT has to obey the RM rules, so the question is
9803 under what conditions must the RM @code{Size} be used.
9804 The following is a list
9805 of the occasions on which the RM @code{Size} must be used:
9806
9807 @itemize @bullet
9808 @item
9809 Component size for packed arrays or records
9810
9811 @item
9812 Value of the attribute @code{Size} for a type
9813
9814 @item
9815 Warning about sizes not matching for unchecked conversion
9816 @end itemize
9817
9818 @noindent
9819 For record types, the @code{Object_Size} is always a multiple of the
9820 alignment of the type (this is true for all types). In some cases the
9821 @code{Value_Size} can be smaller. Consider:
9822
9823 @smallexample
9824    type R is record
9825      X : Integer;
9826      Y : Character;
9827    end record;
9828 @end smallexample
9829
9830 @noindent
9831 On a typical 32-bit architecture, the X component will be four bytes, and
9832 require four-byte alignment, and the Y component will be one byte. In this
9833 case @code{R'Value_Size} will be 40 (bits) since this is the minimum size
9834 required to store a value of this type, and for example, it is permissible
9835 to have a component of type R in an outer record whose component size is
9836 specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits),
9837 since it must be rounded up so that this value is a multiple of the
9838 alignment (4 bytes = 32 bits).
9839
9840 @noindent
9841 For all other types, the @code{Object_Size}
9842 and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
9843 Only @code{Size} may be specified for such types.
9844
9845 @node Component_Size Clauses
9846 @section Component_Size Clauses
9847 @cindex Component_Size Clause
9848
9849 @noindent
9850 Normally, the value specified in a component size clause must be consistent
9851 with the subtype of the array component with regard to size and alignment.
9852 In other words, the value specified must be at least equal to the size
9853 of this subtype, and must be a multiple of the alignment value.
9854
9855 In addition, component size clauses are allowed which cause the array
9856 to be packed, by specifying a smaller value.  The cases in which this
9857 is allowed are for component size values in the range 1 through 63.  The value
9858 specified must not be smaller than the Size of the subtype.  GNAT will
9859 accurately honor all packing requests in this range.  For example, if
9860 we have:
9861
9862 @smallexample @c ada
9863 type r is array (1 .. 8) of Natural;
9864 for r'Component_Size use 31;
9865 @end smallexample
9866
9867 @noindent
9868 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
9869 Of course access to the components of such an array is considerably
9870 less efficient than if the natural component size of 32 is used.
9871
9872 Note that there is no point in giving both a component size clause
9873 and a pragma Pack for the same array type. if such duplicate
9874 clauses are given, the pragma Pack will be ignored.
9875
9876 @node Bit_Order Clauses
9877 @section Bit_Order Clauses
9878 @cindex Bit_Order Clause
9879 @cindex bit ordering
9880 @cindex ordering, of bits
9881
9882 @noindent
9883 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
9884 attribute.  The specification may either correspond to the default bit
9885 order for the target, in which case the specification has no effect and
9886 places no additional restrictions, or it may be for the non-standard
9887 setting (that is the opposite of the default).
9888
9889 In the case where the non-standard value is specified, the effect is
9890 to renumber bits within each byte, but the ordering of bytes is not
9891 affected.  There are certain
9892 restrictions placed on component clauses as follows:
9893
9894 @itemize @bullet
9895
9896 @item Components fitting within a single storage unit.
9897 @noindent
9898 These are unrestricted, and the effect is merely to renumber bits.  For
9899 example if we are on a little-endian machine with @code{Low_Order_First}
9900 being the default, then the following two declarations have exactly
9901 the same effect:
9902
9903 @smallexample @c ada
9904    type R1 is record
9905       A : Boolean;
9906       B : Integer range 1 .. 120;
9907    end record;
9908
9909    for R1 use record
9910       A at 0 range 0 .. 0;
9911       B at 0 range 1 .. 7;
9912    end record;
9913
9914    type R2 is record
9915       A : Boolean;
9916       B : Integer range 1 .. 120;
9917    end record;
9918
9919    for R2'Bit_Order use High_Order_First;
9920
9921    for R2 use record
9922       A at 0 range 7 .. 7;
9923       B at 0 range 0 .. 6;
9924    end record;
9925 @end smallexample
9926
9927 @noindent
9928 The useful application here is to write the second declaration with the
9929 @code{Bit_Order} attribute definition clause, and know that it will be treated
9930 the same, regardless of whether the target is little-endian or big-endian.
9931
9932 @item Components occupying an integral number of bytes.
9933 @noindent
9934 These are components that exactly fit in two or more bytes.  Such component
9935 declarations are allowed, but have no effect, since it is important to realize
9936 that the @code{Bit_Order} specification does not affect the ordering of bytes.
9937 In particular, the following attempt at getting an endian-independent integer
9938 does not work:
9939
9940 @smallexample @c ada
9941    type R2 is record
9942       A : Integer;
9943    end record;
9944
9945    for R2'Bit_Order use High_Order_First;
9946
9947    for R2 use record
9948       A at 0 range 0 .. 31;
9949    end record;
9950 @end smallexample
9951
9952 @noindent
9953 This declaration will result in a little-endian integer on a
9954 little-endian machine, and a big-endian integer on a big-endian machine.
9955 If byte flipping is required for interoperability between big- and
9956 little-endian machines, this must be explicitly programmed.  This capability
9957 is not provided by @code{Bit_Order}.
9958
9959 @item Components that are positioned across byte boundaries
9960 @noindent
9961 but do not occupy an integral number of bytes.  Given that bytes are not
9962 reordered, such fields would occupy a non-contiguous sequence of bits
9963 in memory, requiring non-trivial code to reassemble.  They are for this
9964 reason not permitted, and any component clause specifying such a layout
9965 will be flagged as illegal by GNAT@.
9966
9967 @end itemize
9968
9969 @noindent
9970 Since the misconception that Bit_Order automatically deals with all
9971 endian-related incompatibilities is a common one, the specification of
9972 a component field that is an integral number of bytes will always
9973 generate a warning.  This warning may be suppressed using @code{pragma
9974 Warnings (Off)} if desired.  The following section contains additional
9975 details regarding the issue of byte ordering.
9976
9977 @node Effect of Bit_Order on Byte Ordering
9978 @section Effect of Bit_Order on Byte Ordering
9979 @cindex byte ordering
9980 @cindex ordering, of bytes
9981
9982 @noindent
9983 In this section we will review the effect of the @code{Bit_Order} attribute
9984 definition clause on byte ordering.  Briefly, it has no effect at all, but
9985 a detailed example will be helpful.  Before giving this
9986 example, let us review the precise
9987 definition of the effect of defining @code{Bit_Order}.  The effect of a
9988 non-standard bit order is described in section 15.5.3 of the Ada
9989 Reference Manual:
9990
9991 @quotation
9992 2   A bit ordering is a method of interpreting the meaning of
9993 the storage place attributes.
9994 @end quotation
9995
9996 @noindent
9997 To understand the precise definition of storage place attributes in
9998 this context, we visit section 13.5.1 of the manual:
9999
10000 @quotation
10001 13   A record_representation_clause (without the mod_clause)
10002 specifies the layout.  The storage place attributes (see 13.5.2)
10003 are taken from the values of the position, first_bit, and last_bit
10004 expressions after normalizing those values so that first_bit is
10005 less than Storage_Unit.
10006 @end quotation
10007
10008 @noindent
10009 The critical point here is that storage places are taken from
10010 the values after normalization, not before.  So the @code{Bit_Order}
10011 interpretation applies to normalized values.  The interpretation
10012 is described in the later part of the 15.5.3 paragraph:
10013
10014 @quotation
10015 2   A bit ordering is a method of interpreting the meaning of
10016 the storage place attributes.  High_Order_First (known in the
10017 vernacular as ``big endian'') means that the first bit of a
10018 storage element (bit 0) is the most significant bit (interpreting
10019 the sequence of bits that represent a component as an unsigned
10020 integer value).  Low_Order_First (known in the vernacular as
10021 ``little endian'') means the opposite: the first bit is the
10022 least significant.
10023 @end quotation
10024
10025 @noindent
10026 Note that the numbering is with respect to the bits of a storage
10027 unit.  In other words, the specification affects only the numbering
10028 of bits within a single storage unit.
10029
10030 We can make the effect clearer by giving an example.
10031
10032 Suppose that we have an external device which presents two bytes, the first
10033 byte presented, which is the first (low addressed byte) of the two byte
10034 record is called Master, and the second byte is called Slave.
10035
10036 The left most (most significant bit is called Control for each byte, and
10037 the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
10038 (least significant) bit.
10039
10040 On a big-endian machine, we can write the following representation clause
10041
10042 @smallexample @c ada
10043    type Data is record
10044       Master_Control : Bit;
10045       Master_V1      : Bit;
10046       Master_V2      : Bit;
10047       Master_V3      : Bit;
10048       Master_V4      : Bit;
10049       Master_V5      : Bit;
10050       Master_V6      : Bit;
10051       Master_V7      : Bit;
10052       Slave_Control  : Bit;
10053       Slave_V1       : Bit;
10054       Slave_V2       : Bit;
10055       Slave_V3       : Bit;
10056       Slave_V4       : Bit;
10057       Slave_V5       : Bit;
10058       Slave_V6       : Bit;
10059       Slave_V7       : Bit;
10060    end record;
10061
10062    for Data use record
10063       Master_Control at 0 range 0 .. 0;
10064       Master_V1      at 0 range 1 .. 1;
10065       Master_V2      at 0 range 2 .. 2;
10066       Master_V3      at 0 range 3 .. 3;
10067       Master_V4      at 0 range 4 .. 4;
10068       Master_V5      at 0 range 5 .. 5;
10069       Master_V6      at 0 range 6 .. 6;
10070       Master_V7      at 0 range 7 .. 7;
10071       Slave_Control  at 1 range 0 .. 0;
10072       Slave_V1       at 1 range 1 .. 1;
10073       Slave_V2       at 1 range 2 .. 2;
10074       Slave_V3       at 1 range 3 .. 3;
10075       Slave_V4       at 1 range 4 .. 4;
10076       Slave_V5       at 1 range 5 .. 5;
10077       Slave_V6       at 1 range 6 .. 6;
10078       Slave_V7       at 1 range 7 .. 7;
10079    end record;
10080 @end smallexample
10081
10082 @noindent
10083 Now if we move this to a little endian machine, then the bit ordering within
10084 the byte is backwards, so we have to rewrite the record rep clause as:
10085
10086 @smallexample @c ada
10087    for Data use record
10088       Master_Control at 0 range 7 .. 7;
10089       Master_V1      at 0 range 6 .. 6;
10090       Master_V2      at 0 range 5 .. 5;
10091       Master_V3      at 0 range 4 .. 4;
10092       Master_V4      at 0 range 3 .. 3;
10093       Master_V5      at 0 range 2 .. 2;
10094       Master_V6      at 0 range 1 .. 1;
10095       Master_V7      at 0 range 0 .. 0;
10096       Slave_Control  at 1 range 7 .. 7;
10097       Slave_V1       at 1 range 6 .. 6;
10098       Slave_V2       at 1 range 5 .. 5;
10099       Slave_V3       at 1 range 4 .. 4;
10100       Slave_V4       at 1 range 3 .. 3;
10101       Slave_V5       at 1 range 2 .. 2;
10102       Slave_V6       at 1 range 1 .. 1;
10103       Slave_V7       at 1 range 0 .. 0;
10104    end record;
10105 @end smallexample
10106
10107 @noindent
10108 It is a nuisance to have to rewrite the clause, especially if
10109 the code has to be maintained on both machines.  However,
10110 this is a case that we can handle with the
10111 @code{Bit_Order} attribute if it is implemented.
10112 Note that the implementation is not required on byte addressed
10113 machines, but it is indeed implemented in GNAT.
10114 This means that we can simply use the
10115 first record clause, together with the declaration
10116
10117 @smallexample @c ada
10118    for Data'Bit_Order use High_Order_First;
10119 @end smallexample
10120
10121 @noindent
10122 and the effect is what is desired, namely the layout is exactly the same,
10123 independent of whether the code is compiled on a big-endian or little-endian
10124 machine.
10125
10126 The important point to understand is that byte ordering is not affected.
10127 A @code{Bit_Order} attribute definition never affects which byte a field
10128 ends up in, only where it ends up in that byte.
10129 To make this clear, let us rewrite the record rep clause of the previous
10130 example as:
10131
10132 @smallexample @c ada
10133    for Data'Bit_Order use High_Order_First;
10134    for Data use record
10135       Master_Control at 0 range  0 .. 0;
10136       Master_V1      at 0 range  1 .. 1;
10137       Master_V2      at 0 range  2 .. 2;
10138       Master_V3      at 0 range  3 .. 3;
10139       Master_V4      at 0 range  4 .. 4;
10140       Master_V5      at 0 range  5 .. 5;
10141       Master_V6      at 0 range  6 .. 6;
10142       Master_V7      at 0 range  7 .. 7;
10143       Slave_Control  at 0 range  8 .. 8;
10144       Slave_V1       at 0 range  9 .. 9;
10145       Slave_V2       at 0 range 10 .. 10;
10146       Slave_V3       at 0 range 11 .. 11;
10147       Slave_V4       at 0 range 12 .. 12;
10148       Slave_V5       at 0 range 13 .. 13;
10149       Slave_V6       at 0 range 14 .. 14;
10150       Slave_V7       at 0 range 15 .. 15;
10151    end record;
10152 @end smallexample
10153
10154 @noindent
10155 This is exactly equivalent to saying (a repeat of the first example):
10156
10157 @smallexample @c ada
10158    for Data'Bit_Order use High_Order_First;
10159    for Data use record
10160       Master_Control at 0 range 0 .. 0;
10161       Master_V1      at 0 range 1 .. 1;
10162       Master_V2      at 0 range 2 .. 2;
10163       Master_V3      at 0 range 3 .. 3;
10164       Master_V4      at 0 range 4 .. 4;
10165       Master_V5      at 0 range 5 .. 5;
10166       Master_V6      at 0 range 6 .. 6;
10167       Master_V7      at 0 range 7 .. 7;
10168       Slave_Control  at 1 range 0 .. 0;
10169       Slave_V1       at 1 range 1 .. 1;
10170       Slave_V2       at 1 range 2 .. 2;
10171       Slave_V3       at 1 range 3 .. 3;
10172       Slave_V4       at 1 range 4 .. 4;
10173       Slave_V5       at 1 range 5 .. 5;
10174       Slave_V6       at 1 range 6 .. 6;
10175       Slave_V7       at 1 range 7 .. 7;
10176    end record;
10177 @end smallexample
10178
10179 @noindent
10180 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
10181 field.  The storage place attributes are obtained by normalizing the
10182 values given so that the @code{First_Bit} value is less than 8.  After
10183 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
10184 we specified in the other case.
10185
10186 Now one might expect that the @code{Bit_Order} attribute might affect
10187 bit numbering within the entire record component (two bytes in this
10188 case, thus affecting which byte fields end up in), but that is not
10189 the way this feature is defined, it only affects numbering of bits,
10190 not which byte they end up in.
10191
10192 Consequently it never makes sense to specify a starting bit number
10193 greater than 7 (for a byte addressable field) if an attribute
10194 definition for @code{Bit_Order} has been given, and indeed it
10195 may be actively confusing to specify such a value, so the compiler
10196 generates a warning for such usage.
10197
10198 If you do need to control byte ordering then appropriate conditional
10199 values must be used.  If in our example, the slave byte came first on
10200 some machines we might write:
10201
10202 @smallexample @c ada
10203    Master_Byte_First constant Boolean := @dots{};
10204
10205    Master_Byte : constant Natural :=
10206                    1 - Boolean'Pos (Master_Byte_First);
10207    Slave_Byte  : constant Natural :=
10208                    Boolean'Pos (Master_Byte_First);
10209
10210    for Data'Bit_Order use High_Order_First;
10211    for Data use record
10212       Master_Control at Master_Byte range 0 .. 0;
10213       Master_V1      at Master_Byte range 1 .. 1;
10214       Master_V2      at Master_Byte range 2 .. 2;
10215       Master_V3      at Master_Byte range 3 .. 3;
10216       Master_V4      at Master_Byte range 4 .. 4;
10217       Master_V5      at Master_Byte range 5 .. 5;
10218       Master_V6      at Master_Byte range 6 .. 6;
10219       Master_V7      at Master_Byte range 7 .. 7;
10220       Slave_Control  at Slave_Byte  range 0 .. 0;
10221       Slave_V1       at Slave_Byte  range 1 .. 1;
10222       Slave_V2       at Slave_Byte  range 2 .. 2;
10223       Slave_V3       at Slave_Byte  range 3 .. 3;
10224       Slave_V4       at Slave_Byte  range 4 .. 4;
10225       Slave_V5       at Slave_Byte  range 5 .. 5;
10226       Slave_V6       at Slave_Byte  range 6 .. 6;
10227       Slave_V7       at Slave_Byte  range 7 .. 7;
10228    end record;
10229 @end smallexample
10230
10231 @noindent
10232 Now to switch between machines, all that is necessary is
10233 to set the boolean constant @code{Master_Byte_First} in
10234 an appropriate manner.
10235
10236 @node Pragma Pack for Arrays
10237 @section Pragma Pack for Arrays
10238 @cindex Pragma Pack (for arrays)
10239
10240 @noindent
10241 Pragma @code{Pack} applied to an array has no effect unless the component type
10242 is packable.  For a component type to be packable, it must be one of the
10243 following cases:
10244
10245 @itemize @bullet
10246 @item
10247 Any scalar type
10248 @item
10249 Any type whose size is specified with a size clause
10250 @item
10251 Any packed array type with a static size
10252 @end itemize
10253
10254 @noindent
10255 For all these cases, if the component subtype size is in the range
10256 1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
10257 component size were specified giving the component subtype size.
10258 For example if we have:
10259
10260 @smallexample @c ada
10261    type r is range 0 .. 17;
10262
10263    type ar is array (1 .. 8) of r;
10264    pragma Pack (ar);
10265 @end smallexample
10266
10267 @noindent
10268 Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
10269 and the size of the array @code{ar} will be exactly 40 bits.
10270
10271 Note that in some cases this rather fierce approach to packing can produce
10272 unexpected effects.  For example, in Ada 95 and Ada 2005,
10273 subtype @code{Natural} typically has a size of 31, meaning that if you
10274 pack an array of @code{Natural}, you get 31-bit
10275 close packing, which saves a few bits, but results in far less efficient
10276 access.  Since many other Ada compilers will ignore such a packing request,
10277 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
10278 might not be what is intended.  You can easily remove this warning by
10279 using an explicit @code{Component_Size} setting instead, which never generates
10280 a warning, since the intention of the programmer is clear in this case.
10281
10282 GNAT treats packed arrays in one of two ways.  If the size of the array is
10283 known at compile time and is less than 64 bits, then internally the array
10284 is represented as a single modular type, of exactly the appropriate number
10285 of bits.  If the length is greater than 63 bits, or is not known at compile
10286 time, then the packed array is represented as an array of bytes, and the
10287 length is always a multiple of 8 bits.
10288
10289 Note that to represent a packed array as a modular type, the alignment must
10290 be suitable for the modular type involved. For example, on typical machines
10291 a 32-bit packed array will be represented by a 32-bit modular integer with
10292 an alignment of four bytes. If you explicitly override the default alignment
10293 with an alignment clause that is too small, the modular representation
10294 cannot be used. For example, consider the following set of declarations:
10295
10296 @smallexample @c ada
10297    type R is range 1 .. 3;
10298    type S is array (1 .. 31) of R;
10299    for S'Component_Size use 2;
10300    for S'Size use 62;
10301    for S'Alignment use 1;
10302 @end smallexample
10303
10304 @noindent
10305 If the alignment clause were not present, then a 62-bit modular
10306 representation would be chosen (typically with an alignment of 4 or 8
10307 bytes depending on the target). But the default alignment is overridden
10308 with the explicit alignment clause. This means that the modular
10309 representation cannot be used, and instead the array of bytes
10310 representation must be used, meaning that the length must be a multiple
10311 of 8. Thus the above set of declarations will result in a diagnostic
10312 rejecting the size clause and noting that the minimum size allowed is 64.
10313
10314 @cindex Pragma Pack (for type Natural)
10315 @cindex Pragma Pack warning
10316
10317 One special case that is worth noting occurs when the base type of the
10318 component size is 8/16/32 and the subtype is one bit less. Notably this
10319 occurs with subtype @code{Natural}. Consider:
10320
10321 @smallexample @c ada
10322    type Arr is array (1 .. 32) of Natural;
10323    pragma Pack (Arr);
10324 @end smallexample
10325
10326 @noindent
10327 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
10328 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
10329 Ada 83 compilers did not attempt 31 bit packing.
10330
10331 In Ada 95 and Ada 2005, @code{Natural'Size} is required to be 31. Furthermore,
10332 GNAT really does pack 31-bit subtype to 31 bits. This may result in a
10333 substantial unintended performance penalty when porting legacy Ada 83 code.
10334 To help prevent this, GNAT generates a warning in such cases. If you really
10335 want 31 bit packing in a case like this, you can set the component size
10336 explicitly:
10337
10338 @smallexample @c ada
10339    type Arr is array (1 .. 32) of Natural;
10340    for Arr'Component_Size use 31;
10341 @end smallexample
10342
10343 @noindent
10344 Here 31-bit packing is achieved as required, and no warning is generated,
10345 since in this case the programmer intention is clear.
10346
10347 @node Pragma Pack for Records
10348 @section Pragma Pack for Records
10349 @cindex Pragma Pack (for records)
10350
10351 @noindent
10352 Pragma @code{Pack} applied to a record will pack the components to reduce
10353 wasted space from alignment gaps and by reducing the amount of space
10354 taken by components.  We distinguish between @emph{packable} components and
10355 @emph{non-packable} components.
10356 Components of the following types are considered packable:
10357 @itemize @bullet
10358 @item
10359 All primitive types are packable.
10360
10361 @item
10362 Small packed arrays, whose size does not exceed 64 bits, and where the
10363 size is statically known at compile time, are represented internally
10364 as modular integers, and so they are also packable.
10365
10366 @end itemize
10367
10368 @noindent
10369 All packable components occupy the exact number of bits corresponding to
10370 their @code{Size} value, and are packed with no padding bits, i.e.@: they
10371 can start on an arbitrary bit boundary.
10372
10373 All other types are non-packable, they occupy an integral number of
10374 storage units, and
10375 are placed at a boundary corresponding to their alignment requirements.
10376
10377 For example, consider the record
10378
10379 @smallexample @c ada
10380    type Rb1 is array (1 .. 13) of Boolean;
10381    pragma Pack (rb1);
10382
10383    type Rb2 is array (1 .. 65) of Boolean;
10384    pragma Pack (rb2);
10385
10386    type x2 is record
10387       l1 : Boolean;
10388       l2 : Duration;
10389       l3 : Float;
10390       l4 : Boolean;
10391       l5 : Rb1;
10392       l6 : Rb2;
10393    end record;
10394    pragma Pack (x2);
10395 @end smallexample
10396
10397 @noindent
10398 The representation for the record x2 is as follows:
10399
10400 @smallexample @c ada
10401 for x2'Size use 224;
10402 for x2 use record
10403    l1 at  0 range  0 .. 0;
10404    l2 at  0 range  1 .. 64;
10405    l3 at 12 range  0 .. 31;
10406    l4 at 16 range  0 .. 0;
10407    l5 at 16 range  1 .. 13;
10408    l6 at 18 range  0 .. 71;
10409 end record;
10410 @end smallexample
10411
10412 @noindent
10413 Studying this example, we see that the packable fields @code{l1}
10414 and @code{l2} are
10415 of length equal to their sizes, and placed at specific bit boundaries (and
10416 not byte boundaries) to
10417 eliminate padding.  But @code{l3} is of a non-packable float type, so
10418 it is on the next appropriate alignment boundary.
10419
10420 The next two fields are fully packable, so @code{l4} and @code{l5} are
10421 minimally packed with no gaps.  However, type @code{Rb2} is a packed
10422 array that is longer than 64 bits, so it is itself non-packable.  Thus
10423 the @code{l6} field is aligned to the next byte boundary, and takes an
10424 integral number of bytes, i.e.@: 72 bits.
10425
10426 @node Record Representation Clauses
10427 @section Record Representation Clauses
10428 @cindex Record Representation Clause
10429
10430 @noindent
10431 Record representation clauses may be given for all record types, including
10432 types obtained by record extension.  Component clauses are allowed for any
10433 static component.  The restrictions on component clauses depend on the type
10434 of the component.
10435
10436 @cindex Component Clause
10437 For all components of an elementary type, the only restriction on component
10438 clauses is that the size must be at least the 'Size value of the type
10439 (actually the Value_Size).  There are no restrictions due to alignment,
10440 and such components may freely cross storage boundaries.
10441
10442 Packed arrays with a size up to and including 64 bits are represented
10443 internally using a modular type with the appropriate number of bits, and
10444 thus the same lack of restriction applies.  For example, if you declare:
10445
10446 @smallexample @c ada
10447    type R is array (1 .. 49) of Boolean;
10448    pragma Pack (R);
10449    for R'Size use 49;
10450 @end smallexample
10451
10452 @noindent
10453 then a component clause for a component of type R may start on any
10454 specified bit boundary, and may specify a value of 49 bits or greater.
10455
10456 For packed bit arrays that are longer than 64 bits, there are two
10457 cases. If the component size is a power of 2 (1,2,4,8,16,32 bits),
10458 including the important case of single bits or boolean values, then
10459 there are no limitations on placement of such components, and they
10460 may start and end at arbitrary bit boundaries.
10461
10462 If the component size is not a power of 2 (e.g. 3 or 5), then
10463 an array of this type longer than 64 bits must always be placed on
10464 on a storage unit (byte) boundary and occupy an integral number
10465 of storage units (bytes). Any component clause that does not
10466 meet this requirement will be rejected.
10467
10468 Any aliased component, or component of an aliased type, must
10469 have its normal alignment and size. A component clause that
10470 does not meet this requirement will be rejected.
10471
10472 The tag field of a tagged type always occupies an address sized field at
10473 the start of the record.  No component clause may attempt to overlay this
10474 tag. When a tagged type appears as a component, the tag field must have
10475 proper alignment
10476
10477 In the case of a record extension T1, of a type T, no component clause applied
10478 to the type T1 can specify a storage location that would overlap the first
10479 T'Size bytes of the record.
10480
10481 For all other component types, including non-bit-packed arrays,
10482 the component can be placed at an arbitrary bit boundary,
10483 so for example, the following is permitted:
10484
10485 @smallexample @c ada
10486    type R is array (1 .. 10) of Boolean;
10487    for R'Size use 80;
10488
10489    type Q is record
10490       G, H : Boolean;
10491       L, M : R;
10492    end record;
10493
10494    for Q use record
10495       G at 0 range  0 ..   0;
10496       H at 0 range  1 ..   1;
10497       L at 0 range  2 ..  81;
10498       R at 0 range 82 .. 161;
10499    end record;
10500 @end smallexample
10501
10502 @noindent
10503 Note: the above rules apply to recent releases of GNAT 5.
10504 In GNAT 3, there are more severe restrictions on larger components.
10505 For non-primitive types, including packed arrays with a size greater than
10506 64 bits, component clauses must respect the alignment requirement of the
10507 type, in particular, always starting on a byte boundary, and the length
10508 must be a multiple of the storage unit.
10509
10510 @node Enumeration Clauses
10511 @section Enumeration Clauses
10512
10513 The only restriction on enumeration clauses is that the range of values
10514 must be representable.  For the signed case, if one or more of the
10515 representation values are negative, all values must be in the range:
10516
10517 @smallexample @c ada
10518    System.Min_Int .. System.Max_Int
10519 @end smallexample
10520
10521 @noindent
10522 For the unsigned case, where all values are non negative, the values must
10523 be in the range:
10524
10525 @smallexample @c ada
10526    0 .. System.Max_Binary_Modulus;
10527 @end smallexample
10528
10529 @noindent
10530 A @emph{confirming} representation clause is one in which the values range
10531 from 0 in sequence, i.e.@: a clause that confirms the default representation
10532 for an enumeration type.
10533 Such a confirming representation
10534 is permitted by these rules, and is specially recognized by the compiler so
10535 that no extra overhead results from the use of such a clause.
10536
10537 If an array has an index type which is an enumeration type to which an
10538 enumeration clause has been applied, then the array is stored in a compact
10539 manner.  Consider the declarations:
10540
10541 @smallexample @c ada
10542    type r is (A, B, C);
10543    for r use (A => 1, B => 5, C => 10);
10544    type t is array (r) of Character;
10545 @end smallexample
10546
10547 @noindent
10548 The array type t corresponds to a vector with exactly three elements and
10549 has a default size equal to @code{3*Character'Size}.  This ensures efficient
10550 use of space, but means that accesses to elements of the array will incur
10551 the overhead of converting representation values to the corresponding
10552 positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
10553
10554 @node Address Clauses
10555 @section Address Clauses
10556 @cindex Address Clause
10557
10558 The reference manual allows a general restriction on representation clauses,
10559 as found in RM 13.1(22):
10560
10561 @quotation
10562 An implementation need not support representation
10563 items containing nonstatic expressions, except that
10564 an implementation should support a representation item
10565 for a given entity if each nonstatic expression in the
10566 representation item is a name that statically denotes
10567 a constant declared before the entity.
10568 @end quotation
10569
10570 @noindent
10571 In practice this is applicable only to address clauses, since this is the
10572 only case in which a non-static expression is permitted by the syntax.  As
10573 the AARM notes in sections 13.1 (22.a-22.h):
10574
10575 @display
10576   22.a   Reason: This is to avoid the following sort of thing:
10577
10578   22.b        X : Integer := F(@dots{});
10579               Y : Address := G(@dots{});
10580               for X'Address use Y;
10581
10582   22.c   In the above, we have to evaluate the
10583          initialization expression for X before we
10584          know where to put the result.  This seems
10585          like an unreasonable implementation burden.
10586
10587   22.d   The above code should instead be written
10588          like this:
10589
10590   22.e        Y : constant Address := G(@dots{});
10591               X : Integer := F(@dots{});
10592               for X'Address use Y;
10593
10594   22.f   This allows the expression ``Y'' to be safely
10595          evaluated before X is created.
10596
10597   22.g   The constant could be a formal parameter of mode in.
10598
10599   22.h   An implementation can support other nonstatic
10600          expressions if it wants to.  Expressions of type
10601          Address are hardly ever static, but their value
10602          might be known at compile time anyway in many
10603          cases.
10604 @end display
10605
10606 @noindent
10607 GNAT does indeed permit many additional cases of non-static expressions.  In
10608 particular, if the type involved is elementary there are no restrictions
10609 (since in this case, holding a temporary copy of the initialization value,
10610 if one is present, is inexpensive).  In addition, if there is no implicit or
10611 explicit initialization, then there are no restrictions.  GNAT will reject
10612 only the case where all three of these conditions hold:
10613
10614 @itemize @bullet
10615
10616 @item
10617 The type of the item is non-elementary (e.g.@: a record or array).
10618
10619 @item
10620 There is explicit or implicit initialization required for the object.
10621 Note that access values are always implicitly initialized, and also
10622 in GNAT, certain bit-packed arrays (those having a dynamic length or
10623 a length greater than 64) will also be implicitly initialized to zero.
10624
10625 @item
10626 The address value is non-static.  Here GNAT is more permissive than the
10627 RM, and allows the address value to be the address of a previously declared
10628 stand-alone variable, as long as it does not itself have an address clause.
10629
10630 @smallexample @c ada
10631            Anchor  : Some_Initialized_Type;
10632            Overlay : Some_Initialized_Type;
10633            for Overlay'Address use Anchor'Address;
10634 @end smallexample
10635
10636 @noindent
10637 However, the prefix of the address clause cannot be an array component, or
10638 a component of a discriminated record.
10639
10640 @end itemize
10641
10642 @noindent
10643 As noted above in section 22.h, address values are typically non-static.  In
10644 particular the To_Address function, even if applied to a literal value, is
10645 a non-static function call.  To avoid this minor annoyance, GNAT provides
10646 the implementation defined attribute 'To_Address.  The following two
10647 expressions have identical values:
10648
10649 @findex Attribute
10650 @findex To_Address
10651 @smallexample @c ada
10652    To_Address (16#1234_0000#)
10653    System'To_Address (16#1234_0000#);
10654 @end smallexample
10655
10656 @noindent
10657 except that the second form is considered to be a static expression, and
10658 thus when used as an address clause value is always permitted.
10659
10660 @noindent
10661 Additionally, GNAT treats as static an address clause that is an
10662 unchecked_conversion of a static integer value.  This simplifies the porting
10663 of legacy code, and provides a portable equivalent to the GNAT attribute
10664 @code{To_Address}.
10665
10666 Another issue with address clauses is the interaction with alignment
10667 requirements.  When an address clause is given for an object, the address
10668 value must be consistent with the alignment of the object (which is usually
10669 the same as the alignment of the type of the object).  If an address clause
10670 is given that specifies an inappropriately aligned address value, then the
10671 program execution is erroneous.
10672
10673 Since this source of erroneous behavior can have unfortunate effects, GNAT
10674 checks (at compile time if possible, generating a warning, or at execution
10675 time with a run-time check) that the alignment is appropriate.  If the
10676 run-time check fails, then @code{Program_Error} is raised.  This run-time
10677 check is suppressed if range checks are suppressed, or if the special GNAT
10678 check Alignment_Check is suppressed, or if
10679 @code{pragma Restrictions (No_Elaboration_Code)} is in effect.
10680
10681 Finally, GNAT does not permit overlaying of objects of controlled types or
10682 composite types containing a controlled component. In most cases, the compiler
10683 can detect an attempt at such overlays and will generate a warning at compile
10684 time and a Program_Error exception at run time.
10685
10686 @findex Export
10687 An address clause cannot be given for an exported object.  More
10688 understandably the real restriction is that objects with an address
10689 clause cannot be exported.  This is because such variables are not
10690 defined by the Ada program, so there is no external object to export.
10691
10692 @findex Import
10693 It is permissible to give an address clause and a pragma Import for the
10694 same object.  In this case, the variable is not really defined by the
10695 Ada program, so there is no external symbol to be linked.  The link name
10696 and the external name are ignored in this case.  The reason that we allow this
10697 combination is that it provides a useful idiom to avoid unwanted
10698 initializations on objects with address clauses.
10699
10700 When an address clause is given for an object that has implicit or
10701 explicit initialization, then by default initialization takes place.  This
10702 means that the effect of the object declaration is to overwrite the
10703 memory at the specified address.  This is almost always not what the
10704 programmer wants, so GNAT will output a warning:
10705
10706 @smallexample
10707   with System;
10708   package G is
10709      type R is record
10710         M : Integer := 0;
10711      end record;
10712
10713      Ext : R;
10714      for Ext'Address use System'To_Address (16#1234_1234#);
10715          |
10716   >>> warning: implicit initialization of "Ext" may
10717       modify overlaid storage
10718   >>> warning: use pragma Import for "Ext" to suppress
10719       initialization (RM B(24))
10720
10721   end G;
10722 @end smallexample
10723
10724 @noindent
10725 As indicated by the warning message, the solution is to use a (dummy) pragma
10726 Import to suppress this initialization.  The pragma tell the compiler that the
10727 object is declared and initialized elsewhere.  The following package compiles
10728 without warnings (and the initialization is suppressed):
10729
10730 @smallexample @c ada
10731    with System;
10732    package G is
10733       type R is record
10734          M : Integer := 0;
10735       end record;
10736
10737       Ext : R;
10738       for Ext'Address use System'To_Address (16#1234_1234#);
10739       pragma Import (Ada, Ext);
10740    end G;
10741 @end smallexample
10742
10743 @noindent
10744 A final issue with address clauses involves their use for overlaying
10745 variables, as in the following example:
10746 @cindex Overlaying of objects
10747
10748 @smallexample @c ada
10749   A : Integer;
10750   B : Integer;
10751   for B'Address use A'Address;
10752 @end smallexample
10753
10754 @noindent
10755 or alternatively, using the form recommended by the RM:
10756
10757 @smallexample @c ada
10758   A    : Integer;
10759   Addr : constant Address := A'Address;
10760   B    : Integer;
10761   for B'Address use Addr;
10762 @end smallexample
10763
10764 @noindent
10765 In both of these cases, @code{A}
10766 and @code{B} become aliased to one another via the
10767 address clause. This use of address clauses to overlay
10768 variables, achieving an effect similar to unchecked
10769 conversion was erroneous in Ada 83, but in Ada 95 and Ada 2005
10770 the effect is implementation defined. Furthermore, the
10771 Ada RM specifically recommends that in a situation
10772 like this, @code{B} should be subject to the following
10773 implementation advice (RM 13.3(19)):
10774
10775 @quotation
10776 19  If the Address of an object is specified, or it is imported
10777     or exported, then the implementation should not perform
10778     optimizations based on assumptions of no aliases.
10779 @end quotation
10780
10781 @noindent
10782 GNAT follows this recommendation, and goes further by also applying
10783 this recommendation to the overlaid variable (@code{A}
10784 in the above example) in this case. This means that the overlay
10785 works "as expected", in that a modification to one of the variables
10786 will affect the value of the other.
10787
10788 @node Effect of Convention on Representation
10789 @section Effect of Convention on Representation
10790 @cindex Convention, effect on representation
10791
10792 @noindent
10793 Normally the specification of a foreign language convention for a type or
10794 an object has no effect on the chosen representation.  In particular, the
10795 representation chosen for data in GNAT generally meets the standard system
10796 conventions, and for example records are laid out in a manner that is
10797 consistent with C@.  This means that specifying convention C (for example)
10798 has no effect.
10799
10800 There are four exceptions to this general rule:
10801
10802 @itemize @bullet
10803
10804 @item Convention Fortran and array subtypes
10805 If pragma Convention Fortran is specified for an array subtype, then in
10806 accordance with the implementation advice in section 3.6.2(11) of the
10807 Ada Reference Manual, the array will be stored in a Fortran-compatible
10808 column-major manner, instead of the normal default row-major order.
10809
10810 @item Convention C and enumeration types
10811 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
10812 to accommodate all values of the type.  For example, for the enumeration
10813 type declared by:
10814
10815 @smallexample @c ada
10816    type Color is (Red, Green, Blue);
10817 @end smallexample
10818
10819 @noindent
10820 8 bits is sufficient to store all values of the type, so by default, objects
10821 of type @code{Color} will be represented using 8 bits.  However, normal C
10822 convention is to use 32 bits for all enum values in C, since enum values
10823 are essentially of type int.  If pragma @code{Convention C} is specified for an
10824 Ada enumeration type, then the size is modified as necessary (usually to
10825 32 bits) to be consistent with the C convention for enum values.
10826
10827 Note that this treatment applies only to types. If Convention C is given for
10828 an enumeration object, where the enumeration type is not Convention C, then
10829 Object_Size bits are allocated. For example, for a normal enumeration type,
10830 with less than 256 elements, only 8 bits will be allocated for the object.
10831 Since this may be a surprise in terms of what C expects, GNAT will issue a
10832 warning in this situation. The warning can be suppressed by giving an explicit
10833 size clause specifying the desired size.
10834
10835 @item Convention C/Fortran and Boolean types
10836 In C, the usual convention for boolean values, that is values used for
10837 conditions, is that zero represents false, and nonzero values represent
10838 true.  In Ada, the normal convention is that two specific values, typically
10839 0/1, are used to represent false/true respectively.
10840
10841 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
10842 value represents true).
10843
10844 To accommodate the Fortran and C conventions, if a pragma Convention specifies
10845 C or Fortran convention for a derived Boolean, as in the following example:
10846
10847 @smallexample @c ada
10848    type C_Switch is new Boolean;
10849    pragma Convention (C, C_Switch);
10850 @end smallexample
10851
10852 @noindent
10853 then the GNAT generated code will treat any nonzero value as true.  For truth
10854 values generated by GNAT, the conventional value 1 will be used for True, but
10855 when one of these values is read, any nonzero value is treated as True.
10856
10857 @item Access types on OpenVMS
10858 For 64-bit OpenVMS systems, access types (other than those for unconstrained
10859 arrays) are 64-bits long. An exception to this rule is for the case of
10860 C-convention access types where there is no explicit size clause present (or
10861 inherited for derived types). In this case, GNAT chooses to make these
10862 pointers 32-bits, which provides an easier path for migration of 32-bit legacy
10863 code. size clause specifying 64-bits must be used to obtain a 64-bit pointer.
10864
10865 @end itemize
10866
10867 @node Determining the Representations chosen by GNAT
10868 @section Determining the Representations chosen by GNAT
10869 @cindex Representation, determination of
10870 @cindex @option{-gnatR} switch
10871
10872 @noindent
10873 Although the descriptions in this section are intended to be complete, it is
10874 often easier to simply experiment to see what GNAT accepts and what the
10875 effect is on the layout of types and objects.
10876
10877 As required by the Ada RM, if a representation clause is not accepted, then
10878 it must be rejected as illegal by the compiler.  However, when a
10879 representation clause or pragma is accepted, there can still be questions
10880 of what the compiler actually does.  For example, if a partial record
10881 representation clause specifies the location of some components and not
10882 others, then where are the non-specified components placed? Or if pragma
10883 @code{Pack} is used on a record, then exactly where are the resulting
10884 fields placed? The section on pragma @code{Pack} in this chapter can be
10885 used to answer the second question, but it is often easier to just see
10886 what the compiler does.
10887
10888 For this purpose, GNAT provides the option @option{-gnatR}.  If you compile
10889 with this option, then the compiler will output information on the actual
10890 representations chosen, in a format similar to source representation
10891 clauses.  For example, if we compile the package:
10892
10893 @smallexample @c ada
10894 package q is
10895    type r (x : boolean) is tagged record
10896       case x is
10897          when True => S : String (1 .. 100);
10898          when False => null;
10899       end case;
10900    end record;
10901
10902    type r2 is new r (false) with record
10903       y2 : integer;
10904    end record;
10905
10906    for r2 use record
10907       y2 at 16 range 0 .. 31;
10908    end record;
10909
10910    type x is record
10911       y : character;
10912    end record;
10913
10914    type x1 is array (1 .. 10) of x;
10915    for x1'component_size use 11;
10916
10917    type ia is access integer;
10918
10919    type Rb1 is array (1 .. 13) of Boolean;
10920    pragma Pack (rb1);
10921
10922    type Rb2 is array (1 .. 65) of Boolean;
10923    pragma Pack (rb2);
10924
10925    type x2 is record
10926       l1 : Boolean;
10927       l2 : Duration;
10928       l3 : Float;
10929       l4 : Boolean;
10930       l5 : Rb1;
10931       l6 : Rb2;
10932    end record;
10933    pragma Pack (x2);
10934 end q;
10935 @end smallexample
10936
10937 @noindent
10938 using the switch @option{-gnatR} we obtain the following output:
10939
10940 @smallexample
10941 Representation information for unit q
10942 -------------------------------------
10943
10944 for r'Size use ??;
10945 for r'Alignment use 4;
10946 for r use record
10947    x    at 4 range  0 .. 7;
10948    _tag at 0 range  0 .. 31;
10949    s    at 5 range  0 .. 799;
10950 end record;
10951
10952 for r2'Size use 160;
10953 for r2'Alignment use 4;
10954 for r2 use record
10955    x       at  4 range  0 .. 7;
10956    _tag    at  0 range  0 .. 31;
10957    _parent at  0 range  0 .. 63;
10958    y2      at 16 range  0 .. 31;
10959 end record;
10960
10961 for x'Size use 8;
10962 for x'Alignment use 1;
10963 for x use record
10964    y at 0 range  0 .. 7;
10965 end record;
10966
10967 for x1'Size use 112;
10968 for x1'Alignment use 1;
10969 for x1'Component_Size use 11;
10970
10971 for rb1'Size use 13;
10972 for rb1'Alignment use 2;
10973 for rb1'Component_Size use 1;
10974
10975 for rb2'Size use 72;
10976 for rb2'Alignment use 1;
10977 for rb2'Component_Size use 1;
10978
10979 for x2'Size use 224;
10980 for x2'Alignment use 4;
10981 for x2 use record
10982    l1 at  0 range  0 .. 0;
10983    l2 at  0 range  1 .. 64;
10984    l3 at 12 range  0 .. 31;
10985    l4 at 16 range  0 .. 0;
10986    l5 at 16 range  1 .. 13;
10987    l6 at 18 range  0 .. 71;
10988 end record;
10989 @end smallexample
10990
10991 @noindent
10992 The Size values are actually the Object_Size, i.e.@: the default size that
10993 will be allocated for objects of the type.
10994 The ?? size for type r indicates that we have a variant record, and the
10995 actual size of objects will depend on the discriminant value.
10996
10997 The Alignment values show the actual alignment chosen by the compiler
10998 for each record or array type.
10999
11000 The record representation clause for type r shows where all fields
11001 are placed, including the compiler generated tag field (whose location
11002 cannot be controlled by the programmer).
11003
11004 The record representation clause for the type extension r2 shows all the
11005 fields present, including the parent field, which is a copy of the fields
11006 of the parent type of r2, i.e.@: r1.
11007
11008 The component size and size clauses for types rb1 and rb2 show
11009 the exact effect of pragma @code{Pack} on these arrays, and the record
11010 representation clause for type x2 shows how pragma @code{Pack} affects
11011 this record type.
11012
11013 In some cases, it may be useful to cut and paste the representation clauses
11014 generated by the compiler into the original source to fix and guarantee
11015 the actual representation to be used.
11016
11017 @node Standard Library Routines
11018 @chapter Standard Library Routines
11019
11020 @noindent
11021 The Ada Reference Manual contains in Annex A a full description of an
11022 extensive set of standard library routines that can be used in any Ada
11023 program, and which must be provided by all Ada compilers.  They are
11024 analogous to the standard C library used by C programs.
11025
11026 GNAT implements all of the facilities described in annex A, and for most
11027 purposes the description in the Ada Reference Manual, or appropriate Ada
11028 text book, will be sufficient for making use of these facilities.
11029
11030 In the case of the input-output facilities,
11031 @xref{The Implementation of Standard I/O},
11032 gives details on exactly how GNAT interfaces to the
11033 file system.  For the remaining packages, the Ada Reference Manual
11034 should be sufficient.  The following is a list of the packages included,
11035 together with a brief description of the functionality that is provided.
11036
11037 For completeness, references are included to other predefined library
11038 routines defined in other sections of the Ada Reference Manual (these are
11039 cross-indexed from Annex A).
11040
11041 @table @code
11042 @item Ada (A.2)
11043 This is a parent package for all the standard library packages.  It is
11044 usually included implicitly in your program, and itself contains no
11045 useful data or routines.
11046
11047 @item Ada.Calendar (9.6)
11048 @code{Calendar} provides time of day access, and routines for
11049 manipulating times and durations.
11050
11051 @item Ada.Characters (A.3.1)
11052 This is a dummy parent package that contains no useful entities
11053
11054 @item Ada.Characters.Handling (A.3.2)
11055 This package provides some basic character handling capabilities,
11056 including classification functions for classes of characters (e.g.@: test
11057 for letters, or digits).
11058
11059 @item Ada.Characters.Latin_1 (A.3.3)
11060 This package includes a complete set of definitions of the characters
11061 that appear in type CHARACTER@.  It is useful for writing programs that
11062 will run in international environments.  For example, if you want an
11063 upper case E with an acute accent in a string, it is often better to use
11064 the definition of @code{UC_E_Acute} in this package.  Then your program
11065 will print in an understandable manner even if your environment does not
11066 support these extended characters.
11067
11068 @item Ada.Command_Line (A.15)
11069 This package provides access to the command line parameters and the name
11070 of the current program (analogous to the use of @code{argc} and @code{argv}
11071 in C), and also allows the exit status for the program to be set in a
11072 system-independent manner.
11073
11074 @item Ada.Decimal (F.2)
11075 This package provides constants describing the range of decimal numbers
11076 implemented, and also a decimal divide routine (analogous to the COBOL
11077 verb DIVIDE @dots{} GIVING @dots{} REMAINDER @dots{})
11078
11079 @item Ada.Direct_IO (A.8.4)
11080 This package provides input-output using a model of a set of records of
11081 fixed-length, containing an arbitrary definite Ada type, indexed by an
11082 integer record number.
11083
11084 @item Ada.Dynamic_Priorities (D.5)
11085 This package allows the priorities of a task to be adjusted dynamically
11086 as the task is running.
11087
11088 @item Ada.Exceptions (11.4.1)
11089 This package provides additional information on exceptions, and also
11090 contains facilities for treating exceptions as data objects, and raising
11091 exceptions with associated messages.
11092
11093 @item Ada.Finalization (7.6)
11094 This package contains the declarations and subprograms to support the
11095 use of controlled types, providing for automatic initialization and
11096 finalization (analogous to the constructors and destructors of C++)
11097
11098 @item Ada.Interrupts (C.3.2)
11099 This package provides facilities for interfacing to interrupts, which
11100 includes the set of signals or conditions that can be raised and
11101 recognized as interrupts.
11102
11103 @item Ada.Interrupts.Names (C.3.2)
11104 This package provides the set of interrupt names (actually signal
11105 or condition names) that can be handled by GNAT@.
11106
11107 @item Ada.IO_Exceptions (A.13)
11108 This package defines the set of exceptions that can be raised by use of
11109 the standard IO packages.
11110
11111 @item Ada.Numerics
11112 This package contains some standard constants and exceptions used
11113 throughout the numerics packages.  Note that the constants pi and e are
11114 defined here, and it is better to use these definitions than rolling
11115 your own.
11116
11117 @item Ada.Numerics.Complex_Elementary_Functions
11118 Provides the implementation of standard elementary functions (such as
11119 log and trigonometric functions) operating on complex numbers using the
11120 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
11121 created by the package @code{Numerics.Complex_Types}.
11122
11123 @item Ada.Numerics.Complex_Types
11124 This is a predefined instantiation of
11125 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
11126 build the type @code{Complex} and @code{Imaginary}.
11127
11128 @item Ada.Numerics.Discrete_Random
11129 This package provides a random number generator suitable for generating
11130 random integer values from a specified range.
11131
11132 @item Ada.Numerics.Float_Random
11133 This package provides a random number generator suitable for generating
11134 uniformly distributed floating point values.
11135
11136 @item Ada.Numerics.Generic_Complex_Elementary_Functions
11137 This is a generic version of the package that provides the
11138 implementation of standard elementary functions (such as log and
11139 trigonometric functions) for an arbitrary complex type.
11140
11141 The following predefined instantiations of this package are provided:
11142
11143 @table @code
11144 @item Short_Float
11145 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
11146 @item Float
11147 @code{Ada.Numerics.Complex_Elementary_Functions}
11148 @item Long_Float
11149 @code{Ada.Numerics.
11150  Long_Complex_Elementary_Functions}
11151 @end table
11152
11153 @item Ada.Numerics.Generic_Complex_Types
11154 This is a generic package that allows the creation of complex types,
11155 with associated complex arithmetic operations.
11156
11157 The following predefined instantiations of this package exist
11158 @table @code
11159 @item Short_Float
11160 @code{Ada.Numerics.Short_Complex_Complex_Types}
11161 @item Float
11162 @code{Ada.Numerics.Complex_Complex_Types}
11163 @item Long_Float
11164 @code{Ada.Numerics.Long_Complex_Complex_Types}
11165 @end table
11166
11167 @item Ada.Numerics.Generic_Elementary_Functions
11168 This is a generic package that provides the implementation of standard
11169 elementary functions (such as log an trigonometric functions) for an
11170 arbitrary float type.
11171
11172 The following predefined instantiations of this package exist
11173
11174 @table @code
11175 @item Short_Float
11176 @code{Ada.Numerics.Short_Elementary_Functions}
11177 @item Float
11178 @code{Ada.Numerics.Elementary_Functions}
11179 @item Long_Float
11180 @code{Ada.Numerics.Long_Elementary_Functions}
11181 @end table
11182
11183 @item Ada.Real_Time (D.8)
11184 This package provides facilities similar to those of @code{Calendar}, but
11185 operating with a finer clock suitable for real time control. Note that
11186 annex D requires that there be no backward clock jumps, and GNAT generally
11187 guarantees this behavior, but of course if the external clock on which
11188 the GNAT runtime depends is deliberately reset by some external event,
11189 then such a backward jump may occur.
11190
11191 @item Ada.Sequential_IO (A.8.1)
11192 This package provides input-output facilities for sequential files,
11193 which can contain a sequence of values of a single type, which can be
11194 any Ada type, including indefinite (unconstrained) types.
11195
11196 @item Ada.Storage_IO (A.9)
11197 This package provides a facility for mapping arbitrary Ada types to and
11198 from a storage buffer.  It is primarily intended for the creation of new
11199 IO packages.
11200
11201 @item Ada.Streams (13.13.1)
11202 This is a generic package that provides the basic support for the
11203 concept of streams as used by the stream attributes (@code{Input},
11204 @code{Output}, @code{Read} and @code{Write}).
11205
11206 @item Ada.Streams.Stream_IO (A.12.1)
11207 This package is a specialization of the type @code{Streams} defined in
11208 package @code{Streams} together with a set of operations providing
11209 Stream_IO capability.  The Stream_IO model permits both random and
11210 sequential access to a file which can contain an arbitrary set of values
11211 of one or more Ada types.
11212
11213 @item Ada.Strings (A.4.1)
11214 This package provides some basic constants used by the string handling
11215 packages.
11216
11217 @item Ada.Strings.Bounded (A.4.4)
11218 This package provides facilities for handling variable length
11219 strings.  The bounded model requires a maximum length.  It is thus
11220 somewhat more limited than the unbounded model, but avoids the use of
11221 dynamic allocation or finalization.
11222
11223 @item Ada.Strings.Fixed (A.4.3)
11224 This package provides facilities for handling fixed length strings.
11225
11226 @item Ada.Strings.Maps (A.4.2)
11227 This package provides facilities for handling character mappings and
11228 arbitrarily defined subsets of characters.  For instance it is useful in
11229 defining specialized translation tables.
11230
11231 @item Ada.Strings.Maps.Constants (A.4.6)
11232 This package provides a standard set of predefined mappings and
11233 predefined character sets.  For example, the standard upper to lower case
11234 conversion table is found in this package.  Note that upper to lower case
11235 conversion is non-trivial if you want to take the entire set of
11236 characters, including extended characters like E with an acute accent,
11237 into account.  You should use the mappings in this package (rather than
11238 adding 32 yourself) to do case mappings.
11239
11240 @item Ada.Strings.Unbounded (A.4.5)
11241 This package provides facilities for handling variable length
11242 strings.  The unbounded model allows arbitrary length strings, but
11243 requires the use of dynamic allocation and finalization.
11244
11245 @item Ada.Strings.Wide_Bounded (A.4.7)
11246 @itemx Ada.Strings.Wide_Fixed (A.4.7)
11247 @itemx Ada.Strings.Wide_Maps (A.4.7)
11248 @itemx Ada.Strings.Wide_Maps.Constants (A.4.7)
11249 @itemx Ada.Strings.Wide_Unbounded (A.4.7)
11250 These packages provide analogous capabilities to the corresponding
11251 packages without @samp{Wide_} in the name, but operate with the types
11252 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
11253 and @code{Character}.
11254
11255 @item Ada.Strings.Wide_Wide_Bounded (A.4.7)
11256 @itemx Ada.Strings.Wide_Wide_Fixed (A.4.7)
11257 @itemx Ada.Strings.Wide_Wide_Maps (A.4.7)
11258 @itemx Ada.Strings.Wide_Wide_Maps.Constants (A.4.7)
11259 @itemx Ada.Strings.Wide_Wide_Unbounded (A.4.7)
11260 These packages provide analogous capabilities to the corresponding
11261 packages without @samp{Wide_} in the name, but operate with the types
11262 @code{Wide_Wide_String} and @code{Wide_Wide_Character} instead
11263 of @code{String} and @code{Character}.
11264
11265 @item Ada.Synchronous_Task_Control (D.10)
11266 This package provides some standard facilities for controlling task
11267 communication in a synchronous manner.
11268
11269 @item Ada.Tags
11270 This package contains definitions for manipulation of the tags of tagged
11271 values.
11272
11273 @item Ada.Task_Attributes
11274 This package provides the capability of associating arbitrary
11275 task-specific data with separate tasks.
11276
11277 @item Ada.Text_IO
11278 This package provides basic text input-output capabilities for
11279 character, string and numeric data.  The subpackages of this
11280 package are listed next.
11281
11282 @item Ada.Text_IO.Decimal_IO
11283 Provides input-output facilities for decimal fixed-point types
11284
11285 @item Ada.Text_IO.Enumeration_IO
11286 Provides input-output facilities for enumeration types.
11287
11288 @item Ada.Text_IO.Fixed_IO
11289 Provides input-output facilities for ordinary fixed-point types.
11290
11291 @item Ada.Text_IO.Float_IO
11292 Provides input-output facilities for float types.  The following
11293 predefined instantiations of this generic package are available:
11294
11295 @table @code
11296 @item Short_Float
11297 @code{Short_Float_Text_IO}
11298 @item Float
11299 @code{Float_Text_IO}
11300 @item Long_Float
11301 @code{Long_Float_Text_IO}
11302 @end table
11303
11304 @item Ada.Text_IO.Integer_IO
11305 Provides input-output facilities for integer types.  The following
11306 predefined instantiations of this generic package are available:
11307
11308 @table @code
11309 @item Short_Short_Integer
11310 @code{Ada.Short_Short_Integer_Text_IO}
11311 @item Short_Integer
11312 @code{Ada.Short_Integer_Text_IO}
11313 @item Integer
11314 @code{Ada.Integer_Text_IO}
11315 @item Long_Integer
11316 @code{Ada.Long_Integer_Text_IO}
11317 @item Long_Long_Integer
11318 @code{Ada.Long_Long_Integer_Text_IO}
11319 @end table
11320
11321 @item Ada.Text_IO.Modular_IO
11322 Provides input-output facilities for modular (unsigned) types
11323
11324 @item Ada.Text_IO.Complex_IO (G.1.3)
11325 This package provides basic text input-output capabilities for complex
11326 data.
11327
11328 @item Ada.Text_IO.Editing (F.3.3)
11329 This package contains routines for edited output, analogous to the use
11330 of pictures in COBOL@.  The picture formats used by this package are a
11331 close copy of the facility in COBOL@.
11332
11333 @item Ada.Text_IO.Text_Streams (A.12.2)
11334 This package provides a facility that allows Text_IO files to be treated
11335 as streams, so that the stream attributes can be used for writing
11336 arbitrary data, including binary data, to Text_IO files.
11337
11338 @item Ada.Unchecked_Conversion (13.9)
11339 This generic package allows arbitrary conversion from one type to
11340 another of the same size, providing for breaking the type safety in
11341 special circumstances.
11342
11343 If the types have the same Size (more accurately the same Value_Size),
11344 then the effect is simply to transfer the bits from the source to the
11345 target type without any modification.  This usage is well defined, and
11346 for simple types whose representation is typically the same across
11347 all implementations, gives a portable method of performing such
11348 conversions.
11349
11350 If the types do not have the same size, then the result is implementation
11351 defined, and thus may be non-portable.  The following describes how GNAT
11352 handles such unchecked conversion cases.
11353
11354 If the types are of different sizes, and are both discrete types, then
11355 the effect is of a normal type conversion without any constraint checking.
11356 In particular if the result type has a larger size, the result will be
11357 zero or sign extended.  If the result type has a smaller size, the result
11358 will be truncated by ignoring high order bits.
11359
11360 If the types are of different sizes, and are not both discrete types,
11361 then the conversion works as though pointers were created to the source
11362 and target, and the pointer value is converted.  The effect is that bits
11363 are copied from successive low order storage units and bits of the source
11364 up to the length of the target type.
11365
11366 A warning is issued if the lengths differ, since the effect in this
11367 case is implementation dependent, and the above behavior may not match
11368 that of some other compiler.
11369
11370 A pointer to one type may be converted to a pointer to another type using
11371 unchecked conversion.  The only case in which the effect is undefined is
11372 when one or both pointers are pointers to unconstrained array types.  In
11373 this case, the bounds information may get incorrectly transferred, and in
11374 particular, GNAT uses double size pointers for such types, and it is
11375 meaningless to convert between such pointer types.  GNAT will issue a
11376 warning if the alignment of the target designated type is more strict
11377 than the alignment of the source designated type (since the result may
11378 be unaligned in this case).
11379
11380 A pointer other than a pointer to an unconstrained array type may be
11381 converted to and from System.Address.  Such usage is common in Ada 83
11382 programs, but note that Ada.Address_To_Access_Conversions is the
11383 preferred method of performing such conversions in Ada 95 and Ada 2005.
11384 Neither
11385 unchecked conversion nor Ada.Address_To_Access_Conversions should be
11386 used in conjunction with pointers to unconstrained objects, since
11387 the bounds information cannot be handled correctly in this case.
11388
11389 @item Ada.Unchecked_Deallocation (13.11.2)
11390 This generic package allows explicit freeing of storage previously
11391 allocated by use of an allocator.
11392
11393 @item Ada.Wide_Text_IO (A.11)
11394 This package is similar to @code{Ada.Text_IO}, except that the external
11395 file supports wide character representations, and the internal types are
11396 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
11397 and @code{String}.  It contains generic subpackages listed next.
11398
11399 @item Ada.Wide_Text_IO.Decimal_IO
11400 Provides input-output facilities for decimal fixed-point types
11401
11402 @item Ada.Wide_Text_IO.Enumeration_IO
11403 Provides input-output facilities for enumeration types.
11404
11405 @item Ada.Wide_Text_IO.Fixed_IO
11406 Provides input-output facilities for ordinary fixed-point types.
11407
11408 @item Ada.Wide_Text_IO.Float_IO
11409 Provides input-output facilities for float types.  The following
11410 predefined instantiations of this generic package are available:
11411
11412 @table @code
11413 @item Short_Float
11414 @code{Short_Float_Wide_Text_IO}
11415 @item Float
11416 @code{Float_Wide_Text_IO}
11417 @item Long_Float
11418 @code{Long_Float_Wide_Text_IO}
11419 @end table
11420
11421 @item Ada.Wide_Text_IO.Integer_IO
11422 Provides input-output facilities for integer types.  The following
11423 predefined instantiations of this generic package are available:
11424
11425 @table @code
11426 @item Short_Short_Integer
11427 @code{Ada.Short_Short_Integer_Wide_Text_IO}
11428 @item Short_Integer
11429 @code{Ada.Short_Integer_Wide_Text_IO}
11430 @item Integer
11431 @code{Ada.Integer_Wide_Text_IO}
11432 @item Long_Integer
11433 @code{Ada.Long_Integer_Wide_Text_IO}
11434 @item Long_Long_Integer
11435 @code{Ada.Long_Long_Integer_Wide_Text_IO}
11436 @end table
11437
11438 @item Ada.Wide_Text_IO.Modular_IO
11439 Provides input-output facilities for modular (unsigned) types
11440
11441 @item Ada.Wide_Text_IO.Complex_IO (G.1.3)
11442 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
11443 external file supports wide character representations.
11444
11445 @item Ada.Wide_Text_IO.Editing (F.3.4)
11446 This package is similar to @code{Ada.Text_IO.Editing}, except that the
11447 types are @code{Wide_Character} and @code{Wide_String} instead of
11448 @code{Character} and @code{String}.
11449
11450 @item Ada.Wide_Text_IO.Streams (A.12.3)
11451 This package is similar to @code{Ada.Text_IO.Streams}, except that the
11452 types are @code{Wide_Character} and @code{Wide_String} instead of
11453 @code{Character} and @code{String}.
11454
11455 @item Ada.Wide_Wide_Text_IO (A.11)
11456 This package is similar to @code{Ada.Text_IO}, except that the external
11457 file supports wide character representations, and the internal types are
11458 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
11459 and @code{String}.  It contains generic subpackages listed next.
11460
11461 @item Ada.Wide_Wide_Text_IO.Decimal_IO
11462 Provides input-output facilities for decimal fixed-point types
11463
11464 @item Ada.Wide_Wide_Text_IO.Enumeration_IO
11465 Provides input-output facilities for enumeration types.
11466
11467 @item Ada.Wide_Wide_Text_IO.Fixed_IO
11468 Provides input-output facilities for ordinary fixed-point types.
11469
11470 @item Ada.Wide_Wide_Text_IO.Float_IO
11471 Provides input-output facilities for float types.  The following
11472 predefined instantiations of this generic package are available:
11473
11474 @table @code
11475 @item Short_Float
11476 @code{Short_Float_Wide_Wide_Text_IO}
11477 @item Float
11478 @code{Float_Wide_Wide_Text_IO}
11479 @item Long_Float
11480 @code{Long_Float_Wide_Wide_Text_IO}
11481 @end table
11482
11483 @item Ada.Wide_Wide_Text_IO.Integer_IO
11484 Provides input-output facilities for integer types.  The following
11485 predefined instantiations of this generic package are available:
11486
11487 @table @code
11488 @item Short_Short_Integer
11489 @code{Ada.Short_Short_Integer_Wide_Wide_Text_IO}
11490 @item Short_Integer
11491 @code{Ada.Short_Integer_Wide_Wide_Text_IO}
11492 @item Integer
11493 @code{Ada.Integer_Wide_Wide_Text_IO}
11494 @item Long_Integer
11495 @code{Ada.Long_Integer_Wide_Wide_Text_IO}
11496 @item Long_Long_Integer
11497 @code{Ada.Long_Long_Integer_Wide_Wide_Text_IO}
11498 @end table
11499
11500 @item Ada.Wide_Wide_Text_IO.Modular_IO
11501 Provides input-output facilities for modular (unsigned) types
11502
11503 @item Ada.Wide_Wide_Text_IO.Complex_IO (G.1.3)
11504 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
11505 external file supports wide character representations.
11506
11507 @item Ada.Wide_Wide_Text_IO.Editing (F.3.4)
11508 This package is similar to @code{Ada.Text_IO.Editing}, except that the
11509 types are @code{Wide_Character} and @code{Wide_String} instead of
11510 @code{Character} and @code{String}.
11511
11512 @item Ada.Wide_Wide_Text_IO.Streams (A.12.3)
11513 This package is similar to @code{Ada.Text_IO.Streams}, except that the
11514 types are @code{Wide_Character} and @code{Wide_String} instead of
11515 @code{Character} and @code{String}.
11516 @end table
11517
11518
11519
11520 @node The Implementation of Standard I/O
11521 @chapter The Implementation of Standard I/O
11522
11523 @noindent
11524 GNAT implements all the required input-output facilities described in
11525 A.6 through A.14.  These sections of the Ada Reference Manual describe the
11526 required behavior of these packages from the Ada point of view, and if
11527 you are writing a portable Ada program that does not need to know the
11528 exact manner in which Ada maps to the outside world when it comes to
11529 reading or writing external files, then you do not need to read this
11530 chapter.  As long as your files are all regular files (not pipes or
11531 devices), and as long as you write and read the files only from Ada, the
11532 description in the Ada Reference Manual is sufficient.
11533
11534 However, if you want to do input-output to pipes or other devices, such
11535 as the keyboard or screen, or if the files you are dealing with are
11536 either generated by some other language, or to be read by some other
11537 language, then you need to know more about the details of how the GNAT
11538 implementation of these input-output facilities behaves.
11539
11540 In this chapter we give a detailed description of exactly how GNAT
11541 interfaces to the file system.  As always, the sources of the system are
11542 available to you for answering questions at an even more detailed level,
11543 but for most purposes the information in this chapter will suffice.
11544
11545 Another reason that you may need to know more about how input-output is
11546 implemented arises when you have a program written in mixed languages
11547 where, for example, files are shared between the C and Ada sections of
11548 the same program.  GNAT provides some additional facilities, in the form
11549 of additional child library packages, that facilitate this sharing, and
11550 these additional facilities are also described in this chapter.
11551
11552 @menu
11553 * Standard I/O Packages::
11554 * FORM Strings::
11555 * Direct_IO::
11556 * Sequential_IO::
11557 * Text_IO::
11558 * Wide_Text_IO::
11559 * Wide_Wide_Text_IO::
11560 * Stream_IO::
11561 * Shared Files::
11562 * Filenames encoding::
11563 * Open Modes::
11564 * Operations on C Streams::
11565 * Interfacing to C Streams::
11566 @end menu
11567
11568 @node Standard I/O Packages
11569 @section Standard I/O Packages
11570
11571 @noindent
11572 The Standard I/O packages described in Annex A for
11573
11574 @itemize @bullet
11575 @item
11576 Ada.Text_IO
11577 @item
11578 Ada.Text_IO.Complex_IO
11579 @item
11580 Ada.Text_IO.Text_Streams
11581 @item
11582 Ada.Wide_Text_IO
11583 @item
11584 Ada.Wide_Text_IO.Complex_IO
11585 @item
11586 Ada.Wide_Text_IO.Text_Streams
11587 @item
11588 Ada.Wide_Wide_Text_IO
11589 @item
11590 Ada.Wide_Wide_Text_IO.Complex_IO
11591 @item
11592 Ada.Wide_Wide_Text_IO.Text_Streams
11593 @item
11594 Ada.Stream_IO
11595 @item
11596 Ada.Sequential_IO
11597 @item
11598 Ada.Direct_IO
11599 @end itemize
11600
11601 @noindent
11602 are implemented using the C
11603 library streams facility; where
11604
11605 @itemize @bullet
11606 @item
11607 All files are opened using @code{fopen}.
11608 @item
11609 All input/output operations use @code{fread}/@code{fwrite}.
11610 @end itemize
11611
11612 @noindent
11613 There is no internal buffering of any kind at the Ada library level. The only
11614 buffering is that provided at the system level in the implementation of the
11615 library routines that support streams. This facilitates shared use of these
11616 streams by mixed language programs. Note though that system level buffering is
11617 explicitly enabled at elaboration of the standard I/O packages and that can
11618 have an impact on mixed language programs, in particular those using I/O before
11619 calling the Ada elaboration routine (e.g. adainit). It is recommended to call
11620 the Ada elaboration routine before performing any I/O or when impractical,
11621 flush the common I/O streams and in particular Standard_Output before
11622 elaborating the Ada code.
11623
11624 @node FORM Strings
11625 @section FORM Strings
11626
11627 @noindent
11628 The format of a FORM string in GNAT is:
11629
11630 @smallexample
11631 "keyword=value,keyword=value,@dots{},keyword=value"
11632 @end smallexample
11633
11634 @noindent
11635 where letters may be in upper or lower case, and there are no spaces
11636 between values.  The order of the entries is not important.  Currently
11637 there are two keywords defined.
11638
11639 @smallexample
11640 SHARED=[YES|NO]
11641 WCEM=[n|h|u|s|e|8|b]
11642 @end smallexample
11643
11644 @noindent
11645 The use of these parameters is described later in this section.
11646
11647 @node Direct_IO
11648 @section Direct_IO
11649
11650 @noindent
11651 Direct_IO can only be instantiated for definite types.  This is a
11652 restriction of the Ada language, which means that the records are fixed
11653 length (the length being determined by @code{@var{type}'Size}, rounded
11654 up to the next storage unit boundary if necessary).
11655
11656 The records of a Direct_IO file are simply written to the file in index
11657 sequence, with the first record starting at offset zero, and subsequent
11658 records following.  There is no control information of any kind.  For
11659 example, if 32-bit integers are being written, each record takes
11660 4-bytes, so the record at index @var{K} starts at offset
11661 (@var{K}@minus{}1)*4.
11662
11663 There is no limit on the size of Direct_IO files, they are expanded as
11664 necessary to accommodate whatever records are written to the file.
11665
11666 @node Sequential_IO
11667 @section Sequential_IO
11668
11669 @noindent
11670 Sequential_IO may be instantiated with either a definite (constrained)
11671 or indefinite (unconstrained) type.
11672
11673 For the definite type case, the elements written to the file are simply
11674 the memory images of the data values with no control information of any
11675 kind.  The resulting file should be read using the same type, no validity
11676 checking is performed on input.
11677
11678 For the indefinite type case, the elements written consist of two
11679 parts.  First is the size of the data item, written as the memory image
11680 of a @code{Interfaces.C.size_t} value, followed by the memory image of
11681 the data value.  The resulting file can only be read using the same
11682 (unconstrained) type.  Normal assignment checks are performed on these
11683 read operations, and if these checks fail, @code{Data_Error} is
11684 raised.  In particular, in the array case, the lengths must match, and in
11685 the variant record case, if the variable for a particular read operation
11686 is constrained, the discriminants must match.
11687
11688 Note that it is not possible to use Sequential_IO to write variable
11689 length array items, and then read the data back into different length
11690 arrays.  For example, the following will raise @code{Data_Error}:
11691
11692 @smallexample @c ada
11693  package IO is new Sequential_IO (String);
11694  F : IO.File_Type;
11695  S : String (1..4);
11696  @dots{}
11697  IO.Create (F)
11698  IO.Write (F, "hello!")
11699  IO.Reset (F, Mode=>In_File);
11700  IO.Read (F, S);
11701  Put_Line (S);
11702
11703 @end smallexample
11704
11705 @noindent
11706 On some Ada implementations, this will print @code{hell}, but the program is
11707 clearly incorrect, since there is only one element in the file, and that
11708 element is the string @code{hello!}.
11709
11710 In Ada 95 and Ada 2005, this kind of behavior can be legitimately achieved
11711 using Stream_IO, and this is the preferred mechanism.  In particular, the
11712 above program fragment rewritten to use Stream_IO will work correctly.
11713
11714 @node Text_IO
11715 @section Text_IO
11716
11717 @noindent
11718 Text_IO files consist of a stream of characters containing the following
11719 special control characters:
11720
11721 @smallexample
11722 LF (line feed, 16#0A#) Line Mark
11723 FF (form feed, 16#0C#) Page Mark
11724 @end smallexample
11725
11726 @noindent
11727 A canonical Text_IO file is defined as one in which the following
11728 conditions are met:
11729
11730 @itemize @bullet
11731 @item
11732 The character @code{LF} is used only as a line mark, i.e.@: to mark the end
11733 of the line.
11734
11735 @item
11736 The character @code{FF} is used only as a page mark, i.e.@: to mark the
11737 end of a page and consequently can appear only immediately following a
11738 @code{LF} (line mark) character.
11739
11740 @item
11741 The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
11742 (line mark, page mark).  In the former case, the page mark is implicitly
11743 assumed to be present.
11744 @end itemize
11745
11746 @noindent
11747 A file written using Text_IO will be in canonical form provided that no
11748 explicit @code{LF} or @code{FF} characters are written using @code{Put}
11749 or @code{Put_Line}.  There will be no @code{FF} character at the end of
11750 the file unless an explicit @code{New_Page} operation was performed
11751 before closing the file.
11752
11753 A canonical Text_IO file that is a regular file (i.e., not a device or a
11754 pipe) can be read using any of the routines in Text_IO@.  The
11755 semantics in this case will be exactly as defined in the Ada Reference
11756 Manual, and all the routines in Text_IO are fully implemented.
11757
11758 A text file that does not meet the requirements for a canonical Text_IO
11759 file has one of the following:
11760
11761 @itemize @bullet
11762 @item
11763 The file contains @code{FF} characters not immediately following a
11764 @code{LF} character.
11765
11766 @item
11767 The file contains @code{LF} or @code{FF} characters written by
11768 @code{Put} or @code{Put_Line}, which are not logically considered to be
11769 line marks or page marks.
11770
11771 @item
11772 The file ends in a character other than @code{LF} or @code{FF},
11773 i.e.@: there is no explicit line mark or page mark at the end of the file.
11774 @end itemize
11775
11776 @noindent
11777 Text_IO can be used to read such non-standard text files but subprograms
11778 to do with line or page numbers do not have defined meanings.  In
11779 particular, a @code{FF} character that does not follow a @code{LF}
11780 character may or may not be treated as a page mark from the point of
11781 view of page and line numbering.  Every @code{LF} character is considered
11782 to end a line, and there is an implied @code{LF} character at the end of
11783 the file.
11784
11785 @menu
11786 * Text_IO Stream Pointer Positioning::
11787 * Text_IO Reading and Writing Non-Regular Files::
11788 * Get_Immediate::
11789 * Treating Text_IO Files as Streams::
11790 * Text_IO Extensions::
11791 * Text_IO Facilities for Unbounded Strings::
11792 @end menu
11793
11794 @node Text_IO Stream Pointer Positioning
11795 @subsection Stream Pointer Positioning
11796
11797 @noindent
11798 @code{Ada.Text_IO} has a definition of current position for a file that
11799 is being read.  No internal buffering occurs in Text_IO, and usually the
11800 physical position in the stream used to implement the file corresponds
11801 to this logical position defined by Text_IO@.  There are two exceptions:
11802
11803 @itemize @bullet
11804 @item
11805 After a call to @code{End_Of_Page} that returns @code{True}, the stream
11806 is positioned past the @code{LF} (line mark) that precedes the page
11807 mark.  Text_IO maintains an internal flag so that subsequent read
11808 operations properly handle the logical position which is unchanged by
11809 the @code{End_Of_Page} call.
11810
11811 @item
11812 After a call to @code{End_Of_File} that returns @code{True}, if the
11813 Text_IO file was positioned before the line mark at the end of file
11814 before the call, then the logical position is unchanged, but the stream
11815 is physically positioned right at the end of file (past the line mark,
11816 and past a possible page mark following the line mark.  Again Text_IO
11817 maintains internal flags so that subsequent read operations properly
11818 handle the logical position.
11819 @end itemize
11820
11821 @noindent
11822 These discrepancies have no effect on the observable behavior of
11823 Text_IO, but if a single Ada stream is shared between a C program and
11824 Ada program, or shared (using @samp{shared=yes} in the form string)
11825 between two Ada files, then the difference may be observable in some
11826 situations.
11827
11828 @node Text_IO Reading and Writing Non-Regular Files
11829 @subsection Reading and Writing Non-Regular Files
11830
11831 @noindent
11832 A non-regular file is a device (such as a keyboard), or a pipe.  Text_IO
11833 can be used for reading and writing.  Writing is not affected and the
11834 sequence of characters output is identical to the normal file case, but
11835 for reading, the behavior of Text_IO is modified to avoid undesirable
11836 look-ahead as follows:
11837
11838 An input file that is not a regular file is considered to have no page
11839 marks.  Any @code{Ascii.FF} characters (the character normally used for a
11840 page mark) appearing in the file are considered to be data
11841 characters.  In particular:
11842
11843 @itemize @bullet
11844 @item
11845 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
11846 following a line mark.  If a page mark appears, it will be treated as a
11847 data character.
11848
11849 @item
11850 This avoids the need to wait for an extra character to be typed or
11851 entered from the pipe to complete one of these operations.
11852
11853 @item
11854 @code{End_Of_Page} always returns @code{False}
11855
11856 @item
11857 @code{End_Of_File} will return @code{False} if there is a page mark at
11858 the end of the file.
11859 @end itemize
11860
11861 @noindent
11862 Output to non-regular files is the same as for regular files.  Page marks
11863 may be written to non-regular files using @code{New_Page}, but as noted
11864 above they will not be treated as page marks on input if the output is
11865 piped to another Ada program.
11866
11867 Another important discrepancy when reading non-regular files is that the end
11868 of file indication is not ``sticky''.  If an end of file is entered, e.g.@: by
11869 pressing the @key{EOT} key,
11870 then end of file
11871 is signaled once (i.e.@: the test @code{End_Of_File}
11872 will yield @code{True}, or a read will
11873 raise @code{End_Error}), but then reading can resume
11874 to read data past that end of
11875 file indication, until another end of file indication is entered.
11876
11877 @node Get_Immediate
11878 @subsection Get_Immediate
11879 @cindex Get_Immediate
11880
11881 @noindent
11882 Get_Immediate returns the next character (including control characters)
11883 from the input file.  In particular, Get_Immediate will return LF or FF
11884 characters used as line marks or page marks.  Such operations leave the
11885 file positioned past the control character, and it is thus not treated
11886 as having its normal function.  This means that page, line and column
11887 counts after this kind of Get_Immediate call are set as though the mark
11888 did not occur.  In the case where a Get_Immediate leaves the file
11889 positioned between the line mark and page mark (which is not normally
11890 possible), it is undefined whether the FF character will be treated as a
11891 page mark.
11892
11893 @node Treating Text_IO Files as Streams
11894 @subsection Treating Text_IO Files as Streams
11895 @cindex Stream files
11896
11897 @noindent
11898 The package @code{Text_IO.Streams} allows a Text_IO file to be treated
11899 as a stream.  Data written to a Text_IO file in this stream mode is
11900 binary data.  If this binary data contains bytes 16#0A# (@code{LF}) or
11901 16#0C# (@code{FF}), the resulting file may have non-standard
11902 format.  Similarly if read operations are used to read from a Text_IO
11903 file treated as a stream, then @code{LF} and @code{FF} characters may be
11904 skipped and the effect is similar to that described above for
11905 @code{Get_Immediate}.
11906
11907 @node Text_IO Extensions
11908 @subsection Text_IO Extensions
11909 @cindex Text_IO extensions
11910
11911 @noindent
11912 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
11913 to the standard @code{Text_IO} package:
11914
11915 @itemize @bullet
11916 @item function File_Exists (Name : String) return Boolean;
11917 Determines if a file of the given name exists.
11918
11919 @item function Get_Line return String;
11920 Reads a string from the standard input file.  The value returned is exactly
11921 the length of the line that was read.
11922
11923 @item function Get_Line (File : Ada.Text_IO.File_Type) return String;
11924 Similar, except that the parameter File specifies the file from which
11925 the string is to be read.
11926
11927 @end itemize
11928
11929 @node Text_IO Facilities for Unbounded Strings
11930 @subsection Text_IO Facilities for Unbounded Strings
11931 @cindex Text_IO for unbounded strings
11932 @cindex Unbounded_String, Text_IO operations
11933
11934 @noindent
11935 The package @code{Ada.Strings.Unbounded.Text_IO}
11936 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
11937 subprograms useful for Text_IO operations on unbounded strings:
11938
11939 @itemize @bullet
11940
11941 @item function Get_Line (File : File_Type) return Unbounded_String;
11942 Reads a line from the specified file
11943 and returns the result as an unbounded string.
11944
11945 @item procedure Put (File : File_Type; U : Unbounded_String);
11946 Writes the value of the given unbounded string to the specified file
11947 Similar to the effect of
11948 @code{Put (To_String (U))} except that an extra copy is avoided.
11949
11950 @item procedure Put_Line (File : File_Type; U : Unbounded_String);
11951 Writes the value of the given unbounded string to the specified file,
11952 followed by a @code{New_Line}.
11953 Similar to the effect of @code{Put_Line (To_String (U))} except
11954 that an extra copy is avoided.
11955 @end itemize
11956
11957 @noindent
11958 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
11959 and is optional.  If the parameter is omitted, then the standard input or
11960 output file is referenced as appropriate.
11961
11962 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
11963 files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended
11964 @code{Wide_Text_IO} functionality for unbounded wide strings.
11965
11966 The package @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} in library
11967 files @file{a-szuzti.ads} and @file{a-szuzti.adb} provides similar extended
11968 @code{Wide_Wide_Text_IO} functionality for unbounded wide wide strings.
11969
11970 @node Wide_Text_IO
11971 @section Wide_Text_IO
11972
11973 @noindent
11974 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
11975 both input and output files may contain special sequences that represent
11976 wide character values.  The encoding scheme for a given file may be
11977 specified using a FORM parameter:
11978
11979 @smallexample
11980 WCEM=@var{x}
11981 @end smallexample
11982
11983 @noindent
11984 as part of the FORM string (WCEM = wide character encoding method),
11985 where @var{x} is one of the following characters
11986
11987 @table @samp
11988 @item h
11989 Hex ESC encoding
11990 @item u
11991 Upper half encoding
11992 @item s
11993 Shift-JIS encoding
11994 @item e
11995 EUC Encoding
11996 @item 8
11997 UTF-8 encoding
11998 @item b
11999 Brackets encoding
12000 @end table
12001
12002 @noindent
12003 The encoding methods match those that
12004 can be used in a source
12005 program, but there is no requirement that the encoding method used for
12006 the source program be the same as the encoding method used for files,
12007 and different files may use different encoding methods.
12008
12009 The default encoding method for the standard files, and for opened files
12010 for which no WCEM parameter is given in the FORM string matches the
12011 wide character encoding specified for the main program (the default
12012 being brackets encoding if no coding method was specified with -gnatW).
12013
12014 @table @asis
12015 @item Hex Coding
12016 In this encoding, a wide character is represented by a five character
12017 sequence:
12018
12019 @smallexample
12020 ESC a b c d
12021 @end smallexample
12022
12023 @noindent
12024 where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
12025 characters (using upper case letters) of the wide character code.  For
12026 example, ESC A345 is used to represent the wide character with code
12027 16#A345#.  This scheme is compatible with use of the full
12028 @code{Wide_Character} set.
12029
12030 @item Upper Half Coding
12031 The wide character with encoding 16#abcd#, where the upper bit is on
12032 (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
12033 16#cd#.  The second byte may never be a format control character, but is
12034 not required to be in the upper half.  This method can be also used for
12035 shift-JIS or EUC where the internal coding matches the external coding.
12036
12037 @item Shift JIS Coding
12038 A wide character is represented by a two character sequence 16#ab# and
12039 16#cd#, with the restrictions described for upper half encoding as
12040 described above.  The internal character code is the corresponding JIS
12041 character according to the standard algorithm for Shift-JIS
12042 conversion.  Only characters defined in the JIS code set table can be
12043 used with this encoding method.
12044
12045 @item EUC Coding
12046 A wide character is represented by a two character sequence 16#ab# and
12047 16#cd#, with both characters being in the upper half.  The internal
12048 character code is the corresponding JIS character according to the EUC
12049 encoding algorithm.  Only characters defined in the JIS code set table
12050 can be used with this encoding method.
12051
12052 @item UTF-8 Coding
12053 A wide character is represented using
12054 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
12055 10646-1/Am.2.  Depending on the character value, the representation
12056 is a one, two, or three byte sequence:
12057
12058 @smallexample
12059 16#0000#-16#007f#: 2#0xxxxxxx#
12060 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
12061 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
12062 @end smallexample
12063
12064 @noindent
12065 where the xxx bits correspond to the left-padded bits of the
12066 16-bit character value.  Note that all lower half ASCII characters
12067 are represented as ASCII bytes and all upper half characters and
12068 other wide characters are represented as sequences of upper-half
12069 (The full UTF-8 scheme allows for encoding 31-bit characters as
12070 6-byte sequences, but in this implementation, all UTF-8 sequences
12071 of four or more bytes length will raise a Constraint_Error, as
12072 will all invalid UTF-8 sequences.)
12073
12074 @item Brackets Coding
12075 In this encoding, a wide character is represented by the following eight
12076 character sequence:
12077
12078 @smallexample
12079 [ " a b c d " ]
12080 @end smallexample
12081
12082 @noindent
12083 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
12084 characters (using uppercase letters) of the wide character code.  For
12085 example, @code{["A345"]} is used to represent the wide character with code
12086 @code{16#A345#}.
12087 This scheme is compatible with use of the full Wide_Character set.
12088 On input, brackets coding can also be used for upper half characters,
12089 e.g.@: @code{["C1"]} for lower case a.  However, on output, brackets notation
12090 is only used for wide characters with a code greater than @code{16#FF#}.
12091
12092 Note that brackets coding is not normally used in the context of
12093 Wide_Text_IO or Wide_Wide_Text_IO, since it is really just designed as
12094 a portable way of encoding source files. In the context of Wide_Text_IO
12095 or Wide_Wide_Text_IO, it can only be used if the file does not contain
12096 any instance of the left bracket character other than to encode wide
12097 character values using the brackets encoding method. In practice it is
12098 expected that some standard wide character encoding method such
12099 as UTF-8 will be used for text input output.
12100
12101 If brackets notation is used, then any occurrence of a left bracket
12102 in the input file which is not the start of a valid wide character
12103 sequence will cause Constraint_Error to be raised. It is possible to
12104 encode a left bracket as ["5B"] and Wide_Text_IO and Wide_Wide_Text_IO
12105 input will interpret this as a left bracket.
12106
12107 However, when a left bracket is output, it will be output as a left bracket
12108 and not as ["5B"]. We make this decision because for normal use of
12109 Wide_Text_IO for outputting messages, it is unpleasant to clobber left
12110 brackets. For example, if we write:
12111
12112 @smallexample
12113    Put_Line ("Start of output [first run]");
12114 @end smallexample
12115
12116 @noindent
12117 we really do not want to have the left bracket in this message clobbered so
12118 that the output reads:
12119
12120 @smallexample
12121    Start of output ["5B"]first run]
12122 @end smallexample
12123
12124 @noindent
12125 In practice brackets encoding is reasonably useful for normal Put_Line use
12126 since we won't get confused between left brackets and wide character
12127 sequences in the output. But for input, or when files are written out
12128 and read back in, it really makes better sense to use one of the standard
12129 encoding methods such as UTF-8.
12130
12131 @end table
12132
12133 @noindent
12134 For the coding schemes other than UTF-8, Hex, or Brackets encoding,
12135 not all wide character
12136 values can be represented.  An attempt to output a character that cannot
12137 be represented using the encoding scheme for the file causes
12138 Constraint_Error to be raised.  An invalid wide character sequence on
12139 input also causes Constraint_Error to be raised.
12140
12141 @menu
12142 * Wide_Text_IO Stream Pointer Positioning::
12143 * Wide_Text_IO Reading and Writing Non-Regular Files::
12144 @end menu
12145
12146 @node Wide_Text_IO Stream Pointer Positioning
12147 @subsection Stream Pointer Positioning
12148
12149 @noindent
12150 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
12151 of stream pointer positioning (@pxref{Text_IO}).  There is one additional
12152 case:
12153
12154 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
12155 normal lower ASCII set (i.e.@: a character in the range:
12156
12157 @smallexample @c ada
12158 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
12159 @end smallexample
12160
12161 @noindent
12162 then although the logical position of the file pointer is unchanged by
12163 the @code{Look_Ahead} call, the stream is physically positioned past the
12164 wide character sequence.  Again this is to avoid the need for buffering
12165 or backup, and all @code{Wide_Text_IO} routines check the internal
12166 indication that this situation has occurred so that this is not visible
12167 to a normal program using @code{Wide_Text_IO}.  However, this discrepancy
12168 can be observed if the wide text file shares a stream with another file.
12169
12170 @node Wide_Text_IO Reading and Writing Non-Regular Files
12171 @subsection Reading and Writing Non-Regular Files
12172
12173 @noindent
12174 As in the case of Text_IO, when a non-regular file is read, it is
12175 assumed that the file contains no page marks (any form characters are
12176 treated as data characters), and @code{End_Of_Page} always returns
12177 @code{False}.  Similarly, the end of file indication is not sticky, so
12178 it is possible to read beyond an end of file.
12179
12180 @node Wide_Wide_Text_IO
12181 @section Wide_Wide_Text_IO
12182
12183 @noindent
12184 @code{Wide_Wide_Text_IO} is similar in most respects to Text_IO, except that
12185 both input and output files may contain special sequences that represent
12186 wide wide character values.  The encoding scheme for a given file may be
12187 specified using a FORM parameter:
12188
12189 @smallexample
12190 WCEM=@var{x}
12191 @end smallexample
12192
12193 @noindent
12194 as part of the FORM string (WCEM = wide character encoding method),
12195 where @var{x} is one of the following characters
12196
12197 @table @samp
12198 @item h
12199 Hex ESC encoding
12200 @item u
12201 Upper half encoding
12202 @item s
12203 Shift-JIS encoding
12204 @item e
12205 EUC Encoding
12206 @item 8
12207 UTF-8 encoding
12208 @item b
12209 Brackets encoding
12210 @end table
12211
12212 @noindent
12213 The encoding methods match those that
12214 can be used in a source
12215 program, but there is no requirement that the encoding method used for
12216 the source program be the same as the encoding method used for files,
12217 and different files may use different encoding methods.
12218
12219 The default encoding method for the standard files, and for opened files
12220 for which no WCEM parameter is given in the FORM string matches the
12221 wide character encoding specified for the main program (the default
12222 being brackets encoding if no coding method was specified with -gnatW).
12223
12224 @table @asis
12225
12226 @item UTF-8 Coding
12227 A wide character is represented using
12228 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
12229 10646-1/Am.2.  Depending on the character value, the representation
12230 is a one, two, three, or four byte sequence:
12231
12232 @smallexample
12233 16#000000#-16#00007f#: 2#0xxxxxxx#
12234 16#000080#-16#0007ff#: 2#110xxxxx# 2#10xxxxxx#
12235 16#000800#-16#00ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
12236 16#010000#-16#10ffff#: 2#11110xxx# 2#10xxxxxx# 2#10xxxxxx# 2#10xxxxxx#
12237 @end smallexample
12238
12239 @noindent
12240 where the xxx bits correspond to the left-padded bits of the
12241 21-bit character value.  Note that all lower half ASCII characters
12242 are represented as ASCII bytes and all upper half characters and
12243 other wide characters are represented as sequences of upper-half
12244 characters.
12245
12246 @item Brackets Coding
12247 In this encoding, a wide wide character is represented by the following eight
12248 character sequence if is in wide character range
12249
12250 @smallexample
12251 [ " a b c d " ]
12252 @end smallexample
12253
12254 and by the following ten character sequence if not
12255
12256 @smallexample
12257 [ " a b c d e f " ]
12258 @end smallexample
12259
12260 @noindent
12261 where @code{a}, @code{b}, @code{c}, @code{d}, @code{e}, and @code{f}
12262 are the four or six hexadecimal
12263 characters (using uppercase letters) of the wide wide character code.  For
12264 example, @code{["01A345"]} is used to represent the wide wide character
12265 with code @code{16#01A345#}.
12266
12267 This scheme is compatible with use of the full Wide_Wide_Character set.
12268 On input, brackets coding can also be used for upper half characters,
12269 e.g.@: @code{["C1"]} for lower case a.  However, on output, brackets notation
12270 is only used for wide characters with a code greater than @code{16#FF#}.
12271
12272 @end table
12273
12274 @noindent
12275 If is also possible to use the other Wide_Character encoding methods,
12276 such as Shift-JIS, but the other schemes cannot support the full range
12277 of wide wide characters.
12278 An attempt to output a character that cannot
12279 be represented using the encoding scheme for the file causes
12280 Constraint_Error to be raised.  An invalid wide character sequence on
12281 input also causes Constraint_Error to be raised.
12282
12283 @menu
12284 * Wide_Wide_Text_IO Stream Pointer Positioning::
12285 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
12286 @end menu
12287
12288 @node Wide_Wide_Text_IO Stream Pointer Positioning
12289 @subsection Stream Pointer Positioning
12290
12291 @noindent
12292 @code{Ada.Wide_Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
12293 of stream pointer positioning (@pxref{Text_IO}).  There is one additional
12294 case:
12295
12296 If @code{Ada.Wide_Wide_Text_IO.Look_Ahead} reads a character outside the
12297 normal lower ASCII set (i.e.@: a character in the range:
12298
12299 @smallexample @c ada
12300 Wide_Wide_Character'Val (16#0080#) .. Wide_Wide_Character'Val (16#10FFFF#)
12301 @end smallexample
12302
12303 @noindent
12304 then although the logical position of the file pointer is unchanged by
12305 the @code{Look_Ahead} call, the stream is physically positioned past the
12306 wide character sequence.  Again this is to avoid the need for buffering
12307 or backup, and all @code{Wide_Wide_Text_IO} routines check the internal
12308 indication that this situation has occurred so that this is not visible
12309 to a normal program using @code{Wide_Wide_Text_IO}.  However, this discrepancy
12310 can be observed if the wide text file shares a stream with another file.
12311
12312 @node Wide_Wide_Text_IO Reading and Writing Non-Regular Files
12313 @subsection Reading and Writing Non-Regular Files
12314
12315 @noindent
12316 As in the case of Text_IO, when a non-regular file is read, it is
12317 assumed that the file contains no page marks (any form characters are
12318 treated as data characters), and @code{End_Of_Page} always returns
12319 @code{False}.  Similarly, the end of file indication is not sticky, so
12320 it is possible to read beyond an end of file.
12321
12322 @node Stream_IO
12323 @section Stream_IO
12324
12325 @noindent
12326 A stream file is a sequence of bytes, where individual elements are
12327 written to the file as described in the Ada Reference Manual.  The type
12328 @code{Stream_Element} is simply a byte.  There are two ways to read or
12329 write a stream file.
12330
12331 @itemize @bullet
12332 @item
12333 The operations @code{Read} and @code{Write} directly read or write a
12334 sequence of stream elements with no control information.
12335
12336 @item
12337 The stream attributes applied to a stream file transfer data in the
12338 manner described for stream attributes.
12339 @end itemize
12340
12341 @node Shared Files
12342 @section Shared Files
12343
12344 @noindent
12345 Section A.14 of the Ada Reference Manual allows implementations to
12346 provide a wide variety of behavior if an attempt is made to access the
12347 same external file with two or more internal files.
12348
12349 To provide a full range of functionality, while at the same time
12350 minimizing the problems of portability caused by this implementation
12351 dependence, GNAT handles file sharing as follows:
12352
12353 @itemize @bullet
12354 @item
12355 In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
12356 to open two or more files with the same full name is considered an error
12357 and is not supported.  The exception @code{Use_Error} will be
12358 raised.  Note that a file that is not explicitly closed by the program
12359 remains open until the program terminates.
12360
12361 @item
12362 If the form parameter @samp{shared=no} appears in the form string, the
12363 file can be opened or created with its own separate stream identifier,
12364 regardless of whether other files sharing the same external file are
12365 opened.  The exact effect depends on how the C stream routines handle
12366 multiple accesses to the same external files using separate streams.
12367
12368 @item
12369 If the form parameter @samp{shared=yes} appears in the form string for
12370 each of two or more files opened using the same full name, the same
12371 stream is shared between these files, and the semantics are as described
12372 in Ada Reference Manual, Section A.14.
12373 @end itemize
12374
12375 @noindent
12376 When a program that opens multiple files with the same name is ported
12377 from another Ada compiler to GNAT, the effect will be that
12378 @code{Use_Error} is raised.
12379
12380 The documentation of the original compiler and the documentation of the
12381 program should then be examined to determine if file sharing was
12382 expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
12383 and @code{Create} calls as required.
12384
12385 When a program is ported from GNAT to some other Ada compiler, no
12386 special attention is required unless the @samp{shared=@var{xxx}} form
12387 parameter is used in the program.  In this case, you must examine the
12388 documentation of the new compiler to see if it supports the required
12389 file sharing semantics, and form strings modified appropriately.  Of
12390 course it may be the case that the program cannot be ported if the
12391 target compiler does not support the required functionality.  The best
12392 approach in writing portable code is to avoid file sharing (and hence
12393 the use of the @samp{shared=@var{xxx}} parameter in the form string)
12394 completely.
12395
12396 One common use of file sharing in Ada 83 is the use of instantiations of
12397 Sequential_IO on the same file with different types, to achieve
12398 heterogeneous input-output.  Although this approach will work in GNAT if
12399 @samp{shared=yes} is specified, it is preferable in Ada to use Stream_IO
12400 for this purpose (using the stream attributes)
12401
12402 @node Filenames encoding
12403 @section Filenames encoding
12404
12405 @noindent
12406 An encoding form parameter can be used to specify the filename
12407 encoding @samp{encoding=@var{xxx}}.
12408
12409 @itemize @bullet
12410 @item
12411 If the form parameter @samp{encoding=utf8} appears in the form string, the
12412 filename must be encoded in UTF-8.
12413
12414 @item
12415 If the form parameter @samp{encoding=8bits} appears in the form
12416 string, the filename must be a standard 8bits string.
12417 @end itemize
12418
12419 In the absence of a @samp{encoding=@var{xxx}} form parameter, the
12420 value UTF-8 is used. This encoding form parameter is only supported on
12421 the Windows platform. On the other Operating Systems the runtime is
12422 supporting UTF-8 natively.
12423
12424 @node Open Modes
12425 @section Open Modes
12426
12427 @noindent
12428 @code{Open} and @code{Create} calls result in a call to @code{fopen}
12429 using the mode shown in the following table:
12430
12431 @sp 2
12432 @center @code{Open} and @code{Create} Call Modes
12433 @smallexample
12434                                @b{OPEN }           @b{CREATE}
12435 Append_File                    "r+"             "w+"
12436 In_File                        "r"              "w+"
12437 Out_File (Direct_IO)           "r+"             "w"
12438 Out_File (all other cases)     "w"              "w"
12439 Inout_File                     "r+"             "w+"
12440 @end smallexample
12441
12442 @noindent
12443 If text file translation is required, then either @samp{b} or @samp{t}
12444 is added to the mode, depending on the setting of Text.  Text file
12445 translation refers to the mapping of CR/LF sequences in an external file
12446 to LF characters internally.  This mapping only occurs in DOS and
12447 DOS-like systems, and is not relevant to other systems.
12448
12449 A special case occurs with Stream_IO@.  As shown in the above table, the
12450 file is initially opened in @samp{r} or @samp{w} mode for the
12451 @code{In_File} and @code{Out_File} cases.  If a @code{Set_Mode} operation
12452 subsequently requires switching from reading to writing or vice-versa,
12453 then the file is reopened in @samp{r+} mode to permit the required operation.
12454
12455 @node Operations on C Streams
12456 @section Operations on C Streams
12457 The package @code{Interfaces.C_Streams} provides an Ada program with direct
12458 access to the C library functions for operations on C streams:
12459
12460 @smallexample @c adanocomment
12461 package Interfaces.C_Streams is
12462   -- Note: the reason we do not use the types that are in
12463   -- Interfaces.C is that we want to avoid dragging in the
12464   -- code in this unit if possible.
12465   subtype chars is System.Address;
12466   -- Pointer to null-terminated array of characters
12467   subtype FILEs is System.Address;
12468   -- Corresponds to the C type FILE*
12469   subtype voids is System.Address;
12470   -- Corresponds to the C type void*
12471   subtype int is Integer;
12472   subtype long is Long_Integer;
12473   -- Note: the above types are subtypes deliberately, and it
12474   -- is part of this spec that the above correspondences are
12475   -- guaranteed.  This means that it is legitimate to, for
12476   -- example, use Integer instead of int.  We provide these
12477   -- synonyms for clarity, but in some cases it may be
12478   -- convenient to use the underlying types (for example to
12479   -- avoid an unnecessary dependency of a spec on the spec
12480   -- of this unit).
12481   type size_t is mod 2 ** Standard'Address_Size;
12482   NULL_Stream : constant FILEs;
12483   -- Value returned (NULL in C) to indicate an
12484   -- fdopen/fopen/tmpfile error
12485   ----------------------------------
12486   -- Constants Defined in stdio.h --
12487   ----------------------------------
12488   EOF : constant int;
12489   -- Used by a number of routines to indicate error or
12490   -- end of file
12491   IOFBF : constant int;
12492   IOLBF : constant int;
12493   IONBF : constant int;
12494   -- Used to indicate buffering mode for setvbuf call
12495   SEEK_CUR : constant int;
12496   SEEK_END : constant int;
12497   SEEK_SET : constant int;
12498   -- Used to indicate origin for fseek call
12499   function stdin return FILEs;
12500   function stdout return FILEs;
12501   function stderr return FILEs;
12502   -- Streams associated with standard files
12503   --------------------------
12504   -- Standard C functions --
12505   --------------------------
12506   -- The functions selected below are ones that are
12507   -- available in DOS, OS/2, UNIX and Xenix (but not
12508   -- necessarily in ANSI C).  These are very thin interfaces
12509   -- which copy exactly the C headers.  For more
12510   -- documentation on these functions, see the Microsoft C
12511   -- "Run-Time Library Reference" (Microsoft Press, 1990,
12512   -- ISBN 1-55615-225-6), which includes useful information
12513   -- on system compatibility.
12514   procedure clearerr (stream : FILEs);
12515   function fclose (stream : FILEs) return int;
12516   function fdopen (handle : int; mode : chars) return FILEs;
12517   function feof (stream : FILEs) return int;
12518   function ferror (stream : FILEs) return int;
12519   function fflush (stream : FILEs) return int;
12520   function fgetc (stream : FILEs) return int;
12521   function fgets (strng : chars; n : int; stream : FILEs)
12522       return chars;
12523   function fileno (stream : FILEs) return int;
12524   function fopen (filename : chars; Mode : chars)
12525       return FILEs;
12526   -- Note: to maintain target independence, use
12527   -- text_translation_required, a boolean variable defined in
12528   -- a-sysdep.c to deal with the target dependent text
12529   -- translation requirement.  If this variable is set,
12530   -- then  b/t should be appended to the standard mode
12531   -- argument to set the text translation mode off or on
12532   -- as required.
12533   function fputc (C : int; stream : FILEs) return int;
12534   function fputs (Strng : chars; Stream : FILEs) return int;
12535   function fread
12536      (buffer : voids;
12537       size : size_t;
12538       count : size_t;
12539       stream : FILEs)
12540       return size_t;
12541   function freopen
12542      (filename : chars;
12543       mode : chars;
12544       stream : FILEs)
12545       return FILEs;
12546   function fseek
12547      (stream : FILEs;
12548       offset : long;
12549       origin : int)
12550       return int;
12551   function ftell (stream : FILEs) return long;
12552   function fwrite
12553      (buffer : voids;
12554       size : size_t;
12555       count : size_t;
12556       stream : FILEs)
12557       return size_t;
12558   function isatty (handle : int) return int;
12559   procedure mktemp (template : chars);
12560   -- The return value (which is just a pointer to template)
12561   -- is discarded
12562   procedure rewind (stream : FILEs);
12563   function rmtmp return int;
12564   function setvbuf
12565      (stream : FILEs;
12566       buffer : chars;
12567       mode : int;
12568       size : size_t)
12569       return int;
12570
12571   function tmpfile return FILEs;
12572   function ungetc (c : int; stream : FILEs) return int;
12573   function unlink (filename : chars) return int;
12574   ---------------------
12575   -- Extra functions --
12576   ---------------------
12577   -- These functions supply slightly thicker bindings than
12578   -- those above.  They are derived from functions in the
12579   -- C Run-Time Library, but may do a bit more work than
12580   -- just directly calling one of the Library functions.
12581   function is_regular_file (handle : int) return int;
12582   -- Tests if given handle is for a regular file (result 1)
12583   -- or for a non-regular file (pipe or device, result 0).
12584   ---------------------------------
12585   -- Control of Text/Binary Mode --
12586   ---------------------------------
12587   -- If text_translation_required is true, then the following
12588   -- functions may be used to dynamically switch a file from
12589   -- binary to text mode or vice versa.  These functions have
12590   -- no effect if text_translation_required is false (i.e.  in
12591   -- normal UNIX mode).  Use fileno to get a stream handle.
12592   procedure set_binary_mode (handle : int);
12593   procedure set_text_mode (handle : int);
12594   ----------------------------
12595   -- Full Path Name support --
12596   ----------------------------
12597   procedure full_name (nam : chars; buffer : chars);
12598   -- Given a NUL terminated string representing a file
12599   -- name, returns in buffer a NUL terminated string
12600   -- representing the full path name for the file name.
12601   -- On systems where it is relevant the   drive is also
12602   -- part of the full path name.  It is the responsibility
12603   -- of the caller to pass an actual parameter for buffer
12604   -- that is big enough for any full path name.  Use
12605   -- max_path_len given below as the size of buffer.
12606   max_path_len : integer;
12607   -- Maximum length of an allowable full path name on the
12608   -- system, including a terminating NUL character.
12609 end Interfaces.C_Streams;
12610 @end smallexample
12611
12612 @node Interfacing to C Streams
12613 @section Interfacing to C Streams
12614
12615 @noindent
12616 The packages in this section permit interfacing Ada files to C Stream
12617 operations.
12618
12619 @smallexample @c ada
12620  with Interfaces.C_Streams;
12621  package Ada.Sequential_IO.C_Streams is
12622     function C_Stream (F : File_Type)
12623        return Interfaces.C_Streams.FILEs;
12624     procedure Open
12625       (File : in out File_Type;
12626        Mode : in File_Mode;
12627        C_Stream : in Interfaces.C_Streams.FILEs;
12628        Form : in String := "");
12629  end Ada.Sequential_IO.C_Streams;
12630
12631   with Interfaces.C_Streams;
12632   package Ada.Direct_IO.C_Streams is
12633      function C_Stream (F : File_Type)
12634         return Interfaces.C_Streams.FILEs;
12635      procedure Open
12636        (File : in out File_Type;
12637         Mode : in File_Mode;
12638         C_Stream : in Interfaces.C_Streams.FILEs;
12639         Form : in String := "");
12640   end Ada.Direct_IO.C_Streams;
12641
12642   with Interfaces.C_Streams;
12643   package Ada.Text_IO.C_Streams is
12644      function C_Stream (F : File_Type)
12645         return Interfaces.C_Streams.FILEs;
12646      procedure Open
12647        (File : in out File_Type;
12648         Mode : in File_Mode;
12649         C_Stream : in Interfaces.C_Streams.FILEs;
12650         Form : in String := "");
12651   end Ada.Text_IO.C_Streams;
12652
12653   with Interfaces.C_Streams;
12654   package Ada.Wide_Text_IO.C_Streams is
12655      function C_Stream (F : File_Type)
12656         return Interfaces.C_Streams.FILEs;
12657      procedure Open
12658        (File : in out File_Type;
12659         Mode : in File_Mode;
12660         C_Stream : in Interfaces.C_Streams.FILEs;
12661         Form : in String := "");
12662  end Ada.Wide_Text_IO.C_Streams;
12663
12664   with Interfaces.C_Streams;
12665   package Ada.Wide_Wide_Text_IO.C_Streams is
12666      function C_Stream (F : File_Type)
12667         return Interfaces.C_Streams.FILEs;
12668      procedure Open
12669        (File : in out File_Type;
12670         Mode : in File_Mode;
12671         C_Stream : in Interfaces.C_Streams.FILEs;
12672         Form : in String := "");
12673  end Ada.Wide_Wide_Text_IO.C_Streams;
12674
12675  with Interfaces.C_Streams;
12676  package Ada.Stream_IO.C_Streams is
12677     function C_Stream (F : File_Type)
12678        return Interfaces.C_Streams.FILEs;
12679     procedure Open
12680       (File : in out File_Type;
12681        Mode : in File_Mode;
12682        C_Stream : in Interfaces.C_Streams.FILEs;
12683        Form : in String := "");
12684  end Ada.Stream_IO.C_Streams;
12685 @end smallexample
12686
12687 @noindent
12688 In each of these six packages, the @code{C_Stream} function obtains the
12689 @code{FILE} pointer from a currently opened Ada file.  It is then
12690 possible to use the @code{Interfaces.C_Streams} package to operate on
12691 this stream, or the stream can be passed to a C program which can
12692 operate on it directly.  Of course the program is responsible for
12693 ensuring that only appropriate sequences of operations are executed.
12694
12695 One particular use of relevance to an Ada program is that the
12696 @code{setvbuf} function can be used to control the buffering of the
12697 stream used by an Ada file.  In the absence of such a call the standard
12698 default buffering is used.
12699
12700 The @code{Open} procedures in these packages open a file giving an
12701 existing C Stream instead of a file name.  Typically this stream is
12702 imported from a C program, allowing an Ada file to operate on an
12703 existing C file.
12704
12705 @node The GNAT Library
12706 @chapter The GNAT Library
12707
12708 @noindent
12709 The GNAT library contains a number of general and special purpose packages.
12710 It represents functionality that the GNAT developers have found useful, and
12711 which is made available to GNAT users.  The packages described here are fully
12712 supported, and upwards compatibility will be maintained in future releases,
12713 so you can use these facilities with the confidence that the same functionality
12714 will be available in future releases.
12715
12716 The chapter here simply gives a brief summary of the facilities available.
12717 The full documentation is found in the spec file for the package.  The full
12718 sources of these library packages, including both spec and body, are provided
12719 with all GNAT releases.  For example, to find out the full specifications of
12720 the SPITBOL pattern matching capability, including a full tutorial and
12721 extensive examples, look in the @file{g-spipat.ads} file in the library.
12722
12723 For each entry here, the package name (as it would appear in a @code{with}
12724 clause) is given, followed by the name of the corresponding spec file in
12725 parentheses.  The packages are children in four hierarchies, @code{Ada},
12726 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
12727 GNAT-specific hierarchy.
12728
12729 Note that an application program should only use packages in one of these
12730 four hierarchies if the package is defined in the Ada Reference Manual,
12731 or is listed in this section of the GNAT Programmers Reference Manual.
12732 All other units should be considered internal implementation units and
12733 should not be directly @code{with}'ed by application code.  The use of
12734 a @code{with} statement that references one of these internal implementation
12735 units makes an application potentially dependent on changes in versions
12736 of GNAT, and will generate a warning message.
12737
12738 @menu
12739 * Ada.Characters.Latin_9 (a-chlat9.ads)::
12740 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
12741 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
12742 * Ada.Characters.Wide_Wide_Latin_1 (a-czila1.ads)::
12743 * Ada.Characters.Wide_Wide_Latin_9 (a-czila9.ads)::
12744 * Ada.Command_Line.Remove (a-colire.ads)::
12745 * Ada.Command_Line.Environment (a-colien.ads)::
12746 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
12747 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
12748 * Ada.Exceptions.Traceback (a-exctra.ads)::
12749 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
12750 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
12751 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
12752 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
12753 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
12754 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
12755 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
12756 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
12757 * GNAT.Altivec (g-altive.ads)::
12758 * GNAT.Altivec.Conversions (g-altcon.ads)::
12759 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
12760 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
12761 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
12762 * GNAT.Array_Split (g-arrspl.ads)::
12763 * GNAT.AWK (g-awk.ads)::
12764 * GNAT.Bounded_Buffers (g-boubuf.ads)::
12765 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
12766 * GNAT.Bubble_Sort (g-bubsor.ads)::
12767 * GNAT.Bubble_Sort_A (g-busora.ads)::
12768 * GNAT.Bubble_Sort_G (g-busorg.ads)::
12769 * GNAT.Byte_Order_Mark (g-byorma.ads)::
12770 * GNAT.Byte_Swapping (g-bytswa.ads)::
12771 * GNAT.Calendar (g-calend.ads)::
12772 * GNAT.Calendar.Time_IO (g-catiio.ads)::
12773 * GNAT.CRC32 (g-crc32.ads)::
12774 * GNAT.Case_Util (g-casuti.ads)::
12775 * GNAT.CGI (g-cgi.ads)::
12776 * GNAT.CGI.Cookie (g-cgicoo.ads)::
12777 * GNAT.CGI.Debug (g-cgideb.ads)::
12778 * GNAT.Command_Line (g-comlin.ads)::
12779 * GNAT.Compiler_Version (g-comver.ads)::
12780 * GNAT.Ctrl_C (g-ctrl_c.ads)::
12781 * GNAT.Current_Exception (g-curexc.ads)::
12782 * GNAT.Debug_Pools (g-debpoo.ads)::
12783 * GNAT.Debug_Utilities (g-debuti.ads)::
12784 * GNAT.Decode_String (g-decstr.ads)::
12785 * GNAT.Decode_UTF8_String (g-deutst.ads)::
12786 * GNAT.Directory_Operations (g-dirope.ads)::
12787 * GNAT.Directory_Operations.Iteration (g-diopit.ads)::
12788 * GNAT.Dynamic_HTables (g-dynhta.ads)::
12789 * GNAT.Dynamic_Tables (g-dyntab.ads)::
12790 * GNAT.Encode_String (g-encstr.ads)::
12791 * GNAT.Encode_UTF8_String (g-enutst.ads)::
12792 * GNAT.Exception_Actions (g-excact.ads)::
12793 * GNAT.Exception_Traces (g-exctra.ads)::
12794 * GNAT.Exceptions (g-except.ads)::
12795 * GNAT.Expect (g-expect.ads)::
12796 * GNAT.Float_Control (g-flocon.ads)::
12797 * GNAT.Heap_Sort (g-heasor.ads)::
12798 * GNAT.Heap_Sort_A (g-hesora.ads)::
12799 * GNAT.Heap_Sort_G (g-hesorg.ads)::
12800 * GNAT.HTable (g-htable.ads)::
12801 * GNAT.IO (g-io.ads)::
12802 * GNAT.IO_Aux (g-io_aux.ads)::
12803 * GNAT.Lock_Files (g-locfil.ads)::
12804 * GNAT.MD5 (g-md5.ads)::
12805 * GNAT.Memory_Dump (g-memdum.ads)::
12806 * GNAT.Most_Recent_Exception (g-moreex.ads)::
12807 * GNAT.OS_Lib (g-os_lib.ads)::
12808 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
12809 * GNAT.Random_Numbers (g-rannum.ads)::
12810 * GNAT.Regexp (g-regexp.ads)::
12811 * GNAT.Registry (g-regist.ads)::
12812 * GNAT.Regpat (g-regpat.ads)::
12813 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
12814 * GNAT.Semaphores (g-semaph.ads)::
12815 * GNAT.SHA1 (g-sha1.ads)::
12816 * GNAT.Signals (g-signal.ads)::
12817 * GNAT.Sockets (g-socket.ads)::
12818 * GNAT.Source_Info (g-souinf.ads)::
12819 * GNAT.Spelling_Checker (g-speche.ads)::
12820 * GNAT.Spelling_Checker_Generic (g-spchge.ads)::
12821 * GNAT.Spitbol.Patterns (g-spipat.ads)::
12822 * GNAT.Spitbol (g-spitbo.ads)::
12823 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
12824 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
12825 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
12826 * GNAT.Strings (g-string.ads)::
12827 * GNAT.String_Split (g-strspl.ads)::
12828 * GNAT.Table (g-table.ads)::
12829 * GNAT.Task_Lock (g-tasloc.ads)::
12830 * GNAT.Threads (g-thread.ads)::
12831 * GNAT.Traceback (g-traceb.ads)::
12832 * GNAT.Traceback.Symbolic (g-trasym.ads)::
12833 * GNAT.UTF_32 (g-utf_32.ads)::
12834 * GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)::
12835 * GNAT.Wide_Spelling_Checker (g-wispch.ads)::
12836 * GNAT.Wide_String_Split (g-wistsp.ads)::
12837 * GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)::
12838 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
12839 * Interfaces.C.Extensions (i-cexten.ads)::
12840 * Interfaces.C.Streams (i-cstrea.ads)::
12841 * Interfaces.CPP (i-cpp.ads)::
12842 * Interfaces.Os2lib (i-os2lib.ads)::
12843 * Interfaces.Os2lib.Errors (i-os2err.ads)::
12844 * Interfaces.Os2lib.Synchronization (i-os2syn.ads)::
12845 * Interfaces.Os2lib.Threads (i-os2thr.ads)::
12846 * Interfaces.Packed_Decimal (i-pacdec.ads)::
12847 * Interfaces.VxWorks (i-vxwork.ads)::
12848 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
12849 * System.Address_Image (s-addima.ads)::
12850 * System.Assertions (s-assert.ads)::
12851 * System.Memory (s-memory.ads)::
12852 * System.Partition_Interface (s-parint.ads)::
12853 * System.Restrictions (s-restri.ads)::
12854 * System.Rident (s-rident.ads)::
12855 * System.Task_Info (s-tasinf.ads)::
12856 * System.Wch_Cnv (s-wchcnv.ads)::
12857 * System.Wch_Con (s-wchcon.ads)::
12858 @end menu
12859
12860 @node Ada.Characters.Latin_9 (a-chlat9.ads)
12861 @section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
12862 @cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
12863 @cindex Latin_9 constants for Character
12864
12865 @noindent
12866 This child of @code{Ada.Characters}
12867 provides a set of definitions corresponding to those in the
12868 RM-defined package @code{Ada.Characters.Latin_1} but with the
12869 few modifications required for @code{Latin-9}
12870 The provision of such a package
12871 is specifically authorized by the Ada Reference Manual
12872 (RM A.3.3(27)).
12873
12874 @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
12875 @section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
12876 @cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
12877 @cindex Latin_1 constants for Wide_Character
12878
12879 @noindent
12880 This child of @code{Ada.Characters}
12881 provides a set of definitions corresponding to those in the
12882 RM-defined package @code{Ada.Characters.Latin_1} but with the
12883 types of the constants being @code{Wide_Character}
12884 instead of @code{Character}.  The provision of such a package
12885 is specifically authorized by the Ada Reference Manual
12886 (RM A.3.3(27)).
12887
12888 @node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
12889 @section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
12890 @cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
12891 @cindex Latin_9 constants for Wide_Character
12892
12893 @noindent
12894 This child of @code{Ada.Characters}
12895 provides a set of definitions corresponding to those in the
12896 GNAT defined package @code{Ada.Characters.Latin_9} but with the
12897 types of the constants being @code{Wide_Character}
12898 instead of @code{Character}.  The provision of such a package
12899 is specifically authorized by the Ada Reference Manual
12900 (RM A.3.3(27)).
12901
12902 @node Ada.Characters.Wide_Wide_Latin_1 (a-czila1.ads)
12903 @section @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-czila1.ads})
12904 @cindex @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-czila1.ads})
12905 @cindex Latin_1 constants for Wide_Wide_Character
12906
12907 @noindent
12908 This child of @code{Ada.Characters}
12909 provides a set of definitions corresponding to those in the
12910 RM-defined package @code{Ada.Characters.Latin_1} but with the
12911 types of the constants being @code{Wide_Wide_Character}
12912 instead of @code{Character}.  The provision of such a package
12913 is specifically authorized by the Ada Reference Manual
12914 (RM A.3.3(27)).
12915
12916 @node Ada.Characters.Wide_Wide_Latin_9 (a-czila9.ads)
12917 @section @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-czila9.ads})
12918 @cindex @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-czila9.ads})
12919 @cindex Latin_9 constants for Wide_Wide_Character
12920
12921 @noindent
12922 This child of @code{Ada.Characters}
12923 provides a set of definitions corresponding to those in the
12924 GNAT defined package @code{Ada.Characters.Latin_9} but with the
12925 types of the constants being @code{Wide_Wide_Character}
12926 instead of @code{Character}.  The provision of such a package
12927 is specifically authorized by the Ada Reference Manual
12928 (RM A.3.3(27)).
12929
12930 @node Ada.Command_Line.Remove (a-colire.ads)
12931 @section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
12932 @cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
12933 @cindex Removing command line arguments
12934 @cindex Command line, argument removal
12935
12936 @noindent
12937 This child of @code{Ada.Command_Line}
12938 provides a mechanism for logically removing
12939 arguments from the argument list.  Once removed, an argument is not visible
12940 to further calls on the subprograms in @code{Ada.Command_Line} will not
12941 see the removed argument.
12942
12943 @node Ada.Command_Line.Environment (a-colien.ads)
12944 @section @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
12945 @cindex @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
12946 @cindex Environment entries
12947
12948 @noindent
12949 This child of @code{Ada.Command_Line}
12950 provides a mechanism for obtaining environment values on systems
12951 where this concept makes sense.
12952
12953 @node Ada.Direct_IO.C_Streams (a-diocst.ads)
12954 @section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
12955 @cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
12956 @cindex C Streams, Interfacing with Direct_IO
12957
12958 @noindent
12959 This package provides subprograms that allow interfacing between
12960 C streams and @code{Direct_IO}.  The stream identifier can be
12961 extracted from a file opened on the Ada side, and an Ada file
12962 can be constructed from a stream opened on the C side.
12963
12964 @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
12965 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
12966 @cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
12967 @cindex Null_Occurrence, testing for
12968
12969 @noindent
12970 This child subprogram provides a way of testing for the null
12971 exception occurrence (@code{Null_Occurrence}) without raising
12972 an exception.
12973
12974 @node Ada.Exceptions.Traceback (a-exctra.ads)
12975 @section @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
12976 @cindex @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
12977 @cindex Traceback for Exception Occurrence
12978
12979 @noindent
12980 This child package provides the subprogram (@code{Tracebacks}) to
12981 give a traceback array of addresses based on an exception
12982 occurrence.
12983
12984 @node Ada.Sequential_IO.C_Streams (a-siocst.ads)
12985 @section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
12986 @cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
12987 @cindex C Streams, Interfacing with Sequential_IO
12988
12989 @noindent
12990 This package provides subprograms that allow interfacing between
12991 C streams and @code{Sequential_IO}.  The stream identifier can be
12992 extracted from a file opened on the Ada side, and an Ada file
12993 can be constructed from a stream opened on the C side.
12994
12995 @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
12996 @section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
12997 @cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
12998 @cindex C Streams, Interfacing with Stream_IO
12999
13000 @noindent
13001 This package provides subprograms that allow interfacing between
13002 C streams and @code{Stream_IO}.  The stream identifier can be
13003 extracted from a file opened on the Ada side, and an Ada file
13004 can be constructed from a stream opened on the C side.
13005
13006 @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
13007 @section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
13008 @cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
13009 @cindex @code{Unbounded_String}, IO support
13010 @cindex @code{Text_IO}, extensions for unbounded strings
13011
13012 @noindent
13013 This package provides subprograms for Text_IO for unbounded
13014 strings, avoiding the necessity for an intermediate operation
13015 with ordinary strings.
13016
13017 @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
13018 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
13019 @cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
13020 @cindex @code{Unbounded_Wide_String}, IO support
13021 @cindex @code{Text_IO}, extensions for unbounded wide strings
13022
13023 @noindent
13024 This package provides subprograms for Text_IO for unbounded
13025 wide strings, avoiding the necessity for an intermediate operation
13026 with ordinary wide strings.
13027
13028 @node Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)
13029 @section @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
13030 @cindex @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
13031 @cindex @code{Unbounded_Wide_Wide_String}, IO support
13032 @cindex @code{Text_IO}, extensions for unbounded wide wide strings
13033
13034 @noindent
13035 This package provides subprograms for Text_IO for unbounded
13036 wide wide strings, avoiding the necessity for an intermediate operation
13037 with ordinary wide wide strings.
13038
13039 @node Ada.Text_IO.C_Streams (a-tiocst.ads)
13040 @section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
13041 @cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
13042 @cindex C Streams, Interfacing with @code{Text_IO}
13043
13044 @noindent
13045 This package provides subprograms that allow interfacing between
13046 C streams and @code{Text_IO}.  The stream identifier can be
13047 extracted from a file opened on the Ada side, and an Ada file
13048 can be constructed from a stream opened on the C side.
13049
13050 @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
13051 @section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
13052 @cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
13053 @cindex C Streams, Interfacing with @code{Wide_Text_IO}
13054
13055 @noindent
13056 This package provides subprograms that allow interfacing between
13057 C streams and @code{Wide_Text_IO}.  The stream identifier can be
13058 extracted from a file opened on the Ada side, and an Ada file
13059 can be constructed from a stream opened on the C side.
13060
13061 @node Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)
13062 @section @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
13063 @cindex @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
13064 @cindex C Streams, Interfacing with @code{Wide_Wide_Text_IO}
13065
13066 @noindent
13067 This package provides subprograms that allow interfacing between
13068 C streams and @code{Wide_Wide_Text_IO}.  The stream identifier can be
13069 extracted from a file opened on the Ada side, and an Ada file
13070 can be constructed from a stream opened on the C side.
13071
13072 @node GNAT.Altivec (g-altive.ads)
13073 @section @code{GNAT.Altivec} (@file{g-altive.ads})
13074 @cindex @code{GNAT.Altivec} (@file{g-altive.ads})
13075 @cindex AltiVec
13076
13077 @noindent
13078 This is the root package of the GNAT AltiVec binding. It provides
13079 definitions of constants and types common to all the versions of the
13080 binding.
13081
13082 @node GNAT.Altivec.Conversions (g-altcon.ads)
13083 @section @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
13084 @cindex @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
13085 @cindex AltiVec
13086
13087 @noindent
13088 This package provides the Vector/View conversion routines.
13089
13090 @node GNAT.Altivec.Vector_Operations (g-alveop.ads)
13091 @section @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
13092 @cindex @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
13093 @cindex AltiVec
13094
13095 @noindent
13096 This package exposes the Ada interface to the AltiVec operations on
13097 vector objects. A soft emulation is included by default in the GNAT
13098 library. The hard binding is provided as a separate package. This unit
13099 is common to both bindings.
13100
13101 @node GNAT.Altivec.Vector_Types (g-alvety.ads)
13102 @section @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
13103 @cindex @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
13104 @cindex AltiVec
13105
13106 @noindent
13107 This package exposes the various vector types part of the Ada binding
13108 to AltiVec facilities.
13109
13110 @node GNAT.Altivec.Vector_Views (g-alvevi.ads)
13111 @section @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
13112 @cindex @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
13113 @cindex AltiVec
13114
13115 @noindent
13116 This package provides public 'View' data types from/to which private
13117 vector representations can be converted via
13118 GNAT.Altivec.Conversions. This allows convenient access to individual
13119 vector elements and provides a simple way to initialize vector
13120 objects.
13121
13122 @node GNAT.Array_Split (g-arrspl.ads)
13123 @section @code{GNAT.Array_Split} (@file{g-arrspl.ads})
13124 @cindex @code{GNAT.Array_Split} (@file{g-arrspl.ads})
13125 @cindex Array splitter
13126
13127 @noindent
13128 Useful array-manipulation routines: given a set of separators, split
13129 an array wherever the separators appear, and provide direct access
13130 to the resulting slices.
13131
13132 @node GNAT.AWK (g-awk.ads)
13133 @section @code{GNAT.AWK} (@file{g-awk.ads})
13134 @cindex @code{GNAT.AWK} (@file{g-awk.ads})
13135 @cindex Parsing
13136 @cindex AWK
13137
13138 @noindent
13139 Provides AWK-like parsing functions, with an easy interface for parsing one
13140 or more files containing formatted data.  The file is viewed as a database
13141 where each record is a line and a field is a data element in this line.
13142
13143 @node GNAT.Bounded_Buffers (g-boubuf.ads)
13144 @section @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
13145 @cindex @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
13146 @cindex Parsing
13147 @cindex Bounded Buffers
13148
13149 @noindent
13150 Provides a concurrent generic bounded buffer abstraction.  Instances are
13151 useful directly or as parts of the implementations of other abstractions,
13152 such as mailboxes.
13153
13154 @node GNAT.Bounded_Mailboxes (g-boumai.ads)
13155 @section @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
13156 @cindex @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
13157 @cindex Parsing
13158 @cindex Mailboxes
13159
13160 @noindent
13161 Provides a thread-safe asynchronous intertask mailbox communication facility.
13162
13163 @node GNAT.Bubble_Sort (g-bubsor.ads)
13164 @section @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
13165 @cindex @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
13166 @cindex Sorting
13167 @cindex Bubble sort
13168
13169 @noindent
13170 Provides a general implementation of bubble sort usable for sorting arbitrary
13171 data items.  Exchange and comparison procedures are provided by passing
13172 access-to-procedure values.
13173
13174 @node GNAT.Bubble_Sort_A (g-busora.ads)
13175 @section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
13176 @cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
13177 @cindex Sorting
13178 @cindex Bubble sort
13179
13180 @noindent
13181 Provides a general implementation of bubble sort usable for sorting arbitrary
13182 data items.  Move and comparison procedures are provided by passing
13183 access-to-procedure values. This is an older version, retained for
13184 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
13185
13186 @node GNAT.Bubble_Sort_G (g-busorg.ads)
13187 @section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
13188 @cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
13189 @cindex Sorting
13190 @cindex Bubble sort
13191
13192 @noindent
13193 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
13194 are provided as generic parameters, this improves efficiency, especially
13195 if the procedures can be inlined, at the expense of duplicating code for
13196 multiple instantiations.
13197
13198 @node GNAT.Byte_Order_Mark (g-byorma.ads)
13199 @section @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
13200 @cindex @code{GNAT.Byte_Order_Mark} (@file{g-byorma.ads})
13201 @cindex UTF-8 representation
13202 @cindex Wide characte representations
13203
13204 @noindent
13205 Provides a routine which given a string, reads the start of the string to
13206 see whether it is one of the standard byte order marks (BOM's) which signal
13207 the encoding of the string. The routine includes detection of special XML
13208 sequences for various UCS input formats.
13209
13210 @node GNAT.Byte_Swapping (g-bytswa.ads)
13211 @section @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
13212 @cindex @code{GNAT.Byte_Swapping} (@file{g-bytswa.ads})
13213 @cindex Byte swapping
13214 @cindex Endian
13215
13216 @noindent
13217 General routines for swapping the bytes in 2-, 4-, and 8-byte quantities.
13218 Machine-specific implementations are available in some cases.
13219
13220 @node GNAT.Calendar (g-calend.ads)
13221 @section @code{GNAT.Calendar} (@file{g-calend.ads})
13222 @cindex @code{GNAT.Calendar} (@file{g-calend.ads})
13223 @cindex @code{Calendar}
13224
13225 @noindent
13226 Extends the facilities provided by @code{Ada.Calendar} to include handling
13227 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
13228 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
13229 C @code{timeval} format.
13230
13231 @node GNAT.Calendar.Time_IO (g-catiio.ads)
13232 @section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
13233 @cindex @code{Calendar}
13234 @cindex Time
13235 @cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
13236
13237 @node GNAT.CRC32 (g-crc32.ads)
13238 @section @code{GNAT.CRC32} (@file{g-crc32.ads})
13239 @cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
13240 @cindex CRC32
13241 @cindex Cyclic Redundancy Check
13242
13243 @noindent
13244 This package implements the CRC-32 algorithm.  For a full description
13245 of this algorithm see
13246 ``Computation of Cyclic Redundancy Checks via Table Look-Up'',
13247 @cite{Communications of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013,
13248 Aug.@: 1988.  Sarwate, D.V@.
13249
13250 @node GNAT.Case_Util (g-casuti.ads)
13251 @section @code{GNAT.Case_Util} (@file{g-casuti.ads})
13252 @cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
13253 @cindex Casing utilities
13254 @cindex Character handling (@code{GNAT.Case_Util})
13255
13256 @noindent
13257 A set of simple routines for handling upper and lower casing of strings
13258 without the overhead of the full casing tables
13259 in @code{Ada.Characters.Handling}.
13260
13261 @node GNAT.CGI (g-cgi.ads)
13262 @section @code{GNAT.CGI} (@file{g-cgi.ads})
13263 @cindex @code{GNAT.CGI} (@file{g-cgi.ads})
13264 @cindex CGI (Common Gateway Interface)
13265
13266 @noindent
13267 This is a package for interfacing a GNAT program with a Web server via the
13268 Common Gateway Interface (CGI)@.  Basically this package parses the CGI
13269 parameters, which are a set of key/value pairs sent by the Web server.  It
13270 builds a table whose index is the key and provides some services to deal
13271 with this table.
13272
13273 @node GNAT.CGI.Cookie (g-cgicoo.ads)
13274 @section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
13275 @cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
13276 @cindex CGI (Common Gateway Interface) cookie support
13277 @cindex Cookie support in CGI
13278
13279 @noindent
13280 This is a package to interface a GNAT program with a Web server via the
13281 Common Gateway Interface (CGI).  It exports services to deal with Web
13282 cookies (piece of information kept in the Web client software).
13283
13284 @node GNAT.CGI.Debug (g-cgideb.ads)
13285 @section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
13286 @cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
13287 @cindex CGI (Common Gateway Interface) debugging
13288
13289 @noindent
13290 This is a package to help debugging CGI (Common Gateway Interface)
13291 programs written in Ada.
13292
13293 @node GNAT.Command_Line (g-comlin.ads)
13294 @section @code{GNAT.Command_Line} (@file{g-comlin.ads})
13295 @cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
13296 @cindex Command line
13297
13298 @noindent
13299 Provides a high level interface to @code{Ada.Command_Line} facilities,
13300 including the ability to scan for named switches with optional parameters
13301 and expand file names using wild card notations.
13302
13303 @node GNAT.Compiler_Version (g-comver.ads)
13304 @section @code{GNAT.Compiler_Version} (@file{g-comver.ads})
13305 @cindex @code{GNAT.Compiler_Version} (@file{g-comver.ads})
13306 @cindex Compiler Version
13307 @cindex Version, of compiler
13308
13309 @noindent
13310 Provides a routine for obtaining the version of the compiler used to
13311 compile the program. More accurately this is the version of the binder
13312 used to bind the program (this will normally be the same as the version
13313 of the compiler if a consistent tool set is used to compile all units
13314 of a partition).
13315
13316 @node GNAT.Ctrl_C (g-ctrl_c.ads)
13317 @section @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
13318 @cindex @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
13319 @cindex Interrupt
13320
13321 @noindent
13322 Provides a simple interface to handle Ctrl-C keyboard events.
13323
13324 @node GNAT.Current_Exception (g-curexc.ads)
13325 @section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
13326 @cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
13327 @cindex Current exception
13328 @cindex Exception retrieval
13329
13330 @noindent
13331 Provides access to information on the current exception that has been raised
13332 without the need for using the Ada 95 / Ada 2005 exception choice parameter
13333 specification syntax.
13334 This is particularly useful in simulating typical facilities for
13335 obtaining information about exceptions provided by Ada 83 compilers.
13336
13337 @node GNAT.Debug_Pools (g-debpoo.ads)
13338 @section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
13339 @cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
13340 @cindex Debugging
13341 @cindex Debug pools
13342 @cindex Memory corruption debugging
13343
13344 @noindent
13345 Provide a debugging storage pools that helps tracking memory corruption
13346 problems.  See section ``Finding memory problems with GNAT Debug Pool'' in
13347 the @cite{GNAT User's Guide}.
13348
13349 @node GNAT.Debug_Utilities (g-debuti.ads)
13350 @section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
13351 @cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
13352 @cindex Debugging
13353
13354 @noindent
13355 Provides a few useful utilities for debugging purposes, including conversion
13356 to and from string images of address values. Supports both C and Ada formats
13357 for hexadecimal literals.
13358
13359 @node GNAT.Decode_String (g-decstr.ads)
13360 @section @code{GNAT.Decode_String} (@file{g-decstr.ads})
13361 @cindex @code{GNAT.Decode_String} (@file{g-decstr.ads})
13362 @cindex Decoding strings
13363 @cindex String decoding
13364 @cindex Wide character encoding
13365 @cindex UTF-8
13366 @cindex Unicode
13367
13368 @noindent
13369 A generic package providing routines for decoding wide character and wide wide
13370 character strings encoded as sequences of 8-bit characters using a specified
13371 encoding method. Includes validation routines, and also routines for stepping
13372 to next or previous encoded character in an encoded string.
13373 Useful in conjunction with Unicode character coding. Note there is a
13374 preinstantiation for UTF-8. See next entry.
13375
13376 @node GNAT.Decode_UTF8_String (g-deutst.ads)
13377 @section @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
13378 @cindex @code{GNAT.Decode_UTF8_String} (@file{g-deutst.ads})
13379 @cindex Decoding strings
13380 @cindex Decoding UTF-8 strings
13381 @cindex UTF-8 string decoding
13382 @cindex Wide character decoding
13383 @cindex UTF-8
13384 @cindex Unicode
13385
13386 @noindent
13387 A preinstantiation of GNAT.Decode_Strings for UTF-8 encoding.
13388
13389 @node GNAT.Directory_Operations (g-dirope.ads)
13390 @section @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
13391 @cindex @code{GNAT.Directory_Operations} (@file{g-dirope.ads})
13392 @cindex Directory operations
13393
13394 @noindent
13395 Provides a set of routines for manipulating directories, including changing
13396 the current directory, making new directories, and scanning the files in a
13397 directory.
13398
13399 @node GNAT.Directory_Operations.Iteration (g-diopit.ads)
13400 @section @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
13401 @cindex @code{GNAT.Directory_Operations.Iteration} (@file{g-diopit.ads})
13402 @cindex Directory operations iteration
13403
13404 @noindent
13405 A child unit of GNAT.Directory_Operations providing additional operations
13406 for iterating through directories.
13407
13408 @node GNAT.Dynamic_HTables (g-dynhta.ads)
13409 @section @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
13410 @cindex @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
13411 @cindex Hash tables
13412
13413 @noindent
13414 A generic implementation of hash tables that can be used to hash arbitrary
13415 data.  Provided in two forms, a simple form with built in hash functions,
13416 and a more complex form in which the hash function is supplied.
13417
13418 @noindent
13419 This package provides a facility similar to that of @code{GNAT.HTable},
13420 except that this package declares a type that can be used to define
13421 dynamic instances of the hash table, while an instantiation of
13422 @code{GNAT.HTable} creates a single instance of the hash table.
13423
13424 @node GNAT.Dynamic_Tables (g-dyntab.ads)
13425 @section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
13426 @cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
13427 @cindex Table implementation
13428 @cindex Arrays, extendable
13429
13430 @noindent
13431 A generic package providing a single dimension array abstraction where the
13432 length of the array can be dynamically modified.
13433
13434 @noindent
13435 This package provides a facility similar to that of @code{GNAT.Table},
13436 except that this package declares a type that can be used to define
13437 dynamic instances of the table, while an instantiation of
13438 @code{GNAT.Table} creates a single instance of the table type.
13439
13440 @node GNAT.Encode_String (g-encstr.ads)
13441 @section @code{GNAT.Encode_String} (@file{g-encstr.ads})
13442 @cindex @code{GNAT.Encode_String} (@file{g-encstr.ads})
13443 @cindex Encoding strings
13444 @cindex String encoding
13445 @cindex Wide character encoding
13446 @cindex UTF-8
13447 @cindex Unicode
13448
13449 @noindent
13450 A generic package providing routines for encoding wide character and wide
13451 wide character strings as sequences of 8-bit characters using a specified
13452 encoding method. Useful in conjunction with Unicode character coding.
13453 Note there is a preinstantiation for UTF-8. See next entry.
13454
13455 @node GNAT.Encode_UTF8_String (g-enutst.ads)
13456 @section @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
13457 @cindex @code{GNAT.Encode_UTF8_String} (@file{g-enutst.ads})
13458 @cindex Encoding strings
13459 @cindex Encoding UTF-8 strings
13460 @cindex UTF-8 string encoding
13461 @cindex Wide character encoding
13462 @cindex UTF-8
13463 @cindex Unicode
13464
13465 @noindent
13466 A preinstantiation of GNAT.Encode_Strings for UTF-8 encoding.
13467
13468 @node GNAT.Exception_Actions (g-excact.ads)
13469 @section @code{GNAT.Exception_Actions} (@file{g-excact.ads})
13470 @cindex @code{GNAT.Exception_Actions} (@file{g-excact.ads})
13471 @cindex Exception actions
13472
13473 @noindent
13474 Provides callbacks when an exception is raised. Callbacks can be registered
13475 for specific exceptions, or when any exception is raised. This
13476 can be used for instance to force a core dump to ease debugging.
13477
13478 @node GNAT.Exception_Traces (g-exctra.ads)
13479 @section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
13480 @cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
13481 @cindex Exception traces
13482 @cindex Debugging
13483
13484 @noindent
13485 Provides an interface allowing to control automatic output upon exception
13486 occurrences.
13487
13488 @node GNAT.Exceptions (g-except.ads)
13489 @section @code{GNAT.Exceptions} (@file{g-expect.ads})
13490 @cindex @code{GNAT.Exceptions} (@file{g-expect.ads})
13491 @cindex Exceptions, Pure
13492 @cindex Pure packages, exceptions
13493
13494 @noindent
13495 Normally it is not possible to raise an exception with
13496 a message from a subprogram in a pure package, since the
13497 necessary types and subprograms are in @code{Ada.Exceptions}
13498 which is not a pure unit. @code{GNAT.Exceptions} provides a
13499 facility for getting around this limitation for a few
13500 predefined exceptions, and for example allow raising
13501 @code{Constraint_Error} with a message from a pure subprogram.
13502
13503 @node GNAT.Expect (g-expect.ads)
13504 @section @code{GNAT.Expect} (@file{g-expect.ads})
13505 @cindex @code{GNAT.Expect} (@file{g-expect.ads})
13506
13507 @noindent
13508 Provides a set of subprograms similar to what is available
13509 with the standard Tcl Expect tool.
13510 It allows you to easily spawn and communicate with an external process.
13511 You can send commands or inputs to the process, and compare the output
13512 with some expected regular expression. Currently @code{GNAT.Expect}
13513 is implemented on all native GNAT ports except for OpenVMS@.
13514 It is not implemented for cross ports, and in particular is not
13515 implemented for VxWorks or LynxOS@.
13516
13517 @node GNAT.Float_Control (g-flocon.ads)
13518 @section @code{GNAT.Float_Control} (@file{g-flocon.ads})
13519 @cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
13520 @cindex Floating-Point Processor
13521
13522 @noindent
13523 Provides an interface for resetting the floating-point processor into the
13524 mode required for correct semantic operation in Ada.  Some third party
13525 library calls may cause this mode to be modified, and the Reset procedure
13526 in this package can be used to reestablish the required mode.
13527
13528 @node GNAT.Heap_Sort (g-heasor.ads)
13529 @section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
13530 @cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
13531 @cindex Sorting
13532
13533 @noindent
13534 Provides a general implementation of heap sort usable for sorting arbitrary
13535 data items. Exchange and comparison procedures are provided by passing
13536 access-to-procedure values.  The algorithm used is a modified heap sort
13537 that performs approximately N*log(N) comparisons in the worst case.
13538
13539 @node GNAT.Heap_Sort_A (g-hesora.ads)
13540 @section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
13541 @cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
13542 @cindex Sorting
13543
13544 @noindent
13545 Provides a general implementation of heap sort usable for sorting arbitrary
13546 data items. Move and comparison procedures are provided by passing
13547 access-to-procedure values.  The algorithm used is a modified heap sort
13548 that performs approximately N*log(N) comparisons in the worst case.
13549 This differs from @code{GNAT.Heap_Sort} in having a less convenient
13550 interface, but may be slightly more efficient.
13551
13552 @node GNAT.Heap_Sort_G (g-hesorg.ads)
13553 @section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
13554 @cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
13555 @cindex Sorting
13556
13557 @noindent
13558 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
13559 are provided as generic parameters, this improves efficiency, especially
13560 if the procedures can be inlined, at the expense of duplicating code for
13561 multiple instantiations.
13562
13563 @node GNAT.HTable (g-htable.ads)
13564 @section @code{GNAT.HTable} (@file{g-htable.ads})
13565 @cindex @code{GNAT.HTable} (@file{g-htable.ads})
13566 @cindex Hash tables
13567
13568 @noindent
13569 A generic implementation of hash tables that can be used to hash arbitrary
13570 data.  Provides two approaches, one a simple static approach, and the other
13571 allowing arbitrary dynamic hash tables.
13572
13573 @node GNAT.IO (g-io.ads)
13574 @section @code{GNAT.IO} (@file{g-io.ads})
13575 @cindex @code{GNAT.IO} (@file{g-io.ads})
13576 @cindex Simple I/O
13577 @cindex Input/Output facilities
13578
13579 @noindent
13580 A simple preelaborable input-output package that provides a subset of
13581 simple Text_IO functions for reading characters and strings from
13582 Standard_Input, and writing characters, strings and integers to either
13583 Standard_Output or Standard_Error.
13584
13585 @node GNAT.IO_Aux (g-io_aux.ads)
13586 @section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
13587 @cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
13588 @cindex Text_IO
13589 @cindex Input/Output facilities
13590
13591 Provides some auxiliary functions for use with Text_IO, including a test
13592 for whether a file exists, and functions for reading a line of text.
13593
13594 @node GNAT.Lock_Files (g-locfil.ads)
13595 @section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
13596 @cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
13597 @cindex File locking
13598 @cindex Locking using files
13599
13600 @noindent
13601 Provides a general interface for using files as locks.  Can be used for
13602 providing program level synchronization.
13603
13604 @node GNAT.MD5 (g-md5.ads)
13605 @section @code{GNAT.MD5} (@file{g-md5.ads})
13606 @cindex @code{GNAT.MD5} (@file{g-md5.ads})
13607 @cindex Message Digest MD5
13608
13609 @noindent
13610 Implements the MD5 Message-Digest Algorithm as described in RFC 1321.
13611
13612 @node GNAT.Memory_Dump (g-memdum.ads)
13613 @section @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
13614 @cindex @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
13615 @cindex Dump Memory
13616
13617 @noindent
13618 Provides a convenient routine for dumping raw memory to either the
13619 standard output or standard error files. Uses GNAT.IO for actual
13620 output.
13621
13622 @node GNAT.Most_Recent_Exception (g-moreex.ads)
13623 @section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
13624 @cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
13625 @cindex Exception, obtaining most recent
13626
13627 @noindent
13628 Provides access to the most recently raised exception.  Can be used for
13629 various logging purposes, including duplicating functionality of some
13630 Ada 83 implementation dependent extensions.
13631
13632 @node GNAT.OS_Lib (g-os_lib.ads)
13633 @section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
13634 @cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
13635 @cindex Operating System interface
13636 @cindex Spawn capability
13637
13638 @noindent
13639 Provides a range of target independent operating system interface functions,
13640 including time/date management, file operations, subprocess management,
13641 including a portable spawn procedure, and access to environment variables
13642 and error return codes.
13643
13644 @node GNAT.Perfect_Hash_Generators (g-pehage.ads)
13645 @section @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
13646 @cindex @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
13647 @cindex Hash functions
13648
13649 @noindent
13650 Provides a generator of static minimal perfect hash functions. No
13651 collisions occur and each item can be retrieved from the table in one
13652 probe (perfect property). The hash table size corresponds to the exact
13653 size of the key set and no larger (minimal property). The key set has to
13654 be know in advance (static property). The hash functions are also order
13655 preserving. If w2 is inserted after w1 in the generator, their
13656 hashcode are in the same order. These hashing functions are very
13657 convenient for use with realtime applications.
13658
13659 @node GNAT.Random_Numbers (g-rannum.ads)
13660 @section @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
13661 @cindex @code{GNAT.Random_Numbers} (@file{g-rannum.ads})
13662 @cindex Random number generation
13663
13664 @noindent
13665 Provides random number capabilities which extend those available in the
13666 standard Ada library and are more convenient to use.
13667
13668 @node GNAT.Regexp (g-regexp.ads)
13669 @section @code{GNAT.Regexp} (@file{g-regexp.ads})
13670 @cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
13671 @cindex Regular expressions
13672 @cindex Pattern matching
13673
13674 @noindent
13675 A simple implementation of regular expressions, using a subset of regular
13676 expression syntax copied from familiar Unix style utilities.  This is the
13677 simples of the three pattern matching packages provided, and is particularly
13678 suitable for ``file globbing'' applications.
13679
13680 @node GNAT.Registry (g-regist.ads)
13681 @section @code{GNAT.Registry} (@file{g-regist.ads})
13682 @cindex @code{GNAT.Registry} (@file{g-regist.ads})
13683 @cindex Windows Registry
13684
13685 @noindent
13686 This is a high level binding to the Windows registry.  It is possible to
13687 do simple things like reading a key value, creating a new key.  For full
13688 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
13689 package provided with the Win32Ada binding
13690
13691 @node GNAT.Regpat (g-regpat.ads)
13692 @section @code{GNAT.Regpat} (@file{g-regpat.ads})
13693 @cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
13694 @cindex Regular expressions
13695 @cindex Pattern matching
13696
13697 @noindent
13698 A complete implementation of Unix-style regular expression matching, copied
13699 from the original V7 style regular expression library written in C by
13700 Henry Spencer (and binary compatible with this C library).
13701
13702 @node GNAT.Secondary_Stack_Info (g-sestin.ads)
13703 @section @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
13704 @cindex @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
13705 @cindex Secondary Stack Info
13706
13707 @noindent
13708 Provide the capability to query the high water mark of the current task's
13709 secondary stack.
13710
13711 @node GNAT.Semaphores (g-semaph.ads)
13712 @section @code{GNAT.Semaphores} (@file{g-semaph.ads})
13713 @cindex @code{GNAT.Semaphores} (@file{g-semaph.ads})
13714 @cindex Semaphores
13715
13716 @noindent
13717 Provides classic counting and binary semaphores using protected types.
13718
13719 @node GNAT.SHA1 (g-sha1.ads)
13720 @section @code{GNAT.SHA1} (@file{g-sha1.ads})
13721 @cindex @code{GNAT.SHA1} (@file{g-sha1.ads})
13722 @cindex Secure Hash Algorithm SHA-1
13723
13724 @noindent
13725 Implements the SHA-1 Secure Hash Algorithm as described in RFC 3174.
13726
13727 @node GNAT.Signals (g-signal.ads)
13728 @section @code{GNAT.Signals} (@file{g-signal.ads})
13729 @cindex @code{GNAT.Signals} (@file{g-signal.ads})
13730 @cindex Signals
13731
13732 @noindent
13733 Provides the ability to manipulate the blocked status of signals on supported
13734 targets.
13735
13736 @node GNAT.Sockets (g-socket.ads)
13737 @section @code{GNAT.Sockets} (@file{g-socket.ads})
13738 @cindex @code{GNAT.Sockets} (@file{g-socket.ads})
13739 @cindex Sockets
13740
13741 @noindent
13742 A high level and portable interface to develop sockets based applications.
13743 This package is based on the sockets thin binding found in
13744 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
13745 on all native GNAT ports except for OpenVMS@.  It is not implemented
13746 for the LynxOS@ cross port.
13747
13748 @node GNAT.Source_Info (g-souinf.ads)
13749 @section @code{GNAT.Source_Info} (@file{g-souinf.ads})
13750 @cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
13751 @cindex Source Information
13752
13753 @noindent
13754 Provides subprograms that give access to source code information known at
13755 compile time, such as the current file name and line number.
13756
13757 @node GNAT.Spelling_Checker (g-speche.ads)
13758 @section @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
13759 @cindex @code{GNAT.Spelling_Checker} (@file{g-speche.ads})
13760 @cindex Spell checking
13761
13762 @noindent
13763 Provides a function for determining whether one string is a plausible
13764 near misspelling of another string.
13765
13766 @node GNAT.Spelling_Checker_Generic (g-spchge.ads)
13767 @section @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
13768 @cindex @code{GNAT.Spelling_Checker_Generic} (@file{g-spchge.ads})
13769 @cindex Spell checking
13770
13771 @noindent
13772 Provides a generic function that can be instantiated with a string type for
13773 determining whether one string is a plausible near misspelling of another
13774 string.
13775
13776 @node GNAT.Spitbol.Patterns (g-spipat.ads)
13777 @section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
13778 @cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
13779 @cindex SPITBOL pattern matching
13780 @cindex Pattern matching
13781
13782 @noindent
13783 A complete implementation of SNOBOL4 style pattern matching.  This is the
13784 most elaborate of the pattern matching packages provided.  It fully duplicates
13785 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
13786 efficient algorithm developed by Robert Dewar for the SPITBOL system.
13787
13788 @node GNAT.Spitbol (g-spitbo.ads)
13789 @section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
13790 @cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
13791 @cindex SPITBOL interface
13792
13793 @noindent
13794 The top level package of the collection of SPITBOL-style functionality, this
13795 package provides basic SNOBOL4 string manipulation functions, such as
13796 Pad, Reverse, Trim, Substr capability, as well as a generic table function
13797 useful for constructing arbitrary mappings from strings in the style of
13798 the SNOBOL4 TABLE function.
13799
13800 @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
13801 @section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
13802 @cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
13803 @cindex Sets of strings
13804 @cindex SPITBOL Tables
13805
13806 @noindent
13807 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
13808 for type @code{Standard.Boolean}, giving an implementation of sets of
13809 string values.
13810
13811 @node GNAT.Spitbol.Table_Integer (g-sptain.ads)
13812 @section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
13813 @cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
13814 @cindex Integer maps
13815 @cindex Maps
13816 @cindex SPITBOL Tables
13817
13818 @noindent
13819 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
13820 for type @code{Standard.Integer}, giving an implementation of maps
13821 from string to integer values.
13822
13823 @node GNAT.Spitbol.Table_VString (g-sptavs.ads)
13824 @section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
13825 @cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
13826 @cindex String maps
13827 @cindex Maps
13828 @cindex SPITBOL Tables
13829
13830 @noindent
13831 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
13832 a variable length string type, giving an implementation of general
13833 maps from strings to strings.
13834
13835 @node GNAT.Strings (g-string.ads)
13836 @section @code{GNAT.Strings} (@file{g-string.ads})
13837 @cindex @code{GNAT.Strings} (@file{g-string.ads})
13838
13839 @noindent
13840 Common String access types and related subprograms. Basically it
13841 defines a string access and an array of string access types.
13842
13843 @node GNAT.String_Split (g-strspl.ads)
13844 @section @code{GNAT.String_Split} (@file{g-strspl.ads})
13845 @cindex @code{GNAT.String_Split} (@file{g-strspl.ads})
13846 @cindex String splitter
13847
13848 @noindent
13849 Useful string manipulation routines: given a set of separators, split
13850 a string wherever the separators appear, and provide direct access
13851 to the resulting slices. This package is instantiated from
13852 @code{GNAT.Array_Split}.
13853
13854 @node GNAT.Table (g-table.ads)
13855 @section @code{GNAT.Table} (@file{g-table.ads})
13856 @cindex @code{GNAT.Table} (@file{g-table.ads})
13857 @cindex Table implementation
13858 @cindex Arrays, extendable
13859
13860 @noindent
13861 A generic package providing a single dimension array abstraction where the
13862 length of the array can be dynamically modified.
13863
13864 @noindent
13865 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
13866 except that this package declares a single instance of the table type,
13867 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
13868 used to define dynamic instances of the table.
13869
13870 @node GNAT.Task_Lock (g-tasloc.ads)
13871 @section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
13872 @cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
13873 @cindex Task synchronization
13874 @cindex Task locking
13875 @cindex Locking
13876
13877 @noindent
13878 A very simple facility for locking and unlocking sections of code using a
13879 single global task lock.  Appropriate for use in situations where contention
13880 between tasks is very rarely expected.
13881
13882 @node GNAT.Threads (g-thread.ads)
13883 @section @code{GNAT.Threads} (@file{g-thread.ads})
13884 @cindex @code{GNAT.Threads} (@file{g-thread.ads})
13885 @cindex Foreign threads
13886 @cindex Threads, foreign
13887
13888 @noindent
13889 Provides facilities for dealing with foreign threads which need to be known
13890 by the GNAT run-time system. Consult the documentation of this package for
13891 further details if your program has threads that are created by a non-Ada
13892 environment which then accesses Ada code.
13893
13894 @node GNAT.Traceback (g-traceb.ads)
13895 @section @code{GNAT.Traceback} (@file{g-traceb.ads})
13896 @cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
13897 @cindex Trace back facilities
13898
13899 @noindent
13900 Provides a facility for obtaining non-symbolic traceback information, useful
13901 in various debugging situations.
13902
13903 @node GNAT.Traceback.Symbolic (g-trasym.ads)
13904 @section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
13905 @cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
13906 @cindex Trace back facilities
13907
13908 @node GNAT.UTF_32 (g-utf_32.ads)
13909 @section @code{GNAT.UTF_32} (@file{g-table.ads})
13910 @cindex @code{GNAT.UTF_32} (@file{g-table.ads})
13911 @cindex Wide character codes
13912
13913 @noindent
13914 This is a package intended to be used in conjunction with the
13915 @code{Wide_Character} type in Ada 95 and the
13916 @code{Wide_Wide_Character} type in Ada 2005 (available
13917 in @code{GNAT} in Ada 2005 mode). This package contains
13918 Unicode categorization routines, as well as lexical
13919 categorization routines corresponding to the Ada 2005
13920 lexical rules for identifiers and strings, and also a
13921 lower case to upper case fold routine corresponding to
13922 the Ada 2005 rules for identifier equivalence.
13923
13924 @node GNAT.UTF_32_Spelling_Checker (g-u3spch.ads)
13925 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
13926 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-u3spch.ads})
13927 @cindex Spell checking
13928
13929 @noindent
13930 Provides a function for determining whether one wide wide string is a plausible
13931 near misspelling of another wide wide string, where the strings are represented
13932 using the UTF_32_String type defined in System.Wch_Cnv.
13933
13934 @node GNAT.Wide_Spelling_Checker (g-wispch.ads)
13935 @section @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
13936 @cindex @code{GNAT.Wide_Spelling_Checker} (@file{g-wispch.ads})
13937 @cindex Spell checking
13938
13939 @noindent
13940 Provides a function for determining whether one wide string is a plausible
13941 near misspelling of another wide string.
13942
13943 @node GNAT.Wide_String_Split (g-wistsp.ads)
13944 @section @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
13945 @cindex @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
13946 @cindex Wide_String splitter
13947
13948 @noindent
13949 Useful wide string manipulation routines: given a set of separators, split
13950 a wide string wherever the separators appear, and provide direct access
13951 to the resulting slices. This package is instantiated from
13952 @code{GNAT.Array_Split}.
13953
13954 @node GNAT.Wide_Wide_Spelling_Checker (g-zspche.ads)
13955 @section @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
13956 @cindex @code{GNAT.Wide_Wide_Spelling_Checker} (@file{g-zspche.ads})
13957 @cindex Spell checking
13958
13959 @noindent
13960 Provides a function for determining whether one wide wide string is a plausible
13961 near misspelling of another wide wide string.
13962
13963 @node GNAT.Wide_Wide_String_Split (g-zistsp.ads)
13964 @section @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
13965 @cindex @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
13966 @cindex Wide_Wide_String splitter
13967
13968 @noindent
13969 Useful wide wide string manipulation routines: given a set of separators, split
13970 a wide wide string wherever the separators appear, and provide direct access
13971 to the resulting slices. This package is instantiated from
13972 @code{GNAT.Array_Split}.
13973
13974 @node Interfaces.C.Extensions (i-cexten.ads)
13975 @section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
13976 @cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
13977
13978 @noindent
13979 This package contains additional C-related definitions, intended
13980 for use with either manually or automatically generated bindings
13981 to C libraries.
13982
13983 @node Interfaces.C.Streams (i-cstrea.ads)
13984 @section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
13985 @cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
13986 @cindex  C streams, interfacing
13987
13988 @noindent
13989 This package is a binding for the most commonly used operations
13990 on C streams.
13991
13992 @node Interfaces.CPP (i-cpp.ads)
13993 @section @code{Interfaces.CPP} (@file{i-cpp.ads})
13994 @cindex @code{Interfaces.CPP} (@file{i-cpp.ads})
13995 @cindex  C++ interfacing
13996 @cindex  Interfacing, to C++
13997
13998 @noindent
13999 This package provides facilities for use in interfacing to C++.  It
14000 is primarily intended to be used in connection with automated tools
14001 for the generation of C++ interfaces.
14002
14003 @node Interfaces.Os2lib (i-os2lib.ads)
14004 @section @code{Interfaces.Os2lib} (@file{i-os2lib.ads})
14005 @cindex @code{Interfaces.Os2lib} (@file{i-os2lib.ads})
14006 @cindex Interfacing, to OS/2
14007 @cindex OS/2 interfacing
14008
14009 @noindent
14010 This package provides interface definitions to the OS/2 library.
14011 It is a thin binding which is a direct translation of the
14012 various @file{<bse@.h>} files.
14013
14014 @node Interfaces.Os2lib.Errors (i-os2err.ads)
14015 @section @code{Interfaces.Os2lib.Errors} (@file{i-os2err.ads})
14016 @cindex @code{Interfaces.Os2lib.Errors} (@file{i-os2err.ads})
14017 @cindex OS/2 Error codes
14018 @cindex Interfacing, to OS/2
14019 @cindex OS/2 interfacing
14020
14021 @noindent
14022 This package provides definitions of the OS/2 error codes.
14023
14024 @node Interfaces.Os2lib.Synchronization (i-os2syn.ads)
14025 @section @code{Interfaces.Os2lib.Synchronization} (@file{i-os2syn.ads})
14026 @cindex @code{Interfaces.Os2lib.Synchronization} (@file{i-os2syn.ads})
14027 @cindex Interfacing, to OS/2
14028 @cindex Synchronization, OS/2
14029 @cindex OS/2 synchronization primitives
14030
14031 @noindent
14032 This is a child package that provides definitions for interfacing
14033 to the @code{OS/2} synchronization primitives.
14034
14035 @node Interfaces.Os2lib.Threads (i-os2thr.ads)
14036 @section @code{Interfaces.Os2lib.Threads} (@file{i-os2thr.ads})
14037 @cindex @code{Interfaces.Os2lib.Threads} (@file{i-os2thr.ads})
14038 @cindex Interfacing, to OS/2
14039 @cindex Thread control, OS/2
14040 @cindex OS/2 thread interfacing
14041
14042 @noindent
14043 This is a child package that provides definitions for interfacing
14044 to the @code{OS/2} thread primitives.
14045
14046 @node Interfaces.Packed_Decimal (i-pacdec.ads)
14047 @section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
14048 @cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
14049 @cindex  IBM Packed Format
14050 @cindex  Packed Decimal
14051
14052 @noindent
14053 This package provides a set of routines for conversions to and
14054 from a packed decimal format compatible with that used on IBM
14055 mainframes.
14056
14057 @node Interfaces.VxWorks (i-vxwork.ads)
14058 @section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
14059 @cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
14060 @cindex Interfacing to VxWorks
14061 @cindex VxWorks, interfacing
14062
14063 @noindent
14064 This package provides a limited binding to the VxWorks API.
14065 In particular, it interfaces with the
14066 VxWorks hardware interrupt facilities.
14067
14068 @node Interfaces.VxWorks.IO (i-vxwoio.ads)
14069 @section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
14070 @cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
14071 @cindex Interfacing to VxWorks' I/O
14072 @cindex VxWorks, I/O interfacing
14073 @cindex VxWorks, Get_Immediate
14074 @cindex Get_Immediate, VxWorks
14075
14076 @noindent
14077 This package provides a binding to the ioctl (IO/Control)
14078 function of VxWorks, defining a set of option values and
14079 function codes. A particular use of this package is
14080 to enable the use of Get_Immediate under VxWorks.
14081
14082 @node System.Address_Image (s-addima.ads)
14083 @section @code{System.Address_Image} (@file{s-addima.ads})
14084 @cindex @code{System.Address_Image} (@file{s-addima.ads})
14085 @cindex Address image
14086 @cindex Image, of an address
14087
14088 @noindent
14089 This function provides a useful debugging
14090 function that gives an (implementation dependent)
14091 string which identifies an address.
14092
14093 @node System.Assertions (s-assert.ads)
14094 @section @code{System.Assertions} (@file{s-assert.ads})
14095 @cindex @code{System.Assertions} (@file{s-assert.ads})
14096 @cindex Assertions
14097 @cindex Assert_Failure, exception
14098
14099 @noindent
14100 This package provides the declaration of the exception raised
14101 by an run-time assertion failure, as well as the routine that
14102 is used internally to raise this assertion.
14103
14104 @node System.Memory (s-memory.ads)
14105 @section @code{System.Memory} (@file{s-memory.ads})
14106 @cindex @code{System.Memory} (@file{s-memory.ads})
14107 @cindex Memory allocation
14108
14109 @noindent
14110 This package provides the interface to the low level routines used
14111 by the generated code for allocation and freeing storage for the
14112 default storage pool (analogous to the C routines malloc and free.
14113 It also provides a reallocation interface analogous to the C routine
14114 realloc. The body of this unit may be modified to provide alternative
14115 allocation mechanisms for the default pool, and in addition, direct
14116 calls to this unit may be made for low level allocation uses (for
14117 example see the body of @code{GNAT.Tables}).
14118
14119 @node System.Partition_Interface (s-parint.ads)
14120 @section @code{System.Partition_Interface} (@file{s-parint.ads})
14121 @cindex @code{System.Partition_Interface} (@file{s-parint.ads})
14122 @cindex Partition interfacing functions
14123
14124 @noindent
14125 This package provides facilities for partition interfacing.  It
14126 is used primarily in a distribution context when using Annex E
14127 with @code{GLADE}.
14128
14129 @node System.Restrictions (s-restri.ads)
14130 @section @code{System.Restrictions} (@file{s-restri.ads})
14131 @cindex @code{System.Restrictions} (@file{s-restri.ads})
14132 @cindex Run-time restrictions access
14133
14134 @noindent
14135 This package provides facilities for accessing at run time
14136 the status of restrictions specified at compile time for
14137 the partition. Information is available both with regard
14138 to actual restrictions specified, and with regard to
14139 compiler determined information on which restrictions
14140 are violated by one or more packages in the partition.
14141
14142 @node System.Rident (s-rident.ads)
14143 @section @code{System.Rident} (@file{s-rident.ads})
14144 @cindex @code{System.Rident} (@file{s-rident.ads})
14145 @cindex Restrictions definitions
14146
14147 @noindent
14148 This package provides definitions of the restrictions
14149 identifiers supported by GNAT, and also the format of
14150 the restrictions provided in package System.Restrictions.
14151 It is not normally necessary to @code{with} this generic package
14152 since the necessary instantiation is included in
14153 package System.Restrictions.
14154
14155 @node System.Task_Info (s-tasinf.ads)
14156 @section @code{System.Task_Info} (@file{s-tasinf.ads})
14157 @cindex @code{System.Task_Info} (@file{s-tasinf.ads})
14158 @cindex Task_Info pragma
14159
14160 @noindent
14161 This package provides target dependent functionality that is used
14162 to support the @code{Task_Info} pragma
14163
14164 @node System.Wch_Cnv (s-wchcnv.ads)
14165 @section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
14166 @cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
14167 @cindex Wide Character, Representation
14168 @cindex Wide String, Conversion
14169 @cindex Representation of wide characters
14170
14171 @noindent
14172 This package provides routines for converting between
14173 wide and wide wide characters and a representation as a value of type
14174 @code{Standard.String}, using a specified wide character
14175 encoding method.  It uses definitions in
14176 package @code{System.Wch_Con}.
14177
14178 @node System.Wch_Con (s-wchcon.ads)
14179 @section @code{System.Wch_Con} (@file{s-wchcon.ads})
14180 @cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
14181
14182 @noindent
14183 This package provides definitions and descriptions of
14184 the various methods used for encoding wide characters
14185 in ordinary strings.  These definitions are used by
14186 the package @code{System.Wch_Cnv}.
14187
14188 @node Interfacing to Other Languages
14189 @chapter Interfacing to Other Languages
14190 @noindent
14191 The facilities in annex B of the Ada Reference Manual are fully
14192 implemented in GNAT, and in addition, a full interface to C++ is
14193 provided.
14194
14195 @menu
14196 * Interfacing to C::
14197 * Interfacing to C++::
14198 * Interfacing to COBOL::
14199 * Interfacing to Fortran::
14200 * Interfacing to non-GNAT Ada code::
14201 @end menu
14202
14203 @node Interfacing to C
14204 @section Interfacing to C
14205
14206 @noindent
14207 Interfacing to C with GNAT can use one of two approaches:
14208
14209 @itemize @bullet
14210 @item
14211 The types in the package @code{Interfaces.C} may be used.
14212 @item
14213 Standard Ada types may be used directly.  This may be less portable to
14214 other compilers, but will work on all GNAT compilers, which guarantee
14215 correspondence between the C and Ada types.
14216 @end itemize
14217
14218 @noindent
14219 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
14220 effect, since this is the default.  The following table shows the
14221 correspondence between Ada scalar types and the corresponding C types.
14222
14223 @table @code
14224 @item Integer
14225 @code{int}
14226 @item Short_Integer
14227 @code{short}
14228 @item Short_Short_Integer
14229 @code{signed char}
14230 @item Long_Integer
14231 @code{long}
14232 @item Long_Long_Integer
14233 @code{long long}
14234 @item Short_Float
14235 @code{float}
14236 @item Float
14237 @code{float}
14238 @item Long_Float
14239 @code{double}
14240 @item Long_Long_Float
14241 This is the longest floating-point type supported by the hardware.
14242 @end table
14243
14244 @noindent
14245 Additionally, there are the following general correspondences between Ada
14246 and C types:
14247 @itemize @bullet
14248 @item
14249 Ada enumeration types map to C enumeration types directly if pragma
14250 @code{Convention C} is specified, which causes them to have int
14251 length.  Without pragma @code{Convention C}, Ada enumeration types map to
14252 8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short},
14253 @code{int}, respectively) depending on the number of values passed.
14254 This is the only case in which pragma @code{Convention C} affects the
14255 representation of an Ada type.
14256
14257 @item
14258 Ada access types map to C pointers, except for the case of pointers to
14259 unconstrained types in Ada, which have no direct C equivalent.
14260
14261 @item
14262 Ada arrays map directly to C arrays.
14263
14264 @item
14265 Ada records map directly to C structures.
14266
14267 @item
14268 Packed Ada records map to C structures where all members are bit fields
14269 of the length corresponding to the @code{@var{type}'Size} value in Ada.
14270 @end itemize
14271
14272 @node Interfacing to C++
14273 @section Interfacing to C++
14274
14275 @noindent
14276 The interface to C++ makes use of the following pragmas, which are
14277 primarily intended to be constructed automatically using a binding generator
14278 tool, although it is possible to construct them by hand.  No suitable binding
14279 generator tool is supplied with GNAT though.
14280
14281 Using these pragmas it is possible to achieve complete
14282 inter-operability between Ada tagged types and C++ class definitions.
14283 See @ref{Implementation Defined Pragmas}, for more details.
14284
14285 @table @code
14286 @item pragma CPP_Class ([Entity =>] @var{LOCAL_NAME})
14287 The argument denotes an entity in the current declarative region that is
14288 declared as a tagged or untagged record type. It indicates that the type
14289 corresponds to an externally declared C++ class type, and is to be laid
14290 out the same way that C++ would lay out the type.
14291
14292 Note: Pragma @code{CPP_Class} is currently obsolete. It is supported
14293 for backward compatibility but its functionality is available
14294 using pragma @code{Import} with @code{Convention} = @code{CPP}.
14295
14296 @item pragma CPP_Constructor ([Entity =>] @var{LOCAL_NAME})
14297 This pragma identifies an imported function (imported in the usual way
14298 with pragma @code{Import}) as corresponding to a C++ constructor.
14299 @end table
14300
14301 @node Interfacing to COBOL
14302 @section Interfacing to COBOL
14303
14304 @noindent
14305 Interfacing to COBOL is achieved as described in section B.4 of
14306 the Ada Reference Manual.
14307
14308 @node Interfacing to Fortran
14309 @section Interfacing to Fortran
14310
14311 @noindent
14312 Interfacing to Fortran is achieved as described in section B.5 of the
14313 Ada Reference Manual.  The pragma @code{Convention Fortran}, applied to a
14314 multi-dimensional array causes the array to be stored in column-major
14315 order as required for convenient interface to Fortran.
14316
14317 @node Interfacing to non-GNAT Ada code
14318 @section Interfacing to non-GNAT Ada code
14319
14320 It is possible to specify the convention @code{Ada} in a pragma
14321 @code{Import} or pragma @code{Export}.  However this refers to
14322 the calling conventions used by GNAT, which may or may not be
14323 similar enough to those used by some other Ada 83 / Ada 95 / Ada 2005
14324 compiler to allow interoperation.
14325
14326 If arguments types are kept simple, and if the foreign compiler generally
14327 follows system calling conventions, then it may be possible to integrate
14328 files compiled by other Ada compilers, provided that the elaboration
14329 issues are adequately addressed (for example by eliminating the
14330 need for any load time elaboration).
14331
14332 In particular, GNAT running on VMS is designed to
14333 be highly compatible with the DEC Ada 83 compiler, so this is one
14334 case in which it is possible to import foreign units of this type,
14335 provided that the data items passed are restricted to simple scalar
14336 values or simple record types without variants, or simple array
14337 types with fixed bounds.
14338
14339 @node Specialized Needs Annexes
14340 @chapter Specialized Needs Annexes
14341
14342 @noindent
14343 Ada 95 and Ada 2005 define a number of Specialized Needs Annexes, which are not
14344 required in all implementations.  However, as described in this chapter,
14345 GNAT implements all of these annexes:
14346
14347 @table @asis
14348 @item Systems Programming (Annex C)
14349 The Systems Programming Annex is fully implemented.
14350
14351 @item Real-Time Systems (Annex D)
14352 The Real-Time Systems Annex is fully implemented.
14353
14354 @item Distributed Systems (Annex E)
14355 Stub generation is fully implemented in the GNAT compiler.  In addition,
14356 a complete compatible PCS is available as part of the GLADE system,
14357 a separate product.  When the two
14358 products are used in conjunction, this annex is fully implemented.
14359
14360 @item Information Systems (Annex F)
14361 The Information Systems annex is fully implemented.
14362
14363 @item Numerics (Annex G)
14364 The Numerics Annex is fully implemented.
14365
14366 @item Safety and Security / High-Integrity Systems (Annex H)
14367 The Safety and Security Annex (termed the High-Integrity Systems Annex
14368 in Ada 2005) is fully implemented.
14369 @end table
14370
14371 @node Implementation of Specific Ada Features
14372 @chapter Implementation of Specific Ada Features
14373
14374 @noindent
14375 This chapter describes the GNAT implementation of several Ada language
14376 facilities.
14377
14378 @menu
14379 * Machine Code Insertions::
14380 * GNAT Implementation of Tasking::
14381 * GNAT Implementation of Shared Passive Packages::
14382 * Code Generation for Array Aggregates::
14383 * The Size of Discriminated Records with Default Discriminants::
14384 * Strict Conformance to the Ada Reference Manual::
14385 @end menu
14386
14387 @node Machine Code Insertions
14388 @section Machine Code Insertions
14389 @cindex Machine Code insertions
14390
14391 @noindent
14392 Package @code{Machine_Code} provides machine code support as described
14393 in the Ada Reference Manual in two separate forms:
14394 @itemize @bullet
14395 @item
14396 Machine code statements, consisting of qualified expressions that
14397 fit the requirements of RM section 13.8.
14398 @item
14399 An intrinsic callable procedure, providing an alternative mechanism of
14400 including machine instructions in a subprogram.
14401 @end itemize
14402
14403 @noindent
14404 The two features are similar, and both are closely related to the mechanism
14405 provided by the asm instruction in the GNU C compiler.  Full understanding
14406 and use of the facilities in this package requires understanding the asm
14407 instruction as described in @cite{Using the GNU Compiler Collection (GCC)}
14408 by Richard Stallman. The relevant section is titled ``Extensions to the C
14409 Language Family'' @result{} ``Assembler Instructions with C Expression
14410 Operands''.
14411
14412 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
14413 semantic restrictions and effects as described below.  Both are provided so
14414 that the procedure call can be used as a statement, and the function call
14415 can be used to form a code_statement.
14416
14417 The first example given in the GCC documentation is the C @code{asm}
14418 instruction:
14419 @smallexample
14420    asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
14421 @end smallexample
14422
14423 @noindent
14424 The equivalent can be written for GNAT as:
14425
14426 @smallexample @c ada
14427 Asm ("fsinx %1 %0",
14428      My_Float'Asm_Output ("=f", result),
14429      My_Float'Asm_Input  ("f",  angle));
14430 @end smallexample
14431
14432 @noindent
14433 The first argument to @code{Asm} is the assembler template, and is
14434 identical to what is used in GNU C@.  This string must be a static
14435 expression.  The second argument is the output operand list.  It is
14436 either a single @code{Asm_Output} attribute reference, or a list of such
14437 references enclosed in parentheses (technically an array aggregate of
14438 such references).
14439
14440 The @code{Asm_Output} attribute denotes a function that takes two
14441 parameters.  The first is a string, the second is the name of a variable
14442 of the type designated by the attribute prefix.  The first (string)
14443 argument is required to be a static expression and designates the
14444 constraint for the parameter (e.g.@: what kind of register is
14445 required).  The second argument is the variable to be updated with the
14446 result.  The possible values for constraint are the same as those used in
14447 the RTL, and are dependent on the configuration file used to build the
14448 GCC back end.  If there are no output operands, then this argument may
14449 either be omitted, or explicitly given as @code{No_Output_Operands}.
14450
14451 The second argument of @code{@var{my_float}'Asm_Output} functions as
14452 though it were an @code{out} parameter, which is a little curious, but
14453 all names have the form of expressions, so there is no syntactic
14454 irregularity, even though normally functions would not be permitted
14455 @code{out} parameters.  The third argument is the list of input
14456 operands.  It is either a single @code{Asm_Input} attribute reference, or
14457 a list of such references enclosed in parentheses (technically an array
14458 aggregate of such references).
14459
14460 The @code{Asm_Input} attribute denotes a function that takes two
14461 parameters.  The first is a string, the second is an expression of the
14462 type designated by the prefix.  The first (string) argument is required
14463 to be a static expression, and is the constraint for the parameter,
14464 (e.g.@: what kind of register is required).  The second argument is the
14465 value to be used as the input argument.  The possible values for the
14466 constant are the same as those used in the RTL, and are dependent on
14467 the configuration file used to built the GCC back end.
14468
14469 If there are no input operands, this argument may either be omitted, or
14470 explicitly given as @code{No_Input_Operands}.  The fourth argument, not
14471 present in the above example, is a list of register names, called the
14472 @dfn{clobber} argument.  This argument, if given, must be a static string
14473 expression, and is a space or comma separated list of names of registers
14474 that must be considered destroyed as a result of the @code{Asm} call.  If
14475 this argument is the null string (the default value), then the code
14476 generator assumes that no additional registers are destroyed.
14477
14478 The fifth argument, not present in the above example, called the
14479 @dfn{volatile} argument, is by default @code{False}.  It can be set to
14480 the literal value @code{True} to indicate to the code generator that all
14481 optimizations with respect to the instruction specified should be
14482 suppressed, and that in particular, for an instruction that has outputs,
14483 the instruction will still be generated, even if none of the outputs are
14484 used.  See the full description in the GCC manual for further details.
14485 Generally it is strongly advisable to use Volatile for any ASM statement
14486 that is missing either input or output operands, or when two or more ASM
14487 statements appear in sequence, to avoid unwanted optimizations. A warning
14488 is generated if this advice is not followed.
14489
14490 The @code{Asm} subprograms may be used in two ways.  First the procedure
14491 forms can be used anywhere a procedure call would be valid, and
14492 correspond to what the RM calls ``intrinsic'' routines.  Such calls can
14493 be used to intersperse machine instructions with other Ada statements.
14494 Second, the function forms, which return a dummy value of the limited
14495 private type @code{Asm_Insn}, can be used in code statements, and indeed
14496 this is the only context where such calls are allowed.  Code statements
14497 appear as aggregates of the form:
14498
14499 @smallexample @c ada
14500 Asm_Insn'(Asm (@dots{}));
14501 Asm_Insn'(Asm_Volatile (@dots{}));
14502 @end smallexample
14503
14504 @noindent
14505 In accordance with RM rules, such code statements are allowed only
14506 within subprograms whose entire body consists of such statements.  It is
14507 not permissible to intermix such statements with other Ada statements.
14508
14509 Typically the form using intrinsic procedure calls is more convenient
14510 and more flexible.  The code statement form is provided to meet the RM
14511 suggestion that such a facility should be made available.  The following
14512 is the exact syntax of the call to @code{Asm}. As usual, if named notation
14513 is used, the arguments may be given in arbitrary order, following the
14514 normal rules for use of positional and named arguments)
14515
14516 @smallexample
14517 ASM_CALL ::= Asm (
14518                  [Template =>] static_string_EXPRESSION
14519                [,[Outputs  =>] OUTPUT_OPERAND_LIST      ]
14520                [,[Inputs   =>] INPUT_OPERAND_LIST       ]
14521                [,[Clobber  =>] static_string_EXPRESSION ]
14522                [,[Volatile =>] static_boolean_EXPRESSION] )
14523
14524 OUTPUT_OPERAND_LIST ::=
14525   [PREFIX.]No_Output_Operands
14526 | OUTPUT_OPERAND_ATTRIBUTE
14527 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
14528
14529 OUTPUT_OPERAND_ATTRIBUTE ::=
14530   SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
14531
14532 INPUT_OPERAND_LIST ::=
14533   [PREFIX.]No_Input_Operands
14534 | INPUT_OPERAND_ATTRIBUTE
14535 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
14536
14537 INPUT_OPERAND_ATTRIBUTE ::=
14538   SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
14539 @end smallexample
14540
14541 @noindent
14542 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
14543 are declared in the package @code{Machine_Code} and must be referenced
14544 according to normal visibility rules. In particular if there is no
14545 @code{use} clause for this package, then appropriate package name
14546 qualification is required.
14547
14548 @node GNAT Implementation of Tasking
14549 @section GNAT Implementation of Tasking
14550
14551 @noindent
14552 This chapter outlines the basic GNAT approach to tasking (in particular,
14553 a multi-layered library for portability) and discusses issues related
14554 to compliance with the Real-Time Systems Annex.
14555
14556 @menu
14557 * Mapping Ada Tasks onto the Underlying Kernel Threads::
14558 * Ensuring Compliance with the Real-Time Annex::
14559 @end menu
14560
14561 @node Mapping Ada Tasks onto the Underlying Kernel Threads
14562 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
14563
14564 @noindent
14565 GNAT's run-time support comprises two layers:
14566
14567 @itemize @bullet
14568 @item GNARL (GNAT Run-time Layer)
14569 @item GNULL (GNAT Low-level Library)
14570 @end itemize
14571
14572 @noindent
14573 In GNAT, Ada's tasking services rely on a platform and OS independent
14574 layer known as GNARL@.  This code is responsible for implementing the
14575 correct semantics of Ada's task creation, rendezvous, protected
14576 operations etc.
14577
14578 GNARL decomposes Ada's tasking semantics into simpler lower level
14579 operations such as create a thread, set the priority of a thread,
14580 yield, create a lock, lock/unlock, etc.  The spec for these low-level
14581 operations constitutes GNULLI, the GNULL Interface.  This interface is
14582 directly inspired from the POSIX real-time API@.
14583
14584 If the underlying executive or OS implements the POSIX standard
14585 faithfully, the GNULL Interface maps as is to the services offered by
14586 the underlying kernel.  Otherwise, some target dependent glue code maps
14587 the services offered by the underlying kernel to the semantics expected
14588 by GNARL@.
14589
14590 Whatever the underlying OS (VxWorks, UNIX, OS/2, Windows NT, etc.) the
14591 key point is that each Ada task is mapped on a thread in the underlying
14592 kernel.  For example, in the case of VxWorks, one Ada task = one VxWorks task.
14593
14594 In addition Ada task priorities map onto the underlying thread priorities.
14595 Mapping Ada tasks onto the underlying kernel threads has several advantages:
14596
14597 @itemize @bullet
14598 @item
14599 The underlying scheduler is used to schedule the Ada tasks.  This
14600 makes Ada tasks as efficient as kernel threads from a scheduling
14601 standpoint.
14602
14603 @item
14604 Interaction with code written in C containing threads is eased
14605 since at the lowest level Ada tasks and C threads map onto the same
14606 underlying kernel concept.
14607
14608 @item
14609 When an Ada task is blocked during I/O the remaining Ada tasks are
14610 able to proceed.
14611
14612 @item
14613 On multiprocessor systems Ada tasks can execute in parallel.
14614 @end itemize
14615
14616 @noindent
14617 Some threads libraries offer a mechanism to fork a new process, with the
14618 child process duplicating the threads from the parent.
14619 GNAT does not
14620 support this functionality when the parent contains more than one task.
14621 @cindex Forking a new process
14622
14623 @node Ensuring Compliance with the Real-Time Annex
14624 @subsection Ensuring Compliance with the Real-Time Annex
14625 @cindex Real-Time Systems Annex compliance
14626
14627 @noindent
14628 Although mapping Ada tasks onto
14629 the underlying threads has significant advantages, it does create some
14630 complications when it comes to respecting the scheduling semantics
14631 specified in the real-time annex (Annex D).
14632
14633 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
14634 scheduling policy states:
14635
14636 @quotation
14637 @emph{When the active priority of a ready task that is not running
14638 changes, or the setting of its base priority takes effect, the
14639 task is removed from the ready queue for its old active priority
14640 and is added at the tail of the ready queue for its new active
14641 priority, except in the case where the active priority is lowered
14642 due to the loss of inherited priority, in which case the task is
14643 added at the head of the ready queue for its new active priority.}
14644 @end quotation
14645
14646 @noindent
14647 While most kernels do put tasks at the end of the priority queue when
14648 a task changes its priority, (which respects the main
14649 FIFO_Within_Priorities requirement), almost none keep a thread at the
14650 beginning of its priority queue when its priority drops from the loss
14651 of inherited priority.
14652
14653 As a result most vendors have provided incomplete Annex D implementations.
14654
14655 The GNAT run-time, has a nice cooperative solution to this problem
14656 which ensures that accurate FIFO_Within_Priorities semantics are
14657 respected.
14658
14659 The principle is as follows.  When an Ada task T is about to start
14660 running, it checks whether some other Ada task R with the same
14661 priority as T has been suspended due to the loss of priority
14662 inheritance.  If this is the case, T yields and is placed at the end of
14663 its priority queue.  When R arrives at the front of the queue it
14664 executes.
14665
14666 Note that this simple scheme preserves the relative order of the tasks
14667 that were ready to execute in the priority queue where R has been
14668 placed at the end.
14669
14670 @node GNAT Implementation of Shared Passive Packages
14671 @section GNAT Implementation of Shared Passive Packages
14672 @cindex Shared passive packages
14673
14674 @noindent
14675 GNAT fully implements the pragma @code{Shared_Passive} for
14676 @cindex pragma @code{Shared_Passive}
14677 the purpose of designating shared passive packages.
14678 This allows the use of passive partitions in the
14679 context described in the Ada Reference Manual; i.e. for communication
14680 between separate partitions of a distributed application using the
14681 features in Annex E.
14682 @cindex Annex E
14683 @cindex Distribution Systems Annex
14684
14685 However, the implementation approach used by GNAT provides for more
14686 extensive usage as follows:
14687
14688 @table @emph
14689 @item Communication between separate programs
14690
14691 This allows separate programs to access the data in passive
14692 partitions, using protected objects for synchronization where
14693 needed. The only requirement is that the two programs have a
14694 common shared file system. It is even possible for programs
14695 running on different machines with different architectures
14696 (e.g. different endianness) to communicate via the data in
14697 a passive partition.
14698
14699 @item Persistence between program runs
14700
14701 The data in a passive package can persist from one run of a
14702 program to another, so that a later program sees the final
14703 values stored by a previous run of the same program.
14704
14705 @end table
14706
14707 @noindent
14708 The implementation approach used is to store the data in files. A
14709 separate stream file is created for each object in the package, and
14710 an access to an object causes the corresponding file to be read or
14711 written.
14712
14713 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
14714 @cindex @code{SHARED_MEMORY_DIRECTORY} environment variable
14715 set to the directory to be used for these files.
14716 The files in this directory
14717 have names that correspond to their fully qualified names. For
14718 example, if we have the package
14719
14720 @smallexample @c ada
14721 package X is
14722   pragma Shared_Passive (X);
14723   Y : Integer;
14724   Z : Float;
14725 end X;
14726 @end smallexample
14727
14728 @noindent
14729 and the environment variable is set to @code{/stemp/}, then the files created
14730 will have the names:
14731
14732 @smallexample
14733 /stemp/x.y
14734 /stemp/x.z
14735 @end smallexample
14736
14737 @noindent
14738 These files are created when a value is initially written to the object, and
14739 the files are retained until manually deleted. This provides the persistence
14740 semantics. If no file exists, it means that no partition has assigned a value
14741 to the variable; in this case the initial value declared in the package
14742 will be used. This model ensures that there are no issues in synchronizing
14743 the elaboration process, since elaboration of passive packages elaborates the
14744 initial values, but does not create the files.
14745
14746 The files are written using normal @code{Stream_IO} access.
14747 If you want to be able
14748 to communicate between programs or partitions running on different
14749 architectures, then you should use the XDR versions of the stream attribute
14750 routines, since these are architecture independent.
14751
14752 If active synchronization is required for access to the variables in the
14753 shared passive package, then as described in the Ada Reference Manual, the
14754 package may contain protected objects used for this purpose. In this case
14755 a lock file (whose name is @file{___lock} (three underscores)
14756 is created in the shared memory directory.
14757 @cindex @file{___lock} file (for shared passive packages)
14758 This is used to provide the required locking
14759 semantics for proper protected object synchronization.
14760
14761 As of January 2003, GNAT supports shared passive packages on all platforms
14762 except for OpenVMS.
14763
14764 @node Code Generation for Array Aggregates
14765 @section Code Generation for Array Aggregates
14766
14767 @menu
14768 * Static constant aggregates with static bounds::
14769 * Constant aggregates with unconstrained nominal types::
14770 * Aggregates with static bounds::
14771 * Aggregates with non-static bounds::
14772 * Aggregates in assignment statements::
14773 @end menu
14774
14775 @noindent
14776 Aggregates have a rich syntax and allow the user to specify the values of
14777 complex data structures by means of a single construct.  As a result, the
14778 code generated for aggregates can be quite complex and involve loops, case
14779 statements and multiple assignments.  In the simplest cases, however, the
14780 compiler will recognize aggregates whose components and constraints are
14781 fully static, and in those cases the compiler will generate little or no
14782 executable code.  The following is an outline of the code that GNAT generates
14783 for various aggregate constructs.  For further details, you will find it
14784 useful to examine the output produced by the -gnatG flag to see the expanded
14785 source that is input to the code generator.  You may also want to examine
14786 the assembly code generated at various levels of optimization.
14787
14788 The code generated for aggregates depends on the context, the component values,
14789 and the type.  In the context of an object declaration the code generated is
14790 generally simpler than in the case of an assignment.  As a general rule, static
14791 component values and static subtypes also lead to simpler code.
14792
14793 @node Static constant aggregates with static bounds
14794 @subsection Static constant aggregates with static bounds
14795
14796 @noindent
14797 For the declarations:
14798 @smallexample @c ada
14799     type One_Dim is array (1..10) of integer;
14800     ar0 : constant One_Dim := (1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
14801 @end smallexample
14802
14803 @noindent
14804 GNAT generates no executable code: the constant ar0 is placed in static memory.
14805 The same is true for constant aggregates with named associations:
14806
14807 @smallexample @c ada
14808     Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1 => 1, 5 .. 10 => 0);
14809     Cr3 : constant One_Dim := (others => 7777);
14810 @end smallexample
14811
14812 @noindent
14813 The same is true for multidimensional constant arrays such as:
14814
14815 @smallexample @c ada
14816     type two_dim is array (1..3, 1..3) of integer;
14817     Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
14818 @end smallexample
14819
14820 @noindent
14821 The same is true for arrays of one-dimensional arrays: the following are
14822 static:
14823
14824 @smallexample @c ada
14825 type ar1b  is array (1..3) of boolean;
14826 type ar_ar is array (1..3) of ar1b;
14827 None  : constant ar1b := (others => false);     --  fully static
14828 None2 : constant ar_ar := (1..3 => None);       --  fully static
14829 @end smallexample
14830
14831 @noindent
14832 However, for multidimensional aggregates with named associations, GNAT will
14833 generate assignments and loops, even if all associations are static.  The
14834 following two declarations generate a loop for the first dimension, and
14835 individual component assignments for the second dimension:
14836
14837 @smallexample @c ada
14838 Zero1: constant two_dim := (1..3 => (1..3 => 0));
14839 Zero2: constant two_dim := (others => (others => 0));
14840 @end smallexample
14841
14842 @node Constant aggregates with unconstrained nominal types
14843 @subsection Constant aggregates with unconstrained nominal types
14844
14845 @noindent
14846 In such cases the aggregate itself establishes the subtype, so that
14847 associations with @code{others} cannot be used.  GNAT determines the
14848 bounds for the actual subtype of the aggregate, and allocates the
14849 aggregate statically as well.  No code is generated for the following:
14850
14851 @smallexample @c ada
14852     type One_Unc is array (natural range <>) of integer;
14853     Cr_Unc : constant One_Unc := (12,24,36);
14854 @end smallexample
14855
14856 @node Aggregates with static bounds
14857 @subsection Aggregates with static bounds
14858
14859 @noindent
14860 In all previous examples the aggregate was the initial (and immutable) value
14861 of a constant.  If the aggregate initializes a variable, then code is generated
14862 for it as a combination of individual assignments and loops over the target
14863 object.  The declarations
14864
14865 @smallexample @c ada
14866        Cr_Var1 : One_Dim := (2, 5, 7, 11, 0, 0, 0, 0, 0, 0);
14867        Cr_Var2 : One_Dim := (others > -1);
14868 @end smallexample
14869
14870 @noindent
14871 generate the equivalent of
14872
14873 @smallexample @c ada
14874        Cr_Var1 (1) := 2;
14875        Cr_Var1 (2) := 3;
14876        Cr_Var1 (3) := 5;
14877        Cr_Var1 (4) := 11;
14878
14879        for I in Cr_Var2'range loop
14880           Cr_Var2 (I) := -1;
14881        end loop;
14882 @end smallexample
14883
14884 @node Aggregates with non-static bounds
14885 @subsection Aggregates with non-static bounds
14886
14887 @noindent
14888 If the bounds of the aggregate are not statically compatible with the bounds
14889 of the nominal subtype  of the target, then constraint checks have to be
14890 generated on the bounds.  For a multidimensional array, constraint checks may
14891 have to be applied to sub-arrays individually, if they do not have statically
14892 compatible subtypes.
14893
14894 @node Aggregates in assignment statements
14895 @subsection Aggregates in assignment statements
14896
14897 @noindent
14898 In general, aggregate assignment requires the construction of a temporary,
14899 and a copy from the temporary to the target of the assignment.  This is because
14900 it is not always possible to convert the assignment into a series of individual
14901 component assignments.  For example, consider the simple case:
14902
14903 @smallexample @c ada
14904         A := (A(2), A(1));
14905 @end smallexample
14906
14907 @noindent
14908 This cannot be converted into:
14909
14910 @smallexample @c ada
14911         A(1) := A(2);
14912         A(2) := A(1);
14913 @end smallexample
14914
14915 @noindent
14916 So the aggregate has to be built first in a separate location, and then
14917 copied into the target.  GNAT recognizes simple cases where this intermediate
14918 step is not required, and the assignments can be performed in place, directly
14919 into the target.  The following sufficient criteria are applied:
14920
14921 @itemize @bullet
14922 @item
14923 The bounds of the aggregate are static, and the associations are static.
14924 @item
14925 The components of the aggregate are static constants, names of
14926 simple variables that are not renamings, or expressions not involving
14927 indexed components whose operands obey these rules.
14928 @end itemize
14929
14930 @noindent
14931 If any of these conditions are violated, the aggregate will be built in
14932 a temporary (created either by the front-end or the code generator) and then
14933 that temporary will be copied onto the target.
14934
14935
14936 @node The Size of Discriminated Records with Default Discriminants
14937 @section The Size of Discriminated Records with Default Discriminants
14938
14939 @noindent
14940 If a discriminated type @code{T} has discriminants with default values, it is
14941 possible to declare an object of this type without providing an explicit
14942 constraint:
14943
14944 @smallexample @c ada
14945 @group
14946 type Size is range 1..100;
14947
14948 type Rec (D : Size := 15) is record
14949    Name : String (1..D);
14950 end T;
14951
14952 Word : Rec;
14953 @end group
14954 @end smallexample
14955
14956 @noindent
14957 Such an object is said to be @emph{unconstrained}.
14958 The discriminant of the object
14959 can be modified by a full assignment to the object, as long as it preserves the
14960 relation between the value of the discriminant, and the value of the components
14961 that depend on it:
14962
14963 @smallexample @c ada
14964 @group
14965 Word := (3, "yes");
14966
14967 Word := (5, "maybe");
14968
14969 Word := (5, "no"); -- raises Constraint_Error
14970 @end group
14971 @end smallexample
14972
14973 @noindent
14974 In order to support this behavior efficiently, an unconstrained object is
14975 given the maximum size that any value of the type requires. In the case
14976 above, @code{Word} has storage for the discriminant and for
14977 a @code{String} of length 100.
14978 It is important to note that unconstrained objects do not require dynamic
14979 allocation. It would be an improper implementation to place on the heap those
14980 components whose size depends on discriminants. (This improper implementation
14981 was used by some Ada83 compilers, where the @code{Name} component above
14982 would have
14983 been stored as a pointer to a dynamic string). Following the principle that
14984 dynamic storage management should never be introduced implicitly,
14985 an Ada compiler should reserve the full size for an unconstrained declared
14986 object, and place it on the stack.
14987
14988 This maximum size approach
14989 has been a source of surprise to some users, who expect the default
14990 values of the discriminants to determine the size reserved for an
14991 unconstrained object: ``If the default is 15, why should the object occupy
14992 a larger size?''
14993 The answer, of course, is that the discriminant may be later modified,
14994 and its full range of values must be taken into account. This is why the
14995 declaration:
14996
14997 @smallexample
14998 @group
14999 type Rec (D : Positive := 15) is record
15000    Name : String (1..D);
15001 end record;
15002
15003 Too_Large : Rec;
15004 @end group
15005 @end smallexample
15006
15007 @noindent
15008 is flagged by the compiler with a warning:
15009 an attempt to create @code{Too_Large} will raise @code{Storage_Error},
15010 because the required size includes @code{Positive'Last}
15011 bytes. As the first example indicates, the proper approach is to declare an
15012 index type of ``reasonable'' range so that unconstrained objects are not too
15013 large.
15014
15015 One final wrinkle: if the object is declared to be @code{aliased}, or if it is
15016 created in the heap by means of an allocator, then it is @emph{not}
15017 unconstrained:
15018 it is constrained by the default values of the discriminants, and those values
15019 cannot be modified by full assignment. This is because in the presence of
15020 aliasing all views of the object (which may be manipulated by different tasks,
15021 say) must be consistent, so it is imperative that the object, once created,
15022 remain invariant.
15023
15024 @node Strict Conformance to the Ada Reference Manual
15025 @section Strict Conformance to the Ada Reference Manual
15026
15027 @noindent
15028 The dynamic semantics defined by the Ada Reference Manual impose a set of
15029 run-time checks to be generated. By default, the GNAT compiler will insert many
15030 run-time checks into the compiled code, including most of those required by the
15031 Ada Reference Manual. However, there are three checks that are not enabled
15032 in the default mode for efficiency reasons: arithmetic overflow checking for
15033 integer operations (including division by zero), checks for access before
15034 elaboration on subprogram calls, and stack overflow checking (most operating
15035 systems do not perform this check by default).
15036
15037 Strict conformance to the Ada Reference Manual can be achieved by adding
15038 three compiler options for overflow checking for integer operations
15039 (@option{-gnato}), dynamic checks for access-before-elaboration on subprogram
15040 calls and generic instantiations (@option{-gnatE}), and stack overflow
15041 checking (@option{-fstack-check}).
15042
15043 Note that the result of a floating point arithmetic operation in overflow and
15044 invalid situations, when the @code{Machine_Overflows} attribute of the result
15045 type is @code{False}, is to generate IEEE NaN and infinite values. This is the
15046 case for machines compliant with the IEEE floating-point standard, but on
15047 machines that are not fully compliant with this standard, such as Alpha, the
15048 @option{-mieee} compiler flag must be used for achieving IEEE confirming
15049 behavior (although at the cost of a significant performance penalty), so
15050 infinite and and NaN values are properly generated.
15051
15052
15053 @node Project File Reference
15054 @chapter Project File Reference
15055
15056 @noindent
15057 This chapter describes the syntax and semantics of project files.
15058 Project files specify the options to be used when building a system.
15059 Project files can specify global settings for all tools,
15060 as well as tool-specific settings.
15061 See the chapter on project files in the GNAT Users guide for examples of use.
15062
15063 @menu
15064 * Reserved Words::
15065 * Lexical Elements::
15066 * Declarations::
15067 * Empty declarations::
15068 * Typed string declarations::
15069 * Variables::
15070 * Expressions::
15071 * Attributes::
15072 * Project Attributes::
15073 * Attribute References::
15074 * External Values::
15075 * Case Construction::
15076 * Packages::
15077 * Package Renamings::
15078 * Projects::
15079 * Project Extensions::
15080 * Project File Elaboration::
15081 @end menu
15082
15083 @node Reserved Words
15084 @section Reserved Words
15085
15086 @noindent
15087 All Ada reserved words are reserved in project files, and cannot be used
15088 as variable names or project names. In addition, the following are
15089 also reserved in project files:
15090
15091 @itemize
15092 @item @code{extends}
15093
15094 @item @code{external}
15095
15096 @item @code{project}
15097
15098 @end itemize
15099
15100 @node Lexical Elements
15101 @section Lexical Elements
15102
15103 @noindent
15104 Rules for identifiers are the same as in Ada. Identifiers
15105 are case-insensitive.  Strings are case sensitive, except where noted.
15106 Comments have the same form as in Ada.
15107
15108 @noindent
15109 Syntax:
15110
15111 @smallexample
15112 simple_name ::=
15113   identifier
15114
15115 name ::=
15116   simple_name @{. simple_name@}
15117 @end smallexample
15118
15119 @node Declarations
15120 @section Declarations
15121
15122 @noindent
15123 Declarations introduce new entities that denote types, variables, attributes,
15124 and packages. Some declarations can only appear immediately within a project
15125 declaration. Others can appear within a project or within a package.
15126
15127 Syntax:
15128 @smallexample
15129 declarative_item ::=
15130   simple_declarative_item |
15131   typed_string_declaration |
15132   package_declaration
15133
15134 simple_declarative_item ::=
15135   variable_declaration |
15136   typed_variable_declaration |
15137   attribute_declaration |
15138   case_construction |
15139   empty_declaration
15140 @end smallexample
15141
15142 @node Empty declarations
15143 @section Empty declarations
15144
15145 @smallexample
15146 empty_declaration ::=
15147   @b{null} ;
15148 @end smallexample
15149
15150 An empty declaration is allowed anywhere a declaration is allowed.
15151 It has no effect.
15152
15153 @node Typed string declarations
15154 @section Typed string declarations
15155
15156 @noindent
15157 Typed strings are sequences of string literals. Typed strings are the only
15158 named types in project files. They are used in case constructions, where they
15159 provide support for conditional attribute definitions.
15160
15161 Syntax:
15162 @smallexample
15163 typed_string_declaration ::=
15164   @b{type} <typed_string_>_simple_name @b{is}
15165    ( string_literal @{, string_literal@} );
15166 @end smallexample
15167
15168 @noindent
15169 A typed string declaration can only appear immediately within a project
15170 declaration.
15171
15172 All the string literals in a typed string declaration must be distinct.
15173
15174 @node Variables
15175 @section Variables
15176
15177 @noindent
15178 Variables denote values, and appear as constituents of expressions.
15179
15180 @smallexample
15181 typed_variable_declaration ::=
15182   <typed_variable_>simple_name : <typed_string_>name :=  string_expression ;
15183
15184 variable_declaration ::=
15185   <variable_>simple_name := expression;
15186 @end smallexample
15187
15188 @noindent
15189 The elaboration of a variable declaration introduces the variable and
15190 assigns to it the value of the expression. The name of the variable is
15191 available after the assignment symbol.
15192
15193 @noindent
15194 A typed_variable can only be declare once.
15195
15196 @noindent
15197 a non typed variable can be declared multiple times.
15198
15199 @noindent
15200 Before the completion of its first declaration, the value of variable
15201 is the null string.
15202
15203 @node Expressions
15204 @section Expressions
15205
15206 @noindent
15207 An expression is a formula that defines a computation or retrieval of a value.
15208 In a project file the value of an expression is either a string or a list
15209 of strings. A string value in an expression is either a literal, the current
15210 value of a variable, an external value, an attribute reference, or a
15211 concatenation operation.
15212
15213 Syntax:
15214
15215 @smallexample
15216 expression ::=
15217   term @{& term@}
15218
15219 term ::=
15220   string_literal |
15221   string_list |
15222   <variable_>name |
15223   external_value |
15224   attribute_reference
15225
15226 string_literal ::=
15227   (same as Ada)
15228
15229 string_list ::=
15230   ( <string_>expression @{ , <string_>expression @} )
15231 @end smallexample
15232
15233 @subsection Concatenation
15234 @noindent
15235 The following concatenation functions are defined:
15236
15237 @smallexample @c ada
15238   function "&" (X : String;      Y : String)      return String;
15239   function "&" (X : String_List; Y : String)      return String_List;
15240   function "&" (X : String_List; Y : String_List) return String_List;
15241 @end smallexample
15242
15243 @node Attributes
15244 @section Attributes
15245
15246 @noindent
15247 An attribute declaration defines a property of a project or package. This
15248 property can later be queried by means of an attribute reference.
15249 Attribute values are strings or string lists.
15250
15251 Some attributes are associative arrays. These attributes are mappings whose
15252 domain is a set of strings. These attributes are declared one association
15253 at a time, by specifying a point in the domain and the corresponding image
15254 of the attribute. They may also be declared as a full associative array,
15255 getting the same associations as the corresponding attribute in an imported
15256 or extended project.
15257
15258 Attributes that are not associative arrays are called simple attributes.
15259
15260 Syntax:
15261 @smallexample
15262 attribute_declaration ::=
15263   full_associative_array_declaration |
15264   @b{for} attribute_designator @b{use} expression ;
15265
15266 full_associative_array_declaration ::=
15267   @b{for} <associative_array_attribute_>simple_name @b{use}
15268   <project_>simple_name [ . <package_>simple_Name ] ' <attribute_>simple_name ;
15269
15270 attribute_designator ::=
15271   <simple_attribute_>simple_name |
15272   <associative_array_attribute_>simple_name ( string_literal )
15273 @end smallexample
15274
15275 @noindent
15276 Some attributes are project-specific, and can only appear immediately within
15277 a project declaration. Others are package-specific, and can only appear within
15278 the proper package.
15279
15280 The expression in an attribute definition must be a string or a string_list.
15281 The string literal appearing in the attribute_designator of an associative
15282 array attribute is case-insensitive.
15283
15284 @node Project Attributes
15285 @section Project Attributes
15286
15287 @noindent
15288 The following attributes apply to a project. All of them are simple
15289 attributes.
15290
15291 @table @code
15292 @item   Object_Dir
15293 Expression must be a path name. The attribute defines the
15294 directory in which the object files created by the build are to be placed. If
15295 not specified, object files are placed in the project directory.
15296
15297 @item   Exec_Dir
15298 Expression must be a path name. The attribute defines the
15299 directory in which the executables created by the build are to be placed.
15300 If not specified, executables are placed in the object directory.
15301
15302 @item  Source_Dirs
15303 Expression must be a list of path names. The attribute
15304 defines the directories in which the source files for the project are to be
15305 found. If not specified, source files are found in the project directory.
15306 If a string in the list ends with "/**", then the directory that precedes
15307 "/**" and all of its subdirectories (recursively) are included in the list
15308 of source directories.
15309
15310 @item  Excluded_Source_Dirs
15311 Expression must be a list of strings. Each entry designates a directory that
15312 is not to be included in the list of source directories of the project.
15313 This is normally used when there are strings ending with "/**" in the value
15314 of attribute Source_Dirs.
15315
15316 @item  Source_Files
15317 Expression must be a list of file names. The attribute
15318 defines the individual files, in the project directory, which are to be used
15319 as sources for the project. File names are path_names that contain no directory
15320 information. If the project has no sources the attribute must be declared
15321 explicitly with an empty list.
15322
15323 @item  Excluded_Source_Files (Locally_Removed_Files)
15324 Expression must be a list of strings that are legal file names.
15325 Each file name must designate a source that would normally be a source file
15326 in the source directories of the project or, if the project file is an
15327 extending project file, inherited by the current project file. It cannot
15328 designate an immediate source that is not inherited. Each of the source files
15329 in the list are not considered to be sources of the project file: they are not
15330 inherited. Attribute Locally_Removed_Files is obsolescent, attribute
15331 Excluded_Source_Files is preferred.
15332
15333 @item  Source_List_File
15334 Expression must a single path name. The attribute
15335 defines a text file that contains a list of source file names to be used
15336 as sources for the project
15337
15338 @item  Library_Dir
15339 Expression must be a path name. The attribute defines the
15340 directory in which a  library is to be built.  The directory must exist, must
15341 be distinct from the project's object directory, and must be writable.
15342
15343 @item  Library_Name
15344 Expression must be a string that is a legal file name,
15345 without extension. The attribute defines a string that is used to generate
15346 the name of the library to be built by the project.
15347
15348 @item  Library_Kind
15349 Argument must be a string value that must be one of the
15350 following @code{"static"}, @code{"dynamic"} or @code{"relocatable"}. This
15351 string is case-insensitive. If this attribute is not specified, the library is
15352 a static library. Otherwise, the library may be dynamic or relocatable. This
15353 distinction is operating-system dependent.
15354
15355 @item  Library_Version
15356 Expression must be a string value whose interpretation
15357 is platform dependent. On UNIX, it is used only for dynamic/relocatable
15358 libraries as the internal name of the library (the @code{"soname"}). If the
15359 library file name (built from the @code{Library_Name}) is different from the
15360 @code{Library_Version}, then the library file will be a symbolic link to the
15361 actual file whose name will be @code{Library_Version}.
15362
15363 @item Library_Interface
15364 Expression must be a string list. Each element of the string list
15365 must designate a unit of the project.
15366 If this attribute is present in a Library Project File, then the project
15367 file is a Stand-alone Library_Project_File.
15368
15369 @item Library_Auto_Init
15370 Expression must be a single string "true" or "false", case-insensitive.
15371 If this attribute is present in a Stand-alone Library Project File,
15372 it indicates if initialization is automatic when the dynamic library
15373 is loaded.
15374
15375 @item Library_Options
15376 Expression must be a string list. Indicates additional switches that
15377 are to be used when building a shared library.
15378
15379 @item Library_GCC
15380 Expression must be a single string. Designates an alternative to "gcc"
15381 for building shared libraries.
15382
15383 @item  Library_Src_Dir
15384 Expression must be a path name. The attribute defines the
15385 directory in which the sources of the interfaces of a Stand-alone Library will
15386 be copied.  The directory must exist, must be distinct from the project's
15387 object directory and source directories of all projects in the project tree,
15388 and must be writable.
15389
15390 @item  Library_Src_Dir
15391 Expression must be a path name. The attribute defines the
15392 directory in which the ALI files of a Library will
15393 be copied.  The directory must exist, must be distinct from the project's
15394 object directory and source directories of all projects in the project tree,
15395 and must be writable.
15396
15397 @item  Library_Symbol_File
15398 Expression must be a single string. Its value is the single file name of a
15399 symbol file to be created when building a stand-alone library when the
15400 symbol policy is either "compliant", "controlled" or "restricted",
15401 on platforms that support symbol control, such as VMS. When symbol policy
15402 is "direct", then a file with this name must exist in the object directory.
15403
15404 @item   Library_Reference_Symbol_File
15405 Expression must be a single string. Its value is the path name of a
15406 reference symbol file that is read when the symbol policy is either
15407 "compliant" or "controlled", on platforms that support symbol control,
15408 such as VMS, when building a stand-alone library. The path may be an absolute
15409 path or a path relative to the project directory.
15410
15411 @item  Library_Symbol_Policy
15412 Expression must be a single string. Its case-insensitive value can only be
15413 "autonomous", "default", "compliant", "controlled", "restricted" or "direct".
15414
15415 This attribute is not taken into account on all platforms. It controls the
15416 policy for exported symbols and, on some platforms (like VMS) that have the
15417 notions of major and minor IDs built in the library files, it controls
15418 the setting of these IDs.
15419
15420 "autonomous" or "default": exported symbols are not controlled.
15421
15422 "compliant": if attribute Library_Reference_Symbol_File is not defined, then
15423 it is equivalent to policy "autonomous". If there are exported symbols in
15424 the reference symbol file that are not in the object files of the interfaces,
15425 the major ID of the library is increased. If there are symbols in the
15426 object files of the interfaces that are not in the reference symbol file,
15427 these symbols are put at the end of the list in the newly created symbol file
15428 and the minor ID is increased.
15429
15430 "controlled": the attribute Library_Reference_Symbol_File must be defined.
15431 The library will fail to build if the exported symbols in the object files of
15432 the interfaces do not match exactly the symbol in the symbol file.
15433
15434 "restricted": The attribute Library_Symbol_File must be defined. The library
15435 will fail to build if there are symbols in the symbol file that are not in
15436 the exported symbols of the object files of the interfaces. Additional symbols
15437 in the object files are not added to the symbol file.
15438
15439 "direct": The attribute Library_Symbol_File must be defined and must designate
15440 an existing file in the object directory. This symbol file is passed directly
15441 to the underlying linker without any symbol processing.
15442
15443 @item  Main
15444 Expression must be a list of strings that are legal file names.
15445 These file names designate existing compilation units in the source directory
15446 that are legal main subprograms.
15447
15448 When a project file is elaborated, as part of the execution of a gnatmake
15449 command, one or several executables are built and placed in the Exec_Dir.
15450 If the gnatmake command does not include explicit file names, the executables
15451 that are built correspond to the files specified by this attribute.
15452
15453 @item  Externally_Built
15454 Expression must be a single string. Its value must be either "true" of "false",
15455 case-insensitive. The default is "false". When the value of this attribute is
15456 "true", no attempt is made to compile the sources or to build the library,
15457 when the project is a library project.
15458
15459 @item Main_Language
15460 This is a simple attribute. Its value is a string that specifies the
15461 language of the main program.
15462
15463 @item  Languages
15464 Expression must be a string list. Each string designates
15465 a programming language that is known to GNAT. The strings are case-insensitive.
15466
15467 @end table
15468
15469 @node Attribute References
15470 @section Attribute References
15471
15472 @noindent
15473 Attribute references are used to retrieve the value of previously defined
15474 attribute for a package or project.
15475 Syntax:
15476 @smallexample
15477 attribute_reference ::=
15478   attribute_prefix ' <simple_attribute_>simple_name [ ( string_literal ) ]
15479
15480 attribute_prefix ::=
15481   @b{project} |
15482   <project_simple_name | package_identifier |
15483   <project_>simple_name . package_identifier
15484 @end smallexample
15485
15486 @noindent
15487 If an attribute has not been specified for a given package or project, its
15488 value is the null string or the empty list.
15489
15490 @node External Values
15491 @section External Values
15492
15493 @noindent
15494 An external value is an expression whose value is obtained from the command
15495 that invoked the processing of the current project file (typically a
15496 gnatmake command).
15497
15498 Syntax:
15499 @smallexample
15500 external_value ::=
15501   @b{external} ( string_literal [, string_literal] )
15502 @end smallexample
15503
15504 @noindent
15505 The first string_literal is the string to be used on the command line or
15506 in the environment to specify the external value. The second string_literal,
15507 if present, is the default to use if there is no specification for this
15508 external value either on the command line or in the environment.
15509
15510 @node Case Construction
15511 @section Case Construction
15512
15513 @noindent
15514 A case construction supports attribute and variable declarations that depend
15515 on the value of a previously declared variable.
15516
15517 Syntax:
15518 @smallexample
15519 case_construction ::=
15520   @b{case} <typed_variable_>name @b{is}
15521     @{case_item@}
15522   @b{end case} ;
15523
15524 case_item ::=
15525   @b{when} discrete_choice_list =>
15526     @{case_construction |
15527       attribute_declaration |
15528       variable_declaration |
15529       empty_declaration@}
15530
15531 discrete_choice_list ::=
15532   string_literal @{| string_literal@} |
15533     @b{others}
15534 @end smallexample
15535
15536 @noindent
15537 Inside a case construction, variable declarations must be for variables that
15538 have already been declared before the case construction.
15539
15540 All choices in a choice list must be distinct. The choice lists of two
15541 distinct alternatives must be disjoint. Unlike Ada, the choice lists of all
15542 alternatives do not need to include all values of the type. An @code{others}
15543 choice must appear last in the list of alternatives.
15544
15545 @node Packages
15546 @section Packages
15547
15548 @noindent
15549 A package provides a grouping of variable declarations and attribute
15550 declarations to be used when invoking various GNAT tools. The name of
15551 the package indicates the tool(s) to which it applies.
15552 Syntax:
15553
15554 @smallexample
15555 package_declaration ::=
15556   package_specification | package_renaming
15557
15558 package_specification ::=
15559   @b{package} package_identifier @b{is}
15560     @{simple_declarative_item@}
15561   @b{end} package_identifier ;
15562
15563 package_identifier ::=
15564   @code{Naming} | @code{Builder} | @code{Compiler} | @code{Binder} |
15565   @code{Linker} | @code{Finder}  | @code{Cross_Reference} |
15566   @code{gnatls} | @code{IDE}     | @code{Pretty_Printer}
15567 @end smallexample
15568
15569 @subsection Package Naming
15570
15571 @noindent
15572 The attributes of a @code{Naming} package specifies the naming conventions
15573 that apply to the source files in a project. When invoking other GNAT tools,
15574 they will use the sources in the source directories that satisfy these
15575 naming conventions.
15576
15577 The following attributes apply to a @code{Naming} package:
15578
15579 @table @code
15580 @item Casing
15581 This is a simple attribute whose value is a string. Legal values of this
15582 string are @code{"lowercase"}, @code{"uppercase"} or @code{"mixedcase"}.
15583 These strings are themselves case insensitive.
15584
15585 @noindent
15586 If @code{Casing} is not specified, then the default is @code{"lowercase"}.
15587
15588 @item Dot_Replacement
15589 This is a simple attribute whose string value satisfies the following
15590 requirements:
15591
15592 @itemize @bullet
15593 @item It must not be empty
15594 @item It cannot start or end with an alphanumeric character
15595 @item It cannot be a single underscore
15596 @item It cannot start with an underscore followed by an alphanumeric
15597 @item It cannot contain a dot @code{'.'} if longer than one character
15598 @end itemize
15599
15600 @noindent
15601 If @code{Dot_Replacement} is not specified, then the default is @code{"-"}.
15602
15603 @item Spec_Suffix
15604 This is an associative array attribute, defined on language names,
15605 whose image is a string that must satisfy the following
15606 conditions:
15607
15608 @itemize @bullet
15609 @item It must not be empty
15610 @item It cannot start with an alphanumeric character
15611 @item It cannot start with an underscore followed by an alphanumeric character
15612 @end itemize
15613
15614 @noindent
15615 For Ada, the attribute denotes the suffix used in file names that contain
15616 library unit declarations, that is to say units that are package and
15617 subprogram declarations. If @code{Spec_Suffix ("Ada")} is not
15618 specified, then the default is @code{".ads"}.
15619
15620 For C and C++, the attribute denotes the suffix used in file names that
15621 contain prototypes.
15622
15623 @item Body_Suffix
15624 This is an associative array attribute defined on language names,
15625 whose image is a string that must satisfy the following
15626 conditions:
15627
15628 @itemize @bullet
15629 @item It must not be empty
15630 @item It cannot start with an alphanumeric character
15631 @item It cannot start with an underscore followed by an alphanumeric character
15632 @item It cannot be a suffix of @code{Spec_Suffix}
15633 @end itemize
15634
15635 @noindent
15636 For Ada, the attribute denotes the suffix used in file names that contain
15637 library bodies, that is to say units that are package and subprogram bodies.
15638 If @code{Body_Suffix ("Ada")} is not specified, then the default is
15639 @code{".adb"}.
15640
15641 For C and C++, the attribute denotes the suffix used in file names that contain
15642 source code.
15643
15644 @item Separate_Suffix
15645 This is a simple attribute whose value satisfies the same conditions as
15646 @code{Body_Suffix}.
15647
15648 This attribute is specific to Ada. It denotes the suffix used in file names
15649 that contain separate bodies. If it is not specified, then it defaults to same
15650 value as @code{Body_Suffix ("Ada")}.
15651
15652 @item Spec
15653 This is an associative array attribute, specific to Ada, defined over
15654 compilation unit names. The image is a string that is the name of the file
15655 that contains that library unit. The file name is case sensitive if the
15656 conventions of the host operating system require it.
15657
15658 @item Body
15659 This is an associative array attribute, specific to Ada, defined over
15660 compilation unit names. The image is a string that is the name of the file
15661 that contains the library unit body for the named unit. The file name is case
15662 sensitive if the conventions of the host operating system require it.
15663
15664 @item Specification_Exceptions
15665 This is an associative array attribute defined on language names,
15666 whose value is a list of strings.
15667
15668 This attribute is not significant for Ada.
15669
15670 For C and C++, each string in the list denotes the name of a file that
15671 contains prototypes, but whose suffix is not necessarily the
15672 @code{Spec_Suffix} for the language.
15673
15674 @item Implementation_Exceptions
15675 This is an associative array attribute defined on language names,
15676 whose value is a list of strings.
15677
15678 This attribute is not significant for Ada.
15679
15680 For C and C++, each string in the list denotes the name of a file that
15681 contains source code, but whose suffix is not necessarily the
15682 @code{Body_Suffix} for the language.
15683 @end table
15684
15685 The following attributes of package @code{Naming} are obsolescent. They are
15686 kept as synonyms of other attributes for compatibility with previous versions
15687 of the Project Manager.
15688
15689 @table @code
15690 @item Specification_Suffix
15691 This is a synonym of @code{Spec_Suffix}.
15692
15693 @item Implementation_Suffix
15694 This is a synonym of @code{Body_Suffix}.
15695
15696 @item Specification
15697 This is a synonym of @code{Spec}.
15698
15699 @item Implementation
15700 This is a synonym of @code{Body}.
15701 @end table
15702
15703 @subsection package Compiler
15704
15705 @noindent
15706 The attributes of the @code{Compiler} package specify the compilation options
15707 to be used by the underlying compiler.
15708
15709 @table @code
15710 @item  Default_Switches
15711 This is an associative array attribute. Its
15712 domain is a set of language names. Its range is a string list that
15713 specifies the compilation options to be used when compiling a component
15714 written in that language, for which no file-specific switches have been
15715 specified.
15716
15717 @item  Switches
15718 This is an associative array attribute. Its domain is
15719 a set of file names. Its range is a string list that specifies the
15720 compilation options to be used when compiling the named file. If a file
15721 is not specified in the Switches attribute, it is compiled with the
15722 options specified by Default_Switches of its language, if defined.
15723
15724 @item  Local_Configuration_Pragmas.
15725 This is a simple attribute, whose
15726 value is a path name that designates a file containing configuration pragmas
15727 to be used for all invocations of the compiler for immediate sources of the
15728 project.
15729 @end table
15730
15731 @subsection package Builder
15732
15733 @noindent
15734 The attributes of package @code{Builder} specify the compilation, binding, and
15735 linking options to be used when building an executable for a project. The
15736 following attributes apply to package @code{Builder}:
15737
15738 @table @code
15739 @item Default_Switches
15740 This is an associative array attribute. Its
15741 domain is a set of language names. Its range is a string list that
15742 specifies options to be used when building a main
15743 written in that language, for which no file-specific switches have been
15744 specified.
15745
15746 @item Switches
15747 This is an associative array attribute. Its domain is
15748 a set of file names. Its range is a string list that specifies
15749 options to be used when building the named main file. If a main file
15750 is not specified in the Switches attribute, it is built with the
15751 options specified by Default_Switches of its language, if defined.
15752
15753 @item Global_Configuration_Pragmas
15754 This is a simple attribute, whose
15755 value is a path name that designates a file that contains configuration pragmas
15756 to be used in every build of an executable. If both local and global
15757 configuration pragmas are specified, a compilation makes use of both sets.
15758
15759
15760 @item Executable
15761 This is an associative array attribute. Its domain is
15762 a set of main source file names. Its range is a simple string that specifies
15763 the executable file name to be used when linking the specified main source.
15764 If a main source is not specified in the Executable attribute, the executable
15765 file name is deducted from the main source file name.
15766 This attribute has no effect if its value is the empty string.
15767
15768 @item Executable_Suffix
15769 This is a simple attribute whose value is the suffix to be added to
15770 the executables that don't have an attribute Executable specified.
15771 @end table
15772
15773 @subsection package Gnatls
15774
15775 @noindent
15776 The attributes of package @code{Gnatls} specify the tool options to be used
15777 when invoking the library browser @command{gnatls}.
15778 The following attributes apply to package @code{Gnatls}:
15779
15780 @table @code
15781 @item Switches
15782 This is a single attribute with a string list value. Each non empty string
15783 in the list is an option when invoking @code{gnatls}.
15784 @end table
15785
15786 @subsection package Binder
15787
15788 @noindent
15789 The attributes of package @code{Binder} specify the options to be used
15790 when invoking the binder in the construction of an executable.
15791 The following attributes apply to package @code{Binder}:
15792
15793 @table @code
15794 @item     Default_Switches
15795 This is an associative array attribute. Its
15796 domain is a set of language names. Its range is a string list that
15797 specifies options to be used when binding a main
15798 written in that language, for which no file-specific switches have been
15799 specified.
15800
15801 @item Switches
15802 This is an associative array attribute. Its domain is
15803 a set of file names. Its range is a string list that specifies
15804 options to be used when binding the named main file. If a main file
15805 is not specified in the Switches attribute, it is bound with the
15806 options specified by Default_Switches of its language, if defined.
15807 @end table
15808
15809 @subsection package Linker
15810
15811 @noindent
15812 The attributes of package @code{Linker} specify the options to be used when
15813 invoking the linker in the construction of an executable.
15814 The following attributes apply to package @code{Linker}:
15815
15816 @table @code
15817 @item     Default_Switches
15818 This is an associative array attribute. Its
15819 domain is a set of language names. Its range is a string list that
15820 specifies options to be used when linking a main
15821 written in that language, for which no file-specific switches have been
15822 specified.
15823
15824 @item Switches
15825 This is an associative array attribute. Its domain is
15826 a set of file names. Its range is a string list that specifies
15827 options to be used when linking the named main file. If a main file
15828 is not specified in the Switches attribute, it is linked with the
15829 options specified by Default_Switches of its language, if defined.
15830
15831 @item  Linker_Options
15832 This is a string list attribute. Its value specifies additional options that
15833 be given to the linker when linking an executable. This attribute is not
15834 used in the main project, only in projects imported directly or indirectly.
15835
15836 @end table
15837
15838 @subsection package Cross_Reference
15839
15840 @noindent
15841 The attributes of package @code{Cross_Reference} specify the tool options
15842 to be used
15843 when invoking the library tool @command{gnatxref}.
15844 The following attributes apply to package @code{Cross_Reference}:
15845
15846 @table @code
15847 @item     Default_Switches
15848 This is an associative array attribute. Its
15849 domain is a set of language names. Its range is a string list that
15850 specifies options to be used when calling @command{gnatxref} on a source
15851 written in that language, for which no file-specific switches have been
15852 specified.
15853
15854 @item Switches
15855 This is an associative array attribute. Its domain is
15856 a set of file names. Its range is a string list that specifies
15857 options to be used when calling @command{gnatxref} on the named main source.
15858 If a source is not specified in the Switches attribute, @command{gnatxref} will
15859 be called with the options specified by Default_Switches of its language,
15860 if defined.
15861 @end table
15862
15863 @subsection package   Finder
15864
15865 @noindent
15866 The attributes of package @code{Finder} specify the tool options to be used
15867 when invoking the search tool @command{gnatfind}.
15868 The following attributes apply to package @code{Finder}:
15869
15870 @table @code
15871 @item     Default_Switches
15872 This is an associative array attribute. Its
15873 domain is a set of language names. Its range is a string list that
15874 specifies options to be used when calling @command{gnatfind} on a source
15875 written in that language, for which no file-specific switches have been
15876 specified.
15877
15878 @item Switches
15879 This is an associative array attribute. Its domain is
15880 a set of file names. Its range is a string list that specifies
15881 options to be used when calling @command{gnatfind} on the named main source.
15882 If a source is not specified in the Switches attribute, @command{gnatfind} will
15883 be called with the options specified by Default_Switches of its language,
15884 if defined.
15885 @end table
15886
15887 @subsection package Pretty_Printer
15888
15889 @noindent
15890 The attributes of package @code{Pretty_Printer}
15891 specify the tool options to be used
15892 when invoking the formatting tool @command{gnatpp}.
15893 The following attributes apply to package @code{Pretty_Printer}:
15894
15895 @table @code
15896 @item     Default_switches
15897 This is an associative array attribute. Its
15898 domain is a set of language names. Its range is a string list that
15899 specifies options to be used when calling @command{gnatpp} on a source
15900 written in that language, for which no file-specific switches have been
15901 specified.
15902
15903 @item Switches
15904 This is an associative array attribute. Its domain is
15905 a set of file names. Its range is a string list that specifies
15906 options to be used when calling @command{gnatpp} on the named main source.
15907 If a source is not specified in the Switches attribute, @command{gnatpp} will
15908 be called with the options specified by Default_Switches of its language,
15909 if defined.
15910 @end table
15911
15912 @subsection package gnatstub
15913
15914 @noindent
15915 The attributes of package @code{gnatstub}
15916 specify the tool options to be used
15917 when invoking the tool @command{gnatstub}.
15918 The following attributes apply to package @code{gnatstub}:
15919
15920 @table @code
15921 @item     Default_switches
15922 This is an associative array attribute. Its
15923 domain is a set of language names. Its range is a string list that
15924 specifies options to be used when calling @command{gnatstub} on a source
15925 written in that language, for which no file-specific switches have been
15926 specified.
15927
15928 @item Switches
15929 This is an associative array attribute. Its domain is
15930 a set of file names. Its range is a string list that specifies
15931 options to be used when calling @command{gnatstub} on the named main source.
15932 If a source is not specified in the Switches attribute, @command{gnatpp} will
15933 be called with the options specified by Default_Switches of its language,
15934 if defined.
15935 @end table
15936
15937 @subsection package Eliminate
15938
15939 @noindent
15940 The attributes of package @code{Eliminate}
15941 specify the tool options to be used
15942 when invoking the tool @command{gnatelim}.
15943 The following attributes apply to package @code{Eliminate}:
15944
15945 @table @code
15946 @item     Default_switches
15947 This is an associative array attribute. Its
15948 domain is a set of language names. Its range is a string list that
15949 specifies options to be used when calling @command{gnatelim} on a source
15950 written in that language, for which no file-specific switches have been
15951 specified.
15952
15953 @item Switches
15954 This is an associative array attribute. Its domain is
15955 a set of file names. Its range is a string list that specifies
15956 options to be used when calling @command{gnatelim} on the named main source.
15957 If a source is not specified in the Switches attribute, @command{gnatelim} will
15958 be called with the options specified by Default_Switches of its language,
15959 if defined.
15960 @end table
15961
15962 @subsection package Metrics
15963
15964 @noindent
15965 The attributes of package @code{Metrics}
15966 specify the tool options to be used
15967 when invoking the tool @command{gnatmetric}.
15968 The following attributes apply to package @code{Metrics}:
15969
15970 @table @code
15971 @item     Default_switches
15972 This is an associative array attribute. Its
15973 domain is a set of language names. Its range is a string list that
15974 specifies options to be used when calling @command{gnatmetric} on a source
15975 written in that language, for which no file-specific switches have been
15976 specified.
15977
15978 @item Switches
15979 This is an associative array attribute. Its domain is
15980 a set of file names. Its range is a string list that specifies
15981 options to be used when calling @command{gnatmetric} on the named main source.
15982 If a source is not specified in the Switches attribute, @command{gnatmetric}
15983 will be called with the options specified by Default_Switches of its language,
15984 if defined.
15985 @end table
15986
15987 @subsection  package IDE
15988
15989 @noindent
15990 The attributes of package @code{IDE} specify the options to be used when using
15991 an Integrated Development Environment such as @command{GPS}.
15992
15993 @table @code
15994 @item Remote_Host
15995 This is a simple attribute. Its value is a string that designates the remote
15996 host in a cross-compilation environment, to be used for remote compilation and
15997 debugging. This field should not be specified when running on the local
15998 machine.
15999
16000 @item Program_Host
16001 This is a simple attribute. Its value is a string that specifies the
16002 name of IP address of the embedded target in a cross-compilation environment,
16003 on which the program should execute.
16004
16005 @item Communication_Protocol
16006 This is a simple string attribute. Its value is the name of the protocol
16007 to use to communicate with the target in a cross-compilation environment,
16008 e.g. @code{"wtx"} or @code{"vxworks"}.
16009
16010 @item Compiler_Command
16011 This is an associative array attribute, whose domain is a language name. Its
16012 value is  string that denotes the command to be used to invoke the compiler.
16013 The value of @code{Compiler_Command ("Ada")} is expected to be compatible with
16014 gnatmake, in particular in the handling of switches.
16015
16016 @item Debugger_Command
16017 This is simple attribute, Its value is a string that specifies the name of
16018 the debugger to be used, such as gdb, powerpc-wrs-vxworks-gdb or gdb-4.
16019
16020 @item Default_Switches
16021 This is an associative array attribute. Its indexes are the name of the
16022 external tools that the GNAT Programming System (GPS) is supporting. Its
16023 value is a list of switches to use when invoking that tool.
16024
16025 @item  Gnatlist
16026 This is a simple attribute.  Its value is a string that specifies the name
16027 of the @command{gnatls} utility to be used to retrieve information about the
16028 predefined path; e.g., @code{"gnatls"}, @code{"powerpc-wrs-vxworks-gnatls"}.
16029
16030 @item VCS_Kind
16031 This is a simple attribute. Its value is a string used to specify the
16032 Version Control System (VCS) to be used for this project, e.g CVS, RCS
16033 ClearCase or Perforce.
16034
16035 @item VCS_File_Check
16036 This is a simple attribute. Its value is a string that specifies the
16037 command used by the VCS to check the validity of a file, either
16038 when the user explicitly asks for a check, or as a sanity check before
16039 doing the check-in.
16040
16041 @item VCS_Log_Check
16042 This is a simple attribute. Its value is a string that specifies
16043 the command used by the VCS to check the validity of a log file.
16044
16045 @item VCS_Repository_Root
16046 The VCS repository root path. This is used to create tags or branches
16047 of the repository. For subversion the value should be the @code{URL}
16048 as specified to check-out the working copy of the repository.
16049
16050 @item VCS_Patch_Root
16051 The local root directory to use for building patch file. All patch chunks
16052 will be relative to this path. The root project directory is used if
16053 this value is not defined.
16054
16055 @end table
16056
16057 @node Package Renamings
16058 @section Package Renamings
16059
16060 @noindent
16061 A package can be defined by a renaming declaration. The new package renames
16062 a package declared in a different project file, and has the same attributes
16063 as the package it renames.
16064 Syntax:
16065 @smallexample
16066 package_renaming ::==
16067   @b{package} package_identifier @b{renames}
16068        <project_>simple_name.package_identifier ;
16069 @end smallexample
16070
16071 @noindent
16072 The package_identifier of the renamed package must be the same as the
16073 package_identifier. The project whose name is the prefix of the renamed
16074 package must contain a package declaration with this name. This project
16075 must appear in the context_clause of the enclosing project declaration,
16076 or be the parent project of the enclosing child project.
16077
16078 @node Projects
16079 @section Projects
16080
16081 @noindent
16082 A project file specifies a set of rules for constructing a software system.
16083 A project file can be self-contained, or depend on other project files.
16084 Dependencies are expressed through a context clause that names other projects.
16085
16086 Syntax:
16087
16088 @smallexample
16089 project ::=
16090   context_clause project_declaration
16091
16092 project_declaration ::=
16093   simple_project_declaration | project_extension
16094
16095 simple_project_declaration ::=
16096   @b{project} <project_>simple_name @b{is}
16097     @{declarative_item@}
16098   @b{end} <project_>simple_name;
16099
16100 context_clause ::=
16101   @{with_clause@}
16102
16103 with_clause ::=
16104   [@b{limited}] @b{with} path_name @{ , path_name @} ;
16105
16106 path_name ::=
16107    string_literal
16108 @end smallexample
16109
16110 @noindent
16111 A path name denotes a project file. A path name can be absolute or relative.
16112 An absolute path name includes a sequence of directories, in the syntax of
16113 the host operating system, that identifies uniquely the project file in the
16114 file system. A relative path name identifies the project file, relative
16115 to the directory that contains the current project, or relative to a
16116 directory listed in the environment variable ADA_PROJECT_PATH.
16117 Path names are case sensitive if file names in the host operating system
16118 are case sensitive.
16119
16120 The syntax of the environment variable ADA_PROJECT_PATH is a list of
16121 directory names separated by colons (semicolons on Windows).
16122
16123 A given project name can appear only once in a context_clause.
16124
16125 It is illegal for a project imported by a context clause to refer, directly
16126 or indirectly, to the project in which this context clause appears (the
16127 dependency graph cannot contain cycles), except when one of the with_clause
16128 in the cycle is a @code{limited with}.
16129
16130 @node Project Extensions
16131 @section Project Extensions
16132
16133 @noindent
16134 A project extension introduces a new project, which inherits the declarations
16135 of another project.
16136 Syntax:
16137 @smallexample
16138
16139 project_extension ::=
16140   @b{project} <project_>simple_name  @b{extends} path_name @b{is}
16141     @{declarative_item@}
16142   @b{end} <project_>simple_name;
16143 @end smallexample
16144
16145 @noindent
16146 The project extension declares a child project. The child project inherits
16147 all the declarations and all the files of the parent project, These inherited
16148 declaration can be overridden in the child project, by means of suitable
16149 declarations.
16150
16151 @node Project File Elaboration
16152 @section Project File Elaboration
16153
16154 @noindent
16155 A project file is processed as part of the invocation of a gnat tool that
16156 uses the project option. Elaboration of the process file consists in the
16157 sequential elaboration of all its declarations. The computed values of
16158 attributes and variables in the project are then used to establish the
16159 environment in which the gnat tool will execute.
16160
16161 @node Obsolescent Features
16162 @chapter Obsolescent Features
16163
16164 @noindent
16165 This chapter describes features that are provided by GNAT, but are
16166 considered obsolescent since there are preferred ways of achieving
16167 the same effect. These features are provided solely for historical
16168 compatibility purposes.
16169
16170 @menu
16171 * pragma No_Run_Time::
16172 * pragma Ravenscar::
16173 * pragma Restricted_Run_Time::
16174 @end menu
16175
16176 @node pragma No_Run_Time
16177 @section pragma No_Run_Time
16178
16179 The pragma @code{No_Run_Time} is used to achieve an affect similar
16180 to the use of the "Zero Foot Print" configurable run time, but without
16181 requiring a specially configured run time. The result of using this
16182 pragma, which must be used for all units in a partition, is to restrict
16183 the use of any language features requiring run-time support code. The
16184 preferred usage is to use an appropriately configured run-time that
16185 includes just those features that are to be made accessible.
16186
16187 @node pragma Ravenscar
16188 @section pragma Ravenscar
16189
16190 The pragma @code{Ravenscar} has exactly the same effect as pragma
16191 @code{Profile (Ravenscar)}. The latter usage is preferred since it
16192 is part of the new Ada 2005 standard.
16193
16194 @node pragma Restricted_Run_Time
16195 @section pragma Restricted_Run_Time
16196
16197 The pragma @code{Restricted_Run_Time} has exactly the same effect as
16198 pragma @code{Profile (Restricted)}. The latter usage is
16199 preferred since the Ada 2005 pragma @code{Profile} is intended for
16200 this kind of implementation dependent addition.
16201
16202 @include fdl.texi
16203 @c GNU Free Documentation License
16204
16205 @node Index,,GNU Free Documentation License, Top
16206 @unnumbered Index
16207
16208 @printindex cp
16209
16210 @contents
16211
16212 @bye