gcc/ChangeLog ---------------------------------------------------------
[official-gcc.git] / gcc / ada / gnat_rm.texi
blob8c5f79f5bfccaea13d47e8c70a0c65420e58070c
1 \input texinfo   @c -*-texinfo-*-
3 @c %**start of header
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-2006 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
18 @setfilename gnat_rm.info
20 @set EDITION GNAT
21 @settitle GNAT Reference Manual
23 @setchapternewpage odd
24 @syncodeindex fn cp
26 @include gcc-common.texi
28 @dircategory GNU Ada tools
29 @direntry
30 * GNAT Reference Manual: (gnat_rm).  Reference Manual for GNU Ada tools.
31 @end direntry
33 @copying
34 Copyright @copyright{} 1995-2004, Free Software Foundation
36 Permission is granted to copy, distribute and/or modify this document
37 under the terms of the GNU Free Documentation License, Version 1.2
38 or any later version published by the Free Software Foundation;
39 with the Invariant Sections being ``GNU Free Documentation License'',
40 with the Front-Cover Texts being ``GNAT Reference Manual'', and with
41 no Back-Cover Texts. A copy of the license is included in the section
42 entitled ``GNU Free Documentation License''.
43 @end copying
45 @titlepage
46 @title GNAT Reference Manual
47 @subtitle GNAT, The GNU Ada 95 Compiler
48 @versionsubtitle
49 @author Ada Core Technologies, Inc.
50 @page
51 @vskip 0pt plus 1filll
53 @insertcopying
55 @end titlepage
57 @ifnottex
58 @node Top, About This Guide, (dir), (dir)
59 @top GNAT Reference Manual
61 @noindent
62 GNAT Reference Manual
64 @noindent
65 GNAT, The GNU Ada 95 Compiler@*
66 GCC version @value{version-GCC}@*
68 @noindent
69 AdaCore
71 @menu
72 * About This Guide::
73 * Implementation Defined Pragmas::
74 * Implementation Defined Attributes::
75 * Implementation Advice::
76 * Implementation Defined Characteristics::
77 * Intrinsic Subprograms::
78 * Representation Clauses and Pragmas::
79 * Standard Library Routines::
80 * The Implementation of Standard I/O::
81 * The GNAT Library::
82 * Interfacing to Other Languages::
83 * Specialized Needs Annexes::
84 * Implementation of Specific Ada Features::
85 * Project File Reference::
86 * Obsolescent Features::
87 * GNU Free Documentation License::
88 * Index::
90  --- The Detailed Node Listing ---
92 About This Guide
94 * What This Reference Manual Contains::
95 * Related Information::
97 Implementation Defined Pragmas
99 * Pragma Abort_Defer::
100 * Pragma Ada_83::
101 * Pragma Ada_95::
102 * Pragma Ada_05::
103 * Pragma Ada_2005::
104 * Pragma Annotate::
105 * Pragma Assert::
106 * Pragma Ast_Entry::
107 * Pragma C_Pass_By_Copy::
108 * Pragma Comment::
109 * Pragma Common_Object::
110 * Pragma Compile_Time_Warning::
111 * Pragma Complete_Representation::
112 * Pragma Complex_Representation::
113 * Pragma Component_Alignment::
114 * Pragma Convention_Identifier::
115 * Pragma CPP_Class::
116 * Pragma CPP_Constructor::
117 * Pragma CPP_Virtual::
118 * Pragma CPP_Vtable::
119 * Pragma Debug::
120 * Pragma Debug_Policy::
121 * Pragma Detect_Blocking::
122 * Pragma Elaboration_Checks::
123 * Pragma Eliminate::
124 * Pragma Export_Exception::
125 * Pragma Export_Function::
126 * Pragma Export_Object::
127 * Pragma Export_Procedure::
128 * Pragma Export_Value::
129 * Pragma Export_Valued_Procedure::
130 * Pragma Extend_System::
131 * Pragma External::
132 * Pragma External_Name_Casing::
133 * Pragma Finalize_Storage_Only::
134 * Pragma Float_Representation::
135 * Pragma Ident::
136 * Pragma Import_Exception::
137 * Pragma Import_Function::
138 * Pragma Import_Object::
139 * Pragma Import_Procedure::
140 * Pragma Import_Valued_Procedure::
141 * Pragma Initialize_Scalars::
142 * Pragma Inline_Always::
143 * Pragma Inline_Generic::
144 * Pragma Interface::
145 * Pragma Interface_Name::
146 * Pragma Interrupt_Handler::
147 * Pragma Interrupt_State::
148 * Pragma Keep_Names::
149 * Pragma License::
150 * Pragma Link_With::
151 * Pragma Linker_Alias::
152 * Pragma Linker_Constructor::
153 * Pragma Linker_Destructor::
154 * Pragma Linker_Section::
155 * Pragma Long_Float::
156 * Pragma Machine_Attribute::
157 * Pragma Main_Storage::
158 * Pragma No_Return::
159 * Pragma No_Strict_Aliasing ::
160 * Pragma Normalize_Scalars::
161 * Pragma Obsolescent::
162 * Pragma Passive::
163 * Pragma Persistent_BSS::
164 * Pragma Polling::
165 * Pragma Profile (Ravenscar)::
166 * Pragma Profile (Restricted)::
167 * Pragma Psect_Object::
168 * Pragma Pure_Function::
169 * Pragma Restriction_Warnings::
170 * Pragma Source_File_Name::
171 * Pragma Source_File_Name_Project::
172 * Pragma Source_Reference::
173 * Pragma Stream_Convert::
174 * Pragma Style_Checks::
175 * Pragma Subtitle::
176 * Pragma Suppress::
177 * Pragma Suppress_All::
178 * Pragma Suppress_Exception_Locations::
179 * Pragma Suppress_Initialization::
180 * Pragma Task_Info::
181 * Pragma Task_Name::
182 * Pragma Task_Storage::
183 * Pragma Thread_Body::
184 * Pragma Time_Slice::
185 * Pragma Title::
186 * Pragma Unchecked_Union::
187 * Pragma Unimplemented_Unit::
188 * Pragma Universal_Data::
189 * Pragma Unreferenced::
190 * Pragma Unreserve_All_Interrupts::
191 * Pragma Unsuppress::
192 * Pragma Use_VADS_Size::
193 * Pragma Validity_Checks::
194 * Pragma Volatile::
195 * Pragma Warnings::
196 * Pragma Weak_External::
197 * Pragma Wide_Character_Encoding::
199 Implementation Defined Attributes
201 * Abort_Signal::
202 * Address_Size::
203 * Asm_Input::
204 * Asm_Output::
205 * AST_Entry::
206 * Bit::
207 * Bit_Position::
208 * Code_Address::
209 * Default_Bit_Order::
210 * Elaborated::
211 * Elab_Body::
212 * Elab_Spec::
213 * Emax::
214 * Enum_Rep::
215 * Epsilon::
216 * Fixed_Value::
217 * Has_Access_Values::
218 * Has_Discriminants::
219 * Img::
220 * Integer_Value::
221 * Large::
222 * Machine_Size::
223 * Mantissa::
224 * Max_Interrupt_Priority::
225 * Max_Priority::
226 * Maximum_Alignment::
227 * Mechanism_Code::
228 * Null_Parameter::
229 * Object_Size::
230 * Passed_By_Reference::
231 * Range_Length::
232 * Safe_Emax::
233 * Safe_Large::
234 * Small::
235 * Storage_Unit::
236 * Stub_Type::
237 * Target_Name::
238 * Tick::
239 * To_Address::
240 * Type_Class::
241 * UET_Address::
242 * Unconstrained_Array::
243 * Universal_Literal_String::
244 * Unrestricted_Access::
245 * VADS_Size::
246 * Value_Size::
247 * Wchar_T_Size::
248 * Word_Size::
250 The Implementation of Standard I/O
252 * Standard I/O Packages::
253 * FORM Strings::
254 * Direct_IO::
255 * Sequential_IO::
256 * Text_IO::
257 * Wide_Text_IO::
258 * Wide_Wide_Text_IO::
259 * Stream_IO::
260 * Shared Files::
261 * Open Modes::
262 * Operations on C Streams::
263 * Interfacing to C Streams::
265 The GNAT Library
267 * Ada.Characters.Latin_9 (a-chlat9.ads)::
268 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
269 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
270 * Ada.Characters.Wide_Wide_Latin_1 (a-czila1.ads)::
271 * Ada.Characters.Wide_Wide_Latin_9 (a-czila9.ads)::
272 * Ada.Command_Line.Remove (a-colire.ads)::
273 * Ada.Command_Line.Environment (a-colien.ads)::
274 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
275 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
276 * Ada.Exceptions.Traceback (a-exctra.ads)::
277 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
278 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
279 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
280 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
281 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
282 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
283 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
284 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
285 * GNAT.Altivec (g-altive.ads)::
286 * GNAT.Altivec.Conversions (g-altcon.ads)::
287 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
288 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
289 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
290 * GNAT.Array_Split (g-arrspl.ads)::
291 * GNAT.AWK (g-awk.ads)::
292 * GNAT.Bounded_Buffers (g-boubuf.ads)::
293 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
294 * GNAT.Bubble_Sort (g-bubsor.ads)::
295 * GNAT.Bubble_Sort_A (g-busora.ads)::
296 * GNAT.Bubble_Sort_G (g-busorg.ads)::
297 * GNAT.Calendar (g-calend.ads)::
298 * GNAT.Calendar.Time_IO (g-catiio.ads)::
299 * GNAT.Case_Util (g-casuti.ads)::
300 * GNAT.CGI (g-cgi.ads)::
301 * GNAT.CGI.Cookie (g-cgicoo.ads)::
302 * GNAT.CGI.Debug (g-cgideb.ads)::
303 * GNAT.Command_Line (g-comlin.ads)::
304 * GNAT.Compiler_Version (g-comver.ads)::
305 * GNAT.Ctrl_C (g-ctrl_c.ads)::
306 * GNAT.CRC32 (g-crc32.ads)::
307 * GNAT.Current_Exception (g-curexc.ads)::
308 * GNAT.Debug_Pools (g-debpoo.ads)::
309 * GNAT.Debug_Utilities (g-debuti.ads)::
310 * GNAT.Directory_Operations (g-dirope.ads)::
311 * GNAT.Dynamic_HTables (g-dynhta.ads)::
312 * GNAT.Dynamic_Tables (g-dyntab.ads)::
313 * GNAT.Exception_Actions (g-excact.ads)::
314 * GNAT.Exception_Traces (g-exctra.ads)::
315 * GNAT.Exceptions (g-except.ads)::
316 * GNAT.Expect (g-expect.ads)::
317 * GNAT.Float_Control (g-flocon.ads)::
318 * GNAT.Heap_Sort (g-heasor.ads)::
319 * GNAT.Heap_Sort_A (g-hesora.ads)::
320 * GNAT.Heap_Sort_G (g-hesorg.ads)::
321 * GNAT.HTable (g-htable.ads)::
322 * GNAT.IO (g-io.ads)::
323 * GNAT.IO_Aux (g-io_aux.ads)::
324 * GNAT.Lock_Files (g-locfil.ads)::
325 * GNAT.MD5 (g-md5.ads)::
326 * GNAT.Memory_Dump (g-memdum.ads)::
327 * GNAT.Most_Recent_Exception (g-moreex.ads)::
328 * GNAT.OS_Lib (g-os_lib.ads)::
329 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
330 * GNAT.Regexp (g-regexp.ads)::
331 * GNAT.Registry (g-regist.ads)::
332 * GNAT.Regpat (g-regpat.ads)::
333 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
334 * GNAT.Semaphores (g-semaph.ads)::
335 * GNAT.Signals (g-signal.ads)::
336 * GNAT.Sockets (g-socket.ads)::
337 * GNAT.Source_Info (g-souinf.ads)::
338 * GNAT.Spell_Checker (g-speche.ads)::
339 * GNAT.Spitbol.Patterns (g-spipat.ads)::
340 * GNAT.Spitbol (g-spitbo.ads)::
341 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
342 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
343 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
344 * GNAT.Strings (g-string.ads)::
345 * GNAT.String_Split (g-strspl.ads)::
346 * GNAT.Table (g-table.ads)::
347 * GNAT.Task_Lock (g-tasloc.ads)::
348 * GNAT.Threads (g-thread.ads)::
349 * GNAT.Traceback (g-traceb.ads)::
350 * GNAT.Traceback.Symbolic (g-trasym.ads)::
351 * GNAT.Wide_String_Split (g-wistsp.ads)::
352 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
353 * Interfaces.C.Extensions (i-cexten.ads)::
354 * Interfaces.C.Streams (i-cstrea.ads)::
355 * Interfaces.CPP (i-cpp.ads)::
356 * Interfaces.Os2lib (i-os2lib.ads)::
357 * Interfaces.Os2lib.Errors (i-os2err.ads)::
358 * Interfaces.Os2lib.Synchronization (i-os2syn.ads)::
359 * Interfaces.Os2lib.Threads (i-os2thr.ads)::
360 * Interfaces.Packed_Decimal (i-pacdec.ads)::
361 * Interfaces.VxWorks (i-vxwork.ads)::
362 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
363 * System.Address_Image (s-addima.ads)::
364 * System.Assertions (s-assert.ads)::
365 * System.Memory (s-memory.ads)::
366 * System.Partition_Interface (s-parint.ads)::
367 * System.Restrictions (s-restri.ads)::
368 * System.Rident (s-rident.ads)::
369 * System.Task_Info (s-tasinf.ads)::
370 * System.Wch_Cnv (s-wchcnv.ads)::
371 * System.Wch_Con (s-wchcon.ads)::
373 Text_IO
375 * Text_IO Stream Pointer Positioning::
376 * Text_IO Reading and Writing Non-Regular Files::
377 * Get_Immediate::
378 * Treating Text_IO Files as Streams::
379 * Text_IO Extensions::
380 * Text_IO Facilities for Unbounded Strings::
382 Wide_Text_IO
384 * Wide_Text_IO Stream Pointer Positioning::
385 * Wide_Text_IO Reading and Writing Non-Regular Files::
387 Wide_Wide_Text_IO
389 * Wide_Wide_Text_IO Stream Pointer Positioning::
390 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
392 Interfacing to Other Languages
394 * Interfacing to C::
395 * Interfacing to C++::
396 * Interfacing to COBOL::
397 * Interfacing to Fortran::
398 * Interfacing to non-GNAT Ada code::
400 Specialized Needs Annexes
402 Implementation of Specific Ada Features
403 * Machine Code Insertions::
404 * GNAT Implementation of Tasking::
405 * GNAT Implementation of Shared Passive Packages::
406 * Code Generation for Array Aggregates::
407 * The Size of Discriminated Records with Default Discriminants::
408 * Strict Conformance to the Ada 95 Reference Manual::
410 Project File Reference
412 Obsolescent Features
414 GNU Free Documentation License
416 Index
417 @end menu
419 @end ifnottex
421 @node About This Guide
422 @unnumbered About This Guide
424 @ifclear PROEDITION
425 @noindent
426 This manual contains useful information in writing programs using the
427 GNAT compiler.  It includes information on implementation dependent
428 characteristics of GNAT, including all the information required by Annex
429 M of the standard.
430 @end ifclear
432 @ifset PROEDITION
433 @noindent
434 This manual contains useful information in writing programs using the
435 GNAT Pro compiler.  It includes information on implementation dependent
436 characteristics of GNAT Pro, including all the information required by Annex
437 M of the standard.
438 @end ifset
440 Ada 95 is designed to be highly portable.
441 In general, a program will have the same effect even when compiled by
442 different compilers on different platforms.
443 However, since Ada 95 is designed to be used in a
444 wide variety of applications, it also contains a number of system
445 dependent features to be used in interfacing to the external world.
446 @cindex Implementation-dependent features
447 @cindex Portability
449 Note: Any program that makes use of implementation-dependent features
450 may be non-portable.  You should follow good programming practice and
451 isolate and clearly document any sections of your program that make use
452 of these features in a non-portable manner.
454 @ifset PROEDITION
455 For ease of exposition, ``GNAT Pro'' will be referred to simply as
456 ``GNAT'' in the remainder of this document.
457 @end ifset
459 @menu
460 * What This Reference Manual Contains::
461 * Conventions::
462 * Related Information::
463 @end menu
465 @node What This Reference Manual Contains
466 @unnumberedsec What This Reference Manual Contains
468 @noindent
469 This reference manual contains the following chapters:
471 @itemize @bullet
472 @item
473 @ref{Implementation Defined Pragmas}, lists GNAT implementation-dependent
474 pragmas, which can be used to extend and enhance the functionality of the
475 compiler.
477 @item
478 @ref{Implementation Defined Attributes}, lists GNAT
479 implementation-dependent attributes which can be used to extend and
480 enhance the functionality of the compiler.
482 @item
483 @ref{Implementation Advice}, provides information on generally
484 desirable behavior which are not requirements that all compilers must
485 follow since it cannot be provided on all systems, or which may be
486 undesirable on some systems.
488 @item
489 @ref{Implementation Defined Characteristics}, provides a guide to
490 minimizing implementation dependent features.
492 @item
493 @ref{Intrinsic Subprograms}, describes the intrinsic subprograms
494 implemented by GNAT, and how they can be imported into user
495 application programs.
497 @item
498 @ref{Representation Clauses and Pragmas}, describes in detail the
499 way that GNAT represents data, and in particular the exact set
500 of representation clauses and pragmas that is accepted.
502 @item
503 @ref{Standard Library Routines}, provides a listing of packages and a
504 brief description of the functionality that is provided by Ada's
505 extensive set of standard library routines as implemented by GNAT@.
507 @item
508 @ref{The Implementation of Standard I/O}, details how the GNAT
509 implementation of the input-output facilities.
511 @item
512 @ref{The GNAT Library}, is a catalog of packages that complement
513 the Ada predefined library.
515 @item
516 @ref{Interfacing to Other Languages}, describes how programs
517 written in Ada using GNAT can be interfaced to other programming
518 languages.
520 @ref{Specialized Needs Annexes}, describes the GNAT implementation of all
521 of the specialized needs annexes.
523 @item
524 @ref{Implementation of Specific Ada Features}, discusses issues related
525 to GNAT's implementation of machine code insertions, tasking, and several
526 other features.
528 @item
529 @ref{Project File Reference}, presents the syntax and semantics
530 of project files.
532 @item
533 @ref{Obsolescent Features} documents implementation dependent features,
534 including pragmas and attributes, which are considered obsolescent, since
535 there are other preferred ways of achieving the same results. These
536 obsolescent forms are retained for backwards compatibility.
538 @end itemize
540 @cindex Ada 95 ISO/ANSI Standard
541 @noindent
542 This reference manual assumes that you are familiar with Ada 95
543 language, as described in the International Standard
544 ANSI/ISO/IEC-8652:1995, Jan 1995.
546 @node Conventions
547 @unnumberedsec Conventions
548 @cindex Conventions, typographical
549 @cindex Typographical conventions
551 @noindent
552 Following are examples of the typographical and graphic conventions used
553 in this guide:
555 @itemize @bullet
556 @item
557 @code{Functions}, @code{utility program names}, @code{standard names},
558 and @code{classes}.
560 @item
561 @code{Option flags}
563 @item
564 @file{File Names}, @samp{button names}, and @samp{field names}.
566 @item
567 @code{Variables}.
569 @item
570 @emph{Emphasis}.
572 @item
573 [optional information or parameters]
575 @item
576 Examples are described by text
577 @smallexample
578 and then shown this way.
579 @end smallexample
580 @end itemize
582 @noindent
583 Commands that are entered by the user are preceded in this manual by the
584 characters @samp{$ } (dollar sign followed by space).  If your system uses this
585 sequence as a prompt, then the commands will appear exactly as you see them
586 in the manual.  If your system uses some other prompt, then the command will
587 appear with the @samp{$} replaced by whatever prompt character you are using.
589 @node Related Information
590 @unnumberedsec Related Information
591 @noindent
592 See the following documents for further information on GNAT:
594 @itemize @bullet
595 @item
596 @cite{GNAT User's Guide}, which provides information on how to use
597 the GNAT compiler system.
599 @item
600 @cite{Ada 95 Reference Manual}, which contains all reference
601 material for the Ada 95 programming language.
603 @item
604 @cite{Ada 95 Annotated Reference Manual}, which is an annotated version
605 of the standard reference manual cited above.  The annotations describe
606 detailed aspects of the design decision, and in particular contain useful
607 sections on Ada 83 compatibility.
609 @item
610 @cite{DEC Ada, Technical Overview and Comparison on DIGITAL Platforms},
611 which contains specific information on compatibility between GNAT and
612 DEC Ada 83 systems.
614 @item
615 @cite{DEC Ada, Language Reference Manual, part number AA-PYZAB-TK} which
616 describes in detail the pragmas and attributes provided by the DEC Ada 83
617 compiler system.
619 @end itemize
621 @node Implementation Defined Pragmas
622 @chapter Implementation Defined Pragmas
624 @noindent
625 Ada 95 defines a set of pragmas that can be used to supply additional
626 information to the compiler.  These language defined pragmas are
627 implemented in GNAT and work as described in the Ada 95 Reference
628 Manual.
630 In addition, Ada 95 allows implementations to define additional pragmas
631 whose meaning is defined by the implementation.  GNAT provides a number
632 of these implementation-dependent pragmas which can be used to extend
633 and enhance the functionality of the compiler.  This section of the GNAT
634 Reference Manual describes these additional pragmas.
636 Note that any program using these pragmas may not be portable to other
637 compilers (although GNAT implements this set of pragmas on all
638 platforms).  Therefore if portability to other compilers is an important
639 consideration, the use of these pragmas should be minimized.
641 @menu
642 * Pragma Abort_Defer::
643 * Pragma Ada_83::
644 * Pragma Ada_95::
645 * Pragma Ada_05::
646 * Pragma Ada_2005::
647 * Pragma Annotate::
648 * Pragma Assert::
649 * Pragma Ast_Entry::
650 * Pragma C_Pass_By_Copy::
651 * Pragma Comment::
652 * Pragma Common_Object::
653 * Pragma Compile_Time_Warning::
654 * Pragma Complete_Representation::
655 * Pragma Complex_Representation::
656 * Pragma Component_Alignment::
657 * Pragma Convention_Identifier::
658 * Pragma CPP_Class::
659 * Pragma CPP_Constructor::
660 * Pragma CPP_Virtual::
661 * Pragma CPP_Vtable::
662 * Pragma Debug::
663 * Pragma Debug_Policy::
664 * Pragma Detect_Blocking::
665 * Pragma Elaboration_Checks::
666 * Pragma Eliminate::
667 * Pragma Export_Exception::
668 * Pragma Export_Function::
669 * Pragma Export_Object::
670 * Pragma Export_Procedure::
671 * Pragma Export_Value::
672 * Pragma Export_Valued_Procedure::
673 * Pragma Extend_System::
674 * Pragma External::
675 * Pragma External_Name_Casing::
676 * Pragma Finalize_Storage_Only::
677 * Pragma Float_Representation::
678 * Pragma Ident::
679 * Pragma Import_Exception::
680 * Pragma Import_Function::
681 * Pragma Import_Object::
682 * Pragma Import_Procedure::
683 * Pragma Import_Valued_Procedure::
684 * Pragma Initialize_Scalars::
685 * Pragma Inline_Always::
686 * Pragma Inline_Generic::
687 * Pragma Interface::
688 * Pragma Interface_Name::
689 * Pragma Interrupt_Handler::
690 * Pragma Interrupt_State::
691 * Pragma Keep_Names::
692 * Pragma License::
693 * Pragma Link_With::
694 * Pragma Linker_Alias::
695 * Pragma Linker_Constructor::
696 * Pragma Linker_Destructor::
697 * Pragma Linker_Section::
698 * Pragma Long_Float::
699 * Pragma Machine_Attribute::
700 * Pragma Main_Storage::
701 * Pragma No_Return::
702 * Pragma No_Strict_Aliasing::
703 * Pragma Normalize_Scalars::
704 * Pragma Obsolescent::
705 * Pragma Passive::
706 * Pragma Persistent_BSS::
707 * Pragma Polling::
708 * Pragma Profile (Ravenscar)::
709 * Pragma Profile (Restricted)::
710 * Pragma Psect_Object::
711 * Pragma Pure_Function::
712 * Pragma Restriction_Warnings::
713 * Pragma Source_File_Name::
714 * Pragma Source_File_Name_Project::
715 * Pragma Source_Reference::
716 * Pragma Stream_Convert::
717 * Pragma Style_Checks::
718 * Pragma Subtitle::
719 * Pragma Suppress::
720 * Pragma Suppress_All::
721 * Pragma Suppress_Exception_Locations::
722 * Pragma Suppress_Initialization::
723 * Pragma Task_Info::
724 * Pragma Task_Name::
725 * Pragma Task_Storage::
726 * Pragma Thread_Body::
727 * Pragma Time_Slice::
728 * Pragma Title::
729 * Pragma Unchecked_Union::
730 * Pragma Unimplemented_Unit::
731 * Pragma Universal_Data::
732 * Pragma Unreferenced::
733 * Pragma Unreserve_All_Interrupts::
734 * Pragma Unsuppress::
735 * Pragma Use_VADS_Size::
736 * Pragma Validity_Checks::
737 * Pragma Volatile::
738 * Pragma Warnings::
739 * Pragma Weak_External::
740 * Pragma Wide_Character_Encoding::
741 @end menu
743 @node Pragma Abort_Defer
744 @unnumberedsec Pragma Abort_Defer
745 @findex Abort_Defer
746 @cindex Deferring aborts
747 @noindent
748 Syntax:
749 @smallexample
750 pragma Abort_Defer;
751 @end smallexample
753 @noindent
754 This pragma must appear at the start of the statement sequence of a
755 handled sequence of statements (right after the @code{begin}).  It has
756 the effect of deferring aborts for the sequence of statements (but not
757 for the declarations or handlers, if any, associated with this statement
758 sequence).
760 @node Pragma Ada_83
761 @unnumberedsec Pragma Ada_83
762 @findex Ada_83
763 @noindent
764 Syntax:
765 @smallexample @c ada
766 pragma Ada_83;
767 @end smallexample
769 @noindent
770 A configuration pragma that establishes Ada 83 mode for the unit to
771 which it applies, regardless of the mode set by the command line
772 switches.  In Ada 83 mode, GNAT attempts to be as compatible with
773 the syntax and semantics of Ada 83, as defined in the original Ada
774 83 Reference Manual as possible.  In particular, the new Ada 95
775 keywords are not recognized, optional package bodies are allowed,
776 and generics may name types with unknown discriminants without using
777 the @code{(<>)} notation.  In addition, some but not all of the additional
778 restrictions of Ada 83 are enforced.
780 Ada 83 mode is intended for two purposes.  Firstly, it allows existing
781 legacy Ada 83 code to be compiled and adapted to GNAT with less effort.
782 Secondly, it aids in keeping code backwards compatible with Ada 83.
783 However, there is no guarantee that code that is processed correctly
784 by GNAT in Ada 83 mode will in fact compile and execute with an Ada
785 83 compiler, since GNAT does not enforce all the additional checks
786 required by Ada 83.
788 @node Pragma Ada_95
789 @unnumberedsec Pragma Ada_95
790 @findex Ada_95
791 @noindent
792 Syntax:
793 @smallexample @c ada
794 pragma Ada_95;
795 @end smallexample
797 @noindent
798 A configuration pragma that establishes Ada 95 mode for the unit to which
799 it applies, regardless of the mode set by the command line switches.
800 This mode is set automatically for the @code{Ada} and @code{System}
801 packages and their children, so you need not specify it in these
802 contexts.  This pragma is useful when writing a reusable component that
803 itself uses Ada 95 features, but which is intended to be usable from
804 either Ada 83 or Ada 95 programs.
806 @node Pragma Ada_05
807 @unnumberedsec Pragma Ada_05
808 @findex Ada_05
809 @noindent
810 Syntax:
811 @smallexample @c ada
812 pragma Ada_05;
813 @end smallexample
815 @noindent
816 A configuration pragma that establishes Ada 2005 mode for the unit to which
817 it applies, regardless of the mode set by the command line switches.
818 This mode is set automatically for the @code{Ada} and @code{System}
819 packages and their children, so you need not specify it in these
820 contexts.  This pragma is useful when writing a reusable component that
821 itself uses Ada 2005 features, but which is intended to be usable from
822 either Ada 83 or Ada 95 programs.
824 @node Pragma Ada_2005
825 @unnumberedsec Pragma Ada_2005
826 @findex Ada_2005
827 @noindent
828 Syntax:
829 @smallexample @c ada
830 pragma Ada_2005;
831 @end smallexample
833 @noindent
834 This configuration pragma is a synonym for pragma Ada_05 and has the
835 same syntax and effect.
837 @node Pragma Annotate
838 @unnumberedsec Pragma Annotate
839 @findex Annotate
840 @noindent
841 Syntax:
842 @smallexample @c ada
843 pragma Annotate (IDENTIFIER @{, ARG@});
845 ARG ::= NAME | EXPRESSION
846 @end smallexample
848 @noindent
849 This pragma is used to annotate programs.  @var{identifier} identifies
850 the type of annotation.  GNAT verifies this is an identifier, but does
851 not otherwise analyze it.  The @var{arg} argument
852 can be either a string literal or an
853 expression.  String literals are assumed to be of type
854 @code{Standard.String}.  Names of entities are simply analyzed as entity
855 names.  All other expressions are analyzed as expressions, and must be
856 unambiguous.
858 The analyzed pragma is retained in the tree, but not otherwise processed
859 by any part of the GNAT compiler.  This pragma is intended for use by
860 external tools, including ASIS@.
862 @node Pragma Assert
863 @unnumberedsec Pragma Assert
864 @findex Assert
865 @noindent
866 Syntax:
867 @smallexample @c ada
868 pragma Assert (
869   boolean_EXPRESSION
870   [, static_string_EXPRESSION]);
871 @end smallexample
873 @noindent
874 The effect of this pragma depends on whether the corresponding command
875 line switch is set to activate assertions.  The pragma expands into code
876 equivalent to the following:
878 @smallexample @c ada
879 if assertions-enabled then
880    if not boolean_EXPRESSION then
881       System.Assertions.Raise_Assert_Failure
882         (string_EXPRESSION);
883    end if;
884 end if;
885 @end smallexample
887 @noindent
888 The string argument, if given, is the message that will be associated
889 with the exception occurrence if the exception is raised.  If no second
890 argument is given, the default message is @samp{@var{file}:@var{nnn}},
891 where @var{file} is the name of the source file containing the assert,
892 and @var{nnn} is the line number of the assert.  A pragma is not a
893 statement, so if a statement sequence contains nothing but a pragma
894 assert, then a null statement is required in addition, as in:
896 @smallexample @c ada
897 @dots{}
898 if J > 3 then
899    pragma Assert (K > 3, "Bad value for K");
900    null;
901 end if;
902 @end smallexample
904 @noindent
905 Note that, as with the @code{if} statement to which it is equivalent, the
906 type of the expression is either @code{Standard.Boolean}, or any type derived
907 from this standard type.
909 If assertions are disabled (switch @code{-gnata} not used), then there
910 is no effect (and in particular, any side effects from the expression
911 are suppressed).  More precisely it is not quite true that the pragma
912 has no effect, since the expression is analyzed, and may cause types
913 to be frozen if they are mentioned here for the first time.
915 If assertions are enabled, then the given expression is tested, and if
916 it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
917 which results in the raising of @code{Assert_Failure} with the given message.
919 If the boolean expression has side effects, these side effects will turn
920 on and off with the setting of the assertions mode, resulting in
921 assertions that have an effect on the program.  You should generally
922 avoid side effects in the expression arguments of this pragma.  However,
923 the expressions are analyzed for semantic correctness whether or not
924 assertions are enabled, so turning assertions on and off cannot affect
925 the legality of a program.
927 @node Pragma Ast_Entry
928 @unnumberedsec Pragma Ast_Entry
929 @cindex OpenVMS
930 @findex Ast_Entry
931 @noindent
932 Syntax:
933 @smallexample @c ada
934 pragma AST_Entry (entry_IDENTIFIER);
935 @end smallexample
937 @noindent
938 This pragma is implemented only in the OpenVMS implementation of GNAT@.  The
939 argument is the simple name of a single entry; at most one @code{AST_Entry}
940 pragma is allowed for any given entry.  This pragma must be used in
941 conjunction with the @code{AST_Entry} attribute, and is only allowed after
942 the entry declaration and in the same task type specification or single task
943 as the entry to which it applies.  This pragma specifies that the given entry
944 may be used to handle an OpenVMS asynchronous system trap (@code{AST})
945 resulting from an OpenVMS system service call.  The pragma does not affect
946 normal use of the entry.  For further details on this pragma, see the
947 DEC Ada Language Reference Manual, section 9.12a.
949 @node Pragma C_Pass_By_Copy
950 @unnumberedsec Pragma C_Pass_By_Copy
951 @cindex Passing by copy
952 @findex C_Pass_By_Copy
953 @noindent
954 Syntax:
955 @smallexample @c ada
956 pragma C_Pass_By_Copy
957   ([Max_Size =>] static_integer_EXPRESSION);
958 @end smallexample
960 @noindent
961 Normally the default mechanism for passing C convention records to C
962 convention subprograms is to pass them by reference, as suggested by RM
963 B.3(69).  Use the configuration pragma @code{C_Pass_By_Copy} to change
964 this default, by requiring that record formal parameters be passed by
965 copy if all of the following conditions are met:
967 @itemize @bullet
968 @item
969 The size of the record type does not exceed@*@var{static_integer_expression}.
970 @item
971 The record type has @code{Convention C}.
972 @item
973 The formal parameter has this record type, and the subprogram has a
974 foreign (non-Ada) convention.
975 @end itemize
977 @noindent
978 If these conditions are met the argument is passed by copy, i.e.@: in a
979 manner consistent with what C expects if the corresponding formal in the
980 C prototype is a struct (rather than a pointer to a struct).
982 You can also pass records by copy by specifying the convention
983 @code{C_Pass_By_Copy} for the record type, or by using the extended
984 @code{Import} and @code{Export} pragmas, which allow specification of
985 passing mechanisms on a parameter by parameter basis.
987 @node Pragma Comment
988 @unnumberedsec Pragma Comment
989 @findex Comment
990 @noindent
991 Syntax:
993 @smallexample @c ada
994 pragma Comment (static_string_EXPRESSION);
995 @end smallexample
997 @noindent
998 This is almost identical in effect to pragma @code{Ident}.  It allows the
999 placement of a comment into the object file and hence into the
1000 executable file if the operating system permits such usage.  The
1001 difference is that @code{Comment}, unlike @code{Ident}, has
1002 no limitations on placement of the pragma (it can be placed
1003 anywhere in the main source unit), and if more than one pragma
1004 is used, all comments are retained.
1006 @node Pragma Common_Object
1007 @unnumberedsec Pragma Common_Object
1008 @findex Common_Object
1009 @noindent
1010 Syntax:
1012 @smallexample @c ada
1013 pragma Common_Object (
1014      [Internal =>] local_NAME,
1015   [, [External =>] EXTERNAL_SYMBOL]
1016   [, [Size     =>] EXTERNAL_SYMBOL] );
1018 EXTERNAL_SYMBOL ::=
1019   IDENTIFIER
1020 | static_string_EXPRESSION
1021 @end smallexample
1023 @noindent
1024 This pragma enables the shared use of variables stored in overlaid
1025 linker areas corresponding to the use of @code{COMMON}
1026 in Fortran.  The single
1027 object @var{local_NAME} is assigned to the area designated by
1028 the @var{External} argument.
1029 You may define a record to correspond to a series
1030 of fields.  The @var{size} argument
1031 is syntax checked in GNAT, but otherwise ignored.
1033 @code{Common_Object} is not supported on all platforms.  If no
1034 support is available, then the code generator will issue a message
1035 indicating that the necessary attribute for implementation of this
1036 pragma is not available.
1038 @node Pragma Compile_Time_Warning
1039 @unnumberedsec Pragma Compile_Time_Warning
1040 @findex Compile_Time_Warning
1041 @noindent
1042 Syntax:
1044 @smallexample @c ada
1045 pragma Compile_Time_Warning
1046          (boolean_EXPRESSION, static_string_EXPRESSION);
1047 @end smallexample
1049 @noindent
1050 This pragma can be used to generate additional compile time warnings. It
1051 is particularly useful in generics, where warnings can be issued for
1052 specific problematic instantiations. The first parameter is a boolean
1053 expression. The pragma is effective only if the value of this expression
1054 is known at compile time, and has the value True. The set of expressions
1055 whose values are known at compile time includes all static boolean
1056 expressions, and also other values which the compiler can determine
1057 at compile time (e.g. the size of a record type set by an explicit
1058 size representation clause, or the value of a variable which was
1059 initialized to a constant and is known not to have been modified).
1060 If these conditions are met, a warning message is generated using
1061 the value given as the second argument. This string value may contain
1062 embedded ASCII.LF characters to break the message into multiple lines.
1064 @node Pragma Complete_Representation
1065 @unnumberedsec Pragma Complete_Representation
1066 @findex Complete_Representation
1067 @noindent
1068 Syntax:
1070 @smallexample @c ada
1071 pragma Complete_Representation;
1072 @end smallexample
1074 @noindent
1075 This pragma must appear immediately within a record representation
1076 clause. Typical placements are before the first component clause
1077 or after the last component clause. The effect is to give an error
1078 message if any component is missing a component clause. This pragma
1079 may be used to ensure that a record representation clause is
1080 complete, and that this invariant is maintained if fields are
1081 added to the record in the future.
1083 @node Pragma Complex_Representation
1084 @unnumberedsec Pragma Complex_Representation
1085 @findex Complex_Representation
1086 @noindent
1087 Syntax:
1089 @smallexample @c ada
1090 pragma Complex_Representation
1091         ([Entity =>] local_NAME);
1092 @end smallexample
1094 @noindent
1095 The @var{Entity} argument must be the name of a record type which has
1096 two fields of the same floating-point type.  The effect of this pragma is
1097 to force gcc to use the special internal complex representation form for
1098 this record, which may be more efficient.  Note that this may result in
1099 the code for this type not conforming to standard ABI (application
1100 binary interface) requirements for the handling of record types.  For
1101 example, in some environments, there is a requirement for passing
1102 records by pointer, and the use of this pragma may result in passing
1103 this type in floating-point registers.
1105 @node Pragma Component_Alignment
1106 @unnumberedsec Pragma Component_Alignment
1107 @cindex Alignments of components
1108 @findex Component_Alignment
1109 @noindent
1110 Syntax:
1112 @smallexample @c ada
1113 pragma Component_Alignment (
1114      [Form =>] ALIGNMENT_CHOICE
1115   [, [Name =>] type_local_NAME]);
1117 ALIGNMENT_CHOICE ::=
1118   Component_Size
1119 | Component_Size_4
1120 | Storage_Unit
1121 | Default
1122 @end smallexample
1124 @noindent
1125 Specifies the alignment of components in array or record types.
1126 The meaning of the @var{Form} argument is as follows:
1128 @table @code
1129 @findex Component_Size
1130 @item Component_Size
1131 Aligns scalar components and subcomponents of the array or record type
1132 on boundaries appropriate to their inherent size (naturally
1133 aligned).  For example, 1-byte components are aligned on byte boundaries,
1134 2-byte integer components are aligned on 2-byte boundaries, 4-byte
1135 integer components are aligned on 4-byte boundaries and so on.  These
1136 alignment rules correspond to the normal rules for C compilers on all
1137 machines except the VAX@.
1139 @findex Component_Size_4
1140 @item Component_Size_4
1141 Naturally aligns components with a size of four or fewer
1142 bytes.  Components that are larger than 4 bytes are placed on the next
1143 4-byte boundary.
1145 @findex Storage_Unit
1146 @item Storage_Unit
1147 Specifies that array or record components are byte aligned, i.e.@:
1148 aligned on boundaries determined by the value of the constant
1149 @code{System.Storage_Unit}.
1151 @cindex OpenVMS
1152 @item Default
1153 Specifies that array or record components are aligned on default
1154 boundaries, appropriate to the underlying hardware or operating system or
1155 both.  For OpenVMS VAX systems, the @code{Default} choice is the same as
1156 the @code{Storage_Unit} choice (byte alignment).  For all other systems,
1157 the @code{Default} choice is the same as @code{Component_Size} (natural
1158 alignment).
1159 @end table
1161 @noindent
1162 If the @code{Name} parameter is present, @var{type_local_NAME} must
1163 refer to a local record or array type, and the specified alignment
1164 choice applies to the specified type.  The use of
1165 @code{Component_Alignment} together with a pragma @code{Pack} causes the
1166 @code{Component_Alignment} pragma to be ignored.  The use of
1167 @code{Component_Alignment} together with a record representation clause
1168 is only effective for fields not specified by the representation clause.
1170 If the @code{Name} parameter is absent, the pragma can be used as either
1171 a configuration pragma, in which case it applies to one or more units in
1172 accordance with the normal rules for configuration pragmas, or it can be
1173 used within a declarative part, in which case it applies to types that
1174 are declared within this declarative part, or within any nested scope
1175 within this declarative part.  In either case it specifies the alignment
1176 to be applied to any record or array type which has otherwise standard
1177 representation.
1179 If the alignment for a record or array type is not specified (using
1180 pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
1181 clause), the GNAT uses the default alignment as described previously.
1183 @node Pragma Convention_Identifier
1184 @unnumberedsec Pragma Convention_Identifier
1185 @findex Convention_Identifier
1186 @cindex Conventions, synonyms
1187 @noindent
1188 Syntax:
1190 @smallexample @c ada
1191 pragma Convention_Identifier (
1192          [Name =>]       IDENTIFIER,
1193          [Convention =>] convention_IDENTIFIER);
1194 @end smallexample
1196 @noindent
1197 This pragma provides a mechanism for supplying synonyms for existing
1198 convention identifiers. The @code{Name} identifier can subsequently
1199 be used as a synonym for the given convention in other pragmas (including
1200 for example pragma @code{Import} or another @code{Convention_Identifier}
1201 pragma). As an example of the use of this, suppose you had legacy code
1202 which used Fortran77 as the identifier for Fortran. Then the pragma:
1204 @smallexample @c ada
1205 pragma Convention_Identifier (Fortran77, Fortran);
1206 @end smallexample
1208 @noindent
1209 would allow the use of the convention identifier @code{Fortran77} in
1210 subsequent code, avoiding the need to modify the sources. As another
1211 example, you could use this to parametrize convention requirements
1212 according to systems. Suppose you needed to use @code{Stdcall} on
1213 windows systems, and @code{C} on some other system, then you could
1214 define a convention identifier @code{Library} and use a single
1215 @code{Convention_Identifier} pragma to specify which convention
1216 would be used system-wide.
1218 @node Pragma CPP_Class
1219 @unnumberedsec Pragma CPP_Class
1220 @findex CPP_Class
1221 @cindex Interfacing with C++
1222 @noindent
1223 Syntax:
1225 @smallexample @c ada
1226 pragma CPP_Class ([Entity =>] local_NAME);
1227 @end smallexample
1229 @noindent
1230 The argument denotes an entity in the current declarative region
1231 that is declared as a tagged or untagged record type.  It indicates that
1232 the type corresponds to an externally declared C++ class type, and is to
1233 be laid out the same way that C++ would lay out the type.
1235 If (and only if) the type is tagged, at least one component in the
1236 record must be of type @code{Interfaces.CPP.Vtable_Ptr}, corresponding
1237 to the C++ Vtable (or Vtables in the case of multiple inheritance) used
1238 for dispatching.
1240 Types for which @code{CPP_Class} is specified do not have assignment or
1241 equality operators defined (such operations can be imported or declared
1242 as subprograms as required).  Initialization is allowed only by
1243 constructor functions (see pragma @code{CPP_Constructor}).
1245 Pragma @code{CPP_Class} is intended primarily for automatic generation
1246 using an automatic binding generator tool.
1247 See @ref{Interfacing to C++} for related information.
1249 @node Pragma CPP_Constructor
1250 @unnumberedsec Pragma CPP_Constructor
1251 @cindex Interfacing with C++
1252 @findex CPP_Constructor
1253 @noindent
1254 Syntax:
1256 @smallexample @c ada
1257 pragma CPP_Constructor ([Entity =>] local_NAME);
1258 @end smallexample
1260 @noindent
1261 This pragma identifies an imported function (imported in the usual way
1262 with pragma @code{Import}) as corresponding to a C++
1263 constructor.  The argument is a name that must have been
1264 previously mentioned in a pragma @code{Import}
1265 with @code{Convention} = @code{CPP}, and must be of one of the following
1266 forms:
1268 @itemize @bullet
1269 @item
1270 @code{function @var{Fname} return @var{T}'Class}
1272 @item
1273 @code{function @var{Fname} (@dots{}) return @var{T}'Class}
1274 @end itemize
1276 @noindent
1277 where @var{T} is a tagged type to which the pragma @code{CPP_Class} applies.
1279 The first form is the default constructor, used when an object of type
1280 @var{T} is created on the Ada side with no explicit constructor.  Other
1281 constructors (including the copy constructor, which is simply a special
1282 case of the second form in which the one and only argument is of type
1283 @var{T}), can only appear in two contexts:
1285 @itemize @bullet
1286 @item
1287 On the right side of an initialization of an object of type @var{T}.
1288 @item
1289 In an extension aggregate for an object of a type derived from @var{T}.
1290 @end itemize
1292 @noindent
1293 Although the constructor is described as a function that returns a value
1294 on the Ada side, it is typically a procedure with an extra implicit
1295 argument (the object being initialized) at the implementation
1296 level.  GNAT issues the appropriate call, whatever it is, to get the
1297 object properly initialized.
1299 In the case of derived objects, you may use one of two possible forms
1300 for declaring and creating an object:
1302 @itemize @bullet
1303 @item @code{New_Object : Derived_T}
1304 @item @code{New_Object : Derived_T := (@var{constructor-call with} @dots{})}
1305 @end itemize
1307 @noindent
1308 In the first case the default constructor is called and extension fields
1309 if any are initialized according to the default initialization
1310 expressions in the Ada declaration.  In the second case, the given
1311 constructor is called and the extension aggregate indicates the explicit
1312 values of the extension fields.
1314 If no constructors are imported, it is impossible to create any objects
1315 on the Ada side.  If no default constructor is imported, only the
1316 initialization forms using an explicit call to a constructor are
1317 permitted.
1319 Pragma @code{CPP_Constructor} is intended primarily for automatic generation
1320 using an automatic binding generator tool.
1321 See @ref{Interfacing to C++} for more related information.
1323 @node Pragma CPP_Virtual
1324 @unnumberedsec Pragma CPP_Virtual
1325 @cindex Interfacing to C++
1326 @findex CPP_Virtual
1327 @noindent
1328 Syntax:
1330 @smallexample @c ada
1331 pragma CPP_Virtual
1332      [Entity     =>] ENTITY,
1333   [, [Vtable_Ptr =>] vtable_ENTITY,]
1334   [, [Position   =>] static_integer_EXPRESSION]);
1335 @end smallexample
1337 @noindent
1338 This pragma serves the same function as pragma @code{Import} in that
1339 case of a virtual function imported from C++.  The @var{Entity} argument
1340 must be a
1341 primitive subprogram of a tagged type to which pragma @code{CPP_Class}
1342 applies.  The @var{Vtable_Ptr} argument specifies
1343 the Vtable_Ptr component which contains the
1344 entry for this virtual function.  The @var{Position} argument
1345 is the sequential number
1346 counting virtual functions for this Vtable starting at 1.
1348 The @code{Vtable_Ptr} and @code{Position} arguments may be omitted if
1349 there is one Vtable_Ptr present (single inheritance case) and all
1350 virtual functions are imported.  In that case the compiler can deduce both
1351 these values.
1353 No @code{External_Name} or @code{Link_Name} arguments are required for a
1354 virtual function, since it is always accessed indirectly via the
1355 appropriate Vtable entry.
1357 Pragma @code{CPP_Virtual} is intended primarily for automatic generation
1358 using an automatic binding generator tool.
1359 See @ref{Interfacing to C++} for related information.
1361 @node Pragma CPP_Vtable
1362 @unnumberedsec Pragma CPP_Vtable
1363 @cindex Interfacing with C++
1364 @findex CPP_Vtable
1365 @noindent
1366 Syntax:
1368 @smallexample @c ada
1369 pragma CPP_Vtable (
1370   [Entity      =>] ENTITY,
1371   [Vtable_Ptr  =>] vtable_ENTITY,
1372   [Entry_Count =>] static_integer_EXPRESSION);
1373 @end smallexample
1375 @noindent
1376 Given a record to which the pragma @code{CPP_Class} applies,
1377 this pragma can be specified for each component of type
1378 @code{CPP.Interfaces.Vtable_Ptr}.
1379 @var{Entity} is the tagged type, @var{Vtable_Ptr}
1380 is the record field of type @code{Vtable_Ptr}, and @var{Entry_Count} is
1381 the number of virtual functions on the C++ side.  Not all of these
1382 functions need to be imported on the Ada side.
1384 You may omit the @code{CPP_Vtable} pragma if there is only one
1385 @code{Vtable_Ptr} component in the record and all virtual functions are
1386 imported on the Ada side (the default value for the entry count in this
1387 case is simply the total number of virtual functions).
1389 Pragma @code{CPP_Vtable} is intended primarily for automatic generation
1390 using an automatic binding generator tool.
1391 See @ref{Interfacing to C++} for related information.
1393 @node Pragma Debug
1394 @unnumberedsec Pragma Debug
1395 @findex Debug
1396 @noindent
1397 Syntax:
1399 @smallexample @c ada
1400 pragma Debug ([CONDITION, ]PROCEDURE_CALL_WITHOUT_SEMICOLON);
1402 PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
1403   PROCEDURE_NAME
1404 | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
1405 @end smallexample
1407 @noindent
1408 The procedure call argument has the syntactic form of an expression, meeting
1409 the syntactic requirements for pragmas.
1411 If debug pragmas are not enabled or if the condition is present and evaluates
1412 to False, this pragma has no effect. If debug pragmas are enabled, the
1413 semantics of the pragma is exactly equivalent to the procedure call statement
1414 corresponding to the argument with a terminating semicolon. Pragmas are
1415 permitted in sequences of declarations, so you can use pragma @code{Debug} to
1416 intersperse calls to debug procedures in the middle of declarations. Debug
1417 pragmas can be enabled either by use of the command line switch @code{-gnata}
1418 or by use of the configuration pragma @code{Debug_Policy}.
1420 @node Pragma Debug_Policy
1421 @unnumberedsec Pragma Debug_Policy
1422 @findex Debug_Policy
1423 @noindent
1424 Syntax:
1426 @smallexample @c ada
1427 pragma Debug_Policy (CHECK | IGNORE);
1428 @end smallexample
1430 @noindent
1431 If the argument is @code{CHECK}, then pragma @code{DEBUG} is enabled.
1432 If the argument is @code{IGNORE}, then pragma @code{DEBUG} is ignored.
1433 This pragma overrides the effect of the @code{-gnata} switch on the
1434 command line.
1436 @node Pragma Detect_Blocking
1437 @unnumberedsec Pragma Detect_Blocking
1438 @findex Detect_Blocking
1439 @noindent
1440 Syntax:
1442 @smallexample @c ada
1443 pragma Detect_Blocking;
1444 @end smallexample
1446 @noindent
1447 This is a configuration pragma that forces the detection of potentially
1448 blocking operations within a protected operation, and to raise Program_Error
1449 if that happens.
1451 @node Pragma Elaboration_Checks
1452 @unnumberedsec Pragma Elaboration_Checks
1453 @cindex Elaboration control
1454 @findex Elaboration_Checks
1455 @noindent
1456 Syntax:
1458 @smallexample @c ada
1459 pragma Elaboration_Checks (Dynamic | Static);
1460 @end smallexample
1462 @noindent
1463 This is a configuration pragma that provides control over the
1464 elaboration model used by the compilation affected by the
1465 pragma.  If the parameter is @code{Dynamic},
1466 then the dynamic elaboration
1467 model described in the Ada Reference Manual is used, as though
1468 the @code{-gnatE} switch had been specified on the command
1469 line.  If the parameter is @code{Static}, then the default GNAT static
1470 model is used.  This configuration pragma overrides the setting
1471 of the command line.  For full details on the elaboration models
1472 used by the GNAT compiler, see section ``Elaboration Order
1473 Handling in GNAT'' in the @cite{GNAT User's Guide}.
1475 @node Pragma Eliminate
1476 @unnumberedsec Pragma Eliminate
1477 @cindex Elimination of unused subprograms
1478 @findex Eliminate
1479 @noindent
1480 Syntax:
1482 @smallexample @c ada
1483 pragma Eliminate (
1484     [Unit_Name =>] IDENTIFIER |
1485                    SELECTED_COMPONENT);
1487 pragma Eliminate (
1488     [Unit_Name       =>]  IDENTIFIER |
1489                           SELECTED_COMPONENT,
1490     [Entity          =>]  IDENTIFIER |
1491                           SELECTED_COMPONENT |
1492                           STRING_LITERAL
1493     [,OVERLOADING_RESOLUTION]);
1495 OVERLOADING_RESOLUTION ::= PARAMETER_AND_RESULT_TYPE_PROFILE |
1496                            SOURCE_LOCATION
1498 PARAMETER_AND_RESULT_TYPE_PROFILE ::= PROCEDURE_PROFILE |
1499                                       FUNCTION_PROFILE
1501 PROCEDURE_PROFILE ::= Parameter_Types => PARAMETER_TYPES
1503 FUNCTION_PROFILE ::= [Parameter_Types => PARAMETER_TYPES,]
1504                       Result_Type => result_SUBTYPE_NAME]
1506 PARAMETER_TYPES ::= (SUBTYPE_NAME @{, SUBTYPE_NAME@})
1507 SUBTYPE_NAME    ::= STRING_VALUE
1509 SOURCE_LOCATION ::= Source_Location => SOURCE_TRACE
1510 SOURCE_TRACE    ::= STRING_VALUE
1512 STRING_VALUE ::= STRING_LITERAL @{& STRING_LITERAL@}
1513 @end smallexample
1515 @noindent
1516 This pragma indicates that the given entity is not used outside the
1517 compilation unit it is defined in. The entity must be an explicitly declared
1518 subprogram; this includes  generic subprogram instances and
1519 subprograms declared in generic package instances.
1521 If the entity to be eliminated is a library level subprogram, then
1522 the first form of pragma @code{Eliminate} is used with only a single argument.
1523 In this form, the @code{Unit_Name} argument specifies the name of the
1524 library  level unit to be eliminated.
1526 In all other cases, both @code{Unit_Name} and @code{Entity} arguments
1527 are required. If item is an entity of a library package, then the first
1528 argument specifies the unit name, and the second argument specifies
1529 the particular entity.  If the second argument is in string form, it must
1530 correspond to the internal manner in which GNAT stores entity names (see
1531 compilation unit Namet in the compiler sources for details).
1533 The remaining parameters (OVERLOADING_RESOLUTION) are optionally used
1534 to distinguish between overloaded subprograms. If a pragma does not contain
1535 the OVERLOADING_RESOLUTION parameter(s), it is applied to all the overloaded
1536 subprograms denoted by the first two parameters.
1538 Use PARAMETER_AND_RESULT_TYPE_PROFILE to specify the profile of the subprogram
1539 to be eliminated in a manner similar to that used for the extended
1540 @code{Import} and @code{Export} pragmas, except that the subtype names are
1541 always given as strings. At the moment, this form of distinguishing
1542 overloaded subprograms is implemented only partially, so we do not recommend
1543 using it for practical subprogram elimination.
1545 Note, that in case of a parameterless procedure its profile is represented
1546 as @code{Parameter_Types => ("")}
1548 Alternatively, the @code{Source_Location} parameter is used to specify
1549 which overloaded alternative is to be eliminated by pointing to the
1550 location of the DEFINING_PROGRAM_UNIT_NAME of this subprogram in the
1551 source text. The string literal (or concatenation of string literals)
1552 given as SOURCE_TRACE must have the following format:
1554 @smallexample @c ada
1555 SOURCE_TRACE ::= SOURCE_LOCATION@{LBRACKET SOURCE_LOCATION RBRACKET@}
1557 LBRACKET ::= [
1558 RBRACKET ::= ]
1560 SOURCE_LOCATION ::= FILE_NAME:LINE_NUMBER
1561 FILE_NAME       ::= STRING_LITERAL
1562 LINE_NUMBER     ::= DIGIT @{DIGIT@}
1563 @end smallexample
1565 SOURCE_TRACE should be the short name of the source file (with no directory
1566 information), and LINE_NUMBER is supposed to point to the line where the
1567 defining name of the subprogram is located.
1569 For the subprograms that are not a part of generic instantiations, only one
1570 SOURCE_LOCATION is used. If a subprogram is declared in a package
1571 instantiation, SOURCE_TRACE contains two SOURCE_LOCATIONs, the first one is
1572 the location of the (DEFINING_PROGRAM_UNIT_NAME of the) instantiation, and the
1573 second one denotes the declaration of the corresponding subprogram in the
1574 generic package. This approach is recursively used to create SOURCE_LOCATIONs
1575 in case of nested instantiations.
1577 The effect of the pragma is to allow the compiler to eliminate
1578 the code or data associated with the named entity.  Any reference to
1579 an eliminated entity outside the compilation unit it is defined in,
1580 causes a compile time or link time error.
1582 The intention of pragma @code{Eliminate} is to allow a program to be compiled
1583 in a system independent manner, with unused entities eliminated, without
1584 the requirement of modifying the source text.  Normally the required set
1585 of @code{Eliminate} pragmas is constructed automatically using the gnatelim
1586 tool. Elimination of unused entities local to a compilation unit is
1587 automatic, without requiring the use of pragma @code{Eliminate}.
1589 Note that the reason this pragma takes string literals where names might
1590 be expected is that a pragma @code{Eliminate} can appear in a context where the
1591 relevant names are not visible.
1593 Note that any change in the source files that includes removing, splitting of
1594 adding lines may make the set of Eliminate pragmas using SOURCE_LOCATION
1595 parameter illegal.
1597 @node Pragma Export_Exception
1598 @unnumberedsec Pragma Export_Exception
1599 @cindex OpenVMS
1600 @findex Export_Exception
1601 @noindent
1602 Syntax:
1604 @smallexample @c ada
1605 pragma Export_Exception (
1606      [Internal =>] local_NAME,
1607   [, [External =>] EXTERNAL_SYMBOL,]
1608   [, [Form     =>] Ada | VMS]
1609   [, [Code     =>] static_integer_EXPRESSION]);
1611 EXTERNAL_SYMBOL ::=
1612   IDENTIFIER
1613 | static_string_EXPRESSION
1614 @end smallexample
1616 @noindent
1617 This pragma is implemented only in the OpenVMS implementation of GNAT@.  It
1618 causes the specified exception to be propagated outside of the Ada program,
1619 so that it can be handled by programs written in other OpenVMS languages.
1620 This pragma establishes an external name for an Ada exception and makes the
1621 name available to the OpenVMS Linker as a global symbol.  For further details
1622 on this pragma, see the
1623 DEC Ada Language Reference Manual, section 13.9a3.2.
1625 @node Pragma Export_Function
1626 @unnumberedsec Pragma Export_Function
1627 @cindex Argument passing mechanisms
1628 @findex Export_Function
1630 @noindent
1631 Syntax:
1633 @smallexample @c ada
1634 pragma Export_Function (
1635      [Internal         =>] local_NAME,
1636   [, [External         =>] EXTERNAL_SYMBOL]
1637   [, [Parameter_Types  =>] PARAMETER_TYPES]
1638   [, [Result_Type      =>] result_SUBTYPE_MARK]
1639   [, [Mechanism        =>] MECHANISM]
1640   [, [Result_Mechanism =>] MECHANISM_NAME]);
1642 EXTERNAL_SYMBOL ::=
1643   IDENTIFIER
1644 | static_string_EXPRESSION
1645 | ""
1647 PARAMETER_TYPES ::=
1648   null
1649 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1651 TYPE_DESIGNATOR ::=
1652   subtype_NAME
1653 | subtype_Name ' Access
1655 MECHANISM ::=
1656   MECHANISM_NAME
1657 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1659 MECHANISM_ASSOCIATION ::=
1660   [formal_parameter_NAME =>] MECHANISM_NAME
1662 MECHANISM_NAME ::=
1663   Value
1664 | Reference
1665 @end smallexample
1667 @noindent
1668 Use this pragma to make a function externally callable and optionally
1669 provide information on mechanisms to be used for passing parameter and
1670 result values.  We recommend, for the purposes of improving portability,
1671 this pragma always be used in conjunction with a separate pragma
1672 @code{Export}, which must precede the pragma @code{Export_Function}.
1673 GNAT does not require a separate pragma @code{Export}, but if none is
1674 present, @code{Convention Ada} is assumed, which is usually
1675 not what is wanted, so it is usually appropriate to use this
1676 pragma in conjunction with a @code{Export} or @code{Convention}
1677 pragma that specifies the desired foreign convention.
1678 Pragma @code{Export_Function}
1679 (and @code{Export}, if present) must appear in the same declarative
1680 region as the function to which they apply.
1682 @var{internal_name} must uniquely designate the function to which the
1683 pragma applies.  If more than one function name exists of this name in
1684 the declarative part you must use the @code{Parameter_Types} and
1685 @code{Result_Type} parameters is mandatory to achieve the required
1686 unique designation.  @var{subtype_ mark}s in these parameters must
1687 exactly match the subtypes in the corresponding function specification,
1688 using positional notation to match parameters with subtype marks.
1689 The form with an @code{'Access} attribute can be used to match an
1690 anonymous access parameter.
1692 @cindex OpenVMS
1693 @cindex Passing by descriptor
1694 Note that passing by descriptor is not supported, even on the OpenVMS
1695 ports of GNAT@.
1697 @cindex Suppressing external name
1698 Special treatment is given if the EXTERNAL is an explicit null
1699 string or a static string expressions that evaluates to the null
1700 string. In this case, no external name is generated. This form
1701 still allows the specification of parameter mechanisms.
1703 @node Pragma Export_Object
1704 @unnumberedsec Pragma Export_Object
1705 @findex Export_Object
1706 @noindent
1707 Syntax:
1709 @smallexample @c ada
1710 pragma Export_Object
1711       [Internal =>] local_NAME,
1712    [, [External =>] EXTERNAL_SYMBOL]
1713    [, [Size     =>] EXTERNAL_SYMBOL]
1715 EXTERNAL_SYMBOL ::=
1716   IDENTIFIER
1717 | static_string_EXPRESSION
1718 @end smallexample
1720 @noindent
1721 This pragma designates an object as exported, and apart from the
1722 extended rules for external symbols, is identical in effect to the use of
1723 the normal @code{Export} pragma applied to an object.  You may use a
1724 separate Export pragma (and you probably should from the point of view
1725 of portability), but it is not required.  @var{Size} is syntax checked,
1726 but otherwise ignored by GNAT@.
1728 @node Pragma Export_Procedure
1729 @unnumberedsec Pragma Export_Procedure
1730 @findex Export_Procedure
1731 @noindent
1732 Syntax:
1734 @smallexample @c ada
1735 pragma Export_Procedure (
1736      [Internal        =>] local_NAME
1737   [, [External        =>] EXTERNAL_SYMBOL]
1738   [, [Parameter_Types =>] PARAMETER_TYPES]
1739   [, [Mechanism       =>] MECHANISM]);
1741 EXTERNAL_SYMBOL ::=
1742   IDENTIFIER
1743 | static_string_EXPRESSION
1744 | ""
1746 PARAMETER_TYPES ::=
1747   null
1748 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1750 TYPE_DESIGNATOR ::=
1751   subtype_NAME
1752 | subtype_Name ' Access
1754 MECHANISM ::=
1755   MECHANISM_NAME
1756 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1758 MECHANISM_ASSOCIATION ::=
1759   [formal_parameter_NAME =>] MECHANISM_NAME
1761 MECHANISM_NAME ::=
1762   Value
1763 | Reference
1764 @end smallexample
1766 @noindent
1767 This pragma is identical to @code{Export_Function} except that it
1768 applies to a procedure rather than a function and the parameters
1769 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
1770 GNAT does not require a separate pragma @code{Export}, but if none is
1771 present, @code{Convention Ada} is assumed, which is usually
1772 not what is wanted, so it is usually appropriate to use this
1773 pragma in conjunction with a @code{Export} or @code{Convention}
1774 pragma that specifies the desired foreign convention.
1776 @cindex OpenVMS
1777 @cindex Passing by descriptor
1778 Note that passing by descriptor is not supported, even on the OpenVMS
1779 ports of GNAT@.
1781 @cindex Suppressing external name
1782 Special treatment is given if the EXTERNAL is an explicit null
1783 string or a static string expressions that evaluates to the null
1784 string. In this case, no external name is generated. This form
1785 still allows the specification of parameter mechanisms.
1787 @node Pragma Export_Value
1788 @unnumberedsec Pragma Export_Value
1789 @findex Export_Value
1790 @noindent
1791 Syntax:
1793 @smallexample @c ada
1794 pragma Export_Value (
1795   [Value     =>] static_integer_EXPRESSION,
1796   [Link_Name =>] static_string_EXPRESSION);
1797 @end smallexample
1799 @noindent
1800 This pragma serves to export a static integer value for external use.
1801 The first argument specifies the value to be exported. The Link_Name
1802 argument specifies the symbolic name to be associated with the integer
1803 value. This pragma is useful for defining a named static value in Ada
1804 that can be referenced in assembly language units to be linked with
1805 the application. This pragma is currently supported only for the
1806 AAMP target and is ignored for other targets.
1808 @node Pragma Export_Valued_Procedure
1809 @unnumberedsec Pragma Export_Valued_Procedure
1810 @findex Export_Valued_Procedure
1811 @noindent
1812 Syntax:
1814 @smallexample @c ada
1815 pragma Export_Valued_Procedure (
1816      [Internal        =>] local_NAME
1817   [, [External        =>] EXTERNAL_SYMBOL]
1818   [, [Parameter_Types =>] PARAMETER_TYPES]
1819   [, [Mechanism       =>] MECHANISM]);
1821 EXTERNAL_SYMBOL ::=
1822   IDENTIFIER
1823 | static_string_EXPRESSION
1824 | ""
1826 PARAMETER_TYPES ::=
1827   null
1828 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1830 TYPE_DESIGNATOR ::=
1831   subtype_NAME
1832 | subtype_Name ' Access
1834 MECHANISM ::=
1835   MECHANISM_NAME
1836 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1838 MECHANISM_ASSOCIATION ::=
1839   [formal_parameter_NAME =>] MECHANISM_NAME
1841 MECHANISM_NAME ::=
1842   Value
1843 | Reference
1844 @end smallexample
1846 @noindent
1847 This pragma is identical to @code{Export_Procedure} except that the
1848 first parameter of @var{local_NAME}, which must be present, must be of
1849 mode @code{OUT}, and externally the subprogram is treated as a function
1850 with this parameter as the result of the function.  GNAT provides for
1851 this capability to allow the use of @code{OUT} and @code{IN OUT}
1852 parameters in interfacing to external functions (which are not permitted
1853 in Ada functions).
1854 GNAT does not require a separate pragma @code{Export}, but if none is
1855 present, @code{Convention Ada} is assumed, which is almost certainly
1856 not what is wanted since the whole point of this pragma is to interface
1857 with foreign language functions, so it is usually appropriate to use this
1858 pragma in conjunction with a @code{Export} or @code{Convention}
1859 pragma that specifies the desired foreign convention.
1861 @cindex OpenVMS
1862 @cindex Passing by descriptor
1863 Note that passing by descriptor is not supported, even on the OpenVMS
1864 ports of GNAT@.
1866 @cindex Suppressing external name
1867 Special treatment is given if the EXTERNAL is an explicit null
1868 string or a static string expressions that evaluates to the null
1869 string. In this case, no external name is generated. This form
1870 still allows the specification of parameter mechanisms.
1872 @node Pragma Extend_System
1873 @unnumberedsec Pragma Extend_System
1874 @cindex @code{system}, extending
1875 @cindex Dec Ada 83
1876 @findex Extend_System
1877 @noindent
1878 Syntax:
1880 @smallexample @c ada
1881 pragma Extend_System ([Name =>] IDENTIFIER);
1882 @end smallexample
1884 @noindent
1885 This pragma is used to provide backwards compatibility with other
1886 implementations that extend the facilities of package @code{System}.  In
1887 GNAT, @code{System} contains only the definitions that are present in
1888 the Ada 95 RM@.  However, other implementations, notably the DEC Ada 83
1889 implementation, provide many extensions to package @code{System}.
1891 For each such implementation accommodated by this pragma, GNAT provides a
1892 package @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83
1893 implementation, which provides the required additional definitions.  You
1894 can use this package in two ways.  You can @code{with} it in the normal
1895 way and access entities either by selection or using a @code{use}
1896 clause.  In this case no special processing is required.
1898 However, if existing code contains references such as
1899 @code{System.@var{xxx}} where @var{xxx} is an entity in the extended
1900 definitions provided in package @code{System}, you may use this pragma
1901 to extend visibility in @code{System} in a non-standard way that
1902 provides greater compatibility with the existing code.  Pragma
1903 @code{Extend_System} is a configuration pragma whose single argument is
1904 the name of the package containing the extended definition
1905 (e.g.@: @code{Aux_DEC} for the DEC Ada case).  A unit compiled under
1906 control of this pragma will be processed using special visibility
1907 processing that looks in package @code{System.Aux_@var{xxx}} where
1908 @code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
1909 package @code{System}, but not found in package @code{System}.
1911 You can use this pragma either to access a predefined @code{System}
1912 extension supplied with the compiler, for example @code{Aux_DEC} or
1913 you can construct your own extension unit following the above
1914 definition.  Note that such a package is a child of @code{System}
1915 and thus is considered part of the implementation.  To compile
1916 it you will have to use the appropriate switch for compiling
1917 system units.  See the GNAT User's Guide for details.
1919 @node Pragma External
1920 @unnumberedsec Pragma External
1921 @findex External
1922 @noindent
1923 Syntax:
1925 @smallexample @c ada
1926 pragma External (
1927   [   Convention    =>] convention_IDENTIFIER,
1928   [   Entity        =>] local_NAME
1929   [, [External_Name =>] static_string_EXPRESSION ]
1930   [, [Link_Name     =>] static_string_EXPRESSION ]);
1931 @end smallexample
1933 @noindent
1934 This pragma is identical in syntax and semantics to pragma
1935 @code{Export} as defined in the Ada Reference Manual.  It is
1936 provided for compatibility with some Ada 83 compilers that
1937 used this pragma for exactly the same purposes as pragma
1938 @code{Export} before the latter was standardized.
1940 @node Pragma External_Name_Casing
1941 @unnumberedsec Pragma External_Name_Casing
1942 @cindex Dec Ada 83 casing compatibility
1943 @cindex External Names, casing
1944 @cindex Casing of External names
1945 @findex External_Name_Casing
1946 @noindent
1947 Syntax:
1949 @smallexample @c ada
1950 pragma External_Name_Casing (
1951   Uppercase | Lowercase
1952   [, Uppercase | Lowercase | As_Is]);
1953 @end smallexample
1955 @noindent
1956 This pragma provides control over the casing of external names associated
1957 with Import and Export pragmas.  There are two cases to consider:
1959 @table @asis
1960 @item Implicit external names
1961 Implicit external names are derived from identifiers.  The most common case
1962 arises when a standard Ada 95 Import or Export pragma is used with only two
1963 arguments, as in:
1965 @smallexample @c ada
1966    pragma Import (C, C_Routine);
1967 @end smallexample
1969 @noindent
1970 Since Ada is a case insensitive language, the spelling of the identifier in
1971 the Ada source program does not provide any information on the desired
1972 casing of the external name, and so a convention is needed.  In GNAT the
1973 default treatment is that such names are converted to all lower case
1974 letters.  This corresponds to the normal C style in many environments.
1975 The first argument of pragma @code{External_Name_Casing} can be used to
1976 control this treatment.  If @code{Uppercase} is specified, then the name
1977 will be forced to all uppercase letters.  If @code{Lowercase} is specified,
1978 then the normal default of all lower case letters will be used.
1980 This same implicit treatment is also used in the case of extended DEC Ada 83
1981 compatible Import and Export pragmas where an external name is explicitly
1982 specified using an identifier rather than a string.
1984 @item Explicit external names
1985 Explicit external names are given as string literals.  The most common case
1986 arises when a standard Ada 95 Import or Export pragma is used with three
1987 arguments, as in:
1989 @smallexample @c ada
1990 pragma Import (C, C_Routine, "C_routine");
1991 @end smallexample
1993 @noindent
1994 In this case, the string literal normally provides the exact casing required
1995 for the external name.  The second argument of pragma
1996 @code{External_Name_Casing} may be used to modify this behavior.
1997 If @code{Uppercase} is specified, then the name
1998 will be forced to all uppercase letters.  If @code{Lowercase} is specified,
1999 then the name will be forced to all lowercase letters.  A specification of
2000 @code{As_Is} provides the normal default behavior in which the casing is
2001 taken from the string provided.
2002 @end table
2004 @noindent
2005 This pragma may appear anywhere that a pragma is valid.  In particular, it
2006 can be used as a configuration pragma in the @file{gnat.adc} file, in which
2007 case it applies to all subsequent compilations, or it can be used as a program
2008 unit pragma, in which case it only applies to the current unit, or it can
2009 be used more locally to control individual Import/Export pragmas.
2011 It is primarily intended for use with OpenVMS systems, where many
2012 compilers convert all symbols to upper case by default.  For interfacing to
2013 such compilers (e.g.@: the DEC C compiler), it may be convenient to use
2014 the pragma:
2016 @smallexample @c ada
2017 pragma External_Name_Casing (Uppercase, Uppercase);
2018 @end smallexample
2020 @noindent
2021 to enforce the upper casing of all external symbols.
2023 @node Pragma Finalize_Storage_Only
2024 @unnumberedsec Pragma Finalize_Storage_Only
2025 @findex Finalize_Storage_Only
2026 @noindent
2027 Syntax:
2029 @smallexample @c ada
2030 pragma Finalize_Storage_Only (first_subtype_local_NAME);
2031 @end smallexample
2033 @noindent
2034 This pragma allows the compiler not to emit a Finalize call for objects
2035 defined at the library level.  This is mostly useful for types where
2036 finalization is only used to deal with storage reclamation since in most
2037 environments it is not necessary to reclaim memory just before terminating
2038 execution, hence the name.
2040 @node Pragma Float_Representation
2041 @unnumberedsec Pragma Float_Representation
2042 @cindex OpenVMS
2043 @findex Float_Representation
2044 @noindent
2045 Syntax:
2047 @smallexample @c ada
2048 pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
2050 FLOAT_REP ::= VAX_Float | IEEE_Float
2051 @end smallexample
2053 @noindent
2054 In the one argument form, this pragma is a configuration pragma which
2055 allows control over the internal representation chosen for the predefined
2056 floating point types declared in the packages @code{Standard} and
2057 @code{System}. On all systems other than OpenVMS, the argument must
2058 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2059 argument may be @code{VAX_Float} to specify the use of the VAX float
2060 format for the floating-point types in Standard. This requires that
2061 the standard runtime libraries be recompiled. See the
2062 description of the @code{GNAT LIBRARY} command in the OpenVMS version
2063 of the GNAT Users Guide for details on the use of this command.
2065 The two argument form specifies the representation to be used for
2066 the specified floating-point type. On all systems other than OpenVMS,
2067 the argument must
2068 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2069 argument may be @code{VAX_Float} to specify the use of the VAX float
2070 format, as follows:
2072 @itemize @bullet
2073 @item
2074 For digits values up to 6, F float format will be used.
2075 @item
2076 For digits values from 7 to 9, G float format will be used.
2077 @item
2078 For digits values from 10 to 15, F float format will be used.
2079 @item
2080 Digits values above 15 are not allowed.
2081 @end itemize
2083 @node Pragma Ident
2084 @unnumberedsec Pragma Ident
2085 @findex Ident
2086 @noindent
2087 Syntax:
2089 @smallexample @c ada
2090 pragma Ident (static_string_EXPRESSION);
2091 @end smallexample
2093 @noindent
2094 This pragma provides a string identification in the generated object file,
2095 if the system supports the concept of this kind of identification string.
2096 This pragma is allowed only in the outermost declarative part or
2097 declarative items of a compilation unit. If more than one @code{Ident}
2098 pragma is given, only the last one processed is effective.
2099 @cindex OpenVMS
2100 On OpenVMS systems, the effect of the pragma is identical to the effect of
2101 the DEC Ada 83 pragma of the same name. Note that in DEC Ada 83, the
2102 maximum allowed length is 31 characters, so if it is important to
2103 maintain compatibility with this compiler, you should obey this length
2104 limit.
2106 @node Pragma Import_Exception
2107 @unnumberedsec Pragma Import_Exception
2108 @cindex OpenVMS
2109 @findex Import_Exception
2110 @noindent
2111 Syntax:
2113 @smallexample @c ada
2114 pragma Import_Exception (
2115      [Internal =>] local_NAME,
2116   [, [External =>] EXTERNAL_SYMBOL,]
2117   [, [Form     =>] Ada | VMS]
2118   [, [Code     =>] static_integer_EXPRESSION]);
2120 EXTERNAL_SYMBOL ::=
2121   IDENTIFIER
2122 | static_string_EXPRESSION
2123 @end smallexample
2125 @noindent
2126 This pragma is implemented only in the OpenVMS implementation of GNAT@.
2127 It allows OpenVMS conditions (for example, from OpenVMS system services or
2128 other OpenVMS languages) to be propagated to Ada programs as Ada exceptions.
2129 The pragma specifies that the exception associated with an exception
2130 declaration in an Ada program be defined externally (in non-Ada code).
2131 For further details on this pragma, see the
2132 DEC Ada Language Reference Manual, section 13.9a.3.1.
2134 @node Pragma Import_Function
2135 @unnumberedsec Pragma Import_Function
2136 @findex Import_Function
2137 @noindent
2138 Syntax:
2140 @smallexample @c ada
2141 pragma Import_Function (
2142      [Internal                 =>] local_NAME,
2143   [, [External                 =>] EXTERNAL_SYMBOL]
2144   [, [Parameter_Types          =>] PARAMETER_TYPES]
2145   [, [Result_Type              =>] SUBTYPE_MARK]
2146   [, [Mechanism                =>] MECHANISM]
2147   [, [Result_Mechanism         =>] MECHANISM_NAME]
2148   [, [First_Optional_Parameter =>] IDENTIFIER]);
2150 EXTERNAL_SYMBOL ::=
2151   IDENTIFIER
2152 | static_string_EXPRESSION
2154 PARAMETER_TYPES ::=
2155   null
2156 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2158 TYPE_DESIGNATOR ::=
2159   subtype_NAME
2160 | subtype_Name ' Access
2162 MECHANISM ::=
2163   MECHANISM_NAME
2164 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2166 MECHANISM_ASSOCIATION ::=
2167   [formal_parameter_NAME =>] MECHANISM_NAME
2169 MECHANISM_NAME ::=
2170   Value
2171 | Reference
2172 | Descriptor [([Class =>] CLASS_NAME)]
2174 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2175 @end smallexample
2177 @noindent
2178 This pragma is used in conjunction with a pragma @code{Import} to
2179 specify additional information for an imported function.  The pragma
2180 @code{Import} (or equivalent pragma @code{Interface}) must precede the
2181 @code{Import_Function} pragma and both must appear in the same
2182 declarative part as the function specification.
2184 The @var{Internal} argument must uniquely designate
2185 the function to which the
2186 pragma applies.  If more than one function name exists of this name in
2187 the declarative part you must use the @code{Parameter_Types} and
2188 @var{Result_Type} parameters to achieve the required unique
2189 designation.  Subtype marks in these parameters must exactly match the
2190 subtypes in the corresponding function specification, using positional
2191 notation to match parameters with subtype marks.
2192 The form with an @code{'Access} attribute can be used to match an
2193 anonymous access parameter.
2195 You may optionally use the @var{Mechanism} and @var{Result_Mechanism}
2196 parameters to specify passing mechanisms for the
2197 parameters and result.  If you specify a single mechanism name, it
2198 applies to all parameters.  Otherwise you may specify a mechanism on a
2199 parameter by parameter basis using either positional or named
2200 notation.  If the mechanism is not specified, the default mechanism
2201 is used.
2203 @cindex OpenVMS
2204 @cindex Passing by descriptor
2205 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2207 @code{First_Optional_Parameter} applies only to OpenVMS ports of GNAT@.
2208 It specifies that the designated parameter and all following parameters
2209 are optional, meaning that they are not passed at the generated code
2210 level (this is distinct from the notion of optional parameters in Ada
2211 where the parameters are passed anyway with the designated optional
2212 parameters).  All optional parameters must be of mode @code{IN} and have
2213 default parameter values that are either known at compile time
2214 expressions, or uses of the @code{'Null_Parameter} attribute.
2216 @node Pragma Import_Object
2217 @unnumberedsec Pragma Import_Object
2218 @findex Import_Object
2219 @noindent
2220 Syntax:
2222 @smallexample @c ada
2223 pragma Import_Object
2224      [Internal =>] local_NAME,
2225   [, [External =>] EXTERNAL_SYMBOL],
2226   [, [Size     =>] EXTERNAL_SYMBOL]);
2228 EXTERNAL_SYMBOL ::=
2229   IDENTIFIER
2230 | static_string_EXPRESSION
2231 @end smallexample
2233 @noindent
2234 This pragma designates an object as imported, and apart from the
2235 extended rules for external symbols, is identical in effect to the use of
2236 the normal @code{Import} pragma applied to an object.  Unlike the
2237 subprogram case, you need not use a separate @code{Import} pragma,
2238 although you may do so (and probably should do so from a portability
2239 point of view).  @var{size} is syntax checked, but otherwise ignored by
2240 GNAT@.
2242 @node Pragma Import_Procedure
2243 @unnumberedsec Pragma Import_Procedure
2244 @findex Import_Procedure
2245 @noindent
2246 Syntax:
2248 @smallexample @c ada
2249 pragma Import_Procedure (
2250      [Internal                 =>] local_NAME,
2251   [, [External                 =>] EXTERNAL_SYMBOL]
2252   [, [Parameter_Types          =>] PARAMETER_TYPES]
2253   [, [Mechanism                =>] MECHANISM]
2254   [, [First_Optional_Parameter =>] IDENTIFIER]);
2256 EXTERNAL_SYMBOL ::=
2257   IDENTIFIER
2258 | static_string_EXPRESSION
2260 PARAMETER_TYPES ::=
2261   null
2262 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2264 TYPE_DESIGNATOR ::=
2265   subtype_NAME
2266 | subtype_Name ' Access
2268 MECHANISM ::=
2269   MECHANISM_NAME
2270 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2272 MECHANISM_ASSOCIATION ::=
2273   [formal_parameter_NAME =>] MECHANISM_NAME
2275 MECHANISM_NAME ::=
2276   Value
2277 | Reference
2278 | Descriptor [([Class =>] CLASS_NAME)]
2280 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2281 @end smallexample
2283 @noindent
2284 This pragma is identical to @code{Import_Function} except that it
2285 applies to a procedure rather than a function and the parameters
2286 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2288 @node Pragma Import_Valued_Procedure
2289 @unnumberedsec Pragma Import_Valued_Procedure
2290 @findex Import_Valued_Procedure
2291 @noindent
2292 Syntax:
2294 @smallexample @c ada
2295 pragma Import_Valued_Procedure (
2296      [Internal                 =>] local_NAME,
2297   [, [External                 =>] EXTERNAL_SYMBOL]
2298   [, [Parameter_Types          =>] PARAMETER_TYPES]
2299   [, [Mechanism                =>] MECHANISM]
2300   [, [First_Optional_Parameter =>] IDENTIFIER]);
2302 EXTERNAL_SYMBOL ::=
2303   IDENTIFIER
2304 | static_string_EXPRESSION
2306 PARAMETER_TYPES ::=
2307   null
2308 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2310 TYPE_DESIGNATOR ::=
2311   subtype_NAME
2312 | subtype_Name ' Access
2314 MECHANISM ::=
2315   MECHANISM_NAME
2316 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2318 MECHANISM_ASSOCIATION ::=
2319   [formal_parameter_NAME =>] MECHANISM_NAME
2321 MECHANISM_NAME ::=
2322   Value
2323 | Reference
2324 | Descriptor [([Class =>] CLASS_NAME)]
2326 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2327 @end smallexample
2329 @noindent
2330 This pragma is identical to @code{Import_Procedure} except that the
2331 first parameter of @var{local_NAME}, which must be present, must be of
2332 mode @code{OUT}, and externally the subprogram is treated as a function
2333 with this parameter as the result of the function.  The purpose of this
2334 capability is to allow the use of @code{OUT} and @code{IN OUT}
2335 parameters in interfacing to external functions (which are not permitted
2336 in Ada functions).  You may optionally use the @code{Mechanism}
2337 parameters to specify passing mechanisms for the parameters.
2338 If you specify a single mechanism name, it applies to all parameters.
2339 Otherwise you may specify a mechanism on a parameter by parameter
2340 basis using either positional or named notation.  If the mechanism is not
2341 specified, the default mechanism is used.
2343 Note that it is important to use this pragma in conjunction with a separate
2344 pragma Import that specifies the desired convention, since otherwise the
2345 default convention is Ada, which is almost certainly not what is required.
2347 @node Pragma Initialize_Scalars
2348 @unnumberedsec Pragma Initialize_Scalars
2349 @findex Initialize_Scalars
2350 @cindex debugging with Initialize_Scalars
2351 @noindent
2352 Syntax:
2354 @smallexample @c ada
2355 pragma Initialize_Scalars;
2356 @end smallexample
2358 @noindent
2359 This pragma is similar to @code{Normalize_Scalars} conceptually but has
2360 two important differences.  First, there is no requirement for the pragma
2361 to be used uniformly in all units of a partition, in particular, it is fine
2362 to use this just for some or all of the application units of a partition,
2363 without needing to recompile the run-time library.
2365 In the case where some units are compiled with the pragma, and some without,
2366 then a declaration of a variable where the type is defined in package
2367 Standard or is locally declared will always be subject to initialization,
2368 as will any declaration of a scalar variable.  For composite variables,
2369 whether the variable is initialized may also depend on whether the package
2370 in which the type of the variable is declared is compiled with the pragma.
2372 The other important difference is that you can control the value used
2373 for initializing scalar objects.  At bind time, you can select several
2374 options for initialization. You can
2375 initialize with invalid values (similar to Normalize_Scalars, though for
2376 Initialize_Scalars it is not always possible to determine the invalid
2377 values in complex cases like signed component fields with non-standard
2378 sizes). You can also initialize with high or
2379 low values, or with a specified bit pattern.  See the users guide for binder
2380 options for specifying these cases.
2382 This means that you can compile a program, and then without having to
2383 recompile the program, you can run it with different values being used
2384 for initializing otherwise uninitialized values, to test if your program
2385 behavior depends on the choice.  Of course the behavior should not change,
2386 and if it does, then most likely you have an erroneous reference to an
2387 uninitialized value.
2389 It is even possible to change the value at execution time eliminating even
2390 the need to rebind with a different switch using an environment variable.
2391 See the GNAT users guide for details.
2393 Note that pragma @code{Initialize_Scalars} is particularly useful in
2394 conjunction with the enhanced validity checking that is now provided
2395 in GNAT, which checks for invalid values under more conditions.
2396 Using this feature (see description of the @code{-gnatV} flag in the
2397 users guide) in conjunction with pragma @code{Initialize_Scalars}
2398 provides a powerful new tool to assist in the detection of problems
2399 caused by uninitialized variables.
2401 Note: the use of @code{Initialize_Scalars} has a fairly extensive
2402 effect on the generated code. This may cause your code to be
2403 substantially larger. It may also cause an increase in the amount
2404 of stack required, so it is probably a good idea to turn on stack
2405 checking (see description of stack checking in the GNAT users guide)
2406 when using this pragma.
2408 @node Pragma Inline_Always
2409 @unnumberedsec Pragma Inline_Always
2410 @findex Inline_Always
2411 @noindent
2412 Syntax:
2414 @smallexample @c ada
2415 pragma Inline_Always (NAME [, NAME]);
2416 @end smallexample
2418 @noindent
2419 Similar to pragma @code{Inline} except that inlining is not subject to
2420 the use of option @code{-gnatn} and the inlining happens regardless of
2421 whether this option is used.
2423 @node Pragma Inline_Generic
2424 @unnumberedsec Pragma Inline_Generic
2425 @findex Inline_Generic
2426 @noindent
2427 Syntax:
2429 @smallexample @c ada
2430 pragma Inline_Generic (generic_package_NAME);
2431 @end smallexample
2433 @noindent
2434 This is implemented for compatibility with DEC Ada 83 and is recognized,
2435 but otherwise ignored, by GNAT@.  All generic instantiations are inlined
2436 by default when using GNAT@.
2438 @node Pragma Interface
2439 @unnumberedsec Pragma Interface
2440 @findex Interface
2441 @noindent
2442 Syntax:
2444 @smallexample @c ada
2445 pragma Interface (
2446      [Convention    =>] convention_identifier,
2447      [Entity =>] local_NAME
2448   [, [External_Name =>] static_string_expression],
2449   [, [Link_Name     =>] static_string_expression]);
2450 @end smallexample
2452 @noindent
2453 This pragma is identical in syntax and semantics to
2454 the standard Ada 95 pragma @code{Import}.  It is provided for compatibility
2455 with Ada 83.  The definition is upwards compatible both with pragma
2456 @code{Interface} as defined in the Ada 83 Reference Manual, and also
2457 with some extended implementations of this pragma in certain Ada 83
2458 implementations.
2460 @node Pragma Interface_Name
2461 @unnumberedsec Pragma Interface_Name
2462 @findex Interface_Name
2463 @noindent
2464 Syntax:
2466 @smallexample @c ada
2467 pragma Interface_Name (
2468      [Entity        =>] local_NAME
2469   [, [External_Name =>] static_string_EXPRESSION]
2470   [, [Link_Name     =>] static_string_EXPRESSION]);
2471 @end smallexample
2473 @noindent
2474 This pragma provides an alternative way of specifying the interface name
2475 for an interfaced subprogram, and is provided for compatibility with Ada
2476 83 compilers that use the pragma for this purpose.  You must provide at
2477 least one of @var{External_Name} or @var{Link_Name}.
2479 @node Pragma Interrupt_Handler
2480 @unnumberedsec Pragma Interrupt_Handler
2481 @findex Interrupt_Handler
2482 @noindent
2483 Syntax:
2485 @smallexample @c ada
2486 pragma Interrupt_Handler (procedure_local_NAME);
2487 @end smallexample
2489 @noindent
2490 This program unit pragma is supported for parameterless protected procedures
2491 as described in Annex C of the Ada Reference Manual. On the AAMP target
2492 the pragma can also be specified for nonprotected parameterless procedures
2493 that are declared at the library level (which includes procedures
2494 declared at the top level of a library package). In the case of AAMP,
2495 when this pragma is applied to a nonprotected procedure, the instruction
2496 @code{IERET} is generated for returns from the procedure, enabling
2497 maskable interrupts, in place of the normal return instruction.
2499 @node Pragma Interrupt_State
2500 @unnumberedsec Pragma Interrupt_State
2501 @findex Interrupt_State
2502 @noindent
2503 Syntax:
2505 @smallexample @c ada
2506 pragma Interrupt_State (Name => value, State => SYSTEM | RUNTIME | USER);
2507 @end smallexample
2509 @noindent
2510 Normally certain interrupts are reserved to the implementation.  Any attempt
2511 to attach an interrupt causes Program_Error to be raised, as described in
2512 RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
2513 many systems for an @kbd{Ctrl-C} interrupt.  Normally this interrupt is
2514 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
2515 interrupt execution.  Additionally, signals such as @code{SIGSEGV},
2516 @code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
2517 Ada exceptions, or used to implement run-time functions such as the
2518 @code{abort} statement and stack overflow checking.
2520 Pragma @code{Interrupt_State} provides a general mechanism for overriding
2521 such uses of interrupts.  It subsumes the functionality of pragma
2522 @code{Unreserve_All_Interrupts}.  Pragma @code{Interrupt_State} is not
2523 available on OS/2, Windows or VMS.  On all other platforms than VxWorks,
2524 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
2525 and may be used to mark interrupts required by the board support package
2526 as reserved.
2528 Interrupts can be in one of three states:
2529 @itemize @bullet
2530 @item System
2532 The interrupt is reserved (no Ada handler can be installed), and the
2533 Ada run-time may not install a handler. As a result you are guaranteed
2534 standard system default action if this interrupt is raised.
2536 @item Runtime
2538 The interrupt is reserved (no Ada handler can be installed). The run time
2539 is allowed to install a handler for internal control purposes, but is
2540 not required to do so.
2542 @item User
2544 The interrupt is unreserved.  The user may install a handler to provide
2545 some other action.
2546 @end itemize
2548 @noindent
2549 These states are the allowed values of the @code{State} parameter of the
2550 pragma.  The @code{Name} parameter is a value of the type
2551 @code{Ada.Interrupts.Interrupt_ID}.  Typically, it is a name declared in
2552 @code{Ada.Interrupts.Names}.
2554 This is a configuration pragma, and the binder will check that there
2555 are no inconsistencies between different units in a partition in how a
2556 given interrupt is specified. It may appear anywhere a pragma is legal.
2558 The effect is to move the interrupt to the specified state.
2560 By declaring interrupts to be SYSTEM, you guarantee the standard system
2561 action, such as a core dump.
2563 By declaring interrupts to be USER, you guarantee that you can install
2564 a handler.
2566 Note that certain signals on many operating systems cannot be caught and
2567 handled by applications.  In such cases, the pragma is ignored.  See the
2568 operating system documentation, or the value of the array @code{Reserved}
2569 declared in the specification of package @code{System.OS_Interface}.
2571 Overriding the default state of signals used by the Ada runtime may interfere
2572 with an application's runtime behavior in the cases of the synchronous signals,
2573 and in the case of the signal used to implement the @code{abort} statement.
2575 @node Pragma Keep_Names
2576 @unnumberedsec Pragma Keep_Names
2577 @findex Keep_Names
2578 @noindent
2579 Syntax:
2581 @smallexample @c ada
2582 pragma Keep_Names ([On =>] enumeration_first_subtype_local_NAME);
2583 @end smallexample
2585 @noindent
2586 The @var{local_NAME} argument
2587 must refer to an enumeration first subtype
2588 in the current declarative part. The effect is to retain the enumeration
2589 literal names for use by @code{Image} and @code{Value} even if a global
2590 @code{Discard_Names} pragma applies. This is useful when you want to
2591 generally suppress enumeration literal names and for example you therefore
2592 use a @code{Discard_Names} pragma in the @file{gnat.adc} file, but you
2593 want to retain the names for specific enumeration types.
2595 @node Pragma License
2596 @unnumberedsec Pragma License
2597 @findex License
2598 @cindex License checking
2599 @noindent
2600 Syntax:
2602 @smallexample @c ada
2603 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
2604 @end smallexample
2606 @noindent
2607 This pragma is provided to allow automated checking for appropriate license
2608 conditions with respect to the standard and modified GPL@.  A pragma
2609 @code{License}, which is a configuration pragma that typically appears at
2610 the start of a source file or in a separate @file{gnat.adc} file, specifies
2611 the licensing conditions of a unit as follows:
2613 @itemize @bullet
2614 @item Unrestricted
2615 This is used for a unit that can be freely used with no license restrictions.
2616 Examples of such units are public domain units, and units from the Ada
2617 Reference Manual.
2619 @item GPL
2620 This is used for a unit that is licensed under the unmodified GPL, and which
2621 therefore cannot be @code{with}'ed by a restricted unit.
2623 @item Modified_GPL
2624 This is used for a unit licensed under the GNAT modified GPL that includes
2625 a special exception paragraph that specifically permits the inclusion of
2626 the unit in programs without requiring the entire program to be released
2627 under the GPL@.
2629 @item Restricted
2630 This is used for a unit that is restricted in that it is not permitted to
2631 depend on units that are licensed under the GPL@.  Typical examples are
2632 proprietary code that is to be released under more restrictive license
2633 conditions.  Note that restricted units are permitted to @code{with} units
2634 which are licensed under the modified GPL (this is the whole point of the
2635 modified GPL).
2637 @end itemize
2639 @noindent
2640 Normally a unit with no @code{License} pragma is considered to have an
2641 unknown license, and no checking is done.  However, standard GNAT headers
2642 are recognized, and license information is derived from them as follows.
2644 @itemize @bullet
2646 A GNAT license header starts with a line containing 78 hyphens.  The following
2647 comment text is searched for the appearance of any of the following strings.
2649 If the string ``GNU General Public License'' is found, then the unit is assumed
2650 to have GPL license, unless the string ``As a special exception'' follows, in
2651 which case the license is assumed to be modified GPL@.
2653 If one of the strings
2654 ``This specification is adapted from the Ada Semantic Interface'' or
2655 ``This specification is derived from the Ada Reference Manual'' is found
2656 then the unit is assumed to be unrestricted.
2657 @end itemize
2659 @noindent
2660 These default actions means that a program with a restricted license pragma
2661 will automatically get warnings if a GPL unit is inappropriately
2662 @code{with}'ed.  For example, the program:
2664 @smallexample @c ada
2665 with Sem_Ch3;
2666 with GNAT.Sockets;
2667 procedure Secret_Stuff is
2668   @dots{}
2669 end Secret_Stuff
2670 @end smallexample
2672 @noindent
2673 if compiled with pragma @code{License} (@code{Restricted}) in a
2674 @file{gnat.adc} file will generate the warning:
2676 @smallexample
2677 1.  with Sem_Ch3;
2678         |
2679    >>> license of withed unit "Sem_Ch3" is incompatible
2681 2.  with GNAT.Sockets;
2682 3.  procedure Secret_Stuff is
2683 @end smallexample
2685 @noindent
2686 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
2687 compiler and is licensed under the
2688 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
2689 run time, and is therefore licensed under the modified GPL@.
2691 @node Pragma Link_With
2692 @unnumberedsec Pragma Link_With
2693 @findex Link_With
2694 @noindent
2695 Syntax:
2697 @smallexample @c ada
2698 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
2699 @end smallexample
2701 @noindent
2702 This pragma is provided for compatibility with certain Ada 83 compilers.
2703 It has exactly the same effect as pragma @code{Linker_Options} except
2704 that spaces occurring within one of the string expressions are treated
2705 as separators. For example, in the following case:
2707 @smallexample @c ada
2708 pragma Link_With ("-labc -ldef");
2709 @end smallexample
2711 @noindent
2712 results in passing the strings @code{-labc} and @code{-ldef} as two
2713 separate arguments to the linker. In addition pragma Link_With allows
2714 multiple arguments, with the same effect as successive pragmas.
2716 @node Pragma Linker_Alias
2717 @unnumberedsec Pragma Linker_Alias
2718 @findex Linker_Alias
2719 @noindent
2720 Syntax:
2722 @smallexample @c ada
2723 pragma Linker_Alias (
2724   [Entity =>] local_NAME
2725   [Target =>] static_string_EXPRESSION);
2726 @end smallexample
2728 @noindent
2729 @var{local_NAME} must refer to an object that is declared at the library
2730 level. This pragma establishes the given entity as a linker alias for the
2731 given target. It is equivalent to @code{__attribute__((alias))} in GNU C
2732 and causes @var{local_NAME} to be emitted as an alias for the symbol
2733 @var{static_string_EXPRESSION} in the object file, that is to say no space
2734 is reserved for @var{local_NAME} by the assembler and it will be resolved
2735 to the same address as @var{static_string_EXPRESSION} by the linker.
2737 The actual linker name for the target must be used (e.g. the fully
2738 encoded name with qualification in Ada, or the mangled name in C++),
2739 or it must be declared using the C convention with @code{pragma Import}
2740 or @code{pragma Export}.
2742 Not all target machines support this pragma. On some of them it is accepted
2743 only if @code{pragma Weak_External} has been applied to @var{local_NAME}.
2745 @smallexample @c ada
2746 --  Example of the use of pragma Linker_Alias
2748 package p is
2749   i : Integer := 1;
2750   pragma Export (C, i);
2752   new_name_for_i : Integer;
2753   pragma Linker_Alias (new_name_for_i, "i");
2754 end p;
2755 @end smallexample
2757 @node Pragma Linker_Constructor
2758 @unnumberedsec Pragma Linker_Constructor
2759 @findex Linker_Constructor
2760 @noindent
2761 Syntax:
2763 @smallexample @c ada
2764 pragma Linker_Constructor (procedure_LOCAL_NAME);
2765 @end smallexample
2767 @noindent
2768 @var{procedure_local_NAME} must refer to a parameterless procedure that
2769 is declared at the library level. A procedure to which this pragma is
2770 applied will be treated as an initialization routine by the linker.
2771 It is equivalent to @code{__attribute__((constructor))} in GNU C and
2772 causes @var{procedure_LOCAL_NAME} to be invoked before the entry point
2773 of the executable is called (or immediately after the shared library is
2774 loaded if the procedure is linked in a shared library), in particular
2775 before the Ada run-time environment is set up.
2777 Because of these specific contexts, the set of operations such a procedure
2778 can perform is very limited and the type of objects it can manipulate is
2779 essentially restricted to the elementary types. In particular, it must only
2780 contain code to which pragma Restrictions (No_Elaboration_Code) applies.
2782 This pragma is used by GNAT to implement auto-initialization of shared Stand
2783 Alone Libraries, which provides a related capability without the restrictions
2784 listed above. Where possible, the use of Stand Alone Libraries is preferable
2785 to the use of this pragma.
2787 @node Pragma Linker_Destructor
2788 @unnumberedsec Pragma Linker_Destructor
2789 @findex Linker_Destructor
2790 @noindent
2791 Syntax:
2793 @smallexample @c ada
2794 pragma Linker_Destructor (procedure_LOCAL_NAME);
2795 @end smallexample
2797 @noindent
2798 @var{procedure_local_NAME} must refer to a parameterless procedure that
2799 is declared at the library level. A procedure to which this pragma is
2800 applied will be treated as a finalization routine by the linker.
2801 It is equivalent to @code{__attribute__((destructor))} in GNU C and
2802 causes @var{procedure_LOCAL_NAME} to be invoked after the entry point
2803 of the executable has exited (or immediately before the shared library
2804 is unloaded if the procedure is linked in a shared library), in particular
2805 after the Ada run-time environment is shut down.
2807 See @code{pragma Linker_Constructor} for the set of restrictions that apply
2808 because of these specific contexts.
2810 @node Pragma Linker_Section
2811 @unnumberedsec Pragma Linker_Section
2812 @findex Linker_Section
2813 @noindent
2814 Syntax:
2816 @smallexample @c ada
2817 pragma Linker_Section (
2818   [Entity  =>] local_NAME
2819   [Section =>] static_string_EXPRESSION);
2820 @end smallexample
2822 @noindent
2823 @var{local_NAME} must refer to an object that is declared at the library
2824 level. This pragma specifies the name of the linker section for the given
2825 entity. It is equivalent to @code{__attribute__((section))} in GNU C and
2826 causes @var{local_NAME} to be placed in the @var{static_string_EXPRESSION}
2827 section of the executable (assuming the linker doesn't rename the section).
2829 The compiler normally places library-level objects in standard sections
2830 depending on their type: procedures and functions generally go in the
2831 @code{.text} section, initialized variables in the @code{.data} section
2832 and uninitialized variables in the @code{.bss} section.
2834 Other, special sections may exist on given target machines to map special
2835 hardware, for example I/O ports or flash memory. This pragma is a means to
2836 defer the final layout of the executable to the linker, thus fully working
2837 at the symbolic level with the compiler.
2839 Some file formats do not support arbitrary sections so not all target
2840 machines support this pragma. The use of this pragma may cause a program
2841 execution to be erroneous if it is used to place an entity into an
2842 inappropriate section (e.g. a modified variable into the @code{.text}
2843 section). See also @code{pragma Persistent_BSS}.
2845 @smallexample @c ada
2846 --  Example of the use of pragma Linker_Section
2848 package IO_Card is
2849   Port_A : Integer;
2850   pragma Volatile (Port_A);
2851   pragma Linker_Section (Port_A, ".bss.port_a");
2853   Port_B : Integer;
2854   pragma Volatile (Port_B);
2855   pragma Linker_Section (Port_B, ".bss.port_b");
2856 end IO_Card;
2857 @end smallexample
2859 @node Pragma Long_Float
2860 @unnumberedsec Pragma Long_Float
2861 @cindex OpenVMS
2862 @findex Long_Float
2863 @noindent
2864 Syntax:
2866 @smallexample @c ada
2867 pragma Long_Float (FLOAT_FORMAT);
2869 FLOAT_FORMAT ::= D_Float | G_Float
2870 @end smallexample
2872 @noindent
2873 This pragma is implemented only in the OpenVMS implementation of GNAT@.
2874 It allows control over the internal representation chosen for the predefined
2875 type @code{Long_Float} and for floating point type representations with
2876 @code{digits} specified in the range 7 through 15.
2877 For further details on this pragma, see the
2878 @cite{DEC Ada Language Reference Manual}, section 3.5.7b.  Note that to use
2879 this pragma, the standard runtime libraries must be recompiled.  See the
2880 description of the @code{GNAT LIBRARY} command in the OpenVMS version
2881 of the GNAT User's Guide for details on the use of this command.
2883 @node Pragma Machine_Attribute
2884 @unnumberedsec Pragma Machine_Attribute
2885 @findex Machine_Attribute
2886 @noindent
2887 Syntax:
2889 @smallexample @c ada
2890 pragma Machine_Attribute (
2891   [Attribute_Name =>] string_EXPRESSION,
2892   [Entity         =>] local_NAME);
2893 @end smallexample
2895 @noindent
2896 Machine-dependent attributes can be specified for types and/or
2897 declarations.  This pragma is semantically equivalent to
2898 @code{__attribute__((@var{string_expression}))} in GNU C,
2899 where @code{@var{string_expression}} is
2900 recognized by the target macro @code{TARGET_ATTRIBUTE_TABLE} which is
2901 defined for each machine.  See the GCC manual for further information.
2902 It is not possible to specify attributes defined by other languages,
2903 only attributes defined by the machine the code is intended to run on.
2905 @node Pragma Main_Storage
2906 @unnumberedsec Pragma Main_Storage
2907 @cindex OpenVMS
2908 @findex Main_Storage
2909 @noindent
2910 Syntax:
2912 @smallexample @c ada
2913 pragma Main_Storage
2914   (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
2916 MAIN_STORAGE_OPTION ::=
2917   [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
2918 | [TOP_GUARD       =>] static_SIMPLE_EXPRESSION
2920 @end smallexample
2922 @noindent
2923 This pragma is provided for compatibility with OpenVMS VAX Systems.  It has
2924 no effect in GNAT, other than being syntax checked.  Note that the pragma
2925 also has no effect in DEC Ada 83 for OpenVMS Alpha Systems.
2927 @node Pragma No_Return
2928 @unnumberedsec Pragma No_Return
2929 @findex No_Return
2930 @noindent
2931 Syntax:
2933 @smallexample @c ada
2934 pragma No_Return (procedure_local_NAME @{, procedure_local_NAME@});
2935 @end smallexample
2937 @noindent
2938 Each @var{procedure_local_NAME} argument must refer to one or more procedure
2939 declarations in the current declarative part.  A procedure to which this
2940 pragma is applied may not contain any explicit @code{return} statements.
2941 In addition, if the procedure contains any implicit returns from falling
2942 off the end of a statement sequence, then execution of that implicit
2943 return will cause Program_Error to be raised.
2945 One use of this pragma is to identify procedures whose only purpose is to raise
2946 an exception. Another use of this pragma is to suppress incorrect warnings
2947 about missing returns in functions, where the last statement of a function
2948 statement sequence is a call to such a procedure.
2950 Note that in Ada 2005 mode, this pragma is part of the language, and is
2951 identical in effect to the pragma as implemented in Ada 95 mode.
2953 @node Pragma No_Strict_Aliasing
2954 @unnumberedsec Pragma No_Strict_Aliasing
2955 @findex No_Strict_Aliasing
2956 @noindent
2957 Syntax:
2959 @smallexample @c ada
2960 pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
2961 @end smallexample
2963 @noindent
2964 @var{type_LOCAL_NAME} must refer to an access type
2965 declaration in the current declarative part.  The effect is to inhibit
2966 strict aliasing optimization for the given type.  The form with no
2967 arguments is a configuration pragma which applies to all access types
2968 declared in units to which the pragma applies. For a detailed
2969 description of the strict aliasing optimization, and the situations
2970 in which it must be suppressed, see section
2971 ``Optimization and Strict Aliasing'' in the @value{EDITION} User's Guide.
2973 @node Pragma Normalize_Scalars
2974 @unnumberedsec Pragma Normalize_Scalars
2975 @findex Normalize_Scalars
2976 @noindent
2977 Syntax:
2979 @smallexample @c ada
2980 pragma Normalize_Scalars;
2981 @end smallexample
2983 @noindent
2984 This is a language defined pragma which is fully implemented in GNAT@.  The
2985 effect is to cause all scalar objects that are not otherwise initialized
2986 to be initialized.  The initial values are implementation dependent and
2987 are as follows:
2989 @table @code
2990 @item Standard.Character
2991 @noindent
2992 Objects whose root type is Standard.Character are initialized to
2993 Character'Last unless the subtype range excludes NUL (in which case
2994 NUL is used). This choice will always generate an invalid value if
2995 one exists.
2997 @item Standard.Wide_Character
2998 @noindent
2999 Objects whose root type is Standard.Wide_Character are initialized to
3000 Wide_Character'Last unless the subtype range excludes NUL (in which case
3001 NUL is used). This choice will always generate an invalid value if
3002 one exists.
3004 @item Standard.Wide_Wide_Character
3005 @noindent
3006 Objects whose root type is Standard.Wide_Wide_Character are initialized to
3007 the invalid value 16#FFFF_FFFF# unless the subtype range excludes NUL (in
3008 which case NUL is used). This choice will always generate an invalid value if
3009 one exists.
3011 @item Integer types
3012 @noindent
3013 Objects of an integer type are treated differently depending on whether
3014 negative values are present in the subtype. If no negative values are
3015 present, then all one bits is used as the initial value except in the
3016 special case where zero is excluded from the subtype, in which case
3017 all zero bits are used. This choice will always generate an invalid
3018 value if one exists.
3020 For subtypes with negative values present, the largest negative number
3021 is used, except in the unusual case where this largest negative number
3022 is in the subtype, and the largest positive number is not, in which case
3023 the largest positive value is used. This choice will always generate
3024 an invalid value if one exists.
3026 @item Floating-Point Types
3027 Objects of all floating-point types are initialized to all 1-bits. For
3028 standard IEEE format, this corresponds to a NaN (not a number) which is
3029 indeed an invalid value.
3031 @item Fixed-Point Types
3032 Objects of all fixed-point types are treated as described above for integers,
3033 with the rules applying to the underlying integer value used to represent
3034 the fixed-point value.
3036 @item Modular types
3037 Objects of a modular type are initialized to all one bits, except in
3038 the special case where zero is excluded from the subtype, in which
3039 case all zero bits are used. This choice will always generate an
3040 invalid value if one exists.
3042 @item Enumeration types
3043 Objects of an enumeration type are initialized to all one-bits, i.e.@: to
3044 the value @code{2 ** typ'Size - 1} unless the subtype excludes the literal
3045 whose Pos value is zero, in which case a code of zero is used. This choice
3046 will always generate an invalid value if one exists.
3048 @end table
3050 @node Pragma Obsolescent
3051 @unnumberedsec Pragma Obsolescent
3052 @findex Obsolescent
3053 @noindent
3054 Syntax:
3056 @smallexample @c ada
3057 pragma Obsolescent
3058   (Entity => NAME [, static_string_EXPRESSION [,Ada_05]]);
3059 @end smallexample
3061 @noindent
3062 This pragma can occur immediately following a declaration of an entity,
3063 including the case of a record component, and usually the Entity name
3064 must match the name of the entity declared by this declaration.
3065 Alternatively, the pragma can immediately follow an
3066 enumeration type declaration, where the entity argument names one of the
3067 enumeration literals.
3069 This pragma is used to indicate that the named entity
3070 is considered obsolescent and should not be used. Typically this is
3071 used when an API must be modified by eventually removing or modifying
3072 existing subprograms or other entities. The pragma can be used at an
3073 intermediate stage when the entity is still present, but will be
3074 removed later.
3076 The effect of this pragma is to output a warning message on
3077 a call to a program thus marked that the
3078 subprogram is obsolescent if the appropriate warning option in the
3079 compiler is activated. If the string parameter is present, then a second
3080 warning message is given containing this text.
3081 In addition, a call to such a program is considered a violation of
3082 pragma Restrictions (No_Obsolescent_Features).
3084 This pragma can also be used as a program unit pragma for a package,
3085 in which case the entity name is the name of the package, and the
3086 pragma indicates that the entire package is considered
3087 obsolescent. In this case a client @code{with}'ing such a package
3088 violates the restriction, and the @code{with} statement is
3089 flagged with warnings if the warning option is set.
3091 If the optional third parameter is present (which must be exactly
3092 the identifier Ada_05, no other argument is allowed), then the
3093 indication of obsolescence applies only when compiling in Ada 2005
3094 mode. This is primarily intended for dealing with the situations
3095 in the predefined library where subprograms or packages
3096 have become defined as obsolescent in Ada 2005
3097 (e.g. in Ada.Characters.Handling), but may be used anywhere.
3099 The following examples show typical uses of this pragma:
3101 @smallexample @c ada
3102 package p is
3103    pragma Obsolescent
3104      (Entity => p, "use pp instead of p");
3105 end p;
3107 package q is
3108    procedure q2;
3109    pragma Obsolescent
3110      (Entity => q2, "use q2new instead");
3112    type R is new integer;
3113    pragma Obsolescent
3114      (Entity => R, "use RR in Ada 2005", Ada_05);
3116    type M is record
3117       F1 : Integer;
3118       F2 : Integer;
3119       pragma Obsolescent (Entity => F2);
3120       F3 : Integer;
3121    end record;
3123    type E is (a, bc, 'd', quack);
3124    pragma Obsolescent (Entity => bc)
3125    pragma Obsolescent (Entity => 'd')
3127    function "+"
3128      (a, b : character) return character;
3129    pragma Obsolescent (Entity => "+");
3130 end;
3131 @end smallexample
3133 @noindent
3134 In an earlier version of GNAT, the Entity parameter was not required,
3135 and this form is still accepted for compatibility purposes. If the
3136 Entity parameter is omitted, then the pragma applies to the declaration
3137 immediately preceding the pragma (this form cannot be used for the
3138 enumeration literal case).
3140 @node Pragma Passive
3141 @unnumberedsec Pragma Passive
3142 @findex Passive
3143 @noindent
3144 Syntax:
3146 @smallexample @c ada
3147 pragma Passive ([Semaphore | No]);
3148 @end smallexample
3150 @noindent
3151 Syntax checked, but otherwise ignored by GNAT@.  This is recognized for
3152 compatibility with DEC Ada 83 implementations, where it is used within a
3153 task definition to request that a task be made passive.  If the argument
3154 @code{Semaphore} is present, or the argument is omitted, then DEC Ada 83
3155 treats the pragma as an assertion that the containing task is passive
3156 and that optimization of context switch with this task is permitted and
3157 desired.  If the argument @code{No} is present, the task must not be
3158 optimized.  GNAT does not attempt to optimize any tasks in this manner
3159 (since protected objects are available in place of passive tasks).
3161 @node Pragma Persistent_BSS
3162 @unnumberedsec Pragma Persistent_BSS
3163 @findex Persistent_BSS
3164 @noindent
3165 Syntax:
3167 @smallexample @c ada
3168 pragma Persistent_BSS [local_NAME]
3169 @end smallexample
3171 @noindent
3172 This pragma allows selected objects to be placed in the @code{.persistent_bss}
3173 section. On some targets the linker and loader provide for special
3174 treatment of this section, allowing a program to be reloaded without
3175 affecting the contents of this data (hence the name persistent).
3177 There are two forms of usage. If an argument is given, it must be the
3178 local name of a library level object, with no explicit initialization
3179 and whose type is potentially persistent. If no argument is given, then
3180 the pragma is a configuration pragma, and applies to all library level
3181 objects with no explicit initialization of potentially persistent types.
3183 A potentially persistent type is a scalar type, or a non-tagged,
3184 non-discriminated record, all of whose components have no explicit
3185 initialization and are themselves of a potentially persistent type,
3186 or an array, all of whose constraints are static, and whose component
3187 type is potentially persistent.
3189 If this pragma is used on a target where this feature is not supported,
3190 then the pragma will be ignored. See also @code{pragma Linker_Section}.
3192 @node Pragma Polling
3193 @unnumberedsec Pragma Polling
3194 @findex Polling
3195 @noindent
3196 Syntax:
3198 @smallexample @c ada
3199 pragma Polling (ON | OFF);
3200 @end smallexample
3202 @noindent
3203 This pragma controls the generation of polling code.  This is normally off.
3204 If @code{pragma Polling (ON)} is used then periodic calls are generated to
3205 the routine @code{Ada.Exceptions.Poll}.  This routine is a separate unit in the
3206 runtime library, and can be found in file @file{a-excpol.adb}.
3208 Pragma @code{Polling} can appear as a configuration pragma (for example it
3209 can be placed in the @file{gnat.adc} file) to enable polling globally, or it
3210 can be used in the statement or declaration sequence to control polling
3211 more locally.
3213 A call to the polling routine is generated at the start of every loop and
3214 at the start of every subprogram call.  This guarantees that the @code{Poll}
3215 routine is called frequently, and places an upper bound (determined by
3216 the complexity of the code) on the period between two @code{Poll} calls.
3218 The primary purpose of the polling interface is to enable asynchronous
3219 aborts on targets that cannot otherwise support it (for example Windows
3220 NT), but it may be used for any other purpose requiring periodic polling.
3221 The standard version is null, and can be replaced by a user program.  This
3222 will require re-compilation of the @code{Ada.Exceptions} package that can
3223 be found in files @file{a-except.ads} and @file{a-except.adb}.
3225 A standard alternative unit (in file @file{4wexcpol.adb} in the standard GNAT
3226 distribution) is used to enable the asynchronous abort capability on
3227 targets that do not normally support the capability.  The version of
3228 @code{Poll} in this file makes a call to the appropriate runtime routine
3229 to test for an abort condition.
3231 Note that polling can also be enabled by use of the @code{-gnatP} switch.  See
3232 the @cite{GNAT User's Guide} for details.
3234 @node Pragma Profile (Ravenscar)
3235 @unnumberedsec Pragma Profile (Ravenscar)
3236 @findex Ravenscar
3237 @noindent
3238 Syntax:
3240 @smallexample @c ada
3241 pragma Profile (Ravenscar);
3242 @end smallexample
3244 @noindent
3245 A configuration pragma that establishes the following set of configuration
3246 pragmas:
3248 @table @code
3249 @item Task_Dispatching_Policy (FIFO_Within_Priorities)
3250 [RM D.2.2] Tasks are dispatched following a preemptive
3251 priority-ordered scheduling policy.
3253 @item Locking_Policy (Ceiling_Locking)
3254 [RM D.3] While tasks and interrupts execute a protected action, they inherit
3255 the ceiling priority of the corresponding protected object.
3257 @c @item Detect_Blocking
3258 @c This pragma forces the detection of potentially blocking operations within a
3259 @c protected operation, and to raise Program_Error if that happens.
3260 @end table
3261 @noindent
3263 plus the following set of restrictions:
3265 @table @code
3266 @item Max_Entry_Queue_Length = 1
3267 Defines the maximum number of calls that are queued on a (protected) entry.
3268 Note that this restrictions is checked at run time. Violation of this
3269 restriction results in the raising of Program_Error exception at the point of
3270 the call. For the Profile (Ravenscar) the value of Max_Entry_Queue_Length is
3271 always 1 and hence no task can be queued on a protected entry.
3273 @item Max_Protected_Entries = 1
3274 [RM D.7] Specifies the maximum number of entries per protected type. The
3275 bounds of every entry family of a protected unit shall be static, or shall be
3276 defined by a discriminant of a subtype whose corresponding bound is static.
3277 For the Profile (Ravenscar) the value of Max_Protected_Entries is always 1.
3279 @item Max_Task_Entries = 0
3280 [RM D.7] Specifies the maximum number of entries
3281 per task.  The bounds of every entry family
3282 of a task unit shall be static, or shall be
3283 defined by a discriminant of a subtype whose
3284 corresponding bound is static.  A value of zero
3285 indicates that no rendezvous are possible.  For
3286 the Profile (Ravenscar), the value of Max_Task_Entries is always
3287 0 (zero).
3289 @item No_Abort_Statements
3290 [RM D.7] There are no abort_statements, and there are
3291 no calls to Task_Identification.Abort_Task.
3293 @item No_Asynchronous_Control
3294 [RM D.7] There are no semantic dependences on the package
3295 Asynchronous_Task_Control.
3297 @item No_Calendar
3298 There are no semantic dependencies on the package Ada.Calendar.
3300 @item No_Dynamic_Attachment
3301 There is no call to any of the operations defined in package Ada.Interrupts
3302 (Is_Reserved, Is_Attached, Current_Handler, Attach_Handler, Exchange_Handler,
3303 Detach_Handler, and Reference).
3305 @item No_Dynamic_Priorities
3306 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
3308 @item No_Implicit_Heap_Allocations
3309 [RM D.7] No constructs are allowed to cause implicit heap allocation.
3311 @item No_Local_Protected_Objects
3312 Protected objects and access types that designate
3313 such objects shall be declared only at library level.
3315 @item No_Protected_Type_Allocators
3316 There are no allocators for protected types or
3317 types containing protected subcomponents.
3319 @item No_Relative_Delay
3320 There are no delay_relative statements.
3322 @item No_Requeue_Statements
3323 Requeue statements are not allowed.
3325 @item No_Select_Statements
3326 There are no select_statements.
3328 @item No_Task_Allocators
3329 [RM D.7] There are no allocators for task types
3330 or types containing task subcomponents.
3332 @item No_Task_Attributes_Package
3333 There are no semantic dependencies on the Ada.Task_Attributes package.
3335 @item No_Task_Hierarchy
3336 [RM D.7] All (non-environment) tasks depend
3337 directly on the environment task of the partition.
3339 @item No_Task_Termination
3340 Tasks which terminate are erroneous.
3342 @item Simple_Barriers
3343 Entry barrier condition expressions shall be either static
3344 boolean expressions or boolean objects which are declared in
3345 the protected type which contains the entry.
3346 @end table
3348 @noindent
3349 This set of configuration pragmas and restrictions correspond to the
3350 definition of the ``Ravenscar Profile'' for limited tasking, devised and
3351 published by the @cite{International Real-Time Ada Workshop}, 1997,
3352 and whose most recent description is available at
3353 @url{ftp://ftp.openravenscar.org/openravenscar/ravenscar00.pdf}.
3355 The original definition of the profile was revised at subsequent IRTAW
3356 meetings. It has been included in the ISO
3357 @cite{Guide for the Use of the Ada Programming Language in High
3358 Integrity Systems}, and has been approved by ISO/IEC/SC22/WG9 for inclusion in
3359 the next revision of the standard. The formal definition given by
3360 the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
3361 AI-305) available at
3362 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00249.TXT} and
3363 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00305.TXT}
3364 respectively.
3366 The above set is a superset of the restrictions provided by pragma
3367 @code{Profile (Restricted)}, it includes six additional restrictions
3368 (@code{Simple_Barriers}, @code{No_Select_Statements},
3369 @code{No_Calendar}, @code{No_Implicit_Heap_Allocations},
3370 @code{No_Relative_Delay} and @code{No_Task_Termination}).  This means
3371 that pragma @code{Profile (Ravenscar)}, like the pragma
3372 @code{Profile (Restricted)},
3373 automatically causes the use of a simplified,
3374 more efficient version of the tasking run-time system.
3376 @node Pragma Profile (Restricted)
3377 @unnumberedsec Pragma Profile (Restricted)
3378 @findex Restricted Run Time
3379 @noindent
3380 Syntax:
3382 @smallexample @c ada
3383 pragma Profile (Restricted);
3384 @end smallexample
3386 @noindent
3387 A configuration pragma that establishes the following set of restrictions:
3389 @itemize @bullet
3390 @item No_Abort_Statements
3391 @item No_Entry_Queue
3392 @item No_Task_Hierarchy
3393 @item No_Task_Allocators
3394 @item No_Dynamic_Priorities
3395 @item No_Terminate_Alternatives
3396 @item No_Dynamic_Attachment
3397 @item No_Protected_Type_Allocators
3398 @item No_Local_Protected_Objects
3399 @item No_Requeue_Statements
3400 @item No_Task_Attributes_Package
3401 @item Max_Asynchronous_Select_Nesting =  0
3402 @item Max_Task_Entries =  0
3403 @item Max_Protected_Entries = 1
3404 @item Max_Select_Alternatives = 0
3405 @end itemize
3407 @noindent
3408 This set of restrictions causes the automatic selection of a simplified
3409 version of the run time that provides improved performance for the
3410 limited set of tasking functionality permitted by this set of restrictions.
3412 @node Pragma Psect_Object
3413 @unnumberedsec Pragma Psect_Object
3414 @findex Psect_Object
3415 @noindent
3416 Syntax:
3418 @smallexample @c ada
3419 pragma Psect_Object (
3420      [Internal =>] local_NAME,
3421   [, [External =>] EXTERNAL_SYMBOL]
3422   [, [Size     =>] EXTERNAL_SYMBOL]);
3424 EXTERNAL_SYMBOL ::=
3425   IDENTIFIER
3426 | static_string_EXPRESSION
3427 @end smallexample
3429 @noindent
3430 This pragma is identical in effect to pragma @code{Common_Object}.
3432 @node Pragma Pure_Function
3433 @unnumberedsec Pragma Pure_Function
3434 @findex Pure_Function
3435 @noindent
3436 Syntax:
3438 @smallexample @c ada
3439 pragma Pure_Function ([Entity =>] function_local_NAME);
3440 @end smallexample
3442 @noindent
3443 This pragma appears in the same declarative part as a function
3444 declaration (or a set of function declarations if more than one
3445 overloaded declaration exists, in which case the pragma applies
3446 to all entities).  It specifies that the function @code{Entity} is
3447 to be considered pure for the purposes of code generation.  This means
3448 that the compiler can assume that there are no side effects, and
3449 in particular that two calls with identical arguments produce the
3450 same result.  It also means that the function can be used in an
3451 address clause.
3453 Note that, quite deliberately, there are no static checks to try
3454 to ensure that this promise is met, so @code{Pure_Function} can be used
3455 with functions that are conceptually pure, even if they do modify
3456 global variables.  For example, a square root function that is
3457 instrumented to count the number of times it is called is still
3458 conceptually pure, and can still be optimized, even though it
3459 modifies a global variable (the count).  Memo functions are another
3460 example (where a table of previous calls is kept and consulted to
3461 avoid re-computation).
3463 @findex Pure
3464 Note: Most functions in a @code{Pure} package are automatically pure, and
3465 there is no need to use pragma @code{Pure_Function} for such functions.  One
3466 exception is any function that has at least one formal of type
3467 @code{System.Address} or a type derived from it.  Such functions are not
3468 considered pure by default, since the compiler assumes that the
3469 @code{Address} parameter may be functioning as a pointer and that the
3470 referenced data may change even if the address value does not.
3471 Similarly, imported functions are not considered to be pure by default,
3472 since there is no way of checking that they are in fact pure.  The use
3473 of pragma @code{Pure_Function} for such a function will override these default
3474 assumption, and cause the compiler to treat a designated subprogram as pure
3475 in these cases.
3477 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
3478 applies to the underlying renamed function.  This can be used to
3479 disambiguate cases of overloading where some but not all functions
3480 in a set of overloaded functions are to be designated as pure.
3482 If pragma @code{Pure_Function} is applied to a library level function, the
3483 function is also considered pure from an optimization point of view, but the
3484 unit is not a Pure unit in the categorization sense. So for example, a function
3485 thus marked is free to @code{with} non-pure units.
3487 @node Pragma Restriction_Warnings
3488 @unnumberedsec Pragma Restriction_Warnings
3489 @findex Restriction_Warnings
3490 @noindent
3491 Syntax:
3493 @smallexample @c ada
3494 pragma Restriction_Warnings
3495   (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
3496 @end smallexample
3498 @noindent
3499 This pragma allows a series of restriction identifiers to be
3500 specified (the list of allowed identifiers is the same as for
3501 pragma @code{Restrictions}). For each of these identifiers
3502 the compiler checks for violations of the restriction, but
3503 generates a warning message rather than an error message
3504 if the restriction is violated.
3506 @node Pragma Source_File_Name
3507 @unnumberedsec Pragma Source_File_Name
3508 @findex Source_File_Name
3509 @noindent
3510 Syntax:
3512 @smallexample @c ada
3513 pragma Source_File_Name (
3514   [Unit_Name   =>] unit_NAME,
3515   Spec_File_Name =>  STRING_LITERAL);
3517 pragma Source_File_Name (
3518   [Unit_Name   =>] unit_NAME,
3519   Body_File_Name =>  STRING_LITERAL);
3520 @end smallexample
3522 @noindent
3523 Use this to override the normal naming convention.  It is a configuration
3524 pragma, and so has the usual applicability of configuration pragmas
3525 (i.e.@: it applies to either an entire partition, or to all units in a
3526 compilation, or to a single unit, depending on how it is used.
3527 @var{unit_name} is mapped to @var{file_name_literal}.  The identifier for
3528 the second argument is required, and indicates whether this is the file
3529 name for the spec or for the body.
3531 Another form of the @code{Source_File_Name} pragma allows
3532 the specification of patterns defining alternative file naming schemes
3533 to apply to all files.
3535 @smallexample @c ada
3536 pragma Source_File_Name
3537   (Spec_File_Name => STRING_LITERAL
3538    [,Casing => CASING_SPEC]
3539    [,Dot_Replacement => STRING_LITERAL]);
3541 pragma Source_File_Name
3542   (Body_File_Name => STRING_LITERAL
3543    [,Casing => CASING_SPEC]
3544    [,Dot_Replacement => STRING_LITERAL]);
3546 pragma Source_File_Name
3547   (Subunit_File_Name => STRING_LITERAL
3548    [,Casing => CASING_SPEC]
3549    [,Dot_Replacement => STRING_LITERAL]);
3551 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
3552 @end smallexample
3554 @noindent
3555 The first argument is a pattern that contains a single asterisk indicating
3556 the point at which the unit name is to be inserted in the pattern string
3557 to form the file name.  The second argument is optional.  If present it
3558 specifies the casing of the unit name in the resulting file name string.
3559 The default is lower case.  Finally the third argument allows for systematic
3560 replacement of any dots in the unit name by the specified string literal.
3562 A pragma Source_File_Name cannot appear after a
3563 @ref{Pragma Source_File_Name_Project}.
3565 For more details on the use of the @code{Source_File_Name} pragma,
3566 see the sections ``Using Other File Names'' and
3567 ``Alternative File Naming Schemes'' in the @cite{GNAT User's Guide}.
3569 @node Pragma Source_File_Name_Project
3570 @unnumberedsec Pragma Source_File_Name_Project
3571 @findex Source_File_Name_Project
3572 @noindent
3574 This pragma has the same syntax and semantics as pragma Source_File_Name.
3575 It is only allowed as a stand alone configuration pragma.
3576 It cannot appear after a @ref{Pragma Source_File_Name}, and
3577 most importantly, once pragma Source_File_Name_Project appears,
3578 no further Source_File_Name pragmas are allowed.
3580 The intention is that Source_File_Name_Project pragmas are always
3581 generated by the Project Manager in a manner consistent with the naming
3582 specified in a project file, and when naming is controlled in this manner,
3583 it is not permissible to attempt to modify this naming scheme using
3584 Source_File_Name pragmas (which would not be known to the project manager).
3586 @node Pragma Source_Reference
3587 @unnumberedsec Pragma Source_Reference
3588 @findex Source_Reference
3589 @noindent
3590 Syntax:
3592 @smallexample @c ada
3593 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
3594 @end smallexample
3596 @noindent
3597 This pragma must appear as the first line of a source file.
3598 @var{integer_literal} is the logical line number of the line following
3599 the pragma line (for use in error messages and debugging
3600 information).  @var{string_literal} is a static string constant that
3601 specifies the file name to be used in error messages and debugging
3602 information.  This is most notably used for the output of @code{gnatchop}
3603 with the @code{-r} switch, to make sure that the original unchopped
3604 source file is the one referred to.
3606 The second argument must be a string literal, it cannot be a static
3607 string expression other than a string literal.  This is because its value
3608 is needed for error messages issued by all phases of the compiler.
3610 @node Pragma Stream_Convert
3611 @unnumberedsec Pragma Stream_Convert
3612 @findex Stream_Convert
3613 @noindent
3614 Syntax:
3616 @smallexample @c ada
3617 pragma Stream_Convert (
3618   [Entity =>] type_local_NAME,
3619   [Read   =>] function_NAME,
3620   [Write  =>] function_NAME);
3621 @end smallexample
3623 @noindent
3624 This pragma provides an efficient way of providing stream functions for
3625 types defined in packages.  Not only is it simpler to use than declaring
3626 the necessary functions with attribute representation clauses, but more
3627 significantly, it allows the declaration to made in such a way that the
3628 stream packages are not loaded unless they are needed.  The use of
3629 the Stream_Convert pragma adds no overhead at all, unless the stream
3630 attributes are actually used on the designated type.
3632 The first argument specifies the type for which stream functions are
3633 provided.  The second parameter provides a function used to read values
3634 of this type.  It must name a function whose argument type may be any
3635 subtype, and whose returned type must be the type given as the first
3636 argument to the pragma.
3638 The meaning of the @var{Read}
3639 parameter is that if a stream attribute directly
3640 or indirectly specifies reading of the type given as the first parameter,
3641 then a value of the type given as the argument to the Read function is
3642 read from the stream, and then the Read function is used to convert this
3643 to the required target type.
3645 Similarly the @var{Write} parameter specifies how to treat write attributes
3646 that directly or indirectly apply to the type given as the first parameter.
3647 It must have an input parameter of the type specified by the first parameter,
3648 and the return type must be the same as the input type of the Read function.
3649 The effect is to first call the Write function to convert to the given stream
3650 type, and then write the result type to the stream.
3652 The Read and Write functions must not be overloaded subprograms.  If necessary
3653 renamings can be supplied to meet this requirement.
3654 The usage of this attribute is best illustrated by a simple example, taken
3655 from the GNAT implementation of package Ada.Strings.Unbounded:
3657 @smallexample @c ada
3658 function To_Unbounded (S : String)
3659            return Unbounded_String
3660   renames To_Unbounded_String;
3662 pragma Stream_Convert
3663   (Unbounded_String, To_Unbounded, To_String);
3664 @end smallexample
3666 @noindent
3667 The specifications of the referenced functions, as given in the Ada 95
3668 Reference Manual are:
3670 @smallexample @c ada
3671 function To_Unbounded_String (Source : String)
3672   return Unbounded_String;
3674 function To_String (Source : Unbounded_String)
3675   return String;
3676 @end smallexample
3678 @noindent
3679 The effect is that if the value of an unbounded string is written to a
3680 stream, then the representation of the item in the stream is in the same
3681 format used for @code{Standard.String}, and this same representation is
3682 expected when a value of this type is read from the stream.
3684 @node Pragma Style_Checks
3685 @unnumberedsec Pragma Style_Checks
3686 @findex Style_Checks
3687 @noindent
3688 Syntax:
3690 @smallexample @c ada
3691 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
3692                      On | Off [, local_NAME]);
3693 @end smallexample
3695 @noindent
3696 This pragma is used in conjunction with compiler switches to control the
3697 built in style checking provided by GNAT@.  The compiler switches, if set,
3698 provide an initial setting for the switches, and this pragma may be used
3699 to modify these settings, or the settings may be provided entirely by
3700 the use of the pragma.  This pragma can be used anywhere that a pragma
3701 is legal, including use as a configuration pragma (including use in
3702 the @file{gnat.adc} file).
3704 The form with a string literal specifies which style options are to be
3705 activated.  These are additive, so they apply in addition to any previously
3706 set style check options.  The codes for the options are the same as those
3707 used in the @code{-gnaty} switch to @code{gcc} or @code{gnatmake}.
3708 For example the following two methods can be used to enable
3709 layout checking:
3711 @itemize @bullet
3712 @item
3713 @smallexample @c ada
3714 pragma Style_Checks ("l");
3715 @end smallexample
3717 @item
3718 @smallexample
3719 gcc -c -gnatyl @dots{}
3720 @end smallexample
3721 @end itemize
3723 @noindent
3724 The form ALL_CHECKS activates all standard checks (its use is equivalent
3725 to the use of the @code{gnaty} switch with no options.  See GNAT User's
3726 Guide for details.
3728 The forms with @code{Off} and @code{On}
3729 can be used to temporarily disable style checks
3730 as shown in the following example:
3732 @smallexample @c ada
3733 @iftex
3734 @leftskip=0cm
3735 @end iftex
3736 pragma Style_Checks ("k"); -- requires keywords in lower case
3737 pragma Style_Checks (Off); -- turn off style checks
3738 NULL;                      -- this will not generate an error message
3739 pragma Style_Checks (On);  -- turn style checks back on
3740 NULL;                      -- this will generate an error message
3741 @end smallexample
3743 @noindent
3744 Finally the two argument form is allowed only if the first argument is
3745 @code{On} or @code{Off}.  The effect is to turn of semantic style checks
3746 for the specified entity, as shown in the following example:
3748 @smallexample @c ada
3749 @iftex
3750 @leftskip=0cm
3751 @end iftex
3752 pragma Style_Checks ("r"); -- require consistency of identifier casing
3753 Arg : Integer;
3754 Rf1 : Integer := ARG;      -- incorrect, wrong case
3755 pragma Style_Checks (Off, Arg);
3756 Rf2 : Integer := ARG;      -- OK, no error
3757 @end smallexample
3759 @node Pragma Subtitle
3760 @unnumberedsec Pragma Subtitle
3761 @findex Subtitle
3762 @noindent
3763 Syntax:
3765 @smallexample @c ada
3766 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
3767 @end smallexample
3769 @noindent
3770 This pragma is recognized for compatibility with other Ada compilers
3771 but is ignored by GNAT@.
3773 @node Pragma Suppress
3774 @unnumberedsec Pragma Suppress
3775 @findex Suppress
3776 @noindent
3777 Syntax:
3779 @smallexample @c ada
3780 pragma Suppress (Identifier [, [On =>] Name]);
3781 @end smallexample
3783 @noindent
3784 This is a standard pragma, and supports all the check names required in
3785 the RM. It is included here because GNAT recognizes one additional check
3786 name: @code{Alignment_Check} which can be used to suppress alignment checks
3787 on addresses used in address clauses. Such checks can also be suppressed
3788 by suppressing range checks, but the specific use of @code{Alignment_Check}
3789 allows suppression of alignment checks without suppressing other range checks.
3791 @node Pragma Suppress_All
3792 @unnumberedsec Pragma Suppress_All
3793 @findex Suppress_All
3794 @noindent
3795 Syntax:
3797 @smallexample @c ada
3798 pragma Suppress_All;
3799 @end smallexample
3801 @noindent
3802 This pragma can only appear immediately following a compilation
3803 unit.  The effect is to apply @code{Suppress (All_Checks)} to the unit
3804 which it follows.  This pragma is implemented for compatibility with DEC
3805 Ada 83 usage.  The use of pragma @code{Suppress (All_Checks)} as a normal
3806 configuration pragma is the preferred usage in GNAT@.
3808 @node Pragma Suppress_Exception_Locations
3809 @unnumberedsec Pragma Suppress_Exception_Locations
3810 @findex Suppress_Exception_Locations
3811 @noindent
3812 Syntax:
3814 @smallexample @c ada
3815 pragma Suppress_Exception_Locations;
3816 @end smallexample
3818 @noindent
3819 In normal mode, a raise statement for an exception by default generates
3820 an exception message giving the file name and line number for the location
3821 of the raise. This is useful for debugging and logging purposes, but this
3822 entails extra space for the strings for the messages. The configuration
3823 pragma @code{Suppress_Exception_Locations} can be used to suppress the
3824 generation of these strings, with the result that space is saved, but the
3825 exception message for such raises is null. This configuration pragma may
3826 appear in a global configuration pragma file, or in a specific unit as
3827 usual. It is not required that this pragma be used consistently within
3828 a partition, so it is fine to have some units within a partition compiled
3829 with this pragma and others compiled in normal mode without it.
3831 @node Pragma Suppress_Initialization
3832 @unnumberedsec Pragma Suppress_Initialization
3833 @findex Suppress_Initialization
3834 @cindex Suppressing initialization
3835 @cindex Initialization, suppression of
3836 @noindent
3837 Syntax:
3839 @smallexample @c ada
3840 pragma Suppress_Initialization ([Entity =>] type_Name);
3841 @end smallexample
3843 @noindent
3844 This pragma suppresses any implicit or explicit initialization
3845 associated with the given type name for all variables of this type.
3847 @node Pragma Task_Info
3848 @unnumberedsec Pragma Task_Info
3849 @findex Task_Info
3850 @noindent
3851 Syntax
3853 @smallexample @c ada
3854 pragma Task_Info (EXPRESSION);
3855 @end smallexample
3857 @noindent
3858 This pragma appears within a task definition (like pragma
3859 @code{Priority}) and applies to the task in which it appears.  The
3860 argument must be of type @code{System.Task_Info.Task_Info_Type}.
3861 The @code{Task_Info} pragma provides system dependent control over
3862 aspects of tasking implementation, for example, the ability to map
3863 tasks to specific processors.  For details on the facilities available
3864 for the version of GNAT that you are using, see the documentation
3865 in the specification of package System.Task_Info in the runtime
3866 library.
3868 @node Pragma Task_Name
3869 @unnumberedsec Pragma Task_Name
3870 @findex Task_Name
3871 @noindent
3872 Syntax
3874 @smallexample @c ada
3875 pragma Task_Name (string_EXPRESSION);
3876 @end smallexample
3878 @noindent
3879 This pragma appears within a task definition (like pragma
3880 @code{Priority}) and applies to the task in which it appears.  The
3881 argument must be of type String, and provides a name to be used for
3882 the task instance when the task is created.  Note that this expression
3883 is not required to be static, and in particular, it can contain
3884 references to task discriminants.  This facility can be used to
3885 provide different names for different tasks as they are created,
3886 as illustrated in the example below.
3888 The task name is recorded internally in the run-time structures
3889 and is accessible to tools like the debugger.  In addition the
3890 routine @code{Ada.Task_Identification.Image} will return this
3891 string, with a unique task address appended.
3893 @smallexample @c ada
3894 --  Example of the use of pragma Task_Name
3896 with Ada.Task_Identification;
3897 use Ada.Task_Identification;
3898 with Text_IO; use Text_IO;
3899 procedure t3 is
3901    type Astring is access String;
3903    task type Task_Typ (Name : access String) is
3904       pragma Task_Name (Name.all);
3905    end Task_Typ;
3907    task body Task_Typ is
3908       Nam : constant String := Image (Current_Task);
3909    begin
3910       Put_Line ("-->" & Nam (1 .. 14) & "<--");
3911    end Task_Typ;
3913    type Ptr_Task is access Task_Typ;
3914    Task_Var : Ptr_Task;
3916 begin
3917    Task_Var :=
3918      new Task_Typ (new String'("This is task 1"));
3919    Task_Var :=
3920      new Task_Typ (new String'("This is task 2"));
3921 end;
3922 @end smallexample
3924 @node Pragma Task_Storage
3925 @unnumberedsec Pragma Task_Storage
3926 @findex Task_Storage
3927 Syntax:
3929 @smallexample @c ada
3930 pragma Task_Storage (
3931   [Task_Type =>] local_NAME,
3932   [Top_Guard =>] static_integer_EXPRESSION);
3933 @end smallexample
3935 @noindent
3936 This pragma specifies the length of the guard area for tasks.  The guard
3937 area is an additional storage area allocated to a task.  A value of zero
3938 means that either no guard area is created or a minimal guard area is
3939 created, depending on the target.  This pragma can appear anywhere a
3940 @code{Storage_Size} attribute definition clause is allowed for a task
3941 type.
3943 @node Pragma Thread_Body
3944 @unnumberedsec Pragma Thread_Body
3945 @findex Thread_Body
3946 Syntax:
3948 @smallexample @c ada
3949 pragma Thread_Body (
3950   [Entity =>] local_NAME,
3951  [[Secondary_Stack_Size =>] static_integer_EXPRESSION)];
3952 @end smallexample
3954 @noindent
3955 This pragma specifies that the subprogram whose name is given as the
3956 @code{Entity} argument is a thread body, which will be activated
3957 by being called via its Address from foreign code. The purpose is
3958 to allow execution and registration of the foreign thread within the
3959 Ada run-time system.
3961 See the library unit @code{System.Threads} for details on the expansion of
3962 a thread body subprogram, including the calls made to subprograms
3963 within System.Threads to register the task.  This unit also lists the
3964 targets and runtime systems for which this pragma is supported.
3966 A thread body subprogram may not be called directly from Ada code, and
3967 it is not permitted to apply the Access (or Unrestricted_Access) attributes
3968 to such a subprogram. The only legitimate way of calling such a subprogram
3969 is to pass its Address to foreign code and then make the call from the
3970 foreign code.
3972 A thread body subprogram may have any parameters, and it may be a function
3973 returning a result. The convention of the thread body subprogram may be
3974 set in the usual manner using @code{pragma Convention}.
3976 The secondary stack size parameter, if given, is used to set the size
3977 of secondary stack for the thread. The secondary stack is allocated as
3978 a local variable of the expanded thread body subprogram, and thus is
3979 allocated out of the main thread stack size. If no secondary stack
3980 size parameter is present, the default size (from the declaration in
3981 @code{System.Secondary_Stack} is used.
3983 @node Pragma Time_Slice
3984 @unnumberedsec Pragma Time_Slice
3985 @findex Time_Slice
3986 @noindent
3987 Syntax:
3989 @smallexample @c ada
3990 pragma Time_Slice (static_duration_EXPRESSION);
3991 @end smallexample
3993 @noindent
3994 For implementations of GNAT on operating systems where it is possible
3995 to supply a time slice value, this pragma may be used for this purpose.
3996 It is ignored if it is used in a system that does not allow this control,
3997 or if it appears in other than the main program unit.
3998 @cindex OpenVMS
3999 Note that the effect of this pragma is identical to the effect of the
4000 DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
4002 @node Pragma Title
4003 @unnumberedsec Pragma Title
4004 @findex Title
4005 @noindent
4006 Syntax:
4008 @smallexample @c ada
4009 pragma Title (TITLING_OPTION [, TITLING OPTION]);
4011 TITLING_OPTION ::=
4012   [Title    =>] STRING_LITERAL,
4013 | [Subtitle =>] STRING_LITERAL
4014 @end smallexample
4016 @noindent
4017 Syntax checked but otherwise ignored by GNAT@.  This is a listing control
4018 pragma used in DEC Ada 83 implementations to provide a title and/or
4019 subtitle for the program listing.  The program listing generated by GNAT
4020 does not have titles or subtitles.
4022 Unlike other pragmas, the full flexibility of named notation is allowed
4023 for this pragma, i.e.@: the parameters may be given in any order if named
4024 notation is used, and named and positional notation can be mixed
4025 following the normal rules for procedure calls in Ada.
4027 @node Pragma Unchecked_Union
4028 @unnumberedsec Pragma Unchecked_Union
4029 @cindex Unions in C
4030 @findex Unchecked_Union
4031 @noindent
4032 Syntax:
4034 @smallexample @c ada
4035 pragma Unchecked_Union (first_subtype_local_NAME);
4036 @end smallexample
4038 @noindent
4039 This pragma is used to specify a representation of a record type that is
4040 equivalent to a C union. It was introduced as a GNAT implementation defined
4041 pragma in the GNAT Ada 95 mode. Ada 2005 includes an extended version of this
4042 pragma, making it language defined, and GNAT fully implements this extended
4043 version in all language modes (Ada 83, Ada 95, and Ada 2005). For full
4044 details, consult the Ada 2005 RM, section 8.3.3.
4046 @node Pragma Unimplemented_Unit
4047 @unnumberedsec Pragma Unimplemented_Unit
4048 @findex Unimplemented_Unit
4049 @noindent
4050 Syntax:
4052 @smallexample @c ada
4053 pragma Unimplemented_Unit;
4054 @end smallexample
4056 @noindent
4057 If this pragma occurs in a unit that is processed by the compiler, GNAT
4058 aborts with the message @samp{@var{xxx} not implemented}, where
4059 @var{xxx} is the name of the current compilation unit.  This pragma is
4060 intended to allow the compiler to handle unimplemented library units in
4061 a clean manner.
4063 The abort only happens if code is being generated.  Thus you can use
4064 specs of unimplemented packages in syntax or semantic checking mode.
4066 @node Pragma Universal_Data
4067 @unnumberedsec Pragma Universal_Data
4068 @findex Universal_Data
4069 @noindent
4070 Syntax:
4072 @smallexample @c ada
4073 pragma Universal_Data [(library_unit_Name)];
4074 @end smallexample
4076 @noindent
4077 This pragma is supported only for the AAMP target and is ignored for
4078 other targets. The pragma specifies that all library-level objects
4079 (Counter 0 data) associated with the library unit are to be accessed
4080 and updated using universal addressing (24-bit addresses for AAMP5)
4081 rather than the default of 16-bit Data Environment (DENV) addressing.
4082 Use of this pragma will generally result in less efficient code for
4083 references to global data associated with the library unit, but
4084 allows such data to be located anywhere in memory. This pragma is
4085 a library unit pragma, but can also be used as a configuration pragma
4086 (including use in the @file{gnat.adc} file). The functionality
4087 of this pragma is also available by applying the -univ switch on the
4088 compilations of units where universal addressing of the data is desired.
4090 @node Pragma Unreferenced
4091 @unnumberedsec Pragma Unreferenced
4092 @findex Unreferenced
4093 @cindex Warnings, unreferenced
4094 @noindent
4095 Syntax:
4097 @smallexample @c ada
4098 pragma Unreferenced (local_NAME @{, local_NAME@});
4099 pragma Unreferenced (library_unit_NAME @{, library_unit_NAME@});
4100 @end smallexample
4102 @noindent
4103 This pragma signals that the entities whose names are listed are
4104 deliberately not referenced in the current source unit. This
4105 suppresses warnings about the
4106 entities being unreferenced, and in addition a warning will be
4107 generated if one of these entities is in fact referenced in the
4108 same unit as the pragma (or in the corresponding body, or one
4109 of its subunits).
4111 This is particularly useful for clearly signaling that a particular
4112 parameter is not referenced in some particular subprogram implementation
4113 and that this is deliberate. It can also be useful in the case of
4114 objects declared only for their initialization or finalization side
4115 effects.
4117 If @code{local_NAME} identifies more than one matching homonym in the
4118 current scope, then the entity most recently declared is the one to which
4119 the pragma applies. Note that in the case of accept formals, the pragma
4120 Unreferenced may appear immediately after the keyword @code{do} which
4121 allows the indication of whether or not accept formals are referenced
4122 or not to be given individually for each accept statement.
4124 The left hand side of an assignment does not count as a reference for the
4125 purpose of this pragma. Thus it is fine to assign to an entity for which
4126 pragma Unreferenced is given.
4128 Note that if a warning is desired for all calls to a given subprogram,
4129 regardless of whether they occur in the same unit as the subprogram
4130 declaration, then this pragma should not be used (calls from another
4131 unit would not be flagged); pragma Obsolescent can be used instead
4132 for this purpose, see @xref{Pragma Obsolescent}.
4134 The second form of pragma @code{Unreferenced} is used within a context
4135 clause. In this case the arguments must be unit names of units previously
4136 mentioned in @code{with} clauses (similar to the usage of pragma
4137 @code{Elaborate_All}. The effect is to suppress warnings about unreferenced
4138 units.
4140 @node Pragma Unreserve_All_Interrupts
4141 @unnumberedsec Pragma Unreserve_All_Interrupts
4142 @findex Unreserve_All_Interrupts
4143 @noindent
4144 Syntax:
4146 @smallexample @c ada
4147 pragma Unreserve_All_Interrupts;
4148 @end smallexample
4150 @noindent
4151 Normally certain interrupts are reserved to the implementation.  Any attempt
4152 to attach an interrupt causes Program_Error to be raised, as described in
4153 RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
4154 many systems for a @kbd{Ctrl-C} interrupt.  Normally this interrupt is
4155 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
4156 interrupt execution.
4158 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
4159 a program, then all such interrupts are unreserved.  This allows the
4160 program to handle these interrupts, but disables their standard
4161 functions.  For example, if this pragma is used, then pressing
4162 @kbd{Ctrl-C} will not automatically interrupt execution.  However,
4163 a program can then handle the @code{SIGINT} interrupt as it chooses.
4165 For a full list of the interrupts handled in a specific implementation,
4166 see the source code for the specification of @code{Ada.Interrupts.Names} in
4167 file @file{a-intnam.ads}.  This is a target dependent file that contains the
4168 list of interrupts recognized for a given target.  The documentation in
4169 this file also specifies what interrupts are affected by the use of
4170 the @code{Unreserve_All_Interrupts} pragma.
4172 For a more general facility for controlling what interrupts can be
4173 handled, see pragma @code{Interrupt_State}, which subsumes the functionality
4174 of the @code{Unreserve_All_Interrupts} pragma.
4176 @node Pragma Unsuppress
4177 @unnumberedsec Pragma Unsuppress
4178 @findex Unsuppress
4179 @noindent
4180 Syntax:
4182 @smallexample @c ada
4183 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
4184 @end smallexample
4186 @noindent
4187 This pragma undoes the effect of a previous pragma @code{Suppress}.  If
4188 there is no corresponding pragma @code{Suppress} in effect, it has no
4189 effect.  The range of the effect is the same as for pragma
4190 @code{Suppress}.  The meaning of the arguments is identical to that used
4191 in pragma @code{Suppress}.
4193 One important application is to ensure that checks are on in cases where
4194 code depends on the checks for its correct functioning, so that the code
4195 will compile correctly even if the compiler switches are set to suppress
4196 checks.
4198 @node Pragma Use_VADS_Size
4199 @unnumberedsec Pragma Use_VADS_Size
4200 @cindex @code{Size}, VADS compatibility
4201 @findex Use_VADS_Size
4202 @noindent
4203 Syntax:
4205 @smallexample @c ada
4206 pragma Use_VADS_Size;
4207 @end smallexample
4209 @noindent
4210 This is a configuration pragma.  In a unit to which it applies, any use
4211 of the 'Size attribute is automatically interpreted as a use of the
4212 'VADS_Size attribute.  Note that this may result in incorrect semantic
4213 processing of valid Ada 95 programs.  This is intended to aid in the
4214 handling of legacy code which depends on the interpretation of Size
4215 as implemented in the VADS compiler.  See description of the VADS_Size
4216 attribute for further details.
4218 @node Pragma Validity_Checks
4219 @unnumberedsec Pragma Validity_Checks
4220 @findex Validity_Checks
4221 @noindent
4222 Syntax:
4224 @smallexample @c ada
4225 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
4226 @end smallexample
4228 @noindent
4229 This pragma is used in conjunction with compiler switches to control the
4230 built-in validity checking provided by GNAT@.  The compiler switches, if set
4231 provide an initial setting for the switches, and this pragma may be used
4232 to modify these settings, or the settings may be provided entirely by
4233 the use of the pragma.  This pragma can be used anywhere that a pragma
4234 is legal, including use as a configuration pragma (including use in
4235 the @file{gnat.adc} file).
4237 The form with a string literal specifies which validity options are to be
4238 activated.  The validity checks are first set to include only the default
4239 reference manual settings, and then a string of letters in the string
4240 specifies the exact set of options required.  The form of this string
4241 is exactly as described for the @code{-gnatVx} compiler switch (see the
4242 GNAT users guide for details).  For example the following two methods
4243 can be used to enable validity checking for mode @code{in} and
4244 @code{in out} subprogram parameters:
4246 @itemize @bullet
4247 @item
4248 @smallexample @c ada
4249 pragma Validity_Checks ("im");
4250 @end smallexample
4252 @item
4253 @smallexample
4254 gcc -c -gnatVim @dots{}
4255 @end smallexample
4256 @end itemize
4258 @noindent
4259 The form ALL_CHECKS activates all standard checks (its use is equivalent
4260 to the use of the @code{gnatva} switch.
4262 The forms with @code{Off} and @code{On}
4263 can be used to temporarily disable validity checks
4264 as shown in the following example:
4266 @smallexample @c ada
4267 @iftex
4268 @leftskip=0cm
4269 @end iftex
4270 pragma Validity_Checks ("c"); -- validity checks for copies
4271 pragma Validity_Checks (Off); -- turn off validity checks
4272 A := B;                       -- B will not be validity checked
4273 pragma Validity_Checks (On);  -- turn validity checks back on
4274 A := C;                       -- C will be validity checked
4275 @end smallexample
4277 @node Pragma Volatile
4278 @unnumberedsec Pragma Volatile
4279 @findex Volatile
4280 @noindent
4281 Syntax:
4283 @smallexample @c ada
4284 pragma Volatile (local_NAME);
4285 @end smallexample
4287 @noindent
4288 This pragma is defined by the Ada 95 Reference Manual, and the GNAT
4289 implementation is fully conformant with this definition.  The reason it
4290 is mentioned in this section is that a pragma of the same name was supplied
4291 in some Ada 83 compilers, including DEC Ada 83.  The Ada 95 implementation
4292 of pragma Volatile is upwards compatible with the implementation in
4293 Dec Ada 83.
4295 @node Pragma Warnings
4296 @unnumberedsec Pragma Warnings
4297 @findex Warnings
4298 @noindent
4299 Syntax:
4301 @smallexample @c ada
4302 pragma Warnings (On | Off);
4303 pragma Warnings (On | Off, local_NAME);
4304 pragma Warnings (static_string_EXPRESSION);
4305 pragma Warnings (On | Off, static_string_EXPRESSION);
4306 @end smallexample
4308 @noindent
4309 Normally warnings are enabled, with the output being controlled by
4310 the command line switch.  Warnings (@code{Off}) turns off generation of
4311 warnings until a Warnings (@code{On}) is encountered or the end of the
4312 current unit.  If generation of warnings is turned off using this
4313 pragma, then no warning messages are output, regardless of the
4314 setting of the command line switches.
4316 The form with a single argument may be used as a configuration pragma.
4318 If the @var{local_NAME} parameter is present, warnings are suppressed for
4319 the specified entity.  This suppression is effective from the point where
4320 it occurs till the end of the extended scope of the variable (similar to
4321 the scope of @code{Suppress}).
4323 The form with a single static_string_EXPRESSION argument provides more precise
4324 control over which warnings are active. The string is a list of letters
4325 specifying which warnings are to be activated and which deactivated. The
4326 code for these letters is the same as the string used in the command
4327 line switch controlling warnings. The following is a brief summary. For
4328 full details see the GNAT Users Guide:
4330 @smallexample
4331 a   turn on all optional warnings (except d,h,l)
4332 A   turn off all optional warnings
4333 b   turn on warnings for bad fixed value (not multiple of small)
4334 B   turn off warnings for bad fixed value (not multiple of small)
4335 c   turn on warnings for constant conditional
4336 C   turn off warnings for constant conditional
4337 d   turn on warnings for implicit dereference
4338 D   turn off warnings for implicit dereference
4339 e   treat all warnings as errors
4340 f   turn on warnings for unreferenced formal
4341 F   turn off warnings for unreferenced formal
4342 g   turn on warnings for unrecognized pragma
4343 G   turn off warnings for unrecognized pragma
4344 h   turn on warnings for hiding variable
4345 H   turn off warnings for hiding variable
4346 i   turn on warnings for implementation unit
4347 I   turn off warnings for implementation unit
4348 j   turn on warnings for obsolescent (annex J) feature
4349 J   turn off warnings for obsolescent (annex J) feature
4350 k   turn on warnings on constant variable
4351 K   turn off warnings on constant variable
4352 l   turn on warnings for missing elaboration pragma
4353 L   turn off warnings for missing elaboration pragma
4354 m   turn on warnings for variable assigned but not read
4355 M   turn off warnings for variable assigned but not read
4356 n   normal warning mode (cancels -gnatws/-gnatwe)
4357 o   turn on warnings for address clause overlay
4358 O   turn off warnings for address clause overlay
4359 p   turn on warnings for ineffective pragma Inline
4360 P   turn off warnings for ineffective pragma Inline
4361 r   turn on warnings for redundant construct
4362 R   turn off warnings for redundant construct
4363 s   suppress all warnings
4364 u   turn on warnings for unused entity
4365 U   turn off warnings for unused entity
4366 v   turn on warnings for unassigned variable
4367 V   turn off warnings for unassigned variable
4368 w   turn on warnings for wrong low bound assumption
4369 W   turn off warnings for wrong low bound assumption
4370 x   turn on warnings for export/import
4371 X   turn off warnings for export/import
4372 y   turn on warnings for Ada 2005 incompatibility
4373 Y   turn off warnings for Ada 2005 incompatibility
4374 z   turn on size/align warnings for unchecked conversion
4375 Z   turn off size/align warnings for unchecked conversion
4376 @end smallexample
4378 @noindent
4379 The specified warnings will be in effect until the end of the program
4380 or another pragma Warnings is encountered. The effect of the pragma is
4381 cumulative. Initially the set of warnings is the standard default set
4382 as possibly modified by compiler switches. Then each pragma Warning
4383 modifies this set of warnings as specified. This form of the pragma may
4384 also be used as a configuration pragma.
4386 The fourth form, with an On|Off parameter and a string, is used to
4387 control individual messages, based on their text. The string argument
4388 is a pattern that is used to match against the text of individual
4389 warning messages (not including the initial "warnings: " tag).
4391 The pattern may start with an asterisk, which matches otherwise unmatched
4392 characters at the start of the message, and it may also end with an asterisk
4393 which matches otherwise unmatched characters at the end of the message. For
4394 example, the string "*alignment*" could be used to match any warnings about
4395 alignment problems. Within the string, the sequence "*" can be used to match
4396 any sequence of characters enclosed in quotation marks. No other regular
4397 expression notations are permitted. All characters other than asterisk in
4398 these three specific cases are treated as literal characters in the match.
4400 There are two ways to use this pragma. The OFF form can be used as a
4401 configuration pragma. The effect is to suppress all warnings (if any)
4402 that match the pattern string throughout the compilation.
4404 The second usage is to suppress a warning locally, and in this case, two
4405 pragmas must appear in sequence:
4407 @smallexample @c ada
4408 pragma Warnings (Off, Pattern);
4409 .. code where given warning is to be suppressed
4410 pragma Warnings (On, Pattern);
4411 @end smallexample
4413 @noindent
4414 In this usage, the pattern string must match in the Off and On pragmas,
4415 and at least one matching warning must be suppressed.
4417 @node Pragma Weak_External
4418 @unnumberedsec Pragma Weak_External
4419 @findex Weak_External
4420 @noindent
4421 Syntax:
4423 @smallexample @c ada
4424 pragma Weak_External ([Entity =>] local_NAME);
4425 @end smallexample
4427 @noindent
4428 @var{local_NAME} must refer to an object that is declared at the library
4429 level. This pragma specifies that the given entity should be marked as a
4430 weak symbol for the linker. It is equivalent to @code{__attribute__((weak))}
4431 in GNU C and causes @var{local_NAME} to be emitted as a weak symbol instead
4432 of a regular symbol, that is to say a symbol that does not have to be
4433 resolved by the linker if used in conjunction with a pragma Import.
4435 When a weak symbol is not resolved by the linker, its address is set to
4436 zero. This is useful in writing interfaces to external modules that may
4437 or may not be linked in the final executable, for example depending on
4438 configuration settings.
4440 If a program references at run time an entity to which this pragma has been
4441 applied, and the corresponding symbol was not resolved at link time, then
4442 the execution of the program is erroneous. It is not erroneous to take the
4443 Address of such an entity, for example to guard potential references,
4444 as shown in the example below.
4446 Some file formats do not support weak symbols so not all target machines
4447 support this pragma.
4449 @smallexample @c ada
4450 --  Example of the use of pragma Weak_External
4452 package External_Module is
4453   key : Integer;
4454   pragma Import (C, key);
4455   pragma Weak_External (key);
4456   function Present return boolean;
4457 end External_Module;
4459 with System; use System;
4460 package body External_Module is
4461   function Present return boolean is
4462   begin
4463     return key'Address /= System.Null_Address;
4464   end Present;
4465 end External_Module;
4466 @end smallexample
4468 @node Pragma Wide_Character_Encoding
4469 @unnumberedsec Pragma Wide_Character_Encoding
4470 @findex Wide_Character_Encoding
4471 @noindent
4472 Syntax:
4474 @smallexample @c ada
4475 pragma Wide_Character_Encoding (IDENTIFIER | CHRARACTER_LITERAL);
4476 @end smallexample
4478 @noindent
4479 This pragma specifies the wide character encoding to be used in program
4480 source text appearing subsequently. It is a configuration pragma, but may
4481 also be used at any point that a pragma is allowed, and it is permissible
4482 to have more than one such pragma in a file, allowing multiple encodings
4483 to appear within the same file.
4485 The argument can be an identifier or a character literal. In the identifier
4486 case, it is one of @code{HEX}, @code{UPPER}, @code{SHIFT_JIS},
4487 @code{EUC}, @code{UTF8}, or @code{BRACKETS}. In the character literal
4488 case it is correspondingly one of the characters h,u,s,e,8,b.
4490 Note that when the pragma is used within a file, it affects only the
4491 encoding within that file, and does not affect withed units, specs,
4492 or subunits.
4494 @node Implementation Defined Attributes
4495 @chapter Implementation Defined Attributes
4496 Ada 95 defines (throughout the Ada 95 reference manual,
4497 summarized in annex K),
4498 a set of attributes that provide useful additional functionality in all
4499 areas of the language.  These language defined attributes are implemented
4500 in GNAT and work as described in the Ada 95 Reference Manual.
4502 In addition, Ada 95 allows implementations to define additional
4503 attributes whose meaning is defined by the implementation.  GNAT provides
4504 a number of these implementation-dependent attributes which can be used
4505 to extend and enhance the functionality of the compiler.  This section of
4506 the GNAT reference manual describes these additional attributes.
4508 Note that any program using these attributes may not be portable to
4509 other compilers (although GNAT implements this set of attributes on all
4510 platforms).  Therefore if portability to other compilers is an important
4511 consideration, you should minimize the use of these attributes.
4513 @menu
4514 * Abort_Signal::
4515 * Address_Size::
4516 * Asm_Input::
4517 * Asm_Output::
4518 * AST_Entry::
4519 * Bit::
4520 * Bit_Position::
4521 * Code_Address::
4522 * Default_Bit_Order::
4523 * Elaborated::
4524 * Elab_Body::
4525 * Elab_Spec::
4526 * Emax::
4527 * Enum_Rep::
4528 * Epsilon::
4529 * Fixed_Value::
4530 * Has_Access_Values::
4531 * Has_Discriminants::
4532 * Img::
4533 * Integer_Value::
4534 * Large::
4535 * Machine_Size::
4536 * Mantissa::
4537 * Max_Interrupt_Priority::
4538 * Max_Priority::
4539 * Maximum_Alignment::
4540 * Mechanism_Code::
4541 * Null_Parameter::
4542 * Object_Size::
4543 * Passed_By_Reference::
4544 * Range_Length::
4545 * Safe_Emax::
4546 * Safe_Large::
4547 * Small::
4548 * Storage_Unit::
4549 * Stub_Type::
4550 * Target_Name::
4551 * Tick::
4552 * To_Address::
4553 * Type_Class::
4554 * UET_Address::
4555 * Unconstrained_Array::
4556 * Universal_Literal_String::
4557 * Unrestricted_Access::
4558 * VADS_Size::
4559 * Value_Size::
4560 * Wchar_T_Size::
4561 * Word_Size::
4562 @end menu
4564 @node Abort_Signal
4565 @unnumberedsec Abort_Signal
4566 @findex Abort_Signal
4567 @noindent
4568 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
4569 prefix) provides the entity for the special exception used to signal
4570 task abort or asynchronous transfer of control.  Normally this attribute
4571 should only be used in the tasking runtime (it is highly peculiar, and
4572 completely outside the normal semantics of Ada, for a user program to
4573 intercept the abort exception).
4575 @node Address_Size
4576 @unnumberedsec Address_Size
4577 @cindex Size of @code{Address}
4578 @findex Address_Size
4579 @noindent
4580 @code{Standard'Address_Size} (@code{Standard} is the only allowed
4581 prefix) is a static constant giving the number of bits in an
4582 @code{Address}. It is the same value as System.Address'Size,
4583 but has the advantage of being static, while a direct
4584 reference to System.Address'Size is non-static because Address
4585 is a private type.
4587 @node Asm_Input
4588 @unnumberedsec Asm_Input
4589 @findex Asm_Input
4590 @noindent
4591 The @code{Asm_Input} attribute denotes a function that takes two
4592 parameters.  The first is a string, the second is an expression of the
4593 type designated by the prefix.  The first (string) argument is required
4594 to be a static expression, and is the constraint for the parameter,
4595 (e.g.@: what kind of register is required).  The second argument is the
4596 value to be used as the input argument.  The possible values for the
4597 constant are the same as those used in the RTL, and are dependent on
4598 the configuration file used to built the GCC back end.
4599 @ref{Machine Code Insertions}
4601 @node Asm_Output
4602 @unnumberedsec Asm_Output
4603 @findex Asm_Output
4604 @noindent
4605 The @code{Asm_Output} attribute denotes a function that takes two
4606 parameters.  The first is a string, the second is the name of a variable
4607 of the type designated by the attribute prefix.  The first (string)
4608 argument is required to be a static expression and designates the
4609 constraint for the parameter (e.g.@: what kind of register is
4610 required).  The second argument is the variable to be updated with the
4611 result.  The possible values for constraint are the same as those used in
4612 the RTL, and are dependent on the configuration file used to build the
4613 GCC back end.  If there are no output operands, then this argument may
4614 either be omitted, or explicitly given as @code{No_Output_Operands}.
4615 @ref{Machine Code Insertions}
4617 @node AST_Entry
4618 @unnumberedsec AST_Entry
4619 @cindex OpenVMS
4620 @findex AST_Entry
4621 @noindent
4622 This attribute is implemented only in OpenVMS versions of GNAT@.  Applied to
4623 the name of an entry, it yields a value of the predefined type AST_Handler
4624 (declared in the predefined package System, as extended by the use of
4625 pragma @code{Extend_System (Aux_DEC)}).  This value enables the given entry to
4626 be called when an AST occurs.  For further details, refer to the @cite{DEC Ada
4627 Language Reference Manual}, section 9.12a.
4629 @node Bit
4630 @unnumberedsec Bit
4631 @findex Bit
4632 @code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
4633 offset within the storage unit (byte) that contains the first bit of
4634 storage allocated for the object.  The value of this attribute is of the
4635 type @code{Universal_Integer}, and is always a non-negative number not
4636 exceeding the value of @code{System.Storage_Unit}.
4638 For an object that is a variable or a constant allocated in a register,
4639 the value is zero.  (The use of this attribute does not force the
4640 allocation of a variable to memory).
4642 For an object that is a formal parameter, this attribute applies
4643 to either the matching actual parameter or to a copy of the
4644 matching actual parameter.
4646 For an access object the value is zero.  Note that
4647 @code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
4648 designated object.  Similarly for a record component
4649 @code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
4650 @code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
4651 are subject to index checks.
4653 This attribute is designed to be compatible with the DEC Ada 83 definition
4654 and implementation of the @code{Bit} attribute.
4656 @node Bit_Position
4657 @unnumberedsec Bit_Position
4658 @findex Bit_Position
4659 @noindent
4660 @code{@var{R.C}'Bit}, where @var{R} is a record object and C is one
4661 of the fields of the record type, yields the bit
4662 offset within the record contains the first bit of
4663 storage allocated for the object.  The value of this attribute is of the
4664 type @code{Universal_Integer}.  The value depends only on the field
4665 @var{C} and is independent of the alignment of
4666 the containing record @var{R}.
4668 @node Code_Address
4669 @unnumberedsec Code_Address
4670 @findex Code_Address
4671 @cindex Subprogram address
4672 @cindex Address of subprogram code
4673 @noindent
4674 The @code{'Address}
4675 attribute may be applied to subprograms in Ada 95, but the
4676 intended effect from the Ada 95 reference manual seems to be to provide
4677 an address value which can be used to call the subprogram by means of
4678 an address clause as in the following example:
4680 @smallexample @c ada
4681 procedure K is @dots{}
4683 procedure L;
4684 for L'Address use K'Address;
4685 pragma Import (Ada, L);
4686 @end smallexample
4688 @noindent
4689 A call to @code{L} is then expected to result in a call to @code{K}@.
4690 In Ada 83, where there were no access-to-subprogram values, this was
4691 a common work around for getting the effect of an indirect call.
4692 GNAT implements the above use of @code{Address} and the technique
4693 illustrated by the example code works correctly.
4695 However, for some purposes, it is useful to have the address of the start
4696 of the generated code for the subprogram.  On some architectures, this is
4697 not necessarily the same as the @code{Address} value described above.
4698 For example, the @code{Address} value may reference a subprogram
4699 descriptor rather than the subprogram itself.
4701 The @code{'Code_Address} attribute, which can only be applied to
4702 subprogram entities, always returns the address of the start of the
4703 generated code of the specified subprogram, which may or may not be
4704 the same value as is returned by the corresponding @code{'Address}
4705 attribute.
4707 @node Default_Bit_Order
4708 @unnumberedsec Default_Bit_Order
4709 @cindex Big endian
4710 @cindex Little endian
4711 @findex Default_Bit_Order
4712 @noindent
4713 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
4714 permissible prefix), provides the value @code{System.Default_Bit_Order}
4715 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
4716 @code{Low_Order_First}).  This is used to construct the definition of
4717 @code{Default_Bit_Order} in package @code{System}.
4719 @node Elaborated
4720 @unnumberedsec Elaborated
4721 @findex Elaborated
4722 @noindent
4723 The prefix of the @code{'Elaborated} attribute must be a unit name.  The
4724 value is a Boolean which indicates whether or not the given unit has been
4725 elaborated.  This attribute is primarily intended for internal use by the
4726 generated code for dynamic elaboration checking, but it can also be used
4727 in user programs.  The value will always be True once elaboration of all
4728 units has been completed.  An exception is for units which need no
4729 elaboration, the value is always False for such units.
4731 @node Elab_Body
4732 @unnumberedsec Elab_Body
4733 @findex Elab_Body
4734 @noindent
4735 This attribute can only be applied to a program unit name.  It returns
4736 the entity for the corresponding elaboration procedure for elaborating
4737 the body of the referenced unit.  This is used in the main generated
4738 elaboration procedure by the binder and is not normally used in any
4739 other context.  However, there may be specialized situations in which it
4740 is useful to be able to call this elaboration procedure from Ada code,
4741 e.g.@: if it is necessary to do selective re-elaboration to fix some
4742 error.
4744 @node Elab_Spec
4745 @unnumberedsec Elab_Spec
4746 @findex Elab_Spec
4747 @noindent
4748 This attribute can only be applied to a program unit name.  It returns
4749 the entity for the corresponding elaboration procedure for elaborating
4750 the specification of the referenced unit.  This is used in the main
4751 generated elaboration procedure by the binder and is not normally used
4752 in any other context.  However, there may be specialized situations in
4753 which it is useful to be able to call this elaboration procedure from
4754 Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
4755 some error.
4757 @node Emax
4758 @unnumberedsec Emax
4759 @cindex Ada 83 attributes
4760 @findex Emax
4761 @noindent
4762 The @code{Emax} attribute is provided for compatibility with Ada 83.  See
4763 the Ada 83 reference manual for an exact description of the semantics of
4764 this attribute.
4766 @node Enum_Rep
4767 @unnumberedsec Enum_Rep
4768 @cindex Representation of enums
4769 @findex Enum_Rep
4770 @noindent
4771 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
4772 function with the following spec:
4774 @smallexample @c ada
4775 function @var{S}'Enum_Rep (Arg : @var{S}'Base)
4776   return @i{Universal_Integer};
4777 @end smallexample
4779 @noindent
4780 It is also allowable to apply @code{Enum_Rep} directly to an object of an
4781 enumeration type or to a non-overloaded enumeration
4782 literal.  In this case @code{@var{S}'Enum_Rep} is equivalent to
4783 @code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
4784 enumeration literal or object.
4786 The function returns the representation value for the given enumeration
4787 value.  This will be equal to value of the @code{Pos} attribute in the
4788 absence of an enumeration representation clause.  This is a static
4789 attribute (i.e.@: the result is static if the argument is static).
4791 @code{@var{S}'Enum_Rep} can also be used with integer types and objects,
4792 in which case it simply returns the integer value.  The reason for this
4793 is to allow it to be used for @code{(<>)} discrete formal arguments in
4794 a generic unit that can be instantiated with either enumeration types
4795 or integer types.  Note that if @code{Enum_Rep} is used on a modular
4796 type whose upper bound exceeds the upper bound of the largest signed
4797 integer type, and the argument is a variable, so that the universal
4798 integer calculation is done at run-time, then the call to @code{Enum_Rep}
4799 may raise @code{Constraint_Error}.
4801 @node Epsilon
4802 @unnumberedsec Epsilon
4803 @cindex Ada 83 attributes
4804 @findex Epsilon
4805 @noindent
4806 The @code{Epsilon} attribute is provided for compatibility with Ada 83.  See
4807 the Ada 83 reference manual for an exact description of the semantics of
4808 this attribute.
4810 @node Fixed_Value
4811 @unnumberedsec Fixed_Value
4812 @findex Fixed_Value
4813 @noindent
4814 For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
4815 function with the following specification:
4817 @smallexample @c ada
4818 function @var{S}'Fixed_Value (Arg : @i{Universal_Integer})
4819   return @var{S};
4820 @end smallexample
4822 @noindent
4823 The value returned is the fixed-point value @var{V} such that
4825 @smallexample @c ada
4826 @var{V} = Arg * @var{S}'Small
4827 @end smallexample
4829 @noindent
4830 The effect is thus similar to first converting the argument to the
4831 integer type used to represent @var{S}, and then doing an unchecked
4832 conversion to the fixed-point type.  The difference is
4833 that there are full range checks, to ensure that the result is in range.
4834 This attribute is primarily intended for use in implementation of the
4835 input-output functions for fixed-point values.
4837 @node Has_Access_Values
4838 @unnumberedsec Has_Access_Values
4839 @cindex Access values, testing for
4840 @findex Has_Access_Values
4841 @noindent
4842 The prefix of the @code{Has_Access_Values} attribute is a type.  The result
4843 is a Boolean value which is True if the is an access type, or is a composite
4844 type with a component (at any nesting depth) that is an access type, and is
4845 False otherwise.
4846 The intended use of this attribute is in conjunction with generic
4847 definitions.  If the attribute is applied to a generic private type, it
4848 indicates whether or not the corresponding actual type has access values.
4850 @node Has_Discriminants
4851 @unnumberedsec Has_Discriminants
4852 @cindex Discriminants, testing for
4853 @findex Has_Discriminants
4854 @noindent
4855 The prefix of the @code{Has_Discriminants} attribute is a type.  The result
4856 is a Boolean value which is True if the type has discriminants, and False
4857 otherwise.  The intended use of this attribute is in conjunction with generic
4858 definitions.  If the attribute is applied to a generic private type, it
4859 indicates whether or not the corresponding actual type has discriminants.
4861 @node Img
4862 @unnumberedsec Img
4863 @findex Img
4864 @noindent
4865 The @code{Img} attribute differs from @code{Image} in that it may be
4866 applied to objects as well as types, in which case it gives the
4867 @code{Image} for the subtype of the object.  This is convenient for
4868 debugging:
4870 @smallexample @c ada
4871 Put_Line ("X = " & X'Img);
4872 @end smallexample
4874 @noindent
4875 has the same meaning as the more verbose:
4877 @smallexample @c ada
4878 Put_Line ("X = " & @var{T}'Image (X));
4879 @end smallexample
4881 @noindent
4882 where @var{T} is the (sub)type of the object @code{X}.
4884 @node Integer_Value
4885 @unnumberedsec Integer_Value
4886 @findex Integer_Value
4887 @noindent
4888 For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
4889 function with the following spec:
4891 @smallexample @c ada
4892 function @var{S}'Integer_Value (Arg : @i{Universal_Fixed})
4893   return @var{S};
4894 @end smallexample
4896 @noindent
4897 The value returned is the integer value @var{V}, such that
4899 @smallexample @c ada
4900 Arg = @var{V} * @var{T}'Small
4901 @end smallexample
4903 @noindent
4904 where @var{T} is the type of @code{Arg}.
4905 The effect is thus similar to first doing an unchecked conversion from
4906 the fixed-point type to its corresponding implementation type, and then
4907 converting the result to the target integer type.  The difference is
4908 that there are full range checks, to ensure that the result is in range.
4909 This attribute is primarily intended for use in implementation of the
4910 standard input-output functions for fixed-point values.
4912 @node Large
4913 @unnumberedsec Large
4914 @cindex Ada 83 attributes
4915 @findex Large
4916 @noindent
4917 The @code{Large} attribute is provided for compatibility with Ada 83.  See
4918 the Ada 83 reference manual for an exact description of the semantics of
4919 this attribute.
4921 @node Machine_Size
4922 @unnumberedsec Machine_Size
4923 @findex Machine_Size
4924 @noindent
4925 This attribute is identical to the @code{Object_Size} attribute.  It is
4926 provided for compatibility with the DEC Ada 83 attribute of this name.
4928 @node Mantissa
4929 @unnumberedsec Mantissa
4930 @cindex Ada 83 attributes
4931 @findex Mantissa
4932 @noindent
4933 The @code{Mantissa} attribute is provided for compatibility with Ada 83.  See
4934 the Ada 83 reference manual for an exact description of the semantics of
4935 this attribute.
4937 @node Max_Interrupt_Priority
4938 @unnumberedsec Max_Interrupt_Priority
4939 @cindex Interrupt priority, maximum
4940 @findex Max_Interrupt_Priority
4941 @noindent
4942 @code{Standard'Max_Interrupt_Priority} (@code{Standard} is the only
4943 permissible prefix), provides the same value as
4944 @code{System.Max_Interrupt_Priority}.
4946 @node Max_Priority
4947 @unnumberedsec Max_Priority
4948 @cindex Priority, maximum
4949 @findex Max_Priority
4950 @noindent
4951 @code{Standard'Max_Priority} (@code{Standard} is the only permissible
4952 prefix) provides the same value as @code{System.Max_Priority}.
4954 @node Maximum_Alignment
4955 @unnumberedsec Maximum_Alignment
4956 @cindex Alignment, maximum
4957 @findex Maximum_Alignment
4958 @noindent
4959 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
4960 permissible prefix) provides the maximum useful alignment value for the
4961 target.  This is a static value that can be used to specify the alignment
4962 for an object, guaranteeing that it is properly aligned in all
4963 cases.
4965 @node Mechanism_Code
4966 @unnumberedsec Mechanism_Code
4967 @cindex Return values, passing mechanism
4968 @cindex Parameters, passing mechanism
4969 @findex Mechanism_Code
4970 @noindent
4971 @code{@var{function}'Mechanism_Code} yields an integer code for the
4972 mechanism used for the result of function, and
4973 @code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
4974 used for formal parameter number @var{n} (a static integer value with 1
4975 meaning the first parameter) of @var{subprogram}.  The code returned is:
4977 @table @asis
4978 @item 1
4979 by copy (value)
4980 @item 2
4981 by reference
4982 @item 3
4983 by descriptor (default descriptor class)
4984 @item 4
4985 by descriptor (UBS: unaligned bit string)
4986 @item 5
4987 by descriptor (UBSB: aligned bit string with arbitrary bounds)
4988 @item 6
4989 by descriptor (UBA: unaligned bit array)
4990 @item 7
4991 by descriptor (S: string, also scalar access type parameter)
4992 @item 8
4993 by descriptor (SB: string with arbitrary bounds)
4994 @item 9
4995 by descriptor (A: contiguous array)
4996 @item 10
4997 by descriptor (NCA: non-contiguous array)
4998 @end table
5000 @noindent
5001 Values from 3 through 10 are only relevant to Digital OpenVMS implementations.
5002 @cindex OpenVMS
5004 @node Null_Parameter
5005 @unnumberedsec Null_Parameter
5006 @cindex Zero address, passing
5007 @findex Null_Parameter
5008 @noindent
5009 A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
5010 type or subtype @var{T} allocated at machine address zero.  The attribute
5011 is allowed only as the default expression of a formal parameter, or as
5012 an actual expression of a subprogram call.  In either case, the
5013 subprogram must be imported.
5015 The identity of the object is represented by the address zero in the
5016 argument list, independent of the passing mechanism (explicit or
5017 default).
5019 This capability is needed to specify that a zero address should be
5020 passed for a record or other composite object passed by reference.
5021 There is no way of indicating this without the @code{Null_Parameter}
5022 attribute.
5024 @node Object_Size
5025 @unnumberedsec Object_Size
5026 @cindex Size, used for objects
5027 @findex Object_Size
5028 @noindent
5029 The size of an object is not necessarily the same as the size of the type
5030 of an object.  This is because by default object sizes are increased to be
5031 a multiple of the alignment of the object.  For example,
5032 @code{Natural'Size} is
5033 31, but by default objects of type @code{Natural} will have a size of 32 bits.
5034 Similarly, a record containing an integer and a character:
5036 @smallexample @c ada
5037 type Rec is record
5038    I : Integer;
5039    C : Character;
5040 end record;
5041 @end smallexample
5043 @noindent
5044 will have a size of 40 (that is @code{Rec'Size} will be 40.  The
5045 alignment will be 4, because of the
5046 integer field, and so the default size of record objects for this type
5047 will be 64 (8 bytes).
5049 The @code{@var{type}'Object_Size} attribute
5050 has been added to GNAT to allow the
5051 default object size of a type to be easily determined.  For example,
5052 @code{Natural'Object_Size} is 32, and
5053 @code{Rec'Object_Size} (for the record type in the above example) will be
5054 64.  Note also that, unlike the situation with the
5055 @code{Size} attribute as defined in the Ada RM, the
5056 @code{Object_Size} attribute can be specified individually
5057 for different subtypes.  For example:
5059 @smallexample @c ada
5060 type R is new Integer;
5061 subtype R1 is R range 1 .. 10;
5062 subtype R2 is R range 1 .. 10;
5063 for R2'Object_Size use 8;
5064 @end smallexample
5066 @noindent
5067 In this example, @code{R'Object_Size} and @code{R1'Object_Size} are both
5068 32 since the default object size for a subtype is the same as the object size
5069 for the parent subtype.  This means that objects of type @code{R}
5070 or @code{R1} will
5071 by default be 32 bits (four bytes).  But objects of type
5072 @code{R2} will be only
5073 8 bits (one byte), since @code{R2'Object_Size} has been set to 8.
5075 @node Passed_By_Reference
5076 @unnumberedsec Passed_By_Reference
5077 @cindex Parameters, when passed by reference
5078 @findex Passed_By_Reference
5079 @noindent
5080 @code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
5081 a value of type @code{Boolean} value that is @code{True} if the type is
5082 normally passed by reference and @code{False} if the type is normally
5083 passed by copy in calls.  For scalar types, the result is always @code{False}
5084 and is static.  For non-scalar types, the result is non-static.
5086 @node Range_Length
5087 @unnumberedsec Range_Length
5088 @findex Range_Length
5089 @noindent
5090 @code{@var{type}'Range_Length} for any discrete type @var{type} yields
5091 the number of values represented by the subtype (zero for a null
5092 range).  The result is static for static subtypes.  @code{Range_Length}
5093 applied to the index subtype of a one dimensional array always gives the
5094 same result as @code{Range} applied to the array itself.
5096 @node Safe_Emax
5097 @unnumberedsec Safe_Emax
5098 @cindex Ada 83 attributes
5099 @findex Safe_Emax
5100 @noindent
5101 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83.  See
5102 the Ada 83 reference manual for an exact description of the semantics of
5103 this attribute.
5105 @node Safe_Large
5106 @unnumberedsec Safe_Large
5107 @cindex Ada 83 attributes
5108 @findex Safe_Large
5109 @noindent
5110 The @code{Safe_Large} attribute is provided for compatibility with Ada 83.  See
5111 the Ada 83 reference manual for an exact description of the semantics of
5112 this attribute.
5114 @node Small
5115 @unnumberedsec Small
5116 @cindex Ada 83 attributes
5117 @findex Small
5118 @noindent
5119 The @code{Small} attribute is defined in Ada 95 only for fixed-point types.
5120 GNAT also allows this attribute to be applied to floating-point types
5121 for compatibility with Ada 83.  See
5122 the Ada 83 reference manual for an exact description of the semantics of
5123 this attribute when applied to floating-point types.
5125 @node Storage_Unit
5126 @unnumberedsec Storage_Unit
5127 @findex Storage_Unit
5128 @noindent
5129 @code{Standard'Storage_Unit} (@code{Standard} is the only permissible
5130 prefix) provides the same value as @code{System.Storage_Unit}.
5132 @node Stub_Type
5133 @unnumberedsec Stub_Type
5134 @findex Stub_Type
5135 @noindent
5136 The GNAT implementation of remote access-to-classwide types is
5137 organized as described in AARM section E.4 (20.t): a value of an RACW type
5138 (designating a remote object) is represented as a normal access
5139 value, pointing to a "stub" object which in turn contains the
5140 necessary information to contact the designated remote object. A
5141 call on any dispatching operation of such a stub object does the
5142 remote call, if necessary, using the information in the stub object
5143 to locate the target partition, etc.
5145 For a prefix @code{T} that denotes a remote access-to-classwide type,
5146 @code{T'Stub_Type} denotes the type of the corresponding stub objects.
5148 By construction, the layout of @code{T'Stub_Type} is identical to that of
5149 type @code{RACW_Stub_Type} declared in the internal implementation-defined
5150 unit @code{System.Partition_Interface}. Use of this attribute will create
5151 an implicit dependency on this unit.
5153 @node Target_Name
5154 @unnumberedsec Target_Name
5155 @findex Target_Name
5156 @noindent
5157 @code{Standard'Target_Name} (@code{Standard} is the only permissible
5158 prefix) provides a static string value that identifies the target
5159 for the current compilation. For GCC implementations, this is the
5160 standard gcc target name without the terminating slash (for
5161 example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
5163 @node Tick
5164 @unnumberedsec Tick
5165 @findex Tick
5166 @noindent
5167 @code{Standard'Tick} (@code{Standard} is the only permissible prefix)
5168 provides the same value as @code{System.Tick},
5170 @node To_Address
5171 @unnumberedsec To_Address
5172 @findex To_Address
5173 @noindent
5174 The @code{System'To_Address}
5175 (@code{System} is the only permissible prefix)
5176 denotes a function identical to
5177 @code{System.Storage_Elements.To_Address} except that
5178 it is a static attribute.  This means that if its argument is
5179 a static expression, then the result of the attribute is a
5180 static expression.  The result is that such an expression can be
5181 used in contexts (e.g.@: preelaborable packages) which require a
5182 static expression and where the function call could not be used
5183 (since the function call is always non-static, even if its
5184 argument is static).
5186 @node Type_Class
5187 @unnumberedsec Type_Class
5188 @findex Type_Class
5189 @noindent
5190 @code{@var{type}'Type_Class} for any type or subtype @var{type} yields
5191 the value of the type class for the full type of @var{type}.  If
5192 @var{type} is a generic formal type, the value is the value for the
5193 corresponding actual subtype.  The value of this attribute is of type
5194 @code{System.Aux_DEC.Type_Class}, which has the following definition:
5196 @smallexample @c ada
5197   type Type_Class is
5198     (Type_Class_Enumeration,
5199      Type_Class_Integer,
5200      Type_Class_Fixed_Point,
5201      Type_Class_Floating_Point,
5202      Type_Class_Array,
5203      Type_Class_Record,
5204      Type_Class_Access,
5205      Type_Class_Task,
5206      Type_Class_Address);
5207 @end smallexample
5209 @noindent
5210 Protected types yield the value @code{Type_Class_Task}, which thus
5211 applies to all concurrent types.  This attribute is designed to
5212 be compatible with the DEC Ada 83 attribute of the same name.
5214 @node UET_Address
5215 @unnumberedsec UET_Address
5216 @findex UET_Address
5217 @noindent
5218 The @code{UET_Address} attribute can only be used for a prefix which
5219 denotes a library package.  It yields the address of the unit exception
5220 table when zero cost exception handling is used.  This attribute is
5221 intended only for use within the GNAT implementation.  See the unit
5222 @code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb}
5223 for details on how this attribute is used in the implementation.
5225 @node Unconstrained_Array
5226 @unnumberedsec Unconstrained_Array
5227 @findex Unconstrained_Array
5228 @noindent
5229 The @code{Unconstrained_Array} attribute can be used with a prefix that
5230 denotes any type or subtype. It is a static attribute that yields
5231 @code{True} if the prefix designates an unconstrained array,
5232 and @code{False} otherwise. In a generic instance, the result is
5233 still static, and yields the result of applying this test to the
5234 generic actual.
5236 @node Universal_Literal_String
5237 @unnumberedsec Universal_Literal_String
5238 @cindex Named numbers, representation of
5239 @findex Universal_Literal_String
5240 @noindent
5241 The prefix of @code{Universal_Literal_String} must be a named
5242 number.  The static result is the string consisting of the characters of
5243 the number as defined in the original source.  This allows the user
5244 program to access the actual text of named numbers without intermediate
5245 conversions and without the need to enclose the strings in quotes (which
5246 would preclude their use as numbers).  This is used internally for the
5247 construction of values of the floating-point attributes from the file
5248 @file{ttypef.ads}, but may also be used by user programs.
5250 For example, the following program prints the first 50 digits of pi:
5252 @smallexample @c ada
5253 with Text_IO; use Text_IO;
5254 with Ada.Numerics;
5255 procedure Pi is
5256 begin
5257    Put (Ada.Numerics.Pi'Universal_Literal_String);
5258 end;
5259 @end smallexample
5261 @node Unrestricted_Access
5262 @unnumberedsec Unrestricted_Access
5263 @cindex @code{Access}, unrestricted
5264 @findex Unrestricted_Access
5265 @noindent
5266 The @code{Unrestricted_Access} attribute is similar to @code{Access}
5267 except that all accessibility and aliased view checks are omitted.  This
5268 is a user-beware attribute.  It is similar to
5269 @code{Address}, for which it is a desirable replacement where the value
5270 desired is an access type.  In other words, its effect is identical to
5271 first applying the @code{Address} attribute and then doing an unchecked
5272 conversion to a desired access type.  In GNAT, but not necessarily in
5273 other implementations, the use of static chains for inner level
5274 subprograms means that @code{Unrestricted_Access} applied to a
5275 subprogram yields a value that can be called as long as the subprogram
5276 is in scope (normal Ada 95 accessibility rules restrict this usage).
5278 It is possible to use @code{Unrestricted_Access} for any type, but care
5279 must be exercised if it is used to create pointers to unconstrained
5280 objects. In this case, the resulting pointer has the same scope as the
5281 context of the attribute, and may not be returned to some enclosing
5282 scope. For instance, a function cannot use @code{Unrestricted_Access}
5283 to create a unconstrained pointer and then return that value to the
5284 caller.
5286 @node VADS_Size
5287 @unnumberedsec VADS_Size
5288 @cindex @code{Size}, VADS compatibility
5289 @findex VADS_Size
5290 @noindent
5291 The @code{'VADS_Size} attribute is intended to make it easier to port
5292 legacy code which relies on the semantics of @code{'Size} as implemented
5293 by the VADS Ada 83 compiler.  GNAT makes a best effort at duplicating the
5294 same semantic interpretation.  In particular, @code{'VADS_Size} applied
5295 to a predefined or other primitive type with no Size clause yields the
5296 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
5297 typical machines).  In addition @code{'VADS_Size} applied to an object
5298 gives the result that would be obtained by applying the attribute to
5299 the corresponding type.
5301 @node Value_Size
5302 @unnumberedsec Value_Size
5303 @cindex @code{Size}, setting for not-first subtype
5304 @findex Value_Size
5305 @code{@var{type}'Value_Size} is the number of bits required to represent
5306 a value of the given subtype.  It is the same as @code{@var{type}'Size},
5307 but, unlike @code{Size}, may be set for non-first subtypes.
5309 @node Wchar_T_Size
5310 @unnumberedsec Wchar_T_Size
5311 @findex Wchar_T_Size
5312 @code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
5313 prefix) provides the size in bits of the C @code{wchar_t} type
5314 primarily for constructing the definition of this type in
5315 package @code{Interfaces.C}.
5317 @node Word_Size
5318 @unnumberedsec Word_Size
5319 @findex Word_Size
5320 @code{Standard'Word_Size} (@code{Standard} is the only permissible
5321 prefix) provides the value @code{System.Word_Size}.
5323 @c ------------------------
5324 @node Implementation Advice
5325 @chapter Implementation Advice
5326 @noindent
5327 The main text of the Ada 95 Reference Manual describes the required
5328 behavior of all Ada 95 compilers, and the GNAT compiler conforms to
5329 these requirements.
5331 In addition, there are sections throughout the Ada 95
5332 reference manual headed
5333 by the phrase ``implementation advice''.  These sections are not normative,
5334 i.e.@: they do not specify requirements that all compilers must
5335 follow.  Rather they provide advice on generally desirable behavior.  You
5336 may wonder why they are not requirements.  The most typical answer is
5337 that they describe behavior that seems generally desirable, but cannot
5338 be provided on all systems, or which may be undesirable on some systems.
5340 As far as practical, GNAT follows the implementation advice sections in
5341 the Ada 95 Reference Manual.  This chapter contains a table giving the
5342 reference manual section number, paragraph number and several keywords
5343 for each advice.  Each entry consists of the text of the advice followed
5344 by the GNAT interpretation of this advice.  Most often, this simply says
5345 ``followed'', which means that GNAT follows the advice.  However, in a
5346 number of cases, GNAT deliberately deviates from this advice, in which
5347 case the text describes what GNAT does and why.
5349 @cindex Error detection
5350 @unnumberedsec 1.1.3(20): Error Detection
5351 @sp 1
5352 @cartouche
5353 If an implementation detects the use of an unsupported Specialized Needs
5354 Annex feature at run time, it should raise @code{Program_Error} if
5355 feasible.
5356 @end cartouche
5357 Not relevant.  All specialized needs annex features are either supported,
5358 or diagnosed at compile time.
5360 @cindex Child Units
5361 @unnumberedsec 1.1.3(31): Child Units
5362 @sp 1
5363 @cartouche
5364 If an implementation wishes to provide implementation-defined
5365 extensions to the functionality of a language-defined library unit, it
5366 should normally do so by adding children to the library unit.
5367 @end cartouche
5368 Followed.
5370 @cindex Bounded errors
5371 @unnumberedsec 1.1.5(12): Bounded Errors
5372 @sp 1
5373 @cartouche
5374 If an implementation detects a bounded error or erroneous
5375 execution, it should raise @code{Program_Error}.
5376 @end cartouche
5377 Followed in all cases in which the implementation detects a bounded
5378 error or erroneous execution.  Not all such situations are detected at
5379 runtime.
5381 @cindex Pragmas
5382 @unnumberedsec 2.8(16): Pragmas
5383 @sp 1
5384 @cartouche
5385 Normally, implementation-defined pragmas should have no semantic effect
5386 for error-free programs; that is, if the implementation-defined pragmas
5387 are removed from a working program, the program should still be legal,
5388 and should still have the same semantics.
5389 @end cartouche
5390 The following implementation defined pragmas are exceptions to this
5391 rule:
5393 @table @code
5394 @item Abort_Defer
5395 Affects semantics
5396 @item Ada_83
5397 Affects legality
5398 @item Assert
5399 Affects semantics
5400 @item CPP_Class
5401 Affects semantics
5402 @item CPP_Constructor
5403 Affects semantics
5404 @item CPP_Virtual
5405 Affects semantics
5406 @item CPP_Vtable
5407 Affects semantics
5408 @item Debug
5409 Affects semantics
5410 @item Interface_Name
5411 Affects semantics
5412 @item Machine_Attribute
5413 Affects semantics
5414 @item Unimplemented_Unit
5415 Affects legality
5416 @item Unchecked_Union
5417 Affects semantics
5418 @end table
5420 @noindent
5421 In each of the above cases, it is essential to the purpose of the pragma
5422 that this advice not be followed.  For details see the separate section
5423 on implementation defined pragmas.
5425 @unnumberedsec 2.8(17-19): Pragmas
5426 @sp 1
5427 @cartouche
5428 Normally, an implementation should not define pragmas that can
5429 make an illegal program legal, except as follows:
5430 @end cartouche
5431 @sp 1
5432 @cartouche
5433 A pragma used to complete a declaration, such as a pragma @code{Import};
5434 @end cartouche
5435 @sp 1
5436 @cartouche
5437 A pragma used to configure the environment by adding, removing, or
5438 replacing @code{library_items}.
5439 @end cartouche
5440 See response to paragraph 16 of this same section.
5442 @cindex Character Sets
5443 @cindex Alternative Character Sets
5444 @unnumberedsec 3.5.2(5): Alternative Character Sets
5445 @sp 1
5446 @cartouche
5447 If an implementation supports a mode with alternative interpretations
5448 for @code{Character} and @code{Wide_Character}, the set of graphic
5449 characters of @code{Character} should nevertheless remain a proper
5450 subset of the set of graphic characters of @code{Wide_Character}.  Any
5451 character set ``localizations'' should be reflected in the results of
5452 the subprograms defined in the language-defined package
5453 @code{Characters.Handling} (see A.3) available in such a mode.  In a mode with
5454 an alternative interpretation of @code{Character}, the implementation should
5455 also support a corresponding change in what is a legal
5456 @code{identifier_letter}.
5457 @end cartouche
5458 Not all wide character modes follow this advice, in particular the JIS
5459 and IEC modes reflect standard usage in Japan, and in these encoding,
5460 the upper half of the Latin-1 set is not part of the wide-character
5461 subset, since the most significant bit is used for wide character
5462 encoding.  However, this only applies to the external forms.  Internally
5463 there is no such restriction.
5465 @cindex Integer types
5466 @unnumberedsec 3.5.4(28): Integer Types
5468 @sp 1
5469 @cartouche
5470 An implementation should support @code{Long_Integer} in addition to
5471 @code{Integer} if the target machine supports 32-bit (or longer)
5472 arithmetic.  No other named integer subtypes are recommended for package
5473 @code{Standard}.  Instead, appropriate named integer subtypes should be
5474 provided in the library package @code{Interfaces} (see B.2).
5475 @end cartouche
5476 @code{Long_Integer} is supported.  Other standard integer types are supported
5477 so this advice is not fully followed.  These types
5478 are supported for convenient interface to C, and so that all hardware
5479 types of the machine are easily available.
5480 @unnumberedsec 3.5.4(29): Integer Types
5482 @sp 1
5483 @cartouche
5484 An implementation for a two's complement machine should support
5485 modular types with a binary modulus up to @code{System.Max_Int*2+2}.  An
5486 implementation should support a non-binary modules up to @code{Integer'Last}.
5487 @end cartouche
5488 Followed.
5490 @cindex Enumeration values
5491 @unnumberedsec 3.5.5(8): Enumeration Values
5492 @sp 1
5493 @cartouche
5494 For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
5495 subtype, if the value of the operand does not correspond to the internal
5496 code for any enumeration literal of its type (perhaps due to an
5497 un-initialized variable), then the implementation should raise
5498 @code{Program_Error}.  This is particularly important for enumeration
5499 types with noncontiguous internal codes specified by an
5500 enumeration_representation_clause.
5501 @end cartouche
5502 Followed.
5504 @cindex Float types
5505 @unnumberedsec 3.5.7(17): Float Types
5506 @sp 1
5507 @cartouche
5508 An implementation should support @code{Long_Float} in addition to
5509 @code{Float} if the target machine supports 11 or more digits of
5510 precision.  No other named floating point subtypes are recommended for
5511 package @code{Standard}.  Instead, appropriate named floating point subtypes
5512 should be provided in the library package @code{Interfaces} (see B.2).
5513 @end cartouche
5514 @code{Short_Float} and @code{Long_Long_Float} are also provided.  The
5515 former provides improved compatibility with other implementations
5516 supporting this type.  The latter corresponds to the highest precision
5517 floating-point type supported by the hardware.  On most machines, this
5518 will be the same as @code{Long_Float}, but on some machines, it will
5519 correspond to the IEEE extended form.  The notable case is all ia32
5520 (x86) implementations, where @code{Long_Long_Float} corresponds to
5521 the 80-bit extended precision format supported in hardware on this
5522 processor.  Note that the 128-bit format on SPARC is not supported,
5523 since this is a software rather than a hardware format.
5525 @cindex Multidimensional arrays
5526 @cindex Arrays, multidimensional
5527 @unnumberedsec 3.6.2(11): Multidimensional Arrays
5528 @sp 1
5529 @cartouche
5530 An implementation should normally represent multidimensional arrays in
5531 row-major order, consistent with the notation used for multidimensional
5532 array aggregates (see 4.3.3).  However, if a pragma @code{Convention}
5533 (@code{Fortran}, @dots{}) applies to a multidimensional array type, then
5534 column-major order should be used instead (see B.5, ``Interfacing with
5535 Fortran'').
5536 @end cartouche
5537 Followed.
5539 @findex Duration'Small
5540 @unnumberedsec 9.6(30-31): Duration'Small
5541 @sp 1
5542 @cartouche
5543 Whenever possible in an implementation, the value of @code{Duration'Small}
5544 should be no greater than 100 microseconds.
5545 @end cartouche
5546 Followed.  (@code{Duration'Small} = 10**(@minus{}9)).
5548 @sp 1
5549 @cartouche
5550 The time base for @code{delay_relative_statements} should be monotonic;
5551 it need not be the same time base as used for @code{Calendar.Clock}.
5552 @end cartouche
5553 Followed.
5555 @unnumberedsec 10.2.1(12): Consistent Representation
5556 @sp 1
5557 @cartouche
5558 In an implementation, a type declared in a pre-elaborated package should
5559 have the same representation in every elaboration of a given version of
5560 the package, whether the elaborations occur in distinct executions of
5561 the same program, or in executions of distinct programs or partitions
5562 that include the given version.
5563 @end cartouche
5564 Followed, except in the case of tagged types.  Tagged types involve
5565 implicit pointers to a local copy of a dispatch table, and these pointers
5566 have representations which thus depend on a particular elaboration of the
5567 package.  It is not easy to see how it would be possible to follow this
5568 advice without severely impacting efficiency of execution.
5570 @cindex Exception information
5571 @unnumberedsec 11.4.1(19): Exception Information
5572 @sp 1
5573 @cartouche
5574 @code{Exception_Message} by default and @code{Exception_Information}
5575 should produce information useful for
5576 debugging.  @code{Exception_Message} should be short, about one
5577 line.  @code{Exception_Information} can be long.  @code{Exception_Message}
5578 should not include the
5579 @code{Exception_Name}.  @code{Exception_Information} should include both
5580 the @code{Exception_Name} and the @code{Exception_Message}.
5581 @end cartouche
5582 Followed.  For each exception that doesn't have a specified
5583 @code{Exception_Message}, the compiler generates one containing the location
5584 of the raise statement.  This location has the form ``file:line'', where
5585 file is the short file name (without path information) and line is the line
5586 number in the file.  Note that in the case of the Zero Cost Exception
5587 mechanism, these messages become redundant with the Exception_Information that
5588 contains a full backtrace of the calling sequence, so they are disabled.
5589 To disable explicitly the generation of the source location message, use the
5590 Pragma @code{Discard_Names}.
5592 @cindex Suppression of checks
5593 @cindex Checks, suppression of
5594 @unnumberedsec 11.5(28): Suppression of Checks
5595 @sp 1
5596 @cartouche
5597 The implementation should minimize the code executed for checks that
5598 have been suppressed.
5599 @end cartouche
5600 Followed.
5602 @cindex Representation clauses
5603 @unnumberedsec 13.1 (21-24): Representation Clauses
5604 @sp 1
5605 @cartouche
5606 The recommended level of support for all representation items is
5607 qualified as follows:
5608 @end cartouche
5609 @sp 1
5610 @cartouche
5611 An implementation need not support representation items containing
5612 non-static expressions, except that an implementation should support a
5613 representation item for a given entity if each non-static expression in
5614 the representation item is a name that statically denotes a constant
5615 declared before the entity.
5616 @end cartouche
5617 Followed.  In fact, GNAT goes beyond the recommended level of support
5618 by allowing nonstatic expressions in some representation clauses even
5619 without the need to declare constants initialized with the values of
5620 such expressions.
5621 For example:
5623 @smallexample @c ada
5624   X : Integer;
5625   Y : Float;
5626   for Y'Address use X'Address;>>
5627 @end smallexample
5630 @sp 1
5631 @cartouche
5632 An implementation need not support a specification for the @code{Size}
5633 for a given composite subtype, nor the size or storage place for an
5634 object (including a component) of a given composite subtype, unless the
5635 constraints on the subtype and its composite subcomponents (if any) are
5636 all static constraints.
5637 @end cartouche
5638 Followed.  Size Clauses are not permitted on non-static components, as
5639 described above.
5641 @sp 1
5642 @cartouche
5643 An aliased component, or a component whose type is by-reference, should
5644 always be allocated at an addressable location.
5645 @end cartouche
5646 Followed.
5648 @cindex Packed types
5649 @unnumberedsec 13.2(6-8): Packed Types
5650 @sp 1
5651 @cartouche
5652 If a type is packed, then the implementation should try to minimize
5653 storage allocated to objects of the type, possibly at the expense of
5654 speed of accessing components, subject to reasonable complexity in
5655 addressing calculations.
5656 @end cartouche
5657 @sp 1
5658 @cartouche
5659 The recommended level of support pragma @code{Pack} is:
5661 For a packed record type, the components should be packed as tightly as
5662 possible subject to the Sizes of the component subtypes, and subject to
5663 any @code{record_representation_clause} that applies to the type; the
5664 implementation may, but need not, reorder components or cross aligned
5665 word boundaries to improve the packing.  A component whose @code{Size} is
5666 greater than the word size may be allocated an integral number of words.
5667 @end cartouche
5668 Followed.  Tight packing of arrays is supported for all component sizes
5669 up to 64-bits. If the array component size is 1 (that is to say, if
5670 the component is a boolean type or an enumeration type with two values)
5671 then values of the type are implicitly initialized to zero. This
5672 happens both for objects of the packed type, and for objects that have a
5673 subcomponent of the packed type.
5675 @sp 1
5676 @cartouche
5677 An implementation should support Address clauses for imported
5678 subprograms.
5679 @end cartouche
5680 Followed.
5681 @cindex @code{Address} clauses
5682 @unnumberedsec 13.3(14-19): Address Clauses
5684 @sp 1
5685 @cartouche
5686 For an array @var{X}, @code{@var{X}'Address} should point at the first
5687 component of the array, and not at the array bounds.
5688 @end cartouche
5689 Followed.
5691 @sp 1
5692 @cartouche
5693 The recommended level of support for the @code{Address} attribute is:
5695 @code{@var{X}'Address} should produce a useful result if @var{X} is an
5696 object that is aliased or of a by-reference type, or is an entity whose
5697 @code{Address} has been specified.
5698 @end cartouche
5699 Followed.  A valid address will be produced even if none of those
5700 conditions have been met.  If necessary, the object is forced into
5701 memory to ensure the address is valid.
5703 @sp 1
5704 @cartouche
5705 An implementation should support @code{Address} clauses for imported
5706 subprograms.
5707 @end cartouche
5708 Followed.
5710 @sp 1
5711 @cartouche
5712 Objects (including subcomponents) that are aliased or of a by-reference
5713 type should be allocated on storage element boundaries.
5714 @end cartouche
5715 Followed.
5717 @sp 1
5718 @cartouche
5719 If the @code{Address} of an object is specified, or it is imported or exported,
5720 then the implementation should not perform optimizations based on
5721 assumptions of no aliases.
5722 @end cartouche
5723 Followed.
5725 @cindex @code{Alignment} clauses
5726 @unnumberedsec 13.3(29-35): Alignment Clauses
5727 @sp 1
5728 @cartouche
5729 The recommended level of support for the @code{Alignment} attribute for
5730 subtypes is:
5732 An implementation should support specified Alignments that are factors
5733 and multiples of the number of storage elements per word, subject to the
5734 following:
5735 @end cartouche
5736 Followed.
5738 @sp 1
5739 @cartouche
5740 An implementation need not support specified @code{Alignment}s for
5741 combinations of @code{Size}s and @code{Alignment}s that cannot be easily
5742 loaded and stored by available machine instructions.
5743 @end cartouche
5744 Followed.
5746 @sp 1
5747 @cartouche
5748 An implementation need not support specified @code{Alignment}s that are
5749 greater than the maximum @code{Alignment} the implementation ever returns by
5750 default.
5751 @end cartouche
5752 Followed.
5754 @sp 1
5755 @cartouche
5756 The recommended level of support for the @code{Alignment} attribute for
5757 objects is:
5759 Same as above, for subtypes, but in addition:
5760 @end cartouche
5761 Followed.
5763 @sp 1
5764 @cartouche
5765 For stand-alone library-level objects of statically constrained
5766 subtypes, the implementation should support all @code{Alignment}s
5767 supported by the target linker.  For example, page alignment is likely to
5768 be supported for such objects, but not for subtypes.
5769 @end cartouche
5770 Followed.
5772 @cindex @code{Size} clauses
5773 @unnumberedsec 13.3(42-43): Size Clauses
5774 @sp 1
5775 @cartouche
5776 The recommended level of support for the @code{Size} attribute of
5777 objects is:
5779 A @code{Size} clause should be supported for an object if the specified
5780 @code{Size} is at least as large as its subtype's @code{Size}, and
5781 corresponds to a size in storage elements that is a multiple of the
5782 object's @code{Alignment} (if the @code{Alignment} is nonzero).
5783 @end cartouche
5784 Followed.
5786 @unnumberedsec 13.3(50-56): Size Clauses
5787 @sp 1
5788 @cartouche
5789 If the @code{Size} of a subtype is specified, and allows for efficient
5790 independent addressability (see 9.10) on the target architecture, then
5791 the @code{Size} of the following objects of the subtype should equal the
5792 @code{Size} of the subtype:
5794 Aliased objects (including components).
5795 @end cartouche
5796 Followed.
5798 @sp 1
5799 @cartouche
5800 @code{Size} clause on a composite subtype should not affect the
5801 internal layout of components.
5802 @end cartouche
5803 Followed.
5805 @sp 1
5806 @cartouche
5807 The recommended level of support for the @code{Size} attribute of subtypes is:
5808 @end cartouche
5809 @sp 1
5810 @cartouche
5811 The @code{Size} (if not specified) of a static discrete or fixed point
5812 subtype should be the number of bits needed to represent each value
5813 belonging to the subtype using an unbiased representation, leaving space
5814 for a sign bit only if the subtype contains negative values.  If such a
5815 subtype is a first subtype, then an implementation should support a
5816 specified @code{Size} for it that reflects this representation.
5817 @end cartouche
5818 Followed.
5820 @sp 1
5821 @cartouche
5822 For a subtype implemented with levels of indirection, the @code{Size}
5823 should include the size of the pointers, but not the size of what they
5824 point at.
5825 @end cartouche
5826 Followed.
5828 @cindex @code{Component_Size} clauses
5829 @unnumberedsec 13.3(71-73): Component Size Clauses
5830 @sp 1
5831 @cartouche
5832 The recommended level of support for the @code{Component_Size}
5833 attribute is:
5834 @end cartouche
5835 @sp 1
5836 @cartouche
5837 An implementation need not support specified @code{Component_Sizes} that are
5838 less than the @code{Size} of the component subtype.
5839 @end cartouche
5840 Followed.
5842 @sp 1
5843 @cartouche
5844 An implementation should support specified @code{Component_Size}s that
5845 are factors and multiples of the word size.  For such
5846 @code{Component_Size}s, the array should contain no gaps between
5847 components.  For other @code{Component_Size}s (if supported), the array
5848 should contain no gaps between components when packing is also
5849 specified; the implementation should forbid this combination in cases
5850 where it cannot support a no-gaps representation.
5851 @end cartouche
5852 Followed.
5854 @cindex Enumeration representation clauses
5855 @cindex Representation clauses, enumeration
5856 @unnumberedsec 13.4(9-10): Enumeration Representation Clauses
5857 @sp 1
5858 @cartouche
5859 The recommended level of support for enumeration representation clauses
5862 An implementation need not support enumeration representation clauses
5863 for boolean types, but should at minimum support the internal codes in
5864 the range @code{System.Min_Int.System.Max_Int}.
5865 @end cartouche
5866 Followed.
5868 @cindex Record representation clauses
5869 @cindex Representation clauses, records
5870 @unnumberedsec 13.5.1(17-22): Record Representation Clauses
5871 @sp 1
5872 @cartouche
5873 The recommended level of support for
5874 @*@code{record_representation_clauses} is:
5876 An implementation should support storage places that can be extracted
5877 with a load, mask, shift sequence of machine code, and set with a load,
5878 shift, mask, store sequence, given the available machine instructions
5879 and run-time model.
5880 @end cartouche
5881 Followed.
5883 @sp 1
5884 @cartouche
5885 A storage place should be supported if its size is equal to the
5886 @code{Size} of the component subtype, and it starts and ends on a
5887 boundary that obeys the @code{Alignment} of the component subtype.
5888 @end cartouche
5889 Followed.
5891 @sp 1
5892 @cartouche
5893 If the default bit ordering applies to the declaration of a given type,
5894 then for a component whose subtype's @code{Size} is less than the word
5895 size, any storage place that does not cross an aligned word boundary
5896 should be supported.
5897 @end cartouche
5898 Followed.
5900 @sp 1
5901 @cartouche
5902 An implementation may reserve a storage place for the tag field of a
5903 tagged type, and disallow other components from overlapping that place.
5904 @end cartouche
5905 Followed.  The storage place for the tag field is the beginning of the tagged
5906 record, and its size is Address'Size.  GNAT will reject an explicit component
5907 clause for the tag field.
5909 @sp 1
5910 @cartouche
5911 An implementation need not support a @code{component_clause} for a
5912 component of an extension part if the storage place is not after the
5913 storage places of all components of the parent type, whether or not
5914 those storage places had been specified.
5915 @end cartouche
5916 Followed.  The above advice on record representation clauses is followed,
5917 and all mentioned features are implemented.
5919 @cindex Storage place attributes
5920 @unnumberedsec 13.5.2(5): Storage Place Attributes
5921 @sp 1
5922 @cartouche
5923 If a component is represented using some form of pointer (such as an
5924 offset) to the actual data of the component, and this data is contiguous
5925 with the rest of the object, then the storage place attributes should
5926 reflect the place of the actual data, not the pointer.  If a component is
5927 allocated discontinuously from the rest of the object, then a warning
5928 should be generated upon reference to one of its storage place
5929 attributes.
5930 @end cartouche
5931 Followed.  There are no such components in GNAT@.
5933 @cindex Bit ordering
5934 @unnumberedsec 13.5.3(7-8): Bit Ordering
5935 @sp 1
5936 @cartouche
5937 The recommended level of support for the non-default bit ordering is:
5938 @end cartouche
5939 @sp 1
5940 @cartouche
5941 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
5942 should support the non-default bit ordering in addition to the default
5943 bit ordering.
5944 @end cartouche
5945 Followed.  Word size does not equal storage size in this implementation.
5946 Thus non-default bit ordering is not supported.
5948 @cindex @code{Address}, as private type
5949 @unnumberedsec 13.7(37): Address as Private
5950 @sp 1
5951 @cartouche
5952 @code{Address} should be of a private type.
5953 @end cartouche
5954 Followed.
5956 @cindex Operations, on @code{Address}
5957 @cindex @code{Address}, operations of
5958 @unnumberedsec 13.7.1(16): Address Operations
5959 @sp 1
5960 @cartouche
5961 Operations in @code{System} and its children should reflect the target
5962 environment semantics as closely as is reasonable.  For example, on most
5963 machines, it makes sense for address arithmetic to ``wrap around''.
5964 Operations that do not make sense should raise @code{Program_Error}.
5965 @end cartouche
5966 Followed.  Address arithmetic is modular arithmetic that wraps around.  No
5967 operation raises @code{Program_Error}, since all operations make sense.
5969 @cindex Unchecked conversion
5970 @unnumberedsec 13.9(14-17): Unchecked Conversion
5971 @sp 1
5972 @cartouche
5973 The @code{Size} of an array object should not include its bounds; hence,
5974 the bounds should not be part of the converted data.
5975 @end cartouche
5976 Followed.
5978 @sp 1
5979 @cartouche
5980 The implementation should not generate unnecessary run-time checks to
5981 ensure that the representation of @var{S} is a representation of the
5982 target type.  It should take advantage of the permission to return by
5983 reference when possible.  Restrictions on unchecked conversions should be
5984 avoided unless required by the target environment.
5985 @end cartouche
5986 Followed.  There are no restrictions on unchecked conversion.  A warning is
5987 generated if the source and target types do not have the same size since
5988 the semantics in this case may be target dependent.
5990 @sp 1
5991 @cartouche
5992 The recommended level of support for unchecked conversions is:
5993 @end cartouche
5994 @sp 1
5995 @cartouche
5996 Unchecked conversions should be supported and should be reversible in
5997 the cases where this clause defines the result.  To enable meaningful use
5998 of unchecked conversion, a contiguous representation should be used for
5999 elementary subtypes, for statically constrained array subtypes whose
6000 component subtype is one of the subtypes described in this paragraph,
6001 and for record subtypes without discriminants whose component subtypes
6002 are described in this paragraph.
6003 @end cartouche
6004 Followed.
6006 @cindex Heap usage, implicit
6007 @unnumberedsec 13.11(23-25): Implicit Heap Usage
6008 @sp 1
6009 @cartouche
6010 An implementation should document any cases in which it dynamically
6011 allocates heap storage for a purpose other than the evaluation of an
6012 allocator.
6013 @end cartouche
6014 Followed, the only other points at which heap storage is dynamically
6015 allocated are as follows:
6017 @itemize @bullet
6018 @item
6019 At initial elaboration time, to allocate dynamically sized global
6020 objects.
6022 @item
6023 To allocate space for a task when a task is created.
6025 @item
6026 To extend the secondary stack dynamically when needed.  The secondary
6027 stack is used for returning variable length results.
6028 @end itemize
6030 @sp 1
6031 @cartouche
6032 A default (implementation-provided) storage pool for an
6033 access-to-constant type should not have overhead to support deallocation of
6034 individual objects.
6035 @end cartouche
6036 Followed.
6038 @sp 1
6039 @cartouche
6040 A storage pool for an anonymous access type should be created at the
6041 point of an allocator for the type, and be reclaimed when the designated
6042 object becomes inaccessible.
6043 @end cartouche
6044 Followed.
6046 @cindex Unchecked deallocation
6047 @unnumberedsec 13.11.2(17): Unchecked De-allocation
6048 @sp 1
6049 @cartouche
6050 For a standard storage pool, @code{Free} should actually reclaim the
6051 storage.
6052 @end cartouche
6053 Followed.
6055 @cindex Stream oriented attributes
6056 @unnumberedsec 13.13.2(17): Stream Oriented Attributes
6057 @sp 1
6058 @cartouche
6059 If a stream element is the same size as a storage element, then the
6060 normal in-memory representation should be used by @code{Read} and
6061 @code{Write} for scalar objects.  Otherwise, @code{Read} and @code{Write}
6062 should use the smallest number of stream elements needed to represent
6063 all values in the base range of the scalar type.
6064 @end cartouche
6066 Followed.  By default, GNAT uses the interpretation suggested by AI-195,
6067 which specifies using the size of the first subtype.
6068 However, such an implementation is based on direct binary
6069 representations and is therefore target- and endianness-dependent.
6070 To address this issue, GNAT also supplies an alternate implementation
6071 of the stream attributes @code{Read} and @code{Write},
6072 which uses the target-independent XDR standard representation
6073 for scalar types.
6074 @cindex XDR representation
6075 @cindex @code{Read} attribute
6076 @cindex @code{Write} attribute
6077 @cindex Stream oriented attributes
6078 The XDR implementation is provided as an alternative body of the
6079 @code{System.Stream_Attributes} package, in the file
6080 @file{s-strxdr.adb} in the GNAT library.
6081 There is no @file{s-strxdr.ads} file.
6082 In order to install the XDR implementation, do the following:
6083 @enumerate
6084 @item Replace the default implementation of the
6085 @code{System.Stream_Attributes} package with the XDR implementation.
6086 For example on a Unix platform issue the commands:
6087 @smallexample
6088 $ mv s-stratt.adb s-strold.adb
6089 $ mv s-strxdr.adb s-stratt.adb
6090 @end smallexample
6092 @item
6093 Rebuild the GNAT run-time library as documented in the
6094 @cite{GNAT User's Guide}
6095 @end enumerate
6097 @unnumberedsec A.1(52): Names of Predefined Numeric Types
6098 @sp 1
6099 @cartouche
6100 If an implementation provides additional named predefined integer types,
6101 then the names should end with @samp{Integer} as in
6102 @samp{Long_Integer}.  If an implementation provides additional named
6103 predefined floating point types, then the names should end with
6104 @samp{Float} as in @samp{Long_Float}.
6105 @end cartouche
6106 Followed.
6108 @findex Ada.Characters.Handling
6109 @unnumberedsec A.3.2(49): @code{Ada.Characters.Handling}
6110 @sp 1
6111 @cartouche
6112 If an implementation provides a localized definition of @code{Character}
6113 or @code{Wide_Character}, then the effects of the subprograms in
6114 @code{Characters.Handling} should reflect the localizations.  See also
6115 3.5.2.
6116 @end cartouche
6117 Followed.  GNAT provides no such localized definitions.
6119 @cindex Bounded-length strings
6120 @unnumberedsec A.4.4(106): Bounded-Length String Handling
6121 @sp 1
6122 @cartouche
6123 Bounded string objects should not be implemented by implicit pointers
6124 and dynamic allocation.
6125 @end cartouche
6126 Followed.  No implicit pointers or dynamic allocation are used.
6128 @cindex Random number generation
6129 @unnumberedsec A.5.2(46-47): Random Number Generation
6130 @sp 1
6131 @cartouche
6132 Any storage associated with an object of type @code{Generator} should be
6133 reclaimed on exit from the scope of the object.
6134 @end cartouche
6135 Followed.
6137 @sp 1
6138 @cartouche
6139 If the generator period is sufficiently long in relation to the number
6140 of distinct initiator values, then each possible value of
6141 @code{Initiator} passed to @code{Reset} should initiate a sequence of
6142 random numbers that does not, in a practical sense, overlap the sequence
6143 initiated by any other value.  If this is not possible, then the mapping
6144 between initiator values and generator states should be a rapidly
6145 varying function of the initiator value.
6146 @end cartouche
6147 Followed.  The generator period is sufficiently long for the first
6148 condition here to hold true.
6150 @findex Get_Immediate
6151 @unnumberedsec A.10.7(23): @code{Get_Immediate}
6152 @sp 1
6153 @cartouche
6154 The @code{Get_Immediate} procedures should be implemented with
6155 unbuffered input.  For a device such as a keyboard, input should be
6156 @dfn{available} if a key has already been typed, whereas for a disk
6157 file, input should always be available except at end of file.  For a file
6158 associated with a keyboard-like device, any line-editing features of the
6159 underlying operating system should be disabled during the execution of
6160 @code{Get_Immediate}.
6161 @end cartouche
6162 Followed on all targets except VxWorks. For VxWorks, there is no way to
6163 provide this functionality that does not result in the input buffer being
6164 flushed before the @code{Get_Immediate} call. A special unit
6165 @code{Interfaces.Vxworks.IO} is provided that contains routines to enable
6166 this functionality.
6168 @findex Export
6169 @unnumberedsec B.1(39-41): Pragma @code{Export}
6170 @sp 1
6171 @cartouche
6172 If an implementation supports pragma @code{Export} to a given language,
6173 then it should also allow the main subprogram to be written in that
6174 language.  It should support some mechanism for invoking the elaboration
6175 of the Ada library units included in the system, and for invoking the
6176 finalization of the environment task.  On typical systems, the
6177 recommended mechanism is to provide two subprograms whose link names are
6178 @code{adainit} and @code{adafinal}.  @code{adainit} should contain the
6179 elaboration code for library units.  @code{adafinal} should contain the
6180 finalization code.  These subprograms should have no effect the second
6181 and subsequent time they are called.
6182 @end cartouche
6183 Followed.
6185 @sp 1
6186 @cartouche
6187 Automatic elaboration of pre-elaborated packages should be
6188 provided when pragma @code{Export} is supported.
6189 @end cartouche
6190 Followed when the main program is in Ada.  If the main program is in a
6191 foreign language, then
6192 @code{adainit} must be called to elaborate pre-elaborated
6193 packages.
6195 @sp 1
6196 @cartouche
6197 For each supported convention @var{L} other than @code{Intrinsic}, an
6198 implementation should support @code{Import} and @code{Export} pragmas
6199 for objects of @var{L}-compatible types and for subprograms, and pragma
6200 @code{Convention} for @var{L}-eligible types and for subprograms,
6201 presuming the other language has corresponding features.  Pragma
6202 @code{Convention} need not be supported for scalar types.
6203 @end cartouche
6204 Followed.
6206 @cindex Package @code{Interfaces}
6207 @findex Interfaces
6208 @unnumberedsec B.2(12-13): Package @code{Interfaces}
6209 @sp 1
6210 @cartouche
6211 For each implementation-defined convention identifier, there should be a
6212 child package of package Interfaces with the corresponding name.  This
6213 package should contain any declarations that would be useful for
6214 interfacing to the language (implementation) represented by the
6215 convention.  Any declarations useful for interfacing to any language on
6216 the given hardware architecture should be provided directly in
6217 @code{Interfaces}.
6218 @end cartouche
6219 Followed.  An additional package not defined
6220 in the Ada 95 Reference Manual is @code{Interfaces.CPP}, used
6221 for interfacing to C++.
6223 @sp 1
6224 @cartouche
6225 An implementation supporting an interface to C, COBOL, or Fortran should
6226 provide the corresponding package or packages described in the following
6227 clauses.
6228 @end cartouche
6229 Followed.  GNAT provides all the packages described in this section.
6231 @cindex C, interfacing with
6232 @unnumberedsec B.3(63-71): Interfacing with C
6233 @sp 1
6234 @cartouche
6235 An implementation should support the following interface correspondences
6236 between Ada and C@.
6237 @end cartouche
6238 Followed.
6240 @sp 1
6241 @cartouche
6242 An Ada procedure corresponds to a void-returning C function.
6243 @end cartouche
6244 Followed.
6246 @sp 1
6247 @cartouche
6248 An Ada function corresponds to a non-void C function.
6249 @end cartouche
6250 Followed.
6252 @sp 1
6253 @cartouche
6254 An Ada @code{in} scalar parameter is passed as a scalar argument to a C
6255 function.
6256 @end cartouche
6257 Followed.
6259 @sp 1
6260 @cartouche
6261 An Ada @code{in} parameter of an access-to-object type with designated
6262 type @var{T} is passed as a @code{@var{t}*} argument to a C function,
6263 where @var{t} is the C type corresponding to the Ada type @var{T}.
6264 @end cartouche
6265 Followed.
6267 @sp 1
6268 @cartouche
6269 An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
6270 parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
6271 argument to a C function, where @var{t} is the C type corresponding to
6272 the Ada type @var{T}.  In the case of an elementary @code{out} or
6273 @code{in out} parameter, a pointer to a temporary copy is used to
6274 preserve by-copy semantics.
6275 @end cartouche
6276 Followed.
6278 @sp 1
6279 @cartouche
6280 An Ada parameter of a record type @var{T}, of any mode, is passed as a
6281 @code{@var{t}*} argument to a C function, where @var{t} is the C
6282 structure corresponding to the Ada type @var{T}.
6283 @end cartouche
6284 Followed.  This convention may be overridden by the use of the C_Pass_By_Copy
6285 pragma, or Convention, or by explicitly specifying the mechanism for a given
6286 call using an extended import or export pragma.
6288 @sp 1
6289 @cartouche
6290 An Ada parameter of an array type with component type @var{T}, of any
6291 mode, is passed as a @code{@var{t}*} argument to a C function, where
6292 @var{t} is the C type corresponding to the Ada type @var{T}.
6293 @end cartouche
6294 Followed.
6296 @sp 1
6297 @cartouche
6298 An Ada parameter of an access-to-subprogram type is passed as a pointer
6299 to a C function whose prototype corresponds to the designated
6300 subprogram's specification.
6301 @end cartouche
6302 Followed.
6304 @cindex COBOL, interfacing with
6305 @unnumberedsec B.4(95-98): Interfacing with COBOL
6306 @sp 1
6307 @cartouche
6308 An Ada implementation should support the following interface
6309 correspondences between Ada and COBOL@.
6310 @end cartouche
6311 Followed.
6313 @sp 1
6314 @cartouche
6315 An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of
6316 the COBOL type corresponding to @var{T}.
6317 @end cartouche
6318 Followed.
6320 @sp 1
6321 @cartouche
6322 An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of
6323 the corresponding COBOL type.
6324 @end cartouche
6325 Followed.
6327 @sp 1
6328 @cartouche
6329 Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the
6330 COBOL type corresponding to the Ada parameter type; for scalars, a local
6331 copy is used if necessary to ensure by-copy semantics.
6332 @end cartouche
6333 Followed.
6335 @cindex Fortran, interfacing with
6336 @unnumberedsec B.5(22-26): Interfacing with Fortran
6337 @sp 1
6338 @cartouche
6339 An Ada implementation should support the following interface
6340 correspondences between Ada and Fortran:
6341 @end cartouche
6342 Followed.
6344 @sp 1
6345 @cartouche
6346 An Ada procedure corresponds to a Fortran subroutine.
6347 @end cartouche
6348 Followed.
6350 @sp 1
6351 @cartouche
6352 An Ada function corresponds to a Fortran function.
6353 @end cartouche
6354 Followed.
6356 @sp 1
6357 @cartouche
6358 An Ada parameter of an elementary, array, or record type @var{T} is
6359 passed as a @var{T} argument to a Fortran procedure, where @var{T} is
6360 the Fortran type corresponding to the Ada type @var{T}, and where the
6361 INTENT attribute of the corresponding dummy argument matches the Ada
6362 formal parameter mode; the Fortran implementation's parameter passing
6363 conventions are used.  For elementary types, a local copy is used if
6364 necessary to ensure by-copy semantics.
6365 @end cartouche
6366 Followed.
6368 @sp 1
6369 @cartouche
6370 An Ada parameter of an access-to-subprogram type is passed as a
6371 reference to a Fortran procedure whose interface corresponds to the
6372 designated subprogram's specification.
6373 @end cartouche
6374 Followed.
6376 @cindex Machine operations
6377 @unnumberedsec C.1(3-5): Access to Machine Operations
6378 @sp 1
6379 @cartouche
6380 The machine code or intrinsic support should allow access to all
6381 operations normally available to assembly language programmers for the
6382 target environment, including privileged instructions, if any.
6383 @end cartouche
6384 Followed.
6386 @sp 1
6387 @cartouche
6388 The interfacing pragmas (see Annex B) should support interface to
6389 assembler; the default assembler should be associated with the
6390 convention identifier @code{Assembler}.
6391 @end cartouche
6392 Followed.
6394 @sp 1
6395 @cartouche
6396 If an entity is exported to assembly language, then the implementation
6397 should allocate it at an addressable location, and should ensure that it
6398 is retained by the linking process, even if not otherwise referenced
6399 from the Ada code.  The implementation should assume that any call to a
6400 machine code or assembler subprogram is allowed to read or update every
6401 object that is specified as exported.
6402 @end cartouche
6403 Followed.
6405 @unnumberedsec C.1(10-16): Access to Machine Operations
6406 @sp 1
6407 @cartouche
6408 The implementation should ensure that little or no overhead is
6409 associated with calling intrinsic and machine-code subprograms.
6410 @end cartouche
6411 Followed for both intrinsics and machine-code subprograms.
6413 @sp 1
6414 @cartouche
6415 It is recommended that intrinsic subprograms be provided for convenient
6416 access to any machine operations that provide special capabilities or
6417 efficiency and that are not otherwise available through the language
6418 constructs.
6419 @end cartouche
6420 Followed.  A full set of machine operation intrinsic subprograms is provided.
6422 @sp 1
6423 @cartouche
6424 Atomic read-modify-write operations---e.g.@:, test and set, compare and
6425 swap, decrement and test, enqueue/dequeue.
6426 @end cartouche
6427 Followed on any target supporting such operations.
6429 @sp 1
6430 @cartouche
6431 Standard numeric functions---e.g.@:, sin, log.
6432 @end cartouche
6433 Followed on any target supporting such operations.
6435 @sp 1
6436 @cartouche
6437 String manipulation operations---e.g.@:, translate and test.
6438 @end cartouche
6439 Followed on any target supporting such operations.
6441 @sp 1
6442 @cartouche
6443 Vector operations---e.g.@:, compare vector against thresholds.
6444 @end cartouche
6445 Followed on any target supporting such operations.
6447 @sp 1
6448 @cartouche
6449 Direct operations on I/O ports.
6450 @end cartouche
6451 Followed on any target supporting such operations.
6453 @cindex Interrupt support
6454 @unnumberedsec C.3(28): Interrupt Support
6455 @sp 1
6456 @cartouche
6457 If the @code{Ceiling_Locking} policy is not in effect, the
6458 implementation should provide means for the application to specify which
6459 interrupts are to be blocked during protected actions, if the underlying
6460 system allows for a finer-grain control of interrupt blocking.
6461 @end cartouche
6462 Followed.  The underlying system does not allow for finer-grain control
6463 of interrupt blocking.
6465 @cindex Protected procedure handlers
6466 @unnumberedsec C.3.1(20-21): Protected Procedure Handlers
6467 @sp 1
6468 @cartouche
6469 Whenever possible, the implementation should allow interrupt handlers to
6470 be called directly by the hardware.
6471 @end cartouche
6472 @c SGI info:
6473 @ignore
6474 This is never possible under IRIX, so this is followed by default.
6475 @end ignore
6476 Followed on any target where the underlying operating system permits
6477 such direct calls.
6479 @sp 1
6480 @cartouche
6481 Whenever practical, violations of any
6482 implementation-defined restrictions should be detected before run time.
6483 @end cartouche
6484 Followed.  Compile time warnings are given when possible.
6486 @cindex Package @code{Interrupts}
6487 @findex Interrupts
6488 @unnumberedsec C.3.2(25): Package @code{Interrupts}
6490 @sp 1
6491 @cartouche
6492 If implementation-defined forms of interrupt handler procedures are
6493 supported, such as protected procedures with parameters, then for each
6494 such form of a handler, a type analogous to @code{Parameterless_Handler}
6495 should be specified in a child package of @code{Interrupts}, with the
6496 same operations as in the predefined package Interrupts.
6497 @end cartouche
6498 Followed.
6500 @cindex Pre-elaboration requirements
6501 @unnumberedsec C.4(14): Pre-elaboration Requirements
6502 @sp 1
6503 @cartouche
6504 It is recommended that pre-elaborated packages be implemented in such a
6505 way that there should be little or no code executed at run time for the
6506 elaboration of entities not already covered by the Implementation
6507 Requirements.
6508 @end cartouche
6509 Followed.  Executable code is generated in some cases, e.g.@: loops
6510 to initialize large arrays.
6512 @unnumberedsec C.5(8): Pragma @code{Discard_Names}
6514 @sp 1
6515 @cartouche
6516 If the pragma applies to an entity, then the implementation should
6517 reduce the amount of storage used for storing names associated with that
6518 entity.
6519 @end cartouche
6520 Followed.
6522 @cindex Package @code{Task_Attributes}
6523 @findex Task_Attributes
6524 @unnumberedsec C.7.2(30): The Package Task_Attributes
6525 @sp 1
6526 @cartouche
6527 Some implementations are targeted to domains in which memory use at run
6528 time must be completely deterministic.  For such implementations, it is
6529 recommended that the storage for task attributes will be pre-allocated
6530 statically and not from the heap.  This can be accomplished by either
6531 placing restrictions on the number and the size of the task's
6532 attributes, or by using the pre-allocated storage for the first @var{N}
6533 attribute objects, and the heap for the others.  In the latter case,
6534 @var{N} should be documented.
6535 @end cartouche
6536 Not followed.  This implementation is not targeted to such a domain.
6538 @cindex Locking Policies
6539 @unnumberedsec D.3(17): Locking Policies
6541 @sp 1
6542 @cartouche
6543 The implementation should use names that end with @samp{_Locking} for
6544 locking policies defined by the implementation.
6545 @end cartouche
6546 Followed.  A single implementation-defined locking policy is defined,
6547 whose name (@code{Inheritance_Locking}) follows this suggestion.
6549 @cindex Entry queuing policies
6550 @unnumberedsec D.4(16): Entry Queuing Policies
6551 @sp 1
6552 @cartouche
6553 Names that end with @samp{_Queuing} should be used
6554 for all implementation-defined queuing policies.
6555 @end cartouche
6556 Followed.  No such implementation-defined queuing policies exist.
6558 @cindex Preemptive abort
6559 @unnumberedsec D.6(9-10): Preemptive Abort
6560 @sp 1
6561 @cartouche
6562 Even though the @code{abort_statement} is included in the list of
6563 potentially blocking operations (see 9.5.1), it is recommended that this
6564 statement be implemented in a way that never requires the task executing
6565 the @code{abort_statement} to block.
6566 @end cartouche
6567 Followed.
6569 @sp 1
6570 @cartouche
6571 On a multi-processor, the delay associated with aborting a task on
6572 another processor should be bounded; the implementation should use
6573 periodic polling, if necessary, to achieve this.
6574 @end cartouche
6575 Followed.
6577 @cindex Tasking restrictions
6578 @unnumberedsec D.7(21): Tasking Restrictions
6579 @sp 1
6580 @cartouche
6581 When feasible, the implementation should take advantage of the specified
6582 restrictions to produce a more efficient implementation.
6583 @end cartouche
6584 GNAT currently takes advantage of these restrictions by providing an optimized
6585 run time when the Ravenscar profile and the GNAT restricted run time set
6586 of restrictions are specified.  See pragma @code{Profile (Ravenscar)} and
6587 pragma @code{Profile (Restricted)} for more details.
6589 @cindex Time, monotonic
6590 @unnumberedsec D.8(47-49): Monotonic Time
6591 @sp 1
6592 @cartouche
6593 When appropriate, implementations should provide configuration
6594 mechanisms to change the value of @code{Tick}.
6595 @end cartouche
6596 Such configuration mechanisms are not appropriate to this implementation
6597 and are thus not supported.
6599 @sp 1
6600 @cartouche
6601 It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
6602 be implemented as transformations of the same time base.
6603 @end cartouche
6604 Followed.
6606 @sp 1
6607 @cartouche
6608 It is recommended that the @dfn{best} time base which exists in
6609 the underlying system be available to the application through
6610 @code{Clock}.  @dfn{Best} may mean highest accuracy or largest range.
6611 @end cartouche
6612 Followed.
6614 @cindex Partition communication subsystem
6615 @cindex PCS
6616 @unnumberedsec E.5(28-29): Partition Communication Subsystem
6617 @sp 1
6618 @cartouche
6619 Whenever possible, the PCS on the called partition should allow for
6620 multiple tasks to call the RPC-receiver with different messages and
6621 should allow them to block until the corresponding subprogram body
6622 returns.
6623 @end cartouche
6624 Followed by GLADE, a separately supplied PCS that can be used with
6625 GNAT.
6627 @sp 1
6628 @cartouche
6629 The @code{Write} operation on a stream of type @code{Params_Stream_Type}
6630 should raise @code{Storage_Error} if it runs out of space trying to
6631 write the @code{Item} into the stream.
6632 @end cartouche
6633 Followed by GLADE, a separately supplied PCS that can be used with
6634 GNAT@.
6636 @cindex COBOL support
6637 @unnumberedsec F(7): COBOL Support
6638 @sp 1
6639 @cartouche
6640 If COBOL (respectively, C) is widely supported in the target
6641 environment, implementations supporting the Information Systems Annex
6642 should provide the child package @code{Interfaces.COBOL} (respectively,
6643 @code{Interfaces.C}) specified in Annex B and should support a
6644 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
6645 pragmas (see Annex B), thus allowing Ada programs to interface with
6646 programs written in that language.
6647 @end cartouche
6648 Followed.
6650 @cindex Decimal radix support
6651 @unnumberedsec F.1(2): Decimal Radix Support
6652 @sp 1
6653 @cartouche
6654 Packed decimal should be used as the internal representation for objects
6655 of subtype @var{S} when @var{S}'Machine_Radix = 10.
6656 @end cartouche
6657 Not followed.  GNAT ignores @var{S}'Machine_Radix and always uses binary
6658 representations.
6660 @cindex Numerics
6661 @unnumberedsec G: Numerics
6662 @sp 2
6663 @cartouche
6664 If Fortran (respectively, C) is widely supported in the target
6665 environment, implementations supporting the Numerics Annex
6666 should provide the child package @code{Interfaces.Fortran} (respectively,
6667 @code{Interfaces.C}) specified in Annex B and should support a
6668 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
6669 pragmas (see Annex B), thus allowing Ada programs to interface with
6670 programs written in that language.
6671 @end cartouche
6672 Followed.
6674 @cindex Complex types
6675 @unnumberedsec G.1.1(56-58): Complex Types
6676 @sp 2
6677 @cartouche
6678 Because the usual mathematical meaning of multiplication of a complex
6679 operand and a real operand is that of the scaling of both components of
6680 the former by the latter, an implementation should not perform this
6681 operation by first promoting the real operand to complex type and then
6682 performing a full complex multiplication.  In systems that, in the
6683 future, support an Ada binding to IEC 559:1989, the latter technique
6684 will not generate the required result when one of the components of the
6685 complex operand is infinite.  (Explicit multiplication of the infinite
6686 component by the zero component obtained during promotion yields a NaN
6687 that propagates into the final result.) Analogous advice applies in the
6688 case of multiplication of a complex operand and a pure-imaginary
6689 operand, and in the case of division of a complex operand by a real or
6690 pure-imaginary operand.
6691 @end cartouche
6692 Not followed.
6694 @sp 1
6695 @cartouche
6696 Similarly, because the usual mathematical meaning of addition of a
6697 complex operand and a real operand is that the imaginary operand remains
6698 unchanged, an implementation should not perform this operation by first
6699 promoting the real operand to complex type and then performing a full
6700 complex addition.  In implementations in which the @code{Signed_Zeros}
6701 attribute of the component type is @code{True} (and which therefore
6702 conform to IEC 559:1989 in regard to the handling of the sign of zero in
6703 predefined arithmetic operations), the latter technique will not
6704 generate the required result when the imaginary component of the complex
6705 operand is a negatively signed zero.  (Explicit addition of the negative
6706 zero to the zero obtained during promotion yields a positive zero.)
6707 Analogous advice applies in the case of addition of a complex operand
6708 and a pure-imaginary operand, and in the case of subtraction of a
6709 complex operand and a real or pure-imaginary operand.
6710 @end cartouche
6711 Not followed.
6713 @sp 1
6714 @cartouche
6715 Implementations in which @code{Real'Signed_Zeros} is @code{True} should
6716 attempt to provide a rational treatment of the signs of zero results and
6717 result components.  As one example, the result of the @code{Argument}
6718 function should have the sign of the imaginary component of the
6719 parameter @code{X} when the point represented by that parameter lies on
6720 the positive real axis; as another, the sign of the imaginary component
6721 of the @code{Compose_From_Polar} function should be the same as
6722 (respectively, the opposite of) that of the @code{Argument} parameter when that
6723 parameter has a value of zero and the @code{Modulus} parameter has a
6724 nonnegative (respectively, negative) value.
6725 @end cartouche
6726 Followed.
6728 @cindex Complex elementary functions
6729 @unnumberedsec G.1.2(49): Complex Elementary Functions
6730 @sp 1
6731 @cartouche
6732 Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
6733 @code{True} should attempt to provide a rational treatment of the signs
6734 of zero results and result components.  For example, many of the complex
6735 elementary functions have components that are odd functions of one of
6736 the parameter components; in these cases, the result component should
6737 have the sign of the parameter component at the origin.  Other complex
6738 elementary functions have zero components whose sign is opposite that of
6739 a parameter component at the origin, or is always positive or always
6740 negative.
6741 @end cartouche
6742 Followed.
6744 @cindex Accuracy requirements
6745 @unnumberedsec G.2.4(19): Accuracy Requirements
6746 @sp 1
6747 @cartouche
6748 The versions of the forward trigonometric functions without a
6749 @code{Cycle} parameter should not be implemented by calling the
6750 corresponding version with a @code{Cycle} parameter of
6751 @code{2.0*Numerics.Pi}, since this will not provide the required
6752 accuracy in some portions of the domain.  For the same reason, the
6753 version of @code{Log} without a @code{Base} parameter should not be
6754 implemented by calling the corresponding version with a @code{Base}
6755 parameter of @code{Numerics.e}.
6756 @end cartouche
6757 Followed.
6759 @cindex Complex arithmetic accuracy
6760 @cindex Accuracy, complex arithmetic
6761 @unnumberedsec G.2.6(15): Complex Arithmetic Accuracy
6763 @sp 1
6764 @cartouche
6765 The version of the @code{Compose_From_Polar} function without a
6766 @code{Cycle} parameter should not be implemented by calling the
6767 corresponding version with a @code{Cycle} parameter of
6768 @code{2.0*Numerics.Pi}, since this will not provide the required
6769 accuracy in some portions of the domain.
6770 @end cartouche
6771 Followed.
6773 @c -----------------------------------------
6774 @node Implementation Defined Characteristics
6775 @chapter Implementation Defined Characteristics
6777 @noindent
6778 In addition to the implementation dependent pragmas and attributes, and
6779 the implementation advice, there are a number of other features of Ada
6780 95 that are potentially implementation dependent.  These are mentioned
6781 throughout the Ada 95 Reference Manual, and are summarized in annex M@.
6783 A requirement for conforming Ada compilers is that they provide
6784 documentation describing how the implementation deals with each of these
6785 issues.  In this chapter, you will find each point in annex M listed
6786 followed by a description in italic font of how GNAT
6787 @c SGI info:
6788 @ignore
6789 in the ProDev Ada
6790 implementation on IRIX 5.3 operating system or greater
6791 @end ignore
6792 handles the implementation dependence.
6794 You can use this chapter as a guide to minimizing implementation
6795 dependent features in your programs if portability to other compilers
6796 and other operating systems is an important consideration.  The numbers
6797 in each section below correspond to the paragraph number in the Ada 95
6798 Reference Manual.
6800 @sp 1
6801 @cartouche
6802 @noindent
6803 @strong{2}.  Whether or not each recommendation given in Implementation
6804 Advice is followed.  See 1.1.2(37).
6805 @end cartouche
6806 @noindent
6807 @xref{Implementation Advice}.
6809 @sp 1
6810 @cartouche
6811 @noindent
6812 @strong{3}.  Capacity limitations of the implementation.  See 1.1.3(3).
6813 @end cartouche
6814 @noindent
6815 The complexity of programs that can be processed is limited only by the
6816 total amount of available virtual memory, and disk space for the
6817 generated object files.
6819 @sp 1
6820 @cartouche
6821 @noindent
6822 @strong{4}.  Variations from the standard that are impractical to avoid
6823 given the implementation's execution environment.  See 1.1.3(6).
6824 @end cartouche
6825 @noindent
6826 There are no variations from the standard.
6828 @sp 1
6829 @cartouche
6830 @noindent
6831 @strong{5}.  Which @code{code_statement}s cause external
6832 interactions.  See 1.1.3(10).
6833 @end cartouche
6834 @noindent
6835 Any @code{code_statement} can potentially cause external interactions.
6837 @sp 1
6838 @cartouche
6839 @noindent
6840 @strong{6}.  The coded representation for the text of an Ada
6841 program.  See 2.1(4).
6842 @end cartouche
6843 @noindent
6844 See separate section on source representation.
6846 @sp 1
6847 @cartouche
6848 @noindent
6849 @strong{7}.  The control functions allowed in comments.  See 2.1(14).
6850 @end cartouche
6851 @noindent
6852 See separate section on source representation.
6854 @sp 1
6855 @cartouche
6856 @noindent
6857 @strong{8}.  The representation for an end of line.  See 2.2(2).
6858 @end cartouche
6859 @noindent
6860 See separate section on source representation.
6862 @sp 1
6863 @cartouche
6864 @noindent
6865 @strong{9}.  Maximum supported line length and lexical element
6866 length.  See 2.2(15).
6867 @end cartouche
6868 @noindent
6869 The maximum line length is 255 characters an the maximum length of a
6870 lexical element is also 255 characters.
6872 @sp 1
6873 @cartouche
6874 @noindent
6875 @strong{10}.  Implementation defined pragmas.  See 2.8(14).
6876 @end cartouche
6877 @noindent
6879 @xref{Implementation Defined Pragmas}.
6881 @sp 1
6882 @cartouche
6883 @noindent
6884 @strong{11}.  Effect of pragma @code{Optimize}.  See 2.8(27).
6885 @end cartouche
6886 @noindent
6887 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
6888 parameter, checks that the optimization flag is set, and aborts if it is
6889 not.
6891 @sp 1
6892 @cartouche
6893 @noindent
6894 @strong{12}.  The sequence of characters of the value returned by
6895 @code{@var{S}'Image} when some of the graphic characters of
6896 @code{@var{S}'Wide_Image} are not defined in @code{Character}.  See
6897 3.5(37).
6898 @end cartouche
6899 @noindent
6900 The sequence of characters is as defined by the wide character encoding
6901 method used for the source.  See section on source representation for
6902 further details.
6904 @sp 1
6905 @cartouche
6906 @noindent
6907 @strong{13}.  The predefined integer types declared in
6908 @code{Standard}.  See 3.5.4(25).
6909 @end cartouche
6910 @noindent
6911 @table @code
6912 @item Short_Short_Integer
6913 8 bit signed
6914 @item Short_Integer
6915 (Short) 16 bit signed
6916 @item Integer
6917 32 bit signed
6918 @item Long_Integer
6919 64 bit signed (Alpha OpenVMS only)
6920 32 bit signed (all other targets)
6921 @item Long_Long_Integer
6922 64 bit signed
6923 @end table
6925 @sp 1
6926 @cartouche
6927 @noindent
6928 @strong{14}.  Any nonstandard integer types and the operators defined
6929 for them.  See 3.5.4(26).
6930 @end cartouche
6931 @noindent
6932 There are no nonstandard integer types.
6934 @sp 1
6935 @cartouche
6936 @noindent
6937 @strong{15}.  Any nonstandard real types and the operators defined for
6938 them.  See 3.5.6(8).
6939 @end cartouche
6940 @noindent
6941 There are no nonstandard real types.
6943 @sp 1
6944 @cartouche
6945 @noindent
6946 @strong{16}.  What combinations of requested decimal precision and range
6947 are supported for floating point types.  See 3.5.7(7).
6948 @end cartouche
6949 @noindent
6950 The precision and range is as defined by the IEEE standard.
6952 @sp 1
6953 @cartouche
6954 @noindent
6955 @strong{17}.  The predefined floating point types declared in
6956 @code{Standard}.  See 3.5.7(16).
6957 @end cartouche
6958 @noindent
6959 @table @code
6960 @item Short_Float
6961 32 bit IEEE short
6962 @item Float
6963 (Short) 32 bit IEEE short
6964 @item Long_Float
6965 64 bit IEEE long
6966 @item Long_Long_Float
6967 64 bit IEEE long (80 bit IEEE long on x86 processors)
6968 @end table
6970 @sp 1
6971 @cartouche
6972 @noindent
6973 @strong{18}.  The small of an ordinary fixed point type.  See 3.5.9(8).
6974 @end cartouche
6975 @noindent
6976 @code{Fine_Delta} is 2**(@minus{}63)
6978 @sp 1
6979 @cartouche
6980 @noindent
6981 @strong{19}.  What combinations of small, range, and digits are
6982 supported for fixed point types.  See 3.5.9(10).
6983 @end cartouche
6984 @noindent
6985 Any combinations are permitted that do not result in a small less than
6986 @code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
6987 If the mantissa is larger than 53 bits on machines where Long_Long_Float
6988 is 64 bits (true of all architectures except ia32), then the output from
6989 Text_IO is accurate to only 53 bits, rather than the full mantissa.  This
6990 is because floating-point conversions are used to convert fixed point.
6992 @sp 1
6993 @cartouche
6994 @noindent
6995 @strong{20}.  The result of @code{Tags.Expanded_Name} for types declared
6996 within an unnamed @code{block_statement}.  See 3.9(10).
6997 @end cartouche
6998 @noindent
6999 Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
7000 decimal integer are allocated.
7002 @sp 1
7003 @cartouche
7004 @noindent
7005 @strong{21}.  Implementation-defined attributes.  See 4.1.4(12).
7006 @end cartouche
7007 @noindent
7008 @xref{Implementation Defined Attributes}.
7010 @sp 1
7011 @cartouche
7012 @noindent
7013 @strong{22}.  Any implementation-defined time types.  See 9.6(6).
7014 @end cartouche
7015 @noindent
7016 There are no implementation-defined time types.
7018 @sp 1
7019 @cartouche
7020 @noindent
7021 @strong{23}.  The time base associated with relative delays.
7022 @end cartouche
7023 @noindent
7024 See 9.6(20).  The time base used is that provided by the C library
7025 function @code{gettimeofday}.
7027 @sp 1
7028 @cartouche
7029 @noindent
7030 @strong{24}.  The time base of the type @code{Calendar.Time}.  See
7031 9.6(23).
7032 @end cartouche
7033 @noindent
7034 The time base used is that provided by the C library function
7035 @code{gettimeofday}.
7037 @sp 1
7038 @cartouche
7039 @noindent
7040 @strong{25}.  The time zone used for package @code{Calendar}
7041 operations.  See 9.6(24).
7042 @end cartouche
7043 @noindent
7044 The time zone used by package @code{Calendar} is the current system time zone
7045 setting for local time, as accessed by the C library function
7046 @code{localtime}.
7048 @sp 1
7049 @cartouche
7050 @noindent
7051 @strong{26}.  Any limit on @code{delay_until_statements} of
7052 @code{select_statements}.  See 9.6(29).
7053 @end cartouche
7054 @noindent
7055 There are no such limits.
7057 @sp 1
7058 @cartouche
7059 @noindent
7060 @strong{27}.  Whether or not two non overlapping parts of a composite
7061 object are independently addressable, in the case where packing, record
7062 layout, or @code{Component_Size} is specified for the object.  See
7063 9.10(1).
7064 @end cartouche
7065 @noindent
7066 Separate components are independently addressable if they do not share
7067 overlapping storage units.
7069 @sp 1
7070 @cartouche
7071 @noindent
7072 @strong{28}.  The representation for a compilation.  See 10.1(2).
7073 @end cartouche
7074 @noindent
7075 A compilation is represented by a sequence of files presented to the
7076 compiler in a single invocation of the @code{gcc} command.
7078 @sp 1
7079 @cartouche
7080 @noindent
7081 @strong{29}.  Any restrictions on compilations that contain multiple
7082 compilation_units.  See 10.1(4).
7083 @end cartouche
7084 @noindent
7085 No single file can contain more than one compilation unit, but any
7086 sequence of files can be presented to the compiler as a single
7087 compilation.
7089 @sp 1
7090 @cartouche
7091 @noindent
7092 @strong{30}.  The mechanisms for creating an environment and for adding
7093 and replacing compilation units.  See 10.1.4(3).
7094 @end cartouche
7095 @noindent
7096 See separate section on compilation model.
7098 @sp 1
7099 @cartouche
7100 @noindent
7101 @strong{31}.  The manner of explicitly assigning library units to a
7102 partition.  See 10.2(2).
7103 @end cartouche
7104 @noindent
7105 If a unit contains an Ada main program, then the Ada units for the partition
7106 are determined by recursive application of the rules in the Ada Reference
7107 Manual section 10.2(2-6).  In other words, the Ada units will be those that
7108 are needed by the main program, and then this definition of need is applied
7109 recursively to those units, and the partition contains the transitive
7110 closure determined by this relationship.  In short, all the necessary units
7111 are included, with no need to explicitly specify the list.  If additional
7112 units are required, e.g.@: by foreign language units, then all units must be
7113 mentioned in the context clause of one of the needed Ada units.
7115 If the partition contains no main program, or if the main program is in
7116 a language other than Ada, then GNAT
7117 provides the binder options @code{-z} and @code{-n} respectively, and in
7118 this case a list of units can be explicitly supplied to the binder for
7119 inclusion in the partition (all units needed by these units will also
7120 be included automatically).  For full details on the use of these
7121 options, refer to the @cite{GNAT User's Guide} sections on Binding
7122 and Linking.
7124 @sp 1
7125 @cartouche
7126 @noindent
7127 @strong{32}.  The implementation-defined means, if any, of specifying
7128 which compilation units are needed by a given compilation unit.  See
7129 10.2(2).
7130 @end cartouche
7131 @noindent
7132 The units needed by a given compilation unit are as defined in
7133 the Ada Reference Manual section 10.2(2-6).  There are no
7134 implementation-defined pragmas or other implementation-defined
7135 means for specifying needed units.
7137 @sp 1
7138 @cartouche
7139 @noindent
7140 @strong{33}.  The manner of designating the main subprogram of a
7141 partition.  See 10.2(7).
7142 @end cartouche
7143 @noindent
7144 The main program is designated by providing the name of the
7145 corresponding @file{ALI} file as the input parameter to the binder.
7147 @sp 1
7148 @cartouche
7149 @noindent
7150 @strong{34}.  The order of elaboration of @code{library_items}.  See
7151 10.2(18).
7152 @end cartouche
7153 @noindent
7154 The first constraint on ordering is that it meets the requirements of
7155 chapter 10 of the Ada 95 Reference Manual.  This still leaves some
7156 implementation dependent choices, which are resolved by first
7157 elaborating bodies as early as possible (i.e.@: in preference to specs
7158 where there is a choice), and second by evaluating the immediate with
7159 clauses of a unit to determine the probably best choice, and
7160 third by elaborating in alphabetical order of unit names
7161 where a choice still remains.
7163 @sp 1
7164 @cartouche
7165 @noindent
7166 @strong{35}.  Parameter passing and function return for the main
7167 subprogram.  See 10.2(21).
7168 @end cartouche
7169 @noindent
7170 The main program has no parameters.  It may be a procedure, or a function
7171 returning an integer type.  In the latter case, the returned integer
7172 value is the return code of the program (overriding any value that
7173 may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
7175 @sp 1
7176 @cartouche
7177 @noindent
7178 @strong{36}.  The mechanisms for building and running partitions.  See
7179 10.2(24).
7180 @end cartouche
7181 @noindent
7182 GNAT itself supports programs with only a single partition.  The GNATDIST
7183 tool provided with the GLADE package (which also includes an implementation
7184 of the PCS) provides a completely flexible method for building and running
7185 programs consisting of multiple partitions.  See the separate GLADE manual
7186 for details.
7188 @sp 1
7189 @cartouche
7190 @noindent
7191 @strong{37}.  The details of program execution, including program
7192 termination.  See 10.2(25).
7193 @end cartouche
7194 @noindent
7195 See separate section on compilation model.
7197 @sp 1
7198 @cartouche
7199 @noindent
7200 @strong{38}.  The semantics of any non-active partitions supported by the
7201 implementation.  See 10.2(28).
7202 @end cartouche
7203 @noindent
7204 Passive partitions are supported on targets where shared memory is
7205 provided by the operating system.  See the GLADE reference manual for
7206 further details.
7208 @sp 1
7209 @cartouche
7210 @noindent
7211 @strong{39}.  The information returned by @code{Exception_Message}.  See
7212 11.4.1(10).
7213 @end cartouche
7214 @noindent
7215 Exception message returns the null string unless a specific message has
7216 been passed by the program.
7218 @sp 1
7219 @cartouche
7220 @noindent
7221 @strong{40}.  The result of @code{Exceptions.Exception_Name} for types
7222 declared within an unnamed @code{block_statement}.  See 11.4.1(12).
7223 @end cartouche
7224 @noindent
7225 Blocks have implementation defined names of the form @code{B@var{nnn}}
7226 where @var{nnn} is an integer.
7228 @sp 1
7229 @cartouche
7230 @noindent
7231 @strong{41}.  The information returned by
7232 @code{Exception_Information}.  See 11.4.1(13).
7233 @end cartouche
7234 @noindent
7235 @code{Exception_Information} returns a string in the following format:
7237 @smallexample
7238 @emph{Exception_Name:} nnnnn
7239 @emph{Message:} mmmmm
7240 @emph{PID:} ppp
7241 @emph{Call stack traceback locations:}
7242 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
7243 @end smallexample
7245 @noindent
7246 where
7248 @itemize @bullet
7249 @item
7250 @code{nnnn} is the fully qualified name of the exception in all upper
7251 case letters. This line is always present.
7253 @item
7254 @code{mmmm} is the message (this line present only if message is non-null)
7256 @item
7257 @code{ppp} is the Process Id value as a decimal integer (this line is
7258 present only if the Process Id is nonzero). Currently we are
7259 not making use of this field.
7261 @item
7262 The Call stack traceback locations line and the following values
7263 are present only if at least one traceback location was recorded.
7264 The values are given in C style format, with lower case letters
7265 for a-f, and only as many digits present as are necessary.
7266 @end itemize
7268 @noindent
7269 The line terminator sequence at the end of each line, including
7270 the last line is a single @code{LF} character (@code{16#0A#}).
7272 @sp 1
7273 @cartouche
7274 @noindent
7275 @strong{42}.  Implementation-defined check names.  See 11.5(27).
7276 @end cartouche
7277 @noindent
7278 No implementation-defined check names are supported.
7280 @sp 1
7281 @cartouche
7282 @noindent
7283 @strong{43}.  The interpretation of each aspect of representation.  See
7284 13.1(20).
7285 @end cartouche
7286 @noindent
7287 See separate section on data representations.
7289 @sp 1
7290 @cartouche
7291 @noindent
7292 @strong{44}.  Any restrictions placed upon representation items.  See
7293 13.1(20).
7294 @end cartouche
7295 @noindent
7296 See separate section on data representations.
7298 @sp 1
7299 @cartouche
7300 @noindent
7301 @strong{45}.  The meaning of @code{Size} for indefinite subtypes.  See
7302 13.3(48).
7303 @end cartouche
7304 @noindent
7305 Size for an indefinite subtype is the maximum possible size, except that
7306 for the case of a subprogram parameter, the size of the parameter object
7307 is the actual size.
7309 @sp 1
7310 @cartouche
7311 @noindent
7312 @strong{46}.  The default external representation for a type tag.  See
7313 13.3(75).
7314 @end cartouche
7315 @noindent
7316 The default external representation for a type tag is the fully expanded
7317 name of the type in upper case letters.
7319 @sp 1
7320 @cartouche
7321 @noindent
7322 @strong{47}.  What determines whether a compilation unit is the same in
7323 two different partitions.  See 13.3(76).
7324 @end cartouche
7325 @noindent
7326 A compilation unit is the same in two different partitions if and only
7327 if it derives from the same source file.
7329 @sp 1
7330 @cartouche
7331 @noindent
7332 @strong{48}.  Implementation-defined components.  See 13.5.1(15).
7333 @end cartouche
7334 @noindent
7335 The only implementation defined component is the tag for a tagged type,
7336 which contains a pointer to the dispatching table.
7338 @sp 1
7339 @cartouche
7340 @noindent
7341 @strong{49}.  If @code{Word_Size} = @code{Storage_Unit}, the default bit
7342 ordering.  See 13.5.3(5).
7343 @end cartouche
7344 @noindent
7345 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
7346 implementation, so no non-default bit ordering is supported.  The default
7347 bit ordering corresponds to the natural endianness of the target architecture.
7349 @sp 1
7350 @cartouche
7351 @noindent
7352 @strong{50}.  The contents of the visible part of package @code{System}
7353 and its language-defined children.  See 13.7(2).
7354 @end cartouche
7355 @noindent
7356 See the definition of these packages in files @file{system.ads} and
7357 @file{s-stoele.ads}.
7359 @sp 1
7360 @cartouche
7361 @noindent
7362 @strong{51}.  The contents of the visible part of package
7363 @code{System.Machine_Code}, and the meaning of
7364 @code{code_statements}.  See 13.8(7).
7365 @end cartouche
7366 @noindent
7367 See the definition and documentation in file @file{s-maccod.ads}.
7369 @sp 1
7370 @cartouche
7371 @noindent
7372 @strong{52}.  The effect of unchecked conversion.  See 13.9(11).
7373 @end cartouche
7374 @noindent
7375 Unchecked conversion between types of the same size
7376 results in an uninterpreted transmission of the bits from one type
7377 to the other.  If the types are of unequal sizes, then in the case of
7378 discrete types, a shorter source is first zero or sign extended as
7379 necessary, and a shorter target is simply truncated on the left.
7380 For all non-discrete types, the source is first copied if necessary
7381 to ensure that the alignment requirements of the target are met, then
7382 a pointer is constructed to the source value, and the result is obtained
7383 by dereferencing this pointer after converting it to be a pointer to the
7384 target type. Unchecked conversions where the target subtype is an
7385 unconstrained array are not permitted. If the target alignment is
7386 greater than the source alignment, then a copy of the result is
7387 made with appropriate alignment
7389 @sp 1
7390 @cartouche
7391 @noindent
7392 @strong{53}.  The manner of choosing a storage pool for an access type
7393 when @code{Storage_Pool} is not specified for the type.  See 13.11(17).
7394 @end cartouche
7395 @noindent
7396 There are 3 different standard pools used by the compiler when
7397 @code{Storage_Pool} is not specified depending whether the type is local
7398 to a subprogram or defined at the library level and whether
7399 @code{Storage_Size}is specified or not.  See documentation in the runtime
7400 library units @code{System.Pool_Global}, @code{System.Pool_Size} and
7401 @code{System.Pool_Local} in files @file{s-poosiz.ads},
7402 @file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
7403 default pools used.
7405 @sp 1
7406 @cartouche
7407 @noindent
7408 @strong{54}.  Whether or not the implementation provides user-accessible
7409 names for the standard pool type(s).  See 13.11(17).
7410 @end cartouche
7411 @noindent
7413 See documentation in the sources of the run time mentioned in paragraph
7414 @strong{53} .  All these pools are accessible by means of @code{with}'ing
7415 these units.
7417 @sp 1
7418 @cartouche
7419 @noindent
7420 @strong{55}.  The meaning of @code{Storage_Size}.  See 13.11(18).
7421 @end cartouche
7422 @noindent
7423 @code{Storage_Size} is measured in storage units, and refers to the
7424 total space available for an access type collection, or to the primary
7425 stack space for a task.
7427 @sp 1
7428 @cartouche
7429 @noindent
7430 @strong{56}.  Implementation-defined aspects of storage pools.  See
7431 13.11(22).
7432 @end cartouche
7433 @noindent
7434 See documentation in the sources of the run time mentioned in paragraph
7435 @strong{53} for details on GNAT-defined aspects of storage pools.
7437 @sp 1
7438 @cartouche
7439 @noindent
7440 @strong{57}.  The set of restrictions allowed in a pragma
7441 @code{Restrictions}.  See 13.12(7).
7442 @end cartouche
7443 @noindent
7444 All RM defined Restriction identifiers are implemented.  The following
7445 additional restriction identifiers are provided.  There are two separate
7446 lists of implementation dependent restriction identifiers.  The first
7447 set requires consistency throughout a partition (in other words, if the
7448 restriction identifier is used for any compilation unit in the partition,
7449 then all compilation units in the partition must obey the restriction.
7451 @table @code
7453 @item Simple_Barriers
7454 @findex Simple_Barriers
7455 This restriction ensures at compile time that barriers in entry declarations
7456 for protected types are restricted to either static boolean expressions or
7457 references to simple boolean variables defined in the private part of the
7458 protected type.  No other form of entry barriers is permitted.  This is one
7459 of the restrictions of the Ravenscar profile for limited tasking (see also
7460 pragma @code{Profile (Ravenscar)}).
7462 @item Max_Entry_Queue_Length => Expr
7463 @findex Max_Entry_Queue_Length
7464 This restriction is a declaration that any protected entry compiled in
7465 the scope of the restriction has at most the specified number of
7466 tasks waiting on the entry
7467 at any one time, and so no queue is required.  This restriction is not
7468 checked at compile time.  A program execution is erroneous if an attempt
7469 is made to queue more than the specified number of tasks on such an entry.
7471 @item No_Calendar
7472 @findex No_Calendar
7473 This restriction ensures at compile time that there is no implicit or
7474 explicit dependence on the package @code{Ada.Calendar}.
7476 @item No_Direct_Boolean_Operators
7477 @findex No_Direct_Boolean_Operators
7478 This restriction ensures that no logical (and/or/xor) or comparison
7479 operators are used on operands of type Boolean (or any type derived
7480 from Boolean). This is intended for use in safety critical programs
7481 where the certification protocol requires the use of short-circuit
7482 (and then, or else) forms for all composite boolean operations.
7484 @item No_Dispatching_Calls
7485 @findex No_Dispatching_Calls
7486 This restriction ensures at compile time that the code generated by the
7487 compiler involves no dispatching calls. The use of this restriction allows the
7488 safe use of record extensions, classwide membership tests and other classwide
7489 features not involving implicit dispatching. This restriction ensures that
7490 the code contains no indirect calls through a dispatching mechanism. Note that
7491 this includes internally-generated calls created by the compiler, for example
7492 in the implementation of class-wide objects assignments. The
7493 membership test is allowed in the presence of this restriction, because its
7494 implementation requires no dispatching.
7495 This restriction is comparable to the official Ada restriction
7496 @code{No_Dispatch} except that it is a bit less restrictive in that it allows
7497 all classwide constructs that do not imply dispatching.
7498 The following example indicates constructs that violate this restriction.
7500 @smallexample
7501 package Pkg is
7502   type T is tagged record
7503     Data : Natural;
7504   end record;
7505   procedure P (X : T);
7507   type DT is new T with record
7508     More_Data : Natural;
7509   end record;
7510   procedure Q (X : DT);
7511 end Pkg;
7513 with Pkg; use Pkg;
7514 procedure Example is
7515   procedure Test (O : T'Class) is
7516     N : Natural  := O'Size;--  Error: Dispatching call
7517     C : T'Class := O;      --  Error: implicit Dispatching Call
7518   begin
7519     if O in DT'Class then  --  OK   : Membership test
7520        Q (DT (O));         --  OK   : Type conversion plus direct call
7521     else
7522        P (O);              --  Error: Dispatching call
7523     end if;
7524   end Test;
7526   Obj : DT;
7527 begin
7528   P (Obj);                 --  OK   : Direct call
7529   P (T (Obj));             --  OK   : Type conversion plus direct call
7530   P (T'Class (Obj));       --  Error: Dispatching call
7532   Test (Obj);              --  OK   : Type conversion
7534   if Obj in T'Class then   --  OK   : Membership test
7535      null;
7536   end if;
7537 end Example;
7538 @end smallexample
7540 @item No_Dynamic_Attachment
7541 @findex No_Dynamic_Attachment
7542 This restriction ensures that there is no call to any of the operations
7543 defined in package Ada.Interrupts.
7545 @item No_Enumeration_Maps
7546 @findex No_Enumeration_Maps
7547 This restriction ensures at compile time that no operations requiring
7548 enumeration maps are used (that is Image and Value attributes applied
7549 to enumeration types).
7551 @item No_Entry_Calls_In_Elaboration_Code
7552 @findex No_Entry_Calls_In_Elaboration_Code
7553 This restriction ensures at compile time that no task or protected entry
7554 calls are made during elaboration code.  As a result of the use of this
7555 restriction, the compiler can assume that no code past an accept statement
7556 in a task can be executed at elaboration time.
7558 @item No_Exception_Handlers
7559 @findex No_Exception_Handlers
7560 This restriction ensures at compile time that there are no explicit
7561 exception handlers. It also indicates that no exception propagation will
7562 be provided. In this mode, exceptions may be raised but will result in
7563 an immediate call to the last chance handler, a routine that the user
7564 must define with the following profile:
7566    procedure Last_Chance_Handler
7567      (Source_Location : System.Address; Line : Integer);
7568    pragma Export (C, Last_Chance_Handler,
7569                   "__gnat_last_chance_handler");
7571    The parameter is a C null-terminated string representing a message to be
7572    associated with the exception (typically the source location of the raise
7573    statement generated by the compiler). The Line parameter when nonzero
7574    represents the line number in the source program where the raise occurs.
7576 @item No_Exception_Streams
7577 @findex No_Exception_Streams
7578 This restriction ensures at compile time that no stream operations for
7579 types Exception_Id or Exception_Occurrence are used. This also makes it
7580 impossible to pass exceptions to or from a partition with this restriction
7581 in a distributed environment. If this exception is active, then the generated
7582 code is simplified by omitting the otherwise-required global registration
7583 of exceptions when they are declared.
7585 @item No_Implicit_Conditionals
7586 @findex No_Implicit_Conditionals
7587 This restriction ensures that the generated code does not contain any
7588 implicit conditionals, either by modifying the generated code where possible,
7589 or by rejecting any construct that would otherwise generate an implicit
7590 conditional. Note that this check does not include run time constraint
7591 checks, which on some targets may generate implicit conditionals as
7592 well. To control the latter, constraint checks can be suppressed in the
7593 normal manner. Constructs generating implicit conditionals include comparisons
7594 of composite objects and the Max/Min attributes.
7596 @item No_Implicit_Dynamic_Code
7597 @findex No_Implicit_Dynamic_Code
7598 This restriction prevents the compiler from building ``trampolines''.
7599 This is a structure that is built on the stack and contains dynamic
7600 code to be executed at run time. A trampoline is needed to indirectly
7601 address a nested subprogram (that is a subprogram that is not at the
7602 library level). The restriction prevents the use of any of the
7603 attributes @code{Address}, @code{Access} or @code{Unrestricted_Access}
7604 being applied to a subprogram that is not at the library level.
7606 @item No_Implicit_Loops
7607 @findex No_Implicit_Loops
7608 This restriction ensures that the generated code does not contain any
7609 implicit @code{for} loops, either by modifying
7610 the generated code where possible,
7611 or by rejecting any construct that would otherwise generate an implicit
7612 @code{for} loop.
7614 @item No_Initialize_Scalars
7615 @findex No_Initialize_Scalars
7616 This restriction ensures that no unit in the partition is compiled with
7617 pragma Initialize_Scalars. This allows the generation of more efficient
7618 code, and in particular eliminates dummy null initialization routines that
7619 are otherwise generated for some record and array types.
7621 @item No_Local_Protected_Objects
7622 @findex No_Local_Protected_Objects
7623 This restriction ensures at compile time that protected objects are
7624 only declared at the library level.
7626 @item No_Protected_Type_Allocators
7627 @findex No_Protected_Type_Allocators
7628 This restriction ensures at compile time that there are no allocator
7629 expressions that attempt to allocate protected objects.
7631 @item No_Secondary_Stack
7632 @findex No_Secondary_Stack
7633 This restriction ensures at compile time that the generated code does not
7634 contain any reference to the secondary stack.  The secondary stack is used
7635 to implement functions returning unconstrained objects (arrays or records)
7636 on some targets.
7638 @item No_Select_Statements
7639 @findex No_Select_Statements
7640 This restriction ensures at compile time no select statements of any kind
7641 are permitted, that is the keyword @code{select} may not appear.
7642 This is one of the restrictions of the Ravenscar
7643 profile for limited tasking (see also pragma @code{Profile (Ravenscar)}).
7645 @item No_Standard_Storage_Pools
7646 @findex No_Standard_Storage_Pools
7647 This restriction ensures at compile time that no access types
7648 use the standard default storage pool.  Any access type declared must
7649 have an explicit Storage_Pool attribute defined specifying a
7650 user-defined storage pool.
7652 @item No_Streams
7653 @findex No_Streams
7654 This restriction ensures at compile/bind time that there are no
7655 stream objects created (and therefore no actual stream operations).
7656 This restriction does not forbid dependences on the package
7657 @code{Ada.Streams}. So it is permissible to with
7658 @code{Ada.Streams} (or another package that does so itself)
7659 as long as no actual stream objects are created.
7661 @item No_Task_Attributes_Package
7662 @findex No_Task_Attributes_Package
7663 This restriction ensures at compile time that there are no implicit or
7664 explicit dependencies on the package @code{Ada.Task_Attributes}.
7666 @item No_Task_Termination
7667 @findex No_Task_Termination
7668 This restriction ensures at compile time that no terminate alternatives
7669 appear in any task body.
7671 @item No_Tasking
7672 @findex No_Tasking
7673 This restriction prevents the declaration of tasks or task types throughout
7674 the partition.  It is similar in effect to the use of @code{Max_Tasks => 0}
7675 except that violations are caught at compile time and cause an error message
7676 to be output either by the compiler or binder.
7678 @item Static_Priorities
7679 @findex Static_Priorities
7680 This restriction ensures at compile time that all priority expressions
7681 are static, and that there are no dependencies on the package
7682 @code{Ada.Dynamic_Priorities}.
7684 @item Static_Storage_Size
7685 @findex Static_Storage_Size
7686 This restriction ensures at compile time that any expression appearing
7687 in a Storage_Size pragma or attribute definition clause is static.
7689 @end table
7691 @noindent
7692 The second set of implementation dependent restriction identifiers
7693 does not require partition-wide consistency.
7694 The restriction may be enforced for a single
7695 compilation unit without any effect on any of the
7696 other compilation units in the partition.
7698 @table @code
7700 @item No_Elaboration_Code
7701 @findex No_Elaboration_Code
7702 This restriction ensures at compile time that no elaboration code is
7703 generated.  Note that this is not the same condition as is enforced
7704 by pragma @code{Preelaborate}.  There are cases in which pragma
7705 @code{Preelaborate} still permits code to be generated (e.g.@: code
7706 to initialize a large array to all zeroes), and there are cases of units
7707 which do not meet the requirements for pragma @code{Preelaborate},
7708 but for which no elaboration code is generated.  Generally, it is
7709 the case that preelaborable units will meet the restrictions, with
7710 the exception of large aggregates initialized with an others_clause,
7711 and exception declarations (which generate calls to a run-time
7712 registry procedure).  This restriction is enforced on
7713 a unit by unit basis, it need not be obeyed consistently
7714 throughout a partition.
7716 In the case of aggregates with others, if the aggregate has a dynamic
7717 size, there is no way to eliminate the elaboration code (such dynamic
7718 bounds would be incompatible with @code{Preelaborate} in any case. If
7719 the bounds are static, then use of this restriction actually modifies
7720 the code choice of the compiler to avoid generating a loop, and instead
7721 generate the aggregate statically if possible, no matter how many times
7722 the data for the others clause must be repeatedly generated.
7724 It is not possible to precisely document
7725 the constructs which are compatible with this restriction, since,
7726 unlike most other restrictions, this is not a restriction on the
7727 source code, but a restriction on the generated object code. For
7728 example, if the source contains a declaration:
7730 @smallexample
7731    Val : constant Integer := X;
7732 @end smallexample
7734 @noindent
7735 where X is not a static constant, it may be possible, depending
7736 on complex optimization circuitry, for the compiler to figure
7737 out the value of X at compile time, in which case this initialization
7738 can be done by the loader, and requires no initialization code. It
7739 is not possible to document the precise conditions under which the
7740 optimizer can figure this out.
7742 Note that this the implementation of this restriction requires full
7743 code generation. If it is used in conjunction with "semantics only"
7744 checking, then some cases of violations may be missed.
7746 @item No_Entry_Queue
7747 @findex No_Entry_Queue
7748 This restriction is a declaration that any protected entry compiled in
7749 the scope of the restriction has at most one task waiting on the entry
7750 at any one time, and so no queue is required.  This restriction is not
7751 checked at compile time.  A program execution is erroneous if an attempt
7752 is made to queue a second task on such an entry.
7754 @item No_Implementation_Attributes
7755 @findex No_Implementation_Attributes
7756 This restriction checks at compile time that no GNAT-defined attributes
7757 are present.  With this restriction, the only attributes that can be used
7758 are those defined in the Ada 95 Reference Manual.
7760 @item No_Implementation_Pragmas
7761 @findex No_Implementation_Pragmas
7762 This restriction checks at compile time that no GNAT-defined pragmas
7763 are present.  With this restriction, the only pragmas that can be used
7764 are those defined in the Ada 95 Reference Manual.
7766 @item No_Implementation_Restrictions
7767 @findex No_Implementation_Restrictions
7768 This restriction checks at compile time that no GNAT-defined restriction
7769 identifiers (other than @code{No_Implementation_Restrictions} itself)
7770 are present.  With this restriction, the only other restriction identifiers
7771 that can be used are those defined in the Ada 95 Reference Manual.
7773 @item No_Wide_Characters
7774 @findex No_Wide_Characters
7775 This restriction ensures at compile time that no uses of the types
7776 @code{Wide_Character} or @code{Wide_String} or corresponding wide
7777 wide types
7778 appear, and that no wide or wide wide string or character literals
7779 appear in the program (that is literals representing characters not in
7780 type @code{Character}.
7782 @end table
7784 @sp 1
7785 @cartouche
7786 @noindent
7787 @strong{58}.  The consequences of violating limitations on
7788 @code{Restrictions} pragmas.  See 13.12(9).
7789 @end cartouche
7790 @noindent
7791 Restrictions that can be checked at compile time result in illegalities
7792 if violated.  Currently there are no other consequences of violating
7793 restrictions.
7795 @sp 1
7796 @cartouche
7797 @noindent
7798 @strong{59}.  The representation used by the @code{Read} and
7799 @code{Write} attributes of elementary types in terms of stream
7800 elements.  See 13.13.2(9).
7801 @end cartouche
7802 @noindent
7803 The representation is the in-memory representation of the base type of
7804 the type, using the number of bits corresponding to the
7805 @code{@var{type}'Size} value, and the natural ordering of the machine.
7807 @sp 1
7808 @cartouche
7809 @noindent
7810 @strong{60}.  The names and characteristics of the numeric subtypes
7811 declared in the visible part of package @code{Standard}.  See A.1(3).
7812 @end cartouche
7813 @noindent
7814 See items describing the integer and floating-point types supported.
7816 @sp 1
7817 @cartouche
7818 @noindent
7819 @strong{61}.  The accuracy actually achieved by the elementary
7820 functions.  See A.5.1(1).
7821 @end cartouche
7822 @noindent
7823 The elementary functions correspond to the functions available in the C
7824 library.  Only fast math mode is implemented.
7826 @sp 1
7827 @cartouche
7828 @noindent
7829 @strong{62}.  The sign of a zero result from some of the operators or
7830 functions in @code{Numerics.Generic_Elementary_Functions}, when
7831 @code{Float_Type'Signed_Zeros} is @code{True}.  See A.5.1(46).
7832 @end cartouche
7833 @noindent
7834 The sign of zeroes follows the requirements of the IEEE 754 standard on
7835 floating-point.
7837 @sp 1
7838 @cartouche
7839 @noindent
7840 @strong{63}.  The value of
7841 @code{Numerics.Float_Random.Max_Image_Width}.  See A.5.2(27).
7842 @end cartouche
7843 @noindent
7844 Maximum image width is 649, see library file @file{a-numran.ads}.
7846 @sp 1
7847 @cartouche
7848 @noindent
7849 @strong{64}.  The value of
7850 @code{Numerics.Discrete_Random.Max_Image_Width}.  See A.5.2(27).
7851 @end cartouche
7852 @noindent
7853 Maximum image width is 80, see library file @file{a-nudira.ads}.
7855 @sp 1
7856 @cartouche
7857 @noindent
7858 @strong{65}.  The algorithms for random number generation.  See
7859 A.5.2(32).
7860 @end cartouche
7861 @noindent
7862 The algorithm is documented in the source files @file{a-numran.ads} and
7863 @file{a-numran.adb}.
7865 @sp 1
7866 @cartouche
7867 @noindent
7868 @strong{66}.  The string representation of a random number generator's
7869 state.  See A.5.2(38).
7870 @end cartouche
7871 @noindent
7872 See the documentation contained in the file @file{a-numran.adb}.
7874 @sp 1
7875 @cartouche
7876 @noindent
7877 @strong{67}.  The minimum time interval between calls to the
7878 time-dependent Reset procedure that are guaranteed to initiate different
7879 random number sequences.  See A.5.2(45).
7880 @end cartouche
7881 @noindent
7882 The minimum period between reset calls to guarantee distinct series of
7883 random numbers is one microsecond.
7885 @sp 1
7886 @cartouche
7887 @noindent
7888 @strong{68}.  The values of the @code{Model_Mantissa},
7889 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
7890 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
7891 Annex is not supported.  See A.5.3(72).
7892 @end cartouche
7893 @noindent
7894 See the source file @file{ttypef.ads} for the values of all numeric
7895 attributes.
7897 @sp 1
7898 @cartouche
7899 @noindent
7900 @strong{69}.  Any implementation-defined characteristics of the
7901 input-output packages.  See A.7(14).
7902 @end cartouche
7903 @noindent
7904 There are no special implementation defined characteristics for these
7905 packages.
7907 @sp 1
7908 @cartouche
7909 @noindent
7910 @strong{70}.  The value of @code{Buffer_Size} in @code{Storage_IO}.  See
7911 A.9(10).
7912 @end cartouche
7913 @noindent
7914 All type representations are contiguous, and the @code{Buffer_Size} is
7915 the value of @code{@var{type}'Size} rounded up to the next storage unit
7916 boundary.
7918 @sp 1
7919 @cartouche
7920 @noindent
7921 @strong{71}.  External files for standard input, standard output, and
7922 standard error See A.10(5).
7923 @end cartouche
7924 @noindent
7925 These files are mapped onto the files provided by the C streams
7926 libraries.  See source file @file{i-cstrea.ads} for further details.
7928 @sp 1
7929 @cartouche
7930 @noindent
7931 @strong{72}.  The accuracy of the value produced by @code{Put}.  See
7932 A.10.9(36).
7933 @end cartouche
7934 @noindent
7935 If more digits are requested in the output than are represented by the
7936 precision of the value, zeroes are output in the corresponding least
7937 significant digit positions.
7939 @sp 1
7940 @cartouche
7941 @noindent
7942 @strong{73}.  The meaning of @code{Argument_Count}, @code{Argument}, and
7943 @code{Command_Name}.  See A.15(1).
7944 @end cartouche
7945 @noindent
7946 These are mapped onto the @code{argv} and @code{argc} parameters of the
7947 main program in the natural manner.
7949 @sp 1
7950 @cartouche
7951 @noindent
7952 @strong{74}.  Implementation-defined convention names.  See B.1(11).
7953 @end cartouche
7954 @noindent
7955 The following convention names are supported
7957 @table @code
7958 @item  Ada
7960 @item Assembler
7961 Assembly language
7962 @item Asm
7963 Synonym for Assembler
7964 @item Assembly
7965 Synonym for Assembler
7966 @item C
7968 @item C_Pass_By_Copy
7969 Allowed only for record types, like C, but also notes that record
7970 is to be passed by copy rather than reference.
7971 @item COBOL
7972 COBOL
7973 @item CPP
7975 @item Default
7976 Treated the same as C
7977 @item External
7978 Treated the same as C
7979 @item Fortran
7980 Fortran
7981 @item Intrinsic
7982 For support of pragma @code{Import} with convention Intrinsic, see
7983 separate section on Intrinsic Subprograms.
7984 @item Stdcall
7985 Stdcall (used for Windows implementations only).  This convention correspond
7986 to the WINAPI (previously called Pascal convention) C/C++ convention under
7987 Windows.  A function with this convention cleans the stack before exit.
7988 @item DLL
7989 Synonym for Stdcall
7990 @item Win32
7991 Synonym for Stdcall
7992 @item Stubbed
7993 Stubbed is a special convention used to indicate that the body of the
7994 subprogram will be entirely ignored.  Any call to the subprogram
7995 is converted into a raise of the @code{Program_Error} exception.  If a
7996 pragma @code{Import} specifies convention @code{stubbed} then no body need
7997 be present at all.  This convention is useful during development for the
7998 inclusion of subprograms whose body has not yet been written.
8000 @end table
8001 @noindent
8002 In addition, all otherwise unrecognized convention names are also
8003 treated as being synonymous with convention C@.  In all implementations
8004 except for VMS, use of such other names results in a warning.  In VMS
8005 implementations, these names are accepted silently.
8007 @sp 1
8008 @cartouche
8009 @noindent
8010 @strong{75}.  The meaning of link names.  See B.1(36).
8011 @end cartouche
8012 @noindent
8013 Link names are the actual names used by the linker.
8015 @sp 1
8016 @cartouche
8017 @noindent
8018 @strong{76}.  The manner of choosing link names when neither the link
8019 name nor the address of an imported or exported entity is specified.  See
8020 B.1(36).
8021 @end cartouche
8022 @noindent
8023 The default linker name is that which would be assigned by the relevant
8024 external language, interpreting the Ada name as being in all lower case
8025 letters.
8027 @sp 1
8028 @cartouche
8029 @noindent
8030 @strong{77}.  The effect of pragma @code{Linker_Options}.  See B.1(37).
8031 @end cartouche
8032 @noindent
8033 The string passed to @code{Linker_Options} is presented uninterpreted as
8034 an argument to the link command, unless it contains Ascii.NUL characters.
8035 NUL characters if they appear act as argument separators, so for example
8037 @smallexample @c ada
8038 pragma Linker_Options ("-labc" & ASCII.Nul & "-ldef");
8039 @end smallexample
8041 @noindent
8042 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
8043 linker. The order of linker options is preserved for a given unit. The final
8044 list of options passed to the linker is in reverse order of the elaboration
8045 order. For example, linker options fo a body always appear before the options
8046 from the corresponding package spec.
8048 @sp 1
8049 @cartouche
8050 @noindent
8051 @strong{78}.  The contents of the visible part of package
8052 @code{Interfaces} and its language-defined descendants.  See B.2(1).
8053 @end cartouche
8054 @noindent
8055 See files with prefix @file{i-} in the distributed library.
8057 @sp 1
8058 @cartouche
8059 @noindent
8060 @strong{79}.  Implementation-defined children of package
8061 @code{Interfaces}.  The contents of the visible part of package
8062 @code{Interfaces}.  See B.2(11).
8063 @end cartouche
8064 @noindent
8065 See files with prefix @file{i-} in the distributed library.
8067 @sp 1
8068 @cartouche
8069 @noindent
8070 @strong{80}.  The types @code{Floating}, @code{Long_Floating},
8071 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
8072 @code{COBOL_Character}; and the initialization of the variables
8073 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
8074 @code{Interfaces.COBOL}.  See B.4(50).
8075 @end cartouche
8076 @noindent
8077 @table @code
8078 @item Floating
8079 Float
8080 @item Long_Floating
8081 (Floating) Long_Float
8082 @item Binary
8083 Integer
8084 @item Long_Binary
8085 Long_Long_Integer
8086 @item Decimal_Element
8087 Character
8088 @item COBOL_Character
8089 Character
8090 @end table
8092 @noindent
8093 For initialization, see the file @file{i-cobol.ads} in the distributed library.
8095 @sp 1
8096 @cartouche
8097 @noindent
8098 @strong{81}.  Support for access to machine instructions.  See C.1(1).
8099 @end cartouche
8100 @noindent
8101 See documentation in file @file{s-maccod.ads} in the distributed library.
8103 @sp 1
8104 @cartouche
8105 @noindent
8106 @strong{82}.  Implementation-defined aspects of access to machine
8107 operations.  See C.1(9).
8108 @end cartouche
8109 @noindent
8110 See documentation in file @file{s-maccod.ads} in the distributed library.
8112 @sp 1
8113 @cartouche
8114 @noindent
8115 @strong{83}.  Implementation-defined aspects of interrupts.  See C.3(2).
8116 @end cartouche
8117 @noindent
8118 Interrupts are mapped to signals or conditions as appropriate.  See
8119 definition of unit
8120 @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
8121 on the interrupts supported on a particular target.
8123 @sp 1
8124 @cartouche
8125 @noindent
8126 @strong{84}.  Implementation-defined aspects of pre-elaboration.  See
8127 C.4(13).
8128 @end cartouche
8129 @noindent
8130 GNAT does not permit a partition to be restarted without reloading,
8131 except under control of the debugger.
8133 @sp 1
8134 @cartouche
8135 @noindent
8136 @strong{85}.  The semantics of pragma @code{Discard_Names}.  See C.5(7).
8137 @end cartouche
8138 @noindent
8139 Pragma @code{Discard_Names} causes names of enumeration literals to
8140 be suppressed.  In the presence of this pragma, the Image attribute
8141 provides the image of the Pos of the literal, and Value accepts
8142 Pos values.
8144 @sp 1
8145 @cartouche
8146 @noindent
8147 @strong{86}.  The result of the @code{Task_Identification.Image}
8148 attribute.  See C.7.1(7).
8149 @end cartouche
8150 @noindent
8151 The result of this attribute is an 8-digit hexadecimal string
8152 representing the virtual address of the task control block.
8154 @sp 1
8155 @cartouche
8156 @noindent
8157 @strong{87}.  The value of @code{Current_Task} when in a protected entry
8158 or interrupt handler.  See C.7.1(17).
8159 @end cartouche
8160 @noindent
8161 Protected entries or interrupt handlers can be executed by any
8162 convenient thread, so the value of @code{Current_Task} is undefined.
8164 @sp 1
8165 @cartouche
8166 @noindent
8167 @strong{88}.  The effect of calling @code{Current_Task} from an entry
8168 body or interrupt handler.  See C.7.1(19).
8169 @end cartouche
8170 @noindent
8171 The effect of calling @code{Current_Task} from an entry body or
8172 interrupt handler is to return the identification of the task currently
8173 executing the code.
8175 @sp 1
8176 @cartouche
8177 @noindent
8178 @strong{89}.  Implementation-defined aspects of
8179 @code{Task_Attributes}.  See C.7.2(19).
8180 @end cartouche
8181 @noindent
8182 There are no implementation-defined aspects of @code{Task_Attributes}.
8184 @sp 1
8185 @cartouche
8186 @noindent
8187 @strong{90}.  Values of all @code{Metrics}.  See D(2).
8188 @end cartouche
8189 @noindent
8190 The metrics information for GNAT depends on the performance of the
8191 underlying operating system.  The sources of the run-time for tasking
8192 implementation, together with the output from @code{-gnatG} can be
8193 used to determine the exact sequence of operating systems calls made
8194 to implement various tasking constructs.  Together with appropriate
8195 information on the performance of the underlying operating system,
8196 on the exact target in use, this information can be used to determine
8197 the required metrics.
8199 @sp 1
8200 @cartouche
8201 @noindent
8202 @strong{91}.  The declarations of @code{Any_Priority} and
8203 @code{Priority}.  See D.1(11).
8204 @end cartouche
8205 @noindent
8206 See declarations in file @file{system.ads}.
8208 @sp 1
8209 @cartouche
8210 @noindent
8211 @strong{92}.  Implementation-defined execution resources.  See D.1(15).
8212 @end cartouche
8213 @noindent
8214 There are no implementation-defined execution resources.
8216 @sp 1
8217 @cartouche
8218 @noindent
8219 @strong{93}.  Whether, on a multiprocessor, a task that is waiting for
8220 access to a protected object keeps its processor busy.  See D.2.1(3).
8221 @end cartouche
8222 @noindent
8223 On a multi-processor, a task that is waiting for access to a protected
8224 object does not keep its processor busy.
8226 @sp 1
8227 @cartouche
8228 @noindent
8229 @strong{94}.  The affect of implementation defined execution resources
8230 on task dispatching.  See D.2.1(9).
8231 @end cartouche
8232 @noindent
8233 @c SGI info
8234 @ignore
8235 Tasks map to IRIX threads, and the dispatching policy is as defined by
8236 the IRIX implementation of threads.
8237 @end ignore
8238 Tasks map to threads in the threads package used by GNAT@.  Where possible
8239 and appropriate, these threads correspond to native threads of the
8240 underlying operating system.
8242 @sp 1
8243 @cartouche
8244 @noindent
8245 @strong{95}.  Implementation-defined @code{policy_identifiers} allowed
8246 in a pragma @code{Task_Dispatching_Policy}.  See D.2.2(3).
8247 @end cartouche
8248 @noindent
8249 There are no implementation-defined policy-identifiers allowed in this
8250 pragma.
8252 @sp 1
8253 @cartouche
8254 @noindent
8255 @strong{96}.  Implementation-defined aspects of priority inversion.  See
8256 D.2.2(16).
8257 @end cartouche
8258 @noindent
8259 Execution of a task cannot be preempted by the implementation processing
8260 of delay expirations for lower priority tasks.
8262 @sp 1
8263 @cartouche
8264 @noindent
8265 @strong{97}.  Implementation defined task dispatching.  See D.2.2(18).
8266 @end cartouche
8267 @noindent
8268 @c SGI info:
8269 @ignore
8270 Tasks map to IRIX threads, and the dispatching policy is as defined by
8271 the IRIX implementation of threads.
8272 @end ignore
8273 The policy is the same as that of the underlying threads implementation.
8275 @sp 1
8276 @cartouche
8277 @noindent
8278 @strong{98}.  Implementation-defined @code{policy_identifiers} allowed
8279 in a pragma @code{Locking_Policy}.  See D.3(4).
8280 @end cartouche
8281 @noindent
8282 The only implementation defined policy permitted in GNAT is
8283 @code{Inheritance_Locking}.  On targets that support this policy, locking
8284 is implemented by inheritance, i.e.@: the task owning the lock operates
8285 at a priority equal to the highest priority of any task currently
8286 requesting the lock.
8288 @sp 1
8289 @cartouche
8290 @noindent
8291 @strong{99}.  Default ceiling priorities.  See D.3(10).
8292 @end cartouche
8293 @noindent
8294 The ceiling priority of protected objects of the type
8295 @code{System.Interrupt_Priority'Last} as described in the Ada 95
8296 Reference Manual D.3(10),
8298 @sp 1
8299 @cartouche
8300 @noindent
8301 @strong{100}.  The ceiling of any protected object used internally by
8302 the implementation.  See D.3(16).
8303 @end cartouche
8304 @noindent
8305 The ceiling priority of internal protected objects is
8306 @code{System.Priority'Last}.
8308 @sp 1
8309 @cartouche
8310 @noindent
8311 @strong{101}.  Implementation-defined queuing policies.  See D.4(1).
8312 @end cartouche
8313 @noindent
8314 There are no implementation-defined queuing policies.
8316 @sp 1
8317 @cartouche
8318 @noindent
8319 @strong{102}.  On a multiprocessor, any conditions that cause the
8320 completion of an aborted construct to be delayed later than what is
8321 specified for a single processor.  See D.6(3).
8322 @end cartouche
8323 @noindent
8324 The semantics for abort on a multi-processor is the same as on a single
8325 processor, there are no further delays.
8327 @sp 1
8328 @cartouche
8329 @noindent
8330 @strong{103}.  Any operations that implicitly require heap storage
8331 allocation.  See D.7(8).
8332 @end cartouche
8333 @noindent
8334 The only operation that implicitly requires heap storage allocation is
8335 task creation.
8337 @sp 1
8338 @cartouche
8339 @noindent
8340 @strong{104}.  Implementation-defined aspects of pragma
8341 @code{Restrictions}.  See D.7(20).
8342 @end cartouche
8343 @noindent
8344 There are no such implementation-defined aspects.
8346 @sp 1
8347 @cartouche
8348 @noindent
8349 @strong{105}.  Implementation-defined aspects of package
8350 @code{Real_Time}.  See D.8(17).
8351 @end cartouche
8352 @noindent
8353 There are no implementation defined aspects of package @code{Real_Time}.
8355 @sp 1
8356 @cartouche
8357 @noindent
8358 @strong{106}.  Implementation-defined aspects of
8359 @code{delay_statements}.  See D.9(8).
8360 @end cartouche
8361 @noindent
8362 Any difference greater than one microsecond will cause the task to be
8363 delayed (see D.9(7)).
8365 @sp 1
8366 @cartouche
8367 @noindent
8368 @strong{107}.  The upper bound on the duration of interrupt blocking
8369 caused by the implementation.  See D.12(5).
8370 @end cartouche
8371 @noindent
8372 The upper bound is determined by the underlying operating system.  In
8373 no cases is it more than 10 milliseconds.
8375 @sp 1
8376 @cartouche
8377 @noindent
8378 @strong{108}.  The means for creating and executing distributed
8379 programs.  See E(5).
8380 @end cartouche
8381 @noindent
8382 The GLADE package provides a utility GNATDIST for creating and executing
8383 distributed programs.  See the GLADE reference manual for further details.
8385 @sp 1
8386 @cartouche
8387 @noindent
8388 @strong{109}.  Any events that can result in a partition becoming
8389 inaccessible.  See E.1(7).
8390 @end cartouche
8391 @noindent
8392 See the GLADE reference manual for full details on such events.
8394 @sp 1
8395 @cartouche
8396 @noindent
8397 @strong{110}.  The scheduling policies, treatment of priorities, and
8398 management of shared resources between partitions in certain cases.  See
8399 E.1(11).
8400 @end cartouche
8401 @noindent
8402 See the GLADE reference manual for full details on these aspects of
8403 multi-partition execution.
8405 @sp 1
8406 @cartouche
8407 @noindent
8408 @strong{111}.  Events that cause the version of a compilation unit to
8409 change.  See E.3(5).
8410 @end cartouche
8411 @noindent
8412 Editing the source file of a compilation unit, or the source files of
8413 any units on which it is dependent in a significant way cause the version
8414 to change.  No other actions cause the version number to change.  All changes
8415 are significant except those which affect only layout, capitalization or
8416 comments.
8418 @sp 1
8419 @cartouche
8420 @noindent
8421 @strong{112}.  Whether the execution of the remote subprogram is
8422 immediately aborted as a result of cancellation.  See E.4(13).
8423 @end cartouche
8424 @noindent
8425 See the GLADE reference manual for details on the effect of abort in
8426 a distributed application.
8428 @sp 1
8429 @cartouche
8430 @noindent
8431 @strong{113}.  Implementation-defined aspects of the PCS@.  See E.5(25).
8432 @end cartouche
8433 @noindent
8434 See the GLADE reference manual for a full description of all implementation
8435 defined aspects of the PCS@.
8437 @sp 1
8438 @cartouche
8439 @noindent
8440 @strong{114}.  Implementation-defined interfaces in the PCS@.  See
8441 E.5(26).
8442 @end cartouche
8443 @noindent
8444 See the GLADE reference manual for a full description of all
8445 implementation defined interfaces.
8447 @sp 1
8448 @cartouche
8449 @noindent
8450 @strong{115}.  The values of named numbers in the package
8451 @code{Decimal}.  See F.2(7).
8452 @end cartouche
8453 @noindent
8454 @table @code
8455 @item Max_Scale
8457 @item Min_Scale
8459 @item Min_Delta
8460 1.0E-18
8461 @item Max_Delta
8462 1.0E+18
8463 @item Max_Decimal_Digits
8465 @end table
8467 @sp 1
8468 @cartouche
8469 @noindent
8470 @strong{116}.  The value of @code{Max_Picture_Length} in the package
8471 @code{Text_IO.Editing}.  See F.3.3(16).
8472 @end cartouche
8473 @noindent
8476 @sp 1
8477 @cartouche
8478 @noindent
8479 @strong{117}.  The value of @code{Max_Picture_Length} in the package
8480 @code{Wide_Text_IO.Editing}.  See F.3.4(5).
8481 @end cartouche
8482 @noindent
8485 @sp 1
8486 @cartouche
8487 @noindent
8488 @strong{118}.  The accuracy actually achieved by the complex elementary
8489 functions and by other complex arithmetic operations.  See G.1(1).
8490 @end cartouche
8491 @noindent
8492 Standard library functions are used for the complex arithmetic
8493 operations.  Only fast math mode is currently supported.
8495 @sp 1
8496 @cartouche
8497 @noindent
8498 @strong{119}.  The sign of a zero result (or a component thereof) from
8499 any operator or function in @code{Numerics.Generic_Complex_Types}, when
8500 @code{Real'Signed_Zeros} is True.  See G.1.1(53).
8501 @end cartouche
8502 @noindent
8503 The signs of zero values are as recommended by the relevant
8504 implementation advice.
8506 @sp 1
8507 @cartouche
8508 @noindent
8509 @strong{120}.  The sign of a zero result (or a component thereof) from
8510 any operator or function in
8511 @code{Numerics.Generic_Complex_Elementary_Functions}, when
8512 @code{Real'Signed_Zeros} is @code{True}.  See G.1.2(45).
8513 @end cartouche
8514 @noindent
8515 The signs of zero values are as recommended by the relevant
8516 implementation advice.
8518 @sp 1
8519 @cartouche
8520 @noindent
8521 @strong{121}.  Whether the strict mode or the relaxed mode is the
8522 default.  See G.2(2).
8523 @end cartouche
8524 @noindent
8525 The strict mode is the default.  There is no separate relaxed mode.  GNAT
8526 provides a highly efficient implementation of strict mode.
8528 @sp 1
8529 @cartouche
8530 @noindent
8531 @strong{122}.  The result interval in certain cases of fixed-to-float
8532 conversion.  See G.2.1(10).
8533 @end cartouche
8534 @noindent
8535 For cases where the result interval is implementation dependent, the
8536 accuracy is that provided by performing all operations in 64-bit IEEE
8537 floating-point format.
8539 @sp 1
8540 @cartouche
8541 @noindent
8542 @strong{123}.  The result of a floating point arithmetic operation in
8543 overflow situations, when the @code{Machine_Overflows} attribute of the
8544 result type is @code{False}.  See G.2.1(13).
8545 @end cartouche
8546 @noindent
8547 Infinite and NaN values are produced as dictated by the IEEE
8548 floating-point standard.
8550 Note that on machines that are not fully compliant with the IEEE
8551 floating-point standard, such as Alpha, the @option{-mieee} compiler flag
8552 must be used for achieving IEEE confirming behavior (although at the cost
8553 of a significant performance penalty), so infinite and NaN values are
8554 properly generated.
8556 @sp 1
8557 @cartouche
8558 @noindent
8559 @strong{124}.  The result interval for division (or exponentiation by a
8560 negative exponent), when the floating point hardware implements division
8561 as multiplication by a reciprocal.  See G.2.1(16).
8562 @end cartouche
8563 @noindent
8564 Not relevant, division is IEEE exact.
8566 @sp 1
8567 @cartouche
8568 @noindent
8569 @strong{125}.  The definition of close result set, which determines the
8570 accuracy of certain fixed point multiplications and divisions.  See
8571 G.2.3(5).
8572 @end cartouche
8573 @noindent
8574 Operations in the close result set are performed using IEEE long format
8575 floating-point arithmetic.  The input operands are converted to
8576 floating-point, the operation is done in floating-point, and the result
8577 is converted to the target type.
8579 @sp 1
8580 @cartouche
8581 @noindent
8582 @strong{126}.  Conditions on a @code{universal_real} operand of a fixed
8583 point multiplication or division for which the result shall be in the
8584 perfect result set.  See G.2.3(22).
8585 @end cartouche
8586 @noindent
8587 The result is only defined to be in the perfect result set if the result
8588 can be computed by a single scaling operation involving a scale factor
8589 representable in 64-bits.
8591 @sp 1
8592 @cartouche
8593 @noindent
8594 @strong{127}.  The result of a fixed point arithmetic operation in
8595 overflow situations, when the @code{Machine_Overflows} attribute of the
8596 result type is @code{False}.  See G.2.3(27).
8597 @end cartouche
8598 @noindent
8599 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
8600 types.
8602 @sp 1
8603 @cartouche
8604 @noindent
8605 @strong{128}.  The result of an elementary function reference in
8606 overflow situations, when the @code{Machine_Overflows} attribute of the
8607 result type is @code{False}.  See G.2.4(4).
8608 @end cartouche
8609 @noindent
8610 IEEE infinite and Nan values are produced as appropriate.
8612 @sp 1
8613 @cartouche
8614 @noindent
8615 @strong{129}.  The value of the angle threshold, within which certain
8616 elementary functions, complex arithmetic operations, and complex
8617 elementary functions yield results conforming to a maximum relative
8618 error bound.  See G.2.4(10).
8619 @end cartouche
8620 @noindent
8621 Information on this subject is not yet available.
8623 @sp 1
8624 @cartouche
8625 @noindent
8626 @strong{130}.  The accuracy of certain elementary functions for
8627 parameters beyond the angle threshold.  See G.2.4(10).
8628 @end cartouche
8629 @noindent
8630 Information on this subject is not yet available.
8632 @sp 1
8633 @cartouche
8634 @noindent
8635 @strong{131}.  The result of a complex arithmetic operation or complex
8636 elementary function reference in overflow situations, when the
8637 @code{Machine_Overflows} attribute of the corresponding real type is
8638 @code{False}.  See G.2.6(5).
8639 @end cartouche
8640 @noindent
8641 IEEE infinite and Nan values are produced as appropriate.
8643 @sp 1
8644 @cartouche
8645 @noindent
8646 @strong{132}.  The accuracy of certain complex arithmetic operations and
8647 certain complex elementary functions for parameters (or components
8648 thereof) beyond the angle threshold.  See G.2.6(8).
8649 @end cartouche
8650 @noindent
8651 Information on those subjects is not yet available.
8653 @sp 1
8654 @cartouche
8655 @noindent
8656 @strong{133}.  Information regarding bounded errors and erroneous
8657 execution.  See H.2(1).
8658 @end cartouche
8659 @noindent
8660 Information on this subject is not yet available.
8662 @sp 1
8663 @cartouche
8664 @noindent
8665 @strong{134}.  Implementation-defined aspects of pragma
8666 @code{Inspection_Point}.  See H.3.2(8).
8667 @end cartouche
8668 @noindent
8669 Pragma @code{Inspection_Point} ensures that the variable is live and can
8670 be examined by the debugger at the inspection point.
8672 @sp 1
8673 @cartouche
8674 @noindent
8675 @strong{135}.  Implementation-defined aspects of pragma
8676 @code{Restrictions}.  See H.4(25).
8677 @end cartouche
8678 @noindent
8679 There are no implementation-defined aspects of pragma @code{Restrictions}.  The
8680 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
8681 generated code.  Checks must suppressed by use of pragma @code{Suppress}.
8683 @sp 1
8684 @cartouche
8685 @noindent
8686 @strong{136}.  Any restrictions on pragma @code{Restrictions}.  See
8687 H.4(27).
8688 @end cartouche
8689 @noindent
8690 There are no restrictions on pragma @code{Restrictions}.
8692 @node Intrinsic Subprograms
8693 @chapter Intrinsic Subprograms
8694 @cindex Intrinsic Subprograms
8696 @menu
8697 * Intrinsic Operators::
8698 * Enclosing_Entity::
8699 * Exception_Information::
8700 * Exception_Message::
8701 * Exception_Name::
8702 * File::
8703 * Line::
8704 * Rotate_Left::
8705 * Rotate_Right::
8706 * Shift_Left::
8707 * Shift_Right::
8708 * Shift_Right_Arithmetic::
8709 * Source_Location::
8710 @end menu
8712 @noindent
8713 GNAT allows a user application program to write the declaration:
8715 @smallexample @c ada
8716    pragma Import (Intrinsic, name);
8717 @end smallexample
8719 @noindent
8720 providing that the name corresponds to one of the implemented intrinsic
8721 subprograms in GNAT, and that the parameter profile of the referenced
8722 subprogram meets the requirements.  This chapter describes the set of
8723 implemented intrinsic subprograms, and the requirements on parameter profiles.
8724 Note that no body is supplied; as with other uses of pragma Import, the
8725 body is supplied elsewhere (in this case by the compiler itself).  Note
8726 that any use of this feature is potentially non-portable, since the
8727 Ada standard does not require Ada compilers to implement this feature.
8729 @node Intrinsic Operators
8730 @section Intrinsic Operators
8731 @cindex Intrinsic operator
8733 @noindent
8734 All the predefined numeric operators in package Standard
8735 in @code{pragma Import (Intrinsic,..)}
8736 declarations.  In the binary operator case, the operands must have the same
8737 size.  The operand or operands must also be appropriate for
8738 the operator.  For example, for addition, the operands must
8739 both be floating-point or both be fixed-point, and the
8740 right operand for @code{"**"} must have a root type of
8741 @code{Standard.Integer'Base}.
8742 You can use an intrinsic operator declaration as in the following example:
8744 @smallexample @c ada
8745    type Int1 is new Integer;
8746    type Int2 is new Integer;
8748    function "+" (X1 : Int1; X2 : Int2) return Int1;
8749    function "+" (X1 : Int1; X2 : Int2) return Int2;
8750    pragma Import (Intrinsic, "+");
8751 @end smallexample
8753 @noindent
8754 This declaration would permit ``mixed mode'' arithmetic on items
8755 of the differing types @code{Int1} and @code{Int2}.
8756 It is also possible to specify such operators for private types, if the
8757 full views are appropriate arithmetic types.
8759 @node Enclosing_Entity
8760 @section Enclosing_Entity
8761 @cindex Enclosing_Entity
8762 @noindent
8763 This intrinsic subprogram is used in the implementation of the
8764 library routine @code{GNAT.Source_Info}.  The only useful use of the
8765 intrinsic import in this case is the one in this unit, so an
8766 application program should simply call the function
8767 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
8768 the current subprogram, package, task, entry, or protected subprogram.
8770 @node Exception_Information
8771 @section Exception_Information
8772 @cindex Exception_Information'
8773 @noindent
8774 This intrinsic subprogram is used in the implementation of the
8775 library routine @code{GNAT.Current_Exception}.  The only useful
8776 use of the intrinsic import in this case is the one in this unit,
8777 so an application program should simply call the function
8778 @code{GNAT.Current_Exception.Exception_Information} to obtain
8779 the exception information associated with the current exception.
8781 @node Exception_Message
8782 @section Exception_Message
8783 @cindex Exception_Message
8784 @noindent
8785 This intrinsic subprogram is used in the implementation of the
8786 library routine @code{GNAT.Current_Exception}.  The only useful
8787 use of the intrinsic import in this case is the one in this unit,
8788 so an application program should simply call the function
8789 @code{GNAT.Current_Exception.Exception_Message} to obtain
8790 the message associated with the current exception.
8792 @node Exception_Name
8793 @section Exception_Name
8794 @cindex Exception_Name
8795 @noindent
8796 This intrinsic subprogram is used in the implementation of the
8797 library routine @code{GNAT.Current_Exception}.  The only useful
8798 use of the intrinsic import in this case is the one in this unit,
8799 so an application program should simply call the function
8800 @code{GNAT.Current_Exception.Exception_Name} to obtain
8801 the name of the current exception.
8803 @node File
8804 @section File
8805 @cindex File
8806 @noindent
8807 This intrinsic subprogram is used in the implementation of the
8808 library routine @code{GNAT.Source_Info}.  The only useful use of the
8809 intrinsic import in this case is the one in this unit, so an
8810 application program should simply call the function
8811 @code{GNAT.Source_Info.File} to obtain the name of the current
8812 file.
8814 @node Line
8815 @section Line
8816 @cindex Line
8817 @noindent
8818 This intrinsic subprogram is used in the implementation of the
8819 library routine @code{GNAT.Source_Info}.  The only useful use of the
8820 intrinsic import in this case is the one in this unit, so an
8821 application program should simply call the function
8822 @code{GNAT.Source_Info.Line} to obtain the number of the current
8823 source line.
8825 @node Rotate_Left
8826 @section Rotate_Left
8827 @cindex Rotate_Left
8828 @noindent
8829 In standard Ada 95, the @code{Rotate_Left} function is available only
8830 for the predefined modular types in package @code{Interfaces}.  However, in
8831 GNAT it is possible to define a Rotate_Left function for a user
8832 defined modular type or any signed integer type as in this example:
8834 @smallexample @c ada
8835    function Shift_Left
8836      (Value  : My_Modular_Type;
8837       Amount : Natural)
8838       return   My_Modular_Type;
8839 @end smallexample
8841 @noindent
8842 The requirements are that the profile be exactly as in the example
8843 above.  The only modifications allowed are in the formal parameter
8844 names, and in the type of @code{Value} and the return type, which
8845 must be the same, and must be either a signed integer type, or
8846 a modular integer type with a binary modulus, and the size must
8847 be 8.  16, 32 or 64 bits.
8849 @node Rotate_Right
8850 @section Rotate_Right
8851 @cindex Rotate_Right
8852 @noindent
8853 A @code{Rotate_Right} function can be defined for any user defined
8854 binary modular integer type, or signed integer type, as described
8855 above for @code{Rotate_Left}.
8857 @node Shift_Left
8858 @section Shift_Left
8859 @cindex Shift_Left
8860 @noindent
8861 A @code{Shift_Left} function can be defined for any user defined
8862 binary modular integer type, or signed integer type, as described
8863 above for @code{Rotate_Left}.
8865 @node Shift_Right
8866 @section Shift_Right
8867 @cindex Shift_Right
8868 @noindent
8869 A @code{Shift_Right} function can be defined for any user defined
8870 binary modular integer type, or signed integer type, as described
8871 above for @code{Rotate_Left}.
8873 @node Shift_Right_Arithmetic
8874 @section Shift_Right_Arithmetic
8875 @cindex Shift_Right_Arithmetic
8876 @noindent
8877 A @code{Shift_Right_Arithmetic} function can be defined for any user
8878 defined binary modular integer type, or signed integer type, as described
8879 above for @code{Rotate_Left}.
8881 @node Source_Location
8882 @section Source_Location
8883 @cindex Source_Location
8884 @noindent
8885 This intrinsic subprogram is used in the implementation of the
8886 library routine @code{GNAT.Source_Info}.  The only useful use of the
8887 intrinsic import in this case is the one in this unit, so an
8888 application program should simply call the function
8889 @code{GNAT.Source_Info.Source_Location} to obtain the current
8890 source file location.
8892 @node Representation Clauses and Pragmas
8893 @chapter Representation Clauses and Pragmas
8894 @cindex Representation Clauses
8896 @menu
8897 * Alignment Clauses::
8898 * Size Clauses::
8899 * Storage_Size Clauses::
8900 * Size of Variant Record Objects::
8901 * Biased Representation ::
8902 * Value_Size and Object_Size Clauses::
8903 * Component_Size Clauses::
8904 * Bit_Order Clauses::
8905 * Effect of Bit_Order on Byte Ordering::
8906 * Pragma Pack for Arrays::
8907 * Pragma Pack for Records::
8908 * Record Representation Clauses::
8909 * Enumeration Clauses::
8910 * Address Clauses::
8911 * Effect of Convention on Representation::
8912 * Determining the Representations chosen by GNAT::
8913 @end menu
8915 @noindent
8916 @cindex Representation Clause
8917 @cindex Representation Pragma
8918 @cindex Pragma, representation
8919 This section describes the representation clauses accepted by GNAT, and
8920 their effect on the representation of corresponding data objects.
8922 GNAT fully implements Annex C (Systems Programming).  This means that all
8923 the implementation advice sections in chapter 13 are fully implemented.
8924 However, these sections only require a minimal level of support for
8925 representation clauses.  GNAT provides much more extensive capabilities,
8926 and this section describes the additional capabilities provided.
8928 @node Alignment Clauses
8929 @section Alignment Clauses
8930 @cindex Alignment Clause
8932 @noindent
8933 GNAT requires that all alignment clauses specify a power of 2, and all
8934 default alignments are always a power of 2.  The default alignment
8935 values are as follows:
8937 @itemize @bullet
8938 @item @emph{Primitive Types}.
8939 For primitive types, the alignment is the minimum of the actual size of
8940 objects of the type divided by @code{Storage_Unit},
8941 and the maximum alignment supported by the target.
8942 (This maximum alignment is given by the GNAT-specific attribute
8943 @code{Standard'Maximum_Alignment}; see @ref{Maximum_Alignment}.)
8944 @cindex @code{Maximum_Alignment} attribute
8945 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
8946 default alignment will be 8 on any target that supports alignments
8947 this large, but on some targets, the maximum alignment may be smaller
8948 than 8, in which case objects of type @code{Long_Float} will be maximally
8949 aligned.
8951 @item @emph{Arrays}.
8952 For arrays, the alignment is equal to the alignment of the component type
8953 for the normal case where no packing or component size is given.  If the
8954 array is packed, and the packing is effective (see separate section on
8955 packed arrays), then the alignment will be one for long packed arrays,
8956 or arrays whose length is not known at compile time.  For short packed
8957 arrays, which are handled internally as modular types, the alignment
8958 will be as described for primitive types, e.g.@: a packed array of length
8959 31 bits will have an object size of four bytes, and an alignment of 4.
8961 @item @emph{Records}.
8962 For the normal non-packed case, the alignment of a record is equal to
8963 the maximum alignment of any of its components.  For tagged records, this
8964 includes the implicit access type used for the tag.  If a pragma @code{Pack} is
8965 used and all fields are packable (see separate section on pragma @code{Pack}),
8966 then the resulting alignment is 1.
8968 A special case is when:
8969 @itemize @bullet
8970 @item
8971 the size of the record is given explicitly, or a
8972 full record representation clause is given, and
8973 @item
8974 the size of the record is 2, 4, or 8 bytes.
8975 @end itemize
8976 @noindent
8977 In this case, an alignment is chosen to match the
8978 size of the record. For example, if we have:
8980 @smallexample @c ada
8981    type Small is record
8982       A, B : Character;
8983    end record;
8984    for Small'Size use 16;
8985 @end smallexample
8987 @noindent
8988 then the default alignment of the record type @code{Small} is 2, not 1. This
8989 leads to more efficient code when the record is treated as a unit, and also
8990 allows the type to specified as @code{Atomic} on architectures requiring
8991 strict alignment.
8993 @end itemize
8995 @noindent
8996 An alignment clause may
8997 always specify a larger alignment than the default value, up to some
8998 maximum value dependent on the target (obtainable by using the
8999 attribute reference @code{Standard'Maximum_Alignment}).
9000 The only case where
9001 it is permissible to specify a smaller alignment than the default value
9002 is for a record with a record representation clause.
9003 In this case, packable fields for which a component clause is
9004 given still result in a default alignment corresponding to the original
9005 type, but this may be overridden, since these components in fact only
9006 require an alignment of one byte.  For example, given
9008 @smallexample @c ada
9009   type V is record
9010      A : Integer;
9011   end record;
9013   for V use record
9014      A at 0  range 0 .. 31;
9015   end record;
9017   for V'alignment use 1;
9018 @end smallexample
9020 @noindent
9021 @cindex Alignment, default
9022 The default alignment for the type @code{V} is 4, as a result of the
9023 Integer field in the record, but since this field is placed with a
9024 component clause, it is permissible, as shown, to override the default
9025 alignment of the record with a smaller value.
9027 @node Size Clauses
9028 @section Size Clauses
9029 @cindex Size Clause
9031 @noindent
9032 The default size for a type @code{T} is obtainable through the
9033 language-defined attribute @code{T'Size} and also through the
9034 equivalent GNAT-defined attribute @code{T'Value_Size}.
9035 For objects of type @code{T}, GNAT will generally increase the type size
9036 so that the object size (obtainable through the GNAT-defined attribute
9037 @code{T'Object_Size})
9038 is a multiple of @code{T'Alignment * Storage_Unit}.
9039 For example
9041 @smallexample @c ada
9042    type Smallint is range 1 .. 6;
9044    type Rec is record
9045       Y1 : integer;
9046       Y2 : boolean;
9047    end record;
9048 @end smallexample
9050 @noindent
9051 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
9052 as specified by the RM rules,
9053 but objects of this type will have a size of 8
9054 (@code{Smallint'Object_Size} = 8),
9055 since objects by default occupy an integral number
9056 of storage units.  On some targets, notably older
9057 versions of the Digital Alpha, the size of stand
9058 alone objects of this type may be 32, reflecting
9059 the inability of the hardware to do byte load/stores.
9061 Similarly, the size of type @code{Rec} is 40 bits
9062 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
9063 the alignment is 4, so objects of this type will have
9064 their size increased to 64 bits so that it is a multiple
9065 of the alignment (in bits).  This decision is
9066 in accordance with the specific Implementation Advice in RM 13.3(43):
9068 @quotation
9069 A @code{Size} clause should be supported for an object if the specified
9070 @code{Size} is at least as large as its subtype's @code{Size}, and corresponds
9071 to a size in storage elements that is a multiple of the object's
9072 @code{Alignment} (if the @code{Alignment} is nonzero).
9073 @end quotation
9075 @noindent
9076 An explicit size clause may be used to override the default size by
9077 increasing it.  For example, if we have:
9079 @smallexample @c ada
9080    type My_Boolean is new Boolean;
9081    for My_Boolean'Size use 32;
9082 @end smallexample
9084 @noindent
9085 then values of this type will always be 32 bits long.  In the case of
9086 discrete types, the size can be increased up to 64 bits, with the effect
9087 that the entire specified field is used to hold the value, sign- or
9088 zero-extended as appropriate.  If more than 64 bits is specified, then
9089 padding space is allocated after the value, and a warning is issued that
9090 there are unused bits.
9092 Similarly the size of records and arrays may be increased, and the effect
9093 is to add padding bits after the value.  This also causes a warning message
9094 to be generated.
9096 The largest Size value permitted in GNAT is 2**31@minus{}1.  Since this is a
9097 Size in bits, this corresponds to an object of size 256 megabytes (minus
9098 one).  This limitation is true on all targets.  The reason for this
9099 limitation is that it improves the quality of the code in many cases
9100 if it is known that a Size value can be accommodated in an object of
9101 type Integer.
9103 @node Storage_Size Clauses
9104 @section Storage_Size Clauses
9105 @cindex Storage_Size Clause
9107 @noindent
9108 For tasks, the @code{Storage_Size} clause specifies the amount of space
9109 to be allocated for the task stack.  This cannot be extended, and if the
9110 stack is exhausted, then @code{Storage_Error} will be raised (if stack
9111 checking is enabled).  Use a @code{Storage_Size} attribute definition clause,
9112 or a @code{Storage_Size} pragma in the task definition to set the
9113 appropriate required size.  A useful technique is to include in every
9114 task definition a pragma of the form:
9116 @smallexample @c ada
9117    pragma Storage_Size (Default_Stack_Size);
9118 @end smallexample
9120 @noindent
9121 Then @code{Default_Stack_Size} can be defined in a global package, and
9122 modified as required. Any tasks requiring stack sizes different from the
9123 default can have an appropriate alternative reference in the pragma.
9125 You can also use the @code{-d} binder switch to modify the default stack
9126 size.
9128 For access types, the @code{Storage_Size} clause specifies the maximum
9129 space available for allocation of objects of the type.  If this space is
9130 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
9131 In the case where the access type is declared local to a subprogram, the
9132 use of a @code{Storage_Size} clause triggers automatic use of a special
9133 predefined storage pool (@code{System.Pool_Size}) that ensures that all
9134 space for the pool is automatically reclaimed on exit from the scope in
9135 which the type is declared.
9137 A special case recognized by the compiler is the specification of a
9138 @code{Storage_Size} of zero for an access type.  This means that no
9139 items can be allocated from the pool, and this is recognized at compile
9140 time, and all the overhead normally associated with maintaining a fixed
9141 size storage pool is eliminated.  Consider the following example:
9143 @smallexample @c ada
9144    procedure p is
9145       type R is array (Natural) of Character;
9146       type P is access all R;
9147       for P'Storage_Size use 0;
9148       --  Above access type intended only for interfacing purposes
9150       y : P;
9152       procedure g (m : P);
9153       pragma Import (C, g);
9155       --  @dots{}
9157    begin
9158       --  @dots{}
9159       y := new R;
9160    end;
9161 @end smallexample
9163 @noindent
9164 As indicated in this example, these dummy storage pools are often useful in
9165 connection with interfacing where no object will ever be allocated.  If you
9166 compile the above example, you get the warning:
9168 @smallexample
9169    p.adb:16:09: warning: allocation from empty storage pool
9170    p.adb:16:09: warning: Storage_Error will be raised at run time
9171 @end smallexample
9173 @noindent
9174 Of course in practice, there will not be any explicit allocators in the
9175 case of such an access declaration.
9177 @node Size of Variant Record Objects
9178 @section Size of Variant Record Objects
9179 @cindex Size, variant record objects
9180 @cindex Variant record objects, size
9182 @noindent
9183 In the case of variant record objects, there is a question whether Size gives
9184 information about a particular variant, or the maximum size required
9185 for any variant.  Consider the following program
9187 @smallexample @c ada
9188 with Text_IO; use Text_IO;
9189 procedure q is
9190    type R1 (A : Boolean := False) is record
9191      case A is
9192        when True  => X : Character;
9193        when False => null;
9194      end case;
9195    end record;
9197    V1 : R1 (False);
9198    V2 : R1;
9200 begin
9201    Put_Line (Integer'Image (V1'Size));
9202    Put_Line (Integer'Image (V2'Size));
9203 end q;
9204 @end smallexample
9206 @noindent
9207 Here we are dealing with a variant record, where the True variant
9208 requires 16 bits, and the False variant requires 8 bits.
9209 In the above example, both V1 and V2 contain the False variant,
9210 which is only 8 bits long.  However, the result of running the
9211 program is:
9213 @smallexample
9216 @end smallexample
9218 @noindent
9219 The reason for the difference here is that the discriminant value of
9220 V1 is fixed, and will always be False.  It is not possible to assign
9221 a True variant value to V1, therefore 8 bits is sufficient.  On the
9222 other hand, in the case of V2, the initial discriminant value is
9223 False (from the default), but it is possible to assign a True
9224 variant value to V2, therefore 16 bits must be allocated for V2
9225 in the general case, even fewer bits may be needed at any particular
9226 point during the program execution.
9228 As can be seen from the output of this program, the @code{'Size}
9229 attribute applied to such an object in GNAT gives the actual allocated
9230 size of the variable, which is the largest size of any of the variants.
9231 The Ada Reference Manual is not completely clear on what choice should
9232 be made here, but the GNAT behavior seems most consistent with the
9233 language in the RM@.
9235 In some cases, it may be desirable to obtain the size of the current
9236 variant, rather than the size of the largest variant.  This can be
9237 achieved in GNAT by making use of the fact that in the case of a
9238 subprogram parameter, GNAT does indeed return the size of the current
9239 variant (because a subprogram has no way of knowing how much space
9240 is actually allocated for the actual).
9242 Consider the following modified version of the above program:
9244 @smallexample @c ada
9245 with Text_IO; use Text_IO;
9246 procedure q is
9247    type R1 (A : Boolean := False) is record
9248      case A is
9249        when True  => X : Character;
9250        when False => null;
9251      end case;
9252    end record;
9254    V2 : R1;
9256    function Size (V : R1) return Integer is
9257    begin
9258       return V'Size;
9259    end Size;
9261 begin
9262    Put_Line (Integer'Image (V2'Size));
9263    Put_Line (Integer'IMage (Size (V2)));
9264    V2 := (True, 'x');
9265    Put_Line (Integer'Image (V2'Size));
9266    Put_Line (Integer'IMage (Size (V2)));
9267 end q;
9268 @end smallexample
9270 @noindent
9271 The output from this program is
9273 @smallexample
9278 @end smallexample
9280 @noindent
9281 Here we see that while the @code{'Size} attribute always returns
9282 the maximum size, regardless of the current variant value, the
9283 @code{Size} function does indeed return the size of the current
9284 variant value.
9286 @node Biased Representation
9287 @section Biased Representation
9288 @cindex Size for biased representation
9289 @cindex Biased representation
9291 @noindent
9292 In the case of scalars with a range starting at other than zero, it is
9293 possible in some cases to specify a size smaller than the default minimum
9294 value, and in such cases, GNAT uses an unsigned biased representation,
9295 in which zero is used to represent the lower bound, and successive values
9296 represent successive values of the type.
9298 For example, suppose we have the declaration:
9300 @smallexample @c ada
9301    type Small is range -7 .. -4;
9302    for Small'Size use 2;
9303 @end smallexample
9305 @noindent
9306 Although the default size of type @code{Small} is 4, the @code{Size}
9307 clause is accepted by GNAT and results in the following representation
9308 scheme:
9310 @smallexample
9311   -7 is represented as 2#00#
9312   -6 is represented as 2#01#
9313   -5 is represented as 2#10#
9314   -4 is represented as 2#11#
9315 @end smallexample
9317 @noindent
9318 Biased representation is only used if the specified @code{Size} clause
9319 cannot be accepted in any other manner.  These reduced sizes that force
9320 biased representation can be used for all discrete types except for
9321 enumeration types for which a representation clause is given.
9323 @node Value_Size and Object_Size Clauses
9324 @section Value_Size and Object_Size Clauses
9325 @findex Value_Size
9326 @findex Object_Size
9327 @cindex Size, of objects
9329 @noindent
9330 In Ada 95, @code{T'Size} for a type @code{T} is the minimum number of bits
9331 required to hold values of type @code{T}.  Although this interpretation was
9332 allowed in Ada 83, it was not required, and this requirement in practice
9333 can cause some significant difficulties.  For example, in most Ada 83
9334 compilers, @code{Natural'Size} was 32.  However, in Ada 95,
9335 @code{Natural'Size} is
9336 typically 31.  This means that code may change in behavior when moving
9337 from Ada 83 to Ada 95.  For example, consider:
9339 @smallexample @c ada
9340    type Rec is record;
9341       A : Natural;
9342       B : Natural;
9343    end record;
9345    for Rec use record
9346       at 0  range 0 .. Natural'Size - 1;
9347       at 0  range Natural'Size .. 2 * Natural'Size - 1;
9348    end record;
9349 @end smallexample
9351 @noindent
9352 In the above code, since the typical size of @code{Natural} objects
9353 is 32 bits and @code{Natural'Size} is 31, the above code can cause
9354 unexpected inefficient packing in Ada 95, and in general there are
9355 cases where the fact that the object size can exceed the
9356 size of the type causes surprises.
9358 To help get around this problem GNAT provides two implementation
9359 defined attributes, @code{Value_Size} and @code{Object_Size}.  When
9360 applied to a type, these attributes yield the size of the type
9361 (corresponding to the RM defined size attribute), and the size of
9362 objects of the type respectively.
9364 The @code{Object_Size} is used for determining the default size of
9365 objects and components.  This size value can be referred to using the
9366 @code{Object_Size} attribute.  The phrase ``is used'' here means that it is
9367 the basis of the determination of the size.  The backend is free to
9368 pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
9369 character might be stored in 32 bits on a machine with no efficient
9370 byte access instructions such as the Alpha.
9372 The default rules for the value of @code{Object_Size} for
9373 discrete types are as follows:
9375 @itemize @bullet
9376 @item
9377 The @code{Object_Size} for base subtypes reflect the natural hardware
9378 size in bits (run the compiler with @option{-gnatS} to find those values
9379 for numeric types). Enumeration types and fixed-point base subtypes have
9380 8, 16, 32 or 64 bits for this size, depending on the range of values
9381 to be stored.
9383 @item
9384 The @code{Object_Size} of a subtype is the same as the
9385 @code{Object_Size} of
9386 the type from which it is obtained.
9388 @item
9389 The @code{Object_Size} of a derived base type is copied from the parent
9390 base type, and the @code{Object_Size} of a derived first subtype is copied
9391 from the parent first subtype.
9392 @end itemize
9394 @noindent
9395 The @code{Value_Size} attribute
9396 is the (minimum) number of bits required to store a value
9397 of the type.
9398 This value is used to determine how tightly to pack
9399 records or arrays with components of this type, and also affects
9400 the semantics of unchecked conversion (unchecked conversions where
9401 the @code{Value_Size} values differ generate a warning, and are potentially
9402 target dependent).
9404 The default rules for the value of @code{Value_Size} are as follows:
9406 @itemize @bullet
9407 @item
9408 The @code{Value_Size} for a base subtype is the minimum number of bits
9409 required to store all values of the type (including the sign bit
9410 only if negative values are possible).
9412 @item
9413 If a subtype statically matches the first subtype of a given type, then it has
9414 by default the same @code{Value_Size} as the first subtype.  This is a
9415 consequence of RM 13.1(14) (``if two subtypes statically match,
9416 then their subtype-specific aspects are the same''.)
9418 @item
9419 All other subtypes have a @code{Value_Size} corresponding to the minimum
9420 number of bits required to store all values of the subtype.  For
9421 dynamic bounds, it is assumed that the value can range down or up
9422 to the corresponding bound of the ancestor
9423 @end itemize
9425 @noindent
9426 The RM defined attribute @code{Size} corresponds to the
9427 @code{Value_Size} attribute.
9429 The @code{Size} attribute may be defined for a first-named subtype.  This sets
9430 the @code{Value_Size} of
9431 the first-named subtype to the given value, and the
9432 @code{Object_Size} of this first-named subtype to the given value padded up
9433 to an appropriate boundary.  It is a consequence of the default rules
9434 above that this @code{Object_Size} will apply to all further subtypes.  On the
9435 other hand, @code{Value_Size} is affected only for the first subtype, any
9436 dynamic subtypes obtained from it directly, and any statically matching
9437 subtypes.  The @code{Value_Size} of any other static subtypes is not affected.
9439 @code{Value_Size} and
9440 @code{Object_Size} may be explicitly set for any subtype using
9441 an attribute definition clause.  Note that the use of these attributes
9442 can cause the RM 13.1(14) rule to be violated.  If two access types
9443 reference aliased objects whose subtypes have differing @code{Object_Size}
9444 values as a result of explicit attribute definition clauses, then it
9445 is erroneous to convert from one access subtype to the other.
9447 At the implementation level, Esize stores the Object_Size and the
9448 RM_Size field stores the @code{Value_Size} (and hence the value of the
9449 @code{Size} attribute,
9450 which, as noted above, is equivalent to @code{Value_Size}).
9452 To get a feel for the difference, consider the following examples (note
9453 that in each case the base is @code{Short_Short_Integer} with a size of 8):
9455 @smallexample
9456                                        Object_Size     Value_Size
9458 type x1 is range 0 .. 5;                    8               3
9460 type x2 is range 0 .. 5;
9461 for x2'size use 12;                        16              12
9463 subtype x3 is x2 range 0 .. 3;             16               2
9465 subtype x4 is x2'base range 0 .. 10;        8               4
9467 subtype x5 is x2 range 0 .. dynamic;       16               3*
9469 subtype x6 is x2'base range 0 .. dynamic;   8               3*
9471 @end smallexample
9473 @noindent
9474 Note: the entries marked ``3*'' are not actually specified by the Ada 95 RM,
9475 but it seems in the spirit of the RM rules to allocate the minimum number
9476 of bits (here 3, given the range for @code{x2})
9477 known to be large enough to hold the given range of values.
9479 So far, so good, but GNAT has to obey the RM rules, so the question is
9480 under what conditions must the RM @code{Size} be used.
9481 The following is a list
9482 of the occasions on which the RM @code{Size} must be used:
9484 @itemize @bullet
9485 @item
9486 Component size for packed arrays or records
9488 @item
9489 Value of the attribute @code{Size} for a type
9491 @item
9492 Warning about sizes not matching for unchecked conversion
9493 @end itemize
9495 @noindent
9496 For record types, the @code{Object_Size} is always a multiple of the
9497 alignment of the type (this is true for all types). In some cases the
9498 @code{Value_Size} can be smaller. Consider:
9500 @smallexample
9501    type R is record
9502      X : Integer;
9503      Y : Character;
9504    end record;
9505 @end smallexample
9507 @noindent
9508 On a typical 32-bit architecture, the X component will be four bytes, and
9509 require four-byte alignment, and the Y component will be one byte. In this
9510 case @code{R'Value_Size} will be 40 (bits) since this is the minimum size
9511 required to store a value of this type, and for example, it is permissible
9512 to have a component of type R in an outer record whose component size is
9513 specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits),
9514 since it must be rounded up so that this value is a multiple of the
9515 alignment (4 bytes = 32 bits).
9517 @noindent
9518 For all other types, the @code{Object_Size}
9519 and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
9520 Only @code{Size} may be specified for such types.
9522 @node Component_Size Clauses
9523 @section Component_Size Clauses
9524 @cindex Component_Size Clause
9526 @noindent
9527 Normally, the value specified in a component size clause must be consistent
9528 with the subtype of the array component with regard to size and alignment.
9529 In other words, the value specified must be at least equal to the size
9530 of this subtype, and must be a multiple of the alignment value.
9532 In addition, component size clauses are allowed which cause the array
9533 to be packed, by specifying a smaller value.  The cases in which this
9534 is allowed are for component size values in the range 1 through 63.  The value
9535 specified must not be smaller than the Size of the subtype.  GNAT will
9536 accurately honor all packing requests in this range.  For example, if
9537 we have:
9539 @smallexample @c ada
9540 type r is array (1 .. 8) of Natural;
9541 for r'Component_Size use 31;
9542 @end smallexample
9544 @noindent
9545 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
9546 Of course access to the components of such an array is considerably
9547 less efficient than if the natural component size of 32 is used.
9549 Note that there is no point in giving both a component size clause
9550 and a pragma Pack for the same array type. if such duplicate
9551 clauses are given, the pragma Pack will be ignored.
9553 @node Bit_Order Clauses
9554 @section Bit_Order Clauses
9555 @cindex Bit_Order Clause
9556 @cindex bit ordering
9557 @cindex ordering, of bits
9559 @noindent
9560 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
9561 attribute.  The specification may either correspond to the default bit
9562 order for the target, in which case the specification has no effect and
9563 places no additional restrictions, or it may be for the non-standard
9564 setting (that is the opposite of the default).
9566 In the case where the non-standard value is specified, the effect is
9567 to renumber bits within each byte, but the ordering of bytes is not
9568 affected.  There are certain
9569 restrictions placed on component clauses as follows:
9571 @itemize @bullet
9573 @item Components fitting within a single storage unit.
9574 @noindent
9575 These are unrestricted, and the effect is merely to renumber bits.  For
9576 example if we are on a little-endian machine with @code{Low_Order_First}
9577 being the default, then the following two declarations have exactly
9578 the same effect:
9580 @smallexample @c ada
9581    type R1 is record
9582       A : Boolean;
9583       B : Integer range 1 .. 120;
9584    end record;
9586    for R1 use record
9587       A at 0 range 0 .. 0;
9588       B at 0 range 1 .. 7;
9589    end record;
9591    type R2 is record
9592       A : Boolean;
9593       B : Integer range 1 .. 120;
9594    end record;
9596    for R2'Bit_Order use High_Order_First;
9598    for R2 use record
9599       A at 0 range 7 .. 7;
9600       B at 0 range 0 .. 6;
9601    end record;
9602 @end smallexample
9604 @noindent
9605 The useful application here is to write the second declaration with the
9606 @code{Bit_Order} attribute definition clause, and know that it will be treated
9607 the same, regardless of whether the target is little-endian or big-endian.
9609 @item Components occupying an integral number of bytes.
9610 @noindent
9611 These are components that exactly fit in two or more bytes.  Such component
9612 declarations are allowed, but have no effect, since it is important to realize
9613 that the @code{Bit_Order} specification does not affect the ordering of bytes.
9614 In particular, the following attempt at getting an endian-independent integer
9615 does not work:
9617 @smallexample @c ada
9618    type R2 is record
9619       A : Integer;
9620    end record;
9622    for R2'Bit_Order use High_Order_First;
9624    for R2 use record
9625       A at 0 range 0 .. 31;
9626    end record;
9627 @end smallexample
9629 @noindent
9630 This declaration will result in a little-endian integer on a
9631 little-endian machine, and a big-endian integer on a big-endian machine.
9632 If byte flipping is required for interoperability between big- and
9633 little-endian machines, this must be explicitly programmed.  This capability
9634 is not provided by @code{Bit_Order}.
9636 @item Components that are positioned across byte boundaries
9637 @noindent
9638 but do not occupy an integral number of bytes.  Given that bytes are not
9639 reordered, such fields would occupy a non-contiguous sequence of bits
9640 in memory, requiring non-trivial code to reassemble.  They are for this
9641 reason not permitted, and any component clause specifying such a layout
9642 will be flagged as illegal by GNAT@.
9644 @end itemize
9646 @noindent
9647 Since the misconception that Bit_Order automatically deals with all
9648 endian-related incompatibilities is a common one, the specification of
9649 a component field that is an integral number of bytes will always
9650 generate a warning.  This warning may be suppressed using
9651 @code{pragma Suppress} if desired.  The following section contains additional
9652 details regarding the issue of byte ordering.
9654 @node Effect of Bit_Order on Byte Ordering
9655 @section Effect of Bit_Order on Byte Ordering
9656 @cindex byte ordering
9657 @cindex ordering, of bytes
9659 @noindent
9660 In this section we will review the effect of the @code{Bit_Order} attribute
9661 definition clause on byte ordering.  Briefly, it has no effect at all, but
9662 a detailed example will be helpful.  Before giving this
9663 example, let us review the precise
9664 definition of the effect of defining @code{Bit_Order}.  The effect of a
9665 non-standard bit order is described in section 15.5.3 of the Ada
9666 Reference Manual:
9668 @quotation
9669 2   A bit ordering is a method of interpreting the meaning of
9670 the storage place attributes.
9671 @end quotation
9673 @noindent
9674 To understand the precise definition of storage place attributes in
9675 this context, we visit section 13.5.1 of the manual:
9677 @quotation
9678 13   A record_representation_clause (without the mod_clause)
9679 specifies the layout.  The storage place attributes (see 13.5.2)
9680 are taken from the values of the position, first_bit, and last_bit
9681 expressions after normalizing those values so that first_bit is
9682 less than Storage_Unit.
9683 @end quotation
9685 @noindent
9686 The critical point here is that storage places are taken from
9687 the values after normalization, not before.  So the @code{Bit_Order}
9688 interpretation applies to normalized values.  The interpretation
9689 is described in the later part of the 15.5.3 paragraph:
9691 @quotation
9692 2   A bit ordering is a method of interpreting the meaning of
9693 the storage place attributes.  High_Order_First (known in the
9694 vernacular as ``big endian'') means that the first bit of a
9695 storage element (bit 0) is the most significant bit (interpreting
9696 the sequence of bits that represent a component as an unsigned
9697 integer value).  Low_Order_First (known in the vernacular as
9698 ``little endian'') means the opposite: the first bit is the
9699 least significant.
9700 @end quotation
9702 @noindent
9703 Note that the numbering is with respect to the bits of a storage
9704 unit.  In other words, the specification affects only the numbering
9705 of bits within a single storage unit.
9707 We can make the effect clearer by giving an example.
9709 Suppose that we have an external device which presents two bytes, the first
9710 byte presented, which is the first (low addressed byte) of the two byte
9711 record is called Master, and the second byte is called Slave.
9713 The left most (most significant bit is called Control for each byte, and
9714 the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
9715 (least significant) bit.
9717 On a big-endian machine, we can write the following representation clause
9719 @smallexample @c ada
9720    type Data is record
9721       Master_Control : Bit;
9722       Master_V1      : Bit;
9723       Master_V2      : Bit;
9724       Master_V3      : Bit;
9725       Master_V4      : Bit;
9726       Master_V5      : Bit;
9727       Master_V6      : Bit;
9728       Master_V7      : Bit;
9729       Slave_Control  : Bit;
9730       Slave_V1       : Bit;
9731       Slave_V2       : Bit;
9732       Slave_V3       : Bit;
9733       Slave_V4       : Bit;
9734       Slave_V5       : Bit;
9735       Slave_V6       : Bit;
9736       Slave_V7       : Bit;
9737    end record;
9739    for Data use record
9740       Master_Control at 0 range 0 .. 0;
9741       Master_V1      at 0 range 1 .. 1;
9742       Master_V2      at 0 range 2 .. 2;
9743       Master_V3      at 0 range 3 .. 3;
9744       Master_V4      at 0 range 4 .. 4;
9745       Master_V5      at 0 range 5 .. 5;
9746       Master_V6      at 0 range 6 .. 6;
9747       Master_V7      at 0 range 7 .. 7;
9748       Slave_Control  at 1 range 0 .. 0;
9749       Slave_V1       at 1 range 1 .. 1;
9750       Slave_V2       at 1 range 2 .. 2;
9751       Slave_V3       at 1 range 3 .. 3;
9752       Slave_V4       at 1 range 4 .. 4;
9753       Slave_V5       at 1 range 5 .. 5;
9754       Slave_V6       at 1 range 6 .. 6;
9755       Slave_V7       at 1 range 7 .. 7;
9756    end record;
9757 @end smallexample
9759 @noindent
9760 Now if we move this to a little endian machine, then the bit ordering within
9761 the byte is backwards, so we have to rewrite the record rep clause as:
9763 @smallexample @c ada
9764    for Data use record
9765       Master_Control at 0 range 7 .. 7;
9766       Master_V1      at 0 range 6 .. 6;
9767       Master_V2      at 0 range 5 .. 5;
9768       Master_V3      at 0 range 4 .. 4;
9769       Master_V4      at 0 range 3 .. 3;
9770       Master_V5      at 0 range 2 .. 2;
9771       Master_V6      at 0 range 1 .. 1;
9772       Master_V7      at 0 range 0 .. 0;
9773       Slave_Control  at 1 range 7 .. 7;
9774       Slave_V1       at 1 range 6 .. 6;
9775       Slave_V2       at 1 range 5 .. 5;
9776       Slave_V3       at 1 range 4 .. 4;
9777       Slave_V4       at 1 range 3 .. 3;
9778       Slave_V5       at 1 range 2 .. 2;
9779       Slave_V6       at 1 range 1 .. 1;
9780       Slave_V7       at 1 range 0 .. 0;
9781    end record;
9782 @end smallexample
9784 @noindent
9785 It is a nuisance to have to rewrite the clause, especially if
9786 the code has to be maintained on both machines.  However,
9787 this is a case that we can handle with the
9788 @code{Bit_Order} attribute if it is implemented.
9789 Note that the implementation is not required on byte addressed
9790 machines, but it is indeed implemented in GNAT.
9791 This means that we can simply use the
9792 first record clause, together with the declaration
9794 @smallexample @c ada
9795    for Data'Bit_Order use High_Order_First;
9796 @end smallexample
9798 @noindent
9799 and the effect is what is desired, namely the layout is exactly the same,
9800 independent of whether the code is compiled on a big-endian or little-endian
9801 machine.
9803 The important point to understand is that byte ordering is not affected.
9804 A @code{Bit_Order} attribute definition never affects which byte a field
9805 ends up in, only where it ends up in that byte.
9806 To make this clear, let us rewrite the record rep clause of the previous
9807 example as:
9809 @smallexample @c ada
9810    for Data'Bit_Order use High_Order_First;
9811    for Data use record
9812       Master_Control at 0 range  0 .. 0;
9813       Master_V1      at 0 range  1 .. 1;
9814       Master_V2      at 0 range  2 .. 2;
9815       Master_V3      at 0 range  3 .. 3;
9816       Master_V4      at 0 range  4 .. 4;
9817       Master_V5      at 0 range  5 .. 5;
9818       Master_V6      at 0 range  6 .. 6;
9819       Master_V7      at 0 range  7 .. 7;
9820       Slave_Control  at 0 range  8 .. 8;
9821       Slave_V1       at 0 range  9 .. 9;
9822       Slave_V2       at 0 range 10 .. 10;
9823       Slave_V3       at 0 range 11 .. 11;
9824       Slave_V4       at 0 range 12 .. 12;
9825       Slave_V5       at 0 range 13 .. 13;
9826       Slave_V6       at 0 range 14 .. 14;
9827       Slave_V7       at 0 range 15 .. 15;
9828    end record;
9829 @end smallexample
9831 @noindent
9832 This is exactly equivalent to saying (a repeat of the first example):
9834 @smallexample @c ada
9835    for Data'Bit_Order use High_Order_First;
9836    for Data use record
9837       Master_Control at 0 range 0 .. 0;
9838       Master_V1      at 0 range 1 .. 1;
9839       Master_V2      at 0 range 2 .. 2;
9840       Master_V3      at 0 range 3 .. 3;
9841       Master_V4      at 0 range 4 .. 4;
9842       Master_V5      at 0 range 5 .. 5;
9843       Master_V6      at 0 range 6 .. 6;
9844       Master_V7      at 0 range 7 .. 7;
9845       Slave_Control  at 1 range 0 .. 0;
9846       Slave_V1       at 1 range 1 .. 1;
9847       Slave_V2       at 1 range 2 .. 2;
9848       Slave_V3       at 1 range 3 .. 3;
9849       Slave_V4       at 1 range 4 .. 4;
9850       Slave_V5       at 1 range 5 .. 5;
9851       Slave_V6       at 1 range 6 .. 6;
9852       Slave_V7       at 1 range 7 .. 7;
9853    end record;
9854 @end smallexample
9856 @noindent
9857 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
9858 field.  The storage place attributes are obtained by normalizing the
9859 values given so that the @code{First_Bit} value is less than 8.  After
9860 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
9861 we specified in the other case.
9863 Now one might expect that the @code{Bit_Order} attribute might affect
9864 bit numbering within the entire record component (two bytes in this
9865 case, thus affecting which byte fields end up in), but that is not
9866 the way this feature is defined, it only affects numbering of bits,
9867 not which byte they end up in.
9869 Consequently it never makes sense to specify a starting bit number
9870 greater than 7 (for a byte addressable field) if an attribute
9871 definition for @code{Bit_Order} has been given, and indeed it
9872 may be actively confusing to specify such a value, so the compiler
9873 generates a warning for such usage.
9875 If you do need to control byte ordering then appropriate conditional
9876 values must be used.  If in our example, the slave byte came first on
9877 some machines we might write:
9879 @smallexample @c ada
9880    Master_Byte_First constant Boolean := @dots{};
9882    Master_Byte : constant Natural :=
9883                    1 - Boolean'Pos (Master_Byte_First);
9884    Slave_Byte  : constant Natural :=
9885                    Boolean'Pos (Master_Byte_First);
9887    for Data'Bit_Order use High_Order_First;
9888    for Data use record
9889       Master_Control at Master_Byte range 0 .. 0;
9890       Master_V1      at Master_Byte range 1 .. 1;
9891       Master_V2      at Master_Byte range 2 .. 2;
9892       Master_V3      at Master_Byte range 3 .. 3;
9893       Master_V4      at Master_Byte range 4 .. 4;
9894       Master_V5      at Master_Byte range 5 .. 5;
9895       Master_V6      at Master_Byte range 6 .. 6;
9896       Master_V7      at Master_Byte range 7 .. 7;
9897       Slave_Control  at Slave_Byte  range 0 .. 0;
9898       Slave_V1       at Slave_Byte  range 1 .. 1;
9899       Slave_V2       at Slave_Byte  range 2 .. 2;
9900       Slave_V3       at Slave_Byte  range 3 .. 3;
9901       Slave_V4       at Slave_Byte  range 4 .. 4;
9902       Slave_V5       at Slave_Byte  range 5 .. 5;
9903       Slave_V6       at Slave_Byte  range 6 .. 6;
9904       Slave_V7       at Slave_Byte  range 7 .. 7;
9905    end record;
9906 @end smallexample
9908 @noindent
9909 Now to switch between machines, all that is necessary is
9910 to set the boolean constant @code{Master_Byte_First} in
9911 an appropriate manner.
9913 @node Pragma Pack for Arrays
9914 @section Pragma Pack for Arrays
9915 @cindex Pragma Pack (for arrays)
9917 @noindent
9918 Pragma @code{Pack} applied to an array has no effect unless the component type
9919 is packable.  For a component type to be packable, it must be one of the
9920 following cases:
9922 @itemize @bullet
9923 @item
9924 Any scalar type
9925 @item
9926 Any type whose size is specified with a size clause
9927 @item
9928 Any packed array type with a static size
9929 @end itemize
9931 @noindent
9932 For all these cases, if the component subtype size is in the range
9933 1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
9934 component size were specified giving the component subtype size.
9935 For example if we have:
9937 @smallexample @c ada
9938    type r is range 0 .. 17;
9940    type ar is array (1 .. 8) of r;
9941    pragma Pack (ar);
9942 @end smallexample
9944 @noindent
9945 Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
9946 and the size of the array @code{ar} will be exactly 40 bits.
9948 Note that in some cases this rather fierce approach to packing can produce
9949 unexpected effects.  For example, in Ada 95, type Natural typically has a
9950 size of 31, meaning that if you pack an array of Natural, you get 31-bit
9951 close packing, which saves a few bits, but results in far less efficient
9952 access.  Since many other Ada compilers will ignore such a packing request,
9953 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
9954 might not be what is intended.  You can easily remove this warning by
9955 using an explicit @code{Component_Size} setting instead, which never generates
9956 a warning, since the intention of the programmer is clear in this case.
9958 GNAT treats packed arrays in one of two ways.  If the size of the array is
9959 known at compile time and is less than 64 bits, then internally the array
9960 is represented as a single modular type, of exactly the appropriate number
9961 of bits.  If the length is greater than 63 bits, or is not known at compile
9962 time, then the packed array is represented as an array of bytes, and the
9963 length is always a multiple of 8 bits.
9965 Note that to represent a packed array as a modular type, the alignment must
9966 be suitable for the modular type involved. For example, on typical machines
9967 a 32-bit packed array will be represented by a 32-bit modular integer with
9968 an alignment of four bytes. If you explicitly override the default alignment
9969 with an alignment clause that is too small, the modular representation
9970 cannot be used. For example, consider the following set of declarations:
9972 @smallexample @c ada
9973    type R is range 1 .. 3;
9974    type S is array (1 .. 31) of R;
9975    for S'Component_Size use 2;
9976    for S'Size use 62;
9977    for S'Alignment use 1;
9978 @end smallexample
9980 @noindent
9981 If the alignment clause were not present, then a 62-bit modular
9982 representation would be chosen (typically with an alignment of 4 or 8
9983 bytes depending on the target). But the default alignment is overridden
9984 with the explicit alignment clause. This means that the modular
9985 representation cannot be used, and instead the array of bytes
9986 representation must be used, meaning that the length must be a multiple
9987 of 8. Thus the above set of declarations will result in a diagnostic
9988 rejecting the size clause and noting that the minimum size allowed is 64.
9990 @cindex Pragma Pack (for type Natural)
9991 @cindex Pragma Pack warning
9993 One special case that is worth noting occurs when the base type of the
9994 component size is 8/16/32 and the subtype is one bit less. Notably this
9995 occurs with subtype @code{Natural}. Consider:
9997 @smallexample @c ada
9998    type Arr is array (1 .. 32) of Natural;
9999    pragma Pack (Arr);
10000 @end smallexample
10002 @noindent
10003 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
10004 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
10005 Ada 83 compilers did not attempt 31 bit packing.
10007 In Ada 95, @code{Natural'Size} is required to be 31. Furthermore, GNAT really
10008 does pack 31-bit subtype to 31 bits. This may result in a substantial
10009 unintended performance penalty when porting legacy Ada 83 code. To help
10010 prevent this, GNAT generates a warning in such cases. If you really want 31
10011 bit packing in a case like this, you can set the component size explicitly:
10013 @smallexample @c ada
10014    type Arr is array (1 .. 32) of Natural;
10015    for Arr'Component_Size use 31;
10016 @end smallexample
10018 @noindent
10019 Here 31-bit packing is achieved as required, and no warning is generated,
10020 since in this case the programmer intention is clear.
10022 @node Pragma Pack for Records
10023 @section Pragma Pack for Records
10024 @cindex Pragma Pack (for records)
10026 @noindent
10027 Pragma @code{Pack} applied to a record will pack the components to reduce
10028 wasted space from alignment gaps and by reducing the amount of space
10029 taken by components.  We distinguish between @emph{packable} components and
10030 @emph{non-packable} components.
10031 Components of the following types are considered packable:
10032 @itemize @bullet
10033 @item
10034 All primitive types are packable.
10036 @item
10037 Small packed arrays, whose size does not exceed 64 bits, and where the
10038 size is statically known at compile time, are represented internally
10039 as modular integers, and so they are also packable.
10041 @end itemize
10043 @noindent
10044 All packable components occupy the exact number of bits corresponding to
10045 their @code{Size} value, and are packed with no padding bits, i.e.@: they
10046 can start on an arbitrary bit boundary.
10048 All other types are non-packable, they occupy an integral number of
10049 storage units, and
10050 are placed at a boundary corresponding to their alignment requirements.
10052 For example, consider the record
10054 @smallexample @c ada
10055    type Rb1 is array (1 .. 13) of Boolean;
10056    pragma Pack (rb1);
10058    type Rb2 is array (1 .. 65) of Boolean;
10059    pragma Pack (rb2);
10061    type x2 is record
10062       l1 : Boolean;
10063       l2 : Duration;
10064       l3 : Float;
10065       l4 : Boolean;
10066       l5 : Rb1;
10067       l6 : Rb2;
10068    end record;
10069    pragma Pack (x2);
10070 @end smallexample
10072 @noindent
10073 The representation for the record x2 is as follows:
10075 @smallexample @c ada
10076 for x2'Size use 224;
10077 for x2 use record
10078    l1 at  0 range  0 .. 0;
10079    l2 at  0 range  1 .. 64;
10080    l3 at 12 range  0 .. 31;
10081    l4 at 16 range  0 .. 0;
10082    l5 at 16 range  1 .. 13;
10083    l6 at 18 range  0 .. 71;
10084 end record;
10085 @end smallexample
10087 @noindent
10088 Studying this example, we see that the packable fields @code{l1}
10089 and @code{l2} are
10090 of length equal to their sizes, and placed at specific bit boundaries (and
10091 not byte boundaries) to
10092 eliminate padding.  But @code{l3} is of a non-packable float type, so
10093 it is on the next appropriate alignment boundary.
10095 The next two fields are fully packable, so @code{l4} and @code{l5} are
10096 minimally packed with no gaps.  However, type @code{Rb2} is a packed
10097 array that is longer than 64 bits, so it is itself non-packable.  Thus
10098 the @code{l6} field is aligned to the next byte boundary, and takes an
10099 integral number of bytes, i.e.@: 72 bits.
10101 @node Record Representation Clauses
10102 @section Record Representation Clauses
10103 @cindex Record Representation Clause
10105 @noindent
10106 Record representation clauses may be given for all record types, including
10107 types obtained by record extension.  Component clauses are allowed for any
10108 static component.  The restrictions on component clauses depend on the type
10109 of the component.
10111 @cindex Component Clause
10112 For all components of an elementary type, the only restriction on component
10113 clauses is that the size must be at least the 'Size value of the type
10114 (actually the Value_Size).  There are no restrictions due to alignment,
10115 and such components may freely cross storage boundaries.
10117 Packed arrays with a size up to and including 64 bits are represented
10118 internally using a modular type with the appropriate number of bits, and
10119 thus the same lack of restriction applies.  For example, if you declare:
10121 @smallexample @c ada
10122    type R is array (1 .. 49) of Boolean;
10123    pragma Pack (R);
10124    for R'Size use 49;
10125 @end smallexample
10127 @noindent
10128 then a component clause for a component of type R may start on any
10129 specified bit boundary, and may specify a value of 49 bits or greater.
10131 For packed bit arrays that are longer than 64 bits, there are two
10132 cases. If the component size is a power of 2 (1,2,4,8,16,32 bits),
10133 including the important case of single bits or boolean values, then
10134 there are no limitations on placement of such components, and they
10135 may start and end at arbitrary bit boundaries.
10137 If the component size is not a power of 2 (e.g. 3 or 5), then
10138 an array of this type longer than 64 bits must always be placed on
10139 on a storage unit (byte) boundary and occupy an integral number
10140 of storage units (bytes). Any component clause that does not
10141 meet this requirement will be rejected.
10143 Any aliased component, or component of an aliased type, must
10144 have its normal alignment and size. A component clause that
10145 does not meet this requirement will be rejected.
10147 The tag field of a tagged type always occupies an address sized field at
10148 the start of the record.  No component clause may attempt to overlay this
10149 tag. When a tagged type appears as a component, the tag field must have
10150 proper alignment
10152 In the case of a record extension T1, of a type T, no component clause applied
10153 to the type T1 can specify a storage location that would overlap the first
10154 T'Size bytes of the record.
10156 For all other component types, including non-bit-packed arrays,
10157 the component can be placed at an arbitrary bit boundary,
10158 so for example, the following is permitted:
10160 @smallexample @c ada
10161    type R is array (1 .. 10) of Boolean;
10162    for R'Size use 80;
10164    type Q is record
10165       G, H : Boolean;
10166       L, M : R;
10167    end record;
10169    for Q use record
10170       G at 0 range  0 ..   0;
10171       H at 0 range  1 ..   1;
10172       L at 0 range  2 ..  81;
10173       R at 0 range 82 .. 161;
10174    end record;
10175 @end smallexample
10177 @noindent
10178 Note: the above rules apply to recent releases of GNAT 5.
10179 In GNAT 3, there are more severe restrictions on larger components.
10180 For non-primitive types, including packed arrays with a size greater than
10181 64 bits, component clauses must respect the alignment requirement of the
10182 type, in particular, always starting on a byte boundary, and the length
10183 must be a multiple of the storage unit.
10185 @node Enumeration Clauses
10186 @section Enumeration Clauses
10188 The only restriction on enumeration clauses is that the range of values
10189 must be representable.  For the signed case, if one or more of the
10190 representation values are negative, all values must be in the range:
10192 @smallexample @c ada
10193    System.Min_Int .. System.Max_Int
10194 @end smallexample
10196 @noindent
10197 For the unsigned case, where all values are non negative, the values must
10198 be in the range:
10200 @smallexample @c ada
10201    0 .. System.Max_Binary_Modulus;
10202 @end smallexample
10204 @noindent
10205 A @emph{confirming} representation clause is one in which the values range
10206 from 0 in sequence, i.e.@: a clause that confirms the default representation
10207 for an enumeration type.
10208 Such a confirming representation
10209 is permitted by these rules, and is specially recognized by the compiler so
10210 that no extra overhead results from the use of such a clause.
10212 If an array has an index type which is an enumeration type to which an
10213 enumeration clause has been applied, then the array is stored in a compact
10214 manner.  Consider the declarations:
10216 @smallexample @c ada
10217    type r is (A, B, C);
10218    for r use (A => 1, B => 5, C => 10);
10219    type t is array (r) of Character;
10220 @end smallexample
10222 @noindent
10223 The array type t corresponds to a vector with exactly three elements and
10224 has a default size equal to @code{3*Character'Size}.  This ensures efficient
10225 use of space, but means that accesses to elements of the array will incur
10226 the overhead of converting representation values to the corresponding
10227 positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
10229 @node Address Clauses
10230 @section Address Clauses
10231 @cindex Address Clause
10233 The reference manual allows a general restriction on representation clauses,
10234 as found in RM 13.1(22):
10236 @quotation
10237 An implementation need not support representation
10238 items containing nonstatic expressions, except that
10239 an implementation should support a representation item
10240 for a given entity if each nonstatic expression in the
10241 representation item is a name that statically denotes
10242 a constant declared before the entity.
10243 @end quotation
10245 @noindent
10246 In practice this is applicable only to address clauses, since this is the
10247 only case in which a non-static expression is permitted by the syntax.  As
10248 the AARM notes in sections 13.1 (22.a-22.h):
10250 @display
10251   22.a   Reason: This is to avoid the following sort of thing:
10253   22.b        X : Integer := F(@dots{});
10254               Y : Address := G(@dots{});
10255               for X'Address use Y;
10257   22.c   In the above, we have to evaluate the
10258          initialization expression for X before we
10259          know where to put the result.  This seems
10260          like an unreasonable implementation burden.
10262   22.d   The above code should instead be written
10263          like this:
10265   22.e        Y : constant Address := G(@dots{});
10266               X : Integer := F(@dots{});
10267               for X'Address use Y;
10269   22.f   This allows the expression ``Y'' to be safely
10270          evaluated before X is created.
10272   22.g   The constant could be a formal parameter of mode in.
10274   22.h   An implementation can support other nonstatic
10275          expressions if it wants to.  Expressions of type
10276          Address are hardly ever static, but their value
10277          might be known at compile time anyway in many
10278          cases.
10279 @end display
10281 @noindent
10282 GNAT does indeed permit many additional cases of non-static expressions.  In
10283 particular, if the type involved is elementary there are no restrictions
10284 (since in this case, holding a temporary copy of the initialization value,
10285 if one is present, is inexpensive).  In addition, if there is no implicit or
10286 explicit initialization, then there are no restrictions.  GNAT will reject
10287 only the case where all three of these conditions hold:
10289 @itemize @bullet
10291 @item
10292 The type of the item is non-elementary (e.g.@: a record or array).
10294 @item
10295 There is explicit or implicit initialization required for the object.
10296 Note that access values are always implicitly initialized, and also
10297 in GNAT, certain bit-packed arrays (those having a dynamic length or
10298 a length greater than 64) will also be implicitly initialized to zero.
10300 @item
10301 The address value is non-static.  Here GNAT is more permissive than the
10302 RM, and allows the address value to be the address of a previously declared
10303 stand-alone variable, as long as it does not itself have an address clause.
10305 @smallexample @c ada
10306            Anchor  : Some_Initialized_Type;
10307            Overlay : Some_Initialized_Type;
10308            for Overlay'Address use Anchor'Address;
10309 @end smallexample
10311 @noindent
10312 However, the prefix of the address clause cannot be an array component, or
10313 a component of a discriminated record.
10315 @end itemize
10317 @noindent
10318 As noted above in section 22.h, address values are typically non-static.  In
10319 particular the To_Address function, even if applied to a literal value, is
10320 a non-static function call.  To avoid this minor annoyance, GNAT provides
10321 the implementation defined attribute 'To_Address.  The following two
10322 expressions have identical values:
10324 @findex Attribute
10325 @findex To_Address
10326 @smallexample @c ada
10327    To_Address (16#1234_0000#)
10328    System'To_Address (16#1234_0000#);
10329 @end smallexample
10331 @noindent
10332 except that the second form is considered to be a static expression, and
10333 thus when used as an address clause value is always permitted.
10335 @noindent
10336 Additionally, GNAT treats as static an address clause that is an
10337 unchecked_conversion of a static integer value.  This simplifies the porting
10338 of legacy code, and provides a portable equivalent to the GNAT attribute
10339 @code{To_Address}.
10341 Another issue with address clauses is the interaction with alignment
10342 requirements.  When an address clause is given for an object, the address
10343 value must be consistent with the alignment of the object (which is usually
10344 the same as the alignment of the type of the object).  If an address clause
10345 is given that specifies an inappropriately aligned address value, then the
10346 program execution is erroneous.
10348 Since this source of erroneous behavior can have unfortunate effects, GNAT
10349 checks (at compile time if possible, generating a warning, or at execution
10350 time with a run-time check) that the alignment is appropriate.  If the
10351 run-time check fails, then @code{Program_Error} is raised.  This run-time
10352 check is suppressed if range checks are suppressed, or if the special GNAT
10353 check Alignment_Check is suppressed, or if
10354 @code{pragma Restrictions (No_Elaboration_Code)} is in effect.
10356 @findex Export
10357 An address clause cannot be given for an exported object.  More
10358 understandably the real restriction is that objects with an address
10359 clause cannot be exported.  This is because such variables are not
10360 defined by the Ada program, so there is no external object to export.
10362 @findex Import
10363 It is permissible to give an address clause and a pragma Import for the
10364 same object.  In this case, the variable is not really defined by the
10365 Ada program, so there is no external symbol to be linked.  The link name
10366 and the external name are ignored in this case.  The reason that we allow this
10367 combination is that it provides a useful idiom to avoid unwanted
10368 initializations on objects with address clauses.
10370 When an address clause is given for an object that has implicit or
10371 explicit initialization, then by default initialization takes place.  This
10372 means that the effect of the object declaration is to overwrite the
10373 memory at the specified address.  This is almost always not what the
10374 programmer wants, so GNAT will output a warning:
10376 @smallexample
10377   with System;
10378   package G is
10379      type R is record
10380         M : Integer := 0;
10381      end record;
10383      Ext : R;
10384      for Ext'Address use System'To_Address (16#1234_1234#);
10385          |
10386   >>> warning: implicit initialization of "Ext" may
10387       modify overlaid storage
10388   >>> warning: use pragma Import for "Ext" to suppress
10389       initialization (RM B(24))
10391   end G;
10392 @end smallexample
10394 @noindent
10395 As indicated by the warning message, the solution is to use a (dummy) pragma
10396 Import to suppress this initialization.  The pragma tell the compiler that the
10397 object is declared and initialized elsewhere.  The following package compiles
10398 without warnings (and the initialization is suppressed):
10400 @smallexample @c ada
10401    with System;
10402    package G is
10403       type R is record
10404          M : Integer := 0;
10405       end record;
10407       Ext : R;
10408       for Ext'Address use System'To_Address (16#1234_1234#);
10409       pragma Import (Ada, Ext);
10410    end G;
10411 @end smallexample
10413 @noindent
10414 A final issue with address clauses involves their use for overlaying
10415 variables, as in the following example:
10416 @cindex Overlaying of objects
10418 @smallexample @c ada
10419   A : Integer;
10420   B : Integer;
10421   for B'Address use A'Address;
10422 @end smallexample
10424 @noindent
10425 or alternatively, using the form recommended by the RM:
10427 @smallexample @c ada
10428   A    : Integer;
10429   Addr : constant Address := A'Address;
10430   B    : Integer;
10431   for B'Address use Addr;
10432 @end smallexample
10434 @noindent
10435 In both of these cases, @code{A}
10436 and @code{B} become aliased to one another via the
10437 address clause. This use of address clauses to overlay
10438 variables, achieving an effect similar to unchecked
10439 conversion was erroneous in Ada 83, but in Ada 95
10440 the effect is implementation defined. Furthermore, the
10441 Ada 95 RM specifically recommends that in a situation
10442 like this, @code{B} should be subject to the following
10443 implementation advice (RM 13.3(19)):
10445 @quotation
10446 19  If the Address of an object is specified, or it is imported
10447     or exported, then the implementation should not perform
10448     optimizations based on assumptions of no aliases.
10449 @end quotation
10451 @noindent
10452 GNAT follows this recommendation, and goes further by also applying
10453 this recommendation to the overlaid variable (@code{A}
10454 in the above example) in this case. This means that the overlay
10455 works "as expected", in that a modification to one of the variables
10456 will affect the value of the other.
10458 @node Effect of Convention on Representation
10459 @section Effect of Convention on Representation
10460 @cindex Convention, effect on representation
10462 @noindent
10463 Normally the specification of a foreign language convention for a type or
10464 an object has no effect on the chosen representation.  In particular, the
10465 representation chosen for data in GNAT generally meets the standard system
10466 conventions, and for example records are laid out in a manner that is
10467 consistent with C@.  This means that specifying convention C (for example)
10468 has no effect.
10470 There are four exceptions to this general rule:
10472 @itemize @bullet
10474 @item Convention Fortran and array subtypes
10475 If pragma Convention Fortran is specified for an array subtype, then in
10476 accordance with the implementation advice in section 3.6.2(11) of the
10477 Ada Reference Manual, the array will be stored in a Fortran-compatible
10478 column-major manner, instead of the normal default row-major order.
10480 @item Convention C and enumeration types
10481 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
10482 to accommodate all values of the type.  For example, for the enumeration
10483 type declared by:
10485 @smallexample @c ada
10486    type Color is (Red, Green, Blue);
10487 @end smallexample
10489 @noindent
10490 8 bits is sufficient to store all values of the type, so by default, objects
10491 of type @code{Color} will be represented using 8 bits.  However, normal C
10492 convention is to use 32 bits for all enum values in C, since enum values
10493 are essentially of type int.  If pragma @code{Convention C} is specified for an
10494 Ada enumeration type, then the size is modified as necessary (usually to
10495 32 bits) to be consistent with the C convention for enum values.
10497 @item Convention C/Fortran and Boolean types
10498 In C, the usual convention for boolean values, that is values used for
10499 conditions, is that zero represents false, and nonzero values represent
10500 true.  In Ada, the normal convention is that two specific values, typically
10501 0/1, are used to represent false/true respectively.
10503 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
10504 value represents true).
10506 To accommodate the Fortran and C conventions, if a pragma Convention specifies
10507 C or Fortran convention for a derived Boolean, as in the following example:
10509 @smallexample @c ada
10510    type C_Switch is new Boolean;
10511    pragma Convention (C, C_Switch);
10512 @end smallexample
10514 @noindent
10515 then the GNAT generated code will treat any nonzero value as true.  For truth
10516 values generated by GNAT, the conventional value 1 will be used for True, but
10517 when one of these values is read, any nonzero value is treated as True.
10519 @item Access types on OpenVMS
10520 For 64-bit OpenVMS systems, access types (other than those for unconstrained
10521 arrays) are 64-bits long. An exception to this rule is for the case of
10522 C-convention access types where there is no explicit size clause present (or
10523 inherited for derived types). In this case, GNAT chooses to make these
10524 pointers 32-bits, which provides an easier path for migration of 32-bit legacy
10525 code. size clause specifying 64-bits must be used to obtain a 64-bit pointer.
10527 @end itemize
10529 @node Determining the Representations chosen by GNAT
10530 @section Determining the Representations chosen by GNAT
10531 @cindex Representation, determination of
10532 @cindex @code{-gnatR} switch
10534 @noindent
10535 Although the descriptions in this section are intended to be complete, it is
10536 often easier to simply experiment to see what GNAT accepts and what the
10537 effect is on the layout of types and objects.
10539 As required by the Ada RM, if a representation clause is not accepted, then
10540 it must be rejected as illegal by the compiler.  However, when a
10541 representation clause or pragma is accepted, there can still be questions
10542 of what the compiler actually does.  For example, if a partial record
10543 representation clause specifies the location of some components and not
10544 others, then where are the non-specified components placed? Or if pragma
10545 @code{Pack} is used on a record, then exactly where are the resulting
10546 fields placed? The section on pragma @code{Pack} in this chapter can be
10547 used to answer the second question, but it is often easier to just see
10548 what the compiler does.
10550 For this purpose, GNAT provides the option @code{-gnatR}.  If you compile
10551 with this option, then the compiler will output information on the actual
10552 representations chosen, in a format similar to source representation
10553 clauses.  For example, if we compile the package:
10555 @smallexample @c ada
10556 package q is
10557    type r (x : boolean) is tagged record
10558       case x is
10559          when True => S : String (1 .. 100);
10560          when False => null;
10561       end case;
10562    end record;
10564    type r2 is new r (false) with record
10565       y2 : integer;
10566    end record;
10568    for r2 use record
10569       y2 at 16 range 0 .. 31;
10570    end record;
10572    type x is record
10573       y : character;
10574    end record;
10576    type x1 is array (1 .. 10) of x;
10577    for x1'component_size use 11;
10579    type ia is access integer;
10581    type Rb1 is array (1 .. 13) of Boolean;
10582    pragma Pack (rb1);
10584    type Rb2 is array (1 .. 65) of Boolean;
10585    pragma Pack (rb2);
10587    type x2 is record
10588       l1 : Boolean;
10589       l2 : Duration;
10590       l3 : Float;
10591       l4 : Boolean;
10592       l5 : Rb1;
10593       l6 : Rb2;
10594    end record;
10595    pragma Pack (x2);
10596 end q;
10597 @end smallexample
10599 @noindent
10600 using the switch @code{-gnatR} we obtain the following output:
10602 @smallexample
10603 Representation information for unit q
10604 -------------------------------------
10606 for r'Size use ??;
10607 for r'Alignment use 4;
10608 for r use record
10609    x    at 4 range  0 .. 7;
10610    _tag at 0 range  0 .. 31;
10611    s    at 5 range  0 .. 799;
10612 end record;
10614 for r2'Size use 160;
10615 for r2'Alignment use 4;
10616 for r2 use record
10617    x       at  4 range  0 .. 7;
10618    _tag    at  0 range  0 .. 31;
10619    _parent at  0 range  0 .. 63;
10620    y2      at 16 range  0 .. 31;
10621 end record;
10623 for x'Size use 8;
10624 for x'Alignment use 1;
10625 for x use record
10626    y at 0 range  0 .. 7;
10627 end record;
10629 for x1'Size use 112;
10630 for x1'Alignment use 1;
10631 for x1'Component_Size use 11;
10633 for rb1'Size use 13;
10634 for rb1'Alignment use 2;
10635 for rb1'Component_Size use 1;
10637 for rb2'Size use 72;
10638 for rb2'Alignment use 1;
10639 for rb2'Component_Size use 1;
10641 for x2'Size use 224;
10642 for x2'Alignment use 4;
10643 for x2 use record
10644    l1 at  0 range  0 .. 0;
10645    l2 at  0 range  1 .. 64;
10646    l3 at 12 range  0 .. 31;
10647    l4 at 16 range  0 .. 0;
10648    l5 at 16 range  1 .. 13;
10649    l6 at 18 range  0 .. 71;
10650 end record;
10651 @end smallexample
10653 @noindent
10654 The Size values are actually the Object_Size, i.e.@: the default size that
10655 will be allocated for objects of the type.
10656 The ?? size for type r indicates that we have a variant record, and the
10657 actual size of objects will depend on the discriminant value.
10659 The Alignment values show the actual alignment chosen by the compiler
10660 for each record or array type.
10662 The record representation clause for type r shows where all fields
10663 are placed, including the compiler generated tag field (whose location
10664 cannot be controlled by the programmer).
10666 The record representation clause for the type extension r2 shows all the
10667 fields present, including the parent field, which is a copy of the fields
10668 of the parent type of r2, i.e.@: r1.
10670 The component size and size clauses for types rb1 and rb2 show
10671 the exact effect of pragma @code{Pack} on these arrays, and the record
10672 representation clause for type x2 shows how pragma @code{Pack} affects
10673 this record type.
10675 In some cases, it may be useful to cut and paste the representation clauses
10676 generated by the compiler into the original source to fix and guarantee
10677 the actual representation to be used.
10679 @node Standard Library Routines
10680 @chapter Standard Library Routines
10682 @noindent
10683 The Ada 95 Reference Manual contains in Annex A a full description of an
10684 extensive set of standard library routines that can be used in any Ada
10685 program, and which must be provided by all Ada compilers.  They are
10686 analogous to the standard C library used by C programs.
10688 GNAT implements all of the facilities described in annex A, and for most
10689 purposes the description in the Ada 95
10690 reference manual, or appropriate Ada
10691 text book, will be sufficient for making use of these facilities.
10693 In the case of the input-output facilities,
10694 @xref{The Implementation of Standard I/O},
10695 gives details on exactly how GNAT interfaces to the
10696 file system.  For the remaining packages, the Ada 95 reference manual
10697 should be sufficient.  The following is a list of the packages included,
10698 together with a brief description of the functionality that is provided.
10700 For completeness, references are included to other predefined library
10701 routines defined in other sections of the Ada 95 reference manual (these are
10702 cross-indexed from annex A).
10704 @table @code
10705 @item Ada (A.2)
10706 This is a parent package for all the standard library packages.  It is
10707 usually included implicitly in your program, and itself contains no
10708 useful data or routines.
10710 @item Ada.Calendar (9.6)
10711 @code{Calendar} provides time of day access, and routines for
10712 manipulating times and durations.
10714 @item Ada.Characters (A.3.1)
10715 This is a dummy parent package that contains no useful entities
10717 @item Ada.Characters.Handling (A.3.2)
10718 This package provides some basic character handling capabilities,
10719 including classification functions for classes of characters (e.g.@: test
10720 for letters, or digits).
10722 @item Ada.Characters.Latin_1 (A.3.3)
10723 This package includes a complete set of definitions of the characters
10724 that appear in type CHARACTER@.  It is useful for writing programs that
10725 will run in international environments.  For example, if you want an
10726 upper case E with an acute accent in a string, it is often better to use
10727 the definition of @code{UC_E_Acute} in this package.  Then your program
10728 will print in an understandable manner even if your environment does not
10729 support these extended characters.
10731 @item Ada.Command_Line (A.15)
10732 This package provides access to the command line parameters and the name
10733 of the current program (analogous to the use of @code{argc} and @code{argv}
10734 in C), and also allows the exit status for the program to be set in a
10735 system-independent manner.
10737 @item Ada.Decimal (F.2)
10738 This package provides constants describing the range of decimal numbers
10739 implemented, and also a decimal divide routine (analogous to the COBOL
10740 verb DIVIDE .. GIVING .. REMAINDER ..)
10742 @item Ada.Direct_IO (A.8.4)
10743 This package provides input-output using a model of a set of records of
10744 fixed-length, containing an arbitrary definite Ada type, indexed by an
10745 integer record number.
10747 @item Ada.Dynamic_Priorities (D.5)
10748 This package allows the priorities of a task to be adjusted dynamically
10749 as the task is running.
10751 @item Ada.Exceptions (11.4.1)
10752 This package provides additional information on exceptions, and also
10753 contains facilities for treating exceptions as data objects, and raising
10754 exceptions with associated messages.
10756 @item Ada.Finalization (7.6)
10757 This package contains the declarations and subprograms to support the
10758 use of controlled types, providing for automatic initialization and
10759 finalization (analogous to the constructors and destructors of C++)
10761 @item Ada.Interrupts (C.3.2)
10762 This package provides facilities for interfacing to interrupts, which
10763 includes the set of signals or conditions that can be raised and
10764 recognized as interrupts.
10766 @item Ada.Interrupts.Names (C.3.2)
10767 This package provides the set of interrupt names (actually signal
10768 or condition names) that can be handled by GNAT@.
10770 @item Ada.IO_Exceptions (A.13)
10771 This package defines the set of exceptions that can be raised by use of
10772 the standard IO packages.
10774 @item Ada.Numerics
10775 This package contains some standard constants and exceptions used
10776 throughout the numerics packages.  Note that the constants pi and e are
10777 defined here, and it is better to use these definitions than rolling
10778 your own.
10780 @item Ada.Numerics.Complex_Elementary_Functions
10781 Provides the implementation of standard elementary functions (such as
10782 log and trigonometric functions) operating on complex numbers using the
10783 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
10784 created by the package @code{Numerics.Complex_Types}.
10786 @item Ada.Numerics.Complex_Types
10787 This is a predefined instantiation of
10788 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
10789 build the type @code{Complex} and @code{Imaginary}.
10791 @item Ada.Numerics.Discrete_Random
10792 This package provides a random number generator suitable for generating
10793 random integer values from a specified range.
10795 @item Ada.Numerics.Float_Random
10796 This package provides a random number generator suitable for generating
10797 uniformly distributed floating point values.
10799 @item Ada.Numerics.Generic_Complex_Elementary_Functions
10800 This is a generic version of the package that provides the
10801 implementation of standard elementary functions (such as log and
10802 trigonometric functions) for an arbitrary complex type.
10804 The following predefined instantiations of this package are provided:
10806 @table @code
10807 @item Short_Float
10808 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
10809 @item Float
10810 @code{Ada.Numerics.Complex_Elementary_Functions}
10811 @item Long_Float
10812 @code{Ada.Numerics.
10813  Long_Complex_Elementary_Functions}
10814 @end table
10816 @item Ada.Numerics.Generic_Complex_Types
10817 This is a generic package that allows the creation of complex types,
10818 with associated complex arithmetic operations.
10820 The following predefined instantiations of this package exist
10821 @table @code
10822 @item Short_Float
10823 @code{Ada.Numerics.Short_Complex_Complex_Types}
10824 @item Float
10825 @code{Ada.Numerics.Complex_Complex_Types}
10826 @item Long_Float
10827 @code{Ada.Numerics.Long_Complex_Complex_Types}
10828 @end table
10830 @item Ada.Numerics.Generic_Elementary_Functions
10831 This is a generic package that provides the implementation of standard
10832 elementary functions (such as log an trigonometric functions) for an
10833 arbitrary float type.
10835 The following predefined instantiations of this package exist
10837 @table @code
10838 @item Short_Float
10839 @code{Ada.Numerics.Short_Elementary_Functions}
10840 @item Float
10841 @code{Ada.Numerics.Elementary_Functions}
10842 @item Long_Float
10843 @code{Ada.Numerics.Long_Elementary_Functions}
10844 @end table
10846 @item Ada.Real_Time (D.8)
10847 This package provides facilities similar to those of @code{Calendar}, but
10848 operating with a finer clock suitable for real time control. Note that
10849 annex D requires that there be no backward clock jumps, and GNAT generally
10850 guarantees this behavior, but of course if the external clock on which
10851 the GNAT runtime depends is deliberately reset by some external event,
10852 then such a backward jump may occur.
10854 @item Ada.Sequential_IO (A.8.1)
10855 This package provides input-output facilities for sequential files,
10856 which can contain a sequence of values of a single type, which can be
10857 any Ada type, including indefinite (unconstrained) types.
10859 @item Ada.Storage_IO (A.9)
10860 This package provides a facility for mapping arbitrary Ada types to and
10861 from a storage buffer.  It is primarily intended for the creation of new
10862 IO packages.
10864 @item Ada.Streams (13.13.1)
10865 This is a generic package that provides the basic support for the
10866 concept of streams as used by the stream attributes (@code{Input},
10867 @code{Output}, @code{Read} and @code{Write}).
10869 @item Ada.Streams.Stream_IO (A.12.1)
10870 This package is a specialization of the type @code{Streams} defined in
10871 package @code{Streams} together with a set of operations providing
10872 Stream_IO capability.  The Stream_IO model permits both random and
10873 sequential access to a file which can contain an arbitrary set of values
10874 of one or more Ada types.
10876 @item Ada.Strings (A.4.1)
10877 This package provides some basic constants used by the string handling
10878 packages.
10880 @item Ada.Strings.Bounded (A.4.4)
10881 This package provides facilities for handling variable length
10882 strings.  The bounded model requires a maximum length.  It is thus
10883 somewhat more limited than the unbounded model, but avoids the use of
10884 dynamic allocation or finalization.
10886 @item Ada.Strings.Fixed (A.4.3)
10887 This package provides facilities for handling fixed length strings.
10889 @item Ada.Strings.Maps (A.4.2)
10890 This package provides facilities for handling character mappings and
10891 arbitrarily defined subsets of characters.  For instance it is useful in
10892 defining specialized translation tables.
10894 @item Ada.Strings.Maps.Constants (A.4.6)
10895 This package provides a standard set of predefined mappings and
10896 predefined character sets.  For example, the standard upper to lower case
10897 conversion table is found in this package.  Note that upper to lower case
10898 conversion is non-trivial if you want to take the entire set of
10899 characters, including extended characters like E with an acute accent,
10900 into account.  You should use the mappings in this package (rather than
10901 adding 32 yourself) to do case mappings.
10903 @item Ada.Strings.Unbounded (A.4.5)
10904 This package provides facilities for handling variable length
10905 strings.  The unbounded model allows arbitrary length strings, but
10906 requires the use of dynamic allocation and finalization.
10908 @item Ada.Strings.Wide_Bounded (A.4.7)
10909 @itemx Ada.Strings.Wide_Fixed (A.4.7)
10910 @itemx Ada.Strings.Wide_Maps (A.4.7)
10911 @itemx Ada.Strings.Wide_Maps.Constants (A.4.7)
10912 @itemx Ada.Strings.Wide_Unbounded (A.4.7)
10913 These packages provide analogous capabilities to the corresponding
10914 packages without @samp{Wide_} in the name, but operate with the types
10915 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
10916 and @code{Character}.
10918 @item Ada.Strings.Wide_Wide_Bounded (A.4.7)
10919 @itemx Ada.Strings.Wide_Wide_Fixed (A.4.7)
10920 @itemx Ada.Strings.Wide_Wide_Maps (A.4.7)
10921 @itemx Ada.Strings.Wide_Wide_Maps.Constants (A.4.7)
10922 @itemx Ada.Strings.Wide_Wide_Unbounded (A.4.7)
10923 These packages provide analogous capabilities to the corresponding
10924 packages without @samp{Wide_} in the name, but operate with the types
10925 @code{Wide_Wide_String} and @code{Wide_Wide_Character} instead
10926 of @code{String} and @code{Character}.
10928 @item Ada.Synchronous_Task_Control (D.10)
10929 This package provides some standard facilities for controlling task
10930 communication in a synchronous manner.
10932 @item Ada.Tags
10933 This package contains definitions for manipulation of the tags of tagged
10934 values.
10936 @item Ada.Task_Attributes
10937 This package provides the capability of associating arbitrary
10938 task-specific data with separate tasks.
10940 @item Ada.Text_IO
10941 This package provides basic text input-output capabilities for
10942 character, string and numeric data.  The subpackages of this
10943 package are listed next.
10945 @item Ada.Text_IO.Decimal_IO
10946 Provides input-output facilities for decimal fixed-point types
10948 @item Ada.Text_IO.Enumeration_IO
10949 Provides input-output facilities for enumeration types.
10951 @item Ada.Text_IO.Fixed_IO
10952 Provides input-output facilities for ordinary fixed-point types.
10954 @item Ada.Text_IO.Float_IO
10955 Provides input-output facilities for float types.  The following
10956 predefined instantiations of this generic package are available:
10958 @table @code
10959 @item Short_Float
10960 @code{Short_Float_Text_IO}
10961 @item Float
10962 @code{Float_Text_IO}
10963 @item Long_Float
10964 @code{Long_Float_Text_IO}
10965 @end table
10967 @item Ada.Text_IO.Integer_IO
10968 Provides input-output facilities for integer types.  The following
10969 predefined instantiations of this generic package are available:
10971 @table @code
10972 @item Short_Short_Integer
10973 @code{Ada.Short_Short_Integer_Text_IO}
10974 @item Short_Integer
10975 @code{Ada.Short_Integer_Text_IO}
10976 @item Integer
10977 @code{Ada.Integer_Text_IO}
10978 @item Long_Integer
10979 @code{Ada.Long_Integer_Text_IO}
10980 @item Long_Long_Integer
10981 @code{Ada.Long_Long_Integer_Text_IO}
10982 @end table
10984 @item Ada.Text_IO.Modular_IO
10985 Provides input-output facilities for modular (unsigned) types
10987 @item Ada.Text_IO.Complex_IO (G.1.3)
10988 This package provides basic text input-output capabilities for complex
10989 data.
10991 @item Ada.Text_IO.Editing (F.3.3)
10992 This package contains routines for edited output, analogous to the use
10993 of pictures in COBOL@.  The picture formats used by this package are a
10994 close copy of the facility in COBOL@.
10996 @item Ada.Text_IO.Text_Streams (A.12.2)
10997 This package provides a facility that allows Text_IO files to be treated
10998 as streams, so that the stream attributes can be used for writing
10999 arbitrary data, including binary data, to Text_IO files.
11001 @item Ada.Unchecked_Conversion (13.9)
11002 This generic package allows arbitrary conversion from one type to
11003 another of the same size, providing for breaking the type safety in
11004 special circumstances.
11006 If the types have the same Size (more accurately the same Value_Size),
11007 then the effect is simply to transfer the bits from the source to the
11008 target type without any modification.  This usage is well defined, and
11009 for simple types whose representation is typically the same across
11010 all implementations, gives a portable method of performing such
11011 conversions.
11013 If the types do not have the same size, then the result is implementation
11014 defined, and thus may be non-portable.  The following describes how GNAT
11015 handles such unchecked conversion cases.
11017 If the types are of different sizes, and are both discrete types, then
11018 the effect is of a normal type conversion without any constraint checking.
11019 In particular if the result type has a larger size, the result will be
11020 zero or sign extended.  If the result type has a smaller size, the result
11021 will be truncated by ignoring high order bits.
11023 If the types are of different sizes, and are not both discrete types,
11024 then the conversion works as though pointers were created to the source
11025 and target, and the pointer value is converted.  The effect is that bits
11026 are copied from successive low order storage units and bits of the source
11027 up to the length of the target type.
11029 A warning is issued if the lengths differ, since the effect in this
11030 case is implementation dependent, and the above behavior may not match
11031 that of some other compiler.
11033 A pointer to one type may be converted to a pointer to another type using
11034 unchecked conversion.  The only case in which the effect is undefined is
11035 when one or both pointers are pointers to unconstrained array types.  In
11036 this case, the bounds information may get incorrectly transferred, and in
11037 particular, GNAT uses double size pointers for such types, and it is
11038 meaningless to convert between such pointer types.  GNAT will issue a
11039 warning if the alignment of the target designated type is more strict
11040 than the alignment of the source designated type (since the result may
11041 be unaligned in this case).
11043 A pointer other than a pointer to an unconstrained array type may be
11044 converted to and from System.Address.  Such usage is common in Ada 83
11045 programs, but note that Ada.Address_To_Access_Conversions is the
11046 preferred method of performing such conversions in Ada 95.  Neither
11047 unchecked conversion nor Ada.Address_To_Access_Conversions should be
11048 used in conjunction with pointers to unconstrained objects, since
11049 the bounds information cannot be handled correctly in this case.
11051 @item Ada.Unchecked_Deallocation (13.11.2)
11052 This generic package allows explicit freeing of storage previously
11053 allocated by use of an allocator.
11055 @item Ada.Wide_Text_IO (A.11)
11056 This package is similar to @code{Ada.Text_IO}, except that the external
11057 file supports wide character representations, and the internal types are
11058 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
11059 and @code{String}.  It contains generic subpackages listed next.
11061 @item Ada.Wide_Text_IO.Decimal_IO
11062 Provides input-output facilities for decimal fixed-point types
11064 @item Ada.Wide_Text_IO.Enumeration_IO
11065 Provides input-output facilities for enumeration types.
11067 @item Ada.Wide_Text_IO.Fixed_IO
11068 Provides input-output facilities for ordinary fixed-point types.
11070 @item Ada.Wide_Text_IO.Float_IO
11071 Provides input-output facilities for float types.  The following
11072 predefined instantiations of this generic package are available:
11074 @table @code
11075 @item Short_Float
11076 @code{Short_Float_Wide_Text_IO}
11077 @item Float
11078 @code{Float_Wide_Text_IO}
11079 @item Long_Float
11080 @code{Long_Float_Wide_Text_IO}
11081 @end table
11083 @item Ada.Wide_Text_IO.Integer_IO
11084 Provides input-output facilities for integer types.  The following
11085 predefined instantiations of this generic package are available:
11087 @table @code
11088 @item Short_Short_Integer
11089 @code{Ada.Short_Short_Integer_Wide_Text_IO}
11090 @item Short_Integer
11091 @code{Ada.Short_Integer_Wide_Text_IO}
11092 @item Integer
11093 @code{Ada.Integer_Wide_Text_IO}
11094 @item Long_Integer
11095 @code{Ada.Long_Integer_Wide_Text_IO}
11096 @item Long_Long_Integer
11097 @code{Ada.Long_Long_Integer_Wide_Text_IO}
11098 @end table
11100 @item Ada.Wide_Text_IO.Modular_IO
11101 Provides input-output facilities for modular (unsigned) types
11103 @item Ada.Wide_Text_IO.Complex_IO (G.1.3)
11104 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
11105 external file supports wide character representations.
11107 @item Ada.Wide_Text_IO.Editing (F.3.4)
11108 This package is similar to @code{Ada.Text_IO.Editing}, except that the
11109 types are @code{Wide_Character} and @code{Wide_String} instead of
11110 @code{Character} and @code{String}.
11112 @item Ada.Wide_Text_IO.Streams (A.12.3)
11113 This package is similar to @code{Ada.Text_IO.Streams}, except that the
11114 types are @code{Wide_Character} and @code{Wide_String} instead of
11115 @code{Character} and @code{String}.
11117 @item Ada.Wide_Wide_Text_IO (A.11)
11118 This package is similar to @code{Ada.Text_IO}, except that the external
11119 file supports wide character representations, and the internal types are
11120 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
11121 and @code{String}.  It contains generic subpackages listed next.
11123 @item Ada.Wide_Wide_Text_IO.Decimal_IO
11124 Provides input-output facilities for decimal fixed-point types
11126 @item Ada.Wide_Wide_Text_IO.Enumeration_IO
11127 Provides input-output facilities for enumeration types.
11129 @item Ada.Wide_Wide_Text_IO.Fixed_IO
11130 Provides input-output facilities for ordinary fixed-point types.
11132 @item Ada.Wide_Wide_Text_IO.Float_IO
11133 Provides input-output facilities for float types.  The following
11134 predefined instantiations of this generic package are available:
11136 @table @code
11137 @item Short_Float
11138 @code{Short_Float_Wide_Wide_Text_IO}
11139 @item Float
11140 @code{Float_Wide_Wide_Text_IO}
11141 @item Long_Float
11142 @code{Long_Float_Wide_Wide_Text_IO}
11143 @end table
11145 @item Ada.Wide_Wide_Text_IO.Integer_IO
11146 Provides input-output facilities for integer types.  The following
11147 predefined instantiations of this generic package are available:
11149 @table @code
11150 @item Short_Short_Integer
11151 @code{Ada.Short_Short_Integer_Wide_Wide_Text_IO}
11152 @item Short_Integer
11153 @code{Ada.Short_Integer_Wide_Wide_Text_IO}
11154 @item Integer
11155 @code{Ada.Integer_Wide_Wide_Text_IO}
11156 @item Long_Integer
11157 @code{Ada.Long_Integer_Wide_Wide_Text_IO}
11158 @item Long_Long_Integer
11159 @code{Ada.Long_Long_Integer_Wide_Wide_Text_IO}
11160 @end table
11162 @item Ada.Wide_Wide_Text_IO.Modular_IO
11163 Provides input-output facilities for modular (unsigned) types
11165 @item Ada.Wide_Wide_Text_IO.Complex_IO (G.1.3)
11166 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
11167 external file supports wide character representations.
11169 @item Ada.Wide_Wide_Text_IO.Editing (F.3.4)
11170 This package is similar to @code{Ada.Text_IO.Editing}, except that the
11171 types are @code{Wide_Character} and @code{Wide_String} instead of
11172 @code{Character} and @code{String}.
11174 @item Ada.Wide_Wide_Text_IO.Streams (A.12.3)
11175 This package is similar to @code{Ada.Text_IO.Streams}, except that the
11176 types are @code{Wide_Character} and @code{Wide_String} instead of
11177 @code{Character} and @code{String}.
11178 @end table
11182 @node The Implementation of Standard I/O
11183 @chapter The Implementation of Standard I/O
11185 @noindent
11186 GNAT implements all the required input-output facilities described in
11187 A.6 through A.14.  These sections of the Ada 95 reference manual describe the
11188 required behavior of these packages from the Ada point of view, and if
11189 you are writing a portable Ada program that does not need to know the
11190 exact manner in which Ada maps to the outside world when it comes to
11191 reading or writing external files, then you do not need to read this
11192 chapter.  As long as your files are all regular files (not pipes or
11193 devices), and as long as you write and read the files only from Ada, the
11194 description in the Ada 95 reference manual is sufficient.
11196 However, if you want to do input-output to pipes or other devices, such
11197 as the keyboard or screen, or if the files you are dealing with are
11198 either generated by some other language, or to be read by some other
11199 language, then you need to know more about the details of how the GNAT
11200 implementation of these input-output facilities behaves.
11202 In this chapter we give a detailed description of exactly how GNAT
11203 interfaces to the file system.  As always, the sources of the system are
11204 available to you for answering questions at an even more detailed level,
11205 but for most purposes the information in this chapter will suffice.
11207 Another reason that you may need to know more about how input-output is
11208 implemented arises when you have a program written in mixed languages
11209 where, for example, files are shared between the C and Ada sections of
11210 the same program.  GNAT provides some additional facilities, in the form
11211 of additional child library packages, that facilitate this sharing, and
11212 these additional facilities are also described in this chapter.
11214 @menu
11215 * Standard I/O Packages::
11216 * FORM Strings::
11217 * Direct_IO::
11218 * Sequential_IO::
11219 * Text_IO::
11220 * Wide_Text_IO::
11221 * Wide_Wide_Text_IO::
11222 * Stream_IO::
11223 * Shared Files::
11224 * Open Modes::
11225 * Operations on C Streams::
11226 * Interfacing to C Streams::
11227 @end menu
11229 @node Standard I/O Packages
11230 @section Standard I/O Packages
11232 @noindent
11233 The Standard I/O packages described in Annex A for
11235 @itemize @bullet
11236 @item
11237 Ada.Text_IO
11238 @item
11239 Ada.Text_IO.Complex_IO
11240 @item
11241 Ada.Text_IO.Text_Streams
11242 @item
11243 Ada.Wide_Text_IO
11244 @item
11245 Ada.Wide_Text_IO.Complex_IO
11246 @item
11247 Ada.Wide_Text_IO.Text_Streams
11248 @item
11249 Ada.Wide_Wide_Text_IO
11250 @item
11251 Ada.Wide_Wide_Text_IO.Complex_IO
11252 @item
11253 Ada.Wide_Wide_Text_IO.Text_Streams
11254 @item
11255 Ada.Stream_IO
11256 @item
11257 Ada.Sequential_IO
11258 @item
11259 Ada.Direct_IO
11260 @end itemize
11262 @noindent
11263 are implemented using the C
11264 library streams facility; where
11266 @itemize @bullet
11267 @item
11268 All files are opened using @code{fopen}.
11269 @item
11270 All input/output operations use @code{fread}/@code{fwrite}.
11271 @end itemize
11273 @noindent
11274 There is no internal buffering of any kind at the Ada library level. The only
11275 buffering is that provided at the system level in the implementation of the
11276 library routines that support streams. This facilitates shared use of these
11277 streams by mixed language programs. Note though that system level buffering is
11278 explicitly enabled at elaboration of the standard I/O packages and that can
11279 have an impact on mixed language programs, in particular those using I/O before
11280 calling the Ada elaboration routine (e.g. adainit). It is recommended to call
11281 the Ada elaboration routine before performing any I/O or when impractical,
11282 flush the common I/O streams and in particular Standard_Output before
11283 elaborating the Ada code.
11285 @node FORM Strings
11286 @section FORM Strings
11288 @noindent
11289 The format of a FORM string in GNAT is:
11291 @smallexample
11292 "keyword=value,keyword=value,@dots{},keyword=value"
11293 @end smallexample
11295 @noindent
11296 where letters may be in upper or lower case, and there are no spaces
11297 between values.  The order of the entries is not important.  Currently
11298 there are two keywords defined.
11300 @smallexample
11301 SHARED=[YES|NO]
11302 WCEM=[n|h|u|s\e]
11303 @end smallexample
11305 @noindent
11306 The use of these parameters is described later in this section.
11308 @node Direct_IO
11309 @section Direct_IO
11311 @noindent
11312 Direct_IO can only be instantiated for definite types.  This is a
11313 restriction of the Ada language, which means that the records are fixed
11314 length (the length being determined by @code{@var{type}'Size}, rounded
11315 up to the next storage unit boundary if necessary).
11317 The records of a Direct_IO file are simply written to the file in index
11318 sequence, with the first record starting at offset zero, and subsequent
11319 records following.  There is no control information of any kind.  For
11320 example, if 32-bit integers are being written, each record takes
11321 4-bytes, so the record at index @var{K} starts at offset
11322 (@var{K}@minus{}1)*4.
11324 There is no limit on the size of Direct_IO files, they are expanded as
11325 necessary to accommodate whatever records are written to the file.
11327 @node Sequential_IO
11328 @section Sequential_IO
11330 @noindent
11331 Sequential_IO may be instantiated with either a definite (constrained)
11332 or indefinite (unconstrained) type.
11334 For the definite type case, the elements written to the file are simply
11335 the memory images of the data values with no control information of any
11336 kind.  The resulting file should be read using the same type, no validity
11337 checking is performed on input.
11339 For the indefinite type case, the elements written consist of two
11340 parts.  First is the size of the data item, written as the memory image
11341 of a @code{Interfaces.C.size_t} value, followed by the memory image of
11342 the data value.  The resulting file can only be read using the same
11343 (unconstrained) type.  Normal assignment checks are performed on these
11344 read operations, and if these checks fail, @code{Data_Error} is
11345 raised.  In particular, in the array case, the lengths must match, and in
11346 the variant record case, if the variable for a particular read operation
11347 is constrained, the discriminants must match.
11349 Note that it is not possible to use Sequential_IO to write variable
11350 length array items, and then read the data back into different length
11351 arrays.  For example, the following will raise @code{Data_Error}:
11353 @smallexample @c ada
11354  package IO is new Sequential_IO (String);
11355  F : IO.File_Type;
11356  S : String (1..4);
11357  @dots{}
11358  IO.Create (F)
11359  IO.Write (F, "hello!")
11360  IO.Reset (F, Mode=>In_File);
11361  IO.Read (F, S);
11362  Put_Line (S);
11364 @end smallexample
11366 @noindent
11367 On some Ada implementations, this will print @code{hell}, but the program is
11368 clearly incorrect, since there is only one element in the file, and that
11369 element is the string @code{hello!}.
11371 In Ada 95, this kind of behavior can be legitimately achieved using
11372 Stream_IO, and this is the preferred mechanism.  In particular, the above
11373 program fragment rewritten to use Stream_IO will work correctly.
11375 @node Text_IO
11376 @section Text_IO
11378 @noindent
11379 Text_IO files consist of a stream of characters containing the following
11380 special control characters:
11382 @smallexample
11383 LF (line feed, 16#0A#) Line Mark
11384 FF (form feed, 16#0C#) Page Mark
11385 @end smallexample
11387 @noindent
11388 A canonical Text_IO file is defined as one in which the following
11389 conditions are met:
11391 @itemize @bullet
11392 @item
11393 The character @code{LF} is used only as a line mark, i.e.@: to mark the end
11394 of the line.
11396 @item
11397 The character @code{FF} is used only as a page mark, i.e.@: to mark the
11398 end of a page and consequently can appear only immediately following a
11399 @code{LF} (line mark) character.
11401 @item
11402 The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
11403 (line mark, page mark).  In the former case, the page mark is implicitly
11404 assumed to be present.
11405 @end itemize
11407 @noindent
11408 A file written using Text_IO will be in canonical form provided that no
11409 explicit @code{LF} or @code{FF} characters are written using @code{Put}
11410 or @code{Put_Line}.  There will be no @code{FF} character at the end of
11411 the file unless an explicit @code{New_Page} operation was performed
11412 before closing the file.
11414 A canonical Text_IO file that is a regular file, i.e.@: not a device or a
11415 pipe, can be read using any of the routines in Text_IO@.  The
11416 semantics in this case will be exactly as defined in the Ada 95 reference
11417 manual and all the routines in Text_IO are fully implemented.
11419 A text file that does not meet the requirements for a canonical Text_IO
11420 file has one of the following:
11422 @itemize @bullet
11423 @item
11424 The file contains @code{FF} characters not immediately following a
11425 @code{LF} character.
11427 @item
11428 The file contains @code{LF} or @code{FF} characters written by
11429 @code{Put} or @code{Put_Line}, which are not logically considered to be
11430 line marks or page marks.
11432 @item
11433 The file ends in a character other than @code{LF} or @code{FF},
11434 i.e.@: there is no explicit line mark or page mark at the end of the file.
11435 @end itemize
11437 @noindent
11438 Text_IO can be used to read such non-standard text files but subprograms
11439 to do with line or page numbers do not have defined meanings.  In
11440 particular, a @code{FF} character that does not follow a @code{LF}
11441 character may or may not be treated as a page mark from the point of
11442 view of page and line numbering.  Every @code{LF} character is considered
11443 to end a line, and there is an implied @code{LF} character at the end of
11444 the file.
11446 @menu
11447 * Text_IO Stream Pointer Positioning::
11448 * Text_IO Reading and Writing Non-Regular Files::
11449 * Get_Immediate::
11450 * Treating Text_IO Files as Streams::
11451 * Text_IO Extensions::
11452 * Text_IO Facilities for Unbounded Strings::
11453 @end menu
11455 @node Text_IO Stream Pointer Positioning
11456 @subsection Stream Pointer Positioning
11458 @noindent
11459 @code{Ada.Text_IO} has a definition of current position for a file that
11460 is being read.  No internal buffering occurs in Text_IO, and usually the
11461 physical position in the stream used to implement the file corresponds
11462 to this logical position defined by Text_IO@.  There are two exceptions:
11464 @itemize @bullet
11465 @item
11466 After a call to @code{End_Of_Page} that returns @code{True}, the stream
11467 is positioned past the @code{LF} (line mark) that precedes the page
11468 mark.  Text_IO maintains an internal flag so that subsequent read
11469 operations properly handle the logical position which is unchanged by
11470 the @code{End_Of_Page} call.
11472 @item
11473 After a call to @code{End_Of_File} that returns @code{True}, if the
11474 Text_IO file was positioned before the line mark at the end of file
11475 before the call, then the logical position is unchanged, but the stream
11476 is physically positioned right at the end of file (past the line mark,
11477 and past a possible page mark following the line mark.  Again Text_IO
11478 maintains internal flags so that subsequent read operations properly
11479 handle the logical position.
11480 @end itemize
11482 @noindent
11483 These discrepancies have no effect on the observable behavior of
11484 Text_IO, but if a single Ada stream is shared between a C program and
11485 Ada program, or shared (using @samp{shared=yes} in the form string)
11486 between two Ada files, then the difference may be observable in some
11487 situations.
11489 @node Text_IO Reading and Writing Non-Regular Files
11490 @subsection Reading and Writing Non-Regular Files
11492 @noindent
11493 A non-regular file is a device (such as a keyboard), or a pipe.  Text_IO
11494 can be used for reading and writing.  Writing is not affected and the
11495 sequence of characters output is identical to the normal file case, but
11496 for reading, the behavior of Text_IO is modified to avoid undesirable
11497 look-ahead as follows:
11499 An input file that is not a regular file is considered to have no page
11500 marks.  Any @code{Ascii.FF} characters (the character normally used for a
11501 page mark) appearing in the file are considered to be data
11502 characters.  In particular:
11504 @itemize @bullet
11505 @item
11506 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
11507 following a line mark.  If a page mark appears, it will be treated as a
11508 data character.
11510 @item
11511 This avoids the need to wait for an extra character to be typed or
11512 entered from the pipe to complete one of these operations.
11514 @item
11515 @code{End_Of_Page} always returns @code{False}
11517 @item
11518 @code{End_Of_File} will return @code{False} if there is a page mark at
11519 the end of the file.
11520 @end itemize
11522 @noindent
11523 Output to non-regular files is the same as for regular files.  Page marks
11524 may be written to non-regular files using @code{New_Page}, but as noted
11525 above they will not be treated as page marks on input if the output is
11526 piped to another Ada program.
11528 Another important discrepancy when reading non-regular files is that the end
11529 of file indication is not ``sticky''.  If an end of file is entered, e.g.@: by
11530 pressing the @key{EOT} key,
11531 then end of file
11532 is signaled once (i.e.@: the test @code{End_Of_File}
11533 will yield @code{True}, or a read will
11534 raise @code{End_Error}), but then reading can resume
11535 to read data past that end of
11536 file indication, until another end of file indication is entered.
11538 @node Get_Immediate
11539 @subsection Get_Immediate
11540 @cindex Get_Immediate
11542 @noindent
11543 Get_Immediate returns the next character (including control characters)
11544 from the input file.  In particular, Get_Immediate will return LF or FF
11545 characters used as line marks or page marks.  Such operations leave the
11546 file positioned past the control character, and it is thus not treated
11547 as having its normal function.  This means that page, line and column
11548 counts after this kind of Get_Immediate call are set as though the mark
11549 did not occur.  In the case where a Get_Immediate leaves the file
11550 positioned between the line mark and page mark (which is not normally
11551 possible), it is undefined whether the FF character will be treated as a
11552 page mark.
11554 @node Treating Text_IO Files as Streams
11555 @subsection Treating Text_IO Files as Streams
11556 @cindex Stream files
11558 @noindent
11559 The package @code{Text_IO.Streams} allows a Text_IO file to be treated
11560 as a stream.  Data written to a Text_IO file in this stream mode is
11561 binary data.  If this binary data contains bytes 16#0A# (@code{LF}) or
11562 16#0C# (@code{FF}), the resulting file may have non-standard
11563 format.  Similarly if read operations are used to read from a Text_IO
11564 file treated as a stream, then @code{LF} and @code{FF} characters may be
11565 skipped and the effect is similar to that described above for
11566 @code{Get_Immediate}.
11568 @node Text_IO Extensions
11569 @subsection Text_IO Extensions
11570 @cindex Text_IO extensions
11572 @noindent
11573 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
11574 to the standard @code{Text_IO} package:
11576 @itemize @bullet
11577 @item function File_Exists (Name : String) return Boolean;
11578 Determines if a file of the given name exists.
11580 @item function Get_Line return String;
11581 Reads a string from the standard input file.  The value returned is exactly
11582 the length of the line that was read.
11584 @item function Get_Line (File : Ada.Text_IO.File_Type) return String;
11585 Similar, except that the parameter File specifies the file from which
11586 the string is to be read.
11588 @end itemize
11590 @node Text_IO Facilities for Unbounded Strings
11591 @subsection Text_IO Facilities for Unbounded Strings
11592 @cindex Text_IO for unbounded strings
11593 @cindex Unbounded_String, Text_IO operations
11595 @noindent
11596 The package @code{Ada.Strings.Unbounded.Text_IO}
11597 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
11598 subprograms useful for Text_IO operations on unbounded strings:
11600 @itemize @bullet
11602 @item function Get_Line (File : File_Type) return Unbounded_String;
11603 Reads a line from the specified file
11604 and returns the result as an unbounded string.
11606 @item procedure Put (File : File_Type; U : Unbounded_String);
11607 Writes the value of the given unbounded string to the specified file
11608 Similar to the effect of
11609 @code{Put (To_String (U))} except that an extra copy is avoided.
11611 @item procedure Put_Line (File : File_Type; U : Unbounded_String);
11612 Writes the value of the given unbounded string to the specified file,
11613 followed by a @code{New_Line}.
11614 Similar to the effect of @code{Put_Line (To_String (U))} except
11615 that an extra copy is avoided.
11616 @end itemize
11618 @noindent
11619 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
11620 and is optional.  If the parameter is omitted, then the standard input or
11621 output file is referenced as appropriate.
11623 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
11624 files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended
11625 @code{Wide_Text_IO} functionality for unbounded wide strings.
11627 The package @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} in library
11628 files @file{a-szuzti.ads} and @file{a-szuzti.adb} provides similar extended
11629 @code{Wide_Wide_Text_IO} functionality for unbounded wide wide strings.
11631 @node Wide_Text_IO
11632 @section Wide_Text_IO
11634 @noindent
11635 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
11636 both input and output files may contain special sequences that represent
11637 wide character values.  The encoding scheme for a given file may be
11638 specified using a FORM parameter:
11640 @smallexample
11641 WCEM=@var{x}
11642 @end smallexample
11644 @noindent
11645 as part of the FORM string (WCEM = wide character encoding method),
11646 where @var{x} is one of the following characters
11648 @table @samp
11649 @item h
11650 Hex ESC encoding
11651 @item u
11652 Upper half encoding
11653 @item s
11654 Shift-JIS encoding
11655 @item e
11656 EUC Encoding
11657 @item 8
11658 UTF-8 encoding
11659 @item b
11660 Brackets encoding
11661 @end table
11663 @noindent
11664 The encoding methods match those that
11665 can be used in a source
11666 program, but there is no requirement that the encoding method used for
11667 the source program be the same as the encoding method used for files,
11668 and different files may use different encoding methods.
11670 The default encoding method for the standard files, and for opened files
11671 for which no WCEM parameter is given in the FORM string matches the
11672 wide character encoding specified for the main program (the default
11673 being brackets encoding if no coding method was specified with -gnatW).
11675 @table @asis
11676 @item Hex Coding
11677 In this encoding, a wide character is represented by a five character
11678 sequence:
11680 @smallexample
11681 ESC a b c d
11682 @end smallexample
11684 @noindent
11685 where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
11686 characters (using upper case letters) of the wide character code.  For
11687 example, ESC A345 is used to represent the wide character with code
11688 16#A345#.  This scheme is compatible with use of the full
11689 @code{Wide_Character} set.
11691 @item Upper Half Coding
11692 The wide character with encoding 16#abcd#, where the upper bit is on
11693 (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
11694 16#cd#.  The second byte may never be a format control character, but is
11695 not required to be in the upper half.  This method can be also used for
11696 shift-JIS or EUC where the internal coding matches the external coding.
11698 @item Shift JIS Coding
11699 A wide character is represented by a two character sequence 16#ab# and
11700 16#cd#, with the restrictions described for upper half encoding as
11701 described above.  The internal character code is the corresponding JIS
11702 character according to the standard algorithm for Shift-JIS
11703 conversion.  Only characters defined in the JIS code set table can be
11704 used with this encoding method.
11706 @item EUC Coding
11707 A wide character is represented by a two character sequence 16#ab# and
11708 16#cd#, with both characters being in the upper half.  The internal
11709 character code is the corresponding JIS character according to the EUC
11710 encoding algorithm.  Only characters defined in the JIS code set table
11711 can be used with this encoding method.
11713 @item UTF-8 Coding
11714 A wide character is represented using
11715 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
11716 10646-1/Am.2.  Depending on the character value, the representation
11717 is a one, two, or three byte sequence:
11719 @smallexample
11720 16#0000#-16#007f#: 2#0xxxxxxx#
11721 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
11722 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
11723 @end smallexample
11725 @noindent
11726 where the xxx bits correspond to the left-padded bits of the
11727 16-bit character value.  Note that all lower half ASCII characters
11728 are represented as ASCII bytes and all upper half characters and
11729 other wide characters are represented as sequences of upper-half
11730 (The full UTF-8 scheme allows for encoding 31-bit characters as
11731 6-byte sequences, but in this implementation, all UTF-8 sequences
11732 of four or more bytes length will raise a Constraint_Error, as
11733 will all invalid UTF-8 sequences.)
11735 @item Brackets Coding
11736 In this encoding, a wide character is represented by the following eight
11737 character sequence:
11739 @smallexample
11740 [ " a b c d " ]
11741 @end smallexample
11743 @noindent
11744 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
11745 characters (using uppercase letters) of the wide character code.  For
11746 example, @code{["A345"]} is used to represent the wide character with code
11747 @code{16#A345#}.
11748 This scheme is compatible with use of the full Wide_Character set.
11749 On input, brackets coding can also be used for upper half characters,
11750 e.g.@: @code{["C1"]} for lower case a.  However, on output, brackets notation
11751 is only used for wide characters with a code greater than @code{16#FF#}.
11753 Note that brackets coding is not normally used in the context of
11754 Wide_Text_IO or Wide_Wide_Text_IO, since it is really just designed as
11755 a portable way of encoding source files. In the context of Wide_Text_IO
11756 or Wide_Wide_Text_IO, it can only be used if the file does not contain
11757 any instance of the left bracket character other than to encode wide
11758 character values using the brackets encoding method. In practice it is
11759 expected that some standard wide character encoding method such
11760 as UTF-8 will be used for text input output.
11762 If brackets notation is used, then any occurrence of a left bracket
11763 in the input file which is not the start of a valid wide character
11764 sequence will cause Constraint_Error to be raised. It is possible to
11765 encode a left bracket as ["5B"] and Wide_Text_IO and Wide_Wide_Text_IO
11766 input will interpret this as a left bracket.
11768 However, when a left bracket is output, it will be output as a left bracket
11769 and not as ["5B"]. We make this decision because for normal use of
11770 Wide_Text_IO for outputting messages, it is unpleasant to clobber left
11771 brackets. For example, if we write:
11773 @smallexample
11774    Put_Line ("Start of output [first run]");
11775 @end smallexample
11777 @noindent
11778 we really do not want to have the left bracket in this message clobbered so
11779 that the output reads:
11781 @smallexample
11782    Start of output ["5B"]first run]
11783 @end smallexample
11785 @noindent
11786 In practice brackets encoding is reasonably useful for normal Put_Line use
11787 since we won't get confused between left brackets and wide character
11788 sequences in the output. But for input, or when files are written out
11789 and read back in, it really makes better sense to use one of the standard
11790 encoding methods such as UTF-8.
11792 @end table
11794 @noindent
11795 For the coding schemes other than UTF-8, Hex, or Brackets encoding,
11796 not all wide character
11797 values can be represented.  An attempt to output a character that cannot
11798 be represented using the encoding scheme for the file causes
11799 Constraint_Error to be raised.  An invalid wide character sequence on
11800 input also causes Constraint_Error to be raised.
11802 @menu
11803 * Wide_Text_IO Stream Pointer Positioning::
11804 * Wide_Text_IO Reading and Writing Non-Regular Files::
11805 @end menu
11807 @node Wide_Text_IO Stream Pointer Positioning
11808 @subsection Stream Pointer Positioning
11810 @noindent
11811 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
11812 of stream pointer positioning (@pxref{Text_IO}).  There is one additional
11813 case:
11815 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
11816 normal lower ASCII set (i.e.@: a character in the range:
11818 @smallexample @c ada
11819 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
11820 @end smallexample
11822 @noindent
11823 then although the logical position of the file pointer is unchanged by
11824 the @code{Look_Ahead} call, the stream is physically positioned past the
11825 wide character sequence.  Again this is to avoid the need for buffering
11826 or backup, and all @code{Wide_Text_IO} routines check the internal
11827 indication that this situation has occurred so that this is not visible
11828 to a normal program using @code{Wide_Text_IO}.  However, this discrepancy
11829 can be observed if the wide text file shares a stream with another file.
11831 @node Wide_Text_IO Reading and Writing Non-Regular Files
11832 @subsection Reading and Writing Non-Regular Files
11834 @noindent
11835 As in the case of Text_IO, when a non-regular file is read, it is
11836 assumed that the file contains no page marks (any form characters are
11837 treated as data characters), and @code{End_Of_Page} always returns
11838 @code{False}.  Similarly, the end of file indication is not sticky, so
11839 it is possible to read beyond an end of file.
11841 @node Wide_Wide_Text_IO
11842 @section Wide_Wide_Text_IO
11844 @noindent
11845 @code{Wide_Wide_Text_IO} is similar in most respects to Text_IO, except that
11846 both input and output files may contain special sequences that represent
11847 wide wide character values.  The encoding scheme for a given file may be
11848 specified using a FORM parameter:
11850 @smallexample
11851 WCEM=@var{x}
11852 @end smallexample
11854 @noindent
11855 as part of the FORM string (WCEM = wide character encoding method),
11856 where @var{x} is one of the following characters
11858 @table @samp
11859 @item h
11860 Hex ESC encoding
11861 @item u
11862 Upper half encoding
11863 @item s
11864 Shift-JIS encoding
11865 @item e
11866 EUC Encoding
11867 @item 8
11868 UTF-8 encoding
11869 @item b
11870 Brackets encoding
11871 @end table
11873 @noindent
11874 The encoding methods match those that
11875 can be used in a source
11876 program, but there is no requirement that the encoding method used for
11877 the source program be the same as the encoding method used for files,
11878 and different files may use different encoding methods.
11880 The default encoding method for the standard files, and for opened files
11881 for which no WCEM parameter is given in the FORM string matches the
11882 wide character encoding specified for the main program (the default
11883 being brackets encoding if no coding method was specified with -gnatW).
11885 @table @asis
11887 @item UTF-8 Coding
11888 A wide character is represented using
11889 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
11890 10646-1/Am.2.  Depending on the character value, the representation
11891 is a one, two, three, or four byte sequence:
11893 @smallexample
11894 16#000000#-16#00007f#: 2#0xxxxxxx#
11895 16#000080#-16#0007ff#: 2#110xxxxx# 2#10xxxxxx#
11896 16#000800#-16#00ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
11897 16#010000#-16#10ffff#: 2#11110xxx# 2#10xxxxxx# 2#10xxxxxx# 2#10xxxxxx#
11898 @end smallexample
11900 @noindent
11901 where the xxx bits correspond to the left-padded bits of the
11902 21-bit character value.  Note that all lower half ASCII characters
11903 are represented as ASCII bytes and all upper half characters and
11904 other wide characters are represented as sequences of upper-half
11905 characters.
11907 @item Brackets Coding
11908 In this encoding, a wide wide character is represented by the following eight
11909 character sequence if is in wide character range
11911 @smallexample
11912 [ " a b c d " ]
11913 @end smallexample
11915 and by the following ten character sequence if not
11917 @smallexample
11918 [ " a b c d e f " ]
11919 @end smallexample
11921 @noindent
11922 where @code{a}, @code{b}, @code{c}, @code{d}, @code{e}, and @code{f}
11923 are the four or six hexadecimal
11924 characters (using uppercase letters) of the wide wide character code.  For
11925 example, @code{["01A345"]} is used to represent the wide wide character
11926 with code @code{16#01A345#}.
11928 This scheme is compatible with use of the full Wide_Wide_Character set.
11929 On input, brackets coding can also be used for upper half characters,
11930 e.g.@: @code{["C1"]} for lower case a.  However, on output, brackets notation
11931 is only used for wide characters with a code greater than @code{16#FF#}.
11933 @end table
11935 @noindent
11936 If is also possible to use the other Wide_Character encoding methods,
11937 such as Shift-JIS, but the other schemes cannot support the full range
11938 of wide wide characters.
11939 An attempt to output a character that cannot
11940 be represented using the encoding scheme for the file causes
11941 Constraint_Error to be raised.  An invalid wide character sequence on
11942 input also causes Constraint_Error to be raised.
11944 @menu
11945 * Wide_Wide_Text_IO Stream Pointer Positioning::
11946 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
11947 @end menu
11949 @node Wide_Wide_Text_IO Stream Pointer Positioning
11950 @subsection Stream Pointer Positioning
11952 @noindent
11953 @code{Ada.Wide_Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
11954 of stream pointer positioning (@pxref{Text_IO}).  There is one additional
11955 case:
11957 If @code{Ada.Wide_Wide_Text_IO.Look_Ahead} reads a character outside the
11958 normal lower ASCII set (i.e.@: a character in the range:
11960 @smallexample @c ada
11961 Wide_Wide_Character'Val (16#0080#) .. Wide_Wide_Character'Val (16#10FFFF#)
11962 @end smallexample
11964 @noindent
11965 then although the logical position of the file pointer is unchanged by
11966 the @code{Look_Ahead} call, the stream is physically positioned past the
11967 wide character sequence.  Again this is to avoid the need for buffering
11968 or backup, and all @code{Wide_Wide_Text_IO} routines check the internal
11969 indication that this situation has occurred so that this is not visible
11970 to a normal program using @code{Wide_Wide_Text_IO}.  However, this discrepancy
11971 can be observed if the wide text file shares a stream with another file.
11973 @node Wide_Wide_Text_IO Reading and Writing Non-Regular Files
11974 @subsection Reading and Writing Non-Regular Files
11976 @noindent
11977 As in the case of Text_IO, when a non-regular file is read, it is
11978 assumed that the file contains no page marks (any form characters are
11979 treated as data characters), and @code{End_Of_Page} always returns
11980 @code{False}.  Similarly, the end of file indication is not sticky, so
11981 it is possible to read beyond an end of file.
11983 @node Stream_IO
11984 @section Stream_IO
11986 @noindent
11987 A stream file is a sequence of bytes, where individual elements are
11988 written to the file as described in the Ada 95 reference manual.  The type
11989 @code{Stream_Element} is simply a byte.  There are two ways to read or
11990 write a stream file.
11992 @itemize @bullet
11993 @item
11994 The operations @code{Read} and @code{Write} directly read or write a
11995 sequence of stream elements with no control information.
11997 @item
11998 The stream attributes applied to a stream file transfer data in the
11999 manner described for stream attributes.
12000 @end itemize
12002 @node Shared Files
12003 @section Shared Files
12005 @noindent
12006 Section A.14 of the Ada 95 Reference Manual allows implementations to
12007 provide a wide variety of behavior if an attempt is made to access the
12008 same external file with two or more internal files.
12010 To provide a full range of functionality, while at the same time
12011 minimizing the problems of portability caused by this implementation
12012 dependence, GNAT handles file sharing as follows:
12014 @itemize @bullet
12015 @item
12016 In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
12017 to open two or more files with the same full name is considered an error
12018 and is not supported.  The exception @code{Use_Error} will be
12019 raised.  Note that a file that is not explicitly closed by the program
12020 remains open until the program terminates.
12022 @item
12023 If the form parameter @samp{shared=no} appears in the form string, the
12024 file can be opened or created with its own separate stream identifier,
12025 regardless of whether other files sharing the same external file are
12026 opened.  The exact effect depends on how the C stream routines handle
12027 multiple accesses to the same external files using separate streams.
12029 @item
12030 If the form parameter @samp{shared=yes} appears in the form string for
12031 each of two or more files opened using the same full name, the same
12032 stream is shared between these files, and the semantics are as described
12033 in Ada 95 Reference Manual, Section A.14.
12034 @end itemize
12036 @noindent
12037 When a program that opens multiple files with the same name is ported
12038 from another Ada compiler to GNAT, the effect will be that
12039 @code{Use_Error} is raised.
12041 The documentation of the original compiler and the documentation of the
12042 program should then be examined to determine if file sharing was
12043 expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
12044 and @code{Create} calls as required.
12046 When a program is ported from GNAT to some other Ada compiler, no
12047 special attention is required unless the @samp{shared=@var{xxx}} form
12048 parameter is used in the program.  In this case, you must examine the
12049 documentation of the new compiler to see if it supports the required
12050 file sharing semantics, and form strings modified appropriately.  Of
12051 course it may be the case that the program cannot be ported if the
12052 target compiler does not support the required functionality.  The best
12053 approach in writing portable code is to avoid file sharing (and hence
12054 the use of the @samp{shared=@var{xxx}} parameter in the form string)
12055 completely.
12057 One common use of file sharing in Ada 83 is the use of instantiations of
12058 Sequential_IO on the same file with different types, to achieve
12059 heterogeneous input-output.  Although this approach will work in GNAT if
12060 @samp{shared=yes} is specified, it is preferable in Ada 95 to use Stream_IO
12061 for this purpose (using the stream attributes)
12063 @node Open Modes
12064 @section Open Modes
12066 @noindent
12067 @code{Open} and @code{Create} calls result in a call to @code{fopen}
12068 using the mode shown in the following table:
12070 @sp 2
12071 @center @code{Open} and @code{Create} Call Modes
12072 @smallexample
12073                                @b{OPEN }           @b{CREATE}
12074 Append_File                    "r+"             "w+"
12075 In_File                        "r"              "w+"
12076 Out_File (Direct_IO)           "r+"             "w"
12077 Out_File (all other cases)     "w"              "w"
12078 Inout_File                     "r+"             "w+"
12079 @end smallexample
12081 @noindent
12082 If text file translation is required, then either @samp{b} or @samp{t}
12083 is added to the mode, depending on the setting of Text.  Text file
12084 translation refers to the mapping of CR/LF sequences in an external file
12085 to LF characters internally.  This mapping only occurs in DOS and
12086 DOS-like systems, and is not relevant to other systems.
12088 A special case occurs with Stream_IO@.  As shown in the above table, the
12089 file is initially opened in @samp{r} or @samp{w} mode for the
12090 @code{In_File} and @code{Out_File} cases.  If a @code{Set_Mode} operation
12091 subsequently requires switching from reading to writing or vice-versa,
12092 then the file is reopened in @samp{r+} mode to permit the required operation.
12094 @node Operations on C Streams
12095 @section Operations on C Streams
12096 The package @code{Interfaces.C_Streams} provides an Ada program with direct
12097 access to the C library functions for operations on C streams:
12099 @smallexample @c adanocomment
12100 package Interfaces.C_Streams is
12101   -- Note: the reason we do not use the types that are in
12102   -- Interfaces.C is that we want to avoid dragging in the
12103   -- code in this unit if possible.
12104   subtype chars is System.Address;
12105   -- Pointer to null-terminated array of characters
12106   subtype FILEs is System.Address;
12107   -- Corresponds to the C type FILE*
12108   subtype voids is System.Address;
12109   -- Corresponds to the C type void*
12110   subtype int is Integer;
12111   subtype long is Long_Integer;
12112   -- Note: the above types are subtypes deliberately, and it
12113   -- is part of this spec that the above correspondences are
12114   -- guaranteed.  This means that it is legitimate to, for
12115   -- example, use Integer instead of int.  We provide these
12116   -- synonyms for clarity, but in some cases it may be
12117   -- convenient to use the underlying types (for example to
12118   -- avoid an unnecessary dependency of a spec on the spec
12119   -- of this unit).
12120   type size_t is mod 2 ** Standard'Address_Size;
12121   NULL_Stream : constant FILEs;
12122   -- Value returned (NULL in C) to indicate an
12123   -- fdopen/fopen/tmpfile error
12124   ----------------------------------
12125   -- Constants Defined in stdio.h --
12126   ----------------------------------
12127   EOF : constant int;
12128   -- Used by a number of routines to indicate error or
12129   -- end of file
12130   IOFBF : constant int;
12131   IOLBF : constant int;
12132   IONBF : constant int;
12133   -- Used to indicate buffering mode for setvbuf call
12134   SEEK_CUR : constant int;
12135   SEEK_END : constant int;
12136   SEEK_SET : constant int;
12137   -- Used to indicate origin for fseek call
12138   function stdin return FILEs;
12139   function stdout return FILEs;
12140   function stderr return FILEs;
12141   -- Streams associated with standard files
12142   --------------------------
12143   -- Standard C functions --
12144   --------------------------
12145   -- The functions selected below are ones that are
12146   -- available in DOS, OS/2, UNIX and Xenix (but not
12147   -- necessarily in ANSI C).  These are very thin interfaces
12148   -- which copy exactly the C headers.  For more
12149   -- documentation on these functions, see the Microsoft C
12150   -- "Run-Time Library Reference" (Microsoft Press, 1990,
12151   -- ISBN 1-55615-225-6), which includes useful information
12152   -- on system compatibility.
12153   procedure clearerr (stream : FILEs);
12154   function fclose (stream : FILEs) return int;
12155   function fdopen (handle : int; mode : chars) return FILEs;
12156   function feof (stream : FILEs) return int;
12157   function ferror (stream : FILEs) return int;
12158   function fflush (stream : FILEs) return int;
12159   function fgetc (stream : FILEs) return int;
12160   function fgets (strng : chars; n : int; stream : FILEs)
12161       return chars;
12162   function fileno (stream : FILEs) return int;
12163   function fopen (filename : chars; Mode : chars)
12164       return FILEs;
12165   -- Note: to maintain target independence, use
12166   -- text_translation_required, a boolean variable defined in
12167   -- a-sysdep.c to deal with the target dependent text
12168   -- translation requirement.  If this variable is set,
12169   -- then  b/t should be appended to the standard mode
12170   -- argument to set the text translation mode off or on
12171   -- as required.
12172   function fputc (C : int; stream : FILEs) return int;
12173   function fputs (Strng : chars; Stream : FILEs) return int;
12174   function fread
12175      (buffer : voids;
12176       size : size_t;
12177       count : size_t;
12178       stream : FILEs)
12179       return size_t;
12180   function freopen
12181      (filename : chars;
12182       mode : chars;
12183       stream : FILEs)
12184       return FILEs;
12185   function fseek
12186      (stream : FILEs;
12187       offset : long;
12188       origin : int)
12189       return int;
12190   function ftell (stream : FILEs) return long;
12191   function fwrite
12192      (buffer : voids;
12193       size : size_t;
12194       count : size_t;
12195       stream : FILEs)
12196       return size_t;
12197   function isatty (handle : int) return int;
12198   procedure mktemp (template : chars);
12199   -- The return value (which is just a pointer to template)
12200   -- is discarded
12201   procedure rewind (stream : FILEs);
12202   function rmtmp return int;
12203   function setvbuf
12204      (stream : FILEs;
12205       buffer : chars;
12206       mode : int;
12207       size : size_t)
12208       return int;
12210   function tmpfile return FILEs;
12211   function ungetc (c : int; stream : FILEs) return int;
12212   function unlink (filename : chars) return int;
12213   ---------------------
12214   -- Extra functions --
12215   ---------------------
12216   -- These functions supply slightly thicker bindings than
12217   -- those above.  They are derived from functions in the
12218   -- C Run-Time Library, but may do a bit more work than
12219   -- just directly calling one of the Library functions.
12220   function is_regular_file (handle : int) return int;
12221   -- Tests if given handle is for a regular file (result 1)
12222   -- or for a non-regular file (pipe or device, result 0).
12223   ---------------------------------
12224   -- Control of Text/Binary Mode --
12225   ---------------------------------
12226   -- If text_translation_required is true, then the following
12227   -- functions may be used to dynamically switch a file from
12228   -- binary to text mode or vice versa.  These functions have
12229   -- no effect if text_translation_required is false (i.e.  in
12230   -- normal UNIX mode).  Use fileno to get a stream handle.
12231   procedure set_binary_mode (handle : int);
12232   procedure set_text_mode (handle : int);
12233   ----------------------------
12234   -- Full Path Name support --
12235   ----------------------------
12236   procedure full_name (nam : chars; buffer : chars);
12237   -- Given a NUL terminated string representing a file
12238   -- name, returns in buffer a NUL terminated string
12239   -- representing the full path name for the file name.
12240   -- On systems where it is relevant the   drive is also
12241   -- part of the full path name.  It is the responsibility
12242   -- of the caller to pass an actual parameter for buffer
12243   -- that is big enough for any full path name.  Use
12244   -- max_path_len given below as the size of buffer.
12245   max_path_len : integer;
12246   -- Maximum length of an allowable full path name on the
12247   -- system, including a terminating NUL character.
12248 end Interfaces.C_Streams;
12249 @end smallexample
12251 @node Interfacing to C Streams
12252 @section Interfacing to C Streams
12254 @noindent
12255 The packages in this section permit interfacing Ada files to C Stream
12256 operations.
12258 @smallexample @c ada
12259  with Interfaces.C_Streams;
12260  package Ada.Sequential_IO.C_Streams is
12261     function C_Stream (F : File_Type)
12262        return Interfaces.C_Streams.FILEs;
12263     procedure Open
12264       (File : in out File_Type;
12265        Mode : in File_Mode;
12266        C_Stream : in Interfaces.C_Streams.FILEs;
12267        Form : in String := "");
12268  end Ada.Sequential_IO.C_Streams;
12270   with Interfaces.C_Streams;
12271   package Ada.Direct_IO.C_Streams is
12272      function C_Stream (F : File_Type)
12273         return Interfaces.C_Streams.FILEs;
12274      procedure Open
12275        (File : in out File_Type;
12276         Mode : in File_Mode;
12277         C_Stream : in Interfaces.C_Streams.FILEs;
12278         Form : in String := "");
12279   end Ada.Direct_IO.C_Streams;
12281   with Interfaces.C_Streams;
12282   package Ada.Text_IO.C_Streams is
12283      function C_Stream (F : File_Type)
12284         return Interfaces.C_Streams.FILEs;
12285      procedure Open
12286        (File : in out File_Type;
12287         Mode : in File_Mode;
12288         C_Stream : in Interfaces.C_Streams.FILEs;
12289         Form : in String := "");
12290   end Ada.Text_IO.C_Streams;
12292   with Interfaces.C_Streams;
12293   package Ada.Wide_Text_IO.C_Streams is
12294      function C_Stream (F : File_Type)
12295         return Interfaces.C_Streams.FILEs;
12296      procedure Open
12297        (File : in out File_Type;
12298         Mode : in File_Mode;
12299         C_Stream : in Interfaces.C_Streams.FILEs;
12300         Form : in String := "");
12301  end Ada.Wide_Text_IO.C_Streams;
12303   with Interfaces.C_Streams;
12304   package Ada.Wide_Wide_Text_IO.C_Streams is
12305      function C_Stream (F : File_Type)
12306         return Interfaces.C_Streams.FILEs;
12307      procedure Open
12308        (File : in out File_Type;
12309         Mode : in File_Mode;
12310         C_Stream : in Interfaces.C_Streams.FILEs;
12311         Form : in String := "");
12312  end Ada.Wide_Wide_Text_IO.C_Streams;
12314  with Interfaces.C_Streams;
12315  package Ada.Stream_IO.C_Streams is
12316     function C_Stream (F : File_Type)
12317        return Interfaces.C_Streams.FILEs;
12318     procedure Open
12319       (File : in out File_Type;
12320        Mode : in File_Mode;
12321        C_Stream : in Interfaces.C_Streams.FILEs;
12322        Form : in String := "");
12323  end Ada.Stream_IO.C_Streams;
12324 @end smallexample
12326 @noindent
12327 In each of these six packages, the @code{C_Stream} function obtains the
12328 @code{FILE} pointer from a currently opened Ada file.  It is then
12329 possible to use the @code{Interfaces.C_Streams} package to operate on
12330 this stream, or the stream can be passed to a C program which can
12331 operate on it directly.  Of course the program is responsible for
12332 ensuring that only appropriate sequences of operations are executed.
12334 One particular use of relevance to an Ada program is that the
12335 @code{setvbuf} function can be used to control the buffering of the
12336 stream used by an Ada file.  In the absence of such a call the standard
12337 default buffering is used.
12339 The @code{Open} procedures in these packages open a file giving an
12340 existing C Stream instead of a file name.  Typically this stream is
12341 imported from a C program, allowing an Ada file to operate on an
12342 existing C file.
12344 @node The GNAT Library
12345 @chapter The GNAT Library
12347 @noindent
12348 The GNAT library contains a number of general and special purpose packages.
12349 It represents functionality that the GNAT developers have found useful, and
12350 which is made available to GNAT users.  The packages described here are fully
12351 supported, and upwards compatibility will be maintained in future releases,
12352 so you can use these facilities with the confidence that the same functionality
12353 will be available in future releases.
12355 The chapter here simply gives a brief summary of the facilities available.
12356 The full documentation is found in the spec file for the package.  The full
12357 sources of these library packages, including both spec and body, are provided
12358 with all GNAT releases.  For example, to find out the full specifications of
12359 the SPITBOL pattern matching capability, including a full tutorial and
12360 extensive examples, look in the @file{g-spipat.ads} file in the library.
12362 For each entry here, the package name (as it would appear in a @code{with}
12363 clause) is given, followed by the name of the corresponding spec file in
12364 parentheses.  The packages are children in four hierarchies, @code{Ada},
12365 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
12366 GNAT-specific hierarchy.
12368 Note that an application program should only use packages in one of these
12369 four hierarchies if the package is defined in the Ada Reference Manual,
12370 or is listed in this section of the GNAT Programmers Reference Manual.
12371 All other units should be considered internal implementation units and
12372 should not be directly @code{with}'ed by application code.  The use of
12373 a @code{with} statement that references one of these internal implementation
12374 units makes an application potentially dependent on changes in versions
12375 of GNAT, and will generate a warning message.
12377 @menu
12378 * Ada.Characters.Latin_9 (a-chlat9.ads)::
12379 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
12380 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
12381 * Ada.Characters.Wide_Wide_Latin_1 (a-czila1.ads)::
12382 * Ada.Characters.Wide_Wide_Latin_9 (a-czila9.ads)::
12383 * Ada.Command_Line.Remove (a-colire.ads)::
12384 * Ada.Command_Line.Environment (a-colien.ads)::
12385 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
12386 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
12387 * Ada.Exceptions.Traceback (a-exctra.ads)::
12388 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
12389 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
12390 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
12391 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
12392 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
12393 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
12394 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
12395 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
12396 * GNAT.Altivec (g-altive.ads)::
12397 * GNAT.Altivec.Conversions (g-altcon.ads)::
12398 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
12399 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
12400 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
12401 * GNAT.Array_Split (g-arrspl.ads)::
12402 * GNAT.AWK (g-awk.ads)::
12403 * GNAT.Bounded_Buffers (g-boubuf.ads)::
12404 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
12405 * GNAT.Bubble_Sort (g-bubsor.ads)::
12406 * GNAT.Bubble_Sort_A (g-busora.ads)::
12407 * GNAT.Bubble_Sort_G (g-busorg.ads)::
12408 * GNAT.Calendar (g-calend.ads)::
12409 * GNAT.Calendar.Time_IO (g-catiio.ads)::
12410 * GNAT.CRC32 (g-crc32.ads)::
12411 * GNAT.Case_Util (g-casuti.ads)::
12412 * GNAT.CGI (g-cgi.ads)::
12413 * GNAT.CGI.Cookie (g-cgicoo.ads)::
12414 * GNAT.CGI.Debug (g-cgideb.ads)::
12415 * GNAT.Command_Line (g-comlin.ads)::
12416 * GNAT.Compiler_Version (g-comver.ads)::
12417 * GNAT.Ctrl_C (g-ctrl_c.ads)::
12418 * GNAT.Current_Exception (g-curexc.ads)::
12419 * GNAT.Debug_Pools (g-debpoo.ads)::
12420 * GNAT.Debug_Utilities (g-debuti.ads)::
12421 * GNAT.Directory_Operations (g-dirope.ads)::
12422 * GNAT.Dynamic_HTables (g-dynhta.ads)::
12423 * GNAT.Dynamic_Tables (g-dyntab.ads)::
12424 * GNAT.Exception_Actions (g-excact.ads)::
12425 * GNAT.Exception_Traces (g-exctra.ads)::
12426 * GNAT.Exceptions (g-except.ads)::
12427 * GNAT.Expect (g-expect.ads)::
12428 * GNAT.Float_Control (g-flocon.ads)::
12429 * GNAT.Heap_Sort (g-heasor.ads)::
12430 * GNAT.Heap_Sort_A (g-hesora.ads)::
12431 * GNAT.Heap_Sort_G (g-hesorg.ads)::
12432 * GNAT.HTable (g-htable.ads)::
12433 * GNAT.IO (g-io.ads)::
12434 * GNAT.IO_Aux (g-io_aux.ads)::
12435 * GNAT.Lock_Files (g-locfil.ads)::
12436 * GNAT.MD5 (g-md5.ads)::
12437 * GNAT.Memory_Dump (g-memdum.ads)::
12438 * GNAT.Most_Recent_Exception (g-moreex.ads)::
12439 * GNAT.OS_Lib (g-os_lib.ads)::
12440 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
12441 * GNAT.Regexp (g-regexp.ads)::
12442 * GNAT.Registry (g-regist.ads)::
12443 * GNAT.Regpat (g-regpat.ads)::
12444 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
12445 * GNAT.Semaphores (g-semaph.ads)::
12446 * GNAT.Signals (g-signal.ads)::
12447 * GNAT.Sockets (g-socket.ads)::
12448 * GNAT.Source_Info (g-souinf.ads)::
12449 * GNAT.Spell_Checker (g-speche.ads)::
12450 * GNAT.Spitbol.Patterns (g-spipat.ads)::
12451 * GNAT.Spitbol (g-spitbo.ads)::
12452 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
12453 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
12454 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
12455 * GNAT.Strings (g-string.ads)::
12456 * GNAT.String_Split (g-strspl.ads)::
12457 * GNAT.UTF_32 (g-utf_32.ads)::
12458 * GNAT.Table (g-table.ads)::
12459 * GNAT.Task_Lock (g-tasloc.ads)::
12460 * GNAT.Threads (g-thread.ads)::
12461 * GNAT.Traceback (g-traceb.ads)::
12462 * GNAT.Traceback.Symbolic (g-trasym.ads)::
12463 * GNAT.Wide_String_Split (g-wistsp.ads)::
12464 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
12465 * Interfaces.C.Extensions (i-cexten.ads)::
12466 * Interfaces.C.Streams (i-cstrea.ads)::
12467 * Interfaces.CPP (i-cpp.ads)::
12468 * Interfaces.Os2lib (i-os2lib.ads)::
12469 * Interfaces.Os2lib.Errors (i-os2err.ads)::
12470 * Interfaces.Os2lib.Synchronization (i-os2syn.ads)::
12471 * Interfaces.Os2lib.Threads (i-os2thr.ads)::
12472 * Interfaces.Packed_Decimal (i-pacdec.ads)::
12473 * Interfaces.VxWorks (i-vxwork.ads)::
12474 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
12475 * System.Address_Image (s-addima.ads)::
12476 * System.Assertions (s-assert.ads)::
12477 * System.Memory (s-memory.ads)::
12478 * System.Partition_Interface (s-parint.ads)::
12479 * System.Restrictions (s-restri.ads)::
12480 * System.Rident (s-rident.ads)::
12481 * System.Task_Info (s-tasinf.ads)::
12482 * System.Wch_Cnv (s-wchcnv.ads)::
12483 * System.Wch_Con (s-wchcon.ads)::
12484 @end menu
12486 @node Ada.Characters.Latin_9 (a-chlat9.ads)
12487 @section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
12488 @cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
12489 @cindex Latin_9 constants for Character
12491 @noindent
12492 This child of @code{Ada.Characters}
12493 provides a set of definitions corresponding to those in the
12494 RM-defined package @code{Ada.Characters.Latin_1} but with the
12495 few modifications required for @code{Latin-9}
12496 The provision of such a package
12497 is specifically authorized by the Ada Reference Manual
12498 (RM A.3(27)).
12500 @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
12501 @section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
12502 @cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
12503 @cindex Latin_1 constants for Wide_Character
12505 @noindent
12506 This child of @code{Ada.Characters}
12507 provides a set of definitions corresponding to those in the
12508 RM-defined package @code{Ada.Characters.Latin_1} but with the
12509 types of the constants being @code{Wide_Character}
12510 instead of @code{Character}.  The provision of such a package
12511 is specifically authorized by the Ada Reference Manual
12512 (RM A.3(27)).
12514 @node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
12515 @section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
12516 @cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
12517 @cindex Latin_9 constants for Wide_Character
12519 @noindent
12520 This child of @code{Ada.Characters}
12521 provides a set of definitions corresponding to those in the
12522 GNAT defined package @code{Ada.Characters.Latin_9} but with the
12523 types of the constants being @code{Wide_Character}
12524 instead of @code{Character}.  The provision of such a package
12525 is specifically authorized by the Ada Reference Manual
12526 (RM A.3(27)).
12528 @node Ada.Characters.Wide_Wide_Latin_1 (a-czila1.ads)
12529 @section @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-czila1.ads})
12530 @cindex @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-czila1.ads})
12531 @cindex Latin_1 constants for Wide_Wide_Character
12533 @noindent
12534 This child of @code{Ada.Characters}
12535 provides a set of definitions corresponding to those in the
12536 RM-defined package @code{Ada.Characters.Latin_1} but with the
12537 types of the constants being @code{Wide_Wide_Character}
12538 instead of @code{Character}.  The provision of such a package
12539 is specifically authorized by the Ada Reference Manual
12540 (RM A.3(27)).
12542 @node Ada.Characters.Wide_Wide_Latin_9 (a-czila9.ads)
12543 @section @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-czila9.ads})
12544 @cindex @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-czila9.ads})
12545 @cindex Latin_9 constants for Wide_Wide_Character
12547 @noindent
12548 This child of @code{Ada.Characters}
12549 provides a set of definitions corresponding to those in the
12550 GNAT defined package @code{Ada.Characters.Latin_9} but with the
12551 types of the constants being @code{Wide_Wide_Character}
12552 instead of @code{Character}.  The provision of such a package
12553 is specifically authorized by the Ada Reference Manual
12554 (RM A.3(27)).
12556 @node Ada.Command_Line.Remove (a-colire.ads)
12557 @section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
12558 @cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
12559 @cindex Removing command line arguments
12560 @cindex Command line, argument removal
12562 @noindent
12563 This child of @code{Ada.Command_Line}
12564 provides a mechanism for logically removing
12565 arguments from the argument list.  Once removed, an argument is not visible
12566 to further calls on the subprograms in @code{Ada.Command_Line} will not
12567 see the removed argument.
12569 @node Ada.Command_Line.Environment (a-colien.ads)
12570 @section @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
12571 @cindex @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
12572 @cindex Environment entries
12574 @noindent
12575 This child of @code{Ada.Command_Line}
12576 provides a mechanism for obtaining environment values on systems
12577 where this concept makes sense.
12579 @node Ada.Direct_IO.C_Streams (a-diocst.ads)
12580 @section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
12581 @cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
12582 @cindex C Streams, Interfacing with Direct_IO
12584 @noindent
12585 This package provides subprograms that allow interfacing between
12586 C streams and @code{Direct_IO}.  The stream identifier can be
12587 extracted from a file opened on the Ada side, and an Ada file
12588 can be constructed from a stream opened on the C side.
12590 @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
12591 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
12592 @cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
12593 @cindex Null_Occurrence, testing for
12595 @noindent
12596 This child subprogram provides a way of testing for the null
12597 exception occurrence (@code{Null_Occurrence}) without raising
12598 an exception.
12600 @node Ada.Exceptions.Traceback (a-exctra.ads)
12601 @section @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
12602 @cindex @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
12603 @cindex Traceback for Exception Occurrence
12605 @noindent
12606 This child package provides the subprogram (@code{Tracebacks}) to
12607 give a traceback array of addresses based on an exception
12608 occurrence.
12610 @node Ada.Sequential_IO.C_Streams (a-siocst.ads)
12611 @section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
12612 @cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
12613 @cindex C Streams, Interfacing with Sequential_IO
12615 @noindent
12616 This package provides subprograms that allow interfacing between
12617 C streams and @code{Sequential_IO}.  The stream identifier can be
12618 extracted from a file opened on the Ada side, and an Ada file
12619 can be constructed from a stream opened on the C side.
12621 @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
12622 @section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
12623 @cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
12624 @cindex C Streams, Interfacing with Stream_IO
12626 @noindent
12627 This package provides subprograms that allow interfacing between
12628 C streams and @code{Stream_IO}.  The stream identifier can be
12629 extracted from a file opened on the Ada side, and an Ada file
12630 can be constructed from a stream opened on the C side.
12632 @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
12633 @section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
12634 @cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
12635 @cindex @code{Unbounded_String}, IO support
12636 @cindex @code{Text_IO}, extensions for unbounded strings
12638 @noindent
12639 This package provides subprograms for Text_IO for unbounded
12640 strings, avoiding the necessity for an intermediate operation
12641 with ordinary strings.
12643 @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
12644 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
12645 @cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
12646 @cindex @code{Unbounded_Wide_String}, IO support
12647 @cindex @code{Text_IO}, extensions for unbounded wide strings
12649 @noindent
12650 This package provides subprograms for Text_IO for unbounded
12651 wide strings, avoiding the necessity for an intermediate operation
12652 with ordinary wide strings.
12654 @node Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)
12655 @section @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
12656 @cindex @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
12657 @cindex @code{Unbounded_Wide_Wide_String}, IO support
12658 @cindex @code{Text_IO}, extensions for unbounded wide wide strings
12660 @noindent
12661 This package provides subprograms for Text_IO for unbounded
12662 wide wide strings, avoiding the necessity for an intermediate operation
12663 with ordinary wide wide strings.
12665 @node Ada.Text_IO.C_Streams (a-tiocst.ads)
12666 @section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
12667 @cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
12668 @cindex C Streams, Interfacing with @code{Text_IO}
12670 @noindent
12671 This package provides subprograms that allow interfacing between
12672 C streams and @code{Text_IO}.  The stream identifier can be
12673 extracted from a file opened on the Ada side, and an Ada file
12674 can be constructed from a stream opened on the C side.
12676 @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
12677 @section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
12678 @cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
12679 @cindex C Streams, Interfacing with @code{Wide_Text_IO}
12681 @noindent
12682 This package provides subprograms that allow interfacing between
12683 C streams and @code{Wide_Text_IO}.  The stream identifier can be
12684 extracted from a file opened on the Ada side, and an Ada file
12685 can be constructed from a stream opened on the C side.
12687 @node Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)
12688 @section @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
12689 @cindex @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
12690 @cindex C Streams, Interfacing with @code{Wide_Wide_Text_IO}
12692 @noindent
12693 This package provides subprograms that allow interfacing between
12694 C streams and @code{Wide_Wide_Text_IO}.  The stream identifier can be
12695 extracted from a file opened on the Ada side, and an Ada file
12696 can be constructed from a stream opened on the C side.
12698 @node GNAT.Altivec (g-altive.ads)
12699 @section @code{GNAT.Altivec} (@file{g-altive.ads})
12700 @cindex @code{GNAT.Altivec} (@file{g-altive.ads})
12701 @cindex AltiVec
12703 @noindent
12704 This is the root package of the GNAT AltiVec binding. It provides
12705 definitions of constants and types common to all the versions of the
12706 binding.
12708 @node GNAT.Altivec.Conversions (g-altcon.ads)
12709 @section @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
12710 @cindex @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
12711 @cindex AltiVec
12713 @noindent
12714 This package provides the Vector/View conversion routines.
12716 @node GNAT.Altivec.Vector_Operations (g-alveop.ads)
12717 @section @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
12718 @cindex @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
12719 @cindex AltiVec
12721 @noindent
12722 This package exposes the Ada interface to the AltiVec operations on
12723 vector objects. A soft emulation is included by default in the GNAT
12724 library. The hard binding is provided as a separate package. This unit
12725 is common to both bindings.
12727 @node GNAT.Altivec.Vector_Types (g-alvety.ads)
12728 @section @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
12729 @cindex @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
12730 @cindex AltiVec
12732 @noindent
12733 This package exposes the various vector types part of the Ada binding
12734 to AltiVec facilities.
12736 @node GNAT.Altivec.Vector_Views (g-alvevi.ads)
12737 @section @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
12738 @cindex @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
12739 @cindex AltiVec
12741 @noindent
12742 This package provides public 'View' data types from/to which private
12743 vector representations can be converted via
12744 GNAT.Altivec.Conversions. This allows convenient access to individual
12745 vector elements and provides a simple way to initialize vector
12746 objects.
12748 @node GNAT.Array_Split (g-arrspl.ads)
12749 @section @code{GNAT.Array_Split} (@file{g-arrspl.ads})
12750 @cindex @code{GNAT.Array_Split} (@file{g-arrspl.ads})
12751 @cindex Array splitter
12753 @noindent
12754 Useful array-manipulation routines: given a set of separators, split
12755 an array wherever the separators appear, and provide direct access
12756 to the resulting slices.
12758 @node GNAT.AWK (g-awk.ads)
12759 @section @code{GNAT.AWK} (@file{g-awk.ads})
12760 @cindex @code{GNAT.AWK} (@file{g-awk.ads})
12761 @cindex Parsing
12762 @cindex AWK
12764 @noindent
12765 Provides AWK-like parsing functions, with an easy interface for parsing one
12766 or more files containing formatted data.  The file is viewed as a database
12767 where each record is a line and a field is a data element in this line.
12769 @node GNAT.Bounded_Buffers (g-boubuf.ads)
12770 @section @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
12771 @cindex @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
12772 @cindex Parsing
12773 @cindex Bounded Buffers
12775 @noindent
12776 Provides a concurrent generic bounded buffer abstraction.  Instances are
12777 useful directly or as parts of the implementations of other abstractions,
12778 such as mailboxes.
12780 @node GNAT.Bounded_Mailboxes (g-boumai.ads)
12781 @section @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
12782 @cindex @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
12783 @cindex Parsing
12784 @cindex Mailboxes
12786 @noindent
12787 Provides a thread-safe asynchronous intertask mailbox communication facility.
12789 @node GNAT.Bubble_Sort (g-bubsor.ads)
12790 @section @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
12791 @cindex @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
12792 @cindex Sorting
12793 @cindex Bubble sort
12795 @noindent
12796 Provides a general implementation of bubble sort usable for sorting arbitrary
12797 data items.  Exchange and comparison procedures are provided by passing
12798 access-to-procedure values.
12800 @node GNAT.Bubble_Sort_A (g-busora.ads)
12801 @section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
12802 @cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
12803 @cindex Sorting
12804 @cindex Bubble sort
12806 @noindent
12807 Provides a general implementation of bubble sort usable for sorting arbitrary
12808 data items.  Move and comparison procedures are provided by passing
12809 access-to-procedure values. This is an older version, retained for
12810 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
12812 @node GNAT.Bubble_Sort_G (g-busorg.ads)
12813 @section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
12814 @cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
12815 @cindex Sorting
12816 @cindex Bubble sort
12818 @noindent
12819 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
12820 are provided as generic parameters, this improves efficiency, especially
12821 if the procedures can be inlined, at the expense of duplicating code for
12822 multiple instantiations.
12824 @node GNAT.Calendar (g-calend.ads)
12825 @section @code{GNAT.Calendar} (@file{g-calend.ads})
12826 @cindex @code{GNAT.Calendar} (@file{g-calend.ads})
12827 @cindex @code{Calendar}
12829 @noindent
12830 Extends the facilities provided by @code{Ada.Calendar} to include handling
12831 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
12832 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
12833 C @code{timeval} format.
12835 @node GNAT.Calendar.Time_IO (g-catiio.ads)
12836 @section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
12837 @cindex @code{Calendar}
12838 @cindex Time
12839 @cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
12841 @node GNAT.CRC32 (g-crc32.ads)
12842 @section @code{GNAT.CRC32} (@file{g-crc32.ads})
12843 @cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
12844 @cindex CRC32
12845 @cindex Cyclic Redundancy Check
12847 @noindent
12848 This package implements the CRC-32 algorithm.  For a full description
12849 of this algorithm see
12850 ``Computation of Cyclic Redundancy Checks via Table Look-Up'',
12851 @cite{Communications of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013,
12852 Aug.@: 1988.  Sarwate, D.V@.
12854 @noindent
12855 Provides an extended capability for formatted output of time values with
12856 full user control over the format.  Modeled on the GNU Date specification.
12858 @node GNAT.Case_Util (g-casuti.ads)
12859 @section @code{GNAT.Case_Util} (@file{g-casuti.ads})
12860 @cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
12861 @cindex Casing utilities
12862 @cindex Character handling (@code{GNAT.Case_Util})
12864 @noindent
12865 A set of simple routines for handling upper and lower casing of strings
12866 without the overhead of the full casing tables
12867 in @code{Ada.Characters.Handling}.
12869 @node GNAT.CGI (g-cgi.ads)
12870 @section @code{GNAT.CGI} (@file{g-cgi.ads})
12871 @cindex @code{GNAT.CGI} (@file{g-cgi.ads})
12872 @cindex CGI (Common Gateway Interface)
12874 @noindent
12875 This is a package for interfacing a GNAT program with a Web server via the
12876 Common Gateway Interface (CGI)@.  Basically this package parses the CGI
12877 parameters, which are a set of key/value pairs sent by the Web server.  It
12878 builds a table whose index is the key and provides some services to deal
12879 with this table.
12881 @node GNAT.CGI.Cookie (g-cgicoo.ads)
12882 @section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
12883 @cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
12884 @cindex CGI (Common Gateway Interface) cookie support
12885 @cindex Cookie support in CGI
12887 @noindent
12888 This is a package to interface a GNAT program with a Web server via the
12889 Common Gateway Interface (CGI).  It exports services to deal with Web
12890 cookies (piece of information kept in the Web client software).
12892 @node GNAT.CGI.Debug (g-cgideb.ads)
12893 @section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
12894 @cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
12895 @cindex CGI (Common Gateway Interface) debugging
12897 @noindent
12898 This is a package to help debugging CGI (Common Gateway Interface)
12899 programs written in Ada.
12901 @node GNAT.Command_Line (g-comlin.ads)
12902 @section @code{GNAT.Command_Line} (@file{g-comlin.ads})
12903 @cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
12904 @cindex Command line
12906 @noindent
12907 Provides a high level interface to @code{Ada.Command_Line} facilities,
12908 including the ability to scan for named switches with optional parameters
12909 and expand file names using wild card notations.
12911 @node GNAT.Compiler_Version (g-comver.ads)
12912 @section @code{GNAT.Compiler_Version} (@file{g-comver.ads})
12913 @cindex @code{GNAT.Compiler_Version} (@file{g-comver.ads})
12914 @cindex Compiler Version
12915 @cindex Version, of compiler
12917 @noindent
12918 Provides a routine for obtaining the version of the compiler used to
12919 compile the program. More accurately this is the version of the binder
12920 used to bind the program (this will normally be the same as the version
12921 of the compiler if a consistent tool set is used to compile all units
12922 of a partition).
12924 @node GNAT.Ctrl_C (g-ctrl_c.ads)
12925 @section @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
12926 @cindex @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
12927 @cindex Interrupt
12929 @noindent
12930 Provides a simple interface to handle Ctrl-C keyboard events.
12932 @node GNAT.Current_Exception (g-curexc.ads)
12933 @section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
12934 @cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
12935 @cindex Current exception
12936 @cindex Exception retrieval
12938 @noindent
12939 Provides access to information on the current exception that has been raised
12940 without the need for using the Ada-95 exception choice parameter specification
12941 syntax.  This is particularly useful in simulating typical facilities for
12942 obtaining information about exceptions provided by Ada 83 compilers.
12944 @node GNAT.Debug_Pools (g-debpoo.ads)
12945 @section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
12946 @cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
12947 @cindex Debugging
12948 @cindex Debug pools
12949 @cindex Memory corruption debugging
12951 @noindent
12952 Provide a debugging storage pools that helps tracking memory corruption
12953 problems.  See section ``Finding memory problems with GNAT Debug Pool'' in
12954 the @cite{GNAT User's Guide}.
12956 @node GNAT.Debug_Utilities (g-debuti.ads)
12957 @section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
12958 @cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
12959 @cindex Debugging
12961 @noindent
12962 Provides a few useful utilities for debugging purposes, including conversion
12963 to and from string images of address values. Supports both C and Ada formats
12964 for hexadecimal literals.
12966 @node GNAT.Directory_Operations (g-dirope.ads)
12967 @section @code{GNAT.Directory_Operations} (g-dirope.ads)
12968 @cindex @code{GNAT.Directory_Operations} (g-dirope.ads)
12969 @cindex Directory operations
12971 @noindent
12972 Provides a set of routines for manipulating directories, including changing
12973 the current directory, making new directories, and scanning the files in a
12974 directory.
12976 @node GNAT.Dynamic_HTables (g-dynhta.ads)
12977 @section @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
12978 @cindex @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
12979 @cindex Hash tables
12981 @noindent
12982 A generic implementation of hash tables that can be used to hash arbitrary
12983 data.  Provided in two forms, a simple form with built in hash functions,
12984 and a more complex form in which the hash function is supplied.
12986 @noindent
12987 This package provides a facility similar to that of @code{GNAT.HTable},
12988 except that this package declares a type that can be used to define
12989 dynamic instances of the hash table, while an instantiation of
12990 @code{GNAT.HTable} creates a single instance of the hash table.
12992 @node GNAT.Dynamic_Tables (g-dyntab.ads)
12993 @section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
12994 @cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
12995 @cindex Table implementation
12996 @cindex Arrays, extendable
12998 @noindent
12999 A generic package providing a single dimension array abstraction where the
13000 length of the array can be dynamically modified.
13002 @noindent
13003 This package provides a facility similar to that of @code{GNAT.Table},
13004 except that this package declares a type that can be used to define
13005 dynamic instances of the table, while an instantiation of
13006 @code{GNAT.Table} creates a single instance of the table type.
13008 @node GNAT.Exception_Actions (g-excact.ads)
13009 @section @code{GNAT.Exception_Actions} (@file{g-excact.ads})
13010 @cindex @code{GNAT.Exception_Actions} (@file{g-excact.ads})
13011 @cindex Exception actions
13013 @noindent
13014 Provides callbacks when an exception is raised. Callbacks can be registered
13015 for specific exceptions, or when any exception is raised. This
13016 can be used for instance to force a core dump to ease debugging.
13018 @node GNAT.Exception_Traces (g-exctra.ads)
13019 @section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
13020 @cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
13021 @cindex Exception traces
13022 @cindex Debugging
13024 @noindent
13025 Provides an interface allowing to control automatic output upon exception
13026 occurrences.
13028 @node GNAT.Exceptions (g-except.ads)
13029 @section @code{GNAT.Exceptions} (@file{g-expect.ads})
13030 @cindex @code{GNAT.Exceptions} (@file{g-expect.ads})
13031 @cindex Exceptions, Pure
13032 @cindex Pure packages, exceptions
13034 @noindent
13035 Normally it is not possible to raise an exception with
13036 a message from a subprogram in a pure package, since the
13037 necessary types and subprograms are in @code{Ada.Exceptions}
13038 which is not a pure unit. @code{GNAT.Exceptions} provides a
13039 facility for getting around this limitation for a few
13040 predefined exceptions, and for example allow raising
13041 @code{Constraint_Error} with a message from a pure subprogram.
13043 @node GNAT.Expect (g-expect.ads)
13044 @section @code{GNAT.Expect} (@file{g-expect.ads})
13045 @cindex @code{GNAT.Expect} (@file{g-expect.ads})
13047 @noindent
13048 Provides a set of subprograms similar to what is available
13049 with the standard Tcl Expect tool.
13050 It allows you to easily spawn and communicate with an external process.
13051 You can send commands or inputs to the process, and compare the output
13052 with some expected regular expression. Currently @code{GNAT.Expect}
13053 is implemented on all native GNAT ports except for OpenVMS@.
13054 It is not implemented for cross ports, and in particular is not
13055 implemented for VxWorks or LynxOS@.
13057 @node GNAT.Float_Control (g-flocon.ads)
13058 @section @code{GNAT.Float_Control} (@file{g-flocon.ads})
13059 @cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
13060 @cindex Floating-Point Processor
13062 @noindent
13063 Provides an interface for resetting the floating-point processor into the
13064 mode required for correct semantic operation in Ada.  Some third party
13065 library calls may cause this mode to be modified, and the Reset procedure
13066 in this package can be used to reestablish the required mode.
13068 @node GNAT.Heap_Sort (g-heasor.ads)
13069 @section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
13070 @cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
13071 @cindex Sorting
13073 @noindent
13074 Provides a general implementation of heap sort usable for sorting arbitrary
13075 data items. Exchange and comparison procedures are provided by passing
13076 access-to-procedure values.  The algorithm used is a modified heap sort
13077 that performs approximately N*log(N) comparisons in the worst case.
13079 @node GNAT.Heap_Sort_A (g-hesora.ads)
13080 @section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
13081 @cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
13082 @cindex Sorting
13084 @noindent
13085 Provides a general implementation of heap sort usable for sorting arbitrary
13086 data items. Move and comparison procedures are provided by passing
13087 access-to-procedure values.  The algorithm used is a modified heap sort
13088 that performs approximately N*log(N) comparisons in the worst case.
13089 This differs from @code{GNAT.Heap_Sort} in having a less convenient
13090 interface, but may be slightly more efficient.
13092 @node GNAT.Heap_Sort_G (g-hesorg.ads)
13093 @section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
13094 @cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
13095 @cindex Sorting
13097 @noindent
13098 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
13099 are provided as generic parameters, this improves efficiency, especially
13100 if the procedures can be inlined, at the expense of duplicating code for
13101 multiple instantiations.
13103 @node GNAT.HTable (g-htable.ads)
13104 @section @code{GNAT.HTable} (@file{g-htable.ads})
13105 @cindex @code{GNAT.HTable} (@file{g-htable.ads})
13106 @cindex Hash tables
13108 @noindent
13109 A generic implementation of hash tables that can be used to hash arbitrary
13110 data.  Provides two approaches, one a simple static approach, and the other
13111 allowing arbitrary dynamic hash tables.
13113 @node GNAT.IO (g-io.ads)
13114 @section @code{GNAT.IO} (@file{g-io.ads})
13115 @cindex @code{GNAT.IO} (@file{g-io.ads})
13116 @cindex Simple I/O
13117 @cindex Input/Output facilities
13119 @noindent
13120 A simple preelaborable input-output package that provides a subset of
13121 simple Text_IO functions for reading characters and strings from
13122 Standard_Input, and writing characters, strings and integers to either
13123 Standard_Output or Standard_Error.
13125 @node GNAT.IO_Aux (g-io_aux.ads)
13126 @section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
13127 @cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
13128 @cindex Text_IO
13129 @cindex Input/Output facilities
13131 Provides some auxiliary functions for use with Text_IO, including a test
13132 for whether a file exists, and functions for reading a line of text.
13134 @node GNAT.Lock_Files (g-locfil.ads)
13135 @section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
13136 @cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
13137 @cindex File locking
13138 @cindex Locking using files
13140 @noindent
13141 Provides a general interface for using files as locks.  Can be used for
13142 providing program level synchronization.
13144 @node GNAT.MD5 (g-md5.ads)
13145 @section @code{GNAT.MD5} (@file{g-md5.ads})
13146 @cindex @code{GNAT.MD5} (@file{g-md5.ads})
13147 @cindex Message Digest MD5
13149 @noindent
13150 Implements the MD5 Message-Digest Algorithm as described in RFC 1321.
13152 @node GNAT.Memory_Dump (g-memdum.ads)
13153 @section @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
13154 @cindex @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
13155 @cindex Dump Memory
13157 @noindent
13158 Provides a convenient routine for dumping raw memory to either the
13159 standard output or standard error files. Uses GNAT.IO for actual
13160 output.
13162 @node GNAT.Most_Recent_Exception (g-moreex.ads)
13163 @section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
13164 @cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
13165 @cindex Exception, obtaining most recent
13167 @noindent
13168 Provides access to the most recently raised exception.  Can be used for
13169 various logging purposes, including duplicating functionality of some
13170 Ada 83 implementation dependent extensions.
13172 @node GNAT.OS_Lib (g-os_lib.ads)
13173 @section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
13174 @cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
13175 @cindex Operating System interface
13176 @cindex Spawn capability
13178 @noindent
13179 Provides a range of target independent operating system interface functions,
13180 including time/date management, file operations, subprocess management,
13181 including a portable spawn procedure, and access to environment variables
13182 and error return codes.
13184 @node GNAT.Perfect_Hash_Generators (g-pehage.ads)
13185 @section @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
13186 @cindex @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
13187 @cindex Hash functions
13189 @noindent
13190 Provides a generator of static minimal perfect hash functions. No
13191 collisions occur and each item can be retrieved from the table in one
13192 probe (perfect property). The hash table size corresponds to the exact
13193 size of the key set and no larger (minimal property). The key set has to
13194 be know in advance (static property). The hash functions are also order
13195 preserving. If w2 is inserted after w1 in the generator, their
13196 hashcode are in the same order. These hashing functions are very
13197 convenient for use with realtime applications.
13199 @node GNAT.Regexp (g-regexp.ads)
13200 @section @code{GNAT.Regexp} (@file{g-regexp.ads})
13201 @cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
13202 @cindex Regular expressions
13203 @cindex Pattern matching
13205 @noindent
13206 A simple implementation of regular expressions, using a subset of regular
13207 expression syntax copied from familiar Unix style utilities.  This is the
13208 simples of the three pattern matching packages provided, and is particularly
13209 suitable for ``file globbing'' applications.
13211 @node GNAT.Registry (g-regist.ads)
13212 @section @code{GNAT.Registry} (@file{g-regist.ads})
13213 @cindex @code{GNAT.Registry} (@file{g-regist.ads})
13214 @cindex Windows Registry
13216 @noindent
13217 This is a high level binding to the Windows registry.  It is possible to
13218 do simple things like reading a key value, creating a new key.  For full
13219 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
13220 package provided with the Win32Ada binding
13222 @node GNAT.Regpat (g-regpat.ads)
13223 @section @code{GNAT.Regpat} (@file{g-regpat.ads})
13224 @cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
13225 @cindex Regular expressions
13226 @cindex Pattern matching
13228 @noindent
13229 A complete implementation of Unix-style regular expression matching, copied
13230 from the original V7 style regular expression library written in C by
13231 Henry Spencer (and binary compatible with this C library).
13233 @node GNAT.Secondary_Stack_Info (g-sestin.ads)
13234 @section @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
13235 @cindex @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
13236 @cindex Secondary Stack Info
13238 @noindent
13239 Provide the capability to query the high water mark of the current task's
13240 secondary stack.
13242 @node GNAT.Semaphores (g-semaph.ads)
13243 @section @code{GNAT.Semaphores} (@file{g-semaph.ads})
13244 @cindex @code{GNAT.Semaphores} (@file{g-semaph.ads})
13245 @cindex Semaphores
13247 @noindent
13248 Provides classic counting and binary semaphores using protected types.
13250 @node GNAT.Signals (g-signal.ads)
13251 @section @code{GNAT.Signals} (@file{g-signal.ads})
13252 @cindex @code{GNAT.Signals} (@file{g-signal.ads})
13253 @cindex Signals
13255 @noindent
13256 Provides the ability to manipulate the blocked status of signals on supported
13257 targets.
13259 @node GNAT.Sockets (g-socket.ads)
13260 @section @code{GNAT.Sockets} (@file{g-socket.ads})
13261 @cindex @code{GNAT.Sockets} (@file{g-socket.ads})
13262 @cindex Sockets
13264 @noindent
13265 A high level and portable interface to develop sockets based applications.
13266 This package is based on the sockets thin binding found in
13267 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
13268 on all native GNAT ports except for OpenVMS@.  It is not implemented
13269 for the LynxOS@ cross port.
13271 @node GNAT.Source_Info (g-souinf.ads)
13272 @section @code{GNAT.Source_Info} (@file{g-souinf.ads})
13273 @cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
13274 @cindex Source Information
13276 @noindent
13277 Provides subprograms that give access to source code information known at
13278 compile time, such as the current file name and line number.
13280 @node GNAT.Spell_Checker (g-speche.ads)
13281 @section @code{GNAT.Spell_Checker} (@file{g-speche.ads})
13282 @cindex @code{GNAT.Spell_Checker} (@file{g-speche.ads})
13283 @cindex Spell checking
13285 @noindent
13286 Provides a function for determining whether one string is a plausible
13287 near misspelling of another string.
13289 @node GNAT.Spitbol.Patterns (g-spipat.ads)
13290 @section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
13291 @cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
13292 @cindex SPITBOL pattern matching
13293 @cindex Pattern matching
13295 @noindent
13296 A complete implementation of SNOBOL4 style pattern matching.  This is the
13297 most elaborate of the pattern matching packages provided.  It fully duplicates
13298 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
13299 efficient algorithm developed by Robert Dewar for the SPITBOL system.
13301 @node GNAT.Spitbol (g-spitbo.ads)
13302 @section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
13303 @cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
13304 @cindex SPITBOL interface
13306 @noindent
13307 The top level package of the collection of SPITBOL-style functionality, this
13308 package provides basic SNOBOL4 string manipulation functions, such as
13309 Pad, Reverse, Trim, Substr capability, as well as a generic table function
13310 useful for constructing arbitrary mappings from strings in the style of
13311 the SNOBOL4 TABLE function.
13313 @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
13314 @section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
13315 @cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
13316 @cindex Sets of strings
13317 @cindex SPITBOL Tables
13319 @noindent
13320 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
13321 for type @code{Standard.Boolean}, giving an implementation of sets of
13322 string values.
13324 @node GNAT.Spitbol.Table_Integer (g-sptain.ads)
13325 @section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
13326 @cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
13327 @cindex Integer maps
13328 @cindex Maps
13329 @cindex SPITBOL Tables
13331 @noindent
13332 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
13333 for type @code{Standard.Integer}, giving an implementation of maps
13334 from string to integer values.
13336 @node GNAT.Spitbol.Table_VString (g-sptavs.ads)
13337 @section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
13338 @cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
13339 @cindex String maps
13340 @cindex Maps
13341 @cindex SPITBOL Tables
13343 @noindent
13344 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
13345 a variable length string type, giving an implementation of general
13346 maps from strings to strings.
13348 @node GNAT.Strings (g-string.ads)
13349 @section @code{GNAT.Strings} (@file{g-string.ads})
13350 @cindex @code{GNAT.Strings} (@file{g-string.ads})
13352 @noindent
13353 Common String access types and related subprograms. Basically it
13354 defines a string access and an array of string access types.
13356 @node GNAT.String_Split (g-strspl.ads)
13357 @section @code{GNAT.String_Split} (@file{g-strspl.ads})
13358 @cindex @code{GNAT.String_Split} (@file{g-strspl.ads})
13359 @cindex String splitter
13361 @noindent
13362 Useful string manipulation routines: given a set of separators, split
13363 a string wherever the separators appear, and provide direct access
13364 to the resulting slices. This package is instantiated from
13365 @code{GNAT.Array_Split}.
13367 @node GNAT.UTF_32 (g-utf_32.ads)
13368 @section @code{GNAT.UTF_32} (@file{g-table.ads})
13369 @cindex @code{GNAT.UTF_32} (@file{g-table.ads})
13370 @cindex Wide character codes
13372 @noindent
13373 This is a package intended to be used in conjunction with the
13374 @code{Wide_Character} type in Ada 95 and the
13375 @code{Wide_Wide_Character} type in Ada 2005 (available
13376 in @code{GNAT} in Ada 2005 mode). This package contains
13377 Unicode categorization routines, as well as lexical
13378 categorization routines corresponding to the Ada 2005
13379 lexical rules for identifiers and strings, and also a
13380 lower case to upper case fold routine corresponding to
13381 the Ada 2005 rules for identifier equivalence.
13383 @node GNAT.Table (g-table.ads)
13384 @section @code{GNAT.Table} (@file{g-table.ads})
13385 @cindex @code{GNAT.Table} (@file{g-table.ads})
13386 @cindex Table implementation
13387 @cindex Arrays, extendable
13389 @noindent
13390 A generic package providing a single dimension array abstraction where the
13391 length of the array can be dynamically modified.
13393 @noindent
13394 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
13395 except that this package declares a single instance of the table type,
13396 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
13397 used to define dynamic instances of the table.
13399 @node GNAT.Task_Lock (g-tasloc.ads)
13400 @section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
13401 @cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
13402 @cindex Task synchronization
13403 @cindex Task locking
13404 @cindex Locking
13406 @noindent
13407 A very simple facility for locking and unlocking sections of code using a
13408 single global task lock.  Appropriate for use in situations where contention
13409 between tasks is very rarely expected.
13411 @node GNAT.Threads (g-thread.ads)
13412 @section @code{GNAT.Threads} (@file{g-thread.ads})
13413 @cindex @code{GNAT.Threads} (@file{g-thread.ads})
13414 @cindex Foreign threads
13415 @cindex Threads, foreign
13417 @noindent
13418 Provides facilities for creating and destroying threads with explicit calls.
13419 These threads are known to the GNAT run-time system.  These subprograms are
13420 exported C-convention procedures intended to be called from foreign code.
13421 By using these primitives rather than directly calling operating systems
13422 routines, compatibility with the Ada tasking run-time is provided.
13424 @node GNAT.Traceback (g-traceb.ads)
13425 @section @code{GNAT.Traceback} (@file{g-traceb.ads})
13426 @cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
13427 @cindex Trace back facilities
13429 @noindent
13430 Provides a facility for obtaining non-symbolic traceback information, useful
13431 in various debugging situations.
13433 @node GNAT.Traceback.Symbolic (g-trasym.ads)
13434 @section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
13435 @cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
13436 @cindex Trace back facilities
13438 @noindent
13439 Provides symbolic traceback information that includes the subprogram
13440 name and line number information.
13442 @node GNAT.Wide_String_Split (g-wistsp.ads)
13443 @section @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
13444 @cindex @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
13445 @cindex Wide_String splitter
13447 @noindent
13448 Useful wide string manipulation routines: given a set of separators, split
13449 a wide string wherever the separators appear, and provide direct access
13450 to the resulting slices. This package is instantiated from
13451 @code{GNAT.Array_Split}.
13453 @node GNAT.Wide_Wide_String_Split (g-zistsp.ads)
13454 @section @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
13455 @cindex @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
13456 @cindex Wide_Wide_String splitter
13458 @noindent
13459 Useful wide wide string manipulation routines: given a set of separators, split
13460 a wide wide string wherever the separators appear, and provide direct access
13461 to the resulting slices. This package is instantiated from
13462 @code{GNAT.Array_Split}.
13464 @node Interfaces.C.Extensions (i-cexten.ads)
13465 @section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
13466 @cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
13468 @noindent
13469 This package contains additional C-related definitions, intended
13470 for use with either manually or automatically generated bindings
13471 to C libraries.
13473 @node Interfaces.C.Streams (i-cstrea.ads)
13474 @section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
13475 @cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
13476 @cindex  C streams, interfacing
13478 @noindent
13479 This package is a binding for the most commonly used operations
13480 on C streams.
13482 @node Interfaces.CPP (i-cpp.ads)
13483 @section @code{Interfaces.CPP} (@file{i-cpp.ads})
13484 @cindex @code{Interfaces.CPP} (@file{i-cpp.ads})
13485 @cindex  C++ interfacing
13486 @cindex  Interfacing, to C++
13488 @noindent
13489 This package provides facilities for use in interfacing to C++.  It
13490 is primarily intended to be used in connection with automated tools
13491 for the generation of C++ interfaces.
13493 @node Interfaces.Os2lib (i-os2lib.ads)
13494 @section @code{Interfaces.Os2lib} (@file{i-os2lib.ads})
13495 @cindex @code{Interfaces.Os2lib} (@file{i-os2lib.ads})
13496 @cindex Interfacing, to OS/2
13497 @cindex OS/2 interfacing
13499 @noindent
13500 This package provides interface definitions to the OS/2 library.
13501 It is a thin binding which is a direct translation of the
13502 various @file{<bse@.h>} files.
13504 @node Interfaces.Os2lib.Errors (i-os2err.ads)
13505 @section @code{Interfaces.Os2lib.Errors} (@file{i-os2err.ads})
13506 @cindex @code{Interfaces.Os2lib.Errors} (@file{i-os2err.ads})
13507 @cindex OS/2 Error codes
13508 @cindex Interfacing, to OS/2
13509 @cindex OS/2 interfacing
13511 @noindent
13512 This package provides definitions of the OS/2 error codes.
13514 @node Interfaces.Os2lib.Synchronization (i-os2syn.ads)
13515 @section @code{Interfaces.Os2lib.Synchronization} (@file{i-os2syn.ads})
13516 @cindex @code{Interfaces.Os2lib.Synchronization} (@file{i-os2syn.ads})
13517 @cindex Interfacing, to OS/2
13518 @cindex Synchronization, OS/2
13519 @cindex OS/2 synchronization primitives
13521 @noindent
13522 This is a child package that provides definitions for interfacing
13523 to the @code{OS/2} synchronization primitives.
13525 @node Interfaces.Os2lib.Threads (i-os2thr.ads)
13526 @section @code{Interfaces.Os2lib.Threads} (@file{i-os2thr.ads})
13527 @cindex @code{Interfaces.Os2lib.Threads} (@file{i-os2thr.ads})
13528 @cindex Interfacing, to OS/2
13529 @cindex Thread control, OS/2
13530 @cindex OS/2 thread interfacing
13532 @noindent
13533 This is a child package that provides definitions for interfacing
13534 to the @code{OS/2} thread primitives.
13536 @node Interfaces.Packed_Decimal (i-pacdec.ads)
13537 @section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
13538 @cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
13539 @cindex  IBM Packed Format
13540 @cindex  Packed Decimal
13542 @noindent
13543 This package provides a set of routines for conversions to and
13544 from a packed decimal format compatible with that used on IBM
13545 mainframes.
13547 @node Interfaces.VxWorks (i-vxwork.ads)
13548 @section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
13549 @cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
13550 @cindex Interfacing to VxWorks
13551 @cindex VxWorks, interfacing
13553 @noindent
13554 This package provides a limited binding to the VxWorks API.
13555 In particular, it interfaces with the
13556 VxWorks hardware interrupt facilities.
13558 @node Interfaces.VxWorks.IO (i-vxwoio.ads)
13559 @section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
13560 @cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
13561 @cindex Interfacing to VxWorks' I/O
13562 @cindex VxWorks, I/O interfacing
13563 @cindex VxWorks, Get_Immediate
13564 @cindex Get_Immediate, VxWorks
13566 @noindent
13567 This package provides a binding to the ioctl (IO/Control)
13568 function of VxWorks, defining a set of option values and
13569 function codes. A particular use of this package is
13570 to enable the use of Get_Immediate under VxWorks.
13572 @node System.Address_Image (s-addima.ads)
13573 @section @code{System.Address_Image} (@file{s-addima.ads})
13574 @cindex @code{System.Address_Image} (@file{s-addima.ads})
13575 @cindex Address image
13576 @cindex Image, of an address
13578 @noindent
13579 This function provides a useful debugging
13580 function that gives an (implementation dependent)
13581 string which identifies an address.
13583 @node System.Assertions (s-assert.ads)
13584 @section @code{System.Assertions} (@file{s-assert.ads})
13585 @cindex @code{System.Assertions} (@file{s-assert.ads})
13586 @cindex Assertions
13587 @cindex Assert_Failure, exception
13589 @noindent
13590 This package provides the declaration of the exception raised
13591 by an run-time assertion failure, as well as the routine that
13592 is used internally to raise this assertion.
13594 @node System.Memory (s-memory.ads)
13595 @section @code{System.Memory} (@file{s-memory.ads})
13596 @cindex @code{System.Memory} (@file{s-memory.ads})
13597 @cindex Memory allocation
13599 @noindent
13600 This package provides the interface to the low level routines used
13601 by the generated code for allocation and freeing storage for the
13602 default storage pool (analogous to the C routines malloc and free.
13603 It also provides a reallocation interface analogous to the C routine
13604 realloc. The body of this unit may be modified to provide alternative
13605 allocation mechanisms for the default pool, and in addition, direct
13606 calls to this unit may be made for low level allocation uses (for
13607 example see the body of @code{GNAT.Tables}).
13609 @node System.Partition_Interface (s-parint.ads)
13610 @section @code{System.Partition_Interface} (@file{s-parint.ads})
13611 @cindex @code{System.Partition_Interface} (@file{s-parint.ads})
13612 @cindex Partition interfacing functions
13614 @noindent
13615 This package provides facilities for partition interfacing.  It
13616 is used primarily in a distribution context when using Annex E
13617 with @code{GLADE}.
13619 @node System.Restrictions (s-restri.ads)
13620 @section @code{System.Restrictions} (@file{s-restri.ads})
13621 @cindex @code{System.Restrictions} (@file{s-restri.ads})
13622 @cindex Run-time restrictions access
13624 @noindent
13625 This package provides facilities for accessing at run-time
13626 the status of restrictions specified at compile time for
13627 the partition. Information is available both with regard
13628 to actual restrictions specified, and with regard to
13629 compiler determined information on which restrictions
13630 are violated by one or more packages in the partition.
13632 @node System.Rident (s-rident.ads)
13633 @section @code{System.Rident} (@file{s-rident.ads})
13634 @cindex @code{System.Rident} (@file{s-rident.ads})
13635 @cindex Restrictions definitions
13637 @noindent
13638 This package provides definitions of the restrictions
13639 identifiers supported by GNAT, and also the format of
13640 the restrictions provided in package System.Restrictions.
13641 It is not normally necessary to @code{with} this generic package
13642 since the necessary instantiation is included in
13643 package System.Restrictions.
13645 @node System.Task_Info (s-tasinf.ads)
13646 @section @code{System.Task_Info} (@file{s-tasinf.ads})
13647 @cindex @code{System.Task_Info} (@file{s-tasinf.ads})
13648 @cindex Task_Info pragma
13650 @noindent
13651 This package provides target dependent functionality that is used
13652 to support the @code{Task_Info} pragma
13654 @node System.Wch_Cnv (s-wchcnv.ads)
13655 @section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
13656 @cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
13657 @cindex Wide Character, Representation
13658 @cindex Wide String, Conversion
13659 @cindex Representation of wide characters
13661 @noindent
13662 This package provides routines for converting between
13663 wide and wide wide characters and a representation as a value of type
13664 @code{Standard.String}, using a specified wide character
13665 encoding method.  It uses definitions in
13666 package @code{System.Wch_Con}.
13668 @node System.Wch_Con (s-wchcon.ads)
13669 @section @code{System.Wch_Con} (@file{s-wchcon.ads})
13670 @cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
13672 @noindent
13673 This package provides definitions and descriptions of
13674 the various methods used for encoding wide characters
13675 in ordinary strings.  These definitions are used by
13676 the package @code{System.Wch_Cnv}.
13678 @node Interfacing to Other Languages
13679 @chapter Interfacing to Other Languages
13680 @noindent
13681 The facilities in annex B of the Ada 95 Reference Manual are fully
13682 implemented in GNAT, and in addition, a full interface to C++ is
13683 provided.
13685 @menu
13686 * Interfacing to C::
13687 * Interfacing to C++::
13688 * Interfacing to COBOL::
13689 * Interfacing to Fortran::
13690 * Interfacing to non-GNAT Ada code::
13691 @end menu
13693 @node Interfacing to C
13694 @section Interfacing to C
13696 @noindent
13697 Interfacing to C with GNAT can use one of two approaches:
13699 @itemize @bullet
13700 @item
13701 The types in the package @code{Interfaces.C} may be used.
13702 @item
13703 Standard Ada types may be used directly.  This may be less portable to
13704 other compilers, but will work on all GNAT compilers, which guarantee
13705 correspondence between the C and Ada types.
13706 @end itemize
13708 @noindent
13709 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
13710 effect, since this is the default.  The following table shows the
13711 correspondence between Ada scalar types and the corresponding C types.
13713 @table @code
13714 @item Integer
13715 @code{int}
13716 @item Short_Integer
13717 @code{short}
13718 @item Short_Short_Integer
13719 @code{signed char}
13720 @item Long_Integer
13721 @code{long}
13722 @item Long_Long_Integer
13723 @code{long long}
13724 @item Short_Float
13725 @code{float}
13726 @item Float
13727 @code{float}
13728 @item Long_Float
13729 @code{double}
13730 @item Long_Long_Float
13731 This is the longest floating-point type supported by the hardware.
13732 @end table
13734 @noindent
13735 Additionally, there are the following general correspondences between Ada
13736 and C types:
13737 @itemize @bullet
13738 @item
13739 Ada enumeration types map to C enumeration types directly if pragma
13740 @code{Convention C} is specified, which causes them to have int
13741 length.  Without pragma @code{Convention C}, Ada enumeration types map to
13742 8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short},
13743 @code{int}, respectively) depending on the number of values passed.
13744 This is the only case in which pragma @code{Convention C} affects the
13745 representation of an Ada type.
13747 @item
13748 Ada access types map to C pointers, except for the case of pointers to
13749 unconstrained types in Ada, which have no direct C equivalent.
13751 @item
13752 Ada arrays map directly to C arrays.
13754 @item
13755 Ada records map directly to C structures.
13757 @item
13758 Packed Ada records map to C structures where all members are bit fields
13759 of the length corresponding to the @code{@var{type}'Size} value in Ada.
13760 @end itemize
13762 @node Interfacing to C++
13763 @section Interfacing to C++
13765 @noindent
13766 The interface to C++ makes use of the following pragmas, which are
13767 primarily intended to be constructed automatically using a binding generator
13768 tool, although it is possible to construct them by hand.  No suitable binding
13769 generator tool is supplied with GNAT though.
13771 Using these pragmas it is possible to achieve complete
13772 inter-operability between Ada tagged types and C class definitions.
13773 See @ref{Implementation Defined Pragmas}, for more details.
13775 @table @code
13776 @item pragma CPP_Class ([Entity =>] @var{local_NAME})
13777 The argument denotes an entity in the current declarative region that is
13778 declared as a tagged or untagged record type.  It indicates that the type
13779 corresponds to an externally declared C++ class type, and is to be laid
13780 out the same way that C++ would lay out the type.
13782 @item pragma CPP_Constructor ([Entity =>] @var{local_NAME})
13783 This pragma identifies an imported function (imported in the usual way
13784 with pragma @code{Import}) as corresponding to a C++ constructor.
13786 @item pragma CPP_Vtable @dots{}
13787 One @code{CPP_Vtable} pragma can be present for each component of type
13788 @code{CPP.Interfaces.Vtable_Ptr} in a record to which pragma @code{CPP_Class}
13789 applies.
13790 @end table
13792 @node Interfacing to COBOL
13793 @section Interfacing to COBOL
13795 @noindent
13796 Interfacing to COBOL is achieved as described in section B.4 of
13797 the Ada 95 reference manual.
13799 @node Interfacing to Fortran
13800 @section Interfacing to Fortran
13802 @noindent
13803 Interfacing to Fortran is achieved as described in section B.5 of the
13804 reference manual.  The pragma @code{Convention Fortran}, applied to a
13805 multi-dimensional array causes the array to be stored in column-major
13806 order as required for convenient interface to Fortran.
13808 @node Interfacing to non-GNAT Ada code
13809 @section Interfacing to non-GNAT Ada code
13811 It is possible to specify the convention @code{Ada} in a pragma
13812 @code{Import} or pragma @code{Export}.  However this refers to
13813 the calling conventions used by GNAT, which may or may not be
13814 similar enough to those used by some other Ada 83 or Ada 95
13815 compiler to allow interoperation.
13817 If arguments types are kept simple, and if the foreign compiler generally
13818 follows system calling conventions, then it may be possible to integrate
13819 files compiled by other Ada compilers, provided that the elaboration
13820 issues are adequately addressed (for example by eliminating the
13821 need for any load time elaboration).
13823 In particular, GNAT running on VMS is designed to
13824 be highly compatible with the DEC Ada 83 compiler, so this is one
13825 case in which it is possible to import foreign units of this type,
13826 provided that the data items passed are restricted to simple scalar
13827 values or simple record types without variants, or simple array
13828 types with fixed bounds.
13830 @node Specialized Needs Annexes
13831 @chapter Specialized Needs Annexes
13833 @noindent
13834 Ada 95 defines a number of specialized needs annexes, which are not
13835 required in all implementations.  However, as described in this chapter,
13836 GNAT implements all of these special needs annexes:
13838 @table @asis
13839 @item Systems Programming (Annex C)
13840 The Systems Programming Annex is fully implemented.
13842 @item Real-Time Systems (Annex D)
13843 The Real-Time Systems Annex is fully implemented.
13845 @item Distributed Systems (Annex E)
13846 Stub generation is fully implemented in the GNAT compiler.  In addition,
13847 a complete compatible PCS is available as part of the GLADE system,
13848 a separate product.  When the two
13849 products are used in conjunction, this annex is fully implemented.
13851 @item Information Systems (Annex F)
13852 The Information Systems annex is fully implemented.
13854 @item Numerics (Annex G)
13855 The Numerics Annex is fully implemented.
13857 @item Safety and Security (Annex H)
13858 The Safety and Security annex is fully implemented.
13859 @end table
13861 @node Implementation of Specific Ada Features
13862 @chapter Implementation of Specific Ada Features
13864 @noindent
13865 This chapter describes the GNAT implementation of several Ada language
13866 facilities.
13868 @menu
13869 * Machine Code Insertions::
13870 * GNAT Implementation of Tasking::
13871 * GNAT Implementation of Shared Passive Packages::
13872 * Code Generation for Array Aggregates::
13873 * The Size of Discriminated Records with Default Discriminants::
13874 * Strict Conformance to the Ada 95 Reference Manual::
13875 @end menu
13877 @node Machine Code Insertions
13878 @section Machine Code Insertions
13880 @noindent
13881 Package @code{Machine_Code} provides machine code support as described
13882 in the Ada 95 Reference Manual in two separate forms:
13883 @itemize @bullet
13884 @item
13885 Machine code statements, consisting of qualified expressions that
13886 fit the requirements of RM section 13.8.
13887 @item
13888 An intrinsic callable procedure, providing an alternative mechanism of
13889 including machine instructions in a subprogram.
13890 @end itemize
13892 @noindent
13893 The two features are similar, and both are closely related to the mechanism
13894 provided by the asm instruction in the GNU C compiler.  Full understanding
13895 and use of the facilities in this package requires understanding the asm
13896 instruction as described in @cite{Using the GNU Compiler Collection (GCC)}
13897 by Richard Stallman. The relevant section is titled ``Extensions to the C
13898 Language Family'' -> ``Assembler Instructions with C Expression Operands''.
13900 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
13901 semantic restrictions and effects as described below.  Both are provided so
13902 that the procedure call can be used as a statement, and the function call
13903 can be used to form a code_statement.
13905 The first example given in the GCC documentation is the C @code{asm}
13906 instruction:
13907 @smallexample
13908    asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
13909 @end smallexample
13911 @noindent
13912 The equivalent can be written for GNAT as:
13914 @smallexample @c ada
13915 Asm ("fsinx %1 %0",
13916      My_Float'Asm_Output ("=f", result),
13917      My_Float'Asm_Input  ("f",  angle));
13918 @end smallexample
13920 @noindent
13921 The first argument to @code{Asm} is the assembler template, and is
13922 identical to what is used in GNU C@.  This string must be a static
13923 expression.  The second argument is the output operand list.  It is
13924 either a single @code{Asm_Output} attribute reference, or a list of such
13925 references enclosed in parentheses (technically an array aggregate of
13926 such references).
13928 The @code{Asm_Output} attribute denotes a function that takes two
13929 parameters.  The first is a string, the second is the name of a variable
13930 of the type designated by the attribute prefix.  The first (string)
13931 argument is required to be a static expression and designates the
13932 constraint for the parameter (e.g.@: what kind of register is
13933 required).  The second argument is the variable to be updated with the
13934 result.  The possible values for constraint are the same as those used in
13935 the RTL, and are dependent on the configuration file used to build the
13936 GCC back end.  If there are no output operands, then this argument may
13937 either be omitted, or explicitly given as @code{No_Output_Operands}.
13939 The second argument of @code{@var{my_float}'Asm_Output} functions as
13940 though it were an @code{out} parameter, which is a little curious, but
13941 all names have the form of expressions, so there is no syntactic
13942 irregularity, even though normally functions would not be permitted
13943 @code{out} parameters.  The third argument is the list of input
13944 operands.  It is either a single @code{Asm_Input} attribute reference, or
13945 a list of such references enclosed in parentheses (technically an array
13946 aggregate of such references).
13948 The @code{Asm_Input} attribute denotes a function that takes two
13949 parameters.  The first is a string, the second is an expression of the
13950 type designated by the prefix.  The first (string) argument is required
13951 to be a static expression, and is the constraint for the parameter,
13952 (e.g.@: what kind of register is required).  The second argument is the
13953 value to be used as the input argument.  The possible values for the
13954 constant are the same as those used in the RTL, and are dependent on
13955 the configuration file used to built the GCC back end.
13957 If there are no input operands, this argument may either be omitted, or
13958 explicitly given as @code{No_Input_Operands}.  The fourth argument, not
13959 present in the above example, is a list of register names, called the
13960 @dfn{clobber} argument.  This argument, if given, must be a static string
13961 expression, and is a space or comma separated list of names of registers
13962 that must be considered destroyed as a result of the @code{Asm} call.  If
13963 this argument is the null string (the default value), then the code
13964 generator assumes that no additional registers are destroyed.
13966 The fifth argument, not present in the above example, called the
13967 @dfn{volatile} argument, is by default @code{False}.  It can be set to
13968 the literal value @code{True} to indicate to the code generator that all
13969 optimizations with respect to the instruction specified should be
13970 suppressed, and that in particular, for an instruction that has outputs,
13971 the instruction will still be generated, even if none of the outputs are
13972 used.  See the full description in the GCC manual for further details.
13973 Generally it is strongly advisable to use Volatile for any ASM statement
13974 that is missing either input or output operands, or when two or more ASM
13975 statements appear in sequence, to avoid unwanted optimizations. A warning
13976 is generated if this advice is not followed.
13978 The @code{Asm} subprograms may be used in two ways.  First the procedure
13979 forms can be used anywhere a procedure call would be valid, and
13980 correspond to what the RM calls ``intrinsic'' routines.  Such calls can
13981 be used to intersperse machine instructions with other Ada statements.
13982 Second, the function forms, which return a dummy value of the limited
13983 private type @code{Asm_Insn}, can be used in code statements, and indeed
13984 this is the only context where such calls are allowed.  Code statements
13985 appear as aggregates of the form:
13987 @smallexample @c ada
13988 Asm_Insn'(Asm (@dots{}));
13989 Asm_Insn'(Asm_Volatile (@dots{}));
13990 @end smallexample
13992 @noindent
13993 In accordance with RM rules, such code statements are allowed only
13994 within subprograms whose entire body consists of such statements.  It is
13995 not permissible to intermix such statements with other Ada statements.
13997 Typically the form using intrinsic procedure calls is more convenient
13998 and more flexible.  The code statement form is provided to meet the RM
13999 suggestion that such a facility should be made available.  The following
14000 is the exact syntax of the call to @code{Asm}. As usual, if named notation
14001 is used, the arguments may be given in arbitrary order, following the
14002 normal rules for use of positional and named arguments)
14004 @smallexample
14005 ASM_CALL ::= Asm (
14006                  [Template =>] static_string_EXPRESSION
14007                [,[Outputs  =>] OUTPUT_OPERAND_LIST      ]
14008                [,[Inputs   =>] INPUT_OPERAND_LIST       ]
14009                [,[Clobber  =>] static_string_EXPRESSION ]
14010                [,[Volatile =>] static_boolean_EXPRESSION] )
14012 OUTPUT_OPERAND_LIST ::=
14013   [PREFIX.]No_Output_Operands
14014 | OUTPUT_OPERAND_ATTRIBUTE
14015 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
14017 OUTPUT_OPERAND_ATTRIBUTE ::=
14018   SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
14020 INPUT_OPERAND_LIST ::=
14021   [PREFIX.]No_Input_Operands
14022 | INPUT_OPERAND_ATTRIBUTE
14023 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
14025 INPUT_OPERAND_ATTRIBUTE ::=
14026   SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
14027 @end smallexample
14029 @noindent
14030 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
14031 are declared in the package @code{Machine_Code} and must be referenced
14032 according to normal visibility rules. In particular if there is no
14033 @code{use} clause for this package, then appropriate package name
14034 qualification is required.
14036 @node GNAT Implementation of Tasking
14037 @section GNAT Implementation of Tasking
14039 @noindent
14040 This chapter outlines the basic GNAT approach to tasking (in particular,
14041 a multi-layered library for portability) and discusses issues related
14042 to compliance with the Real-Time Systems Annex.
14044 @menu
14045 * Mapping Ada Tasks onto the Underlying Kernel Threads::
14046 * Ensuring Compliance with the Real-Time Annex::
14047 @end menu
14049 @node Mapping Ada Tasks onto the Underlying Kernel Threads
14050 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
14052 @noindent
14053 GNAT's run-time support comprises two layers:
14055 @itemize @bullet
14056 @item GNARL (GNAT Run-time Layer)
14057 @item GNULL (GNAT Low-level Library)
14058 @end itemize
14060 @noindent
14061 In GNAT, Ada's tasking services rely on a platform and OS independent
14062 layer known as GNARL@.  This code is responsible for implementing the
14063 correct semantics of Ada's task creation, rendezvous, protected
14064 operations etc.
14066 GNARL decomposes Ada's tasking semantics into simpler lower level
14067 operations such as create a thread, set the priority of a thread,
14068 yield, create a lock, lock/unlock, etc.  The spec for these low-level
14069 operations constitutes GNULLI, the GNULL Interface.  This interface is
14070 directly inspired from the POSIX real-time API@.
14072 If the underlying executive or OS implements the POSIX standard
14073 faithfully, the GNULL Interface maps as is to the services offered by
14074 the underlying kernel.  Otherwise, some target dependent glue code maps
14075 the services offered by the underlying kernel to the semantics expected
14076 by GNARL@.
14078 Whatever the underlying OS (VxWorks, UNIX, OS/2, Windows NT, etc.) the
14079 key point is that each Ada task is mapped on a thread in the underlying
14080 kernel.  For example, in the case of VxWorks, one Ada task = one VxWorks task.
14082 In addition Ada task priorities map onto the underlying thread priorities.
14083 Mapping Ada tasks onto the underlying kernel threads has several advantages:
14085 @itemize @bullet
14086 @item
14087 The underlying scheduler is used to schedule the Ada tasks.  This
14088 makes Ada tasks as efficient as kernel threads from a scheduling
14089 standpoint.
14091 @item
14092 Interaction with code written in C containing threads is eased
14093 since at the lowest level Ada tasks and C threads map onto the same
14094 underlying kernel concept.
14096 @item
14097 When an Ada task is blocked during I/O the remaining Ada tasks are
14098 able to proceed.
14100 @item
14101 On multiprocessor systems Ada tasks can execute in parallel.
14102 @end itemize
14104 @noindent
14105 Some threads libraries offer a mechanism to fork a new process, with the
14106 child process duplicating the threads from the parent.
14107 GNAT does not
14108 support this functionality when the parent contains more than one task.
14109 @cindex Forking a new process
14111 @node Ensuring Compliance with the Real-Time Annex
14112 @subsection Ensuring Compliance with the Real-Time Annex
14113 @cindex Real-Time Systems Annex compliance
14115 @noindent
14116 Although mapping Ada tasks onto
14117 the underlying threads has significant advantages, it does create some
14118 complications when it comes to respecting the scheduling semantics
14119 specified in the real-time annex (Annex D).
14121 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
14122 scheduling policy states:
14124 @quotation
14125 @emph{When the active priority of a ready task that is not running
14126 changes, or the setting of its base priority takes effect, the
14127 task is removed from the ready queue for its old active priority
14128 and is added at the tail of the ready queue for its new active
14129 priority, except in the case where the active priority is lowered
14130 due to the loss of inherited priority, in which case the task is
14131 added at the head of the ready queue for its new active priority.}
14132 @end quotation
14134 @noindent
14135 While most kernels do put tasks at the end of the priority queue when
14136 a task changes its priority, (which respects the main
14137 FIFO_Within_Priorities requirement), almost none keep a thread at the
14138 beginning of its priority queue when its priority drops from the loss
14139 of inherited priority.
14141 As a result most vendors have provided incomplete Annex D implementations.
14143 The GNAT run-time, has a nice cooperative solution to this problem
14144 which ensures that accurate FIFO_Within_Priorities semantics are
14145 respected.
14147 The principle is as follows.  When an Ada task T is about to start
14148 running, it checks whether some other Ada task R with the same
14149 priority as T has been suspended due to the loss of priority
14150 inheritance.  If this is the case, T yields and is placed at the end of
14151 its priority queue.  When R arrives at the front of the queue it
14152 executes.
14154 Note that this simple scheme preserves the relative order of the tasks
14155 that were ready to execute in the priority queue where R has been
14156 placed at the end.
14158 @node GNAT Implementation of Shared Passive Packages
14159 @section GNAT Implementation of Shared Passive Packages
14160 @cindex Shared passive packages
14162 @noindent
14163 GNAT fully implements the pragma @code{Shared_Passive} for
14164 @cindex pragma @code{Shared_Passive}
14165 the purpose of designating shared passive packages.
14166 This allows the use of passive partitions in the
14167 context described in the Ada Reference Manual; i.e. for communication
14168 between separate partitions of a distributed application using the
14169 features in Annex E.
14170 @cindex Annex E
14171 @cindex Distribution Systems Annex
14173 However, the implementation approach used by GNAT provides for more
14174 extensive usage as follows:
14176 @table @emph
14177 @item Communication between separate programs
14179 This allows separate programs to access the data in passive
14180 partitions, using protected objects for synchronization where
14181 needed. The only requirement is that the two programs have a
14182 common shared file system. It is even possible for programs
14183 running on different machines with different architectures
14184 (e.g. different endianness) to communicate via the data in
14185 a passive partition.
14187 @item Persistence between program runs
14189 The data in a passive package can persist from one run of a
14190 program to another, so that a later program sees the final
14191 values stored by a previous run of the same program.
14193 @end table
14195 @noindent
14196 The implementation approach used is to store the data in files. A
14197 separate stream file is created for each object in the package, and
14198 an access to an object causes the corresponding file to be read or
14199 written.
14201 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
14202 @cindex @code{SHARED_MEMORY_DIRECTORY} environment variable
14203 set to the directory to be used for these files.
14204 The files in this directory
14205 have names that correspond to their fully qualified names. For
14206 example, if we have the package
14208 @smallexample @c ada
14209 package X is
14210   pragma Shared_Passive (X);
14211   Y : Integer;
14212   Z : Float;
14213 end X;
14214 @end smallexample
14216 @noindent
14217 and the environment variable is set to @code{/stemp/}, then the files created
14218 will have the names:
14220 @smallexample
14221 /stemp/x.y
14222 /stemp/x.z
14223 @end smallexample
14225 @noindent
14226 These files are created when a value is initially written to the object, and
14227 the files are retained until manually deleted. This provides the persistence
14228 semantics. If no file exists, it means that no partition has assigned a value
14229 to the variable; in this case the initial value declared in the package
14230 will be used. This model ensures that there are no issues in synchronizing
14231 the elaboration process, since elaboration of passive packages elaborates the
14232 initial values, but does not create the files.
14234 The files are written using normal @code{Stream_IO} access.
14235 If you want to be able
14236 to communicate between programs or partitions running on different
14237 architectures, then you should use the XDR versions of the stream attribute
14238 routines, since these are architecture independent.
14240 If active synchronization is required for access to the variables in the
14241 shared passive package, then as described in the Ada Reference Manual, the
14242 package may contain protected objects used for this purpose. In this case
14243 a lock file (whose name is @file{___lock} (three underscores)
14244 is created in the shared memory directory.
14245 @cindex @file{___lock} file (for shared passive packages)
14246 This is used to provide the required locking
14247 semantics for proper protected object synchronization.
14249 As of January 2003, GNAT supports shared passive packages on all platforms
14250 except for OpenVMS.
14252 @node Code Generation for Array Aggregates
14253 @section Code Generation for Array Aggregates
14255 @menu
14256 * Static constant aggregates with static bounds::
14257 * Constant aggregates with unconstrained nominal types::
14258 * Aggregates with static bounds::
14259 * Aggregates with non-static bounds::
14260 * Aggregates in assignment statements::
14261 @end menu
14263 @noindent
14264 Aggregates have a rich syntax and allow the user to specify the values of
14265 complex data structures by means of a single construct.  As a result, the
14266 code generated for aggregates can be quite complex and involve loops, case
14267 statements and multiple assignments.  In the simplest cases, however, the
14268 compiler will recognize aggregates whose components and constraints are
14269 fully static, and in those cases the compiler will generate little or no
14270 executable code.  The following is an outline of the code that GNAT generates
14271 for various aggregate constructs.  For further details, you will find it
14272 useful to examine the output produced by the -gnatG flag to see the expanded
14273 source that is input to the code generator.  You may also want to examine
14274 the assembly code generated at various levels of optimization.
14276 The code generated for aggregates depends on the context, the component values,
14277 and the type.  In the context of an object declaration the code generated is
14278 generally simpler than in the case of an assignment.  As a general rule, static
14279 component values and static subtypes also lead to simpler code.
14281 @node Static constant aggregates with static bounds
14282 @subsection Static constant aggregates with static bounds
14284 @noindent
14285 For the declarations:
14286 @smallexample @c ada
14287     type One_Dim is array (1..10) of integer;
14288     ar0 : constant One_Dim := (1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
14289 @end smallexample
14291 @noindent
14292 GNAT generates no executable code: the constant ar0 is placed in static memory.
14293 The same is true for constant aggregates with named associations:
14295 @smallexample @c ada
14296     Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1 => 1, 5 .. 10 => 0);
14297     Cr3 : constant One_Dim := (others => 7777);
14298 @end smallexample
14300 @noindent
14301 The same is true for multidimensional constant arrays such as:
14303 @smallexample @c ada
14304     type two_dim is array (1..3, 1..3) of integer;
14305     Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
14306 @end smallexample
14308 @noindent
14309 The same is true for arrays of one-dimensional arrays: the following are
14310 static:
14312 @smallexample @c ada
14313 type ar1b  is array (1..3) of boolean;
14314 type ar_ar is array (1..3) of ar1b;
14315 None  : constant ar1b := (others => false);     --  fully static
14316 None2 : constant ar_ar := (1..3 => None);       --  fully static
14317 @end smallexample
14319 @noindent
14320 However, for multidimensional aggregates with named associations, GNAT will
14321 generate assignments and loops, even if all associations are static.  The
14322 following two declarations generate a loop for the first dimension, and
14323 individual component assignments for the second dimension:
14325 @smallexample @c ada
14326 Zero1: constant two_dim := (1..3 => (1..3 => 0));
14327 Zero2: constant two_dim := (others => (others => 0));
14328 @end smallexample
14330 @node Constant aggregates with unconstrained nominal types
14331 @subsection Constant aggregates with unconstrained nominal types
14333 @noindent
14334 In such cases the aggregate itself establishes the subtype, so that
14335 associations with @code{others} cannot be used.  GNAT determines the
14336 bounds for the actual subtype of the aggregate, and allocates the
14337 aggregate statically as well.  No code is generated for the following:
14339 @smallexample @c ada
14340     type One_Unc is array (natural range <>) of integer;
14341     Cr_Unc : constant One_Unc := (12,24,36);
14342 @end smallexample
14344 @node Aggregates with static bounds
14345 @subsection Aggregates with static bounds
14347 @noindent
14348 In all previous examples the aggregate was the initial (and immutable) value
14349 of a constant.  If the aggregate initializes a variable, then code is generated
14350 for it as a combination of individual assignments and loops over the target
14351 object.  The declarations
14353 @smallexample @c ada
14354        Cr_Var1 : One_Dim := (2, 5, 7, 11, 0, 0, 0, 0, 0, 0);
14355        Cr_Var2 : One_Dim := (others > -1);
14356 @end smallexample
14358 @noindent
14359 generate the equivalent of
14361 @smallexample @c ada
14362        Cr_Var1 (1) := 2;
14363        Cr_Var1 (2) := 3;
14364        Cr_Var1 (3) := 5;
14365        Cr_Var1 (4) := 11;
14367        for I in Cr_Var2'range loop
14368           Cr_Var2 (I) := =-1;
14369        end loop;
14370 @end smallexample
14372 @node Aggregates with non-static bounds
14373 @subsection Aggregates with non-static bounds
14375 @noindent
14376 If the bounds of the aggregate are not statically compatible with the bounds
14377 of the nominal subtype  of the target, then constraint checks have to be
14378 generated on the bounds.  For a multidimensional array, constraint checks may
14379 have to be applied to sub-arrays individually, if they do not have statically
14380 compatible subtypes.
14382 @node Aggregates in assignment statements
14383 @subsection Aggregates in assignment statements
14385 @noindent
14386 In general, aggregate assignment requires the construction of a temporary,
14387 and a copy from the temporary to the target of the assignment.  This is because
14388 it is not always possible to convert the assignment into a series of individual
14389 component assignments.  For example, consider the simple case:
14391 @smallexample @c ada
14392         A := (A(2), A(1));
14393 @end smallexample
14395 @noindent
14396 This cannot be converted into:
14398 @smallexample @c ada
14399         A(1) := A(2);
14400         A(2) := A(1);
14401 @end smallexample
14403 @noindent
14404 So the aggregate has to be built first in a separate location, and then
14405 copied into the target.  GNAT recognizes simple cases where this intermediate
14406 step is not required, and the assignments can be performed in place, directly
14407 into the target.  The following sufficient criteria are applied:
14409 @itemize @bullet
14410 @item
14411 The bounds of the aggregate are static, and the associations are static.
14412 @item
14413 The components of the aggregate are static constants, names of
14414 simple variables that are not renamings, or expressions not involving
14415 indexed components whose operands obey these rules.
14416 @end itemize
14418 @noindent
14419 If any of these conditions are violated, the aggregate will be built in
14420 a temporary (created either by the front-end or the code generator) and then
14421 that temporary will be copied onto the target.
14424 @node The Size of Discriminated Records with Default Discriminants
14425 @section The Size of Discriminated Records with Default Discriminants
14427 @noindent
14428 If a discriminated type @code{T} has discriminants with default values, it is
14429 possible to declare an object of this type without providing an explicit
14430 constraint:
14432 @smallexample @c ada
14433 @group
14434 type Size is range 1..100;
14436 type Rec (D : Size := 15) is record
14437    Name : String (1..D);
14438 end T;
14440 Word : Rec;
14441 @end group
14442 @end smallexample
14444 @noindent
14445 Such an object is said to be @emph{unconstrained}.
14446 The discriminant of the object
14447 can be modified by a full assignment to the object, as long as it preserves the
14448 relation between the value of the discriminant, and the value of the components
14449 that depend on it:
14451 @smallexample @c ada
14452 @group
14453 Word := (3, "yes");
14455 Word := (5, "maybe");
14457 Word := (5, "no"); -- raises Constraint_Error
14458 @end group
14459 @end smallexample
14461 @noindent
14462 In order to support this behavior efficiently, an unconstrained object is
14463 given the maximum size that any value of the type requires. In the case
14464 above, @code{Word} has storage for the discriminant and for
14465 a @code{String} of length 100.
14466 It is important to note that unconstrained objects do not require dynamic
14467 allocation. It would be an improper implementation to place on the heap those
14468 components whose size depends on discriminants. (This improper implementation
14469 was used by some Ada83 compilers, where the @code{Name} component above
14470 would have
14471 been stored as a pointer to a dynamic string). Following the principle that
14472 dynamic storage management should never be introduced implicitly,
14473 an Ada95 compiler should reserve the full size for an unconstrained declared
14474 object, and place it on the stack.
14476 This maximum size approach
14477 has been a source of surprise to some users, who expect the default
14478 values of the discriminants to determine the size reserved for an
14479 unconstrained object: ``If the default is 15, why should the object occupy
14480 a larger size?''
14481 The answer, of course, is that the discriminant may be later modified,
14482 and its full range of values must be taken into account. This is why the
14483 declaration:
14485 @smallexample
14486 @group
14487 type Rec (D : Positive := 15) is record
14488    Name : String (1..D);
14489 end record;
14491 Too_Large : Rec;
14492 @end group
14493 @end smallexample
14495 @noindent
14496 is flagged by the compiler with a warning:
14497 an attempt to create @code{Too_Large} will raise @code{Storage_Error},
14498 because the required size includes @code{Positive'Last}
14499 bytes. As the first example indicates, the proper approach is to declare an
14500 index type of ``reasonable'' range so that unconstrained objects are not too
14501 large.
14503 One final wrinkle: if the object is declared to be @code{aliased}, or if it is
14504 created in the heap by means of an allocator, then it is @emph{not}
14505 unconstrained:
14506 it is constrained by the default values of the discriminants, and those values
14507 cannot be modified by full assignment. This is because in the presence of
14508 aliasing all views of the object (which may be manipulated by different tasks,
14509 say) must be consistent, so it is imperative that the object, once created,
14510 remain invariant.
14512 @node Strict Conformance to the Ada 95 Reference Manual
14513 @section Strict Conformance to the Ada 95 Reference Manual
14515 @noindent
14516 The dynamic semantics defined by the Ada 95 Reference Manual impose a set of
14517 run-time checks to be generated. By default, the GNAT compiler will insert many
14518 run-time checks into the compiled code, including most of those required by the
14519 Ada 95 Reference Manual. However, there are three checks that are not enabled
14520 in the default mode for efficiency reasons: arithmetic overflow checking for
14521 integer operations (including division by zero), checks for access before
14522 elaboration on subprogram calls, and stack overflow checking (most operating
14523 systems do not perform this check by default).
14525 Strict conformance to the Ada 95 Reference Manual can be achieved by adding
14526 three compiler options for overflow checking for integer operations
14527 (@option{-gnato}), dynamic checks for access-before-elaboration on subprogram
14528 calls and generic instantiations (@option{-gnatE}), and stack overflow
14529 checking (@option{-fstack-check}).
14531 Note that the result of a floating point arithmetic operation in overflow and
14532 invalid situations, when the @code{Machine_Overflows} attribute of the result
14533 type is @code{False}, is to generate IEEE NaN and infinite values. This is the
14534 case for machines compliant with the IEEE floating-point standard, but on
14535 machines that are not fully compliant with this standard, such as Alpha, the
14536 @option{-mieee} compiler flag must be used for achieving IEEE confirming
14537 behavior (although at the cost of a significant performance penalty), so
14538 infinite and and NaN values are properly generated.
14541 @node Project File Reference
14542 @chapter Project File Reference
14544 @noindent
14545 This chapter describes the syntax and semantics of project files.
14546 Project files specify the options to be used when building a system.
14547 Project files can specify global settings for all tools,
14548 as well as tool-specific settings.
14549 See the chapter on project files in the GNAT Users guide for examples of use.
14551 @menu
14552 * Reserved Words::
14553 * Lexical Elements::
14554 * Declarations::
14555 * Empty declarations::
14556 * Typed string declarations::
14557 * Variables::
14558 * Expressions::
14559 * Attributes::
14560 * Project Attributes::
14561 * Attribute References::
14562 * External Values::
14563 * Case Construction::
14564 * Packages::
14565 * Package Renamings::
14566 * Projects::
14567 * Project Extensions::
14568 * Project File Elaboration::
14569 @end menu
14571 @node Reserved Words
14572 @section Reserved Words
14574 @noindent
14575 All Ada95 reserved words are reserved in project files, and cannot be used
14576 as variable names or project names. In addition, the following are
14577 also reserved in project files:
14579 @itemize
14580 @item @code{extends}
14582 @item @code{external}
14584 @item @code{project}
14586 @end itemize
14588 @node Lexical Elements
14589 @section Lexical Elements
14591 @noindent
14592 Rules for identifiers are the same as in Ada95. Identifiers
14593 are case-insensitive.  Strings are case sensitive, except where noted.
14594 Comments have the same form as in Ada95.
14596 @noindent
14597 Syntax:
14599 @smallexample
14600 simple_name ::=
14601   identifier
14603 name ::=
14604   simple_name @{. simple_name@}
14605 @end smallexample
14607 @node Declarations
14608 @section Declarations
14610 @noindent
14611 Declarations introduce new entities that denote types, variables, attributes,
14612 and packages. Some declarations can only appear immediately within a project
14613 declaration. Others can appear within a project or within a package.
14615 Syntax:
14616 @smallexample
14617 declarative_item ::=
14618   simple_declarative_item |
14619   typed_string_declaration |
14620   package_declaration
14622 simple_declarative_item ::=
14623   variable_declaration |
14624   typed_variable_declaration |
14625   attribute_declaration |
14626   case_construction |
14627   empty_declaration
14628 @end smallexample
14630 @node Empty declarations
14631 @section Empty declarations
14633 @smallexample
14634 empty_declaration ::=
14635   @b{null} ;
14636 @end smallexample
14638 An empty declaration is allowed anywhere a declaration is allowed.
14639 It has no effect.
14641 @node Typed string declarations
14642 @section Typed string declarations
14644 @noindent
14645 Typed strings are sequences of string literals. Typed strings are the only
14646 named types in project files. They are used in case constructions, where they
14647 provide support for conditional attribute definitions.
14649 Syntax:
14650 @smallexample
14651 typed_string_declaration ::=
14652   @b{type} <typed_string_>_simple_name @b{is}
14653    ( string_literal @{, string_literal@} );
14654 @end smallexample
14656 @noindent
14657 A typed string declaration can only appear immediately within a project
14658 declaration.
14660 All the string literals in a typed string declaration must be distinct.
14662 @node Variables
14663 @section Variables
14665 @noindent
14666 Variables denote values, and appear as constituents of expressions.
14668 @smallexample
14669 typed_variable_declaration ::=
14670   <typed_variable_>simple_name : <typed_string_>name :=  string_expression ;
14672 variable_declaration ::=
14673   <variable_>simple_name := expression;
14674 @end smallexample
14676 @noindent
14677 The elaboration of a variable declaration introduces the variable and
14678 assigns to it the value of the expression. The name of the variable is
14679 available after the assignment symbol.
14681 @noindent
14682 A typed_variable can only be declare once.
14684 @noindent
14685 a non typed variable can be declared multiple times.
14687 @noindent
14688 Before the completion of its first declaration, the value of variable
14689 is the null string.
14691 @node Expressions
14692 @section Expressions
14694 @noindent
14695 An expression is a formula that defines a computation or retrieval of a value.
14696 In a project file the value of an expression is either a string or a list
14697 of strings. A string value in an expression is either a literal, the current
14698 value of a variable, an external value, an attribute reference, or a
14699 concatenation operation.
14701 Syntax:
14703 @smallexample
14704 expression ::=
14705   term @{& term@}
14707 term ::=
14708   string_literal |
14709   string_list |
14710   <variable_>name |
14711   external_value |
14712   attribute_reference
14714 string_literal ::=
14715   (same as Ada)
14717 string_list ::=
14718   ( <string_>expression @{ , <string_>expression @} )
14719 @end smallexample
14721 @subsection Concatenation
14722 @noindent
14723 The following concatenation functions are defined:
14725 @smallexample @c ada
14726   function "&" (X : String;      Y : String)      return String;
14727   function "&" (X : String_List; Y : String)      return String_List;
14728   function "&" (X : String_List; Y : String_List) return String_List;
14729 @end smallexample
14731 @node Attributes
14732 @section Attributes
14734 @noindent
14735 An attribute declaration defines a property of a project or package. This
14736 property can later be queried by means of an attribute reference.
14737 Attribute values are strings or string lists.
14739 Some attributes are associative arrays. These attributes are mappings whose
14740 domain is a set of strings. These attributes are declared one association
14741 at a time, by specifying a point in the domain and the corresponding image
14742 of the attribute. They may also be declared as a full associative array,
14743 getting the same associations as the corresponding attribute in an imported
14744 or extended project.
14746 Attributes that are not associative arrays are called simple attributes.
14748 Syntax:
14749 @smallexample
14750 attribute_declaration ::=
14751   full_associative_array_declaration |
14752   @b{for} attribute_designator @b{use} expression ;
14754 full_associative_array_declaration ::=
14755   @b{for} <associative_array_attribute_>simple_name @b{use}
14756   <project_>simple_name [ . <package_>simple_Name ] ' <attribute_>simple_name ;
14758 attribute_designator ::=
14759   <simple_attribute_>simple_name |
14760   <associative_array_attribute_>simple_name ( string_literal )
14761 @end smallexample
14763 @noindent
14764 Some attributes are project-specific, and can only appear immediately within
14765 a project declaration. Others are package-specific, and can only appear within
14766 the proper package.
14768 The expression in an attribute definition must be a string or a string_list.
14769 The string literal appearing in the attribute_designator of an associative
14770 array attribute is case-insensitive.
14772 @node Project Attributes
14773 @section Project Attributes
14775 @noindent
14776 The following attributes apply to a project. All of them are simple
14777 attributes.
14779 @table @code
14780 @item   Object_Dir
14781 Expression must be a path name. The attribute defines the
14782 directory in which the object files created by the build are to be placed. If
14783 not specified, object files are placed in the project directory.
14785 @item   Exec_Dir
14786 Expression must be a path name. The attribute defines the
14787 directory in which the executables created by the build are to be placed.
14788 If not specified, executables are placed in the object directory.
14790 @item  Source_Dirs
14791 Expression must be a list of path names. The attribute
14792 defines the directories in which the source files for the project are to be
14793 found. If not specified, source files are found in the project directory.
14795 @item  Source_Files
14796 Expression must be a list of file names. The attribute
14797 defines the individual files, in the project directory, which are to be used
14798 as sources for the project. File names are path_names that contain no directory
14799 information. If the project has no sources the attribute must be declared
14800 explicitly with an empty list.
14802 @item  Source_List_File
14803 Expression must a single path name. The attribute
14804 defines a text file that contains a list of source file names to be used
14805 as sources for the project
14807 @item  Library_Dir
14808 Expression must be a path name. The attribute defines the
14809 directory in which a  library is to be built.  The directory must exist, must
14810 be distinct from the project's object directory, and must be writable.
14812 @item  Library_Name
14813 Expression must be a string that is a legal file name,
14814 without extension. The attribute defines a string that is used to generate
14815 the name of the library to be built by the project.
14817 @item  Library_Kind
14818 Argument must be a string value that must be one of the
14819 following @code{"static"}, @code{"dynamic"} or @code{"relocatable"}. This
14820 string is case-insensitive. If this attribute is not specified, the library is
14821 a static library. Otherwise, the library may be dynamic or relocatable. This
14822 distinction is operating-system dependent.
14824 @item  Library_Version
14825 Expression must be a string value whose interpretation
14826 is platform dependent. On UNIX, it is used only for dynamic/relocatable
14827 libraries as the internal name of the library (the @code{"soname"}). If the
14828 library file name (built from the @code{Library_Name}) is different from the
14829 @code{Library_Version}, then the library file will be a symbolic link to the
14830 actual file whose name will be @code{Library_Version}.
14832 @item Library_Interface
14833 Expression must be a string list. Each element of the string list
14834 must designate a unit of the project.
14835 If this attribute is present in a Library Project File, then the project
14836 file is a Stand-alone Library_Project_File.
14838 @item Library_Auto_Init
14839 Expression must be a single string "true" or "false", case-insensitive.
14840 If this attribute is present in a Stand-alone Library Project File,
14841 it indicates if initialization is automatic when the dynamic library
14842 is loaded.
14844 @item Library_Options
14845 Expression must be a string list. Indicates additional switches that
14846 are to be used when building a shared library.
14848 @item Library_GCC
14849 Expression must be a single string. Designates an alternative to "gcc"
14850 for building shared libraries.
14852 @item  Library_Src_Dir
14853 Expression must be a path name. The attribute defines the
14854 directory in which the sources of the interfaces of a Stand-alone Library will
14855 be copied.  The directory must exist, must be distinct from the project's
14856 object directory and source directories of all projects in the project tree,
14857 and must be writable.
14859 @item  Library_Src_Dir
14860 Expression must be a path name. The attribute defines the
14861 directory in which the ALI files of a Library will
14862 be copied.  The directory must exist, must be distinct from the project's
14863 object directory and source directories of all projects in the project tree,
14864 and must be writable.
14866 @item  Library_Symbol_File
14867 Expression must be a single string. Its value is the single file name of a
14868 symbol file to be created when building a stand-alone library when the
14869 symbol policy is either "compliant", "controlled" or "restricted",
14870 on platforms that support symbol control, such as VMS.
14872 @item   Library_Reference_Symbol_File
14873 Expression must be a single string. Its value is the single file name of a
14874 reference symbol file that is read when the symbol policy is either
14875 "compliant" or "controlled", on platforms that support symbol control,
14876 such as VMS, when building a stand-alone library.
14878 @item  Library_Symbol_Policy
14879 Expression must be a single string. Its case-insensitive value can only be
14880 "autonomous", "default", "compliant", "controlled" or "restricted".
14882 This attribute is not taken into account on all platforms. It controls the
14883 policy for exported symbols and, on some platforms (like VMS) that have the
14884 notions of major and minor IDs built in the library files, it controls
14885 the setting of these IDs.
14887 "autonomous" or "default": exported symbols are not controlled.
14889 "compliant": if attribute Library_Reference_Symbol_File is not defined, then
14890 it is equivalent to policy "autonomous". If there are exported symbols in
14891 the reference symbol file that are not in the object files of the interfaces,
14892 the major ID of the library is increased. If there are symbols in the
14893 object files of the interfaces that are not in the reference symbol file,
14894 these symbols are put at the end of the list in the newly created symbol file
14895 and the minor ID is increased.
14897 "controlled": the attribute Library_Reference_Symbol_File must be defined.
14898 The library will fail to build if the exported symbols in the object files of
14899 the interfaces do not match exactly the symbol in the symbol file.
14901 "restricted": The attribute Library_Symbol_File must be defined. The library
14902 will fail to build if there are symbols in the symbol file that are not in
14903 the exported symbols of the object files of the interfaces. Additional symbols
14904 in the object files are not added to the symbol file.
14906 @item  Main
14907 Expression must be a list of strings that are legal file names.
14908 These file names designate existing compilation units in the source directory
14909 that are legal main subprograms.
14911 When a project file is elaborated, as part of the execution of a gnatmake
14912 command, one or several executables are built and placed in the Exec_Dir.
14913 If the gnatmake command does not include explicit file names, the executables
14914 that are built correspond to the files specified by this attribute.
14916 @item  Externally_Built
14917 Expression must be a single string. Its value must be either "true" of "false",
14918 case-insensitive. The default is "false". When the value of this attribute is
14919 "true", no attempt is made to compile the sources or to build the library,
14920 when the project is a library project.
14922 @item Main_Language
14923 This is a simple attribute. Its value is a string that specifies the
14924 language of the main program.
14926 @item  Languages
14927 Expression must be a string list. Each string designates
14928 a programming language that is known to GNAT. The strings are case-insensitive.
14930 @item  Locally_Removed_Files
14931 This attribute is legal only in a project file that extends another.
14932 Expression must be a list of strings that are legal file names.
14933 Each file name must designate a source that would normally be inherited
14934 by the current project file. It cannot designate an immediate source that is
14935 not inherited. Each of the source files in the list are not considered to
14936 be sources of the project file: they are not inherited.
14937 @end table
14939 @node Attribute References
14940 @section Attribute References
14942 @noindent
14943 Attribute references are used to retrieve the value of previously defined
14944 attribute for a package or project.
14945 Syntax:
14946 @smallexample
14947 attribute_reference ::=
14948   attribute_prefix ' <simple_attribute_>simple_name [ ( string_literal ) ]
14950 attribute_prefix ::=
14951   @b{project} |
14952   <project_simple_name | package_identifier |
14953   <project_>simple_name . package_identifier
14954 @end smallexample
14956 @noindent
14957 If an attribute has not been specified for a given package or project, its
14958 value is the null string or the empty list.
14960 @node External Values
14961 @section External Values
14963 @noindent
14964 An external value is an expression whose value is obtained from the command
14965 that invoked the processing of the current project file (typically a
14966 gnatmake command).
14968 Syntax:
14969 @smallexample
14970 external_value ::=
14971   @b{external} ( string_literal [, string_literal] )
14972 @end smallexample
14974 @noindent
14975 The first string_literal is the string to be used on the command line or
14976 in the environment to specify the external value. The second string_literal,
14977 if present, is the default to use if there is no specification for this
14978 external value either on the command line or in the environment.
14980 @node Case Construction
14981 @section Case Construction
14983 @noindent
14984 A case construction supports attribute declarations that depend on the value of
14985 a previously declared variable.
14987 Syntax:
14988 @smallexample
14989 case_construction ::=
14990   @b{case} <typed_variable_>name @b{is}
14991     @{case_item@}
14992   @b{end case} ;
14994 case_item ::=
14995   @b{when} discrete_choice_list =>
14996     @{case_construction | attribute_declaration | empty_declaration@}
14998 discrete_choice_list ::=
14999   string_literal @{| string_literal@} |
15000     @b{others}
15001 @end smallexample
15003 @noindent
15004 All choices in a choice list must be distinct. The choice lists of two
15005 distinct alternatives must be disjoint. Unlike Ada, the choice lists of all
15006 alternatives do not need to include all values of the type. An @code{others}
15007 choice must appear last in the list of alternatives.
15009 @node Packages
15010 @section Packages
15012 @noindent
15013 A package provides a grouping of variable declarations and attribute
15014 declarations to be used when invoking various GNAT tools. The name of
15015 the package indicates the tool(s) to which it applies.
15016 Syntax:
15018 @smallexample
15019 package_declaration ::=
15020   package_specification | package_renaming
15022 package_specification ::=
15023   @b{package} package_identifier @b{is}
15024     @{simple_declarative_item@}
15025   @b{end} package_identifier ;
15027 package_identifier ::=
15028   @code{Naming} | @code{Builder} | @code{Compiler} | @code{Binder} |
15029   @code{Linker} | @code{Finder}  | @code{Cross_Reference} |
15030   @code{gnatls} | @code{IDE}     | @code{Pretty_Printer}
15031 @end smallexample
15033 @subsection Package Naming
15035 @noindent
15036 The attributes of a @code{Naming} package specifies the naming conventions
15037 that apply to the source files in a project. When invoking other GNAT tools,
15038 they will use the sources in the source directories that satisfy these
15039 naming conventions.
15041 The following attributes apply to a @code{Naming} package:
15043 @table @code
15044 @item Casing
15045 This is a simple attribute whose value is a string. Legal values of this
15046 string are @code{"lowercase"}, @code{"uppercase"} or @code{"mixedcase"}.
15047 These strings are themselves case insensitive.
15049 @noindent
15050 If @code{Casing} is not specified, then the default is @code{"lowercase"}.
15052 @item Dot_Replacement
15053 This is a simple attribute whose string value satisfies the following
15054 requirements:
15056 @itemize @bullet
15057 @item It must not be empty
15058 @item It cannot start or end with an alphanumeric character
15059 @item It cannot be a single underscore
15060 @item It cannot start with an underscore followed by an alphanumeric
15061 @item It cannot contain a dot @code{'.'} if longer than one character
15062 @end itemize
15064 @noindent
15065 If @code{Dot_Replacement} is not specified, then the default is @code{"-"}.
15067 @item Spec_Suffix
15068 This is an associative array attribute, defined on language names,
15069 whose image is a string that must satisfy the following
15070 conditions:
15072 @itemize @bullet
15073 @item It must not be empty
15074 @item It cannot start with an alphanumeric character
15075 @item It cannot start with an underscore followed by an alphanumeric character
15076 @end itemize
15078 @noindent
15079 For Ada, the attribute denotes the suffix used in file names that contain
15080 library unit declarations, that is to say units that are package and
15081 subprogram declarations. If @code{Spec_Suffix ("Ada")} is not
15082 specified, then the default is @code{".ads"}.
15084 For C and C++, the attribute denotes the suffix used in file names that
15085 contain prototypes.
15087 @item Body_Suffix
15088 This is an associative array attribute defined on language names,
15089 whose image is a string that must satisfy the following
15090 conditions:
15092 @itemize @bullet
15093 @item It must not be empty
15094 @item It cannot start with an alphanumeric character
15095 @item It cannot start with an underscore followed by an alphanumeric character
15096 @item It cannot be a suffix of @code{Spec_Suffix}
15097 @end itemize
15099 @noindent
15100 For Ada, the attribute denotes the suffix used in file names that contain
15101 library bodies, that is to say units that are package and subprogram bodies.
15102 If @code{Body_Suffix ("Ada")} is not specified, then the default is
15103 @code{".adb"}.
15105 For C and C++, the attribute denotes the suffix used in file names that contain
15106 source code.
15108 @item Separate_Suffix
15109 This is a simple attribute whose value satisfies the same conditions as
15110 @code{Body_Suffix}.
15112 This attribute is specific to Ada. It denotes the suffix used in file names
15113 that contain separate bodies. If it is not specified, then it defaults to same
15114 value as @code{Body_Suffix ("Ada")}.
15116 @item Spec
15117 This is an associative array attribute, specific to Ada, defined over
15118 compilation unit names. The image is a string that is the name of the file
15119 that contains that library unit. The file name is case sensitive if the
15120 conventions of the host operating system require it.
15122 @item Body
15123 This is an associative array attribute, specific to Ada, defined over
15124 compilation unit names. The image is a string that is the name of the file
15125 that contains the library unit body for the named unit. The file name is case
15126 sensitive if the conventions of the host operating system require it.
15128 @item Specification_Exceptions
15129 This is an associative array attribute defined on language names,
15130 whose value is a list of strings.
15132 This attribute is not significant for Ada.
15134 For C and C++, each string in the list denotes the name of a file that
15135 contains prototypes, but whose suffix is not necessarily the
15136 @code{Spec_Suffix} for the language.
15138 @item Implementation_Exceptions
15139 This is an associative array attribute defined on language names,
15140 whose value is a list of strings.
15142 This attribute is not significant for Ada.
15144 For C and C++, each string in the list denotes the name of a file that
15145 contains source code, but whose suffix is not necessarily the
15146 @code{Body_Suffix} for the language.
15147 @end table
15149 The following attributes of package @code{Naming} are obsolescent. They are
15150 kept as synonyms of other attributes for compatibility with previous versions
15151 of the Project Manager.
15153 @table @code
15154 @item Specification_Suffix
15155 This is a synonym of @code{Spec_Suffix}.
15157 @item Implementation_Suffix
15158 This is a synonym of @code{Body_Suffix}.
15160 @item Specification
15161 This is a synonym of @code{Spec}.
15163 @item Implementation
15164 This is a synonym of @code{Body}.
15165 @end table
15167 @subsection package Compiler
15169 @noindent
15170 The attributes of the @code{Compiler} package specify the compilation options
15171 to be used by the underlying compiler.
15173 @table @code
15174 @item  Default_Switches
15175 This is an associative array attribute. Its
15176 domain is a set of language names. Its range is a string list that
15177 specifies the compilation options to be used when compiling a component
15178 written in that language, for which no file-specific switches have been
15179 specified.
15181 @item  Switches
15182 This is an associative array attribute. Its domain is
15183 a set of file names. Its range is a string list that specifies the
15184 compilation options to be used when compiling the named file. If a file
15185 is not specified in the Switches attribute, it is compiled with the
15186 options specified by Default_Switches of its language, if defined.
15188 @item  Local_Configuration_Pragmas.
15189 This is a simple attribute, whose
15190 value is a path name that designates a file containing configuration pragmas
15191 to be used for all invocations of the compiler for immediate sources of the
15192 project.
15193 @end table
15195 @subsection package Builder
15197 @noindent
15198 The attributes of package @code{Builder} specify the compilation, binding, and
15199 linking options to be used when building an executable for a project. The
15200 following attributes apply to package @code{Builder}:
15202 @table @code
15203 @item Default_Switches
15204 This is an associative array attribute. Its
15205 domain is a set of language names. Its range is a string list that
15206 specifies options to be used when building a main
15207 written in that language, for which no file-specific switches have been
15208 specified.
15210 @item Switches
15211 This is an associative array attribute. Its domain is
15212 a set of file names. Its range is a string list that specifies
15213 options to be used when building the named main file. If a main file
15214 is not specified in the Switches attribute, it is built with the
15215 options specified by Default_Switches of its language, if defined.
15217 @item Global_Configuration_Pragmas
15218 This is a simple attribute, whose
15219 value is a path name that designates a file that contains configuration pragmas
15220 to be used in every build of an executable. If both local and global
15221 configuration pragmas are specified, a compilation makes use of both sets.
15224 @item Executable
15225 This is an associative array attribute. Its domain is
15226 a set of main source file names. Its range is a simple string that specifies
15227 the executable file name to be used when linking the specified main source.
15228 If a main source is not specified in the Executable attribute, the executable
15229 file name is deducted from the main source file name.
15230 This attribute has no effect if its value is the empty string.
15232 @item Executable_Suffix
15233 This is a simple attribute whose value is the suffix to be added to
15234 the executables that don't have an attribute Executable specified.
15235 @end table
15237 @subsection package Gnatls
15239 @noindent
15240 The attributes of package @code{Gnatls} specify the tool options to be used
15241 when invoking the library browser @command{gnatls}.
15242 The following attributes apply to package @code{Gnatls}:
15244 @table @code
15245 @item Switches
15246 This is a single attribute with a string list value. Each non empty string
15247 in the list is an option when invoking @code{gnatls}.
15248 @end table
15250 @subsection package Binder
15252 @noindent
15253 The attributes of package @code{Binder} specify the options to be used
15254 when invoking the binder in the construction of an executable.
15255 The following attributes apply to package @code{Binder}:
15257 @table @code
15258 @item     Default_Switches
15259 This is an associative array attribute. Its
15260 domain is a set of language names. Its range is a string list that
15261 specifies options to be used when binding a main
15262 written in that language, for which no file-specific switches have been
15263 specified.
15265 @item Switches
15266 This is an associative array attribute. Its domain is
15267 a set of file names. Its range is a string list that specifies
15268 options to be used when binding the named main file. If a main file
15269 is not specified in the Switches attribute, it is bound with the
15270 options specified by Default_Switches of its language, if defined.
15271 @end table
15273 @subsection package Linker
15275 @noindent
15276 The attributes of package @code{Linker} specify the options to be used when
15277 invoking the linker in the construction of an executable.
15278 The following attributes apply to package @code{Linker}:
15280 @table @code
15281 @item     Default_Switches
15282 This is an associative array attribute. Its
15283 domain is a set of language names. Its range is a string list that
15284 specifies options to be used when linking a main
15285 written in that language, for which no file-specific switches have been
15286 specified.
15288 @item Switches
15289 This is an associative array attribute. Its domain is
15290 a set of file names. Its range is a string list that specifies
15291 options to be used when linking the named main file. If a main file
15292 is not specified in the Switches attribute, it is linked with the
15293 options specified by Default_Switches of its language, if defined.
15295 @item  Linker_Options
15296 This is a string list attribute. Its value specifies additional options that
15297 be given to the linker when linking an executable. This attribute is not
15298 used in the main project, only in projects imported directly or indirectly.
15300 @end table
15302 @subsection package Cross_Reference
15304 @noindent
15305 The attributes of package @code{Cross_Reference} specify the tool options
15306 to be used
15307 when invoking the library tool @command{gnatxref}.
15308 The following attributes apply to package @code{Cross_Reference}:
15310 @table @code
15311 @item     Default_Switches
15312 This is an associative array attribute. Its
15313 domain is a set of language names. Its range is a string list that
15314 specifies options to be used when calling @command{gnatxref} on a source
15315 written in that language, for which no file-specific switches have been
15316 specified.
15318 @item Switches
15319 This is an associative array attribute. Its domain is
15320 a set of file names. Its range is a string list that specifies
15321 options to be used when calling @command{gnatxref} on the named main source.
15322 If a source is not specified in the Switches attribute, @command{gnatxref} will
15323 be called with the options specified by Default_Switches of its language,
15324 if defined.
15325 @end table
15327 @subsection package   Finder
15329 @noindent
15330 The attributes of package @code{Finder} specify the tool options to be used
15331 when invoking the search tool @command{gnatfind}.
15332 The following attributes apply to package @code{Finder}:
15334 @table @code
15335 @item     Default_Switches
15336 This is an associative array attribute. Its
15337 domain is a set of language names. Its range is a string list that
15338 specifies options to be used when calling @command{gnatfind} on a source
15339 written in that language, for which no file-specific switches have been
15340 specified.
15342 @item Switches
15343 This is an associative array attribute. Its domain is
15344 a set of file names. Its range is a string list that specifies
15345 options to be used when calling @command{gnatfind} on the named main source.
15346 If a source is not specified in the Switches attribute, @command{gnatfind} will
15347 be called with the options specified by Default_Switches of its language,
15348 if defined.
15349 @end table
15351 @subsection package Pretty_Printer
15353 @noindent
15354 The attributes of package @code{Pretty_Printer}
15355 specify the tool options to be used
15356 when invoking the formatting tool @command{gnatpp}.
15357 The following attributes apply to package @code{Pretty_Printer}:
15359 @table @code
15360 @item     Default_switches
15361 This is an associative array attribute. Its
15362 domain is a set of language names. Its range is a string list that
15363 specifies options to be used when calling @command{gnatpp} on a source
15364 written in that language, for which no file-specific switches have been
15365 specified.
15367 @item Switches
15368 This is an associative array attribute. Its domain is
15369 a set of file names. Its range is a string list that specifies
15370 options to be used when calling @command{gnatpp} on the named main source.
15371 If a source is not specified in the Switches attribute, @command{gnatpp} will
15372 be called with the options specified by Default_Switches of its language,
15373 if defined.
15374 @end table
15376 @subsection package gnatstub
15378 @noindent
15379 The attributes of package @code{gnatstub}
15380 specify the tool options to be used
15381 when invoking the tool @command{gnatstub}.
15382 The following attributes apply to package @code{gnatstub}:
15384 @table @code
15385 @item     Default_switches
15386 This is an associative array attribute. Its
15387 domain is a set of language names. Its range is a string list that
15388 specifies options to be used when calling @command{gnatstub} on a source
15389 written in that language, for which no file-specific switches have been
15390 specified.
15392 @item Switches
15393 This is an associative array attribute. Its domain is
15394 a set of file names. Its range is a string list that specifies
15395 options to be used when calling @command{gnatstub} on the named main source.
15396 If a source is not specified in the Switches attribute, @command{gnatpp} will
15397 be called with the options specified by Default_Switches of its language,
15398 if defined.
15399 @end table
15401 @subsection package Eliminate
15403 @noindent
15404 The attributes of package @code{Eliminate}
15405 specify the tool options to be used
15406 when invoking the tool @command{gnatelim}.
15407 The following attributes apply to package @code{Eliminate}:
15409 @table @code
15410 @item     Default_switches
15411 This is an associative array attribute. Its
15412 domain is a set of language names. Its range is a string list that
15413 specifies options to be used when calling @command{gnatelim} on a source
15414 written in that language, for which no file-specific switches have been
15415 specified.
15417 @item Switches
15418 This is an associative array attribute. Its domain is
15419 a set of file names. Its range is a string list that specifies
15420 options to be used when calling @command{gnatelim} on the named main source.
15421 If a source is not specified in the Switches attribute, @command{gnatelim} will
15422 be called with the options specified by Default_Switches of its language,
15423 if defined.
15424 @end table
15426 @subsection package Metrics
15428 @noindent
15429 The attributes of package @code{Metrics}
15430 specify the tool options to be used
15431 when invoking the tool @command{gnatmetric}.
15432 The following attributes apply to package @code{Metrics}:
15434 @table @code
15435 @item     Default_switches
15436 This is an associative array attribute. Its
15437 domain is a set of language names. Its range is a string list that
15438 specifies options to be used when calling @command{gnatmetric} on a source
15439 written in that language, for which no file-specific switches have been
15440 specified.
15442 @item Switches
15443 This is an associative array attribute. Its domain is
15444 a set of file names. Its range is a string list that specifies
15445 options to be used when calling @command{gnatmetric} on the named main source.
15446 If a source is not specified in the Switches attribute, @command{gnatmetric}
15447 will be called with the options specified by Default_Switches of its language,
15448 if defined.
15449 @end table
15451 @subsection  package IDE
15453 @noindent
15454 The attributes of package @code{IDE} specify the options to be used when using
15455 an Integrated Development Environment such as @command{GPS}.
15457 @table @code
15458 @item Remote_Host
15459 This is a simple attribute. Its value is a string that designates the remote
15460 host in a cross-compilation environment, to be used for remote compilation and
15461 debugging. This field should not be specified when running on the local
15462 machine.
15464 @item Program_Host
15465 This is a simple attribute. Its value is a string that specifies the
15466 name of IP address of the embedded target in a cross-compilation environment,
15467 on which the program should execute.
15469 @item Communication_Protocol
15470 This is a simple string attribute. Its value is the name of the protocol
15471 to use to communicate with the target in a cross-compilation environment,
15472 e.g. @code{"wtx"} or @code{"vxworks"}.
15474 @item Compiler_Command
15475 This is an associative array attribute, whose domain is a language name. Its
15476 value is  string that denotes the command to be used to invoke the compiler.
15477 The value of @code{Compiler_Command ("Ada")} is expected to be compatible with
15478 gnatmake, in particular in the handling of switches.
15480 @item Debugger_Command
15481 This is simple attribute, Its value is a string that specifies the name of
15482 the debugger to be used, such as gdb, powerpc-wrs-vxworks-gdb or gdb-4.
15484 @item Default_Switches
15485 This is an associative array attribute. Its indexes are the name of the
15486 external tools that the GNAT Programming System (GPS) is supporting. Its
15487 value is a list of switches to use when invoking that tool.
15489 @item  Gnatlist
15490 This is a simple attribute.  Its value is a string that specifies the name
15491 of the @command{gnatls} utility to be used to retrieve information about the
15492 predefined path; e.g., @code{"gnatls"}, @code{"powerpc-wrs-vxworks-gnatls"}.
15494 @item VCS_Kind
15495 This is a simple attribute. Its value is a string used to specify the
15496 Version Control System (VCS) to be used for this project, e.g CVS, RCS
15497 ClearCase or Perforce.
15499 @item VCS_File_Check
15500 This is a simple attribute. Its value is a string that specifies the
15501 command used by the VCS to check the validity of a file, either
15502 when the user explicitly asks for a check, or as a sanity check before
15503 doing the check-in.
15505 @item VCS_Log_Check
15506 This is a simple attribute. Its value is a string that specifies
15507 the command used by the VCS to check the validity of a log file.
15509 @end table
15511 @node Package Renamings
15512 @section Package Renamings
15514 @noindent
15515 A package can be defined by a renaming declaration. The new package renames
15516 a package declared in a different project file, and has the same attributes
15517 as the package it renames.
15518 Syntax:
15519 @smallexample
15520 package_renaming ::==
15521   @b{package} package_identifier @b{renames}
15522        <project_>simple_name.package_identifier ;
15523 @end smallexample
15525 @noindent
15526 The package_identifier of the renamed package must be the same as the
15527 package_identifier. The project whose name is the prefix of the renamed
15528 package must contain a package declaration with this name. This project
15529 must appear in the context_clause of the enclosing project declaration,
15530 or be the parent project of the enclosing child project.
15532 @node Projects
15533 @section Projects
15535 @noindent
15536 A project file specifies a set of rules for constructing a software system.
15537 A project file can be self-contained, or depend on other project files.
15538 Dependencies are expressed through a context clause that names other projects.
15540 Syntax:
15542 @smallexample
15543 project ::=
15544   context_clause project_declaration
15546 project_declaration ::=
15547   simple_project_declaration | project_extension
15549 simple_project_declaration ::=
15550   @b{project} <project_>simple_name @b{is}
15551     @{declarative_item@}
15552   @b{end} <project_>simple_name;
15554 context_clause ::=
15555   @{with_clause@}
15557 with_clause ::=
15558   [@b{limited}] @b{with} path_name @{ , path_name @} ;
15560 path_name ::=
15561    string_literal
15562 @end smallexample
15564 @noindent
15565 A path name denotes a project file. A path name can be absolute or relative.
15566 An absolute path name includes a sequence of directories, in the syntax of
15567 the host operating system, that identifies uniquely the project file in the
15568 file system. A relative path name identifies the project file, relative
15569 to the directory that contains the current project, or relative to a
15570 directory listed in the environment variable ADA_PROJECT_PATH.
15571 Path names are case sensitive if file names in the host operating system
15572 are case sensitive.
15574 The syntax of the environment variable ADA_PROJECT_PATH is a list of
15575 directory names separated by colons (semicolons on Windows).
15577 A given project name can appear only once in a context_clause.
15579 It is illegal for a project imported by a context clause to refer, directly
15580 or indirectly, to the project in which this context clause appears (the
15581 dependency graph cannot contain cycles), except when one of the with_clause
15582 in the cycle is a @code{limited with}.
15584 @node Project Extensions
15585 @section Project Extensions
15587 @noindent
15588 A project extension introduces a new project, which inherits the declarations
15589 of another project.
15590 Syntax:
15591 @smallexample
15593 project_extension ::=
15594   @b{project} <project_>simple_name  @b{extends} path_name @b{is}
15595     @{declarative_item@}
15596   @b{end} <project_>simple_name;
15597 @end smallexample
15599 @noindent
15600 The project extension declares a child project. The child project inherits
15601 all the declarations and all the files of the parent project, These inherited
15602 declaration can be overridden in the child project, by means of suitable
15603 declarations.
15605 @node Project File Elaboration
15606 @section Project File Elaboration
15608 @noindent
15609 A project file is processed as part of the invocation of a gnat tool that
15610 uses the project option. Elaboration of the process file consists in the
15611 sequential elaboration of all its declarations. The computed values of
15612 attributes and variables in the project are then used to establish the
15613 environment in which the gnat tool will execute.
15615 @node Obsolescent Features
15616 @chapter Obsolescent Features
15618 @noindent
15619 This chapter describes features that are provided by GNAT, but are
15620 considered obsolescent since there are preferred ways of achieving
15621 the same effect. These features are provided solely for historical
15622 compatibility purposes.
15624 @menu
15625 * pragma No_Run_Time::
15626 * pragma Ravenscar::
15627 * pragma Restricted_Run_Time::
15628 @end menu
15630 @node pragma No_Run_Time
15631 @section pragma No_Run_Time
15633 The pragma @code{No_Run_Time} is used to achieve an affect similar
15634 to the use of the "Zero Foot Print" configurable run time, but without
15635 requiring a specially configured run time. The result of using this
15636 pragma, which must be used for all units in a partition, is to restrict
15637 the use of any language features requiring run-time support code. The
15638 preferred usage is to use an appropriately configured run-time that
15639 includes just those features that are to be made accessible.
15641 @node pragma Ravenscar
15642 @section pragma Ravenscar
15644 The pragma @code{Ravenscar} has exactly the same effect as pragma
15645 @code{Profile (Ravenscar)}. The latter usage is preferred since it
15646 is part of the new Ada 2005 standard.
15648 @node pragma Restricted_Run_Time
15649 @section pragma Restricted_Run_Time
15651 The pragma @code{Restricted_Run_Time} has exactly the same effect as
15652 pragma @code{Profile (Restricted)}. The latter usage is
15653 preferred since the Ada 2005 pragma @code{Profile} is intended for
15654 this kind of implementation dependent addition.
15656 @include fdl.texi
15657 @c GNU Free Documentation License
15659 @node Index,,GNU Free Documentation License, Top
15660 @unnumbered Index
15662 @printindex cp
15664 @contents
15666 @bye