* config/mips/mips.c (function_arg): Where one part of a
[official-gcc.git] / gcc / ada / gnat_rm.texi
bloba0f1b4fa96e9a05d045466d043972443ae61e80e
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-2005 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 FSFEDITION
22 @settitle GNAT Reference Manual
24 @setchapternewpage odd
25 @syncodeindex fn cp
27 @include gcc-common.texi
29 @dircategory GNU Ada tools
30 @direntry
31 * GNAT Reference Manual: (gnat_rm).  Reference Manual for GNU Ada tools.
32 @end direntry
34 @copying
35 Copyright @copyright{} 1995-2004, Free Software Foundation
37 Permission is granted to copy, distribute and/or modify this document
38 under the terms of the GNU Free Documentation License, Version 1.2
39 or any later version published by the Free Software Foundation;
40 with the Invariant Sections being ``GNU Free Documentation License'',
41 with the Front-Cover Texts being ``GNAT Reference Manual'', and with
42 no Back-Cover Texts. A copy of the license is included in the section
43 entitled ``GNU Free Documentation License''.
44 @end copying
46 @titlepage
48 @title GNAT Reference Manual
49 @subtitle GNAT, The GNU Ada 95 Compiler
50 @subtitle GCC version @value{version-GCC}
51 @author AdaCore
53 @page
54 @vskip 0pt plus 1filll
56 @insertcopying
58 @end titlepage
60 @ifnottex
61 @node Top, About This Guide, (dir), (dir)
62 @top GNAT Reference Manual
64 @noindent
65 GNAT Reference Manual
67 @noindent
68 GNAT, The GNU Ada 95 Compiler@*
69 GCC version @value{version-GCC}@*
71 @noindent
72 AdaCore
74 @menu
75 * About This Guide::
76 * Implementation Defined Pragmas::
77 * Implementation Defined Attributes::
78 * Implementation Advice::
79 * Implementation Defined Characteristics::
80 * Intrinsic Subprograms::
81 * Representation Clauses and Pragmas::
82 * Standard Library Routines::
83 * The Implementation of Standard I/O::
84 * The GNAT Library::
85 * Interfacing to Other Languages::
86 * Specialized Needs Annexes::
87 * Implementation of Specific Ada Features::
88 * Project File Reference::
89 * Obsolescent Features::
90 * GNU Free Documentation License::
91 * Index::
93  --- The Detailed Node Listing ---
95 About This Guide
97 * What This Reference Manual Contains::
98 * Related Information::
100 Implementation Defined Pragmas
102 * Pragma Abort_Defer::
103 * Pragma Ada_83::
104 * Pragma Ada_95::
105 * Pragma Ada_05::
106 * Pragma Ada_2005::
107 * Pragma Annotate::
108 * Pragma Assert::
109 * Pragma Ast_Entry::
110 * Pragma C_Pass_By_Copy::
111 * Pragma Comment::
112 * Pragma Common_Object::
113 * Pragma Compile_Time_Warning::
114 * Pragma Complete_Representation::
115 * Pragma Complex_Representation::
116 * Pragma Component_Alignment::
117 * Pragma Convention_Identifier::
118 * Pragma CPP_Class::
119 * Pragma CPP_Constructor::
120 * Pragma CPP_Virtual::
121 * Pragma CPP_Vtable::
122 * Pragma Debug::
123 * Pragma Debug_Policy::
124 * Pragma Detect_Blocking::
125 * Pragma Elaboration_Checks::
126 * Pragma Eliminate::
127 * Pragma Export_Exception::
128 * Pragma Export_Function::
129 * Pragma Export_Object::
130 * Pragma Export_Procedure::
131 * Pragma Export_Value::
132 * Pragma Export_Valued_Procedure::
133 * Pragma Extend_System::
134 * Pragma External::
135 * Pragma External_Name_Casing::
136 * Pragma Finalize_Storage_Only::
137 * Pragma Float_Representation::
138 * Pragma Ident::
139 * Pragma Import_Exception::
140 * Pragma Import_Function::
141 * Pragma Import_Object::
142 * Pragma Import_Procedure::
143 * Pragma Import_Valued_Procedure::
144 * Pragma Initialize_Scalars::
145 * Pragma Inline_Always::
146 * Pragma Inline_Generic::
147 * Pragma Interface::
148 * Pragma Interface_Name::
149 * Pragma Interrupt_Handler::
150 * Pragma Interrupt_State::
151 * Pragma Keep_Names::
152 * Pragma License::
153 * Pragma Link_With::
154 * Pragma Linker_Alias::
155 * Pragma Linker_Constructor::
156 * Pragma Linker_Destructor::
157 * Pragma Linker_Section::
158 * Pragma Long_Float::
159 * Pragma Machine_Attribute::
160 * Pragma Main_Storage::
161 * Pragma No_Return::
162 * Pragma No_Strict_Aliasing ::
163 * Pragma Normalize_Scalars::
164 * Pragma Obsolescent::
165 * Pragma Passive::
166 * Pragma Persistent_BSS::
167 * Pragma Polling::
168 * Pragma Profile (Ravenscar)::
169 * Pragma Profile (Restricted)::
170 * Pragma Psect_Object::
171 * Pragma Pure_Function::
172 * Pragma Restriction_Warnings::
173 * Pragma Source_File_Name::
174 * Pragma Source_File_Name_Project::
175 * Pragma Source_Reference::
176 * Pragma Stream_Convert::
177 * Pragma Style_Checks::
178 * Pragma Subtitle::
179 * Pragma Suppress_All::
180 * Pragma Suppress_Exception_Locations::
181 * Pragma Suppress_Initialization::
182 * Pragma Task_Info::
183 * Pragma Task_Name::
184 * Pragma Task_Storage::
185 * Pragma Thread_Body::
186 * Pragma Time_Slice::
187 * Pragma Title::
188 * Pragma Unchecked_Union::
189 * Pragma Unimplemented_Unit::
190 * Pragma Universal_Data::
191 * Pragma Unreferenced::
192 * Pragma Unreserve_All_Interrupts::
193 * Pragma Unsuppress::
194 * Pragma Use_VADS_Size::
195 * Pragma Validity_Checks::
196 * Pragma Volatile::
197 * Pragma Warnings::
198 * Pragma Weak_External::
200 Implementation Defined Attributes
202 * Abort_Signal::
203 * Address_Size::
204 * Asm_Input::
205 * Asm_Output::
206 * AST_Entry::
207 * Bit::
208 * Bit_Position::
209 * Code_Address::
210 * Default_Bit_Order::
211 * Elaborated::
212 * Elab_Body::
213 * Elab_Spec::
214 * Emax::
215 * Enum_Rep::
216 * Epsilon::
217 * Fixed_Value::
218 * Has_Access_Values::
219 * Has_Discriminants::
220 * Img::
221 * Integer_Value::
222 * Large::
223 * Machine_Size::
224 * Mantissa::
225 * Max_Interrupt_Priority::
226 * Max_Priority::
227 * Maximum_Alignment::
228 * Mechanism_Code::
229 * Null_Parameter::
230 * Object_Size::
231 * Passed_By_Reference::
232 * Range_Length::
233 * Safe_Emax::
234 * Safe_Large::
235 * Small::
236 * Storage_Unit::
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_All::
720 * Pragma Suppress_Exception_Locations::
721 * Pragma Suppress_Initialization::
722 * Pragma Task_Info::
723 * Pragma Task_Name::
724 * Pragma Task_Storage::
725 * Pragma Thread_Body::
726 * Pragma Time_Slice::
727 * Pragma Title::
728 * Pragma Unchecked_Union::
729 * Pragma Unimplemented_Unit::
730 * Pragma Universal_Data::
731 * Pragma Unreferenced::
732 * Pragma Unreserve_All_Interrupts::
733 * Pragma Unsuppress::
734 * Pragma Use_VADS_Size::
735 * Pragma Validity_Checks::
736 * Pragma Volatile::
737 * Pragma Warnings::
738 * Pragma Weak_External::
739 @end menu
741 @node Pragma Abort_Defer
742 @unnumberedsec Pragma Abort_Defer
743 @findex Abort_Defer
744 @cindex Deferring aborts
745 @noindent
746 Syntax:
747 @smallexample
748 pragma Abort_Defer;
749 @end smallexample
751 @noindent
752 This pragma must appear at the start of the statement sequence of a
753 handled sequence of statements (right after the @code{begin}).  It has
754 the effect of deferring aborts for the sequence of statements (but not
755 for the declarations or handlers, if any, associated with this statement
756 sequence).
758 @node Pragma Ada_83
759 @unnumberedsec Pragma Ada_83
760 @findex Ada_83
761 @noindent
762 Syntax:
763 @smallexample @c ada
764 pragma Ada_83;
765 @end smallexample
767 @noindent
768 A configuration pragma that establishes Ada 83 mode for the unit to
769 which it applies, regardless of the mode set by the command line
770 switches.  In Ada 83 mode, GNAT attempts to be as compatible with
771 the syntax and semantics of Ada 83, as defined in the original Ada
772 83 Reference Manual as possible.  In particular, the new Ada 95
773 keywords are not recognized, optional package bodies are allowed,
774 and generics may name types with unknown discriminants without using
775 the @code{(<>)} notation.  In addition, some but not all of the additional
776 restrictions of Ada 83 are enforced.
778 Ada 83 mode is intended for two purposes.  Firstly, it allows existing
779 legacy Ada 83 code to be compiled and adapted to GNAT with less effort.
780 Secondly, it aids in keeping code backwards compatible with Ada 83.
781 However, there is no guarantee that code that is processed correctly
782 by GNAT in Ada 83 mode will in fact compile and execute with an Ada
783 83 compiler, since GNAT does not enforce all the additional checks
784 required by Ada 83.
786 @node Pragma Ada_95
787 @unnumberedsec Pragma Ada_95
788 @findex Ada_95
789 @noindent
790 Syntax:
791 @smallexample @c ada
792 pragma Ada_95;
793 @end smallexample
795 @noindent
796 A configuration pragma that establishes Ada 95 mode for the unit to which
797 it applies, regardless of the mode set by the command line switches.
798 This mode is set automatically for the @code{Ada} and @code{System}
799 packages and their children, so you need not specify it in these
800 contexts.  This pragma is useful when writing a reusable component that
801 itself uses Ada 95 features, but which is intended to be usable from
802 either Ada 83 or Ada 95 programs.
804 @node Pragma Ada_05
805 @unnumberedsec Pragma Ada_05
806 @findex Ada_05
807 @noindent
808 Syntax:
809 @smallexample @c ada
810 pragma Ada_05;
811 @end smallexample
813 @noindent
814 A configuration pragma that establishes Ada 2005 mode for the unit to which
815 it applies, regardless of the mode set by the command line switches.
816 This mode is set automatically for the @code{Ada} and @code{System}
817 packages and their children, so you need not specify it in these
818 contexts.  This pragma is useful when writing a reusable component that
819 itself uses Ada 2005 features, but which is intended to be usable from
820 either Ada 83 or Ada 95 programs.
822 @node Pragma Ada_2005
823 @unnumberedsec Pragma Ada_2005
824 @findex Ada_2005
825 @noindent
826 Syntax:
827 @smallexample @c ada
828 pragma Ada_2005;
829 @end smallexample
831 @noindent
832 This configuration pragma is a synonym for pragma Ada_05 and has the
833 same syntax and effect.
835 @node Pragma Annotate
836 @unnumberedsec Pragma Annotate
837 @findex Annotate
838 @noindent
839 Syntax:
840 @smallexample @c ada
841 pragma Annotate (IDENTIFIER @{, ARG@});
843 ARG ::= NAME | EXPRESSION
844 @end smallexample
846 @noindent
847 This pragma is used to annotate programs.  @var{identifier} identifies
848 the type of annotation.  GNAT verifies this is an identifier, but does
849 not otherwise analyze it.  The @var{arg} argument
850 can be either a string literal or an
851 expression.  String literals are assumed to be of type
852 @code{Standard.String}.  Names of entities are simply analyzed as entity
853 names.  All other expressions are analyzed as expressions, and must be
854 unambiguous.
856 The analyzed pragma is retained in the tree, but not otherwise processed
857 by any part of the GNAT compiler.  This pragma is intended for use by
858 external tools, including ASIS@.
860 @node Pragma Assert
861 @unnumberedsec Pragma Assert
862 @findex Assert
863 @noindent
864 Syntax:
865 @smallexample @c ada
866 pragma Assert (
867   boolean_EXPRESSION
868   [, static_string_EXPRESSION]);
869 @end smallexample
871 @noindent
872 The effect of this pragma depends on whether the corresponding command
873 line switch is set to activate assertions.  The pragma expands into code
874 equivalent to the following:
876 @smallexample @c ada
877 if assertions-enabled then
878    if not boolean_EXPRESSION then
879       System.Assertions.Raise_Assert_Failure
880         (string_EXPRESSION);
881    end if;
882 end if;
883 @end smallexample
885 @noindent
886 The string argument, if given, is the message that will be associated
887 with the exception occurrence if the exception is raised.  If no second
888 argument is given, the default message is @samp{@var{file}:@var{nnn}},
889 where @var{file} is the name of the source file containing the assert,
890 and @var{nnn} is the line number of the assert.  A pragma is not a
891 statement, so if a statement sequence contains nothing but a pragma
892 assert, then a null statement is required in addition, as in:
894 @smallexample @c ada
895 @dots{}
896 if J > 3 then
897    pragma Assert (K > 3, "Bad value for K");
898    null;
899 end if;
900 @end smallexample
902 @noindent
903 Note that, as with the @code{if} statement to which it is equivalent, the
904 type of the expression is either @code{Standard.Boolean}, or any type derived
905 from this standard type.
907 If assertions are disabled (switch @code{-gnata} not used), then there
908 is no effect (and in particular, any side effects from the expression
909 are suppressed).  More precisely it is not quite true that the pragma
910 has no effect, since the expression is analyzed, and may cause types
911 to be frozen if they are mentioned here for the first time.
913 If assertions are enabled, then the given expression is tested, and if
914 it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
915 which results in the raising of @code{Assert_Failure} with the given message.
917 If the boolean expression has side effects, these side effects will turn
918 on and off with the setting of the assertions mode, resulting in
919 assertions that have an effect on the program.  You should generally
920 avoid side effects in the expression arguments of this pragma.  However,
921 the expressions are analyzed for semantic correctness whether or not
922 assertions are enabled, so turning assertions on and off cannot affect
923 the legality of a program.
925 @node Pragma Ast_Entry
926 @unnumberedsec Pragma Ast_Entry
927 @cindex OpenVMS
928 @findex Ast_Entry
929 @noindent
930 Syntax:
931 @smallexample @c ada
932 pragma AST_Entry (entry_IDENTIFIER);
933 @end smallexample
935 @noindent
936 This pragma is implemented only in the OpenVMS implementation of GNAT@.  The
937 argument is the simple name of a single entry; at most one @code{AST_Entry}
938 pragma is allowed for any given entry.  This pragma must be used in
939 conjunction with the @code{AST_Entry} attribute, and is only allowed after
940 the entry declaration and in the same task type specification or single task
941 as the entry to which it applies.  This pragma specifies that the given entry
942 may be used to handle an OpenVMS asynchronous system trap (@code{AST})
943 resulting from an OpenVMS system service call.  The pragma does not affect
944 normal use of the entry.  For further details on this pragma, see the
945 DEC Ada Language Reference Manual, section 9.12a.
947 @node Pragma C_Pass_By_Copy
948 @unnumberedsec Pragma C_Pass_By_Copy
949 @cindex Passing by copy
950 @findex C_Pass_By_Copy
951 @noindent
952 Syntax:
953 @smallexample @c ada
954 pragma C_Pass_By_Copy
955   ([Max_Size =>] static_integer_EXPRESSION);
956 @end smallexample
958 @noindent
959 Normally the default mechanism for passing C convention records to C
960 convention subprograms is to pass them by reference, as suggested by RM
961 B.3(69).  Use the configuration pragma @code{C_Pass_By_Copy} to change
962 this default, by requiring that record formal parameters be passed by
963 copy if all of the following conditions are met:
965 @itemize @bullet
966 @item
967 The size of the record type does not exceed@*@var{static_integer_expression}.
968 @item
969 The record type has @code{Convention C}.
970 @item
971 The formal parameter has this record type, and the subprogram has a
972 foreign (non-Ada) convention.
973 @end itemize
975 @noindent
976 If these conditions are met the argument is passed by copy, i.e.@: in a
977 manner consistent with what C expects if the corresponding formal in the
978 C prototype is a struct (rather than a pointer to a struct).
980 You can also pass records by copy by specifying the convention
981 @code{C_Pass_By_Copy} for the record type, or by using the extended
982 @code{Import} and @code{Export} pragmas, which allow specification of
983 passing mechanisms on a parameter by parameter basis.
985 @node Pragma Comment
986 @unnumberedsec Pragma Comment
987 @findex Comment
988 @noindent
989 Syntax:
991 @smallexample @c ada
992 pragma Comment (static_string_EXPRESSION);
993 @end smallexample
995 @noindent
996 This is almost identical in effect to pragma @code{Ident}.  It allows the
997 placement of a comment into the object file and hence into the
998 executable file if the operating system permits such usage.  The
999 difference is that @code{Comment}, unlike @code{Ident}, has
1000 no limitations on placement of the pragma (it can be placed
1001 anywhere in the main source unit), and if more than one pragma
1002 is used, all comments are retained.
1004 @node Pragma Common_Object
1005 @unnumberedsec Pragma Common_Object
1006 @findex Common_Object
1007 @noindent
1008 Syntax:
1010 @smallexample @c ada
1011 pragma Common_Object (
1012      [Internal =>] local_NAME,
1013   [, [External =>] EXTERNAL_SYMBOL]
1014   [, [Size     =>] EXTERNAL_SYMBOL] );
1016 EXTERNAL_SYMBOL ::=
1017   IDENTIFIER
1018 | static_string_EXPRESSION
1019 @end smallexample
1021 @noindent
1022 This pragma enables the shared use of variables stored in overlaid
1023 linker areas corresponding to the use of @code{COMMON}
1024 in Fortran.  The single
1025 object @var{local_NAME} is assigned to the area designated by
1026 the @var{External} argument.
1027 You may define a record to correspond to a series
1028 of fields.  The @var{size} argument
1029 is syntax checked in GNAT, but otherwise ignored.
1031 @code{Common_Object} is not supported on all platforms.  If no
1032 support is available, then the code generator will issue a message
1033 indicating that the necessary attribute for implementation of this
1034 pragma is not available.
1036 @node Pragma Compile_Time_Warning
1037 @unnumberedsec Pragma Compile_Time_Warning
1038 @findex Compile_Time_Warning
1039 @noindent
1040 Syntax:
1042 @smallexample @c ada
1043 pragma Compile_Time_Warning
1044          (boolean_EXPRESSION, static_string_EXPRESSION);
1045 @end smallexample
1047 @noindent
1048 This pragma can be used to generate additional compile time warnings. It
1049 is particularly useful in generics, where warnings can be issued for
1050 specific problematic instantiations. The first parameter is a boolean
1051 expression. The pragma is effective only if the value of this expression
1052 is known at compile time, and has the value True. The set of expressions
1053 whose values are known at compile time includes all static boolean
1054 expressions, and also other values which the compiler can determine
1055 at compile time (e.g. the size of a record type set by an explicit
1056 size representation clause, or the value of a variable which was
1057 initialized to a constant and is known not to have been modified).
1058 If these conditions are met, a warning message is generated using
1059 the value given as the second argument. This string value may contain
1060 embedded ASCII.LF characters to break the message into multiple lines.
1062 @node Pragma Complete_Representation
1063 @unnumberedsec Pragma Complete_Representation
1064 @findex Complete_Representation
1065 @noindent
1066 Syntax:
1068 @smallexample @c ada
1069 pragma Complete_Representation;
1070 @end smallexample
1072 @noindent
1073 This pragma must appear immediately within a record representation
1074 clause. Typical placements are before the first component clause
1075 or after the last component clause. The effect is to give an error
1076 message if any component is missing a component clause. This pragma
1077 may be used to ensure that a record representation clause is
1078 complete, and that this invariant is maintained if fields are
1079 added to the record in the future.
1081 @node Pragma Complex_Representation
1082 @unnumberedsec Pragma Complex_Representation
1083 @findex Complex_Representation
1084 @noindent
1085 Syntax:
1087 @smallexample @c ada
1088 pragma Complex_Representation
1089         ([Entity =>] local_NAME);
1090 @end smallexample
1092 @noindent
1093 The @var{Entity} argument must be the name of a record type which has
1094 two fields of the same floating-point type.  The effect of this pragma is
1095 to force gcc to use the special internal complex representation form for
1096 this record, which may be more efficient.  Note that this may result in
1097 the code for this type not conforming to standard ABI (application
1098 binary interface) requirements for the handling of record types.  For
1099 example, in some environments, there is a requirement for passing
1100 records by pointer, and the use of this pragma may result in passing
1101 this type in floating-point registers.
1103 @node Pragma Component_Alignment
1104 @unnumberedsec Pragma Component_Alignment
1105 @cindex Alignments of components
1106 @findex Component_Alignment
1107 @noindent
1108 Syntax:
1110 @smallexample @c ada
1111 pragma Component_Alignment (
1112      [Form =>] ALIGNMENT_CHOICE
1113   [, [Name =>] type_local_NAME]);
1115 ALIGNMENT_CHOICE ::=
1116   Component_Size
1117 | Component_Size_4
1118 | Storage_Unit
1119 | Default
1120 @end smallexample
1122 @noindent
1123 Specifies the alignment of components in array or record types.
1124 The meaning of the @var{Form} argument is as follows:
1126 @table @code
1127 @findex Component_Size
1128 @item Component_Size
1129 Aligns scalar components and subcomponents of the array or record type
1130 on boundaries appropriate to their inherent size (naturally
1131 aligned).  For example, 1-byte components are aligned on byte boundaries,
1132 2-byte integer components are aligned on 2-byte boundaries, 4-byte
1133 integer components are aligned on 4-byte boundaries and so on.  These
1134 alignment rules correspond to the normal rules for C compilers on all
1135 machines except the VAX@.
1137 @findex Component_Size_4
1138 @item Component_Size_4
1139 Naturally aligns components with a size of four or fewer
1140 bytes.  Components that are larger than 4 bytes are placed on the next
1141 4-byte boundary.
1143 @findex Storage_Unit
1144 @item Storage_Unit
1145 Specifies that array or record components are byte aligned, i.e.@:
1146 aligned on boundaries determined by the value of the constant
1147 @code{System.Storage_Unit}.
1149 @cindex OpenVMS
1150 @item Default
1151 Specifies that array or record components are aligned on default
1152 boundaries, appropriate to the underlying hardware or operating system or
1153 both.  For OpenVMS VAX systems, the @code{Default} choice is the same as
1154 the @code{Storage_Unit} choice (byte alignment).  For all other systems,
1155 the @code{Default} choice is the same as @code{Component_Size} (natural
1156 alignment).
1157 @end table
1159 @noindent
1160 If the @code{Name} parameter is present, @var{type_local_NAME} must
1161 refer to a local record or array type, and the specified alignment
1162 choice applies to the specified type.  The use of
1163 @code{Component_Alignment} together with a pragma @code{Pack} causes the
1164 @code{Component_Alignment} pragma to be ignored.  The use of
1165 @code{Component_Alignment} together with a record representation clause
1166 is only effective for fields not specified by the representation clause.
1168 If the @code{Name} parameter is absent, the pragma can be used as either
1169 a configuration pragma, in which case it applies to one or more units in
1170 accordance with the normal rules for configuration pragmas, or it can be
1171 used within a declarative part, in which case it applies to types that
1172 are declared within this declarative part, or within any nested scope
1173 within this declarative part.  In either case it specifies the alignment
1174 to be applied to any record or array type which has otherwise standard
1175 representation.
1177 If the alignment for a record or array type is not specified (using
1178 pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
1179 clause), the GNAT uses the default alignment as described previously.
1181 @node Pragma Convention_Identifier
1182 @unnumberedsec Pragma Convention_Identifier
1183 @findex Convention_Identifier
1184 @cindex Conventions, synonyms
1185 @noindent
1186 Syntax:
1188 @smallexample @c ada
1189 pragma Convention_Identifier (
1190          [Name =>]       IDENTIFIER,
1191          [Convention =>] convention_IDENTIFIER);
1192 @end smallexample
1194 @noindent
1195 This pragma provides a mechanism for supplying synonyms for existing
1196 convention identifiers. The @code{Name} identifier can subsequently
1197 be used as a synonym for the given convention in other pragmas (including
1198 for example pragma @code{Import} or another @code{Convention_Identifier}
1199 pragma). As an example of the use of this, suppose you had legacy code
1200 which used Fortran77 as the identifier for Fortran. Then the pragma:
1202 @smallexample @c ada
1203 pragma Convention_Identifier (Fortran77, Fortran);
1204 @end smallexample
1206 @noindent
1207 would allow the use of the convention identifier @code{Fortran77} in
1208 subsequent code, avoiding the need to modify the sources. As another
1209 example, you could use this to parametrize convention requirements
1210 according to systems. Suppose you needed to use @code{Stdcall} on
1211 windows systems, and @code{C} on some other system, then you could
1212 define a convention identifier @code{Library} and use a single
1213 @code{Convention_Identifier} pragma to specify which convention
1214 would be used system-wide.
1216 @node Pragma CPP_Class
1217 @unnumberedsec Pragma CPP_Class
1218 @findex CPP_Class
1219 @cindex Interfacing with C++
1220 @noindent
1221 Syntax:
1223 @smallexample @c ada
1224 pragma CPP_Class ([Entity =>] local_NAME);
1225 @end smallexample
1227 @noindent
1228 The argument denotes an entity in the current declarative region
1229 that is declared as a tagged or untagged record type.  It indicates that
1230 the type corresponds to an externally declared C++ class type, and is to
1231 be laid out the same way that C++ would lay out the type.
1233 If (and only if) the type is tagged, at least one component in the
1234 record must be of type @code{Interfaces.CPP.Vtable_Ptr}, corresponding
1235 to the C++ Vtable (or Vtables in the case of multiple inheritance) used
1236 for dispatching.
1238 Types for which @code{CPP_Class} is specified do not have assignment or
1239 equality operators defined (such operations can be imported or declared
1240 as subprograms as required).  Initialization is allowed only by
1241 constructor functions (see pragma @code{CPP_Constructor}).
1243 Pragma @code{CPP_Class} is intended primarily for automatic generation
1244 using an automatic binding generator tool.
1245 See @ref{Interfacing to C++} for related information.
1247 @node Pragma CPP_Constructor
1248 @unnumberedsec Pragma CPP_Constructor
1249 @cindex Interfacing with C++
1250 @findex CPP_Constructor
1251 @noindent
1252 Syntax:
1254 @smallexample @c ada
1255 pragma CPP_Constructor ([Entity =>] local_NAME);
1256 @end smallexample
1258 @noindent
1259 This pragma identifies an imported function (imported in the usual way
1260 with pragma @code{Import}) as corresponding to a C++
1261 constructor.  The argument is a name that must have been
1262 previously mentioned in a pragma @code{Import}
1263 with @code{Convention} = @code{CPP}, and must be of one of the following
1264 forms:
1266 @itemize @bullet
1267 @item
1268 @code{function @var{Fname} return @var{T}'Class}
1270 @item
1271 @code{function @var{Fname} (@dots{}) return @var{T}'Class}
1272 @end itemize
1274 @noindent
1275 where @var{T} is a tagged type to which the pragma @code{CPP_Class} applies.
1277 The first form is the default constructor, used when an object of type
1278 @var{T} is created on the Ada side with no explicit constructor.  Other
1279 constructors (including the copy constructor, which is simply a special
1280 case of the second form in which the one and only argument is of type
1281 @var{T}), can only appear in two contexts:
1283 @itemize @bullet
1284 @item
1285 On the right side of an initialization of an object of type @var{T}.
1286 @item
1287 In an extension aggregate for an object of a type derived from @var{T}.
1288 @end itemize
1290 @noindent
1291 Although the constructor is described as a function that returns a value
1292 on the Ada side, it is typically a procedure with an extra implicit
1293 argument (the object being initialized) at the implementation
1294 level.  GNAT issues the appropriate call, whatever it is, to get the
1295 object properly initialized.
1297 In the case of derived objects, you may use one of two possible forms
1298 for declaring and creating an object:
1300 @itemize @bullet
1301 @item @code{New_Object : Derived_T}
1302 @item @code{New_Object : Derived_T := (@var{constructor-call with} @dots{})}
1303 @end itemize
1305 @noindent
1306 In the first case the default constructor is called and extension fields
1307 if any are initialized according to the default initialization
1308 expressions in the Ada declaration.  In the second case, the given
1309 constructor is called and the extension aggregate indicates the explicit
1310 values of the extension fields.
1312 If no constructors are imported, it is impossible to create any objects
1313 on the Ada side.  If no default constructor is imported, only the
1314 initialization forms using an explicit call to a constructor are
1315 permitted.
1317 Pragma @code{CPP_Constructor} is intended primarily for automatic generation
1318 using an automatic binding generator tool.
1319 See @ref{Interfacing to C++} for more related information.
1321 @node Pragma CPP_Virtual
1322 @unnumberedsec Pragma CPP_Virtual
1323 @cindex Interfacing to C++
1324 @findex CPP_Virtual
1325 @noindent
1326 Syntax:
1328 @smallexample @c ada
1329 pragma CPP_Virtual
1330      [Entity     =>] ENTITY,
1331   [, [Vtable_Ptr =>] vtable_ENTITY,]
1332   [, [Position   =>] static_integer_EXPRESSION]);
1333 @end smallexample
1335 @noindent
1336 This pragma serves the same function as pragma @code{Import} in that
1337 case of a virtual function imported from C++.  The @var{Entity} argument
1338 must be a
1339 primitive subprogram of a tagged type to which pragma @code{CPP_Class}
1340 applies.  The @var{Vtable_Ptr} argument specifies
1341 the Vtable_Ptr component which contains the
1342 entry for this virtual function.  The @var{Position} argument
1343 is the sequential number
1344 counting virtual functions for this Vtable starting at 1.
1346 The @code{Vtable_Ptr} and @code{Position} arguments may be omitted if
1347 there is one Vtable_Ptr present (single inheritance case) and all
1348 virtual functions are imported.  In that case the compiler can deduce both
1349 these values.
1351 No @code{External_Name} or @code{Link_Name} arguments are required for a
1352 virtual function, since it is always accessed indirectly via the
1353 appropriate Vtable entry.
1355 Pragma @code{CPP_Virtual} is intended primarily for automatic generation
1356 using an automatic binding generator tool.
1357 See @ref{Interfacing to C++} for related information.
1359 @node Pragma CPP_Vtable
1360 @unnumberedsec Pragma CPP_Vtable
1361 @cindex Interfacing with C++
1362 @findex CPP_Vtable
1363 @noindent
1364 Syntax:
1366 @smallexample @c ada
1367 pragma CPP_Vtable (
1368   [Entity      =>] ENTITY,
1369   [Vtable_Ptr  =>] vtable_ENTITY,
1370   [Entry_Count =>] static_integer_EXPRESSION);
1371 @end smallexample
1373 @noindent
1374 Given a record to which the pragma @code{CPP_Class} applies,
1375 this pragma can be specified for each component of type
1376 @code{CPP.Interfaces.Vtable_Ptr}.
1377 @var{Entity} is the tagged type, @var{Vtable_Ptr}
1378 is the record field of type @code{Vtable_Ptr}, and @var{Entry_Count} is
1379 the number of virtual functions on the C++ side.  Not all of these
1380 functions need to be imported on the Ada side.
1382 You may omit the @code{CPP_Vtable} pragma if there is only one
1383 @code{Vtable_Ptr} component in the record and all virtual functions are
1384 imported on the Ada side (the default value for the entry count in this
1385 case is simply the total number of virtual functions).
1387 Pragma @code{CPP_Vtable} is intended primarily for automatic generation
1388 using an automatic binding generator tool.
1389 See @ref{Interfacing to C++} for related information.
1391 @node Pragma Debug
1392 @unnumberedsec Pragma Debug
1393 @findex Debug
1394 @noindent
1395 Syntax:
1397 @smallexample @c ada
1398 pragma Debug ([CONDITION, ]PROCEDURE_CALL_WITHOUT_SEMICOLON);
1400 PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
1401   PROCEDURE_NAME
1402 | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
1403 @end smallexample
1405 @noindent
1406 The procedure call argument has the syntactic form of an expression, meeting
1407 the syntactic requirements for pragmas.
1409 If debug pragmas are not enabled or if the condition is present and evaluates
1410 to False, this pragma has no effect. If debug pragmas are enabled, the
1411 semantics of the pragma is exactly equivalent to the procedure call statement
1412 corresponding to the argument with a terminating semicolon. Pragmas are
1413 permitted in sequences of declarations, so you can use pragma @code{Debug} to
1414 intersperse calls to debug procedures in the middle of declarations. Debug
1415 pragmas can be enabled either by use of the command line switch @code{-gnata}
1416 or by use of the configuration pragma @code{Debug_Policy}.
1418 @node Pragma Debug_Policy
1419 @unnumberedsec Pragma Debug_Policy
1420 @findex Debug_Policy
1421 @noindent
1422 Syntax:
1424 @smallexample @c ada
1425 pragma Debug_Policy (CHECK | IGNORE);
1426 @end smallexample
1428 @noindent
1429 If the argument is @code{CHECK}, then pragma @code{DEBUG} is enabled.
1430 If the argument is @code{IGNORE}, then pragma @code{DEBUG} is ignored.
1431 This pragma overrides the effect of the @code{-gnata} switch on the
1432 command line.
1434 @node Pragma Detect_Blocking
1435 @unnumberedsec Pragma Detect_Blocking
1436 @findex Detect_Blocking
1437 @noindent
1438 Syntax:
1440 @smallexample @c ada
1441 pragma Detect_Blocking;
1442 @end smallexample
1444 @noindent
1445 This is a configuration pragma that forces the detection of potentially
1446 blocking operations within a protected operation, and to raise Program_Error
1447 if that happens.
1449 @node Pragma Elaboration_Checks
1450 @unnumberedsec Pragma Elaboration_Checks
1451 @cindex Elaboration control
1452 @findex Elaboration_Checks
1453 @noindent
1454 Syntax:
1456 @smallexample @c ada
1457 pragma Elaboration_Checks (Dynamic | Static);
1458 @end smallexample
1460 @noindent
1461 This is a configuration pragma that provides control over the
1462 elaboration model used by the compilation affected by the
1463 pragma.  If the parameter is @code{Dynamic},
1464 then the dynamic elaboration
1465 model described in the Ada Reference Manual is used, as though
1466 the @code{-gnatE} switch had been specified on the command
1467 line.  If the parameter is @code{Static}, then the default GNAT static
1468 model is used.  This configuration pragma overrides the setting
1469 of the command line.  For full details on the elaboration models
1470 used by the GNAT compiler, see section ``Elaboration Order
1471 Handling in GNAT'' in the @cite{GNAT User's Guide}.
1473 @node Pragma Eliminate
1474 @unnumberedsec Pragma Eliminate
1475 @cindex Elimination of unused subprograms
1476 @findex Eliminate
1477 @noindent
1478 Syntax:
1480 @smallexample @c ada
1481 pragma Eliminate (
1482     [Unit_Name =>] IDENTIFIER |
1483                    SELECTED_COMPONENT);
1485 pragma Eliminate (
1486     [Unit_Name       =>]  IDENTIFIER |
1487                           SELECTED_COMPONENT,
1488     [Entity          =>]  IDENTIFIER |
1489                           SELECTED_COMPONENT |
1490                           STRING_LITERAL
1491     [,OVERLOADING_RESOLUTION]);
1493 OVERLOADING_RESOLUTION ::= PARAMETER_AND_RESULT_TYPE_PROFILE |
1494                            SOURCE_LOCATION
1496 PARAMETER_AND_RESULT_TYPE_PROFILE ::= PROCEDURE_PROFILE |
1497                                       FUNCTION_PROFILE
1499 PROCEDURE_PROFILE ::= Parameter_Types => PARAMETER_TYPES
1501 FUNCTION_PROFILE ::= [Parameter_Types => PARAMETER_TYPES,]
1502                       Result_Type => result_SUBTYPE_NAME]
1504 PARAMETER_TYPES ::= (SUBTYPE_NAME @{, SUBTYPE_NAME@})
1505 SUBTYPE_NAME    ::= STRING_VALUE
1507 SOURCE_LOCATION ::= Source_Location => SOURCE_TRACE
1508 SOURCE_TRACE    ::= STRING_VALUE
1510 STRING_VALUE ::= STRING_LITERAL @{& STRING_LITERAL@}
1511 @end smallexample
1513 @noindent
1514 This pragma indicates that the given entity is not used outside the
1515 compilation unit it is defined in. The entity must be an explicitly declared
1516 subprogram; this includes  generic subprogram instances and
1517 subprograms declared in generic package instances.
1519 If the entity to be eliminated is a library level subprogram, then
1520 the first form of pragma @code{Eliminate} is used with only a single argument.
1521 In this form, the @code{Unit_Name} argument specifies the name of the
1522 library  level unit to be eliminated.
1524 In all other cases, both @code{Unit_Name} and @code{Entity} arguments
1525 are required. If item is an entity of a library package, then the first
1526 argument specifies the unit name, and the second argument specifies
1527 the particular entity.  If the second argument is in string form, it must
1528 correspond to the internal manner in which GNAT stores entity names (see
1529 compilation unit Namet in the compiler sources for details).
1531 The remaining parameters (OVERLOADING_RESOLUTION) are optionally used
1532 to distinguish between overloaded subprograms. If a pragma does not contain
1533 the OVERLOADING_RESOLUTION parameter(s), it is applied to all the overloaded
1534 subprograms denoted by the first two parameters.
1536 Use PARAMETER_AND_RESULT_TYPE_PROFILE to specify the profile of the subprogram
1537 to be eliminated in a manner similar to that used for the extended
1538 @code{Import} and @code{Export} pragmas, except that the subtype names are
1539 always given as strings. At the moment, this form of distinguishing
1540 overloaded subprograms is implemented only partially, so we do not recommend
1541 using it for practical subprogram elimination.
1543 Note, that in case of a parameterless procedure its profile is represented
1544 as @code{Parameter_Types => ("")}
1546 Alternatively, the @code{Source_Location} parameter is used to specify
1547 which overloaded alternative is to be eliminated by pointing to the
1548 location of the DEFINING_PROGRAM_UNIT_NAME of this subprogram in the
1549 source text. The string literal (or concatenation of string literals)
1550 given as SOURCE_TRACE must have the following format:
1552 @smallexample @c ada
1553 SOURCE_TRACE ::= SOURCE_LOCATION@{LBRACKET SOURCE_LOCATION RBRACKET@}
1555 LBRACKET ::= [
1556 RBRACKET ::= ]
1558 SOURCE_LOCATION ::= FILE_NAME:LINE_NUMBER
1559 FILE_NAME       ::= STRING_LITERAL
1560 LINE_NUMBER     ::= DIGIT @{DIGIT@}
1561 @end smallexample
1563 SOURCE_TRACE should be the short name of the source file (with no directory
1564 information), and LINE_NUMBER is supposed to point to the line where the
1565 defining name of the subprogram is located.
1567 For the subprograms that are not a part of generic instantiations, only one
1568 SOURCE_LOCATION is used. If a subprogram is declared in a package
1569 instantiation, SOURCE_TRACE contains two SOURCE_LOCATIONs, the first one is
1570 the location of the (DEFINING_PROGRAM_UNIT_NAME of the) instantiation, and the
1571 second one denotes the declaration of the corresponding subprogram in the
1572 generic package. This approach is recursively used to create SOURCE_LOCATIONs
1573 in case of nested instantiations.
1575 The effect of the pragma is to allow the compiler to eliminate
1576 the code or data associated with the named entity.  Any reference to
1577 an eliminated entity outside the compilation unit it is defined in,
1578 causes a compile time or link time error.
1580 The intention of pragma @code{Eliminate} is to allow a program to be compiled
1581 in a system independent manner, with unused entities eliminated, without
1582 the requirement of modifying the source text.  Normally the required set
1583 of @code{Eliminate} pragmas is constructed automatically using the gnatelim
1584 tool. Elimination of unused entities local to a compilation unit is
1585 automatic, without requiring the use of pragma @code{Eliminate}.
1587 Note that the reason this pragma takes string literals where names might
1588 be expected is that a pragma @code{Eliminate} can appear in a context where the
1589 relevant names are not visible.
1591 Note that any change in the source files that includes removing, splitting of
1592 adding lines may make the set of Eliminate pragmas using SOURCE_LOCATION
1593 parameter illegal.
1595 @node Pragma Export_Exception
1596 @unnumberedsec Pragma Export_Exception
1597 @cindex OpenVMS
1598 @findex Export_Exception
1599 @noindent
1600 Syntax:
1602 @smallexample @c ada
1603 pragma Export_Exception (
1604      [Internal =>] local_NAME,
1605   [, [External =>] EXTERNAL_SYMBOL,]
1606   [, [Form     =>] Ada | VMS]
1607   [, [Code     =>] static_integer_EXPRESSION]);
1609 EXTERNAL_SYMBOL ::=
1610   IDENTIFIER
1611 | static_string_EXPRESSION
1612 @end smallexample
1614 @noindent
1615 This pragma is implemented only in the OpenVMS implementation of GNAT@.  It
1616 causes the specified exception to be propagated outside of the Ada program,
1617 so that it can be handled by programs written in other OpenVMS languages.
1618 This pragma establishes an external name for an Ada exception and makes the
1619 name available to the OpenVMS Linker as a global symbol.  For further details
1620 on this pragma, see the
1621 DEC Ada Language Reference Manual, section 13.9a3.2.
1623 @node Pragma Export_Function
1624 @unnumberedsec Pragma Export_Function
1625 @cindex Argument passing mechanisms
1626 @findex Export_Function
1628 @noindent
1629 Syntax:
1631 @smallexample @c ada
1632 pragma Export_Function (
1633      [Internal         =>] local_NAME,
1634   [, [External         =>] EXTERNAL_SYMBOL]
1635   [, [Parameter_Types  =>] PARAMETER_TYPES]
1636   [, [Result_Type      =>] result_SUBTYPE_MARK]
1637   [, [Mechanism        =>] MECHANISM]
1638   [, [Result_Mechanism =>] MECHANISM_NAME]);
1640 EXTERNAL_SYMBOL ::=
1641   IDENTIFIER
1642 | static_string_EXPRESSION
1643 | ""
1645 PARAMETER_TYPES ::=
1646   null
1647 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1649 TYPE_DESIGNATOR ::=
1650   subtype_NAME
1651 | subtype_Name ' Access
1653 MECHANISM ::=
1654   MECHANISM_NAME
1655 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1657 MECHANISM_ASSOCIATION ::=
1658   [formal_parameter_NAME =>] MECHANISM_NAME
1660 MECHANISM_NAME ::=
1661   Value
1662 | Reference
1663 @end smallexample
1665 @noindent
1666 Use this pragma to make a function externally callable and optionally
1667 provide information on mechanisms to be used for passing parameter and
1668 result values.  We recommend, for the purposes of improving portability,
1669 this pragma always be used in conjunction with a separate pragma
1670 @code{Export}, which must precede the pragma @code{Export_Function}.
1671 GNAT does not require a separate pragma @code{Export}, but if none is
1672 present, @code{Convention Ada} is assumed, which is usually
1673 not what is wanted, so it is usually appropriate to use this
1674 pragma in conjunction with a @code{Export} or @code{Convention}
1675 pragma that specifies the desired foreign convention.
1676 Pragma @code{Export_Function}
1677 (and @code{Export}, if present) must appear in the same declarative
1678 region as the function to which they apply.
1680 @var{internal_name} must uniquely designate the function to which the
1681 pragma applies.  If more than one function name exists of this name in
1682 the declarative part you must use the @code{Parameter_Types} and
1683 @code{Result_Type} parameters is mandatory to achieve the required
1684 unique designation.  @var{subtype_ mark}s in these parameters must
1685 exactly match the subtypes in the corresponding function specification,
1686 using positional notation to match parameters with subtype marks.
1687 The form with an @code{'Access} attribute can be used to match an
1688 anonymous access parameter.
1690 @cindex OpenVMS
1691 @cindex Passing by descriptor
1692 Note that passing by descriptor is not supported, even on the OpenVMS
1693 ports of GNAT@.
1695 @cindex Suppressing external name
1696 Special treatment is given if the EXTERNAL is an explicit null
1697 string or a static string expressions that evaluates to the null
1698 string. In this case, no external name is generated. This form
1699 still allows the specification of parameter mechanisms.
1701 @node Pragma Export_Object
1702 @unnumberedsec Pragma Export_Object
1703 @findex Export_Object
1704 @noindent
1705 Syntax:
1707 @smallexample @c ada
1708 pragma Export_Object
1709       [Internal =>] local_NAME,
1710    [, [External =>] EXTERNAL_SYMBOL]
1711    [, [Size     =>] EXTERNAL_SYMBOL]
1713 EXTERNAL_SYMBOL ::=
1714   IDENTIFIER
1715 | static_string_EXPRESSION
1716 @end smallexample
1718 @noindent
1719 This pragma designates an object as exported, and apart from the
1720 extended rules for external symbols, is identical in effect to the use of
1721 the normal @code{Export} pragma applied to an object.  You may use a
1722 separate Export pragma (and you probably should from the point of view
1723 of portability), but it is not required.  @var{Size} is syntax checked,
1724 but otherwise ignored by GNAT@.
1726 @node Pragma Export_Procedure
1727 @unnumberedsec Pragma Export_Procedure
1728 @findex Export_Procedure
1729 @noindent
1730 Syntax:
1732 @smallexample @c ada
1733 pragma Export_Procedure (
1734      [Internal        =>] local_NAME
1735   [, [External        =>] EXTERNAL_SYMBOL]
1736   [, [Parameter_Types =>] PARAMETER_TYPES]
1737   [, [Mechanism       =>] MECHANISM]);
1739 EXTERNAL_SYMBOL ::=
1740   IDENTIFIER
1741 | static_string_EXPRESSION
1742 | ""
1744 PARAMETER_TYPES ::=
1745   null
1746 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1748 TYPE_DESIGNATOR ::=
1749   subtype_NAME
1750 | subtype_Name ' Access
1752 MECHANISM ::=
1753   MECHANISM_NAME
1754 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1756 MECHANISM_ASSOCIATION ::=
1757   [formal_parameter_NAME =>] MECHANISM_NAME
1759 MECHANISM_NAME ::=
1760   Value
1761 | Reference
1762 @end smallexample
1764 @noindent
1765 This pragma is identical to @code{Export_Function} except that it
1766 applies to a procedure rather than a function and the parameters
1767 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
1768 GNAT does not require a separate pragma @code{Export}, but if none is
1769 present, @code{Convention Ada} is assumed, which is usually
1770 not what is wanted, so it is usually appropriate to use this
1771 pragma in conjunction with a @code{Export} or @code{Convention}
1772 pragma that specifies the desired foreign convention.
1774 @cindex OpenVMS
1775 @cindex Passing by descriptor
1776 Note that passing by descriptor is not supported, even on the OpenVMS
1777 ports of GNAT@.
1779 @cindex Suppressing external name
1780 Special treatment is given if the EXTERNAL is an explicit null
1781 string or a static string expressions that evaluates to the null
1782 string. In this case, no external name is generated. This form
1783 still allows the specification of parameter mechanisms.
1785 @node Pragma Export_Value
1786 @unnumberedsec Pragma Export_Value
1787 @findex Export_Value
1788 @noindent
1789 Syntax:
1791 @smallexample @c ada
1792 pragma Export_Value (
1793   [Value     =>] static_integer_EXPRESSION,
1794   [Link_Name =>] static_string_EXPRESSION);
1795 @end smallexample
1797 @noindent
1798 This pragma serves to export a static integer value for external use.
1799 The first argument specifies the value to be exported. The Link_Name
1800 argument specifies the symbolic name to be associated with the integer
1801 value. This pragma is useful for defining a named static value in Ada
1802 that can be referenced in assembly language units to be linked with
1803 the application. This pragma is currently supported only for the
1804 AAMP target and is ignored for other targets.
1806 @node Pragma Export_Valued_Procedure
1807 @unnumberedsec Pragma Export_Valued_Procedure
1808 @findex Export_Valued_Procedure
1809 @noindent
1810 Syntax:
1812 @smallexample @c ada
1813 pragma Export_Valued_Procedure (
1814      [Internal        =>] local_NAME
1815   [, [External        =>] EXTERNAL_SYMBOL]
1816   [, [Parameter_Types =>] PARAMETER_TYPES]
1817   [, [Mechanism       =>] MECHANISM]);
1819 EXTERNAL_SYMBOL ::=
1820   IDENTIFIER
1821 | static_string_EXPRESSION
1822 | ""
1824 PARAMETER_TYPES ::=
1825   null
1826 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1828 TYPE_DESIGNATOR ::=
1829   subtype_NAME
1830 | subtype_Name ' Access
1832 MECHANISM ::=
1833   MECHANISM_NAME
1834 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1836 MECHANISM_ASSOCIATION ::=
1837   [formal_parameter_NAME =>] MECHANISM_NAME
1839 MECHANISM_NAME ::=
1840   Value
1841 | Reference
1842 @end smallexample
1844 @noindent
1845 This pragma is identical to @code{Export_Procedure} except that the
1846 first parameter of @var{local_NAME}, which must be present, must be of
1847 mode @code{OUT}, and externally the subprogram is treated as a function
1848 with this parameter as the result of the function.  GNAT provides for
1849 this capability to allow the use of @code{OUT} and @code{IN OUT}
1850 parameters in interfacing to external functions (which are not permitted
1851 in Ada functions).
1852 GNAT does not require a separate pragma @code{Export}, but if none is
1853 present, @code{Convention Ada} is assumed, which is almost certainly
1854 not what is wanted since the whole point of this pragma is to interface
1855 with foreign language functions, so it is usually appropriate to use this
1856 pragma in conjunction with a @code{Export} or @code{Convention}
1857 pragma that specifies the desired foreign convention.
1859 @cindex OpenVMS
1860 @cindex Passing by descriptor
1861 Note that passing by descriptor is not supported, even on the OpenVMS
1862 ports of GNAT@.
1864 @cindex Suppressing external name
1865 Special treatment is given if the EXTERNAL is an explicit null
1866 string or a static string expressions that evaluates to the null
1867 string. In this case, no external name is generated. This form
1868 still allows the specification of parameter mechanisms.
1870 @node Pragma Extend_System
1871 @unnumberedsec Pragma Extend_System
1872 @cindex @code{system}, extending
1873 @cindex Dec Ada 83
1874 @findex Extend_System
1875 @noindent
1876 Syntax:
1878 @smallexample @c ada
1879 pragma Extend_System ([Name =>] IDENTIFIER);
1880 @end smallexample
1882 @noindent
1883 This pragma is used to provide backwards compatibility with other
1884 implementations that extend the facilities of package @code{System}.  In
1885 GNAT, @code{System} contains only the definitions that are present in
1886 the Ada 95 RM@.  However, other implementations, notably the DEC Ada 83
1887 implementation, provide many extensions to package @code{System}.
1889 For each such implementation accommodated by this pragma, GNAT provides a
1890 package @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83
1891 implementation, which provides the required additional definitions.  You
1892 can use this package in two ways.  You can @code{with} it in the normal
1893 way and access entities either by selection or using a @code{use}
1894 clause.  In this case no special processing is required.
1896 However, if existing code contains references such as
1897 @code{System.@var{xxx}} where @var{xxx} is an entity in the extended
1898 definitions provided in package @code{System}, you may use this pragma
1899 to extend visibility in @code{System} in a non-standard way that
1900 provides greater compatibility with the existing code.  Pragma
1901 @code{Extend_System} is a configuration pragma whose single argument is
1902 the name of the package containing the extended definition
1903 (e.g.@: @code{Aux_DEC} for the DEC Ada case).  A unit compiled under
1904 control of this pragma will be processed using special visibility
1905 processing that looks in package @code{System.Aux_@var{xxx}} where
1906 @code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
1907 package @code{System}, but not found in package @code{System}.
1909 You can use this pragma either to access a predefined @code{System}
1910 extension supplied with the compiler, for example @code{Aux_DEC} or
1911 you can construct your own extension unit following the above
1912 definition.  Note that such a package is a child of @code{System}
1913 and thus is considered part of the implementation.  To compile
1914 it you will have to use the appropriate switch for compiling
1915 system units.  See the GNAT User's Guide for details.
1917 @node Pragma External
1918 @unnumberedsec Pragma External
1919 @findex External
1920 @noindent
1921 Syntax:
1923 @smallexample @c ada
1924 pragma External (
1925   [   Convention    =>] convention_IDENTIFIER,
1926   [   Entity        =>] local_NAME
1927   [, [External_Name =>] static_string_EXPRESSION ]
1928   [, [Link_Name     =>] static_string_EXPRESSION ]);
1929 @end smallexample
1931 @noindent
1932 This pragma is identical in syntax and semantics to pragma
1933 @code{Export} as defined in the Ada Reference Manual.  It is
1934 provided for compatibility with some Ada 83 compilers that
1935 used this pragma for exactly the same purposes as pragma
1936 @code{Export} before the latter was standardized.
1938 @node Pragma External_Name_Casing
1939 @unnumberedsec Pragma External_Name_Casing
1940 @cindex Dec Ada 83 casing compatibility
1941 @cindex External Names, casing
1942 @cindex Casing of External names
1943 @findex External_Name_Casing
1944 @noindent
1945 Syntax:
1947 @smallexample @c ada
1948 pragma External_Name_Casing (
1949   Uppercase | Lowercase
1950   [, Uppercase | Lowercase | As_Is]);
1951 @end smallexample
1953 @noindent
1954 This pragma provides control over the casing of external names associated
1955 with Import and Export pragmas.  There are two cases to consider:
1957 @table @asis
1958 @item Implicit external names
1959 Implicit external names are derived from identifiers.  The most common case
1960 arises when a standard Ada 95 Import or Export pragma is used with only two
1961 arguments, as in:
1963 @smallexample @c ada
1964    pragma Import (C, C_Routine);
1965 @end smallexample
1967 @noindent
1968 Since Ada is a case insensitive language, the spelling of the identifier in
1969 the Ada source program does not provide any information on the desired
1970 casing of the external name, and so a convention is needed.  In GNAT the
1971 default treatment is that such names are converted to all lower case
1972 letters.  This corresponds to the normal C style in many environments.
1973 The first argument of pragma @code{External_Name_Casing} can be used to
1974 control this treatment.  If @code{Uppercase} is specified, then the name
1975 will be forced to all uppercase letters.  If @code{Lowercase} is specified,
1976 then the normal default of all lower case letters will be used.
1978 This same implicit treatment is also used in the case of extended DEC Ada 83
1979 compatible Import and Export pragmas where an external name is explicitly
1980 specified using an identifier rather than a string.
1982 @item Explicit external names
1983 Explicit external names are given as string literals.  The most common case
1984 arises when a standard Ada 95 Import or Export pragma is used with three
1985 arguments, as in:
1987 @smallexample @c ada
1988 pragma Import (C, C_Routine, "C_routine");
1989 @end smallexample
1991 @noindent
1992 In this case, the string literal normally provides the exact casing required
1993 for the external name.  The second argument of pragma
1994 @code{External_Name_Casing} may be used to modify this behavior.
1995 If @code{Uppercase} is specified, then the name
1996 will be forced to all uppercase letters.  If @code{Lowercase} is specified,
1997 then the name will be forced to all lowercase letters.  A specification of
1998 @code{As_Is} provides the normal default behavior in which the casing is
1999 taken from the string provided.
2000 @end table
2002 @noindent
2003 This pragma may appear anywhere that a pragma is valid.  In particular, it
2004 can be used as a configuration pragma in the @file{gnat.adc} file, in which
2005 case it applies to all subsequent compilations, or it can be used as a program
2006 unit pragma, in which case it only applies to the current unit, or it can
2007 be used more locally to control individual Import/Export pragmas.
2009 It is primarily intended for use with OpenVMS systems, where many
2010 compilers convert all symbols to upper case by default.  For interfacing to
2011 such compilers (e.g.@: the DEC C compiler), it may be convenient to use
2012 the pragma:
2014 @smallexample @c ada
2015 pragma External_Name_Casing (Uppercase, Uppercase);
2016 @end smallexample
2018 @noindent
2019 to enforce the upper casing of all external symbols.
2021 @node Pragma Finalize_Storage_Only
2022 @unnumberedsec Pragma Finalize_Storage_Only
2023 @findex Finalize_Storage_Only
2024 @noindent
2025 Syntax:
2027 @smallexample @c ada
2028 pragma Finalize_Storage_Only (first_subtype_local_NAME);
2029 @end smallexample
2031 @noindent
2032 This pragma allows the compiler not to emit a Finalize call for objects
2033 defined at the library level.  This is mostly useful for types where
2034 finalization is only used to deal with storage reclamation since in most
2035 environments it is not necessary to reclaim memory just before terminating
2036 execution, hence the name.
2038 @node Pragma Float_Representation
2039 @unnumberedsec Pragma Float_Representation
2040 @cindex OpenVMS
2041 @findex Float_Representation
2042 @noindent
2043 Syntax:
2045 @smallexample @c ada
2046 pragma Float_Representation (FLOAT_REP[, float_type_LOCAL_NAME]);
2048 FLOAT_REP ::= VAX_Float | IEEE_Float
2049 @end smallexample
2051 @noindent
2052 In the one argument form, this pragma is a configuration pragma which
2053 allows control over the internal representation chosen for the predefined
2054 floating point types declared in the packages @code{Standard} and
2055 @code{System}. On all systems other than OpenVMS, the argument must
2056 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2057 argument may be @code{VAX_Float} to specify the use of the VAX float
2058 format for the floating-point types in Standard. This requires that
2059 the standard runtime libraries be recompiled. See the
2060 description of the @code{GNAT LIBRARY} command in the OpenVMS version
2061 of the GNAT Users Guide for details on the use of this command.
2063 The two argument form specifies the representation to be used for
2064 the specified floating-point type. On all systems other than OpenVMS,
2065 the argument must
2066 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
2067 argument may be @code{VAX_Float} to specify the use of the VAX float
2068 format, as follows:
2070 @itemize @bullet
2071 @item
2072 For digits values up to 6, F float format will be used.
2073 @item
2074 For digits values from 7 to 9, G float format will be used.
2075 @item
2076 For digits values from 10 to 15, F float format will be used.
2077 @item
2078 Digits values above 15 are not allowed.
2079 @end itemize
2081 @node Pragma Ident
2082 @unnumberedsec Pragma Ident
2083 @findex Ident
2084 @noindent
2085 Syntax:
2087 @smallexample @c ada
2088 pragma Ident (static_string_EXPRESSION);
2089 @end smallexample
2091 @noindent
2092 This pragma provides a string identification in the generated object file,
2093 if the system supports the concept of this kind of identification string.
2094 This pragma is allowed only in the outermost declarative part or
2095 declarative items of a compilation unit. If more than one @code{Ident}
2096 pragma is given, only the last one processed is effective.
2097 @cindex OpenVMS
2098 On OpenVMS systems, the effect of the pragma is identical to the effect of
2099 the DEC Ada 83 pragma of the same name. Note that in DEC Ada 83, the
2100 maximum allowed length is 31 characters, so if it is important to
2101 maintain compatibility with this compiler, you should obey this length
2102 limit.
2104 @node Pragma Import_Exception
2105 @unnumberedsec Pragma Import_Exception
2106 @cindex OpenVMS
2107 @findex Import_Exception
2108 @noindent
2109 Syntax:
2111 @smallexample @c ada
2112 pragma Import_Exception (
2113      [Internal =>] local_NAME,
2114   [, [External =>] EXTERNAL_SYMBOL,]
2115   [, [Form     =>] Ada | VMS]
2116   [, [Code     =>] static_integer_EXPRESSION]);
2118 EXTERNAL_SYMBOL ::=
2119   IDENTIFIER
2120 | static_string_EXPRESSION
2121 @end smallexample
2123 @noindent
2124 This pragma is implemented only in the OpenVMS implementation of GNAT@.
2125 It allows OpenVMS conditions (for example, from OpenVMS system services or
2126 other OpenVMS languages) to be propagated to Ada programs as Ada exceptions.
2127 The pragma specifies that the exception associated with an exception
2128 declaration in an Ada program be defined externally (in non-Ada code).
2129 For further details on this pragma, see the
2130 DEC Ada Language Reference Manual, section 13.9a.3.1.
2132 @node Pragma Import_Function
2133 @unnumberedsec Pragma Import_Function
2134 @findex Import_Function
2135 @noindent
2136 Syntax:
2138 @smallexample @c ada
2139 pragma Import_Function (
2140      [Internal                 =>] local_NAME,
2141   [, [External                 =>] EXTERNAL_SYMBOL]
2142   [, [Parameter_Types          =>] PARAMETER_TYPES]
2143   [, [Result_Type              =>] SUBTYPE_MARK]
2144   [, [Mechanism                =>] MECHANISM]
2145   [, [Result_Mechanism         =>] MECHANISM_NAME]
2146   [, [First_Optional_Parameter =>] IDENTIFIER]);
2148 EXTERNAL_SYMBOL ::=
2149   IDENTIFIER
2150 | static_string_EXPRESSION
2152 PARAMETER_TYPES ::=
2153   null
2154 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2156 TYPE_DESIGNATOR ::=
2157   subtype_NAME
2158 | subtype_Name ' Access
2160 MECHANISM ::=
2161   MECHANISM_NAME
2162 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2164 MECHANISM_ASSOCIATION ::=
2165   [formal_parameter_NAME =>] MECHANISM_NAME
2167 MECHANISM_NAME ::=
2168   Value
2169 | Reference
2170 | Descriptor [([Class =>] CLASS_NAME)]
2172 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2173 @end smallexample
2175 @noindent
2176 This pragma is used in conjunction with a pragma @code{Import} to
2177 specify additional information for an imported function.  The pragma
2178 @code{Import} (or equivalent pragma @code{Interface}) must precede the
2179 @code{Import_Function} pragma and both must appear in the same
2180 declarative part as the function specification.
2182 The @var{Internal} argument must uniquely designate
2183 the function to which the
2184 pragma applies.  If more than one function name exists of this name in
2185 the declarative part you must use the @code{Parameter_Types} and
2186 @var{Result_Type} parameters to achieve the required unique
2187 designation.  Subtype marks in these parameters must exactly match the
2188 subtypes in the corresponding function specification, using positional
2189 notation to match parameters with subtype marks.
2190 The form with an @code{'Access} attribute can be used to match an
2191 anonymous access parameter.
2193 You may optionally use the @var{Mechanism} and @var{Result_Mechanism}
2194 parameters to specify passing mechanisms for the
2195 parameters and result.  If you specify a single mechanism name, it
2196 applies to all parameters.  Otherwise you may specify a mechanism on a
2197 parameter by parameter basis using either positional or named
2198 notation.  If the mechanism is not specified, the default mechanism
2199 is used.
2201 @cindex OpenVMS
2202 @cindex Passing by descriptor
2203 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2205 @code{First_Optional_Parameter} applies only to OpenVMS ports of GNAT@.
2206 It specifies that the designated parameter and all following parameters
2207 are optional, meaning that they are not passed at the generated code
2208 level (this is distinct from the notion of optional parameters in Ada
2209 where the parameters are passed anyway with the designated optional
2210 parameters).  All optional parameters must be of mode @code{IN} and have
2211 default parameter values that are either known at compile time
2212 expressions, or uses of the @code{'Null_Parameter} attribute.
2214 @node Pragma Import_Object
2215 @unnumberedsec Pragma Import_Object
2216 @findex Import_Object
2217 @noindent
2218 Syntax:
2220 @smallexample @c ada
2221 pragma Import_Object
2222      [Internal =>] local_NAME,
2223   [, [External =>] EXTERNAL_SYMBOL],
2224   [, [Size     =>] EXTERNAL_SYMBOL]);
2226 EXTERNAL_SYMBOL ::=
2227   IDENTIFIER
2228 | static_string_EXPRESSION
2229 @end smallexample
2231 @noindent
2232 This pragma designates an object as imported, and apart from the
2233 extended rules for external symbols, is identical in effect to the use of
2234 the normal @code{Import} pragma applied to an object.  Unlike the
2235 subprogram case, you need not use a separate @code{Import} pragma,
2236 although you may do so (and probably should do so from a portability
2237 point of view).  @var{size} is syntax checked, but otherwise ignored by
2238 GNAT@.
2240 @node Pragma Import_Procedure
2241 @unnumberedsec Pragma Import_Procedure
2242 @findex Import_Procedure
2243 @noindent
2244 Syntax:
2246 @smallexample @c ada
2247 pragma Import_Procedure (
2248      [Internal                 =>] local_NAME,
2249   [, [External                 =>] EXTERNAL_SYMBOL]
2250   [, [Parameter_Types          =>] PARAMETER_TYPES]
2251   [, [Mechanism                =>] MECHANISM]
2252   [, [First_Optional_Parameter =>] IDENTIFIER]);
2254 EXTERNAL_SYMBOL ::=
2255   IDENTIFIER
2256 | static_string_EXPRESSION
2258 PARAMETER_TYPES ::=
2259   null
2260 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2262 TYPE_DESIGNATOR ::=
2263   subtype_NAME
2264 | subtype_Name ' Access
2266 MECHANISM ::=
2267   MECHANISM_NAME
2268 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2270 MECHANISM_ASSOCIATION ::=
2271   [formal_parameter_NAME =>] MECHANISM_NAME
2273 MECHANISM_NAME ::=
2274   Value
2275 | Reference
2276 | Descriptor [([Class =>] CLASS_NAME)]
2278 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2279 @end smallexample
2281 @noindent
2282 This pragma is identical to @code{Import_Function} except that it
2283 applies to a procedure rather than a function and the parameters
2284 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2286 @node Pragma Import_Valued_Procedure
2287 @unnumberedsec Pragma Import_Valued_Procedure
2288 @findex Import_Valued_Procedure
2289 @noindent
2290 Syntax:
2292 @smallexample @c ada
2293 pragma Import_Valued_Procedure (
2294      [Internal                 =>] local_NAME,
2295   [, [External                 =>] EXTERNAL_SYMBOL]
2296   [, [Parameter_Types          =>] PARAMETER_TYPES]
2297   [, [Mechanism                =>] MECHANISM]
2298   [, [First_Optional_Parameter =>] IDENTIFIER]);
2300 EXTERNAL_SYMBOL ::=
2301   IDENTIFIER
2302 | static_string_EXPRESSION
2304 PARAMETER_TYPES ::=
2305   null
2306 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2308 TYPE_DESIGNATOR ::=
2309   subtype_NAME
2310 | subtype_Name ' Access
2312 MECHANISM ::=
2313   MECHANISM_NAME
2314 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2316 MECHANISM_ASSOCIATION ::=
2317   [formal_parameter_NAME =>] MECHANISM_NAME
2319 MECHANISM_NAME ::=
2320   Value
2321 | Reference
2322 | Descriptor [([Class =>] CLASS_NAME)]
2324 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2325 @end smallexample
2327 @noindent
2328 This pragma is identical to @code{Import_Procedure} except that the
2329 first parameter of @var{local_NAME}, which must be present, must be of
2330 mode @code{OUT}, and externally the subprogram is treated as a function
2331 with this parameter as the result of the function.  The purpose of this
2332 capability is to allow the use of @code{OUT} and @code{IN OUT}
2333 parameters in interfacing to external functions (which are not permitted
2334 in Ada functions).  You may optionally use the @code{Mechanism}
2335 parameters to specify passing mechanisms for the parameters.
2336 If you specify a single mechanism name, it applies to all parameters.
2337 Otherwise you may specify a mechanism on a parameter by parameter
2338 basis using either positional or named notation.  If the mechanism is not
2339 specified, the default mechanism is used.
2341 Note that it is important to use this pragma in conjunction with a separate
2342 pragma Import that specifies the desired convention, since otherwise the
2343 default convention is Ada, which is almost certainly not what is required.
2345 @node Pragma Initialize_Scalars
2346 @unnumberedsec Pragma Initialize_Scalars
2347 @findex Initialize_Scalars
2348 @cindex debugging with Initialize_Scalars
2349 @noindent
2350 Syntax:
2352 @smallexample @c ada
2353 pragma Initialize_Scalars;
2354 @end smallexample
2356 @noindent
2357 This pragma is similar to @code{Normalize_Scalars} conceptually but has
2358 two important differences.  First, there is no requirement for the pragma
2359 to be used uniformly in all units of a partition, in particular, it is fine
2360 to use this just for some or all of the application units of a partition,
2361 without needing to recompile the run-time library.
2363 In the case where some units are compiled with the pragma, and some without,
2364 then a declaration of a variable where the type is defined in package
2365 Standard or is locally declared will always be subject to initialization,
2366 as will any declaration of a scalar variable.  For composite variables,
2367 whether the variable is initialized may also depend on whether the package
2368 in which the type of the variable is declared is compiled with the pragma.
2370 The other important difference is that you can control the value used
2371 for initializing scalar objects.  At bind time, you can select several
2372 options for initialization. You can
2373 initialize with invalid values (similar to Normalize_Scalars, though for
2374 Initialize_Scalars it is not always possible to determine the invalid
2375 values in complex cases like signed component fields with non-standard
2376 sizes). You can also initialize with high or
2377 low values, or with a specified bit pattern.  See the users guide for binder
2378 options for specifying these cases.
2380 This means that you can compile a program, and then without having to
2381 recompile the program, you can run it with different values being used
2382 for initializing otherwise uninitialized values, to test if your program
2383 behavior depends on the choice.  Of course the behavior should not change,
2384 and if it does, then most likely you have an erroneous reference to an
2385 uninitialized value.
2387 It is even possible to change the value at execution time eliminating even
2388 the need to rebind with a different switch using an environment variable.
2389 See the GNAT users guide for details.
2391 Note that pragma @code{Initialize_Scalars} is particularly useful in
2392 conjunction with the enhanced validity checking that is now provided
2393 in GNAT, which checks for invalid values under more conditions.
2394 Using this feature (see description of the @code{-gnatV} flag in the
2395 users guide) in conjunction with pragma @code{Initialize_Scalars}
2396 provides a powerful new tool to assist in the detection of problems
2397 caused by uninitialized variables.
2399 Note: the use of @code{Initialize_Scalars} has a fairly extensive
2400 effect on the generated code. This may cause your code to be
2401 substantially larger. It may also cause an increase in the amount
2402 of stack required, so it is probably a good idea to turn on stack
2403 checking (see description of stack checking in the GNAT users guide)
2404 when using this pragma.
2406 @node Pragma Inline_Always
2407 @unnumberedsec Pragma Inline_Always
2408 @findex Inline_Always
2409 @noindent
2410 Syntax:
2412 @smallexample @c ada
2413 pragma Inline_Always (NAME [, NAME]);
2414 @end smallexample
2416 @noindent
2417 Similar to pragma @code{Inline} except that inlining is not subject to
2418 the use of option @code{-gnatn} and the inlining happens regardless of
2419 whether this option is used.
2421 @node Pragma Inline_Generic
2422 @unnumberedsec Pragma Inline_Generic
2423 @findex Inline_Generic
2424 @noindent
2425 Syntax:
2427 @smallexample @c ada
2428 pragma Inline_Generic (generic_package_NAME);
2429 @end smallexample
2431 @noindent
2432 This is implemented for compatibility with DEC Ada 83 and is recognized,
2433 but otherwise ignored, by GNAT@.  All generic instantiations are inlined
2434 by default when using GNAT@.
2436 @node Pragma Interface
2437 @unnumberedsec Pragma Interface
2438 @findex Interface
2439 @noindent
2440 Syntax:
2442 @smallexample @c ada
2443 pragma Interface (
2444      [Convention    =>] convention_identifier,
2445      [Entity =>] local_NAME
2446   [, [External_Name =>] static_string_expression],
2447   [, [Link_Name     =>] static_string_expression]);
2448 @end smallexample
2450 @noindent
2451 This pragma is identical in syntax and semantics to
2452 the standard Ada 95 pragma @code{Import}.  It is provided for compatibility
2453 with Ada 83.  The definition is upwards compatible both with pragma
2454 @code{Interface} as defined in the Ada 83 Reference Manual, and also
2455 with some extended implementations of this pragma in certain Ada 83
2456 implementations.
2458 @node Pragma Interface_Name
2459 @unnumberedsec Pragma Interface_Name
2460 @findex Interface_Name
2461 @noindent
2462 Syntax:
2464 @smallexample @c ada
2465 pragma Interface_Name (
2466      [Entity        =>] local_NAME
2467   [, [External_Name =>] static_string_EXPRESSION]
2468   [, [Link_Name     =>] static_string_EXPRESSION]);
2469 @end smallexample
2471 @noindent
2472 This pragma provides an alternative way of specifying the interface name
2473 for an interfaced subprogram, and is provided for compatibility with Ada
2474 83 compilers that use the pragma for this purpose.  You must provide at
2475 least one of @var{External_Name} or @var{Link_Name}.
2477 @node Pragma Interrupt_Handler
2478 @unnumberedsec Pragma Interrupt_Handler
2479 @findex Interrupt_Handler
2480 @noindent
2481 Syntax:
2483 @smallexample @c ada
2484 pragma Interrupt_Handler (procedure_local_NAME);
2485 @end smallexample
2487 @noindent
2488 This program unit pragma is supported for parameterless protected procedures
2489 as described in Annex C of the Ada Reference Manual. On the AAMP target
2490 the pragma can also be specified for nonprotected parameterless procedures
2491 that are declared at the library level (which includes procedures
2492 declared at the top level of a library package). In the case of AAMP,
2493 when this pragma is applied to a nonprotected procedure, the instruction
2494 @code{IERET} is generated for returns from the procedure, enabling
2495 maskable interrupts, in place of the normal return instruction.
2497 @node Pragma Interrupt_State
2498 @unnumberedsec Pragma Interrupt_State
2499 @findex Interrupt_State
2500 @noindent
2501 Syntax:
2503 @smallexample @c ada
2504 pragma Interrupt_State (Name => value, State => SYSTEM | RUNTIME | USER);
2505 @end smallexample
2507 @noindent
2508 Normally certain interrupts are reserved to the implementation.  Any attempt
2509 to attach an interrupt causes Program_Error to be raised, as described in
2510 RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
2511 many systems for an @kbd{Ctrl-C} interrupt.  Normally this interrupt is
2512 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
2513 interrupt execution.  Additionally, signals such as @code{SIGSEGV},
2514 @code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
2515 Ada exceptions, or used to implement run-time functions such as the
2516 @code{abort} statement and stack overflow checking.
2518 Pragma @code{Interrupt_State} provides a general mechanism for overriding
2519 such uses of interrupts.  It subsumes the functionality of pragma
2520 @code{Unreserve_All_Interrupts}.  Pragma @code{Interrupt_State} is not
2521 available on OS/2, Windows or VMS.  On all other platforms than VxWorks,
2522 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
2523 and may be used to mark interrupts required by the board support package
2524 as reserved.
2526 Interrupts can be in one of three states:
2527 @itemize @bullet
2528 @item System
2530 The interrupt is reserved (no Ada handler can be installed), and the
2531 Ada run-time may not install a handler. As a result you are guaranteed
2532 standard system default action if this interrupt is raised.
2534 @item Runtime
2536 The interrupt is reserved (no Ada handler can be installed). The run time
2537 is allowed to install a handler for internal control purposes, but is
2538 not required to do so.
2540 @item User
2542 The interrupt is unreserved.  The user may install a handler to provide
2543 some other action.
2544 @end itemize
2546 @noindent
2547 These states are the allowed values of the @code{State} parameter of the
2548 pragma.  The @code{Name} parameter is a value of the type
2549 @code{Ada.Interrupts.Interrupt_ID}.  Typically, it is a name declared in
2550 @code{Ada.Interrupts.Names}.
2552 This is a configuration pragma, and the binder will check that there
2553 are no inconsistencies between different units in a partition in how a
2554 given interrupt is specified. It may appear anywhere a pragma is legal.
2556 The effect is to move the interrupt to the specified state.
2558 By declaring interrupts to be SYSTEM, you guarantee the standard system
2559 action, such as a core dump.
2561 By declaring interrupts to be USER, you guarantee that you can install
2562 a handler.
2564 Note that certain signals on many operating systems cannot be caught and
2565 handled by applications.  In such cases, the pragma is ignored.  See the
2566 operating system documentation, or the value of the array @code{Reserved}
2567 declared in the specification of package @code{System.OS_Interface}.
2569 Overriding the default state of signals used by the Ada runtime may interfere
2570 with an application's runtime behavior in the cases of the synchronous signals,
2571 and in the case of the signal used to implement the @code{abort} statement.
2573 @node Pragma Keep_Names
2574 @unnumberedsec Pragma Keep_Names
2575 @findex Keep_Names
2576 @noindent
2577 Syntax:
2579 @smallexample @c ada
2580 pragma Keep_Names ([On =>] enumeration_first_subtype_local_NAME);
2581 @end smallexample
2583 @noindent
2584 The @var{local_NAME} argument
2585 must refer to an enumeration first subtype
2586 in the current declarative part. The effect is to retain the enumeration
2587 literal names for use by @code{Image} and @code{Value} even if a global
2588 @code{Discard_Names} pragma applies. This is useful when you want to
2589 generally suppress enumeration literal names and for example you therefore
2590 use a @code{Discard_Names} pragma in the @file{gnat.adc} file, but you
2591 want to retain the names for specific enumeration types.
2593 @node Pragma License
2594 @unnumberedsec Pragma License
2595 @findex License
2596 @cindex License checking
2597 @noindent
2598 Syntax:
2600 @smallexample @c ada
2601 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
2602 @end smallexample
2604 @noindent
2605 This pragma is provided to allow automated checking for appropriate license
2606 conditions with respect to the standard and modified GPL@.  A pragma
2607 @code{License}, which is a configuration pragma that typically appears at
2608 the start of a source file or in a separate @file{gnat.adc} file, specifies
2609 the licensing conditions of a unit as follows:
2611 @itemize @bullet
2612 @item Unrestricted
2613 This is used for a unit that can be freely used with no license restrictions.
2614 Examples of such units are public domain units, and units from the Ada
2615 Reference Manual.
2617 @item GPL
2618 This is used for a unit that is licensed under the unmodified GPL, and which
2619 therefore cannot be @code{with}'ed by a restricted unit.
2621 @item Modified_GPL
2622 This is used for a unit licensed under the GNAT modified GPL that includes
2623 a special exception paragraph that specifically permits the inclusion of
2624 the unit in programs without requiring the entire program to be released
2625 under the GPL@.
2627 @item Restricted
2628 This is used for a unit that is restricted in that it is not permitted to
2629 depend on units that are licensed under the GPL@.  Typical examples are
2630 proprietary code that is to be released under more restrictive license
2631 conditions.  Note that restricted units are permitted to @code{with} units
2632 which are licensed under the modified GPL (this is the whole point of the
2633 modified GPL).
2635 @end itemize
2637 @noindent
2638 Normally a unit with no @code{License} pragma is considered to have an
2639 unknown license, and no checking is done.  However, standard GNAT headers
2640 are recognized, and license information is derived from them as follows.
2642 @itemize @bullet
2644 A GNAT license header starts with a line containing 78 hyphens.  The following
2645 comment text is searched for the appearance of any of the following strings.
2647 If the string ``GNU General Public License'' is found, then the unit is assumed
2648 to have GPL license, unless the string ``As a special exception'' follows, in
2649 which case the license is assumed to be modified GPL@.
2651 If one of the strings
2652 ``This specification is adapted from the Ada Semantic Interface'' or
2653 ``This specification is derived from the Ada Reference Manual'' is found
2654 then the unit is assumed to be unrestricted.
2655 @end itemize
2657 @noindent
2658 These default actions means that a program with a restricted license pragma
2659 will automatically get warnings if a GPL unit is inappropriately
2660 @code{with}'ed.  For example, the program:
2662 @smallexample @c ada
2663 with Sem_Ch3;
2664 with GNAT.Sockets;
2665 procedure Secret_Stuff is
2666   @dots{}
2667 end Secret_Stuff
2668 @end smallexample
2670 @noindent
2671 if compiled with pragma @code{License} (@code{Restricted}) in a
2672 @file{gnat.adc} file will generate the warning:
2674 @smallexample
2675 1.  with Sem_Ch3;
2676         |
2677    >>> license of withed unit "Sem_Ch3" is incompatible
2679 2.  with GNAT.Sockets;
2680 3.  procedure Secret_Stuff is
2681 @end smallexample
2683 @noindent
2684 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
2685 compiler and is licensed under the
2686 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
2687 run time, and is therefore licensed under the modified GPL@.
2689 @node Pragma Link_With
2690 @unnumberedsec Pragma Link_With
2691 @findex Link_With
2692 @noindent
2693 Syntax:
2695 @smallexample @c ada
2696 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
2697 @end smallexample
2699 @noindent
2700 This pragma is provided for compatibility with certain Ada 83 compilers.
2701 It has exactly the same effect as pragma @code{Linker_Options} except
2702 that spaces occurring within one of the string expressions are treated
2703 as separators. For example, in the following case:
2705 @smallexample @c ada
2706 pragma Link_With ("-labc -ldef");
2707 @end smallexample
2709 @noindent
2710 results in passing the strings @code{-labc} and @code{-ldef} as two
2711 separate arguments to the linker. In addition pragma Link_With allows
2712 multiple arguments, with the same effect as successive pragmas.
2714 @node Pragma Linker_Alias
2715 @unnumberedsec Pragma Linker_Alias
2716 @findex Linker_Alias
2717 @noindent
2718 Syntax:
2720 @smallexample @c ada
2721 pragma Linker_Alias (
2722   [Entity =>] local_NAME
2723   [Target =>] static_string_EXPRESSION);
2724 @end smallexample
2726 @noindent
2727 @var{local_NAME} must refer to an object that is declared at the library
2728 level. This pragma establishes the given entity as a linker alias for the
2729 given target. It is equivalent to @code{__attribute__((alias))} in GNU C
2730 and causes @var{local_NAME} to be emitted as an alias for the symbol
2731 @var{static_string_EXPRESSION} in the object file, that is to say no space
2732 is reserved for @var{local_NAME} by the assembler and it will be resolved
2733 to the same address as @var{static_string_EXPRESSION} by the linker.
2735 The actual linker name for the target must be used (e.g. the fully
2736 encoded name with qualification in Ada, or the mangled name in C++),
2737 or it must be declared using the C convention with @code{pragma Import}
2738 or @code{pragma Export}.
2740 Not all target machines support this pragma. On some of them it is accepted
2741 only if @code{pragma Weak_External} has been applied to @var{local_NAME}.
2743 @smallexample @c ada
2744 --  Example of the use of pragma Linker_Alias
2746 package p is
2747   i : Integer := 1;
2748   pragma Export (C, i);
2750   new_name_for_i : Integer;
2751   pragma Linker_Alias (new_name_for_i, "i");
2752 end p;
2753 @end smallexample
2755 @node Pragma Linker_Constructor
2756 @unnumberedsec Pragma Linker_Constructor
2757 @findex Linker_Constructor
2758 @noindent
2759 Syntax:
2761 @smallexample @c ada
2762 pragma Linker_Constructor (procedure_LOCAL_NAME);
2763 @end smallexample
2765 @noindent
2766 @var{procedure_local_NAME} must refer to a parameterless procedure that
2767 is declared at the library level. A procedure to which this pragma is
2768 applied will be treated as an initialization routine by the linker.
2769 It is equivalent to @code{__attribute__((constructor))} in GNU C and
2770 causes @var{procedure_LOCAL_NAME} to be invoked before the entry point
2771 of the executable is called (or immediately after the shared library is
2772 loaded if the procedure is linked in a shared library), in particular
2773 before the Ada run-time environment is set up.
2775 Because of these specific contexts, the set of operations such a procedure
2776 can perform is very limited and the type of objects it can manipulate is
2777 essentially restricted to the elementary types. In particular, it must only
2778 contain code to which pragma Restrictions (No_Elaboration_Code) applies.
2780 This pragma is used by GNAT to implement auto-initialization of shared Stand
2781 Alone Libraries, which provides a related capability without the restrictions
2782 listed above. Where possible, the use of Stand Alone Libraries is preferable
2783 to the use of this pragma.
2785 @node Pragma Linker_Destructor
2786 @unnumberedsec Pragma Linker_Destructor
2787 @findex Linker_Destructor
2788 @noindent
2789 Syntax:
2791 @smallexample @c ada
2792 pragma Linker_Destructor (procedure_LOCAL_NAME);
2793 @end smallexample
2795 @noindent
2796 @var{procedure_local_NAME} must refer to a parameterless procedure that
2797 is declared at the library level. A procedure to which this pragma is
2798 applied will be treated as a finalization routine by the linker.
2799 It is equivalent to @code{__attribute__((destructor))} in GNU C and
2800 causes @var{procedure_LOCAL_NAME} to be invoked after the entry point
2801 of the executable has exited (or immediately before the shared library
2802 is unloaded if the procedure is linked in a shared library), in particular
2803 after the Ada run-time environment is shut down.
2805 See @code{pragma Linker_Constructor} for the set of restrictions that apply
2806 because of these specific contexts.
2808 @node Pragma Linker_Section
2809 @unnumberedsec Pragma Linker_Section
2810 @findex Linker_Section
2811 @noindent
2812 Syntax:
2814 @smallexample @c ada
2815 pragma Linker_Section (
2816   [Entity  =>] local_NAME
2817   [Section =>] static_string_EXPRESSION);
2818 @end smallexample
2820 @noindent
2821 @var{local_NAME} must refer to an object that is declared at the library
2822 level. This pragma specifies the name of the linker section for the given
2823 entity. It is equivalent to @code{__attribute__((section))} in GNU C and
2824 causes @var{local_NAME} to be placed in the @var{static_string_EXPRESSION}
2825 section of the executable (assuming the linker doesn't rename the section).
2827 The compiler normally places library-level objects in standard sections
2828 depending on their type: procedures and functions generally go in the
2829 @code{.text} section, initialized variables in the @code{.data} section
2830 and uninitialized variables in the @code{.bss} section.
2832 Other, special sections may exist on given target machines to map special
2833 hardware, for example I/O ports or flash memory. This pragma is a means to
2834 defer the final layout of the executable to the linker, thus fully working
2835 at the symbolic level with the compiler.
2837 Some file formats do not support arbitrary sections so not all target
2838 machines support this pragma. The use of this pragma may cause a program
2839 execution to be erroneous if it is used to place an entity into an
2840 inappropriate section (e.g. a modified variable into the @code{.text}
2841 section). See also @code{pragma Persistent_BSS}.
2843 @smallexample @c ada
2844 --  Example of the use of pragma Linker_Section
2846 package IO_Card is
2847   Port_A : Integer;
2848   pragma Volatile (Port_A);
2849   pragma Linker_Section (Port_A, ".bss.port_a");
2851   Port_B : Integer;
2852   pragma Volatile (Port_B);
2853   pragma Linker_Section (Port_B, ".bss.port_b");
2854 end IO_Card;
2855 @end smallexample
2857 @node Pragma Long_Float
2858 @unnumberedsec Pragma Long_Float
2859 @cindex OpenVMS
2860 @findex Long_Float
2861 @noindent
2862 Syntax:
2864 @smallexample @c ada
2865 pragma Long_Float (FLOAT_FORMAT);
2867 FLOAT_FORMAT ::= D_Float | G_Float
2868 @end smallexample
2870 @noindent
2871 This pragma is implemented only in the OpenVMS implementation of GNAT@.
2872 It allows control over the internal representation chosen for the predefined
2873 type @code{Long_Float} and for floating point type representations with
2874 @code{digits} specified in the range 7 through 15.
2875 For further details on this pragma, see the
2876 @cite{DEC Ada Language Reference Manual}, section 3.5.7b.  Note that to use
2877 this pragma, the standard runtime libraries must be recompiled.  See the
2878 description of the @code{GNAT LIBRARY} command in the OpenVMS version
2879 of the GNAT User's Guide for details on the use of this command.
2881 @node Pragma Machine_Attribute
2882 @unnumberedsec Pragma Machine_Attribute
2883 @findex Machine_Attribute
2884 @noindent
2885 Syntax:
2887 @smallexample @c ada
2888 pragma Machine_Attribute (
2889   [Attribute_Name =>] string_EXPRESSION,
2890   [Entity         =>] local_NAME);
2891 @end smallexample
2893 @noindent
2894 Machine-dependent attributes can be specified for types and/or
2895 declarations.  This pragma is semantically equivalent to
2896 @code{__attribute__((@var{string_expression}))} in GNU C,
2897 where @code{@var{string_expression}} is
2898 recognized by the target macro @code{TARGET_ATTRIBUTE_TABLE} which is
2899 defined for each machine.  See the GCC manual for further information.
2900 It is not possible to specify attributes defined by other languages,
2901 only attributes defined by the machine the code is intended to run on.
2903 @node Pragma Main_Storage
2904 @unnumberedsec Pragma Main_Storage
2905 @cindex OpenVMS
2906 @findex Main_Storage
2907 @noindent
2908 Syntax:
2910 @smallexample @c ada
2911 pragma Main_Storage
2912   (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
2914 MAIN_STORAGE_OPTION ::=
2915   [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
2916 | [TOP_GUARD       =>] static_SIMPLE_EXPRESSION
2918 @end smallexample
2920 @noindent
2921 This pragma is provided for compatibility with OpenVMS VAX Systems.  It has
2922 no effect in GNAT, other than being syntax checked.  Note that the pragma
2923 also has no effect in DEC Ada 83 for OpenVMS Alpha Systems.
2925 @node Pragma No_Return
2926 @unnumberedsec Pragma No_Return
2927 @findex No_Return
2928 @noindent
2929 Syntax:
2931 @smallexample @c ada
2932 pragma No_Return (procedure_local_NAME @{, procedure_local_NAME@});
2933 @end smallexample
2935 @noindent
2936 Each @var{procedure_local_NAME} argument must refer to one or more procedure
2937 declarations in the current declarative part.  A procedure to which this
2938 pragma is applied may not contain any explicit @code{return} statements.
2939 In addition, if the procedure contains any implicit returns from falling
2940 off the end of a statement sequence, then execution of that implicit
2941 return will cause Program_Error to be raised.
2943 One use of this pragma is to identify procedures whose only purpose is to raise
2944 an exception. Another use of this pragma is to suppress incorrect warnings
2945 about missing returns in functions, where the last statement of a function
2946 statement sequence is a call to such a procedure.
2948 Note that in Ada 2005 mode, this pragma is part of the language, and is
2949 identical in effect to the pragma as implemented in Ada 95 mode.
2951 @node Pragma No_Strict_Aliasing
2952 @unnumberedsec Pragma No_Strict_Aliasing
2953 @findex No_Strict_Aliasing
2954 @noindent
2955 Syntax:
2957 @smallexample @c ada
2958 pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)];
2959 @end smallexample
2961 @noindent
2962 @var{type_LOCAL_NAME} must refer to an access type
2963 declaration in the current declarative part.  The effect is to inhibit
2964 strict aliasing optimization for the given type.  The form with no
2965 arguments is a configuration pragma which applies to all access types
2966 declared in units to which the pragma applies. For a detailed
2967 description of the strict aliasing optimization, and the situations
2968 in which it must be suppressed, see section
2969 ``Optimization and Strict Aliasing'' in the @value{EDITION} User's Guide.
2971 @node Pragma Normalize_Scalars
2972 @unnumberedsec Pragma Normalize_Scalars
2973 @findex Normalize_Scalars
2974 @noindent
2975 Syntax:
2977 @smallexample @c ada
2978 pragma Normalize_Scalars;
2979 @end smallexample
2981 @noindent
2982 This is a language defined pragma which is fully implemented in GNAT@.  The
2983 effect is to cause all scalar objects that are not otherwise initialized
2984 to be initialized.  The initial values are implementation dependent and
2985 are as follows:
2987 @table @code
2988 @item Standard.Character
2989 @noindent
2990 Objects whose root type is Standard.Character are initialized to
2991 Character'Last unless the subtype range excludes NUL (in which case
2992 NUL is used). This choice will always generate an invalid value if
2993 one exists.
2995 @item Standard.Wide_Character
2996 @noindent
2997 Objects whose root type is Standard.Wide_Character are initialized to
2998 Wide_Character'Last unless the subtype range excludes NUL (in which case
2999 NUL is used). This choice will always generate an invalid value if
3000 one exists.
3002 @item Standard.Wide_Wide_Character
3003 @noindent
3004 Objects whose root type is Standard.Wide_Wide_Character are initialized to
3005 the invalid value 16#FFFF_FFFF# unless the subtype range excludes NUL (in
3006 which case NUL is used). This choice will always generate an invalid value if
3007 one exists.
3009 @item Integer types
3010 @noindent
3011 Objects of an integer type are treated differently depending on whether
3012 negative values are present in the subtype. If no negative values are
3013 present, then all one bits is used as the initial value except in the
3014 special case where zero is excluded from the subtype, in which case
3015 all zero bits are used. This choice will always generate an invalid
3016 value if one exists.
3018 For subtypes with negative values present, the largest negative number
3019 is used, except in the unusual case where this largest negative number
3020 is in the subtype, and the largest positive number is not, in which case
3021 the largest positive value is used. This choice will always generate
3022 an invalid value if one exists.
3024 @item Floating-Point Types
3025 Objects of all floating-point types are initialized to all 1-bits. For
3026 standard IEEE format, this corresponds to a NaN (not a number) which is
3027 indeed an invalid value.
3029 @item Fixed-Point Types
3030 Objects of all fixed-point types are treated as described above for integers,
3031 with the rules applying to the underlying integer value used to represent
3032 the fixed-point value.
3034 @item Modular types
3035 Objects of a modular type are initialized to all one bits, except in
3036 the special case where zero is excluded from the subtype, in which
3037 case all zero bits are used. This choice will always generate an
3038 invalid value if one exists.
3040 @item Enumeration types
3041 Objects of an enumeration type are initialized to all one-bits, i.e.@: to
3042 the value @code{2 ** typ'Size - 1} unless the subtype excludes the literal
3043 whose Pos value is zero, in which case a code of zero is used. This choice
3044 will always generate an invalid value if one exists.
3046 @end table
3048 @node Pragma Obsolescent
3049 @unnumberedsec Pragma Obsolescent
3050 @findex Obsolescent
3051 @noindent
3052 Syntax:
3054 @smallexample @c ada
3055 pragma Obsolescent [(static_string_EXPRESSION [,Ada_05])];
3056 @end smallexample
3058 @noindent
3059 This pragma can occur immediately following a subprogram
3060 declaration and indicates that the associated function or procedure
3061 is considered obsolescent and should not be used. Typically this is
3062 used when an API must be modified by eventually removing or modifying
3063 existing subprograms. The pragma can be used at an intermediate stage
3064 when the subprogram is still present, but will be removed later.
3066 The effect of this pragma is to output a warning message on
3067 a call to a program thus marked that the
3068 subprogram is obsolescent if the appropriate warning option in the
3069 compiler is activated. If a parameter is present, then a second
3070 warning message is given containing this text.
3071 In addition, a call to such a program is considered a violation of
3072 pragma Restrictions (No_Obsolescent_Features).
3074 This pragma can also be used as a program unit pragma for a package,
3075 in which case it indicates that the entire package is considered
3076 obsolescent. In this case a client @code{with}'ing such a package
3077 violates the restriction, and the @code{with} statement is
3078 flagged with warnings if the warning option is set.
3080 If the optional second parameter is present (which must be exactly
3081 the identifier Ada_05, no other argument is allowed), then the
3082 indication of obsolescence applies only when compiling in Ada 2005
3083 mode. This is primarily intended for dealing with the situations
3084 in the predefined library where subprograms or packages
3085 have become defined as obsolescent in Ada 2005
3086 (e.g. in Ada.Characters.Handling), but may be used anywhere.
3088 @node Pragma Passive
3089 @unnumberedsec Pragma Passive
3090 @findex Passive
3091 @noindent
3092 Syntax:
3094 @smallexample @c ada
3095 pragma Passive ([Semaphore | No]);
3096 @end smallexample
3098 @noindent
3099 Syntax checked, but otherwise ignored by GNAT@.  This is recognized for
3100 compatibility with DEC Ada 83 implementations, where it is used within a
3101 task definition to request that a task be made passive.  If the argument
3102 @code{Semaphore} is present, or the argument is omitted, then DEC Ada 83
3103 treats the pragma as an assertion that the containing task is passive
3104 and that optimization of context switch with this task is permitted and
3105 desired.  If the argument @code{No} is present, the task must not be
3106 optimized.  GNAT does not attempt to optimize any tasks in this manner
3107 (since protected objects are available in place of passive tasks).
3109 @node Pragma Persistent_BSS
3110 @unnumberedsec Pragma Persistent_BSS
3111 @findex Persistent_BSS
3112 @noindent
3113 Syntax:
3115 @smallexample @c ada
3116 pragma Persistent_BSS [local_NAME]
3117 @end smallexample
3119 @noindent
3120 This pragma allows selected objects to be placed in the @code{.persistent_bss}
3121 section. On some targets the linker and loader provide for special
3122 treatment of this section, allowing a program to be reloaded without
3123 affecting the contents of this data (hence the name persistent).
3125 There are two forms of usage. If an argument is given, it must be the
3126 local name of a library level object, with no explicit initialization
3127 and whose type is potentially persistent. If no argument is given, then
3128 the pragma is a configuration pragma, and applies to all library level
3129 objects with no explicit initialization of potentially persistent types.
3131 A potentially persistent type is a scalar type, or a non-tagged,
3132 non-discriminated record, all of whose components have no explicit
3133 initialization and are themselves of a potentially persistent type,
3134 or an array, all of whose constraints are static, and whose component
3135 type is potentially persistent.
3137 If this pragma is used on a target where this feature is not supported,
3138 then the pragma will be ignored. See also @code{pragma Linker_Section}.
3140 @node Pragma Polling
3141 @unnumberedsec Pragma Polling
3142 @findex Polling
3143 @noindent
3144 Syntax:
3146 @smallexample @c ada
3147 pragma Polling (ON | OFF);
3148 @end smallexample
3150 @noindent
3151 This pragma controls the generation of polling code.  This is normally off.
3152 If @code{pragma Polling (ON)} is used then periodic calls are generated to
3153 the routine @code{Ada.Exceptions.Poll}.  This routine is a separate unit in the
3154 runtime library, and can be found in file @file{a-excpol.adb}.
3156 Pragma @code{Polling} can appear as a configuration pragma (for example it
3157 can be placed in the @file{gnat.adc} file) to enable polling globally, or it
3158 can be used in the statement or declaration sequence to control polling
3159 more locally.
3161 A call to the polling routine is generated at the start of every loop and
3162 at the start of every subprogram call.  This guarantees that the @code{Poll}
3163 routine is called frequently, and places an upper bound (determined by
3164 the complexity of the code) on the period between two @code{Poll} calls.
3166 The primary purpose of the polling interface is to enable asynchronous
3167 aborts on targets that cannot otherwise support it (for example Windows
3168 NT), but it may be used for any other purpose requiring periodic polling.
3169 The standard version is null, and can be replaced by a user program.  This
3170 will require re-compilation of the @code{Ada.Exceptions} package that can
3171 be found in files @file{a-except.ads} and @file{a-except.adb}.
3173 A standard alternative unit (in file @file{4wexcpol.adb} in the standard GNAT
3174 distribution) is used to enable the asynchronous abort capability on
3175 targets that do not normally support the capability.  The version of
3176 @code{Poll} in this file makes a call to the appropriate runtime routine
3177 to test for an abort condition.
3179 Note that polling can also be enabled by use of the @code{-gnatP} switch.  See
3180 the @cite{GNAT User's Guide} for details.
3182 @node Pragma Profile (Ravenscar)
3183 @unnumberedsec Pragma Profile (Ravenscar)
3184 @findex Ravenscar
3185 @noindent
3186 Syntax:
3188 @smallexample @c ada
3189 pragma Profile (Ravenscar);
3190 @end smallexample
3192 @noindent
3193 A configuration pragma that establishes the following set of configuration
3194 pragmas:
3196 @table @code
3197 @item Task_Dispatching_Policy (FIFO_Within_Priorities)
3198 [RM D.2.2] Tasks are dispatched following a preemptive
3199 priority-ordered scheduling policy.
3201 @item Locking_Policy (Ceiling_Locking)
3202 [RM D.3] While tasks and interrupts execute a protected action, they inherit
3203 the ceiling priority of the corresponding protected object.
3205 @c @item Detect_Blocking
3206 @c This pragma forces the detection of potentially blocking operations within a
3207 @c protected operation, and to raise Program_Error if that happens.
3208 @end table
3209 @noindent
3211 plus the following set of restrictions:
3213 @table @code
3214 @item Max_Entry_Queue_Length = 1
3215 Defines the maximum number of calls that are queued on a (protected) entry.
3216 Note that this restrictions is checked at run time. Violation of this
3217 restriction results in the raising of Program_Error exception at the point of
3218 the call. For the Profile (Ravenscar) the value of Max_Entry_Queue_Length is
3219 always 1 and hence no task can be queued on a protected entry.
3221 @item Max_Protected_Entries = 1
3222 [RM D.7] Specifies the maximum number of entries per protected type. The
3223 bounds of every entry family of a protected unit shall be static, or shall be
3224 defined by a discriminant of a subtype whose corresponding bound is static.
3225 For the Profile (Ravenscar) the value of Max_Protected_Entries is always 1.
3227 @item Max_Task_Entries = 0
3228 [RM D.7] Specifies the maximum number of entries
3229 per task.  The bounds of every entry family
3230 of a task unit shall be static, or shall be
3231 defined by a discriminant of a subtype whose
3232 corresponding bound is static.  A value of zero
3233 indicates that no rendezvous are possible.  For
3234 the Profile (Ravenscar), the value of Max_Task_Entries is always
3235 0 (zero).
3237 @item No_Abort_Statements
3238 [RM D.7] There are no abort_statements, and there are
3239 no calls to Task_Identification.Abort_Task.
3241 @item No_Asynchronous_Control
3242 [RM D.7] There are no semantic dependences on the package
3243 Asynchronous_Task_Control.
3245 @item No_Calendar
3246 There are no semantic dependencies on the package Ada.Calendar.
3248 @item No_Dynamic_Attachment
3249 There is no call to any of the operations defined in package Ada.Interrupts
3250 (Is_Reserved, Is_Attached, Current_Handler, Attach_Handler, Exchange_Handler,
3251 Detach_Handler, and Reference).
3253 @item No_Dynamic_Priorities
3254 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
3256 @item No_Implicit_Heap_Allocations
3257 [RM D.7] No constructs are allowed to cause implicit heap allocation.
3259 @item No_Local_Protected_Objects
3260 Protected objects and access types that designate
3261 such objects shall be declared only at library level.
3263 @item No_Protected_Type_Allocators
3264 There are no allocators for protected types or
3265 types containing protected subcomponents.
3267 @item No_Relative_Delay
3268 There are no delay_relative statements.
3270 @item No_Requeue_Statements
3271 Requeue statements are not allowed.
3273 @item No_Select_Statements
3274 There are no select_statements.
3276 @item No_Task_Allocators
3277 [RM D.7] There are no allocators for task types
3278 or types containing task subcomponents.
3280 @item No_Task_Attributes_Package
3281 There are no semantic dependencies on the Ada.Task_Attributes package.
3283 @item No_Task_Hierarchy
3284 [RM D.7] All (non-environment) tasks depend
3285 directly on the environment task of the partition.
3287 @item No_Task_Termination
3288 Tasks which terminate are erroneous.
3290 @item Simple_Barriers
3291 Entry barrier condition expressions shall be either static
3292 boolean expressions or boolean objects which are declared in
3293 the protected type which contains the entry.
3294 @end table
3296 @noindent
3297 This set of configuration pragmas and restrictions correspond to the
3298 definition of the ``Ravenscar Profile'' for limited tasking, devised and
3299 published by the @cite{International Real-Time Ada Workshop}, 1997,
3300 and whose most recent description is available at
3301 @url{ftp://ftp.openravenscar.org/openravenscar/ravenscar00.pdf}.
3303 The original definition of the profile was revised at subsequent IRTAW
3304 meetings. It has been included in the ISO
3305 @cite{Guide for the Use of the Ada Programming Language in High
3306 Integrity Systems}, and has been approved by ISO/IEC/SC22/WG9 for inclusion in
3307 the next revision of the standard. The formal definition given by
3308 the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
3309 AI-305) available at
3310 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00249.TXT} and
3311 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00305.TXT}
3312 respectively.
3314 The above set is a superset of the restrictions provided by pragma
3315 @code{Profile (Restricted)}, it includes six additional restrictions
3316 (@code{Simple_Barriers}, @code{No_Select_Statements},
3317 @code{No_Calendar}, @code{No_Implicit_Heap_Allocations},
3318 @code{No_Relative_Delay} and @code{No_Task_Termination}).  This means
3319 that pragma @code{Profile (Ravenscar)}, like the pragma
3320 @code{Profile (Restricted)},
3321 automatically causes the use of a simplified,
3322 more efficient version of the tasking run-time system.
3324 @node Pragma Profile (Restricted)
3325 @unnumberedsec Pragma Profile (Restricted)
3326 @findex Restricted Run Time
3327 @noindent
3328 Syntax:
3330 @smallexample @c ada
3331 pragma Profile (Restricted);
3332 @end smallexample
3334 @noindent
3335 A configuration pragma that establishes the following set of restrictions:
3337 @itemize @bullet
3338 @item No_Abort_Statements
3339 @item No_Entry_Queue
3340 @item No_Task_Hierarchy
3341 @item No_Task_Allocators
3342 @item No_Dynamic_Priorities
3343 @item No_Terminate_Alternatives
3344 @item No_Dynamic_Attachment
3345 @item No_Protected_Type_Allocators
3346 @item No_Local_Protected_Objects
3347 @item No_Requeue_Statements
3348 @item No_Task_Attributes_Package
3349 @item Max_Asynchronous_Select_Nesting =  0
3350 @item Max_Task_Entries =  0
3351 @item Max_Protected_Entries = 1
3352 @item Max_Select_Alternatives = 0
3353 @end itemize
3355 @noindent
3356 This set of restrictions causes the automatic selection of a simplified
3357 version of the run time that provides improved performance for the
3358 limited set of tasking functionality permitted by this set of restrictions.
3360 @node Pragma Psect_Object
3361 @unnumberedsec Pragma Psect_Object
3362 @findex Psect_Object
3363 @noindent
3364 Syntax:
3366 @smallexample @c ada
3367 pragma Psect_Object (
3368      [Internal =>] local_NAME,
3369   [, [External =>] EXTERNAL_SYMBOL]
3370   [, [Size     =>] EXTERNAL_SYMBOL]);
3372 EXTERNAL_SYMBOL ::=
3373   IDENTIFIER
3374 | static_string_EXPRESSION
3375 @end smallexample
3377 @noindent
3378 This pragma is identical in effect to pragma @code{Common_Object}.
3380 @node Pragma Pure_Function
3381 @unnumberedsec Pragma Pure_Function
3382 @findex Pure_Function
3383 @noindent
3384 Syntax:
3386 @smallexample @c ada
3387 pragma Pure_Function ([Entity =>] function_local_NAME);
3388 @end smallexample
3390 @noindent
3391 This pragma appears in the same declarative part as a function
3392 declaration (or a set of function declarations if more than one
3393 overloaded declaration exists, in which case the pragma applies
3394 to all entities).  It specifies that the function @code{Entity} is
3395 to be considered pure for the purposes of code generation.  This means
3396 that the compiler can assume that there are no side effects, and
3397 in particular that two calls with identical arguments produce the
3398 same result.  It also means that the function can be used in an
3399 address clause.
3401 Note that, quite deliberately, there are no static checks to try
3402 to ensure that this promise is met, so @code{Pure_Function} can be used
3403 with functions that are conceptually pure, even if they do modify
3404 global variables.  For example, a square root function that is
3405 instrumented to count the number of times it is called is still
3406 conceptually pure, and can still be optimized, even though it
3407 modifies a global variable (the count).  Memo functions are another
3408 example (where a table of previous calls is kept and consulted to
3409 avoid re-computation).
3411 @findex Pure
3412 Note: Most functions in a @code{Pure} package are automatically pure, and
3413 there is no need to use pragma @code{Pure_Function} for such functions.  One
3414 exception is any function that has at least one formal of type
3415 @code{System.Address} or a type derived from it.  Such functions are not
3416 considered pure by default, since the compiler assumes that the
3417 @code{Address} parameter may be functioning as a pointer and that the
3418 referenced data may change even if the address value does not.
3419 Similarly, imported functions are not considered to be pure by default,
3420 since there is no way of checking that they are in fact pure.  The use
3421 of pragma @code{Pure_Function} for such a function will override these default
3422 assumption, and cause the compiler to treat a designated subprogram as pure
3423 in these cases.
3425 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
3426 applies to the underlying renamed function.  This can be used to
3427 disambiguate cases of overloading where some but not all functions
3428 in a set of overloaded functions are to be designated as pure.
3430 If pragma @code{Pure_Function} is applied to a library level function, the
3431 function is also considered pure from an optimization point of view, but the
3432 unit is not a Pure unit in the categorization sense. So for example, a function
3433 thus marked is free to @code{with} non-pure units.
3435 @node Pragma Restriction_Warnings
3436 @unnumberedsec Pragma Restriction_Warnings
3437 @findex Restriction_Warnings
3438 @noindent
3439 Syntax:
3441 @smallexample @c ada
3442 pragma Restriction_Warnings
3443   (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
3444 @end smallexample
3446 @noindent
3447 This pragma allows a series of restriction identifiers to be
3448 specified (the list of allowed identifiers is the same as for
3449 pragma @code{Restrictions}). For each of these identifiers
3450 the compiler checks for violations of the restriction, but
3451 generates a warning message rather than an error message
3452 if the restriction is violated.
3454 @node Pragma Source_File_Name
3455 @unnumberedsec Pragma Source_File_Name
3456 @findex Source_File_Name
3457 @noindent
3458 Syntax:
3460 @smallexample @c ada
3461 pragma Source_File_Name (
3462   [Unit_Name   =>] unit_NAME,
3463   Spec_File_Name =>  STRING_LITERAL);
3465 pragma Source_File_Name (
3466   [Unit_Name   =>] unit_NAME,
3467   Body_File_Name =>  STRING_LITERAL);
3468 @end smallexample
3470 @noindent
3471 Use this to override the normal naming convention.  It is a configuration
3472 pragma, and so has the usual applicability of configuration pragmas
3473 (i.e.@: it applies to either an entire partition, or to all units in a
3474 compilation, or to a single unit, depending on how it is used.
3475 @var{unit_name} is mapped to @var{file_name_literal}.  The identifier for
3476 the second argument is required, and indicates whether this is the file
3477 name for the spec or for the body.
3479 Another form of the @code{Source_File_Name} pragma allows
3480 the specification of patterns defining alternative file naming schemes
3481 to apply to all files.
3483 @smallexample @c ada
3484 pragma Source_File_Name
3485   (Spec_File_Name => STRING_LITERAL
3486    [,Casing => CASING_SPEC]
3487    [,Dot_Replacement => STRING_LITERAL]);
3489 pragma Source_File_Name
3490   (Body_File_Name => STRING_LITERAL
3491    [,Casing => CASING_SPEC]
3492    [,Dot_Replacement => STRING_LITERAL]);
3494 pragma Source_File_Name
3495   (Subunit_File_Name => STRING_LITERAL
3496    [,Casing => CASING_SPEC]
3497    [,Dot_Replacement => STRING_LITERAL]);
3499 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
3500 @end smallexample
3502 @noindent
3503 The first argument is a pattern that contains a single asterisk indicating
3504 the point at which the unit name is to be inserted in the pattern string
3505 to form the file name.  The second argument is optional.  If present it
3506 specifies the casing of the unit name in the resulting file name string.
3507 The default is lower case.  Finally the third argument allows for systematic
3508 replacement of any dots in the unit name by the specified string literal.
3510 A pragma Source_File_Name cannot appear after a
3511 @ref{Pragma Source_File_Name_Project}.
3513 For more details on the use of the @code{Source_File_Name} pragma,
3514 see the sections ``Using Other File Names'' and
3515 ``Alternative File Naming Schemes'' in the @cite{GNAT User's Guide}.
3517 @node Pragma Source_File_Name_Project
3518 @unnumberedsec Pragma Source_File_Name_Project
3519 @findex Source_File_Name_Project
3520 @noindent
3522 This pragma has the same syntax and semantics as pragma Source_File_Name.
3523 It is only allowed as a stand alone configuration pragma.
3524 It cannot appear after a @ref{Pragma Source_File_Name}, and
3525 most importantly, once pragma Source_File_Name_Project appears,
3526 no further Source_File_Name pragmas are allowed.
3528 The intention is that Source_File_Name_Project pragmas are always
3529 generated by the Project Manager in a manner consistent with the naming
3530 specified in a project file, and when naming is controlled in this manner,
3531 it is not permissible to attempt to modify this naming scheme using
3532 Source_File_Name pragmas (which would not be known to the project manager).
3534 @node Pragma Source_Reference
3535 @unnumberedsec Pragma Source_Reference
3536 @findex Source_Reference
3537 @noindent
3538 Syntax:
3540 @smallexample @c ada
3541 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
3542 @end smallexample
3544 @noindent
3545 This pragma must appear as the first line of a source file.
3546 @var{integer_literal} is the logical line number of the line following
3547 the pragma line (for use in error messages and debugging
3548 information).  @var{string_literal} is a static string constant that
3549 specifies the file name to be used in error messages and debugging
3550 information.  This is most notably used for the output of @code{gnatchop}
3551 with the @code{-r} switch, to make sure that the original unchopped
3552 source file is the one referred to.
3554 The second argument must be a string literal, it cannot be a static
3555 string expression other than a string literal.  This is because its value
3556 is needed for error messages issued by all phases of the compiler.
3558 @node Pragma Stream_Convert
3559 @unnumberedsec Pragma Stream_Convert
3560 @findex Stream_Convert
3561 @noindent
3562 Syntax:
3564 @smallexample @c ada
3565 pragma Stream_Convert (
3566   [Entity =>] type_local_NAME,
3567   [Read   =>] function_NAME,
3568   [Write  =>] function_NAME);
3569 @end smallexample
3571 @noindent
3572 This pragma provides an efficient way of providing stream functions for
3573 types defined in packages.  Not only is it simpler to use than declaring
3574 the necessary functions with attribute representation clauses, but more
3575 significantly, it allows the declaration to made in such a way that the
3576 stream packages are not loaded unless they are needed.  The use of
3577 the Stream_Convert pragma adds no overhead at all, unless the stream
3578 attributes are actually used on the designated type.
3580 The first argument specifies the type for which stream functions are
3581 provided.  The second parameter provides a function used to read values
3582 of this type.  It must name a function whose argument type may be any
3583 subtype, and whose returned type must be the type given as the first
3584 argument to the pragma.
3586 The meaning of the @var{Read}
3587 parameter is that if a stream attribute directly
3588 or indirectly specifies reading of the type given as the first parameter,
3589 then a value of the type given as the argument to the Read function is
3590 read from the stream, and then the Read function is used to convert this
3591 to the required target type.
3593 Similarly the @var{Write} parameter specifies how to treat write attributes
3594 that directly or indirectly apply to the type given as the first parameter.
3595 It must have an input parameter of the type specified by the first parameter,
3596 and the return type must be the same as the input type of the Read function.
3597 The effect is to first call the Write function to convert to the given stream
3598 type, and then write the result type to the stream.
3600 The Read and Write functions must not be overloaded subprograms.  If necessary
3601 renamings can be supplied to meet this requirement.
3602 The usage of this attribute is best illustrated by a simple example, taken
3603 from the GNAT implementation of package Ada.Strings.Unbounded:
3605 @smallexample @c ada
3606 function To_Unbounded (S : String)
3607            return Unbounded_String
3608   renames To_Unbounded_String;
3610 pragma Stream_Convert
3611   (Unbounded_String, To_Unbounded, To_String);
3612 @end smallexample
3614 @noindent
3615 The specifications of the referenced functions, as given in the Ada 95
3616 Reference Manual are:
3618 @smallexample @c ada
3619 function To_Unbounded_String (Source : String)
3620   return Unbounded_String;
3622 function To_String (Source : Unbounded_String)
3623   return String;
3624 @end smallexample
3626 @noindent
3627 The effect is that if the value of an unbounded string is written to a
3628 stream, then the representation of the item in the stream is in the same
3629 format used for @code{Standard.String}, and this same representation is
3630 expected when a value of this type is read from the stream.
3632 @node Pragma Style_Checks
3633 @unnumberedsec Pragma Style_Checks
3634 @findex Style_Checks
3635 @noindent
3636 Syntax:
3638 @smallexample @c ada
3639 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
3640                      On | Off [, local_NAME]);
3641 @end smallexample
3643 @noindent
3644 This pragma is used in conjunction with compiler switches to control the
3645 built in style checking provided by GNAT@.  The compiler switches, if set,
3646 provide an initial setting for the switches, and this pragma may be used
3647 to modify these settings, or the settings may be provided entirely by
3648 the use of the pragma.  This pragma can be used anywhere that a pragma
3649 is legal, including use as a configuration pragma (including use in
3650 the @file{gnat.adc} file).
3652 The form with a string literal specifies which style options are to be
3653 activated.  These are additive, so they apply in addition to any previously
3654 set style check options.  The codes for the options are the same as those
3655 used in the @code{-gnaty} switch to @code{gcc} or @code{gnatmake}.
3656 For example the following two methods can be used to enable
3657 layout checking:
3659 @itemize @bullet
3660 @item
3661 @smallexample @c ada
3662 pragma Style_Checks ("l");
3663 @end smallexample
3665 @item
3666 @smallexample
3667 gcc -c -gnatyl @dots{}
3668 @end smallexample
3669 @end itemize
3671 @noindent
3672 The form ALL_CHECKS activates all standard checks (its use is equivalent
3673 to the use of the @code{gnaty} switch with no options.  See GNAT User's
3674 Guide for details.
3676 The forms with @code{Off} and @code{On}
3677 can be used to temporarily disable style checks
3678 as shown in the following example:
3680 @smallexample @c ada
3681 @iftex
3682 @leftskip=0cm
3683 @end iftex
3684 pragma Style_Checks ("k"); -- requires keywords in lower case
3685 pragma Style_Checks (Off); -- turn off style checks
3686 NULL;                      -- this will not generate an error message
3687 pragma Style_Checks (On);  -- turn style checks back on
3688 NULL;                      -- this will generate an error message
3689 @end smallexample
3691 @noindent
3692 Finally the two argument form is allowed only if the first argument is
3693 @code{On} or @code{Off}.  The effect is to turn of semantic style checks
3694 for the specified entity, as shown in the following example:
3696 @smallexample @c ada
3697 @iftex
3698 @leftskip=0cm
3699 @end iftex
3700 pragma Style_Checks ("r"); -- require consistency of identifier casing
3701 Arg : Integer;
3702 Rf1 : Integer := ARG;      -- incorrect, wrong case
3703 pragma Style_Checks (Off, Arg);
3704 Rf2 : Integer := ARG;      -- OK, no error
3705 @end smallexample
3707 @node Pragma Subtitle
3708 @unnumberedsec Pragma Subtitle
3709 @findex Subtitle
3710 @noindent
3711 Syntax:
3713 @smallexample @c ada
3714 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
3715 @end smallexample
3717 @noindent
3718 This pragma is recognized for compatibility with other Ada compilers
3719 but is ignored by GNAT@.
3721 @node Pragma Suppress_All
3722 @unnumberedsec Pragma Suppress_All
3723 @findex Suppress_All
3724 @noindent
3725 Syntax:
3727 @smallexample @c ada
3728 pragma Suppress_All;
3729 @end smallexample
3731 @noindent
3732 This pragma can only appear immediately following a compilation
3733 unit.  The effect is to apply @code{Suppress (All_Checks)} to the unit
3734 which it follows.  This pragma is implemented for compatibility with DEC
3735 Ada 83 usage.  The use of pragma @code{Suppress (All_Checks)} as a normal
3736 configuration pragma is the preferred usage in GNAT@.
3738 @node Pragma Suppress_Exception_Locations
3739 @unnumberedsec Pragma Suppress_Exception_Locations
3740 @findex Suppress_Exception_Locations
3741 @noindent
3742 Syntax:
3744 @smallexample @c ada
3745 pragma Suppress_Exception_Locations;
3746 @end smallexample
3748 @noindent
3749 In normal mode, a raise statement for an exception by default generates
3750 an exception message giving the file name and line number for the location
3751 of the raise. This is useful for debugging and logging purposes, but this
3752 entails extra space for the strings for the messages. The configuration
3753 pragma @code{Suppress_Exception_Locations} can be used to suppress the
3754 generation of these strings, with the result that space is saved, but the
3755 exception message for such raises is null. This configuration pragma may
3756 appear in a global configuration pragma file, or in a specific unit as
3757 usual. It is not required that this pragma be used consistently within
3758 a partition, so it is fine to have some units within a partition compiled
3759 with this pragma and others compiled in normal mode without it.
3761 @node Pragma Suppress_Initialization
3762 @unnumberedsec Pragma Suppress_Initialization
3763 @findex Suppress_Initialization
3764 @cindex Suppressing initialization
3765 @cindex Initialization, suppression of
3766 @noindent
3767 Syntax:
3769 @smallexample @c ada
3770 pragma Suppress_Initialization ([Entity =>] type_Name);
3771 @end smallexample
3773 @noindent
3774 This pragma suppresses any implicit or explicit initialization
3775 associated with the given type name for all variables of this type.
3777 @node Pragma Task_Info
3778 @unnumberedsec Pragma Task_Info
3779 @findex Task_Info
3780 @noindent
3781 Syntax
3783 @smallexample @c ada
3784 pragma Task_Info (EXPRESSION);
3785 @end smallexample
3787 @noindent
3788 This pragma appears within a task definition (like pragma
3789 @code{Priority}) and applies to the task in which it appears.  The
3790 argument must be of type @code{System.Task_Info.Task_Info_Type}.
3791 The @code{Task_Info} pragma provides system dependent control over
3792 aspects of tasking implementation, for example, the ability to map
3793 tasks to specific processors.  For details on the facilities available
3794 for the version of GNAT that you are using, see the documentation
3795 in the specification of package System.Task_Info in the runtime
3796 library.
3798 @node Pragma Task_Name
3799 @unnumberedsec Pragma Task_Name
3800 @findex Task_Name
3801 @noindent
3802 Syntax
3804 @smallexample @c ada
3805 pragma Task_Name (string_EXPRESSION);
3806 @end smallexample
3808 @noindent
3809 This pragma appears within a task definition (like pragma
3810 @code{Priority}) and applies to the task in which it appears.  The
3811 argument must be of type String, and provides a name to be used for
3812 the task instance when the task is created.  Note that this expression
3813 is not required to be static, and in particular, it can contain
3814 references to task discriminants.  This facility can be used to
3815 provide different names for different tasks as they are created,
3816 as illustrated in the example below.
3818 The task name is recorded internally in the run-time structures
3819 and is accessible to tools like the debugger.  In addition the
3820 routine @code{Ada.Task_Identification.Image} will return this
3821 string, with a unique task address appended.
3823 @smallexample @c ada
3824 --  Example of the use of pragma Task_Name
3826 with Ada.Task_Identification;
3827 use Ada.Task_Identification;
3828 with Text_IO; use Text_IO;
3829 procedure t3 is
3831    type Astring is access String;
3833    task type Task_Typ (Name : access String) is
3834       pragma Task_Name (Name.all);
3835    end Task_Typ;
3837    task body Task_Typ is
3838       Nam : constant String := Image (Current_Task);
3839    begin
3840       Put_Line ("-->" & Nam (1 .. 14) & "<--");
3841    end Task_Typ;
3843    type Ptr_Task is access Task_Typ;
3844    Task_Var : Ptr_Task;
3846 begin
3847    Task_Var :=
3848      new Task_Typ (new String'("This is task 1"));
3849    Task_Var :=
3850      new Task_Typ (new String'("This is task 2"));
3851 end;
3852 @end smallexample
3854 @node Pragma Task_Storage
3855 @unnumberedsec Pragma Task_Storage
3856 @findex Task_Storage
3857 Syntax:
3859 @smallexample @c ada
3860 pragma Task_Storage (
3861   [Task_Type =>] local_NAME,
3862   [Top_Guard =>] static_integer_EXPRESSION);
3863 @end smallexample
3865 @noindent
3866 This pragma specifies the length of the guard area for tasks.  The guard
3867 area is an additional storage area allocated to a task.  A value of zero
3868 means that either no guard area is created or a minimal guard area is
3869 created, depending on the target.  This pragma can appear anywhere a
3870 @code{Storage_Size} attribute definition clause is allowed for a task
3871 type.
3873 @node Pragma Thread_Body
3874 @unnumberedsec Pragma Thread_Body
3875 @findex Thread_Body
3876 Syntax:
3878 @smallexample @c ada
3879 pragma Thread_Body (
3880   [Entity =>] local_NAME,
3881  [[Secondary_Stack_Size =>] static_integer_EXPRESSION)];
3882 @end smallexample
3884 @noindent
3885 This pragma specifies that the subprogram whose name is given as the
3886 @code{Entity} argument is a thread body, which will be activated
3887 by being called via its Address from foreign code. The purpose is
3888 to allow execution and registration of the foreign thread within the
3889 Ada run-time system.
3891 See the library unit @code{System.Threads} for details on the expansion of
3892 a thread body subprogram, including the calls made to subprograms
3893 within System.Threads to register the task.  This unit also lists the
3894 targets and runtime systems for which this pragma is supported.
3896 A thread body subprogram may not be called directly from Ada code, and
3897 it is not permitted to apply the Access (or Unrestricted_Access) attributes
3898 to such a subprogram. The only legitimate way of calling such a subprogram
3899 is to pass its Address to foreign code and then make the call from the
3900 foreign code.
3902 A thread body subprogram may have any parameters, and it may be a function
3903 returning a result. The convention of the thread body subprogram may be
3904 set in the usual manner using @code{pragma Convention}.
3906 The secondary stack size parameter, if given, is used to set the size
3907 of secondary stack for the thread. The secondary stack is allocated as
3908 a local variable of the expanded thread body subprogram, and thus is
3909 allocated out of the main thread stack size. If no secondary stack
3910 size parameter is present, the default size (from the declaration in
3911 @code{System.Secondary_Stack} is used.
3913 @node Pragma Time_Slice
3914 @unnumberedsec Pragma Time_Slice
3915 @findex Time_Slice
3916 @noindent
3917 Syntax:
3919 @smallexample @c ada
3920 pragma Time_Slice (static_duration_EXPRESSION);
3921 @end smallexample
3923 @noindent
3924 For implementations of GNAT on operating systems where it is possible
3925 to supply a time slice value, this pragma may be used for this purpose.
3926 It is ignored if it is used in a system that does not allow this control,
3927 or if it appears in other than the main program unit.
3928 @cindex OpenVMS
3929 Note that the effect of this pragma is identical to the effect of the
3930 DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
3932 @node Pragma Title
3933 @unnumberedsec Pragma Title
3934 @findex Title
3935 @noindent
3936 Syntax:
3938 @smallexample @c ada
3939 pragma Title (TITLING_OPTION [, TITLING OPTION]);
3941 TITLING_OPTION ::=
3942   [Title    =>] STRING_LITERAL,
3943 | [Subtitle =>] STRING_LITERAL
3944 @end smallexample
3946 @noindent
3947 Syntax checked but otherwise ignored by GNAT@.  This is a listing control
3948 pragma used in DEC Ada 83 implementations to provide a title and/or
3949 subtitle for the program listing.  The program listing generated by GNAT
3950 does not have titles or subtitles.
3952 Unlike other pragmas, the full flexibility of named notation is allowed
3953 for this pragma, i.e.@: the parameters may be given in any order if named
3954 notation is used, and named and positional notation can be mixed
3955 following the normal rules for procedure calls in Ada.
3957 @node Pragma Unchecked_Union
3958 @unnumberedsec Pragma Unchecked_Union
3959 @cindex Unions in C
3960 @findex Unchecked_Union
3961 @noindent
3962 Syntax:
3964 @smallexample @c ada
3965 pragma Unchecked_Union (first_subtype_local_NAME);
3966 @end smallexample
3968 @noindent
3969 This pragma is used to declare that the specified type should be represented
3970 in a manner
3971 equivalent to a C union type, and is intended only for use in
3972 interfacing with C code that uses union types.  In Ada terms, the named
3973 type must obey the following rules:
3975 @itemize @bullet
3976 @item
3977 It is a non-tagged non-limited record type.
3978 @item
3979 It has a single discrete discriminant with a default value.
3980 @item
3981 The component list consists of a single variant part.
3982 @item
3983 Each variant has a component list with a single component.
3984 @item
3985 No nested variants are allowed.
3986 @item
3987 No component has an explicit default value.
3988 @item
3989 No component has a non-static constraint.
3990 @end itemize
3992 @noindent
3993 In addition, given a type that meets the above requirements, the
3994 following restrictions apply to its use throughout the program:
3996 @itemize @bullet
3997 @item
3998 The discriminant name can be mentioned only in an aggregate.
3999 @item
4000 No subtypes may be created of this type.
4001 @item
4002 The type may not be constrained by giving a discriminant value.
4003 @item
4004 The type cannot be passed as the actual for a generic formal with a
4005 discriminant.
4006 @end itemize
4008 @noindent
4009 Equality and inequality operations on @code{unchecked_unions} are not
4010 available, since there is no discriminant to compare and the compiler
4011 does not even know how many bits to compare.  It is implementation
4012 dependent whether this is detected at compile time as an illegality or
4013 whether it is undetected and considered to be an erroneous construct.  In
4014 GNAT, a direct comparison is illegal, but GNAT does not attempt to catch
4015 the composite case (where two composites are compared that contain an
4016 unchecked union component), so such comparisons are simply considered
4017 erroneous.
4019 The layout of the resulting type corresponds exactly to a C union, where
4020 each branch of the union corresponds to a single variant in the Ada
4021 record.  The semantics of the Ada program is not changed in any way by
4022 the pragma, i.e.@: provided the above restrictions are followed, and no
4023 erroneous incorrect references to fields or erroneous comparisons occur,
4024 the semantics is exactly as described by the Ada reference manual.
4025 Pragma @code{Suppress (Discriminant_Check)} applies implicitly to the
4026 type and the default convention is C.
4028 @node Pragma Unimplemented_Unit
4029 @unnumberedsec Pragma Unimplemented_Unit
4030 @findex Unimplemented_Unit
4031 @noindent
4032 Syntax:
4034 @smallexample @c ada
4035 pragma Unimplemented_Unit;
4036 @end smallexample
4038 @noindent
4039 If this pragma occurs in a unit that is processed by the compiler, GNAT
4040 aborts with the message @samp{@var{xxx} not implemented}, where
4041 @var{xxx} is the name of the current compilation unit.  This pragma is
4042 intended to allow the compiler to handle unimplemented library units in
4043 a clean manner.
4045 The abort only happens if code is being generated.  Thus you can use
4046 specs of unimplemented packages in syntax or semantic checking mode.
4048 @node Pragma Universal_Data
4049 @unnumberedsec Pragma Universal_Data
4050 @findex Universal_Data
4051 @noindent
4052 Syntax:
4054 @smallexample @c ada
4055 pragma Universal_Data [(library_unit_Name)];
4056 @end smallexample
4058 @noindent
4059 This pragma is supported only for the AAMP target and is ignored for
4060 other targets. The pragma specifies that all library-level objects
4061 (Counter 0 data) associated with the library unit are to be accessed
4062 and updated using universal addressing (24-bit addresses for AAMP5)
4063 rather than the default of 16-bit Data Environment (DENV) addressing.
4064 Use of this pragma will generally result in less efficient code for
4065 references to global data associated with the library unit, but
4066 allows such data to be located anywhere in memory. This pragma is
4067 a library unit pragma, but can also be used as a configuration pragma
4068 (including use in the @file{gnat.adc} file). The functionality
4069 of this pragma is also available by applying the -univ switch on the
4070 compilations of units where universal addressing of the data is desired.
4072 @node Pragma Unreferenced
4073 @unnumberedsec Pragma Unreferenced
4074 @findex Unreferenced
4075 @cindex Warnings, unreferenced
4076 @noindent
4077 Syntax:
4079 @smallexample @c ada
4080 pragma Unreferenced (local_NAME @{, local_NAME@});
4081 @end smallexample
4083 @noindent
4084 This pragma signals that the entities whose names are listed are
4085 deliberately not referenced in the current source unit. This
4086 suppresses warnings about the
4087 entities being unreferenced, and in addition a warning will be
4088 generated if one of these entities is in fact referenced in the
4089 same unit as the pragma (or in the corresponding body, or one
4090 of its subunits).
4092 This is particularly useful for clearly signaling that a particular
4093 parameter is not referenced in some particular subprogram implementation
4094 and that this is deliberate. It can also be useful in the case of
4095 objects declared only for their initialization or finalization side
4096 effects.
4098 If @code{local_NAME} identifies more than one matching homonym in the
4099 current scope, then the entity most recently declared is the one to which
4100 the pragma applies. Note that in the case of accept formals, the pragma
4101 Unreferenced may appear immediately after the keyword @code{do} which
4102 allows the indication of whether or not accept formals are referenced
4103 or not to be given individually for each accept statement.
4105 The left hand side of an assignment does not count as a reference for the
4106 purpose of this pragma. Thus it is fine to assign to an entity for which
4107 pragma Unreferenced is given.
4109 Note that if a warning is desired for all calls to a given subprogram,
4110 regardless of whether they occur in the same unit as the subprogram
4111 declaration, then this pragma should not be used (calls from another
4112 unit would not be flagged); pragma Obsolescent can be used instead
4113 for this purpose, see @xref{Pragma Obsolescent}.
4115 @node Pragma Unreserve_All_Interrupts
4116 @unnumberedsec Pragma Unreserve_All_Interrupts
4117 @findex Unreserve_All_Interrupts
4118 @noindent
4119 Syntax:
4121 @smallexample @c ada
4122 pragma Unreserve_All_Interrupts;
4123 @end smallexample
4125 @noindent
4126 Normally certain interrupts are reserved to the implementation.  Any attempt
4127 to attach an interrupt causes Program_Error to be raised, as described in
4128 RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
4129 many systems for a @kbd{Ctrl-C} interrupt.  Normally this interrupt is
4130 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
4131 interrupt execution.
4133 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
4134 a program, then all such interrupts are unreserved.  This allows the
4135 program to handle these interrupts, but disables their standard
4136 functions.  For example, if this pragma is used, then pressing
4137 @kbd{Ctrl-C} will not automatically interrupt execution.  However,
4138 a program can then handle the @code{SIGINT} interrupt as it chooses.
4140 For a full list of the interrupts handled in a specific implementation,
4141 see the source code for the specification of @code{Ada.Interrupts.Names} in
4142 file @file{a-intnam.ads}.  This is a target dependent file that contains the
4143 list of interrupts recognized for a given target.  The documentation in
4144 this file also specifies what interrupts are affected by the use of
4145 the @code{Unreserve_All_Interrupts} pragma.
4147 For a more general facility for controlling what interrupts can be
4148 handled, see pragma @code{Interrupt_State}, which subsumes the functionality
4149 of the @code{Unreserve_All_Interrupts} pragma.
4151 @node Pragma Unsuppress
4152 @unnumberedsec Pragma Unsuppress
4153 @findex Unsuppress
4154 @noindent
4155 Syntax:
4157 @smallexample @c ada
4158 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
4159 @end smallexample
4161 @noindent
4162 This pragma undoes the effect of a previous pragma @code{Suppress}.  If
4163 there is no corresponding pragma @code{Suppress} in effect, it has no
4164 effect.  The range of the effect is the same as for pragma
4165 @code{Suppress}.  The meaning of the arguments is identical to that used
4166 in pragma @code{Suppress}.
4168 One important application is to ensure that checks are on in cases where
4169 code depends on the checks for its correct functioning, so that the code
4170 will compile correctly even if the compiler switches are set to suppress
4171 checks.
4173 @node Pragma Use_VADS_Size
4174 @unnumberedsec Pragma Use_VADS_Size
4175 @cindex @code{Size}, VADS compatibility
4176 @findex Use_VADS_Size
4177 @noindent
4178 Syntax:
4180 @smallexample @c ada
4181 pragma Use_VADS_Size;
4182 @end smallexample
4184 @noindent
4185 This is a configuration pragma.  In a unit to which it applies, any use
4186 of the 'Size attribute is automatically interpreted as a use of the
4187 'VADS_Size attribute.  Note that this may result in incorrect semantic
4188 processing of valid Ada 95 programs.  This is intended to aid in the
4189 handling of legacy code which depends on the interpretation of Size
4190 as implemented in the VADS compiler.  See description of the VADS_Size
4191 attribute for further details.
4193 @node Pragma Validity_Checks
4194 @unnumberedsec Pragma Validity_Checks
4195 @findex Validity_Checks
4196 @noindent
4197 Syntax:
4199 @smallexample @c ada
4200 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
4201 @end smallexample
4203 @noindent
4204 This pragma is used in conjunction with compiler switches to control the
4205 built-in validity checking provided by GNAT@.  The compiler switches, if set
4206 provide an initial setting for the switches, and this pragma may be used
4207 to modify these settings, or the settings may be provided entirely by
4208 the use of the pragma.  This pragma can be used anywhere that a pragma
4209 is legal, including use as a configuration pragma (including use in
4210 the @file{gnat.adc} file).
4212 The form with a string literal specifies which validity options are to be
4213 activated.  The validity checks are first set to include only the default
4214 reference manual settings, and then a string of letters in the string
4215 specifies the exact set of options required.  The form of this string
4216 is exactly as described for the @code{-gnatVx} compiler switch (see the
4217 GNAT users guide for details).  For example the following two methods
4218 can be used to enable validity checking for mode @code{in} and
4219 @code{in out} subprogram parameters:
4221 @itemize @bullet
4222 @item
4223 @smallexample @c ada
4224 pragma Validity_Checks ("im");
4225 @end smallexample
4227 @item
4228 @smallexample
4229 gcc -c -gnatVim @dots{}
4230 @end smallexample
4231 @end itemize
4233 @noindent
4234 The form ALL_CHECKS activates all standard checks (its use is equivalent
4235 to the use of the @code{gnatva} switch.
4237 The forms with @code{Off} and @code{On}
4238 can be used to temporarily disable validity checks
4239 as shown in the following example:
4241 @smallexample @c ada
4242 @iftex
4243 @leftskip=0cm
4244 @end iftex
4245 pragma Validity_Checks ("c"); -- validity checks for copies
4246 pragma Validity_Checks (Off); -- turn off validity checks
4247 A := B;                       -- B will not be validity checked
4248 pragma Validity_Checks (On);  -- turn validity checks back on
4249 A := C;                       -- C will be validity checked
4250 @end smallexample
4252 @node Pragma Volatile
4253 @unnumberedsec Pragma Volatile
4254 @findex Volatile
4255 @noindent
4256 Syntax:
4258 @smallexample @c ada
4259 pragma Volatile (local_NAME);
4260 @end smallexample
4262 @noindent
4263 This pragma is defined by the Ada 95 Reference Manual, and the GNAT
4264 implementation is fully conformant with this definition.  The reason it
4265 is mentioned in this section is that a pragma of the same name was supplied
4266 in some Ada 83 compilers, including DEC Ada 83.  The Ada 95 implementation
4267 of pragma Volatile is upwards compatible with the implementation in
4268 Dec Ada 83.
4270 @node Pragma Warnings
4271 @unnumberedsec Pragma Warnings
4272 @findex Warnings
4273 @noindent
4274 Syntax:
4276 @smallexample @c ada
4277 pragma Warnings (On | Off [, local_NAME]);
4278 pragma Warnings (static_string_EXPRESSION);
4279 @end smallexample
4281 @noindent
4282 Normally warnings are enabled, with the output being controlled by
4283 the command line switch.  Warnings (@code{Off}) turns off generation of
4284 warnings until a Warnings (@code{On}) is encountered or the end of the
4285 current unit.  If generation of warnings is turned off using this
4286 pragma, then no warning messages are output, regardless of the
4287 setting of the command line switches.
4289 The form with a single argument is a configuration pragma.
4291 If the @var{local_NAME} parameter is present, warnings are suppressed for
4292 the specified entity.  This suppression is effective from the point where
4293 it occurs till the end of the extended scope of the variable (similar to
4294 the scope of @code{Suppress}).
4296 The form with a static_string_EXPRESSION argument provides more precise
4297 control over which warnings are active. The string is a list of letters
4298 specifying which warnings are to be activated and which deactivated. The
4299 code for these letters is the same as the string used in the command
4300 line switch controlling warnings. The following is a brief summary. For
4301 full details see the GNAT Users Guide:
4303 @smallexample
4304 a   turn on all optional warnings (except d,h,l)
4305 A   turn off all optional warnings
4306 b   turn on warnings for bad fixed value (not multiple of small)
4307 B   turn off warnings for bad fixed value (not multiple of small)
4308 c   turn on warnings for constant conditional
4309 C   turn off warnings for constant conditional
4310 d   turn on warnings for implicit dereference
4311 D   turn off warnings for implicit dereference
4312 e   treat all warnings as errors
4313 f   turn on warnings for unreferenced formal
4314 F   turn off warnings for unreferenced formal
4315 g   turn on warnings for unrecognized pragma
4316 G   turn off warnings for unrecognized pragma
4317 h   turn on warnings for hiding variable
4318 H   turn off warnings for hiding variable
4319 i   turn on warnings for implementation unit
4320 I   turn off warnings for implementation unit
4321 j   turn on warnings for obsolescent (annex J) feature
4322 J   turn off warnings for obsolescent (annex J) feature
4323 k   turn on warnings on constant variable
4324 K   turn off warnings on constant variable
4325 l   turn on warnings for missing elaboration pragma
4326 L   turn off warnings for missing elaboration pragma
4327 m   turn on warnings for variable assigned but not read
4328 M   turn off warnings for variable assigned but not read
4329 n   normal warning mode (cancels s/e)
4330 o   turn on warnings for address clause overlay
4331 O   turn off warnings for address clause overlay
4332 p   turn on warnings for ineffective pragma Inline
4333 P   turn off warnings for ineffective pragma Inline
4334 r   turn on warnings for redundant construct
4335 R   turn off warnings for redundant construct
4336 s   suppress all warnings
4337 u   turn on warnings for unused entity
4338 U   turn off warnings for unused entity
4339 v   turn on warnings for unassigned variable
4340 V   turn off warnings for unassigned variable
4341 x   turn on warnings for export/import
4342 X   turn off warnings for export/import
4343 y   turn on warnings for Ada 2005 incompatibility
4344 Y   turn off warnings for Ada 2005 incompatibility
4345 z   turn on size/align warnings for unchecked conversion
4346 Z   turn off size/align warnings for unchecked conversion
4347 @end smallexample
4349 @noindent
4350 The specified warnings will be in effect until the end of the program
4351 or another pragma Warnings is encountered. The effect of the pragma is
4352 cumulative. Initially the set of warnings is the standard default set
4353 as possibly modified by compiler switches. Then each pragma Warning
4354 modifies this set of warnings as specified.
4356 @node Pragma Weak_External
4357 @unnumberedsec Pragma Weak_External
4358 @findex Weak_External
4359 @noindent
4360 Syntax:
4362 @smallexample @c ada
4363 pragma Weak_External ([Entity =>] local_NAME);
4364 @end smallexample
4366 @noindent
4367 @var{local_NAME} must refer to an object that is declared at the library
4368 level. This pragma specifies that the given entity should be marked as a
4369 weak symbol for the linker. It is equivalent to @code{__attribute__((weak))}
4370 in GNU C and causes @var{local_NAME} to be emitted as a weak symbol instead
4371 of a regular symbol, that is to say a symbol that does not have to be
4372 resolved by the linker if used in conjunction with a pragma Import.
4374 When a weak symbol is not resolved by the linker, its address is set to
4375 zero. This is useful in writing interfaces to external modules that may
4376 or may not be linked in the final executable, for example depending on
4377 configuration settings.
4379 If a program references at run time an entity to which this pragma has been
4380 applied, and the corresponding symbol was not resolved at link time, then
4381 the execution of the program is erroneous. It is not erroneous to take the
4382 Address of such an entity, for example to guard potential references,
4383 as shown in the example below.
4385 Some file formats do not support weak symbols so not all target machines
4386 support this pragma.
4388 @smallexample @c ada
4389 --  Example of the use of pragma Weak_External
4391 package External_Module is
4392   key : Integer;
4393   pragma Import (C, key);
4394   pragma Weak_External (key);
4395   function Present return boolean;
4396 end External_Module;
4398 with System; use System;
4399 package body External_Module is
4400   function Present return boolean is
4401   begin
4402     return key'Address /= System.Null_Address;
4403   end Present;
4404 end External_Module;
4405 @end smallexample
4407 @node Implementation Defined Attributes
4408 @chapter Implementation Defined Attributes
4409 Ada 95 defines (throughout the Ada 95 reference manual,
4410 summarized in annex K),
4411 a set of attributes that provide useful additional functionality in all
4412 areas of the language.  These language defined attributes are implemented
4413 in GNAT and work as described in the Ada 95 Reference Manual.
4415 In addition, Ada 95 allows implementations to define additional
4416 attributes whose meaning is defined by the implementation.  GNAT provides
4417 a number of these implementation-dependent attributes which can be used
4418 to extend and enhance the functionality of the compiler.  This section of
4419 the GNAT reference manual describes these additional attributes.
4421 Note that any program using these attributes may not be portable to
4422 other compilers (although GNAT implements this set of attributes on all
4423 platforms).  Therefore if portability to other compilers is an important
4424 consideration, you should minimize the use of these attributes.
4426 @menu
4427 * Abort_Signal::
4428 * Address_Size::
4429 * Asm_Input::
4430 * Asm_Output::
4431 * AST_Entry::
4432 * Bit::
4433 * Bit_Position::
4434 * Code_Address::
4435 * Default_Bit_Order::
4436 * Elaborated::
4437 * Elab_Body::
4438 * Elab_Spec::
4439 * Emax::
4440 * Enum_Rep::
4441 * Epsilon::
4442 * Fixed_Value::
4443 * Has_Access_Values::
4444 * Has_Discriminants::
4445 * Img::
4446 * Integer_Value::
4447 * Large::
4448 * Machine_Size::
4449 * Mantissa::
4450 * Max_Interrupt_Priority::
4451 * Max_Priority::
4452 * Maximum_Alignment::
4453 * Mechanism_Code::
4454 * Null_Parameter::
4455 * Object_Size::
4456 * Passed_By_Reference::
4457 * Range_Length::
4458 * Safe_Emax::
4459 * Safe_Large::
4460 * Small::
4461 * Storage_Unit::
4462 * Target_Name::
4463 * Tick::
4464 * To_Address::
4465 * Type_Class::
4466 * UET_Address::
4467 * Unconstrained_Array::
4468 * Universal_Literal_String::
4469 * Unrestricted_Access::
4470 * VADS_Size::
4471 * Value_Size::
4472 * Wchar_T_Size::
4473 * Word_Size::
4474 @end menu
4476 @node Abort_Signal
4477 @unnumberedsec Abort_Signal
4478 @findex Abort_Signal
4479 @noindent
4480 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
4481 prefix) provides the entity for the special exception used to signal
4482 task abort or asynchronous transfer of control.  Normally this attribute
4483 should only be used in the tasking runtime (it is highly peculiar, and
4484 completely outside the normal semantics of Ada, for a user program to
4485 intercept the abort exception).
4487 @node Address_Size
4488 @unnumberedsec Address_Size
4489 @cindex Size of @code{Address}
4490 @findex Address_Size
4491 @noindent
4492 @code{Standard'Address_Size} (@code{Standard} is the only allowed
4493 prefix) is a static constant giving the number of bits in an
4494 @code{Address}. It is the same value as System.Address'Size,
4495 but has the advantage of being static, while a direct
4496 reference to System.Address'Size is non-static because Address
4497 is a private type.
4499 @node Asm_Input
4500 @unnumberedsec Asm_Input
4501 @findex Asm_Input
4502 @noindent
4503 The @code{Asm_Input} attribute denotes a function that takes two
4504 parameters.  The first is a string, the second is an expression of the
4505 type designated by the prefix.  The first (string) argument is required
4506 to be a static expression, and is the constraint for the parameter,
4507 (e.g.@: what kind of register is required).  The second argument is the
4508 value to be used as the input argument.  The possible values for the
4509 constant are the same as those used in the RTL, and are dependent on
4510 the configuration file used to built the GCC back end.
4511 @ref{Machine Code Insertions}
4513 @node Asm_Output
4514 @unnumberedsec Asm_Output
4515 @findex Asm_Output
4516 @noindent
4517 The @code{Asm_Output} attribute denotes a function that takes two
4518 parameters.  The first is a string, the second is the name of a variable
4519 of the type designated by the attribute prefix.  The first (string)
4520 argument is required to be a static expression and designates the
4521 constraint for the parameter (e.g.@: what kind of register is
4522 required).  The second argument is the variable to be updated with the
4523 result.  The possible values for constraint are the same as those used in
4524 the RTL, and are dependent on the configuration file used to build the
4525 GCC back end.  If there are no output operands, then this argument may
4526 either be omitted, or explicitly given as @code{No_Output_Operands}.
4527 @ref{Machine Code Insertions}
4529 @node AST_Entry
4530 @unnumberedsec AST_Entry
4531 @cindex OpenVMS
4532 @findex AST_Entry
4533 @noindent
4534 This attribute is implemented only in OpenVMS versions of GNAT@.  Applied to
4535 the name of an entry, it yields a value of the predefined type AST_Handler
4536 (declared in the predefined package System, as extended by the use of
4537 pragma @code{Extend_System (Aux_DEC)}).  This value enables the given entry to
4538 be called when an AST occurs.  For further details, refer to the @cite{DEC Ada
4539 Language Reference Manual}, section 9.12a.
4541 @node Bit
4542 @unnumberedsec Bit
4543 @findex Bit
4544 @code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
4545 offset within the storage unit (byte) that contains the first bit of
4546 storage allocated for the object.  The value of this attribute is of the
4547 type @code{Universal_Integer}, and is always a non-negative number not
4548 exceeding the value of @code{System.Storage_Unit}.
4550 For an object that is a variable or a constant allocated in a register,
4551 the value is zero.  (The use of this attribute does not force the
4552 allocation of a variable to memory).
4554 For an object that is a formal parameter, this attribute applies
4555 to either the matching actual parameter or to a copy of the
4556 matching actual parameter.
4558 For an access object the value is zero.  Note that
4559 @code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
4560 designated object.  Similarly for a record component
4561 @code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
4562 @code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
4563 are subject to index checks.
4565 This attribute is designed to be compatible with the DEC Ada 83 definition
4566 and implementation of the @code{Bit} attribute.
4568 @node Bit_Position
4569 @unnumberedsec Bit_Position
4570 @findex Bit_Position
4571 @noindent
4572 @code{@var{R.C}'Bit}, where @var{R} is a record object and C is one
4573 of the fields of the record type, yields the bit
4574 offset within the record contains the first bit of
4575 storage allocated for the object.  The value of this attribute is of the
4576 type @code{Universal_Integer}.  The value depends only on the field
4577 @var{C} and is independent of the alignment of
4578 the containing record @var{R}.
4580 @node Code_Address
4581 @unnumberedsec Code_Address
4582 @findex Code_Address
4583 @cindex Subprogram address
4584 @cindex Address of subprogram code
4585 @noindent
4586 The @code{'Address}
4587 attribute may be applied to subprograms in Ada 95, but the
4588 intended effect from the Ada 95 reference manual seems to be to provide
4589 an address value which can be used to call the subprogram by means of
4590 an address clause as in the following example:
4592 @smallexample @c ada
4593 procedure K is @dots{}
4595 procedure L;
4596 for L'Address use K'Address;
4597 pragma Import (Ada, L);
4598 @end smallexample
4600 @noindent
4601 A call to @code{L} is then expected to result in a call to @code{K}@.
4602 In Ada 83, where there were no access-to-subprogram values, this was
4603 a common work around for getting the effect of an indirect call.
4604 GNAT implements the above use of @code{Address} and the technique
4605 illustrated by the example code works correctly.
4607 However, for some purposes, it is useful to have the address of the start
4608 of the generated code for the subprogram.  On some architectures, this is
4609 not necessarily the same as the @code{Address} value described above.
4610 For example, the @code{Address} value may reference a subprogram
4611 descriptor rather than the subprogram itself.
4613 The @code{'Code_Address} attribute, which can only be applied to
4614 subprogram entities, always returns the address of the start of the
4615 generated code of the specified subprogram, which may or may not be
4616 the same value as is returned by the corresponding @code{'Address}
4617 attribute.
4619 @node Default_Bit_Order
4620 @unnumberedsec Default_Bit_Order
4621 @cindex Big endian
4622 @cindex Little endian
4623 @findex Default_Bit_Order
4624 @noindent
4625 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
4626 permissible prefix), provides the value @code{System.Default_Bit_Order}
4627 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
4628 @code{Low_Order_First}).  This is used to construct the definition of
4629 @code{Default_Bit_Order} in package @code{System}.
4631 @node Elaborated
4632 @unnumberedsec Elaborated
4633 @findex Elaborated
4634 @noindent
4635 The prefix of the @code{'Elaborated} attribute must be a unit name.  The
4636 value is a Boolean which indicates whether or not the given unit has been
4637 elaborated.  This attribute is primarily intended for internal use by the
4638 generated code for dynamic elaboration checking, but it can also be used
4639 in user programs.  The value will always be True once elaboration of all
4640 units has been completed.  An exception is for units which need no
4641 elaboration, the value is always False for such units.
4643 @node Elab_Body
4644 @unnumberedsec Elab_Body
4645 @findex Elab_Body
4646 @noindent
4647 This attribute can only be applied to a program unit name.  It returns
4648 the entity for the corresponding elaboration procedure for elaborating
4649 the body of the referenced unit.  This is used in the main generated
4650 elaboration procedure by the binder and is not normally used in any
4651 other context.  However, there may be specialized situations in which it
4652 is useful to be able to call this elaboration procedure from Ada code,
4653 e.g.@: if it is necessary to do selective re-elaboration to fix some
4654 error.
4656 @node Elab_Spec
4657 @unnumberedsec Elab_Spec
4658 @findex Elab_Spec
4659 @noindent
4660 This attribute can only be applied to a program unit name.  It returns
4661 the entity for the corresponding elaboration procedure for elaborating
4662 the specification of the referenced unit.  This is used in the main
4663 generated elaboration procedure by the binder and is not normally used
4664 in any other context.  However, there may be specialized situations in
4665 which it is useful to be able to call this elaboration procedure from
4666 Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
4667 some error.
4669 @node Emax
4670 @unnumberedsec Emax
4671 @cindex Ada 83 attributes
4672 @findex Emax
4673 @noindent
4674 The @code{Emax} attribute is provided for compatibility with Ada 83.  See
4675 the Ada 83 reference manual for an exact description of the semantics of
4676 this attribute.
4678 @node Enum_Rep
4679 @unnumberedsec Enum_Rep
4680 @cindex Representation of enums
4681 @findex Enum_Rep
4682 @noindent
4683 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
4684 function with the following spec:
4686 @smallexample @c ada
4687 function @var{S}'Enum_Rep (Arg : @var{S}'Base)
4688   return @i{Universal_Integer};
4689 @end smallexample
4691 @noindent
4692 It is also allowable to apply @code{Enum_Rep} directly to an object of an
4693 enumeration type or to a non-overloaded enumeration
4694 literal.  In this case @code{@var{S}'Enum_Rep} is equivalent to
4695 @code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
4696 enumeration literal or object.
4698 The function returns the representation value for the given enumeration
4699 value.  This will be equal to value of the @code{Pos} attribute in the
4700 absence of an enumeration representation clause.  This is a static
4701 attribute (i.e.@: the result is static if the argument is static).
4703 @code{@var{S}'Enum_Rep} can also be used with integer types and objects,
4704 in which case it simply returns the integer value.  The reason for this
4705 is to allow it to be used for @code{(<>)} discrete formal arguments in
4706 a generic unit that can be instantiated with either enumeration types
4707 or integer types.  Note that if @code{Enum_Rep} is used on a modular
4708 type whose upper bound exceeds the upper bound of the largest signed
4709 integer type, and the argument is a variable, so that the universal
4710 integer calculation is done at run-time, then the call to @code{Enum_Rep}
4711 may raise @code{Constraint_Error}.
4713 @node Epsilon
4714 @unnumberedsec Epsilon
4715 @cindex Ada 83 attributes
4716 @findex Epsilon
4717 @noindent
4718 The @code{Epsilon} attribute is provided for compatibility with Ada 83.  See
4719 the Ada 83 reference manual for an exact description of the semantics of
4720 this attribute.
4722 @node Fixed_Value
4723 @unnumberedsec Fixed_Value
4724 @findex Fixed_Value
4725 @noindent
4726 For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
4727 function with the following specification:
4729 @smallexample @c ada
4730 function @var{S}'Fixed_Value (Arg : @i{Universal_Integer})
4731   return @var{S};
4732 @end smallexample
4734 @noindent
4735 The value returned is the fixed-point value @var{V} such that
4737 @smallexample @c ada
4738 @var{V} = Arg * @var{S}'Small
4739 @end smallexample
4741 @noindent
4742 The effect is thus similar to first converting the argument to the
4743 integer type used to represent @var{S}, and then doing an unchecked
4744 conversion to the fixed-point type.  The difference is
4745 that there are full range checks, to ensure that the result is in range.
4746 This attribute is primarily intended for use in implementation of the
4747 input-output functions for fixed-point values.
4749 @node Has_Access_Values
4750 @unnumberedsec Has_Access_Values
4751 @cindex Access values, testing for
4752 @findex Has_Access_Values
4753 @noindent
4754 The prefix of the @code{Has_Access_Values} attribute is a type.  The result
4755 is a Boolean value which is True if the is an access type, or is a composite
4756 type with a component (at any nesting depth) that is an access type, and is
4757 False otherwise.
4758 The intended use of this attribute is in conjunction with generic
4759 definitions.  If the attribute is applied to a generic private type, it
4760 indicates whether or not the corresponding actual type has access values.
4762 @node Has_Discriminants
4763 @unnumberedsec Has_Discriminants
4764 @cindex Discriminants, testing for
4765 @findex Has_Discriminants
4766 @noindent
4767 The prefix of the @code{Has_Discriminants} attribute is a type.  The result
4768 is a Boolean value which is True if the type has discriminants, and False
4769 otherwise.  The intended use of this attribute is in conjunction with generic
4770 definitions.  If the attribute is applied to a generic private type, it
4771 indicates whether or not the corresponding actual type has discriminants.
4773 @node Img
4774 @unnumberedsec Img
4775 @findex Img
4776 @noindent
4777 The @code{Img} attribute differs from @code{Image} in that it may be
4778 applied to objects as well as types, in which case it gives the
4779 @code{Image} for the subtype of the object.  This is convenient for
4780 debugging:
4782 @smallexample @c ada
4783 Put_Line ("X = " & X'Img);
4784 @end smallexample
4786 @noindent
4787 has the same meaning as the more verbose:
4789 @smallexample @c ada
4790 Put_Line ("X = " & @var{T}'Image (X));
4791 @end smallexample
4793 @noindent
4794 where @var{T} is the (sub)type of the object @code{X}.
4796 @node Integer_Value
4797 @unnumberedsec Integer_Value
4798 @findex Integer_Value
4799 @noindent
4800 For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
4801 function with the following spec:
4803 @smallexample @c ada
4804 function @var{S}'Integer_Value (Arg : @i{Universal_Fixed})
4805   return @var{S};
4806 @end smallexample
4808 @noindent
4809 The value returned is the integer value @var{V}, such that
4811 @smallexample @c ada
4812 Arg = @var{V} * @var{T}'Small
4813 @end smallexample
4815 @noindent
4816 where @var{T} is the type of @code{Arg}.
4817 The effect is thus similar to first doing an unchecked conversion from
4818 the fixed-point type to its corresponding implementation type, and then
4819 converting the result to the target integer type.  The difference is
4820 that there are full range checks, to ensure that the result is in range.
4821 This attribute is primarily intended for use in implementation of the
4822 standard input-output functions for fixed-point values.
4824 @node Large
4825 @unnumberedsec Large
4826 @cindex Ada 83 attributes
4827 @findex Large
4828 @noindent
4829 The @code{Large} attribute is provided for compatibility with Ada 83.  See
4830 the Ada 83 reference manual for an exact description of the semantics of
4831 this attribute.
4833 @node Machine_Size
4834 @unnumberedsec Machine_Size
4835 @findex Machine_Size
4836 @noindent
4837 This attribute is identical to the @code{Object_Size} attribute.  It is
4838 provided for compatibility with the DEC Ada 83 attribute of this name.
4840 @node Mantissa
4841 @unnumberedsec Mantissa
4842 @cindex Ada 83 attributes
4843 @findex Mantissa
4844 @noindent
4845 The @code{Mantissa} attribute is provided for compatibility with Ada 83.  See
4846 the Ada 83 reference manual for an exact description of the semantics of
4847 this attribute.
4849 @node Max_Interrupt_Priority
4850 @unnumberedsec Max_Interrupt_Priority
4851 @cindex Interrupt priority, maximum
4852 @findex Max_Interrupt_Priority
4853 @noindent
4854 @code{Standard'Max_Interrupt_Priority} (@code{Standard} is the only
4855 permissible prefix), provides the same value as
4856 @code{System.Max_Interrupt_Priority}.
4858 @node Max_Priority
4859 @unnumberedsec Max_Priority
4860 @cindex Priority, maximum
4861 @findex Max_Priority
4862 @noindent
4863 @code{Standard'Max_Priority} (@code{Standard} is the only permissible
4864 prefix) provides the same value as @code{System.Max_Priority}.
4866 @node Maximum_Alignment
4867 @unnumberedsec Maximum_Alignment
4868 @cindex Alignment, maximum
4869 @findex Maximum_Alignment
4870 @noindent
4871 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
4872 permissible prefix) provides the maximum useful alignment value for the
4873 target.  This is a static value that can be used to specify the alignment
4874 for an object, guaranteeing that it is properly aligned in all
4875 cases.
4877 @node Mechanism_Code
4878 @unnumberedsec Mechanism_Code
4879 @cindex Return values, passing mechanism
4880 @cindex Parameters, passing mechanism
4881 @findex Mechanism_Code
4882 @noindent
4883 @code{@var{function}'Mechanism_Code} yields an integer code for the
4884 mechanism used for the result of function, and
4885 @code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
4886 used for formal parameter number @var{n} (a static integer value with 1
4887 meaning the first parameter) of @var{subprogram}.  The code returned is:
4889 @table @asis
4890 @item 1
4891 by copy (value)
4892 @item 2
4893 by reference
4894 @item 3
4895 by descriptor (default descriptor class)
4896 @item 4
4897 by descriptor (UBS: unaligned bit string)
4898 @item 5
4899 by descriptor (UBSB: aligned bit string with arbitrary bounds)
4900 @item 6
4901 by descriptor (UBA: unaligned bit array)
4902 @item 7
4903 by descriptor (S: string, also scalar access type parameter)
4904 @item 8
4905 by descriptor (SB: string with arbitrary bounds)
4906 @item 9
4907 by descriptor (A: contiguous array)
4908 @item 10
4909 by descriptor (NCA: non-contiguous array)
4910 @end table
4912 @noindent
4913 Values from 3 through 10 are only relevant to Digital OpenVMS implementations.
4914 @cindex OpenVMS
4916 @node Null_Parameter
4917 @unnumberedsec Null_Parameter
4918 @cindex Zero address, passing
4919 @findex Null_Parameter
4920 @noindent
4921 A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
4922 type or subtype @var{T} allocated at machine address zero.  The attribute
4923 is allowed only as the default expression of a formal parameter, or as
4924 an actual expression of a subprogram call.  In either case, the
4925 subprogram must be imported.
4927 The identity of the object is represented by the address zero in the
4928 argument list, independent of the passing mechanism (explicit or
4929 default).
4931 This capability is needed to specify that a zero address should be
4932 passed for a record or other composite object passed by reference.
4933 There is no way of indicating this without the @code{Null_Parameter}
4934 attribute.
4936 @node Object_Size
4937 @unnumberedsec Object_Size
4938 @cindex Size, used for objects
4939 @findex Object_Size
4940 @noindent
4941 The size of an object is not necessarily the same as the size of the type
4942 of an object.  This is because by default object sizes are increased to be
4943 a multiple of the alignment of the object.  For example,
4944 @code{Natural'Size} is
4945 31, but by default objects of type @code{Natural} will have a size of 32 bits.
4946 Similarly, a record containing an integer and a character:
4948 @smallexample @c ada
4949 type Rec is record
4950    I : Integer;
4951    C : Character;
4952 end record;
4953 @end smallexample
4955 @noindent
4956 will have a size of 40 (that is @code{Rec'Size} will be 40.  The
4957 alignment will be 4, because of the
4958 integer field, and so the default size of record objects for this type
4959 will be 64 (8 bytes).
4961 The @code{@var{type}'Object_Size} attribute
4962 has been added to GNAT to allow the
4963 default object size of a type to be easily determined.  For example,
4964 @code{Natural'Object_Size} is 32, and
4965 @code{Rec'Object_Size} (for the record type in the above example) will be
4966 64.  Note also that, unlike the situation with the
4967 @code{Size} attribute as defined in the Ada RM, the
4968 @code{Object_Size} attribute can be specified individually
4969 for different subtypes.  For example:
4971 @smallexample @c ada
4972 type R is new Integer;
4973 subtype R1 is R range 1 .. 10;
4974 subtype R2 is R range 1 .. 10;
4975 for R2'Object_Size use 8;
4976 @end smallexample
4978 @noindent
4979 In this example, @code{R'Object_Size} and @code{R1'Object_Size} are both
4980 32 since the default object size for a subtype is the same as the object size
4981 for the parent subtype.  This means that objects of type @code{R}
4982 or @code{R1} will
4983 by default be 32 bits (four bytes).  But objects of type
4984 @code{R2} will be only
4985 8 bits (one byte), since @code{R2'Object_Size} has been set to 8.
4987 @node Passed_By_Reference
4988 @unnumberedsec Passed_By_Reference
4989 @cindex Parameters, when passed by reference
4990 @findex Passed_By_Reference
4991 @noindent
4992 @code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
4993 a value of type @code{Boolean} value that is @code{True} if the type is
4994 normally passed by reference and @code{False} if the type is normally
4995 passed by copy in calls.  For scalar types, the result is always @code{False}
4996 and is static.  For non-scalar types, the result is non-static.
4998 @node Range_Length
4999 @unnumberedsec Range_Length
5000 @findex Range_Length
5001 @noindent
5002 @code{@var{type}'Range_Length} for any discrete type @var{type} yields
5003 the number of values represented by the subtype (zero for a null
5004 range).  The result is static for static subtypes.  @code{Range_Length}
5005 applied to the index subtype of a one dimensional array always gives the
5006 same result as @code{Range} applied to the array itself.
5008 @node Safe_Emax
5009 @unnumberedsec Safe_Emax
5010 @cindex Ada 83 attributes
5011 @findex Safe_Emax
5012 @noindent
5013 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83.  See
5014 the Ada 83 reference manual for an exact description of the semantics of
5015 this attribute.
5017 @node Safe_Large
5018 @unnumberedsec Safe_Large
5019 @cindex Ada 83 attributes
5020 @findex Safe_Large
5021 @noindent
5022 The @code{Safe_Large} attribute is provided for compatibility with Ada 83.  See
5023 the Ada 83 reference manual for an exact description of the semantics of
5024 this attribute.
5026 @node Small
5027 @unnumberedsec Small
5028 @cindex Ada 83 attributes
5029 @findex Small
5030 @noindent
5031 The @code{Small} attribute is defined in Ada 95 only for fixed-point types.
5032 GNAT also allows this attribute to be applied to floating-point types
5033 for compatibility with Ada 83.  See
5034 the Ada 83 reference manual for an exact description of the semantics of
5035 this attribute when applied to floating-point types.
5037 @node Storage_Unit
5038 @unnumberedsec Storage_Unit
5039 @findex Storage_Unit
5040 @noindent
5041 @code{Standard'Storage_Unit} (@code{Standard} is the only permissible
5042 prefix) provides the same value as @code{System.Storage_Unit}.
5044 @node Target_Name
5045 @unnumberedsec Target_Name
5046 @findex Target_Name
5047 @noindent
5048 @code{Standard'Target_Name} (@code{Standard} is the only permissible
5049 prefix) provides a static string value that identifies the target
5050 for the current compilation. For GCC implementations, this is the
5051 standard gcc target name without the terminating slash (for
5052 example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
5054 @node Tick
5055 @unnumberedsec Tick
5056 @findex Tick
5057 @noindent
5058 @code{Standard'Tick} (@code{Standard} is the only permissible prefix)
5059 provides the same value as @code{System.Tick},
5061 @node To_Address
5062 @unnumberedsec To_Address
5063 @findex To_Address
5064 @noindent
5065 The @code{System'To_Address}
5066 (@code{System} is the only permissible prefix)
5067 denotes a function identical to
5068 @code{System.Storage_Elements.To_Address} except that
5069 it is a static attribute.  This means that if its argument is
5070 a static expression, then the result of the attribute is a
5071 static expression.  The result is that such an expression can be
5072 used in contexts (e.g.@: preelaborable packages) which require a
5073 static expression and where the function call could not be used
5074 (since the function call is always non-static, even if its
5075 argument is static).
5077 @node Type_Class
5078 @unnumberedsec Type_Class
5079 @findex Type_Class
5080 @noindent
5081 @code{@var{type}'Type_Class} for any type or subtype @var{type} yields
5082 the value of the type class for the full type of @var{type}.  If
5083 @var{type} is a generic formal type, the value is the value for the
5084 corresponding actual subtype.  The value of this attribute is of type
5085 @code{System.Aux_DEC.Type_Class}, which has the following definition:
5087 @smallexample @c ada
5088   type Type_Class is
5089     (Type_Class_Enumeration,
5090      Type_Class_Integer,
5091      Type_Class_Fixed_Point,
5092      Type_Class_Floating_Point,
5093      Type_Class_Array,
5094      Type_Class_Record,
5095      Type_Class_Access,
5096      Type_Class_Task,
5097      Type_Class_Address);
5098 @end smallexample
5100 @noindent
5101 Protected types yield the value @code{Type_Class_Task}, which thus
5102 applies to all concurrent types.  This attribute is designed to
5103 be compatible with the DEC Ada 83 attribute of the same name.
5105 @node UET_Address
5106 @unnumberedsec UET_Address
5107 @findex UET_Address
5108 @noindent
5109 The @code{UET_Address} attribute can only be used for a prefix which
5110 denotes a library package.  It yields the address of the unit exception
5111 table when zero cost exception handling is used.  This attribute is
5112 intended only for use within the GNAT implementation.  See the unit
5113 @code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb}
5114 for details on how this attribute is used in the implementation.
5116 @node Unconstrained_Array
5117 @unnumberedsec Unconstrained_Array
5118 @findex Unconstrained_Array
5119 @noindent
5120 The @code{Unconstrained_Array} attribute can be used with a prefix that
5121 denotes any type or subtype. It is a static attribute that yields
5122 @code{True} if the prefix designates an unconstrained array,
5123 and @code{False} otherwise. In a generic instance, the result is
5124 still static, and yields the result of applying this test to the
5125 generic actual.
5127 @node Universal_Literal_String
5128 @unnumberedsec Universal_Literal_String
5129 @cindex Named numbers, representation of
5130 @findex Universal_Literal_String
5131 @noindent
5132 The prefix of @code{Universal_Literal_String} must be a named
5133 number.  The static result is the string consisting of the characters of
5134 the number as defined in the original source.  This allows the user
5135 program to access the actual text of named numbers without intermediate
5136 conversions and without the need to enclose the strings in quotes (which
5137 would preclude their use as numbers).  This is used internally for the
5138 construction of values of the floating-point attributes from the file
5139 @file{ttypef.ads}, but may also be used by user programs.
5141 For example, the following program prints the first 50 digits of pi:
5143 @smallexample @c ada
5144 with Text_IO; use Text_IO;
5145 with Ada.Numerics;
5146 procedure Pi is
5147 begin
5148    Put (Ada.Numerics.Pi'Universal_Literal_String);
5149 end;
5150 @end smallexample
5152 @node Unrestricted_Access
5153 @unnumberedsec Unrestricted_Access
5154 @cindex @code{Access}, unrestricted
5155 @findex Unrestricted_Access
5156 @noindent
5157 The @code{Unrestricted_Access} attribute is similar to @code{Access}
5158 except that all accessibility and aliased view checks are omitted.  This
5159 is a user-beware attribute.  It is similar to
5160 @code{Address}, for which it is a desirable replacement where the value
5161 desired is an access type.  In other words, its effect is identical to
5162 first applying the @code{Address} attribute and then doing an unchecked
5163 conversion to a desired access type.  In GNAT, but not necessarily in
5164 other implementations, the use of static chains for inner level
5165 subprograms means that @code{Unrestricted_Access} applied to a
5166 subprogram yields a value that can be called as long as the subprogram
5167 is in scope (normal Ada 95 accessibility rules restrict this usage).
5169 It is possible to use @code{Unrestricted_Access} for any type, but care
5170 must be exercised if it is used to create pointers to unconstrained
5171 objects. In this case, the resulting pointer has the same scope as the
5172 context of the attribute, and may not be returned to some enclosing
5173 scope. For instance, a function cannot use @code{Unrestricted_Access}
5174 to create a unconstrained pointer and then return that value to the
5175 caller.
5177 @node VADS_Size
5178 @unnumberedsec VADS_Size
5179 @cindex @code{Size}, VADS compatibility
5180 @findex VADS_Size
5181 @noindent
5182 The @code{'VADS_Size} attribute is intended to make it easier to port
5183 legacy code which relies on the semantics of @code{'Size} as implemented
5184 by the VADS Ada 83 compiler.  GNAT makes a best effort at duplicating the
5185 same semantic interpretation.  In particular, @code{'VADS_Size} applied
5186 to a predefined or other primitive type with no Size clause yields the
5187 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
5188 typical machines).  In addition @code{'VADS_Size} applied to an object
5189 gives the result that would be obtained by applying the attribute to
5190 the corresponding type.
5192 @node Value_Size
5193 @unnumberedsec Value_Size
5194 @cindex @code{Size}, setting for not-first subtype
5195 @findex Value_Size
5196 @code{@var{type}'Value_Size} is the number of bits required to represent
5197 a value of the given subtype.  It is the same as @code{@var{type}'Size},
5198 but, unlike @code{Size}, may be set for non-first subtypes.
5200 @node Wchar_T_Size
5201 @unnumberedsec Wchar_T_Size
5202 @findex Wchar_T_Size
5203 @code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
5204 prefix) provides the size in bits of the C @code{wchar_t} type
5205 primarily for constructing the definition of this type in
5206 package @code{Interfaces.C}.
5208 @node Word_Size
5209 @unnumberedsec Word_Size
5210 @findex Word_Size
5211 @code{Standard'Word_Size} (@code{Standard} is the only permissible
5212 prefix) provides the value @code{System.Word_Size}.
5214 @c ------------------------
5215 @node Implementation Advice
5216 @chapter Implementation Advice
5217 @noindent
5218 The main text of the Ada 95 Reference Manual describes the required
5219 behavior of all Ada 95 compilers, and the GNAT compiler conforms to
5220 these requirements.
5222 In addition, there are sections throughout the Ada 95
5223 reference manual headed
5224 by the phrase ``implementation advice''.  These sections are not normative,
5225 i.e.@: they do not specify requirements that all compilers must
5226 follow.  Rather they provide advice on generally desirable behavior.  You
5227 may wonder why they are not requirements.  The most typical answer is
5228 that they describe behavior that seems generally desirable, but cannot
5229 be provided on all systems, or which may be undesirable on some systems.
5231 As far as practical, GNAT follows the implementation advice sections in
5232 the Ada 95 Reference Manual.  This chapter contains a table giving the
5233 reference manual section number, paragraph number and several keywords
5234 for each advice.  Each entry consists of the text of the advice followed
5235 by the GNAT interpretation of this advice.  Most often, this simply says
5236 ``followed'', which means that GNAT follows the advice.  However, in a
5237 number of cases, GNAT deliberately deviates from this advice, in which
5238 case the text describes what GNAT does and why.
5240 @cindex Error detection
5241 @unnumberedsec 1.1.3(20): Error Detection
5242 @sp 1
5243 @cartouche
5244 If an implementation detects the use of an unsupported Specialized Needs
5245 Annex feature at run time, it should raise @code{Program_Error} if
5246 feasible.
5247 @end cartouche
5248 Not relevant.  All specialized needs annex features are either supported,
5249 or diagnosed at compile time.
5251 @cindex Child Units
5252 @unnumberedsec 1.1.3(31): Child Units
5253 @sp 1
5254 @cartouche
5255 If an implementation wishes to provide implementation-defined
5256 extensions to the functionality of a language-defined library unit, it
5257 should normally do so by adding children to the library unit.
5258 @end cartouche
5259 Followed.
5261 @cindex Bounded errors
5262 @unnumberedsec 1.1.5(12): Bounded Errors
5263 @sp 1
5264 @cartouche
5265 If an implementation detects a bounded error or erroneous
5266 execution, it should raise @code{Program_Error}.
5267 @end cartouche
5268 Followed in all cases in which the implementation detects a bounded
5269 error or erroneous execution.  Not all such situations are detected at
5270 runtime.
5272 @cindex Pragmas
5273 @unnumberedsec 2.8(16): Pragmas
5274 @sp 1
5275 @cartouche
5276 Normally, implementation-defined pragmas should have no semantic effect
5277 for error-free programs; that is, if the implementation-defined pragmas
5278 are removed from a working program, the program should still be legal,
5279 and should still have the same semantics.
5280 @end cartouche
5281 The following implementation defined pragmas are exceptions to this
5282 rule:
5284 @table @code
5285 @item Abort_Defer
5286 Affects semantics
5287 @item Ada_83
5288 Affects legality
5289 @item Assert
5290 Affects semantics
5291 @item CPP_Class
5292 Affects semantics
5293 @item CPP_Constructor
5294 Affects semantics
5295 @item CPP_Virtual
5296 Affects semantics
5297 @item CPP_Vtable
5298 Affects semantics
5299 @item Debug
5300 Affects semantics
5301 @item Interface_Name
5302 Affects semantics
5303 @item Machine_Attribute
5304 Affects semantics
5305 @item Unimplemented_Unit
5306 Affects legality
5307 @item Unchecked_Union
5308 Affects semantics
5309 @end table
5311 @noindent
5312 In each of the above cases, it is essential to the purpose of the pragma
5313 that this advice not be followed.  For details see the separate section
5314 on implementation defined pragmas.
5316 @unnumberedsec 2.8(17-19): Pragmas
5317 @sp 1
5318 @cartouche
5319 Normally, an implementation should not define pragmas that can
5320 make an illegal program legal, except as follows:
5321 @end cartouche
5322 @sp 1
5323 @cartouche
5324 A pragma used to complete a declaration, such as a pragma @code{Import};
5325 @end cartouche
5326 @sp 1
5327 @cartouche
5328 A pragma used to configure the environment by adding, removing, or
5329 replacing @code{library_items}.
5330 @end cartouche
5331 See response to paragraph 16 of this same section.
5333 @cindex Character Sets
5334 @cindex Alternative Character Sets
5335 @unnumberedsec 3.5.2(5): Alternative Character Sets
5336 @sp 1
5337 @cartouche
5338 If an implementation supports a mode with alternative interpretations
5339 for @code{Character} and @code{Wide_Character}, the set of graphic
5340 characters of @code{Character} should nevertheless remain a proper
5341 subset of the set of graphic characters of @code{Wide_Character}.  Any
5342 character set ``localizations'' should be reflected in the results of
5343 the subprograms defined in the language-defined package
5344 @code{Characters.Handling} (see A.3) available in such a mode.  In a mode with
5345 an alternative interpretation of @code{Character}, the implementation should
5346 also support a corresponding change in what is a legal
5347 @code{identifier_letter}.
5348 @end cartouche
5349 Not all wide character modes follow this advice, in particular the JIS
5350 and IEC modes reflect standard usage in Japan, and in these encoding,
5351 the upper half of the Latin-1 set is not part of the wide-character
5352 subset, since the most significant bit is used for wide character
5353 encoding.  However, this only applies to the external forms.  Internally
5354 there is no such restriction.
5356 @cindex Integer types
5357 @unnumberedsec 3.5.4(28): Integer Types
5359 @sp 1
5360 @cartouche
5361 An implementation should support @code{Long_Integer} in addition to
5362 @code{Integer} if the target machine supports 32-bit (or longer)
5363 arithmetic.  No other named integer subtypes are recommended for package
5364 @code{Standard}.  Instead, appropriate named integer subtypes should be
5365 provided in the library package @code{Interfaces} (see B.2).
5366 @end cartouche
5367 @code{Long_Integer} is supported.  Other standard integer types are supported
5368 so this advice is not fully followed.  These types
5369 are supported for convenient interface to C, and so that all hardware
5370 types of the machine are easily available.
5371 @unnumberedsec 3.5.4(29): Integer Types
5373 @sp 1
5374 @cartouche
5375 An implementation for a two's complement machine should support
5376 modular types with a binary modulus up to @code{System.Max_Int*2+2}.  An
5377 implementation should support a non-binary modules up to @code{Integer'Last}.
5378 @end cartouche
5379 Followed.
5381 @cindex Enumeration values
5382 @unnumberedsec 3.5.5(8): Enumeration Values
5383 @sp 1
5384 @cartouche
5385 For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
5386 subtype, if the value of the operand does not correspond to the internal
5387 code for any enumeration literal of its type (perhaps due to an
5388 un-initialized variable), then the implementation should raise
5389 @code{Program_Error}.  This is particularly important for enumeration
5390 types with noncontiguous internal codes specified by an
5391 enumeration_representation_clause.
5392 @end cartouche
5393 Followed.
5395 @cindex Float types
5396 @unnumberedsec 3.5.7(17): Float Types
5397 @sp 1
5398 @cartouche
5399 An implementation should support @code{Long_Float} in addition to
5400 @code{Float} if the target machine supports 11 or more digits of
5401 precision.  No other named floating point subtypes are recommended for
5402 package @code{Standard}.  Instead, appropriate named floating point subtypes
5403 should be provided in the library package @code{Interfaces} (see B.2).
5404 @end cartouche
5405 @code{Short_Float} and @code{Long_Long_Float} are also provided.  The
5406 former provides improved compatibility with other implementations
5407 supporting this type.  The latter corresponds to the highest precision
5408 floating-point type supported by the hardware.  On most machines, this
5409 will be the same as @code{Long_Float}, but on some machines, it will
5410 correspond to the IEEE extended form.  The notable case is all ia32
5411 (x86) implementations, where @code{Long_Long_Float} corresponds to
5412 the 80-bit extended precision format supported in hardware on this
5413 processor.  Note that the 128-bit format on SPARC is not supported,
5414 since this is a software rather than a hardware format.
5416 @cindex Multidimensional arrays
5417 @cindex Arrays, multidimensional
5418 @unnumberedsec 3.6.2(11): Multidimensional Arrays
5419 @sp 1
5420 @cartouche
5421 An implementation should normally represent multidimensional arrays in
5422 row-major order, consistent with the notation used for multidimensional
5423 array aggregates (see 4.3.3).  However, if a pragma @code{Convention}
5424 (@code{Fortran}, @dots{}) applies to a multidimensional array type, then
5425 column-major order should be used instead (see B.5, ``Interfacing with
5426 Fortran'').
5427 @end cartouche
5428 Followed.
5430 @findex Duration'Small
5431 @unnumberedsec 9.6(30-31): Duration'Small
5432 @sp 1
5433 @cartouche
5434 Whenever possible in an implementation, the value of @code{Duration'Small}
5435 should be no greater than 100 microseconds.
5436 @end cartouche
5437 Followed.  (@code{Duration'Small} = 10**(@minus{}9)).
5439 @sp 1
5440 @cartouche
5441 The time base for @code{delay_relative_statements} should be monotonic;
5442 it need not be the same time base as used for @code{Calendar.Clock}.
5443 @end cartouche
5444 Followed.
5446 @unnumberedsec 10.2.1(12): Consistent Representation
5447 @sp 1
5448 @cartouche
5449 In an implementation, a type declared in a pre-elaborated package should
5450 have the same representation in every elaboration of a given version of
5451 the package, whether the elaborations occur in distinct executions of
5452 the same program, or in executions of distinct programs or partitions
5453 that include the given version.
5454 @end cartouche
5455 Followed, except in the case of tagged types.  Tagged types involve
5456 implicit pointers to a local copy of a dispatch table, and these pointers
5457 have representations which thus depend on a particular elaboration of the
5458 package.  It is not easy to see how it would be possible to follow this
5459 advice without severely impacting efficiency of execution.
5461 @cindex Exception information
5462 @unnumberedsec 11.4.1(19): Exception Information
5463 @sp 1
5464 @cartouche
5465 @code{Exception_Message} by default and @code{Exception_Information}
5466 should produce information useful for
5467 debugging.  @code{Exception_Message} should be short, about one
5468 line.  @code{Exception_Information} can be long.  @code{Exception_Message}
5469 should not include the
5470 @code{Exception_Name}.  @code{Exception_Information} should include both
5471 the @code{Exception_Name} and the @code{Exception_Message}.
5472 @end cartouche
5473 Followed.  For each exception that doesn't have a specified
5474 @code{Exception_Message}, the compiler generates one containing the location
5475 of the raise statement.  This location has the form ``file:line'', where
5476 file is the short file name (without path information) and line is the line
5477 number in the file.  Note that in the case of the Zero Cost Exception
5478 mechanism, these messages become redundant with the Exception_Information that
5479 contains a full backtrace of the calling sequence, so they are disabled.
5480 To disable explicitly the generation of the source location message, use the
5481 Pragma @code{Discard_Names}.
5483 @cindex Suppression of checks
5484 @cindex Checks, suppression of
5485 @unnumberedsec 11.5(28): Suppression of Checks
5486 @sp 1
5487 @cartouche
5488 The implementation should minimize the code executed for checks that
5489 have been suppressed.
5490 @end cartouche
5491 Followed.
5493 @cindex Representation clauses
5494 @unnumberedsec 13.1 (21-24): Representation Clauses
5495 @sp 1
5496 @cartouche
5497 The recommended level of support for all representation items is
5498 qualified as follows:
5499 @end cartouche
5500 @sp 1
5501 @cartouche
5502 An implementation need not support representation items containing
5503 non-static expressions, except that an implementation should support a
5504 representation item for a given entity if each non-static expression in
5505 the representation item is a name that statically denotes a constant
5506 declared before the entity.
5507 @end cartouche
5508 Followed.  In fact, GNAT goes beyond the recommended level of support
5509 by allowing nonstatic expressions in some representation clauses even
5510 without the need to declare constants initialized with the values of
5511 such expressions.
5512 For example:
5514 @smallexample @c ada
5515   X : Integer;
5516   Y : Float;
5517   for Y'Address use X'Address;>>
5518 @end smallexample
5521 @sp 1
5522 @cartouche
5523 An implementation need not support a specification for the @code{Size}
5524 for a given composite subtype, nor the size or storage place for an
5525 object (including a component) of a given composite subtype, unless the
5526 constraints on the subtype and its composite subcomponents (if any) are
5527 all static constraints.
5528 @end cartouche
5529 Followed.  Size Clauses are not permitted on non-static components, as
5530 described above.
5532 @sp 1
5533 @cartouche
5534 An aliased component, or a component whose type is by-reference, should
5535 always be allocated at an addressable location.
5536 @end cartouche
5537 Followed.
5539 @cindex Packed types
5540 @unnumberedsec 13.2(6-8): Packed Types
5541 @sp 1
5542 @cartouche
5543 If a type is packed, then the implementation should try to minimize
5544 storage allocated to objects of the type, possibly at the expense of
5545 speed of accessing components, subject to reasonable complexity in
5546 addressing calculations.
5547 @end cartouche
5548 @sp 1
5549 @cartouche
5550 The recommended level of support pragma @code{Pack} is:
5552 For a packed record type, the components should be packed as tightly as
5553 possible subject to the Sizes of the component subtypes, and subject to
5554 any @code{record_representation_clause} that applies to the type; the
5555 implementation may, but need not, reorder components or cross aligned
5556 word boundaries to improve the packing.  A component whose @code{Size} is
5557 greater than the word size may be allocated an integral number of words.
5558 @end cartouche
5559 Followed.  Tight packing of arrays is supported for all component sizes
5560 up to 64-bits. If the array component size is 1 (that is to say, if
5561 the component is a boolean type or an enumeration type with two values)
5562 then values of the type are implicitly initialized to zero. This
5563 happens both for objects of the packed type, and for objects that have a
5564 subcomponent of the packed type.
5566 @sp 1
5567 @cartouche
5568 An implementation should support Address clauses for imported
5569 subprograms.
5570 @end cartouche
5571 Followed.
5572 @cindex @code{Address} clauses
5573 @unnumberedsec 13.3(14-19): Address Clauses
5575 @sp 1
5576 @cartouche
5577 For an array @var{X}, @code{@var{X}'Address} should point at the first
5578 component of the array, and not at the array bounds.
5579 @end cartouche
5580 Followed.
5582 @sp 1
5583 @cartouche
5584 The recommended level of support for the @code{Address} attribute is:
5586 @code{@var{X}'Address} should produce a useful result if @var{X} is an
5587 object that is aliased or of a by-reference type, or is an entity whose
5588 @code{Address} has been specified.
5589 @end cartouche
5590 Followed.  A valid address will be produced even if none of those
5591 conditions have been met.  If necessary, the object is forced into
5592 memory to ensure the address is valid.
5594 @sp 1
5595 @cartouche
5596 An implementation should support @code{Address} clauses for imported
5597 subprograms.
5598 @end cartouche
5599 Followed.
5601 @sp 1
5602 @cartouche
5603 Objects (including subcomponents) that are aliased or of a by-reference
5604 type should be allocated on storage element boundaries.
5605 @end cartouche
5606 Followed.
5608 @sp 1
5609 @cartouche
5610 If the @code{Address} of an object is specified, or it is imported or exported,
5611 then the implementation should not perform optimizations based on
5612 assumptions of no aliases.
5613 @end cartouche
5614 Followed.
5616 @cindex @code{Alignment} clauses
5617 @unnumberedsec 13.3(29-35): Alignment Clauses
5618 @sp 1
5619 @cartouche
5620 The recommended level of support for the @code{Alignment} attribute for
5621 subtypes is:
5623 An implementation should support specified Alignments that are factors
5624 and multiples of the number of storage elements per word, subject to the
5625 following:
5626 @end cartouche
5627 Followed.
5629 @sp 1
5630 @cartouche
5631 An implementation need not support specified @code{Alignment}s for
5632 combinations of @code{Size}s and @code{Alignment}s that cannot be easily
5633 loaded and stored by available machine instructions.
5634 @end cartouche
5635 Followed.
5637 @sp 1
5638 @cartouche
5639 An implementation need not support specified @code{Alignment}s that are
5640 greater than the maximum @code{Alignment} the implementation ever returns by
5641 default.
5642 @end cartouche
5643 Followed.
5645 @sp 1
5646 @cartouche
5647 The recommended level of support for the @code{Alignment} attribute for
5648 objects is:
5650 Same as above, for subtypes, but in addition:
5651 @end cartouche
5652 Followed.
5654 @sp 1
5655 @cartouche
5656 For stand-alone library-level objects of statically constrained
5657 subtypes, the implementation should support all @code{Alignment}s
5658 supported by the target linker.  For example, page alignment is likely to
5659 be supported for such objects, but not for subtypes.
5660 @end cartouche
5661 Followed.
5663 @cindex @code{Size} clauses
5664 @unnumberedsec 13.3(42-43): Size Clauses
5665 @sp 1
5666 @cartouche
5667 The recommended level of support for the @code{Size} attribute of
5668 objects is:
5670 A @code{Size} clause should be supported for an object if the specified
5671 @code{Size} is at least as large as its subtype's @code{Size}, and
5672 corresponds to a size in storage elements that is a multiple of the
5673 object's @code{Alignment} (if the @code{Alignment} is nonzero).
5674 @end cartouche
5675 Followed.
5677 @unnumberedsec 13.3(50-56): Size Clauses
5678 @sp 1
5679 @cartouche
5680 If the @code{Size} of a subtype is specified, and allows for efficient
5681 independent addressability (see 9.10) on the target architecture, then
5682 the @code{Size} of the following objects of the subtype should equal the
5683 @code{Size} of the subtype:
5685 Aliased objects (including components).
5686 @end cartouche
5687 Followed.
5689 @sp 1
5690 @cartouche
5691 @code{Size} clause on a composite subtype should not affect the
5692 internal layout of components.
5693 @end cartouche
5694 Followed.
5696 @sp 1
5697 @cartouche
5698 The recommended level of support for the @code{Size} attribute of subtypes is:
5699 @end cartouche
5700 @sp 1
5701 @cartouche
5702 The @code{Size} (if not specified) of a static discrete or fixed point
5703 subtype should be the number of bits needed to represent each value
5704 belonging to the subtype using an unbiased representation, leaving space
5705 for a sign bit only if the subtype contains negative values.  If such a
5706 subtype is a first subtype, then an implementation should support a
5707 specified @code{Size} for it that reflects this representation.
5708 @end cartouche
5709 Followed.
5711 @sp 1
5712 @cartouche
5713 For a subtype implemented with levels of indirection, the @code{Size}
5714 should include the size of the pointers, but not the size of what they
5715 point at.
5716 @end cartouche
5717 Followed.
5719 @cindex @code{Component_Size} clauses
5720 @unnumberedsec 13.3(71-73): Component Size Clauses
5721 @sp 1
5722 @cartouche
5723 The recommended level of support for the @code{Component_Size}
5724 attribute is:
5725 @end cartouche
5726 @sp 1
5727 @cartouche
5728 An implementation need not support specified @code{Component_Sizes} that are
5729 less than the @code{Size} of the component subtype.
5730 @end cartouche
5731 Followed.
5733 @sp 1
5734 @cartouche
5735 An implementation should support specified @code{Component_Size}s that
5736 are factors and multiples of the word size.  For such
5737 @code{Component_Size}s, the array should contain no gaps between
5738 components.  For other @code{Component_Size}s (if supported), the array
5739 should contain no gaps between components when packing is also
5740 specified; the implementation should forbid this combination in cases
5741 where it cannot support a no-gaps representation.
5742 @end cartouche
5743 Followed.
5745 @cindex Enumeration representation clauses
5746 @cindex Representation clauses, enumeration
5747 @unnumberedsec 13.4(9-10): Enumeration Representation Clauses
5748 @sp 1
5749 @cartouche
5750 The recommended level of support for enumeration representation clauses
5753 An implementation need not support enumeration representation clauses
5754 for boolean types, but should at minimum support the internal codes in
5755 the range @code{System.Min_Int.System.Max_Int}.
5756 @end cartouche
5757 Followed.
5759 @cindex Record representation clauses
5760 @cindex Representation clauses, records
5761 @unnumberedsec 13.5.1(17-22): Record Representation Clauses
5762 @sp 1
5763 @cartouche
5764 The recommended level of support for
5765 @*@code{record_representation_clauses} is:
5767 An implementation should support storage places that can be extracted
5768 with a load, mask, shift sequence of machine code, and set with a load,
5769 shift, mask, store sequence, given the available machine instructions
5770 and run-time model.
5771 @end cartouche
5772 Followed.
5774 @sp 1
5775 @cartouche
5776 A storage place should be supported if its size is equal to the
5777 @code{Size} of the component subtype, and it starts and ends on a
5778 boundary that obeys the @code{Alignment} of the component subtype.
5779 @end cartouche
5780 Followed.
5782 @sp 1
5783 @cartouche
5784 If the default bit ordering applies to the declaration of a given type,
5785 then for a component whose subtype's @code{Size} is less than the word
5786 size, any storage place that does not cross an aligned word boundary
5787 should be supported.
5788 @end cartouche
5789 Followed.
5791 @sp 1
5792 @cartouche
5793 An implementation may reserve a storage place for the tag field of a
5794 tagged type, and disallow other components from overlapping that place.
5795 @end cartouche
5796 Followed.  The storage place for the tag field is the beginning of the tagged
5797 record, and its size is Address'Size.  GNAT will reject an explicit component
5798 clause for the tag field.
5800 @sp 1
5801 @cartouche
5802 An implementation need not support a @code{component_clause} for a
5803 component of an extension part if the storage place is not after the
5804 storage places of all components of the parent type, whether or not
5805 those storage places had been specified.
5806 @end cartouche
5807 Followed.  The above advice on record representation clauses is followed,
5808 and all mentioned features are implemented.
5810 @cindex Storage place attributes
5811 @unnumberedsec 13.5.2(5): Storage Place Attributes
5812 @sp 1
5813 @cartouche
5814 If a component is represented using some form of pointer (such as an
5815 offset) to the actual data of the component, and this data is contiguous
5816 with the rest of the object, then the storage place attributes should
5817 reflect the place of the actual data, not the pointer.  If a component is
5818 allocated discontinuously from the rest of the object, then a warning
5819 should be generated upon reference to one of its storage place
5820 attributes.
5821 @end cartouche
5822 Followed.  There are no such components in GNAT@.
5824 @cindex Bit ordering
5825 @unnumberedsec 13.5.3(7-8): Bit Ordering
5826 @sp 1
5827 @cartouche
5828 The recommended level of support for the non-default bit ordering is:
5829 @end cartouche
5830 @sp 1
5831 @cartouche
5832 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
5833 should support the non-default bit ordering in addition to the default
5834 bit ordering.
5835 @end cartouche
5836 Followed.  Word size does not equal storage size in this implementation.
5837 Thus non-default bit ordering is not supported.
5839 @cindex @code{Address}, as private type
5840 @unnumberedsec 13.7(37): Address as Private
5841 @sp 1
5842 @cartouche
5843 @code{Address} should be of a private type.
5844 @end cartouche
5845 Followed.
5847 @cindex Operations, on @code{Address}
5848 @cindex @code{Address}, operations of
5849 @unnumberedsec 13.7.1(16): Address Operations
5850 @sp 1
5851 @cartouche
5852 Operations in @code{System} and its children should reflect the target
5853 environment semantics as closely as is reasonable.  For example, on most
5854 machines, it makes sense for address arithmetic to ``wrap around''.
5855 Operations that do not make sense should raise @code{Program_Error}.
5856 @end cartouche
5857 Followed.  Address arithmetic is modular arithmetic that wraps around.  No
5858 operation raises @code{Program_Error}, since all operations make sense.
5860 @cindex Unchecked conversion
5861 @unnumberedsec 13.9(14-17): Unchecked Conversion
5862 @sp 1
5863 @cartouche
5864 The @code{Size} of an array object should not include its bounds; hence,
5865 the bounds should not be part of the converted data.
5866 @end cartouche
5867 Followed.
5869 @sp 1
5870 @cartouche
5871 The implementation should not generate unnecessary run-time checks to
5872 ensure that the representation of @var{S} is a representation of the
5873 target type.  It should take advantage of the permission to return by
5874 reference when possible.  Restrictions on unchecked conversions should be
5875 avoided unless required by the target environment.
5876 @end cartouche
5877 Followed.  There are no restrictions on unchecked conversion.  A warning is
5878 generated if the source and target types do not have the same size since
5879 the semantics in this case may be target dependent.
5881 @sp 1
5882 @cartouche
5883 The recommended level of support for unchecked conversions is:
5884 @end cartouche
5885 @sp 1
5886 @cartouche
5887 Unchecked conversions should be supported and should be reversible in
5888 the cases where this clause defines the result.  To enable meaningful use
5889 of unchecked conversion, a contiguous representation should be used for
5890 elementary subtypes, for statically constrained array subtypes whose
5891 component subtype is one of the subtypes described in this paragraph,
5892 and for record subtypes without discriminants whose component subtypes
5893 are described in this paragraph.
5894 @end cartouche
5895 Followed.
5897 @cindex Heap usage, implicit
5898 @unnumberedsec 13.11(23-25): Implicit Heap Usage
5899 @sp 1
5900 @cartouche
5901 An implementation should document any cases in which it dynamically
5902 allocates heap storage for a purpose other than the evaluation of an
5903 allocator.
5904 @end cartouche
5905 Followed, the only other points at which heap storage is dynamically
5906 allocated are as follows:
5908 @itemize @bullet
5909 @item
5910 At initial elaboration time, to allocate dynamically sized global
5911 objects.
5913 @item
5914 To allocate space for a task when a task is created.
5916 @item
5917 To extend the secondary stack dynamically when needed.  The secondary
5918 stack is used for returning variable length results.
5919 @end itemize
5921 @sp 1
5922 @cartouche
5923 A default (implementation-provided) storage pool for an
5924 access-to-constant type should not have overhead to support deallocation of
5925 individual objects.
5926 @end cartouche
5927 Followed.
5929 @sp 1
5930 @cartouche
5931 A storage pool for an anonymous access type should be created at the
5932 point of an allocator for the type, and be reclaimed when the designated
5933 object becomes inaccessible.
5934 @end cartouche
5935 Followed.
5937 @cindex Unchecked deallocation
5938 @unnumberedsec 13.11.2(17): Unchecked De-allocation
5939 @sp 1
5940 @cartouche
5941 For a standard storage pool, @code{Free} should actually reclaim the
5942 storage.
5943 @end cartouche
5944 Followed.
5946 @cindex Stream oriented attributes
5947 @unnumberedsec 13.13.2(17): Stream Oriented Attributes
5948 @sp 1
5949 @cartouche
5950 If a stream element is the same size as a storage element, then the
5951 normal in-memory representation should be used by @code{Read} and
5952 @code{Write} for scalar objects.  Otherwise, @code{Read} and @code{Write}
5953 should use the smallest number of stream elements needed to represent
5954 all values in the base range of the scalar type.
5955 @end cartouche
5957 Followed.  By default, GNAT uses the interpretation suggested by AI-195,
5958 which specifies using the size of the first subtype.
5959 However, such an implementation is based on direct binary
5960 representations and is therefore target- and endianness-dependent.
5961 To address this issue, GNAT also supplies an alternate implementation
5962 of the stream attributes @code{Read} and @code{Write},
5963 which uses the target-independent XDR standard representation
5964 for scalar types.
5965 @cindex XDR representation
5966 @cindex @code{Read} attribute
5967 @cindex @code{Write} attribute
5968 @cindex Stream oriented attributes
5969 The XDR implementation is provided as an alternative body of the
5970 @code{System.Stream_Attributes} package, in the file
5971 @file{s-strxdr.adb} in the GNAT library.
5972 There is no @file{s-strxdr.ads} file.
5973 In order to install the XDR implementation, do the following:
5974 @enumerate
5975 @item Replace the default implementation of the
5976 @code{System.Stream_Attributes} package with the XDR implementation.
5977 For example on a Unix platform issue the commands:
5978 @smallexample
5979 $ mv s-stratt.adb s-strold.adb
5980 $ mv s-strxdr.adb s-stratt.adb
5981 @end smallexample
5983 @item
5984 Rebuild the GNAT run-time library as documented in the
5985 @cite{GNAT User's Guide}
5986 @end enumerate
5988 @unnumberedsec A.1(52): Names of Predefined Numeric Types
5989 @sp 1
5990 @cartouche
5991 If an implementation provides additional named predefined integer types,
5992 then the names should end with @samp{Integer} as in
5993 @samp{Long_Integer}.  If an implementation provides additional named
5994 predefined floating point types, then the names should end with
5995 @samp{Float} as in @samp{Long_Float}.
5996 @end cartouche
5997 Followed.
5999 @findex Ada.Characters.Handling
6000 @unnumberedsec A.3.2(49): @code{Ada.Characters.Handling}
6001 @sp 1
6002 @cartouche
6003 If an implementation provides a localized definition of @code{Character}
6004 or @code{Wide_Character}, then the effects of the subprograms in
6005 @code{Characters.Handling} should reflect the localizations.  See also
6006 3.5.2.
6007 @end cartouche
6008 Followed.  GNAT provides no such localized definitions.
6010 @cindex Bounded-length strings
6011 @unnumberedsec A.4.4(106): Bounded-Length String Handling
6012 @sp 1
6013 @cartouche
6014 Bounded string objects should not be implemented by implicit pointers
6015 and dynamic allocation.
6016 @end cartouche
6017 Followed.  No implicit pointers or dynamic allocation are used.
6019 @cindex Random number generation
6020 @unnumberedsec A.5.2(46-47): Random Number Generation
6021 @sp 1
6022 @cartouche
6023 Any storage associated with an object of type @code{Generator} should be
6024 reclaimed on exit from the scope of the object.
6025 @end cartouche
6026 Followed.
6028 @sp 1
6029 @cartouche
6030 If the generator period is sufficiently long in relation to the number
6031 of distinct initiator values, then each possible value of
6032 @code{Initiator} passed to @code{Reset} should initiate a sequence of
6033 random numbers that does not, in a practical sense, overlap the sequence
6034 initiated by any other value.  If this is not possible, then the mapping
6035 between initiator values and generator states should be a rapidly
6036 varying function of the initiator value.
6037 @end cartouche
6038 Followed.  The generator period is sufficiently long for the first
6039 condition here to hold true.
6041 @findex Get_Immediate
6042 @unnumberedsec A.10.7(23): @code{Get_Immediate}
6043 @sp 1
6044 @cartouche
6045 The @code{Get_Immediate} procedures should be implemented with
6046 unbuffered input.  For a device such as a keyboard, input should be
6047 @dfn{available} if a key has already been typed, whereas for a disk
6048 file, input should always be available except at end of file.  For a file
6049 associated with a keyboard-like device, any line-editing features of the
6050 underlying operating system should be disabled during the execution of
6051 @code{Get_Immediate}.
6052 @end cartouche
6053 Followed on all targets except VxWorks. For VxWorks, there is no way to
6054 provide this functionality that does not result in the input buffer being
6055 flushed before the @code{Get_Immediate} call. A special unit
6056 @code{Interfaces.Vxworks.IO} is provided that contains routines to enable
6057 this functionality.
6059 @findex Export
6060 @unnumberedsec B.1(39-41): Pragma @code{Export}
6061 @sp 1
6062 @cartouche
6063 If an implementation supports pragma @code{Export} to a given language,
6064 then it should also allow the main subprogram to be written in that
6065 language.  It should support some mechanism for invoking the elaboration
6066 of the Ada library units included in the system, and for invoking the
6067 finalization of the environment task.  On typical systems, the
6068 recommended mechanism is to provide two subprograms whose link names are
6069 @code{adainit} and @code{adafinal}.  @code{adainit} should contain the
6070 elaboration code for library units.  @code{adafinal} should contain the
6071 finalization code.  These subprograms should have no effect the second
6072 and subsequent time they are called.
6073 @end cartouche
6074 Followed.
6076 @sp 1
6077 @cartouche
6078 Automatic elaboration of pre-elaborated packages should be
6079 provided when pragma @code{Export} is supported.
6080 @end cartouche
6081 Followed when the main program is in Ada.  If the main program is in a
6082 foreign language, then
6083 @code{adainit} must be called to elaborate pre-elaborated
6084 packages.
6086 @sp 1
6087 @cartouche
6088 For each supported convention @var{L} other than @code{Intrinsic}, an
6089 implementation should support @code{Import} and @code{Export} pragmas
6090 for objects of @var{L}-compatible types and for subprograms, and pragma
6091 @code{Convention} for @var{L}-eligible types and for subprograms,
6092 presuming the other language has corresponding features.  Pragma
6093 @code{Convention} need not be supported for scalar types.
6094 @end cartouche
6095 Followed.
6097 @cindex Package @code{Interfaces}
6098 @findex Interfaces
6099 @unnumberedsec B.2(12-13): Package @code{Interfaces}
6100 @sp 1
6101 @cartouche
6102 For each implementation-defined convention identifier, there should be a
6103 child package of package Interfaces with the corresponding name.  This
6104 package should contain any declarations that would be useful for
6105 interfacing to the language (implementation) represented by the
6106 convention.  Any declarations useful for interfacing to any language on
6107 the given hardware architecture should be provided directly in
6108 @code{Interfaces}.
6109 @end cartouche
6110 Followed.  An additional package not defined
6111 in the Ada 95 Reference Manual is @code{Interfaces.CPP}, used
6112 for interfacing to C++.
6114 @sp 1
6115 @cartouche
6116 An implementation supporting an interface to C, COBOL, or Fortran should
6117 provide the corresponding package or packages described in the following
6118 clauses.
6119 @end cartouche
6120 Followed.  GNAT provides all the packages described in this section.
6122 @cindex C, interfacing with
6123 @unnumberedsec B.3(63-71): Interfacing with C
6124 @sp 1
6125 @cartouche
6126 An implementation should support the following interface correspondences
6127 between Ada and C@.
6128 @end cartouche
6129 Followed.
6131 @sp 1
6132 @cartouche
6133 An Ada procedure corresponds to a void-returning C function.
6134 @end cartouche
6135 Followed.
6137 @sp 1
6138 @cartouche
6139 An Ada function corresponds to a non-void C function.
6140 @end cartouche
6141 Followed.
6143 @sp 1
6144 @cartouche
6145 An Ada @code{in} scalar parameter is passed as a scalar argument to a C
6146 function.
6147 @end cartouche
6148 Followed.
6150 @sp 1
6151 @cartouche
6152 An Ada @code{in} parameter of an access-to-object type with designated
6153 type @var{T} is passed as a @code{@var{t}*} argument to a C function,
6154 where @var{t} is the C type corresponding to the Ada type @var{T}.
6155 @end cartouche
6156 Followed.
6158 @sp 1
6159 @cartouche
6160 An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
6161 parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
6162 argument to a C function, where @var{t} is the C type corresponding to
6163 the Ada type @var{T}.  In the case of an elementary @code{out} or
6164 @code{in out} parameter, a pointer to a temporary copy is used to
6165 preserve by-copy semantics.
6166 @end cartouche
6167 Followed.
6169 @sp 1
6170 @cartouche
6171 An Ada parameter of a record type @var{T}, of any mode, is passed as a
6172 @code{@var{t}*} argument to a C function, where @var{t} is the C
6173 structure corresponding to the Ada type @var{T}.
6174 @end cartouche
6175 Followed.  This convention may be overridden by the use of the C_Pass_By_Copy
6176 pragma, or Convention, or by explicitly specifying the mechanism for a given
6177 call using an extended import or export pragma.
6179 @sp 1
6180 @cartouche
6181 An Ada parameter of an array type with component type @var{T}, of any
6182 mode, is passed as a @code{@var{t}*} argument to a C function, where
6183 @var{t} is the C type corresponding to the Ada type @var{T}.
6184 @end cartouche
6185 Followed.
6187 @sp 1
6188 @cartouche
6189 An Ada parameter of an access-to-subprogram type is passed as a pointer
6190 to a C function whose prototype corresponds to the designated
6191 subprogram's specification.
6192 @end cartouche
6193 Followed.
6195 @cindex COBOL, interfacing with
6196 @unnumberedsec B.4(95-98): Interfacing with COBOL
6197 @sp 1
6198 @cartouche
6199 An Ada implementation should support the following interface
6200 correspondences between Ada and COBOL@.
6201 @end cartouche
6202 Followed.
6204 @sp 1
6205 @cartouche
6206 An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of
6207 the COBOL type corresponding to @var{T}.
6208 @end cartouche
6209 Followed.
6211 @sp 1
6212 @cartouche
6213 An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of
6214 the corresponding COBOL type.
6215 @end cartouche
6216 Followed.
6218 @sp 1
6219 @cartouche
6220 Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the
6221 COBOL type corresponding to the Ada parameter type; for scalars, a local
6222 copy is used if necessary to ensure by-copy semantics.
6223 @end cartouche
6224 Followed.
6226 @cindex Fortran, interfacing with
6227 @unnumberedsec B.5(22-26): Interfacing with Fortran
6228 @sp 1
6229 @cartouche
6230 An Ada implementation should support the following interface
6231 correspondences between Ada and Fortran:
6232 @end cartouche
6233 Followed.
6235 @sp 1
6236 @cartouche
6237 An Ada procedure corresponds to a Fortran subroutine.
6238 @end cartouche
6239 Followed.
6241 @sp 1
6242 @cartouche
6243 An Ada function corresponds to a Fortran function.
6244 @end cartouche
6245 Followed.
6247 @sp 1
6248 @cartouche
6249 An Ada parameter of an elementary, array, or record type @var{T} is
6250 passed as a @var{T} argument to a Fortran procedure, where @var{T} is
6251 the Fortran type corresponding to the Ada type @var{T}, and where the
6252 INTENT attribute of the corresponding dummy argument matches the Ada
6253 formal parameter mode; the Fortran implementation's parameter passing
6254 conventions are used.  For elementary types, a local copy is used if
6255 necessary to ensure by-copy semantics.
6256 @end cartouche
6257 Followed.
6259 @sp 1
6260 @cartouche
6261 An Ada parameter of an access-to-subprogram type is passed as a
6262 reference to a Fortran procedure whose interface corresponds to the
6263 designated subprogram's specification.
6264 @end cartouche
6265 Followed.
6267 @cindex Machine operations
6268 @unnumberedsec C.1(3-5): Access to Machine Operations
6269 @sp 1
6270 @cartouche
6271 The machine code or intrinsic support should allow access to all
6272 operations normally available to assembly language programmers for the
6273 target environment, including privileged instructions, if any.
6274 @end cartouche
6275 Followed.
6277 @sp 1
6278 @cartouche
6279 The interfacing pragmas (see Annex B) should support interface to
6280 assembler; the default assembler should be associated with the
6281 convention identifier @code{Assembler}.
6282 @end cartouche
6283 Followed.
6285 @sp 1
6286 @cartouche
6287 If an entity is exported to assembly language, then the implementation
6288 should allocate it at an addressable location, and should ensure that it
6289 is retained by the linking process, even if not otherwise referenced
6290 from the Ada code.  The implementation should assume that any call to a
6291 machine code or assembler subprogram is allowed to read or update every
6292 object that is specified as exported.
6293 @end cartouche
6294 Followed.
6296 @unnumberedsec C.1(10-16): Access to Machine Operations
6297 @sp 1
6298 @cartouche
6299 The implementation should ensure that little or no overhead is
6300 associated with calling intrinsic and machine-code subprograms.
6301 @end cartouche
6302 Followed for both intrinsics and machine-code subprograms.
6304 @sp 1
6305 @cartouche
6306 It is recommended that intrinsic subprograms be provided for convenient
6307 access to any machine operations that provide special capabilities or
6308 efficiency and that are not otherwise available through the language
6309 constructs.
6310 @end cartouche
6311 Followed.  A full set of machine operation intrinsic subprograms is provided.
6313 @sp 1
6314 @cartouche
6315 Atomic read-modify-write operations---e.g.@:, test and set, compare and
6316 swap, decrement and test, enqueue/dequeue.
6317 @end cartouche
6318 Followed on any target supporting such operations.
6320 @sp 1
6321 @cartouche
6322 Standard numeric functions---e.g.@:, sin, log.
6323 @end cartouche
6324 Followed on any target supporting such operations.
6326 @sp 1
6327 @cartouche
6328 String manipulation operations---e.g.@:, translate and test.
6329 @end cartouche
6330 Followed on any target supporting such operations.
6332 @sp 1
6333 @cartouche
6334 Vector operations---e.g.@:, compare vector against thresholds.
6335 @end cartouche
6336 Followed on any target supporting such operations.
6338 @sp 1
6339 @cartouche
6340 Direct operations on I/O ports.
6341 @end cartouche
6342 Followed on any target supporting such operations.
6344 @cindex Interrupt support
6345 @unnumberedsec C.3(28): Interrupt Support
6346 @sp 1
6347 @cartouche
6348 If the @code{Ceiling_Locking} policy is not in effect, the
6349 implementation should provide means for the application to specify which
6350 interrupts are to be blocked during protected actions, if the underlying
6351 system allows for a finer-grain control of interrupt blocking.
6352 @end cartouche
6353 Followed.  The underlying system does not allow for finer-grain control
6354 of interrupt blocking.
6356 @cindex Protected procedure handlers
6357 @unnumberedsec C.3.1(20-21): Protected Procedure Handlers
6358 @sp 1
6359 @cartouche
6360 Whenever possible, the implementation should allow interrupt handlers to
6361 be called directly by the hardware.
6362 @end cartouche
6363 @c SGI info:
6364 @ignore
6365 This is never possible under IRIX, so this is followed by default.
6366 @end ignore
6367 Followed on any target where the underlying operating system permits
6368 such direct calls.
6370 @sp 1
6371 @cartouche
6372 Whenever practical, violations of any
6373 implementation-defined restrictions should be detected before run time.
6374 @end cartouche
6375 Followed.  Compile time warnings are given when possible.
6377 @cindex Package @code{Interrupts}
6378 @findex Interrupts
6379 @unnumberedsec C.3.2(25): Package @code{Interrupts}
6381 @sp 1
6382 @cartouche
6383 If implementation-defined forms of interrupt handler procedures are
6384 supported, such as protected procedures with parameters, then for each
6385 such form of a handler, a type analogous to @code{Parameterless_Handler}
6386 should be specified in a child package of @code{Interrupts}, with the
6387 same operations as in the predefined package Interrupts.
6388 @end cartouche
6389 Followed.
6391 @cindex Pre-elaboration requirements
6392 @unnumberedsec C.4(14): Pre-elaboration Requirements
6393 @sp 1
6394 @cartouche
6395 It is recommended that pre-elaborated packages be implemented in such a
6396 way that there should be little or no code executed at run time for the
6397 elaboration of entities not already covered by the Implementation
6398 Requirements.
6399 @end cartouche
6400 Followed.  Executable code is generated in some cases, e.g.@: loops
6401 to initialize large arrays.
6403 @unnumberedsec C.5(8): Pragma @code{Discard_Names}
6405 @sp 1
6406 @cartouche
6407 If the pragma applies to an entity, then the implementation should
6408 reduce the amount of storage used for storing names associated with that
6409 entity.
6410 @end cartouche
6411 Followed.
6413 @cindex Package @code{Task_Attributes}
6414 @findex Task_Attributes
6415 @unnumberedsec C.7.2(30): The Package Task_Attributes
6416 @sp 1
6417 @cartouche
6418 Some implementations are targeted to domains in which memory use at run
6419 time must be completely deterministic.  For such implementations, it is
6420 recommended that the storage for task attributes will be pre-allocated
6421 statically and not from the heap.  This can be accomplished by either
6422 placing restrictions on the number and the size of the task's
6423 attributes, or by using the pre-allocated storage for the first @var{N}
6424 attribute objects, and the heap for the others.  In the latter case,
6425 @var{N} should be documented.
6426 @end cartouche
6427 Not followed.  This implementation is not targeted to such a domain.
6429 @cindex Locking Policies
6430 @unnumberedsec D.3(17): Locking Policies
6432 @sp 1
6433 @cartouche
6434 The implementation should use names that end with @samp{_Locking} for
6435 locking policies defined by the implementation.
6436 @end cartouche
6437 Followed.  A single implementation-defined locking policy is defined,
6438 whose name (@code{Inheritance_Locking}) follows this suggestion.
6440 @cindex Entry queuing policies
6441 @unnumberedsec D.4(16): Entry Queuing Policies
6442 @sp 1
6443 @cartouche
6444 Names that end with @samp{_Queuing} should be used
6445 for all implementation-defined queuing policies.
6446 @end cartouche
6447 Followed.  No such implementation-defined queuing policies exist.
6449 @cindex Preemptive abort
6450 @unnumberedsec D.6(9-10): Preemptive Abort
6451 @sp 1
6452 @cartouche
6453 Even though the @code{abort_statement} is included in the list of
6454 potentially blocking operations (see 9.5.1), it is recommended that this
6455 statement be implemented in a way that never requires the task executing
6456 the @code{abort_statement} to block.
6457 @end cartouche
6458 Followed.
6460 @sp 1
6461 @cartouche
6462 On a multi-processor, the delay associated with aborting a task on
6463 another processor should be bounded; the implementation should use
6464 periodic polling, if necessary, to achieve this.
6465 @end cartouche
6466 Followed.
6468 @cindex Tasking restrictions
6469 @unnumberedsec D.7(21): Tasking Restrictions
6470 @sp 1
6471 @cartouche
6472 When feasible, the implementation should take advantage of the specified
6473 restrictions to produce a more efficient implementation.
6474 @end cartouche
6475 GNAT currently takes advantage of these restrictions by providing an optimized
6476 run time when the Ravenscar profile and the GNAT restricted run time set
6477 of restrictions are specified.  See pragma @code{Profile (Ravenscar)} and
6478 pragma @code{Profile (Restricted)} for more details.
6480 @cindex Time, monotonic
6481 @unnumberedsec D.8(47-49): Monotonic Time
6482 @sp 1
6483 @cartouche
6484 When appropriate, implementations should provide configuration
6485 mechanisms to change the value of @code{Tick}.
6486 @end cartouche
6487 Such configuration mechanisms are not appropriate to this implementation
6488 and are thus not supported.
6490 @sp 1
6491 @cartouche
6492 It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
6493 be implemented as transformations of the same time base.
6494 @end cartouche
6495 Followed.
6497 @sp 1
6498 @cartouche
6499 It is recommended that the @dfn{best} time base which exists in
6500 the underlying system be available to the application through
6501 @code{Clock}.  @dfn{Best} may mean highest accuracy or largest range.
6502 @end cartouche
6503 Followed.
6505 @cindex Partition communication subsystem
6506 @cindex PCS
6507 @unnumberedsec E.5(28-29): Partition Communication Subsystem
6508 @sp 1
6509 @cartouche
6510 Whenever possible, the PCS on the called partition should allow for
6511 multiple tasks to call the RPC-receiver with different messages and
6512 should allow them to block until the corresponding subprogram body
6513 returns.
6514 @end cartouche
6515 Followed by GLADE, a separately supplied PCS that can be used with
6516 GNAT.
6518 @sp 1
6519 @cartouche
6520 The @code{Write} operation on a stream of type @code{Params_Stream_Type}
6521 should raise @code{Storage_Error} if it runs out of space trying to
6522 write the @code{Item} into the stream.
6523 @end cartouche
6524 Followed by GLADE, a separately supplied PCS that can be used with
6525 GNAT@.
6527 @cindex COBOL support
6528 @unnumberedsec F(7): COBOL Support
6529 @sp 1
6530 @cartouche
6531 If COBOL (respectively, C) is widely supported in the target
6532 environment, implementations supporting the Information Systems Annex
6533 should provide the child package @code{Interfaces.COBOL} (respectively,
6534 @code{Interfaces.C}) specified in Annex B and should support a
6535 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
6536 pragmas (see Annex B), thus allowing Ada programs to interface with
6537 programs written in that language.
6538 @end cartouche
6539 Followed.
6541 @cindex Decimal radix support
6542 @unnumberedsec F.1(2): Decimal Radix Support
6543 @sp 1
6544 @cartouche
6545 Packed decimal should be used as the internal representation for objects
6546 of subtype @var{S} when @var{S}'Machine_Radix = 10.
6547 @end cartouche
6548 Not followed.  GNAT ignores @var{S}'Machine_Radix and always uses binary
6549 representations.
6551 @cindex Numerics
6552 @unnumberedsec G: Numerics
6553 @sp 2
6554 @cartouche
6555 If Fortran (respectively, C) is widely supported in the target
6556 environment, implementations supporting the Numerics Annex
6557 should provide the child package @code{Interfaces.Fortran} (respectively,
6558 @code{Interfaces.C}) specified in Annex B and should support a
6559 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
6560 pragmas (see Annex B), thus allowing Ada programs to interface with
6561 programs written in that language.
6562 @end cartouche
6563 Followed.
6565 @cindex Complex types
6566 @unnumberedsec G.1.1(56-58): Complex Types
6567 @sp 2
6568 @cartouche
6569 Because the usual mathematical meaning of multiplication of a complex
6570 operand and a real operand is that of the scaling of both components of
6571 the former by the latter, an implementation should not perform this
6572 operation by first promoting the real operand to complex type and then
6573 performing a full complex multiplication.  In systems that, in the
6574 future, support an Ada binding to IEC 559:1989, the latter technique
6575 will not generate the required result when one of the components of the
6576 complex operand is infinite.  (Explicit multiplication of the infinite
6577 component by the zero component obtained during promotion yields a NaN
6578 that propagates into the final result.) Analogous advice applies in the
6579 case of multiplication of a complex operand and a pure-imaginary
6580 operand, and in the case of division of a complex operand by a real or
6581 pure-imaginary operand.
6582 @end cartouche
6583 Not followed.
6585 @sp 1
6586 @cartouche
6587 Similarly, because the usual mathematical meaning of addition of a
6588 complex operand and a real operand is that the imaginary operand remains
6589 unchanged, an implementation should not perform this operation by first
6590 promoting the real operand to complex type and then performing a full
6591 complex addition.  In implementations in which the @code{Signed_Zeros}
6592 attribute of the component type is @code{True} (and which therefore
6593 conform to IEC 559:1989 in regard to the handling of the sign of zero in
6594 predefined arithmetic operations), the latter technique will not
6595 generate the required result when the imaginary component of the complex
6596 operand is a negatively signed zero.  (Explicit addition of the negative
6597 zero to the zero obtained during promotion yields a positive zero.)
6598 Analogous advice applies in the case of addition of a complex operand
6599 and a pure-imaginary operand, and in the case of subtraction of a
6600 complex operand and a real or pure-imaginary operand.
6601 @end cartouche
6602 Not followed.
6604 @sp 1
6605 @cartouche
6606 Implementations in which @code{Real'Signed_Zeros} is @code{True} should
6607 attempt to provide a rational treatment of the signs of zero results and
6608 result components.  As one example, the result of the @code{Argument}
6609 function should have the sign of the imaginary component of the
6610 parameter @code{X} when the point represented by that parameter lies on
6611 the positive real axis; as another, the sign of the imaginary component
6612 of the @code{Compose_From_Polar} function should be the same as
6613 (respectively, the opposite of) that of the @code{Argument} parameter when that
6614 parameter has a value of zero and the @code{Modulus} parameter has a
6615 nonnegative (respectively, negative) value.
6616 @end cartouche
6617 Followed.
6619 @cindex Complex elementary functions
6620 @unnumberedsec G.1.2(49): Complex Elementary Functions
6621 @sp 1
6622 @cartouche
6623 Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
6624 @code{True} should attempt to provide a rational treatment of the signs
6625 of zero results and result components.  For example, many of the complex
6626 elementary functions have components that are odd functions of one of
6627 the parameter components; in these cases, the result component should
6628 have the sign of the parameter component at the origin.  Other complex
6629 elementary functions have zero components whose sign is opposite that of
6630 a parameter component at the origin, or is always positive or always
6631 negative.
6632 @end cartouche
6633 Followed.
6635 @cindex Accuracy requirements
6636 @unnumberedsec G.2.4(19): Accuracy Requirements
6637 @sp 1
6638 @cartouche
6639 The versions of the forward trigonometric functions without a
6640 @code{Cycle} parameter should not be implemented by calling the
6641 corresponding version with a @code{Cycle} parameter of
6642 @code{2.0*Numerics.Pi}, since this will not provide the required
6643 accuracy in some portions of the domain.  For the same reason, the
6644 version of @code{Log} without a @code{Base} parameter should not be
6645 implemented by calling the corresponding version with a @code{Base}
6646 parameter of @code{Numerics.e}.
6647 @end cartouche
6648 Followed.
6650 @cindex Complex arithmetic accuracy
6651 @cindex Accuracy, complex arithmetic
6652 @unnumberedsec G.2.6(15): Complex Arithmetic Accuracy
6654 @sp 1
6655 @cartouche
6656 The version of the @code{Compose_From_Polar} function without a
6657 @code{Cycle} parameter should not be implemented by calling the
6658 corresponding version with a @code{Cycle} parameter of
6659 @code{2.0*Numerics.Pi}, since this will not provide the required
6660 accuracy in some portions of the domain.
6661 @end cartouche
6662 Followed.
6664 @c -----------------------------------------
6665 @node Implementation Defined Characteristics
6666 @chapter Implementation Defined Characteristics
6668 @noindent
6669 In addition to the implementation dependent pragmas and attributes, and
6670 the implementation advice, there are a number of other features of Ada
6671 95 that are potentially implementation dependent.  These are mentioned
6672 throughout the Ada 95 Reference Manual, and are summarized in annex M@.
6674 A requirement for conforming Ada compilers is that they provide
6675 documentation describing how the implementation deals with each of these
6676 issues.  In this chapter, you will find each point in annex M listed
6677 followed by a description in italic font of how GNAT
6678 @c SGI info:
6679 @ignore
6680 in the ProDev Ada
6681 implementation on IRIX 5.3 operating system or greater
6682 @end ignore
6683 handles the implementation dependence.
6685 You can use this chapter as a guide to minimizing implementation
6686 dependent features in your programs if portability to other compilers
6687 and other operating systems is an important consideration.  The numbers
6688 in each section below correspond to the paragraph number in the Ada 95
6689 Reference Manual.
6691 @sp 1
6692 @cartouche
6693 @noindent
6694 @strong{2}.  Whether or not each recommendation given in Implementation
6695 Advice is followed.  See 1.1.2(37).
6696 @end cartouche
6697 @noindent
6698 @xref{Implementation Advice}.
6700 @sp 1
6701 @cartouche
6702 @noindent
6703 @strong{3}.  Capacity limitations of the implementation.  See 1.1.3(3).
6704 @end cartouche
6705 @noindent
6706 The complexity of programs that can be processed is limited only by the
6707 total amount of available virtual memory, and disk space for the
6708 generated object files.
6710 @sp 1
6711 @cartouche
6712 @noindent
6713 @strong{4}.  Variations from the standard that are impractical to avoid
6714 given the implementation's execution environment.  See 1.1.3(6).
6715 @end cartouche
6716 @noindent
6717 There are no variations from the standard.
6719 @sp 1
6720 @cartouche
6721 @noindent
6722 @strong{5}.  Which @code{code_statement}s cause external
6723 interactions.  See 1.1.3(10).
6724 @end cartouche
6725 @noindent
6726 Any @code{code_statement} can potentially cause external interactions.
6728 @sp 1
6729 @cartouche
6730 @noindent
6731 @strong{6}.  The coded representation for the text of an Ada
6732 program.  See 2.1(4).
6733 @end cartouche
6734 @noindent
6735 See separate section on source representation.
6737 @sp 1
6738 @cartouche
6739 @noindent
6740 @strong{7}.  The control functions allowed in comments.  See 2.1(14).
6741 @end cartouche
6742 @noindent
6743 See separate section on source representation.
6745 @sp 1
6746 @cartouche
6747 @noindent
6748 @strong{8}.  The representation for an end of line.  See 2.2(2).
6749 @end cartouche
6750 @noindent
6751 See separate section on source representation.
6753 @sp 1
6754 @cartouche
6755 @noindent
6756 @strong{9}.  Maximum supported line length and lexical element
6757 length.  See 2.2(15).
6758 @end cartouche
6759 @noindent
6760 The maximum line length is 255 characters an the maximum length of a
6761 lexical element is also 255 characters.
6763 @sp 1
6764 @cartouche
6765 @noindent
6766 @strong{10}.  Implementation defined pragmas.  See 2.8(14).
6767 @end cartouche
6768 @noindent
6770 @xref{Implementation Defined Pragmas}.
6772 @sp 1
6773 @cartouche
6774 @noindent
6775 @strong{11}.  Effect of pragma @code{Optimize}.  See 2.8(27).
6776 @end cartouche
6777 @noindent
6778 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
6779 parameter, checks that the optimization flag is set, and aborts if it is
6780 not.
6782 @sp 1
6783 @cartouche
6784 @noindent
6785 @strong{12}.  The sequence of characters of the value returned by
6786 @code{@var{S}'Image} when some of the graphic characters of
6787 @code{@var{S}'Wide_Image} are not defined in @code{Character}.  See
6788 3.5(37).
6789 @end cartouche
6790 @noindent
6791 The sequence of characters is as defined by the wide character encoding
6792 method used for the source.  See section on source representation for
6793 further details.
6795 @sp 1
6796 @cartouche
6797 @noindent
6798 @strong{13}.  The predefined integer types declared in
6799 @code{Standard}.  See 3.5.4(25).
6800 @end cartouche
6801 @noindent
6802 @table @code
6803 @item Short_Short_Integer
6804 8 bit signed
6805 @item Short_Integer
6806 (Short) 16 bit signed
6807 @item Integer
6808 32 bit signed
6809 @item Long_Integer
6810 64 bit signed (Alpha OpenVMS only)
6811 32 bit signed (all other targets)
6812 @item Long_Long_Integer
6813 64 bit signed
6814 @end table
6816 @sp 1
6817 @cartouche
6818 @noindent
6819 @strong{14}.  Any nonstandard integer types and the operators defined
6820 for them.  See 3.5.4(26).
6821 @end cartouche
6822 @noindent
6823 There are no nonstandard integer types.
6825 @sp 1
6826 @cartouche
6827 @noindent
6828 @strong{15}.  Any nonstandard real types and the operators defined for
6829 them.  See 3.5.6(8).
6830 @end cartouche
6831 @noindent
6832 There are no nonstandard real types.
6834 @sp 1
6835 @cartouche
6836 @noindent
6837 @strong{16}.  What combinations of requested decimal precision and range
6838 are supported for floating point types.  See 3.5.7(7).
6839 @end cartouche
6840 @noindent
6841 The precision and range is as defined by the IEEE standard.
6843 @sp 1
6844 @cartouche
6845 @noindent
6846 @strong{17}.  The predefined floating point types declared in
6847 @code{Standard}.  See 3.5.7(16).
6848 @end cartouche
6849 @noindent
6850 @table @code
6851 @item Short_Float
6852 32 bit IEEE short
6853 @item Float
6854 (Short) 32 bit IEEE short
6855 @item Long_Float
6856 64 bit IEEE long
6857 @item Long_Long_Float
6858 64 bit IEEE long (80 bit IEEE long on x86 processors)
6859 @end table
6861 @sp 1
6862 @cartouche
6863 @noindent
6864 @strong{18}.  The small of an ordinary fixed point type.  See 3.5.9(8).
6865 @end cartouche
6866 @noindent
6867 @code{Fine_Delta} is 2**(@minus{}63)
6869 @sp 1
6870 @cartouche
6871 @noindent
6872 @strong{19}.  What combinations of small, range, and digits are
6873 supported for fixed point types.  See 3.5.9(10).
6874 @end cartouche
6875 @noindent
6876 Any combinations are permitted that do not result in a small less than
6877 @code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
6878 If the mantissa is larger than 53 bits on machines where Long_Long_Float
6879 is 64 bits (true of all architectures except ia32), then the output from
6880 Text_IO is accurate to only 53 bits, rather than the full mantissa.  This
6881 is because floating-point conversions are used to convert fixed point.
6883 @sp 1
6884 @cartouche
6885 @noindent
6886 @strong{20}.  The result of @code{Tags.Expanded_Name} for types declared
6887 within an unnamed @code{block_statement}.  See 3.9(10).
6888 @end cartouche
6889 @noindent
6890 Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
6891 decimal integer are allocated.
6893 @sp 1
6894 @cartouche
6895 @noindent
6896 @strong{21}.  Implementation-defined attributes.  See 4.1.4(12).
6897 @end cartouche
6898 @noindent
6899 @xref{Implementation Defined Attributes}.
6901 @sp 1
6902 @cartouche
6903 @noindent
6904 @strong{22}.  Any implementation-defined time types.  See 9.6(6).
6905 @end cartouche
6906 @noindent
6907 There are no implementation-defined time types.
6909 @sp 1
6910 @cartouche
6911 @noindent
6912 @strong{23}.  The time base associated with relative delays.
6913 @end cartouche
6914 @noindent
6915 See 9.6(20).  The time base used is that provided by the C library
6916 function @code{gettimeofday}.
6918 @sp 1
6919 @cartouche
6920 @noindent
6921 @strong{24}.  The time base of the type @code{Calendar.Time}.  See
6922 9.6(23).
6923 @end cartouche
6924 @noindent
6925 The time base used is that provided by the C library function
6926 @code{gettimeofday}.
6928 @sp 1
6929 @cartouche
6930 @noindent
6931 @strong{25}.  The time zone used for package @code{Calendar}
6932 operations.  See 9.6(24).
6933 @end cartouche
6934 @noindent
6935 The time zone used by package @code{Calendar} is the current system time zone
6936 setting for local time, as accessed by the C library function
6937 @code{localtime}.
6939 @sp 1
6940 @cartouche
6941 @noindent
6942 @strong{26}.  Any limit on @code{delay_until_statements} of
6943 @code{select_statements}.  See 9.6(29).
6944 @end cartouche
6945 @noindent
6946 There are no such limits.
6948 @sp 1
6949 @cartouche
6950 @noindent
6951 @strong{27}.  Whether or not two non overlapping parts of a composite
6952 object are independently addressable, in the case where packing, record
6953 layout, or @code{Component_Size} is specified for the object.  See
6954 9.10(1).
6955 @end cartouche
6956 @noindent
6957 Separate components are independently addressable if they do not share
6958 overlapping storage units.
6960 @sp 1
6961 @cartouche
6962 @noindent
6963 @strong{28}.  The representation for a compilation.  See 10.1(2).
6964 @end cartouche
6965 @noindent
6966 A compilation is represented by a sequence of files presented to the
6967 compiler in a single invocation of the @code{gcc} command.
6969 @sp 1
6970 @cartouche
6971 @noindent
6972 @strong{29}.  Any restrictions on compilations that contain multiple
6973 compilation_units.  See 10.1(4).
6974 @end cartouche
6975 @noindent
6976 No single file can contain more than one compilation unit, but any
6977 sequence of files can be presented to the compiler as a single
6978 compilation.
6980 @sp 1
6981 @cartouche
6982 @noindent
6983 @strong{30}.  The mechanisms for creating an environment and for adding
6984 and replacing compilation units.  See 10.1.4(3).
6985 @end cartouche
6986 @noindent
6987 See separate section on compilation model.
6989 @sp 1
6990 @cartouche
6991 @noindent
6992 @strong{31}.  The manner of explicitly assigning library units to a
6993 partition.  See 10.2(2).
6994 @end cartouche
6995 @noindent
6996 If a unit contains an Ada main program, then the Ada units for the partition
6997 are determined by recursive application of the rules in the Ada Reference
6998 Manual section 10.2(2-6).  In other words, the Ada units will be those that
6999 are needed by the main program, and then this definition of need is applied
7000 recursively to those units, and the partition contains the transitive
7001 closure determined by this relationship.  In short, all the necessary units
7002 are included, with no need to explicitly specify the list.  If additional
7003 units are required, e.g.@: by foreign language units, then all units must be
7004 mentioned in the context clause of one of the needed Ada units.
7006 If the partition contains no main program, or if the main program is in
7007 a language other than Ada, then GNAT
7008 provides the binder options @code{-z} and @code{-n} respectively, and in
7009 this case a list of units can be explicitly supplied to the binder for
7010 inclusion in the partition (all units needed by these units will also
7011 be included automatically).  For full details on the use of these
7012 options, refer to the @cite{GNAT User's Guide} sections on Binding
7013 and Linking.
7015 @sp 1
7016 @cartouche
7017 @noindent
7018 @strong{32}.  The implementation-defined means, if any, of specifying
7019 which compilation units are needed by a given compilation unit.  See
7020 10.2(2).
7021 @end cartouche
7022 @noindent
7023 The units needed by a given compilation unit are as defined in
7024 the Ada Reference Manual section 10.2(2-6).  There are no
7025 implementation-defined pragmas or other implementation-defined
7026 means for specifying needed units.
7028 @sp 1
7029 @cartouche
7030 @noindent
7031 @strong{33}.  The manner of designating the main subprogram of a
7032 partition.  See 10.2(7).
7033 @end cartouche
7034 @noindent
7035 The main program is designated by providing the name of the
7036 corresponding @file{ALI} file as the input parameter to the binder.
7038 @sp 1
7039 @cartouche
7040 @noindent
7041 @strong{34}.  The order of elaboration of @code{library_items}.  See
7042 10.2(18).
7043 @end cartouche
7044 @noindent
7045 The first constraint on ordering is that it meets the requirements of
7046 chapter 10 of the Ada 95 Reference Manual.  This still leaves some
7047 implementation dependent choices, which are resolved by first
7048 elaborating bodies as early as possible (i.e.@: in preference to specs
7049 where there is a choice), and second by evaluating the immediate with
7050 clauses of a unit to determine the probably best choice, and
7051 third by elaborating in alphabetical order of unit names
7052 where a choice still remains.
7054 @sp 1
7055 @cartouche
7056 @noindent
7057 @strong{35}.  Parameter passing and function return for the main
7058 subprogram.  See 10.2(21).
7059 @end cartouche
7060 @noindent
7061 The main program has no parameters.  It may be a procedure, or a function
7062 returning an integer type.  In the latter case, the returned integer
7063 value is the return code of the program (overriding any value that
7064 may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
7066 @sp 1
7067 @cartouche
7068 @noindent
7069 @strong{36}.  The mechanisms for building and running partitions.  See
7070 10.2(24).
7071 @end cartouche
7072 @noindent
7073 GNAT itself supports programs with only a single partition.  The GNATDIST
7074 tool provided with the GLADE package (which also includes an implementation
7075 of the PCS) provides a completely flexible method for building and running
7076 programs consisting of multiple partitions.  See the separate GLADE manual
7077 for details.
7079 @sp 1
7080 @cartouche
7081 @noindent
7082 @strong{37}.  The details of program execution, including program
7083 termination.  See 10.2(25).
7084 @end cartouche
7085 @noindent
7086 See separate section on compilation model.
7088 @sp 1
7089 @cartouche
7090 @noindent
7091 @strong{38}.  The semantics of any non-active partitions supported by the
7092 implementation.  See 10.2(28).
7093 @end cartouche
7094 @noindent
7095 Passive partitions are supported on targets where shared memory is
7096 provided by the operating system.  See the GLADE reference manual for
7097 further details.
7099 @sp 1
7100 @cartouche
7101 @noindent
7102 @strong{39}.  The information returned by @code{Exception_Message}.  See
7103 11.4.1(10).
7104 @end cartouche
7105 @noindent
7106 Exception message returns the null string unless a specific message has
7107 been passed by the program.
7109 @sp 1
7110 @cartouche
7111 @noindent
7112 @strong{40}.  The result of @code{Exceptions.Exception_Name} for types
7113 declared within an unnamed @code{block_statement}.  See 11.4.1(12).
7114 @end cartouche
7115 @noindent
7116 Blocks have implementation defined names of the form @code{B@var{nnn}}
7117 where @var{nnn} is an integer.
7119 @sp 1
7120 @cartouche
7121 @noindent
7122 @strong{41}.  The information returned by
7123 @code{Exception_Information}.  See 11.4.1(13).
7124 @end cartouche
7125 @noindent
7126 @code{Exception_Information} returns a string in the following format:
7128 @smallexample
7129 @emph{Exception_Name:} nnnnn
7130 @emph{Message:} mmmmm
7131 @emph{PID:} ppp
7132 @emph{Call stack traceback locations:}
7133 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
7134 @end smallexample
7136 @noindent
7137 where
7139 @itemize @bullet
7140 @item
7141 @code{nnnn} is the fully qualified name of the exception in all upper
7142 case letters. This line is always present.
7144 @item
7145 @code{mmmm} is the message (this line present only if message is non-null)
7147 @item
7148 @code{ppp} is the Process Id value as a decimal integer (this line is
7149 present only if the Process Id is nonzero). Currently we are
7150 not making use of this field.
7152 @item
7153 The Call stack traceback locations line and the following values
7154 are present only if at least one traceback location was recorded.
7155 The values are given in C style format, with lower case letters
7156 for a-f, and only as many digits present as are necessary.
7157 @end itemize
7159 @noindent
7160 The line terminator sequence at the end of each line, including
7161 the last line is a single @code{LF} character (@code{16#0A#}).
7163 @sp 1
7164 @cartouche
7165 @noindent
7166 @strong{42}.  Implementation-defined check names.  See 11.5(27).
7167 @end cartouche
7168 @noindent
7169 No implementation-defined check names are supported.
7171 @sp 1
7172 @cartouche
7173 @noindent
7174 @strong{43}.  The interpretation of each aspect of representation.  See
7175 13.1(20).
7176 @end cartouche
7177 @noindent
7178 See separate section on data representations.
7180 @sp 1
7181 @cartouche
7182 @noindent
7183 @strong{44}.  Any restrictions placed upon representation items.  See
7184 13.1(20).
7185 @end cartouche
7186 @noindent
7187 See separate section on data representations.
7189 @sp 1
7190 @cartouche
7191 @noindent
7192 @strong{45}.  The meaning of @code{Size} for indefinite subtypes.  See
7193 13.3(48).
7194 @end cartouche
7195 @noindent
7196 Size for an indefinite subtype is the maximum possible size, except that
7197 for the case of a subprogram parameter, the size of the parameter object
7198 is the actual size.
7200 @sp 1
7201 @cartouche
7202 @noindent
7203 @strong{46}.  The default external representation for a type tag.  See
7204 13.3(75).
7205 @end cartouche
7206 @noindent
7207 The default external representation for a type tag is the fully expanded
7208 name of the type in upper case letters.
7210 @sp 1
7211 @cartouche
7212 @noindent
7213 @strong{47}.  What determines whether a compilation unit is the same in
7214 two different partitions.  See 13.3(76).
7215 @end cartouche
7216 @noindent
7217 A compilation unit is the same in two different partitions if and only
7218 if it derives from the same source file.
7220 @sp 1
7221 @cartouche
7222 @noindent
7223 @strong{48}.  Implementation-defined components.  See 13.5.1(15).
7224 @end cartouche
7225 @noindent
7226 The only implementation defined component is the tag for a tagged type,
7227 which contains a pointer to the dispatching table.
7229 @sp 1
7230 @cartouche
7231 @noindent
7232 @strong{49}.  If @code{Word_Size} = @code{Storage_Unit}, the default bit
7233 ordering.  See 13.5.3(5).
7234 @end cartouche
7235 @noindent
7236 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
7237 implementation, so no non-default bit ordering is supported.  The default
7238 bit ordering corresponds to the natural endianness of the target architecture.
7240 @sp 1
7241 @cartouche
7242 @noindent
7243 @strong{50}.  The contents of the visible part of package @code{System}
7244 and its language-defined children.  See 13.7(2).
7245 @end cartouche
7246 @noindent
7247 See the definition of these packages in files @file{system.ads} and
7248 @file{s-stoele.ads}.
7250 @sp 1
7251 @cartouche
7252 @noindent
7253 @strong{51}.  The contents of the visible part of package
7254 @code{System.Machine_Code}, and the meaning of
7255 @code{code_statements}.  See 13.8(7).
7256 @end cartouche
7257 @noindent
7258 See the definition and documentation in file @file{s-maccod.ads}.
7260 @sp 1
7261 @cartouche
7262 @noindent
7263 @strong{52}.  The effect of unchecked conversion.  See 13.9(11).
7264 @end cartouche
7265 @noindent
7266 Unchecked conversion between types of the same size
7267 results in an uninterpreted transmission of the bits from one type
7268 to the other.  If the types are of unequal sizes, then in the case of
7269 discrete types, a shorter source is first zero or sign extended as
7270 necessary, and a shorter target is simply truncated on the left.
7271 For all non-discrete types, the source is first copied if necessary
7272 to ensure that the alignment requirements of the target are met, then
7273 a pointer is constructed to the source value, and the result is obtained
7274 by dereferencing this pointer after converting it to be a pointer to the
7275 target type. Unchecked conversions where the target subtype is an
7276 unconstrained array are not permitted. If the target alignment is
7277 greater than the source alignment, then a copy of the result is
7278 made with appropriate alignment
7280 @sp 1
7281 @cartouche
7282 @noindent
7283 @strong{53}.  The manner of choosing a storage pool for an access type
7284 when @code{Storage_Pool} is not specified for the type.  See 13.11(17).
7285 @end cartouche
7286 @noindent
7287 There are 3 different standard pools used by the compiler when
7288 @code{Storage_Pool} is not specified depending whether the type is local
7289 to a subprogram or defined at the library level and whether
7290 @code{Storage_Size}is specified or not.  See documentation in the runtime
7291 library units @code{System.Pool_Global}, @code{System.Pool_Size} and
7292 @code{System.Pool_Local} in files @file{s-poosiz.ads},
7293 @file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
7294 default pools used.
7296 @sp 1
7297 @cartouche
7298 @noindent
7299 @strong{54}.  Whether or not the implementation provides user-accessible
7300 names for the standard pool type(s).  See 13.11(17).
7301 @end cartouche
7302 @noindent
7304 See documentation in the sources of the run time mentioned in paragraph
7305 @strong{53} .  All these pools are accessible by means of @code{with}'ing
7306 these units.
7308 @sp 1
7309 @cartouche
7310 @noindent
7311 @strong{55}.  The meaning of @code{Storage_Size}.  See 13.11(18).
7312 @end cartouche
7313 @noindent
7314 @code{Storage_Size} is measured in storage units, and refers to the
7315 total space available for an access type collection, or to the primary
7316 stack space for a task.
7318 @sp 1
7319 @cartouche
7320 @noindent
7321 @strong{56}.  Implementation-defined aspects of storage pools.  See
7322 13.11(22).
7323 @end cartouche
7324 @noindent
7325 See documentation in the sources of the run time mentioned in paragraph
7326 @strong{53} for details on GNAT-defined aspects of storage pools.
7328 @sp 1
7329 @cartouche
7330 @noindent
7331 @strong{57}.  The set of restrictions allowed in a pragma
7332 @code{Restrictions}.  See 13.12(7).
7333 @end cartouche
7334 @noindent
7335 All RM defined Restriction identifiers are implemented.  The following
7336 additional restriction identifiers are provided.  There are two separate
7337 lists of implementation dependent restriction identifiers.  The first
7338 set requires consistency throughout a partition (in other words, if the
7339 restriction identifier is used for any compilation unit in the partition,
7340 then all compilation units in the partition must obey the restriction.
7342 @table @code
7344 @item Simple_Barriers
7345 @findex Simple_Barriers
7346 This restriction ensures at compile time that barriers in entry declarations
7347 for protected types are restricted to either static boolean expressions or
7348 references to simple boolean variables defined in the private part of the
7349 protected type.  No other form of entry barriers is permitted.  This is one
7350 of the restrictions of the Ravenscar profile for limited tasking (see also
7351 pragma @code{Profile (Ravenscar)}).
7353 @item Max_Entry_Queue_Length => Expr
7354 @findex Max_Entry_Queue_Length
7355 This restriction is a declaration that any protected entry compiled in
7356 the scope of the restriction has at most the specified number of
7357 tasks waiting on the entry
7358 at any one time, and so no queue is required.  This restriction is not
7359 checked at compile time.  A program execution is erroneous if an attempt
7360 is made to queue more than the specified number of tasks on such an entry.
7362 @item No_Calendar
7363 @findex No_Calendar
7364 This restriction ensures at compile time that there is no implicit or
7365 explicit dependence on the package @code{Ada.Calendar}.
7367 @item No_Direct_Boolean_Operators
7368 @findex No_Direct_Boolean_Operators
7369 This restriction ensures that no logical (and/or/xor) or comparison
7370 operators are used on operands of type Boolean (or any type derived
7371 from Boolean). This is intended for use in safety critical programs
7372 where the certification protocol requires the use of short-circuit
7373 (and then, or else) forms for all composite boolean operations.
7375 @item No_Dispatching_Calls
7376 @findex No_Dispatching_Calls
7377 This restriction ensures at compile time that the code generated by the
7378 compiler involves no dispatching calls. The use of this restriction allows the
7379 safe use of record extensions and membership tests and ensures that the code 
7380 contains no indirect calls through a dispatching mechanism. (Note that this
7381 includes internally-generated calls created by the compiler, for example in
7382 the implementation of the predefined attributes on class-wide objects.) The
7383 membership test is allowed in the presence of this restriction, because its
7384 implementation requires no dispatching. The following example indicates
7385 constructs that violate this restriction.
7387 @smallexample
7388 package Pkg is
7389   type T is tagged record
7390     Data : Natural;
7391   end record;
7392   procedure P (X : T);
7394   type DT is new T with record
7395     More_Data : Natural;
7396   end record;
7397   procedure Q (X : DT);
7398 end Pkg;
7400 with Pkg; use Pkg;
7401 procedure Example is
7402   procedure Test (O : T'Class) is
7403     N : Natural := O'Size; --  Error: Dispatching call
7404   begin
7405     if O in DT'Class then  --  OK   : Membership test
7406        Q (DT (O));         --  OK   : Type conversion plus direct call         
7407     else
7408        P (O);              --  Error: Dispatching call
7409     end if;
7410   end Test;
7412   Obj : DT;
7413 begin
7414   P (Obj);                 --  OK   : Direct call
7415   P (T (Obj));             --  OK   : Type conversion plus direct call
7416   P (T'Class (Obj));       --  Error: Dispatching call
7418   Test (Obj);              --  OK   : Type conversion
7420   if Obj in T'Class then   --  OK   : Membership test
7421      null;
7422   end if;
7423 end Example;
7424 @end smallexample
7426 @item No_Dynamic_Attachment
7427 @findex No_Dynamic_Attachment
7428 This restriction ensures that there is no call to any of the operations
7429 defined in package Ada.Interrupts.
7431 @item No_Enumeration_Maps
7432 @findex No_Enumeration_Maps
7433 This restriction ensures at compile time that no operations requiring
7434 enumeration maps are used (that is Image and Value attributes applied
7435 to enumeration types).
7437 @item No_Entry_Calls_In_Elaboration_Code
7438 @findex No_Entry_Calls_In_Elaboration_Code
7439 This restriction ensures at compile time that no task or protected entry
7440 calls are made during elaboration code.  As a result of the use of this
7441 restriction, the compiler can assume that no code past an accept statement
7442 in a task can be executed at elaboration time.
7444 @item No_Exception_Handlers
7445 @findex No_Exception_Handlers
7446 This restriction ensures at compile time that there are no explicit
7447 exception handlers. It also indicates that no exception propagation will
7448 be provided. In this mode, exceptions may be raised but will result in
7449 an immediate call to the last chance handler, a routine that the user
7450 must define with the following profile:
7452    procedure Last_Chance_Handler
7453      (Source_Location : System.Address; Line : Integer);
7454    pragma Export (C, Last_Chance_Handler,
7455                   "__gnat_last_chance_handler");
7457    The parameter is a C null-terminated string representing a message to be
7458    associated with the exception (typically the source location of the raise
7459    statement generated by the compiler). The Line parameter when nonzero
7460    represents the line number in the source program where the raise occurs.
7462 @item No_Exception_Streams
7463 @findex No_Exception_Streams
7464 This restriction ensures at compile time that no stream operations for
7465 types Exception_Id or Exception_Occurrence are used. This also makes it
7466 impossible to pass exceptions to or from a partition with this restriction
7467 in a distributed environment. If this exception is active, then the generated
7468 code is simplified by omitting the otherwise-required global registration
7469 of exceptions when they are declared.
7471 @item No_Implicit_Conditionals
7472 @findex No_Implicit_Conditionals
7473 This restriction ensures that the generated code does not contain any
7474 implicit conditionals, either by modifying the generated code where possible,
7475 or by rejecting any construct that would otherwise generate an implicit
7476 conditional. Note that this check does not include run time constraint
7477 checks, which on some targets may generate implicit conditionals as
7478 well. To control the latter, constraint checks can be suppressed in the
7479 normal manner. Constructs generating implicit conditionals include comparisons
7480 of composite objects and the Max/Min attributes.
7482 @item No_Implicit_Dynamic_Code
7483 @findex No_Implicit_Dynamic_Code
7484 This restriction prevents the compiler from building ``trampolines''.
7485 This is a structure that is built on the stack and contains dynamic
7486 code to be executed at run time. A trampoline is needed to indirectly
7487 address a nested subprogram (that is a subprogram that is not at the
7488 library level). The restriction prevents the use of any of the
7489 attributes @code{Address}, @code{Access} or @code{Unrestricted_Access}
7490 being applied to a subprogram that is not at the library level.
7492 @item No_Implicit_Loops
7493 @findex No_Implicit_Loops
7494 This restriction ensures that the generated code does not contain any
7495 implicit @code{for} loops, either by modifying
7496 the generated code where possible,
7497 or by rejecting any construct that would otherwise generate an implicit
7498 @code{for} loop.
7500 @item No_Initialize_Scalars
7501 @findex No_Initialize_Scalars
7502 This restriction ensures that no unit in the partition is compiled with
7503 pragma Initialize_Scalars. This allows the generation of more efficient
7504 code, and in particular eliminates dummy null initialization routines that
7505 are otherwise generated for some record and array types.
7507 @item No_Local_Protected_Objects
7508 @findex No_Local_Protected_Objects
7509 This restriction ensures at compile time that protected objects are
7510 only declared at the library level.
7512 @item No_Protected_Type_Allocators
7513 @findex No_Protected_Type_Allocators
7514 This restriction ensures at compile time that there are no allocator
7515 expressions that attempt to allocate protected objects.
7517 @item No_Secondary_Stack
7518 @findex No_Secondary_Stack
7519 This restriction ensures at compile time that the generated code does not
7520 contain any reference to the secondary stack.  The secondary stack is used
7521 to implement functions returning unconstrained objects (arrays or records)
7522 on some targets.
7524 @item No_Select_Statements
7525 @findex No_Select_Statements
7526 This restriction ensures at compile time no select statements of any kind
7527 are permitted, that is the keyword @code{select} may not appear.
7528 This is one of the restrictions of the Ravenscar
7529 profile for limited tasking (see also pragma @code{Profile (Ravenscar)}).
7531 @item No_Standard_Storage_Pools
7532 @findex No_Standard_Storage_Pools
7533 This restriction ensures at compile time that no access types
7534 use the standard default storage pool.  Any access type declared must
7535 have an explicit Storage_Pool attribute defined specifying a
7536 user-defined storage pool.
7538 @item No_Streams
7539 @findex No_Streams
7540 This restriction ensures at compile/bind time that there are no
7541 stream objects created (and therefore no actual stream operations).
7542 This restriction does not forbid dependences on the package
7543 @code{Ada.Streams}. So it is permissible to with
7544 @code{Ada.Streams} (or another package that does so itself)
7545 as long as no actual stream objects are created.
7547 @item No_Task_Attributes_Package
7548 @findex No_Task_Attributes_Package
7549 This restriction ensures at compile time that there are no implicit or
7550 explicit dependencies on the package @code{Ada.Task_Attributes}.
7552 @item No_Task_Termination
7553 @findex No_Task_Termination
7554 This restriction ensures at compile time that no terminate alternatives
7555 appear in any task body.
7557 @item No_Tasking
7558 @findex No_Tasking
7559 This restriction prevents the declaration of tasks or task types throughout
7560 the partition.  It is similar in effect to the use of @code{Max_Tasks => 0}
7561 except that violations are caught at compile time and cause an error message
7562 to be output either by the compiler or binder.
7564 @item Static_Priorities
7565 @findex Static_Priorities
7566 This restriction ensures at compile time that all priority expressions
7567 are static, and that there are no dependencies on the package
7568 @code{Ada.Dynamic_Priorities}.
7570 @item Static_Storage_Size
7571 @findex Static_Storage_Size
7572 This restriction ensures at compile time that any expression appearing
7573 in a Storage_Size pragma or attribute definition clause is static.
7575 @end table
7577 @noindent
7578 The second set of implementation dependent restriction identifiers
7579 does not require partition-wide consistency.
7580 The restriction may be enforced for a single
7581 compilation unit without any effect on any of the
7582 other compilation units in the partition.
7584 @table @code
7586 @item No_Elaboration_Code
7587 @findex No_Elaboration_Code
7588 This restriction ensures at compile time that no elaboration code is
7589 generated.  Note that this is not the same condition as is enforced
7590 by pragma @code{Preelaborate}.  There are cases in which pragma
7591 @code{Preelaborate} still permits code to be generated (e.g.@: code
7592 to initialize a large array to all zeroes), and there are cases of units
7593 which do not meet the requirements for pragma @code{Preelaborate},
7594 but for which no elaboration code is generated.  Generally, it is
7595 the case that preelaborable units will meet the restrictions, with
7596 the exception of large aggregates initialized with an others_clause,
7597 and exception declarations (which generate calls to a run-time
7598 registry procedure).  This restriction is enforced on
7599 a unit by unit basis, it need not be obeyed consistently
7600 throughout a partition.
7602 It is not possible to precisely document
7603 the constructs which are compatible with this restriction, since,
7604 unlike most other restrictions, this is not a restriction on the
7605 source code, but a restriction on the generated object code. For
7606 example, if the source contains a declaration:
7608 @smallexample
7609    Val : constant Integer := X;
7610 @end smallexample
7612 @noindent
7613 where X is not a static constant, it may be possible, depending
7614 on complex optimization circuitry, for the compiler to figure
7615 out the value of X at compile time, in which case this initialization
7616 can be done by the loader, and requires no initialization code. It
7617 is not possible to document the precise conditions under which the
7618 optimizer can figure this out.
7620 @item No_Entry_Queue
7621 @findex No_Entry_Queue
7622 This restriction is a declaration that any protected entry compiled in
7623 the scope of the restriction has at most one task waiting on the entry
7624 at any one time, and so no queue is required.  This restriction is not
7625 checked at compile time.  A program execution is erroneous if an attempt
7626 is made to queue a second task on such an entry.
7628 @item No_Implementation_Attributes
7629 @findex No_Implementation_Attributes
7630 This restriction checks at compile time that no GNAT-defined attributes
7631 are present.  With this restriction, the only attributes that can be used
7632 are those defined in the Ada 95 Reference Manual.
7634 @item No_Implementation_Pragmas
7635 @findex No_Implementation_Pragmas
7636 This restriction checks at compile time that no GNAT-defined pragmas
7637 are present.  With this restriction, the only pragmas that can be used
7638 are those defined in the Ada 95 Reference Manual.
7640 @item No_Implementation_Restrictions
7641 @findex No_Implementation_Restrictions
7642 This restriction checks at compile time that no GNAT-defined restriction
7643 identifiers (other than @code{No_Implementation_Restrictions} itself)
7644 are present.  With this restriction, the only other restriction identifiers
7645 that can be used are those defined in the Ada 95 Reference Manual.
7647 @item No_Wide_Characters
7648 @findex No_Wide_Characters
7649 This restriction ensures at compile time that no uses of the types
7650 @code{Wide_Character} or @code{Wide_String} or corresponding wide
7651 wide types
7652 appear, and that no wide or wide wide string or character literals
7653 appear in the program (that is literals representing characters not in
7654 type @code{Character}.
7656 @end table
7658 @sp 1
7659 @cartouche
7660 @noindent
7661 @strong{58}.  The consequences of violating limitations on
7662 @code{Restrictions} pragmas.  See 13.12(9).
7663 @end cartouche
7664 @noindent
7665 Restrictions that can be checked at compile time result in illegalities
7666 if violated.  Currently there are no other consequences of violating
7667 restrictions.
7669 @sp 1
7670 @cartouche
7671 @noindent
7672 @strong{59}.  The representation used by the @code{Read} and
7673 @code{Write} attributes of elementary types in terms of stream
7674 elements.  See 13.13.2(9).
7675 @end cartouche
7676 @noindent
7677 The representation is the in-memory representation of the base type of
7678 the type, using the number of bits corresponding to the
7679 @code{@var{type}'Size} value, and the natural ordering of the machine.
7681 @sp 1
7682 @cartouche
7683 @noindent
7684 @strong{60}.  The names and characteristics of the numeric subtypes
7685 declared in the visible part of package @code{Standard}.  See A.1(3).
7686 @end cartouche
7687 @noindent
7688 See items describing the integer and floating-point types supported.
7690 @sp 1
7691 @cartouche
7692 @noindent
7693 @strong{61}.  The accuracy actually achieved by the elementary
7694 functions.  See A.5.1(1).
7695 @end cartouche
7696 @noindent
7697 The elementary functions correspond to the functions available in the C
7698 library.  Only fast math mode is implemented.
7700 @sp 1
7701 @cartouche
7702 @noindent
7703 @strong{62}.  The sign of a zero result from some of the operators or
7704 functions in @code{Numerics.Generic_Elementary_Functions}, when
7705 @code{Float_Type'Signed_Zeros} is @code{True}.  See A.5.1(46).
7706 @end cartouche
7707 @noindent
7708 The sign of zeroes follows the requirements of the IEEE 754 standard on
7709 floating-point.
7711 @sp 1
7712 @cartouche
7713 @noindent
7714 @strong{63}.  The value of
7715 @code{Numerics.Float_Random.Max_Image_Width}.  See A.5.2(27).
7716 @end cartouche
7717 @noindent
7718 Maximum image width is 649, see library file @file{a-numran.ads}.
7720 @sp 1
7721 @cartouche
7722 @noindent
7723 @strong{64}.  The value of
7724 @code{Numerics.Discrete_Random.Max_Image_Width}.  See A.5.2(27).
7725 @end cartouche
7726 @noindent
7727 Maximum image width is 80, see library file @file{a-nudira.ads}.
7729 @sp 1
7730 @cartouche
7731 @noindent
7732 @strong{65}.  The algorithms for random number generation.  See
7733 A.5.2(32).
7734 @end cartouche
7735 @noindent
7736 The algorithm is documented in the source files @file{a-numran.ads} and
7737 @file{a-numran.adb}.
7739 @sp 1
7740 @cartouche
7741 @noindent
7742 @strong{66}.  The string representation of a random number generator's
7743 state.  See A.5.2(38).
7744 @end cartouche
7745 @noindent
7746 See the documentation contained in the file @file{a-numran.adb}.
7748 @sp 1
7749 @cartouche
7750 @noindent
7751 @strong{67}.  The minimum time interval between calls to the
7752 time-dependent Reset procedure that are guaranteed to initiate different
7753 random number sequences.  See A.5.2(45).
7754 @end cartouche
7755 @noindent
7756 The minimum period between reset calls to guarantee distinct series of
7757 random numbers is one microsecond.
7759 @sp 1
7760 @cartouche
7761 @noindent
7762 @strong{68}.  The values of the @code{Model_Mantissa},
7763 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
7764 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
7765 Annex is not supported.  See A.5.3(72).
7766 @end cartouche
7767 @noindent
7768 See the source file @file{ttypef.ads} for the values of all numeric
7769 attributes.
7771 @sp 1
7772 @cartouche
7773 @noindent
7774 @strong{69}.  Any implementation-defined characteristics of the
7775 input-output packages.  See A.7(14).
7776 @end cartouche
7777 @noindent
7778 There are no special implementation defined characteristics for these
7779 packages.
7781 @sp 1
7782 @cartouche
7783 @noindent
7784 @strong{70}.  The value of @code{Buffer_Size} in @code{Storage_IO}.  See
7785 A.9(10).
7786 @end cartouche
7787 @noindent
7788 All type representations are contiguous, and the @code{Buffer_Size} is
7789 the value of @code{@var{type}'Size} rounded up to the next storage unit
7790 boundary.
7792 @sp 1
7793 @cartouche
7794 @noindent
7795 @strong{71}.  External files for standard input, standard output, and
7796 standard error See A.10(5).
7797 @end cartouche
7798 @noindent
7799 These files are mapped onto the files provided by the C streams
7800 libraries.  See source file @file{i-cstrea.ads} for further details.
7802 @sp 1
7803 @cartouche
7804 @noindent
7805 @strong{72}.  The accuracy of the value produced by @code{Put}.  See
7806 A.10.9(36).
7807 @end cartouche
7808 @noindent
7809 If more digits are requested in the output than are represented by the
7810 precision of the value, zeroes are output in the corresponding least
7811 significant digit positions.
7813 @sp 1
7814 @cartouche
7815 @noindent
7816 @strong{73}.  The meaning of @code{Argument_Count}, @code{Argument}, and
7817 @code{Command_Name}.  See A.15(1).
7818 @end cartouche
7819 @noindent
7820 These are mapped onto the @code{argv} and @code{argc} parameters of the
7821 main program in the natural manner.
7823 @sp 1
7824 @cartouche
7825 @noindent
7826 @strong{74}.  Implementation-defined convention names.  See B.1(11).
7827 @end cartouche
7828 @noindent
7829 The following convention names are supported
7831 @table @code
7832 @item  Ada
7834 @item Assembler
7835 Assembly language
7836 @item Asm
7837 Synonym for Assembler
7838 @item Assembly
7839 Synonym for Assembler
7840 @item C
7842 @item C_Pass_By_Copy
7843 Allowed only for record types, like C, but also notes that record
7844 is to be passed by copy rather than reference.
7845 @item COBOL
7846 COBOL
7847 @item CPP
7849 @item Default
7850 Treated the same as C
7851 @item External
7852 Treated the same as C
7853 @item Fortran
7854 Fortran
7855 @item Intrinsic
7856 For support of pragma @code{Import} with convention Intrinsic, see
7857 separate section on Intrinsic Subprograms.
7858 @item Stdcall
7859 Stdcall (used for Windows implementations only).  This convention correspond
7860 to the WINAPI (previously called Pascal convention) C/C++ convention under
7861 Windows.  A function with this convention cleans the stack before exit.
7862 @item DLL
7863 Synonym for Stdcall
7864 @item Win32
7865 Synonym for Stdcall
7866 @item Stubbed
7867 Stubbed is a special convention used to indicate that the body of the
7868 subprogram will be entirely ignored.  Any call to the subprogram
7869 is converted into a raise of the @code{Program_Error} exception.  If a
7870 pragma @code{Import} specifies convention @code{stubbed} then no body need
7871 be present at all.  This convention is useful during development for the
7872 inclusion of subprograms whose body has not yet been written.
7874 @end table
7875 @noindent
7876 In addition, all otherwise unrecognized convention names are also
7877 treated as being synonymous with convention C@.  In all implementations
7878 except for VMS, use of such other names results in a warning.  In VMS
7879 implementations, these names are accepted silently.
7881 @sp 1
7882 @cartouche
7883 @noindent
7884 @strong{75}.  The meaning of link names.  See B.1(36).
7885 @end cartouche
7886 @noindent
7887 Link names are the actual names used by the linker.
7889 @sp 1
7890 @cartouche
7891 @noindent
7892 @strong{76}.  The manner of choosing link names when neither the link
7893 name nor the address of an imported or exported entity is specified.  See
7894 B.1(36).
7895 @end cartouche
7896 @noindent
7897 The default linker name is that which would be assigned by the relevant
7898 external language, interpreting the Ada name as being in all lower case
7899 letters.
7901 @sp 1
7902 @cartouche
7903 @noindent
7904 @strong{77}.  The effect of pragma @code{Linker_Options}.  See B.1(37).
7905 @end cartouche
7906 @noindent
7907 The string passed to @code{Linker_Options} is presented uninterpreted as
7908 an argument to the link command, unless it contains Ascii.NUL characters.
7909 NUL characters if they appear act as argument separators, so for example
7911 @smallexample @c ada
7912 pragma Linker_Options ("-labc" & ASCII.Nul & "-ldef");
7913 @end smallexample
7915 @noindent
7916 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
7917 linker. The order of linker options is preserved for a given unit. The final
7918 list of options passed to the linker is in reverse order of the elaboration
7919 order. For example, linker options fo a body always appear before the options
7920 from the corresponding package spec.
7922 @sp 1
7923 @cartouche
7924 @noindent
7925 @strong{78}.  The contents of the visible part of package
7926 @code{Interfaces} and its language-defined descendants.  See B.2(1).
7927 @end cartouche
7928 @noindent
7929 See files with prefix @file{i-} in the distributed library.
7931 @sp 1
7932 @cartouche
7933 @noindent
7934 @strong{79}.  Implementation-defined children of package
7935 @code{Interfaces}.  The contents of the visible part of package
7936 @code{Interfaces}.  See B.2(11).
7937 @end cartouche
7938 @noindent
7939 See files with prefix @file{i-} in the distributed library.
7941 @sp 1
7942 @cartouche
7943 @noindent
7944 @strong{80}.  The types @code{Floating}, @code{Long_Floating},
7945 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
7946 @code{COBOL_Character}; and the initialization of the variables
7947 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
7948 @code{Interfaces.COBOL}.  See B.4(50).
7949 @end cartouche
7950 @noindent
7951 @table @code
7952 @item Floating
7953 Float
7954 @item Long_Floating
7955 (Floating) Long_Float
7956 @item Binary
7957 Integer
7958 @item Long_Binary
7959 Long_Long_Integer
7960 @item Decimal_Element
7961 Character
7962 @item COBOL_Character
7963 Character
7964 @end table
7966 @noindent
7967 For initialization, see the file @file{i-cobol.ads} in the distributed library.
7969 @sp 1
7970 @cartouche
7971 @noindent
7972 @strong{81}.  Support for access to machine instructions.  See C.1(1).
7973 @end cartouche
7974 @noindent
7975 See documentation in file @file{s-maccod.ads} in the distributed library.
7977 @sp 1
7978 @cartouche
7979 @noindent
7980 @strong{82}.  Implementation-defined aspects of access to machine
7981 operations.  See C.1(9).
7982 @end cartouche
7983 @noindent
7984 See documentation in file @file{s-maccod.ads} in the distributed library.
7986 @sp 1
7987 @cartouche
7988 @noindent
7989 @strong{83}.  Implementation-defined aspects of interrupts.  See C.3(2).
7990 @end cartouche
7991 @noindent
7992 Interrupts are mapped to signals or conditions as appropriate.  See
7993 definition of unit
7994 @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
7995 on the interrupts supported on a particular target.
7997 @sp 1
7998 @cartouche
7999 @noindent
8000 @strong{84}.  Implementation-defined aspects of pre-elaboration.  See
8001 C.4(13).
8002 @end cartouche
8003 @noindent
8004 GNAT does not permit a partition to be restarted without reloading,
8005 except under control of the debugger.
8007 @sp 1
8008 @cartouche
8009 @noindent
8010 @strong{85}.  The semantics of pragma @code{Discard_Names}.  See C.5(7).
8011 @end cartouche
8012 @noindent
8013 Pragma @code{Discard_Names} causes names of enumeration literals to
8014 be suppressed.  In the presence of this pragma, the Image attribute
8015 provides the image of the Pos of the literal, and Value accepts
8016 Pos values.
8018 @sp 1
8019 @cartouche
8020 @noindent
8021 @strong{86}.  The result of the @code{Task_Identification.Image}
8022 attribute.  See C.7.1(7).
8023 @end cartouche
8024 @noindent
8025 The result of this attribute is an 8-digit hexadecimal string
8026 representing the virtual address of the task control block.
8028 @sp 1
8029 @cartouche
8030 @noindent
8031 @strong{87}.  The value of @code{Current_Task} when in a protected entry
8032 or interrupt handler.  See C.7.1(17).
8033 @end cartouche
8034 @noindent
8035 Protected entries or interrupt handlers can be executed by any
8036 convenient thread, so the value of @code{Current_Task} is undefined.
8038 @sp 1
8039 @cartouche
8040 @noindent
8041 @strong{88}.  The effect of calling @code{Current_Task} from an entry
8042 body or interrupt handler.  See C.7.1(19).
8043 @end cartouche
8044 @noindent
8045 The effect of calling @code{Current_Task} from an entry body or
8046 interrupt handler is to return the identification of the task currently
8047 executing the code.
8049 @sp 1
8050 @cartouche
8051 @noindent
8052 @strong{89}.  Implementation-defined aspects of
8053 @code{Task_Attributes}.  See C.7.2(19).
8054 @end cartouche
8055 @noindent
8056 There are no implementation-defined aspects of @code{Task_Attributes}.
8058 @sp 1
8059 @cartouche
8060 @noindent
8061 @strong{90}.  Values of all @code{Metrics}.  See D(2).
8062 @end cartouche
8063 @noindent
8064 The metrics information for GNAT depends on the performance of the
8065 underlying operating system.  The sources of the run-time for tasking
8066 implementation, together with the output from @code{-gnatG} can be
8067 used to determine the exact sequence of operating systems calls made
8068 to implement various tasking constructs.  Together with appropriate
8069 information on the performance of the underlying operating system,
8070 on the exact target in use, this information can be used to determine
8071 the required metrics.
8073 @sp 1
8074 @cartouche
8075 @noindent
8076 @strong{91}.  The declarations of @code{Any_Priority} and
8077 @code{Priority}.  See D.1(11).
8078 @end cartouche
8079 @noindent
8080 See declarations in file @file{system.ads}.
8082 @sp 1
8083 @cartouche
8084 @noindent
8085 @strong{92}.  Implementation-defined execution resources.  See D.1(15).
8086 @end cartouche
8087 @noindent
8088 There are no implementation-defined execution resources.
8090 @sp 1
8091 @cartouche
8092 @noindent
8093 @strong{93}.  Whether, on a multiprocessor, a task that is waiting for
8094 access to a protected object keeps its processor busy.  See D.2.1(3).
8095 @end cartouche
8096 @noindent
8097 On a multi-processor, a task that is waiting for access to a protected
8098 object does not keep its processor busy.
8100 @sp 1
8101 @cartouche
8102 @noindent
8103 @strong{94}.  The affect of implementation defined execution resources
8104 on task dispatching.  See D.2.1(9).
8105 @end cartouche
8106 @noindent
8107 @c SGI info
8108 @ignore
8109 Tasks map to IRIX threads, and the dispatching policy is as defined by
8110 the IRIX implementation of threads.
8111 @end ignore
8112 Tasks map to threads in the threads package used by GNAT@.  Where possible
8113 and appropriate, these threads correspond to native threads of the
8114 underlying operating system.
8116 @sp 1
8117 @cartouche
8118 @noindent
8119 @strong{95}.  Implementation-defined @code{policy_identifiers} allowed
8120 in a pragma @code{Task_Dispatching_Policy}.  See D.2.2(3).
8121 @end cartouche
8122 @noindent
8123 There are no implementation-defined policy-identifiers allowed in this
8124 pragma.
8126 @sp 1
8127 @cartouche
8128 @noindent
8129 @strong{96}.  Implementation-defined aspects of priority inversion.  See
8130 D.2.2(16).
8131 @end cartouche
8132 @noindent
8133 Execution of a task cannot be preempted by the implementation processing
8134 of delay expirations for lower priority tasks.
8136 @sp 1
8137 @cartouche
8138 @noindent
8139 @strong{97}.  Implementation defined task dispatching.  See D.2.2(18).
8140 @end cartouche
8141 @noindent
8142 @c SGI info:
8143 @ignore
8144 Tasks map to IRIX threads, and the dispatching policy is as defined by
8145 the IRIX implementation of threads.
8146 @end ignore
8147 The policy is the same as that of the underlying threads implementation.
8149 @sp 1
8150 @cartouche
8151 @noindent
8152 @strong{98}.  Implementation-defined @code{policy_identifiers} allowed
8153 in a pragma @code{Locking_Policy}.  See D.3(4).
8154 @end cartouche
8155 @noindent
8156 The only implementation defined policy permitted in GNAT is
8157 @code{Inheritance_Locking}.  On targets that support this policy, locking
8158 is implemented by inheritance, i.e.@: the task owning the lock operates
8159 at a priority equal to the highest priority of any task currently
8160 requesting the lock.
8162 @sp 1
8163 @cartouche
8164 @noindent
8165 @strong{99}.  Default ceiling priorities.  See D.3(10).
8166 @end cartouche
8167 @noindent
8168 The ceiling priority of protected objects of the type
8169 @code{System.Interrupt_Priority'Last} as described in the Ada 95
8170 Reference Manual D.3(10),
8172 @sp 1
8173 @cartouche
8174 @noindent
8175 @strong{100}.  The ceiling of any protected object used internally by
8176 the implementation.  See D.3(16).
8177 @end cartouche
8178 @noindent
8179 The ceiling priority of internal protected objects is
8180 @code{System.Priority'Last}.
8182 @sp 1
8183 @cartouche
8184 @noindent
8185 @strong{101}.  Implementation-defined queuing policies.  See D.4(1).
8186 @end cartouche
8187 @noindent
8188 There are no implementation-defined queuing policies.
8190 @sp 1
8191 @cartouche
8192 @noindent
8193 @strong{102}.  On a multiprocessor, any conditions that cause the
8194 completion of an aborted construct to be delayed later than what is
8195 specified for a single processor.  See D.6(3).
8196 @end cartouche
8197 @noindent
8198 The semantics for abort on a multi-processor is the same as on a single
8199 processor, there are no further delays.
8201 @sp 1
8202 @cartouche
8203 @noindent
8204 @strong{103}.  Any operations that implicitly require heap storage
8205 allocation.  See D.7(8).
8206 @end cartouche
8207 @noindent
8208 The only operation that implicitly requires heap storage allocation is
8209 task creation.
8211 @sp 1
8212 @cartouche
8213 @noindent
8214 @strong{104}.  Implementation-defined aspects of pragma
8215 @code{Restrictions}.  See D.7(20).
8216 @end cartouche
8217 @noindent
8218 There are no such implementation-defined aspects.
8220 @sp 1
8221 @cartouche
8222 @noindent
8223 @strong{105}.  Implementation-defined aspects of package
8224 @code{Real_Time}.  See D.8(17).
8225 @end cartouche
8226 @noindent
8227 There are no implementation defined aspects of package @code{Real_Time}.
8229 @sp 1
8230 @cartouche
8231 @noindent
8232 @strong{106}.  Implementation-defined aspects of
8233 @code{delay_statements}.  See D.9(8).
8234 @end cartouche
8235 @noindent
8236 Any difference greater than one microsecond will cause the task to be
8237 delayed (see D.9(7)).
8239 @sp 1
8240 @cartouche
8241 @noindent
8242 @strong{107}.  The upper bound on the duration of interrupt blocking
8243 caused by the implementation.  See D.12(5).
8244 @end cartouche
8245 @noindent
8246 The upper bound is determined by the underlying operating system.  In
8247 no cases is it more than 10 milliseconds.
8249 @sp 1
8250 @cartouche
8251 @noindent
8252 @strong{108}.  The means for creating and executing distributed
8253 programs.  See E(5).
8254 @end cartouche
8255 @noindent
8256 The GLADE package provides a utility GNATDIST for creating and executing
8257 distributed programs.  See the GLADE reference manual for further details.
8259 @sp 1
8260 @cartouche
8261 @noindent
8262 @strong{109}.  Any events that can result in a partition becoming
8263 inaccessible.  See E.1(7).
8264 @end cartouche
8265 @noindent
8266 See the GLADE reference manual for full details on such events.
8268 @sp 1
8269 @cartouche
8270 @noindent
8271 @strong{110}.  The scheduling policies, treatment of priorities, and
8272 management of shared resources between partitions in certain cases.  See
8273 E.1(11).
8274 @end cartouche
8275 @noindent
8276 See the GLADE reference manual for full details on these aspects of
8277 multi-partition execution.
8279 @sp 1
8280 @cartouche
8281 @noindent
8282 @strong{111}.  Events that cause the version of a compilation unit to
8283 change.  See E.3(5).
8284 @end cartouche
8285 @noindent
8286 Editing the source file of a compilation unit, or the source files of
8287 any units on which it is dependent in a significant way cause the version
8288 to change.  No other actions cause the version number to change.  All changes
8289 are significant except those which affect only layout, capitalization or
8290 comments.
8292 @sp 1
8293 @cartouche
8294 @noindent
8295 @strong{112}.  Whether the execution of the remote subprogram is
8296 immediately aborted as a result of cancellation.  See E.4(13).
8297 @end cartouche
8298 @noindent
8299 See the GLADE reference manual for details on the effect of abort in
8300 a distributed application.
8302 @sp 1
8303 @cartouche
8304 @noindent
8305 @strong{113}.  Implementation-defined aspects of the PCS@.  See E.5(25).
8306 @end cartouche
8307 @noindent
8308 See the GLADE reference manual for a full description of all implementation
8309 defined aspects of the PCS@.
8311 @sp 1
8312 @cartouche
8313 @noindent
8314 @strong{114}.  Implementation-defined interfaces in the PCS@.  See
8315 E.5(26).
8316 @end cartouche
8317 @noindent
8318 See the GLADE reference manual for a full description of all
8319 implementation defined interfaces.
8321 @sp 1
8322 @cartouche
8323 @noindent
8324 @strong{115}.  The values of named numbers in the package
8325 @code{Decimal}.  See F.2(7).
8326 @end cartouche
8327 @noindent
8328 @table @code
8329 @item Max_Scale
8331 @item Min_Scale
8333 @item Min_Delta
8334 1.0E-18
8335 @item Max_Delta
8336 1.0E+18
8337 @item Max_Decimal_Digits
8339 @end table
8341 @sp 1
8342 @cartouche
8343 @noindent
8344 @strong{116}.  The value of @code{Max_Picture_Length} in the package
8345 @code{Text_IO.Editing}.  See F.3.3(16).
8346 @end cartouche
8347 @noindent
8350 @sp 1
8351 @cartouche
8352 @noindent
8353 @strong{117}.  The value of @code{Max_Picture_Length} in the package
8354 @code{Wide_Text_IO.Editing}.  See F.3.4(5).
8355 @end cartouche
8356 @noindent
8359 @sp 1
8360 @cartouche
8361 @noindent
8362 @strong{118}.  The accuracy actually achieved by the complex elementary
8363 functions and by other complex arithmetic operations.  See G.1(1).
8364 @end cartouche
8365 @noindent
8366 Standard library functions are used for the complex arithmetic
8367 operations.  Only fast math mode is currently supported.
8369 @sp 1
8370 @cartouche
8371 @noindent
8372 @strong{119}.  The sign of a zero result (or a component thereof) from
8373 any operator or function in @code{Numerics.Generic_Complex_Types}, when
8374 @code{Real'Signed_Zeros} is True.  See G.1.1(53).
8375 @end cartouche
8376 @noindent
8377 The signs of zero values are as recommended by the relevant
8378 implementation advice.
8380 @sp 1
8381 @cartouche
8382 @noindent
8383 @strong{120}.  The sign of a zero result (or a component thereof) from
8384 any operator or function in
8385 @code{Numerics.Generic_Complex_Elementary_Functions}, when
8386 @code{Real'Signed_Zeros} is @code{True}.  See G.1.2(45).
8387 @end cartouche
8388 @noindent
8389 The signs of zero values are as recommended by the relevant
8390 implementation advice.
8392 @sp 1
8393 @cartouche
8394 @noindent
8395 @strong{121}.  Whether the strict mode or the relaxed mode is the
8396 default.  See G.2(2).
8397 @end cartouche
8398 @noindent
8399 The strict mode is the default.  There is no separate relaxed mode.  GNAT
8400 provides a highly efficient implementation of strict mode.
8402 @sp 1
8403 @cartouche
8404 @noindent
8405 @strong{122}.  The result interval in certain cases of fixed-to-float
8406 conversion.  See G.2.1(10).
8407 @end cartouche
8408 @noindent
8409 For cases where the result interval is implementation dependent, the
8410 accuracy is that provided by performing all operations in 64-bit IEEE
8411 floating-point format.
8413 @sp 1
8414 @cartouche
8415 @noindent
8416 @strong{123}.  The result of a floating point arithmetic operation in
8417 overflow situations, when the @code{Machine_Overflows} attribute of the
8418 result type is @code{False}.  See G.2.1(13).
8419 @end cartouche
8420 @noindent
8421 Infinite and NaN values are produced as dictated by the IEEE
8422 floating-point standard.
8424 Note that on machines that are not fully compliant with the IEEE
8425 floating-point standard, such as Alpha, the @option{-mieee} compiler flag
8426 must be used for achieving IEEE confirming behavior (although at the cost
8427 of a significant performance penalty), so infinite and NaN values are
8428 properly generated.
8430 @sp 1
8431 @cartouche
8432 @noindent
8433 @strong{124}.  The result interval for division (or exponentiation by a
8434 negative exponent), when the floating point hardware implements division
8435 as multiplication by a reciprocal.  See G.2.1(16).
8436 @end cartouche
8437 @noindent
8438 Not relevant, division is IEEE exact.
8440 @sp 1
8441 @cartouche
8442 @noindent
8443 @strong{125}.  The definition of close result set, which determines the
8444 accuracy of certain fixed point multiplications and divisions.  See
8445 G.2.3(5).
8446 @end cartouche
8447 @noindent
8448 Operations in the close result set are performed using IEEE long format
8449 floating-point arithmetic.  The input operands are converted to
8450 floating-point, the operation is done in floating-point, and the result
8451 is converted to the target type.
8453 @sp 1
8454 @cartouche
8455 @noindent
8456 @strong{126}.  Conditions on a @code{universal_real} operand of a fixed
8457 point multiplication or division for which the result shall be in the
8458 perfect result set.  See G.2.3(22).
8459 @end cartouche
8460 @noindent
8461 The result is only defined to be in the perfect result set if the result
8462 can be computed by a single scaling operation involving a scale factor
8463 representable in 64-bits.
8465 @sp 1
8466 @cartouche
8467 @noindent
8468 @strong{127}.  The result of a fixed point arithmetic operation in
8469 overflow situations, when the @code{Machine_Overflows} attribute of the
8470 result type is @code{False}.  See G.2.3(27).
8471 @end cartouche
8472 @noindent
8473 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
8474 types.
8476 @sp 1
8477 @cartouche
8478 @noindent
8479 @strong{128}.  The result of an elementary function reference in
8480 overflow situations, when the @code{Machine_Overflows} attribute of the
8481 result type is @code{False}.  See G.2.4(4).
8482 @end cartouche
8483 @noindent
8484 IEEE infinite and Nan values are produced as appropriate.
8486 @sp 1
8487 @cartouche
8488 @noindent
8489 @strong{129}.  The value of the angle threshold, within which certain
8490 elementary functions, complex arithmetic operations, and complex
8491 elementary functions yield results conforming to a maximum relative
8492 error bound.  See G.2.4(10).
8493 @end cartouche
8494 @noindent
8495 Information on this subject is not yet available.
8497 @sp 1
8498 @cartouche
8499 @noindent
8500 @strong{130}.  The accuracy of certain elementary functions for
8501 parameters beyond the angle threshold.  See G.2.4(10).
8502 @end cartouche
8503 @noindent
8504 Information on this subject is not yet available.
8506 @sp 1
8507 @cartouche
8508 @noindent
8509 @strong{131}.  The result of a complex arithmetic operation or complex
8510 elementary function reference in overflow situations, when the
8511 @code{Machine_Overflows} attribute of the corresponding real type is
8512 @code{False}.  See G.2.6(5).
8513 @end cartouche
8514 @noindent
8515 IEEE infinite and Nan values are produced as appropriate.
8517 @sp 1
8518 @cartouche
8519 @noindent
8520 @strong{132}.  The accuracy of certain complex arithmetic operations and
8521 certain complex elementary functions for parameters (or components
8522 thereof) beyond the angle threshold.  See G.2.6(8).
8523 @end cartouche
8524 @noindent
8525 Information on those subjects is not yet available.
8527 @sp 1
8528 @cartouche
8529 @noindent
8530 @strong{133}.  Information regarding bounded errors and erroneous
8531 execution.  See H.2(1).
8532 @end cartouche
8533 @noindent
8534 Information on this subject is not yet available.
8536 @sp 1
8537 @cartouche
8538 @noindent
8539 @strong{134}.  Implementation-defined aspects of pragma
8540 @code{Inspection_Point}.  See H.3.2(8).
8541 @end cartouche
8542 @noindent
8543 Pragma @code{Inspection_Point} ensures that the variable is live and can
8544 be examined by the debugger at the inspection point.
8546 @sp 1
8547 @cartouche
8548 @noindent
8549 @strong{135}.  Implementation-defined aspects of pragma
8550 @code{Restrictions}.  See H.4(25).
8551 @end cartouche
8552 @noindent
8553 There are no implementation-defined aspects of pragma @code{Restrictions}.  The
8554 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
8555 generated code.  Checks must suppressed by use of pragma @code{Suppress}.
8557 @sp 1
8558 @cartouche
8559 @noindent
8560 @strong{136}.  Any restrictions on pragma @code{Restrictions}.  See
8561 H.4(27).
8562 @end cartouche
8563 @noindent
8564 There are no restrictions on pragma @code{Restrictions}.
8566 @node Intrinsic Subprograms
8567 @chapter Intrinsic Subprograms
8568 @cindex Intrinsic Subprograms
8570 @menu
8571 * Intrinsic Operators::
8572 * Enclosing_Entity::
8573 * Exception_Information::
8574 * Exception_Message::
8575 * Exception_Name::
8576 * File::
8577 * Line::
8578 * Rotate_Left::
8579 * Rotate_Right::
8580 * Shift_Left::
8581 * Shift_Right::
8582 * Shift_Right_Arithmetic::
8583 * Source_Location::
8584 @end menu
8586 @noindent
8587 GNAT allows a user application program to write the declaration:
8589 @smallexample @c ada
8590    pragma Import (Intrinsic, name);
8591 @end smallexample
8593 @noindent
8594 providing that the name corresponds to one of the implemented intrinsic
8595 subprograms in GNAT, and that the parameter profile of the referenced
8596 subprogram meets the requirements.  This chapter describes the set of
8597 implemented intrinsic subprograms, and the requirements on parameter profiles.
8598 Note that no body is supplied; as with other uses of pragma Import, the
8599 body is supplied elsewhere (in this case by the compiler itself).  Note
8600 that any use of this feature is potentially non-portable, since the
8601 Ada standard does not require Ada compilers to implement this feature.
8603 @node Intrinsic Operators
8604 @section Intrinsic Operators
8605 @cindex Intrinsic operator
8607 @noindent
8608 All the predefined numeric operators in package Standard
8609 in @code{pragma Import (Intrinsic,..)}
8610 declarations.  In the binary operator case, the operands must have the same
8611 size.  The operand or operands must also be appropriate for
8612 the operator.  For example, for addition, the operands must
8613 both be floating-point or both be fixed-point, and the
8614 right operand for @code{"**"} must have a root type of
8615 @code{Standard.Integer'Base}.
8616 You can use an intrinsic operator declaration as in the following example:
8618 @smallexample @c ada
8619    type Int1 is new Integer;
8620    type Int2 is new Integer;
8622    function "+" (X1 : Int1; X2 : Int2) return Int1;
8623    function "+" (X1 : Int1; X2 : Int2) return Int2;
8624    pragma Import (Intrinsic, "+");
8625 @end smallexample
8627 @noindent
8628 This declaration would permit ``mixed mode'' arithmetic on items
8629 of the differing types @code{Int1} and @code{Int2}.
8630 It is also possible to specify such operators for private types, if the
8631 full views are appropriate arithmetic types.
8633 @node Enclosing_Entity
8634 @section Enclosing_Entity
8635 @cindex Enclosing_Entity
8636 @noindent
8637 This intrinsic subprogram is used in the implementation of the
8638 library routine @code{GNAT.Source_Info}.  The only useful use of the
8639 intrinsic import in this case is the one in this unit, so an
8640 application program should simply call the function
8641 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
8642 the current subprogram, package, task, entry, or protected subprogram.
8644 @node Exception_Information
8645 @section Exception_Information
8646 @cindex Exception_Information'
8647 @noindent
8648 This intrinsic subprogram is used in the implementation of the
8649 library routine @code{GNAT.Current_Exception}.  The only useful
8650 use of the intrinsic import in this case is the one in this unit,
8651 so an application program should simply call the function
8652 @code{GNAT.Current_Exception.Exception_Information} to obtain
8653 the exception information associated with the current exception.
8655 @node Exception_Message
8656 @section Exception_Message
8657 @cindex Exception_Message
8658 @noindent
8659 This intrinsic subprogram is used in the implementation of the
8660 library routine @code{GNAT.Current_Exception}.  The only useful
8661 use of the intrinsic import in this case is the one in this unit,
8662 so an application program should simply call the function
8663 @code{GNAT.Current_Exception.Exception_Message} to obtain
8664 the message associated with the current exception.
8666 @node Exception_Name
8667 @section Exception_Name
8668 @cindex Exception_Name
8669 @noindent
8670 This intrinsic subprogram is used in the implementation of the
8671 library routine @code{GNAT.Current_Exception}.  The only useful
8672 use of the intrinsic import in this case is the one in this unit,
8673 so an application program should simply call the function
8674 @code{GNAT.Current_Exception.Exception_Name} to obtain
8675 the name of the current exception.
8677 @node File
8678 @section File
8679 @cindex File
8680 @noindent
8681 This intrinsic subprogram is used in the implementation of the
8682 library routine @code{GNAT.Source_Info}.  The only useful use of the
8683 intrinsic import in this case is the one in this unit, so an
8684 application program should simply call the function
8685 @code{GNAT.Source_Info.File} to obtain the name of the current
8686 file.
8688 @node Line
8689 @section Line
8690 @cindex Line
8691 @noindent
8692 This intrinsic subprogram is used in the implementation of the
8693 library routine @code{GNAT.Source_Info}.  The only useful use of the
8694 intrinsic import in this case is the one in this unit, so an
8695 application program should simply call the function
8696 @code{GNAT.Source_Info.Line} to obtain the number of the current
8697 source line.
8699 @node Rotate_Left
8700 @section Rotate_Left
8701 @cindex Rotate_Left
8702 @noindent
8703 In standard Ada 95, the @code{Rotate_Left} function is available only
8704 for the predefined modular types in package @code{Interfaces}.  However, in
8705 GNAT it is possible to define a Rotate_Left function for a user
8706 defined modular type or any signed integer type as in this example:
8708 @smallexample @c ada
8709    function Shift_Left
8710      (Value  : My_Modular_Type;
8711       Amount : Natural)
8712       return   My_Modular_Type;
8713 @end smallexample
8715 @noindent
8716 The requirements are that the profile be exactly as in the example
8717 above.  The only modifications allowed are in the formal parameter
8718 names, and in the type of @code{Value} and the return type, which
8719 must be the same, and must be either a signed integer type, or
8720 a modular integer type with a binary modulus, and the size must
8721 be 8.  16, 32 or 64 bits.
8723 @node Rotate_Right
8724 @section Rotate_Right
8725 @cindex Rotate_Right
8726 @noindent
8727 A @code{Rotate_Right} function can be defined for any user defined
8728 binary modular integer type, or signed integer type, as described
8729 above for @code{Rotate_Left}.
8731 @node Shift_Left
8732 @section Shift_Left
8733 @cindex Shift_Left
8734 @noindent
8735 A @code{Shift_Left} function can be defined for any user defined
8736 binary modular integer type, or signed integer type, as described
8737 above for @code{Rotate_Left}.
8739 @node Shift_Right
8740 @section Shift_Right
8741 @cindex Shift_Right
8742 @noindent
8743 A @code{Shift_Right} function can be defined for any user defined
8744 binary modular integer type, or signed integer type, as described
8745 above for @code{Rotate_Left}.
8747 @node Shift_Right_Arithmetic
8748 @section Shift_Right_Arithmetic
8749 @cindex Shift_Right_Arithmetic
8750 @noindent
8751 A @code{Shift_Right_Arithmetic} function can be defined for any user
8752 defined binary modular integer type, or signed integer type, as described
8753 above for @code{Rotate_Left}.
8755 @node Source_Location
8756 @section Source_Location
8757 @cindex Source_Location
8758 @noindent
8759 This intrinsic subprogram is used in the implementation of the
8760 library routine @code{GNAT.Source_Info}.  The only useful use of the
8761 intrinsic import in this case is the one in this unit, so an
8762 application program should simply call the function
8763 @code{GNAT.Source_Info.Source_Location} to obtain the current
8764 source file location.
8766 @node Representation Clauses and Pragmas
8767 @chapter Representation Clauses and Pragmas
8768 @cindex Representation Clauses
8770 @menu
8771 * Alignment Clauses::
8772 * Size Clauses::
8773 * Storage_Size Clauses::
8774 * Size of Variant Record Objects::
8775 * Biased Representation ::
8776 * Value_Size and Object_Size Clauses::
8777 * Component_Size Clauses::
8778 * Bit_Order Clauses::
8779 * Effect of Bit_Order on Byte Ordering::
8780 * Pragma Pack for Arrays::
8781 * Pragma Pack for Records::
8782 * Record Representation Clauses::
8783 * Enumeration Clauses::
8784 * Address Clauses::
8785 * Effect of Convention on Representation::
8786 * Determining the Representations chosen by GNAT::
8787 @end menu
8789 @noindent
8790 @cindex Representation Clause
8791 @cindex Representation Pragma
8792 @cindex Pragma, representation
8793 This section describes the representation clauses accepted by GNAT, and
8794 their effect on the representation of corresponding data objects.
8796 GNAT fully implements Annex C (Systems Programming).  This means that all
8797 the implementation advice sections in chapter 13 are fully implemented.
8798 However, these sections only require a minimal level of support for
8799 representation clauses.  GNAT provides much more extensive capabilities,
8800 and this section describes the additional capabilities provided.
8802 @node Alignment Clauses
8803 @section Alignment Clauses
8804 @cindex Alignment Clause
8806 @noindent
8807 GNAT requires that all alignment clauses specify a power of 2, and all
8808 default alignments are always a power of 2.  The default alignment
8809 values are as follows:
8811 @itemize @bullet
8812 @item @emph{Primitive Types}.
8813 For primitive types, the alignment is the minimum of the actual size of
8814 objects of the type divided by @code{Storage_Unit},
8815 and the maximum alignment supported by the target.
8816 (This maximum alignment is given by the GNAT-specific attribute
8817 @code{Standard'Maximum_Alignment}; see @ref{Maximum_Alignment}.)
8818 @cindex @code{Maximum_Alignment} attribute
8819 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
8820 default alignment will be 8 on any target that supports alignments
8821 this large, but on some targets, the maximum alignment may be smaller
8822 than 8, in which case objects of type @code{Long_Float} will be maximally
8823 aligned.
8825 @item @emph{Arrays}.
8826 For arrays, the alignment is equal to the alignment of the component type
8827 for the normal case where no packing or component size is given.  If the
8828 array is packed, and the packing is effective (see separate section on
8829 packed arrays), then the alignment will be one for long packed arrays,
8830 or arrays whose length is not known at compile time.  For short packed
8831 arrays, which are handled internally as modular types, the alignment
8832 will be as described for primitive types, e.g.@: a packed array of length
8833 31 bits will have an object size of four bytes, and an alignment of 4.
8835 @item @emph{Records}.
8836 For the normal non-packed case, the alignment of a record is equal to
8837 the maximum alignment of any of its components.  For tagged records, this
8838 includes the implicit access type used for the tag.  If a pragma @code{Pack} is
8839 used and all fields are packable (see separate section on pragma @code{Pack}),
8840 then the resulting alignment is 1.
8842 A special case is when:
8843 @itemize @bullet
8844 @item
8845 the size of the record is given explicitly, or a
8846 full record representation clause is given, and
8847 @item
8848 the size of the record is 2, 4, or 8 bytes.
8849 @end itemize
8850 @noindent
8851 In this case, an alignment is chosen to match the
8852 size of the record. For example, if we have:
8854 @smallexample @c ada
8855    type Small is record
8856       A, B : Character;
8857    end record;
8858    for Small'Size use 16;
8859 @end smallexample
8861 @noindent
8862 then the default alignment of the record type @code{Small} is 2, not 1. This
8863 leads to more efficient code when the record is treated as a unit, and also
8864 allows the type to specified as @code{Atomic} on architectures requiring
8865 strict alignment.
8867 @end itemize
8869 @noindent
8870 An alignment clause may
8871 always specify a larger alignment than the default value, up to some
8872 maximum value dependent on the target (obtainable by using the
8873 attribute reference @code{Standard'Maximum_Alignment}).
8874 The only case where
8875 it is permissible to specify a smaller alignment than the default value
8876 is for a record with a record representation clause.
8877 In this case, packable fields for which a component clause is
8878 given still result in a default alignment corresponding to the original
8879 type, but this may be overridden, since these components in fact only
8880 require an alignment of one byte.  For example, given
8882 @smallexample @c ada
8883   type V is record
8884      A : Integer;
8885   end record;
8887   for V use record
8888      A at 0  range 0 .. 31;
8889   end record;
8891   for V'alignment use 1;
8892 @end smallexample
8894 @noindent
8895 @cindex Alignment, default
8896 The default alignment for the type @code{V} is 4, as a result of the
8897 Integer field in the record, but since this field is placed with a
8898 component clause, it is permissible, as shown, to override the default
8899 alignment of the record with a smaller value.
8901 @node Size Clauses
8902 @section Size Clauses
8903 @cindex Size Clause
8905 @noindent
8906 The default size for a type @code{T} is obtainable through the
8907 language-defined attribute @code{T'Size} and also through the
8908 equivalent GNAT-defined attribute @code{T'Value_Size}.
8909 For objects of type @code{T}, GNAT will generally increase the type size
8910 so that the object size (obtainable through the GNAT-defined attribute
8911 @code{T'Object_Size})
8912 is a multiple of @code{T'Alignment * Storage_Unit}.
8913 For example
8915 @smallexample @c ada
8916    type Smallint is range 1 .. 6;
8918    type Rec is record
8919       Y1 : integer;
8920       Y2 : boolean;
8921    end record;
8922 @end smallexample
8924 @noindent
8925 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
8926 as specified by the RM rules,
8927 but objects of this type will have a size of 8
8928 (@code{Smallint'Object_Size} = 8),
8929 since objects by default occupy an integral number
8930 of storage units.  On some targets, notably older
8931 versions of the Digital Alpha, the size of stand
8932 alone objects of this type may be 32, reflecting
8933 the inability of the hardware to do byte load/stores.
8935 Similarly, the size of type @code{Rec} is 40 bits
8936 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
8937 the alignment is 4, so objects of this type will have
8938 their size increased to 64 bits so that it is a multiple
8939 of the alignment (in bits).  This decision is
8940 in accordance with the specific Implementation Advice in RM 13.3(43):
8942 @quotation
8943 A @code{Size} clause should be supported for an object if the specified
8944 @code{Size} is at least as large as its subtype's @code{Size}, and corresponds
8945 to a size in storage elements that is a multiple of the object's
8946 @code{Alignment} (if the @code{Alignment} is nonzero).
8947 @end quotation
8949 @noindent
8950 An explicit size clause may be used to override the default size by
8951 increasing it.  For example, if we have:
8953 @smallexample @c ada
8954    type My_Boolean is new Boolean;
8955    for My_Boolean'Size use 32;
8956 @end smallexample
8958 @noindent
8959 then values of this type will always be 32 bits long.  In the case of
8960 discrete types, the size can be increased up to 64 bits, with the effect
8961 that the entire specified field is used to hold the value, sign- or
8962 zero-extended as appropriate.  If more than 64 bits is specified, then
8963 padding space is allocated after the value, and a warning is issued that
8964 there are unused bits.
8966 Similarly the size of records and arrays may be increased, and the effect
8967 is to add padding bits after the value.  This also causes a warning message
8968 to be generated.
8970 The largest Size value permitted in GNAT is 2**31@minus{}1.  Since this is a
8971 Size in bits, this corresponds to an object of size 256 megabytes (minus
8972 one).  This limitation is true on all targets.  The reason for this
8973 limitation is that it improves the quality of the code in many cases
8974 if it is known that a Size value can be accommodated in an object of
8975 type Integer.
8977 @node Storage_Size Clauses
8978 @section Storage_Size Clauses
8979 @cindex Storage_Size Clause
8981 @noindent
8982 For tasks, the @code{Storage_Size} clause specifies the amount of space
8983 to be allocated for the task stack.  This cannot be extended, and if the
8984 stack is exhausted, then @code{Storage_Error} will be raised (if stack
8985 checking is enabled).  Use a @code{Storage_Size} attribute definition clause,
8986 or a @code{Storage_Size} pragma in the task definition to set the
8987 appropriate required size.  A useful technique is to include in every
8988 task definition a pragma of the form:
8990 @smallexample @c ada
8991    pragma Storage_Size (Default_Stack_Size);
8992 @end smallexample
8994 @noindent
8995 Then @code{Default_Stack_Size} can be defined in a global package, and
8996 modified as required. Any tasks requiring stack sizes different from the
8997 default can have an appropriate alternative reference in the pragma.
8999 You can also use the @code{-d} binder switch to modify the default stack
9000 size.
9002 For access types, the @code{Storage_Size} clause specifies the maximum
9003 space available for allocation of objects of the type.  If this space is
9004 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
9005 In the case where the access type is declared local to a subprogram, the
9006 use of a @code{Storage_Size} clause triggers automatic use of a special
9007 predefined storage pool (@code{System.Pool_Size}) that ensures that all
9008 space for the pool is automatically reclaimed on exit from the scope in
9009 which the type is declared.
9011 A special case recognized by the compiler is the specification of a
9012 @code{Storage_Size} of zero for an access type.  This means that no
9013 items can be allocated from the pool, and this is recognized at compile
9014 time, and all the overhead normally associated with maintaining a fixed
9015 size storage pool is eliminated.  Consider the following example:
9017 @smallexample @c ada
9018    procedure p is
9019       type R is array (Natural) of Character;
9020       type P is access all R;
9021       for P'Storage_Size use 0;
9022       --  Above access type intended only for interfacing purposes
9024       y : P;
9026       procedure g (m : P);
9027       pragma Import (C, g);
9029       --  @dots{}
9031    begin
9032       --  @dots{}
9033       y := new R;
9034    end;
9035 @end smallexample
9037 @noindent
9038 As indicated in this example, these dummy storage pools are often useful in
9039 connection with interfacing where no object will ever be allocated.  If you
9040 compile the above example, you get the warning:
9042 @smallexample
9043    p.adb:16:09: warning: allocation from empty storage pool
9044    p.adb:16:09: warning: Storage_Error will be raised at run time
9045 @end smallexample
9047 @noindent
9048 Of course in practice, there will not be any explicit allocators in the
9049 case of such an access declaration.
9051 @node Size of Variant Record Objects
9052 @section Size of Variant Record Objects
9053 @cindex Size, variant record objects
9054 @cindex Variant record objects, size
9056 @noindent
9057 In the case of variant record objects, there is a question whether Size gives
9058 information about a particular variant, or the maximum size required
9059 for any variant.  Consider the following program
9061 @smallexample @c ada
9062 with Text_IO; use Text_IO;
9063 procedure q is
9064    type R1 (A : Boolean := False) is record
9065      case A is
9066        when True  => X : Character;
9067        when False => null;
9068      end case;
9069    end record;
9071    V1 : R1 (False);
9072    V2 : R1;
9074 begin
9075    Put_Line (Integer'Image (V1'Size));
9076    Put_Line (Integer'Image (V2'Size));
9077 end q;
9078 @end smallexample
9080 @noindent
9081 Here we are dealing with a variant record, where the True variant
9082 requires 16 bits, and the False variant requires 8 bits.
9083 In the above example, both V1 and V2 contain the False variant,
9084 which is only 8 bits long.  However, the result of running the
9085 program is:
9087 @smallexample
9090 @end smallexample
9092 @noindent
9093 The reason for the difference here is that the discriminant value of
9094 V1 is fixed, and will always be False.  It is not possible to assign
9095 a True variant value to V1, therefore 8 bits is sufficient.  On the
9096 other hand, in the case of V2, the initial discriminant value is
9097 False (from the default), but it is possible to assign a True
9098 variant value to V2, therefore 16 bits must be allocated for V2
9099 in the general case, even fewer bits may be needed at any particular
9100 point during the program execution.
9102 As can be seen from the output of this program, the @code{'Size}
9103 attribute applied to such an object in GNAT gives the actual allocated
9104 size of the variable, which is the largest size of any of the variants.
9105 The Ada Reference Manual is not completely clear on what choice should
9106 be made here, but the GNAT behavior seems most consistent with the
9107 language in the RM@.
9109 In some cases, it may be desirable to obtain the size of the current
9110 variant, rather than the size of the largest variant.  This can be
9111 achieved in GNAT by making use of the fact that in the case of a
9112 subprogram parameter, GNAT does indeed return the size of the current
9113 variant (because a subprogram has no way of knowing how much space
9114 is actually allocated for the actual).
9116 Consider the following modified version of the above program:
9118 @smallexample @c ada
9119 with Text_IO; use Text_IO;
9120 procedure q is
9121    type R1 (A : Boolean := False) is record
9122      case A is
9123        when True  => X : Character;
9124        when False => null;
9125      end case;
9126    end record;
9128    V2 : R1;
9130    function Size (V : R1) return Integer is
9131    begin
9132       return V'Size;
9133    end Size;
9135 begin
9136    Put_Line (Integer'Image (V2'Size));
9137    Put_Line (Integer'IMage (Size (V2)));
9138    V2 := (True, 'x');
9139    Put_Line (Integer'Image (V2'Size));
9140    Put_Line (Integer'IMage (Size (V2)));
9141 end q;
9142 @end smallexample
9144 @noindent
9145 The output from this program is
9147 @smallexample
9152 @end smallexample
9154 @noindent
9155 Here we see that while the @code{'Size} attribute always returns
9156 the maximum size, regardless of the current variant value, the
9157 @code{Size} function does indeed return the size of the current
9158 variant value.
9160 @node Biased Representation
9161 @section Biased Representation
9162 @cindex Size for biased representation
9163 @cindex Biased representation
9165 @noindent
9166 In the case of scalars with a range starting at other than zero, it is
9167 possible in some cases to specify a size smaller than the default minimum
9168 value, and in such cases, GNAT uses an unsigned biased representation,
9169 in which zero is used to represent the lower bound, and successive values
9170 represent successive values of the type.
9172 For example, suppose we have the declaration:
9174 @smallexample @c ada
9175    type Small is range -7 .. -4;
9176    for Small'Size use 2;
9177 @end smallexample
9179 @noindent
9180 Although the default size of type @code{Small} is 4, the @code{Size}
9181 clause is accepted by GNAT and results in the following representation
9182 scheme:
9184 @smallexample
9185   -7 is represented as 2#00#
9186   -6 is represented as 2#01#
9187   -5 is represented as 2#10#
9188   -4 is represented as 2#11#
9189 @end smallexample
9191 @noindent
9192 Biased representation is only used if the specified @code{Size} clause
9193 cannot be accepted in any other manner.  These reduced sizes that force
9194 biased representation can be used for all discrete types except for
9195 enumeration types for which a representation clause is given.
9197 @node Value_Size and Object_Size Clauses
9198 @section Value_Size and Object_Size Clauses
9199 @findex Value_Size
9200 @findex Object_Size
9201 @cindex Size, of objects
9203 @noindent
9204 In Ada 95, @code{T'Size} for a type @code{T} is the minimum number of bits
9205 required to hold values of type @code{T}.  Although this interpretation was
9206 allowed in Ada 83, it was not required, and this requirement in practice
9207 can cause some significant difficulties.  For example, in most Ada 83
9208 compilers, @code{Natural'Size} was 32.  However, in Ada 95,
9209 @code{Natural'Size} is
9210 typically 31.  This means that code may change in behavior when moving
9211 from Ada 83 to Ada 95.  For example, consider:
9213 @smallexample @c ada
9214    type Rec is record;
9215       A : Natural;
9216       B : Natural;
9217    end record;
9219    for Rec use record
9220       at 0  range 0 .. Natural'Size - 1;
9221       at 0  range Natural'Size .. 2 * Natural'Size - 1;
9222    end record;
9223 @end smallexample
9225 @noindent
9226 In the above code, since the typical size of @code{Natural} objects
9227 is 32 bits and @code{Natural'Size} is 31, the above code can cause
9228 unexpected inefficient packing in Ada 95, and in general there are
9229 cases where the fact that the object size can exceed the
9230 size of the type causes surprises.
9232 To help get around this problem GNAT provides two implementation
9233 defined attributes, @code{Value_Size} and @code{Object_Size}.  When
9234 applied to a type, these attributes yield the size of the type
9235 (corresponding to the RM defined size attribute), and the size of
9236 objects of the type respectively.
9238 The @code{Object_Size} is used for determining the default size of
9239 objects and components.  This size value can be referred to using the
9240 @code{Object_Size} attribute.  The phrase ``is used'' here means that it is
9241 the basis of the determination of the size.  The backend is free to
9242 pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
9243 character might be stored in 32 bits on a machine with no efficient
9244 byte access instructions such as the Alpha.
9246 The default rules for the value of @code{Object_Size} for
9247 discrete types are as follows:
9249 @itemize @bullet
9250 @item
9251 The @code{Object_Size} for base subtypes reflect the natural hardware
9252 size in bits (run the compiler with @option{-gnatS} to find those values
9253 for numeric types). Enumeration types and fixed-point base subtypes have
9254 8, 16, 32 or 64 bits for this size, depending on the range of values
9255 to be stored.
9257 @item
9258 The @code{Object_Size} of a subtype is the same as the
9259 @code{Object_Size} of
9260 the type from which it is obtained.
9262 @item
9263 The @code{Object_Size} of a derived base type is copied from the parent
9264 base type, and the @code{Object_Size} of a derived first subtype is copied
9265 from the parent first subtype.
9266 @end itemize
9268 @noindent
9269 The @code{Value_Size} attribute
9270 is the (minimum) number of bits required to store a value
9271 of the type.
9272 This value is used to determine how tightly to pack
9273 records or arrays with components of this type, and also affects
9274 the semantics of unchecked conversion (unchecked conversions where
9275 the @code{Value_Size} values differ generate a warning, and are potentially
9276 target dependent).
9278 The default rules for the value of @code{Value_Size} are as follows:
9280 @itemize @bullet
9281 @item
9282 The @code{Value_Size} for a base subtype is the minimum number of bits
9283 required to store all values of the type (including the sign bit
9284 only if negative values are possible).
9286 @item
9287 If a subtype statically matches the first subtype of a given type, then it has
9288 by default the same @code{Value_Size} as the first subtype.  This is a
9289 consequence of RM 13.1(14) (``if two subtypes statically match,
9290 then their subtype-specific aspects are the same''.)
9292 @item
9293 All other subtypes have a @code{Value_Size} corresponding to the minimum
9294 number of bits required to store all values of the subtype.  For
9295 dynamic bounds, it is assumed that the value can range down or up
9296 to the corresponding bound of the ancestor
9297 @end itemize
9299 @noindent
9300 The RM defined attribute @code{Size} corresponds to the
9301 @code{Value_Size} attribute.
9303 The @code{Size} attribute may be defined for a first-named subtype.  This sets
9304 the @code{Value_Size} of
9305 the first-named subtype to the given value, and the
9306 @code{Object_Size} of this first-named subtype to the given value padded up
9307 to an appropriate boundary.  It is a consequence of the default rules
9308 above that this @code{Object_Size} will apply to all further subtypes.  On the
9309 other hand, @code{Value_Size} is affected only for the first subtype, any
9310 dynamic subtypes obtained from it directly, and any statically matching
9311 subtypes.  The @code{Value_Size} of any other static subtypes is not affected.
9313 @code{Value_Size} and
9314 @code{Object_Size} may be explicitly set for any subtype using
9315 an attribute definition clause.  Note that the use of these attributes
9316 can cause the RM 13.1(14) rule to be violated.  If two access types
9317 reference aliased objects whose subtypes have differing @code{Object_Size}
9318 values as a result of explicit attribute definition clauses, then it
9319 is erroneous to convert from one access subtype to the other.
9321 At the implementation level, Esize stores the Object_Size and the
9322 RM_Size field stores the @code{Value_Size} (and hence the value of the
9323 @code{Size} attribute,
9324 which, as noted above, is equivalent to @code{Value_Size}).
9326 To get a feel for the difference, consider the following examples (note
9327 that in each case the base is @code{Short_Short_Integer} with a size of 8):
9329 @smallexample
9330                                        Object_Size     Value_Size
9332 type x1 is range 0 .. 5;                    8               3
9334 type x2 is range 0 .. 5;
9335 for x2'size use 12;                        16              12
9337 subtype x3 is x2 range 0 .. 3;             16               2
9339 subtype x4 is x2'base range 0 .. 10;        8               4
9341 subtype x5 is x2 range 0 .. dynamic;       16               3*
9343 subtype x6 is x2'base range 0 .. dynamic;   8               3*
9345 @end smallexample
9347 @noindent
9348 Note: the entries marked ``3*'' are not actually specified by the Ada 95 RM,
9349 but it seems in the spirit of the RM rules to allocate the minimum number
9350 of bits (here 3, given the range for @code{x2})
9351 known to be large enough to hold the given range of values.
9353 So far, so good, but GNAT has to obey the RM rules, so the question is
9354 under what conditions must the RM @code{Size} be used.
9355 The following is a list
9356 of the occasions on which the RM @code{Size} must be used:
9358 @itemize @bullet
9359 @item
9360 Component size for packed arrays or records
9362 @item
9363 Value of the attribute @code{Size} for a type
9365 @item
9366 Warning about sizes not matching for unchecked conversion
9367 @end itemize
9369 @noindent
9370 For record types, the @code{Object_Size} is always a multiple of the
9371 alignment of the type (this is true for all types). In some cases the
9372 @code{Value_Size} can be smaller. Consider:
9374 @smallexample
9375    type R is record
9376      X : Integer;
9377      Y : Character;
9378    end record;
9379 @end smallexample
9381 @noindent
9382 On a typical 32-bit architecture, the X component will be four bytes, and
9383 require four-byte alignment, and the Y component will be one byte. In this
9384 case @code{R'Value_Size} will be 40 (bits) since this is the minimum size
9385 required to store a value of this type, and for example, it is permissible
9386 to have a component of type R in an outer record whose component size is
9387 specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits),
9388 since it must be rounded up so that this value is a multiple of the
9389 alignment (4 bytes = 32 bits).
9391 @noindent
9392 For all other types, the @code{Object_Size}
9393 and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
9394 Only @code{Size} may be specified for such types.
9396 @node Component_Size Clauses
9397 @section Component_Size Clauses
9398 @cindex Component_Size Clause
9400 @noindent
9401 Normally, the value specified in a component size clause must be consistent
9402 with the subtype of the array component with regard to size and alignment.
9403 In other words, the value specified must be at least equal to the size
9404 of this subtype, and must be a multiple of the alignment value.
9406 In addition, component size clauses are allowed which cause the array
9407 to be packed, by specifying a smaller value.  The cases in which this
9408 is allowed are for component size values in the range 1 through 63.  The value
9409 specified must not be smaller than the Size of the subtype.  GNAT will
9410 accurately honor all packing requests in this range.  For example, if
9411 we have:
9413 @smallexample @c ada
9414 type r is array (1 .. 8) of Natural;
9415 for r'Component_Size use 31;
9416 @end smallexample
9418 @noindent
9419 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
9420 Of course access to the components of such an array is considerably
9421 less efficient than if the natural component size of 32 is used.
9423 Note that there is no point in giving both a component size clause
9424 and a pragma Pack for the same array type. if such duplicate
9425 clauses are given, the pragma Pack will be ignored.
9427 @node Bit_Order Clauses
9428 @section Bit_Order Clauses
9429 @cindex Bit_Order Clause
9430 @cindex bit ordering
9431 @cindex ordering, of bits
9433 @noindent
9434 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
9435 attribute.  The specification may either correspond to the default bit
9436 order for the target, in which case the specification has no effect and
9437 places no additional restrictions, or it may be for the non-standard
9438 setting (that is the opposite of the default).
9440 In the case where the non-standard value is specified, the effect is
9441 to renumber bits within each byte, but the ordering of bytes is not
9442 affected.  There are certain
9443 restrictions placed on component clauses as follows:
9445 @itemize @bullet
9447 @item Components fitting within a single storage unit.
9448 @noindent
9449 These are unrestricted, and the effect is merely to renumber bits.  For
9450 example if we are on a little-endian machine with @code{Low_Order_First}
9451 being the default, then the following two declarations have exactly
9452 the same effect:
9454 @smallexample @c ada
9455    type R1 is record
9456       A : Boolean;
9457       B : Integer range 1 .. 120;
9458    end record;
9460    for R1 use record
9461       A at 0 range 0 .. 0;
9462       B at 0 range 1 .. 7;
9463    end record;
9465    type R2 is record
9466       A : Boolean;
9467       B : Integer range 1 .. 120;
9468    end record;
9470    for R2'Bit_Order use High_Order_First;
9472    for R2 use record
9473       A at 0 range 7 .. 7;
9474       B at 0 range 0 .. 6;
9475    end record;
9476 @end smallexample
9478 @noindent
9479 The useful application here is to write the second declaration with the
9480 @code{Bit_Order} attribute definition clause, and know that it will be treated
9481 the same, regardless of whether the target is little-endian or big-endian.
9483 @item Components occupying an integral number of bytes.
9484 @noindent
9485 These are components that exactly fit in two or more bytes.  Such component
9486 declarations are allowed, but have no effect, since it is important to realize
9487 that the @code{Bit_Order} specification does not affect the ordering of bytes.
9488 In particular, the following attempt at getting an endian-independent integer
9489 does not work:
9491 @smallexample @c ada
9492    type R2 is record
9493       A : Integer;
9494    end record;
9496    for R2'Bit_Order use High_Order_First;
9498    for R2 use record
9499       A at 0 range 0 .. 31;
9500    end record;
9501 @end smallexample
9503 @noindent
9504 This declaration will result in a little-endian integer on a
9505 little-endian machine, and a big-endian integer on a big-endian machine.
9506 If byte flipping is required for interoperability between big- and
9507 little-endian machines, this must be explicitly programmed.  This capability
9508 is not provided by @code{Bit_Order}.
9510 @item Components that are positioned across byte boundaries
9511 @noindent
9512 but do not occupy an integral number of bytes.  Given that bytes are not
9513 reordered, such fields would occupy a non-contiguous sequence of bits
9514 in memory, requiring non-trivial code to reassemble.  They are for this
9515 reason not permitted, and any component clause specifying such a layout
9516 will be flagged as illegal by GNAT@.
9518 @end itemize
9520 @noindent
9521 Since the misconception that Bit_Order automatically deals with all
9522 endian-related incompatibilities is a common one, the specification of
9523 a component field that is an integral number of bytes will always
9524 generate a warning.  This warning may be suppressed using
9525 @code{pragma Suppress} if desired.  The following section contains additional
9526 details regarding the issue of byte ordering.
9528 @node Effect of Bit_Order on Byte Ordering
9529 @section Effect of Bit_Order on Byte Ordering
9530 @cindex byte ordering
9531 @cindex ordering, of bytes
9533 @noindent
9534 In this section we will review the effect of the @code{Bit_Order} attribute
9535 definition clause on byte ordering.  Briefly, it has no effect at all, but
9536 a detailed example will be helpful.  Before giving this
9537 example, let us review the precise
9538 definition of the effect of defining @code{Bit_Order}.  The effect of a
9539 non-standard bit order is described in section 15.5.3 of the Ada
9540 Reference Manual:
9542 @quotation
9543 2   A bit ordering is a method of interpreting the meaning of
9544 the storage place attributes.
9545 @end quotation
9547 @noindent
9548 To understand the precise definition of storage place attributes in
9549 this context, we visit section 13.5.1 of the manual:
9551 @quotation
9552 13   A record_representation_clause (without the mod_clause)
9553 specifies the layout.  The storage place attributes (see 13.5.2)
9554 are taken from the values of the position, first_bit, and last_bit
9555 expressions after normalizing those values so that first_bit is
9556 less than Storage_Unit.
9557 @end quotation
9559 @noindent
9560 The critical point here is that storage places are taken from
9561 the values after normalization, not before.  So the @code{Bit_Order}
9562 interpretation applies to normalized values.  The interpretation
9563 is described in the later part of the 15.5.3 paragraph:
9565 @quotation
9566 2   A bit ordering is a method of interpreting the meaning of
9567 the storage place attributes.  High_Order_First (known in the
9568 vernacular as ``big endian'') means that the first bit of a
9569 storage element (bit 0) is the most significant bit (interpreting
9570 the sequence of bits that represent a component as an unsigned
9571 integer value).  Low_Order_First (known in the vernacular as
9572 ``little endian'') means the opposite: the first bit is the
9573 least significant.
9574 @end quotation
9576 @noindent
9577 Note that the numbering is with respect to the bits of a storage
9578 unit.  In other words, the specification affects only the numbering
9579 of bits within a single storage unit.
9581 We can make the effect clearer by giving an example.
9583 Suppose that we have an external device which presents two bytes, the first
9584 byte presented, which is the first (low addressed byte) of the two byte
9585 record is called Master, and the second byte is called Slave.
9587 The left most (most significant bit is called Control for each byte, and
9588 the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
9589 (least significant) bit.
9591 On a big-endian machine, we can write the following representation clause
9593 @smallexample @c ada
9594    type Data is record
9595       Master_Control : Bit;
9596       Master_V1      : Bit;
9597       Master_V2      : Bit;
9598       Master_V3      : Bit;
9599       Master_V4      : Bit;
9600       Master_V5      : Bit;
9601       Master_V6      : Bit;
9602       Master_V7      : Bit;
9603       Slave_Control  : Bit;
9604       Slave_V1       : Bit;
9605       Slave_V2       : Bit;
9606       Slave_V3       : Bit;
9607       Slave_V4       : Bit;
9608       Slave_V5       : Bit;
9609       Slave_V6       : Bit;
9610       Slave_V7       : Bit;
9611    end record;
9613    for Data use record
9614       Master_Control at 0 range 0 .. 0;
9615       Master_V1      at 0 range 1 .. 1;
9616       Master_V2      at 0 range 2 .. 2;
9617       Master_V3      at 0 range 3 .. 3;
9618       Master_V4      at 0 range 4 .. 4;
9619       Master_V5      at 0 range 5 .. 5;
9620       Master_V6      at 0 range 6 .. 6;
9621       Master_V7      at 0 range 7 .. 7;
9622       Slave_Control  at 1 range 0 .. 0;
9623       Slave_V1       at 1 range 1 .. 1;
9624       Slave_V2       at 1 range 2 .. 2;
9625       Slave_V3       at 1 range 3 .. 3;
9626       Slave_V4       at 1 range 4 .. 4;
9627       Slave_V5       at 1 range 5 .. 5;
9628       Slave_V6       at 1 range 6 .. 6;
9629       Slave_V7       at 1 range 7 .. 7;
9630    end record;
9631 @end smallexample
9633 @noindent
9634 Now if we move this to a little endian machine, then the bit ordering within
9635 the byte is backwards, so we have to rewrite the record rep clause as:
9637 @smallexample @c ada
9638    for Data use record
9639       Master_Control at 0 range 7 .. 7;
9640       Master_V1      at 0 range 6 .. 6;
9641       Master_V2      at 0 range 5 .. 5;
9642       Master_V3      at 0 range 4 .. 4;
9643       Master_V4      at 0 range 3 .. 3;
9644       Master_V5      at 0 range 2 .. 2;
9645       Master_V6      at 0 range 1 .. 1;
9646       Master_V7      at 0 range 0 .. 0;
9647       Slave_Control  at 1 range 7 .. 7;
9648       Slave_V1       at 1 range 6 .. 6;
9649       Slave_V2       at 1 range 5 .. 5;
9650       Slave_V3       at 1 range 4 .. 4;
9651       Slave_V4       at 1 range 3 .. 3;
9652       Slave_V5       at 1 range 2 .. 2;
9653       Slave_V6       at 1 range 1 .. 1;
9654       Slave_V7       at 1 range 0 .. 0;
9655    end record;
9656 @end smallexample
9658 @noindent
9659 It is a nuisance to have to rewrite the clause, especially if
9660 the code has to be maintained on both machines.  However,
9661 this is a case that we can handle with the
9662 @code{Bit_Order} attribute if it is implemented.
9663 Note that the implementation is not required on byte addressed
9664 machines, but it is indeed implemented in GNAT.
9665 This means that we can simply use the
9666 first record clause, together with the declaration
9668 @smallexample @c ada
9669    for Data'Bit_Order use High_Order_First;
9670 @end smallexample
9672 @noindent
9673 and the effect is what is desired, namely the layout is exactly the same,
9674 independent of whether the code is compiled on a big-endian or little-endian
9675 machine.
9677 The important point to understand is that byte ordering is not affected.
9678 A @code{Bit_Order} attribute definition never affects which byte a field
9679 ends up in, only where it ends up in that byte.
9680 To make this clear, let us rewrite the record rep clause of the previous
9681 example as:
9683 @smallexample @c ada
9684    for Data'Bit_Order use High_Order_First;
9685    for Data use record
9686       Master_Control at 0 range  0 .. 0;
9687       Master_V1      at 0 range  1 .. 1;
9688       Master_V2      at 0 range  2 .. 2;
9689       Master_V3      at 0 range  3 .. 3;
9690       Master_V4      at 0 range  4 .. 4;
9691       Master_V5      at 0 range  5 .. 5;
9692       Master_V6      at 0 range  6 .. 6;
9693       Master_V7      at 0 range  7 .. 7;
9694       Slave_Control  at 0 range  8 .. 8;
9695       Slave_V1       at 0 range  9 .. 9;
9696       Slave_V2       at 0 range 10 .. 10;
9697       Slave_V3       at 0 range 11 .. 11;
9698       Slave_V4       at 0 range 12 .. 12;
9699       Slave_V5       at 0 range 13 .. 13;
9700       Slave_V6       at 0 range 14 .. 14;
9701       Slave_V7       at 0 range 15 .. 15;
9702    end record;
9703 @end smallexample
9705 @noindent
9706 This is exactly equivalent to saying (a repeat of the first example):
9708 @smallexample @c ada
9709    for Data'Bit_Order use High_Order_First;
9710    for Data use record
9711       Master_Control at 0 range 0 .. 0;
9712       Master_V1      at 0 range 1 .. 1;
9713       Master_V2      at 0 range 2 .. 2;
9714       Master_V3      at 0 range 3 .. 3;
9715       Master_V4      at 0 range 4 .. 4;
9716       Master_V5      at 0 range 5 .. 5;
9717       Master_V6      at 0 range 6 .. 6;
9718       Master_V7      at 0 range 7 .. 7;
9719       Slave_Control  at 1 range 0 .. 0;
9720       Slave_V1       at 1 range 1 .. 1;
9721       Slave_V2       at 1 range 2 .. 2;
9722       Slave_V3       at 1 range 3 .. 3;
9723       Slave_V4       at 1 range 4 .. 4;
9724       Slave_V5       at 1 range 5 .. 5;
9725       Slave_V6       at 1 range 6 .. 6;
9726       Slave_V7       at 1 range 7 .. 7;
9727    end record;
9728 @end smallexample
9730 @noindent
9731 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
9732 field.  The storage place attributes are obtained by normalizing the
9733 values given so that the @code{First_Bit} value is less than 8.  After
9734 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
9735 we specified in the other case.
9737 Now one might expect that the @code{Bit_Order} attribute might affect
9738 bit numbering within the entire record component (two bytes in this
9739 case, thus affecting which byte fields end up in), but that is not
9740 the way this feature is defined, it only affects numbering of bits,
9741 not which byte they end up in.
9743 Consequently it never makes sense to specify a starting bit number
9744 greater than 7 (for a byte addressable field) if an attribute
9745 definition for @code{Bit_Order} has been given, and indeed it
9746 may be actively confusing to specify such a value, so the compiler
9747 generates a warning for such usage.
9749 If you do need to control byte ordering then appropriate conditional
9750 values must be used.  If in our example, the slave byte came first on
9751 some machines we might write:
9753 @smallexample @c ada
9754    Master_Byte_First constant Boolean := @dots{};
9756    Master_Byte : constant Natural :=
9757                    1 - Boolean'Pos (Master_Byte_First);
9758    Slave_Byte  : constant Natural :=
9759                    Boolean'Pos (Master_Byte_First);
9761    for Data'Bit_Order use High_Order_First;
9762    for Data use record
9763       Master_Control at Master_Byte range 0 .. 0;
9764       Master_V1      at Master_Byte range 1 .. 1;
9765       Master_V2      at Master_Byte range 2 .. 2;
9766       Master_V3      at Master_Byte range 3 .. 3;
9767       Master_V4      at Master_Byte range 4 .. 4;
9768       Master_V5      at Master_Byte range 5 .. 5;
9769       Master_V6      at Master_Byte range 6 .. 6;
9770       Master_V7      at Master_Byte range 7 .. 7;
9771       Slave_Control  at Slave_Byte  range 0 .. 0;
9772       Slave_V1       at Slave_Byte  range 1 .. 1;
9773       Slave_V2       at Slave_Byte  range 2 .. 2;
9774       Slave_V3       at Slave_Byte  range 3 .. 3;
9775       Slave_V4       at Slave_Byte  range 4 .. 4;
9776       Slave_V5       at Slave_Byte  range 5 .. 5;
9777       Slave_V6       at Slave_Byte  range 6 .. 6;
9778       Slave_V7       at Slave_Byte  range 7 .. 7;
9779    end record;
9780 @end smallexample
9782 @noindent
9783 Now to switch between machines, all that is necessary is
9784 to set the boolean constant @code{Master_Byte_First} in
9785 an appropriate manner.
9787 @node Pragma Pack for Arrays
9788 @section Pragma Pack for Arrays
9789 @cindex Pragma Pack (for arrays)
9791 @noindent
9792 Pragma @code{Pack} applied to an array has no effect unless the component type
9793 is packable.  For a component type to be packable, it must be one of the
9794 following cases:
9796 @itemize @bullet
9797 @item
9798 Any scalar type
9799 @item
9800 Any type whose size is specified with a size clause
9801 @item
9802 Any packed array type with a static size
9803 @end itemize
9805 @noindent
9806 For all these cases, if the component subtype size is in the range
9807 1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
9808 component size were specified giving the component subtype size.
9809 For example if we have:
9811 @smallexample @c ada
9812    type r is range 0 .. 17;
9814    type ar is array (1 .. 8) of r;
9815    pragma Pack (ar);
9816 @end smallexample
9818 @noindent
9819 Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
9820 and the size of the array @code{ar} will be exactly 40 bits.
9822 Note that in some cases this rather fierce approach to packing can produce
9823 unexpected effects.  For example, in Ada 95, type Natural typically has a
9824 size of 31, meaning that if you pack an array of Natural, you get 31-bit
9825 close packing, which saves a few bits, but results in far less efficient
9826 access.  Since many other Ada compilers will ignore such a packing request,
9827 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
9828 might not be what is intended.  You can easily remove this warning by
9829 using an explicit @code{Component_Size} setting instead, which never generates
9830 a warning, since the intention of the programmer is clear in this case.
9832 GNAT treats packed arrays in one of two ways.  If the size of the array is
9833 known at compile time and is less than 64 bits, then internally the array
9834 is represented as a single modular type, of exactly the appropriate number
9835 of bits.  If the length is greater than 63 bits, or is not known at compile
9836 time, then the packed array is represented as an array of bytes, and the
9837 length is always a multiple of 8 bits.
9839 Note that to represent a packed array as a modular type, the alignment must
9840 be suitable for the modular type involved. For example, on typical machines
9841 a 32-bit packed array will be represented by a 32-bit modular integer with
9842 an alignment of four bytes. If you explicitly override the default alignment
9843 with an alignment clause that is too small, the modular representation
9844 cannot be used. For example, consider the following set of declarations:
9846 @smallexample @c ada
9847    type R is range 1 .. 3;
9848    type S is array (1 .. 31) of R;
9849    for S'Component_Size use 2;
9850    for S'Size use 62;
9851    for S'Alignment use 1;
9852 @end smallexample
9854 @noindent
9855 If the alignment clause were not present, then a 62-bit modular
9856 representation would be chosen (typically with an alignment of 4 or 8
9857 bytes depending on the target). But the default alignment is overridden
9858 with the explicit alignment clause. This means that the modular
9859 representation cannot be used, and instead the array of bytes
9860 representation must be used, meaning that the length must be a multiple
9861 of 8. Thus the above set of declarations will result in a diagnostic
9862 rejecting the size clause and noting that the minimum size allowed is 64.
9864 @cindex Pragma Pack (for type Natural)
9865 @cindex Pragma Pack warning
9867 One special case that is worth noting occurs when the base type of the
9868 component size is 8/16/32 and the subtype is one bit less. Notably this
9869 occurs with subtype @code{Natural}. Consider:
9871 @smallexample @c ada
9872    type Arr is array (1 .. 32) of Natural;
9873    pragma Pack (Arr);
9874 @end smallexample
9876 @noindent
9877 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
9878 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
9879 Ada 83 compilers did not attempt 31 bit packing.
9881 In Ada 95, @code{Natural'Size} is required to be 31. Furthermore, GNAT really
9882 does pack 31-bit subtype to 31 bits. This may result in a substantial
9883 unintended performance penalty when porting legacy Ada 83 code. To help
9884 prevent this, GNAT generates a warning in such cases. If you really want 31
9885 bit packing in a case like this, you can set the component size explicitly:
9887 @smallexample @c ada
9888    type Arr is array (1 .. 32) of Natural;
9889    for Arr'Component_Size use 31;
9890 @end smallexample
9892 @noindent
9893 Here 31-bit packing is achieved as required, and no warning is generated,
9894 since in this case the programmer intention is clear.
9896 @node Pragma Pack for Records
9897 @section Pragma Pack for Records
9898 @cindex Pragma Pack (for records)
9900 @noindent
9901 Pragma @code{Pack} applied to a record will pack the components to reduce
9902 wasted space from alignment gaps and by reducing the amount of space
9903 taken by components.  We distinguish between @emph{packable} components and
9904 @emph{non-packable} components.
9905 Components of the following types are considered packable:
9906 @itemize @bullet
9907 @item
9908 All primitive types are packable.
9910 @item
9911 Small packed arrays, whose size does not exceed 64 bits, and where the
9912 size is statically known at compile time, are represented internally
9913 as modular integers, and so they are also packable.
9915 @end itemize
9917 @noindent
9918 All packable components occupy the exact number of bits corresponding to
9919 their @code{Size} value, and are packed with no padding bits, i.e.@: they
9920 can start on an arbitrary bit boundary.
9922 All other types are non-packable, they occupy an integral number of
9923 storage units, and
9924 are placed at a boundary corresponding to their alignment requirements.
9926 For example, consider the record
9928 @smallexample @c ada
9929    type Rb1 is array (1 .. 13) of Boolean;
9930    pragma Pack (rb1);
9932    type Rb2 is array (1 .. 65) of Boolean;
9933    pragma Pack (rb2);
9935    type x2 is record
9936       l1 : Boolean;
9937       l2 : Duration;
9938       l3 : Float;
9939       l4 : Boolean;
9940       l5 : Rb1;
9941       l6 : Rb2;
9942    end record;
9943    pragma Pack (x2);
9944 @end smallexample
9946 @noindent
9947 The representation for the record x2 is as follows:
9949 @smallexample @c ada
9950 for x2'Size use 224;
9951 for x2 use record
9952    l1 at  0 range  0 .. 0;
9953    l2 at  0 range  1 .. 64;
9954    l3 at 12 range  0 .. 31;
9955    l4 at 16 range  0 .. 0;
9956    l5 at 16 range  1 .. 13;
9957    l6 at 18 range  0 .. 71;
9958 end record;
9959 @end smallexample
9961 @noindent
9962 Studying this example, we see that the packable fields @code{l1}
9963 and @code{l2} are
9964 of length equal to their sizes, and placed at specific bit boundaries (and
9965 not byte boundaries) to
9966 eliminate padding.  But @code{l3} is of a non-packable float type, so
9967 it is on the next appropriate alignment boundary.
9969 The next two fields are fully packable, so @code{l4} and @code{l5} are
9970 minimally packed with no gaps.  However, type @code{Rb2} is a packed
9971 array that is longer than 64 bits, so it is itself non-packable.  Thus
9972 the @code{l6} field is aligned to the next byte boundary, and takes an
9973 integral number of bytes, i.e.@: 72 bits.
9975 @node Record Representation Clauses
9976 @section Record Representation Clauses
9977 @cindex Record Representation Clause
9979 @noindent
9980 Record representation clauses may be given for all record types, including
9981 types obtained by record extension.  Component clauses are allowed for any
9982 static component.  The restrictions on component clauses depend on the type
9983 of the component.
9985 @cindex Component Clause
9986 For all components of an elementary type, the only restriction on component
9987 clauses is that the size must be at least the 'Size value of the type
9988 (actually the Value_Size).  There are no restrictions due to alignment,
9989 and such components may freely cross storage boundaries.
9991 Packed arrays with a size up to and including 64 bits are represented
9992 internally using a modular type with the appropriate number of bits, and
9993 thus the same lack of restriction applies.  For example, if you declare:
9995 @smallexample @c ada
9996    type R is array (1 .. 49) of Boolean;
9997    pragma Pack (R);
9998    for R'Size use 49;
9999 @end smallexample
10001 @noindent
10002 then a component clause for a component of type R may start on any
10003 specified bit boundary, and may specify a value of 49 bits or greater.
10005 For packed bit arrays that are longer than 64 bits, there are two
10006 cases. If the component size is a power of 2 (1,2,4,8,16,32 bits),
10007 including the important case of single bits or boolean values, then
10008 there are no limitations on placement of such components, and they
10009 may start and end at arbitrary bit boundaries.
10011 If the component size is not a power of 2 (e.g. 3 or 5), then
10012 an array of this type longer than 64 bits must always be placed on
10013 on a storage unit (byte) boundary and occupy an integral number
10014 of storage units (bytes). Any component clause that does not
10015 meet this requirement will be rejected.
10017 Any aliased component, or component of an aliased type, must
10018 have its normal alignment and size. A component clause that
10019 does not meet this requirement will be rejected.
10021 The tag field of a tagged type always occupies an address sized field at
10022 the start of the record.  No component clause may attempt to overlay this
10023 tag. When a tagged type appears as a component, the tag field must have
10024 proper alignment
10026 In the case of a record extension T1, of a type T, no component clause applied
10027 to the type T1 can specify a storage location that would overlap the first
10028 T'Size bytes of the record.
10030 For all other component types, including non-bit-packed arrays,
10031 the component can be placed at an arbitrary bit boundary,
10032 so for example, the following is permitted:
10034 @smallexample @c ada
10035    type R is array (1 .. 10) of Boolean;
10036    for R'Size use 80;
10038    type Q is record
10039       G, H : Boolean;
10040       L, M : R;
10041    end record;
10043    for Q use record
10044       G at 0 range  0 ..   0;
10045       H at 0 range  1 ..   1;
10046       L at 0 range  2 ..  81;
10047       R at 0 range 82 .. 161;
10048    end record;
10049 @end smallexample
10051 @noindent
10052 Note: the above rules apply to recent releases of GNAT 5.
10053 In GNAT 3, there are more severe restrictions on larger components.
10054 For non-primitive types, including packed arrays with a size greater than
10055 64 bits, component clauses must respect the alignment requirement of the
10056 type, in particular, always starting on a byte boundary, and the length
10057 must be a multiple of the storage unit.
10059 @node Enumeration Clauses
10060 @section Enumeration Clauses
10062 The only restriction on enumeration clauses is that the range of values
10063 must be representable.  For the signed case, if one or more of the
10064 representation values are negative, all values must be in the range:
10066 @smallexample @c ada
10067    System.Min_Int .. System.Max_Int
10068 @end smallexample
10070 @noindent
10071 For the unsigned case, where all values are non negative, the values must
10072 be in the range:
10074 @smallexample @c ada
10075    0 .. System.Max_Binary_Modulus;
10076 @end smallexample
10078 @noindent
10079 A @emph{confirming} representation clause is one in which the values range
10080 from 0 in sequence, i.e.@: a clause that confirms the default representation
10081 for an enumeration type.
10082 Such a confirming representation
10083 is permitted by these rules, and is specially recognized by the compiler so
10084 that no extra overhead results from the use of such a clause.
10086 If an array has an index type which is an enumeration type to which an
10087 enumeration clause has been applied, then the array is stored in a compact
10088 manner.  Consider the declarations:
10090 @smallexample @c ada
10091    type r is (A, B, C);
10092    for r use (A => 1, B => 5, C => 10);
10093    type t is array (r) of Character;
10094 @end smallexample
10096 @noindent
10097 The array type t corresponds to a vector with exactly three elements and
10098 has a default size equal to @code{3*Character'Size}.  This ensures efficient
10099 use of space, but means that accesses to elements of the array will incur
10100 the overhead of converting representation values to the corresponding
10101 positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
10103 @node Address Clauses
10104 @section Address Clauses
10105 @cindex Address Clause
10107 The reference manual allows a general restriction on representation clauses,
10108 as found in RM 13.1(22):
10110 @quotation
10111 An implementation need not support representation
10112 items containing nonstatic expressions, except that
10113 an implementation should support a representation item
10114 for a given entity if each nonstatic expression in the
10115 representation item is a name that statically denotes
10116 a constant declared before the entity.
10117 @end quotation
10119 @noindent
10120 In practice this is applicable only to address clauses, since this is the
10121 only case in which a non-static expression is permitted by the syntax.  As
10122 the AARM notes in sections 13.1 (22.a-22.h):
10124 @display
10125   22.a   Reason: This is to avoid the following sort of thing:
10127   22.b        X : Integer := F(@dots{});
10128               Y : Address := G(@dots{});
10129               for X'Address use Y;
10131   22.c   In the above, we have to evaluate the
10132          initialization expression for X before we
10133          know where to put the result.  This seems
10134          like an unreasonable implementation burden.
10136   22.d   The above code should instead be written
10137          like this:
10139   22.e        Y : constant Address := G(@dots{});
10140               X : Integer := F(@dots{});
10141               for X'Address use Y;
10143   22.f   This allows the expression ``Y'' to be safely
10144          evaluated before X is created.
10146   22.g   The constant could be a formal parameter of mode in.
10148   22.h   An implementation can support other nonstatic
10149          expressions if it wants to.  Expressions of type
10150          Address are hardly ever static, but their value
10151          might be known at compile time anyway in many
10152          cases.
10153 @end display
10155 @noindent
10156 GNAT does indeed permit many additional cases of non-static expressions.  In
10157 particular, if the type involved is elementary there are no restrictions
10158 (since in this case, holding a temporary copy of the initialization value,
10159 if one is present, is inexpensive).  In addition, if there is no implicit or
10160 explicit initialization, then there are no restrictions.  GNAT will reject
10161 only the case where all three of these conditions hold:
10163 @itemize @bullet
10165 @item
10166 The type of the item is non-elementary (e.g.@: a record or array).
10168 @item
10169 There is explicit or implicit initialization required for the object.
10170 Note that access values are always implicitly initialized, and also
10171 in GNAT, certain bit-packed arrays (those having a dynamic length or
10172 a length greater than 64) will also be implicitly initialized to zero.
10174 @item
10175 The address value is non-static.  Here GNAT is more permissive than the
10176 RM, and allows the address value to be the address of a previously declared
10177 stand-alone variable, as long as it does not itself have an address clause.
10179 @smallexample @c ada
10180            Anchor  : Some_Initialized_Type;
10181            Overlay : Some_Initialized_Type;
10182            for Overlay'Address use Anchor'Address;
10183 @end smallexample
10185 @noindent
10186 However, the prefix of the address clause cannot be an array component, or
10187 a component of a discriminated record.
10189 @end itemize
10191 @noindent
10192 As noted above in section 22.h, address values are typically non-static.  In
10193 particular the To_Address function, even if applied to a literal value, is
10194 a non-static function call.  To avoid this minor annoyance, GNAT provides
10195 the implementation defined attribute 'To_Address.  The following two
10196 expressions have identical values:
10198 @findex Attribute
10199 @findex To_Address
10200 @smallexample @c ada
10201    To_Address (16#1234_0000#)
10202    System'To_Address (16#1234_0000#);
10203 @end smallexample
10205 @noindent
10206 except that the second form is considered to be a static expression, and
10207 thus when used as an address clause value is always permitted.
10209 @noindent
10210 Additionally, GNAT treats as static an address clause that is an
10211 unchecked_conversion of a static integer value.  This simplifies the porting
10212 of legacy code, and provides a portable equivalent to the GNAT attribute
10213 @code{To_Address}.
10215 Another issue with address clauses is the interaction with alignment
10216 requirements.  When an address clause is given for an object, the address
10217 value must be consistent with the alignment of the object (which is usually
10218 the same as the alignment of the type of the object).  If an address clause
10219 is given that specifies an inappropriately aligned address value, then the
10220 program execution is erroneous.
10222 Since this source of erroneous behavior can have unfortunate effects, GNAT
10223 checks (at compile time if possible, generating a warning, or at execution
10224 time with a run-time check) that the alignment is appropriate.  If the
10225 run-time check fails, then @code{Program_Error} is raised.  This run-time
10226 check is suppressed if range checks are suppressed, or if
10227 @code{pragma Restrictions (No_Elaboration_Code)} is in effect.
10229 @findex Export
10230 An address clause cannot be given for an exported object.  More
10231 understandably the real restriction is that objects with an address
10232 clause cannot be exported.  This is because such variables are not
10233 defined by the Ada program, so there is no external object to export.
10235 @findex Import
10236 It is permissible to give an address clause and a pragma Import for the
10237 same object.  In this case, the variable is not really defined by the
10238 Ada program, so there is no external symbol to be linked.  The link name
10239 and the external name are ignored in this case.  The reason that we allow this
10240 combination is that it provides a useful idiom to avoid unwanted
10241 initializations on objects with address clauses.
10243 When an address clause is given for an object that has implicit or
10244 explicit initialization, then by default initialization takes place.  This
10245 means that the effect of the object declaration is to overwrite the
10246 memory at the specified address.  This is almost always not what the
10247 programmer wants, so GNAT will output a warning:
10249 @smallexample
10250   with System;
10251   package G is
10252      type R is record
10253         M : Integer := 0;
10254      end record;
10256      Ext : R;
10257      for Ext'Address use System'To_Address (16#1234_1234#);
10258          |
10259   >>> warning: implicit initialization of "Ext" may
10260       modify overlaid storage
10261   >>> warning: use pragma Import for "Ext" to suppress
10262       initialization (RM B(24))
10264   end G;
10265 @end smallexample
10267 @noindent
10268 As indicated by the warning message, the solution is to use a (dummy) pragma
10269 Import to suppress this initialization.  The pragma tell the compiler that the
10270 object is declared and initialized elsewhere.  The following package compiles
10271 without warnings (and the initialization is suppressed):
10273 @smallexample @c ada
10274    with System;
10275    package G is
10276       type R is record
10277          M : Integer := 0;
10278       end record;
10280       Ext : R;
10281       for Ext'Address use System'To_Address (16#1234_1234#);
10282       pragma Import (Ada, Ext);
10283    end G;
10284 @end smallexample
10286 @noindent
10287 A final issue with address clauses involves their use for overlaying
10288 variables, as in the following example:
10289 @cindex Overlaying of objects
10291 @smallexample @c ada
10292   A : Integer;
10293   B : Integer;
10294   for B'Address use A'Address;
10295 @end smallexample
10297 @noindent
10298 or alternatively, using the form recommended by the RM:
10300 @smallexample @c ada
10301   A    : Integer;
10302   Addr : constant Address := A'Address;
10303   B    : Integer;
10304   for B'Address use Addr;
10305 @end smallexample
10307 @noindent
10308 In both of these cases, @code{A}
10309 and @code{B} become aliased to one another via the
10310 address clause. This use of address clauses to overlay
10311 variables, achieving an effect similar to unchecked
10312 conversion was erroneous in Ada 83, but in Ada 95
10313 the effect is implementation defined. Furthermore, the
10314 Ada 95 RM specifically recommends that in a situation
10315 like this, @code{B} should be subject to the following
10316 implementation advice (RM 13.3(19)):
10318 @quotation
10319 19  If the Address of an object is specified, or it is imported
10320     or exported, then the implementation should not perform
10321     optimizations based on assumptions of no aliases.
10322 @end quotation
10324 @noindent
10325 GNAT follows this recommendation, and goes further by also applying
10326 this recommendation to the overlaid variable (@code{A}
10327 in the above example) in this case. This means that the overlay
10328 works "as expected", in that a modification to one of the variables
10329 will affect the value of the other.
10331 @node Effect of Convention on Representation
10332 @section Effect of Convention on Representation
10333 @cindex Convention, effect on representation
10335 @noindent
10336 Normally the specification of a foreign language convention for a type or
10337 an object has no effect on the chosen representation.  In particular, the
10338 representation chosen for data in GNAT generally meets the standard system
10339 conventions, and for example records are laid out in a manner that is
10340 consistent with C@.  This means that specifying convention C (for example)
10341 has no effect.
10343 There are three exceptions to this general rule:
10345 @itemize @bullet
10347 @item Convention Fortran and array subtypes
10348 If pragma Convention Fortran is specified for an array subtype, then in
10349 accordance with the implementation advice in section 3.6.2(11) of the
10350 Ada Reference Manual, the array will be stored in a Fortran-compatible
10351 column-major manner, instead of the normal default row-major order.
10353 @item Convention C and enumeration types
10354 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
10355 to accommodate all values of the type.  For example, for the enumeration
10356 type declared by:
10358 @smallexample @c ada
10359    type Color is (Red, Green, Blue);
10360 @end smallexample
10362 @noindent
10363 8 bits is sufficient to store all values of the type, so by default, objects
10364 of type @code{Color} will be represented using 8 bits.  However, normal C
10365 convention is to use 32 bits for all enum values in C, since enum values
10366 are essentially of type int.  If pragma @code{Convention C} is specified for an
10367 Ada enumeration type, then the size is modified as necessary (usually to
10368 32 bits) to be consistent with the C convention for enum values.
10370 @item Convention C/Fortran and Boolean types
10371 In C, the usual convention for boolean values, that is values used for
10372 conditions, is that zero represents false, and nonzero values represent
10373 true.  In Ada, the normal convention is that two specific values, typically
10374 0/1, are used to represent false/true respectively.
10376 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
10377 value represents true).
10379 To accommodate the Fortran and C conventions, if a pragma Convention specifies
10380 C or Fortran convention for a derived Boolean, as in the following example:
10382 @smallexample @c ada
10383    type C_Switch is new Boolean;
10384    pragma Convention (C, C_Switch);
10385 @end smallexample
10387 @noindent
10388 then the GNAT generated code will treat any nonzero value as true.  For truth
10389 values generated by GNAT, the conventional value 1 will be used for True, but
10390 when one of these values is read, any nonzero value is treated as True.
10392 @end itemize
10394 @node Determining the Representations chosen by GNAT
10395 @section Determining the Representations chosen by GNAT
10396 @cindex Representation, determination of
10397 @cindex @code{-gnatR} switch
10399 @noindent
10400 Although the descriptions in this section are intended to be complete, it is
10401 often easier to simply experiment to see what GNAT accepts and what the
10402 effect is on the layout of types and objects.
10404 As required by the Ada RM, if a representation clause is not accepted, then
10405 it must be rejected as illegal by the compiler.  However, when a
10406 representation clause or pragma is accepted, there can still be questions
10407 of what the compiler actually does.  For example, if a partial record
10408 representation clause specifies the location of some components and not
10409 others, then where are the non-specified components placed? Or if pragma
10410 @code{Pack} is used on a record, then exactly where are the resulting
10411 fields placed? The section on pragma @code{Pack} in this chapter can be
10412 used to answer the second question, but it is often easier to just see
10413 what the compiler does.
10415 For this purpose, GNAT provides the option @code{-gnatR}.  If you compile
10416 with this option, then the compiler will output information on the actual
10417 representations chosen, in a format similar to source representation
10418 clauses.  For example, if we compile the package:
10420 @smallexample @c ada
10421 package q is
10422    type r (x : boolean) is tagged record
10423       case x is
10424          when True => S : String (1 .. 100);
10425          when False => null;
10426       end case;
10427    end record;
10429    type r2 is new r (false) with record
10430       y2 : integer;
10431    end record;
10433    for r2 use record
10434       y2 at 16 range 0 .. 31;
10435    end record;
10437    type x is record
10438       y : character;
10439    end record;
10441    type x1 is array (1 .. 10) of x;
10442    for x1'component_size use 11;
10444    type ia is access integer;
10446    type Rb1 is array (1 .. 13) of Boolean;
10447    pragma Pack (rb1);
10449    type Rb2 is array (1 .. 65) of Boolean;
10450    pragma Pack (rb2);
10452    type x2 is record
10453       l1 : Boolean;
10454       l2 : Duration;
10455       l3 : Float;
10456       l4 : Boolean;
10457       l5 : Rb1;
10458       l6 : Rb2;
10459    end record;
10460    pragma Pack (x2);
10461 end q;
10462 @end smallexample
10464 @noindent
10465 using the switch @code{-gnatR} we obtain the following output:
10467 @smallexample
10468 Representation information for unit q
10469 -------------------------------------
10471 for r'Size use ??;
10472 for r'Alignment use 4;
10473 for r use record
10474    x    at 4 range  0 .. 7;
10475    _tag at 0 range  0 .. 31;
10476    s    at 5 range  0 .. 799;
10477 end record;
10479 for r2'Size use 160;
10480 for r2'Alignment use 4;
10481 for r2 use record
10482    x       at  4 range  0 .. 7;
10483    _tag    at  0 range  0 .. 31;
10484    _parent at  0 range  0 .. 63;
10485    y2      at 16 range  0 .. 31;
10486 end record;
10488 for x'Size use 8;
10489 for x'Alignment use 1;
10490 for x use record
10491    y at 0 range  0 .. 7;
10492 end record;
10494 for x1'Size use 112;
10495 for x1'Alignment use 1;
10496 for x1'Component_Size use 11;
10498 for rb1'Size use 13;
10499 for rb1'Alignment use 2;
10500 for rb1'Component_Size use 1;
10502 for rb2'Size use 72;
10503 for rb2'Alignment use 1;
10504 for rb2'Component_Size use 1;
10506 for x2'Size use 224;
10507 for x2'Alignment use 4;
10508 for x2 use record
10509    l1 at  0 range  0 .. 0;
10510    l2 at  0 range  1 .. 64;
10511    l3 at 12 range  0 .. 31;
10512    l4 at 16 range  0 .. 0;
10513    l5 at 16 range  1 .. 13;
10514    l6 at 18 range  0 .. 71;
10515 end record;
10516 @end smallexample
10518 @noindent
10519 The Size values are actually the Object_Size, i.e.@: the default size that
10520 will be allocated for objects of the type.
10521 The ?? size for type r indicates that we have a variant record, and the
10522 actual size of objects will depend on the discriminant value.
10524 The Alignment values show the actual alignment chosen by the compiler
10525 for each record or array type.
10527 The record representation clause for type r shows where all fields
10528 are placed, including the compiler generated tag field (whose location
10529 cannot be controlled by the programmer).
10531 The record representation clause for the type extension r2 shows all the
10532 fields present, including the parent field, which is a copy of the fields
10533 of the parent type of r2, i.e.@: r1.
10535 The component size and size clauses for types rb1 and rb2 show
10536 the exact effect of pragma @code{Pack} on these arrays, and the record
10537 representation clause for type x2 shows how pragma @code{Pack} affects
10538 this record type.
10540 In some cases, it may be useful to cut and paste the representation clauses
10541 generated by the compiler into the original source to fix and guarantee
10542 the actual representation to be used.
10544 @node Standard Library Routines
10545 @chapter Standard Library Routines
10547 @noindent
10548 The Ada 95 Reference Manual contains in Annex A a full description of an
10549 extensive set of standard library routines that can be used in any Ada
10550 program, and which must be provided by all Ada compilers.  They are
10551 analogous to the standard C library used by C programs.
10553 GNAT implements all of the facilities described in annex A, and for most
10554 purposes the description in the Ada 95
10555 reference manual, or appropriate Ada
10556 text book, will be sufficient for making use of these facilities.
10558 In the case of the input-output facilities,
10559 @xref{The Implementation of Standard I/O},
10560 gives details on exactly how GNAT interfaces to the
10561 file system.  For the remaining packages, the Ada 95 reference manual
10562 should be sufficient.  The following is a list of the packages included,
10563 together with a brief description of the functionality that is provided.
10565 For completeness, references are included to other predefined library
10566 routines defined in other sections of the Ada 95 reference manual (these are
10567 cross-indexed from annex A).
10569 @table @code
10570 @item Ada (A.2)
10571 This is a parent package for all the standard library packages.  It is
10572 usually included implicitly in your program, and itself contains no
10573 useful data or routines.
10575 @item Ada.Calendar (9.6)
10576 @code{Calendar} provides time of day access, and routines for
10577 manipulating times and durations.
10579 @item Ada.Characters (A.3.1)
10580 This is a dummy parent package that contains no useful entities
10582 @item Ada.Characters.Handling (A.3.2)
10583 This package provides some basic character handling capabilities,
10584 including classification functions for classes of characters (e.g.@: test
10585 for letters, or digits).
10587 @item Ada.Characters.Latin_1 (A.3.3)
10588 This package includes a complete set of definitions of the characters
10589 that appear in type CHARACTER@.  It is useful for writing programs that
10590 will run in international environments.  For example, if you want an
10591 upper case E with an acute accent in a string, it is often better to use
10592 the definition of @code{UC_E_Acute} in this package.  Then your program
10593 will print in an understandable manner even if your environment does not
10594 support these extended characters.
10596 @item Ada.Command_Line (A.15)
10597 This package provides access to the command line parameters and the name
10598 of the current program (analogous to the use of @code{argc} and @code{argv}
10599 in C), and also allows the exit status for the program to be set in a
10600 system-independent manner.
10602 @item Ada.Decimal (F.2)
10603 This package provides constants describing the range of decimal numbers
10604 implemented, and also a decimal divide routine (analogous to the COBOL
10605 verb DIVIDE .. GIVING .. REMAINDER ..)
10607 @item Ada.Direct_IO (A.8.4)
10608 This package provides input-output using a model of a set of records of
10609 fixed-length, containing an arbitrary definite Ada type, indexed by an
10610 integer record number.
10612 @item Ada.Dynamic_Priorities (D.5)
10613 This package allows the priorities of a task to be adjusted dynamically
10614 as the task is running.
10616 @item Ada.Exceptions (11.4.1)
10617 This package provides additional information on exceptions, and also
10618 contains facilities for treating exceptions as data objects, and raising
10619 exceptions with associated messages.
10621 @item Ada.Finalization (7.6)
10622 This package contains the declarations and subprograms to support the
10623 use of controlled types, providing for automatic initialization and
10624 finalization (analogous to the constructors and destructors of C++)
10626 @item Ada.Interrupts (C.3.2)
10627 This package provides facilities for interfacing to interrupts, which
10628 includes the set of signals or conditions that can be raised and
10629 recognized as interrupts.
10631 @item Ada.Interrupts.Names (C.3.2)
10632 This package provides the set of interrupt names (actually signal
10633 or condition names) that can be handled by GNAT@.
10635 @item Ada.IO_Exceptions (A.13)
10636 This package defines the set of exceptions that can be raised by use of
10637 the standard IO packages.
10639 @item Ada.Numerics
10640 This package contains some standard constants and exceptions used
10641 throughout the numerics packages.  Note that the constants pi and e are
10642 defined here, and it is better to use these definitions than rolling
10643 your own.
10645 @item Ada.Numerics.Complex_Elementary_Functions
10646 Provides the implementation of standard elementary functions (such as
10647 log and trigonometric functions) operating on complex numbers using the
10648 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
10649 created by the package @code{Numerics.Complex_Types}.
10651 @item Ada.Numerics.Complex_Types
10652 This is a predefined instantiation of
10653 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
10654 build the type @code{Complex} and @code{Imaginary}.
10656 @item Ada.Numerics.Discrete_Random
10657 This package provides a random number generator suitable for generating
10658 random integer values from a specified range.
10660 @item Ada.Numerics.Float_Random
10661 This package provides a random number generator suitable for generating
10662 uniformly distributed floating point values.
10664 @item Ada.Numerics.Generic_Complex_Elementary_Functions
10665 This is a generic version of the package that provides the
10666 implementation of standard elementary functions (such as log and
10667 trigonometric functions) for an arbitrary complex type.
10669 The following predefined instantiations of this package are provided:
10671 @table @code
10672 @item Short_Float
10673 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
10674 @item Float
10675 @code{Ada.Numerics.Complex_Elementary_Functions}
10676 @item Long_Float
10677 @code{Ada.Numerics.
10678  Long_Complex_Elementary_Functions}
10679 @end table
10681 @item Ada.Numerics.Generic_Complex_Types
10682 This is a generic package that allows the creation of complex types,
10683 with associated complex arithmetic operations.
10685 The following predefined instantiations of this package exist
10686 @table @code
10687 @item Short_Float
10688 @code{Ada.Numerics.Short_Complex_Complex_Types}
10689 @item Float
10690 @code{Ada.Numerics.Complex_Complex_Types}
10691 @item Long_Float
10692 @code{Ada.Numerics.Long_Complex_Complex_Types}
10693 @end table
10695 @item Ada.Numerics.Generic_Elementary_Functions
10696 This is a generic package that provides the implementation of standard
10697 elementary functions (such as log an trigonometric functions) for an
10698 arbitrary float type.
10700 The following predefined instantiations of this package exist
10702 @table @code
10703 @item Short_Float
10704 @code{Ada.Numerics.Short_Elementary_Functions}
10705 @item Float
10706 @code{Ada.Numerics.Elementary_Functions}
10707 @item Long_Float
10708 @code{Ada.Numerics.Long_Elementary_Functions}
10709 @end table
10711 @item Ada.Real_Time (D.8)
10712 This package provides facilities similar to those of @code{Calendar}, but
10713 operating with a finer clock suitable for real time control. Note that
10714 annex D requires that there be no backward clock jumps, and GNAT generally
10715 guarantees this behavior, but of course if the external clock on which
10716 the GNAT runtime depends is deliberately reset by some external event,
10717 then such a backward jump may occur.
10719 @item Ada.Sequential_IO (A.8.1)
10720 This package provides input-output facilities for sequential files,
10721 which can contain a sequence of values of a single type, which can be
10722 any Ada type, including indefinite (unconstrained) types.
10724 @item Ada.Storage_IO (A.9)
10725 This package provides a facility for mapping arbitrary Ada types to and
10726 from a storage buffer.  It is primarily intended for the creation of new
10727 IO packages.
10729 @item Ada.Streams (13.13.1)
10730 This is a generic package that provides the basic support for the
10731 concept of streams as used by the stream attributes (@code{Input},
10732 @code{Output}, @code{Read} and @code{Write}).
10734 @item Ada.Streams.Stream_IO (A.12.1)
10735 This package is a specialization of the type @code{Streams} defined in
10736 package @code{Streams} together with a set of operations providing
10737 Stream_IO capability.  The Stream_IO model permits both random and
10738 sequential access to a file which can contain an arbitrary set of values
10739 of one or more Ada types.
10741 @item Ada.Strings (A.4.1)
10742 This package provides some basic constants used by the string handling
10743 packages.
10745 @item Ada.Strings.Bounded (A.4.4)
10746 This package provides facilities for handling variable length
10747 strings.  The bounded model requires a maximum length.  It is thus
10748 somewhat more limited than the unbounded model, but avoids the use of
10749 dynamic allocation or finalization.
10751 @item Ada.Strings.Fixed (A.4.3)
10752 This package provides facilities for handling fixed length strings.
10754 @item Ada.Strings.Maps (A.4.2)
10755 This package provides facilities for handling character mappings and
10756 arbitrarily defined subsets of characters.  For instance it is useful in
10757 defining specialized translation tables.
10759 @item Ada.Strings.Maps.Constants (A.4.6)
10760 This package provides a standard set of predefined mappings and
10761 predefined character sets.  For example, the standard upper to lower case
10762 conversion table is found in this package.  Note that upper to lower case
10763 conversion is non-trivial if you want to take the entire set of
10764 characters, including extended characters like E with an acute accent,
10765 into account.  You should use the mappings in this package (rather than
10766 adding 32 yourself) to do case mappings.
10768 @item Ada.Strings.Unbounded (A.4.5)
10769 This package provides facilities for handling variable length
10770 strings.  The unbounded model allows arbitrary length strings, but
10771 requires the use of dynamic allocation and finalization.
10773 @item Ada.Strings.Wide_Bounded (A.4.7)
10774 @itemx Ada.Strings.Wide_Fixed (A.4.7)
10775 @itemx Ada.Strings.Wide_Maps (A.4.7)
10776 @itemx Ada.Strings.Wide_Maps.Constants (A.4.7)
10777 @itemx Ada.Strings.Wide_Unbounded (A.4.7)
10778 These packages provide analogous capabilities to the corresponding
10779 packages without @samp{Wide_} in the name, but operate with the types
10780 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
10781 and @code{Character}.
10783 @item Ada.Strings.Wide_Wide_Bounded (A.4.7)
10784 @itemx Ada.Strings.Wide_Wide_Fixed (A.4.7)
10785 @itemx Ada.Strings.Wide_Wide_Maps (A.4.7)
10786 @itemx Ada.Strings.Wide_Wide_Maps.Constants (A.4.7)
10787 @itemx Ada.Strings.Wide_Wide_Unbounded (A.4.7)
10788 These packages provide analogous capabilities to the corresponding
10789 packages without @samp{Wide_} in the name, but operate with the types
10790 @code{Wide_Wide_String} and @code{Wide_Wide_Character} instead
10791 of @code{String} and @code{Character}.
10793 @item Ada.Synchronous_Task_Control (D.10)
10794 This package provides some standard facilities for controlling task
10795 communication in a synchronous manner.
10797 @item Ada.Tags
10798 This package contains definitions for manipulation of the tags of tagged
10799 values.
10801 @item Ada.Task_Attributes
10802 This package provides the capability of associating arbitrary
10803 task-specific data with separate tasks.
10805 @item Ada.Text_IO
10806 This package provides basic text input-output capabilities for
10807 character, string and numeric data.  The subpackages of this
10808 package are listed next.
10810 @item Ada.Text_IO.Decimal_IO
10811 Provides input-output facilities for decimal fixed-point types
10813 @item Ada.Text_IO.Enumeration_IO
10814 Provides input-output facilities for enumeration types.
10816 @item Ada.Text_IO.Fixed_IO
10817 Provides input-output facilities for ordinary fixed-point types.
10819 @item Ada.Text_IO.Float_IO
10820 Provides input-output facilities for float types.  The following
10821 predefined instantiations of this generic package are available:
10823 @table @code
10824 @item Short_Float
10825 @code{Short_Float_Text_IO}
10826 @item Float
10827 @code{Float_Text_IO}
10828 @item Long_Float
10829 @code{Long_Float_Text_IO}
10830 @end table
10832 @item Ada.Text_IO.Integer_IO
10833 Provides input-output facilities for integer types.  The following
10834 predefined instantiations of this generic package are available:
10836 @table @code
10837 @item Short_Short_Integer
10838 @code{Ada.Short_Short_Integer_Text_IO}
10839 @item Short_Integer
10840 @code{Ada.Short_Integer_Text_IO}
10841 @item Integer
10842 @code{Ada.Integer_Text_IO}
10843 @item Long_Integer
10844 @code{Ada.Long_Integer_Text_IO}
10845 @item Long_Long_Integer
10846 @code{Ada.Long_Long_Integer_Text_IO}
10847 @end table
10849 @item Ada.Text_IO.Modular_IO
10850 Provides input-output facilities for modular (unsigned) types
10852 @item Ada.Text_IO.Complex_IO (G.1.3)
10853 This package provides basic text input-output capabilities for complex
10854 data.
10856 @item Ada.Text_IO.Editing (F.3.3)
10857 This package contains routines for edited output, analogous to the use
10858 of pictures in COBOL@.  The picture formats used by this package are a
10859 close copy of the facility in COBOL@.
10861 @item Ada.Text_IO.Text_Streams (A.12.2)
10862 This package provides a facility that allows Text_IO files to be treated
10863 as streams, so that the stream attributes can be used for writing
10864 arbitrary data, including binary data, to Text_IO files.
10866 @item Ada.Unchecked_Conversion (13.9)
10867 This generic package allows arbitrary conversion from one type to
10868 another of the same size, providing for breaking the type safety in
10869 special circumstances.
10871 If the types have the same Size (more accurately the same Value_Size),
10872 then the effect is simply to transfer the bits from the source to the
10873 target type without any modification.  This usage is well defined, and
10874 for simple types whose representation is typically the same across
10875 all implementations, gives a portable method of performing such
10876 conversions.
10878 If the types do not have the same size, then the result is implementation
10879 defined, and thus may be non-portable.  The following describes how GNAT
10880 handles such unchecked conversion cases.
10882 If the types are of different sizes, and are both discrete types, then
10883 the effect is of a normal type conversion without any constraint checking.
10884 In particular if the result type has a larger size, the result will be
10885 zero or sign extended.  If the result type has a smaller size, the result
10886 will be truncated by ignoring high order bits.
10888 If the types are of different sizes, and are not both discrete types,
10889 then the conversion works as though pointers were created to the source
10890 and target, and the pointer value is converted.  The effect is that bits
10891 are copied from successive low order storage units and bits of the source
10892 up to the length of the target type.
10894 A warning is issued if the lengths differ, since the effect in this
10895 case is implementation dependent, and the above behavior may not match
10896 that of some other compiler.
10898 A pointer to one type may be converted to a pointer to another type using
10899 unchecked conversion.  The only case in which the effect is undefined is
10900 when one or both pointers are pointers to unconstrained array types.  In
10901 this case, the bounds information may get incorrectly transferred, and in
10902 particular, GNAT uses double size pointers for such types, and it is
10903 meaningless to convert between such pointer types.  GNAT will issue a
10904 warning if the alignment of the target designated type is more strict
10905 than the alignment of the source designated type (since the result may
10906 be unaligned in this case).
10908 A pointer other than a pointer to an unconstrained array type may be
10909 converted to and from System.Address.  Such usage is common in Ada 83
10910 programs, but note that Ada.Address_To_Access_Conversions is the
10911 preferred method of performing such conversions in Ada 95.  Neither
10912 unchecked conversion nor Ada.Address_To_Access_Conversions should be
10913 used in conjunction with pointers to unconstrained objects, since
10914 the bounds information cannot be handled correctly in this case.
10916 @item Ada.Unchecked_Deallocation (13.11.2)
10917 This generic package allows explicit freeing of storage previously
10918 allocated by use of an allocator.
10920 @item Ada.Wide_Text_IO (A.11)
10921 This package is similar to @code{Ada.Text_IO}, except that the external
10922 file supports wide character representations, and the internal types are
10923 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
10924 and @code{String}.  It contains generic subpackages listed next.
10926 @item Ada.Wide_Text_IO.Decimal_IO
10927 Provides input-output facilities for decimal fixed-point types
10929 @item Ada.Wide_Text_IO.Enumeration_IO
10930 Provides input-output facilities for enumeration types.
10932 @item Ada.Wide_Text_IO.Fixed_IO
10933 Provides input-output facilities for ordinary fixed-point types.
10935 @item Ada.Wide_Text_IO.Float_IO
10936 Provides input-output facilities for float types.  The following
10937 predefined instantiations of this generic package are available:
10939 @table @code
10940 @item Short_Float
10941 @code{Short_Float_Wide_Text_IO}
10942 @item Float
10943 @code{Float_Wide_Text_IO}
10944 @item Long_Float
10945 @code{Long_Float_Wide_Text_IO}
10946 @end table
10948 @item Ada.Wide_Text_IO.Integer_IO
10949 Provides input-output facilities for integer types.  The following
10950 predefined instantiations of this generic package are available:
10952 @table @code
10953 @item Short_Short_Integer
10954 @code{Ada.Short_Short_Integer_Wide_Text_IO}
10955 @item Short_Integer
10956 @code{Ada.Short_Integer_Wide_Text_IO}
10957 @item Integer
10958 @code{Ada.Integer_Wide_Text_IO}
10959 @item Long_Integer
10960 @code{Ada.Long_Integer_Wide_Text_IO}
10961 @item Long_Long_Integer
10962 @code{Ada.Long_Long_Integer_Wide_Text_IO}
10963 @end table
10965 @item Ada.Wide_Text_IO.Modular_IO
10966 Provides input-output facilities for modular (unsigned) types
10968 @item Ada.Wide_Text_IO.Complex_IO (G.1.3)
10969 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
10970 external file supports wide character representations.
10972 @item Ada.Wide_Text_IO.Editing (F.3.4)
10973 This package is similar to @code{Ada.Text_IO.Editing}, except that the
10974 types are @code{Wide_Character} and @code{Wide_String} instead of
10975 @code{Character} and @code{String}.
10977 @item Ada.Wide_Text_IO.Streams (A.12.3)
10978 This package is similar to @code{Ada.Text_IO.Streams}, except that the
10979 types are @code{Wide_Character} and @code{Wide_String} instead of
10980 @code{Character} and @code{String}.
10982 @item Ada.Wide_Wide_Text_IO (A.11)
10983 This package is similar to @code{Ada.Text_IO}, except that the external
10984 file supports wide character representations, and the internal types are
10985 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
10986 and @code{String}.  It contains generic subpackages listed next.
10988 @item Ada.Wide_Wide_Text_IO.Decimal_IO
10989 Provides input-output facilities for decimal fixed-point types
10991 @item Ada.Wide_Wide_Text_IO.Enumeration_IO
10992 Provides input-output facilities for enumeration types.
10994 @item Ada.Wide_Wide_Text_IO.Fixed_IO
10995 Provides input-output facilities for ordinary fixed-point types.
10997 @item Ada.Wide_Wide_Text_IO.Float_IO
10998 Provides input-output facilities for float types.  The following
10999 predefined instantiations of this generic package are available:
11001 @table @code
11002 @item Short_Float
11003 @code{Short_Float_Wide_Wide_Text_IO}
11004 @item Float
11005 @code{Float_Wide_Wide_Text_IO}
11006 @item Long_Float
11007 @code{Long_Float_Wide_Wide_Text_IO}
11008 @end table
11010 @item Ada.Wide_Wide_Text_IO.Integer_IO
11011 Provides input-output facilities for integer types.  The following
11012 predefined instantiations of this generic package are available:
11014 @table @code
11015 @item Short_Short_Integer
11016 @code{Ada.Short_Short_Integer_Wide_Wide_Text_IO}
11017 @item Short_Integer
11018 @code{Ada.Short_Integer_Wide_Wide_Text_IO}
11019 @item Integer
11020 @code{Ada.Integer_Wide_Wide_Text_IO}
11021 @item Long_Integer
11022 @code{Ada.Long_Integer_Wide_Wide_Text_IO}
11023 @item Long_Long_Integer
11024 @code{Ada.Long_Long_Integer_Wide_Wide_Text_IO}
11025 @end table
11027 @item Ada.Wide_Wide_Text_IO.Modular_IO
11028 Provides input-output facilities for modular (unsigned) types
11030 @item Ada.Wide_Wide_Text_IO.Complex_IO (G.1.3)
11031 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
11032 external file supports wide character representations.
11034 @item Ada.Wide_Wide_Text_IO.Editing (F.3.4)
11035 This package is similar to @code{Ada.Text_IO.Editing}, except that the
11036 types are @code{Wide_Character} and @code{Wide_String} instead of
11037 @code{Character} and @code{String}.
11039 @item Ada.Wide_Wide_Text_IO.Streams (A.12.3)
11040 This package is similar to @code{Ada.Text_IO.Streams}, except that the
11041 types are @code{Wide_Character} and @code{Wide_String} instead of
11042 @code{Character} and @code{String}.
11043 @end table
11047 @node The Implementation of Standard I/O
11048 @chapter The Implementation of Standard I/O
11050 @noindent
11051 GNAT implements all the required input-output facilities described in
11052 A.6 through A.14.  These sections of the Ada 95 reference manual describe the
11053 required behavior of these packages from the Ada point of view, and if
11054 you are writing a portable Ada program that does not need to know the
11055 exact manner in which Ada maps to the outside world when it comes to
11056 reading or writing external files, then you do not need to read this
11057 chapter.  As long as your files are all regular files (not pipes or
11058 devices), and as long as you write and read the files only from Ada, the
11059 description in the Ada 95 reference manual is sufficient.
11061 However, if you want to do input-output to pipes or other devices, such
11062 as the keyboard or screen, or if the files you are dealing with are
11063 either generated by some other language, or to be read by some other
11064 language, then you need to know more about the details of how the GNAT
11065 implementation of these input-output facilities behaves.
11067 In this chapter we give a detailed description of exactly how GNAT
11068 interfaces to the file system.  As always, the sources of the system are
11069 available to you for answering questions at an even more detailed level,
11070 but for most purposes the information in this chapter will suffice.
11072 Another reason that you may need to know more about how input-output is
11073 implemented arises when you have a program written in mixed languages
11074 where, for example, files are shared between the C and Ada sections of
11075 the same program.  GNAT provides some additional facilities, in the form
11076 of additional child library packages, that facilitate this sharing, and
11077 these additional facilities are also described in this chapter.
11079 @menu
11080 * Standard I/O Packages::
11081 * FORM Strings::
11082 * Direct_IO::
11083 * Sequential_IO::
11084 * Text_IO::
11085 * Wide_Text_IO::
11086 * Wide_Wide_Text_IO::
11087 * Stream_IO::
11088 * Shared Files::
11089 * Open Modes::
11090 * Operations on C Streams::
11091 * Interfacing to C Streams::
11092 @end menu
11094 @node Standard I/O Packages
11095 @section Standard I/O Packages
11097 @noindent
11098 The Standard I/O packages described in Annex A for
11100 @itemize @bullet
11101 @item
11102 Ada.Text_IO
11103 @item
11104 Ada.Text_IO.Complex_IO
11105 @item
11106 Ada.Text_IO.Text_Streams
11107 @item
11108 Ada.Wide_Text_IO
11109 @item
11110 Ada.Wide_Text_IO.Complex_IO
11111 @item
11112 Ada.Wide_Text_IO.Text_Streams
11113 @item
11114 Ada.Wide_Wide_Text_IO
11115 @item
11116 Ada.Wide_Wide_Text_IO.Complex_IO
11117 @item
11118 Ada.Wide_Wide_Text_IO.Text_Streams
11119 @item
11120 Ada.Stream_IO
11121 @item
11122 Ada.Sequential_IO
11123 @item
11124 Ada.Direct_IO
11125 @end itemize
11127 @noindent
11128 are implemented using the C
11129 library streams facility; where
11131 @itemize @bullet
11132 @item
11133 All files are opened using @code{fopen}.
11134 @item
11135 All input/output operations use @code{fread}/@code{fwrite}.
11136 @end itemize
11138 @noindent
11139 There is no internal buffering of any kind at the Ada library level. The only
11140 buffering is that provided at the system level in the implementation of the
11141 library routines that support streams. This facilitates shared use of these
11142 streams by mixed language programs. Note though that system level buffering is
11143 explicitly enabled at elaboration of the standard I/O packages and that can
11144 have an impact on mixed language programs, in particular those using I/O before
11145 calling the Ada elaboration routine (e.g. adainit). It is recommended to call
11146 the Ada elaboration routine before performing any I/O or when impractical,
11147 flush the common I/O streams and in particular Standard_Output before
11148 elaborating the Ada code.
11150 @node FORM Strings
11151 @section FORM Strings
11153 @noindent
11154 The format of a FORM string in GNAT is:
11156 @smallexample
11157 "keyword=value,keyword=value,@dots{},keyword=value"
11158 @end smallexample
11160 @noindent
11161 where letters may be in upper or lower case, and there are no spaces
11162 between values.  The order of the entries is not important.  Currently
11163 there are two keywords defined.
11165 @smallexample
11166 SHARED=[YES|NO]
11167 WCEM=[n|h|u|s\e]
11168 @end smallexample
11170 @noindent
11171 The use of these parameters is described later in this section.
11173 @node Direct_IO
11174 @section Direct_IO
11176 @noindent
11177 Direct_IO can only be instantiated for definite types.  This is a
11178 restriction of the Ada language, which means that the records are fixed
11179 length (the length being determined by @code{@var{type}'Size}, rounded
11180 up to the next storage unit boundary if necessary).
11182 The records of a Direct_IO file are simply written to the file in index
11183 sequence, with the first record starting at offset zero, and subsequent
11184 records following.  There is no control information of any kind.  For
11185 example, if 32-bit integers are being written, each record takes
11186 4-bytes, so the record at index @var{K} starts at offset
11187 (@var{K}@minus{}1)*4.
11189 There is no limit on the size of Direct_IO files, they are expanded as
11190 necessary to accommodate whatever records are written to the file.
11192 @node Sequential_IO
11193 @section Sequential_IO
11195 @noindent
11196 Sequential_IO may be instantiated with either a definite (constrained)
11197 or indefinite (unconstrained) type.
11199 For the definite type case, the elements written to the file are simply
11200 the memory images of the data values with no control information of any
11201 kind.  The resulting file should be read using the same type, no validity
11202 checking is performed on input.
11204 For the indefinite type case, the elements written consist of two
11205 parts.  First is the size of the data item, written as the memory image
11206 of a @code{Interfaces.C.size_t} value, followed by the memory image of
11207 the data value.  The resulting file can only be read using the same
11208 (unconstrained) type.  Normal assignment checks are performed on these
11209 read operations, and if these checks fail, @code{Data_Error} is
11210 raised.  In particular, in the array case, the lengths must match, and in
11211 the variant record case, if the variable for a particular read operation
11212 is constrained, the discriminants must match.
11214 Note that it is not possible to use Sequential_IO to write variable
11215 length array items, and then read the data back into different length
11216 arrays.  For example, the following will raise @code{Data_Error}:
11218 @smallexample @c ada
11219  package IO is new Sequential_IO (String);
11220  F : IO.File_Type;
11221  S : String (1..4);
11222  @dots{}
11223  IO.Create (F)
11224  IO.Write (F, "hello!")
11225  IO.Reset (F, Mode=>In_File);
11226  IO.Read (F, S);
11227  Put_Line (S);
11229 @end smallexample
11231 @noindent
11232 On some Ada implementations, this will print @code{hell}, but the program is
11233 clearly incorrect, since there is only one element in the file, and that
11234 element is the string @code{hello!}.
11236 In Ada 95, this kind of behavior can be legitimately achieved using
11237 Stream_IO, and this is the preferred mechanism.  In particular, the above
11238 program fragment rewritten to use Stream_IO will work correctly.
11240 @node Text_IO
11241 @section Text_IO
11243 @noindent
11244 Text_IO files consist of a stream of characters containing the following
11245 special control characters:
11247 @smallexample
11248 LF (line feed, 16#0A#) Line Mark
11249 FF (form feed, 16#0C#) Page Mark
11250 @end smallexample
11252 @noindent
11253 A canonical Text_IO file is defined as one in which the following
11254 conditions are met:
11256 @itemize @bullet
11257 @item
11258 The character @code{LF} is used only as a line mark, i.e.@: to mark the end
11259 of the line.
11261 @item
11262 The character @code{FF} is used only as a page mark, i.e.@: to mark the
11263 end of a page and consequently can appear only immediately following a
11264 @code{LF} (line mark) character.
11266 @item
11267 The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
11268 (line mark, page mark).  In the former case, the page mark is implicitly
11269 assumed to be present.
11270 @end itemize
11272 @noindent
11273 A file written using Text_IO will be in canonical form provided that no
11274 explicit @code{LF} or @code{FF} characters are written using @code{Put}
11275 or @code{Put_Line}.  There will be no @code{FF} character at the end of
11276 the file unless an explicit @code{New_Page} operation was performed
11277 before closing the file.
11279 A canonical Text_IO file that is a regular file, i.e.@: not a device or a
11280 pipe, can be read using any of the routines in Text_IO@.  The
11281 semantics in this case will be exactly as defined in the Ada 95 reference
11282 manual and all the routines in Text_IO are fully implemented.
11284 A text file that does not meet the requirements for a canonical Text_IO
11285 file has one of the following:
11287 @itemize @bullet
11288 @item
11289 The file contains @code{FF} characters not immediately following a
11290 @code{LF} character.
11292 @item
11293 The file contains @code{LF} or @code{FF} characters written by
11294 @code{Put} or @code{Put_Line}, which are not logically considered to be
11295 line marks or page marks.
11297 @item
11298 The file ends in a character other than @code{LF} or @code{FF},
11299 i.e.@: there is no explicit line mark or page mark at the end of the file.
11300 @end itemize
11302 @noindent
11303 Text_IO can be used to read such non-standard text files but subprograms
11304 to do with line or page numbers do not have defined meanings.  In
11305 particular, a @code{FF} character that does not follow a @code{LF}
11306 character may or may not be treated as a page mark from the point of
11307 view of page and line numbering.  Every @code{LF} character is considered
11308 to end a line, and there is an implied @code{LF} character at the end of
11309 the file.
11311 @menu
11312 * Text_IO Stream Pointer Positioning::
11313 * Text_IO Reading and Writing Non-Regular Files::
11314 * Get_Immediate::
11315 * Treating Text_IO Files as Streams::
11316 * Text_IO Extensions::
11317 * Text_IO Facilities for Unbounded Strings::
11318 @end menu
11320 @node Text_IO Stream Pointer Positioning
11321 @subsection Stream Pointer Positioning
11323 @noindent
11324 @code{Ada.Text_IO} has a definition of current position for a file that
11325 is being read.  No internal buffering occurs in Text_IO, and usually the
11326 physical position in the stream used to implement the file corresponds
11327 to this logical position defined by Text_IO@.  There are two exceptions:
11329 @itemize @bullet
11330 @item
11331 After a call to @code{End_Of_Page} that returns @code{True}, the stream
11332 is positioned past the @code{LF} (line mark) that precedes the page
11333 mark.  Text_IO maintains an internal flag so that subsequent read
11334 operations properly handle the logical position which is unchanged by
11335 the @code{End_Of_Page} call.
11337 @item
11338 After a call to @code{End_Of_File} that returns @code{True}, if the
11339 Text_IO file was positioned before the line mark at the end of file
11340 before the call, then the logical position is unchanged, but the stream
11341 is physically positioned right at the end of file (past the line mark,
11342 and past a possible page mark following the line mark.  Again Text_IO
11343 maintains internal flags so that subsequent read operations properly
11344 handle the logical position.
11345 @end itemize
11347 @noindent
11348 These discrepancies have no effect on the observable behavior of
11349 Text_IO, but if a single Ada stream is shared between a C program and
11350 Ada program, or shared (using @samp{shared=yes} in the form string)
11351 between two Ada files, then the difference may be observable in some
11352 situations.
11354 @node Text_IO Reading and Writing Non-Regular Files
11355 @subsection Reading and Writing Non-Regular Files
11357 @noindent
11358 A non-regular file is a device (such as a keyboard), or a pipe.  Text_IO
11359 can be used for reading and writing.  Writing is not affected and the
11360 sequence of characters output is identical to the normal file case, but
11361 for reading, the behavior of Text_IO is modified to avoid undesirable
11362 look-ahead as follows:
11364 An input file that is not a regular file is considered to have no page
11365 marks.  Any @code{Ascii.FF} characters (the character normally used for a
11366 page mark) appearing in the file are considered to be data
11367 characters.  In particular:
11369 @itemize @bullet
11370 @item
11371 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
11372 following a line mark.  If a page mark appears, it will be treated as a
11373 data character.
11375 @item
11376 This avoids the need to wait for an extra character to be typed or
11377 entered from the pipe to complete one of these operations.
11379 @item
11380 @code{End_Of_Page} always returns @code{False}
11382 @item
11383 @code{End_Of_File} will return @code{False} if there is a page mark at
11384 the end of the file.
11385 @end itemize
11387 @noindent
11388 Output to non-regular files is the same as for regular files.  Page marks
11389 may be written to non-regular files using @code{New_Page}, but as noted
11390 above they will not be treated as page marks on input if the output is
11391 piped to another Ada program.
11393 Another important discrepancy when reading non-regular files is that the end
11394 of file indication is not ``sticky''.  If an end of file is entered, e.g.@: by
11395 pressing the @key{EOT} key,
11396 then end of file
11397 is signaled once (i.e.@: the test @code{End_Of_File}
11398 will yield @code{True}, or a read will
11399 raise @code{End_Error}), but then reading can resume
11400 to read data past that end of
11401 file indication, until another end of file indication is entered.
11403 @node Get_Immediate
11404 @subsection Get_Immediate
11405 @cindex Get_Immediate
11407 @noindent
11408 Get_Immediate returns the next character (including control characters)
11409 from the input file.  In particular, Get_Immediate will return LF or FF
11410 characters used as line marks or page marks.  Such operations leave the
11411 file positioned past the control character, and it is thus not treated
11412 as having its normal function.  This means that page, line and column
11413 counts after this kind of Get_Immediate call are set as though the mark
11414 did not occur.  In the case where a Get_Immediate leaves the file
11415 positioned between the line mark and page mark (which is not normally
11416 possible), it is undefined whether the FF character will be treated as a
11417 page mark.
11419 @node Treating Text_IO Files as Streams
11420 @subsection Treating Text_IO Files as Streams
11421 @cindex Stream files
11423 @noindent
11424 The package @code{Text_IO.Streams} allows a Text_IO file to be treated
11425 as a stream.  Data written to a Text_IO file in this stream mode is
11426 binary data.  If this binary data contains bytes 16#0A# (@code{LF}) or
11427 16#0C# (@code{FF}), the resulting file may have non-standard
11428 format.  Similarly if read operations are used to read from a Text_IO
11429 file treated as a stream, then @code{LF} and @code{FF} characters may be
11430 skipped and the effect is similar to that described above for
11431 @code{Get_Immediate}.
11433 @node Text_IO Extensions
11434 @subsection Text_IO Extensions
11435 @cindex Text_IO extensions
11437 @noindent
11438 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
11439 to the standard @code{Text_IO} package:
11441 @itemize @bullet
11442 @item function File_Exists (Name : String) return Boolean;
11443 Determines if a file of the given name exists.
11445 @item function Get_Line return String;
11446 Reads a string from the standard input file.  The value returned is exactly
11447 the length of the line that was read.
11449 @item function Get_Line (File : Ada.Text_IO.File_Type) return String;
11450 Similar, except that the parameter File specifies the file from which
11451 the string is to be read.
11453 @end itemize
11455 @node Text_IO Facilities for Unbounded Strings
11456 @subsection Text_IO Facilities for Unbounded Strings
11457 @cindex Text_IO for unbounded strings
11458 @cindex Unbounded_String, Text_IO operations
11460 @noindent
11461 The package @code{Ada.Strings.Unbounded.Text_IO}
11462 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
11463 subprograms useful for Text_IO operations on unbounded strings:
11465 @itemize @bullet
11467 @item function Get_Line (File : File_Type) return Unbounded_String;
11468 Reads a line from the specified file
11469 and returns the result as an unbounded string.
11471 @item procedure Put (File : File_Type; U : Unbounded_String);
11472 Writes the value of the given unbounded string to the specified file
11473 Similar to the effect of
11474 @code{Put (To_String (U))} except that an extra copy is avoided.
11476 @item procedure Put_Line (File : File_Type; U : Unbounded_String);
11477 Writes the value of the given unbounded string to the specified file,
11478 followed by a @code{New_Line}.
11479 Similar to the effect of @code{Put_Line (To_String (U))} except
11480 that an extra copy is avoided.
11481 @end itemize
11483 @noindent
11484 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
11485 and is optional.  If the parameter is omitted, then the standard input or
11486 output file is referenced as appropriate.
11488 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
11489 files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended
11490 @code{Wide_Text_IO} functionality for unbounded wide strings.
11492 The package @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} in library
11493 files @file{a-szuzti.ads} and @file{a-szuzti.adb} provides similar extended
11494 @code{Wide_Wide_Text_IO} functionality for unbounded wide wide strings.
11496 @node Wide_Text_IO
11497 @section Wide_Text_IO
11499 @noindent
11500 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
11501 both input and output files may contain special sequences that represent
11502 wide character values.  The encoding scheme for a given file may be
11503 specified using a FORM parameter:
11505 @smallexample
11506 WCEM=@var{x}
11507 @end smallexample
11509 @noindent
11510 as part of the FORM string (WCEM = wide character encoding method),
11511 where @var{x} is one of the following characters
11513 @table @samp
11514 @item h
11515 Hex ESC encoding
11516 @item u
11517 Upper half encoding
11518 @item s
11519 Shift-JIS encoding
11520 @item e
11521 EUC Encoding
11522 @item 8
11523 UTF-8 encoding
11524 @item b
11525 Brackets encoding
11526 @end table
11528 @noindent
11529 The encoding methods match those that
11530 can be used in a source
11531 program, but there is no requirement that the encoding method used for
11532 the source program be the same as the encoding method used for files,
11533 and different files may use different encoding methods.
11535 The default encoding method for the standard files, and for opened files
11536 for which no WCEM parameter is given in the FORM string matches the
11537 wide character encoding specified for the main program (the default
11538 being brackets encoding if no coding method was specified with -gnatW).
11540 @table @asis
11541 @item Hex Coding
11542 In this encoding, a wide character is represented by a five character
11543 sequence:
11545 @smallexample
11546 ESC a b c d
11547 @end smallexample
11549 @noindent
11550 where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
11551 characters (using upper case letters) of the wide character code.  For
11552 example, ESC A345 is used to represent the wide character with code
11553 16#A345#.  This scheme is compatible with use of the full
11554 @code{Wide_Character} set.
11556 @item Upper Half Coding
11557 The wide character with encoding 16#abcd#, where the upper bit is on
11558 (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
11559 16#cd#.  The second byte may never be a format control character, but is
11560 not required to be in the upper half.  This method can be also used for
11561 shift-JIS or EUC where the internal coding matches the external coding.
11563 @item Shift JIS Coding
11564 A wide character is represented by a two character sequence 16#ab# and
11565 16#cd#, with the restrictions described for upper half encoding as
11566 described above.  The internal character code is the corresponding JIS
11567 character according to the standard algorithm for Shift-JIS
11568 conversion.  Only characters defined in the JIS code set table can be
11569 used with this encoding method.
11571 @item EUC Coding
11572 A wide character is represented by a two character sequence 16#ab# and
11573 16#cd#, with both characters being in the upper half.  The internal
11574 character code is the corresponding JIS character according to the EUC
11575 encoding algorithm.  Only characters defined in the JIS code set table
11576 can be used with this encoding method.
11578 @item UTF-8 Coding
11579 A wide character is represented using
11580 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
11581 10646-1/Am.2.  Depending on the character value, the representation
11582 is a one, two, or three byte sequence:
11584 @smallexample
11585 16#0000#-16#007f#: 2#0xxxxxxx#
11586 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
11587 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
11588 @end smallexample
11590 @noindent
11591 where the xxx bits correspond to the left-padded bits of the
11592 16-bit character value.  Note that all lower half ASCII characters
11593 are represented as ASCII bytes and all upper half characters and
11594 other wide characters are represented as sequences of upper-half
11595 (The full UTF-8 scheme allows for encoding 31-bit characters as
11596 6-byte sequences, but in this implementation, all UTF-8 sequences
11597 of four or more bytes length will raise a Constraint_Error, as
11598 will all invalid UTF-8 sequences.)
11600 @item Brackets Coding
11601 In this encoding, a wide character is represented by the following eight
11602 character sequence:
11604 @smallexample
11605 [ " a b c d " ]
11606 @end smallexample
11608 @noindent
11609 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
11610 characters (using uppercase letters) of the wide character code.  For
11611 example, @code{["A345"]} is used to represent the wide character with code
11612 @code{16#A345#}.
11613 This scheme is compatible with use of the full Wide_Character set.
11614 On input, brackets coding can also be used for upper half characters,
11615 e.g.@: @code{["C1"]} for lower case a.  However, on output, brackets notation
11616 is only used for wide characters with a code greater than @code{16#FF#}.
11618 @end table
11620 @noindent
11621 For the coding schemes other than Hex and Brackets encoding,
11622 not all wide character
11623 values can be represented.  An attempt to output a character that cannot
11624 be represented using the encoding scheme for the file causes
11625 Constraint_Error to be raised.  An invalid wide character sequence on
11626 input also causes Constraint_Error to be raised.
11628 @menu
11629 * Wide_Text_IO Stream Pointer Positioning::
11630 * Wide_Text_IO Reading and Writing Non-Regular Files::
11631 @end menu
11633 @node Wide_Text_IO Stream Pointer Positioning
11634 @subsection Stream Pointer Positioning
11636 @noindent
11637 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
11638 of stream pointer positioning (@pxref{Text_IO}).  There is one additional
11639 case:
11641 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
11642 normal lower ASCII set (i.e.@: a character in the range:
11644 @smallexample @c ada
11645 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
11646 @end smallexample
11648 @noindent
11649 then although the logical position of the file pointer is unchanged by
11650 the @code{Look_Ahead} call, the stream is physically positioned past the
11651 wide character sequence.  Again this is to avoid the need for buffering
11652 or backup, and all @code{Wide_Text_IO} routines check the internal
11653 indication that this situation has occurred so that this is not visible
11654 to a normal program using @code{Wide_Text_IO}.  However, this discrepancy
11655 can be observed if the wide text file shares a stream with another file.
11657 @node Wide_Text_IO Reading and Writing Non-Regular Files
11658 @subsection Reading and Writing Non-Regular Files
11660 @noindent
11661 As in the case of Text_IO, when a non-regular file is read, it is
11662 assumed that the file contains no page marks (any form characters are
11663 treated as data characters), and @code{End_Of_Page} always returns
11664 @code{False}.  Similarly, the end of file indication is not sticky, so
11665 it is possible to read beyond an end of file.
11667 @node Wide_Wide_Text_IO
11668 @section Wide_Wide_Text_IO
11670 @noindent
11671 @code{Wide_Wide_Text_IO} is similar in most respects to Text_IO, except that
11672 both input and output files may contain special sequences that represent
11673 wide wide character values.  The encoding scheme for a given file may be
11674 specified using a FORM parameter:
11676 @smallexample
11677 WCEM=@var{x}
11678 @end smallexample
11680 @noindent
11681 as part of the FORM string (WCEM = wide character encoding method),
11682 where @var{x} is one of the following characters
11684 @table @samp
11685 @item h
11686 Hex ESC encoding
11687 @item u
11688 Upper half encoding
11689 @item s
11690 Shift-JIS encoding
11691 @item e
11692 EUC Encoding
11693 @item 8
11694 UTF-8 encoding
11695 @item b
11696 Brackets encoding
11697 @end table
11699 @noindent
11700 The encoding methods match those that
11701 can be used in a source
11702 program, but there is no requirement that the encoding method used for
11703 the source program be the same as the encoding method used for files,
11704 and different files may use different encoding methods.
11706 The default encoding method for the standard files, and for opened files
11707 for which no WCEM parameter is given in the FORM string matches the
11708 wide character encoding specified for the main program (the default
11709 being brackets encoding if no coding method was specified with -gnatW).
11711 @table @asis
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, three, or four byte sequence:
11719 @smallexample
11720 16#000000#-16#00007f#: 2#0xxxxxxx#
11721 16#000080#-16#0007ff#: 2#110xxxxx# 2#10xxxxxx#
11722 16#000800#-16#00ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
11723 16#010000#-16#10ffff#: 2#11110xxx# 2#10xxxxxx# 2#10xxxxxx# 2#10xxxxxx#
11724 @end smallexample
11726 @noindent
11727 where the xxx bits correspond to the left-padded bits of the
11728 21-bit character value.  Note that all lower half ASCII characters
11729 are represented as ASCII bytes and all upper half characters and
11730 other wide characters are represented as sequences of upper-half
11731 characters.
11733 @item Brackets Coding
11734 In this encoding, a wide wide character is represented by the following eight
11735 character sequence if is in wide character range
11737 @smallexample
11738 [ " a b c d " ]
11739 @end smallexample
11741 and by the following ten character sequence if not
11743 @smallexample
11744 [ " a b c d e f " ]
11745 @end smallexample
11747 @noindent
11748 where @code{a}, @code{b}, @code{c}, @code{d}, @code{e}, and @code{f}
11749 are the four or six hexadecimal
11750 characters (using uppercase letters) of the wide wide character code.  For
11751 example, @code{["01A345"]} is used to represent the wide wide character
11752 with code @code{16#01A345#}.
11754 This scheme is compatible with use of the full Wide_Wide_Character set.
11755 On input, brackets coding can also be used for upper half characters,
11756 e.g.@: @code{["C1"]} for lower case a.  However, on output, brackets notation
11757 is only used for wide characters with a code greater than @code{16#FF#}.
11759 @end table
11761 @noindent
11762 If is also possible to use the other Wide_Character encoding methods,
11763 such as Shift-JIS, but the other schemes cannot support the full range
11764 of wide wide characters.
11765 An attempt to output a character that cannot
11766 be represented using the encoding scheme for the file causes
11767 Constraint_Error to be raised.  An invalid wide character sequence on
11768 input also causes Constraint_Error to be raised.
11770 @menu
11771 * Wide_Wide_Text_IO Stream Pointer Positioning::
11772 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
11773 @end menu
11775 @node Wide_Wide_Text_IO Stream Pointer Positioning
11776 @subsection Stream Pointer Positioning
11778 @noindent
11779 @code{Ada.Wide_Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
11780 of stream pointer positioning (@pxref{Text_IO}).  There is one additional
11781 case:
11783 If @code{Ada.Wide_Wide_Text_IO.Look_Ahead} reads a character outside the
11784 normal lower ASCII set (i.e.@: a character in the range:
11786 @smallexample @c ada
11787 Wide_Wide_Character'Val (16#0080#) .. Wide_Wide_Character'Val (16#10FFFF#)
11788 @end smallexample
11790 @noindent
11791 then although the logical position of the file pointer is unchanged by
11792 the @code{Look_Ahead} call, the stream is physically positioned past the
11793 wide character sequence.  Again this is to avoid the need for buffering
11794 or backup, and all @code{Wide_Wide_Text_IO} routines check the internal
11795 indication that this situation has occurred so that this is not visible
11796 to a normal program using @code{Wide_Wide_Text_IO}.  However, this discrepancy
11797 can be observed if the wide text file shares a stream with another file.
11799 @node Wide_Wide_Text_IO Reading and Writing Non-Regular Files
11800 @subsection Reading and Writing Non-Regular Files
11802 @noindent
11803 As in the case of Text_IO, when a non-regular file is read, it is
11804 assumed that the file contains no page marks (any form characters are
11805 treated as data characters), and @code{End_Of_Page} always returns
11806 @code{False}.  Similarly, the end of file indication is not sticky, so
11807 it is possible to read beyond an end of file.
11809 @node Stream_IO
11810 @section Stream_IO
11812 @noindent
11813 A stream file is a sequence of bytes, where individual elements are
11814 written to the file as described in the Ada 95 reference manual.  The type
11815 @code{Stream_Element} is simply a byte.  There are two ways to read or
11816 write a stream file.
11818 @itemize @bullet
11819 @item
11820 The operations @code{Read} and @code{Write} directly read or write a
11821 sequence of stream elements with no control information.
11823 @item
11824 The stream attributes applied to a stream file transfer data in the
11825 manner described for stream attributes.
11826 @end itemize
11828 @node Shared Files
11829 @section Shared Files
11831 @noindent
11832 Section A.14 of the Ada 95 Reference Manual allows implementations to
11833 provide a wide variety of behavior if an attempt is made to access the
11834 same external file with two or more internal files.
11836 To provide a full range of functionality, while at the same time
11837 minimizing the problems of portability caused by this implementation
11838 dependence, GNAT handles file sharing as follows:
11840 @itemize @bullet
11841 @item
11842 In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
11843 to open two or more files with the same full name is considered an error
11844 and is not supported.  The exception @code{Use_Error} will be
11845 raised.  Note that a file that is not explicitly closed by the program
11846 remains open until the program terminates.
11848 @item
11849 If the form parameter @samp{shared=no} appears in the form string, the
11850 file can be opened or created with its own separate stream identifier,
11851 regardless of whether other files sharing the same external file are
11852 opened.  The exact effect depends on how the C stream routines handle
11853 multiple accesses to the same external files using separate streams.
11855 @item
11856 If the form parameter @samp{shared=yes} appears in the form string for
11857 each of two or more files opened using the same full name, the same
11858 stream is shared between these files, and the semantics are as described
11859 in Ada 95 Reference Manual, Section A.14.
11860 @end itemize
11862 @noindent
11863 When a program that opens multiple files with the same name is ported
11864 from another Ada compiler to GNAT, the effect will be that
11865 @code{Use_Error} is raised.
11867 The documentation of the original compiler and the documentation of the
11868 program should then be examined to determine if file sharing was
11869 expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
11870 and @code{Create} calls as required.
11872 When a program is ported from GNAT to some other Ada compiler, no
11873 special attention is required unless the @samp{shared=@var{xxx}} form
11874 parameter is used in the program.  In this case, you must examine the
11875 documentation of the new compiler to see if it supports the required
11876 file sharing semantics, and form strings modified appropriately.  Of
11877 course it may be the case that the program cannot be ported if the
11878 target compiler does not support the required functionality.  The best
11879 approach in writing portable code is to avoid file sharing (and hence
11880 the use of the @samp{shared=@var{xxx}} parameter in the form string)
11881 completely.
11883 One common use of file sharing in Ada 83 is the use of instantiations of
11884 Sequential_IO on the same file with different types, to achieve
11885 heterogeneous input-output.  Although this approach will work in GNAT if
11886 @samp{shared=yes} is specified, it is preferable in Ada 95 to use Stream_IO
11887 for this purpose (using the stream attributes)
11889 @node Open Modes
11890 @section Open Modes
11892 @noindent
11893 @code{Open} and @code{Create} calls result in a call to @code{fopen}
11894 using the mode shown in the following table:
11896 @sp 2
11897 @center @code{Open} and @code{Create} Call Modes
11898 @smallexample
11899                                @b{OPEN }           @b{CREATE}
11900 Append_File                    "r+"             "w+"
11901 In_File                        "r"              "w+"
11902 Out_File (Direct_IO)           "r+"             "w"
11903 Out_File (all other cases)     "w"              "w"
11904 Inout_File                     "r+"             "w+"
11905 @end smallexample
11907 @noindent
11908 If text file translation is required, then either @samp{b} or @samp{t}
11909 is added to the mode, depending on the setting of Text.  Text file
11910 translation refers to the mapping of CR/LF sequences in an external file
11911 to LF characters internally.  This mapping only occurs in DOS and
11912 DOS-like systems, and is not relevant to other systems.
11914 A special case occurs with Stream_IO@.  As shown in the above table, the
11915 file is initially opened in @samp{r} or @samp{w} mode for the
11916 @code{In_File} and @code{Out_File} cases.  If a @code{Set_Mode} operation
11917 subsequently requires switching from reading to writing or vice-versa,
11918 then the file is reopened in @samp{r+} mode to permit the required operation.
11920 @node Operations on C Streams
11921 @section Operations on C Streams
11922 The package @code{Interfaces.C_Streams} provides an Ada program with direct
11923 access to the C library functions for operations on C streams:
11925 @smallexample @c adanocomment
11926 package Interfaces.C_Streams is
11927   -- Note: the reason we do not use the types that are in
11928   -- Interfaces.C is that we want to avoid dragging in the
11929   -- code in this unit if possible.
11930   subtype chars is System.Address;
11931   -- Pointer to null-terminated array of characters
11932   subtype FILEs is System.Address;
11933   -- Corresponds to the C type FILE*
11934   subtype voids is System.Address;
11935   -- Corresponds to the C type void*
11936   subtype int is Integer;
11937   subtype long is Long_Integer;
11938   -- Note: the above types are subtypes deliberately, and it
11939   -- is part of this spec that the above correspondences are
11940   -- guaranteed.  This means that it is legitimate to, for
11941   -- example, use Integer instead of int.  We provide these
11942   -- synonyms for clarity, but in some cases it may be
11943   -- convenient to use the underlying types (for example to
11944   -- avoid an unnecessary dependency of a spec on the spec
11945   -- of this unit).
11946   type size_t is mod 2 ** Standard'Address_Size;
11947   NULL_Stream : constant FILEs;
11948   -- Value returned (NULL in C) to indicate an
11949   -- fdopen/fopen/tmpfile error
11950   ----------------------------------
11951   -- Constants Defined in stdio.h --
11952   ----------------------------------
11953   EOF : constant int;
11954   -- Used by a number of routines to indicate error or
11955   -- end of file
11956   IOFBF : constant int;
11957   IOLBF : constant int;
11958   IONBF : constant int;
11959   -- Used to indicate buffering mode for setvbuf call
11960   SEEK_CUR : constant int;
11961   SEEK_END : constant int;
11962   SEEK_SET : constant int;
11963   -- Used to indicate origin for fseek call
11964   function stdin return FILEs;
11965   function stdout return FILEs;
11966   function stderr return FILEs;
11967   -- Streams associated with standard files
11968   --------------------------
11969   -- Standard C functions --
11970   --------------------------
11971   -- The functions selected below are ones that are
11972   -- available in DOS, OS/2, UNIX and Xenix (but not
11973   -- necessarily in ANSI C).  These are very thin interfaces
11974   -- which copy exactly the C headers.  For more
11975   -- documentation on these functions, see the Microsoft C
11976   -- "Run-Time Library Reference" (Microsoft Press, 1990,
11977   -- ISBN 1-55615-225-6), which includes useful information
11978   -- on system compatibility.
11979   procedure clearerr (stream : FILEs);
11980   function fclose (stream : FILEs) return int;
11981   function fdopen (handle : int; mode : chars) return FILEs;
11982   function feof (stream : FILEs) return int;
11983   function ferror (stream : FILEs) return int;
11984   function fflush (stream : FILEs) return int;
11985   function fgetc (stream : FILEs) return int;
11986   function fgets (strng : chars; n : int; stream : FILEs)
11987       return chars;
11988   function fileno (stream : FILEs) return int;
11989   function fopen (filename : chars; Mode : chars)
11990       return FILEs;
11991   -- Note: to maintain target independence, use
11992   -- text_translation_required, a boolean variable defined in
11993   -- a-sysdep.c to deal with the target dependent text
11994   -- translation requirement.  If this variable is set,
11995   -- then  b/t should be appended to the standard mode
11996   -- argument to set the text translation mode off or on
11997   -- as required.
11998   function fputc (C : int; stream : FILEs) return int;
11999   function fputs (Strng : chars; Stream : FILEs) return int;
12000   function fread
12001      (buffer : voids;
12002       size : size_t;
12003       count : size_t;
12004       stream : FILEs)
12005       return size_t;
12006   function freopen
12007      (filename : chars;
12008       mode : chars;
12009       stream : FILEs)
12010       return FILEs;
12011   function fseek
12012      (stream : FILEs;
12013       offset : long;
12014       origin : int)
12015       return int;
12016   function ftell (stream : FILEs) return long;
12017   function fwrite
12018      (buffer : voids;
12019       size : size_t;
12020       count : size_t;
12021       stream : FILEs)
12022       return size_t;
12023   function isatty (handle : int) return int;
12024   procedure mktemp (template : chars);
12025   -- The return value (which is just a pointer to template)
12026   -- is discarded
12027   procedure rewind (stream : FILEs);
12028   function rmtmp return int;
12029   function setvbuf
12030      (stream : FILEs;
12031       buffer : chars;
12032       mode : int;
12033       size : size_t)
12034       return int;
12036   function tmpfile return FILEs;
12037   function ungetc (c : int; stream : FILEs) return int;
12038   function unlink (filename : chars) return int;
12039   ---------------------
12040   -- Extra functions --
12041   ---------------------
12042   -- These functions supply slightly thicker bindings than
12043   -- those above.  They are derived from functions in the
12044   -- C Run-Time Library, but may do a bit more work than
12045   -- just directly calling one of the Library functions.
12046   function is_regular_file (handle : int) return int;
12047   -- Tests if given handle is for a regular file (result 1)
12048   -- or for a non-regular file (pipe or device, result 0).
12049   ---------------------------------
12050   -- Control of Text/Binary Mode --
12051   ---------------------------------
12052   -- If text_translation_required is true, then the following
12053   -- functions may be used to dynamically switch a file from
12054   -- binary to text mode or vice versa.  These functions have
12055   -- no effect if text_translation_required is false (i.e.  in
12056   -- normal UNIX mode).  Use fileno to get a stream handle.
12057   procedure set_binary_mode (handle : int);
12058   procedure set_text_mode (handle : int);
12059   ----------------------------
12060   -- Full Path Name support --
12061   ----------------------------
12062   procedure full_name (nam : chars; buffer : chars);
12063   -- Given a NUL terminated string representing a file
12064   -- name, returns in buffer a NUL terminated string
12065   -- representing the full path name for the file name.
12066   -- On systems where it is relevant the   drive is also
12067   -- part of the full path name.  It is the responsibility
12068   -- of the caller to pass an actual parameter for buffer
12069   -- that is big enough for any full path name.  Use
12070   -- max_path_len given below as the size of buffer.
12071   max_path_len : integer;
12072   -- Maximum length of an allowable full path name on the
12073   -- system, including a terminating NUL character.
12074 end Interfaces.C_Streams;
12075 @end smallexample
12077 @node Interfacing to C Streams
12078 @section Interfacing to C Streams
12080 @noindent
12081 The packages in this section permit interfacing Ada files to C Stream
12082 operations.
12084 @smallexample @c ada
12085  with Interfaces.C_Streams;
12086  package Ada.Sequential_IO.C_Streams is
12087     function C_Stream (F : File_Type)
12088        return Interfaces.C_Streams.FILEs;
12089     procedure Open
12090       (File : in out File_Type;
12091        Mode : in File_Mode;
12092        C_Stream : in Interfaces.C_Streams.FILEs;
12093        Form : in String := "");
12094  end Ada.Sequential_IO.C_Streams;
12096   with Interfaces.C_Streams;
12097   package Ada.Direct_IO.C_Streams is
12098      function C_Stream (F : File_Type)
12099         return Interfaces.C_Streams.FILEs;
12100      procedure Open
12101        (File : in out File_Type;
12102         Mode : in File_Mode;
12103         C_Stream : in Interfaces.C_Streams.FILEs;
12104         Form : in String := "");
12105   end Ada.Direct_IO.C_Streams;
12107   with Interfaces.C_Streams;
12108   package Ada.Text_IO.C_Streams is
12109      function C_Stream (F : File_Type)
12110         return Interfaces.C_Streams.FILEs;
12111      procedure Open
12112        (File : in out File_Type;
12113         Mode : in File_Mode;
12114         C_Stream : in Interfaces.C_Streams.FILEs;
12115         Form : in String := "");
12116   end Ada.Text_IO.C_Streams;
12118   with Interfaces.C_Streams;
12119   package Ada.Wide_Text_IO.C_Streams is
12120      function C_Stream (F : File_Type)
12121         return Interfaces.C_Streams.FILEs;
12122      procedure Open
12123        (File : in out File_Type;
12124         Mode : in File_Mode;
12125         C_Stream : in Interfaces.C_Streams.FILEs;
12126         Form : in String := "");
12127  end Ada.Wide_Text_IO.C_Streams;
12129   with Interfaces.C_Streams;
12130   package Ada.Wide_Wide_Text_IO.C_Streams is
12131      function C_Stream (F : File_Type)
12132         return Interfaces.C_Streams.FILEs;
12133      procedure Open
12134        (File : in out File_Type;
12135         Mode : in File_Mode;
12136         C_Stream : in Interfaces.C_Streams.FILEs;
12137         Form : in String := "");
12138  end Ada.Wide_Wide_Text_IO.C_Streams;
12140  with Interfaces.C_Streams;
12141  package Ada.Stream_IO.C_Streams is
12142     function C_Stream (F : File_Type)
12143        return Interfaces.C_Streams.FILEs;
12144     procedure Open
12145       (File : in out File_Type;
12146        Mode : in File_Mode;
12147        C_Stream : in Interfaces.C_Streams.FILEs;
12148        Form : in String := "");
12149  end Ada.Stream_IO.C_Streams;
12150 @end smallexample
12152 @noindent
12153 In each of these six packages, the @code{C_Stream} function obtains the
12154 @code{FILE} pointer from a currently opened Ada file.  It is then
12155 possible to use the @code{Interfaces.C_Streams} package to operate on
12156 this stream, or the stream can be passed to a C program which can
12157 operate on it directly.  Of course the program is responsible for
12158 ensuring that only appropriate sequences of operations are executed.
12160 One particular use of relevance to an Ada program is that the
12161 @code{setvbuf} function can be used to control the buffering of the
12162 stream used by an Ada file.  In the absence of such a call the standard
12163 default buffering is used.
12165 The @code{Open} procedures in these packages open a file giving an
12166 existing C Stream instead of a file name.  Typically this stream is
12167 imported from a C program, allowing an Ada file to operate on an
12168 existing C file.
12170 @node The GNAT Library
12171 @chapter The GNAT Library
12173 @noindent
12174 The GNAT library contains a number of general and special purpose packages.
12175 It represents functionality that the GNAT developers have found useful, and
12176 which is made available to GNAT users.  The packages described here are fully
12177 supported, and upwards compatibility will be maintained in future releases,
12178 so you can use these facilities with the confidence that the same functionality
12179 will be available in future releases.
12181 The chapter here simply gives a brief summary of the facilities available.
12182 The full documentation is found in the spec file for the package.  The full
12183 sources of these library packages, including both spec and body, are provided
12184 with all GNAT releases.  For example, to find out the full specifications of
12185 the SPITBOL pattern matching capability, including a full tutorial and
12186 extensive examples, look in the @file{g-spipat.ads} file in the library.
12188 For each entry here, the package name (as it would appear in a @code{with}
12189 clause) is given, followed by the name of the corresponding spec file in
12190 parentheses.  The packages are children in four hierarchies, @code{Ada},
12191 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
12192 GNAT-specific hierarchy.
12194 Note that an application program should only use packages in one of these
12195 four hierarchies if the package is defined in the Ada Reference Manual,
12196 or is listed in this section of the GNAT Programmers Reference Manual.
12197 All other units should be considered internal implementation units and
12198 should not be directly @code{with}'ed by application code.  The use of
12199 a @code{with} statement that references one of these internal implementation
12200 units makes an application potentially dependent on changes in versions
12201 of GNAT, and will generate a warning message.
12203 @menu
12204 * Ada.Characters.Latin_9 (a-chlat9.ads)::
12205 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
12206 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
12207 * Ada.Characters.Wide_Wide_Latin_1 (a-czila1.ads)::
12208 * Ada.Characters.Wide_Wide_Latin_9 (a-czila9.ads)::
12209 * Ada.Command_Line.Remove (a-colire.ads)::
12210 * Ada.Command_Line.Environment (a-colien.ads)::
12211 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
12212 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
12213 * Ada.Exceptions.Traceback (a-exctra.ads)::
12214 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
12215 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
12216 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
12217 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
12218 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
12219 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
12220 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
12221 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
12222 * GNAT.Altivec (g-altive.ads)::
12223 * GNAT.Altivec.Conversions (g-altcon.ads)::
12224 * GNAT.Altivec.Vector_Operations (g-alveop.ads)::
12225 * GNAT.Altivec.Vector_Types (g-alvety.ads)::
12226 * GNAT.Altivec.Vector_Views (g-alvevi.ads)::
12227 * GNAT.Array_Split (g-arrspl.ads)::
12228 * GNAT.AWK (g-awk.ads)::
12229 * GNAT.Bounded_Buffers (g-boubuf.ads)::
12230 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
12231 * GNAT.Bubble_Sort (g-bubsor.ads)::
12232 * GNAT.Bubble_Sort_A (g-busora.ads)::
12233 * GNAT.Bubble_Sort_G (g-busorg.ads)::
12234 * GNAT.Calendar (g-calend.ads)::
12235 * GNAT.Calendar.Time_IO (g-catiio.ads)::
12236 * GNAT.CRC32 (g-crc32.ads)::
12237 * GNAT.Case_Util (g-casuti.ads)::
12238 * GNAT.CGI (g-cgi.ads)::
12239 * GNAT.CGI.Cookie (g-cgicoo.ads)::
12240 * GNAT.CGI.Debug (g-cgideb.ads)::
12241 * GNAT.Command_Line (g-comlin.ads)::
12242 * GNAT.Compiler_Version (g-comver.ads)::
12243 * GNAT.Ctrl_C (g-ctrl_c.ads)::
12244 * GNAT.Current_Exception (g-curexc.ads)::
12245 * GNAT.Debug_Pools (g-debpoo.ads)::
12246 * GNAT.Debug_Utilities (g-debuti.ads)::
12247 * GNAT.Directory_Operations (g-dirope.ads)::
12248 * GNAT.Dynamic_HTables (g-dynhta.ads)::
12249 * GNAT.Dynamic_Tables (g-dyntab.ads)::
12250 * GNAT.Exception_Actions (g-excact.ads)::
12251 * GNAT.Exception_Traces (g-exctra.ads)::
12252 * GNAT.Exceptions (g-except.ads)::
12253 * GNAT.Expect (g-expect.ads)::
12254 * GNAT.Float_Control (g-flocon.ads)::
12255 * GNAT.Heap_Sort (g-heasor.ads)::
12256 * GNAT.Heap_Sort_A (g-hesora.ads)::
12257 * GNAT.Heap_Sort_G (g-hesorg.ads)::
12258 * GNAT.HTable (g-htable.ads)::
12259 * GNAT.IO (g-io.ads)::
12260 * GNAT.IO_Aux (g-io_aux.ads)::
12261 * GNAT.Lock_Files (g-locfil.ads)::
12262 * GNAT.MD5 (g-md5.ads)::
12263 * GNAT.Memory_Dump (g-memdum.ads)::
12264 * GNAT.Most_Recent_Exception (g-moreex.ads)::
12265 * GNAT.OS_Lib (g-os_lib.ads)::
12266 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
12267 * GNAT.Regexp (g-regexp.ads)::
12268 * GNAT.Registry (g-regist.ads)::
12269 * GNAT.Regpat (g-regpat.ads)::
12270 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
12271 * GNAT.Semaphores (g-semaph.ads)::
12272 * GNAT.Signals (g-signal.ads)::
12273 * GNAT.Sockets (g-socket.ads)::
12274 * GNAT.Source_Info (g-souinf.ads)::
12275 * GNAT.Spell_Checker (g-speche.ads)::
12276 * GNAT.Spitbol.Patterns (g-spipat.ads)::
12277 * GNAT.Spitbol (g-spitbo.ads)::
12278 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
12279 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
12280 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
12281 * GNAT.Strings (g-string.ads)::
12282 * GNAT.String_Split (g-strspl.ads)::
12283 * GNAT.UTF_32 (g-utf_32.ads)::
12284 * GNAT.Table (g-table.ads)::
12285 * GNAT.Task_Lock (g-tasloc.ads)::
12286 * GNAT.Threads (g-thread.ads)::
12287 * GNAT.Traceback (g-traceb.ads)::
12288 * GNAT.Traceback.Symbolic (g-trasym.ads)::
12289 * GNAT.Wide_String_Split (g-wistsp.ads)::
12290 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
12291 * Interfaces.C.Extensions (i-cexten.ads)::
12292 * Interfaces.C.Streams (i-cstrea.ads)::
12293 * Interfaces.CPP (i-cpp.ads)::
12294 * Interfaces.Os2lib (i-os2lib.ads)::
12295 * Interfaces.Os2lib.Errors (i-os2err.ads)::
12296 * Interfaces.Os2lib.Synchronization (i-os2syn.ads)::
12297 * Interfaces.Os2lib.Threads (i-os2thr.ads)::
12298 * Interfaces.Packed_Decimal (i-pacdec.ads)::
12299 * Interfaces.VxWorks (i-vxwork.ads)::
12300 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
12301 * System.Address_Image (s-addima.ads)::
12302 * System.Assertions (s-assert.ads)::
12303 * System.Memory (s-memory.ads)::
12304 * System.Partition_Interface (s-parint.ads)::
12305 * System.Restrictions (s-restri.ads)::
12306 * System.Rident (s-rident.ads)::
12307 * System.Task_Info (s-tasinf.ads)::
12308 * System.Wch_Cnv (s-wchcnv.ads)::
12309 * System.Wch_Con (s-wchcon.ads)::
12310 @end menu
12312 @node Ada.Characters.Latin_9 (a-chlat9.ads)
12313 @section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
12314 @cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
12315 @cindex Latin_9 constants for Character
12317 @noindent
12318 This child of @code{Ada.Characters}
12319 provides a set of definitions corresponding to those in the
12320 RM-defined package @code{Ada.Characters.Latin_1} but with the
12321 few modifications required for @code{Latin-9}
12322 The provision of such a package
12323 is specifically authorized by the Ada Reference Manual
12324 (RM A.3(27)).
12326 @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
12327 @section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
12328 @cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
12329 @cindex Latin_1 constants for Wide_Character
12331 @noindent
12332 This child of @code{Ada.Characters}
12333 provides a set of definitions corresponding to those in the
12334 RM-defined package @code{Ada.Characters.Latin_1} but with the
12335 types of the constants being @code{Wide_Character}
12336 instead of @code{Character}.  The provision of such a package
12337 is specifically authorized by the Ada Reference Manual
12338 (RM A.3(27)).
12340 @node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
12341 @section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
12342 @cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
12343 @cindex Latin_9 constants for Wide_Character
12345 @noindent
12346 This child of @code{Ada.Characters}
12347 provides a set of definitions corresponding to those in the
12348 GNAT defined package @code{Ada.Characters.Latin_9} but with the
12349 types of the constants being @code{Wide_Character}
12350 instead of @code{Character}.  The provision of such a package
12351 is specifically authorized by the Ada Reference Manual
12352 (RM A.3(27)).
12354 @node Ada.Characters.Wide_Wide_Latin_1 (a-czila1.ads)
12355 @section @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-czila1.ads})
12356 @cindex @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-czila1.ads})
12357 @cindex Latin_1 constants for Wide_Wide_Character
12359 @noindent
12360 This child of @code{Ada.Characters}
12361 provides a set of definitions corresponding to those in the
12362 RM-defined package @code{Ada.Characters.Latin_1} but with the
12363 types of the constants being @code{Wide_Wide_Character}
12364 instead of @code{Character}.  The provision of such a package
12365 is specifically authorized by the Ada Reference Manual
12366 (RM A.3(27)).
12368 @node Ada.Characters.Wide_Wide_Latin_9 (a-czila9.ads)
12369 @section @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-czila9.ads})
12370 @cindex @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-czila9.ads})
12371 @cindex Latin_9 constants for Wide_Wide_Character
12373 @noindent
12374 This child of @code{Ada.Characters}
12375 provides a set of definitions corresponding to those in the
12376 GNAT defined package @code{Ada.Characters.Latin_9} but with the
12377 types of the constants being @code{Wide_Wide_Character}
12378 instead of @code{Character}.  The provision of such a package
12379 is specifically authorized by the Ada Reference Manual
12380 (RM A.3(27)).
12382 @node Ada.Command_Line.Remove (a-colire.ads)
12383 @section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
12384 @cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
12385 @cindex Removing command line arguments
12386 @cindex Command line, argument removal
12388 @noindent
12389 This child of @code{Ada.Command_Line}
12390 provides a mechanism for logically removing
12391 arguments from the argument list.  Once removed, an argument is not visible
12392 to further calls on the subprograms in @code{Ada.Command_Line} will not
12393 see the removed argument.
12395 @node Ada.Command_Line.Environment (a-colien.ads)
12396 @section @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
12397 @cindex @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
12398 @cindex Environment entries
12400 @noindent
12401 This child of @code{Ada.Command_Line}
12402 provides a mechanism for obtaining environment values on systems
12403 where this concept makes sense.
12405 @node Ada.Direct_IO.C_Streams (a-diocst.ads)
12406 @section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
12407 @cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
12408 @cindex C Streams, Interfacing with Direct_IO
12410 @noindent
12411 This package provides subprograms that allow interfacing between
12412 C streams and @code{Direct_IO}.  The stream identifier can be
12413 extracted from a file opened on the Ada side, and an Ada file
12414 can be constructed from a stream opened on the C side.
12416 @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
12417 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
12418 @cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
12419 @cindex Null_Occurrence, testing for
12421 @noindent
12422 This child subprogram provides a way of testing for the null
12423 exception occurrence (@code{Null_Occurrence}) without raising
12424 an exception.
12426 @node Ada.Exceptions.Traceback (a-exctra.ads)
12427 @section @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
12428 @cindex @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
12429 @cindex Traceback for Exception Occurrence
12431 @noindent
12432 This child package provides the subprogram (@code{Tracebacks}) to
12433 give a traceback array of addresses based on an exception
12434 occurrence.
12436 @node Ada.Sequential_IO.C_Streams (a-siocst.ads)
12437 @section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
12438 @cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
12439 @cindex C Streams, Interfacing with Sequential_IO
12441 @noindent
12442 This package provides subprograms that allow interfacing between
12443 C streams and @code{Sequential_IO}.  The stream identifier can be
12444 extracted from a file opened on the Ada side, and an Ada file
12445 can be constructed from a stream opened on the C side.
12447 @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
12448 @section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
12449 @cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
12450 @cindex C Streams, Interfacing with Stream_IO
12452 @noindent
12453 This package provides subprograms that allow interfacing between
12454 C streams and @code{Stream_IO}.  The stream identifier can be
12455 extracted from a file opened on the Ada side, and an Ada file
12456 can be constructed from a stream opened on the C side.
12458 @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
12459 @section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
12460 @cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
12461 @cindex @code{Unbounded_String}, IO support
12462 @cindex @code{Text_IO}, extensions for unbounded strings
12464 @noindent
12465 This package provides subprograms for Text_IO for unbounded
12466 strings, avoiding the necessity for an intermediate operation
12467 with ordinary strings.
12469 @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
12470 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
12471 @cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
12472 @cindex @code{Unbounded_Wide_String}, IO support
12473 @cindex @code{Text_IO}, extensions for unbounded wide strings
12475 @noindent
12476 This package provides subprograms for Text_IO for unbounded
12477 wide strings, avoiding the necessity for an intermediate operation
12478 with ordinary wide strings.
12480 @node Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)
12481 @section @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
12482 @cindex @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
12483 @cindex @code{Unbounded_Wide_Wide_String}, IO support
12484 @cindex @code{Text_IO}, extensions for unbounded wide wide strings
12486 @noindent
12487 This package provides subprograms for Text_IO for unbounded
12488 wide wide strings, avoiding the necessity for an intermediate operation
12489 with ordinary wide wide strings.
12491 @node Ada.Text_IO.C_Streams (a-tiocst.ads)
12492 @section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
12493 @cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
12494 @cindex C Streams, Interfacing with @code{Text_IO}
12496 @noindent
12497 This package provides subprograms that allow interfacing between
12498 C streams and @code{Text_IO}.  The stream identifier can be
12499 extracted from a file opened on the Ada side, and an Ada file
12500 can be constructed from a stream opened on the C side.
12502 @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
12503 @section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
12504 @cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
12505 @cindex C Streams, Interfacing with @code{Wide_Text_IO}
12507 @noindent
12508 This package provides subprograms that allow interfacing between
12509 C streams and @code{Wide_Text_IO}.  The stream identifier can be
12510 extracted from a file opened on the Ada side, and an Ada file
12511 can be constructed from a stream opened on the C side.
12513 @node Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)
12514 @section @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
12515 @cindex @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
12516 @cindex C Streams, Interfacing with @code{Wide_Wide_Text_IO}
12518 @noindent
12519 This package provides subprograms that allow interfacing between
12520 C streams and @code{Wide_Wide_Text_IO}.  The stream identifier can be
12521 extracted from a file opened on the Ada side, and an Ada file
12522 can be constructed from a stream opened on the C side.
12524 @node GNAT.Altivec (g-altive.ads)
12525 @section @code{GNAT.Altivec} (@file{g-altive.ads})
12526 @cindex @code{GNAT.Altivec} (@file{g-altive.ads})
12527 @cindex AltiVec
12529 @noindent
12530 This is the root package of the GNAT AltiVec binding. It provides
12531 definitions of constants and types common to all the versions of the
12532 binding.
12534 @node GNAT.Altivec.Conversions (g-altcon.ads)
12535 @section @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
12536 @cindex @code{GNAT.Altivec.Conversions} (@file{g-altcon.ads})
12537 @cindex AltiVec
12539 @noindent
12540 This package provides the Vector/View conversion routines.
12542 @node GNAT.Altivec.Vector_Operations (g-alveop.ads)
12543 @section @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
12544 @cindex @code{GNAT.Altivec.Vector_Operations} (@file{g-alveop.ads})
12545 @cindex AltiVec
12547 @noindent
12548 This package exposes the Ada interface to the AltiVec operations on
12549 vector objects. A soft emulation is included by default in the GNAT
12550 library. The hard binding is provided as a separate package. This unit
12551 is common to both bindings.
12553 @node GNAT.Altivec.Vector_Types (g-alvety.ads)
12554 @section @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
12555 @cindex @code{GNAT.Altivec.Vector_Types} (@file{g-alvety.ads})
12556 @cindex AltiVec
12558 @noindent
12559 This package exposes the various vector types part of the Ada binding
12560 to AltiVec facilities.
12562 @node GNAT.Altivec.Vector_Views (g-alvevi.ads)
12563 @section @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
12564 @cindex @code{GNAT.Altivec.Vector_Views} (@file{g-alvevi.ads})
12565 @cindex AltiVec
12567 @noindent
12568 This package provides public 'View' data types from/to which private
12569 vector representations can be converted via
12570 GNAT.Altivec.Conversions. This allows convenient access to individual
12571 vector elements and provides a simple way to initialize vector
12572 objects.
12574 @node GNAT.Array_Split (g-arrspl.ads)
12575 @section @code{GNAT.Array_Split} (@file{g-arrspl.ads})
12576 @cindex @code{GNAT.Array_Split} (@file{g-arrspl.ads})
12577 @cindex Array splitter
12579 @noindent
12580 Useful array-manipulation routines: given a set of separators, split
12581 an array wherever the separators appear, and provide direct access
12582 to the resulting slices.
12584 @node GNAT.AWK (g-awk.ads)
12585 @section @code{GNAT.AWK} (@file{g-awk.ads})
12586 @cindex @code{GNAT.AWK} (@file{g-awk.ads})
12587 @cindex Parsing
12588 @cindex AWK
12590 @noindent
12591 Provides AWK-like parsing functions, with an easy interface for parsing one
12592 or more files containing formatted data.  The file is viewed as a database
12593 where each record is a line and a field is a data element in this line.
12595 @node GNAT.Bounded_Buffers (g-boubuf.ads)
12596 @section @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
12597 @cindex @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
12598 @cindex Parsing
12599 @cindex Bounded Buffers
12601 @noindent
12602 Provides a concurrent generic bounded buffer abstraction.  Instances are
12603 useful directly or as parts of the implementations of other abstractions,
12604 such as mailboxes.
12606 @node GNAT.Bounded_Mailboxes (g-boumai.ads)
12607 @section @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
12608 @cindex @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
12609 @cindex Parsing
12610 @cindex Mailboxes
12612 @noindent
12613 Provides a thread-safe asynchronous intertask mailbox communication facility.
12615 @node GNAT.Bubble_Sort (g-bubsor.ads)
12616 @section @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
12617 @cindex @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
12618 @cindex Sorting
12619 @cindex Bubble sort
12621 @noindent
12622 Provides a general implementation of bubble sort usable for sorting arbitrary
12623 data items.  Exchange and comparison procedures are provided by passing
12624 access-to-procedure values.
12626 @node GNAT.Bubble_Sort_A (g-busora.ads)
12627 @section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
12628 @cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
12629 @cindex Sorting
12630 @cindex Bubble sort
12632 @noindent
12633 Provides a general implementation of bubble sort usable for sorting arbitrary
12634 data items.  Move and comparison procedures are provided by passing
12635 access-to-procedure values. This is an older version, retained for
12636 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
12638 @node GNAT.Bubble_Sort_G (g-busorg.ads)
12639 @section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
12640 @cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
12641 @cindex Sorting
12642 @cindex Bubble sort
12644 @noindent
12645 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
12646 are provided as generic parameters, this improves efficiency, especially
12647 if the procedures can be inlined, at the expense of duplicating code for
12648 multiple instantiations.
12650 @node GNAT.Calendar (g-calend.ads)
12651 @section @code{GNAT.Calendar} (@file{g-calend.ads})
12652 @cindex @code{GNAT.Calendar} (@file{g-calend.ads})
12653 @cindex @code{Calendar}
12655 @noindent
12656 Extends the facilities provided by @code{Ada.Calendar} to include handling
12657 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
12658 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
12659 C @code{timeval} format.
12661 @node GNAT.Calendar.Time_IO (g-catiio.ads)
12662 @section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
12663 @cindex @code{Calendar}
12664 @cindex Time
12665 @cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
12667 @node GNAT.CRC32 (g-crc32.ads)
12668 @section @code{GNAT.CRC32} (@file{g-crc32.ads})
12669 @cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
12670 @cindex CRC32
12671 @cindex Cyclic Redundancy Check
12673 @noindent
12674 This package implements the CRC-32 algorithm.  For a full description
12675 of this algorithm see
12676 ``Computation of Cyclic Redundancy Checks via Table Look-Up'',
12677 @cite{Communications of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013,
12678 Aug.@: 1988.  Sarwate, D.V@.
12680 @noindent
12681 Provides an extended capability for formatted output of time values with
12682 full user control over the format.  Modeled on the GNU Date specification.
12684 @node GNAT.Case_Util (g-casuti.ads)
12685 @section @code{GNAT.Case_Util} (@file{g-casuti.ads})
12686 @cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
12687 @cindex Casing utilities
12688 @cindex Character handling (@code{GNAT.Case_Util})
12690 @noindent
12691 A set of simple routines for handling upper and lower casing of strings
12692 without the overhead of the full casing tables
12693 in @code{Ada.Characters.Handling}.
12695 @node GNAT.CGI (g-cgi.ads)
12696 @section @code{GNAT.CGI} (@file{g-cgi.ads})
12697 @cindex @code{GNAT.CGI} (@file{g-cgi.ads})
12698 @cindex CGI (Common Gateway Interface)
12700 @noindent
12701 This is a package for interfacing a GNAT program with a Web server via the
12702 Common Gateway Interface (CGI)@.  Basically this package parses the CGI
12703 parameters, which are a set of key/value pairs sent by the Web server.  It
12704 builds a table whose index is the key and provides some services to deal
12705 with this table.
12707 @node GNAT.CGI.Cookie (g-cgicoo.ads)
12708 @section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
12709 @cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
12710 @cindex CGI (Common Gateway Interface) cookie support
12711 @cindex Cookie support in CGI
12713 @noindent
12714 This is a package to interface a GNAT program with a Web server via the
12715 Common Gateway Interface (CGI).  It exports services to deal with Web
12716 cookies (piece of information kept in the Web client software).
12718 @node GNAT.CGI.Debug (g-cgideb.ads)
12719 @section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
12720 @cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
12721 @cindex CGI (Common Gateway Interface) debugging
12723 @noindent
12724 This is a package to help debugging CGI (Common Gateway Interface)
12725 programs written in Ada.
12727 @node GNAT.Command_Line (g-comlin.ads)
12728 @section @code{GNAT.Command_Line} (@file{g-comlin.ads})
12729 @cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
12730 @cindex Command line
12732 @noindent
12733 Provides a high level interface to @code{Ada.Command_Line} facilities,
12734 including the ability to scan for named switches with optional parameters
12735 and expand file names using wild card notations.
12737 @node GNAT.Compiler_Version (g-comver.ads)
12738 @section @code{GNAT.Compiler_Version} (@file{g-comver.ads})
12739 @cindex @code{GNAT.Compiler_Version} (@file{g-comver.ads})
12740 @cindex Compiler Version
12741 @cindex Version, of compiler
12743 @noindent
12744 Provides a routine for obtaining the version of the compiler used to
12745 compile the program. More accurately this is the version of the binder
12746 used to bind the program (this will normally be the same as the version
12747 of the compiler if a consistent tool set is used to compile all units
12748 of a partition).
12750 @node GNAT.Ctrl_C (g-ctrl_c.ads)
12751 @section @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
12752 @cindex @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
12753 @cindex Interrupt
12755 @noindent
12756 Provides a simple interface to handle Ctrl-C keyboard events.
12758 @node GNAT.Current_Exception (g-curexc.ads)
12759 @section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
12760 @cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
12761 @cindex Current exception
12762 @cindex Exception retrieval
12764 @noindent
12765 Provides access to information on the current exception that has been raised
12766 without the need for using the Ada-95 exception choice parameter specification
12767 syntax.  This is particularly useful in simulating typical facilities for
12768 obtaining information about exceptions provided by Ada 83 compilers.
12770 @node GNAT.Debug_Pools (g-debpoo.ads)
12771 @section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
12772 @cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
12773 @cindex Debugging
12774 @cindex Debug pools
12775 @cindex Memory corruption debugging
12777 @noindent
12778 Provide a debugging storage pools that helps tracking memory corruption
12779 problems.  See section ``Finding memory problems with GNAT Debug Pool'' in
12780 the @cite{GNAT User's Guide}.
12782 @node GNAT.Debug_Utilities (g-debuti.ads)
12783 @section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
12784 @cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
12785 @cindex Debugging
12787 @noindent
12788 Provides a few useful utilities for debugging purposes, including conversion
12789 to and from string images of address values. Supports both C and Ada formats
12790 for hexadecimal literals.
12792 @node GNAT.Directory_Operations (g-dirope.ads)
12793 @section @code{GNAT.Directory_Operations} (g-dirope.ads)
12794 @cindex @code{GNAT.Directory_Operations} (g-dirope.ads)
12795 @cindex Directory operations
12797 @noindent
12798 Provides a set of routines for manipulating directories, including changing
12799 the current directory, making new directories, and scanning the files in a
12800 directory.
12802 @node GNAT.Dynamic_HTables (g-dynhta.ads)
12803 @section @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
12804 @cindex @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
12805 @cindex Hash tables
12807 @noindent
12808 A generic implementation of hash tables that can be used to hash arbitrary
12809 data.  Provided in two forms, a simple form with built in hash functions,
12810 and a more complex form in which the hash function is supplied.
12812 @noindent
12813 This package provides a facility similar to that of @code{GNAT.HTable},
12814 except that this package declares a type that can be used to define
12815 dynamic instances of the hash table, while an instantiation of
12816 @code{GNAT.HTable} creates a single instance of the hash table.
12818 @node GNAT.Dynamic_Tables (g-dyntab.ads)
12819 @section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
12820 @cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
12821 @cindex Table implementation
12822 @cindex Arrays, extendable
12824 @noindent
12825 A generic package providing a single dimension array abstraction where the
12826 length of the array can be dynamically modified.
12828 @noindent
12829 This package provides a facility similar to that of @code{GNAT.Table},
12830 except that this package declares a type that can be used to define
12831 dynamic instances of the table, while an instantiation of
12832 @code{GNAT.Table} creates a single instance of the table type.
12834 @node GNAT.Exception_Actions (g-excact.ads)
12835 @section @code{GNAT.Exception_Actions} (@file{g-excact.ads})
12836 @cindex @code{GNAT.Exception_Actions} (@file{g-excact.ads})
12837 @cindex Exception actions
12839 @noindent
12840 Provides callbacks when an exception is raised. Callbacks can be registered
12841 for specific exceptions, or when any exception is raised. This
12842 can be used for instance to force a core dump to ease debugging.
12844 @node GNAT.Exception_Traces (g-exctra.ads)
12845 @section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
12846 @cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
12847 @cindex Exception traces
12848 @cindex Debugging
12850 @noindent
12851 Provides an interface allowing to control automatic output upon exception
12852 occurrences.
12854 @node GNAT.Exceptions (g-except.ads)
12855 @section @code{GNAT.Exceptions} (@file{g-expect.ads})
12856 @cindex @code{GNAT.Exceptions} (@file{g-expect.ads})
12857 @cindex Exceptions, Pure
12858 @cindex Pure packages, exceptions
12860 @noindent
12861 Normally it is not possible to raise an exception with
12862 a message from a subprogram in a pure package, since the
12863 necessary types and subprograms are in @code{Ada.Exceptions}
12864 which is not a pure unit. @code{GNAT.Exceptions} provides a
12865 facility for getting around this limitation for a few
12866 predefined exceptions, and for example allow raising
12867 @code{Constraint_Error} with a message from a pure subprogram.
12869 @node GNAT.Expect (g-expect.ads)
12870 @section @code{GNAT.Expect} (@file{g-expect.ads})
12871 @cindex @code{GNAT.Expect} (@file{g-expect.ads})
12873 @noindent
12874 Provides a set of subprograms similar to what is available
12875 with the standard Tcl Expect tool.
12876 It allows you to easily spawn and communicate with an external process.
12877 You can send commands or inputs to the process, and compare the output
12878 with some expected regular expression. Currently @code{GNAT.Expect}
12879 is implemented on all native GNAT ports except for OpenVMS@.
12880 It is not implemented for cross ports, and in particular is not
12881 implemented for VxWorks or LynxOS@.
12883 @node GNAT.Float_Control (g-flocon.ads)
12884 @section @code{GNAT.Float_Control} (@file{g-flocon.ads})
12885 @cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
12886 @cindex Floating-Point Processor
12888 @noindent
12889 Provides an interface for resetting the floating-point processor into the
12890 mode required for correct semantic operation in Ada.  Some third party
12891 library calls may cause this mode to be modified, and the Reset procedure
12892 in this package can be used to reestablish the required mode.
12894 @node GNAT.Heap_Sort (g-heasor.ads)
12895 @section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
12896 @cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
12897 @cindex Sorting
12899 @noindent
12900 Provides a general implementation of heap sort usable for sorting arbitrary
12901 data items. Exchange and comparison procedures are provided by passing
12902 access-to-procedure values.  The algorithm used is a modified heap sort
12903 that performs approximately N*log(N) comparisons in the worst case.
12905 @node GNAT.Heap_Sort_A (g-hesora.ads)
12906 @section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
12907 @cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
12908 @cindex Sorting
12910 @noindent
12911 Provides a general implementation of heap sort usable for sorting arbitrary
12912 data items. Move and comparison procedures are provided by passing
12913 access-to-procedure values.  The algorithm used is a modified heap sort
12914 that performs approximately N*log(N) comparisons in the worst case.
12915 This differs from @code{GNAT.Heap_Sort} in having a less convenient
12916 interface, but may be slightly more efficient.
12918 @node GNAT.Heap_Sort_G (g-hesorg.ads)
12919 @section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
12920 @cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
12921 @cindex Sorting
12923 @noindent
12924 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
12925 are provided as generic parameters, this improves efficiency, especially
12926 if the procedures can be inlined, at the expense of duplicating code for
12927 multiple instantiations.
12929 @node GNAT.HTable (g-htable.ads)
12930 @section @code{GNAT.HTable} (@file{g-htable.ads})
12931 @cindex @code{GNAT.HTable} (@file{g-htable.ads})
12932 @cindex Hash tables
12934 @noindent
12935 A generic implementation of hash tables that can be used to hash arbitrary
12936 data.  Provides two approaches, one a simple static approach, and the other
12937 allowing arbitrary dynamic hash tables.
12939 @node GNAT.IO (g-io.ads)
12940 @section @code{GNAT.IO} (@file{g-io.ads})
12941 @cindex @code{GNAT.IO} (@file{g-io.ads})
12942 @cindex Simple I/O
12943 @cindex Input/Output facilities
12945 @noindent
12946 A simple preelaborable input-output package that provides a subset of
12947 simple Text_IO functions for reading characters and strings from
12948 Standard_Input, and writing characters, strings and integers to either
12949 Standard_Output or Standard_Error.
12951 @node GNAT.IO_Aux (g-io_aux.ads)
12952 @section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
12953 @cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
12954 @cindex Text_IO
12955 @cindex Input/Output facilities
12957 Provides some auxiliary functions for use with Text_IO, including a test
12958 for whether a file exists, and functions for reading a line of text.
12960 @node GNAT.Lock_Files (g-locfil.ads)
12961 @section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
12962 @cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
12963 @cindex File locking
12964 @cindex Locking using files
12966 @noindent
12967 Provides a general interface for using files as locks.  Can be used for
12968 providing program level synchronization.
12970 @node GNAT.MD5 (g-md5.ads)
12971 @section @code{GNAT.MD5} (@file{g-md5.ads})
12972 @cindex @code{GNAT.MD5} (@file{g-md5.ads})
12973 @cindex Message Digest MD5
12975 @noindent
12976 Implements the MD5 Message-Digest Algorithm as described in RFC 1321.
12978 @node GNAT.Memory_Dump (g-memdum.ads)
12979 @section @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
12980 @cindex @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
12981 @cindex Dump Memory
12983 @noindent
12984 Provides a convenient routine for dumping raw memory to either the
12985 standard output or standard error files. Uses GNAT.IO for actual
12986 output.
12988 @node GNAT.Most_Recent_Exception (g-moreex.ads)
12989 @section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
12990 @cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
12991 @cindex Exception, obtaining most recent
12993 @noindent
12994 Provides access to the most recently raised exception.  Can be used for
12995 various logging purposes, including duplicating functionality of some
12996 Ada 83 implementation dependent extensions.
12998 @node GNAT.OS_Lib (g-os_lib.ads)
12999 @section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
13000 @cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
13001 @cindex Operating System interface
13002 @cindex Spawn capability
13004 @noindent
13005 Provides a range of target independent operating system interface functions,
13006 including time/date management, file operations, subprocess management,
13007 including a portable spawn procedure, and access to environment variables
13008 and error return codes.
13010 @node GNAT.Perfect_Hash_Generators (g-pehage.ads)
13011 @section @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
13012 @cindex @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
13013 @cindex Hash functions
13015 @noindent
13016 Provides a generator of static minimal perfect hash functions. No
13017 collisions occur and each item can be retrieved from the table in one
13018 probe (perfect property). The hash table size corresponds to the exact
13019 size of the key set and no larger (minimal property). The key set has to
13020 be know in advance (static property). The hash functions are also order
13021 preserving. If w2 is inserted after w1 in the generator, their
13022 hashcode are in the same order. These hashing functions are very
13023 convenient for use with realtime applications.
13025 @node GNAT.Regexp (g-regexp.ads)
13026 @section @code{GNAT.Regexp} (@file{g-regexp.ads})
13027 @cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
13028 @cindex Regular expressions
13029 @cindex Pattern matching
13031 @noindent
13032 A simple implementation of regular expressions, using a subset of regular
13033 expression syntax copied from familiar Unix style utilities.  This is the
13034 simples of the three pattern matching packages provided, and is particularly
13035 suitable for ``file globbing'' applications.
13037 @node GNAT.Registry (g-regist.ads)
13038 @section @code{GNAT.Registry} (@file{g-regist.ads})
13039 @cindex @code{GNAT.Registry} (@file{g-regist.ads})
13040 @cindex Windows Registry
13042 @noindent
13043 This is a high level binding to the Windows registry.  It is possible to
13044 do simple things like reading a key value, creating a new key.  For full
13045 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
13046 package provided with the Win32Ada binding
13048 @node GNAT.Regpat (g-regpat.ads)
13049 @section @code{GNAT.Regpat} (@file{g-regpat.ads})
13050 @cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
13051 @cindex Regular expressions
13052 @cindex Pattern matching
13054 @noindent
13055 A complete implementation of Unix-style regular expression matching, copied
13056 from the original V7 style regular expression library written in C by
13057 Henry Spencer (and binary compatible with this C library).
13059 @node GNAT.Secondary_Stack_Info (g-sestin.ads)
13060 @section @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
13061 @cindex @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
13062 @cindex Secondary Stack Info
13064 @noindent
13065 Provide the capability to query the high water mark of the current task's
13066 secondary stack.
13068 @node GNAT.Semaphores (g-semaph.ads)
13069 @section @code{GNAT.Semaphores} (@file{g-semaph.ads})
13070 @cindex @code{GNAT.Semaphores} (@file{g-semaph.ads})
13071 @cindex Semaphores
13073 @noindent
13074 Provides classic counting and binary semaphores using protected types.
13076 @node GNAT.Signals (g-signal.ads)
13077 @section @code{GNAT.Signals} (@file{g-signal.ads})
13078 @cindex @code{GNAT.Signals} (@file{g-signal.ads})
13079 @cindex Signals
13081 @noindent
13082 Provides the ability to manipulate the blocked status of signals on supported
13083 targets.
13085 @node GNAT.Sockets (g-socket.ads)
13086 @section @code{GNAT.Sockets} (@file{g-socket.ads})
13087 @cindex @code{GNAT.Sockets} (@file{g-socket.ads})
13088 @cindex Sockets
13090 @noindent
13091 A high level and portable interface to develop sockets based applications.
13092 This package is based on the sockets thin binding found in
13093 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
13094 on all native GNAT ports except for OpenVMS@.  It is not implemented
13095 for the LynxOS@ cross port.
13097 @node GNAT.Source_Info (g-souinf.ads)
13098 @section @code{GNAT.Source_Info} (@file{g-souinf.ads})
13099 @cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
13100 @cindex Source Information
13102 @noindent
13103 Provides subprograms that give access to source code information known at
13104 compile time, such as the current file name and line number.
13106 @node GNAT.Spell_Checker (g-speche.ads)
13107 @section @code{GNAT.Spell_Checker} (@file{g-speche.ads})
13108 @cindex @code{GNAT.Spell_Checker} (@file{g-speche.ads})
13109 @cindex Spell checking
13111 @noindent
13112 Provides a function for determining whether one string is a plausible
13113 near misspelling of another string.
13115 @node GNAT.Spitbol.Patterns (g-spipat.ads)
13116 @section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
13117 @cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
13118 @cindex SPITBOL pattern matching
13119 @cindex Pattern matching
13121 @noindent
13122 A complete implementation of SNOBOL4 style pattern matching.  This is the
13123 most elaborate of the pattern matching packages provided.  It fully duplicates
13124 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
13125 efficient algorithm developed by Robert Dewar for the SPITBOL system.
13127 @node GNAT.Spitbol (g-spitbo.ads)
13128 @section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
13129 @cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
13130 @cindex SPITBOL interface
13132 @noindent
13133 The top level package of the collection of SPITBOL-style functionality, this
13134 package provides basic SNOBOL4 string manipulation functions, such as
13135 Pad, Reverse, Trim, Substr capability, as well as a generic table function
13136 useful for constructing arbitrary mappings from strings in the style of
13137 the SNOBOL4 TABLE function.
13139 @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
13140 @section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
13141 @cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
13142 @cindex Sets of strings
13143 @cindex SPITBOL Tables
13145 @noindent
13146 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
13147 for type @code{Standard.Boolean}, giving an implementation of sets of
13148 string values.
13150 @node GNAT.Spitbol.Table_Integer (g-sptain.ads)
13151 @section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
13152 @cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
13153 @cindex Integer maps
13154 @cindex Maps
13155 @cindex SPITBOL Tables
13157 @noindent
13158 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
13159 for type @code{Standard.Integer}, giving an implementation of maps
13160 from string to integer values.
13162 @node GNAT.Spitbol.Table_VString (g-sptavs.ads)
13163 @section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
13164 @cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
13165 @cindex String maps
13166 @cindex Maps
13167 @cindex SPITBOL Tables
13169 @noindent
13170 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
13171 a variable length string type, giving an implementation of general
13172 maps from strings to strings.
13174 @node GNAT.Strings (g-string.ads)
13175 @section @code{GNAT.Strings} (@file{g-string.ads})
13176 @cindex @code{GNAT.Strings} (@file{g-string.ads})
13178 @noindent
13179 Common String access types and related subprograms. Basically it
13180 defines a string access and an array of string access types.
13182 @node GNAT.String_Split (g-strspl.ads)
13183 @section @code{GNAT.String_Split} (@file{g-strspl.ads})
13184 @cindex @code{GNAT.String_Split} (@file{g-strspl.ads})
13185 @cindex String splitter
13187 @noindent
13188 Useful string manipulation routines: given a set of separators, split
13189 a string wherever the separators appear, and provide direct access
13190 to the resulting slices. This package is instantiated from
13191 @code{GNAT.Array_Split}.
13193 @node GNAT.UTF_32 (g-utf_32.ads)
13194 @section @code{GNAT.UTF_32} (@file{g-table.ads})
13195 @cindex @code{GNAT.UTF_32} (@file{g-table.ads})
13196 @cindex Wide character codes
13198 @noindent
13199 This is a package intended to be used in conjunction with the
13200 @code{Wide_Character} type in Ada 95 and the
13201 @code{Wide_Wide_Character} type in Ada 2005 (available
13202 in @code{GNAT} in Ada 2005 mode). This package contains
13203 Unicode categorization routines, as well as lexical
13204 categorization routines corresponding to the Ada 2005
13205 lexical rules for identifiers and strings, and also a
13206 lower case to upper case fold routine corresponding to
13207 the Ada 2005 rules for identifier equivalence.
13209 @node GNAT.Table (g-table.ads)
13210 @section @code{GNAT.Table} (@file{g-table.ads})
13211 @cindex @code{GNAT.Table} (@file{g-table.ads})
13212 @cindex Table implementation
13213 @cindex Arrays, extendable
13215 @noindent
13216 A generic package providing a single dimension array abstraction where the
13217 length of the array can be dynamically modified.
13219 @noindent
13220 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
13221 except that this package declares a single instance of the table type,
13222 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
13223 used to define dynamic instances of the table.
13225 @node GNAT.Task_Lock (g-tasloc.ads)
13226 @section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
13227 @cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
13228 @cindex Task synchronization
13229 @cindex Task locking
13230 @cindex Locking
13232 @noindent
13233 A very simple facility for locking and unlocking sections of code using a
13234 single global task lock.  Appropriate for use in situations where contention
13235 between tasks is very rarely expected.
13237 @node GNAT.Threads (g-thread.ads)
13238 @section @code{GNAT.Threads} (@file{g-thread.ads})
13239 @cindex @code{GNAT.Threads} (@file{g-thread.ads})
13240 @cindex Foreign threads
13241 @cindex Threads, foreign
13243 @noindent
13244 Provides facilities for creating and destroying threads with explicit calls.
13245 These threads are known to the GNAT run-time system.  These subprograms are
13246 exported C-convention procedures intended to be called from foreign code.
13247 By using these primitives rather than directly calling operating systems
13248 routines, compatibility with the Ada tasking run-time is provided.
13250 @node GNAT.Traceback (g-traceb.ads)
13251 @section @code{GNAT.Traceback} (@file{g-traceb.ads})
13252 @cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
13253 @cindex Trace back facilities
13255 @noindent
13256 Provides a facility for obtaining non-symbolic traceback information, useful
13257 in various debugging situations.
13259 @node GNAT.Traceback.Symbolic (g-trasym.ads)
13260 @section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
13261 @cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
13262 @cindex Trace back facilities
13264 @noindent
13265 Provides symbolic traceback information that includes the subprogram
13266 name and line number information.
13268 @node GNAT.Wide_String_Split (g-wistsp.ads)
13269 @section @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
13270 @cindex @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
13271 @cindex Wide_String splitter
13273 @noindent
13274 Useful wide string manipulation routines: given a set of separators, split
13275 a wide string wherever the separators appear, and provide direct access
13276 to the resulting slices. This package is instantiated from
13277 @code{GNAT.Array_Split}.
13279 @node GNAT.Wide_Wide_String_Split (g-zistsp.ads)
13280 @section @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
13281 @cindex @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
13282 @cindex Wide_Wide_String splitter
13284 @noindent
13285 Useful wide wide string manipulation routines: given a set of separators, split
13286 a wide wide string wherever the separators appear, and provide direct access
13287 to the resulting slices. This package is instantiated from
13288 @code{GNAT.Array_Split}.
13290 @node Interfaces.C.Extensions (i-cexten.ads)
13291 @section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
13292 @cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
13294 @noindent
13295 This package contains additional C-related definitions, intended
13296 for use with either manually or automatically generated bindings
13297 to C libraries.
13299 @node Interfaces.C.Streams (i-cstrea.ads)
13300 @section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
13301 @cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
13302 @cindex  C streams, interfacing
13304 @noindent
13305 This package is a binding for the most commonly used operations
13306 on C streams.
13308 @node Interfaces.CPP (i-cpp.ads)
13309 @section @code{Interfaces.CPP} (@file{i-cpp.ads})
13310 @cindex @code{Interfaces.CPP} (@file{i-cpp.ads})
13311 @cindex  C++ interfacing
13312 @cindex  Interfacing, to C++
13314 @noindent
13315 This package provides facilities for use in interfacing to C++.  It
13316 is primarily intended to be used in connection with automated tools
13317 for the generation of C++ interfaces.
13319 @node Interfaces.Os2lib (i-os2lib.ads)
13320 @section @code{Interfaces.Os2lib} (@file{i-os2lib.ads})
13321 @cindex @code{Interfaces.Os2lib} (@file{i-os2lib.ads})
13322 @cindex Interfacing, to OS/2
13323 @cindex OS/2 interfacing
13325 @noindent
13326 This package provides interface definitions to the OS/2 library.
13327 It is a thin binding which is a direct translation of the
13328 various @file{<bse@.h>} files.
13330 @node Interfaces.Os2lib.Errors (i-os2err.ads)
13331 @section @code{Interfaces.Os2lib.Errors} (@file{i-os2err.ads})
13332 @cindex @code{Interfaces.Os2lib.Errors} (@file{i-os2err.ads})
13333 @cindex OS/2 Error codes
13334 @cindex Interfacing, to OS/2
13335 @cindex OS/2 interfacing
13337 @noindent
13338 This package provides definitions of the OS/2 error codes.
13340 @node Interfaces.Os2lib.Synchronization (i-os2syn.ads)
13341 @section @code{Interfaces.Os2lib.Synchronization} (@file{i-os2syn.ads})
13342 @cindex @code{Interfaces.Os2lib.Synchronization} (@file{i-os2syn.ads})
13343 @cindex Interfacing, to OS/2
13344 @cindex Synchronization, OS/2
13345 @cindex OS/2 synchronization primitives
13347 @noindent
13348 This is a child package that provides definitions for interfacing
13349 to the @code{OS/2} synchronization primitives.
13351 @node Interfaces.Os2lib.Threads (i-os2thr.ads)
13352 @section @code{Interfaces.Os2lib.Threads} (@file{i-os2thr.ads})
13353 @cindex @code{Interfaces.Os2lib.Threads} (@file{i-os2thr.ads})
13354 @cindex Interfacing, to OS/2
13355 @cindex Thread control, OS/2
13356 @cindex OS/2 thread interfacing
13358 @noindent
13359 This is a child package that provides definitions for interfacing
13360 to the @code{OS/2} thread primitives.
13362 @node Interfaces.Packed_Decimal (i-pacdec.ads)
13363 @section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
13364 @cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
13365 @cindex  IBM Packed Format
13366 @cindex  Packed Decimal
13368 @noindent
13369 This package provides a set of routines for conversions to and
13370 from a packed decimal format compatible with that used on IBM
13371 mainframes.
13373 @node Interfaces.VxWorks (i-vxwork.ads)
13374 @section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
13375 @cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
13376 @cindex Interfacing to VxWorks
13377 @cindex VxWorks, interfacing
13379 @noindent
13380 This package provides a limited binding to the VxWorks API.
13381 In particular, it interfaces with the
13382 VxWorks hardware interrupt facilities.
13384 @node Interfaces.VxWorks.IO (i-vxwoio.ads)
13385 @section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
13386 @cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
13387 @cindex Interfacing to VxWorks' I/O
13388 @cindex VxWorks, I/O interfacing
13389 @cindex VxWorks, Get_Immediate
13390 @cindex Get_Immediate, VxWorks
13392 @noindent
13393 This package provides a binding to the ioctl (IO/Control)
13394 function of VxWorks, defining a set of option values and
13395 function codes. A particular use of this package is
13396 to enable the use of Get_Immediate under VxWorks.
13398 @node System.Address_Image (s-addima.ads)
13399 @section @code{System.Address_Image} (@file{s-addima.ads})
13400 @cindex @code{System.Address_Image} (@file{s-addima.ads})
13401 @cindex Address image
13402 @cindex Image, of an address
13404 @noindent
13405 This function provides a useful debugging
13406 function that gives an (implementation dependent)
13407 string which identifies an address.
13409 @node System.Assertions (s-assert.ads)
13410 @section @code{System.Assertions} (@file{s-assert.ads})
13411 @cindex @code{System.Assertions} (@file{s-assert.ads})
13412 @cindex Assertions
13413 @cindex Assert_Failure, exception
13415 @noindent
13416 This package provides the declaration of the exception raised
13417 by an run-time assertion failure, as well as the routine that
13418 is used internally to raise this assertion.
13420 @node System.Memory (s-memory.ads)
13421 @section @code{System.Memory} (@file{s-memory.ads})
13422 @cindex @code{System.Memory} (@file{s-memory.ads})
13423 @cindex Memory allocation
13425 @noindent
13426 This package provides the interface to the low level routines used
13427 by the generated code for allocation and freeing storage for the
13428 default storage pool (analogous to the C routines malloc and free.
13429 It also provides a reallocation interface analogous to the C routine
13430 realloc. The body of this unit may be modified to provide alternative
13431 allocation mechanisms for the default pool, and in addition, direct
13432 calls to this unit may be made for low level allocation uses (for
13433 example see the body of @code{GNAT.Tables}).
13435 @node System.Partition_Interface (s-parint.ads)
13436 @section @code{System.Partition_Interface} (@file{s-parint.ads})
13437 @cindex @code{System.Partition_Interface} (@file{s-parint.ads})
13438 @cindex Partition interfacing functions
13440 @noindent
13441 This package provides facilities for partition interfacing.  It
13442 is used primarily in a distribution context when using Annex E
13443 with @code{GLADE}.
13445 @node System.Restrictions (s-restri.ads)
13446 @section @code{System.Restrictions} (@file{s-restri.ads})
13447 @cindex @code{System.Restrictions} (@file{s-restri.ads})
13448 @cindex Run-time restrictions access
13450 @noindent
13451 This package provides facilities for accessing at run-time
13452 the status of restrictions specified at compile time for
13453 the partition. Information is available both with regard
13454 to actual restrictions specified, and with regard to
13455 compiler determined information on which restrictions
13456 are violated by one or more packages in the partition.
13458 @node System.Rident (s-rident.ads)
13459 @section @code{System.Rident} (@file{s-rident.ads})
13460 @cindex @code{System.Rident} (@file{s-rident.ads})
13461 @cindex Restrictions definitions
13463 @noindent
13464 This package provides definitions of the restrictions
13465 identifiers supported by GNAT, and also the format of
13466 the restrictions provided in package System.Restrictions.
13467 It is not normally necessary to @code{with} this generic package
13468 since the necessary instantiation is included in
13469 package System.Restrictions.
13471 @node System.Task_Info (s-tasinf.ads)
13472 @section @code{System.Task_Info} (@file{s-tasinf.ads})
13473 @cindex @code{System.Task_Info} (@file{s-tasinf.ads})
13474 @cindex Task_Info pragma
13476 @noindent
13477 This package provides target dependent functionality that is used
13478 to support the @code{Task_Info} pragma
13480 @node System.Wch_Cnv (s-wchcnv.ads)
13481 @section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
13482 @cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
13483 @cindex Wide Character, Representation
13484 @cindex Wide String, Conversion
13485 @cindex Representation of wide characters
13487 @noindent
13488 This package provides routines for converting between
13489 wide and wide wide characters and a representation as a value of type
13490 @code{Standard.String}, using a specified wide character
13491 encoding method.  It uses definitions in
13492 package @code{System.Wch_Con}.
13494 @node System.Wch_Con (s-wchcon.ads)
13495 @section @code{System.Wch_Con} (@file{s-wchcon.ads})
13496 @cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
13498 @noindent
13499 This package provides definitions and descriptions of
13500 the various methods used for encoding wide characters
13501 in ordinary strings.  These definitions are used by
13502 the package @code{System.Wch_Cnv}.
13504 @node Interfacing to Other Languages
13505 @chapter Interfacing to Other Languages
13506 @noindent
13507 The facilities in annex B of the Ada 95 Reference Manual are fully
13508 implemented in GNAT, and in addition, a full interface to C++ is
13509 provided.
13511 @menu
13512 * Interfacing to C::
13513 * Interfacing to C++::
13514 * Interfacing to COBOL::
13515 * Interfacing to Fortran::
13516 * Interfacing to non-GNAT Ada code::
13517 @end menu
13519 @node Interfacing to C
13520 @section Interfacing to C
13522 @noindent
13523 Interfacing to C with GNAT can use one of two approaches:
13525 @itemize @bullet
13526 @item
13527 The types in the package @code{Interfaces.C} may be used.
13528 @item
13529 Standard Ada types may be used directly.  This may be less portable to
13530 other compilers, but will work on all GNAT compilers, which guarantee
13531 correspondence between the C and Ada types.
13532 @end itemize
13534 @noindent
13535 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
13536 effect, since this is the default.  The following table shows the
13537 correspondence between Ada scalar types and the corresponding C types.
13539 @table @code
13540 @item Integer
13541 @code{int}
13542 @item Short_Integer
13543 @code{short}
13544 @item Short_Short_Integer
13545 @code{signed char}
13546 @item Long_Integer
13547 @code{long}
13548 @item Long_Long_Integer
13549 @code{long long}
13550 @item Short_Float
13551 @code{float}
13552 @item Float
13553 @code{float}
13554 @item Long_Float
13555 @code{double}
13556 @item Long_Long_Float
13557 This is the longest floating-point type supported by the hardware.
13558 @end table
13560 @noindent
13561 Additionally, there are the following general correspondences between Ada
13562 and C types:
13563 @itemize @bullet
13564 @item
13565 Ada enumeration types map to C enumeration types directly if pragma
13566 @code{Convention C} is specified, which causes them to have int
13567 length.  Without pragma @code{Convention C}, Ada enumeration types map to
13568 8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short},
13569 @code{int}, respectively) depending on the number of values passed.
13570 This is the only case in which pragma @code{Convention C} affects the
13571 representation of an Ada type.
13573 @item
13574 Ada access types map to C pointers, except for the case of pointers to
13575 unconstrained types in Ada, which have no direct C equivalent.
13577 @item
13578 Ada arrays map directly to C arrays.
13580 @item
13581 Ada records map directly to C structures.
13583 @item
13584 Packed Ada records map to C structures where all members are bit fields
13585 of the length corresponding to the @code{@var{type}'Size} value in Ada.
13586 @end itemize
13588 @node Interfacing to C++
13589 @section Interfacing to C++
13591 @noindent
13592 The interface to C++ makes use of the following pragmas, which are
13593 primarily intended to be constructed automatically using a binding generator
13594 tool, although it is possible to construct them by hand.  No suitable binding
13595 generator tool is supplied with GNAT though.
13597 Using these pragmas it is possible to achieve complete
13598 inter-operability between Ada tagged types and C class definitions.
13599 See @ref{Implementation Defined Pragmas}, for more details.
13601 @table @code
13602 @item pragma CPP_Class ([Entity =>] @var{local_NAME})
13603 The argument denotes an entity in the current declarative region that is
13604 declared as a tagged or untagged record type.  It indicates that the type
13605 corresponds to an externally declared C++ class type, and is to be laid
13606 out the same way that C++ would lay out the type.
13608 @item pragma CPP_Constructor ([Entity =>] @var{local_NAME})
13609 This pragma identifies an imported function (imported in the usual way
13610 with pragma @code{Import}) as corresponding to a C++ constructor.
13612 @item pragma CPP_Vtable @dots{}
13613 One @code{CPP_Vtable} pragma can be present for each component of type
13614 @code{CPP.Interfaces.Vtable_Ptr} in a record to which pragma @code{CPP_Class}
13615 applies.
13616 @end table
13618 @node Interfacing to COBOL
13619 @section Interfacing to COBOL
13621 @noindent
13622 Interfacing to COBOL is achieved as described in section B.4 of
13623 the Ada 95 reference manual.
13625 @node Interfacing to Fortran
13626 @section Interfacing to Fortran
13628 @noindent
13629 Interfacing to Fortran is achieved as described in section B.5 of the
13630 reference manual.  The pragma @code{Convention Fortran}, applied to a
13631 multi-dimensional array causes the array to be stored in column-major
13632 order as required for convenient interface to Fortran.
13634 @node Interfacing to non-GNAT Ada code
13635 @section Interfacing to non-GNAT Ada code
13637 It is possible to specify the convention @code{Ada} in a pragma
13638 @code{Import} or pragma @code{Export}.  However this refers to
13639 the calling conventions used by GNAT, which may or may not be
13640 similar enough to those used by some other Ada 83 or Ada 95
13641 compiler to allow interoperation.
13643 If arguments types are kept simple, and if the foreign compiler generally
13644 follows system calling conventions, then it may be possible to integrate
13645 files compiled by other Ada compilers, provided that the elaboration
13646 issues are adequately addressed (for example by eliminating the
13647 need for any load time elaboration).
13649 In particular, GNAT running on VMS is designed to
13650 be highly compatible with the DEC Ada 83 compiler, so this is one
13651 case in which it is possible to import foreign units of this type,
13652 provided that the data items passed are restricted to simple scalar
13653 values or simple record types without variants, or simple array
13654 types with fixed bounds.
13656 @node Specialized Needs Annexes
13657 @chapter Specialized Needs Annexes
13659 @noindent
13660 Ada 95 defines a number of specialized needs annexes, which are not
13661 required in all implementations.  However, as described in this chapter,
13662 GNAT implements all of these special needs annexes:
13664 @table @asis
13665 @item Systems Programming (Annex C)
13666 The Systems Programming Annex is fully implemented.
13668 @item Real-Time Systems (Annex D)
13669 The Real-Time Systems Annex is fully implemented.
13671 @item Distributed Systems (Annex E)
13672 Stub generation is fully implemented in the GNAT compiler.  In addition,
13673 a complete compatible PCS is available as part of the GLADE system,
13674 a separate product.  When the two
13675 products are used in conjunction, this annex is fully implemented.
13677 @item Information Systems (Annex F)
13678 The Information Systems annex is fully implemented.
13680 @item Numerics (Annex G)
13681 The Numerics Annex is fully implemented.
13683 @item Safety and Security (Annex H)
13684 The Safety and Security annex is fully implemented.
13685 @end table
13687 @node Implementation of Specific Ada Features
13688 @chapter Implementation of Specific Ada Features
13690 @noindent
13691 This chapter describes the GNAT implementation of several Ada language
13692 facilities.
13694 @menu
13695 * Machine Code Insertions::
13696 * GNAT Implementation of Tasking::
13697 * GNAT Implementation of Shared Passive Packages::
13698 * Code Generation for Array Aggregates::
13699 * The Size of Discriminated Records with Default Discriminants::
13700 * Strict Conformance to the Ada 95 Reference Manual::
13701 @end menu
13703 @node Machine Code Insertions
13704 @section Machine Code Insertions
13706 @noindent
13707 Package @code{Machine_Code} provides machine code support as described
13708 in the Ada 95 Reference Manual in two separate forms:
13709 @itemize @bullet
13710 @item
13711 Machine code statements, consisting of qualified expressions that
13712 fit the requirements of RM section 13.8.
13713 @item
13714 An intrinsic callable procedure, providing an alternative mechanism of
13715 including machine instructions in a subprogram.
13716 @end itemize
13718 @noindent
13719 The two features are similar, and both are closely related to the mechanism
13720 provided by the asm instruction in the GNU C compiler.  Full understanding
13721 and use of the facilities in this package requires understanding the asm
13722 instruction as described in @cite{Using the GNU Compiler Collection (GCC)}
13723 by Richard Stallman. The relevant section is titled ``Extensions to the C
13724 Language Family'' -> ``Assembler Instructions with C Expression Operands''.
13726 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
13727 semantic restrictions and effects as described below.  Both are provided so
13728 that the procedure call can be used as a statement, and the function call
13729 can be used to form a code_statement.
13731 The first example given in the GCC documentation is the C @code{asm}
13732 instruction:
13733 @smallexample
13734    asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
13735 @end smallexample
13737 @noindent
13738 The equivalent can be written for GNAT as:
13740 @smallexample @c ada
13741 Asm ("fsinx %1 %0",
13742      My_Float'Asm_Output ("=f", result),
13743      My_Float'Asm_Input  ("f",  angle));
13744 @end smallexample
13746 @noindent
13747 The first argument to @code{Asm} is the assembler template, and is
13748 identical to what is used in GNU C@.  This string must be a static
13749 expression.  The second argument is the output operand list.  It is
13750 either a single @code{Asm_Output} attribute reference, or a list of such
13751 references enclosed in parentheses (technically an array aggregate of
13752 such references).
13754 The @code{Asm_Output} attribute denotes a function that takes two
13755 parameters.  The first is a string, the second is the name of a variable
13756 of the type designated by the attribute prefix.  The first (string)
13757 argument is required to be a static expression and designates the
13758 constraint for the parameter (e.g.@: what kind of register is
13759 required).  The second argument is the variable to be updated with the
13760 result.  The possible values for constraint are the same as those used in
13761 the RTL, and are dependent on the configuration file used to build the
13762 GCC back end.  If there are no output operands, then this argument may
13763 either be omitted, or explicitly given as @code{No_Output_Operands}.
13765 The second argument of @code{@var{my_float}'Asm_Output} functions as
13766 though it were an @code{out} parameter, which is a little curious, but
13767 all names have the form of expressions, so there is no syntactic
13768 irregularity, even though normally functions would not be permitted
13769 @code{out} parameters.  The third argument is the list of input
13770 operands.  It is either a single @code{Asm_Input} attribute reference, or
13771 a list of such references enclosed in parentheses (technically an array
13772 aggregate of such references).
13774 The @code{Asm_Input} attribute denotes a function that takes two
13775 parameters.  The first is a string, the second is an expression of the
13776 type designated by the prefix.  The first (string) argument is required
13777 to be a static expression, and is the constraint for the parameter,
13778 (e.g.@: what kind of register is required).  The second argument is the
13779 value to be used as the input argument.  The possible values for the
13780 constant are the same as those used in the RTL, and are dependent on
13781 the configuration file used to built the GCC back end.
13783 If there are no input operands, this argument may either be omitted, or
13784 explicitly given as @code{No_Input_Operands}.  The fourth argument, not
13785 present in the above example, is a list of register names, called the
13786 @dfn{clobber} argument.  This argument, if given, must be a static string
13787 expression, and is a space or comma separated list of names of registers
13788 that must be considered destroyed as a result of the @code{Asm} call.  If
13789 this argument is the null string (the default value), then the code
13790 generator assumes that no additional registers are destroyed.
13792 The fifth argument, not present in the above example, called the
13793 @dfn{volatile} argument, is by default @code{False}.  It can be set to
13794 the literal value @code{True} to indicate to the code generator that all
13795 optimizations with respect to the instruction specified should be
13796 suppressed, and that in particular, for an instruction that has outputs,
13797 the instruction will still be generated, even if none of the outputs are
13798 used.  See the full description in the GCC manual for further details.
13800 The @code{Asm} subprograms may be used in two ways.  First the procedure
13801 forms can be used anywhere a procedure call would be valid, and
13802 correspond to what the RM calls ``intrinsic'' routines.  Such calls can
13803 be used to intersperse machine instructions with other Ada statements.
13804 Second, the function forms, which return a dummy value of the limited
13805 private type @code{Asm_Insn}, can be used in code statements, and indeed
13806 this is the only context where such calls are allowed.  Code statements
13807 appear as aggregates of the form:
13809 @smallexample @c ada
13810 Asm_Insn'(Asm (@dots{}));
13811 Asm_Insn'(Asm_Volatile (@dots{}));
13812 @end smallexample
13814 @noindent
13815 In accordance with RM rules, such code statements are allowed only
13816 within subprograms whose entire body consists of such statements.  It is
13817 not permissible to intermix such statements with other Ada statements.
13819 Typically the form using intrinsic procedure calls is more convenient
13820 and more flexible.  The code statement form is provided to meet the RM
13821 suggestion that such a facility should be made available.  The following
13822 is the exact syntax of the call to @code{Asm}. As usual, if named notation
13823 is used, the arguments may be given in arbitrary order, following the
13824 normal rules for use of positional and named arguments)
13826 @smallexample
13827 ASM_CALL ::= Asm (
13828                  [Template =>] static_string_EXPRESSION
13829                [,[Outputs  =>] OUTPUT_OPERAND_LIST      ]
13830                [,[Inputs   =>] INPUT_OPERAND_LIST       ]
13831                [,[Clobber  =>] static_string_EXPRESSION ]
13832                [,[Volatile =>] static_boolean_EXPRESSION] )
13834 OUTPUT_OPERAND_LIST ::=
13835   [PREFIX.]No_Output_Operands
13836 | OUTPUT_OPERAND_ATTRIBUTE
13837 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
13839 OUTPUT_OPERAND_ATTRIBUTE ::=
13840   SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
13842 INPUT_OPERAND_LIST ::=
13843   [PREFIX.]No_Input_Operands
13844 | INPUT_OPERAND_ATTRIBUTE
13845 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
13847 INPUT_OPERAND_ATTRIBUTE ::=
13848   SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
13849 @end smallexample
13851 @noindent
13852 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
13853 are declared in the package @code{Machine_Code} and must be referenced
13854 according to normal visibility rules. In particular if there is no
13855 @code{use} clause for this package, then appropriate package name
13856 qualification is required.
13858 @node GNAT Implementation of Tasking
13859 @section GNAT Implementation of Tasking
13861 @noindent
13862 This chapter outlines the basic GNAT approach to tasking (in particular,
13863 a multi-layered library for portability) and discusses issues related
13864 to compliance with the Real-Time Systems Annex.
13866 @menu
13867 * Mapping Ada Tasks onto the Underlying Kernel Threads::
13868 * Ensuring Compliance with the Real-Time Annex::
13869 @end menu
13871 @node Mapping Ada Tasks onto the Underlying Kernel Threads
13872 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
13874 @noindent
13875 GNAT's run-time support comprises two layers:
13877 @itemize @bullet
13878 @item GNARL (GNAT Run-time Layer)
13879 @item GNULL (GNAT Low-level Library)
13880 @end itemize
13882 @noindent
13883 In GNAT, Ada's tasking services rely on a platform and OS independent
13884 layer known as GNARL@.  This code is responsible for implementing the
13885 correct semantics of Ada's task creation, rendezvous, protected
13886 operations etc.
13888 GNARL decomposes Ada's tasking semantics into simpler lower level
13889 operations such as create a thread, set the priority of a thread,
13890 yield, create a lock, lock/unlock, etc.  The spec for these low-level
13891 operations constitutes GNULLI, the GNULL Interface.  This interface is
13892 directly inspired from the POSIX real-time API@.
13894 If the underlying executive or OS implements the POSIX standard
13895 faithfully, the GNULL Interface maps as is to the services offered by
13896 the underlying kernel.  Otherwise, some target dependent glue code maps
13897 the services offered by the underlying kernel to the semantics expected
13898 by GNARL@.
13900 Whatever the underlying OS (VxWorks, UNIX, OS/2, Windows NT, etc.) the
13901 key point is that each Ada task is mapped on a thread in the underlying
13902 kernel.  For example, in the case of VxWorks, one Ada task = one VxWorks task.
13904 In addition Ada task priorities map onto the underlying thread priorities.
13905 Mapping Ada tasks onto the underlying kernel threads has several advantages:
13907 @itemize @bullet
13908 @item
13909 The underlying scheduler is used to schedule the Ada tasks.  This
13910 makes Ada tasks as efficient as kernel threads from a scheduling
13911 standpoint.
13913 @item
13914 Interaction with code written in C containing threads is eased
13915 since at the lowest level Ada tasks and C threads map onto the same
13916 underlying kernel concept.
13918 @item
13919 When an Ada task is blocked during I/O the remaining Ada tasks are
13920 able to proceed.
13922 @item
13923 On multiprocessor systems Ada tasks can execute in parallel.
13924 @end itemize
13926 @noindent
13927 Some threads libraries offer a mechanism to fork a new process, with the
13928 child process duplicating the threads from the parent.
13929 GNAT does not
13930 support this functionality when the parent contains more than one task.
13931 @cindex Forking a new process
13933 @node Ensuring Compliance with the Real-Time Annex
13934 @subsection Ensuring Compliance with the Real-Time Annex
13935 @cindex Real-Time Systems Annex compliance
13937 @noindent
13938 Although mapping Ada tasks onto
13939 the underlying threads has significant advantages, it does create some
13940 complications when it comes to respecting the scheduling semantics
13941 specified in the real-time annex (Annex D).
13943 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
13944 scheduling policy states:
13946 @quotation
13947 @emph{When the active priority of a ready task that is not running
13948 changes, or the setting of its base priority takes effect, the
13949 task is removed from the ready queue for its old active priority
13950 and is added at the tail of the ready queue for its new active
13951 priority, except in the case where the active priority is lowered
13952 due to the loss of inherited priority, in which case the task is
13953 added at the head of the ready queue for its new active priority.}
13954 @end quotation
13956 @noindent
13957 While most kernels do put tasks at the end of the priority queue when
13958 a task changes its priority, (which respects the main
13959 FIFO_Within_Priorities requirement), almost none keep a thread at the
13960 beginning of its priority queue when its priority drops from the loss
13961 of inherited priority.
13963 As a result most vendors have provided incomplete Annex D implementations.
13965 The GNAT run-time, has a nice cooperative solution to this problem
13966 which ensures that accurate FIFO_Within_Priorities semantics are
13967 respected.
13969 The principle is as follows.  When an Ada task T is about to start
13970 running, it checks whether some other Ada task R with the same
13971 priority as T has been suspended due to the loss of priority
13972 inheritance.  If this is the case, T yields and is placed at the end of
13973 its priority queue.  When R arrives at the front of the queue it
13974 executes.
13976 Note that this simple scheme preserves the relative order of the tasks
13977 that were ready to execute in the priority queue where R has been
13978 placed at the end.
13980 @node GNAT Implementation of Shared Passive Packages
13981 @section GNAT Implementation of Shared Passive Packages
13982 @cindex Shared passive packages
13984 @noindent
13985 GNAT fully implements the pragma @code{Shared_Passive} for
13986 @cindex pragma @code{Shared_Passive}
13987 the purpose of designating shared passive packages.
13988 This allows the use of passive partitions in the
13989 context described in the Ada Reference Manual; i.e. for communication
13990 between separate partitions of a distributed application using the
13991 features in Annex E.
13992 @cindex Annex E
13993 @cindex Distribution Systems Annex
13995 However, the implementation approach used by GNAT provides for more
13996 extensive usage as follows:
13998 @table @emph
13999 @item Communication between separate programs
14001 This allows separate programs to access the data in passive
14002 partitions, using protected objects for synchronization where
14003 needed. The only requirement is that the two programs have a
14004 common shared file system. It is even possible for programs
14005 running on different machines with different architectures
14006 (e.g. different endianness) to communicate via the data in
14007 a passive partition.
14009 @item Persistence between program runs
14011 The data in a passive package can persist from one run of a
14012 program to another, so that a later program sees the final
14013 values stored by a previous run of the same program.
14015 @end table
14017 @noindent
14018 The implementation approach used is to store the data in files. A
14019 separate stream file is created for each object in the package, and
14020 an access to an object causes the corresponding file to be read or
14021 written.
14023 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
14024 @cindex @code{SHARED_MEMORY_DIRECTORY} environment variable
14025 set to the directory to be used for these files.
14026 The files in this directory
14027 have names that correspond to their fully qualified names. For
14028 example, if we have the package
14030 @smallexample @c ada
14031 package X is
14032   pragma Shared_Passive (X);
14033   Y : Integer;
14034   Z : Float;
14035 end X;
14036 @end smallexample
14038 @noindent
14039 and the environment variable is set to @code{/stemp/}, then the files created
14040 will have the names:
14042 @smallexample
14043 /stemp/x.y
14044 /stemp/x.z
14045 @end smallexample
14047 @noindent
14048 These files are created when a value is initially written to the object, and
14049 the files are retained until manually deleted. This provides the persistence
14050 semantics. If no file exists, it means that no partition has assigned a value
14051 to the variable; in this case the initial value declared in the package
14052 will be used. This model ensures that there are no issues in synchronizing
14053 the elaboration process, since elaboration of passive packages elaborates the
14054 initial values, but does not create the files.
14056 The files are written using normal @code{Stream_IO} access.
14057 If you want to be able
14058 to communicate between programs or partitions running on different
14059 architectures, then you should use the XDR versions of the stream attribute
14060 routines, since these are architecture independent.
14062 If active synchronization is required for access to the variables in the
14063 shared passive package, then as described in the Ada Reference Manual, the
14064 package may contain protected objects used for this purpose. In this case
14065 a lock file (whose name is @file{___lock} (three underscores)
14066 is created in the shared memory directory.
14067 @cindex @file{___lock} file (for shared passive packages)
14068 This is used to provide the required locking
14069 semantics for proper protected object synchronization.
14071 As of January 2003, GNAT supports shared passive packages on all platforms
14072 except for OpenVMS.
14074 @node Code Generation for Array Aggregates
14075 @section Code Generation for Array Aggregates
14077 @menu
14078 * Static constant aggregates with static bounds::
14079 * Constant aggregates with unconstrained nominal types::
14080 * Aggregates with static bounds::
14081 * Aggregates with non-static bounds::
14082 * Aggregates in assignment statements::
14083 @end menu
14085 @noindent
14086 Aggregates have a rich syntax and allow the user to specify the values of
14087 complex data structures by means of a single construct.  As a result, the
14088 code generated for aggregates can be quite complex and involve loops, case
14089 statements and multiple assignments.  In the simplest cases, however, the
14090 compiler will recognize aggregates whose components and constraints are
14091 fully static, and in those cases the compiler will generate little or no
14092 executable code.  The following is an outline of the code that GNAT generates
14093 for various aggregate constructs.  For further details, you will find it
14094 useful to examine the output produced by the -gnatG flag to see the expanded
14095 source that is input to the code generator.  You may also want to examine
14096 the assembly code generated at various levels of optimization.
14098 The code generated for aggregates depends on the context, the component values,
14099 and the type.  In the context of an object declaration the code generated is
14100 generally simpler than in the case of an assignment.  As a general rule, static
14101 component values and static subtypes also lead to simpler code.
14103 @node Static constant aggregates with static bounds
14104 @subsection Static constant aggregates with static bounds
14106 @noindent
14107 For the declarations:
14108 @smallexample @c ada
14109     type One_Dim is array (1..10) of integer;
14110     ar0 : constant One_Dim := (1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
14111 @end smallexample
14113 @noindent
14114 GNAT generates no executable code: the constant ar0 is placed in static memory.
14115 The same is true for constant aggregates with named associations:
14117 @smallexample @c ada
14118     Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1 => 1, 5 .. 10 => 0);
14119     Cr3 : constant One_Dim := (others => 7777);
14120 @end smallexample
14122 @noindent
14123 The same is true for multidimensional constant arrays such as:
14125 @smallexample @c ada
14126     type two_dim is array (1..3, 1..3) of integer;
14127     Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
14128 @end smallexample
14130 @noindent
14131 The same is true for arrays of one-dimensional arrays: the following are
14132 static:
14134 @smallexample @c ada
14135 type ar1b  is array (1..3) of boolean;
14136 type ar_ar is array (1..3) of ar1b;
14137 None  : constant ar1b := (others => false);     --  fully static
14138 None2 : constant ar_ar := (1..3 => None);       --  fully static
14139 @end smallexample
14141 @noindent
14142 However, for multidimensional aggregates with named associations, GNAT will
14143 generate assignments and loops, even if all associations are static.  The
14144 following two declarations generate a loop for the first dimension, and
14145 individual component assignments for the second dimension:
14147 @smallexample @c ada
14148 Zero1: constant two_dim := (1..3 => (1..3 => 0));
14149 Zero2: constant two_dim := (others => (others => 0));
14150 @end smallexample
14152 @node Constant aggregates with unconstrained nominal types
14153 @subsection Constant aggregates with unconstrained nominal types
14155 @noindent
14156 In such cases the aggregate itself establishes the subtype, so that
14157 associations with @code{others} cannot be used.  GNAT determines the
14158 bounds for the actual subtype of the aggregate, and allocates the
14159 aggregate statically as well.  No code is generated for the following:
14161 @smallexample @c ada
14162     type One_Unc is array (natural range <>) of integer;
14163     Cr_Unc : constant One_Unc := (12,24,36);
14164 @end smallexample
14166 @node Aggregates with static bounds
14167 @subsection Aggregates with static bounds
14169 @noindent
14170 In all previous examples the aggregate was the initial (and immutable) value
14171 of a constant.  If the aggregate initializes a variable, then code is generated
14172 for it as a combination of individual assignments and loops over the target
14173 object.  The declarations
14175 @smallexample @c ada
14176        Cr_Var1 : One_Dim := (2, 5, 7, 11, 0, 0, 0, 0, 0, 0);
14177        Cr_Var2 : One_Dim := (others > -1);
14178 @end smallexample
14180 @noindent
14181 generate the equivalent of
14183 @smallexample @c ada
14184        Cr_Var1 (1) := 2;
14185        Cr_Var1 (2) := 3;
14186        Cr_Var1 (3) := 5;
14187        Cr_Var1 (4) := 11;
14189        for I in Cr_Var2'range loop
14190           Cr_Var2 (I) := =-1;
14191        end loop;
14192 @end smallexample
14194 @node Aggregates with non-static bounds
14195 @subsection Aggregates with non-static bounds
14197 @noindent
14198 If the bounds of the aggregate are not statically compatible with the bounds
14199 of the nominal subtype  of the target, then constraint checks have to be
14200 generated on the bounds.  For a multidimensional array, constraint checks may
14201 have to be applied to sub-arrays individually, if they do not have statically
14202 compatible subtypes.
14204 @node Aggregates in assignment statements
14205 @subsection Aggregates in assignment statements
14207 @noindent
14208 In general, aggregate assignment requires the construction of a temporary,
14209 and a copy from the temporary to the target of the assignment.  This is because
14210 it is not always possible to convert the assignment into a series of individual
14211 component assignments.  For example, consider the simple case:
14213 @smallexample @c ada
14214         A := (A(2), A(1));
14215 @end smallexample
14217 @noindent
14218 This cannot be converted into:
14220 @smallexample @c ada
14221         A(1) := A(2);
14222         A(2) := A(1);
14223 @end smallexample
14225 @noindent
14226 So the aggregate has to be built first in a separate location, and then
14227 copied into the target.  GNAT recognizes simple cases where this intermediate
14228 step is not required, and the assignments can be performed in place, directly
14229 into the target.  The following sufficient criteria are applied:
14231 @itemize @bullet
14232 @item
14233 The bounds of the aggregate are static, and the associations are static.
14234 @item
14235 The components of the aggregate are static constants, names of
14236 simple variables that are not renamings, or expressions not involving
14237 indexed components whose operands obey these rules.
14238 @end itemize
14240 @noindent
14241 If any of these conditions are violated, the aggregate will be built in
14242 a temporary (created either by the front-end or the code generator) and then
14243 that temporary will be copied onto the target.
14246 @node The Size of Discriminated Records with Default Discriminants
14247 @section The Size of Discriminated Records with Default Discriminants
14249 @noindent
14250 If a discriminated type @code{T} has discriminants with default values, it is
14251 possible to declare an object of this type without providing an explicit
14252 constraint:
14254 @smallexample @c ada
14255 @group
14256 type Size is range 1..100;
14258 type Rec (D : Size := 15) is record
14259    Name : String (1..D);
14260 end T;
14262 Word : Rec;
14263 @end group
14264 @end smallexample
14266 @noindent
14267 Such an object is said to be @emph{unconstrained}.
14268 The discriminant of the object
14269 can be modified by a full assignment to the object, as long as it preserves the
14270 relation between the value of the discriminant, and the value of the components
14271 that depend on it:
14273 @smallexample @c ada
14274 @group
14275 Word := (3, "yes");
14277 Word := (5, "maybe");
14279 Word := (5, "no"); -- raises Constraint_Error
14280 @end group
14281 @end smallexample
14283 @noindent
14284 In order to support this behavior efficiently, an unconstrained object is
14285 given the maximum size that any value of the type requires. In the case
14286 above, @code{Word} has storage for the discriminant and for
14287 a @code{String} of length 100.
14288 It is important to note that unconstrained objects do not require dynamic
14289 allocation. It would be an improper implementation to place on the heap those
14290 components whose size depends on discriminants. (This improper implementation
14291 was used by some Ada83 compilers, where the @code{Name} component above
14292 would have
14293 been stored as a pointer to a dynamic string). Following the principle that
14294 dynamic storage management should never be introduced implicitly,
14295 an Ada95 compiler should reserve the full size for an unconstrained declared
14296 object, and place it on the stack.
14298 This maximum size approach
14299 has been a source of surprise to some users, who expect the default
14300 values of the discriminants to determine the size reserved for an
14301 unconstrained object: ``If the default is 15, why should the object occupy
14302 a larger size?''
14303 The answer, of course, is that the discriminant may be later modified,
14304 and its full range of values must be taken into account. This is why the
14305 declaration:
14307 @smallexample
14308 @group
14309 type Rec (D : Positive := 15) is record
14310    Name : String (1..D);
14311 end record;
14313 Too_Large : Rec;
14314 @end group
14315 @end smallexample
14317 @noindent
14318 is flagged by the compiler with a warning:
14319 an attempt to create @code{Too_Large} will raise @code{Storage_Error},
14320 because the required size includes @code{Positive'Last}
14321 bytes. As the first example indicates, the proper approach is to declare an
14322 index type of ``reasonable'' range so that unconstrained objects are not too
14323 large.
14325 One final wrinkle: if the object is declared to be @code{aliased}, or if it is
14326 created in the heap by means of an allocator, then it is @emph{not}
14327 unconstrained:
14328 it is constrained by the default values of the discriminants, and those values
14329 cannot be modified by full assignment. This is because in the presence of
14330 aliasing all views of the object (which may be manipulated by different tasks,
14331 say) must be consistent, so it is imperative that the object, once created,
14332 remain invariant.
14334 @node Strict Conformance to the Ada 95 Reference Manual
14335 @section Strict Conformance to the Ada 95 Reference Manual
14337 @noindent
14338 The dynamic semantics defined by the Ada 95 Reference Manual impose a set of
14339 run-time checks to be generated. By default, the GNAT compiler will insert many
14340 run-time checks into the compiled code, including most of those required by the
14341 Ada 95 Reference Manual. However, there are three checks that are not enabled
14342 in the default mode for efficiency reasons: arithmetic overflow checking for
14343 integer operations (including division by zero), checks for access before
14344 elaboration on subprogram calls, and stack overflow checking (most operating
14345 systems do not perform this check by default).
14347 Strict conformance to the Ada 95 Reference Manual can be achieved by adding
14348 three compiler options for overflow checking for integer operations
14349 (@option{-gnato}), dynamic checks for access-before-elaboration on subprogram
14350 calls and generic instantiations (@option{-gnatE}), and stack overflow
14351 checking (@option{-fstack-check}).
14353 Note that the result of a floating point arithmetic operation in overflow and
14354 invalid situations, when the @code{Machine_Overflows} attribute of the result
14355 type is @code{False}, is to generate IEEE NaN and infinite values. This is the
14356 case for machines compliant with the IEEE floating-point standard, but on
14357 machines that are not fully compliant with this standard, such as Alpha, the
14358 @option{-mieee} compiler flag must be used for achieving IEEE confirming
14359 behavior (although at the cost of a significant performance penalty), so
14360 infinite and and NaN values are properly generated.
14363 @node Project File Reference
14364 @chapter Project File Reference
14366 @noindent
14367 This chapter describes the syntax and semantics of project files.
14368 Project files specify the options to be used when building a system.
14369 Project files can specify global settings for all tools,
14370 as well as tool-specific settings.
14371 See the chapter on project files in the GNAT Users guide for examples of use.
14373 @menu
14374 * Reserved Words::
14375 * Lexical Elements::
14376 * Declarations::
14377 * Empty declarations::
14378 * Typed string declarations::
14379 * Variables::
14380 * Expressions::
14381 * Attributes::
14382 * Project Attributes::
14383 * Attribute References::
14384 * External Values::
14385 * Case Construction::
14386 * Packages::
14387 * Package Renamings::
14388 * Projects::
14389 * Project Extensions::
14390 * Project File Elaboration::
14391 @end menu
14393 @node Reserved Words
14394 @section Reserved Words
14396 @noindent
14397 All Ada95 reserved words are reserved in project files, and cannot be used
14398 as variable names or project names. In addition, the following are
14399 also reserved in project files:
14401 @itemize
14402 @item @code{extends}
14404 @item @code{external}
14406 @item @code{project}
14408 @end itemize
14410 @node Lexical Elements
14411 @section Lexical Elements
14413 @noindent
14414 Rules for identifiers are the same as in Ada95. Identifiers
14415 are case-insensitive.  Strings are case sensitive, except where noted.
14416 Comments have the same form as in Ada95.
14418 @noindent
14419 Syntax:
14421 @smallexample
14422 simple_name ::=
14423   identifier
14425 name ::=
14426   simple_name @{. simple_name@}
14427 @end smallexample
14429 @node Declarations
14430 @section Declarations
14432 @noindent
14433 Declarations introduce new entities that denote types, variables, attributes,
14434 and packages. Some declarations can only appear immediately within a project
14435 declaration. Others can appear within a project or within a package.
14437 Syntax:
14438 @smallexample
14439 declarative_item ::=
14440   simple_declarative_item |
14441   typed_string_declaration |
14442   package_declaration
14444 simple_declarative_item ::=
14445   variable_declaration |
14446   typed_variable_declaration |
14447   attribute_declaration |
14448   case_construction |
14449   empty_declaration
14450 @end smallexample
14452 @node Empty declarations
14453 @section Empty declarations
14455 @smallexample
14456 empty_declaration ::=
14457   @b{null} ;
14458 @end smallexample
14460 An empty declaration is allowed anywhere a declaration is allowed.
14461 It has no effect.
14463 @node Typed string declarations
14464 @section Typed string declarations
14466 @noindent
14467 Typed strings are sequences of string literals. Typed strings are the only
14468 named types in project files. They are used in case constructions, where they
14469 provide support for conditional attribute definitions.
14471 Syntax:
14472 @smallexample
14473 typed_string_declaration ::=
14474   @b{type} <typed_string_>_simple_name @b{is}
14475    ( string_literal @{, string_literal@} );
14476 @end smallexample
14478 @noindent
14479 A typed string declaration can only appear immediately within a project
14480 declaration.
14482 All the string literals in a typed string declaration must be distinct.
14484 @node Variables
14485 @section Variables
14487 @noindent
14488 Variables denote values, and appear as constituents of expressions.
14490 @smallexample
14491 typed_variable_declaration ::=
14492   <typed_variable_>simple_name : <typed_string_>name :=  string_expression ;
14494 variable_declaration ::=
14495   <variable_>simple_name := expression;
14496 @end smallexample
14498 @noindent
14499 The elaboration of a variable declaration introduces the variable and
14500 assigns to it the value of the expression. The name of the variable is
14501 available after the assignment symbol.
14503 @noindent
14504 A typed_variable can only be declare once.
14506 @noindent
14507 a non typed variable can be declared multiple times.
14509 @noindent
14510 Before the completion of its first declaration, the value of variable
14511 is the null string.
14513 @node Expressions
14514 @section Expressions
14516 @noindent
14517 An expression is a formula that defines a computation or retrieval of a value.
14518 In a project file the value of an expression is either a string or a list
14519 of strings. A string value in an expression is either a literal, the current
14520 value of a variable, an external value, an attribute reference, or a
14521 concatenation operation.
14523 Syntax:
14525 @smallexample
14526 expression ::=
14527   term @{& term@}
14529 term ::=
14530   string_literal |
14531   string_list |
14532   <variable_>name |
14533   external_value |
14534   attribute_reference
14536 string_literal ::=
14537   (same as Ada)
14539 string_list ::=
14540   ( <string_>expression @{ , <string_>expression @} )
14541 @end smallexample
14543 @subsection Concatenation
14544 @noindent
14545 The following concatenation functions are defined:
14547 @smallexample @c ada
14548   function "&" (X : String;      Y : String)      return String;
14549   function "&" (X : String_List; Y : String)      return String_List;
14550   function "&" (X : String_List; Y : String_List) return String_List;
14551 @end smallexample
14553 @node Attributes
14554 @section Attributes
14556 @noindent
14557 An attribute declaration defines a property of a project or package. This
14558 property can later be queried by means of an attribute reference.
14559 Attribute values are strings or string lists.
14561 Some attributes are associative arrays. These attributes are mappings whose
14562 domain is a set of strings. These attributes are declared one association
14563 at a time, by specifying a point in the domain and the corresponding image
14564 of the attribute. They may also be declared as a full associative array,
14565 getting the same associations as the corresponding attribute in an imported
14566 or extended project.
14568 Attributes that are not associative arrays are called simple attributes.
14570 Syntax:
14571 @smallexample
14572 attribute_declaration ::=
14573   full_associative_array_declaration |
14574   @b{for} attribute_designator @b{use} expression ;
14576 full_associative_array_declaration ::=
14577   @b{for} <associative_array_attribute_>simple_name @b{use}
14578   <project_>simple_name [ . <package_>simple_Name ] ' <attribute_>simple_name ;
14580 attribute_designator ::=
14581   <simple_attribute_>simple_name |
14582   <associative_array_attribute_>simple_name ( string_literal )
14583 @end smallexample
14585 @noindent
14586 Some attributes are project-specific, and can only appear immediately within
14587 a project declaration. Others are package-specific, and can only appear within
14588 the proper package.
14590 The expression in an attribute definition must be a string or a string_list.
14591 The string literal appearing in the attribute_designator of an associative
14592 array attribute is case-insensitive.
14594 @node Project Attributes
14595 @section Project Attributes
14597 @noindent
14598 The following attributes apply to a project. All of them are simple
14599 attributes.
14601 @table @code
14602 @item   Object_Dir
14603 Expression must be a path name. The attribute defines the
14604 directory in which the object files created by the build are to be placed. If
14605 not specified, object files are placed in the project directory.
14607 @item   Exec_Dir
14608 Expression must be a path name. The attribute defines the
14609 directory in which the executables created by the build are to be placed.
14610 If not specified, executables are placed in the object directory.
14612 @item  Source_Dirs
14613 Expression must be a list of path names. The attribute
14614 defines the directories in which the source files for the project are to be
14615 found. If not specified, source files are found in the project directory.
14617 @item  Source_Files
14618 Expression must be a list of file names. The attribute
14619 defines the individual files, in the project directory, which are to be used
14620 as sources for the project. File names are path_names that contain no directory
14621 information. If the project has no sources the attribute must be declared
14622 explicitly with an empty list.
14624 @item  Source_List_File
14625 Expression must a single path name. The attribute
14626 defines a text file that contains a list of source file names to be used
14627 as sources for the project
14629 @item  Library_Dir
14630 Expression must be a path name. The attribute defines the
14631 directory in which a  library is to be built.  The directory must exist, must
14632 be distinct from the project's object directory, and must be writable.
14634 @item  Library_Name
14635 Expression must be a string that is a legal file name,
14636 without extension. The attribute defines a string that is used to generate
14637 the name of the library to be built by the project.
14639 @item  Library_Kind
14640 Argument must be a string value that must be one of the
14641 following @code{"static"}, @code{"dynamic"} or @code{"relocatable"}. This
14642 string is case-insensitive. If this attribute is not specified, the library is
14643 a static library. Otherwise, the library may be dynamic or relocatable. This
14644 distinction is operating-system dependent.
14646 @item  Library_Version
14647 Expression must be a string value whose interpretation
14648 is platform dependent. On UNIX, it is used only for dynamic/relocatable
14649 libraries as the internal name of the library (the @code{"soname"}). If the
14650 library file name (built from the @code{Library_Name}) is different from the
14651 @code{Library_Version}, then the library file will be a symbolic link to the
14652 actual file whose name will be @code{Library_Version}.
14654 @item Library_Interface
14655 Expression must be a string list. Each element of the string list
14656 must designate a unit of the project.
14657 If this attribute is present in a Library Project File, then the project
14658 file is a Stand-alone Library_Project_File.
14660 @item Library_Auto_Init
14661 Expression must be a single string "true" or "false", case-insensitive.
14662 If this attribute is present in a Stand-alone Library Project File,
14663 it indicates if initialization is automatic when the dynamic library
14664 is loaded.
14666 @item Library_Options
14667 Expression must be a string list. Indicates additional switches that
14668 are to be used when building a shared library.
14670 @item Library_GCC
14671 Expression must be a single string. Designates an alternative to "gcc"
14672 for building shared libraries.
14674 @item  Library_Src_Dir
14675 Expression must be a path name. The attribute defines the
14676 directory in which the sources of the interfaces of a Stand-alone Library will
14677 be copied.  The directory must exist, must be distinct from the project's
14678 object directory and source directories of all projects in the project tree,
14679 and must be writable.
14681 @item  Library_Src_Dir
14682 Expression must be a path name. The attribute defines the
14683 directory in which the ALI files of a Library will
14684 be copied.  The directory must exist, must be distinct from the project's
14685 object directory and source directories of all projects in the project tree,
14686 and must be writable.
14688 @item  Library_Symbol_File
14689 Expression must be a single string. Its value is the single file name of a
14690 symbol file to be created when building a stand-alone library when the
14691 symbol policy is either "compliant", "controlled" or "restricted",
14692 on platforms that support symbol control, such as VMS.
14694 @item   Library_Reference_Symbol_File
14695 Expression must be a single string. Its value is the single file name of a
14696 reference symbol file that is read when the symbol policy is either
14697 "compliant" or "controlled", on platforms that support symbol control,
14698 such as VMS, when building a stand-alone library.
14700 @item  Library_Symbol_Policy
14701 Expression must be a single string. Its case-insensitive value can only be
14702 "autonomous", "default", "compliant", "controlled" or "restricted".
14704 This attribute is not taken into account on all platforms. It controls the
14705 policy for exported symbols and, on some platforms (like VMS) that have the
14706 notions of major and minor IDs built in the library files, it controls
14707 the setting of these IDs.
14709 "autonomous" or "default": exported symbols are not controlled.
14711 "compliant": if attribute Library_Reference_Symbol_File is not defined, then
14712 it is equivalent to policy "autonomous". If there are exported symbols in
14713 the reference symbol file that are not in the object files of the interfaces,
14714 the major ID of the library is increased. If there are symbols in the
14715 object files of the interfaces that are not in the reference symbol file,
14716 these symbols are put at the end of the list in the newly created symbol file
14717 and the minor ID is increased.
14719 "controlled": the attribute Library_Reference_Symbol_File must be defined.
14720 The library will fail to build if the exported symbols in the object files of
14721 the interfaces do not match exactly the symbol in the symbol file.
14723 "restricted": The attribute Library_Symbol_File must be defined. The library
14724 will fail to build if there are symbols in the symbol file that are not in
14725 the exported symbols of the object files of the interfaces. Additional symbols
14726 in the object files are not added to the symbol file.
14728 @item  Main
14729 Expression must be a list of strings that are legal file names.
14730 These file names designate existing compilation units in the source directory
14731 that are legal main subprograms.
14733 When a project file is elaborated, as part of the execution of a gnatmake
14734 command, one or several executables are built and placed in the Exec_Dir.
14735 If the gnatmake command does not include explicit file names, the executables
14736 that are built correspond to the files specified by this attribute.
14738 @item  Externally_Built
14739 Expression must be a single string. Its value must be either "true" of "false",
14740 case-insensitive. The default is "false". When the value of this attribute is
14741 "true", no attempt is made to compile the sources or to build the library,
14742 when the project is a library project.
14744 @item Main_Language
14745 This is a simple attribute. Its value is a string that specifies the
14746 language of the main program.
14748 @item  Languages
14749 Expression must be a string list. Each string designates
14750 a programming language that is known to GNAT. The strings are case-insensitive.
14752 @item  Locally_Removed_Files
14753 This attribute is legal only in a project file that extends another.
14754 Expression must be a list of strings that are legal file names.
14755 Each file name must designate a source that would normally be inherited
14756 by the current project file. It cannot designate an immediate source that is
14757 not inherited. Each of the source files in the list are not considered to
14758 be sources of the project file: they are not inherited.
14759 @end table
14761 @node Attribute References
14762 @section Attribute References
14764 @noindent
14765 Attribute references are used to retrieve the value of previously defined
14766 attribute for a package or project.
14767 Syntax:
14768 @smallexample
14769 attribute_reference ::=
14770   attribute_prefix ' <simple_attribute_>simple_name [ ( string_literal ) ]
14772 attribute_prefix ::=
14773   @b{project} |
14774   <project_simple_name | package_identifier |
14775   <project_>simple_name . package_identifier
14776 @end smallexample
14778 @noindent
14779 If an attribute has not been specified for a given package or project, its
14780 value is the null string or the empty list.
14782 @node External Values
14783 @section External Values
14785 @noindent
14786 An external value is an expression whose value is obtained from the command
14787 that invoked the processing of the current project file (typically a
14788 gnatmake command).
14790 Syntax:
14791 @smallexample
14792 external_value ::=
14793   @b{external} ( string_literal [, string_literal] )
14794 @end smallexample
14796 @noindent
14797 The first string_literal is the string to be used on the command line or
14798 in the environment to specify the external value. The second string_literal,
14799 if present, is the default to use if there is no specification for this
14800 external value either on the command line or in the environment.
14802 @node Case Construction
14803 @section Case Construction
14805 @noindent
14806 A case construction supports attribute declarations that depend on the value of
14807 a previously declared variable.
14809 Syntax:
14810 @smallexample
14811 case_construction ::=
14812   @b{case} <typed_variable_>name @b{is}
14813     @{case_item@}
14814   @b{end case} ;
14816 case_item ::=
14817   @b{when} discrete_choice_list =>
14818     @{case_construction | attribute_declaration | empty_declaration@}
14820 discrete_choice_list ::=
14821   string_literal @{| string_literal@} |
14822     @b{others}
14823 @end smallexample
14825 @noindent
14826 All choices in a choice list must be distinct. The choice lists of two
14827 distinct alternatives must be disjoint. Unlike Ada, the choice lists of all
14828 alternatives do not need to include all values of the type. An @code{others}
14829 choice must appear last in the list of alternatives.
14831 @node Packages
14832 @section Packages
14834 @noindent
14835 A package provides a grouping of variable declarations and attribute
14836 declarations to be used when invoking various GNAT tools. The name of
14837 the package indicates the tool(s) to which it applies.
14838 Syntax:
14840 @smallexample
14841 package_declaration ::=
14842   package_specification | package_renaming
14844 package_specification ::=
14845   @b{package} package_identifier @b{is}
14846     @{simple_declarative_item@}
14847   @b{end} package_identifier ;
14849 package_identifier ::=
14850   @code{Naming} | @code{Builder} | @code{Compiler} | @code{Binder} |
14851   @code{Linker} | @code{Finder}  | @code{Cross_Reference} |
14852   @code{gnatls} | @code{IDE}     | @code{Pretty_Printer}
14853 @end smallexample
14855 @subsection Package Naming
14857 @noindent
14858 The attributes of a @code{Naming} package specifies the naming conventions
14859 that apply to the source files in a project. When invoking other GNAT tools,
14860 they will use the sources in the source directories that satisfy these
14861 naming conventions.
14863 The following attributes apply to a @code{Naming} package:
14865 @table @code
14866 @item Casing
14867 This is a simple attribute whose value is a string. Legal values of this
14868 string are @code{"lowercase"}, @code{"uppercase"} or @code{"mixedcase"}.
14869 These strings are themselves case insensitive.
14871 @noindent
14872 If @code{Casing} is not specified, then the default is @code{"lowercase"}.
14874 @item Dot_Replacement
14875 This is a simple attribute whose string value satisfies the following
14876 requirements:
14878 @itemize @bullet
14879 @item It must not be empty
14880 @item It cannot start or end with an alphanumeric character
14881 @item It cannot be a single underscore
14882 @item It cannot start with an underscore followed by an alphanumeric
14883 @item It cannot contain a dot @code{'.'} if longer than one character
14884 @end itemize
14886 @noindent
14887 If @code{Dot_Replacement} is not specified, then the default is @code{"-"}.
14889 @item Spec_Suffix
14890 This is an associative array attribute, defined on language names,
14891 whose image is a string that must satisfy the following
14892 conditions:
14894 @itemize @bullet
14895 @item It must not be empty
14896 @item It cannot start with an alphanumeric character
14897 @item It cannot start with an underscore followed by an alphanumeric character
14898 @end itemize
14900 @noindent
14901 For Ada, the attribute denotes the suffix used in file names that contain
14902 library unit declarations, that is to say units that are package and
14903 subprogram declarations. If @code{Spec_Suffix ("Ada")} is not
14904 specified, then the default is @code{".ads"}.
14906 For C and C++, the attribute denotes the suffix used in file names that
14907 contain prototypes.
14909 @item Body_Suffix
14910 This is an associative array attribute defined on language names,
14911 whose image is a string that must satisfy the following
14912 conditions:
14914 @itemize @bullet
14915 @item It must not be empty
14916 @item It cannot start with an alphanumeric character
14917 @item It cannot start with an underscore followed by an alphanumeric character
14918 @item It cannot be a suffix of @code{Spec_Suffix}
14919 @end itemize
14921 @noindent
14922 For Ada, the attribute denotes the suffix used in file names that contain
14923 library bodies, that is to say units that are package and subprogram bodies.
14924 If @code{Body_Suffix ("Ada")} is not specified, then the default is
14925 @code{".adb"}.
14927 For C and C++, the attribute denotes the suffix used in file names that contain
14928 source code.
14930 @item Separate_Suffix
14931 This is a simple attribute whose value satisfies the same conditions as
14932 @code{Body_Suffix}.
14934 This attribute is specific to Ada. It denotes the suffix used in file names
14935 that contain separate bodies. If it is not specified, then it defaults to same
14936 value as @code{Body_Suffix ("Ada")}.
14938 @item Spec
14939 This is an associative array attribute, specific to Ada, defined over
14940 compilation unit names. The image is a string that is the name of the file
14941 that contains that library unit. The file name is case sensitive if the
14942 conventions of the host operating system require it.
14944 @item Body
14945 This is an associative array attribute, specific to Ada, defined over
14946 compilation unit names. The image is a string that is the name of the file
14947 that contains the library unit body for the named unit. The file name is case
14948 sensitive if the conventions of the host operating system require it.
14950 @item Specification_Exceptions
14951 This is an associative array attribute defined on language names,
14952 whose value is a list of strings.
14954 This attribute is not significant for Ada.
14956 For C and C++, each string in the list denotes the name of a file that
14957 contains prototypes, but whose suffix is not necessarily the
14958 @code{Spec_Suffix} for the language.
14960 @item Implementation_Exceptions
14961 This is an associative array attribute defined on language names,
14962 whose value is a list of strings.
14964 This attribute is not significant for Ada.
14966 For C and C++, each string in the list denotes the name of a file that
14967 contains source code, but whose suffix is not necessarily the
14968 @code{Body_Suffix} for the language.
14969 @end table
14971 The following attributes of package @code{Naming} are obsolescent. They are
14972 kept as synonyms of other attributes for compatibility with previous versions
14973 of the Project Manager.
14975 @table @code
14976 @item Specification_Suffix
14977 This is a synonym of @code{Spec_Suffix}.
14979 @item Implementation_Suffix
14980 This is a synonym of @code{Body_Suffix}.
14982 @item Specification
14983 This is a synonym of @code{Spec}.
14985 @item Implementation
14986 This is a synonym of @code{Body}.
14987 @end table
14989 @subsection package Compiler
14991 @noindent
14992 The attributes of the @code{Compiler} package specify the compilation options
14993 to be used by the underlying compiler.
14995 @table @code
14996 @item  Default_Switches
14997 This is an associative array attribute. Its
14998 domain is a set of language names. Its range is a string list that
14999 specifies the compilation options to be used when compiling a component
15000 written in that language, for which no file-specific switches have been
15001 specified.
15003 @item  Switches
15004 This is an associative array attribute. Its domain is
15005 a set of file names. Its range is a string list that specifies the
15006 compilation options to be used when compiling the named file. If a file
15007 is not specified in the Switches attribute, it is compiled with the
15008 options specified by Default_Switches of its language, if defined.
15010 @item  Local_Configuration_Pragmas.
15011 This is a simple attribute, whose
15012 value is a path name that designates a file containing configuration pragmas
15013 to be used for all invocations of the compiler for immediate sources of the
15014 project.
15015 @end table
15017 @subsection package Builder
15019 @noindent
15020 The attributes of package @code{Builder} specify the compilation, binding, and
15021 linking options to be used when building an executable for a project. The
15022 following attributes apply to package @code{Builder}:
15024 @table @code
15025 @item Default_Switches
15026 This is an associative array attribute. Its
15027 domain is a set of language names. Its range is a string list that
15028 specifies options to be used when building a main
15029 written in that language, for which no file-specific switches have been
15030 specified.
15032 @item Switches
15033 This is an associative array attribute. Its domain is
15034 a set of file names. Its range is a string list that specifies
15035 options to be used when building the named main file. If a main file
15036 is not specified in the Switches attribute, it is built with the
15037 options specified by Default_Switches of its language, if defined.
15039 @item Global_Configuration_Pragmas
15040 This is a simple attribute, whose
15041 value is a path name that designates a file that contains configuration pragmas
15042 to be used in every build of an executable. If both local and global
15043 configuration pragmas are specified, a compilation makes use of both sets.
15046 @item Executable
15047 This is an associative array attribute. Its domain is
15048 a set of main source file names. Its range is a simple string that specifies
15049 the executable file name to be used when linking the specified main source.
15050 If a main source is not specified in the Executable attribute, the executable
15051 file name is deducted from the main source file name.
15052 This attribute has no effect if its value is the empty string.
15054 @item Executable_Suffix
15055 This is a simple attribute whose value is the suffix to be added to
15056 the executables that don't have an attribute Executable specified.
15057 @end table
15059 @subsection package Gnatls
15061 @noindent
15062 The attributes of package @code{Gnatls} specify the tool options to be used
15063 when invoking the library browser @command{gnatls}.
15064 The following attributes apply to package @code{Gnatls}:
15066 @table @code
15067 @item Switches
15068 This is a single attribute with a string list value. Each non empty string
15069 in the list is an option when invoking @code{gnatls}.
15070 @end table
15072 @subsection package Binder
15074 @noindent
15075 The attributes of package @code{Binder} specify the options to be used
15076 when invoking the binder in the construction of an executable.
15077 The following attributes apply to package @code{Binder}:
15079 @table @code
15080 @item     Default_Switches
15081 This is an associative array attribute. Its
15082 domain is a set of language names. Its range is a string list that
15083 specifies options to be used when binding a main
15084 written in that language, for which no file-specific switches have been
15085 specified.
15087 @item Switches
15088 This is an associative array attribute. Its domain is
15089 a set of file names. Its range is a string list that specifies
15090 options to be used when binding the named main file. If a main file
15091 is not specified in the Switches attribute, it is bound with the
15092 options specified by Default_Switches of its language, if defined.
15093 @end table
15095 @subsection package Linker
15097 @noindent
15098 The attributes of package @code{Linker} specify the options to be used when
15099 invoking the linker in the construction of an executable.
15100 The following attributes apply to package @code{Linker}:
15102 @table @code
15103 @item     Default_Switches
15104 This is an associative array attribute. Its
15105 domain is a set of language names. Its range is a string list that
15106 specifies options to be used when linking a main
15107 written in that language, for which no file-specific switches have been
15108 specified.
15110 @item Switches
15111 This is an associative array attribute. Its domain is
15112 a set of file names. Its range is a string list that specifies
15113 options to be used when linking the named main file. If a main file
15114 is not specified in the Switches attribute, it is linked with the
15115 options specified by Default_Switches of its language, if defined.
15117 @item  Linker_Options
15118 This is a string list attribute. Its value specifies additional options that
15119 be given to the linker when linking an executable. This attribute is not
15120 used in the main project, only in projects imported directly or indirectly.
15122 @end table
15124 @subsection package Cross_Reference
15126 @noindent
15127 The attributes of package @code{Cross_Reference} specify the tool options
15128 to be used
15129 when invoking the library tool @command{gnatxref}.
15130 The following attributes apply to package @code{Cross_Reference}:
15132 @table @code
15133 @item     Default_Switches
15134 This is an associative array attribute. Its
15135 domain is a set of language names. Its range is a string list that
15136 specifies options to be used when calling @command{gnatxref} on a source
15137 written in that language, for which no file-specific switches have been
15138 specified.
15140 @item Switches
15141 This is an associative array attribute. Its domain is
15142 a set of file names. Its range is a string list that specifies
15143 options to be used when calling @command{gnatxref} on the named main source.
15144 If a source is not specified in the Switches attribute, @command{gnatxref} will
15145 be called with the options specified by Default_Switches of its language,
15146 if defined.
15147 @end table
15149 @subsection package   Finder
15151 @noindent
15152 The attributes of package @code{Finder} specify the tool options to be used
15153 when invoking the search tool @command{gnatfind}.
15154 The following attributes apply to package @code{Finder}:
15156 @table @code
15157 @item     Default_Switches
15158 This is an associative array attribute. Its
15159 domain is a set of language names. Its range is a string list that
15160 specifies options to be used when calling @command{gnatfind} on a source
15161 written in that language, for which no file-specific switches have been
15162 specified.
15164 @item Switches
15165 This is an associative array attribute. Its domain is
15166 a set of file names. Its range is a string list that specifies
15167 options to be used when calling @command{gnatfind} on the named main source.
15168 If a source is not specified in the Switches attribute, @command{gnatfind} will
15169 be called with the options specified by Default_Switches of its language,
15170 if defined.
15171 @end table
15173 @subsection package Pretty_Printer
15175 @noindent
15176 The attributes of package @code{Pretty_Printer}
15177 specify the tool options to be used
15178 when invoking the formatting tool @command{gnatpp}.
15179 The following attributes apply to package @code{Pretty_Printer}:
15181 @table @code
15182 @item     Default_switches
15183 This is an associative array attribute. Its
15184 domain is a set of language names. Its range is a string list that
15185 specifies options to be used when calling @command{gnatpp} on a source
15186 written in that language, for which no file-specific switches have been
15187 specified.
15189 @item Switches
15190 This is an associative array attribute. Its domain is
15191 a set of file names. Its range is a string list that specifies
15192 options to be used when calling @command{gnatpp} on the named main source.
15193 If a source is not specified in the Switches attribute, @command{gnatpp} will
15194 be called with the options specified by Default_Switches of its language,
15195 if defined.
15196 @end table
15198 @subsection package gnatstub
15200 @noindent
15201 The attributes of package @code{gnatstub}
15202 specify the tool options to be used
15203 when invoking the tool @command{gnatstub}.
15204 The following attributes apply to package @code{gnatstub}:
15206 @table @code
15207 @item     Default_switches
15208 This is an associative array attribute. Its
15209 domain is a set of language names. Its range is a string list that
15210 specifies options to be used when calling @command{gnatstub} on a source
15211 written in that language, for which no file-specific switches have been
15212 specified.
15214 @item Switches
15215 This is an associative array attribute. Its domain is
15216 a set of file names. Its range is a string list that specifies
15217 options to be used when calling @command{gnatstub} on the named main source.
15218 If a source is not specified in the Switches attribute, @command{gnatpp} will
15219 be called with the options specified by Default_Switches of its language,
15220 if defined.
15221 @end table
15223 @subsection package Eliminate
15225 @noindent
15226 The attributes of package @code{Eliminate}
15227 specify the tool options to be used
15228 when invoking the tool @command{gnatelim}.
15229 The following attributes apply to package @code{Eliminate}:
15231 @table @code
15232 @item     Default_switches
15233 This is an associative array attribute. Its
15234 domain is a set of language names. Its range is a string list that
15235 specifies options to be used when calling @command{gnatelim} on a source
15236 written in that language, for which no file-specific switches have been
15237 specified.
15239 @item Switches
15240 This is an associative array attribute. Its domain is
15241 a set of file names. Its range is a string list that specifies
15242 options to be used when calling @command{gnatelim} on the named main source.
15243 If a source is not specified in the Switches attribute, @command{gnatelim} will
15244 be called with the options specified by Default_Switches of its language,
15245 if defined.
15246 @end table
15248 @subsection package Metrics
15250 @noindent
15251 The attributes of package @code{Metrics}
15252 specify the tool options to be used
15253 when invoking the tool @command{gnatmetric}.
15254 The following attributes apply to package @code{Metrics}:
15256 @table @code
15257 @item     Default_switches
15258 This is an associative array attribute. Its
15259 domain is a set of language names. Its range is a string list that
15260 specifies options to be used when calling @command{gnatmetric} on a source
15261 written in that language, for which no file-specific switches have been
15262 specified.
15264 @item Switches
15265 This is an associative array attribute. Its domain is
15266 a set of file names. Its range is a string list that specifies
15267 options to be used when calling @command{gnatmetric} on the named main source.
15268 If a source is not specified in the Switches attribute, @command{gnatmetric}
15269 will be called with the options specified by Default_Switches of its language,
15270 if defined.
15271 @end table
15273 @subsection  package IDE
15275 @noindent
15276 The attributes of package @code{IDE} specify the options to be used when using
15277 an Integrated Development Environment such as @command{GPS}.
15279 @table @code
15280 @item Remote_Host
15281 This is a simple attribute. Its value is a string that designates the remote
15282 host in a cross-compilation environment, to be used for remote compilation and
15283 debugging. This field should not be specified when running on the local
15284 machine.
15286 @item Program_Host
15287 This is a simple attribute. Its value is a string that specifies the
15288 name of IP address of the embedded target in a cross-compilation environment,
15289 on which the program should execute.
15291 @item Communication_Protocol
15292 This is a simple string attribute. Its value is the name of the protocol
15293 to use to communicate with the target in a cross-compilation environment,
15294 e.g. @code{"wtx"} or @code{"vxworks"}.
15296 @item Compiler_Command
15297 This is an associative array attribute, whose domain is a language name. Its
15298 value is  string that denotes the command to be used to invoke the compiler.
15299 The value of @code{Compiler_Command ("Ada")} is expected to be compatible with
15300 gnatmake, in particular in the handling of switches.
15302 @item Debugger_Command
15303 This is simple attribute, Its value is a string that specifies the name of
15304 the debugger to be used, such as gdb, powerpc-wrs-vxworks-gdb or gdb-4.
15306 @item Default_Switches
15307 This is an associative array attribute. Its indexes are the name of the
15308 external tools that the GNAT Programming System (GPS) is supporting. Its
15309 value is a list of switches to use when invoking that tool.
15311 @item  Gnatlist
15312 This is a simple attribute.  Its value is a string that specifies the name
15313 of the @command{gnatls} utility to be used to retrieve information about the
15314 predefined path; e.g., @code{"gnatls"}, @code{"powerpc-wrs-vxworks-gnatls"}.
15316 @item VCS_Kind
15317 This is a simple attribute. Its value is a string used to specify the
15318 Version Control System (VCS) to be used for this project, e.g CVS, RCS
15319 ClearCase or Perforce.
15321 @item VCS_File_Check
15322 This is a simple attribute. Its value is a string that specifies the
15323 command used by the VCS to check the validity of a file, either
15324 when the user explicitly asks for a check, or as a sanity check before
15325 doing the check-in.
15327 @item VCS_Log_Check
15328 This is a simple attribute. Its value is a string that specifies
15329 the command used by the VCS to check the validity of a log file.
15331 @end table
15333 @node Package Renamings
15334 @section Package Renamings
15336 @noindent
15337 A package can be defined by a renaming declaration. The new package renames
15338 a package declared in a different project file, and has the same attributes
15339 as the package it renames.
15340 Syntax:
15341 @smallexample
15342 package_renaming ::==
15343   @b{package} package_identifier @b{renames}
15344        <project_>simple_name.package_identifier ;
15345 @end smallexample
15347 @noindent
15348 The package_identifier of the renamed package must be the same as the
15349 package_identifier. The project whose name is the prefix of the renamed
15350 package must contain a package declaration with this name. This project
15351 must appear in the context_clause of the enclosing project declaration,
15352 or be the parent project of the enclosing child project.
15354 @node Projects
15355 @section Projects
15357 @noindent
15358 A project file specifies a set of rules for constructing a software system.
15359 A project file can be self-contained, or depend on other project files.
15360 Dependencies are expressed through a context clause that names other projects.
15362 Syntax:
15364 @smallexample
15365 project ::=
15366   context_clause project_declaration
15368 project_declaration ::=
15369   simple_project_declaration | project_extension
15371 simple_project_declaration ::=
15372   @b{project} <project_>simple_name @b{is}
15373     @{declarative_item@}
15374   @b{end} <project_>simple_name;
15376 context_clause ::=
15377   @{with_clause@}
15379 with_clause ::=
15380   [@b{limited}] @b{with} path_name @{ , path_name @} ;
15382 path_name ::=
15383    string_literal
15384 @end smallexample
15386 @noindent
15387 A path name denotes a project file. A path name can be absolute or relative.
15388 An absolute path name includes a sequence of directories, in the syntax of
15389 the host operating system, that identifies uniquely the project file in the
15390 file system. A relative path name identifies the project file, relative
15391 to the directory that contains the current project, or relative to a
15392 directory listed in the environment variable ADA_PROJECT_PATH.
15393 Path names are case sensitive if file names in the host operating system
15394 are case sensitive.
15396 The syntax of the environment variable ADA_PROJECT_PATH is a list of
15397 directory names separated by colons (semicolons on Windows).
15399 A given project name can appear only once in a context_clause.
15401 It is illegal for a project imported by a context clause to refer, directly
15402 or indirectly, to the project in which this context clause appears (the
15403 dependency graph cannot contain cycles), except when one of the with_clause
15404 in the cycle is a @code{limited with}.
15406 @node Project Extensions
15407 @section Project Extensions
15409 @noindent
15410 A project extension introduces a new project, which inherits the declarations
15411 of another project.
15412 Syntax:
15413 @smallexample
15415 project_extension ::=
15416   @b{project} <project_>simple_name  @b{extends} path_name @b{is}
15417     @{declarative_item@}
15418   @b{end} <project_>simple_name;
15419 @end smallexample
15421 @noindent
15422 The project extension declares a child project. The child project inherits
15423 all the declarations and all the files of the parent project, These inherited
15424 declaration can be overridden in the child project, by means of suitable
15425 declarations.
15427 @node Project File Elaboration
15428 @section Project File Elaboration
15430 @noindent
15431 A project file is processed as part of the invocation of a gnat tool that
15432 uses the project option. Elaboration of the process file consists in the
15433 sequential elaboration of all its declarations. The computed values of
15434 attributes and variables in the project are then used to establish the
15435 environment in which the gnat tool will execute.
15437 @node Obsolescent Features
15438 @chapter Obsolescent Features
15440 @noindent
15441 This chapter describes features that are provided by GNAT, but are
15442 considered obsolescent since there are preferred ways of achieving
15443 the same effect. These features are provided solely for historical
15444 compatibility purposes.
15446 @menu
15447 * pragma No_Run_Time::
15448 * pragma Ravenscar::
15449 * pragma Restricted_Run_Time::
15450 @end menu
15452 @node pragma No_Run_Time
15453 @section pragma No_Run_Time
15455 The pragma @code{No_Run_Time} is used to achieve an affect similar
15456 to the use of the "Zero Foot Print" configurable run time, but without
15457 requiring a specially configured run time. The result of using this
15458 pragma, which must be used for all units in a partition, is to restrict
15459 the use of any language features requiring run-time support code. The
15460 preferred usage is to use an appropriately configured run-time that
15461 includes just those features that are to be made accessible.
15463 @node pragma Ravenscar
15464 @section pragma Ravenscar
15466 The pragma @code{Ravenscar} has exactly the same effect as pragma
15467 @code{Profile (Ravenscar)}. The latter usage is preferred since it
15468 is part of the new Ada 2005 standard.
15470 @node pragma Restricted_Run_Time
15471 @section pragma Restricted_Run_Time
15473 The pragma @code{Restricted_Run_Time} has exactly the same effect as
15474 pragma @code{Profile (Restricted)}. The latter usage is
15475 preferred since the Ada 2005 pragma @code{Profile} is intended for
15476 this kind of implementation dependent addition.
15478 @include fdl.texi
15479 @c GNU Free Documentation License
15481 @node Index,,GNU Free Documentation License, Top
15482 @unnumbered Index
15484 @printindex cp
15486 @contents
15488 @bye