Merge from mainline (gomp-merge-2005-02-26).
[official-gcc.git] / gcc / ada / gnat_rm.texi
blobba11f6a71f99687b83ff21907178e6c81c8641d6
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-2004 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 Ada Core Technologies, Inc.
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 Ada Core Technologies, Inc.
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 Annotate::
106 * Pragma Assert::
107 * Pragma Ast_Entry::
108 * Pragma C_Pass_By_Copy::
109 * Pragma Comment::
110 * Pragma Common_Object::
111 * Pragma Compile_Time_Warning::
112 * Pragma Complex_Representation::
113 * Pragma Component_Alignment::
114 * Pragma Convention_Identifier::
115 * Pragma CPP_Class::
116 * Pragma CPP_Constructor::
117 * Pragma CPP_Virtual::
118 * Pragma CPP_Vtable::
119 * Pragma Debug::
120 * Pragma Detect_Blocking::
121 * Pragma Elaboration_Checks::
122 * Pragma Eliminate::
123 * Pragma Export_Exception::
124 * Pragma Export_Function::
125 * Pragma Export_Object::
126 * Pragma Export_Procedure::
127 * Pragma Export_Value::
128 * Pragma Export_Valued_Procedure::
129 * Pragma Extend_System::
130 * Pragma External::
131 * Pragma External_Name_Casing::
132 * Pragma Finalize_Storage_Only::
133 * Pragma Float_Representation::
134 * Pragma Ident::
135 * Pragma Import_Exception::
136 * Pragma Import_Function::
137 * Pragma Import_Object::
138 * Pragma Import_Procedure::
139 * Pragma Import_Valued_Procedure::
140 * Pragma Initialize_Scalars::
141 * Pragma Inline_Always::
142 * Pragma Inline_Generic::
143 * Pragma Interface::
144 * Pragma Interface_Name::
145 * Pragma Interrupt_Handler::
146 * Pragma Interrupt_State::
147 * Pragma Keep_Names::
148 * Pragma License::
149 * Pragma Link_With::
150 * Pragma Linker_Alias::
151 * Pragma Linker_Section::
152 * Pragma Long_Float::
153 * Pragma Machine_Attribute::
154 * Pragma Main_Storage::
155 * Pragma No_Return::
156 * Pragma Normalize_Scalars::
157 * Pragma Obsolescent::
158 * Pragma Passive::
159 * Pragma Polling::
160 * Pragma Profile (Ravenscar)::
161 * Pragma Profile (Restricted)::
162 * Pragma Propagate_Exceptions::
163 * Pragma Psect_Object::
164 * Pragma Pure_Function::
165 * Pragma Restriction_Warnings::
166 * Pragma Source_File_Name::
167 * Pragma Source_File_Name_Project::
168 * Pragma Source_Reference::
169 * Pragma Stream_Convert::
170 * Pragma Style_Checks::
171 * Pragma Subtitle::
172 * Pragma Suppress_All::
173 * Pragma Suppress_Exception_Locations::
174 * Pragma Suppress_Initialization::
175 * Pragma Task_Info::
176 * Pragma Task_Name::
177 * Pragma Task_Storage::
178 * Pragma Thread_Body::
179 * Pragma Time_Slice::
180 * Pragma Title::
181 * Pragma Unchecked_Union::
182 * Pragma Unimplemented_Unit::
183 * Pragma Universal_Data::
184 * Pragma Unreferenced::
185 * Pragma Unreserve_All_Interrupts::
186 * Pragma Unsuppress::
187 * Pragma Use_VADS_Size::
188 * Pragma Validity_Checks::
189 * Pragma Volatile::
190 * Pragma Warnings::
191 * Pragma Weak_External::
193 Implementation Defined Attributes
195 * Abort_Signal::
196 * Address_Size::
197 * Asm_Input::
198 * Asm_Output::
199 * AST_Entry::
200 * Bit::
201 * Bit_Position::
202 * Code_Address::
203 * Default_Bit_Order::
204 * Elaborated::
205 * Elab_Body::
206 * Elab_Spec::
207 * Emax::
208 * Enum_Rep::
209 * Epsilon::
210 * Fixed_Value::
211 * Has_Access_Values::
212 * Has_Discriminants::
213 * Img::
214 * Integer_Value::
215 * Large::
216 * Machine_Size::
217 * Mantissa::
218 * Max_Interrupt_Priority::
219 * Max_Priority::
220 * Maximum_Alignment::
221 * Mechanism_Code::
222 * Null_Parameter::
223 * Object_Size::
224 * Passed_By_Reference::
225 * Range_Length::
226 * Safe_Emax::
227 * Safe_Large::
228 * Small::
229 * Storage_Unit::
230 * Target_Name::
231 * Tick::
232 * To_Address::
233 * Type_Class::
234 * UET_Address::
235 * Unconstrained_Array::
236 * Universal_Literal_String::
237 * Unrestricted_Access::
238 * VADS_Size::
239 * Value_Size::
240 * Wchar_T_Size::
241 * Word_Size::
243 The Implementation of Standard I/O
245 * Standard I/O Packages::
246 * FORM Strings::
247 * Direct_IO::
248 * Sequential_IO::
249 * Text_IO::
250 * Wide_Text_IO::
251 * Wide_Wide_Text_IO::
252 * Stream_IO::
253 * Shared Files::
254 * Open Modes::
255 * Operations on C Streams::
256 * Interfacing to C Streams::
258 The GNAT Library
260 * Ada.Characters.Latin_9 (a-chlat9.ads)::
261 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
262 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
263 * Ada.Characters.Wide_Wide_Latin_1 (a-czila1.ads)::
264 * Ada.Characters.Wide_Wide_Latin_9 (a-czila9.ads)::
265 * Ada.Command_Line.Remove (a-colire.ads)::
266 * Ada.Command_Line.Environment (a-colien.ads)::
267 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
268 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
269 * Ada.Exceptions.Traceback (a-exctra.ads)::
270 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
271 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
272 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
273 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
274 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
275 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
276 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
277 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
278 * GNAT.Array_Split (g-arrspl.ads)::
279 * GNAT.AWK (g-awk.ads)::
280 * GNAT.Bounded_Buffers (g-boubuf.ads)::
281 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
282 * GNAT.Bubble_Sort (g-bubsor.ads)::
283 * GNAT.Bubble_Sort_A (g-busora.ads)::
284 * GNAT.Bubble_Sort_G (g-busorg.ads)::
285 * GNAT.Calendar (g-calend.ads)::
286 * GNAT.Calendar.Time_IO (g-catiio.ads)::
287 * GNAT.Case_Util (g-casuti.ads)::
288 * GNAT.CGI (g-cgi.ads)::
289 * GNAT.CGI.Cookie (g-cgicoo.ads)::
290 * GNAT.CGI.Debug (g-cgideb.ads)::
291 * GNAT.Command_Line (g-comlin.ads)::
292 * GNAT.Compiler_Version (g-comver.ads)::
293 * GNAT.Ctrl_C (g-ctrl_c.ads)::
294 * GNAT.CRC32 (g-crc32.ads)::
295 * GNAT.Current_Exception (g-curexc.ads)::
296 * GNAT.Debug_Pools (g-debpoo.ads)::
297 * GNAT.Debug_Utilities (g-debuti.ads)::
298 * GNAT.Directory_Operations (g-dirope.ads)::
299 * GNAT.Dynamic_HTables (g-dynhta.ads)::
300 * GNAT.Dynamic_Tables (g-dyntab.ads)::
301 * GNAT.Exception_Actions (g-excact.ads)::
302 * GNAT.Exception_Traces (g-exctra.ads)::
303 * GNAT.Exceptions (g-except.ads)::
304 * GNAT.Expect (g-expect.ads)::
305 * GNAT.Float_Control (g-flocon.ads)::
306 * GNAT.Heap_Sort (g-heasor.ads)::
307 * GNAT.Heap_Sort_A (g-hesora.ads)::
308 * GNAT.Heap_Sort_G (g-hesorg.ads)::
309 * GNAT.HTable (g-htable.ads)::
310 * GNAT.IO (g-io.ads)::
311 * GNAT.IO_Aux (g-io_aux.ads)::
312 * GNAT.Lock_Files (g-locfil.ads)::
313 * GNAT.MD5 (g-md5.ads)::
314 * GNAT.Memory_Dump (g-memdum.ads)::
315 * GNAT.Most_Recent_Exception (g-moreex.ads)::
316 * GNAT.OS_Lib (g-os_lib.ads)::
317 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
318 * GNAT.Regexp (g-regexp.ads)::
319 * GNAT.Registry (g-regist.ads)::
320 * GNAT.Regpat (g-regpat.ads)::
321 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
322 * GNAT.Semaphores (g-semaph.ads)::
323 * GNAT.Signals (g-signal.ads)::
324 * GNAT.Sockets (g-socket.ads)::
325 * GNAT.Source_Info (g-souinf.ads)::
326 * GNAT.Spell_Checker (g-speche.ads)::
327 * GNAT.Spitbol.Patterns (g-spipat.ads)::
328 * GNAT.Spitbol (g-spitbo.ads)::
329 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
330 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
331 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
332 * GNAT.Strings (g-string.ads)::
333 * GNAT.String_Split (g-strspl.ads)::
334 * GNAT.Table (g-table.ads)::
335 * GNAT.Task_Lock (g-tasloc.ads)::
336 * GNAT.Threads (g-thread.ads)::
337 * GNAT.Traceback (g-traceb.ads)::
338 * GNAT.Traceback.Symbolic (g-trasym.ads)::
339 * GNAT.Wide_String_Split (g-wistsp.ads)::
340 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
341 * Interfaces.C.Extensions (i-cexten.ads)::
342 * Interfaces.C.Streams (i-cstrea.ads)::
343 * Interfaces.CPP (i-cpp.ads)::
344 * Interfaces.Os2lib (i-os2lib.ads)::
345 * Interfaces.Os2lib.Errors (i-os2err.ads)::
346 * Interfaces.Os2lib.Synchronization (i-os2syn.ads)::
347 * Interfaces.Os2lib.Threads (i-os2thr.ads)::
348 * Interfaces.Packed_Decimal (i-pacdec.ads)::
349 * Interfaces.VxWorks (i-vxwork.ads)::
350 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
351 * System.Address_Image (s-addima.ads)::
352 * System.Assertions (s-assert.ads)::
353 * System.Memory (s-memory.ads)::
354 * System.Partition_Interface (s-parint.ads)::
355 * System.Restrictions (s-restri.ads)::
356 * System.Rident (s-rident.ads)::
357 * System.Task_Info (s-tasinf.ads)::
358 * System.Wch_Cnv (s-wchcnv.ads)::
359 * System.Wch_Con (s-wchcon.ads)::
361 Text_IO
363 * Text_IO Stream Pointer Positioning::
364 * Text_IO Reading and Writing Non-Regular Files::
365 * Get_Immediate::
366 * Treating Text_IO Files as Streams::
367 * Text_IO Extensions::
368 * Text_IO Facilities for Unbounded Strings::
370 Wide_Text_IO
372 * Wide_Text_IO Stream Pointer Positioning::
373 * Wide_Text_IO Reading and Writing Non-Regular Files::
375 Wide_Wide_Text_IO
377 * Wide_Wide_Text_IO Stream Pointer Positioning::
378 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
380 Interfacing to Other Languages
382 * Interfacing to C::
383 * Interfacing to C++::
384 * Interfacing to COBOL::
385 * Interfacing to Fortran::
386 * Interfacing to non-GNAT Ada code::
388 Specialized Needs Annexes
390 Implementation of Specific Ada Features
391 * Machine Code Insertions::
392 * GNAT Implementation of Tasking::
393 * GNAT Implementation of Shared Passive Packages::
394 * Code Generation for Array Aggregates::
395 * The Size of Discriminated Records with Default Discriminants::
397 Project File Reference
399 Obsolescent Features
401 GNU Free Documentation License
403 Index
404 @end menu
406 @end ifnottex
408 @node About This Guide
409 @unnumbered About This Guide
411 @ifclear PROEDITION
412 @noindent
413 This manual contains useful information in writing programs using the
414 GNAT compiler.  It includes information on implementation dependent
415 characteristics of GNAT, including all the information required by Annex
416 M of the standard.
417 @end ifclear
419 @ifset PROEDITION
420 @noindent
421 This manual contains useful information in writing programs using the
422 GNAT Pro compiler.  It includes information on implementation dependent
423 characteristics of GNAT Pro, including all the information required by Annex
424 M of the standard.
425 @end ifset
427 Ada 95 is designed to be highly portable.
428 In general, a program will have the same effect even when compiled by
429 different compilers on different platforms.
430 However, since Ada 95 is designed to be used in a
431 wide variety of applications, it also contains a number of system
432 dependent features to be used in interfacing to the external world.
433 @cindex Implementation-dependent features
434 @cindex Portability
436 Note: Any program that makes use of implementation-dependent features
437 may be non-portable.  You should follow good programming practice and
438 isolate and clearly document any sections of your program that make use
439 of these features in a non-portable manner.
441 @ifset PROEDITION
442 For ease of exposition, ``GNAT Pro'' will be referred to simply as
443 ``GNAT'' in the remainder of this document.
444 @end ifset
446 @menu
447 * What This Reference Manual Contains::
448 * Conventions::
449 * Related Information::
450 @end menu
452 @node What This Reference Manual Contains
453 @unnumberedsec What This Reference Manual Contains
455 @noindent
456 This reference manual contains the following chapters:
458 @itemize @bullet
459 @item
460 @ref{Implementation Defined Pragmas}, lists GNAT implementation-dependent
461 pragmas, which can be used to extend and enhance the functionality of the
462 compiler.
464 @item
465 @ref{Implementation Defined Attributes}, lists GNAT
466 implementation-dependent attributes which can be used to extend and
467 enhance the functionality of the compiler.
469 @item
470 @ref{Implementation Advice}, provides information on generally
471 desirable behavior which are not requirements that all compilers must
472 follow since it cannot be provided on all systems, or which may be
473 undesirable on some systems.
475 @item
476 @ref{Implementation Defined Characteristics}, provides a guide to
477 minimizing implementation dependent features.
479 @item
480 @ref{Intrinsic Subprograms}, describes the intrinsic subprograms
481 implemented by GNAT, and how they can be imported into user
482 application programs.
484 @item
485 @ref{Representation Clauses and Pragmas}, describes in detail the
486 way that GNAT represents data, and in particular the exact set
487 of representation clauses and pragmas that is accepted.
489 @item
490 @ref{Standard Library Routines}, provides a listing of packages and a
491 brief description of the functionality that is provided by Ada's
492 extensive set of standard library routines as implemented by GNAT@.
494 @item
495 @ref{The Implementation of Standard I/O}, details how the GNAT
496 implementation of the input-output facilities.
498 @item
499 @ref{The GNAT Library}, is a catalog of packages that complement
500 the Ada predefined library.
502 @item
503 @ref{Interfacing to Other Languages}, describes how programs
504 written in Ada using GNAT can be interfaced to other programming
505 languages.
507 @ref{Specialized Needs Annexes}, describes the GNAT implementation of all
508 of the specialized needs annexes.
510 @item
511 @ref{Implementation of Specific Ada Features}, discusses issues related
512 to GNAT's implementation of machine code insertions, tasking, and several
513 other features.
515 @item
516 @ref{Project File Reference}, presents the syntax and semantics
517 of project files.
519 @item
520 @ref{Obsolescent Features} documents implementation dependent features,
521 including pragmas and attributes, which are considered obsolescent, since
522 there are other preferred ways of achieving the same results. These
523 obsolescent forms are retained for backwards compatibilty.
525 @end itemize
527 @cindex Ada 95 ISO/ANSI Standard
528 @noindent
529 This reference manual assumes that you are familiar with Ada 95
530 language, as described in the International Standard
531 ANSI/ISO/IEC-8652:1995, Jan 1995.
533 @node Conventions
534 @unnumberedsec Conventions
535 @cindex Conventions, typographical
536 @cindex Typographical conventions
538 @noindent
539 Following are examples of the typographical and graphic conventions used
540 in this guide:
542 @itemize @bullet
543 @item
544 @code{Functions}, @code{utility program names}, @code{standard names},
545 and @code{classes}.
547 @item
548 @code{Option flags}
550 @item
551 @file{File Names}, @samp{button names}, and @samp{field names}.
553 @item
554 @code{Variables}.
556 @item
557 @emph{Emphasis}.
559 @item
560 [optional information or parameters]
562 @item
563 Examples are described by text
564 @smallexample
565 and then shown this way.
566 @end smallexample
567 @end itemize
569 @noindent
570 Commands that are entered by the user are preceded in this manual by the
571 characters @samp{$ } (dollar sign followed by space).  If your system uses this
572 sequence as a prompt, then the commands will appear exactly as you see them
573 in the manual.  If your system uses some other prompt, then the command will
574 appear with the @samp{$} replaced by whatever prompt character you are using.
576 @node Related Information
577 @unnumberedsec Related Information
578 @noindent
579 See the following documents for further information on GNAT:
581 @itemize @bullet
582 @item
583 @cite{GNAT User's Guide}, which provides information on how to use
584 the GNAT compiler system.
586 @item
587 @cite{Ada 95 Reference Manual}, which contains all reference
588 material for the Ada 95 programming language.
590 @item
591 @cite{Ada 95 Annotated Reference Manual}, which is an annotated version
592 of the standard reference manual cited above.  The annotations describe
593 detailed aspects of the design decision, and in particular contain useful
594 sections on Ada 83 compatibility.
596 @item
597 @cite{DEC Ada, Technical Overview and Comparison on DIGITAL Platforms},
598 which contains specific information on compatibility between GNAT and
599 DEC Ada 83 systems.
601 @item
602 @cite{DEC Ada, Language Reference Manual, part number AA-PYZAB-TK} which
603 describes in detail the pragmas and attributes provided by the DEC Ada 83
604 compiler system.
606 @end itemize
608 @node Implementation Defined Pragmas
609 @chapter Implementation Defined Pragmas
611 @noindent
612 Ada 95 defines a set of pragmas that can be used to supply additional
613 information to the compiler.  These language defined pragmas are
614 implemented in GNAT and work as described in the Ada 95 Reference
615 Manual.
617 In addition, Ada 95 allows implementations to define additional pragmas
618 whose meaning is defined by the implementation.  GNAT provides a number
619 of these implementation-dependent pragmas which can be used to extend
620 and enhance the functionality of the compiler.  This section of the GNAT
621 Reference Manual describes these additional pragmas.
623 Note that any program using these pragmas may not be portable to other
624 compilers (although GNAT implements this set of pragmas on all
625 platforms).  Therefore if portability to other compilers is an important
626 consideration, the use of these pragmas should be minimized.
628 @menu
629 * Pragma Abort_Defer::
630 * Pragma Ada_83::
631 * Pragma Ada_95::
632 * Pragma Annotate::
633 * Pragma Assert::
634 * Pragma Ast_Entry::
635 * Pragma C_Pass_By_Copy::
636 * Pragma Comment::
637 * Pragma Common_Object::
638 * Pragma Compile_Time_Warning::
639 * Pragma Complex_Representation::
640 * Pragma Component_Alignment::
641 * Pragma Convention_Identifier::
642 * Pragma CPP_Class::
643 * Pragma CPP_Constructor::
644 * Pragma CPP_Virtual::
645 * Pragma CPP_Vtable::
646 * Pragma Debug::
647 * Pragma Detect_Blocking::
648 * Pragma Elaboration_Checks::
649 * Pragma Eliminate::
650 * Pragma Export_Exception::
651 * Pragma Export_Function::
652 * Pragma Export_Object::
653 * Pragma Export_Procedure::
654 * Pragma Export_Value::
655 * Pragma Export_Valued_Procedure::
656 * Pragma Extend_System::
657 * Pragma External::
658 * Pragma External_Name_Casing::
659 * Pragma Finalize_Storage_Only::
660 * Pragma Float_Representation::
661 * Pragma Ident::
662 * Pragma Import_Exception::
663 * Pragma Import_Function::
664 * Pragma Import_Object::
665 * Pragma Import_Procedure::
666 * Pragma Import_Valued_Procedure::
667 * Pragma Initialize_Scalars::
668 * Pragma Inline_Always::
669 * Pragma Inline_Generic::
670 * Pragma Interface::
671 * Pragma Interface_Name::
672 * Pragma Interrupt_Handler::
673 * Pragma Interrupt_State::
674 * Pragma Keep_Names::
675 * Pragma License::
676 * Pragma Link_With::
677 * Pragma Linker_Alias::
678 * Pragma Linker_Section::
679 * Pragma Long_Float::
680 * Pragma Machine_Attribute::
681 * Pragma Main_Storage::
682 * Pragma No_Return::
683 * Pragma Normalize_Scalars::
684 * Pragma Obsolescent::
685 * Pragma Passive::
686 * Pragma Polling::
687 * Pragma Profile (Ravenscar)::
688 * Pragma Profile (Restricted)::
689 * Pragma Propagate_Exceptions::
690 * Pragma Psect_Object::
691 * Pragma Pure_Function::
692 * Pragma Restriction_Warnings::
693 * Pragma Source_File_Name::
694 * Pragma Source_File_Name_Project::
695 * Pragma Source_Reference::
696 * Pragma Stream_Convert::
697 * Pragma Style_Checks::
698 * Pragma Subtitle::
699 * Pragma Suppress_All::
700 * Pragma Suppress_Exception_Locations::
701 * Pragma Suppress_Initialization::
702 * Pragma Task_Info::
703 * Pragma Task_Name::
704 * Pragma Task_Storage::
705 * Pragma Thread_Body::
706 * Pragma Time_Slice::
707 * Pragma Title::
708 * Pragma Unchecked_Union::
709 * Pragma Unimplemented_Unit::
710 * Pragma Universal_Data::
711 * Pragma Unreferenced::
712 * Pragma Unreserve_All_Interrupts::
713 * Pragma Unsuppress::
714 * Pragma Use_VADS_Size::
715 * Pragma Validity_Checks::
716 * Pragma Volatile::
717 * Pragma Warnings::
718 * Pragma Weak_External::
719 @end menu
721 @node Pragma Abort_Defer
722 @unnumberedsec Pragma Abort_Defer
723 @findex Abort_Defer
724 @cindex Deferring aborts
725 @noindent
726 Syntax:
727 @smallexample
728 pragma Abort_Defer;
729 @end smallexample
731 @noindent
732 This pragma must appear at the start of the statement sequence of a
733 handled sequence of statements (right after the @code{begin}).  It has
734 the effect of deferring aborts for the sequence of statements (but not
735 for the declarations or handlers, if any, associated with this statement
736 sequence).
738 @node Pragma Ada_83
739 @unnumberedsec Pragma Ada_83
740 @findex Ada_83
741 @noindent
742 Syntax:
743 @smallexample @c ada
744 pragma Ada_83;
745 @end smallexample
747 @noindent
748 A configuration pragma that establishes Ada 83 mode for the unit to
749 which it applies, regardless of the mode set by the command line
750 switches.  In Ada 83 mode, GNAT attempts to be as compatible with
751 the syntax and semantics of Ada 83, as defined in the original Ada
752 83 Reference Manual as possible.  In particular, the new Ada 95
753 keywords are not recognized, optional package bodies are allowed,
754 and generics may name types with unknown discriminants without using
755 the @code{(<>)} notation.  In addition, some but not all of the additional
756 restrictions of Ada 83 are enforced.
758 Ada 83 mode is intended for two purposes.  Firstly, it allows existing
759 legacy Ada 83 code to be compiled and adapted to GNAT with less effort.
760 Secondly, it aids in keeping code backwards compatible with Ada 83.
761 However, there is no guarantee that code that is processed correctly
762 by GNAT in Ada 83 mode will in fact compile and execute with an Ada
763 83 compiler, since GNAT does not enforce all the additional checks
764 required by Ada 83.
766 @node Pragma Ada_95
767 @unnumberedsec Pragma Ada_95
768 @findex Ada_95
769 @noindent
770 Syntax:
771 @smallexample @c ada
772 pragma Ada_95;
773 @end smallexample
775 @noindent
776 A configuration pragma that establishes Ada 95 mode for the unit to which
777 it applies, regardless of the mode set by the command line switches.
778 This mode is set automatically for the @code{Ada} and @code{System}
779 packages and their children, so you need not specify it in these
780 contexts.  This pragma is useful when writing a reusable component that
781 itself uses Ada 95 features, but which is intended to be usable from
782 either Ada 83 or Ada 95 programs.
784 @node Pragma Annotate
785 @unnumberedsec Pragma Annotate
786 @findex Annotate
787 @noindent
788 Syntax:
789 @smallexample @c ada
790 pragma Annotate (IDENTIFIER @{, ARG@});
792 ARG ::= NAME | EXPRESSION
793 @end smallexample
795 @noindent
796 This pragma is used to annotate programs.  @var{identifier} identifies
797 the type of annotation.  GNAT verifies this is an identifier, but does
798 not otherwise analyze it.  The @var{arg} argument
799 can be either a string literal or an
800 expression.  String literals are assumed to be of type
801 @code{Standard.String}.  Names of entities are simply analyzed as entity
802 names.  All other expressions are analyzed as expressions, and must be
803 unambiguous.
805 The analyzed pragma is retained in the tree, but not otherwise processed
806 by any part of the GNAT compiler.  This pragma is intended for use by
807 external tools, including ASIS@.
809 @node Pragma Assert
810 @unnumberedsec Pragma Assert
811 @findex Assert
812 @noindent
813 Syntax:
814 @smallexample @c ada
815 pragma Assert (
816   boolean_EXPRESSION
817   [, static_string_EXPRESSION]);
818 @end smallexample
820 @noindent
821 The effect of this pragma depends on whether the corresponding command
822 line switch is set to activate assertions.  The pragma expands into code
823 equivalent to the following:
825 @smallexample @c ada
826 if assertions-enabled then
827    if not boolean_EXPRESSION then
828       System.Assertions.Raise_Assert_Failure
829         (string_EXPRESSION);
830    end if;
831 end if;
832 @end smallexample
834 @noindent
835 The string argument, if given, is the message that will be associated
836 with the exception occurrence if the exception is raised.  If no second
837 argument is given, the default message is @samp{@var{file}:@var{nnn}},
838 where @var{file} is the name of the source file containing the assert,
839 and @var{nnn} is the line number of the assert.  A pragma is not a
840 statement, so if a statement sequence contains nothing but a pragma
841 assert, then a null statement is required in addition, as in:
843 @smallexample @c ada
844 @dots{}
845 if J > 3 then
846    pragma Assert (K > 3, "Bad value for K");
847    null;
848 end if;
849 @end smallexample
851 @noindent
852 Note that, as with the @code{if} statement to which it is equivalent, the
853 type of the expression is either @code{Standard.Boolean}, or any type derived
854 from this standard type.
856 If assertions are disabled (switch @code{-gnata} not used), then there
857 is no effect (and in particular, any side effects from the expression
858 are suppressed).  More precisely it is not quite true that the pragma
859 has no effect, since the expression is analyzed, and may cause types
860 to be frozen if they are mentioned here for the first time.
862 If assertions are enabled, then the given expression is tested, and if
863 it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
864 which results in the raising of @code{Assert_Failure} with the given message.
866 If the boolean expression has side effects, these side effects will turn
867 on and off with the setting of the assertions mode, resulting in
868 assertions that have an effect on the program.  You should generally
869 avoid side effects in the expression arguments of this pragma.  However,
870 the expressions are analyzed for semantic correctness whether or not
871 assertions are enabled, so turning assertions on and off cannot affect
872 the legality of a program.
874 @node Pragma Ast_Entry
875 @unnumberedsec Pragma Ast_Entry
876 @cindex OpenVMS
877 @findex Ast_Entry
878 @noindent
879 Syntax:
880 @smallexample @c ada
881 pragma AST_Entry (entry_IDENTIFIER);
882 @end smallexample
884 @noindent
885 This pragma is implemented only in the OpenVMS implementation of GNAT@.  The
886 argument is the simple name of a single entry; at most one @code{AST_Entry}
887 pragma is allowed for any given entry.  This pragma must be used in
888 conjunction with the @code{AST_Entry} attribute, and is only allowed after
889 the entry declaration and in the same task type specification or single task
890 as the entry to which it applies.  This pragma specifies that the given entry
891 may be used to handle an OpenVMS asynchronous system trap (@code{AST})
892 resulting from an OpenVMS system service call.  The pragma does not affect
893 normal use of the entry.  For further details on this pragma, see the
894 DEC Ada Language Reference Manual, section 9.12a.
896 @node Pragma C_Pass_By_Copy
897 @unnumberedsec Pragma C_Pass_By_Copy
898 @cindex Passing by copy
899 @findex C_Pass_By_Copy
900 @noindent
901 Syntax:
902 @smallexample @c ada
903 pragma C_Pass_By_Copy
904   ([Max_Size =>] static_integer_EXPRESSION);
905 @end smallexample
907 @noindent
908 Normally the default mechanism for passing C convention records to C
909 convention subprograms is to pass them by reference, as suggested by RM
910 B.3(69).  Use the configuration pragma @code{C_Pass_By_Copy} to change
911 this default, by requiring that record formal parameters be passed by
912 copy if all of the following conditions are met:
914 @itemize @bullet
915 @item
916 The size of the record type does not exceed@*@var{static_integer_expression}.
917 @item
918 The record type has @code{Convention C}.
919 @item
920 The formal parameter has this record type, and the subprogram has a
921 foreign (non-Ada) convention.
922 @end itemize
924 @noindent
925 If these conditions are met the argument is passed by copy, i.e.@: in a
926 manner consistent with what C expects if the corresponding formal in the
927 C prototype is a struct (rather than a pointer to a struct).
929 You can also pass records by copy by specifying the convention
930 @code{C_Pass_By_Copy} for the record type, or by using the extended
931 @code{Import} and @code{Export} pragmas, which allow specification of
932 passing mechanisms on a parameter by parameter basis.
934 @node Pragma Comment
935 @unnumberedsec Pragma Comment
936 @findex Comment
937 @noindent
938 Syntax:
940 @smallexample @c ada
941 pragma Comment (static_string_EXPRESSION);
942 @end smallexample
944 @noindent
945 This is almost identical in effect to pragma @code{Ident}.  It allows the
946 placement of a comment into the object file and hence into the
947 executable file if the operating system permits such usage.  The
948 difference is that @code{Comment}, unlike @code{Ident}, has
949 no limitations on placement of the pragma (it can be placed
950 anywhere in the main source unit), and if more than one pragma
951 is used, all comments are retained.
953 @node Pragma Common_Object
954 @unnumberedsec Pragma Common_Object
955 @findex Common_Object
956 @noindent
957 Syntax:
959 @smallexample @c ada
960 pragma Common_Object (
961      [Internal =>] LOCAL_NAME,
962   [, [External =>] EXTERNAL_SYMBOL]
963   [, [Size     =>] EXTERNAL_SYMBOL] );
965 EXTERNAL_SYMBOL ::=
966   IDENTIFIER
967 | static_string_EXPRESSION
968 @end smallexample
970 @noindent
971 This pragma enables the shared use of variables stored in overlaid
972 linker areas corresponding to the use of @code{COMMON}
973 in Fortran.  The single
974 object @var{local_name} is assigned to the area designated by
975 the @var{External} argument.
976 You may define a record to correspond to a series
977 of fields.  The @var{size} argument
978 is syntax checked in GNAT, but otherwise ignored.
980 @code{Common_Object} is not supported on all platforms.  If no
981 support is available, then the code generator will issue a message
982 indicating that the necessary attribute for implementation of this
983 pragma is not available.
985 @node Pragma Compile_Time_Warning
986 @unnumberedsec Pragma Compile_Time_Warning
987 @findex Compile_Time_Warning
988 @noindent
989 Syntax:
991 @smallexample @c ada
992 pragma Compile_Time_Warning
993          (boolean_EXPRESSION, static_string_EXPRESSION);
994 @end smallexample
996 @noindent
997 This pragma can be used to generate additional compile time warnings. It
998 is particularly useful in generics, where warnings can be issued for
999 specific problematic instantiations. The first parameter is a boolean
1000 expression. The pragma is effective only if the value of this expression
1001 is known at compile time, and has the value True. The set of expressions
1002 whose values are known at compile time includes all static boolean
1003 expressions, and also other values which the compiler can determine
1004 at compile time (e.g. the size of a record type set by an explicit
1005 size representation clause, or the value of a variable which was
1006 initialized to a constant and is known not to have been modified).
1007 If these conditions are met, a warning message is generated using
1008 the value given as the second argument. This string value may contain
1009 embedded ASCII.LF characters to break the message into multiple lines.
1011 @node Pragma Complex_Representation
1012 @unnumberedsec Pragma Complex_Representation
1013 @findex Complex_Representation
1014 @noindent
1015 Syntax:
1017 @smallexample @c ada
1018 pragma Complex_Representation
1019         ([Entity =>] LOCAL_NAME);
1020 @end smallexample
1022 @noindent
1023 The @var{Entity} argument must be the name of a record type which has
1024 two fields of the same floating-point type.  The effect of this pragma is
1025 to force gcc to use the special internal complex representation form for
1026 this record, which may be more efficient.  Note that this may result in
1027 the code for this type not conforming to standard ABI (application
1028 binary interface) requirements for the handling of record types.  For
1029 example, in some environments, there is a requirement for passing
1030 records by pointer, and the use of this pragma may result in passing
1031 this type in floating-point registers.
1033 @node Pragma Component_Alignment
1034 @unnumberedsec Pragma Component_Alignment
1035 @cindex Alignments of components
1036 @findex Component_Alignment
1037 @noindent
1038 Syntax:
1040 @smallexample @c ada
1041 pragma Component_Alignment (
1042      [Form =>] ALIGNMENT_CHOICE
1043   [, [Name =>] type_LOCAL_NAME]);
1045 ALIGNMENT_CHOICE ::=
1046   Component_Size
1047 | Component_Size_4
1048 | Storage_Unit
1049 | Default
1050 @end smallexample
1052 @noindent
1053 Specifies the alignment of components in array or record types.
1054 The meaning of the @var{Form} argument is as follows:
1056 @table @code
1057 @findex Component_Size
1058 @item Component_Size
1059 Aligns scalar components and subcomponents of the array or record type
1060 on boundaries appropriate to their inherent size (naturally
1061 aligned).  For example, 1-byte components are aligned on byte boundaries,
1062 2-byte integer components are aligned on 2-byte boundaries, 4-byte
1063 integer components are aligned on 4-byte boundaries and so on.  These
1064 alignment rules correspond to the normal rules for C compilers on all
1065 machines except the VAX@.
1067 @findex Component_Size_4
1068 @item Component_Size_4
1069 Naturally aligns components with a size of four or fewer
1070 bytes.  Components that are larger than 4 bytes are placed on the next
1071 4-byte boundary.
1073 @findex Storage_Unit
1074 @item Storage_Unit
1075 Specifies that array or record components are byte aligned, i.e.@:
1076 aligned on boundaries determined by the value of the constant
1077 @code{System.Storage_Unit}.
1079 @cindex OpenVMS
1080 @item Default
1081 Specifies that array or record components are aligned on default
1082 boundaries, appropriate to the underlying hardware or operating system or
1083 both.  For OpenVMS VAX systems, the @code{Default} choice is the same as
1084 the @code{Storage_Unit} choice (byte alignment).  For all other systems,
1085 the @code{Default} choice is the same as @code{Component_Size} (natural
1086 alignment).
1087 @end table
1089 @noindent
1090 If the @code{Name} parameter is present, @var{type_local_name} must
1091 refer to a local record or array type, and the specified alignment
1092 choice applies to the specified type.  The use of
1093 @code{Component_Alignment} together with a pragma @code{Pack} causes the
1094 @code{Component_Alignment} pragma to be ignored.  The use of
1095 @code{Component_Alignment} together with a record representation clause
1096 is only effective for fields not specified by the representation clause.
1098 If the @code{Name} parameter is absent, the pragma can be used as either
1099 a configuration pragma, in which case it applies to one or more units in
1100 accordance with the normal rules for configuration pragmas, or it can be
1101 used within a declarative part, in which case it applies to types that
1102 are declared within this declarative part, or within any nested scope
1103 within this declarative part.  In either case it specifies the alignment
1104 to be applied to any record or array type which has otherwise standard
1105 representation.
1107 If the alignment for a record or array type is not specified (using
1108 pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
1109 clause), the GNAT uses the default alignment as described previously.
1111 @node Pragma Convention_Identifier
1112 @unnumberedsec Pragma Convention_Identifier
1113 @findex Convention_Identifier
1114 @cindex Conventions, synonyms
1115 @noindent
1116 Syntax:
1118 @smallexample @c ada
1119 pragma Convention_Identifier (
1120          [Name =>]       IDENTIFIER,
1121          [Convention =>] convention_IDENTIFIER);
1122 @end smallexample
1124 @noindent
1125 This pragma provides a mechanism for supplying synonyms for existing
1126 convention identifiers. The @code{Name} identifier can subsequently
1127 be used as a synonym for the given convention in other pragmas (including
1128 for example pragma @code{Import} or another @code{Convention_Identifier}
1129 pragma). As an example of the use of this, suppose you had legacy code
1130 which used Fortran77 as the identifier for Fortran. Then the pragma:
1132 @smallexample @c ada
1133 pragma Convention_Identifier (Fortran77, Fortran);
1134 @end smallexample
1136 @noindent
1137 would allow the use of the convention identifier @code{Fortran77} in
1138 subsequent code, avoiding the need to modify the sources. As another
1139 example, you could use this to parametrize convention requirements
1140 according to systems. Suppose you needed to use @code{Stdcall} on
1141 windows systems, and @code{C} on some other system, then you could
1142 define a convention identifier @code{Library} and use a single
1143 @code{Convention_Identifier} pragma to specify which convention
1144 would be used system-wide.
1146 @node Pragma CPP_Class
1147 @unnumberedsec Pragma CPP_Class
1148 @findex CPP_Class
1149 @cindex Interfacing with C++
1150 @noindent
1151 Syntax:
1153 @smallexample @c ada
1154 pragma CPP_Class ([Entity =>] LOCAL_NAME);
1155 @end smallexample
1157 @noindent
1158 The argument denotes an entity in the current declarative region
1159 that is declared as a tagged or untagged record type.  It indicates that
1160 the type corresponds to an externally declared C++ class type, and is to
1161 be laid out the same way that C++ would lay out the type.
1163 If (and only if) the type is tagged, at least one component in the
1164 record must be of type @code{Interfaces.CPP.Vtable_Ptr}, corresponding
1165 to the C++ Vtable (or Vtables in the case of multiple inheritance) used
1166 for dispatching.
1168 Types for which @code{CPP_Class} is specified do not have assignment or
1169 equality operators defined (such operations can be imported or declared
1170 as subprograms as required).  Initialization is allowed only by
1171 constructor functions (see pragma @code{CPP_Constructor}).
1173 Pragma @code{CPP_Class} is intended primarily for automatic generation
1174 using an automatic binding generator tool.
1175 See @ref{Interfacing to C++} for related information.
1177 @node Pragma CPP_Constructor
1178 @unnumberedsec Pragma CPP_Constructor
1179 @cindex Interfacing with C++
1180 @findex CPP_Constructor
1181 @noindent
1182 Syntax:
1184 @smallexample @c ada
1185 pragma CPP_Constructor ([Entity =>] LOCAL_NAME);
1186 @end smallexample
1188 @noindent
1189 This pragma identifies an imported function (imported in the usual way
1190 with pragma @code{Import}) as corresponding to a C++
1191 constructor.  The argument is a name that must have been
1192 previously mentioned in a pragma @code{Import}
1193 with @code{Convention} = @code{CPP}, and must be of one of the following
1194 forms:
1196 @itemize @bullet
1197 @item
1198 @code{function @var{Fname} return @var{T}'Class}
1200 @item
1201 @code{function @var{Fname} (@dots{}) return @var{T}'Class}
1202 @end itemize
1204 @noindent
1205 where @var{T} is a tagged type to which the pragma @code{CPP_Class} applies.
1207 The first form is the default constructor, used when an object of type
1208 @var{T} is created on the Ada side with no explicit constructor.  Other
1209 constructors (including the copy constructor, which is simply a special
1210 case of the second form in which the one and only argument is of type
1211 @var{T}), can only appear in two contexts:
1213 @itemize @bullet
1214 @item
1215 On the right side of an initialization of an object of type @var{T}.
1216 @item
1217 In an extension aggregate for an object of a type derived from @var{T}.
1218 @end itemize
1220 @noindent
1221 Although the constructor is described as a function that returns a value
1222 on the Ada side, it is typically a procedure with an extra implicit
1223 argument (the object being initialized) at the implementation
1224 level.  GNAT issues the appropriate call, whatever it is, to get the
1225 object properly initialized.
1227 In the case of derived objects, you may use one of two possible forms
1228 for declaring and creating an object:
1230 @itemize @bullet
1231 @item @code{New_Object : Derived_T}
1232 @item @code{New_Object : Derived_T := (@var{constructor-call with} @dots{})}
1233 @end itemize
1235 @noindent
1236 In the first case the default constructor is called and extension fields
1237 if any are initialized according to the default initialization
1238 expressions in the Ada declaration.  In the second case, the given
1239 constructor is called and the extension aggregate indicates the explicit
1240 values of the extension fields.
1242 If no constructors are imported, it is impossible to create any objects
1243 on the Ada side.  If no default constructor is imported, only the
1244 initialization forms using an explicit call to a constructor are
1245 permitted.
1247 Pragma @code{CPP_Constructor} is intended primarily for automatic generation
1248 using an automatic binding generator tool.
1249 See @ref{Interfacing to C++} for more related information.
1251 @node Pragma CPP_Virtual
1252 @unnumberedsec Pragma CPP_Virtual
1253 @cindex Interfacing to C++
1254 @findex CPP_Virtual
1255 @noindent
1256 Syntax:
1258 @smallexample @c ada
1259 pragma CPP_Virtual
1260      [Entity     =>] ENTITY,
1261   [, [Vtable_Ptr =>] vtable_ENTITY,]
1262   [, [Position   =>] static_integer_EXPRESSION]);
1263 @end smallexample
1265 @noindent
1266 This pragma serves the same function as pragma @code{Import} in that
1267 case of a virtual function imported from C++.  The @var{Entity} argument
1268 must be a
1269 primitive subprogram of a tagged type to which pragma @code{CPP_Class}
1270 applies.  The @var{Vtable_Ptr} argument specifies
1271 the Vtable_Ptr component which contains the
1272 entry for this virtual function.  The @var{Position} argument
1273 is the sequential number
1274 counting virtual functions for this Vtable starting at 1.
1276 The @code{Vtable_Ptr} and @code{Position} arguments may be omitted if
1277 there is one Vtable_Ptr present (single inheritance case) and all
1278 virtual functions are imported.  In that case the compiler can deduce both
1279 these values.
1281 No @code{External_Name} or @code{Link_Name} arguments are required for a
1282 virtual function, since it is always accessed indirectly via the
1283 appropriate Vtable entry.
1285 Pragma @code{CPP_Virtual} is intended primarily for automatic generation
1286 using an automatic binding generator tool.
1287 See @ref{Interfacing to C++} for related information.
1289 @node Pragma CPP_Vtable
1290 @unnumberedsec Pragma CPP_Vtable
1291 @cindex Interfacing with C++
1292 @findex CPP_Vtable
1293 @noindent
1294 Syntax:
1296 @smallexample @c ada
1297 pragma CPP_Vtable (
1298   [Entity      =>] ENTITY,
1299   [Vtable_Ptr  =>] vtable_ENTITY,
1300   [Entry_Count =>] static_integer_EXPRESSION);
1301 @end smallexample
1303 @noindent
1304 Given a record to which the pragma @code{CPP_Class} applies,
1305 this pragma can be specified for each component of type
1306 @code{CPP.Interfaces.Vtable_Ptr}.
1307 @var{Entity} is the tagged type, @var{Vtable_Ptr}
1308 is the record field of type @code{Vtable_Ptr}, and @var{Entry_Count} is
1309 the number of virtual functions on the C++ side.  Not all of these
1310 functions need to be imported on the Ada side.
1312 You may omit the @code{CPP_Vtable} pragma if there is only one
1313 @code{Vtable_Ptr} component in the record and all virtual functions are
1314 imported on the Ada side (the default value for the entry count in this
1315 case is simply the total number of virtual functions).
1317 Pragma @code{CPP_Vtable} is intended primarily for automatic generation
1318 using an automatic binding generator tool.
1319 See @ref{Interfacing to C++} for related information.
1321 @node Pragma Debug
1322 @unnumberedsec Pragma Debug
1323 @findex Debug
1324 @noindent
1325 Syntax:
1327 @smallexample @c ada
1328 pragma Debug (PROCEDURE_CALL_WITHOUT_SEMICOLON);
1330 PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
1331   PROCEDURE_NAME
1332 | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
1333 @end smallexample
1335 @noindent
1336 The argument has the syntactic form of an expression, meeting the
1337 syntactic requirements for pragmas.
1339 If assertions are not enabled on the command line, this pragma has no
1340 effect.  If asserts are enabled, the semantics of the pragma is exactly
1341 equivalent to the procedure call statement corresponding to the argument
1342 with a terminating semicolon.  Pragmas are permitted in sequences of
1343 declarations, so you can use pragma @code{Debug} to intersperse calls to
1344 debug procedures in the middle of declarations.
1346 @node Pragma Detect_Blocking
1347 @unnumberedsec Pragma Detect_Blocking
1348 @findex Detect_Blocking
1349 @noindent
1350 Syntax:
1352 @smallexample @c ada
1353 pragma Detect_Blocking;
1354 @end smallexample
1356 @noindent
1357 This is a configuration pragma that forces the detection of potentially
1358 blocking operations within a protected operation, and to raise Program_Error
1359 if that happens.
1361 @node Pragma Elaboration_Checks
1362 @unnumberedsec Pragma Elaboration_Checks
1363 @cindex Elaboration control
1364 @findex Elaboration_Checks
1365 @noindent
1366 Syntax:
1368 @smallexample @c ada
1369 pragma Elaboration_Checks (Dynamic | Static);
1370 @end smallexample
1372 @noindent
1373 This is a configuration pragma that provides control over the
1374 elaboration model used by the compilation affected by the
1375 pragma.  If the parameter is @code{Dynamic},
1376 then the dynamic elaboration
1377 model described in the Ada Reference Manual is used, as though
1378 the @code{-gnatE} switch had been specified on the command
1379 line.  If the parameter is @code{Static}, then the default GNAT static
1380 model is used.  This configuration pragma overrides the setting
1381 of the command line.  For full details on the elaboration models
1382 used by the GNAT compiler, see section ``Elaboration Order
1383 Handling in GNAT'' in the @cite{GNAT User's Guide}.
1385 @node Pragma Eliminate
1386 @unnumberedsec Pragma Eliminate
1387 @cindex Elimination of unused subprograms
1388 @findex Eliminate
1389 @noindent
1390 Syntax:
1392 @smallexample @c ada
1393 pragma Eliminate (
1394     [Unit_Name =>] IDENTIFIER |
1395                    SELECTED_COMPONENT);
1397 pragma Eliminate (
1398     [Unit_Name       =>]  IDENTIFIER |
1399                           SELECTED_COMPONENT,
1400     [Entity          =>]  IDENTIFIER |
1401                           SELECTED_COMPONENT |
1402                           STRING_LITERAL
1403     [,OVERLOADING_RESOLUTION]);
1405 OVERLOADING_RESOLUTION ::= PARAMETER_AND_RESULT_TYPE_PROFILE |
1406                            SOURCE_LOCATION
1408 PARAMETER_AND_RESULT_TYPE_PROFILE ::= PROCEDURE_PROFILE |
1409                                       FUNCTION_PROFILE
1411 PROCEDURE_PROFILE ::= Parameter_Types => PARAMETER_TYPES
1413 FUNCTION_PROFILE ::= [Parameter_Types => PARAMETER_TYPES,]
1414                       Result_Type => result_SUBTYPE_NAME]
1416 PARAMETER_TYPES ::= (SUBTYPE_NAME @{, SUBTYPE_NAME@})
1417 SUBTYPE_NAME    ::= STRING_VALUE
1419 SOURCE_LOCATION ::= Source_Location => SOURCE_TRACE
1420 SOURCE_TRACE    ::= STRING_VALUE
1422 STRING_VALUE ::= STRING_LITERAL @{& STRING_LITERAL@}
1423 @end smallexample
1425 @noindent
1426 This pragma indicates that the given entity is not used outside the
1427 compilation unit it is defined in. The entity must be an explicitly declared
1428 subprogram; this includes  generic subprogram instances and
1429 subprograms declared in generic package instances.
1431 If the entity to be eliminated is a library level subprogram, then
1432 the first form of pragma @code{Eliminate} is used with only a single argument.
1433 In this form, the @code{Unit_Name} argument specifies the name of the
1434 library  level unit to be eliminated.
1436 In all other cases, both @code{Unit_Name} and @code{Entity} arguments
1437 are required. If item is an entity of a library package, then the first
1438 argument specifies the unit name, and the second argument specifies
1439 the particular entity.  If the second argument is in string form, it must
1440 correspond to the internal manner in which GNAT stores entity names (see
1441 compilation unit Namet in the compiler sources for details).
1443 The remaining parameters (OVERLOADING_RESOLUTION) are optionally used
1444 to distinguish between overloaded subprograms. If a pragma does not contain
1445 the OVERLOADING_RESOLUTION parameter(s), it is applied to all the overloaded
1446 subprograms denoted by the first two parameters.
1448 Use PARAMETER_AND_RESULT_TYPE_PROFILE to specify the profile of the subprogram
1449 to be eliminated in a manner similar to that used for the extended
1450 @code{Import} and @code{Export} pragmas, except that the subtype names are
1451 always given as strings. At the moment, this form of distinguishing
1452 overloaded subprograms is implemented only partially, so we do not recommend
1453 using it for practical subprogram elimination.
1455 Note, that in case of a parameterless procedure its profile is represented
1456 as @code{Parameter_Types => ("")}
1458 Alternatively, the @code{Source_Location} parameter is used to specify
1459 which overloaded alternative is to be eliminated by pointing to the
1460 location of the DEFINING_PROGRAM_UNIT_NAME of this subprogram in the
1461 source text. The string literal (or concatenation of string literals)
1462 given as SOURCE_TRACE must have the following format:
1464 @smallexample @c ada
1465 SOURCE_TRACE ::= SOURCE_LOCATION@{LBRACKET SOURCE_LOCATION RBRACKET@}
1467 LBRACKET ::= [
1468 RBRACKET ::= ]
1470 SOURCE_LOCATION ::= FILE_NAME:LINE_NUMBER
1471 FILE_NAME       ::= STRING_LITERAL
1472 LINE_NUMBER     ::= DIGIT @{DIGIT@}
1473 @end smallexample
1475 SOURCE_TRACE should be the short name of the source file (with no directory
1476 information), and LINE_NUMBER is supposed to point to the line where the
1477 defining name of the subprogram is located.
1479 For the subprograms that are not a part of generic instantiations, only one
1480 SOURCE_LOCATION is used. If a subprogram is declared in a package
1481 instantiation, SOURCE_TRACE contains two SOURCE_LOCATIONs, the first one is
1482 the location of the (DEFINING_PROGRAM_UNIT_NAME of the) instantiation, and the
1483 second one denotes the declaration of the corresponding subprogram in the
1484 generic package. This approach is recursively used to create SOURCE_LOCATIONs
1485 in case of nested instantiations.
1487 The effect of the pragma is to allow the compiler to eliminate
1488 the code or data associated with the named entity.  Any reference to
1489 an eliminated entity outside the compilation unit it is defined in,
1490 causes a compile time or link time error.
1492 The intention of pragma @code{Eliminate} is to allow a program to be compiled
1493 in a system independent manner, with unused entities eliminated, without
1494 the requirement of modifying the source text.  Normally the required set
1495 of @code{Eliminate} pragmas is constructed automatically using the gnatelim
1496 tool. Elimination of unused entities local to a compilation unit is
1497 automatic, without requiring the use of pragma @code{Eliminate}.
1499 Note that the reason this pragma takes string literals where names might
1500 be expected is that a pragma @code{Eliminate} can appear in a context where the
1501 relevant names are not visible.
1503 Note that any change in the source files that includes removing, splitting of
1504 adding lines may make the set of Eliminate pragmas using SOURCE_LOCATION
1505 parameter illegal.
1507 @node Pragma Export_Exception
1508 @unnumberedsec Pragma Export_Exception
1509 @cindex OpenVMS
1510 @findex Export_Exception
1511 @noindent
1512 Syntax:
1514 @smallexample @c ada
1515 pragma Export_Exception (
1516      [Internal =>] LOCAL_NAME,
1517   [, [External =>] EXTERNAL_SYMBOL,]
1518   [, [Form     =>] Ada | VMS]
1519   [, [Code     =>] static_integer_EXPRESSION]);
1521 EXTERNAL_SYMBOL ::=
1522   IDENTIFIER
1523 | static_string_EXPRESSION
1524 @end smallexample
1526 @noindent
1527 This pragma is implemented only in the OpenVMS implementation of GNAT@.  It
1528 causes the specified exception to be propagated outside of the Ada program,
1529 so that it can be handled by programs written in other OpenVMS languages.
1530 This pragma establishes an external name for an Ada exception and makes the
1531 name available to the OpenVMS Linker as a global symbol.  For further details
1532 on this pragma, see the
1533 DEC Ada Language Reference Manual, section 13.9a3.2.
1535 @node Pragma Export_Function
1536 @unnumberedsec Pragma Export_Function
1537 @cindex Argument passing mechanisms
1538 @findex Export_Function
1540 @noindent
1541 Syntax:
1543 @smallexample @c ada
1544 pragma Export_Function (
1545      [Internal         =>] LOCAL_NAME,
1546   [, [External         =>] EXTERNAL_SYMBOL]
1547   [, [Parameter_Types  =>] PARAMETER_TYPES]
1548   [, [Result_Type      =>] result_SUBTYPE_MARK]
1549   [, [Mechanism        =>] MECHANISM]
1550   [, [Result_Mechanism =>] MECHANISM_NAME]);
1552 EXTERNAL_SYMBOL ::=
1553   IDENTIFIER
1554 | static_string_EXPRESSION
1555 | ""
1557 PARAMETER_TYPES ::=
1558   null
1559 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1561 TYPE_DESIGNATOR ::=
1562   subtype_NAME
1563 | subtype_Name ' Access
1565 MECHANISM ::=
1566   MECHANISM_NAME
1567 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1569 MECHANISM_ASSOCIATION ::=
1570   [formal_parameter_NAME =>] MECHANISM_NAME
1572 MECHANISM_NAME ::=
1573   Value
1574 | Reference
1575 @end smallexample
1577 @noindent
1578 Use this pragma to make a function externally callable and optionally
1579 provide information on mechanisms to be used for passing parameter and
1580 result values.  We recommend, for the purposes of improving portability,
1581 this pragma always be used in conjunction with a separate pragma
1582 @code{Export}, which must precede the pragma @code{Export_Function}.
1583 GNAT does not require a separate pragma @code{Export}, but if none is
1584 present, @code{Convention Ada} is assumed, which is usually
1585 not what is wanted, so it is usually appropriate to use this
1586 pragma in conjunction with a @code{Export} or @code{Convention}
1587 pragma that specifies the desired foreign convention.
1588 Pragma @code{Export_Function}
1589 (and @code{Export}, if present) must appear in the same declarative
1590 region as the function to which they apply.
1592 @var{internal_name} must uniquely designate the function to which the
1593 pragma applies.  If more than one function name exists of this name in
1594 the declarative part you must use the @code{Parameter_Types} and
1595 @code{Result_Type} parameters is mandatory to achieve the required
1596 unique designation.  @var{subtype_ mark}s in these parameters must
1597 exactly match the subtypes in the corresponding function specification,
1598 using positional notation to match parameters with subtype marks.
1599 The form with an @code{'Access} attribute can be used to match an
1600 anonymous access parameter.
1602 @cindex OpenVMS
1603 @cindex Passing by descriptor
1604 Note that passing by descriptor is not supported, even on the OpenVMS
1605 ports of GNAT@.
1607 @cindex Suppressing external name
1608 Special treatment is given if the EXTERNAL is an explicit null
1609 string or a static string expressions that evaluates to the null
1610 string. In this case, no external name is generated. This form
1611 still allows the specification of parameter mechanisms.
1613 @node Pragma Export_Object
1614 @unnumberedsec Pragma Export_Object
1615 @findex Export_Object
1616 @noindent
1617 Syntax:
1619 @smallexample @c ada
1620 pragma Export_Object
1621       [Internal =>] LOCAL_NAME,
1622    [, [External =>] EXTERNAL_SYMBOL]
1623    [, [Size     =>] EXTERNAL_SYMBOL]
1625 EXTERNAL_SYMBOL ::=
1626   IDENTIFIER
1627 | static_string_EXPRESSION
1628 @end smallexample
1630 @noindent
1631 This pragma designates an object as exported, and apart from the
1632 extended rules for external symbols, is identical in effect to the use of
1633 the normal @code{Export} pragma applied to an object.  You may use a
1634 separate Export pragma (and you probably should from the point of view
1635 of portability), but it is not required.  @var{Size} is syntax checked,
1636 but otherwise ignored by GNAT@.
1638 @node Pragma Export_Procedure
1639 @unnumberedsec Pragma Export_Procedure
1640 @findex Export_Procedure
1641 @noindent
1642 Syntax:
1644 @smallexample @c ada
1645 pragma Export_Procedure (
1646      [Internal        =>] LOCAL_NAME
1647   [, [External        =>] EXTERNAL_SYMBOL]
1648   [, [Parameter_Types =>] PARAMETER_TYPES]
1649   [, [Mechanism       =>] MECHANISM]);
1651 EXTERNAL_SYMBOL ::=
1652   IDENTIFIER
1653 | static_string_EXPRESSION
1654 | ""
1656 PARAMETER_TYPES ::=
1657   null
1658 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1660 TYPE_DESIGNATOR ::=
1661   subtype_NAME
1662 | subtype_Name ' Access
1664 MECHANISM ::=
1665   MECHANISM_NAME
1666 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1668 MECHANISM_ASSOCIATION ::=
1669   [formal_parameter_NAME =>] MECHANISM_NAME
1671 MECHANISM_NAME ::=
1672   Value
1673 | Reference
1674 @end smallexample
1676 @noindent
1677 This pragma is identical to @code{Export_Function} except that it
1678 applies to a procedure rather than a function and the parameters
1679 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
1680 GNAT does not require a separate pragma @code{Export}, but if none is
1681 present, @code{Convention Ada} is assumed, which is usually
1682 not what is wanted, so it is usually appropriate to use this
1683 pragma in conjunction with a @code{Export} or @code{Convention}
1684 pragma that specifies the desired foreign convention.
1686 @cindex OpenVMS
1687 @cindex Passing by descriptor
1688 Note that passing by descriptor is not supported, even on the OpenVMS
1689 ports of GNAT@.
1691 @cindex Suppressing external name
1692 Special treatment is given if the EXTERNAL is an explicit null
1693 string or a static string expressions that evaluates to the null
1694 string. In this case, no external name is generated. This form
1695 still allows the specification of parameter mechanisms.
1697 @node Pragma Export_Value
1698 @unnumberedsec Pragma Export_Value
1699 @findex Export_Value
1700 @noindent
1701 Syntax:
1703 @smallexample @c ada
1704 pragma Export_Value (
1705   [Value     =>] static_integer_EXPRESSION,
1706   [Link_Name =>] static_string_EXPRESSION);
1707 @end smallexample
1709 @noindent
1710 This pragma serves to export a static integer value for external use.
1711 The first argument specifies the value to be exported. The Link_Name
1712 argument specifies the symbolic name to be associated with the integer
1713 value. This pragma is useful for defining a named static value in Ada
1714 that can be referenced in assembly language units to be linked with
1715 the application. This pragma is currently supported only for the
1716 AAMP target and is ignored for other targets.
1718 @node Pragma Export_Valued_Procedure
1719 @unnumberedsec Pragma Export_Valued_Procedure
1720 @findex Export_Valued_Procedure
1721 @noindent
1722 Syntax:
1724 @smallexample @c ada
1725 pragma Export_Valued_Procedure (
1726      [Internal        =>] LOCAL_NAME
1727   [, [External        =>] EXTERNAL_SYMBOL]
1728   [, [Parameter_Types =>] PARAMETER_TYPES]
1729   [, [Mechanism       =>] MECHANISM]);
1731 EXTERNAL_SYMBOL ::=
1732   IDENTIFIER
1733 | static_string_EXPRESSION
1734 | ""
1736 PARAMETER_TYPES ::=
1737   null
1738 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1740 TYPE_DESIGNATOR ::=
1741   subtype_NAME
1742 | subtype_Name ' Access
1744 MECHANISM ::=
1745   MECHANISM_NAME
1746 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1748 MECHANISM_ASSOCIATION ::=
1749   [formal_parameter_NAME =>] MECHANISM_NAME
1751 MECHANISM_NAME ::=
1752   Value
1753 | Reference
1754 @end smallexample
1756 @noindent
1757 This pragma is identical to @code{Export_Procedure} except that the
1758 first parameter of @var{local_name}, which must be present, must be of
1759 mode @code{OUT}, and externally the subprogram is treated as a function
1760 with this parameter as the result of the function.  GNAT provides for
1761 this capability to allow the use of @code{OUT} and @code{IN OUT}
1762 parameters in interfacing to external functions (which are not permitted
1763 in Ada functions).
1764 GNAT does not require a separate pragma @code{Export}, but if none is
1765 present, @code{Convention Ada} is assumed, which is almost certainly
1766 not what is wanted since the whole point of this pragma is to interface
1767 with foreign language functions, so it is usually appropriate to use this
1768 pragma in conjunction with a @code{Export} or @code{Convention}
1769 pragma that specifies the desired foreign convention.
1771 @cindex OpenVMS
1772 @cindex Passing by descriptor
1773 Note that passing by descriptor is not supported, even on the OpenVMS
1774 ports of GNAT@.
1776 @cindex Suppressing external name
1777 Special treatment is given if the EXTERNAL is an explicit null
1778 string or a static string expressions that evaluates to the null
1779 string. In this case, no external name is generated. This form
1780 still allows the specification of parameter mechanisms.
1782 @node Pragma Extend_System
1783 @unnumberedsec Pragma Extend_System
1784 @cindex @code{system}, extending
1785 @cindex Dec Ada 83
1786 @findex Extend_System
1787 @noindent
1788 Syntax:
1790 @smallexample @c ada
1791 pragma Extend_System ([Name =>] IDENTIFIER);
1792 @end smallexample
1794 @noindent
1795 This pragma is used to provide backwards compatibility with other
1796 implementations that extend the facilities of package @code{System}.  In
1797 GNAT, @code{System} contains only the definitions that are present in
1798 the Ada 95 RM@.  However, other implementations, notably the DEC Ada 83
1799 implementation, provide many extensions to package @code{System}.
1801 For each such implementation accommodated by this pragma, GNAT provides a
1802 package @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83
1803 implementation, which provides the required additional definitions.  You
1804 can use this package in two ways.  You can @code{with} it in the normal
1805 way and access entities either by selection or using a @code{use}
1806 clause.  In this case no special processing is required.
1808 However, if existing code contains references such as
1809 @code{System.@var{xxx}} where @var{xxx} is an entity in the extended
1810 definitions provided in package @code{System}, you may use this pragma
1811 to extend visibility in @code{System} in a non-standard way that
1812 provides greater compatibility with the existing code.  Pragma
1813 @code{Extend_System} is a configuration pragma whose single argument is
1814 the name of the package containing the extended definition
1815 (e.g.@: @code{Aux_DEC} for the DEC Ada case).  A unit compiled under
1816 control of this pragma will be processed using special visibility
1817 processing that looks in package @code{System.Aux_@var{xxx}} where
1818 @code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
1819 package @code{System}, but not found in package @code{System}.
1821 You can use this pragma either to access a predefined @code{System}
1822 extension supplied with the compiler, for example @code{Aux_DEC} or
1823 you can construct your own extension unit following the above
1824 definition.  Note that such a package is a child of @code{System}
1825 and thus is considered part of the implementation.  To compile
1826 it you will have to use the appropriate switch for compiling
1827 system units.  See the GNAT User's Guide for details.
1829 @node Pragma External
1830 @unnumberedsec Pragma External
1831 @findex External
1832 @noindent
1833 Syntax:
1835 @smallexample @c ada
1836 pragma External (
1837   [   Convention    =>] convention_IDENTIFIER,
1838   [   Entity        =>] local_NAME
1839   [, [External_Name =>] static_string_EXPRESSION ]
1840   [, [Link_Name     =>] static_string_EXPRESSION ]);
1841 @end smallexample
1843 @noindent
1844 This pragma is identical in syntax and semantics to pragma
1845 @code{Export} as defined in the Ada Reference Manual.  It is
1846 provided for compatibility with some Ada 83 compilers that
1847 used this pragma for exactly the same purposes as pragma
1848 @code{Export} before the latter was standardized.
1850 @node Pragma External_Name_Casing
1851 @unnumberedsec Pragma External_Name_Casing
1852 @cindex Dec Ada 83 casing compatibility
1853 @cindex External Names, casing
1854 @cindex Casing of External names
1855 @findex External_Name_Casing
1856 @noindent
1857 Syntax:
1859 @smallexample @c ada
1860 pragma External_Name_Casing (
1861   Uppercase | Lowercase
1862   [, Uppercase | Lowercase | As_Is]);
1863 @end smallexample
1865 @noindent
1866 This pragma provides control over the casing of external names associated
1867 with Import and Export pragmas.  There are two cases to consider:
1869 @table @asis
1870 @item Implicit external names
1871 Implicit external names are derived from identifiers.  The most common case
1872 arises when a standard Ada 95 Import or Export pragma is used with only two
1873 arguments, as in:
1875 @smallexample @c ada
1876    pragma Import (C, C_Routine);
1877 @end smallexample
1879 @noindent
1880 Since Ada is a case insensitive language, the spelling of the identifier in
1881 the Ada source program does not provide any information on the desired
1882 casing of the external name, and so a convention is needed.  In GNAT the
1883 default treatment is that such names are converted to all lower case
1884 letters.  This corresponds to the normal C style in many environments.
1885 The first argument of pragma @code{External_Name_Casing} can be used to
1886 control this treatment.  If @code{Uppercase} is specified, then the name
1887 will be forced to all uppercase letters.  If @code{Lowercase} is specified,
1888 then the normal default of all lower case letters will be used.
1890 This same implicit treatment is also used in the case of extended DEC Ada 83
1891 compatible Import and Export pragmas where an external name is explicitly
1892 specified using an identifier rather than a string.
1894 @item Explicit external names
1895 Explicit external names are given as string literals.  The most common case
1896 arises when a standard Ada 95 Import or Export pragma is used with three
1897 arguments, as in:
1899 @smallexample @c ada
1900 pragma Import (C, C_Routine, "C_routine");
1901 @end smallexample
1903 @noindent
1904 In this case, the string literal normally provides the exact casing required
1905 for the external name.  The second argument of pragma
1906 @code{External_Name_Casing} may be used to modify this behavior.
1907 If @code{Uppercase} is specified, then the name
1908 will be forced to all uppercase letters.  If @code{Lowercase} is specified,
1909 then the name will be forced to all lowercase letters.  A specification of
1910 @code{As_Is} provides the normal default behavior in which the casing is
1911 taken from the string provided.
1912 @end table
1914 @noindent
1915 This pragma may appear anywhere that a pragma is valid.  In particular, it
1916 can be used as a configuration pragma in the @file{gnat.adc} file, in which
1917 case it applies to all subsequent compilations, or it can be used as a program
1918 unit pragma, in which case it only applies to the current unit, or it can
1919 be used more locally to control individual Import/Export pragmas.
1921 It is primarily intended for use with OpenVMS systems, where many
1922 compilers convert all symbols to upper case by default.  For interfacing to
1923 such compilers (e.g.@: the DEC C compiler), it may be convenient to use
1924 the pragma:
1926 @smallexample @c ada
1927 pragma External_Name_Casing (Uppercase, Uppercase);
1928 @end smallexample
1930 @noindent
1931 to enforce the upper casing of all external symbols.
1933 @node Pragma Finalize_Storage_Only
1934 @unnumberedsec Pragma Finalize_Storage_Only
1935 @findex Finalize_Storage_Only
1936 @noindent
1937 Syntax:
1939 @smallexample @c ada
1940 pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
1941 @end smallexample
1943 @noindent
1944 This pragma allows the compiler not to emit a Finalize call for objects
1945 defined at the library level.  This is mostly useful for types where
1946 finalization is only used to deal with storage reclamation since in most
1947 environments it is not necessary to reclaim memory just before terminating
1948 execution, hence the name.
1950 @node Pragma Float_Representation
1951 @unnumberedsec Pragma Float_Representation
1952 @cindex OpenVMS
1953 @findex Float_Representation
1954 @noindent
1955 Syntax:
1957 @smallexample @c ada
1958 pragma Float_Representation (FLOAT_REP);
1960 FLOAT_REP ::= VAX_Float | IEEE_Float
1961 @end smallexample
1963 @noindent
1964 This pragma
1965 allows control over the internal representation chosen for the predefined
1966 floating point types declared in the packages @code{Standard} and
1967 @code{System}. On all systems other than OpenVMS, the argument must
1968 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
1969 argument may be @code{VAX_Float} to specify the use of the VAX float
1970 format for the floating-point types in Standard. This requires that
1971 the standard runtime libraries be recompiled. See the
1972 description of the @code{GNAT LIBRARY} command in the OpenVMS version
1973 of the GNAT Users Guide for details on the use of this command.
1975 @node Pragma Ident
1976 @unnumberedsec Pragma Ident
1977 @findex Ident
1978 @noindent
1979 Syntax:
1981 @smallexample @c ada
1982 pragma Ident (static_string_EXPRESSION);
1983 @end smallexample
1985 @noindent
1986 This pragma provides a string identification in the generated object file,
1987 if the system supports the concept of this kind of identification string.
1988 This pragma is allowed only in the outermost declarative part or
1989 declarative items of a compilation unit. If more than one @code{Ident}
1990 pragma is given, only the last one processed is effective.
1991 @cindex OpenVMS
1992 On OpenVMS systems, the effect of the pragma is identical to the effect of
1993 the DEC Ada 83 pragma of the same name. Note that in DEC Ada 83, the
1994 maximum allowed length is 31 characters, so if it is important to
1995 maintain compatibility with this compiler, you should obey this length
1996 limit.
1998 @node Pragma Import_Exception
1999 @unnumberedsec Pragma Import_Exception
2000 @cindex OpenVMS
2001 @findex Import_Exception
2002 @noindent
2003 Syntax:
2005 @smallexample @c ada
2006 pragma Import_Exception (
2007      [Internal =>] LOCAL_NAME,
2008   [, [External =>] EXTERNAL_SYMBOL,]
2009   [, [Form     =>] Ada | VMS]
2010   [, [Code     =>] static_integer_EXPRESSION]);
2012 EXTERNAL_SYMBOL ::=
2013   IDENTIFIER
2014 | static_string_EXPRESSION
2015 @end smallexample
2017 @noindent
2018 This pragma is implemented only in the OpenVMS implementation of GNAT@.
2019 It allows OpenVMS conditions (for example, from OpenVMS system services or
2020 other OpenVMS languages) to be propagated to Ada programs as Ada exceptions.
2021 The pragma specifies that the exception associated with an exception
2022 declaration in an Ada program be defined externally (in non-Ada code).
2023 For further details on this pragma, see the
2024 DEC Ada Language Reference Manual, section 13.9a.3.1.
2026 @node Pragma Import_Function
2027 @unnumberedsec Pragma Import_Function
2028 @findex Import_Function
2029 @noindent
2030 Syntax:
2032 @smallexample @c ada
2033 pragma Import_Function (
2034      [Internal                 =>] LOCAL_NAME,
2035   [, [External                 =>] EXTERNAL_SYMBOL]
2036   [, [Parameter_Types          =>] PARAMETER_TYPES]
2037   [, [Result_Type              =>] SUBTYPE_MARK]
2038   [, [Mechanism                =>] MECHANISM]
2039   [, [Result_Mechanism         =>] MECHANISM_NAME]
2040   [, [First_Optional_Parameter =>] IDENTIFIER]);
2042 EXTERNAL_SYMBOL ::=
2043   IDENTIFIER
2044 | static_string_EXPRESSION
2046 PARAMETER_TYPES ::=
2047   null
2048 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2050 TYPE_DESIGNATOR ::=
2051   subtype_NAME
2052 | subtype_Name ' Access
2054 MECHANISM ::=
2055   MECHANISM_NAME
2056 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2058 MECHANISM_ASSOCIATION ::=
2059   [formal_parameter_NAME =>] MECHANISM_NAME
2061 MECHANISM_NAME ::=
2062   Value
2063 | Reference
2064 | Descriptor [([Class =>] CLASS_NAME)]
2066 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2067 @end smallexample
2069 @noindent
2070 This pragma is used in conjunction with a pragma @code{Import} to
2071 specify additional information for an imported function.  The pragma
2072 @code{Import} (or equivalent pragma @code{Interface}) must precede the
2073 @code{Import_Function} pragma and both must appear in the same
2074 declarative part as the function specification.
2076 The @var{Internal} argument must uniquely designate
2077 the function to which the
2078 pragma applies.  If more than one function name exists of this name in
2079 the declarative part you must use the @code{Parameter_Types} and
2080 @var{Result_Type} parameters to achieve the required unique
2081 designation.  Subtype marks in these parameters must exactly match the
2082 subtypes in the corresponding function specification, using positional
2083 notation to match parameters with subtype marks.
2084 The form with an @code{'Access} attribute can be used to match an
2085 anonymous access parameter.
2087 You may optionally use the @var{Mechanism} and @var{Result_Mechanism}
2088 parameters to specify passing mechanisms for the
2089 parameters and result.  If you specify a single mechanism name, it
2090 applies to all parameters.  Otherwise you may specify a mechanism on a
2091 parameter by parameter basis using either positional or named
2092 notation.  If the mechanism is not specified, the default mechanism
2093 is used.
2095 @cindex OpenVMS
2096 @cindex Passing by descriptor
2097 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2099 @code{First_Optional_Parameter} applies only to OpenVMS ports of GNAT@.
2100 It specifies that the designated parameter and all following parameters
2101 are optional, meaning that they are not passed at the generated code
2102 level (this is distinct from the notion of optional parameters in Ada
2103 where the parameters are passed anyway with the designated optional
2104 parameters).  All optional parameters must be of mode @code{IN} and have
2105 default parameter values that are either known at compile time
2106 expressions, or uses of the @code{'Null_Parameter} attribute.
2108 @node Pragma Import_Object
2109 @unnumberedsec Pragma Import_Object
2110 @findex Import_Object
2111 @noindent
2112 Syntax:
2114 @smallexample @c ada
2115 pragma Import_Object
2116      [Internal =>] LOCAL_NAME,
2117   [, [External =>] EXTERNAL_SYMBOL],
2118   [, [Size     =>] EXTERNAL_SYMBOL]);
2120 EXTERNAL_SYMBOL ::=
2121   IDENTIFIER
2122 | static_string_EXPRESSION
2123 @end smallexample
2125 @noindent
2126 This pragma designates an object as imported, and apart from the
2127 extended rules for external symbols, is identical in effect to the use of
2128 the normal @code{Import} pragma applied to an object.  Unlike the
2129 subprogram case, you need not use a separate @code{Import} pragma,
2130 although you may do so (and probably should do so from a portability
2131 point of view).  @var{size} is syntax checked, but otherwise ignored by
2132 GNAT@.
2134 @node Pragma Import_Procedure
2135 @unnumberedsec Pragma Import_Procedure
2136 @findex Import_Procedure
2137 @noindent
2138 Syntax:
2140 @smallexample @c ada
2141 pragma Import_Procedure (
2142      [Internal                 =>] LOCAL_NAME,
2143   [, [External                 =>] EXTERNAL_SYMBOL]
2144   [, [Parameter_Types          =>] PARAMETER_TYPES]
2145   [, [Mechanism                =>] MECHANISM]
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 identical to @code{Import_Function} except that it
2177 applies to a procedure rather than a function and the parameters
2178 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2180 @node Pragma Import_Valued_Procedure
2181 @unnumberedsec Pragma Import_Valued_Procedure
2182 @findex Import_Valued_Procedure
2183 @noindent
2184 Syntax:
2186 @smallexample @c ada
2187 pragma Import_Valued_Procedure (
2188      [Internal                 =>] LOCAL_NAME,
2189   [, [External                 =>] EXTERNAL_SYMBOL]
2190   [, [Parameter_Types          =>] PARAMETER_TYPES]
2191   [, [Mechanism                =>] MECHANISM]
2192   [, [First_Optional_Parameter =>] IDENTIFIER]);
2194 EXTERNAL_SYMBOL ::=
2195   IDENTIFIER
2196 | static_string_EXPRESSION
2198 PARAMETER_TYPES ::=
2199   null
2200 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2202 TYPE_DESIGNATOR ::=
2203   subtype_NAME
2204 | subtype_Name ' Access
2206 MECHANISM ::=
2207   MECHANISM_NAME
2208 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2210 MECHANISM_ASSOCIATION ::=
2211   [formal_parameter_NAME =>] MECHANISM_NAME
2213 MECHANISM_NAME ::=
2214   Value
2215 | Reference
2216 | Descriptor [([Class =>] CLASS_NAME)]
2218 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2219 @end smallexample
2221 @noindent
2222 This pragma is identical to @code{Import_Procedure} except that the
2223 first parameter of @var{local_name}, which must be present, must be of
2224 mode @code{OUT}, and externally the subprogram is treated as a function
2225 with this parameter as the result of the function.  The purpose of this
2226 capability is to allow the use of @code{OUT} and @code{IN OUT}
2227 parameters in interfacing to external functions (which are not permitted
2228 in Ada functions).  You may optionally use the @code{Mechanism}
2229 parameters to specify passing mechanisms for the parameters.
2230 If you specify a single mechanism name, it applies to all parameters.
2231 Otherwise you may specify a mechanism on a parameter by parameter
2232 basis using either positional or named notation.  If the mechanism is not
2233 specified, the default mechanism is used.
2235 Note that it is important to use this pragma in conjunction with a separate
2236 pragma Import that specifies the desired convention, since otherwise the
2237 default convention is Ada, which is almost certainly not what is required.
2239 @node Pragma Initialize_Scalars
2240 @unnumberedsec Pragma Initialize_Scalars
2241 @findex Initialize_Scalars
2242 @cindex debugging with Initialize_Scalars
2243 @noindent
2244 Syntax:
2246 @smallexample @c ada
2247 pragma Initialize_Scalars;
2248 @end smallexample
2250 @noindent
2251 This pragma is similar to @code{Normalize_Scalars} conceptually but has
2252 two important differences.  First, there is no requirement for the pragma
2253 to be used uniformly in all units of a partition, in particular, it is fine
2254 to use this just for some or all of the application units of a partition,
2255 without needing to recompile the run-time library.
2257 In the case where some units are compiled with the pragma, and some without,
2258 then a declaration of a variable where the type is defined in package
2259 Standard or is locally declared will always be subject to initialization,
2260 as will any declaration of a scalar variable.  For composite variables,
2261 whether the variable is initialized may also depend on whether the package
2262 in which the type of the variable is declared is compiled with the pragma.
2264 The other important difference is that you can control the value used
2265 for initializing scalar objects.  At bind time, you can select several
2266 options for initialization. You can
2267 initialize with invalid values (similar to Normalize_Scalars, though for
2268 Initialize_Scalars it is not always possible to determine the invalid
2269 values in complex cases like signed component fields with non-standard
2270 sizes). You can also initialize with high or
2271 low values, or with a specified bit pattern.  See the users guide for binder
2272 options for specifying these cases.
2274 This means that you can compile a program, and then without having to
2275 recompile the program, you can run it with different values being used
2276 for initializing otherwise uninitialized values, to test if your program
2277 behavior depends on the choice.  Of course the behavior should not change,
2278 and if it does, then most likely you have an erroneous reference to an
2279 uninitialized value.
2281 It is even possible to change the value at execution time eliminating even
2282 the need to rebind with a different switch using an environment variable.
2283 See the GNAT users guide for details.
2285 Note that pragma @code{Initialize_Scalars} is particularly useful in
2286 conjunction with the enhanced validity checking that is now provided
2287 in GNAT, which checks for invalid values under more conditions.
2288 Using this feature (see description of the @code{-gnatV} flag in the
2289 users guide) in conjunction with pragma @code{Initialize_Scalars}
2290 provides a powerful new tool to assist in the detection of problems
2291 caused by uninitialized variables.
2293 Note: the use of @code{Initialize_Scalars} has a fairly extensive
2294 effect on the generated code. This may cause your code to be
2295 substantially larger. It may also cause an increase in the amount
2296 of stack required, so it is probably a good idea to turn on stack
2297 checking (see description of stack checking in the GNAT users guide)
2298 when using this pragma.
2300 @node Pragma Inline_Always
2301 @unnumberedsec Pragma Inline_Always
2302 @findex Inline_Always
2303 @noindent
2304 Syntax:
2306 @smallexample @c ada
2307 pragma Inline_Always (NAME [, NAME]);
2308 @end smallexample
2310 @noindent
2311 Similar to pragma @code{Inline} except that inlining is not subject to
2312 the use of option @code{-gnatn} and the inlining happens regardless of
2313 whether this option is used.
2315 @node Pragma Inline_Generic
2316 @unnumberedsec Pragma Inline_Generic
2317 @findex Inline_Generic
2318 @noindent
2319 Syntax:
2321 @smallexample @c ada
2322 pragma Inline_Generic (generic_package_NAME);
2323 @end smallexample
2325 @noindent
2326 This is implemented for compatibility with DEC Ada 83 and is recognized,
2327 but otherwise ignored, by GNAT@.  All generic instantiations are inlined
2328 by default when using GNAT@.
2330 @node Pragma Interface
2331 @unnumberedsec Pragma Interface
2332 @findex Interface
2333 @noindent
2334 Syntax:
2336 @smallexample @c ada
2337 pragma Interface (
2338      [Convention    =>] convention_identifier,
2339      [Entity =>] local_name
2340   [, [External_Name =>] static_string_expression],
2341   [, [Link_Name     =>] static_string_expression]);
2342 @end smallexample
2344 @noindent
2345 This pragma is identical in syntax and semantics to
2346 the standard Ada 95 pragma @code{Import}.  It is provided for compatibility
2347 with Ada 83.  The definition is upwards compatible both with pragma
2348 @code{Interface} as defined in the Ada 83 Reference Manual, and also
2349 with some extended implementations of this pragma in certain Ada 83
2350 implementations.
2352 @node Pragma Interface_Name
2353 @unnumberedsec Pragma Interface_Name
2354 @findex Interface_Name
2355 @noindent
2356 Syntax:
2358 @smallexample @c ada
2359 pragma Interface_Name (
2360      [Entity        =>] LOCAL_NAME
2361   [, [External_Name =>] static_string_EXPRESSION]
2362   [, [Link_Name     =>] static_string_EXPRESSION]);
2363 @end smallexample
2365 @noindent
2366 This pragma provides an alternative way of specifying the interface name
2367 for an interfaced subprogram, and is provided for compatibility with Ada
2368 83 compilers that use the pragma for this purpose.  You must provide at
2369 least one of @var{External_Name} or @var{Link_Name}.
2371 @node Pragma Interrupt_Handler
2372 @unnumberedsec Pragma Interrupt_Handler
2373 @findex Interrupt_Handler
2374 @noindent
2375 Syntax:
2377 @smallexample @c ada
2378 pragma Interrupt_Handler (procedure_LOCAL_NAME);
2379 @end smallexample
2381 @noindent
2382 This program unit pragma is supported for parameterless protected procedures
2383 as described in Annex C of the Ada Reference Manual. On the AAMP target
2384 the pragma can also be specified for nonprotected parameterless procedures
2385 that are declared at the library level (which includes procedures
2386 declared at the top level of a library package). In the case of AAMP,
2387 when this pragma is applied to a nonprotected procedure, the instruction
2388 @code{IERET} is generated for returns from the procedure, enabling
2389 maskable interrupts, in place of the normal return instruction.
2391 @node Pragma Interrupt_State
2392 @unnumberedsec Pragma Interrupt_State
2393 @findex Interrupt_State
2394 @noindent
2395 Syntax:
2397 @smallexample @c ada
2398 pragma Interrupt_State (Name => value, State => SYSTEM | RUNTIME | USER);
2399 @end smallexample
2401 @noindent
2402 Normally certain interrupts are reserved to the implementation.  Any attempt
2403 to attach an interrupt causes Program_Error to be raised, as described in
2404 RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
2405 many systems for an @kbd{Ctrl-C} interrupt.  Normally this interrupt is
2406 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
2407 interrupt execution.  Additionally, signals such as @code{SIGSEGV},
2408 @code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
2409 Ada exceptions, or used to implement run-time functions such as the
2410 @code{abort} statement and stack overflow checking.
2412 Pragma @code{Interrupt_State} provides a general mechanism for overriding
2413 such uses of interrupts.  It subsumes the functionality of pragma
2414 @code{Unreserve_All_Interrupts}.  Pragma @code{Interrupt_State} is not
2415 available on OS/2, Windows or VMS.  On all other platforms than VxWorks,
2416 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
2417 and may be used to mark interrupts required by the board support package
2418 as reserved.
2420 Interrupts can be in one of three states:
2421 @itemize @bullet
2422 @item System
2424 The interrupt is reserved (no Ada handler can be installed), and the
2425 Ada run-time may not install a handler. As a result you are guaranteed
2426 standard system default action if this interrupt is raised.
2428 @item Runtime
2430 The interrupt is reserved (no Ada handler can be installed). The run time
2431 is allowed to install a handler for internal control purposes, but is
2432 not required to do so.
2434 @item User
2436 The interrupt is unreserved.  The user may install a handler to provide
2437 some other action.
2438 @end itemize
2440 @noindent
2441 These states are the allowed values of the @code{State} parameter of the
2442 pragma.  The @code{Name} parameter is a value of the type
2443 @code{Ada.Interrupts.Interrupt_ID}.  Typically, it is a name declared in
2444 @code{Ada.Interrupts.Names}.
2446 This is a configuration pragma, and the binder will check that there
2447 are no inconsistencies between different units in a partition in how a
2448 given interrupt is specified. It may appear anywhere a pragma is legal.
2450 The effect is to move the interrupt to the specified state.
2452 By declaring interrupts to be SYSTEM, you guarantee the standard system
2453 action, such as a core dump.
2455 By declaring interrupts to be USER, you guarantee that you can install
2456 a handler.
2458 Note that certain signals on many operating systems cannot be caught and
2459 handled by applications.  In such cases, the pragma is ignored.  See the
2460 operating system documentation, or the value of the array @code{Reserved}
2461 declared in the specification of package @code{System.OS_Interface}.
2463 Overriding the default state of signals used by the Ada runtime may interfere
2464 with an application's runtime behavior in the cases of the synchronous signals,
2465 and in the case of the signal used to implement the @code{abort} statement.
2467 @node Pragma Keep_Names
2468 @unnumberedsec Pragma Keep_Names
2469 @findex Keep_Names
2470 @noindent
2471 Syntax:
2473 @smallexample @c ada
2474 pragma Keep_Names ([On =>] enumeration_first_subtype_LOCAL_NAME);
2475 @end smallexample
2477 @noindent
2478 The @var{LOCAL_NAME} argument
2479 must refer to an enumeration first subtype
2480 in the current declarative part. The effect is to retain the enumeration
2481 literal names for use by @code{Image} and @code{Value} even if a global
2482 @code{Discard_Names} pragma applies. This is useful when you want to
2483 generally suppress enumeration literal names and for example you therefore
2484 use a @code{Discard_Names} pragma in the @file{gnat.adc} file, but you
2485 want to retain the names for specific enumeration types.
2487 @node Pragma License
2488 @unnumberedsec Pragma License
2489 @findex License
2490 @cindex License checking
2491 @noindent
2492 Syntax:
2494 @smallexample @c ada
2495 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
2496 @end smallexample
2498 @noindent
2499 This pragma is provided to allow automated checking for appropriate license
2500 conditions with respect to the standard and modified GPL@.  A pragma
2501 @code{License}, which is a configuration pragma that typically appears at
2502 the start of a source file or in a separate @file{gnat.adc} file, specifies
2503 the licensing conditions of a unit as follows:
2505 @itemize @bullet
2506 @item Unrestricted
2507 This is used for a unit that can be freely used with no license restrictions.
2508 Examples of such units are public domain units, and units from the Ada
2509 Reference Manual.
2511 @item GPL
2512 This is used for a unit that is licensed under the unmodified GPL, and which
2513 therefore cannot be @code{with}'ed by a restricted unit.
2515 @item Modified_GPL
2516 This is used for a unit licensed under the GNAT modified GPL that includes
2517 a special exception paragraph that specifically permits the inclusion of
2518 the unit in programs without requiring the entire program to be released
2519 under the GPL@.  This is the license used for the GNAT run-time which ensures
2520 that the run-time can be used freely in any program without GPL concerns.
2522 @item Restricted
2523 This is used for a unit that is restricted in that it is not permitted to
2524 depend on units that are licensed under the GPL@.  Typical examples are
2525 proprietary code that is to be released under more restrictive license
2526 conditions.  Note that restricted units are permitted to @code{with} units
2527 which are licensed under the modified GPL (this is the whole point of the
2528 modified GPL).
2530 @end itemize
2532 @noindent
2533 Normally a unit with no @code{License} pragma is considered to have an
2534 unknown license, and no checking is done.  However, standard GNAT headers
2535 are recognized, and license information is derived from them as follows.
2537 @itemize @bullet
2539 A GNAT license header starts with a line containing 78 hyphens.  The following
2540 comment text is searched for the appearance of any of the following strings.
2542 If the string ``GNU General Public License'' is found, then the unit is assumed
2543 to have GPL license, unless the string ``As a special exception'' follows, in
2544 which case the license is assumed to be modified GPL@.
2546 If one of the strings
2547 ``This specification is adapted from the Ada Semantic Interface'' or
2548 ``This specification is derived from the Ada Reference Manual'' is found
2549 then the unit is assumed to be unrestricted.
2550 @end itemize
2552 @noindent
2553 These default actions means that a program with a restricted license pragma
2554 will automatically get warnings if a GPL unit is inappropriately
2555 @code{with}'ed.  For example, the program:
2557 @smallexample @c ada
2558 with Sem_Ch3;
2559 with GNAT.Sockets;
2560 procedure Secret_Stuff is
2561   @dots{}
2562 end Secret_Stuff
2563 @end smallexample
2565 @noindent
2566 if compiled with pragma @code{License} (@code{Restricted}) in a
2567 @file{gnat.adc} file will generate the warning:
2569 @smallexample
2570 1.  with Sem_Ch3;
2571         |
2572    >>> license of withed unit "Sem_Ch3" is incompatible
2574 2.  with GNAT.Sockets;
2575 3.  procedure Secret_Stuff is
2576 @end smallexample
2578 @noindent
2579 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
2580 compiler and is licensed under the
2581 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
2582 run time, and is therefore licensed under the modified GPL@.
2584 @node Pragma Link_With
2585 @unnumberedsec Pragma Link_With
2586 @findex Link_With
2587 @noindent
2588 Syntax:
2590 @smallexample @c ada
2591 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
2592 @end smallexample
2594 @noindent
2595 This pragma is provided for compatibility with certain Ada 83 compilers.
2596 It has exactly the same effect as pragma @code{Linker_Options} except
2597 that spaces occurring within one of the string expressions are treated
2598 as separators. For example, in the following case:
2600 @smallexample @c ada
2601 pragma Link_With ("-labc -ldef");
2602 @end smallexample
2604 @noindent
2605 results in passing the strings @code{-labc} and @code{-ldef} as two
2606 separate arguments to the linker. In addition pragma Link_With allows
2607 multiple arguments, with the same effect as successive pragmas.
2609 @node Pragma Linker_Alias
2610 @unnumberedsec Pragma Linker_Alias
2611 @findex Linker_Alias
2612 @noindent
2613 Syntax:
2615 @smallexample @c ada
2616 pragma Linker_Alias (
2617   [Entity =>] LOCAL_NAME
2618   [Alias  =>] static_string_EXPRESSION);
2619 @end smallexample
2621 @noindent
2622 This pragma establishes a linker alias for the given named entity.  For
2623 further details on the exact effect, consult the GCC manual.
2625 @node Pragma Linker_Section
2626 @unnumberedsec Pragma Linker_Section
2627 @findex Linker_Section
2628 @noindent
2629 Syntax:
2631 @smallexample @c ada
2632 pragma Linker_Section (
2633   [Entity  =>] LOCAL_NAME
2634   [Section =>] static_string_EXPRESSION);
2635 @end smallexample
2637 @noindent
2638 This pragma specifies the name of the linker section for the given entity.
2639 For further details on the exact effect, consult the GCC manual.
2641 @node Pragma Long_Float
2642 @unnumberedsec Pragma Long_Float
2643 @cindex OpenVMS
2644 @findex Long_Float
2645 @noindent
2646 Syntax:
2648 @smallexample @c ada
2649 pragma Long_Float (FLOAT_FORMAT);
2651 FLOAT_FORMAT ::= D_Float | G_Float
2652 @end smallexample
2654 @noindent
2655 This pragma is implemented only in the OpenVMS implementation of GNAT@.
2656 It allows control over the internal representation chosen for the predefined
2657 type @code{Long_Float} and for floating point type representations with
2658 @code{digits} specified in the range 7 through 15.
2659 For further details on this pragma, see the
2660 @cite{DEC Ada Language Reference Manual}, section 3.5.7b.  Note that to use
2661 this pragma, the standard runtime libraries must be recompiled.  See the
2662 description of the @code{GNAT LIBRARY} command in the OpenVMS version
2663 of the GNAT User's Guide for details on the use of this command.
2665 @node Pragma Machine_Attribute
2666 @unnumberedsec Pragma Machine_Attribute
2667 @findex Machine_Attribute
2668 @noindent
2669 Syntax:
2671 @smallexample @c ada
2672 pragma Machine_Attribute (
2673   [Attribute_Name =>] string_EXPRESSION,
2674   [Entity         =>] LOCAL_NAME);
2675 @end smallexample
2677 @noindent
2678 Machine dependent attributes can be specified for types and/or
2679 declarations.  Currently only subprogram entities are supported.  This
2680 pragma is semantically equivalent to
2681 @code{__attribute__((@var{string_expression}))} in GNU C,
2682 where @code{@var{string_expression}} is
2683 recognized by the GNU C macros @code{VALID_MACHINE_TYPE_ATTRIBUTE} and
2684 @code{VALID_MACHINE_DECL_ATTRIBUTE} which are defined in the
2685 configuration header file @file{tm.h} for each machine.  See the GCC
2686 manual for further information.
2688 @node Pragma Main_Storage
2689 @unnumberedsec Pragma Main_Storage
2690 @cindex OpenVMS
2691 @findex Main_Storage
2692 @noindent
2693 Syntax:
2695 @smallexample @c ada
2696 pragma Main_Storage
2697   (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
2699 MAIN_STORAGE_OPTION ::=
2700   [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
2701 | [TOP_GUARD       =>] static_SIMPLE_EXPRESSION
2703 @end smallexample
2705 @noindent
2706 This pragma is provided for compatibility with OpenVMS VAX Systems.  It has
2707 no effect in GNAT, other than being syntax checked.  Note that the pragma
2708 also has no effect in DEC Ada 83 for OpenVMS Alpha Systems.
2710 @node Pragma No_Return
2711 @unnumberedsec Pragma No_Return
2712 @findex No_Return
2713 @noindent
2714 Syntax:
2716 @smallexample @c ada
2717 pragma No_Return (procedure_LOCAL_NAME);
2718 @end smallexample
2720 @noindent
2721 @var{procedure_local_NAME} must refer to one or more procedure
2722 declarations in the current declarative part.  A procedure to which this
2723 pragma is applied may not contain any explicit @code{return} statements,
2724 and also may not contain any implicit return statements from falling off
2725 the end of a statement sequence.  One use of this pragma is to identify
2726 procedures whose only purpose is to raise an exception.
2728 Another use of this pragma is to suppress incorrect warnings about
2729 missing returns in functions, where the last statement of a function
2730 statement sequence is a call to such a procedure.
2732 @node Pragma Normalize_Scalars
2733 @unnumberedsec Pragma Normalize_Scalars
2734 @findex Normalize_Scalars
2735 @noindent
2736 Syntax:
2738 @smallexample @c ada
2739 pragma Normalize_Scalars;
2740 @end smallexample
2742 @noindent
2743 This is a language defined pragma which is fully implemented in GNAT@.  The
2744 effect is to cause all scalar objects that are not otherwise initialized
2745 to be initialized.  The initial values are implementation dependent and
2746 are as follows:
2748 @table @code
2749 @item Standard.Character
2750 @noindent
2751 Objects whose root type is Standard.Character are initialized to
2752 Character'Last unless the subtype range excludes NUL (in which case
2753 NUL is used). This choice will always generate an invalid value if
2754 one exists.
2756 @item Standard.Wide_Character
2757 @noindent
2758 Objects whose root type is Standard.Wide_Character are initialized to
2759 Wide_Character'Last unless the subtype range excludes NUL (in which case
2760 NUL is used). This choice will always generate an invalid value if
2761 one exists.
2763 @item Standard.Wide_Wide_Character
2764 @noindent
2765 Objects whose root type is Standard.Wide_Wide_Character are initialized to
2766 the invalid value 16#FFFF_FFFF# unless the subtype range excludes NUL (in
2767 which case NUL is used). This choice will always generate an invalid value if
2768 one exists.
2770 @item Integer types
2771 @noindent
2772 Objects of an integer type are treated differently depending on whether
2773 negative values are present in the subtype. If no negative values are
2774 present, then all one bits is used as the initial value except in the
2775 special case where zero is excluded from the subtype, in which case
2776 all zero bits are used. This choice will always generate an invalid
2777 value if one exists.
2779 For subtypes with negative values present, the largest negative number
2780 is used, except in the unusual case where this largest negative number
2781 is in the subtype, and the largest positive number is not, in which case
2782 the largest positive value is used. This choice will always generate
2783 an invalid value if one exists.
2785 @item Floating-Point Types
2786 Objects of all floating-point types are initialized to all 1-bits. For
2787 standard IEEE format, this corresponds to a NaN (not a number) which is
2788 indeed an invalid value.
2790 @item Fixed-Point Types
2791 Objects of all fixed-point types are treated as described above for integers,
2792 with the rules applying to the underlying integer value used to represent
2793 the fixed-point value.
2795 @item Modular types
2796 Objects of a modular type are initialized to all one bits, except in
2797 the special case where zero is excluded from the subtype, in which
2798 case all zero bits are used. This choice will always generate an
2799 invalid value if one exists.
2801 @item Enumeration types
2802 Objects of an enumeration type are initialized to all one-bits, i.e.@: to
2803 the value @code{2 ** typ'Size - 1} unless the subtype excludes the literal
2804 whose Pos value is zero, in which case a code of zero is used. This choice
2805 will always generate an invalid value if one exists.
2807 @end table
2809 @node Pragma Obsolescent
2810 @unnumberedsec Pragma Obsolescent
2811 @findex Obsolescent
2812 @noindent
2813 Syntax:
2815 @smallexample @c ada
2816 pragma Obsolescent [(static_string_EXPRESSION)];
2817 @end smallexample
2819 @noindent
2820 This pragma must occur immediately following a subprogram
2821 declaration. It indicates that the associated function or procedure
2822 is considered obsolescent and should not be used. Typically this is
2823 used when an API must be modified by eventually removing or modifying
2824 existing subprograms. The pragma can be used at an intermediate stage
2825 when the subprogram is still present, but will be removed later.
2827 The effect of this pragma is to output a warning message that the
2828 subprogram is obsolescent if the appropriate warning option in the
2829 compiler is activated. If a parameter is present, then a second
2830 warning message is given containing this text.
2832 @node Pragma Passive
2833 @unnumberedsec Pragma Passive
2834 @findex Passive
2835 @noindent
2836 Syntax:
2838 @smallexample @c ada
2839 pragma Passive ([Semaphore | No]);
2840 @end smallexample
2842 @noindent
2843 Syntax checked, but otherwise ignored by GNAT@.  This is recognized for
2844 compatibility with DEC Ada 83 implementations, where it is used within a
2845 task definition to request that a task be made passive.  If the argument
2846 @code{Semaphore} is present, or the argument is omitted, then DEC Ada 83
2847 treats the pragma as an assertion that the containing task is passive
2848 and that optimization of context switch with this task is permitted and
2849 desired.  If the argument @code{No} is present, the task must not be
2850 optimized.  GNAT does not attempt to optimize any tasks in this manner
2851 (since protected objects are available in place of passive tasks).
2853 @node Pragma Polling
2854 @unnumberedsec Pragma Polling
2855 @findex Polling
2856 @noindent
2857 Syntax:
2859 @smallexample @c ada
2860 pragma Polling (ON | OFF);
2861 @end smallexample
2863 @noindent
2864 This pragma controls the generation of polling code.  This is normally off.
2865 If @code{pragma Polling (ON)} is used then periodic calls are generated to
2866 the routine @code{Ada.Exceptions.Poll}.  This routine is a separate unit in the
2867 runtime library, and can be found in file @file{a-excpol.adb}.
2869 Pragma @code{Polling} can appear as a configuration pragma (for example it
2870 can be placed in the @file{gnat.adc} file) to enable polling globally, or it
2871 can be used in the statement or declaration sequence to control polling
2872 more locally.
2874 A call to the polling routine is generated at the start of every loop and
2875 at the start of every subprogram call.  This guarantees that the @code{Poll}
2876 routine is called frequently, and places an upper bound (determined by
2877 the complexity of the code) on the period between two @code{Poll} calls.
2879 The primary purpose of the polling interface is to enable asynchronous
2880 aborts on targets that cannot otherwise support it (for example Windows
2881 NT), but it may be used for any other purpose requiring periodic polling.
2882 The standard version is null, and can be replaced by a user program.  This
2883 will require re-compilation of the @code{Ada.Exceptions} package that can
2884 be found in files @file{a-except.ads} and @file{a-except.adb}.
2886 A standard alternative unit (in file @file{4wexcpol.adb} in the standard GNAT
2887 distribution) is used to enable the asynchronous abort capability on
2888 targets that do not normally support the capability.  The version of
2889 @code{Poll} in this file makes a call to the appropriate runtime routine
2890 to test for an abort condition.
2892 Note that polling can also be enabled by use of the @code{-gnatP} switch.  See
2893 the @cite{GNAT User's Guide} for details.
2895 @node Pragma Profile (Ravenscar)
2896 @unnumberedsec Pragma Profile (Ravenscar)
2897 @findex Ravenscar
2898 @noindent
2899 Syntax:
2901 @smallexample @c ada
2902 pragma Profile (Ravenscar);
2903 @end smallexample
2905 @noindent
2906 A configuration pragma that establishes the following set of configuration
2907 pragmas:
2909 @table @code
2910 @item Task_Dispatching_Policy (FIFO_Within_Priorities)
2911 [RM D.2.2] Tasks are dispatched following a preemptive
2912 priority-ordered scheduling policy.
2914 @item Locking_Policy (Ceiling_Locking)
2915 [RM D.3] While tasks and interrupts execute a protected action, they inherit
2916 the ceiling priority of the corresponding protected object.
2918 @c @item Detect_Blocking
2919 @c This pragma forces the detection of potentially blocking operations within a
2920 @c protected operation, and to raise Program_Error if that happens.
2921 @end table
2922 @noindent
2924 plus the following set of restrictions:
2926 @table @code
2927 @item Max_Entry_Queue_Length = 1
2928 Defines the maximum number of calls that are queued on a (protected) entry.
2929 Note that this restrictions is checked at run time. Violation of this
2930 restriction results in the raising of Program_Error exception at the point of
2931 the call. For the Profile (Ravenscar) the value of Max_Entry_Queue_Length is
2932 always 1 and hence no task can be queued on a protected entry.
2934 @item Max_Protected_Entries = 1
2935 [RM D.7] Specifies the maximum number of entries per protected type. The
2936 bounds of every entry family of a protected unit shall be static, or shall be
2937 defined by a discriminant of a subtype whose corresponding bound is static.
2938 For the Profile (Ravenscar) the value of Max_Protected_Entries is always 1.
2940 @item Max_Task_Entries = 0
2941 [RM D.7] Specifies the maximum number of entries
2942 per task.  The bounds of every entry family
2943 of a task unit shall be static, or shall be
2944 defined by a discriminant of a subtype whose
2945 corresponding bound is static.  A value of zero
2946 indicates that no rendezvous are possible.  For
2947 the Profile (Ravenscar), the value of Max_Task_Entries is always
2948 0 (zero).
2950 @item No_Abort_Statements
2951 [RM D.7] There are no abort_statements, and there are
2952 no calls to Task_Identification.Abort_Task.
2954 @item No_Asynchronous_Control
2955 [RM D.7] There are no semantic dependences on the package
2956 Asynchronous_Task_Control.
2958 @item No_Calendar
2959 There are no semantic dependencies on the package Ada.Calendar.
2961 @item No_Dynamic_Attachment
2962 There is no call to any of the operations defined in package Ada.Interrupts
2963 (Is_Reserved, Is_Attached, Current_Handler, Attach_Handler, Exchange_Handler,
2964 Detach_Handler, and Reference).
2966 @item No_Dynamic_Priorities
2967 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
2969 @item No_Implicit_Heap_Allocations
2970 [RM D.7] No constructs are allowed to cause implicit heap allocation.
2972 @item No_Local_Protected_Objects
2973 Protected objects and access types that designate
2974 such objects shall be declared only at library level.
2976 @item No_Protected_Type_Allocators
2977 There are no allocators for protected types or
2978 types containing protected subcomponents.
2980 @item No_Relative_Delay
2981 There are no delay_relative statements.
2983 @item No_Requeue_Statements
2984 Requeue statements are not allowed.
2986 @item No_Select_Statements
2987 There are no select_statements.
2989 @item No_Task_Allocators
2990 [RM D.7] There are no allocators for task types
2991 or types containing task subcomponents.
2993 @item No_Task_Attributes_Package
2994 There are no semantic dependencies on the Ada.Task_Attributes package.
2996 @item No_Task_Hierarchy
2997 [RM D.7] All (non-environment) tasks depend
2998 directly on the environment task of the partition.
3000 @item No_Task_Termination
3001 Tasks which terminate are erroneous.
3003 @item Simple_Barriers
3004 Entry barrier condition expressions shall be either static
3005 boolean expressions or boolean objects which are declared in
3006 the protected type which contains the entry.
3007 @end table
3009 @noindent
3010 This set of configuration pragmas and restrictions correspond to the
3011 definition of the ``Ravenscar Profile'' for limited tasking, devised and
3012 published by the @cite{International Real-Time Ada Workshop}, 1997,
3013 and whose most recent description is available at
3014 @url{ftp://ftp.openravenscar.org/openravenscar/ravenscar00.pdf}.
3016 The original definition of the profile was revised at subsequent IRTAW
3017 meetings. It has been included in the ISO
3018 @cite{Guide for the Use of the Ada Programming Language in High
3019 Integrity Systems}, and has been approved by ISO/IEC/SC22/WG9 for inclusion in
3020 the next revision of the standard. The formal definition given by
3021 the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
3022 AI-305) available at
3023 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00249.TXT} and
3024 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00305.TXT}
3025 respectively.
3027 The above set is a superset of the restrictions provided by pragma
3028 @code{Profile (Restricted)}, it includes six additional restrictions
3029 (@code{Simple_Barriers}, @code{No_Select_Statements},
3030 @code{No_Calendar}, @code{No_Implicit_Heap_Allocations},
3031 @code{No_Relative_Delay} and @code{No_Task_Termination}).  This means
3032 that pragma @code{Profile (Ravenscar)}, like the pragma
3033 @code{Profile (Restricted)},
3034 automatically causes the use of a simplified,
3035 more efficient version of the tasking run-time system.
3037 @node Pragma Profile (Restricted)
3038 @unnumberedsec Pragma Profile (Restricted)
3039 @findex Restricted Run Time
3040 @noindent
3041 Syntax:
3043 @smallexample @c ada
3044 pragma Profile (Restricted);
3045 @end smallexample
3047 @noindent
3048 A configuration pragma that establishes the following set of restrictions:
3050 @itemize @bullet
3051 @item No_Abort_Statements
3052 @item No_Entry_Queue
3053 @item No_Task_Hierarchy
3054 @item No_Task_Allocators
3055 @item No_Dynamic_Priorities
3056 @item No_Terminate_Alternatives
3057 @item No_Dynamic_Attachment
3058 @item No_Protected_Type_Allocators
3059 @item No_Local_Protected_Objects
3060 @item No_Requeue_Statements
3061 @item No_Task_Attributes_Package
3062 @item Max_Asynchronous_Select_Nesting =  0
3063 @item Max_Task_Entries =  0
3064 @item Max_Protected_Entries = 1
3065 @item Max_Select_Alternatives = 0
3066 @end itemize
3068 @noindent
3069 This set of restrictions causes the automatic selection of a simplified
3070 version of the run time that provides improved performance for the
3071 limited set of tasking functionality permitted by this set of restrictions.
3073 @node Pragma Propagate_Exceptions
3074 @unnumberedsec Pragma Propagate_Exceptions
3075 @findex Propagate_Exceptions
3076 @cindex Zero Cost Exceptions
3077 @noindent
3078 Syntax:
3080 @smallexample @c ada
3081 pragma Propagate_Exceptions (subprogram_LOCAL_NAME);
3082 @end smallexample
3084 @noindent
3085 This pragma indicates that the given entity, which is the name of an
3086 imported foreign-language subprogram may receive an Ada exception,
3087 and that the exception should be propagated.  It is relevant only if
3088 zero cost exception handling is in use, and is thus never needed if
3089 the alternative @code{longjmp} / @code{setjmp} implementation of
3090 exceptions is used (although it is harmless to use it in such cases).
3092 The implementation of fast exceptions always properly propagates
3093 exceptions through Ada code, as described in the Ada Reference Manual.
3094 However, this manual is silent about the propagation of exceptions
3095 through foreign code.  For example, consider the
3096 situation where @code{P1} calls
3097 @code{P2}, and @code{P2} calls @code{P3}, where
3098 @code{P1} and @code{P3} are in Ada, but @code{P2} is in C@.
3099 @code{P3} raises an Ada exception.  The question is whether or not
3100 it will be propagated through @code{P2} and can be handled in
3101 @code{P1}.
3103 For the @code{longjmp} / @code{setjmp} implementation of exceptions,
3104 the answer is always yes.  For some targets on which zero cost exception
3105 handling is implemented, the answer is also always yes.  However, there
3106 are some targets, notably in the current version all x86 architecture
3107 targets, in which the answer is that such propagation does not
3108 happen automatically.  If such propagation is required on these
3109 targets, it is mandatory to use @code{Propagate_Exceptions} to
3110 name all foreign language routines through which Ada exceptions
3111 may be propagated.
3113 @node Pragma Psect_Object
3114 @unnumberedsec Pragma Psect_Object
3115 @findex Psect_Object
3116 @noindent
3117 Syntax:
3119 @smallexample @c ada
3120 pragma Psect_Object (
3121      [Internal =>] LOCAL_NAME,
3122   [, [External =>] EXTERNAL_SYMBOL]
3123   [, [Size     =>] EXTERNAL_SYMBOL]);
3125 EXTERNAL_SYMBOL ::=
3126   IDENTIFIER
3127 | static_string_EXPRESSION
3128 @end smallexample
3130 @noindent
3131 This pragma is identical in effect to pragma @code{Common_Object}.
3133 @node Pragma Pure_Function
3134 @unnumberedsec Pragma Pure_Function
3135 @findex Pure_Function
3136 @noindent
3137 Syntax:
3139 @smallexample @c ada
3140 pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
3141 @end smallexample
3143 @noindent
3144 This pragma appears in the same declarative part as a function
3145 declaration (or a set of function declarations if more than one
3146 overloaded declaration exists, in which case the pragma applies
3147 to all entities).  It specifies that the function @code{Entity} is
3148 to be considered pure for the purposes of code generation.  This means
3149 that the compiler can assume that there are no side effects, and
3150 in particular that two calls with identical arguments produce the
3151 same result.  It also means that the function can be used in an
3152 address clause.
3154 Note that, quite deliberately, there are no static checks to try
3155 to ensure that this promise is met, so @code{Pure_Function} can be used
3156 with functions that are conceptually pure, even if they do modify
3157 global variables.  For example, a square root function that is
3158 instrumented to count the number of times it is called is still
3159 conceptually pure, and can still be optimized, even though it
3160 modifies a global variable (the count).  Memo functions are another
3161 example (where a table of previous calls is kept and consulted to
3162 avoid re-computation).
3164 @findex Pure
3165 Note: Most functions in a @code{Pure} package are automatically pure, and
3166 there is no need to use pragma @code{Pure_Function} for such functions.  One
3167 exception is any function that has at least one formal of type
3168 @code{System.Address} or a type derived from it.  Such functions are not
3169 considered pure by default, since the compiler assumes that the
3170 @code{Address} parameter may be functioning as a pointer and that the
3171 referenced data may change even if the address value does not.
3172 Similarly, imported functions are not considered to be pure by default,
3173 since there is no way of checking that they are in fact pure.  The use
3174 of pragma @code{Pure_Function} for such a function will override these default
3175 assumption, and cause the compiler to treat a designated subprogram as pure
3176 in these cases.
3178 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
3179 applies to the underlying renamed function.  This can be used to
3180 disambiguate cases of overloading where some but not all functions
3181 in a set of overloaded functions are to be designated as pure.
3183 @node Pragma Restriction_Warnings
3184 @unnumberedsec Pragma Restriction_Warnings
3185 @findex Restriction_Warnings
3186 @noindent
3187 Syntax:
3189 @smallexample @c ada
3190 pragma Restriction_Warnings
3191   (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
3192 @end smallexample
3194 @noindent
3195 This pragma allows a series of restriction identifiers to be
3196 specified (the list of allowed identifiers is the same as for
3197 pragma @code{Restrictions}). For each of these identifiers
3198 the compiler checks for violations of the restriction, but
3199 generates a warning message rather than an error message
3200 if the restriction is violated.
3202 @node Pragma Source_File_Name
3203 @unnumberedsec Pragma Source_File_Name
3204 @findex Source_File_Name
3205 @noindent
3206 Syntax:
3208 @smallexample @c ada
3209 pragma Source_File_Name (
3210   [Unit_Name   =>] unit_NAME,
3211   Spec_File_Name =>  STRING_LITERAL);
3213 pragma Source_File_Name (
3214   [Unit_Name   =>] unit_NAME,
3215   Body_File_Name =>  STRING_LITERAL);
3216 @end smallexample
3218 @noindent
3219 Use this to override the normal naming convention.  It is a configuration
3220 pragma, and so has the usual applicability of configuration pragmas
3221 (i.e.@: it applies to either an entire partition, or to all units in a
3222 compilation, or to a single unit, depending on how it is used.
3223 @var{unit_name} is mapped to @var{file_name_literal}.  The identifier for
3224 the second argument is required, and indicates whether this is the file
3225 name for the spec or for the body.
3227 Another form of the @code{Source_File_Name} pragma allows
3228 the specification of patterns defining alternative file naming schemes
3229 to apply to all files.
3231 @smallexample @c ada
3232 pragma Source_File_Name
3233   (Spec_File_Name => STRING_LITERAL
3234    [,Casing => CASING_SPEC]
3235    [,Dot_Replacement => STRING_LITERAL]);
3237 pragma Source_File_Name
3238   (Body_File_Name => STRING_LITERAL
3239    [,Casing => CASING_SPEC]
3240    [,Dot_Replacement => STRING_LITERAL]);
3242 pragma Source_File_Name
3243   (Subunit_File_Name => STRING_LITERAL
3244    [,Casing => CASING_SPEC]
3245    [,Dot_Replacement => STRING_LITERAL]);
3247 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
3248 @end smallexample
3250 @noindent
3251 The first argument is a pattern that contains a single asterisk indicating
3252 the point at which the unit name is to be inserted in the pattern string
3253 to form the file name.  The second argument is optional.  If present it
3254 specifies the casing of the unit name in the resulting file name string.
3255 The default is lower case.  Finally the third argument allows for systematic
3256 replacement of any dots in the unit name by the specified string literal.
3258 A pragma Source_File_Name cannot appear after a
3259 @ref{Pragma Source_File_Name_Project}.
3261 For more details on the use of the @code{Source_File_Name} pragma,
3262 see the sections ``Using Other File Names'' and
3263 ``Alternative File Naming Schemes'' in the @cite{GNAT User's Guide}.
3265 @node Pragma Source_File_Name_Project
3266 @unnumberedsec Pragma Source_File_Name_Project
3267 @findex Source_File_Name_Project
3268 @noindent
3270 This pragma has the same syntax and semantics as pragma Source_File_Name.
3271 It is only allowed as a stand alone configuration pragma.
3272 It cannot appear after a @ref{Pragma Source_File_Name}, and
3273 most importantly, once pragma Source_File_Name_Project appears,
3274 no further Source_File_Name pragmas are allowed.
3276 The intention is that Source_File_Name_Project pragmas are always
3277 generated by the Project Manager in a manner consistent with the naming
3278 specified in a project file, and when naming is controlled in this manner,
3279 it is not permissible to attempt to modify this naming scheme using
3280 Source_File_Name pragmas (which would not be known to the project manager).
3282 @node Pragma Source_Reference
3283 @unnumberedsec Pragma Source_Reference
3284 @findex Source_Reference
3285 @noindent
3286 Syntax:
3288 @smallexample @c ada
3289 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
3290 @end smallexample
3292 @noindent
3293 This pragma must appear as the first line of a source file.
3294 @var{integer_literal} is the logical line number of the line following
3295 the pragma line (for use in error messages and debugging
3296 information).  @var{string_literal} is a static string constant that
3297 specifies the file name to be used in error messages and debugging
3298 information.  This is most notably used for the output of @code{gnatchop}
3299 with the @code{-r} switch, to make sure that the original unchopped
3300 source file is the one referred to.
3302 The second argument must be a string literal, it cannot be a static
3303 string expression other than a string literal.  This is because its value
3304 is needed for error messages issued by all phases of the compiler.
3306 @node Pragma Stream_Convert
3307 @unnumberedsec Pragma Stream_Convert
3308 @findex Stream_Convert
3309 @noindent
3310 Syntax:
3312 @smallexample @c ada
3313 pragma Stream_Convert (
3314   [Entity =>] type_LOCAL_NAME,
3315   [Read   =>] function_NAME,
3316   [Write  =>] function_NAME);
3317 @end smallexample
3319 @noindent
3320 This pragma provides an efficient way of providing stream functions for
3321 types defined in packages.  Not only is it simpler to use than declaring
3322 the necessary functions with attribute representation clauses, but more
3323 significantly, it allows the declaration to made in such a way that the
3324 stream packages are not loaded unless they are needed.  The use of
3325 the Stream_Convert pragma adds no overhead at all, unless the stream
3326 attributes are actually used on the designated type.
3328 The first argument specifies the type for which stream functions are
3329 provided.  The second parameter provides a function used to read values
3330 of this type.  It must name a function whose argument type may be any
3331 subtype, and whose returned type must be the type given as the first
3332 argument to the pragma.
3334 The meaning of the @var{Read}
3335 parameter is that if a stream attribute directly
3336 or indirectly specifies reading of the type given as the first parameter,
3337 then a value of the type given as the argument to the Read function is
3338 read from the stream, and then the Read function is used to convert this
3339 to the required target type.
3341 Similarly the @var{Write} parameter specifies how to treat write attributes
3342 that directly or indirectly apply to the type given as the first parameter.
3343 It must have an input parameter of the type specified by the first parameter,
3344 and the return type must be the same as the input type of the Read function.
3345 The effect is to first call the Write function to convert to the given stream
3346 type, and then write the result type to the stream.
3348 The Read and Write functions must not be overloaded subprograms.  If necessary
3349 renamings can be supplied to meet this requirement.
3350 The usage of this attribute is best illustrated by a simple example, taken
3351 from the GNAT implementation of package Ada.Strings.Unbounded:
3353 @smallexample @c ada
3354 function To_Unbounded (S : String)
3355            return Unbounded_String
3356   renames To_Unbounded_String;
3358 pragma Stream_Convert
3359   (Unbounded_String, To_Unbounded, To_String);
3360 @end smallexample
3362 @noindent
3363 The specifications of the referenced functions, as given in the Ada 95
3364 Reference Manual are:
3366 @smallexample @c ada
3367 function To_Unbounded_String (Source : String)
3368   return Unbounded_String;
3370 function To_String (Source : Unbounded_String)
3371   return String;
3372 @end smallexample
3374 @noindent
3375 The effect is that if the value of an unbounded string is written to a
3376 stream, then the representation of the item in the stream is in the same
3377 format used for @code{Standard.String}, and this same representation is
3378 expected when a value of this type is read from the stream.
3380 @node Pragma Style_Checks
3381 @unnumberedsec Pragma Style_Checks
3382 @findex Style_Checks
3383 @noindent
3384 Syntax:
3386 @smallexample @c ada
3387 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
3388                      On | Off [, LOCAL_NAME]);
3389 @end smallexample
3391 @noindent
3392 This pragma is used in conjunction with compiler switches to control the
3393 built in style checking provided by GNAT@.  The compiler switches, if set,
3394 provide an initial setting for the switches, and this pragma may be used
3395 to modify these settings, or the settings may be provided entirely by
3396 the use of the pragma.  This pragma can be used anywhere that a pragma
3397 is legal, including use as a configuration pragma (including use in
3398 the @file{gnat.adc} file).
3400 The form with a string literal specifies which style options are to be
3401 activated.  These are additive, so they apply in addition to any previously
3402 set style check options.  The codes for the options are the same as those
3403 used in the @code{-gnaty} switch to @code{gcc} or @code{gnatmake}.
3404 For example the following two methods can be used to enable
3405 layout checking:
3407 @itemize @bullet
3408 @item
3409 @smallexample @c ada
3410 pragma Style_Checks ("l");
3411 @end smallexample
3413 @item
3414 @smallexample
3415 gcc -c -gnatyl @dots{}
3416 @end smallexample
3417 @end itemize
3419 @noindent
3420 The form ALL_CHECKS activates all standard checks (its use is equivalent
3421 to the use of the @code{gnaty} switch with no options.  See GNAT User's
3422 Guide for details.
3424 The forms with @code{Off} and @code{On}
3425 can be used to temporarily disable style checks
3426 as shown in the following example:
3428 @smallexample @c ada
3429 @iftex
3430 @leftskip=0cm
3431 @end iftex
3432 pragma Style_Checks ("k"); -- requires keywords in lower case
3433 pragma Style_Checks (Off); -- turn off style checks
3434 NULL;                      -- this will not generate an error message
3435 pragma Style_Checks (On);  -- turn style checks back on
3436 NULL;                      -- this will generate an error message
3437 @end smallexample
3439 @noindent
3440 Finally the two argument form is allowed only if the first argument is
3441 @code{On} or @code{Off}.  The effect is to turn of semantic style checks
3442 for the specified entity, as shown in the following example:
3444 @smallexample @c ada
3445 @iftex
3446 @leftskip=0cm
3447 @end iftex
3448 pragma Style_Checks ("r"); -- require consistency of identifier casing
3449 Arg : Integer;
3450 Rf1 : Integer := ARG;      -- incorrect, wrong case
3451 pragma Style_Checks (Off, Arg);
3452 Rf2 : Integer := ARG;      -- OK, no error
3453 @end smallexample
3455 @node Pragma Subtitle
3456 @unnumberedsec Pragma Subtitle
3457 @findex Subtitle
3458 @noindent
3459 Syntax:
3461 @smallexample @c ada
3462 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
3463 @end smallexample
3465 @noindent
3466 This pragma is recognized for compatibility with other Ada compilers
3467 but is ignored by GNAT@.
3469 @node Pragma Suppress_All
3470 @unnumberedsec Pragma Suppress_All
3471 @findex Suppress_All
3472 @noindent
3473 Syntax:
3475 @smallexample @c ada
3476 pragma Suppress_All;
3477 @end smallexample
3479 @noindent
3480 This pragma can only appear immediately following a compilation
3481 unit.  The effect is to apply @code{Suppress (All_Checks)} to the unit
3482 which it follows.  This pragma is implemented for compatibility with DEC
3483 Ada 83 usage.  The use of pragma @code{Suppress (All_Checks)} as a normal
3484 configuration pragma is the preferred usage in GNAT@.
3486 @node Pragma Suppress_Exception_Locations
3487 @unnumberedsec Pragma Suppress_Exception_Locations
3488 @findex Suppress_Exception_Locations
3489 @noindent
3490 Syntax:
3492 @smallexample @c ada
3493 pragma Suppress_Exception_Locations;
3494 @end smallexample
3496 @noindent
3497 In normal mode, a raise statement for an exception by default generates
3498 an exception message giving the file name and line number for the location
3499 of the raise. This is useful for debugging and logging purposes, but this
3500 entails extra space for the strings for the messages. The configuration
3501 pragma @code{Suppress_Exception_Locations} can be used to suppress the
3502 generation of these strings, with the result that space is saved, but the
3503 exception message for such raises is null. This configuration pragma may
3504 appear in a global configuration pragma file, or in a specific unit as
3505 usual. It is not required that this pragma be used consistently within
3506 a partition, so it is fine to have some units within a partition compiled
3507 with this pragma and others compiled in normal mode without it.
3509 @node Pragma Suppress_Initialization
3510 @unnumberedsec Pragma Suppress_Initialization
3511 @findex Suppress_Initialization
3512 @cindex Suppressing initialization
3513 @cindex Initialization, suppression of
3514 @noindent
3515 Syntax:
3517 @smallexample @c ada
3518 pragma Suppress_Initialization ([Entity =>] type_Name);
3519 @end smallexample
3521 @noindent
3522 This pragma suppresses any implicit or explicit initialization
3523 associated with the given type name for all variables of this type.
3525 @node Pragma Task_Info
3526 @unnumberedsec Pragma Task_Info
3527 @findex Task_Info
3528 @noindent
3529 Syntax
3531 @smallexample @c ada
3532 pragma Task_Info (EXPRESSION);
3533 @end smallexample
3535 @noindent
3536 This pragma appears within a task definition (like pragma
3537 @code{Priority}) and applies to the task in which it appears.  The
3538 argument must be of type @code{System.Task_Info.Task_Info_Type}.
3539 The @code{Task_Info} pragma provides system dependent control over
3540 aspects of tasking implementation, for example, the ability to map
3541 tasks to specific processors.  For details on the facilities available
3542 for the version of GNAT that you are using, see the documentation
3543 in the specification of package System.Task_Info in the runtime
3544 library.
3546 @node Pragma Task_Name
3547 @unnumberedsec Pragma Task_Name
3548 @findex Task_Name
3549 @noindent
3550 Syntax
3552 @smallexample @c ada
3553 pragma Task_Name (string_EXPRESSION);
3554 @end smallexample
3556 @noindent
3557 This pragma appears within a task definition (like pragma
3558 @code{Priority}) and applies to the task in which it appears.  The
3559 argument must be of type String, and provides a name to be used for
3560 the task instance when the task is created.  Note that this expression
3561 is not required to be static, and in particular, it can contain
3562 references to task discriminants.  This facility can be used to
3563 provide different names for different tasks as they are created,
3564 as illustrated in the example below.
3566 The task name is recorded internally in the run-time structures
3567 and is accessible to tools like the debugger.  In addition the
3568 routine @code{Ada.Task_Identification.Image} will return this
3569 string, with a unique task address appended.
3571 @smallexample @c ada
3572 --  Example of the use of pragma Task_Name
3574 with Ada.Task_Identification;
3575 use Ada.Task_Identification;
3576 with Text_IO; use Text_IO;
3577 procedure t3 is
3579    type Astring is access String;
3581    task type Task_Typ (Name : access String) is
3582       pragma Task_Name (Name.all);
3583    end Task_Typ;
3585    task body Task_Typ is
3586       Nam : constant String := Image (Current_Task);
3587    begin
3588       Put_Line ("-->" & Nam (1 .. 14) & "<--");
3589    end Task_Typ;
3591    type Ptr_Task is access Task_Typ;
3592    Task_Var : Ptr_Task;
3594 begin
3595    Task_Var :=
3596      new Task_Typ (new String'("This is task 1"));
3597    Task_Var :=
3598      new Task_Typ (new String'("This is task 2"));
3599 end;
3600 @end smallexample
3602 @node Pragma Task_Storage
3603 @unnumberedsec Pragma Task_Storage
3604 @findex Task_Storage
3605 Syntax:
3607 @smallexample @c ada
3608 pragma Task_Storage (
3609   [Task_Type =>] LOCAL_NAME,
3610   [Top_Guard =>] static_integer_EXPRESSION);
3611 @end smallexample
3613 @noindent
3614 This pragma specifies the length of the guard area for tasks.  The guard
3615 area is an additional storage area allocated to a task.  A value of zero
3616 means that either no guard area is created or a minimal guard area is
3617 created, depending on the target.  This pragma can appear anywhere a
3618 @code{Storage_Size} attribute definition clause is allowed for a task
3619 type.
3621 @node Pragma Thread_Body
3622 @unnumberedsec Pragma Thread_Body
3623 @findex Thread_Body
3624 Syntax:
3626 @smallexample @c ada
3627 pragma Thread_Body (
3628   [Entity =>] LOCAL_NAME,
3629  [[Secondary_Stack_Size =>] static_integer_EXPRESSION)];
3630 @end smallexample
3632 @noindent
3633 This pragma specifies that the subprogram whose name is given as the
3634 @code{Entity} argument is a thread body, which will be activated
3635 by being called via its Address from foreign code. The purpose is
3636 to allow execution and registration of the foreign thread within the
3637 Ada run-time system.
3639 See the library unit @code{System.Threads} for details on the expansion of
3640 a thread body subprogram, including the calls made to subprograms
3641 within System.Threads to register the task.  This unit also lists the
3642 targets and runtime systems for which this pragma is supported.
3644 A thread body subprogram may not be called directly from Ada code, and
3645 it is not permitted to apply the Access (or Unrestricted_Access) attributes
3646 to such a subprogram. The only legitimate way of calling such a subprogram
3647 is to pass its Address to foreign code and then make the call from the
3648 foreign code.
3650 A thread body subprogram may have any parameters, and it may be a function
3651 returning a result. The convention of the thread body subprogram may be
3652 set in the usual manner using @code{pragma Convention}.
3654 The secondary stack size parameter, if given, is used to set the size
3655 of secondary stack for the thread. The secondary stack is allocated as
3656 a local variable of the expanded thread body subprogram, and thus is
3657 allocated out of the main thread stack size. If no secondary stack
3658 size parameter is present, the default size (from the declaration in
3659 @code{System.Secondary_Stack} is used.
3661 @node Pragma Time_Slice
3662 @unnumberedsec Pragma Time_Slice
3663 @findex Time_Slice
3664 @noindent
3665 Syntax:
3667 @smallexample @c ada
3668 pragma Time_Slice (static_duration_EXPRESSION);
3669 @end smallexample
3671 @noindent
3672 For implementations of GNAT on operating systems where it is possible
3673 to supply a time slice value, this pragma may be used for this purpose.
3674 It is ignored if it is used in a system that does not allow this control,
3675 or if it appears in other than the main program unit.
3676 @cindex OpenVMS
3677 Note that the effect of this pragma is identical to the effect of the
3678 DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
3680 @node Pragma Title
3681 @unnumberedsec Pragma Title
3682 @findex Title
3683 @noindent
3684 Syntax:
3686 @smallexample @c ada
3687 pragma Title (TITLING_OPTION [, TITLING OPTION]);
3689 TITLING_OPTION ::=
3690   [Title    =>] STRING_LITERAL,
3691 | [Subtitle =>] STRING_LITERAL
3692 @end smallexample
3694 @noindent
3695 Syntax checked but otherwise ignored by GNAT@.  This is a listing control
3696 pragma used in DEC Ada 83 implementations to provide a title and/or
3697 subtitle for the program listing.  The program listing generated by GNAT
3698 does not have titles or subtitles.
3700 Unlike other pragmas, the full flexibility of named notation is allowed
3701 for this pragma, i.e.@: the parameters may be given in any order if named
3702 notation is used, and named and positional notation can be mixed
3703 following the normal rules for procedure calls in Ada.
3705 @node Pragma Unchecked_Union
3706 @unnumberedsec Pragma Unchecked_Union
3707 @cindex Unions in C
3708 @findex Unchecked_Union
3709 @noindent
3710 Syntax:
3712 @smallexample @c ada
3713 pragma Unchecked_Union (first_subtype_LOCAL_NAME);
3714 @end smallexample
3716 @noindent
3717 This pragma is used to declare that the specified type should be represented
3718 in a manner
3719 equivalent to a C union type, and is intended only for use in
3720 interfacing with C code that uses union types.  In Ada terms, the named
3721 type must obey the following rules:
3723 @itemize @bullet
3724 @item
3725 It is a non-tagged non-limited record type.
3726 @item
3727 It has a single discrete discriminant with a default value.
3728 @item
3729 The component list consists of a single variant part.
3730 @item
3731 Each variant has a component list with a single component.
3732 @item
3733 No nested variants are allowed.
3734 @item
3735 No component has an explicit default value.
3736 @item
3737 No component has a non-static constraint.
3738 @end itemize
3740 @noindent
3741 In addition, given a type that meets the above requirements, the
3742 following restrictions apply to its use throughout the program:
3744 @itemize @bullet
3745 @item
3746 The discriminant name can be mentioned only in an aggregate.
3747 @item
3748 No subtypes may be created of this type.
3749 @item
3750 The type may not be constrained by giving a discriminant value.
3751 @item
3752 The type cannot be passed as the actual for a generic formal with a
3753 discriminant.
3754 @end itemize
3756 @noindent
3757 Equality and inequality operations on @code{unchecked_unions} are not
3758 available, since there is no discriminant to compare and the compiler
3759 does not even know how many bits to compare.  It is implementation
3760 dependent whether this is detected at compile time as an illegality or
3761 whether it is undetected and considered to be an erroneous construct.  In
3762 GNAT, a direct comparison is illegal, but GNAT does not attempt to catch
3763 the composite case (where two composites are compared that contain an
3764 unchecked union component), so such comparisons are simply considered
3765 erroneous.
3767 The layout of the resulting type corresponds exactly to a C union, where
3768 each branch of the union corresponds to a single variant in the Ada
3769 record.  The semantics of the Ada program is not changed in any way by
3770 the pragma, i.e.@: provided the above restrictions are followed, and no
3771 erroneous incorrect references to fields or erroneous comparisons occur,
3772 the semantics is exactly as described by the Ada reference manual.
3773 Pragma @code{Suppress (Discriminant_Check)} applies implicitly to the
3774 type and the default convention is C.
3776 @node Pragma Unimplemented_Unit
3777 @unnumberedsec Pragma Unimplemented_Unit
3778 @findex Unimplemented_Unit
3779 @noindent
3780 Syntax:
3782 @smallexample @c ada
3783 pragma Unimplemented_Unit;
3784 @end smallexample
3786 @noindent
3787 If this pragma occurs in a unit that is processed by the compiler, GNAT
3788 aborts with the message @samp{@var{xxx} not implemented}, where
3789 @var{xxx} is the name of the current compilation unit.  This pragma is
3790 intended to allow the compiler to handle unimplemented library units in
3791 a clean manner.
3793 The abort only happens if code is being generated.  Thus you can use
3794 specs of unimplemented packages in syntax or semantic checking mode.
3796 @node Pragma Universal_Data
3797 @unnumberedsec Pragma Universal_Data
3798 @findex Universal_Data
3799 @noindent
3800 Syntax:
3802 @smallexample @c ada
3803 pragma Universal_Data [(library_unit_Name)];
3804 @end smallexample
3806 @noindent
3807 This pragma is supported only for the AAMP target and is ignored for
3808 other targets. The pragma specifies that all library-level objects
3809 (Counter 0 data) associated with the library unit are to be accessed
3810 and updated using universal addressing (24-bit addresses for AAMP5)
3811 rather than the default of 16-bit Data Environment (DENV) addressing.
3812 Use of this pragma will generally result in less efficient code for
3813 references to global data associated with the library unit, but
3814 allows such data to be located anywhere in memory. This pragma is
3815 a library unit pragma, but can also be used as a configuration pragma
3816 (including use in the @file{gnat.adc} file). The functionality
3817 of this pragma is also available by applying the -univ switch on the
3818 compilations of units where universal addressing of the data is desired.
3820 @node Pragma Unreferenced
3821 @unnumberedsec Pragma Unreferenced
3822 @findex Unreferenced
3823 @cindex Warnings, unreferenced
3824 @noindent
3825 Syntax:
3827 @smallexample @c ada
3828 pragma Unreferenced (local_Name @{, local_Name@});
3829 @end smallexample
3831 @noindent
3832 This pragma signals that the entities whose names are listed are
3833 deliberately not referenced in the current source unit. This
3834 suppresses warnings about the
3835 entities being unreferenced, and in addition a warning will be
3836 generated if one of these entities is in fact referenced in the
3837 same unit as the pragma (or in the corresponding body, or one
3838 of its subunits).
3840 This is particularly useful for clearly signaling that a particular
3841 parameter is not referenced in some particular subprogram implementation
3842 and that this is deliberate. It can also be useful in the case of
3843 objects declared only for their initialization or finalization side
3844 effects.
3846 If @code{local_Name} identifies more than one matching homonym in the
3847 current scope, then the entity most recently declared is the one to which
3848 the pragma applies.
3850 The left hand side of an assignment does not count as a reference for the
3851 purpose of this pragma. Thus it is fine to assign to an entity for which
3852 pragma Unreferenced is given.
3854 @node Pragma Unreserve_All_Interrupts
3855 @unnumberedsec Pragma Unreserve_All_Interrupts
3856 @findex Unreserve_All_Interrupts
3857 @noindent
3858 Syntax:
3860 @smallexample @c ada
3861 pragma Unreserve_All_Interrupts;
3862 @end smallexample
3864 @noindent
3865 Normally certain interrupts are reserved to the implementation.  Any attempt
3866 to attach an interrupt causes Program_Error to be raised, as described in
3867 RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
3868 many systems for a @kbd{Ctrl-C} interrupt.  Normally this interrupt is
3869 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
3870 interrupt execution.
3872 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
3873 a program, then all such interrupts are unreserved.  This allows the
3874 program to handle these interrupts, but disables their standard
3875 functions.  For example, if this pragma is used, then pressing
3876 @kbd{Ctrl-C} will not automatically interrupt execution.  However,
3877 a program can then handle the @code{SIGINT} interrupt as it chooses.
3879 For a full list of the interrupts handled in a specific implementation,
3880 see the source code for the specification of @code{Ada.Interrupts.Names} in
3881 file @file{a-intnam.ads}.  This is a target dependent file that contains the
3882 list of interrupts recognized for a given target.  The documentation in
3883 this file also specifies what interrupts are affected by the use of
3884 the @code{Unreserve_All_Interrupts} pragma.
3886 For a more general facility for controlling what interrupts can be
3887 handled, see pragma @code{Interrupt_State}, which subsumes the functionality
3888 of the @code{Unreserve_All_Interrupts} pragma.
3890 @node Pragma Unsuppress
3891 @unnumberedsec Pragma Unsuppress
3892 @findex Unsuppress
3893 @noindent
3894 Syntax:
3896 @smallexample @c ada
3897 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
3898 @end smallexample
3900 @noindent
3901 This pragma undoes the effect of a previous pragma @code{Suppress}.  If
3902 there is no corresponding pragma @code{Suppress} in effect, it has no
3903 effect.  The range of the effect is the same as for pragma
3904 @code{Suppress}.  The meaning of the arguments is identical to that used
3905 in pragma @code{Suppress}.
3907 One important application is to ensure that checks are on in cases where
3908 code depends on the checks for its correct functioning, so that the code
3909 will compile correctly even if the compiler switches are set to suppress
3910 checks.
3912 @node Pragma Use_VADS_Size
3913 @unnumberedsec Pragma Use_VADS_Size
3914 @cindex @code{Size}, VADS compatibility
3915 @findex Use_VADS_Size
3916 @noindent
3917 Syntax:
3919 @smallexample @c ada
3920 pragma Use_VADS_Size;
3921 @end smallexample
3923 @noindent
3924 This is a configuration pragma.  In a unit to which it applies, any use
3925 of the 'Size attribute is automatically interpreted as a use of the
3926 'VADS_Size attribute.  Note that this may result in incorrect semantic
3927 processing of valid Ada 95 programs.  This is intended to aid in the
3928 handling of legacy code which depends on the interpretation of Size
3929 as implemented in the VADS compiler.  See description of the VADS_Size
3930 attribute for further details.
3932 @node Pragma Validity_Checks
3933 @unnumberedsec Pragma Validity_Checks
3934 @findex Validity_Checks
3935 @noindent
3936 Syntax:
3938 @smallexample @c ada
3939 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
3940 @end smallexample
3942 @noindent
3943 This pragma is used in conjunction with compiler switches to control the
3944 built-in validity checking provided by GNAT@.  The compiler switches, if set
3945 provide an initial setting for the switches, and this pragma may be used
3946 to modify these settings, or the settings may be provided entirely by
3947 the use of the pragma.  This pragma can be used anywhere that a pragma
3948 is legal, including use as a configuration pragma (including use in
3949 the @file{gnat.adc} file).
3951 The form with a string literal specifies which validity options are to be
3952 activated.  The validity checks are first set to include only the default
3953 reference manual settings, and then a string of letters in the string
3954 specifies the exact set of options required.  The form of this string
3955 is exactly as described for the @code{-gnatVx} compiler switch (see the
3956 GNAT users guide for details).  For example the following two methods
3957 can be used to enable validity checking for mode @code{in} and
3958 @code{in out} subprogram parameters:
3960 @itemize @bullet
3961 @item
3962 @smallexample @c ada
3963 pragma Validity_Checks ("im");
3964 @end smallexample
3966 @item
3967 @smallexample
3968 gcc -c -gnatVim @dots{}
3969 @end smallexample
3970 @end itemize
3972 @noindent
3973 The form ALL_CHECKS activates all standard checks (its use is equivalent
3974 to the use of the @code{gnatva} switch.
3976 The forms with @code{Off} and @code{On}
3977 can be used to temporarily disable validity checks
3978 as shown in the following example:
3980 @smallexample @c ada
3981 @iftex
3982 @leftskip=0cm
3983 @end iftex
3984 pragma Validity_Checks ("c"); -- validity checks for copies
3985 pragma Validity_Checks (Off); -- turn off validity checks
3986 A := B;                       -- B will not be validity checked
3987 pragma Validity_Checks (On);  -- turn validity checks back on
3988 A := C;                       -- C will be validity checked
3989 @end smallexample
3991 @node Pragma Volatile
3992 @unnumberedsec Pragma Volatile
3993 @findex Volatile
3994 @noindent
3995 Syntax:
3997 @smallexample @c ada
3998 pragma Volatile (local_NAME);
3999 @end smallexample
4001 @noindent
4002 This pragma is defined by the Ada 95 Reference Manual, and the GNAT
4003 implementation is fully conformant with this definition.  The reason it
4004 is mentioned in this section is that a pragma of the same name was supplied
4005 in some Ada 83 compilers, including DEC Ada 83.  The Ada 95 implementation
4006 of pragma Volatile is upwards compatible with the implementation in
4007 Dec Ada 83.
4009 @node Pragma Warnings
4010 @unnumberedsec Pragma Warnings
4011 @findex Warnings
4012 @noindent
4013 Syntax:
4015 @smallexample @c ada
4016 pragma Warnings (On | Off [, LOCAL_NAME]);
4017 @end smallexample
4019 @noindent
4020 Normally warnings are enabled, with the output being controlled by
4021 the command line switch.  Warnings (@code{Off}) turns off generation of
4022 warnings until a Warnings (@code{On}) is encountered or the end of the
4023 current unit.  If generation of warnings is turned off using this
4024 pragma, then no warning messages are output, regardless of the
4025 setting of the command line switches.
4027 The form with a single argument is a configuration pragma.
4029 If the @var{local_name} parameter is present, warnings are suppressed for
4030 the specified entity.  This suppression is effective from the point where
4031 it occurs till the end of the extended scope of the variable (similar to
4032 the scope of @code{Suppress}).
4034 @node Pragma Weak_External
4035 @unnumberedsec Pragma Weak_External
4036 @findex Weak_External
4037 @noindent
4038 Syntax:
4040 @smallexample @c ada
4041 pragma Weak_External ([Entity =>] LOCAL_NAME);
4042 @end smallexample
4044 @noindent
4045 This pragma specifies that the given entity should be marked as a weak
4046 external (one that does not have to be resolved) for the linker.  For
4047 further details, consult the GCC manual.
4049 @node Implementation Defined Attributes
4050 @chapter Implementation Defined Attributes
4051 Ada 95 defines (throughout the Ada 95 reference manual,
4052 summarized in annex K),
4053 a set of attributes that provide useful additional functionality in all
4054 areas of the language.  These language defined attributes are implemented
4055 in GNAT and work as described in the Ada 95 Reference Manual.
4057 In addition, Ada 95 allows implementations to define additional
4058 attributes whose meaning is defined by the implementation.  GNAT provides
4059 a number of these implementation-dependent attributes which can be used
4060 to extend and enhance the functionality of the compiler.  This section of
4061 the GNAT reference manual describes these additional attributes.
4063 Note that any program using these attributes may not be portable to
4064 other compilers (although GNAT implements this set of attributes on all
4065 platforms).  Therefore if portability to other compilers is an important
4066 consideration, you should minimize the use of these attributes.
4068 @menu
4069 * Abort_Signal::
4070 * Address_Size::
4071 * Asm_Input::
4072 * Asm_Output::
4073 * AST_Entry::
4074 * Bit::
4075 * Bit_Position::
4076 * Code_Address::
4077 * Default_Bit_Order::
4078 * Elaborated::
4079 * Elab_Body::
4080 * Elab_Spec::
4081 * Emax::
4082 * Enum_Rep::
4083 * Epsilon::
4084 * Fixed_Value::
4085 * Has_Access_Values::
4086 * Has_Discriminants::
4087 * Img::
4088 * Integer_Value::
4089 * Large::
4090 * Machine_Size::
4091 * Mantissa::
4092 * Max_Interrupt_Priority::
4093 * Max_Priority::
4094 * Maximum_Alignment::
4095 * Mechanism_Code::
4096 * Null_Parameter::
4097 * Object_Size::
4098 * Passed_By_Reference::
4099 * Range_Length::
4100 * Safe_Emax::
4101 * Safe_Large::
4102 * Small::
4103 * Storage_Unit::
4104 * Target_Name::
4105 * Tick::
4106 * To_Address::
4107 * Type_Class::
4108 * UET_Address::
4109 * Unconstrained_Array::
4110 * Universal_Literal_String::
4111 * Unrestricted_Access::
4112 * VADS_Size::
4113 * Value_Size::
4114 * Wchar_T_Size::
4115 * Word_Size::
4116 @end menu
4118 @node Abort_Signal
4119 @unnumberedsec Abort_Signal
4120 @findex Abort_Signal
4121 @noindent
4122 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
4123 prefix) provides the entity for the special exception used to signal
4124 task abort or asynchronous transfer of control.  Normally this attribute
4125 should only be used in the tasking runtime (it is highly peculiar, and
4126 completely outside the normal semantics of Ada, for a user program to
4127 intercept the abort exception).
4129 @node Address_Size
4130 @unnumberedsec Address_Size
4131 @cindex Size of @code{Address}
4132 @findex Address_Size
4133 @noindent
4134 @code{Standard'Address_Size} (@code{Standard} is the only allowed
4135 prefix) is a static constant giving the number of bits in an
4136 @code{Address}. It is the same value as System.Address'Size,
4137 but has the advantage of being static, while a direct
4138 reference to System.Address'Size is non-static because Address
4139 is a private type.
4141 @node Asm_Input
4142 @unnumberedsec Asm_Input
4143 @findex Asm_Input
4144 @noindent
4145 The @code{Asm_Input} attribute denotes a function that takes two
4146 parameters.  The first is a string, the second is an expression of the
4147 type designated by the prefix.  The first (string) argument is required
4148 to be a static expression, and is the constraint for the parameter,
4149 (e.g.@: what kind of register is required).  The second argument is the
4150 value to be used as the input argument.  The possible values for the
4151 constant are the same as those used in the RTL, and are dependent on
4152 the configuration file used to built the GCC back end.
4153 @ref{Machine Code Insertions}
4155 @node Asm_Output
4156 @unnumberedsec Asm_Output
4157 @findex Asm_Output
4158 @noindent
4159 The @code{Asm_Output} attribute denotes a function that takes two
4160 parameters.  The first is a string, the second is the name of a variable
4161 of the type designated by the attribute prefix.  The first (string)
4162 argument is required to be a static expression and designates the
4163 constraint for the parameter (e.g.@: what kind of register is
4164 required).  The second argument is the variable to be updated with the
4165 result.  The possible values for constraint are the same as those used in
4166 the RTL, and are dependent on the configuration file used to build the
4167 GCC back end.  If there are no output operands, then this argument may
4168 either be omitted, or explicitly given as @code{No_Output_Operands}.
4169 @ref{Machine Code Insertions}
4171 @node AST_Entry
4172 @unnumberedsec AST_Entry
4173 @cindex OpenVMS
4174 @findex AST_Entry
4175 @noindent
4176 This attribute is implemented only in OpenVMS versions of GNAT@.  Applied to
4177 the name of an entry, it yields a value of the predefined type AST_Handler
4178 (declared in the predefined package System, as extended by the use of
4179 pragma @code{Extend_System (Aux_DEC)}).  This value enables the given entry to
4180 be called when an AST occurs.  For further details, refer to the @cite{DEC Ada
4181 Language Reference Manual}, section 9.12a.
4183 @node Bit
4184 @unnumberedsec Bit
4185 @findex Bit
4186 @code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
4187 offset within the storage unit (byte) that contains the first bit of
4188 storage allocated for the object.  The value of this attribute is of the
4189 type @code{Universal_Integer}, and is always a non-negative number not
4190 exceeding the value of @code{System.Storage_Unit}.
4192 For an object that is a variable or a constant allocated in a register,
4193 the value is zero.  (The use of this attribute does not force the
4194 allocation of a variable to memory).
4196 For an object that is a formal parameter, this attribute applies
4197 to either the matching actual parameter or to a copy of the
4198 matching actual parameter.
4200 For an access object the value is zero.  Note that
4201 @code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
4202 designated object.  Similarly for a record component
4203 @code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
4204 @code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
4205 are subject to index checks.
4207 This attribute is designed to be compatible with the DEC Ada 83 definition
4208 and implementation of the @code{Bit} attribute.
4210 @node Bit_Position
4211 @unnumberedsec Bit_Position
4212 @findex Bit_Position
4213 @noindent
4214 @code{@var{R.C}'Bit}, where @var{R} is a record object and C is one
4215 of the fields of the record type, yields the bit
4216 offset within the record contains the first bit of
4217 storage allocated for the object.  The value of this attribute is of the
4218 type @code{Universal_Integer}.  The value depends only on the field
4219 @var{C} and is independent of the alignment of
4220 the containing record @var{R}.
4222 @node Code_Address
4223 @unnumberedsec Code_Address
4224 @findex Code_Address
4225 @cindex Subprogram address
4226 @cindex Address of subprogram code
4227 @noindent
4228 The @code{'Address}
4229 attribute may be applied to subprograms in Ada 95, but the
4230 intended effect from the Ada 95 reference manual seems to be to provide
4231 an address value which can be used to call the subprogram by means of
4232 an address clause as in the following example:
4234 @smallexample @c ada
4235 procedure K is @dots{}
4237 procedure L;
4238 for L'Address use K'Address;
4239 pragma Import (Ada, L);
4240 @end smallexample
4242 @noindent
4243 A call to @code{L} is then expected to result in a call to @code{K}@.
4244 In Ada 83, where there were no access-to-subprogram values, this was
4245 a common work around for getting the effect of an indirect call.
4246 GNAT implements the above use of @code{Address} and the technique
4247 illustrated by the example code works correctly.
4249 However, for some purposes, it is useful to have the address of the start
4250 of the generated code for the subprogram.  On some architectures, this is
4251 not necessarily the same as the @code{Address} value described above.
4252 For example, the @code{Address} value may reference a subprogram
4253 descriptor rather than the subprogram itself.
4255 The @code{'Code_Address} attribute, which can only be applied to
4256 subprogram entities, always returns the address of the start of the
4257 generated code of the specified subprogram, which may or may not be
4258 the same value as is returned by the corresponding @code{'Address}
4259 attribute.
4261 @node Default_Bit_Order
4262 @unnumberedsec Default_Bit_Order
4263 @cindex Big endian
4264 @cindex Little endian
4265 @findex Default_Bit_Order
4266 @noindent
4267 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
4268 permissible prefix), provides the value @code{System.Default_Bit_Order}
4269 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
4270 @code{Low_Order_First}).  This is used to construct the definition of
4271 @code{Default_Bit_Order} in package @code{System}.
4273 @node Elaborated
4274 @unnumberedsec Elaborated
4275 @findex Elaborated
4276 @noindent
4277 The prefix of the @code{'Elaborated} attribute must be a unit name.  The
4278 value is a Boolean which indicates whether or not the given unit has been
4279 elaborated.  This attribute is primarily intended for internal use by the
4280 generated code for dynamic elaboration checking, but it can also be used
4281 in user programs.  The value will always be True once elaboration of all
4282 units has been completed.  An exception is for units which need no
4283 elaboration, the value is always False for such units.
4285 @node Elab_Body
4286 @unnumberedsec Elab_Body
4287 @findex Elab_Body
4288 @noindent
4289 This attribute can only be applied to a program unit name.  It returns
4290 the entity for the corresponding elaboration procedure for elaborating
4291 the body of the referenced unit.  This is used in the main generated
4292 elaboration procedure by the binder and is not normally used in any
4293 other context.  However, there may be specialized situations in which it
4294 is useful to be able to call this elaboration procedure from Ada code,
4295 e.g.@: if it is necessary to do selective re-elaboration to fix some
4296 error.
4298 @node Elab_Spec
4299 @unnumberedsec Elab_Spec
4300 @findex Elab_Spec
4301 @noindent
4302 This attribute can only be applied to a program unit name.  It returns
4303 the entity for the corresponding elaboration procedure for elaborating
4304 the specification of the referenced unit.  This is used in the main
4305 generated elaboration procedure by the binder and is not normally used
4306 in any other context.  However, there may be specialized situations in
4307 which it is useful to be able to call this elaboration procedure from
4308 Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
4309 some error.
4311 @node Emax
4312 @unnumberedsec Emax
4313 @cindex Ada 83 attributes
4314 @findex Emax
4315 @noindent
4316 The @code{Emax} attribute is provided for compatibility with Ada 83.  See
4317 the Ada 83 reference manual for an exact description of the semantics of
4318 this attribute.
4320 @node Enum_Rep
4321 @unnumberedsec Enum_Rep
4322 @cindex Representation of enums
4323 @findex Enum_Rep
4324 @noindent
4325 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
4326 function with the following spec:
4328 @smallexample @c ada
4329 function @var{S}'Enum_Rep (Arg : @var{S}'Base)
4330   return @i{Universal_Integer};
4331 @end smallexample
4333 @noindent
4334 It is also allowable to apply @code{Enum_Rep} directly to an object of an
4335 enumeration type or to a non-overloaded enumeration
4336 literal.  In this case @code{@var{S}'Enum_Rep} is equivalent to
4337 @code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
4338 enumeration literal or object.
4340 The function returns the representation value for the given enumeration
4341 value.  This will be equal to value of the @code{Pos} attribute in the
4342 absence of an enumeration representation clause.  This is a static
4343 attribute (i.e.@: the result is static if the argument is static).
4345 @code{@var{S}'Enum_Rep} can also be used with integer types and objects,
4346 in which case it simply returns the integer value.  The reason for this
4347 is to allow it to be used for @code{(<>)} discrete formal arguments in
4348 a generic unit that can be instantiated with either enumeration types
4349 or integer types.  Note that if @code{Enum_Rep} is used on a modular
4350 type whose upper bound exceeds the upper bound of the largest signed
4351 integer type, and the argument is a variable, so that the universal
4352 integer calculation is done at run-time, then the call to @code{Enum_Rep}
4353 may raise @code{Constraint_Error}.
4355 @node Epsilon
4356 @unnumberedsec Epsilon
4357 @cindex Ada 83 attributes
4358 @findex Epsilon
4359 @noindent
4360 The @code{Epsilon} attribute is provided for compatibility with Ada 83.  See
4361 the Ada 83 reference manual for an exact description of the semantics of
4362 this attribute.
4364 @node Fixed_Value
4365 @unnumberedsec Fixed_Value
4366 @findex Fixed_Value
4367 @noindent
4368 For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
4369 function with the following specification:
4371 @smallexample @c ada
4372 function @var{S}'Fixed_Value (Arg : @i{Universal_Integer})
4373   return @var{S};
4374 @end smallexample
4376 @noindent
4377 The value returned is the fixed-point value @var{V} such that
4379 @smallexample @c ada
4380 @var{V} = Arg * @var{S}'Small
4381 @end smallexample
4383 @noindent
4384 The effect is thus similar to first converting the argument to the
4385 integer type used to represent @var{S}, and then doing an unchecked
4386 conversion to the fixed-point type.  The difference is
4387 that there are full range checks, to ensure that the result is in range.
4388 This attribute is primarily intended for use in implementation of the
4389 input-output functions for fixed-point values.
4391 @node Has_Access_Values
4392 @unnumberedsec Has_Access_Values
4393 @cindex Access values, testing for
4394 @findex Has_Access_Values
4395 @noindent
4396 The prefix of the @code{Has_Access_Values} attribute is a type.  The result
4397 is a Boolean value which is True if the is an access type, or is a composite
4398 type with a component (at any nesting depth) that is an access type, and is
4399 False otherwise.
4400 The intended use of this attribute is in conjunction with generic
4401 definitions.  If the attribute is applied to a generic private type, it
4402 indicates whether or not the corresponding actual type has access values.
4404 @node Has_Discriminants
4405 @unnumberedsec Has_Discriminants
4406 @cindex Discriminants, testing for
4407 @findex Has_Discriminants
4408 @noindent
4409 The prefix of the @code{Has_Discriminants} attribute is a type.  The result
4410 is a Boolean value which is True if the type has discriminants, and False
4411 otherwise.  The intended use of this attribute is in conjunction with generic
4412 definitions.  If the attribute is applied to a generic private type, it
4413 indicates whether or not the corresponding actual type has discriminants.
4415 @node Img
4416 @unnumberedsec Img
4417 @findex Img
4418 @noindent
4419 The @code{Img} attribute differs from @code{Image} in that it may be
4420 applied to objects as well as types, in which case it gives the
4421 @code{Image} for the subtype of the object.  This is convenient for
4422 debugging:
4424 @smallexample @c ada
4425 Put_Line ("X = " & X'Img);
4426 @end smallexample
4428 @noindent
4429 has the same meaning as the more verbose:
4431 @smallexample @c ada
4432 Put_Line ("X = " & @var{T}'Image (X));
4433 @end smallexample
4435 @noindent
4436 where @var{T} is the (sub)type of the object @code{X}.
4438 @node Integer_Value
4439 @unnumberedsec Integer_Value
4440 @findex Integer_Value
4441 @noindent
4442 For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
4443 function with the following spec:
4445 @smallexample @c ada
4446 function @var{S}'Integer_Value (Arg : @i{Universal_Fixed})
4447   return @var{S};
4448 @end smallexample
4450 @noindent
4451 The value returned is the integer value @var{V}, such that
4453 @smallexample @c ada
4454 Arg = @var{V} * @var{T}'Small
4455 @end smallexample
4457 @noindent
4458 where @var{T} is the type of @code{Arg}.
4459 The effect is thus similar to first doing an unchecked conversion from
4460 the fixed-point type to its corresponding implementation type, and then
4461 converting the result to the target integer type.  The difference is
4462 that there are full range checks, to ensure that the result is in range.
4463 This attribute is primarily intended for use in implementation of the
4464 standard input-output functions for fixed-point values.
4466 @node Large
4467 @unnumberedsec Large
4468 @cindex Ada 83 attributes
4469 @findex Large
4470 @noindent
4471 The @code{Large} attribute is provided for compatibility with Ada 83.  See
4472 the Ada 83 reference manual for an exact description of the semantics of
4473 this attribute.
4475 @node Machine_Size
4476 @unnumberedsec Machine_Size
4477 @findex Machine_Size
4478 @noindent
4479 This attribute is identical to the @code{Object_Size} attribute.  It is
4480 provided for compatibility with the DEC Ada 83 attribute of this name.
4482 @node Mantissa
4483 @unnumberedsec Mantissa
4484 @cindex Ada 83 attributes
4485 @findex Mantissa
4486 @noindent
4487 The @code{Mantissa} attribute is provided for compatibility with Ada 83.  See
4488 the Ada 83 reference manual for an exact description of the semantics of
4489 this attribute.
4491 @node Max_Interrupt_Priority
4492 @unnumberedsec Max_Interrupt_Priority
4493 @cindex Interrupt priority, maximum
4494 @findex Max_Interrupt_Priority
4495 @noindent
4496 @code{Standard'Max_Interrupt_Priority} (@code{Standard} is the only
4497 permissible prefix), provides the same value as
4498 @code{System.Max_Interrupt_Priority}.
4500 @node Max_Priority
4501 @unnumberedsec Max_Priority
4502 @cindex Priority, maximum
4503 @findex Max_Priority
4504 @noindent
4505 @code{Standard'Max_Priority} (@code{Standard} is the only permissible
4506 prefix) provides the same value as @code{System.Max_Priority}.
4508 @node Maximum_Alignment
4509 @unnumberedsec Maximum_Alignment
4510 @cindex Alignment, maximum
4511 @findex Maximum_Alignment
4512 @noindent
4513 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
4514 permissible prefix) provides the maximum useful alignment value for the
4515 target.  This is a static value that can be used to specify the alignment
4516 for an object, guaranteeing that it is properly aligned in all
4517 cases.
4519 @node Mechanism_Code
4520 @unnumberedsec Mechanism_Code
4521 @cindex Return values, passing mechanism
4522 @cindex Parameters, passing mechanism
4523 @findex Mechanism_Code
4524 @noindent
4525 @code{@var{function}'Mechanism_Code} yields an integer code for the
4526 mechanism used for the result of function, and
4527 @code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
4528 used for formal parameter number @var{n} (a static integer value with 1
4529 meaning the first parameter) of @var{subprogram}.  The code returned is:
4531 @table @asis
4532 @item 1
4533 by copy (value)
4534 @item 2
4535 by reference
4536 @item 3
4537 by descriptor (default descriptor class)
4538 @item 4
4539 by descriptor (UBS: unaligned bit string)
4540 @item 5
4541 by descriptor (UBSB: aligned bit string with arbitrary bounds)
4542 @item 6
4543 by descriptor (UBA: unaligned bit array)
4544 @item 7
4545 by descriptor (S: string, also scalar access type parameter)
4546 @item 8
4547 by descriptor (SB: string with arbitrary bounds)
4548 @item 9
4549 by descriptor (A: contiguous array)
4550 @item 10
4551 by descriptor (NCA: non-contiguous array)
4552 @end table
4554 @noindent
4555 Values from 3 through 10 are only relevant to Digital OpenVMS implementations.
4556 @cindex OpenVMS
4558 @node Null_Parameter
4559 @unnumberedsec Null_Parameter
4560 @cindex Zero address, passing
4561 @findex Null_Parameter
4562 @noindent
4563 A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
4564 type or subtype @var{T} allocated at machine address zero.  The attribute
4565 is allowed only as the default expression of a formal parameter, or as
4566 an actual expression of a subprogram call.  In either case, the
4567 subprogram must be imported.
4569 The identity of the object is represented by the address zero in the
4570 argument list, independent of the passing mechanism (explicit or
4571 default).
4573 This capability is needed to specify that a zero address should be
4574 passed for a record or other composite object passed by reference.
4575 There is no way of indicating this without the @code{Null_Parameter}
4576 attribute.
4578 @node Object_Size
4579 @unnumberedsec Object_Size
4580 @cindex Size, used for objects
4581 @findex Object_Size
4582 @noindent
4583 The size of an object is not necessarily the same as the size of the type
4584 of an object.  This is because by default object sizes are increased to be
4585 a multiple of the alignment of the object.  For example,
4586 @code{Natural'Size} is
4587 31, but by default objects of type @code{Natural} will have a size of 32 bits.
4588 Similarly, a record containing an integer and a character:
4590 @smallexample @c ada
4591 type Rec is record
4592    I : Integer;
4593    C : Character;
4594 end record;
4595 @end smallexample
4597 @noindent
4598 will have a size of 40 (that is @code{Rec'Size} will be 40.  The
4599 alignment will be 4, because of the
4600 integer field, and so the default size of record objects for this type
4601 will be 64 (8 bytes).
4603 The @code{@var{type}'Object_Size} attribute
4604 has been added to GNAT to allow the
4605 default object size of a type to be easily determined.  For example,
4606 @code{Natural'Object_Size} is 32, and
4607 @code{Rec'Object_Size} (for the record type in the above example) will be
4608 64.  Note also that, unlike the situation with the
4609 @code{Size} attribute as defined in the Ada RM, the
4610 @code{Object_Size} attribute can be specified individually
4611 for different subtypes.  For example:
4613 @smallexample @c ada
4614 type R is new Integer;
4615 subtype R1 is R range 1 .. 10;
4616 subtype R2 is R range 1 .. 10;
4617 for R2'Object_Size use 8;
4618 @end smallexample
4620 @noindent
4621 In this example, @code{R'Object_Size} and @code{R1'Object_Size} are both
4622 32 since the default object size for a subtype is the same as the object size
4623 for the parent subtype.  This means that objects of type @code{R}
4624 or @code{R1} will
4625 by default be 32 bits (four bytes).  But objects of type
4626 @code{R2} will be only
4627 8 bits (one byte), since @code{R2'Object_Size} has been set to 8.
4629 @node Passed_By_Reference
4630 @unnumberedsec Passed_By_Reference
4631 @cindex Parameters, when passed by reference
4632 @findex Passed_By_Reference
4633 @noindent
4634 @code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
4635 a value of type @code{Boolean} value that is @code{True} if the type is
4636 normally passed by reference and @code{False} if the type is normally
4637 passed by copy in calls.  For scalar types, the result is always @code{False}
4638 and is static.  For non-scalar types, the result is non-static.
4640 @node Range_Length
4641 @unnumberedsec Range_Length
4642 @findex Range_Length
4643 @noindent
4644 @code{@var{type}'Range_Length} for any discrete type @var{type} yields
4645 the number of values represented by the subtype (zero for a null
4646 range).  The result is static for static subtypes.  @code{Range_Length}
4647 applied to the index subtype of a one dimensional array always gives the
4648 same result as @code{Range} applied to the array itself.
4650 @node Safe_Emax
4651 @unnumberedsec Safe_Emax
4652 @cindex Ada 83 attributes
4653 @findex Safe_Emax
4654 @noindent
4655 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83.  See
4656 the Ada 83 reference manual for an exact description of the semantics of
4657 this attribute.
4659 @node Safe_Large
4660 @unnumberedsec Safe_Large
4661 @cindex Ada 83 attributes
4662 @findex Safe_Large
4663 @noindent
4664 The @code{Safe_Large} attribute is provided for compatibility with Ada 83.  See
4665 the Ada 83 reference manual for an exact description of the semantics of
4666 this attribute.
4668 @node Small
4669 @unnumberedsec Small
4670 @cindex Ada 83 attributes
4671 @findex Small
4672 @noindent
4673 The @code{Small} attribute is defined in Ada 95 only for fixed-point types.
4674 GNAT also allows this attribute to be applied to floating-point types
4675 for compatibility with Ada 83.  See
4676 the Ada 83 reference manual for an exact description of the semantics of
4677 this attribute when applied to floating-point types.
4679 @node Storage_Unit
4680 @unnumberedsec Storage_Unit
4681 @findex Storage_Unit
4682 @noindent
4683 @code{Standard'Storage_Unit} (@code{Standard} is the only permissible
4684 prefix) provides the same value as @code{System.Storage_Unit}.
4686 @node Target_Name
4687 @unnumberedsec Target_Name
4688 @findex Target_Name
4689 @noindent
4690 @code{Standard'Target_Name} (@code{Standard} is the only permissible
4691 prefix) provides a static string value that identifies the target
4692 for the current compilation. For GCC implementations, this is the
4693 standard gcc target name without the terminating slash (for
4694 example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
4696 @node Tick
4697 @unnumberedsec Tick
4698 @findex Tick
4699 @noindent
4700 @code{Standard'Tick} (@code{Standard} is the only permissible prefix)
4701 provides the same value as @code{System.Tick},
4703 @node To_Address
4704 @unnumberedsec To_Address
4705 @findex To_Address
4706 @noindent
4707 The @code{System'To_Address}
4708 (@code{System} is the only permissible prefix)
4709 denotes a function identical to
4710 @code{System.Storage_Elements.To_Address} except that
4711 it is a static attribute.  This means that if its argument is
4712 a static expression, then the result of the attribute is a
4713 static expression.  The result is that such an expression can be
4714 used in contexts (e.g.@: preelaborable packages) which require a
4715 static expression and where the function call could not be used
4716 (since the function call is always non-static, even if its
4717 argument is static).
4719 @node Type_Class
4720 @unnumberedsec Type_Class
4721 @findex Type_Class
4722 @noindent
4723 @code{@var{type}'Type_Class} for any type or subtype @var{type} yields
4724 the value of the type class for the full type of @var{type}.  If
4725 @var{type} is a generic formal type, the value is the value for the
4726 corresponding actual subtype.  The value of this attribute is of type
4727 @code{System.Aux_DEC.Type_Class}, which has the following definition:
4729 @smallexample @c ada
4730   type Type_Class is
4731     (Type_Class_Enumeration,
4732      Type_Class_Integer,
4733      Type_Class_Fixed_Point,
4734      Type_Class_Floating_Point,
4735      Type_Class_Array,
4736      Type_Class_Record,
4737      Type_Class_Access,
4738      Type_Class_Task,
4739      Type_Class_Address);
4740 @end smallexample
4742 @noindent
4743 Protected types yield the value @code{Type_Class_Task}, which thus
4744 applies to all concurrent types.  This attribute is designed to
4745 be compatible with the DEC Ada 83 attribute of the same name.
4747 @node UET_Address
4748 @unnumberedsec UET_Address
4749 @findex UET_Address
4750 @noindent
4751 The @code{UET_Address} attribute can only be used for a prefix which
4752 denotes a library package.  It yields the address of the unit exception
4753 table when zero cost exception handling is used.  This attribute is
4754 intended only for use within the GNAT implementation.  See the unit
4755 @code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb}
4756 for details on how this attribute is used in the implementation.
4758 @node Unconstrained_Array
4759 @unnumberedsec Unconstrained_Array
4760 @findex Unconstrained_Array
4761 @noindent
4762 The @code{Unconstrained_Array} attribute can be used with a prefix that
4763 denotes any type or subtype. It is a static attribute that yields
4764 @code{True} if the prefix designates an unconstrained array,
4765 and @code{False} otherwise. In a generic instance, the result is
4766 still static, and yields the result of applying this test to the
4767 generic actual.
4769 @node Universal_Literal_String
4770 @unnumberedsec Universal_Literal_String
4771 @cindex Named numbers, representation of
4772 @findex Universal_Literal_String
4773 @noindent
4774 The prefix of @code{Universal_Literal_String} must be a named
4775 number.  The static result is the string consisting of the characters of
4776 the number as defined in the original source.  This allows the user
4777 program to access the actual text of named numbers without intermediate
4778 conversions and without the need to enclose the strings in quotes (which
4779 would preclude their use as numbers).  This is used internally for the
4780 construction of values of the floating-point attributes from the file
4781 @file{ttypef.ads}, but may also be used by user programs.
4783 @node Unrestricted_Access
4784 @unnumberedsec Unrestricted_Access
4785 @cindex @code{Access}, unrestricted
4786 @findex Unrestricted_Access
4787 @noindent
4788 The @code{Unrestricted_Access} attribute is similar to @code{Access}
4789 except that all accessibility and aliased view checks are omitted.  This
4790 is a user-beware attribute.  It is similar to
4791 @code{Address}, for which it is a desirable replacement where the value
4792 desired is an access type.  In other words, its effect is identical to
4793 first applying the @code{Address} attribute and then doing an unchecked
4794 conversion to a desired access type.  In GNAT, but not necessarily in
4795 other implementations, the use of static chains for inner level
4796 subprograms means that @code{Unrestricted_Access} applied to a
4797 subprogram yields a value that can be called as long as the subprogram
4798 is in scope (normal Ada 95 accessibility rules restrict this usage).
4800 It is possible to use @code{Unrestricted_Access} for any type, but care
4801 must be excercised if it is used to create pointers to unconstrained
4802 objects. In this case, the resulting pointer has the same scope as the
4803 context of the attribute, and may not be returned to some enclosing
4804 scope. For instance, a function cannot use @code{Unrestricted_Access}
4805 to create a unconstrained pointer and then return that value to the
4806 caller.
4808 @node VADS_Size
4809 @unnumberedsec VADS_Size
4810 @cindex @code{Size}, VADS compatibility
4811 @findex VADS_Size
4812 @noindent
4813 The @code{'VADS_Size} attribute is intended to make it easier to port
4814 legacy code which relies on the semantics of @code{'Size} as implemented
4815 by the VADS Ada 83 compiler.  GNAT makes a best effort at duplicating the
4816 same semantic interpretation.  In particular, @code{'VADS_Size} applied
4817 to a predefined or other primitive type with no Size clause yields the
4818 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
4819 typical machines).  In addition @code{'VADS_Size} applied to an object
4820 gives the result that would be obtained by applying the attribute to
4821 the corresponding type.
4823 @node Value_Size
4824 @unnumberedsec Value_Size
4825 @cindex @code{Size}, setting for not-first subtype
4826 @findex Value_Size
4827 @code{@var{type}'Value_Size} is the number of bits required to represent
4828 a value of the given subtype.  It is the same as @code{@var{type}'Size},
4829 but, unlike @code{Size}, may be set for non-first subtypes.
4831 @node Wchar_T_Size
4832 @unnumberedsec Wchar_T_Size
4833 @findex Wchar_T_Size
4834 @code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
4835 prefix) provides the size in bits of the C @code{wchar_t} type
4836 primarily for constructing the definition of this type in
4837 package @code{Interfaces.C}.
4839 @node Word_Size
4840 @unnumberedsec Word_Size
4841 @findex Word_Size
4842 @code{Standard'Word_Size} (@code{Standard} is the only permissible
4843 prefix) provides the value @code{System.Word_Size}.
4845 @c ------------------------
4846 @node Implementation Advice
4847 @chapter Implementation Advice
4848 @noindent
4849 The main text of the Ada 95 Reference Manual describes the required
4850 behavior of all Ada 95 compilers, and the GNAT compiler conforms to
4851 these requirements.
4853 In addition, there are sections throughout the Ada 95
4854 reference manual headed
4855 by the phrase ``implementation advice''.  These sections are not normative,
4856 i.e.@: they do not specify requirements that all compilers must
4857 follow.  Rather they provide advice on generally desirable behavior.  You
4858 may wonder why they are not requirements.  The most typical answer is
4859 that they describe behavior that seems generally desirable, but cannot
4860 be provided on all systems, or which may be undesirable on some systems.
4862 As far as practical, GNAT follows the implementation advice sections in
4863 the Ada 95 Reference Manual.  This chapter contains a table giving the
4864 reference manual section number, paragraph number and several keywords
4865 for each advice.  Each entry consists of the text of the advice followed
4866 by the GNAT interpretation of this advice.  Most often, this simply says
4867 ``followed'', which means that GNAT follows the advice.  However, in a
4868 number of cases, GNAT deliberately deviates from this advice, in which
4869 case the text describes what GNAT does and why.
4871 @cindex Error detection
4872 @unnumberedsec 1.1.3(20): Error Detection
4873 @sp 1
4874 @cartouche
4875 If an implementation detects the use of an unsupported Specialized Needs
4876 Annex feature at run time, it should raise @code{Program_Error} if
4877 feasible.
4878 @end cartouche
4879 Not relevant.  All specialized needs annex features are either supported,
4880 or diagnosed at compile time.
4882 @cindex Child Units
4883 @unnumberedsec 1.1.3(31): Child Units
4884 @sp 1
4885 @cartouche
4886 If an implementation wishes to provide implementation-defined
4887 extensions to the functionality of a language-defined library unit, it
4888 should normally do so by adding children to the library unit.
4889 @end cartouche
4890 Followed.
4892 @cindex Bounded errors
4893 @unnumberedsec 1.1.5(12): Bounded Errors
4894 @sp 1
4895 @cartouche
4896 If an implementation detects a bounded error or erroneous
4897 execution, it should raise @code{Program_Error}.
4898 @end cartouche
4899 Followed in all cases in which the implementation detects a bounded
4900 error or erroneous execution.  Not all such situations are detected at
4901 runtime.
4903 @cindex Pragmas
4904 @unnumberedsec 2.8(16): Pragmas
4905 @sp 1
4906 @cartouche
4907 Normally, implementation-defined pragmas should have no semantic effect
4908 for error-free programs; that is, if the implementation-defined pragmas
4909 are removed from a working program, the program should still be legal,
4910 and should still have the same semantics.
4911 @end cartouche
4912 The following implementation defined pragmas are exceptions to this
4913 rule:
4915 @table @code
4916 @item Abort_Defer
4917 Affects semantics
4918 @item Ada_83
4919 Affects legality
4920 @item Assert
4921 Affects semantics
4922 @item CPP_Class
4923 Affects semantics
4924 @item CPP_Constructor
4925 Affects semantics
4926 @item CPP_Virtual
4927 Affects semantics
4928 @item CPP_Vtable
4929 Affects semantics
4930 @item Debug
4931 Affects semantics
4932 @item Interface_Name
4933 Affects semantics
4934 @item Machine_Attribute
4935 Affects semantics
4936 @item Unimplemented_Unit
4937 Affects legality
4938 @item Unchecked_Union
4939 Affects semantics
4940 @end table
4942 @noindent
4943 In each of the above cases, it is essential to the purpose of the pragma
4944 that this advice not be followed.  For details see the separate section
4945 on implementation defined pragmas.
4947 @unnumberedsec 2.8(17-19): Pragmas
4948 @sp 1
4949 @cartouche
4950 Normally, an implementation should not define pragmas that can
4951 make an illegal program legal, except as follows:
4952 @end cartouche
4953 @sp 1
4954 @cartouche
4955 A pragma used to complete a declaration, such as a pragma @code{Import};
4956 @end cartouche
4957 @sp 1
4958 @cartouche
4959 A pragma used to configure the environment by adding, removing, or
4960 replacing @code{library_items}.
4961 @end cartouche
4962 See response to paragraph 16 of this same section.
4964 @cindex Character Sets
4965 @cindex Alternative Character Sets
4966 @unnumberedsec 3.5.2(5): Alternative Character Sets
4967 @sp 1
4968 @cartouche
4969 If an implementation supports a mode with alternative interpretations
4970 for @code{Character} and @code{Wide_Character}, the set of graphic
4971 characters of @code{Character} should nevertheless remain a proper
4972 subset of the set of graphic characters of @code{Wide_Character}.  Any
4973 character set ``localizations'' should be reflected in the results of
4974 the subprograms defined in the language-defined package
4975 @code{Characters.Handling} (see A.3) available in such a mode.  In a mode with
4976 an alternative interpretation of @code{Character}, the implementation should
4977 also support a corresponding change in what is a legal
4978 @code{identifier_letter}.
4979 @end cartouche
4980 Not all wide character modes follow this advice, in particular the JIS
4981 and IEC modes reflect standard usage in Japan, and in these encoding,
4982 the upper half of the Latin-1 set is not part of the wide-character
4983 subset, since the most significant bit is used for wide character
4984 encoding.  However, this only applies to the external forms.  Internally
4985 there is no such restriction.
4987 @cindex Integer types
4988 @unnumberedsec 3.5.4(28): Integer Types
4990 @sp 1
4991 @cartouche
4992 An implementation should support @code{Long_Integer} in addition to
4993 @code{Integer} if the target machine supports 32-bit (or longer)
4994 arithmetic.  No other named integer subtypes are recommended for package
4995 @code{Standard}.  Instead, appropriate named integer subtypes should be
4996 provided in the library package @code{Interfaces} (see B.2).
4997 @end cartouche
4998 @code{Long_Integer} is supported.  Other standard integer types are supported
4999 so this advice is not fully followed.  These types
5000 are supported for convenient interface to C, and so that all hardware
5001 types of the machine are easily available.
5002 @unnumberedsec 3.5.4(29): Integer Types
5004 @sp 1
5005 @cartouche
5006 An implementation for a two's complement machine should support
5007 modular types with a binary modulus up to @code{System.Max_Int*2+2}.  An
5008 implementation should support a non-binary modules up to @code{Integer'Last}.
5009 @end cartouche
5010 Followed.
5012 @cindex Enumeration values
5013 @unnumberedsec 3.5.5(8): Enumeration Values
5014 @sp 1
5015 @cartouche
5016 For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
5017 subtype, if the value of the operand does not correspond to the internal
5018 code for any enumeration literal of its type (perhaps due to an
5019 un-initialized variable), then the implementation should raise
5020 @code{Program_Error}.  This is particularly important for enumeration
5021 types with noncontiguous internal codes specified by an
5022 enumeration_representation_clause.
5023 @end cartouche
5024 Followed.
5026 @cindex Float types
5027 @unnumberedsec 3.5.7(17): Float Types
5028 @sp 1
5029 @cartouche
5030 An implementation should support @code{Long_Float} in addition to
5031 @code{Float} if the target machine supports 11 or more digits of
5032 precision.  No other named floating point subtypes are recommended for
5033 package @code{Standard}.  Instead, appropriate named floating point subtypes
5034 should be provided in the library package @code{Interfaces} (see B.2).
5035 @end cartouche
5036 @code{Short_Float} and @code{Long_Long_Float} are also provided.  The
5037 former provides improved compatibility with other implementations
5038 supporting this type.  The latter corresponds to the highest precision
5039 floating-point type supported by the hardware.  On most machines, this
5040 will be the same as @code{Long_Float}, but on some machines, it will
5041 correspond to the IEEE extended form.  The notable case is all ia32
5042 (x86) implementations, where @code{Long_Long_Float} corresponds to
5043 the 80-bit extended precision format supported in hardware on this
5044 processor.  Note that the 128-bit format on SPARC is not supported,
5045 since this is a software rather than a hardware format.
5047 @cindex Multidimensional arrays
5048 @cindex Arrays, multidimensional
5049 @unnumberedsec 3.6.2(11): Multidimensional Arrays
5050 @sp 1
5051 @cartouche
5052 An implementation should normally represent multidimensional arrays in
5053 row-major order, consistent with the notation used for multidimensional
5054 array aggregates (see 4.3.3).  However, if a pragma @code{Convention}
5055 (@code{Fortran}, @dots{}) applies to a multidimensional array type, then
5056 column-major order should be used instead (see B.5, ``Interfacing with
5057 Fortran'').
5058 @end cartouche
5059 Followed.
5061 @findex Duration'Small
5062 @unnumberedsec 9.6(30-31): Duration'Small
5063 @sp 1
5064 @cartouche
5065 Whenever possible in an implementation, the value of @code{Duration'Small}
5066 should be no greater than 100 microseconds.
5067 @end cartouche
5068 Followed.  (@code{Duration'Small} = 10**(@minus{}9)).
5070 @sp 1
5071 @cartouche
5072 The time base for @code{delay_relative_statements} should be monotonic;
5073 it need not be the same time base as used for @code{Calendar.Clock}.
5074 @end cartouche
5075 Followed.
5077 @unnumberedsec 10.2.1(12): Consistent Representation
5078 @sp 1
5079 @cartouche
5080 In an implementation, a type declared in a pre-elaborated package should
5081 have the same representation in every elaboration of a given version of
5082 the package, whether the elaborations occur in distinct executions of
5083 the same program, or in executions of distinct programs or partitions
5084 that include the given version.
5085 @end cartouche
5086 Followed, except in the case of tagged types.  Tagged types involve
5087 implicit pointers to a local copy of a dispatch table, and these pointers
5088 have representations which thus depend on a particular elaboration of the
5089 package.  It is not easy to see how it would be possible to follow this
5090 advice without severely impacting efficiency of execution.
5092 @cindex Exception information
5093 @unnumberedsec 11.4.1(19): Exception Information
5094 @sp 1
5095 @cartouche
5096 @code{Exception_Message} by default and @code{Exception_Information}
5097 should produce information useful for
5098 debugging.  @code{Exception_Message} should be short, about one
5099 line.  @code{Exception_Information} can be long.  @code{Exception_Message}
5100 should not include the
5101 @code{Exception_Name}.  @code{Exception_Information} should include both
5102 the @code{Exception_Name} and the @code{Exception_Message}.
5103 @end cartouche
5104 Followed.  For each exception that doesn't have a specified
5105 @code{Exception_Message}, the compiler generates one containing the location
5106 of the raise statement.  This location has the form ``file:line'', where
5107 file is the short file name (without path information) and line is the line
5108 number in the file.  Note that in the case of the Zero Cost Exception
5109 mechanism, these messages become redundant with the Exception_Information that
5110 contains a full backtrace of the calling sequence, so they are disabled.
5111 To disable explicitly the generation of the source location message, use the
5112 Pragma @code{Discard_Names}.
5114 @cindex Suppression of checks
5115 @cindex Checks, suppression of
5116 @unnumberedsec 11.5(28): Suppression of Checks
5117 @sp 1
5118 @cartouche
5119 The implementation should minimize the code executed for checks that
5120 have been suppressed.
5121 @end cartouche
5122 Followed.
5124 @cindex Representation clauses
5125 @unnumberedsec 13.1 (21-24): Representation Clauses
5126 @sp 1
5127 @cartouche
5128 The recommended level of support for all representation items is
5129 qualified as follows:
5130 @end cartouche
5131 @sp 1
5132 @cartouche
5133 An implementation need not support representation items containing
5134 non-static expressions, except that an implementation should support a
5135 representation item for a given entity if each non-static expression in
5136 the representation item is a name that statically denotes a constant
5137 declared before the entity.
5138 @end cartouche
5139 Followed.  GNAT does not support non-static expressions in representation
5140 clauses unless they are constants declared before the entity.  For
5141 example:
5143 @smallexample @c ada
5144 X : Some_Type;
5145 for X'Address use To_address (16#2000#);
5146 @end smallexample
5148 @noindent
5149 will be rejected, since the To_Address expression is non-static.  Instead
5150 write:
5152 @smallexample @c ada
5153 X_Address : constant Address : = To_Address (16#2000#);
5154 X         : Some_Type;
5155 for X'Address use X_Address;
5156 @end smallexample
5158 @sp 1
5159 @cartouche
5160 An implementation need not support a specification for the @code{Size}
5161 for a given composite subtype, nor the size or storage place for an
5162 object (including a component) of a given composite subtype, unless the
5163 constraints on the subtype and its composite subcomponents (if any) are
5164 all static constraints.
5165 @end cartouche
5166 Followed.  Size Clauses are not permitted on non-static components, as
5167 described above.
5169 @sp 1
5170 @cartouche
5171 An aliased component, or a component whose type is by-reference, should
5172 always be allocated at an addressable location.
5173 @end cartouche
5174 Followed.
5176 @cindex Packed types
5177 @unnumberedsec 13.2(6-8): Packed Types
5178 @sp 1
5179 @cartouche
5180 If a type is packed, then the implementation should try to minimize
5181 storage allocated to objects of the type, possibly at the expense of
5182 speed of accessing components, subject to reasonable complexity in
5183 addressing calculations.
5184 @end cartouche
5185 @sp 1
5186 @cartouche
5187 The recommended level of support pragma @code{Pack} is:
5189 For a packed record type, the components should be packed as tightly as
5190 possible subject to the Sizes of the component subtypes, and subject to
5191 any @code{record_representation_clause} that applies to the type; the
5192 implementation may, but need not, reorder components or cross aligned
5193 word boundaries to improve the packing.  A component whose @code{Size} is
5194 greater than the word size may be allocated an integral number of words.
5195 @end cartouche
5196 Followed.  Tight packing of arrays is supported for all component sizes
5197 up to 64-bits. If the array component size is 1 (that is to say, if
5198 the component is a boolean type or an enumeration type with two values)
5199 then values of the type are implicitly initialized to zero. This
5200 happens both for objects of the packed type, and for objects that have a
5201 subcomponent of the packed type.
5203 @sp 1
5204 @cartouche
5205 An implementation should support Address clauses for imported
5206 subprograms.
5207 @end cartouche
5208 Followed.
5209 @cindex @code{Address} clauses
5210 @unnumberedsec 13.3(14-19): Address Clauses
5212 @sp 1
5213 @cartouche
5214 For an array @var{X}, @code{@var{X}'Address} should point at the first
5215 component of the array, and not at the array bounds.
5216 @end cartouche
5217 Followed.
5219 @sp 1
5220 @cartouche
5221 The recommended level of support for the @code{Address} attribute is:
5223 @code{@var{X}'Address} should produce a useful result if @var{X} is an
5224 object that is aliased or of a by-reference type, or is an entity whose
5225 @code{Address} has been specified.
5226 @end cartouche
5227 Followed.  A valid address will be produced even if none of those
5228 conditions have been met.  If necessary, the object is forced into
5229 memory to ensure the address is valid.
5231 @sp 1
5232 @cartouche
5233 An implementation should support @code{Address} clauses for imported
5234 subprograms.
5235 @end cartouche
5236 Followed.
5238 @sp 1
5239 @cartouche
5240 Objects (including subcomponents) that are aliased or of a by-reference
5241 type should be allocated on storage element boundaries.
5242 @end cartouche
5243 Followed.
5245 @sp 1
5246 @cartouche
5247 If the @code{Address} of an object is specified, or it is imported or exported,
5248 then the implementation should not perform optimizations based on
5249 assumptions of no aliases.
5250 @end cartouche
5251 Followed.
5253 @cindex @code{Alignment} clauses
5254 @unnumberedsec 13.3(29-35): Alignment Clauses
5255 @sp 1
5256 @cartouche
5257 The recommended level of support for the @code{Alignment} attribute for
5258 subtypes is:
5260 An implementation should support specified Alignments that are factors
5261 and multiples of the number of storage elements per word, subject to the
5262 following:
5263 @end cartouche
5264 Followed.
5266 @sp 1
5267 @cartouche
5268 An implementation need not support specified @code{Alignment}s for
5269 combinations of @code{Size}s and @code{Alignment}s that cannot be easily
5270 loaded and stored by available machine instructions.
5271 @end cartouche
5272 Followed.
5274 @sp 1
5275 @cartouche
5276 An implementation need not support specified @code{Alignment}s that are
5277 greater than the maximum @code{Alignment} the implementation ever returns by
5278 default.
5279 @end cartouche
5280 Followed.
5282 @sp 1
5283 @cartouche
5284 The recommended level of support for the @code{Alignment} attribute for
5285 objects is:
5287 Same as above, for subtypes, but in addition:
5288 @end cartouche
5289 Followed.
5291 @sp 1
5292 @cartouche
5293 For stand-alone library-level objects of statically constrained
5294 subtypes, the implementation should support all @code{Alignment}s
5295 supported by the target linker.  For example, page alignment is likely to
5296 be supported for such objects, but not for subtypes.
5297 @end cartouche
5298 Followed.
5300 @cindex @code{Size} clauses
5301 @unnumberedsec 13.3(42-43): Size Clauses
5302 @sp 1
5303 @cartouche
5304 The recommended level of support for the @code{Size} attribute of
5305 objects is:
5307 A @code{Size} clause should be supported for an object if the specified
5308 @code{Size} is at least as large as its subtype's @code{Size}, and
5309 corresponds to a size in storage elements that is a multiple of the
5310 object's @code{Alignment} (if the @code{Alignment} is nonzero).
5311 @end cartouche
5312 Followed.
5314 @unnumberedsec 13.3(50-56): Size Clauses
5315 @sp 1
5316 @cartouche
5317 If the @code{Size} of a subtype is specified, and allows for efficient
5318 independent addressability (see 9.10) on the target architecture, then
5319 the @code{Size} of the following objects of the subtype should equal the
5320 @code{Size} of the subtype:
5322 Aliased objects (including components).
5323 @end cartouche
5324 Followed.
5326 @sp 1
5327 @cartouche
5328 @code{Size} clause on a composite subtype should not affect the
5329 internal layout of components.
5330 @end cartouche
5331 Followed.
5333 @sp 1
5334 @cartouche
5335 The recommended level of support for the @code{Size} attribute of subtypes is:
5336 @end cartouche
5337 @sp 1
5338 @cartouche
5339 The @code{Size} (if not specified) of a static discrete or fixed point
5340 subtype should be the number of bits needed to represent each value
5341 belonging to the subtype using an unbiased representation, leaving space
5342 for a sign bit only if the subtype contains negative values.  If such a
5343 subtype is a first subtype, then an implementation should support a
5344 specified @code{Size} for it that reflects this representation.
5345 @end cartouche
5346 Followed.
5348 @sp 1
5349 @cartouche
5350 For a subtype implemented with levels of indirection, the @code{Size}
5351 should include the size of the pointers, but not the size of what they
5352 point at.
5353 @end cartouche
5354 Followed.
5356 @cindex @code{Component_Size} clauses
5357 @unnumberedsec 13.3(71-73): Component Size Clauses
5358 @sp 1
5359 @cartouche
5360 The recommended level of support for the @code{Component_Size}
5361 attribute is:
5362 @end cartouche
5363 @sp 1
5364 @cartouche
5365 An implementation need not support specified @code{Component_Sizes} that are
5366 less than the @code{Size} of the component subtype.
5367 @end cartouche
5368 Followed.
5370 @sp 1
5371 @cartouche
5372 An implementation should support specified @code{Component_Size}s that
5373 are factors and multiples of the word size.  For such
5374 @code{Component_Size}s, the array should contain no gaps between
5375 components.  For other @code{Component_Size}s (if supported), the array
5376 should contain no gaps between components when packing is also
5377 specified; the implementation should forbid this combination in cases
5378 where it cannot support a no-gaps representation.
5379 @end cartouche
5380 Followed.
5382 @cindex Enumeration representation clauses
5383 @cindex Representation clauses, enumeration
5384 @unnumberedsec 13.4(9-10): Enumeration Representation Clauses
5385 @sp 1
5386 @cartouche
5387 The recommended level of support for enumeration representation clauses
5390 An implementation need not support enumeration representation clauses
5391 for boolean types, but should at minimum support the internal codes in
5392 the range @code{System.Min_Int.System.Max_Int}.
5393 @end cartouche
5394 Followed.
5396 @cindex Record representation clauses
5397 @cindex Representation clauses, records
5398 @unnumberedsec 13.5.1(17-22): Record Representation Clauses
5399 @sp 1
5400 @cartouche
5401 The recommended level of support for
5402 @*@code{record_representation_clauses} is:
5404 An implementation should support storage places that can be extracted
5405 with a load, mask, shift sequence of machine code, and set with a load,
5406 shift, mask, store sequence, given the available machine instructions
5407 and run-time model.
5408 @end cartouche
5409 Followed.
5411 @sp 1
5412 @cartouche
5413 A storage place should be supported if its size is equal to the
5414 @code{Size} of the component subtype, and it starts and ends on a
5415 boundary that obeys the @code{Alignment} of the component subtype.
5416 @end cartouche
5417 Followed.
5419 @sp 1
5420 @cartouche
5421 If the default bit ordering applies to the declaration of a given type,
5422 then for a component whose subtype's @code{Size} is less than the word
5423 size, any storage place that does not cross an aligned word boundary
5424 should be supported.
5425 @end cartouche
5426 Followed.
5428 @sp 1
5429 @cartouche
5430 An implementation may reserve a storage place for the tag field of a
5431 tagged type, and disallow other components from overlapping that place.
5432 @end cartouche
5433 Followed.  The storage place for the tag field is the beginning of the tagged
5434 record, and its size is Address'Size.  GNAT will reject an explicit component
5435 clause for the tag field.
5437 @sp 1
5438 @cartouche
5439 An implementation need not support a @code{component_clause} for a
5440 component of an extension part if the storage place is not after the
5441 storage places of all components of the parent type, whether or not
5442 those storage places had been specified.
5443 @end cartouche
5444 Followed.  The above advice on record representation clauses is followed,
5445 and all mentioned features are implemented.
5447 @cindex Storage place attributes
5448 @unnumberedsec 13.5.2(5): Storage Place Attributes
5449 @sp 1
5450 @cartouche
5451 If a component is represented using some form of pointer (such as an
5452 offset) to the actual data of the component, and this data is contiguous
5453 with the rest of the object, then the storage place attributes should
5454 reflect the place of the actual data, not the pointer.  If a component is
5455 allocated discontinuously from the rest of the object, then a warning
5456 should be generated upon reference to one of its storage place
5457 attributes.
5458 @end cartouche
5459 Followed.  There are no such components in GNAT@.
5461 @cindex Bit ordering
5462 @unnumberedsec 13.5.3(7-8): Bit Ordering
5463 @sp 1
5464 @cartouche
5465 The recommended level of support for the non-default bit ordering is:
5466 @end cartouche
5467 @sp 1
5468 @cartouche
5469 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
5470 should support the non-default bit ordering in addition to the default
5471 bit ordering.
5472 @end cartouche
5473 Followed.  Word size does not equal storage size in this implementation.
5474 Thus non-default bit ordering is not supported.
5476 @cindex @code{Address}, as private type
5477 @unnumberedsec 13.7(37): Address as Private
5478 @sp 1
5479 @cartouche
5480 @code{Address} should be of a private type.
5481 @end cartouche
5482 Followed.
5484 @cindex Operations, on @code{Address}
5485 @cindex @code{Address}, operations of
5486 @unnumberedsec 13.7.1(16): Address Operations
5487 @sp 1
5488 @cartouche
5489 Operations in @code{System} and its children should reflect the target
5490 environment semantics as closely as is reasonable.  For example, on most
5491 machines, it makes sense for address arithmetic to ``wrap around''.
5492 Operations that do not make sense should raise @code{Program_Error}.
5493 @end cartouche
5494 Followed.  Address arithmetic is modular arithmetic that wraps around.  No
5495 operation raises @code{Program_Error}, since all operations make sense.
5497 @cindex Unchecked conversion
5498 @unnumberedsec 13.9(14-17): Unchecked Conversion
5499 @sp 1
5500 @cartouche
5501 The @code{Size} of an array object should not include its bounds; hence,
5502 the bounds should not be part of the converted data.
5503 @end cartouche
5504 Followed.
5506 @sp 1
5507 @cartouche
5508 The implementation should not generate unnecessary run-time checks to
5509 ensure that the representation of @var{S} is a representation of the
5510 target type.  It should take advantage of the permission to return by
5511 reference when possible.  Restrictions on unchecked conversions should be
5512 avoided unless required by the target environment.
5513 @end cartouche
5514 Followed.  There are no restrictions on unchecked conversion.  A warning is
5515 generated if the source and target types do not have the same size since
5516 the semantics in this case may be target dependent.
5518 @sp 1
5519 @cartouche
5520 The recommended level of support for unchecked conversions is:
5521 @end cartouche
5522 @sp 1
5523 @cartouche
5524 Unchecked conversions should be supported and should be reversible in
5525 the cases where this clause defines the result.  To enable meaningful use
5526 of unchecked conversion, a contiguous representation should be used for
5527 elementary subtypes, for statically constrained array subtypes whose
5528 component subtype is one of the subtypes described in this paragraph,
5529 and for record subtypes without discriminants whose component subtypes
5530 are described in this paragraph.
5531 @end cartouche
5532 Followed.
5534 @cindex Heap usage, implicit
5535 @unnumberedsec 13.11(23-25): Implicit Heap Usage
5536 @sp 1
5537 @cartouche
5538 An implementation should document any cases in which it dynamically
5539 allocates heap storage for a purpose other than the evaluation of an
5540 allocator.
5541 @end cartouche
5542 Followed, the only other points at which heap storage is dynamically
5543 allocated are as follows:
5545 @itemize @bullet
5546 @item
5547 At initial elaboration time, to allocate dynamically sized global
5548 objects.
5550 @item
5551 To allocate space for a task when a task is created.
5553 @item
5554 To extend the secondary stack dynamically when needed.  The secondary
5555 stack is used for returning variable length results.
5556 @end itemize
5558 @sp 1
5559 @cartouche
5560 A default (implementation-provided) storage pool for an
5561 access-to-constant type should not have overhead to support deallocation of
5562 individual objects.
5563 @end cartouche
5564 Followed.
5566 @sp 1
5567 @cartouche
5568 A storage pool for an anonymous access type should be created at the
5569 point of an allocator for the type, and be reclaimed when the designated
5570 object becomes inaccessible.
5571 @end cartouche
5572 Followed.
5574 @cindex Unchecked deallocation
5575 @unnumberedsec 13.11.2(17): Unchecked De-allocation
5576 @sp 1
5577 @cartouche
5578 For a standard storage pool, @code{Free} should actually reclaim the
5579 storage.
5580 @end cartouche
5581 Followed.
5583 @cindex Stream oriented attributes
5584 @unnumberedsec 13.13.2(17): Stream Oriented Attributes
5585 @sp 1
5586 @cartouche
5587 If a stream element is the same size as a storage element, then the
5588 normal in-memory representation should be used by @code{Read} and
5589 @code{Write} for scalar objects.  Otherwise, @code{Read} and @code{Write}
5590 should use the smallest number of stream elements needed to represent
5591 all values in the base range of the scalar type.
5592 @end cartouche
5594 Followed.  By default, GNAT uses the interpretation suggested by AI-195,
5595 which specifies using the size of the first subtype.
5596 However, such an implementation is based on direct binary
5597 representations and is therefore target- and endianness-dependent.
5598 To address this issue, GNAT also supplies an alternate implementation
5599 of the stream attributes @code{Read} and @code{Write},
5600 which uses the target-independent XDR standard representation
5601 for scalar types.
5602 @cindex XDR representation
5603 @cindex @code{Read} attribute
5604 @cindex @code{Write} attribute
5605 @cindex Stream oriented attributes
5606 The XDR implementation is provided as an alternative body of the
5607 @code{System.Stream_Attributes} package, in the file
5608 @file{s-strxdr.adb} in the GNAT library.
5609 There is no @file{s-strxdr.ads} file.
5610 In order to install the XDR implementation, do the following:
5611 @enumerate
5612 @item Replace the default implementation of the
5613 @code{System.Stream_Attributes} package with the XDR implementation.
5614 For example on a Unix platform issue the commands:
5615 @smallexample
5616 $ mv s-stratt.adb s-strold.adb
5617 $ mv s-strxdr.adb s-stratt.adb
5618 @end smallexample
5620 @item
5621 Rebuild the GNAT run-time library as documented in the
5622 @cite{GNAT User's Guide}
5623 @end enumerate
5625 @unnumberedsec A.1(52): Names of Predefined Numeric Types
5626 @sp 1
5627 @cartouche
5628 If an implementation provides additional named predefined integer types,
5629 then the names should end with @samp{Integer} as in
5630 @samp{Long_Integer}.  If an implementation provides additional named
5631 predefined floating point types, then the names should end with
5632 @samp{Float} as in @samp{Long_Float}.
5633 @end cartouche
5634 Followed.
5636 @findex Ada.Characters.Handling
5637 @unnumberedsec A.3.2(49): @code{Ada.Characters.Handling}
5638 @sp 1
5639 @cartouche
5640 If an implementation provides a localized definition of @code{Character}
5641 or @code{Wide_Character}, then the effects of the subprograms in
5642 @code{Characters.Handling} should reflect the localizations.  See also
5643 3.5.2.
5644 @end cartouche
5645 Followed.  GNAT provides no such localized definitions.
5647 @cindex Bounded-length strings
5648 @unnumberedsec A.4.4(106): Bounded-Length String Handling
5649 @sp 1
5650 @cartouche
5651 Bounded string objects should not be implemented by implicit pointers
5652 and dynamic allocation.
5653 @end cartouche
5654 Followed.  No implicit pointers or dynamic allocation are used.
5656 @cindex Random number generation
5657 @unnumberedsec A.5.2(46-47): Random Number Generation
5658 @sp 1
5659 @cartouche
5660 Any storage associated with an object of type @code{Generator} should be
5661 reclaimed on exit from the scope of the object.
5662 @end cartouche
5663 Followed.
5665 @sp 1
5666 @cartouche
5667 If the generator period is sufficiently long in relation to the number
5668 of distinct initiator values, then each possible value of
5669 @code{Initiator} passed to @code{Reset} should initiate a sequence of
5670 random numbers that does not, in a practical sense, overlap the sequence
5671 initiated by any other value.  If this is not possible, then the mapping
5672 between initiator values and generator states should be a rapidly
5673 varying function of the initiator value.
5674 @end cartouche
5675 Followed.  The generator period is sufficiently long for the first
5676 condition here to hold true.
5678 @findex Get_Immediate
5679 @unnumberedsec A.10.7(23): @code{Get_Immediate}
5680 @sp 1
5681 @cartouche
5682 The @code{Get_Immediate} procedures should be implemented with
5683 unbuffered input.  For a device such as a keyboard, input should be
5684 @dfn{available} if a key has already been typed, whereas for a disk
5685 file, input should always be available except at end of file.  For a file
5686 associated with a keyboard-like device, any line-editing features of the
5687 underlying operating system should be disabled during the execution of
5688 @code{Get_Immediate}.
5689 @end cartouche
5690 Followed on all targets except VxWorks. For VxWorks, there is no way to
5691 provide this functionality that does not result in the input buffer being
5692 flushed before the @code{Get_Immediate} call. A special unit
5693 @code{Interfaces.Vxworks.IO} is provided that contains routines to enable
5694 this functionality.
5696 @findex Export
5697 @unnumberedsec B.1(39-41): Pragma @code{Export}
5698 @sp 1
5699 @cartouche
5700 If an implementation supports pragma @code{Export} to a given language,
5701 then it should also allow the main subprogram to be written in that
5702 language.  It should support some mechanism for invoking the elaboration
5703 of the Ada library units included in the system, and for invoking the
5704 finalization of the environment task.  On typical systems, the
5705 recommended mechanism is to provide two subprograms whose link names are
5706 @code{adainit} and @code{adafinal}.  @code{adainit} should contain the
5707 elaboration code for library units.  @code{adafinal} should contain the
5708 finalization code.  These subprograms should have no effect the second
5709 and subsequent time they are called.
5710 @end cartouche
5711 Followed.
5713 @sp 1
5714 @cartouche
5715 Automatic elaboration of pre-elaborated packages should be
5716 provided when pragma @code{Export} is supported.
5717 @end cartouche
5718 Followed when the main program is in Ada.  If the main program is in a
5719 foreign language, then
5720 @code{adainit} must be called to elaborate pre-elaborated
5721 packages.
5723 @sp 1
5724 @cartouche
5725 For each supported convention @var{L} other than @code{Intrinsic}, an
5726 implementation should support @code{Import} and @code{Export} pragmas
5727 for objects of @var{L}-compatible types and for subprograms, and pragma
5728 @code{Convention} for @var{L}-eligible types and for subprograms,
5729 presuming the other language has corresponding features.  Pragma
5730 @code{Convention} need not be supported for scalar types.
5731 @end cartouche
5732 Followed.
5734 @cindex Package @code{Interfaces}
5735 @findex Interfaces
5736 @unnumberedsec B.2(12-13): Package @code{Interfaces}
5737 @sp 1
5738 @cartouche
5739 For each implementation-defined convention identifier, there should be a
5740 child package of package Interfaces with the corresponding name.  This
5741 package should contain any declarations that would be useful for
5742 interfacing to the language (implementation) represented by the
5743 convention.  Any declarations useful for interfacing to any language on
5744 the given hardware architecture should be provided directly in
5745 @code{Interfaces}.
5746 @end cartouche
5747 Followed.  An additional package not defined
5748 in the Ada 95 Reference Manual is @code{Interfaces.CPP}, used
5749 for interfacing to C++.
5751 @sp 1
5752 @cartouche
5753 An implementation supporting an interface to C, COBOL, or Fortran should
5754 provide the corresponding package or packages described in the following
5755 clauses.
5756 @end cartouche
5757 Followed.  GNAT provides all the packages described in this section.
5759 @cindex C, interfacing with
5760 @unnumberedsec B.3(63-71): Interfacing with C
5761 @sp 1
5762 @cartouche
5763 An implementation should support the following interface correspondences
5764 between Ada and C@.
5765 @end cartouche
5766 Followed.
5768 @sp 1
5769 @cartouche
5770 An Ada procedure corresponds to a void-returning C function.
5771 @end cartouche
5772 Followed.
5774 @sp 1
5775 @cartouche
5776 An Ada function corresponds to a non-void C function.
5777 @end cartouche
5778 Followed.
5780 @sp 1
5781 @cartouche
5782 An Ada @code{in} scalar parameter is passed as a scalar argument to a C
5783 function.
5784 @end cartouche
5785 Followed.
5787 @sp 1
5788 @cartouche
5789 An Ada @code{in} parameter of an access-to-object type with designated
5790 type @var{T} is passed as a @code{@var{t}*} argument to a C function,
5791 where @var{t} is the C type corresponding to the Ada type @var{T}.
5792 @end cartouche
5793 Followed.
5795 @sp 1
5796 @cartouche
5797 An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
5798 parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
5799 argument to a C function, where @var{t} is the C type corresponding to
5800 the Ada type @var{T}.  In the case of an elementary @code{out} or
5801 @code{in out} parameter, a pointer to a temporary copy is used to
5802 preserve by-copy semantics.
5803 @end cartouche
5804 Followed.
5806 @sp 1
5807 @cartouche
5808 An Ada parameter of a record type @var{T}, of any mode, is passed as a
5809 @code{@var{t}*} argument to a C function, where @var{t} is the C
5810 structure corresponding to the Ada type @var{T}.
5811 @end cartouche
5812 Followed.  This convention may be overridden by the use of the C_Pass_By_Copy
5813 pragma, or Convention, or by explicitly specifying the mechanism for a given
5814 call using an extended import or export pragma.
5816 @sp 1
5817 @cartouche
5818 An Ada parameter of an array type with component type @var{T}, of any
5819 mode, is passed as a @code{@var{t}*} argument to a C function, where
5820 @var{t} is the C type corresponding to the Ada type @var{T}.
5821 @end cartouche
5822 Followed.
5824 @sp 1
5825 @cartouche
5826 An Ada parameter of an access-to-subprogram type is passed as a pointer
5827 to a C function whose prototype corresponds to the designated
5828 subprogram's specification.
5829 @end cartouche
5830 Followed.
5832 @cindex COBOL, interfacing with
5833 @unnumberedsec B.4(95-98): Interfacing with COBOL
5834 @sp 1
5835 @cartouche
5836 An Ada implementation should support the following interface
5837 correspondences between Ada and COBOL@.
5838 @end cartouche
5839 Followed.
5841 @sp 1
5842 @cartouche
5843 An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of
5844 the COBOL type corresponding to @var{T}.
5845 @end cartouche
5846 Followed.
5848 @sp 1
5849 @cartouche
5850 An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of
5851 the corresponding COBOL type.
5852 @end cartouche
5853 Followed.
5855 @sp 1
5856 @cartouche
5857 Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the
5858 COBOL type corresponding to the Ada parameter type; for scalars, a local
5859 copy is used if necessary to ensure by-copy semantics.
5860 @end cartouche
5861 Followed.
5863 @cindex Fortran, interfacing with
5864 @unnumberedsec B.5(22-26): Interfacing with Fortran
5865 @sp 1
5866 @cartouche
5867 An Ada implementation should support the following interface
5868 correspondences between Ada and Fortran:
5869 @end cartouche
5870 Followed.
5872 @sp 1
5873 @cartouche
5874 An Ada procedure corresponds to a Fortran subroutine.
5875 @end cartouche
5876 Followed.
5878 @sp 1
5879 @cartouche
5880 An Ada function corresponds to a Fortran function.
5881 @end cartouche
5882 Followed.
5884 @sp 1
5885 @cartouche
5886 An Ada parameter of an elementary, array, or record type @var{T} is
5887 passed as a @var{T} argument to a Fortran procedure, where @var{T} is
5888 the Fortran type corresponding to the Ada type @var{T}, and where the
5889 INTENT attribute of the corresponding dummy argument matches the Ada
5890 formal parameter mode; the Fortran implementation's parameter passing
5891 conventions are used.  For elementary types, a local copy is used if
5892 necessary to ensure by-copy semantics.
5893 @end cartouche
5894 Followed.
5896 @sp 1
5897 @cartouche
5898 An Ada parameter of an access-to-subprogram type is passed as a
5899 reference to a Fortran procedure whose interface corresponds to the
5900 designated subprogram's specification.
5901 @end cartouche
5902 Followed.
5904 @cindex Machine operations
5905 @unnumberedsec C.1(3-5): Access to Machine Operations
5906 @sp 1
5907 @cartouche
5908 The machine code or intrinsic support should allow access to all
5909 operations normally available to assembly language programmers for the
5910 target environment, including privileged instructions, if any.
5911 @end cartouche
5912 Followed.
5914 @sp 1
5915 @cartouche
5916 The interfacing pragmas (see Annex B) should support interface to
5917 assembler; the default assembler should be associated with the
5918 convention identifier @code{Assembler}.
5919 @end cartouche
5920 Followed.
5922 @sp 1
5923 @cartouche
5924 If an entity is exported to assembly language, then the implementation
5925 should allocate it at an addressable location, and should ensure that it
5926 is retained by the linking process, even if not otherwise referenced
5927 from the Ada code.  The implementation should assume that any call to a
5928 machine code or assembler subprogram is allowed to read or update every
5929 object that is specified as exported.
5930 @end cartouche
5931 Followed.
5933 @unnumberedsec C.1(10-16): Access to Machine Operations
5934 @sp 1
5935 @cartouche
5936 The implementation should ensure that little or no overhead is
5937 associated with calling intrinsic and machine-code subprograms.
5938 @end cartouche
5939 Followed for both intrinsics and machine-code subprograms.
5941 @sp 1
5942 @cartouche
5943 It is recommended that intrinsic subprograms be provided for convenient
5944 access to any machine operations that provide special capabilities or
5945 efficiency and that are not otherwise available through the language
5946 constructs.
5947 @end cartouche
5948 Followed.  A full set of machine operation intrinsic subprograms is provided.
5950 @sp 1
5951 @cartouche
5952 Atomic read-modify-write operations---e.g.@:, test and set, compare and
5953 swap, decrement and test, enqueue/dequeue.
5954 @end cartouche
5955 Followed on any target supporting such operations.
5957 @sp 1
5958 @cartouche
5959 Standard numeric functions---e.g.@:, sin, log.
5960 @end cartouche
5961 Followed on any target supporting such operations.
5963 @sp 1
5964 @cartouche
5965 String manipulation operations---e.g.@:, translate and test.
5966 @end cartouche
5967 Followed on any target supporting such operations.
5969 @sp 1
5970 @cartouche
5971 Vector operations---e.g.@:, compare vector against thresholds.
5972 @end cartouche
5973 Followed on any target supporting such operations.
5975 @sp 1
5976 @cartouche
5977 Direct operations on I/O ports.
5978 @end cartouche
5979 Followed on any target supporting such operations.
5981 @cindex Interrupt support
5982 @unnumberedsec C.3(28): Interrupt Support
5983 @sp 1
5984 @cartouche
5985 If the @code{Ceiling_Locking} policy is not in effect, the
5986 implementation should provide means for the application to specify which
5987 interrupts are to be blocked during protected actions, if the underlying
5988 system allows for a finer-grain control of interrupt blocking.
5989 @end cartouche
5990 Followed.  The underlying system does not allow for finer-grain control
5991 of interrupt blocking.
5993 @cindex Protected procedure handlers
5994 @unnumberedsec C.3.1(20-21): Protected Procedure Handlers
5995 @sp 1
5996 @cartouche
5997 Whenever possible, the implementation should allow interrupt handlers to
5998 be called directly by the hardware.
5999 @end cartouche
6000 @c SGI info:
6001 @ignore
6002 This is never possible under IRIX, so this is followed by default.
6003 @end ignore
6004 Followed on any target where the underlying operating system permits
6005 such direct calls.
6007 @sp 1
6008 @cartouche
6009 Whenever practical, violations of any
6010 implementation-defined restrictions should be detected before run time.
6011 @end cartouche
6012 Followed.  Compile time warnings are given when possible.
6014 @cindex Package @code{Interrupts}
6015 @findex Interrupts
6016 @unnumberedsec C.3.2(25): Package @code{Interrupts}
6018 @sp 1
6019 @cartouche
6020 If implementation-defined forms of interrupt handler procedures are
6021 supported, such as protected procedures with parameters, then for each
6022 such form of a handler, a type analogous to @code{Parameterless_Handler}
6023 should be specified in a child package of @code{Interrupts}, with the
6024 same operations as in the predefined package Interrupts.
6025 @end cartouche
6026 Followed.
6028 @cindex Pre-elaboration requirements
6029 @unnumberedsec C.4(14): Pre-elaboration Requirements
6030 @sp 1
6031 @cartouche
6032 It is recommended that pre-elaborated packages be implemented in such a
6033 way that there should be little or no code executed at run time for the
6034 elaboration of entities not already covered by the Implementation
6035 Requirements.
6036 @end cartouche
6037 Followed.  Executable code is generated in some cases, e.g.@: loops
6038 to initialize large arrays.
6040 @unnumberedsec C.5(8): Pragma @code{Discard_Names}
6042 @sp 1
6043 @cartouche
6044 If the pragma applies to an entity, then the implementation should
6045 reduce the amount of storage used for storing names associated with that
6046 entity.
6047 @end cartouche
6048 Followed.
6050 @cindex Package @code{Task_Attributes}
6051 @findex Task_Attributes
6052 @unnumberedsec C.7.2(30): The Package Task_Attributes
6053 @sp 1
6054 @cartouche
6055 Some implementations are targeted to domains in which memory use at run
6056 time must be completely deterministic.  For such implementations, it is
6057 recommended that the storage for task attributes will be pre-allocated
6058 statically and not from the heap.  This can be accomplished by either
6059 placing restrictions on the number and the size of the task's
6060 attributes, or by using the pre-allocated storage for the first @var{N}
6061 attribute objects, and the heap for the others.  In the latter case,
6062 @var{N} should be documented.
6063 @end cartouche
6064 Not followed.  This implementation is not targeted to such a domain.
6066 @cindex Locking Policies
6067 @unnumberedsec D.3(17): Locking Policies
6069 @sp 1
6070 @cartouche
6071 The implementation should use names that end with @samp{_Locking} for
6072 locking policies defined by the implementation.
6073 @end cartouche
6074 Followed.  A single implementation-defined locking policy is defined,
6075 whose name (@code{Inheritance_Locking}) follows this suggestion.
6077 @cindex Entry queuing policies
6078 @unnumberedsec D.4(16): Entry Queuing Policies
6079 @sp 1
6080 @cartouche
6081 Names that end with @samp{_Queuing} should be used
6082 for all implementation-defined queuing policies.
6083 @end cartouche
6084 Followed.  No such implementation-defined queuing policies exist.
6086 @cindex Preemptive abort
6087 @unnumberedsec D.6(9-10): Preemptive Abort
6088 @sp 1
6089 @cartouche
6090 Even though the @code{abort_statement} is included in the list of
6091 potentially blocking operations (see 9.5.1), it is recommended that this
6092 statement be implemented in a way that never requires the task executing
6093 the @code{abort_statement} to block.
6094 @end cartouche
6095 Followed.
6097 @sp 1
6098 @cartouche
6099 On a multi-processor, the delay associated with aborting a task on
6100 another processor should be bounded; the implementation should use
6101 periodic polling, if necessary, to achieve this.
6102 @end cartouche
6103 Followed.
6105 @cindex Tasking restrictions
6106 @unnumberedsec D.7(21): Tasking Restrictions
6107 @sp 1
6108 @cartouche
6109 When feasible, the implementation should take advantage of the specified
6110 restrictions to produce a more efficient implementation.
6111 @end cartouche
6112 GNAT currently takes advantage of these restrictions by providing an optimized
6113 run time when the Ravenscar profile and the GNAT restricted run time set
6114 of restrictions are specified.  See pragma @code{Profile (Ravenscar)} and
6115 pragma @code{Profile (Restricted)} for more details.
6117 @cindex Time, monotonic
6118 @unnumberedsec D.8(47-49): Monotonic Time
6119 @sp 1
6120 @cartouche
6121 When appropriate, implementations should provide configuration
6122 mechanisms to change the value of @code{Tick}.
6123 @end cartouche
6124 Such configuration mechanisms are not appropriate to this implementation
6125 and are thus not supported.
6127 @sp 1
6128 @cartouche
6129 It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
6130 be implemented as transformations of the same time base.
6131 @end cartouche
6132 Followed.
6134 @sp 1
6135 @cartouche
6136 It is recommended that the @dfn{best} time base which exists in
6137 the underlying system be available to the application through
6138 @code{Clock}.  @dfn{Best} may mean highest accuracy or largest range.
6139 @end cartouche
6140 Followed.
6142 @cindex Partition communication subsystem
6143 @cindex PCS
6144 @unnumberedsec E.5(28-29): Partition Communication Subsystem
6145 @sp 1
6146 @cartouche
6147 Whenever possible, the PCS on the called partition should allow for
6148 multiple tasks to call the RPC-receiver with different messages and
6149 should allow them to block until the corresponding subprogram body
6150 returns.
6151 @end cartouche
6152 Followed by GLADE, a separately supplied PCS that can be used with
6153 GNAT.
6155 @sp 1
6156 @cartouche
6157 The @code{Write} operation on a stream of type @code{Params_Stream_Type}
6158 should raise @code{Storage_Error} if it runs out of space trying to
6159 write the @code{Item} into the stream.
6160 @end cartouche
6161 Followed by GLADE, a separately supplied PCS that can be used with
6162 GNAT@.
6164 @cindex COBOL support
6165 @unnumberedsec F(7): COBOL Support
6166 @sp 1
6167 @cartouche
6168 If COBOL (respectively, C) is widely supported in the target
6169 environment, implementations supporting the Information Systems Annex
6170 should provide the child package @code{Interfaces.COBOL} (respectively,
6171 @code{Interfaces.C}) specified in Annex B and should support a
6172 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
6173 pragmas (see Annex B), thus allowing Ada programs to interface with
6174 programs written in that language.
6175 @end cartouche
6176 Followed.
6178 @cindex Decimal radix support
6179 @unnumberedsec F.1(2): Decimal Radix Support
6180 @sp 1
6181 @cartouche
6182 Packed decimal should be used as the internal representation for objects
6183 of subtype @var{S} when @var{S}'Machine_Radix = 10.
6184 @end cartouche
6185 Not followed.  GNAT ignores @var{S}'Machine_Radix and always uses binary
6186 representations.
6188 @cindex Numerics
6189 @unnumberedsec G: Numerics
6190 @sp 2
6191 @cartouche
6192 If Fortran (respectively, C) is widely supported in the target
6193 environment, implementations supporting the Numerics Annex
6194 should provide the child package @code{Interfaces.Fortran} (respectively,
6195 @code{Interfaces.C}) specified in Annex B and should support a
6196 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
6197 pragmas (see Annex B), thus allowing Ada programs to interface with
6198 programs written in that language.
6199 @end cartouche
6200 Followed.
6202 @cindex Complex types
6203 @unnumberedsec G.1.1(56-58): Complex Types
6204 @sp 2
6205 @cartouche
6206 Because the usual mathematical meaning of multiplication of a complex
6207 operand and a real operand is that of the scaling of both components of
6208 the former by the latter, an implementation should not perform this
6209 operation by first promoting the real operand to complex type and then
6210 performing a full complex multiplication.  In systems that, in the
6211 future, support an Ada binding to IEC 559:1989, the latter technique
6212 will not generate the required result when one of the components of the
6213 complex operand is infinite.  (Explicit multiplication of the infinite
6214 component by the zero component obtained during promotion yields a NaN
6215 that propagates into the final result.) Analogous advice applies in the
6216 case of multiplication of a complex operand and a pure-imaginary
6217 operand, and in the case of division of a complex operand by a real or
6218 pure-imaginary operand.
6219 @end cartouche
6220 Not followed.
6222 @sp 1
6223 @cartouche
6224 Similarly, because the usual mathematical meaning of addition of a
6225 complex operand and a real operand is that the imaginary operand remains
6226 unchanged, an implementation should not perform this operation by first
6227 promoting the real operand to complex type and then performing a full
6228 complex addition.  In implementations in which the @code{Signed_Zeros}
6229 attribute of the component type is @code{True} (and which therefore
6230 conform to IEC 559:1989 in regard to the handling of the sign of zero in
6231 predefined arithmetic operations), the latter technique will not
6232 generate the required result when the imaginary component of the complex
6233 operand is a negatively signed zero.  (Explicit addition of the negative
6234 zero to the zero obtained during promotion yields a positive zero.)
6235 Analogous advice applies in the case of addition of a complex operand
6236 and a pure-imaginary operand, and in the case of subtraction of a
6237 complex operand and a real or pure-imaginary operand.
6238 @end cartouche
6239 Not followed.
6241 @sp 1
6242 @cartouche
6243 Implementations in which @code{Real'Signed_Zeros} is @code{True} should
6244 attempt to provide a rational treatment of the signs of zero results and
6245 result components.  As one example, the result of the @code{Argument}
6246 function should have the sign of the imaginary component of the
6247 parameter @code{X} when the point represented by that parameter lies on
6248 the positive real axis; as another, the sign of the imaginary component
6249 of the @code{Compose_From_Polar} function should be the same as
6250 (respectively, the opposite of) that of the @code{Argument} parameter when that
6251 parameter has a value of zero and the @code{Modulus} parameter has a
6252 nonnegative (respectively, negative) value.
6253 @end cartouche
6254 Followed.
6256 @cindex Complex elementary functions
6257 @unnumberedsec G.1.2(49): Complex Elementary Functions
6258 @sp 1
6259 @cartouche
6260 Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
6261 @code{True} should attempt to provide a rational treatment of the signs
6262 of zero results and result components.  For example, many of the complex
6263 elementary functions have components that are odd functions of one of
6264 the parameter components; in these cases, the result component should
6265 have the sign of the parameter component at the origin.  Other complex
6266 elementary functions have zero components whose sign is opposite that of
6267 a parameter component at the origin, or is always positive or always
6268 negative.
6269 @end cartouche
6270 Followed.
6272 @cindex Accuracy requirements
6273 @unnumberedsec G.2.4(19): Accuracy Requirements
6274 @sp 1
6275 @cartouche
6276 The versions of the forward trigonometric functions without a
6277 @code{Cycle} parameter should not be implemented by calling the
6278 corresponding version with a @code{Cycle} parameter of
6279 @code{2.0*Numerics.Pi}, since this will not provide the required
6280 accuracy in some portions of the domain.  For the same reason, the
6281 version of @code{Log} without a @code{Base} parameter should not be
6282 implemented by calling the corresponding version with a @code{Base}
6283 parameter of @code{Numerics.e}.
6284 @end cartouche
6285 Followed.
6287 @cindex Complex arithmetic accuracy
6288 @cindex Accuracy, complex arithmetic
6289 @unnumberedsec G.2.6(15): Complex Arithmetic Accuracy
6291 @sp 1
6292 @cartouche
6293 The version of the @code{Compose_From_Polar} function without a
6294 @code{Cycle} parameter should not be implemented by calling the
6295 corresponding version with a @code{Cycle} parameter of
6296 @code{2.0*Numerics.Pi}, since this will not provide the required
6297 accuracy in some portions of the domain.
6298 @end cartouche
6299 Followed.
6301 @c -----------------------------------------
6302 @node Implementation Defined Characteristics
6303 @chapter Implementation Defined Characteristics
6305 @noindent
6306 In addition to the implementation dependent pragmas and attributes, and
6307 the implementation advice, there are a number of other features of Ada
6308 95 that are potentially implementation dependent.  These are mentioned
6309 throughout the Ada 95 Reference Manual, and are summarized in annex M@.
6311 A requirement for conforming Ada compilers is that they provide
6312 documentation describing how the implementation deals with each of these
6313 issues.  In this chapter, you will find each point in annex M listed
6314 followed by a description in italic font of how GNAT
6315 @c SGI info:
6316 @ignore
6317 in the ProDev Ada
6318 implementation on IRIX 5.3 operating system or greater
6319 @end ignore
6320 handles the implementation dependence.
6322 You can use this chapter as a guide to minimizing implementation
6323 dependent features in your programs if portability to other compilers
6324 and other operating systems is an important consideration.  The numbers
6325 in each section below correspond to the paragraph number in the Ada 95
6326 Reference Manual.
6328 @sp 1
6329 @cartouche
6330 @noindent
6331 @strong{2}.  Whether or not each recommendation given in Implementation
6332 Advice is followed.  See 1.1.2(37).
6333 @end cartouche
6334 @noindent
6335 @xref{Implementation Advice}.
6337 @sp 1
6338 @cartouche
6339 @noindent
6340 @strong{3}.  Capacity limitations of the implementation.  See 1.1.3(3).
6341 @end cartouche
6342 @noindent
6343 The complexity of programs that can be processed is limited only by the
6344 total amount of available virtual memory, and disk space for the
6345 generated object files.
6347 @sp 1
6348 @cartouche
6349 @noindent
6350 @strong{4}.  Variations from the standard that are impractical to avoid
6351 given the implementation's execution environment.  See 1.1.3(6).
6352 @end cartouche
6353 @noindent
6354 There are no variations from the standard.
6356 @sp 1
6357 @cartouche
6358 @noindent
6359 @strong{5}.  Which @code{code_statement}s cause external
6360 interactions.  See 1.1.3(10).
6361 @end cartouche
6362 @noindent
6363 Any @code{code_statement} can potentially cause external interactions.
6365 @sp 1
6366 @cartouche
6367 @noindent
6368 @strong{6}.  The coded representation for the text of an Ada
6369 program.  See 2.1(4).
6370 @end cartouche
6371 @noindent
6372 See separate section on source representation.
6374 @sp 1
6375 @cartouche
6376 @noindent
6377 @strong{7}.  The control functions allowed in comments.  See 2.1(14).
6378 @end cartouche
6379 @noindent
6380 See separate section on source representation.
6382 @sp 1
6383 @cartouche
6384 @noindent
6385 @strong{8}.  The representation for an end of line.  See 2.2(2).
6386 @end cartouche
6387 @noindent
6388 See separate section on source representation.
6390 @sp 1
6391 @cartouche
6392 @noindent
6393 @strong{9}.  Maximum supported line length and lexical element
6394 length.  See 2.2(15).
6395 @end cartouche
6396 @noindent
6397 The maximum line length is 255 characters an the maximum length of a
6398 lexical element is also 255 characters.
6400 @sp 1
6401 @cartouche
6402 @noindent
6403 @strong{10}.  Implementation defined pragmas.  See 2.8(14).
6404 @end cartouche
6405 @noindent
6407 @xref{Implementation Defined Pragmas}.
6409 @sp 1
6410 @cartouche
6411 @noindent
6412 @strong{11}.  Effect of pragma @code{Optimize}.  See 2.8(27).
6413 @end cartouche
6414 @noindent
6415 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
6416 parameter, checks that the optimization flag is set, and aborts if it is
6417 not.
6419 @sp 1
6420 @cartouche
6421 @noindent
6422 @strong{12}.  The sequence of characters of the value returned by
6423 @code{@var{S}'Image} when some of the graphic characters of
6424 @code{@var{S}'Wide_Image} are not defined in @code{Character}.  See
6425 3.5(37).
6426 @end cartouche
6427 @noindent
6428 The sequence of characters is as defined by the wide character encoding
6429 method used for the source.  See section on source representation for
6430 further details.
6432 @sp 1
6433 @cartouche
6434 @noindent
6435 @strong{13}.  The predefined integer types declared in
6436 @code{Standard}.  See 3.5.4(25).
6437 @end cartouche
6438 @noindent
6439 @table @code
6440 @item Short_Short_Integer
6441 8 bit signed
6442 @item Short_Integer
6443 (Short) 16 bit signed
6444 @item Integer
6445 32 bit signed
6446 @item Long_Integer
6447 64 bit signed (Alpha OpenVMS only)
6448 32 bit signed (all other targets)
6449 @item Long_Long_Integer
6450 64 bit signed
6451 @end table
6453 @sp 1
6454 @cartouche
6455 @noindent
6456 @strong{14}.  Any nonstandard integer types and the operators defined
6457 for them.  See 3.5.4(26).
6458 @end cartouche
6459 @noindent
6460 There are no nonstandard integer types.
6462 @sp 1
6463 @cartouche
6464 @noindent
6465 @strong{15}.  Any nonstandard real types and the operators defined for
6466 them.  See 3.5.6(8).
6467 @end cartouche
6468 @noindent
6469 There are no nonstandard real types.
6471 @sp 1
6472 @cartouche
6473 @noindent
6474 @strong{16}.  What combinations of requested decimal precision and range
6475 are supported for floating point types.  See 3.5.7(7).
6476 @end cartouche
6477 @noindent
6478 The precision and range is as defined by the IEEE standard.
6480 @sp 1
6481 @cartouche
6482 @noindent
6483 @strong{17}.  The predefined floating point types declared in
6484 @code{Standard}.  See 3.5.7(16).
6485 @end cartouche
6486 @noindent
6487 @table @code
6488 @item Short_Float
6489 32 bit IEEE short
6490 @item Float
6491 (Short) 32 bit IEEE short
6492 @item Long_Float
6493 64 bit IEEE long
6494 @item Long_Long_Float
6495 64 bit IEEE long (80 bit IEEE long on x86 processors)
6496 @end table
6498 @sp 1
6499 @cartouche
6500 @noindent
6501 @strong{18}.  The small of an ordinary fixed point type.  See 3.5.9(8).
6502 @end cartouche
6503 @noindent
6504 @code{Fine_Delta} is 2**(@minus{}63)
6506 @sp 1
6507 @cartouche
6508 @noindent
6509 @strong{19}.  What combinations of small, range, and digits are
6510 supported for fixed point types.  See 3.5.9(10).
6511 @end cartouche
6512 @noindent
6513 Any combinations are permitted that do not result in a small less than
6514 @code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
6515 If the mantissa is larger than 53 bits on machines where Long_Long_Float
6516 is 64 bits (true of all architectures except ia32), then the output from
6517 Text_IO is accurate to only 53 bits, rather than the full mantissa.  This
6518 is because floating-point conversions are used to convert fixed point.
6520 @sp 1
6521 @cartouche
6522 @noindent
6523 @strong{20}.  The result of @code{Tags.Expanded_Name} for types declared
6524 within an unnamed @code{block_statement}.  See 3.9(10).
6525 @end cartouche
6526 @noindent
6527 Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
6528 decimal integer are allocated.
6530 @sp 1
6531 @cartouche
6532 @noindent
6533 @strong{21}.  Implementation-defined attributes.  See 4.1.4(12).
6534 @end cartouche
6535 @noindent
6536 @xref{Implementation Defined Attributes}.
6538 @sp 1
6539 @cartouche
6540 @noindent
6541 @strong{22}.  Any implementation-defined time types.  See 9.6(6).
6542 @end cartouche
6543 @noindent
6544 There are no implementation-defined time types.
6546 @sp 1
6547 @cartouche
6548 @noindent
6549 @strong{23}.  The time base associated with relative delays.
6550 @end cartouche
6551 @noindent
6552 See 9.6(20).  The time base used is that provided by the C library
6553 function @code{gettimeofday}.
6555 @sp 1
6556 @cartouche
6557 @noindent
6558 @strong{24}.  The time base of the type @code{Calendar.Time}.  See
6559 9.6(23).
6560 @end cartouche
6561 @noindent
6562 The time base used is that provided by the C library function
6563 @code{gettimeofday}.
6565 @sp 1
6566 @cartouche
6567 @noindent
6568 @strong{25}.  The time zone used for package @code{Calendar}
6569 operations.  See 9.6(24).
6570 @end cartouche
6571 @noindent
6572 The time zone used by package @code{Calendar} is the current system time zone
6573 setting for local time, as accessed by the C library function
6574 @code{localtime}.
6576 @sp 1
6577 @cartouche
6578 @noindent
6579 @strong{26}.  Any limit on @code{delay_until_statements} of
6580 @code{select_statements}.  See 9.6(29).
6581 @end cartouche
6582 @noindent
6583 There are no such limits.
6585 @sp 1
6586 @cartouche
6587 @noindent
6588 @strong{27}.  Whether or not two non overlapping parts of a composite
6589 object are independently addressable, in the case where packing, record
6590 layout, or @code{Component_Size} is specified for the object.  See
6591 9.10(1).
6592 @end cartouche
6593 @noindent
6594 Separate components are independently addressable if they do not share
6595 overlapping storage units.
6597 @sp 1
6598 @cartouche
6599 @noindent
6600 @strong{28}.  The representation for a compilation.  See 10.1(2).
6601 @end cartouche
6602 @noindent
6603 A compilation is represented by a sequence of files presented to the
6604 compiler in a single invocation of the @code{gcc} command.
6606 @sp 1
6607 @cartouche
6608 @noindent
6609 @strong{29}.  Any restrictions on compilations that contain multiple
6610 compilation_units.  See 10.1(4).
6611 @end cartouche
6612 @noindent
6613 No single file can contain more than one compilation unit, but any
6614 sequence of files can be presented to the compiler as a single
6615 compilation.
6617 @sp 1
6618 @cartouche
6619 @noindent
6620 @strong{30}.  The mechanisms for creating an environment and for adding
6621 and replacing compilation units.  See 10.1.4(3).
6622 @end cartouche
6623 @noindent
6624 See separate section on compilation model.
6626 @sp 1
6627 @cartouche
6628 @noindent
6629 @strong{31}.  The manner of explicitly assigning library units to a
6630 partition.  See 10.2(2).
6631 @end cartouche
6632 @noindent
6633 If a unit contains an Ada main program, then the Ada units for the partition
6634 are determined by recursive application of the rules in the Ada Reference
6635 Manual section 10.2(2-6).  In other words, the Ada units will be those that
6636 are needed by the main program, and then this definition of need is applied
6637 recursively to those units, and the partition contains the transitive
6638 closure determined by this relationship.  In short, all the necessary units
6639 are included, with no need to explicitly specify the list.  If additional
6640 units are required, e.g.@: by foreign language units, then all units must be
6641 mentioned in the context clause of one of the needed Ada units.
6643 If the partition contains no main program, or if the main program is in
6644 a language other than Ada, then GNAT
6645 provides the binder options @code{-z} and @code{-n} respectively, and in
6646 this case a list of units can be explicitly supplied to the binder for
6647 inclusion in the partition (all units needed by these units will also
6648 be included automatically).  For full details on the use of these
6649 options, refer to the @cite{GNAT User's Guide} sections on Binding
6650 and Linking.
6652 @sp 1
6653 @cartouche
6654 @noindent
6655 @strong{32}.  The implementation-defined means, if any, of specifying
6656 which compilation units are needed by a given compilation unit.  See
6657 10.2(2).
6658 @end cartouche
6659 @noindent
6660 The units needed by a given compilation unit are as defined in
6661 the Ada Reference Manual section 10.2(2-6).  There are no
6662 implementation-defined pragmas or other implementation-defined
6663 means for specifying needed units.
6665 @sp 1
6666 @cartouche
6667 @noindent
6668 @strong{33}.  The manner of designating the main subprogram of a
6669 partition.  See 10.2(7).
6670 @end cartouche
6671 @noindent
6672 The main program is designated by providing the name of the
6673 corresponding @file{ALI} file as the input parameter to the binder.
6675 @sp 1
6676 @cartouche
6677 @noindent
6678 @strong{34}.  The order of elaboration of @code{library_items}.  See
6679 10.2(18).
6680 @end cartouche
6681 @noindent
6682 The first constraint on ordering is that it meets the requirements of
6683 chapter 10 of the Ada 95 Reference Manual.  This still leaves some
6684 implementation dependent choices, which are resolved by first
6685 elaborating bodies as early as possible (i.e.@: in preference to specs
6686 where there is a choice), and second by evaluating the immediate with
6687 clauses of a unit to determine the probably best choice, and
6688 third by elaborating in alphabetical order of unit names
6689 where a choice still remains.
6691 @sp 1
6692 @cartouche
6693 @noindent
6694 @strong{35}.  Parameter passing and function return for the main
6695 subprogram.  See 10.2(21).
6696 @end cartouche
6697 @noindent
6698 The main program has no parameters.  It may be a procedure, or a function
6699 returning an integer type.  In the latter case, the returned integer
6700 value is the return code of the program (overriding any value that
6701 may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
6703 @sp 1
6704 @cartouche
6705 @noindent
6706 @strong{36}.  The mechanisms for building and running partitions.  See
6707 10.2(24).
6708 @end cartouche
6709 @noindent
6710 GNAT itself supports programs with only a single partition.  The GNATDIST
6711 tool provided with the GLADE package (which also includes an implementation
6712 of the PCS) provides a completely flexible method for building and running
6713 programs consisting of multiple partitions.  See the separate GLADE manual
6714 for details.
6716 @sp 1
6717 @cartouche
6718 @noindent
6719 @strong{37}.  The details of program execution, including program
6720 termination.  See 10.2(25).
6721 @end cartouche
6722 @noindent
6723 See separate section on compilation model.
6725 @sp 1
6726 @cartouche
6727 @noindent
6728 @strong{38}.  The semantics of any non-active partitions supported by the
6729 implementation.  See 10.2(28).
6730 @end cartouche
6731 @noindent
6732 Passive partitions are supported on targets where shared memory is
6733 provided by the operating system.  See the GLADE reference manual for
6734 further details.
6736 @sp 1
6737 @cartouche
6738 @noindent
6739 @strong{39}.  The information returned by @code{Exception_Message}.  See
6740 11.4.1(10).
6741 @end cartouche
6742 @noindent
6743 Exception message returns the null string unless a specific message has
6744 been passed by the program.
6746 @sp 1
6747 @cartouche
6748 @noindent
6749 @strong{40}.  The result of @code{Exceptions.Exception_Name} for types
6750 declared within an unnamed @code{block_statement}.  See 11.4.1(12).
6751 @end cartouche
6752 @noindent
6753 Blocks have implementation defined names of the form @code{B@var{nnn}}
6754 where @var{nnn} is an integer.
6756 @sp 1
6757 @cartouche
6758 @noindent
6759 @strong{41}.  The information returned by
6760 @code{Exception_Information}.  See 11.4.1(13).
6761 @end cartouche
6762 @noindent
6763 @code{Exception_Information} returns a string in the following format:
6765 @smallexample
6766 @emph{Exception_Name:} nnnnn
6767 @emph{Message:} mmmmm
6768 @emph{PID:} ppp
6769 @emph{Call stack traceback locations:}
6770 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
6771 @end smallexample
6773 @noindent
6774 where
6776 @itemize @bullet
6777 @item
6778 @code{nnnn} is the fully qualified name of the exception in all upper
6779 case letters. This line is always present.
6781 @item
6782 @code{mmmm} is the message (this line present only if message is non-null)
6784 @item
6785 @code{ppp} is the Process Id value as a decimal integer (this line is
6786 present only if the Process Id is non-zero). Currently we are
6787 not making use of this field.
6789 @item
6790 The Call stack traceback locations line and the following values
6791 are present only if at least one traceback location was recorded.
6792 The values are given in C style format, with lower case letters
6793 for a-f, and only as many digits present as are necessary.
6794 @end itemize
6796 @noindent
6797 The line terminator sequence at the end of each line, including
6798 the last line is a single @code{LF} character (@code{16#0A#}).
6800 @sp 1
6801 @cartouche
6802 @noindent
6803 @strong{42}.  Implementation-defined check names.  See 11.5(27).
6804 @end cartouche
6805 @noindent
6806 No implementation-defined check names are supported.
6808 @sp 1
6809 @cartouche
6810 @noindent
6811 @strong{43}.  The interpretation of each aspect of representation.  See
6812 13.1(20).
6813 @end cartouche
6814 @noindent
6815 See separate section on data representations.
6817 @sp 1
6818 @cartouche
6819 @noindent
6820 @strong{44}.  Any restrictions placed upon representation items.  See
6821 13.1(20).
6822 @end cartouche
6823 @noindent
6824 See separate section on data representations.
6826 @sp 1
6827 @cartouche
6828 @noindent
6829 @strong{45}.  The meaning of @code{Size} for indefinite subtypes.  See
6830 13.3(48).
6831 @end cartouche
6832 @noindent
6833 Size for an indefinite subtype is the maximum possible size, except that
6834 for the case of a subprogram parameter, the size of the parameter object
6835 is the actual size.
6837 @sp 1
6838 @cartouche
6839 @noindent
6840 @strong{46}.  The default external representation for a type tag.  See
6841 13.3(75).
6842 @end cartouche
6843 @noindent
6844 The default external representation for a type tag is the fully expanded
6845 name of the type in upper case letters.
6847 @sp 1
6848 @cartouche
6849 @noindent
6850 @strong{47}.  What determines whether a compilation unit is the same in
6851 two different partitions.  See 13.3(76).
6852 @end cartouche
6853 @noindent
6854 A compilation unit is the same in two different partitions if and only
6855 if it derives from the same source file.
6857 @sp 1
6858 @cartouche
6859 @noindent
6860 @strong{48}.  Implementation-defined components.  See 13.5.1(15).
6861 @end cartouche
6862 @noindent
6863 The only implementation defined component is the tag for a tagged type,
6864 which contains a pointer to the dispatching table.
6866 @sp 1
6867 @cartouche
6868 @noindent
6869 @strong{49}.  If @code{Word_Size} = @code{Storage_Unit}, the default bit
6870 ordering.  See 13.5.3(5).
6871 @end cartouche
6872 @noindent
6873 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
6874 implementation, so no non-default bit ordering is supported.  The default
6875 bit ordering corresponds to the natural endianness of the target architecture.
6877 @sp 1
6878 @cartouche
6879 @noindent
6880 @strong{50}.  The contents of the visible part of package @code{System}
6881 and its language-defined children.  See 13.7(2).
6882 @end cartouche
6883 @noindent
6884 See the definition of these packages in files @file{system.ads} and
6885 @file{s-stoele.ads}.
6887 @sp 1
6888 @cartouche
6889 @noindent
6890 @strong{51}.  The contents of the visible part of package
6891 @code{System.Machine_Code}, and the meaning of
6892 @code{code_statements}.  See 13.8(7).
6893 @end cartouche
6894 @noindent
6895 See the definition and documentation in file @file{s-maccod.ads}.
6897 @sp 1
6898 @cartouche
6899 @noindent
6900 @strong{52}.  The effect of unchecked conversion.  See 13.9(11).
6901 @end cartouche
6902 @noindent
6903 Unchecked conversion between types of the same size
6904 and results in an uninterpreted transmission of the bits from one type
6905 to the other.  If the types are of unequal sizes, then in the case of
6906 discrete types, a shorter source is first zero or sign extended as
6907 necessary, and a shorter target is simply truncated on the left.
6908 For all non-discrete types, the source is first copied if necessary
6909 to ensure that the alignment requirements of the target are met, then
6910 a pointer is constructed to the source value, and the result is obtained
6911 by dereferencing this pointer after converting it to be a pointer to the
6912 target type.
6914 @sp 1
6915 @cartouche
6916 @noindent
6917 @strong{53}.  The manner of choosing a storage pool for an access type
6918 when @code{Storage_Pool} is not specified for the type.  See 13.11(17).
6919 @end cartouche
6920 @noindent
6921 There are 3 different standard pools used by the compiler when
6922 @code{Storage_Pool} is not specified depending whether the type is local
6923 to a subprogram or defined at the library level and whether
6924 @code{Storage_Size}is specified or not.  See documentation in the runtime
6925 library units @code{System.Pool_Global}, @code{System.Pool_Size} and
6926 @code{System.Pool_Local} in files @file{s-poosiz.ads},
6927 @file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
6928 default pools used.
6930 @sp 1
6931 @cartouche
6932 @noindent
6933 @strong{54}.  Whether or not the implementation provides user-accessible
6934 names for the standard pool type(s).  See 13.11(17).
6935 @end cartouche
6936 @noindent
6938 See documentation in the sources of the run time mentioned in paragraph
6939 @strong{53} .  All these pools are accessible by means of @code{with}'ing
6940 these units.
6942 @sp 1
6943 @cartouche
6944 @noindent
6945 @strong{55}.  The meaning of @code{Storage_Size}.  See 13.11(18).
6946 @end cartouche
6947 @noindent
6948 @code{Storage_Size} is measured in storage units, and refers to the
6949 total space available for an access type collection, or to the primary
6950 stack space for a task.
6952 @sp 1
6953 @cartouche
6954 @noindent
6955 @strong{56}.  Implementation-defined aspects of storage pools.  See
6956 13.11(22).
6957 @end cartouche
6958 @noindent
6959 See documentation in the sources of the run time mentioned in paragraph
6960 @strong{53} for details on GNAT-defined aspects of storage pools.
6962 @sp 1
6963 @cartouche
6964 @noindent
6965 @strong{57}.  The set of restrictions allowed in a pragma
6966 @code{Restrictions}.  See 13.12(7).
6967 @end cartouche
6968 @noindent
6969 All RM defined Restriction identifiers are implemented.  The following
6970 additional restriction identifiers are provided.  There are two separate
6971 lists of implementation dependent restriction identifiers.  The first
6972 set requires consistency throughout a partition (in other words, if the
6973 restriction identifier is used for any compilation unit in the partition,
6974 then all compilation units in the partition must obey the restriction.
6976 @table @code
6978 @item Simple_Barriers
6979 @findex Simple_Barriers
6980 This restriction ensures at compile time that barriers in entry declarations
6981 for protected types are restricted to either static boolean expressions or
6982 references to simple boolean variables defined in the private part of the
6983 protected type.  No other form of entry barriers is permitted.  This is one
6984 of the restrictions of the Ravenscar profile for limited tasking (see also
6985 pragma @code{Profile (Ravenscar)}).
6987 @item Max_Entry_Queue_Length => Expr
6988 @findex Max_Entry_Queue_Length
6989 This restriction is a declaration that any protected entry compiled in
6990 the scope of the restriction has at most the specified number of
6991 tasks waiting on the entry
6992 at any one time, and so no queue is required.  This restriction is not
6993 checked at compile time.  A program execution is erroneous if an attempt
6994 is made to queue more than the specified number of tasks on such an entry.
6996 @item No_Calendar
6997 @findex No_Calendar
6998 This restriction ensures at compile time that there is no implicit or
6999 explicit dependence on the package @code{Ada.Calendar}.
7001 @item No_Direct_Boolean_Operators
7002 @findex No_Direct_Boolean_Operators
7003 This restriction ensures that no logical (and/or/xor) or comparison
7004 operators are used on operands of type Boolean (or any type derived
7005 from Boolean). This is intended for use in safety critical programs
7006 where the certification protocol requires the use of short-circuit
7007 (and then, or else) forms for all composite boolean operations.
7009 @item No_Dynamic_Attachment
7010 @findex No_Dynamic_Attachment
7011 This restriction ensures that there is no call to any of the operations
7012 defined in package Ada.Interrupts.
7014 @item No_Enumeration_Maps
7015 @findex No_Enumeration_Maps
7016 This restriction ensures at compile time that no operations requiring
7017 enumeration maps are used (that is Image and Value attributes applied
7018 to enumeration types).
7020 @item No_Entry_Calls_In_Elaboration_Code
7021 @findex No_Entry_Calls_In_Elaboration_Code
7022 This restriction ensures at compile time that no task or protected entry
7023 calls are made during elaboration code.  As a result of the use of this
7024 restriction, the compiler can assume that no code past an accept statement
7025 in a task can be executed at elaboration time.
7027 @item No_Exception_Handlers
7028 @findex No_Exception_Handlers
7029 This restriction ensures at compile time that there are no explicit
7030 exception handlers. It also indicates that no exception propagation will
7031 be provided. In this mode, exceptions may be raised but will result in
7032 an immediate call to the last chance handler, a routine that the user
7033 must define with the following profile:
7035    procedure Last_Chance_Handler
7036      (Source_Location : System.Address; Line : Integer);
7037    pragma Export (C, Last_Chance_Handler,
7038                   "__gnat_last_chance_handler");
7040    The parameter is a C null-terminated string representing a message to be
7041    associated with the exception (typically the source location of the raise
7042    statement generated by the compiler). The Line parameter when non-zero
7043    represents the line number in the source program where the raise occurs.
7045 @item No_Exception_Streams
7046 @findex No_Exception_Streams
7047 This restriction ensures at compile time that no stream operations for
7048 types Exception_Id or Exception_Occurrence are used. This also makes it
7049 impossible to pass exceptions to or from a partition with this restriction
7050 in a distributed environment. If this exception is active, then the generated
7051 code is simplified by omitting the otherwise-required global registration
7052 of exceptions when they are declared.
7054 @item No_Implicit_Conditionals
7055 @findex No_Implicit_Conditionals
7056 This restriction ensures that the generated code does not contain any
7057 implicit conditionals, either by modifying the generated code where possible,
7058 or by rejecting any construct that would otherwise generate an implicit
7059 conditional. Note that this check does not include run time constraint
7060 checks, which on some targets may generate implicit conditionals as
7061 well. To control the latter, constraint checks can be suppressed in the
7062 normal manner.
7064 @item No_Implicit_Dynamic_Code
7065 @findex No_Implicit_Dynamic_Code
7066 This restriction prevents the compiler from building ``trampolines''.
7067 This is a structure that is built on the stack and contains dynamic
7068 code to be executed at run time. A trampoline is needed to indirectly
7069 address a nested subprogram (that is a subprogram that is not at the
7070 library level). The restriction prevents the use of any of the
7071 attributes @code{Address}, @code{Access} or @code{Unrestricted_Access}
7072 being applied to a subprogram that is not at the library level.
7074 @item No_Implicit_Loops
7075 @findex No_Implicit_Loops
7076 This restriction ensures that the generated code does not contain any
7077 implicit @code{for} loops, either by modifying
7078 the generated code where possible,
7079 or by rejecting any construct that would otherwise generate an implicit
7080 @code{for} loop.
7082 @item No_Initialize_Scalars
7083 @findex No_Initialize_Scalars
7084 This restriction ensures that no unit in the partition is compiled with
7085 pragma Initialize_Scalars. This allows the generation of more efficient
7086 code, and in particular eliminates dummy null initialization routines that
7087 are otherwise generated for some record and array types.
7089 @item No_Local_Protected_Objects
7090 @findex No_Local_Protected_Objects
7091 This restriction ensures at compile time that protected objects are
7092 only declared at the library level.
7094 @item No_Protected_Type_Allocators
7095 @findex No_Protected_Type_Allocators
7096 This restriction ensures at compile time that there are no allocator
7097 expressions that attempt to allocate protected objects.
7099 @item No_Secondary_Stack
7100 @findex No_Secondary_Stack
7101 This restriction ensures at compile time that the generated code does not
7102 contain any reference to the secondary stack.  The secondary stack is used
7103 to implement functions returning unconstrained objects (arrays or records)
7104 on some targets.
7106 @item No_Select_Statements
7107 @findex No_Select_Statements
7108 This restriction ensures at compile time no select statements of any kind
7109 are permitted, that is the keyword @code{select} may not appear.
7110 This is one of the restrictions of the Ravenscar
7111 profile for limited tasking (see also pragma @code{Profile (Ravenscar)}).
7113 @item No_Standard_Storage_Pools
7114 @findex No_Standard_Storage_Pools
7115 This restriction ensures at compile time that no access types
7116 use the standard default storage pool.  Any access type declared must
7117 have an explicit Storage_Pool attribute defined specifying a
7118 user-defined storage pool.
7120 @item No_Streams
7121 @findex No_Streams
7122 This restriction ensures at compile/bind time that there are no
7123 stream objects created (and therefore no actual stream operations).
7124 This restriction does not forbid dependences on the package
7125 @code{Ada.Streams}. So it is permissible to with
7126 @code{Ada.Streams} (or another package that does so itself)
7127 as long as no actual stream objects are created.
7129 @item No_Task_Attributes_Package
7130 @findex No_Task_Attributes_Package
7131 This restriction ensures at compile time that there are no implicit or
7132 explicit dependencies on the package @code{Ada.Task_Attributes}.
7134 @item No_Task_Termination
7135 @findex No_Task_Termination
7136 This restriction ensures at compile time that no terminate alternatives
7137 appear in any task body.
7139 @item No_Tasking
7140 @findex No_Tasking
7141 This restriction prevents the declaration of tasks or task types throughout
7142 the partition.  It is similar in effect to the use of @code{Max_Tasks => 0}
7143 except that violations are caught at compile time and cause an error message
7144 to be output either by the compiler or binder.
7146 @item No_Wide_Characters
7147 @findex No_Wide_Characters
7148 This restriction ensures at compile time that no uses of the types
7149 @code{Wide_Character} or @code{Wide_String} or corresponding wide
7150 wide types
7151 appear, and that no wide or wide wide string or character literals
7152 appear in the program (that is literals representing characters not in
7153 type @code{Character}.
7155 @item Static_Priorities
7156 @findex Static_Priorities
7157 This restriction ensures at compile time that all priority expressions
7158 are static, and that there are no dependencies on the package
7159 @code{Ada.Dynamic_Priorities}.
7161 @item Static_Storage_Size
7162 @findex Static_Storage_Size
7163 This restriction ensures at compile time that any expression appearing
7164 in a Storage_Size pragma or attribute definition clause is static.
7166 @end table
7168 @noindent
7169 The second set of implementation dependent restriction identifiers
7170 does not require partition-wide consistency.
7171 The restriction may be enforced for a single
7172 compilation unit without any effect on any of the
7173 other compilation units in the partition.
7175 @table @code
7177 @item No_Elaboration_Code
7178 @findex No_Elaboration_Code
7179 This restriction ensures at compile time that no elaboration code is
7180 generated.  Note that this is not the same condition as is enforced
7181 by pragma @code{Preelaborate}.  There are cases in which pragma
7182 @code{Preelaborate} still permits code to be generated (e.g.@: code
7183 to initialize a large array to all zeroes), and there are cases of units
7184 which do not meet the requirements for pragma @code{Preelaborate},
7185 but for which no elaboration code is generated.  Generally, it is
7186 the case that preelaborable units will meet the restrictions, with
7187 the exception of large aggregates initialized with an others_clause,
7188 and exception declarations (which generate calls to a run-time
7189 registry procedure).  Note that this restriction is enforced on
7190 a unit by unit basis, it need not be obeyed consistently
7191 throughout a partition.
7193 @item No_Entry_Queue
7194 @findex No_Entry_Queue
7195 This restriction is a declaration that any protected entry compiled in
7196 the scope of the restriction has at most one task waiting on the entry
7197 at any one time, and so no queue is required.  This restriction is not
7198 checked at compile time.  A program execution is erroneous if an attempt
7199 is made to queue a second task on such an entry.
7201 @item No_Implementation_Attributes
7202 @findex No_Implementation_Attributes
7203 This restriction checks at compile time that no GNAT-defined attributes
7204 are present.  With this restriction, the only attributes that can be used
7205 are those defined in the Ada 95 Reference Manual.
7207 @item No_Implementation_Pragmas
7208 @findex No_Implementation_Pragmas
7209 This restriction checks at compile time that no GNAT-defined pragmas
7210 are present.  With this restriction, the only pragmas that can be used
7211 are those defined in the Ada 95 Reference Manual.
7213 @item No_Implementation_Restrictions
7214 @findex No_Implementation_Restrictions
7215 This restriction checks at compile time that no GNAT-defined restriction
7216 identifiers (other than @code{No_Implementation_Restrictions} itself)
7217 are present.  With this restriction, the only other restriction identifiers
7218 that can be used are those defined in the Ada 95 Reference Manual.
7220 @end table
7222 @sp 1
7223 @cartouche
7224 @noindent
7225 @strong{58}.  The consequences of violating limitations on
7226 @code{Restrictions} pragmas.  See 13.12(9).
7227 @end cartouche
7228 @noindent
7229 Restrictions that can be checked at compile time result in illegalities
7230 if violated.  Currently there are no other consequences of violating
7231 restrictions.
7233 @sp 1
7234 @cartouche
7235 @noindent
7236 @strong{59}.  The representation used by the @code{Read} and
7237 @code{Write} attributes of elementary types in terms of stream
7238 elements.  See 13.13.2(9).
7239 @end cartouche
7240 @noindent
7241 The representation is the in-memory representation of the base type of
7242 the type, using the number of bits corresponding to the
7243 @code{@var{type}'Size} value, and the natural ordering of the machine.
7245 @sp 1
7246 @cartouche
7247 @noindent
7248 @strong{60}.  The names and characteristics of the numeric subtypes
7249 declared in the visible part of package @code{Standard}.  See A.1(3).
7250 @end cartouche
7251 @noindent
7252 See items describing the integer and floating-point types supported.
7254 @sp 1
7255 @cartouche
7256 @noindent
7257 @strong{61}.  The accuracy actually achieved by the elementary
7258 functions.  See A.5.1(1).
7259 @end cartouche
7260 @noindent
7261 The elementary functions correspond to the functions available in the C
7262 library.  Only fast math mode is implemented.
7264 @sp 1
7265 @cartouche
7266 @noindent
7267 @strong{62}.  The sign of a zero result from some of the operators or
7268 functions in @code{Numerics.Generic_Elementary_Functions}, when
7269 @code{Float_Type'Signed_Zeros} is @code{True}.  See A.5.1(46).
7270 @end cartouche
7271 @noindent
7272 The sign of zeroes follows the requirements of the IEEE 754 standard on
7273 floating-point.
7275 @sp 1
7276 @cartouche
7277 @noindent
7278 @strong{63}.  The value of
7279 @code{Numerics.Float_Random.Max_Image_Width}.  See A.5.2(27).
7280 @end cartouche
7281 @noindent
7282 Maximum image width is 649, see library file @file{a-numran.ads}.
7284 @sp 1
7285 @cartouche
7286 @noindent
7287 @strong{64}.  The value of
7288 @code{Numerics.Discrete_Random.Max_Image_Width}.  See A.5.2(27).
7289 @end cartouche
7290 @noindent
7291 Maximum image width is 80, see library file @file{a-nudira.ads}.
7293 @sp 1
7294 @cartouche
7295 @noindent
7296 @strong{65}.  The algorithms for random number generation.  See
7297 A.5.2(32).
7298 @end cartouche
7299 @noindent
7300 The algorithm is documented in the source files @file{a-numran.ads} and
7301 @file{a-numran.adb}.
7303 @sp 1
7304 @cartouche
7305 @noindent
7306 @strong{66}.  The string representation of a random number generator's
7307 state.  See A.5.2(38).
7308 @end cartouche
7309 @noindent
7310 See the documentation contained in the file @file{a-numran.adb}.
7312 @sp 1
7313 @cartouche
7314 @noindent
7315 @strong{67}.  The minimum time interval between calls to the
7316 time-dependent Reset procedure that are guaranteed to initiate different
7317 random number sequences.  See A.5.2(45).
7318 @end cartouche
7319 @noindent
7320 The minimum period between reset calls to guarantee distinct series of
7321 random numbers is one microsecond.
7323 @sp 1
7324 @cartouche
7325 @noindent
7326 @strong{68}.  The values of the @code{Model_Mantissa},
7327 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
7328 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
7329 Annex is not supported.  See A.5.3(72).
7330 @end cartouche
7331 @noindent
7332 See the source file @file{ttypef.ads} for the values of all numeric
7333 attributes.
7335 @sp 1
7336 @cartouche
7337 @noindent
7338 @strong{69}.  Any implementation-defined characteristics of the
7339 input-output packages.  See A.7(14).
7340 @end cartouche
7341 @noindent
7342 There are no special implementation defined characteristics for these
7343 packages.
7345 @sp 1
7346 @cartouche
7347 @noindent
7348 @strong{70}.  The value of @code{Buffer_Size} in @code{Storage_IO}.  See
7349 A.9(10).
7350 @end cartouche
7351 @noindent
7352 All type representations are contiguous, and the @code{Buffer_Size} is
7353 the value of @code{@var{type}'Size} rounded up to the next storage unit
7354 boundary.
7356 @sp 1
7357 @cartouche
7358 @noindent
7359 @strong{71}.  External files for standard input, standard output, and
7360 standard error See A.10(5).
7361 @end cartouche
7362 @noindent
7363 These files are mapped onto the files provided by the C streams
7364 libraries.  See source file @file{i-cstrea.ads} for further details.
7366 @sp 1
7367 @cartouche
7368 @noindent
7369 @strong{72}.  The accuracy of the value produced by @code{Put}.  See
7370 A.10.9(36).
7371 @end cartouche
7372 @noindent
7373 If more digits are requested in the output than are represented by the
7374 precision of the value, zeroes are output in the corresponding least
7375 significant digit positions.
7377 @sp 1
7378 @cartouche
7379 @noindent
7380 @strong{73}.  The meaning of @code{Argument_Count}, @code{Argument}, and
7381 @code{Command_Name}.  See A.15(1).
7382 @end cartouche
7383 @noindent
7384 These are mapped onto the @code{argv} and @code{argc} parameters of the
7385 main program in the natural manner.
7387 @sp 1
7388 @cartouche
7389 @noindent
7390 @strong{74}.  Implementation-defined convention names.  See B.1(11).
7391 @end cartouche
7392 @noindent
7393 The following convention names are supported
7395 @table @code
7396 @item  Ada
7398 @item Assembler
7399 Assembly language
7400 @item Asm
7401 Synonym for Assembler
7402 @item Assembly
7403 Synonym for Assembler
7404 @item C
7406 @item C_Pass_By_Copy
7407 Allowed only for record types, like C, but also notes that record
7408 is to be passed by copy rather than reference.
7409 @item COBOL
7410 COBOL
7411 @item CPP
7413 @item Default
7414 Treated the same as C
7415 @item External
7416 Treated the same as C
7417 @item Fortran
7418 Fortran
7419 @item Intrinsic
7420 For support of pragma @code{Import} with convention Intrinsic, see
7421 separate section on Intrinsic Subprograms.
7422 @item Stdcall
7423 Stdcall (used for Windows implementations only).  This convention correspond
7424 to the WINAPI (previously called Pascal convention) C/C++ convention under
7425 Windows.  A function with this convention cleans the stack before exit.
7426 @item DLL
7427 Synonym for Stdcall
7428 @item Win32
7429 Synonym for Stdcall
7430 @item Stubbed
7431 Stubbed is a special convention used to indicate that the body of the
7432 subprogram will be entirely ignored.  Any call to the subprogram
7433 is converted into a raise of the @code{Program_Error} exception.  If a
7434 pragma @code{Import} specifies convention @code{stubbed} then no body need
7435 be present at all.  This convention is useful during development for the
7436 inclusion of subprograms whose body has not yet been written.
7438 @end table
7439 @noindent
7440 In addition, all otherwise unrecognized convention names are also
7441 treated as being synonymous with convention C@.  In all implementations
7442 except for VMS, use of such other names results in a warning.  In VMS
7443 implementations, these names are accepted silently.
7445 @sp 1
7446 @cartouche
7447 @noindent
7448 @strong{75}.  The meaning of link names.  See B.1(36).
7449 @end cartouche
7450 @noindent
7451 Link names are the actual names used by the linker.
7453 @sp 1
7454 @cartouche
7455 @noindent
7456 @strong{76}.  The manner of choosing link names when neither the link
7457 name nor the address of an imported or exported entity is specified.  See
7458 B.1(36).
7459 @end cartouche
7460 @noindent
7461 The default linker name is that which would be assigned by the relevant
7462 external language, interpreting the Ada name as being in all lower case
7463 letters.
7465 @sp 1
7466 @cartouche
7467 @noindent
7468 @strong{77}.  The effect of pragma @code{Linker_Options}.  See B.1(37).
7469 @end cartouche
7470 @noindent
7471 The string passed to @code{Linker_Options} is presented uninterpreted as
7472 an argument to the link command, unless it contains Ascii.NUL characters.
7473 NUL characters if they appear act as argument separators, so for example
7475 @smallexample @c ada
7476 pragma Linker_Options ("-labc" & ASCII.Nul & "-ldef");
7477 @end smallexample
7479 @noindent
7480 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
7481 linker. The order of linker options is preserved for a given unit. The final
7482 list of options passed to the linker is in reverse order of the elaboration
7483 order. For example, linker options fo a body always appear before the options
7484 from the corresponding package spec.
7486 @sp 1
7487 @cartouche
7488 @noindent
7489 @strong{78}.  The contents of the visible part of package
7490 @code{Interfaces} and its language-defined descendants.  See B.2(1).
7491 @end cartouche
7492 @noindent
7493 See files with prefix @file{i-} in the distributed library.
7495 @sp 1
7496 @cartouche
7497 @noindent
7498 @strong{79}.  Implementation-defined children of package
7499 @code{Interfaces}.  The contents of the visible part of package
7500 @code{Interfaces}.  See B.2(11).
7501 @end cartouche
7502 @noindent
7503 See files with prefix @file{i-} in the distributed library.
7505 @sp 1
7506 @cartouche
7507 @noindent
7508 @strong{80}.  The types @code{Floating}, @code{Long_Floating},
7509 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
7510 @code{COBOL_Character}; and the initialization of the variables
7511 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
7512 @code{Interfaces.COBOL}.  See B.4(50).
7513 @end cartouche
7514 @noindent
7515 @table @code
7516 @item Floating
7517 Float
7518 @item Long_Floating
7519 (Floating) Long_Float
7520 @item Binary
7521 Integer
7522 @item Long_Binary
7523 Long_Long_Integer
7524 @item Decimal_Element
7525 Character
7526 @item COBOL_Character
7527 Character
7528 @end table
7530 @noindent
7531 For initialization, see the file @file{i-cobol.ads} in the distributed library.
7533 @sp 1
7534 @cartouche
7535 @noindent
7536 @strong{81}.  Support for access to machine instructions.  See C.1(1).
7537 @end cartouche
7538 @noindent
7539 See documentation in file @file{s-maccod.ads} in the distributed library.
7541 @sp 1
7542 @cartouche
7543 @noindent
7544 @strong{82}.  Implementation-defined aspects of access to machine
7545 operations.  See C.1(9).
7546 @end cartouche
7547 @noindent
7548 See documentation in file @file{s-maccod.ads} in the distributed library.
7550 @sp 1
7551 @cartouche
7552 @noindent
7553 @strong{83}.  Implementation-defined aspects of interrupts.  See C.3(2).
7554 @end cartouche
7555 @noindent
7556 Interrupts are mapped to signals or conditions as appropriate.  See
7557 definition of unit
7558 @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
7559 on the interrupts supported on a particular target.
7561 @sp 1
7562 @cartouche
7563 @noindent
7564 @strong{84}.  Implementation-defined aspects of pre-elaboration.  See
7565 C.4(13).
7566 @end cartouche
7567 @noindent
7568 GNAT does not permit a partition to be restarted without reloading,
7569 except under control of the debugger.
7571 @sp 1
7572 @cartouche
7573 @noindent
7574 @strong{85}.  The semantics of pragma @code{Discard_Names}.  See C.5(7).
7575 @end cartouche
7576 @noindent
7577 Pragma @code{Discard_Names} causes names of enumeration literals to
7578 be suppressed.  In the presence of this pragma, the Image attribute
7579 provides the image of the Pos of the literal, and Value accepts
7580 Pos values.
7582 @sp 1
7583 @cartouche
7584 @noindent
7585 @strong{86}.  The result of the @code{Task_Identification.Image}
7586 attribute.  See C.7.1(7).
7587 @end cartouche
7588 @noindent
7589 The result of this attribute is an 8-digit hexadecimal string
7590 representing the virtual address of the task control block.
7592 @sp 1
7593 @cartouche
7594 @noindent
7595 @strong{87}.  The value of @code{Current_Task} when in a protected entry
7596 or interrupt handler.  See C.7.1(17).
7597 @end cartouche
7598 @noindent
7599 Protected entries or interrupt handlers can be executed by any
7600 convenient thread, so the value of @code{Current_Task} is undefined.
7602 @sp 1
7603 @cartouche
7604 @noindent
7605 @strong{88}.  The effect of calling @code{Current_Task} from an entry
7606 body or interrupt handler.  See C.7.1(19).
7607 @end cartouche
7608 @noindent
7609 The effect of calling @code{Current_Task} from an entry body or
7610 interrupt handler is to return the identification of the task currently
7611 executing the code.
7613 @sp 1
7614 @cartouche
7615 @noindent
7616 @strong{89}.  Implementation-defined aspects of
7617 @code{Task_Attributes}.  See C.7.2(19).
7618 @end cartouche
7619 @noindent
7620 There are no implementation-defined aspects of @code{Task_Attributes}.
7622 @sp 1
7623 @cartouche
7624 @noindent
7625 @strong{90}.  Values of all @code{Metrics}.  See D(2).
7626 @end cartouche
7627 @noindent
7628 The metrics information for GNAT depends on the performance of the
7629 underlying operating system.  The sources of the run-time for tasking
7630 implementation, together with the output from @code{-gnatG} can be
7631 used to determine the exact sequence of operating systems calls made
7632 to implement various tasking constructs.  Together with appropriate
7633 information on the performance of the underlying operating system,
7634 on the exact target in use, this information can be used to determine
7635 the required metrics.
7637 @sp 1
7638 @cartouche
7639 @noindent
7640 @strong{91}.  The declarations of @code{Any_Priority} and
7641 @code{Priority}.  See D.1(11).
7642 @end cartouche
7643 @noindent
7644 See declarations in file @file{system.ads}.
7646 @sp 1
7647 @cartouche
7648 @noindent
7649 @strong{92}.  Implementation-defined execution resources.  See D.1(15).
7650 @end cartouche
7651 @noindent
7652 There are no implementation-defined execution resources.
7654 @sp 1
7655 @cartouche
7656 @noindent
7657 @strong{93}.  Whether, on a multiprocessor, a task that is waiting for
7658 access to a protected object keeps its processor busy.  See D.2.1(3).
7659 @end cartouche
7660 @noindent
7661 On a multi-processor, a task that is waiting for access to a protected
7662 object does not keep its processor busy.
7664 @sp 1
7665 @cartouche
7666 @noindent
7667 @strong{94}.  The affect of implementation defined execution resources
7668 on task dispatching.  See D.2.1(9).
7669 @end cartouche
7670 @noindent
7671 @c SGI info
7672 @ignore
7673 Tasks map to IRIX threads, and the dispatching policy is as defined by
7674 the IRIX implementation of threads.
7675 @end ignore
7676 Tasks map to threads in the threads package used by GNAT@.  Where possible
7677 and appropriate, these threads correspond to native threads of the
7678 underlying operating system.
7680 @sp 1
7681 @cartouche
7682 @noindent
7683 @strong{95}.  Implementation-defined @code{policy_identifiers} allowed
7684 in a pragma @code{Task_Dispatching_Policy}.  See D.2.2(3).
7685 @end cartouche
7686 @noindent
7687 There are no implementation-defined policy-identifiers allowed in this
7688 pragma.
7690 @sp 1
7691 @cartouche
7692 @noindent
7693 @strong{96}.  Implementation-defined aspects of priority inversion.  See
7694 D.2.2(16).
7695 @end cartouche
7696 @noindent
7697 Execution of a task cannot be preempted by the implementation processing
7698 of delay expirations for lower priority tasks.
7700 @sp 1
7701 @cartouche
7702 @noindent
7703 @strong{97}.  Implementation defined task dispatching.  See D.2.2(18).
7704 @end cartouche
7705 @noindent
7706 @c SGI info:
7707 @ignore
7708 Tasks map to IRIX threads, and the dispatching policy is as defied by
7709 the IRIX implementation of threads.
7710 @end ignore
7711 The policy is the same as that of the underlying threads implementation.
7713 @sp 1
7714 @cartouche
7715 @noindent
7716 @strong{98}.  Implementation-defined @code{policy_identifiers} allowed
7717 in a pragma @code{Locking_Policy}.  See D.3(4).
7718 @end cartouche
7719 @noindent
7720 The only implementation defined policy permitted in GNAT is
7721 @code{Inheritance_Locking}.  On targets that support this policy, locking
7722 is implemented by inheritance, i.e.@: the task owning the lock operates
7723 at a priority equal to the highest priority of any task currently
7724 requesting the lock.
7726 @sp 1
7727 @cartouche
7728 @noindent
7729 @strong{99}.  Default ceiling priorities.  See D.3(10).
7730 @end cartouche
7731 @noindent
7732 The ceiling priority of protected objects of the type
7733 @code{System.Interrupt_Priority'Last} as described in the Ada 95
7734 Reference Manual D.3(10),
7736 @sp 1
7737 @cartouche
7738 @noindent
7739 @strong{100}.  The ceiling of any protected object used internally by
7740 the implementation.  See D.3(16).
7741 @end cartouche
7742 @noindent
7743 The ceiling priority of internal protected objects is
7744 @code{System.Priority'Last}.
7746 @sp 1
7747 @cartouche
7748 @noindent
7749 @strong{101}.  Implementation-defined queuing policies.  See D.4(1).
7750 @end cartouche
7751 @noindent
7752 There are no implementation-defined queueing policies.
7754 @sp 1
7755 @cartouche
7756 @noindent
7757 @strong{102}.  On a multiprocessor, any conditions that cause the
7758 completion of an aborted construct to be delayed later than what is
7759 specified for a single processor.  See D.6(3).
7760 @end cartouche
7761 @noindent
7762 The semantics for abort on a multi-processor is the same as on a single
7763 processor, there are no further delays.
7765 @sp 1
7766 @cartouche
7767 @noindent
7768 @strong{103}.  Any operations that implicitly require heap storage
7769 allocation.  See D.7(8).
7770 @end cartouche
7771 @noindent
7772 The only operation that implicitly requires heap storage allocation is
7773 task creation.
7775 @sp 1
7776 @cartouche
7777 @noindent
7778 @strong{104}.  Implementation-defined aspects of pragma
7779 @code{Restrictions}.  See D.7(20).
7780 @end cartouche
7781 @noindent
7782 There are no such implementation-defined aspects.
7784 @sp 1
7785 @cartouche
7786 @noindent
7787 @strong{105}.  Implementation-defined aspects of package
7788 @code{Real_Time}.  See D.8(17).
7789 @end cartouche
7790 @noindent
7791 There are no implementation defined aspects of package @code{Real_Time}.
7793 @sp 1
7794 @cartouche
7795 @noindent
7796 @strong{106}.  Implementation-defined aspects of
7797 @code{delay_statements}.  See D.9(8).
7798 @end cartouche
7799 @noindent
7800 Any difference greater than one microsecond will cause the task to be
7801 delayed (see D.9(7)).
7803 @sp 1
7804 @cartouche
7805 @noindent
7806 @strong{107}.  The upper bound on the duration of interrupt blocking
7807 caused by the implementation.  See D.12(5).
7808 @end cartouche
7809 @noindent
7810 The upper bound is determined by the underlying operating system.  In
7811 no cases is it more than 10 milliseconds.
7813 @sp 1
7814 @cartouche
7815 @noindent
7816 @strong{108}.  The means for creating and executing distributed
7817 programs.  See E(5).
7818 @end cartouche
7819 @noindent
7820 The GLADE package provides a utility GNATDIST for creating and executing
7821 distributed programs.  See the GLADE reference manual for further details.
7823 @sp 1
7824 @cartouche
7825 @noindent
7826 @strong{109}.  Any events that can result in a partition becoming
7827 inaccessible.  See E.1(7).
7828 @end cartouche
7829 @noindent
7830 See the GLADE reference manual for full details on such events.
7832 @sp 1
7833 @cartouche
7834 @noindent
7835 @strong{110}.  The scheduling policies, treatment of priorities, and
7836 management of shared resources between partitions in certain cases.  See
7837 E.1(11).
7838 @end cartouche
7839 @noindent
7840 See the GLADE reference manual for full details on these aspects of
7841 multi-partition execution.
7843 @sp 1
7844 @cartouche
7845 @noindent
7846 @strong{111}.  Events that cause the version of a compilation unit to
7847 change.  See E.3(5).
7848 @end cartouche
7849 @noindent
7850 Editing the source file of a compilation unit, or the source files of
7851 any units on which it is dependent in a significant way cause the version
7852 to change.  No other actions cause the version number to change.  All changes
7853 are significant except those which affect only layout, capitalization or
7854 comments.
7856 @sp 1
7857 @cartouche
7858 @noindent
7859 @strong{112}.  Whether the execution of the remote subprogram is
7860 immediately aborted as a result of cancellation.  See E.4(13).
7861 @end cartouche
7862 @noindent
7863 See the GLADE reference manual for details on the effect of abort in
7864 a distributed application.
7866 @sp 1
7867 @cartouche
7868 @noindent
7869 @strong{113}.  Implementation-defined aspects of the PCS@.  See E.5(25).
7870 @end cartouche
7871 @noindent
7872 See the GLADE reference manual for a full description of all implementation
7873 defined aspects of the PCS@.
7875 @sp 1
7876 @cartouche
7877 @noindent
7878 @strong{114}.  Implementation-defined interfaces in the PCS@.  See
7879 E.5(26).
7880 @end cartouche
7881 @noindent
7882 See the GLADE reference manual for a full description of all
7883 implementation defined interfaces.
7885 @sp 1
7886 @cartouche
7887 @noindent
7888 @strong{115}.  The values of named numbers in the package
7889 @code{Decimal}.  See F.2(7).
7890 @end cartouche
7891 @noindent
7892 @table @code
7893 @item Max_Scale
7895 @item Min_Scale
7897 @item Min_Delta
7898 1.0E-18
7899 @item Max_Delta
7900 1.0E+18
7901 @item Max_Decimal_Digits
7903 @end table
7905 @sp 1
7906 @cartouche
7907 @noindent
7908 @strong{116}.  The value of @code{Max_Picture_Length} in the package
7909 @code{Text_IO.Editing}.  See F.3.3(16).
7910 @end cartouche
7911 @noindent
7914 @sp 1
7915 @cartouche
7916 @noindent
7917 @strong{117}.  The value of @code{Max_Picture_Length} in the package
7918 @code{Wide_Text_IO.Editing}.  See F.3.4(5).
7919 @end cartouche
7920 @noindent
7923 @sp 1
7924 @cartouche
7925 @noindent
7926 @strong{118}.  The accuracy actually achieved by the complex elementary
7927 functions and by other complex arithmetic operations.  See G.1(1).
7928 @end cartouche
7929 @noindent
7930 Standard library functions are used for the complex arithmetic
7931 operations.  Only fast math mode is currently supported.
7933 @sp 1
7934 @cartouche
7935 @noindent
7936 @strong{119}.  The sign of a zero result (or a component thereof) from
7937 any operator or function in @code{Numerics.Generic_Complex_Types}, when
7938 @code{Real'Signed_Zeros} is True.  See G.1.1(53).
7939 @end cartouche
7940 @noindent
7941 The signs of zero values are as recommended by the relevant
7942 implementation advice.
7944 @sp 1
7945 @cartouche
7946 @noindent
7947 @strong{120}.  The sign of a zero result (or a component thereof) from
7948 any operator or function in
7949 @code{Numerics.Generic_Complex_Elementary_Functions}, when
7950 @code{Real'Signed_Zeros} is @code{True}.  See G.1.2(45).
7951 @end cartouche
7952 @noindent
7953 The signs of zero values are as recommended by the relevant
7954 implementation advice.
7956 @sp 1
7957 @cartouche
7958 @noindent
7959 @strong{121}.  Whether the strict mode or the relaxed mode is the
7960 default.  See G.2(2).
7961 @end cartouche
7962 @noindent
7963 The strict mode is the default.  There is no separate relaxed mode.  GNAT
7964 provides a highly efficient implementation of strict mode.
7966 @sp 1
7967 @cartouche
7968 @noindent
7969 @strong{122}.  The result interval in certain cases of fixed-to-float
7970 conversion.  See G.2.1(10).
7971 @end cartouche
7972 @noindent
7973 For cases where the result interval is implementation dependent, the
7974 accuracy is that provided by performing all operations in 64-bit IEEE
7975 floating-point format.
7977 @sp 1
7978 @cartouche
7979 @noindent
7980 @strong{123}.  The result of a floating point arithmetic operation in
7981 overflow situations, when the @code{Machine_Overflows} attribute of the
7982 result type is @code{False}.  See G.2.1(13).
7983 @end cartouche
7984 @noindent
7985 Infinite and Nan values are produced as dictated by the IEEE
7986 floating-point standard.
7988 @sp 1
7989 @cartouche
7990 @noindent
7991 @strong{124}.  The result interval for division (or exponentiation by a
7992 negative exponent), when the floating point hardware implements division
7993 as multiplication by a reciprocal.  See G.2.1(16).
7994 @end cartouche
7995 @noindent
7996 Not relevant, division is IEEE exact.
7998 @sp 1
7999 @cartouche
8000 @noindent
8001 @strong{125}.  The definition of close result set, which determines the
8002 accuracy of certain fixed point multiplications and divisions.  See
8003 G.2.3(5).
8004 @end cartouche
8005 @noindent
8006 Operations in the close result set are performed using IEEE long format
8007 floating-point arithmetic.  The input operands are converted to
8008 floating-point, the operation is done in floating-point, and the result
8009 is converted to the target type.
8011 @sp 1
8012 @cartouche
8013 @noindent
8014 @strong{126}.  Conditions on a @code{universal_real} operand of a fixed
8015 point multiplication or division for which the result shall be in the
8016 perfect result set.  See G.2.3(22).
8017 @end cartouche
8018 @noindent
8019 The result is only defined to be in the perfect result set if the result
8020 can be computed by a single scaling operation involving a scale factor
8021 representable in 64-bits.
8023 @sp 1
8024 @cartouche
8025 @noindent
8026 @strong{127}.  The result of a fixed point arithmetic operation in
8027 overflow situations, when the @code{Machine_Overflows} attribute of the
8028 result type is @code{False}.  See G.2.3(27).
8029 @end cartouche
8030 @noindent
8031 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
8032 types.
8034 @sp 1
8035 @cartouche
8036 @noindent
8037 @strong{128}.  The result of an elementary function reference in
8038 overflow situations, when the @code{Machine_Overflows} attribute of the
8039 result type is @code{False}.  See G.2.4(4).
8040 @end cartouche
8041 @noindent
8042 IEEE infinite and Nan values are produced as appropriate.
8044 @sp 1
8045 @cartouche
8046 @noindent
8047 @strong{129}.  The value of the angle threshold, within which certain
8048 elementary functions, complex arithmetic operations, and complex
8049 elementary functions yield results conforming to a maximum relative
8050 error bound.  See G.2.4(10).
8051 @end cartouche
8052 @noindent
8053 Information on this subject is not yet available.
8055 @sp 1
8056 @cartouche
8057 @noindent
8058 @strong{130}.  The accuracy of certain elementary functions for
8059 parameters beyond the angle threshold.  See G.2.4(10).
8060 @end cartouche
8061 @noindent
8062 Information on this subject is not yet available.
8064 @sp 1
8065 @cartouche
8066 @noindent
8067 @strong{131}.  The result of a complex arithmetic operation or complex
8068 elementary function reference in overflow situations, when the
8069 @code{Machine_Overflows} attribute of the corresponding real type is
8070 @code{False}.  See G.2.6(5).
8071 @end cartouche
8072 @noindent
8073 IEEE infinite and Nan values are produced as appropriate.
8075 @sp 1
8076 @cartouche
8077 @noindent
8078 @strong{132}.  The accuracy of certain complex arithmetic operations and
8079 certain complex elementary functions for parameters (or components
8080 thereof) beyond the angle threshold.  See G.2.6(8).
8081 @end cartouche
8082 @noindent
8083 Information on those subjects is not yet available.
8085 @sp 1
8086 @cartouche
8087 @noindent
8088 @strong{133}.  Information regarding bounded errors and erroneous
8089 execution.  See H.2(1).
8090 @end cartouche
8091 @noindent
8092 Information on this subject is not yet available.
8094 @sp 1
8095 @cartouche
8096 @noindent
8097 @strong{134}.  Implementation-defined aspects of pragma
8098 @code{Inspection_Point}.  See H.3.2(8).
8099 @end cartouche
8100 @noindent
8101 Pragma @code{Inspection_Point} ensures that the variable is live and can
8102 be examined by the debugger at the inspection point.
8104 @sp 1
8105 @cartouche
8106 @noindent
8107 @strong{135}.  Implementation-defined aspects of pragma
8108 @code{Restrictions}.  See H.4(25).
8109 @end cartouche
8110 @noindent
8111 There are no implementation-defined aspects of pragma @code{Restrictions}.  The
8112 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
8113 generated code.  Checks must suppressed by use of pragma @code{Suppress}.
8115 @sp 1
8116 @cartouche
8117 @noindent
8118 @strong{136}.  Any restrictions on pragma @code{Restrictions}.  See
8119 H.4(27).
8120 @end cartouche
8121 @noindent
8122 There are no restrictions on pragma @code{Restrictions}.
8124 @node Intrinsic Subprograms
8125 @chapter Intrinsic Subprograms
8126 @cindex Intrinsic Subprograms
8128 @menu
8129 * Intrinsic Operators::
8130 * Enclosing_Entity::
8131 * Exception_Information::
8132 * Exception_Message::
8133 * Exception_Name::
8134 * File::
8135 * Line::
8136 * Rotate_Left::
8137 * Rotate_Right::
8138 * Shift_Left::
8139 * Shift_Right::
8140 * Shift_Right_Arithmetic::
8141 * Source_Location::
8142 @end menu
8144 @noindent
8145 GNAT allows a user application program to write the declaration:
8147 @smallexample @c ada
8148    pragma Import (Intrinsic, name);
8149 @end smallexample
8151 @noindent
8152 providing that the name corresponds to one of the implemented intrinsic
8153 subprograms in GNAT, and that the parameter profile of the referenced
8154 subprogram meets the requirements.  This chapter describes the set of
8155 implemented intrinsic subprograms, and the requirements on parameter profiles.
8156 Note that no body is supplied; as with other uses of pragma Import, the
8157 body is supplied elsewhere (in this case by the compiler itself).  Note
8158 that any use of this feature is potentially non-portable, since the
8159 Ada standard does not require Ada compilers to implement this feature.
8161 @node Intrinsic Operators
8162 @section Intrinsic Operators
8163 @cindex Intrinsic operator
8165 @noindent
8166 All the predefined numeric operators in package Standard
8167 in @code{pragma Import (Intrinsic,..)}
8168 declarations.  In the binary operator case, the operands must have the same
8169 size.  The operand or operands must also be appropriate for
8170 the operator.  For example, for addition, the operands must
8171 both be floating-point or both be fixed-point, and the
8172 right operand for @code{"**"} must have a root type of
8173 @code{Standard.Integer'Base}.
8174 You can use an intrinsic operator declaration as in the following example:
8176 @smallexample @c ada
8177    type Int1 is new Integer;
8178    type Int2 is new Integer;
8180    function "+" (X1 : Int1; X2 : Int2) return Int1;
8181    function "+" (X1 : Int1; X2 : Int2) return Int2;
8182    pragma Import (Intrinsic, "+");
8183 @end smallexample
8185 @noindent
8186 This declaration would permit ``mixed mode'' arithmetic on items
8187 of the differing types @code{Int1} and @code{Int2}.
8188 It is also possible to specify such operators for private types, if the
8189 full views are appropriate arithmetic types.
8191 @node Enclosing_Entity
8192 @section Enclosing_Entity
8193 @cindex Enclosing_Entity
8194 @noindent
8195 This intrinsic subprogram is used in the implementation of the
8196 library routine @code{GNAT.Source_Info}.  The only useful use of the
8197 intrinsic import in this case is the one in this unit, so an
8198 application program should simply call the function
8199 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
8200 the current subprogram, package, task, entry, or protected subprogram.
8202 @node Exception_Information
8203 @section Exception_Information
8204 @cindex Exception_Information'
8205 @noindent
8206 This intrinsic subprogram is used in the implementation of the
8207 library routine @code{GNAT.Current_Exception}.  The only useful
8208 use of the intrinsic import in this case is the one in this unit,
8209 so an application program should simply call the function
8210 @code{GNAT.Current_Exception.Exception_Information} to obtain
8211 the exception information associated with the current exception.
8213 @node Exception_Message
8214 @section Exception_Message
8215 @cindex Exception_Message
8216 @noindent
8217 This intrinsic subprogram is used in the implementation of the
8218 library routine @code{GNAT.Current_Exception}.  The only useful
8219 use of the intrinsic import in this case is the one in this unit,
8220 so an application program should simply call the function
8221 @code{GNAT.Current_Exception.Exception_Message} to obtain
8222 the message associated with the current exception.
8224 @node Exception_Name
8225 @section Exception_Name
8226 @cindex Exception_Name
8227 @noindent
8228 This intrinsic subprogram is used in the implementation of the
8229 library routine @code{GNAT.Current_Exception}.  The only useful
8230 use of the intrinsic import in this case is the one in this unit,
8231 so an application program should simply call the function
8232 @code{GNAT.Current_Exception.Exception_Name} to obtain
8233 the name of the current exception.
8235 @node File
8236 @section File
8237 @cindex File
8238 @noindent
8239 This intrinsic subprogram is used in the implementation of the
8240 library routine @code{GNAT.Source_Info}.  The only useful use of the
8241 intrinsic import in this case is the one in this unit, so an
8242 application program should simply call the function
8243 @code{GNAT.Source_Info.File} to obtain the name of the current
8244 file.
8246 @node Line
8247 @section Line
8248 @cindex Line
8249 @noindent
8250 This intrinsic subprogram is used in the implementation of the
8251 library routine @code{GNAT.Source_Info}.  The only useful use of the
8252 intrinsic import in this case is the one in this unit, so an
8253 application program should simply call the function
8254 @code{GNAT.Source_Info.Line} to obtain the number of the current
8255 source line.
8257 @node Rotate_Left
8258 @section Rotate_Left
8259 @cindex Rotate_Left
8260 @noindent
8261 In standard Ada 95, the @code{Rotate_Left} function is available only
8262 for the predefined modular types in package @code{Interfaces}.  However, in
8263 GNAT it is possible to define a Rotate_Left function for a user
8264 defined modular type or any signed integer type as in this example:
8266 @smallexample @c ada
8267    function Shift_Left
8268      (Value  : My_Modular_Type;
8269       Amount : Natural)
8270       return   My_Modular_Type;
8271 @end smallexample
8273 @noindent
8274 The requirements are that the profile be exactly as in the example
8275 above.  The only modifications allowed are in the formal parameter
8276 names, and in the type of @code{Value} and the return type, which
8277 must be the same, and must be either a signed integer type, or
8278 a modular integer type with a binary modulus, and the size must
8279 be 8.  16, 32 or 64 bits.
8281 @node Rotate_Right
8282 @section Rotate_Right
8283 @cindex Rotate_Right
8284 @noindent
8285 A @code{Rotate_Right} function can be defined for any user defined
8286 binary modular integer type, or signed integer type, as described
8287 above for @code{Rotate_Left}.
8289 @node Shift_Left
8290 @section Shift_Left
8291 @cindex Shift_Left
8292 @noindent
8293 A @code{Shift_Left} function can be defined for any user defined
8294 binary modular integer type, or signed integer type, as described
8295 above for @code{Rotate_Left}.
8297 @node Shift_Right
8298 @section Shift_Right
8299 @cindex Shift_Right
8300 @noindent
8301 A @code{Shift_Right} function can be defined for any user defined
8302 binary modular integer type, or signed integer type, as described
8303 above for @code{Rotate_Left}.
8305 @node Shift_Right_Arithmetic
8306 @section Shift_Right_Arithmetic
8307 @cindex Shift_Right_Arithmetic
8308 @noindent
8309 A @code{Shift_Right_Arithmetic} function can be defined for any user
8310 defined binary modular integer type, or signed integer type, as described
8311 above for @code{Rotate_Left}.
8313 @node Source_Location
8314 @section Source_Location
8315 @cindex Source_Location
8316 @noindent
8317 This intrinsic subprogram is used in the implementation of the
8318 library routine @code{GNAT.Source_Info}.  The only useful use of the
8319 intrinsic import in this case is the one in this unit, so an
8320 application program should simply call the function
8321 @code{GNAT.Source_Info.Source_Location} to obtain the current
8322 source file location.
8324 @node Representation Clauses and Pragmas
8325 @chapter Representation Clauses and Pragmas
8326 @cindex Representation Clauses
8328 @menu
8329 * Alignment Clauses::
8330 * Size Clauses::
8331 * Storage_Size Clauses::
8332 * Size of Variant Record Objects::
8333 * Biased Representation ::
8334 * Value_Size and Object_Size Clauses::
8335 * Component_Size Clauses::
8336 * Bit_Order Clauses::
8337 * Effect of Bit_Order on Byte Ordering::
8338 * Pragma Pack for Arrays::
8339 * Pragma Pack for Records::
8340 * Record Representation Clauses::
8341 * Enumeration Clauses::
8342 * Address Clauses::
8343 * Effect of Convention on Representation::
8344 * Determining the Representations chosen by GNAT::
8345 @end menu
8347 @noindent
8348 @cindex Representation Clause
8349 @cindex Representation Pragma
8350 @cindex Pragma, representation
8351 This section describes the representation clauses accepted by GNAT, and
8352 their effect on the representation of corresponding data objects.
8354 GNAT fully implements Annex C (Systems Programming).  This means that all
8355 the implementation advice sections in chapter 13 are fully implemented.
8356 However, these sections only require a minimal level of support for
8357 representation clauses.  GNAT provides much more extensive capabilities,
8358 and this section describes the additional capabilities provided.
8360 @node Alignment Clauses
8361 @section Alignment Clauses
8362 @cindex Alignment Clause
8364 @noindent
8365 GNAT requires that all alignment clauses specify a power of 2, and all
8366 default alignments are always a power of 2.  The default alignment
8367 values are as follows:
8369 @itemize @bullet
8370 @item @emph{Primitive Types}.
8371 For primitive types, the alignment is the minimum of the actual size of
8372 objects of the type divided by @code{Storage_Unit},
8373 and the maximum alignment supported by the target.
8374 (This maximum alignment is given by the GNAT-specific attribute
8375 @code{Standard'Maximum_Alignment}; see @ref{Maximum_Alignment}.)
8376 @cindex @code{Maximum_Alignment} attribute
8377 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
8378 default alignment will be 8 on any target that supports alignments
8379 this large, but on some targets, the maximum alignment may be smaller
8380 than 8, in which case objects of type @code{Long_Float} will be maximally
8381 aligned.
8383 @item @emph{Arrays}.
8384 For arrays, the alignment is equal to the alignment of the component type
8385 for the normal case where no packing or component size is given.  If the
8386 array is packed, and the packing is effective (see separate section on
8387 packed arrays), then the alignment will be one for long packed arrays,
8388 or arrays whose length is not known at compile time.  For short packed
8389 arrays, which are handled internally as modular types, the alignment
8390 will be as described for primitive types, e.g.@: a packed array of length
8391 31 bits will have an object size of four bytes, and an alignment of 4.
8393 @item @emph{Records}.
8394 For the normal non-packed case, the alignment of a record is equal to
8395 the maximum alignment of any of its components.  For tagged records, this
8396 includes the implicit access type used for the tag.  If a pragma @code{Pack} is
8397 used and all fields are packable (see separate section on pragma @code{Pack}),
8398 then the resulting alignment is 1.
8400 A special case is when:
8401 @itemize @bullet
8402 @item
8403 the size of the record is given explicitly, or a
8404 full record representation clause is given, and
8405 @item
8406 the size of the record is 2, 4, or 8 bytes.
8407 @end itemize
8408 @noindent
8409 In this case, an alignment is chosen to match the
8410 size of the record. For example, if we have:
8412 @smallexample @c ada
8413    type Small is record
8414       A, B : Character;
8415    end record;
8416    for Small'Size use 16;
8417 @end smallexample
8419 @noindent
8420 then the default alignment of the record type @code{Small} is 2, not 1. This
8421 leads to more efficient code when the record is treated as a unit, and also
8422 allows the type to specified as @code{Atomic} on architectures requiring
8423 strict alignment.
8425 @end itemize
8427 @noindent
8428 An alignment clause may
8429 always specify a larger alignment than the default value, up to some
8430 maximum value dependent on the target (obtainable by using the
8431 attribute reference @code{Standard'Maximum_Alignment}).
8432 The only case where
8433 it is permissible to specify a smaller alignment than the default value
8434 is for a record with a record representation clause.
8435 In this case, packable fields for which a component clause is
8436 given still result in a default alignment corresponding to the original
8437 type, but this may be overridden, since these components in fact only
8438 require an alignment of one byte.  For example, given
8440 @smallexample @c ada
8441   type V is record
8442      A : Integer;
8443   end record;
8445   for V use record
8446      A at 0  range 0 .. 31;
8447   end record;
8449   for V'alignment use 1;
8450 @end smallexample
8452 @noindent
8453 @cindex Alignment, default
8454 The default alignment for the type @code{V} is 4, as a result of the
8455 Integer field in the record, but since this field is placed with a
8456 component clause, it is permissible, as shown, to override the default
8457 alignment of the record with a smaller value.
8459 @node Size Clauses
8460 @section Size Clauses
8461 @cindex Size Clause
8463 @noindent
8464 The default size for a type @code{T} is obtainable through the
8465 language-defined attribute @code{T'Size} and also through the
8466 equivalent GNAT-defined attribute @code{T'Value_Size}.
8467 For objects of type @code{T}, GNAT will generally increase the type size
8468 so that the object size (obtainable through the GNAT-defined attribute
8469 @code{T'Object_Size})
8470 is a multiple of @code{T'Alignment * Storage_Unit}.
8471 For example
8473 @smallexample @c ada
8474    type Smallint is range 1 .. 6;
8476    type Rec is record
8477       Y1 : integer;
8478       Y2 : boolean;
8479    end record;
8480 @end smallexample
8482 @noindent
8483 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
8484 as specified by the RM rules,
8485 but objects of this type will have a size of 8
8486 (@code{Smallint'Object_Size} = 8),
8487 since objects by default occupy an integral number
8488 of storage units.  On some targets, notably older
8489 versions of the Digital Alpha, the size of stand
8490 alone objects of this type may be 32, reflecting
8491 the inability of the hardware to do byte load/stores.
8493 Similarly, the size of type @code{Rec} is 40 bits
8494 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
8495 the alignment is 4, so objects of this type will have
8496 their size increased to 64 bits so that it is a multiple
8497 of the alignment (in bits).  This decision is
8498 in accordance with the specific Implementation Advice in RM 13.3(43):
8500 @quotation
8501 A @code{Size} clause should be supported for an object if the specified
8502 @code{Size} is at least as large as its subtype's @code{Size}, and corresponds
8503 to a size in storage elements that is a multiple of the object's
8504 @code{Alignment} (if the @code{Alignment} is nonzero).
8505 @end quotation
8507 @noindent
8508 An explicit size clause may be used to override the default size by
8509 increasing it.  For example, if we have:
8511 @smallexample @c ada
8512    type My_Boolean is new Boolean;
8513    for My_Boolean'Size use 32;
8514 @end smallexample
8516 @noindent
8517 then values of this type will always be 32 bits long.  In the case of
8518 discrete types, the size can be increased up to 64 bits, with the effect
8519 that the entire specified field is used to hold the value, sign- or
8520 zero-extended as appropriate.  If more than 64 bits is specified, then
8521 padding space is allocated after the value, and a warning is issued that
8522 there are unused bits.
8524 Similarly the size of records and arrays may be increased, and the effect
8525 is to add padding bits after the value.  This also causes a warning message
8526 to be generated.
8528 The largest Size value permitted in GNAT is 2**31@minus{}1.  Since this is a
8529 Size in bits, this corresponds to an object of size 256 megabytes (minus
8530 one).  This limitation is true on all targets.  The reason for this
8531 limitation is that it improves the quality of the code in many cases
8532 if it is known that a Size value can be accommodated in an object of
8533 type Integer.
8535 @node Storage_Size Clauses
8536 @section Storage_Size Clauses
8537 @cindex Storage_Size Clause
8539 @noindent
8540 For tasks, the @code{Storage_Size} clause specifies the amount of space
8541 to be allocated for the task stack.  This cannot be extended, and if the
8542 stack is exhausted, then @code{Storage_Error} will be raised (if stack
8543 checking is enabled).  Use a @code{Storage_Size} attribute definition clause,
8544 or a @code{Storage_Size} pragma in the task definition to set the
8545 appropriate required size.  A useful technique is to include in every
8546 task definition a pragma of the form:
8548 @smallexample @c ada
8549    pragma Storage_Size (Default_Stack_Size);
8550 @end smallexample
8552 @noindent
8553 Then @code{Default_Stack_Size} can be defined in a global package, and
8554 modified as required.  Any tasks requiring stack sizes different from the
8555 default can have an appropriate alternative reference in the pragma.
8557 For access types, the @code{Storage_Size} clause specifies the maximum
8558 space available for allocation of objects of the type.  If this space is
8559 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
8560 In the case where the access type is declared local to a subprogram, the
8561 use of a @code{Storage_Size} clause triggers automatic use of a special
8562 predefined storage pool (@code{System.Pool_Size}) that ensures that all
8563 space for the pool is automatically reclaimed on exit from the scope in
8564 which the type is declared.
8566 A special case recognized by the compiler is the specification of a
8567 @code{Storage_Size} of zero for an access type.  This means that no
8568 items can be allocated from the pool, and this is recognized at compile
8569 time, and all the overhead normally associated with maintaining a fixed
8570 size storage pool is eliminated.  Consider the following example:
8572 @smallexample @c ada
8573    procedure p is
8574       type R is array (Natural) of Character;
8575       type P is access all R;
8576       for P'Storage_Size use 0;
8577       --  Above access type intended only for interfacing purposes
8579       y : P;
8581       procedure g (m : P);
8582       pragma Import (C, g);
8584       --  @dots{}
8586    begin
8587       --  @dots{}
8588       y := new R;
8589    end;
8590 @end smallexample
8592 @noindent
8593 As indicated in this example, these dummy storage pools are often useful in
8594 connection with interfacing where no object will ever be allocated.  If you
8595 compile the above example, you get the warning:
8597 @smallexample
8598    p.adb:16:09: warning: allocation from empty storage pool
8599    p.adb:16:09: warning: Storage_Error will be raised at run time
8600 @end smallexample
8602 @noindent
8603 Of course in practice, there will not be any explicit allocators in the
8604 case of such an access declaration.
8606 @node Size of Variant Record Objects
8607 @section Size of Variant Record Objects
8608 @cindex Size, variant record objects
8609 @cindex Variant record objects, size
8611 @noindent
8612 In the case of variant record objects, there is a question whether Size gives
8613 information about a particular variant, or the maximum size required
8614 for any variant.  Consider the following program
8616 @smallexample @c ada
8617 with Text_IO; use Text_IO;
8618 procedure q is
8619    type R1 (A : Boolean := False) is record
8620      case A is
8621        when True  => X : Character;
8622        when False => null;
8623      end case;
8624    end record;
8626    V1 : R1 (False);
8627    V2 : R1;
8629 begin
8630    Put_Line (Integer'Image (V1'Size));
8631    Put_Line (Integer'Image (V2'Size));
8632 end q;
8633 @end smallexample
8635 @noindent
8636 Here we are dealing with a variant record, where the True variant
8637 requires 16 bits, and the False variant requires 8 bits.
8638 In the above example, both V1 and V2 contain the False variant,
8639 which is only 8 bits long.  However, the result of running the
8640 program is:
8642 @smallexample
8645 @end smallexample
8647 @noindent
8648 The reason for the difference here is that the discriminant value of
8649 V1 is fixed, and will always be False.  It is not possible to assign
8650 a True variant value to V1, therefore 8 bits is sufficient.  On the
8651 other hand, in the case of V2, the initial discriminant value is
8652 False (from the default), but it is possible to assign a True
8653 variant value to V2, therefore 16 bits must be allocated for V2
8654 in the general case, even fewer bits may be needed at any particular
8655 point during the program execution.
8657 As can be seen from the output of this program, the @code{'Size}
8658 attribute applied to such an object in GNAT gives the actual allocated
8659 size of the variable, which is the largest size of any of the variants.
8660 The Ada Reference Manual is not completely clear on what choice should
8661 be made here, but the GNAT behavior seems most consistent with the
8662 language in the RM@.
8664 In some cases, it may be desirable to obtain the size of the current
8665 variant, rather than the size of the largest variant.  This can be
8666 achieved in GNAT by making use of the fact that in the case of a
8667 subprogram parameter, GNAT does indeed return the size of the current
8668 variant (because a subprogram has no way of knowing how much space
8669 is actually allocated for the actual).
8671 Consider the following modified version of the above program:
8673 @smallexample @c ada
8674 with Text_IO; use Text_IO;
8675 procedure q is
8676    type R1 (A : Boolean := False) is record
8677      case A is
8678        when True  => X : Character;
8679        when False => null;
8680      end case;
8681    end record;
8683    V2 : R1;
8685    function Size (V : R1) return Integer is
8686    begin
8687       return V'Size;
8688    end Size;
8690 begin
8691    Put_Line (Integer'Image (V2'Size));
8692    Put_Line (Integer'IMage (Size (V2)));
8693    V2 := (True, 'x');
8694    Put_Line (Integer'Image (V2'Size));
8695    Put_Line (Integer'IMage (Size (V2)));
8696 end q;
8697 @end smallexample
8699 @noindent
8700 The output from this program is
8702 @smallexample
8707 @end smallexample
8709 @noindent
8710 Here we see that while the @code{'Size} attribute always returns
8711 the maximum size, regardless of the current variant value, the
8712 @code{Size} function does indeed return the size of the current
8713 variant value.
8715 @node Biased Representation
8716 @section Biased Representation
8717 @cindex Size for biased representation
8718 @cindex Biased representation
8720 @noindent
8721 In the case of scalars with a range starting at other than zero, it is
8722 possible in some cases to specify a size smaller than the default minimum
8723 value, and in such cases, GNAT uses an unsigned biased representation,
8724 in which zero is used to represent the lower bound, and successive values
8725 represent successive values of the type.
8727 For example, suppose we have the declaration:
8729 @smallexample @c ada
8730    type Small is range -7 .. -4;
8731    for Small'Size use 2;
8732 @end smallexample
8734 @noindent
8735 Although the default size of type @code{Small} is 4, the @code{Size}
8736 clause is accepted by GNAT and results in the following representation
8737 scheme:
8739 @smallexample
8740   -7 is represented as 2#00#
8741   -6 is represented as 2#01#
8742   -5 is represented as 2#10#
8743   -4 is represented as 2#11#
8744 @end smallexample
8746 @noindent
8747 Biased representation is only used if the specified @code{Size} clause
8748 cannot be accepted in any other manner.  These reduced sizes that force
8749 biased representation can be used for all discrete types except for
8750 enumeration types for which a representation clause is given.
8752 @node Value_Size and Object_Size Clauses
8753 @section Value_Size and Object_Size Clauses
8754 @findex Value_Size
8755 @findex Object_Size
8756 @cindex Size, of objects
8758 @noindent
8759 In Ada 95, @code{T'Size} for a type @code{T} is the minimum number of bits
8760 required to hold values of type @code{T}.  Although this interpretation was
8761 allowed in Ada 83, it was not required, and this requirement in practice
8762 can cause some significant difficulties.  For example, in most Ada 83
8763 compilers, @code{Natural'Size} was 32.  However, in Ada 95,
8764 @code{Natural'Size} is
8765 typically 31.  This means that code may change in behavior when moving
8766 from Ada 83 to Ada 95.  For example, consider:
8768 @smallexample @c ada
8769    type Rec is record;
8770       A : Natural;
8771       B : Natural;
8772    end record;
8774    for Rec use record
8775       at 0  range 0 .. Natural'Size - 1;
8776       at 0  range Natural'Size .. 2 * Natural'Size - 1;
8777    end record;
8778 @end smallexample
8780 @noindent
8781 In the above code, since the typical size of @code{Natural} objects
8782 is 32 bits and @code{Natural'Size} is 31, the above code can cause
8783 unexpected inefficient packing in Ada 95, and in general there are
8784 cases where the fact that the object size can exceed the
8785 size of the type causes surprises.
8787 To help get around this problem GNAT provides two implementation
8788 defined attributes, @code{Value_Size} and @code{Object_Size}.  When
8789 applied to a type, these attributes yield the size of the type
8790 (corresponding to the RM defined size attribute), and the size of
8791 objects of the type respectively.
8793 The @code{Object_Size} is used for determining the default size of
8794 objects and components.  This size value can be referred to using the
8795 @code{Object_Size} attribute.  The phrase ``is used'' here means that it is
8796 the basis of the determination of the size.  The backend is free to
8797 pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
8798 character might be stored in 32 bits on a machine with no efficient
8799 byte access instructions such as the Alpha.
8801 The default rules for the value of @code{Object_Size} for
8802 discrete types are as follows:
8804 @itemize @bullet
8805 @item
8806 The @code{Object_Size} for base subtypes reflect the natural hardware
8807 size in bits (run the compiler with @option{-gnatS} to find those values
8808 for numeric types). Enumeration types and fixed-point base subtypes have
8809 8, 16, 32 or 64 bits for this size, depending on the range of values
8810 to be stored.
8812 @item
8813 The @code{Object_Size} of a subtype is the same as the
8814 @code{Object_Size} of
8815 the type from which it is obtained.
8817 @item
8818 The @code{Object_Size} of a derived base type is copied from the parent
8819 base type, and the @code{Object_Size} of a derived first subtype is copied
8820 from the parent first subtype.
8821 @end itemize
8823 @noindent
8824 The @code{Value_Size} attribute
8825 is the (minimum) number of bits required to store a value
8826 of the type.
8827 This value is used to determine how tightly to pack
8828 records or arrays with components of this type, and also affects
8829 the semantics of unchecked conversion (unchecked conversions where
8830 the @code{Value_Size} values differ generate a warning, and are potentially
8831 target dependent).
8833 The default rules for the value of @code{Value_Size} are as follows:
8835 @itemize @bullet
8836 @item
8837 The @code{Value_Size} for a base subtype is the minimum number of bits
8838 required to store all values of the type (including the sign bit
8839 only if negative values are possible).
8841 @item
8842 If a subtype statically matches the first subtype of a given type, then it has
8843 by default the same @code{Value_Size} as the first subtype.  This is a
8844 consequence of RM 13.1(14) (``if two subtypes statically match,
8845 then their subtype-specific aspects are the same''.)
8847 @item
8848 All other subtypes have a @code{Value_Size} corresponding to the minimum
8849 number of bits required to store all values of the subtype.  For
8850 dynamic bounds, it is assumed that the value can range down or up
8851 to the corresponding bound of the ancestor
8852 @end itemize
8854 @noindent
8855 The RM defined attribute @code{Size} corresponds to the
8856 @code{Value_Size} attribute.
8858 The @code{Size} attribute may be defined for a first-named subtype.  This sets
8859 the @code{Value_Size} of
8860 the first-named subtype to the given value, and the
8861 @code{Object_Size} of this first-named subtype to the given value padded up
8862 to an appropriate boundary.  It is a consequence of the default rules
8863 above that this @code{Object_Size} will apply to all further subtypes.  On the
8864 other hand, @code{Value_Size} is affected only for the first subtype, any
8865 dynamic subtypes obtained from it directly, and any statically matching
8866 subtypes.  The @code{Value_Size} of any other static subtypes is not affected.
8868 @code{Value_Size} and
8869 @code{Object_Size} may be explicitly set for any subtype using
8870 an attribute definition clause.  Note that the use of these attributes
8871 can cause the RM 13.1(14) rule to be violated.  If two access types
8872 reference aliased objects whose subtypes have differing @code{Object_Size}
8873 values as a result of explicit attribute definition clauses, then it
8874 is erroneous to convert from one access subtype to the other.
8876 At the implementation level, Esize stores the Object_Size and the
8877 RM_Size field stores the @code{Value_Size} (and hence the value of the
8878 @code{Size} attribute,
8879 which, as noted above, is equivalent to @code{Value_Size}).
8881 To get a feel for the difference, consider the following examples (note
8882 that in each case the base is @code{Short_Short_Integer} with a size of 8):
8884 @smallexample
8885                                        Object_Size     Value_Size
8887 type x1 is range 0 .. 5;                    8               3
8889 type x2 is range 0 .. 5;
8890 for x2'size use 12;                        16              12
8892 subtype x3 is x2 range 0 .. 3;             16               2
8894 subtype x4 is x2'base range 0 .. 10;        8               4
8896 subtype x5 is x2 range 0 .. dynamic;       16               3*
8898 subtype x6 is x2'base range 0 .. dynamic;   8               3*
8900 @end smallexample
8902 @noindent
8903 Note: the entries marked ``3*'' are not actually specified by the Ada 95 RM,
8904 but it seems in the spirit of the RM rules to allocate the minimum number
8905 of bits (here 3, given the range for @code{x2})
8906 known to be large enough to hold the given range of values.
8908 So far, so good, but GNAT has to obey the RM rules, so the question is
8909 under what conditions must the RM @code{Size} be used.
8910 The following is a list
8911 of the occasions on which the RM @code{Size} must be used:
8913 @itemize @bullet
8914 @item
8915 Component size for packed arrays or records
8917 @item
8918 Value of the attribute @code{Size} for a type
8920 @item
8921 Warning about sizes not matching for unchecked conversion
8922 @end itemize
8924 @noindent
8925 For record types, the @code{Object_Size} is always a multiple of the
8926 alignment of the type (this is true for all types). In some cases the
8927 @code{Value_Size} can be smaller. Consider:
8929 @smallexample
8930    type R is record
8931      X : Integer;
8932      Y : Character;
8933    end record;
8934 @end smallexample
8936 @noindent
8937 On a typical 32-bit architecture, the X component will be four bytes, and
8938 require four-byte alignment, and the Y component will be one byte. In this
8939 case @code{R'Value_Size} will be 40 (bits) since this is the minimum size
8940 required to store a value of this type, and for example, it is permissible
8941 to have a component of type R in an outer record whose component size is
8942 specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits),
8943 since it must be rounded up so that this value is a multiple of the
8944 alignment (4 bytes = 32 bits).
8946 @noindent
8947 For all other types, the @code{Object_Size}
8948 and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
8949 Only @code{Size} may be specified for such types.
8951 @node Component_Size Clauses
8952 @section Component_Size Clauses
8953 @cindex Component_Size Clause
8955 @noindent
8956 Normally, the value specified in a component clause must be consistent
8957 with the subtype of the array component with regard to size and alignment.
8958 In other words, the value specified must be at least equal to the size
8959 of this subtype, and must be a multiple of the alignment value.
8961 In addition, component size clauses are allowed which cause the array
8962 to be packed, by specifying a smaller value.  The cases in which this
8963 is allowed are for component size values in the range 1 through 63.  The value
8964 specified must not be smaller than the Size of the subtype.  GNAT will
8965 accurately honor all packing requests in this range.  For example, if
8966 we have:
8968 @smallexample @c ada
8969 type r is array (1 .. 8) of Natural;
8970 for r'Component_Size use 31;
8971 @end smallexample
8973 @noindent
8974 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
8975 Of course access to the components of such an array is considerably
8976 less efficient than if the natural component size of 32 is used.
8978 @node Bit_Order Clauses
8979 @section Bit_Order Clauses
8980 @cindex Bit_Order Clause
8981 @cindex bit ordering
8982 @cindex ordering, of bits
8984 @noindent
8985 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
8986 attribute.  The specification may either correspond to the default bit
8987 order for the target, in which case the specification has no effect and
8988 places no additional restrictions, or it may be for the non-standard
8989 setting (that is the opposite of the default).
8991 In the case where the non-standard value is specified, the effect is
8992 to renumber bits within each byte, but the ordering of bytes is not
8993 affected.  There are certain
8994 restrictions placed on component clauses as follows:
8996 @itemize @bullet
8998 @item Components fitting within a single storage unit.
8999 @noindent
9000 These are unrestricted, and the effect is merely to renumber bits.  For
9001 example if we are on a little-endian machine with @code{Low_Order_First}
9002 being the default, then the following two declarations have exactly
9003 the same effect:
9005 @smallexample @c ada
9006    type R1 is record
9007       A : Boolean;
9008       B : Integer range 1 .. 120;
9009    end record;
9011    for R1 use record
9012       A at 0 range 0 .. 0;
9013       B at 0 range 1 .. 7;
9014    end record;
9016    type R2 is record
9017       A : Boolean;
9018       B : Integer range 1 .. 120;
9019    end record;
9021    for R2'Bit_Order use High_Order_First;
9023    for R2 use record
9024       A at 0 range 7 .. 7;
9025       B at 0 range 0 .. 6;
9026    end record;
9027 @end smallexample
9029 @noindent
9030 The useful application here is to write the second declaration with the
9031 @code{Bit_Order} attribute definition clause, and know that it will be treated
9032 the same, regardless of whether the target is little-endian or big-endian.
9034 @item Components occupying an integral number of bytes.
9035 @noindent
9036 These are components that exactly fit in two or more bytes.  Such component
9037 declarations are allowed, but have no effect, since it is important to realize
9038 that the @code{Bit_Order} specification does not affect the ordering of bytes.
9039 In particular, the following attempt at getting an endian-independent integer
9040 does not work:
9042 @smallexample @c ada
9043    type R2 is record
9044       A : Integer;
9045    end record;
9047    for R2'Bit_Order use High_Order_First;
9049    for R2 use record
9050       A at 0 range 0 .. 31;
9051    end record;
9052 @end smallexample
9054 @noindent
9055 This declaration will result in a little-endian integer on a
9056 little-endian machine, and a big-endian integer on a big-endian machine.
9057 If byte flipping is required for interoperability between big- and
9058 little-endian machines, this must be explicitly programmed.  This capability
9059 is not provided by @code{Bit_Order}.
9061 @item Components that are positioned across byte boundaries
9062 @noindent
9063 but do not occupy an integral number of bytes.  Given that bytes are not
9064 reordered, such fields would occupy a non-contiguous sequence of bits
9065 in memory, requiring non-trivial code to reassemble.  They are for this
9066 reason not permitted, and any component clause specifying such a layout
9067 will be flagged as illegal by GNAT@.
9069 @end itemize
9071 @noindent
9072 Since the misconception that Bit_Order automatically deals with all
9073 endian-related incompatibilities is a common one, the specification of
9074 a component field that is an integral number of bytes will always
9075 generate a warning.  This warning may be suppressed using
9076 @code{pragma Suppress} if desired.  The following section contains additional
9077 details regarding the issue of byte ordering.
9079 @node Effect of Bit_Order on Byte Ordering
9080 @section Effect of Bit_Order on Byte Ordering
9081 @cindex byte ordering
9082 @cindex ordering, of bytes
9084 @noindent
9085 In this section we will review the effect of the @code{Bit_Order} attribute
9086 definition clause on byte ordering.  Briefly, it has no effect at all, but
9087 a detailed example will be helpful.  Before giving this
9088 example, let us review the precise
9089 definition of the effect of defining @code{Bit_Order}.  The effect of a
9090 non-standard bit order is described in section 15.5.3 of the Ada
9091 Reference Manual:
9093 @quotation
9094 2   A bit ordering is a method of interpreting the meaning of
9095 the storage place attributes.
9096 @end quotation
9098 @noindent
9099 To understand the precise definition of storage place attributes in
9100 this context, we visit section 13.5.1 of the manual:
9102 @quotation
9103 13   A record_representation_clause (without the mod_clause)
9104 specifies the layout.  The storage place attributes (see 13.5.2)
9105 are taken from the values of the position, first_bit, and last_bit
9106 expressions after normalizing those values so that first_bit is
9107 less than Storage_Unit.
9108 @end quotation
9110 @noindent
9111 The critical point here is that storage places are taken from
9112 the values after normalization, not before.  So the @code{Bit_Order}
9113 interpretation applies to normalized values.  The interpretation
9114 is described in the later part of the 15.5.3 paragraph:
9116 @quotation
9117 2   A bit ordering is a method of interpreting the meaning of
9118 the storage place attributes.  High_Order_First (known in the
9119 vernacular as ``big endian'') means that the first bit of a
9120 storage element (bit 0) is the most significant bit (interpreting
9121 the sequence of bits that represent a component as an unsigned
9122 integer value).  Low_Order_First (known in the vernacular as
9123 ``little endian'') means the opposite: the first bit is the
9124 least significant.
9125 @end quotation
9127 @noindent
9128 Note that the numbering is with respect to the bits of a storage
9129 unit.  In other words, the specification affects only the numbering
9130 of bits within a single storage unit.
9132 We can make the effect clearer by giving an example.
9134 Suppose that we have an external device which presents two bytes, the first
9135 byte presented, which is the first (low addressed byte) of the two byte
9136 record is called Master, and the second byte is called Slave.
9138 The left most (most significant bit is called Control for each byte, and
9139 the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
9140 (least significant) bit.
9142 On a big-endian machine, we can write the following representation clause
9144 @smallexample @c ada
9145    type Data is record
9146       Master_Control : Bit;
9147       Master_V1      : Bit;
9148       Master_V2      : Bit;
9149       Master_V3      : Bit;
9150       Master_V4      : Bit;
9151       Master_V5      : Bit;
9152       Master_V6      : Bit;
9153       Master_V7      : Bit;
9154       Slave_Control  : Bit;
9155       Slave_V1       : Bit;
9156       Slave_V2       : Bit;
9157       Slave_V3       : Bit;
9158       Slave_V4       : Bit;
9159       Slave_V5       : Bit;
9160       Slave_V6       : Bit;
9161       Slave_V7       : Bit;
9162    end record;
9164    for Data use record
9165       Master_Control at 0 range 0 .. 0;
9166       Master_V1      at 0 range 1 .. 1;
9167       Master_V2      at 0 range 2 .. 2;
9168       Master_V3      at 0 range 3 .. 3;
9169       Master_V4      at 0 range 4 .. 4;
9170       Master_V5      at 0 range 5 .. 5;
9171       Master_V6      at 0 range 6 .. 6;
9172       Master_V7      at 0 range 7 .. 7;
9173       Slave_Control  at 1 range 0 .. 0;
9174       Slave_V1       at 1 range 1 .. 1;
9175       Slave_V2       at 1 range 2 .. 2;
9176       Slave_V3       at 1 range 3 .. 3;
9177       Slave_V4       at 1 range 4 .. 4;
9178       Slave_V5       at 1 range 5 .. 5;
9179       Slave_V6       at 1 range 6 .. 6;
9180       Slave_V7       at 1 range 7 .. 7;
9181    end record;
9182 @end smallexample
9184 @noindent
9185 Now if we move this to a little endian machine, then the bit ordering within
9186 the byte is backwards, so we have to rewrite the record rep clause as:
9188 @smallexample @c ada
9189    for Data use record
9190       Master_Control at 0 range 7 .. 7;
9191       Master_V1      at 0 range 6 .. 6;
9192       Master_V2      at 0 range 5 .. 5;
9193       Master_V3      at 0 range 4 .. 4;
9194       Master_V4      at 0 range 3 .. 3;
9195       Master_V5      at 0 range 2 .. 2;
9196       Master_V6      at 0 range 1 .. 1;
9197       Master_V7      at 0 range 0 .. 0;
9198       Slave_Control  at 1 range 7 .. 7;
9199       Slave_V1       at 1 range 6 .. 6;
9200       Slave_V2       at 1 range 5 .. 5;
9201       Slave_V3       at 1 range 4 .. 4;
9202       Slave_V4       at 1 range 3 .. 3;
9203       Slave_V5       at 1 range 2 .. 2;
9204       Slave_V6       at 1 range 1 .. 1;
9205       Slave_V7       at 1 range 0 .. 0;
9206    end record;
9207 @end smallexample
9209 @noindent
9210 It is a nuisance to have to rewrite the clause, especially if
9211 the code has to be maintained on both machines.  However,
9212 this is a case that we can handle with the
9213 @code{Bit_Order} attribute if it is implemented.
9214 Note that the implementation is not required on byte addressed
9215 machines, but it is indeed implemented in GNAT.
9216 This means that we can simply use the
9217 first record clause, together with the declaration
9219 @smallexample @c ada
9220    for Data'Bit_Order use High_Order_First;
9221 @end smallexample
9223 @noindent
9224 and the effect is what is desired, namely the layout is exactly the same,
9225 independent of whether the code is compiled on a big-endian or little-endian
9226 machine.
9228 The important point to understand is that byte ordering is not affected.
9229 A @code{Bit_Order} attribute definition never affects which byte a field
9230 ends up in, only where it ends up in that byte.
9231 To make this clear, let us rewrite the record rep clause of the previous
9232 example as:
9234 @smallexample @c ada
9235    for Data'Bit_Order use High_Order_First;
9236    for Data use record
9237       Master_Control at 0 range  0 .. 0;
9238       Master_V1      at 0 range  1 .. 1;
9239       Master_V2      at 0 range  2 .. 2;
9240       Master_V3      at 0 range  3 .. 3;
9241       Master_V4      at 0 range  4 .. 4;
9242       Master_V5      at 0 range  5 .. 5;
9243       Master_V6      at 0 range  6 .. 6;
9244       Master_V7      at 0 range  7 .. 7;
9245       Slave_Control  at 0 range  8 .. 8;
9246       Slave_V1       at 0 range  9 .. 9;
9247       Slave_V2       at 0 range 10 .. 10;
9248       Slave_V3       at 0 range 11 .. 11;
9249       Slave_V4       at 0 range 12 .. 12;
9250       Slave_V5       at 0 range 13 .. 13;
9251       Slave_V6       at 0 range 14 .. 14;
9252       Slave_V7       at 0 range 15 .. 15;
9253    end record;
9254 @end smallexample
9256 @noindent
9257 This is exactly equivalent to saying (a repeat of the first example):
9259 @smallexample @c ada
9260    for Data'Bit_Order use High_Order_First;
9261    for Data use record
9262       Master_Control at 0 range 0 .. 0;
9263       Master_V1      at 0 range 1 .. 1;
9264       Master_V2      at 0 range 2 .. 2;
9265       Master_V3      at 0 range 3 .. 3;
9266       Master_V4      at 0 range 4 .. 4;
9267       Master_V5      at 0 range 5 .. 5;
9268       Master_V6      at 0 range 6 .. 6;
9269       Master_V7      at 0 range 7 .. 7;
9270       Slave_Control  at 1 range 0 .. 0;
9271       Slave_V1       at 1 range 1 .. 1;
9272       Slave_V2       at 1 range 2 .. 2;
9273       Slave_V3       at 1 range 3 .. 3;
9274       Slave_V4       at 1 range 4 .. 4;
9275       Slave_V5       at 1 range 5 .. 5;
9276       Slave_V6       at 1 range 6 .. 6;
9277       Slave_V7       at 1 range 7 .. 7;
9278    end record;
9279 @end smallexample
9281 @noindent
9282 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
9283 field.  The storage place attributes are obtained by normalizing the
9284 values given so that the @code{First_Bit} value is less than 8.  After
9285 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
9286 we specified in the other case.
9288 Now one might expect that the @code{Bit_Order} attribute might affect
9289 bit numbering within the entire record component (two bytes in this
9290 case, thus affecting which byte fields end up in), but that is not
9291 the way this feature is defined, it only affects numbering of bits,
9292 not which byte they end up in.
9294 Consequently it never makes sense to specify a starting bit number
9295 greater than 7 (for a byte addressable field) if an attribute
9296 definition for @code{Bit_Order} has been given, and indeed it
9297 may be actively confusing to specify such a value, so the compiler
9298 generates a warning for such usage.
9300 If you do need to control byte ordering then appropriate conditional
9301 values must be used.  If in our example, the slave byte came first on
9302 some machines we might write:
9304 @smallexample @c ada
9305    Master_Byte_First constant Boolean := @dots{};
9307    Master_Byte : constant Natural :=
9308                    1 - Boolean'Pos (Master_Byte_First);
9309    Slave_Byte  : constant Natural :=
9310                    Boolean'Pos (Master_Byte_First);
9312    for Data'Bit_Order use High_Order_First;
9313    for Data use record
9314       Master_Control at Master_Byte range 0 .. 0;
9315       Master_V1      at Master_Byte range 1 .. 1;
9316       Master_V2      at Master_Byte range 2 .. 2;
9317       Master_V3      at Master_Byte range 3 .. 3;
9318       Master_V4      at Master_Byte range 4 .. 4;
9319       Master_V5      at Master_Byte range 5 .. 5;
9320       Master_V6      at Master_Byte range 6 .. 6;
9321       Master_V7      at Master_Byte range 7 .. 7;
9322       Slave_Control  at Slave_Byte  range 0 .. 0;
9323       Slave_V1       at Slave_Byte  range 1 .. 1;
9324       Slave_V2       at Slave_Byte  range 2 .. 2;
9325       Slave_V3       at Slave_Byte  range 3 .. 3;
9326       Slave_V4       at Slave_Byte  range 4 .. 4;
9327       Slave_V5       at Slave_Byte  range 5 .. 5;
9328       Slave_V6       at Slave_Byte  range 6 .. 6;
9329       Slave_V7       at Slave_Byte  range 7 .. 7;
9330    end record;
9331 @end smallexample
9333 @noindent
9334 Now to switch between machines, all that is necessary is
9335 to set the boolean constant @code{Master_Byte_First} in
9336 an appropriate manner.
9338 @node Pragma Pack for Arrays
9339 @section Pragma Pack for Arrays
9340 @cindex Pragma Pack (for arrays)
9342 @noindent
9343 Pragma @code{Pack} applied to an array has no effect unless the component type
9344 is packable.  For a component type to be packable, it must be one of the
9345 following cases:
9347 @itemize @bullet
9348 @item
9349 Any scalar type
9350 @item
9351 Any type whose size is specified with a size clause
9352 @item
9353 Any packed array type with a static size
9354 @end itemize
9356 @noindent
9357 For all these cases, if the component subtype size is in the range
9358 1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
9359 component size were specified giving the component subtype size.
9360 For example if we have:
9362 @smallexample @c ada
9363    type r is range 0 .. 17;
9365    type ar is array (1 .. 8) of r;
9366    pragma Pack (ar);
9367 @end smallexample
9369 @noindent
9370 Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
9371 and the size of the array @code{ar} will be exactly 40 bits.
9373 Note that in some cases this rather fierce approach to packing can produce
9374 unexpected effects.  For example, in Ada 95, type Natural typically has a
9375 size of 31, meaning that if you pack an array of Natural, you get 31-bit
9376 close packing, which saves a few bits, but results in far less efficient
9377 access.  Since many other Ada compilers will ignore such a packing request,
9378 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
9379 might not be what is intended.  You can easily remove this warning by
9380 using an explicit @code{Component_Size} setting instead, which never generates
9381 a warning, since the intention of the programmer is clear in this case.
9383 GNAT treats packed arrays in one of two ways.  If the size of the array is
9384 known at compile time and is less than 64 bits, then internally the array
9385 is represented as a single modular type, of exactly the appropriate number
9386 of bits.  If the length is greater than 63 bits, or is not known at compile
9387 time, then the packed array is represented as an array of bytes, and the
9388 length is always a multiple of 8 bits.
9390 Note that to represent a packed array as a modular type, the alignment must
9391 be suitable for the modular type involved. For example, on typical machines
9392 a 32-bit packed array will be represented by a 32-bit modular integer with
9393 an alignment of four bytes. If you explicitly override the default alignment
9394 with an alignment clause that is too small, the modular representation
9395 cannot be used. For example, consider the following set of declarations:
9397 @smallexample @c ada
9398    type R is range 1 .. 3;
9399    type S is array (1 .. 31) of R;
9400    for S'Component_Size use 2;
9401    for S'Size use 62;
9402    for S'Alignment use 1;
9403 @end smallexample
9405 @noindent
9406 If the alignment clause were not present, then a 62-bit modular
9407 representation would be chosen (typically with an alignment of 4 or 8
9408 bytes depending on the target). But the default alignment is overridden
9409 with the explicit alignment clause. This means that the modular
9410 representation cannot be used, and instead the array of bytes
9411 representation must be used, meaning that the length must be a multiple
9412 of 8. Thus the above set of declarations will result in a diagnostic
9413 rejecting the size clause and noting that the minimum size allowed is 64.
9415 @cindex Pragma Pack (for type Natural)
9416 @cindex Pragma Pack warning
9418 One special case that is worth noting occurs when the base type of the
9419 component size is 8/16/32 and the subtype is one bit less. Notably this
9420 occurs with subtype @code{Natural}. Consider:
9422 @smallexample @c ada
9423    type Arr is array (1 .. 32) of Natural;
9424    pragma Pack (Arr);
9425 @end smallexample
9427 @noindent
9428 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
9429 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
9430 Ada 83 compilers did not attempt 31 bit packing.
9432 In Ada 95, @code{Natural'Size} is required to be 31. Furthermore, GNAT really
9433 does pack 31-bit subtype to 31 bits. This may result in a substantial
9434 unintended performance penalty when porting legacy Ada 83 code. To help
9435 prevent this, GNAT generates a warning in such cases. If you really want 31
9436 bit packing in a case like this, you can set the component size explicitly:
9438 @smallexample @c ada
9439    type Arr is array (1 .. 32) of Natural;
9440    for Arr'Component_Size use 31;
9441 @end smallexample
9443 @noindent
9444 Here 31-bit packing is achieved as required, and no warning is generated,
9445 since in this case the programmer intention is clear.
9447 @node Pragma Pack for Records
9448 @section Pragma Pack for Records
9449 @cindex Pragma Pack (for records)
9451 @noindent
9452 Pragma @code{Pack} applied to a record will pack the components to reduce
9453 wasted space from alignment gaps and by reducing the amount of space
9454 taken by components.  We distinguish between @emph{packable} components and
9455 @emph{non-packable} components.
9456 Components of the following types are considered packable:
9457 @itemize @bullet
9458 @item
9459 All primitive types are packable.
9461 @item
9462 Small packed arrays, whose size does not exceed 64 bits, and where the
9463 size is statically known at compile time, are represented internally
9464 as modular integers, and so they are also packable.
9466 @end itemize
9468 @noindent
9469 All packable components occupy the exact number of bits corresponding to
9470 their @code{Size} value, and are packed with no padding bits, i.e.@: they
9471 can start on an arbitrary bit boundary.
9473 All other types are non-packable, they occupy an integral number of
9474 storage units, and
9475 are placed at a boundary corresponding to their alignment requirements.
9477 For example, consider the record
9479 @smallexample @c ada
9480    type Rb1 is array (1 .. 13) of Boolean;
9481    pragma Pack (rb1);
9483    type Rb2 is array (1 .. 65) of Boolean;
9484    pragma Pack (rb2);
9486    type x2 is record
9487       l1 : Boolean;
9488       l2 : Duration;
9489       l3 : Float;
9490       l4 : Boolean;
9491       l5 : Rb1;
9492       l6 : Rb2;
9493    end record;
9494    pragma Pack (x2);
9495 @end smallexample
9497 @noindent
9498 The representation for the record x2 is as follows:
9500 @smallexample @c ada
9501 for x2'Size use 224;
9502 for x2 use record
9503    l1 at  0 range  0 .. 0;
9504    l2 at  0 range  1 .. 64;
9505    l3 at 12 range  0 .. 31;
9506    l4 at 16 range  0 .. 0;
9507    l5 at 16 range  1 .. 13;
9508    l6 at 18 range  0 .. 71;
9509 end record;
9510 @end smallexample
9512 @noindent
9513 Studying this example, we see that the packable fields @code{l1}
9514 and @code{l2} are
9515 of length equal to their sizes, and placed at specific bit boundaries (and
9516 not byte boundaries) to
9517 eliminate padding.  But @code{l3} is of a non-packable float type, so
9518 it is on the next appropriate alignment boundary.
9520 The next two fields are fully packable, so @code{l4} and @code{l5} are
9521 minimally packed with no gaps.  However, type @code{Rb2} is a packed
9522 array that is longer than 64 bits, so it is itself non-packable.  Thus
9523 the @code{l6} field is aligned to the next byte boundary, and takes an
9524 integral number of bytes, i.e.@: 72 bits.
9526 @node Record Representation Clauses
9527 @section Record Representation Clauses
9528 @cindex Record Representation Clause
9530 @noindent
9531 Record representation clauses may be given for all record types, including
9532 types obtained by record extension.  Component clauses are allowed for any
9533 static component.  The restrictions on component clauses depend on the type
9534 of the component.
9536 @cindex Component Clause
9537 For all components of an elementary type, the only restriction on component
9538 clauses is that the size must be at least the 'Size value of the type
9539 (actually the Value_Size).  There are no restrictions due to alignment,
9540 and such components may freely cross storage boundaries.
9542 Packed arrays with a size up to and including 64 bits are represented
9543 internally using a modular type with the appropriate number of bits, and
9544 thus the same lack of restriction applies.  For example, if you declare:
9546 @smallexample @c ada
9547    type R is array (1 .. 49) of Boolean;
9548    pragma Pack (R);
9549    for R'Size use 49;
9550 @end smallexample
9552 @noindent
9553 then a component clause for a component of type R may start on any
9554 specified bit boundary, and may specify a value of 49 bits or greater.
9556 Packed bit arrays that are longer than 64 bits must always be placed
9557 on a storage unit (byte) boundary. Any component clause that does not
9558 meet this requirement will be rejected.
9560 The rules for other types are different for GNAT 3 and GNAT 5 versions
9561 (based on GCC 2 and GCC 3 respectively). In GNAT 5, larger components
9562 (other than packed arrays)
9563 may also be placed on arbitrary boundaries, so for example, the following
9564 is permitted:
9566 @smallexample @c ada
9567    type R is array (1 .. 10) of Boolean;
9568    for R'Size use 80;
9570    type Q is record
9571       G, H : Boolean;
9572       L, M : R;
9573    end record;
9575    for Q use record
9576       G at 0 range  0 ..   0;
9577       H at 0 range  1 ..   1;
9578       L at 0 range  2 ..  81;
9579       R at 0 range 82 .. 161;
9580    end record;
9581 @end smallexample
9583 @noindent
9584 In GNAT 3, there are more severe restrictions on larger components.
9585 For non-primitive types, including packed arrays with a size greater than
9586 64 bits, component clauses must respect the alignment requirement of the
9587 type, in particular, always starting on a byte boundary, and the length
9588 must be a multiple of the storage unit.
9590 The following rules regarding tagged types are enforced in both GNAT 3 and
9591 GNAT 5:
9593 The tag field of a tagged type always occupies an address sized field at
9594 the start of the record.  No component clause may attempt to overlay this
9595 tag.
9597 In the case of a record extension T1, of a type T, no component clause applied
9598 to the type T1 can specify a storage location that would overlap the first
9599 T'Size bytes of the record.
9601 @node Enumeration Clauses
9602 @section Enumeration Clauses
9604 The only restriction on enumeration clauses is that the range of values
9605 must be representable.  For the signed case, if one or more of the
9606 representation values are negative, all values must be in the range:
9608 @smallexample @c ada
9609    System.Min_Int .. System.Max_Int
9610 @end smallexample
9612 @noindent
9613 For the unsigned case, where all values are non negative, the values must
9614 be in the range:
9616 @smallexample @c ada
9617    0 .. System.Max_Binary_Modulus;
9618 @end smallexample
9620 @noindent
9621 A @emph{confirming} representation clause is one in which the values range
9622 from 0 in sequence, i.e.@: a clause that confirms the default representation
9623 for an enumeration type.
9624 Such a confirming representation
9625 is permitted by these rules, and is specially recognized by the compiler so
9626 that no extra overhead results from the use of such a clause.
9628 If an array has an index type which is an enumeration type to which an
9629 enumeration clause has been applied, then the array is stored in a compact
9630 manner.  Consider the declarations:
9632 @smallexample @c ada
9633    type r is (A, B, C);
9634    for r use (A => 1, B => 5, C => 10);
9635    type t is array (r) of Character;
9636 @end smallexample
9638 @noindent
9639 The array type t corresponds to a vector with exactly three elements and
9640 has a default size equal to @code{3*Character'Size}.  This ensures efficient
9641 use of space, but means that accesses to elements of the array will incur
9642 the overhead of converting representation values to the corresponding
9643 positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
9645 @node Address Clauses
9646 @section Address Clauses
9647 @cindex Address Clause
9649 The reference manual allows a general restriction on representation clauses,
9650 as found in RM 13.1(22):
9652 @quotation
9653 An implementation need not support representation
9654 items containing nonstatic expressions, except that
9655 an implementation should support a representation item
9656 for a given entity if each nonstatic expression in the
9657 representation item is a name that statically denotes
9658 a constant declared before the entity.
9659 @end quotation
9661 @noindent
9662 In practice this is applicable only to address clauses, since this is the
9663 only case in which a non-static expression is permitted by the syntax.  As
9664 the AARM notes in sections 13.1 (22.a-22.h):
9666 @display
9667   22.a   Reason: This is to avoid the following sort of thing:
9669   22.b        X : Integer := F(@dots{});
9670               Y : Address := G(@dots{});
9671               for X'Address use Y;
9673   22.c   In the above, we have to evaluate the
9674          initialization expression for X before we
9675          know where to put the result.  This seems
9676          like an unreasonable implementation burden.
9678   22.d   The above code should instead be written
9679          like this:
9681   22.e        Y : constant Address := G(@dots{});
9682               X : Integer := F(@dots{});
9683               for X'Address use Y;
9685   22.f   This allows the expression ``Y'' to be safely
9686          evaluated before X is created.
9688   22.g   The constant could be a formal parameter of mode in.
9690   22.h   An implementation can support other nonstatic
9691          expressions if it wants to.  Expressions of type
9692          Address are hardly ever static, but their value
9693          might be known at compile time anyway in many
9694          cases.
9695 @end display
9697 @noindent
9698 GNAT does indeed permit many additional cases of non-static expressions.  In
9699 particular, if the type involved is elementary there are no restrictions
9700 (since in this case, holding a temporary copy of the initialization value,
9701 if one is present, is inexpensive).  In addition, if there is no implicit or
9702 explicit initialization, then there are no restrictions.  GNAT will reject
9703 only the case where all three of these conditions hold:
9705 @itemize @bullet
9707 @item
9708 The type of the item is non-elementary (e.g.@: a record or array).
9710 @item
9711 There is explicit or implicit initialization required for the object.
9712 Note that access values are always implicitly initialized, and also
9713 in GNAT, certain bit-packed arrays (those having a dynamic length or
9714 a length greater than 64) will also be implicitly initialized to zero.
9716 @item
9717 The address value is non-static.  Here GNAT is more permissive than the
9718 RM, and allows the address value to be the address of a previously declared
9719 stand-alone variable, as long as it does not itself have an address clause.
9721 @smallexample @c ada
9722            Anchor  : Some_Initialized_Type;
9723            Overlay : Some_Initialized_Type;
9724            for Overlay'Address use Anchor'Address;
9725 @end smallexample
9727 @noindent
9728 However, the prefix of the address clause cannot be an array component, or
9729 a component of a discriminated record.
9731 @end itemize
9733 @noindent
9734 As noted above in section 22.h, address values are typically non-static.  In
9735 particular the To_Address function, even if applied to a literal value, is
9736 a non-static function call.  To avoid this minor annoyance, GNAT provides
9737 the implementation defined attribute 'To_Address.  The following two
9738 expressions have identical values:
9740 @findex Attribute
9741 @findex To_Address
9742 @smallexample @c ada
9743    To_Address (16#1234_0000#)
9744    System'To_Address (16#1234_0000#);
9745 @end smallexample
9747 @noindent
9748 except that the second form is considered to be a static expression, and
9749 thus when used as an address clause value is always permitted.
9751 @noindent
9752 Additionally, GNAT treats as static an address clause that is an
9753 unchecked_conversion of a static integer value.  This simplifies the porting
9754 of legacy code, and provides a portable equivalent to the GNAT attribute
9755 @code{To_Address}.
9757 Another issue with address clauses is the interaction with alignment
9758 requirements.  When an address clause is given for an object, the address
9759 value must be consistent with the alignment of the object (which is usually
9760 the same as the alignment of the type of the object).  If an address clause
9761 is given that specifies an inappropriately aligned address value, then the
9762 program execution is erroneous.
9764 Since this source of erroneous behavior can have unfortunate effects, GNAT
9765 checks (at compile time if possible, generating a warning, or at execution
9766 time with a run-time check) that the alignment is appropriate.  If the
9767 run-time check fails, then @code{Program_Error} is raised.  This run-time
9768 check is suppressed if range checks are suppressed, or if
9769 @code{pragma Restrictions (No_Elaboration_Code)} is in effect.
9771 @findex Export
9772 An address clause cannot be given for an exported object.  More
9773 understandably the real restriction is that objects with an address
9774 clause cannot be exported.  This is because such variables are not
9775 defined by the Ada program, so there is no external object to export.
9777 @findex Import
9778 It is permissible to give an address clause and a pragma Import for the
9779 same object.  In this case, the variable is not really defined by the
9780 Ada program, so there is no external symbol to be linked.  The link name
9781 and the external name are ignored in this case.  The reason that we allow this
9782 combination is that it provides a useful idiom to avoid unwanted
9783 initializations on objects with address clauses.
9785 When an address clause is given for an object that has implicit or
9786 explicit initialization, then by default initialization takes place.  This
9787 means that the effect of the object declaration is to overwrite the
9788 memory at the specified address.  This is almost always not what the
9789 programmer wants, so GNAT will output a warning:
9791 @smallexample
9792   with System;
9793   package G is
9794      type R is record
9795         M : Integer := 0;
9796      end record;
9798      Ext : R;
9799      for Ext'Address use System'To_Address (16#1234_1234#);
9800          |
9801   >>> warning: implicit initialization of "Ext" may
9802       modify overlaid storage
9803   >>> warning: use pragma Import for "Ext" to suppress
9804       initialization (RM B(24))
9806   end G;
9807 @end smallexample
9809 @noindent
9810 As indicated by the warning message, the solution is to use a (dummy) pragma
9811 Import to suppress this initialization.  The pragma tell the compiler that the
9812 object is declared and initialized elsewhere.  The following package compiles
9813 without warnings (and the initialization is suppressed):
9815 @smallexample @c ada
9816    with System;
9817    package G is
9818       type R is record
9819          M : Integer := 0;
9820       end record;
9822       Ext : R;
9823       for Ext'Address use System'To_Address (16#1234_1234#);
9824       pragma Import (Ada, Ext);
9825    end G;
9826 @end smallexample
9828 @noindent
9829 A final issue with address clauses involves their use for overlaying
9830 variables, as in the following example:
9831 @cindex Overlaying of objects
9833 @smallexample @c ada
9834   A : Integer;
9835   B : Integer;
9836   for B'Address use A'Address;
9837 @end smallexample
9839 @noindent
9840 or alternatively, using the form recommended by the RM:
9842 @smallexample @c ada
9843   A    : Integer;
9844   Addr : constant Address := A'Address;
9845   B    : Integer;
9846   for B'Address use Addr;
9847 @end smallexample
9849 @noindent
9850 In both of these cases, @code{A}
9851 and @code{B} become aliased to one another via the
9852 address clause. This use of address clauses to overlay
9853 variables, achieving an effect similar to unchecked
9854 conversion was erroneous in Ada 83, but in Ada 95
9855 the effect is implementation defined. Furthermore, the
9856 Ada 95 RM specifically recommends that in a situation
9857 like this, @code{B} should be subject to the following
9858 implementation advice (RM 13.3(19)):
9860 @quotation
9861 19  If the Address of an object is specified, or it is imported
9862     or exported, then the implementation should not perform
9863     optimizations based on assumptions of no aliases.
9864 @end quotation
9866 @noindent
9867 GNAT follows this recommendation, and goes further by also applying
9868 this recommendation to the overlaid variable (@code{A}
9869 in the above example) in this case. This means that the overlay
9870 works "as expected", in that a modification to one of the variables
9871 will affect the value of the other.
9873 @node Effect of Convention on Representation
9874 @section Effect of Convention on Representation
9875 @cindex Convention, effect on representation
9877 @noindent
9878 Normally the specification of a foreign language convention for a type or
9879 an object has no effect on the chosen representation.  In particular, the
9880 representation chosen for data in GNAT generally meets the standard system
9881 conventions, and for example records are laid out in a manner that is
9882 consistent with C@.  This means that specifying convention C (for example)
9883 has no effect.
9885 There are three exceptions to this general rule:
9887 @itemize @bullet
9889 @item Convention Fortran and array subtypes
9890 If pragma Convention Fortran is specified for an array subtype, then in
9891 accordance with the implementation advice in section 3.6.2(11) of the
9892 Ada Reference Manual, the array will be stored in a Fortran-compatible
9893 column-major manner, instead of the normal default row-major order.
9895 @item Convention C and enumeration types
9896 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
9897 to accommodate all values of the type.  For example, for the enumeration
9898 type declared by:
9900 @smallexample @c ada
9901    type Color is (Red, Green, Blue);
9902 @end smallexample
9904 @noindent
9905 8 bits is sufficient to store all values of the type, so by default, objects
9906 of type @code{Color} will be represented using 8 bits.  However, normal C
9907 convention is to use 32 bits for all enum values in C, since enum values
9908 are essentially of type int.  If pragma @code{Convention C} is specified for an
9909 Ada enumeration type, then the size is modified as necessary (usually to
9910 32 bits) to be consistent with the C convention for enum values.
9912 @item Convention C/Fortran and Boolean types
9913 In C, the usual convention for boolean values, that is values used for
9914 conditions, is that zero represents false, and nonzero values represent
9915 true.  In Ada, the normal convention is that two specific values, typically
9916 0/1, are used to represent false/true respectively.
9918 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
9919 value represents true).
9921 To accommodate the Fortran and C conventions, if a pragma Convention specifies
9922 C or Fortran convention for a derived Boolean, as in the following example:
9924 @smallexample @c ada
9925    type C_Switch is new Boolean;
9926    pragma Convention (C, C_Switch);
9927 @end smallexample
9929 @noindent
9930 then the GNAT generated code will treat any nonzero value as true.  For truth
9931 values generated by GNAT, the conventional value 1 will be used for True, but
9932 when one of these values is read, any nonzero value is treated as True.
9934 @end itemize
9936 @node Determining the Representations chosen by GNAT
9937 @section Determining the Representations chosen by GNAT
9938 @cindex Representation, determination of
9939 @cindex @code{-gnatR} switch
9941 @noindent
9942 Although the descriptions in this section are intended to be complete, it is
9943 often easier to simply experiment to see what GNAT accepts and what the
9944 effect is on the layout of types and objects.
9946 As required by the Ada RM, if a representation clause is not accepted, then
9947 it must be rejected as illegal by the compiler.  However, when a
9948 representation clause or pragma is accepted, there can still be questions
9949 of what the compiler actually does.  For example, if a partial record
9950 representation clause specifies the location of some components and not
9951 others, then where are the non-specified components placed? Or if pragma
9952 @code{Pack} is used on a record, then exactly where are the resulting
9953 fields placed? The section on pragma @code{Pack} in this chapter can be
9954 used to answer the second question, but it is often easier to just see
9955 what the compiler does.
9957 For this purpose, GNAT provides the option @code{-gnatR}.  If you compile
9958 with this option, then the compiler will output information on the actual
9959 representations chosen, in a format similar to source representation
9960 clauses.  For example, if we compile the package:
9962 @smallexample @c ada
9963 package q is
9964    type r (x : boolean) is tagged record
9965       case x is
9966          when True => S : String (1 .. 100);
9967          when False => null;
9968       end case;
9969    end record;
9971    type r2 is new r (false) with record
9972       y2 : integer;
9973    end record;
9975    for r2 use record
9976       y2 at 16 range 0 .. 31;
9977    end record;
9979    type x is record
9980       y : character;
9981    end record;
9983    type x1 is array (1 .. 10) of x;
9984    for x1'component_size use 11;
9986    type ia is access integer;
9988    type Rb1 is array (1 .. 13) of Boolean;
9989    pragma Pack (rb1);
9991    type Rb2 is array (1 .. 65) of Boolean;
9992    pragma Pack (rb2);
9994    type x2 is record
9995       l1 : Boolean;
9996       l2 : Duration;
9997       l3 : Float;
9998       l4 : Boolean;
9999       l5 : Rb1;
10000       l6 : Rb2;
10001    end record;
10002    pragma Pack (x2);
10003 end q;
10004 @end smallexample
10006 @noindent
10007 using the switch @code{-gnatR} we obtain the following output:
10009 @smallexample
10010 Representation information for unit q
10011 -------------------------------------
10013 for r'Size use ??;
10014 for r'Alignment use 4;
10015 for r use record
10016    x    at 4 range  0 .. 7;
10017    _tag at 0 range  0 .. 31;
10018    s    at 5 range  0 .. 799;
10019 end record;
10021 for r2'Size use 160;
10022 for r2'Alignment use 4;
10023 for r2 use record
10024    x       at  4 range  0 .. 7;
10025    _tag    at  0 range  0 .. 31;
10026    _parent at  0 range  0 .. 63;
10027    y2      at 16 range  0 .. 31;
10028 end record;
10030 for x'Size use 8;
10031 for x'Alignment use 1;
10032 for x use record
10033    y at 0 range  0 .. 7;
10034 end record;
10036 for x1'Size use 112;
10037 for x1'Alignment use 1;
10038 for x1'Component_Size use 11;
10040 for rb1'Size use 13;
10041 for rb1'Alignment use 2;
10042 for rb1'Component_Size use 1;
10044 for rb2'Size use 72;
10045 for rb2'Alignment use 1;
10046 for rb2'Component_Size use 1;
10048 for x2'Size use 224;
10049 for x2'Alignment use 4;
10050 for x2 use record
10051    l1 at  0 range  0 .. 0;
10052    l2 at  0 range  1 .. 64;
10053    l3 at 12 range  0 .. 31;
10054    l4 at 16 range  0 .. 0;
10055    l5 at 16 range  1 .. 13;
10056    l6 at 18 range  0 .. 71;
10057 end record;
10058 @end smallexample
10060 @noindent
10061 The Size values are actually the Object_Size, i.e.@: the default size that
10062 will be allocated for objects of the type.
10063 The ?? size for type r indicates that we have a variant record, and the
10064 actual size of objects will depend on the discriminant value.
10066 The Alignment values show the actual alignment chosen by the compiler
10067 for each record or array type.
10069 The record representation clause for type r shows where all fields
10070 are placed, including the compiler generated tag field (whose location
10071 cannot be controlled by the programmer).
10073 The record representation clause for the type extension r2 shows all the
10074 fields present, including the parent field, which is a copy of the fields
10075 of the parent type of r2, i.e.@: r1.
10077 The component size and size clauses for types rb1 and rb2 show
10078 the exact effect of pragma @code{Pack} on these arrays, and the record
10079 representation clause for type x2 shows how pragma @code{Pack} affects
10080 this record type.
10082 In some cases, it may be useful to cut and paste the representation clauses
10083 generated by the compiler into the original source to fix and guarantee
10084 the actual representation to be used.
10086 @node Standard Library Routines
10087 @chapter Standard Library Routines
10089 @noindent
10090 The Ada 95 Reference Manual contains in Annex A a full description of an
10091 extensive set of standard library routines that can be used in any Ada
10092 program, and which must be provided by all Ada compilers.  They are
10093 analogous to the standard C library used by C programs.
10095 GNAT implements all of the facilities described in annex A, and for most
10096 purposes the description in the Ada 95
10097 reference manual, or appropriate Ada
10098 text book, will be sufficient for making use of these facilities.
10100 In the case of the input-output facilities, @xref{The Implementation of
10101 Standard I/O}, gives details on exactly how GNAT interfaces to the
10102 file system.  For the remaining packages, the Ada 95 reference manual
10103 should be sufficient.  The following is a list of the packages included,
10104 together with a brief description of the functionality that is provided.
10106 For completeness, references are included to other predefined library
10107 routines defined in other sections of the Ada 95 reference manual (these are
10108 cross-indexed from annex A).
10110 @table @code
10111 @item Ada (A.2)
10112 This is a parent package for all the standard library packages.  It is
10113 usually included implicitly in your program, and itself contains no
10114 useful data or routines.
10116 @item Ada.Calendar (9.6)
10117 @code{Calendar} provides time of day access, and routines for
10118 manipulating times and durations.
10120 @item Ada.Characters (A.3.1)
10121 This is a dummy parent package that contains no useful entities
10123 @item Ada.Characters.Handling (A.3.2)
10124 This package provides some basic character handling capabilities,
10125 including classification functions for classes of characters (e.g.@: test
10126 for letters, or digits).
10128 @item Ada.Characters.Latin_1 (A.3.3)
10129 This package includes a complete set of definitions of the characters
10130 that appear in type CHARACTER@.  It is useful for writing programs that
10131 will run in international environments.  For example, if you want an
10132 upper case E with an acute accent in a string, it is often better to use
10133 the definition of @code{UC_E_Acute} in this package.  Then your program
10134 will print in an understandable manner even if your environment does not
10135 support these extended characters.
10137 @item Ada.Command_Line (A.15)
10138 This package provides access to the command line parameters and the name
10139 of the current program (analogous to the use of @code{argc} and @code{argv}
10140 in C), and also allows the exit status for the program to be set in a
10141 system-independent manner.
10143 @item Ada.Decimal (F.2)
10144 This package provides constants describing the range of decimal numbers
10145 implemented, and also a decimal divide routine (analogous to the COBOL
10146 verb DIVIDE .. GIVING .. REMAINDER ..)
10148 @item Ada.Direct_IO (A.8.4)
10149 This package provides input-output using a model of a set of records of
10150 fixed-length, containing an arbitrary definite Ada type, indexed by an
10151 integer record number.
10153 @item Ada.Dynamic_Priorities (D.5)
10154 This package allows the priorities of a task to be adjusted dynamically
10155 as the task is running.
10157 @item Ada.Exceptions (11.4.1)
10158 This package provides additional information on exceptions, and also
10159 contains facilities for treating exceptions as data objects, and raising
10160 exceptions with associated messages.
10162 @item Ada.Finalization (7.6)
10163 This package contains the declarations and subprograms to support the
10164 use of controlled types, providing for automatic initialization and
10165 finalization (analogous to the constructors and destructors of C++)
10167 @item Ada.Interrupts (C.3.2)
10168 This package provides facilities for interfacing to interrupts, which
10169 includes the set of signals or conditions that can be raised and
10170 recognized as interrupts.
10172 @item Ada.Interrupts.Names (C.3.2)
10173 This package provides the set of interrupt names (actually signal
10174 or condition names) that can be handled by GNAT@.
10176 @item Ada.IO_Exceptions (A.13)
10177 This package defines the set of exceptions that can be raised by use of
10178 the standard IO packages.
10180 @item Ada.Numerics
10181 This package contains some standard constants and exceptions used
10182 throughout the numerics packages.  Note that the constants pi and e are
10183 defined here, and it is better to use these definitions than rolling
10184 your own.
10186 @item Ada.Numerics.Complex_Elementary_Functions
10187 Provides the implementation of standard elementary functions (such as
10188 log and trigonometric functions) operating on complex numbers using the
10189 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
10190 created by the package @code{Numerics.Complex_Types}.
10192 @item Ada.Numerics.Complex_Types
10193 This is a predefined instantiation of
10194 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
10195 build the type @code{Complex} and @code{Imaginary}.
10197 @item Ada.Numerics.Discrete_Random
10198 This package provides a random number generator suitable for generating
10199 random integer values from a specified range.
10201 @item Ada.Numerics.Float_Random
10202 This package provides a random number generator suitable for generating
10203 uniformly distributed floating point values.
10205 @item Ada.Numerics.Generic_Complex_Elementary_Functions
10206 This is a generic version of the package that provides the
10207 implementation of standard elementary functions (such as log and
10208 trigonometric functions) for an arbitrary complex type.
10210 The following predefined instantiations of this package are provided:
10212 @table @code
10213 @item Short_Float
10214 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
10215 @item Float
10216 @code{Ada.Numerics.Complex_Elementary_Functions}
10217 @item Long_Float
10218 @code{Ada.Numerics.
10219  Long_Complex_Elementary_Functions}
10220 @end table
10222 @item Ada.Numerics.Generic_Complex_Types
10223 This is a generic package that allows the creation of complex types,
10224 with associated complex arithmetic operations.
10226 The following predefined instantiations of this package exist
10227 @table @code
10228 @item Short_Float
10229 @code{Ada.Numerics.Short_Complex_Complex_Types}
10230 @item Float
10231 @code{Ada.Numerics.Complex_Complex_Types}
10232 @item Long_Float
10233 @code{Ada.Numerics.Long_Complex_Complex_Types}
10234 @end table
10236 @item Ada.Numerics.Generic_Elementary_Functions
10237 This is a generic package that provides the implementation of standard
10238 elementary functions (such as log an trigonometric functions) for an
10239 arbitrary float type.
10241 The following predefined instantiations of this package exist
10243 @table @code
10244 @item Short_Float
10245 @code{Ada.Numerics.Short_Elementary_Functions}
10246 @item Float
10247 @code{Ada.Numerics.Elementary_Functions}
10248 @item Long_Float
10249 @code{Ada.Numerics.Long_Elementary_Functions}
10250 @end table
10252 @item Ada.Real_Time (D.8)
10253 This package provides facilities similar to those of @code{Calendar}, but
10254 operating with a finer clock suitable for real time control. Note that
10255 annex D requires that there be no backward clock jumps, and GNAT generally
10256 guarantees this behavior, but of course if the external clock on which
10257 the GNAT runtime depends is deliberately reset by some external event,
10258 then such a backward jump may occur.
10260 @item Ada.Sequential_IO (A.8.1)
10261 This package provides input-output facilities for sequential files,
10262 which can contain a sequence of values of a single type, which can be
10263 any Ada type, including indefinite (unconstrained) types.
10265 @item Ada.Storage_IO (A.9)
10266 This package provides a facility for mapping arbitrary Ada types to and
10267 from a storage buffer.  It is primarily intended for the creation of new
10268 IO packages.
10270 @item Ada.Streams (13.13.1)
10271 This is a generic package that provides the basic support for the
10272 concept of streams as used by the stream attributes (@code{Input},
10273 @code{Output}, @code{Read} and @code{Write}).
10275 @item Ada.Streams.Stream_IO (A.12.1)
10276 This package is a specialization of the type @code{Streams} defined in
10277 package @code{Streams} together with a set of operations providing
10278 Stream_IO capability.  The Stream_IO model permits both random and
10279 sequential access to a file which can contain an arbitrary set of values
10280 of one or more Ada types.
10282 @item Ada.Strings (A.4.1)
10283 This package provides some basic constants used by the string handling
10284 packages.
10286 @item Ada.Strings.Bounded (A.4.4)
10287 This package provides facilities for handling variable length
10288 strings.  The bounded model requires a maximum length.  It is thus
10289 somewhat more limited than the unbounded model, but avoids the use of
10290 dynamic allocation or finalization.
10292 @item Ada.Strings.Fixed (A.4.3)
10293 This package provides facilities for handling fixed length strings.
10295 @item Ada.Strings.Maps (A.4.2)
10296 This package provides facilities for handling character mappings and
10297 arbitrarily defined subsets of characters.  For instance it is useful in
10298 defining specialized translation tables.
10300 @item Ada.Strings.Maps.Constants (A.4.6)
10301 This package provides a standard set of predefined mappings and
10302 predefined character sets.  For example, the standard upper to lower case
10303 conversion table is found in this package.  Note that upper to lower case
10304 conversion is non-trivial if you want to take the entire set of
10305 characters, including extended characters like E with an acute accent,
10306 into account.  You should use the mappings in this package (rather than
10307 adding 32 yourself) to do case mappings.
10309 @item Ada.Strings.Unbounded (A.4.5)
10310 This package provides facilities for handling variable length
10311 strings.  The unbounded model allows arbitrary length strings, but
10312 requires the use of dynamic allocation and finalization.
10314 @item Ada.Strings.Wide_Bounded (A.4.7)
10315 @itemx Ada.Strings.Wide_Fixed (A.4.7)
10316 @itemx Ada.Strings.Wide_Maps (A.4.7)
10317 @itemx Ada.Strings.Wide_Maps.Constants (A.4.7)
10318 @itemx Ada.Strings.Wide_Unbounded (A.4.7)
10319 These packages provide analogous capabilities to the corresponding
10320 packages without @samp{Wide_} in the name, but operate with the types
10321 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
10322 and @code{Character}.
10324 @item Ada.Strings.Wide_Wide_Bounded (A.4.7)
10325 @itemx Ada.Strings.Wide_Wide_Fixed (A.4.7)
10326 @itemx Ada.Strings.Wide_Wide_Maps (A.4.7)
10327 @itemx Ada.Strings.Wide_Wide_Maps.Constants (A.4.7)
10328 @itemx Ada.Strings.Wide_Wide_Unbounded (A.4.7)
10329 These packages provide analogous capabilities to the corresponding
10330 packages without @samp{Wide_} in the name, but operate with the types
10331 @code{Wide_Wide_String} and @code{Wide_Wide_Character} instead
10332 of @code{String} and @code{Character}.
10334 @item Ada.Synchronous_Task_Control (D.10)
10335 This package provides some standard facilities for controlling task
10336 communication in a synchronous manner.
10338 @item Ada.Tags
10339 This package contains definitions for manipulation of the tags of tagged
10340 values.
10342 @item Ada.Task_Attributes
10343 This package provides the capability of associating arbitrary
10344 task-specific data with separate tasks.
10346 @item Ada.Text_IO
10347 This package provides basic text input-output capabilities for
10348 character, string and numeric data.  The subpackages of this
10349 package are listed next.
10351 @item Ada.Text_IO.Decimal_IO
10352 Provides input-output facilities for decimal fixed-point types
10354 @item Ada.Text_IO.Enumeration_IO
10355 Provides input-output facilities for enumeration types.
10357 @item Ada.Text_IO.Fixed_IO
10358 Provides input-output facilities for ordinary fixed-point types.
10360 @item Ada.Text_IO.Float_IO
10361 Provides input-output facilities for float types.  The following
10362 predefined instantiations of this generic package are available:
10364 @table @code
10365 @item Short_Float
10366 @code{Short_Float_Text_IO}
10367 @item Float
10368 @code{Float_Text_IO}
10369 @item Long_Float
10370 @code{Long_Float_Text_IO}
10371 @end table
10373 @item Ada.Text_IO.Integer_IO
10374 Provides input-output facilities for integer types.  The following
10375 predefined instantiations of this generic package are available:
10377 @table @code
10378 @item Short_Short_Integer
10379 @code{Ada.Short_Short_Integer_Text_IO}
10380 @item Short_Integer
10381 @code{Ada.Short_Integer_Text_IO}
10382 @item Integer
10383 @code{Ada.Integer_Text_IO}
10384 @item Long_Integer
10385 @code{Ada.Long_Integer_Text_IO}
10386 @item Long_Long_Integer
10387 @code{Ada.Long_Long_Integer_Text_IO}
10388 @end table
10390 @item Ada.Text_IO.Modular_IO
10391 Provides input-output facilities for modular (unsigned) types
10393 @item Ada.Text_IO.Complex_IO (G.1.3)
10394 This package provides basic text input-output capabilities for complex
10395 data.
10397 @item Ada.Text_IO.Editing (F.3.3)
10398 This package contains routines for edited output, analogous to the use
10399 of pictures in COBOL@.  The picture formats used by this package are a
10400 close copy of the facility in COBOL@.
10402 @item Ada.Text_IO.Text_Streams (A.12.2)
10403 This package provides a facility that allows Text_IO files to be treated
10404 as streams, so that the stream attributes can be used for writing
10405 arbitrary data, including binary data, to Text_IO files.
10407 @item Ada.Unchecked_Conversion (13.9)
10408 This generic package allows arbitrary conversion from one type to
10409 another of the same size, providing for breaking the type safety in
10410 special circumstances.
10412 If the types have the same Size (more accurately the same Value_Size),
10413 then the effect is simply to transfer the bits from the source to the
10414 target type without any modification.  This usage is well defined, and
10415 for simple types whose representation is typically the same across
10416 all implementations, gives a portable method of performing such
10417 conversions.
10419 If the types do not have the same size, then the result is implementation
10420 defined, and thus may be non-portable.  The following describes how GNAT
10421 handles such unchecked conversion cases.
10423 If the types are of different sizes, and are both discrete types, then
10424 the effect is of a normal type conversion without any constraint checking.
10425 In particular if the result type has a larger size, the result will be
10426 zero or sign extended.  If the result type has a smaller size, the result
10427 will be truncated by ignoring high order bits.
10429 If the types are of different sizes, and are not both discrete types,
10430 then the conversion works as though pointers were created to the source
10431 and target, and the pointer value is converted.  The effect is that bits
10432 are copied from successive low order storage units and bits of the source
10433 up to the length of the target type.
10435 A warning is issued if the lengths differ, since the effect in this
10436 case is implementation dependent, and the above behavior may not match
10437 that of some other compiler.
10439 A pointer to one type may be converted to a pointer to another type using
10440 unchecked conversion.  The only case in which the effect is undefined is
10441 when one or both pointers are pointers to unconstrained array types.  In
10442 this case, the bounds information may get incorrectly transferred, and in
10443 particular, GNAT uses double size pointers for such types, and it is
10444 meaningless to convert between such pointer types.  GNAT will issue a
10445 warning if the alignment of the target designated type is more strict
10446 than the alignment of the source designated type (since the result may
10447 be unaligned in this case).
10449 A pointer other than a pointer to an unconstrained array type may be
10450 converted to and from System.Address.  Such usage is common in Ada 83
10451 programs, but note that Ada.Address_To_Access_Conversions is the
10452 preferred method of performing such conversions in Ada 95.  Neither
10453 unchecked conversion nor Ada.Address_To_Access_Conversions should be
10454 used in conjunction with pointers to unconstrained objects, since
10455 the bounds information cannot be handled correctly in this case.
10457 @item Ada.Unchecked_Deallocation (13.11.2)
10458 This generic package allows explicit freeing of storage previously
10459 allocated by use of an allocator.
10461 @item Ada.Wide_Text_IO (A.11)
10462 This package is similar to @code{Ada.Text_IO}, except that the external
10463 file supports wide character representations, and the internal types are
10464 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
10465 and @code{String}.  It contains generic subpackages listed next.
10467 @item Ada.Wide_Text_IO.Decimal_IO
10468 Provides input-output facilities for decimal fixed-point types
10470 @item Ada.Wide_Text_IO.Enumeration_IO
10471 Provides input-output facilities for enumeration types.
10473 @item Ada.Wide_Text_IO.Fixed_IO
10474 Provides input-output facilities for ordinary fixed-point types.
10476 @item Ada.Wide_Text_IO.Float_IO
10477 Provides input-output facilities for float types.  The following
10478 predefined instantiations of this generic package are available:
10480 @table @code
10481 @item Short_Float
10482 @code{Short_Float_Wide_Text_IO}
10483 @item Float
10484 @code{Float_Wide_Text_IO}
10485 @item Long_Float
10486 @code{Long_Float_Wide_Text_IO}
10487 @end table
10489 @item Ada.Wide_Text_IO.Integer_IO
10490 Provides input-output facilities for integer types.  The following
10491 predefined instantiations of this generic package are available:
10493 @table @code
10494 @item Short_Short_Integer
10495 @code{Ada.Short_Short_Integer_Wide_Text_IO}
10496 @item Short_Integer
10497 @code{Ada.Short_Integer_Wide_Text_IO}
10498 @item Integer
10499 @code{Ada.Integer_Wide_Text_IO}
10500 @item Long_Integer
10501 @code{Ada.Long_Integer_Wide_Text_IO}
10502 @item Long_Long_Integer
10503 @code{Ada.Long_Long_Integer_Wide_Text_IO}
10504 @end table
10506 @item Ada.Wide_Text_IO.Modular_IO
10507 Provides input-output facilities for modular (unsigned) types
10509 @item Ada.Wide_Text_IO.Complex_IO (G.1.3)
10510 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
10511 external file supports wide character representations.
10513 @item Ada.Wide_Text_IO.Editing (F.3.4)
10514 This package is similar to @code{Ada.Text_IO.Editing}, except that the
10515 types are @code{Wide_Character} and @code{Wide_String} instead of
10516 @code{Character} and @code{String}.
10518 @item Ada.Wide_Text_IO.Streams (A.12.3)
10519 This package is similar to @code{Ada.Text_IO.Streams}, except that the
10520 types are @code{Wide_Character} and @code{Wide_String} instead of
10521 @code{Character} and @code{String}.
10523 @item Ada.Wide_Wide_Text_IO (A.11)
10524 This package is similar to @code{Ada.Text_IO}, except that the external
10525 file supports wide character representations, and the internal types are
10526 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
10527 and @code{String}.  It contains generic subpackages listed next.
10529 @item Ada.Wide_Wide_Text_IO.Decimal_IO
10530 Provides input-output facilities for decimal fixed-point types
10532 @item Ada.Wide_Wide_Text_IO.Enumeration_IO
10533 Provides input-output facilities for enumeration types.
10535 @item Ada.Wide_Wide_Text_IO.Fixed_IO
10536 Provides input-output facilities for ordinary fixed-point types.
10538 @item Ada.Wide_Wide_Text_IO.Float_IO
10539 Provides input-output facilities for float types.  The following
10540 predefined instantiations of this generic package are available:
10542 @table @code
10543 @item Short_Float
10544 @code{Short_Float_Wide_Wide_Text_IO}
10545 @item Float
10546 @code{Float_Wide_Wide_Text_IO}
10547 @item Long_Float
10548 @code{Long_Float_Wide_Wide_Text_IO}
10549 @end table
10551 @item Ada.Wide_Wide_Text_IO.Integer_IO
10552 Provides input-output facilities for integer types.  The following
10553 predefined instantiations of this generic package are available:
10555 @table @code
10556 @item Short_Short_Integer
10557 @code{Ada.Short_Short_Integer_Wide_Wide_Text_IO}
10558 @item Short_Integer
10559 @code{Ada.Short_Integer_Wide_Wide_Text_IO}
10560 @item Integer
10561 @code{Ada.Integer_Wide_Wide_Text_IO}
10562 @item Long_Integer
10563 @code{Ada.Long_Integer_Wide_Wide_Text_IO}
10564 @item Long_Long_Integer
10565 @code{Ada.Long_Long_Integer_Wide_Wide_Text_IO}
10566 @end table
10568 @item Ada.Wide_Wide_Text_IO.Modular_IO
10569 Provides input-output facilities for modular (unsigned) types
10571 @item Ada.Wide_Wide_Text_IO.Complex_IO (G.1.3)
10572 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
10573 external file supports wide character representations.
10575 @item Ada.Wide_Wide_Text_IO.Editing (F.3.4)
10576 This package is similar to @code{Ada.Text_IO.Editing}, except that the
10577 types are @code{Wide_Character} and @code{Wide_String} instead of
10578 @code{Character} and @code{String}.
10580 @item Ada.Wide_Wide_Text_IO.Streams (A.12.3)
10581 This package is similar to @code{Ada.Text_IO.Streams}, except that the
10582 types are @code{Wide_Character} and @code{Wide_String} instead of
10583 @code{Character} and @code{String}.
10584 @end table
10588 @node The Implementation of Standard I/O
10589 @chapter The Implementation of Standard I/O
10591 @noindent
10592 GNAT implements all the required input-output facilities described in
10593 A.6 through A.14.  These sections of the Ada 95 reference manual describe the
10594 required behavior of these packages from the Ada point of view, and if
10595 you are writing a portable Ada program that does not need to know the
10596 exact manner in which Ada maps to the outside world when it comes to
10597 reading or writing external files, then you do not need to read this
10598 chapter.  As long as your files are all regular files (not pipes or
10599 devices), and as long as you write and read the files only from Ada, the
10600 description in the Ada 95 reference manual is sufficient.
10602 However, if you want to do input-output to pipes or other devices, such
10603 as the keyboard or screen, or if the files you are dealing with are
10604 either generated by some other language, or to be read by some other
10605 language, then you need to know more about the details of how the GNAT
10606 implementation of these input-output facilities behaves.
10608 In this chapter we give a detailed description of exactly how GNAT
10609 interfaces to the file system.  As always, the sources of the system are
10610 available to you for answering questions at an even more detailed level,
10611 but for most purposes the information in this chapter will suffice.
10613 Another reason that you may need to know more about how input-output is
10614 implemented arises when you have a program written in mixed languages
10615 where, for example, files are shared between the C and Ada sections of
10616 the same program.  GNAT provides some additional facilities, in the form
10617 of additional child library packages, that facilitate this sharing, and
10618 these additional facilities are also described in this chapter.
10620 @menu
10621 * Standard I/O Packages::
10622 * FORM Strings::
10623 * Direct_IO::
10624 * Sequential_IO::
10625 * Text_IO::
10626 * Wide_Text_IO::
10627 * Wide_Wide_Text_IO::
10628 * Stream_IO::
10629 * Shared Files::
10630 * Open Modes::
10631 * Operations on C Streams::
10632 * Interfacing to C Streams::
10633 @end menu
10635 @node Standard I/O Packages
10636 @section Standard I/O Packages
10638 @noindent
10639 The Standard I/O packages described in Annex A for
10641 @itemize @bullet
10642 @item
10643 Ada.Text_IO
10644 @item
10645 Ada.Text_IO.Complex_IO
10646 @item
10647 Ada.Text_IO.Text_Streams
10648 @item
10649 Ada.Wide_Text_IO
10650 @item
10651 Ada.Wide_Text_IO.Complex_IO
10652 @item
10653 Ada.Wide_Text_IO.Text_Streams
10654 @item
10655 Ada.Wide_Wide_Text_IO
10656 @item
10657 Ada.Wide_Wide_Text_IO.Complex_IO
10658 @item
10659 Ada.Wide_Wide_Text_IO.Text_Streams
10660 @item
10661 Ada.Stream_IO
10662 @item
10663 Ada.Sequential_IO
10664 @item
10665 Ada.Direct_IO
10666 @end itemize
10668 @noindent
10669 are implemented using the C
10670 library streams facility; where
10672 @itemize @bullet
10673 @item
10674 All files are opened using @code{fopen}.
10675 @item
10676 All input/output operations use @code{fread}/@code{fwrite}.
10677 @end itemize
10679 @noindent
10680 There is no internal buffering of any kind at the Ada library level.  The
10681 only buffering is that provided at the system level in the
10682 implementation of the C library routines that support streams.  This
10683 facilitates shared use of these streams by mixed language programs.
10685 @node FORM Strings
10686 @section FORM Strings
10688 @noindent
10689 The format of a FORM string in GNAT is:
10691 @smallexample
10692 "keyword=value,keyword=value,@dots{},keyword=value"
10693 @end smallexample
10695 @noindent
10696 where letters may be in upper or lower case, and there are no spaces
10697 between values.  The order of the entries is not important.  Currently
10698 there are two keywords defined.
10700 @smallexample
10701 SHARED=[YES|NO]
10702 WCEM=[n|h|u|s\e]
10703 @end smallexample
10705 @noindent
10706 The use of these parameters is described later in this section.
10708 @node Direct_IO
10709 @section Direct_IO
10711 @noindent
10712 Direct_IO can only be instantiated for definite types.  This is a
10713 restriction of the Ada language, which means that the records are fixed
10714 length (the length being determined by @code{@var{type}'Size}, rounded
10715 up to the next storage unit boundary if necessary).
10717 The records of a Direct_IO file are simply written to the file in index
10718 sequence, with the first record starting at offset zero, and subsequent
10719 records following.  There is no control information of any kind.  For
10720 example, if 32-bit integers are being written, each record takes
10721 4-bytes, so the record at index @var{K} starts at offset
10722 (@var{K}@minus{}1)*4.
10724 There is no limit on the size of Direct_IO files, they are expanded as
10725 necessary to accommodate whatever records are written to the file.
10727 @node Sequential_IO
10728 @section Sequential_IO
10730 @noindent
10731 Sequential_IO may be instantiated with either a definite (constrained)
10732 or indefinite (unconstrained) type.
10734 For the definite type case, the elements written to the file are simply
10735 the memory images of the data values with no control information of any
10736 kind.  The resulting file should be read using the same type, no validity
10737 checking is performed on input.
10739 For the indefinite type case, the elements written consist of two
10740 parts.  First is the size of the data item, written as the memory image
10741 of a @code{Interfaces.C.size_t} value, followed by the memory image of
10742 the data value.  The resulting file can only be read using the same
10743 (unconstrained) type.  Normal assignment checks are performed on these
10744 read operations, and if these checks fail, @code{Data_Error} is
10745 raised.  In particular, in the array case, the lengths must match, and in
10746 the variant record case, if the variable for a particular read operation
10747 is constrained, the discriminants must match.
10749 Note that it is not possible to use Sequential_IO to write variable
10750 length array items, and then read the data back into different length
10751 arrays.  For example, the following will raise @code{Data_Error}:
10753 @smallexample @c ada
10754  package IO is new Sequential_IO (String);
10755  F : IO.File_Type;
10756  S : String (1..4);
10757  @dots{}
10758  IO.Create (F)
10759  IO.Write (F, "hello!")
10760  IO.Reset (F, Mode=>In_File);
10761  IO.Read (F, S);
10762  Put_Line (S);
10764 @end smallexample
10766 @noindent
10767 On some Ada implementations, this will print @code{hell}, but the program is
10768 clearly incorrect, since there is only one element in the file, and that
10769 element is the string @code{hello!}.
10771 In Ada 95, this kind of behavior can be legitimately achieved using
10772 Stream_IO, and this is the preferred mechanism.  In particular, the above
10773 program fragment rewritten to use Stream_IO will work correctly.
10775 @node Text_IO
10776 @section Text_IO
10778 @noindent
10779 Text_IO files consist of a stream of characters containing the following
10780 special control characters:
10782 @smallexample
10783 LF (line feed, 16#0A#) Line Mark
10784 FF (form feed, 16#0C#) Page Mark
10785 @end smallexample
10787 @noindent
10788 A canonical Text_IO file is defined as one in which the following
10789 conditions are met:
10791 @itemize @bullet
10792 @item
10793 The character @code{LF} is used only as a line mark, i.e.@: to mark the end
10794 of the line.
10796 @item
10797 The character @code{FF} is used only as a page mark, i.e.@: to mark the
10798 end of a page and consequently can appear only immediately following a
10799 @code{LF} (line mark) character.
10801 @item
10802 The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
10803 (line mark, page mark).  In the former case, the page mark is implicitly
10804 assumed to be present.
10805 @end itemize
10807 @noindent
10808 A file written using Text_IO will be in canonical form provided that no
10809 explicit @code{LF} or @code{FF} characters are written using @code{Put}
10810 or @code{Put_Line}.  There will be no @code{FF} character at the end of
10811 the file unless an explicit @code{New_Page} operation was performed
10812 before closing the file.
10814 A canonical Text_IO file that is a regular file, i.e.@: not a device or a
10815 pipe, can be read using any of the routines in Text_IO@.  The
10816 semantics in this case will be exactly as defined in the Ada 95 reference
10817 manual and all the routines in Text_IO are fully implemented.
10819 A text file that does not meet the requirements for a canonical Text_IO
10820 file has one of the following:
10822 @itemize @bullet
10823 @item
10824 The file contains @code{FF} characters not immediately following a
10825 @code{LF} character.
10827 @item
10828 The file contains @code{LF} or @code{FF} characters written by
10829 @code{Put} or @code{Put_Line}, which are not logically considered to be
10830 line marks or page marks.
10832 @item
10833 The file ends in a character other than @code{LF} or @code{FF},
10834 i.e.@: there is no explicit line mark or page mark at the end of the file.
10835 @end itemize
10837 @noindent
10838 Text_IO can be used to read such non-standard text files but subprograms
10839 to do with line or page numbers do not have defined meanings.  In
10840 particular, a @code{FF} character that does not follow a @code{LF}
10841 character may or may not be treated as a page mark from the point of
10842 view of page and line numbering.  Every @code{LF} character is considered
10843 to end a line, and there is an implied @code{LF} character at the end of
10844 the file.
10846 @menu
10847 * Text_IO Stream Pointer Positioning::
10848 * Text_IO Reading and Writing Non-Regular Files::
10849 * Get_Immediate::
10850 * Treating Text_IO Files as Streams::
10851 * Text_IO Extensions::
10852 * Text_IO Facilities for Unbounded Strings::
10853 @end menu
10855 @node Text_IO Stream Pointer Positioning
10856 @subsection Stream Pointer Positioning
10858 @noindent
10859 @code{Ada.Text_IO} has a definition of current position for a file that
10860 is being read.  No internal buffering occurs in Text_IO, and usually the
10861 physical position in the stream used to implement the file corresponds
10862 to this logical position defined by Text_IO@.  There are two exceptions:
10864 @itemize @bullet
10865 @item
10866 After a call to @code{End_Of_Page} that returns @code{True}, the stream
10867 is positioned past the @code{LF} (line mark) that precedes the page
10868 mark.  Text_IO maintains an internal flag so that subsequent read
10869 operations properly handle the logical position which is unchanged by
10870 the @code{End_Of_Page} call.
10872 @item
10873 After a call to @code{End_Of_File} that returns @code{True}, if the
10874 Text_IO file was positioned before the line mark at the end of file
10875 before the call, then the logical position is unchanged, but the stream
10876 is physically positioned right at the end of file (past the line mark,
10877 and past a possible page mark following the line mark.  Again Text_IO
10878 maintains internal flags so that subsequent read operations properly
10879 handle the logical position.
10880 @end itemize
10882 @noindent
10883 These discrepancies have no effect on the observable behavior of
10884 Text_IO, but if a single Ada stream is shared between a C program and
10885 Ada program, or shared (using @samp{shared=yes} in the form string)
10886 between two Ada files, then the difference may be observable in some
10887 situations.
10889 @node Text_IO Reading and Writing Non-Regular Files
10890 @subsection Reading and Writing Non-Regular Files
10892 @noindent
10893 A non-regular file is a device (such as a keyboard), or a pipe.  Text_IO
10894 can be used for reading and writing.  Writing is not affected and the
10895 sequence of characters output is identical to the normal file case, but
10896 for reading, the behavior of Text_IO is modified to avoid undesirable
10897 look-ahead as follows:
10899 An input file that is not a regular file is considered to have no page
10900 marks.  Any @code{Ascii.FF} characters (the character normally used for a
10901 page mark) appearing in the file are considered to be data
10902 characters.  In particular:
10904 @itemize @bullet
10905 @item
10906 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
10907 following a line mark.  If a page mark appears, it will be treated as a
10908 data character.
10910 @item
10911 This avoids the need to wait for an extra character to be typed or
10912 entered from the pipe to complete one of these operations.
10914 @item
10915 @code{End_Of_Page} always returns @code{False}
10917 @item
10918 @code{End_Of_File} will return @code{False} if there is a page mark at
10919 the end of the file.
10920 @end itemize
10922 @noindent
10923 Output to non-regular files is the same as for regular files.  Page marks
10924 may be written to non-regular files using @code{New_Page}, but as noted
10925 above they will not be treated as page marks on input if the output is
10926 piped to another Ada program.
10928 Another important discrepancy when reading non-regular files is that the end
10929 of file indication is not ``sticky''.  If an end of file is entered, e.g.@: by
10930 pressing the @key{EOT} key,
10931 then end of file
10932 is signaled once (i.e.@: the test @code{End_Of_File}
10933 will yield @code{True}, or a read will
10934 raise @code{End_Error}), but then reading can resume
10935 to read data past that end of
10936 file indication, until another end of file indication is entered.
10938 @node Get_Immediate
10939 @subsection Get_Immediate
10940 @cindex Get_Immediate
10942 @noindent
10943 Get_Immediate returns the next character (including control characters)
10944 from the input file.  In particular, Get_Immediate will return LF or FF
10945 characters used as line marks or page marks.  Such operations leave the
10946 file positioned past the control character, and it is thus not treated
10947 as having its normal function.  This means that page, line and column
10948 counts after this kind of Get_Immediate call are set as though the mark
10949 did not occur.  In the case where a Get_Immediate leaves the file
10950 positioned between the line mark and page mark (which is not normally
10951 possible), it is undefined whether the FF character will be treated as a
10952 page mark.
10954 @node Treating Text_IO Files as Streams
10955 @subsection Treating Text_IO Files as Streams
10956 @cindex Stream files
10958 @noindent
10959 The package @code{Text_IO.Streams} allows a Text_IO file to be treated
10960 as a stream.  Data written to a Text_IO file in this stream mode is
10961 binary data.  If this binary data contains bytes 16#0A# (@code{LF}) or
10962 16#0C# (@code{FF}), the resulting file may have non-standard
10963 format.  Similarly if read operations are used to read from a Text_IO
10964 file treated as a stream, then @code{LF} and @code{FF} characters may be
10965 skipped and the effect is similar to that described above for
10966 @code{Get_Immediate}.
10968 @node Text_IO Extensions
10969 @subsection Text_IO Extensions
10970 @cindex Text_IO extensions
10972 @noindent
10973 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
10974 to the standard @code{Text_IO} package:
10976 @itemize @bullet
10977 @item function File_Exists (Name : String) return Boolean;
10978 Determines if a file of the given name exists.
10980 @item function Get_Line return String;
10981 Reads a string from the standard input file.  The value returned is exactly
10982 the length of the line that was read.
10984 @item function Get_Line (File : Ada.Text_IO.File_Type) return String;
10985 Similar, except that the parameter File specifies the file from which
10986 the string is to be read.
10988 @end itemize
10990 @node Text_IO Facilities for Unbounded Strings
10991 @subsection Text_IO Facilities for Unbounded Strings
10992 @cindex Text_IO for unbounded strings
10993 @cindex Unbounded_String, Text_IO operations
10995 @noindent
10996 The package @code{Ada.Strings.Unbounded.Text_IO}
10997 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
10998 subprograms useful for Text_IO operations on unbounded strings:
11000 @itemize @bullet
11002 @item function Get_Line (File : File_Type) return Unbounded_String;
11003 Reads a line from the specified file
11004 and returns the result as an unbounded string.
11006 @item procedure Put (File : File_Type; U : Unbounded_String);
11007 Writes the value of the given unbounded string to the specified file
11008 Similar to the effect of
11009 @code{Put (To_String (U))} except that an extra copy is avoided.
11011 @item procedure Put_Line (File : File_Type; U : Unbounded_String);
11012 Writes the value of the given unbounded string to the specified file,
11013 followed by a @code{New_Line}.
11014 Similar to the effect of @code{Put_Line (To_String (U))} except
11015 that an extra copy is avoided.
11016 @end itemize
11018 @noindent
11019 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
11020 and is optional.  If the parameter is omitted, then the standard input or
11021 output file is referenced as appropriate.
11023 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
11024 files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended
11025 @code{Wide_Text_IO} functionality for unbounded wide strings.
11027 The package @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} in library
11028 files @file{a-szuzti.ads} and @file{a-szuzti.adb} provides similar extended
11029 @code{Wide_Wide_Text_IO} functionality for unbounded wide wide strings.
11031 @node Wide_Text_IO
11032 @section Wide_Text_IO
11034 @noindent
11035 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
11036 both input and output files may contain special sequences that represent
11037 wide character values.  The encoding scheme for a given file may be
11038 specified using a FORM parameter:
11040 @smallexample
11041 WCEM=@var{x}
11042 @end smallexample
11044 @noindent
11045 as part of the FORM string (WCEM = wide character encoding method),
11046 where @var{x} is one of the following characters
11048 @table @samp
11049 @item h
11050 Hex ESC encoding
11051 @item u
11052 Upper half encoding
11053 @item s
11054 Shift-JIS encoding
11055 @item e
11056 EUC Encoding
11057 @item 8
11058 UTF-8 encoding
11059 @item b
11060 Brackets encoding
11061 @end table
11063 @noindent
11064 The encoding methods match those that
11065 can be used in a source
11066 program, but there is no requirement that the encoding method used for
11067 the source program be the same as the encoding method used for files,
11068 and different files may use different encoding methods.
11070 The default encoding method for the standard files, and for opened files
11071 for which no WCEM parameter is given in the FORM string matches the
11072 wide character encoding specified for the main program (the default
11073 being brackets encoding if no coding method was specified with -gnatW).
11075 @table @asis
11076 @item Hex Coding
11077 In this encoding, a wide character is represented by a five character
11078 sequence:
11080 @smallexample
11081 ESC a b c d
11082 @end smallexample
11084 @noindent
11085 where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
11086 characters (using upper case letters) of the wide character code.  For
11087 example, ESC A345 is used to represent the wide character with code
11088 16#A345#.  This scheme is compatible with use of the full
11089 @code{Wide_Character} set.
11091 @item Upper Half Coding
11092 The wide character with encoding 16#abcd#, where the upper bit is on
11093 (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
11094 16#cd#.  The second byte may never be a format control character, but is
11095 not required to be in the upper half.  This method can be also used for
11096 shift-JIS or EUC where the internal coding matches the external coding.
11098 @item Shift JIS Coding
11099 A wide character is represented by a two character sequence 16#ab# and
11100 16#cd#, with the restrictions described for upper half encoding as
11101 described above.  The internal character code is the corresponding JIS
11102 character according to the standard algorithm for Shift-JIS
11103 conversion.  Only characters defined in the JIS code set table can be
11104 used with this encoding method.
11106 @item EUC Coding
11107 A wide character is represented by a two character sequence 16#ab# and
11108 16#cd#, with both characters being in the upper half.  The internal
11109 character code is the corresponding JIS character according to the EUC
11110 encoding algorithm.  Only characters defined in the JIS code set table
11111 can be used with this encoding method.
11113 @item UTF-8 Coding
11114 A wide character is represented using
11115 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
11116 10646-1/Am.2.  Depending on the character value, the representation
11117 is a one, two, or three byte sequence:
11119 @smallexample
11120 16#0000#-16#007f#: 2#0xxxxxxx#
11121 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
11122 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
11123 @end smallexample
11125 @noindent
11126 where the xxx bits correspond to the left-padded bits of the
11127 16-bit character value.  Note that all lower half ASCII characters
11128 are represented as ASCII bytes and all upper half characters and
11129 other wide characters are represented as sequences of upper-half
11130 (The full UTF-8 scheme allows for encoding 31-bit characters as
11131 6-byte sequences, but in this implementation, all UTF-8 sequences
11132 of four or more bytes length will raise a Constraint_Error, as
11133 will all invalid UTF-8 sequences.)
11135 @item Brackets Coding
11136 In this encoding, a wide character is represented by the following eight
11137 character sequence:
11139 @smallexample
11140 [ " a b c d " ]
11141 @end smallexample
11143 @noindent
11144 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
11145 characters (using uppercase letters) of the wide character code.  For
11146 example, @code{["A345"]} is used to represent the wide character with code
11147 @code{16#A345#}.
11148 This scheme is compatible with use of the full Wide_Character set.
11149 On input, brackets coding can also be used for upper half characters,
11150 e.g.@: @code{["C1"]} for lower case a.  However, on output, brackets notation
11151 is only used for wide characters with a code greater than @code{16#FF#}.
11153 @end table
11155 @noindent
11156 For the coding schemes other than Hex and Brackets encoding,
11157 not all wide character
11158 values can be represented.  An attempt to output a character that cannot
11159 be represented using the encoding scheme for the file causes
11160 Constraint_Error to be raised.  An invalid wide character sequence on
11161 input also causes Constraint_Error to be raised.
11163 @menu
11164 * Wide_Text_IO Stream Pointer Positioning::
11165 * Wide_Text_IO Reading and Writing Non-Regular Files::
11166 @end menu
11168 @node Wide_Text_IO Stream Pointer Positioning
11169 @subsection Stream Pointer Positioning
11171 @noindent
11172 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
11173 of stream pointer positioning (@pxref{Text_IO}).  There is one additional
11174 case:
11176 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
11177 normal lower ASCII set (i.e.@: a character in the range:
11179 @smallexample @c ada
11180 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
11181 @end smallexample
11183 @noindent
11184 then although the logical position of the file pointer is unchanged by
11185 the @code{Look_Ahead} call, the stream is physically positioned past the
11186 wide character sequence.  Again this is to avoid the need for buffering
11187 or backup, and all @code{Wide_Text_IO} routines check the internal
11188 indication that this situation has occurred so that this is not visible
11189 to a normal program using @code{Wide_Text_IO}.  However, this discrepancy
11190 can be observed if the wide text file shares a stream with another file.
11192 @node Wide_Text_IO Reading and Writing Non-Regular Files
11193 @subsection Reading and Writing Non-Regular Files
11195 @noindent
11196 As in the case of Text_IO, when a non-regular file is read, it is
11197 assumed that the file contains no page marks (any form characters are
11198 treated as data characters), and @code{End_Of_Page} always returns
11199 @code{False}.  Similarly, the end of file indication is not sticky, so
11200 it is possible to read beyond an end of file.
11202 @node Wide_Wide_Text_IO
11203 @section Wide_Wide_Text_IO
11205 @noindent
11206 @code{Wide_Wide_Text_IO} is similar in most respects to Text_IO, except that
11207 both input and output files may contain special sequences that represent
11208 wide wide character values.  The encoding scheme for a given file may be
11209 specified using a FORM parameter:
11211 @smallexample
11212 WCEM=@var{x}
11213 @end smallexample
11215 @noindent
11216 as part of the FORM string (WCEM = wide character encoding method),
11217 where @var{x} is one of the following characters
11219 @table @samp
11220 @item h
11221 Hex ESC encoding
11222 @item u
11223 Upper half encoding
11224 @item s
11225 Shift-JIS encoding
11226 @item e
11227 EUC Encoding
11228 @item 8
11229 UTF-8 encoding
11230 @item b
11231 Brackets encoding
11232 @end table
11234 @noindent
11235 The encoding methods match those that
11236 can be used in a source
11237 program, but there is no requirement that the encoding method used for
11238 the source program be the same as the encoding method used for files,
11239 and different files may use different encoding methods.
11241 The default encoding method for the standard files, and for opened files
11242 for which no WCEM parameter is given in the FORM string matches the
11243 wide character encoding specified for the main program (the default
11244 being brackets encoding if no coding method was specified with -gnatW).
11246 @table @asis
11248 @item UTF-8 Coding
11249 A wide character is represented using
11250 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
11251 10646-1/Am.2.  Depending on the character value, the representation
11252 is a one, two, three, or four byte sequence:
11254 @smallexample
11255 16#000000#-16#00007f#: 2#0xxxxxxx#
11256 16#000080#-16#0007ff#: 2#110xxxxx# 2#10xxxxxx#
11257 16#000800#-16#00ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
11258 16#010000#-16#10ffff#: 2#11110xxx# 2#10xxxxxx# 2#10xxxxxx# 2#10xxxxxx#
11259 @end smallexample
11261 @noindent
11262 where the xxx bits correspond to the left-padded bits of the
11263 21-bit character value.  Note that all lower half ASCII characters
11264 are represented as ASCII bytes and all upper half characters and
11265 other wide characters are represented as sequences of upper-half
11266 characters.
11268 @item Brackets Coding
11269 In this encoding, a wide wide character is represented by the following eight
11270 character sequence if is in wide character range
11272 @smallexample
11273 [ " a b c d " ]
11274 @end smallexample
11276 and by the following ten character sequence if not
11278 @smallexample
11279 [ " a b c d e f " ]
11280 @end smallexample
11282 @noindent
11283 where @code{a}, @code{b}, @code{c}, @code{d}, @code{e}, and @code{f}
11284 are the four or six hexadecimal
11285 characters (using uppercase letters) of the wide wide character code.  For
11286 example, @code{["01A345"]} is used to represent the wide wide character
11287 with code @code{16#01A345#}.
11289 This scheme is compatible with use of the full Wide_Wide_Character set.
11290 On input, brackets coding can also be used for upper half characters,
11291 e.g.@: @code{["C1"]} for lower case a.  However, on output, brackets notation
11292 is only used for wide characters with a code greater than @code{16#FF#}.
11294 @end table
11296 @noindent
11297 If is also possible to use the other Wide_Character encoding methods,
11298 such as Shift-JIS, but the other schemes cannot support the full range
11299 of wide wide characters.
11300 An attempt to output a character that cannot
11301 be represented using the encoding scheme for the file causes
11302 Constraint_Error to be raised.  An invalid wide character sequence on
11303 input also causes Constraint_Error to be raised.
11305 @menu
11306 * Wide_Wide_Text_IO Stream Pointer Positioning::
11307 * Wide_Wide_Text_IO Reading and Writing Non-Regular Files::
11308 @end menu
11310 @node Wide_Wide_Text_IO Stream Pointer Positioning
11311 @subsection Stream Pointer Positioning
11313 @noindent
11314 @code{Ada.Wide_Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
11315 of stream pointer positioning (@pxref{Text_IO}).  There is one additional
11316 case:
11318 If @code{Ada.Wide_Wide_Text_IO.Look_Ahead} reads a character outside the
11319 normal lower ASCII set (i.e.@: a character in the range:
11321 @smallexample @c ada
11322 Wide_Wide_Character'Val (16#0080#) .. Wide_Wide_Character'Val (16#10FFFF#)
11323 @end smallexample
11325 @noindent
11326 then although the logical position of the file pointer is unchanged by
11327 the @code{Look_Ahead} call, the stream is physically positioned past the
11328 wide character sequence.  Again this is to avoid the need for buffering
11329 or backup, and all @code{Wide_Wide_Text_IO} routines check the internal
11330 indication that this situation has occurred so that this is not visible
11331 to a normal program using @code{Wide_Wide_Text_IO}.  However, this discrepancy
11332 can be observed if the wide text file shares a stream with another file.
11334 @node Wide_Wide_Text_IO Reading and Writing Non-Regular Files
11335 @subsection Reading and Writing Non-Regular Files
11337 @noindent
11338 As in the case of Text_IO, when a non-regular file is read, it is
11339 assumed that the file contains no page marks (any form characters are
11340 treated as data characters), and @code{End_Of_Page} always returns
11341 @code{False}.  Similarly, the end of file indication is not sticky, so
11342 it is possible to read beyond an end of file.
11344 @node Stream_IO
11345 @section Stream_IO
11347 @noindent
11348 A stream file is a sequence of bytes, where individual elements are
11349 written to the file as described in the Ada 95 reference manual.  The type
11350 @code{Stream_Element} is simply a byte.  There are two ways to read or
11351 write a stream file.
11353 @itemize @bullet
11354 @item
11355 The operations @code{Read} and @code{Write} directly read or write a
11356 sequence of stream elements with no control information.
11358 @item
11359 The stream attributes applied to a stream file transfer data in the
11360 manner described for stream attributes.
11361 @end itemize
11363 @node Shared Files
11364 @section Shared Files
11366 @noindent
11367 Section A.14 of the Ada 95 Reference Manual allows implementations to
11368 provide a wide variety of behavior if an attempt is made to access the
11369 same external file with two or more internal files.
11371 To provide a full range of functionality, while at the same time
11372 minimizing the problems of portability caused by this implementation
11373 dependence, GNAT handles file sharing as follows:
11375 @itemize @bullet
11376 @item
11377 In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
11378 to open two or more files with the same full name is considered an error
11379 and is not supported.  The exception @code{Use_Error} will be
11380 raised.  Note that a file that is not explicitly closed by the program
11381 remains open until the program terminates.
11383 @item
11384 If the form parameter @samp{shared=no} appears in the form string, the
11385 file can be opened or created with its own separate stream identifier,
11386 regardless of whether other files sharing the same external file are
11387 opened.  The exact effect depends on how the C stream routines handle
11388 multiple accesses to the same external files using separate streams.
11390 @item
11391 If the form parameter @samp{shared=yes} appears in the form string for
11392 each of two or more files opened using the same full name, the same
11393 stream is shared between these files, and the semantics are as described
11394 in Ada 95 Reference Manual, Section A.14.
11395 @end itemize
11397 @noindent
11398 When a program that opens multiple files with the same name is ported
11399 from another Ada compiler to GNAT, the effect will be that
11400 @code{Use_Error} is raised.
11402 The documentation of the original compiler and the documentation of the
11403 program should then be examined to determine if file sharing was
11404 expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
11405 and @code{Create} calls as required.
11407 When a program is ported from GNAT to some other Ada compiler, no
11408 special attention is required unless the @samp{shared=@var{xxx}} form
11409 parameter is used in the program.  In this case, you must examine the
11410 documentation of the new compiler to see if it supports the required
11411 file sharing semantics, and form strings modified appropriately.  Of
11412 course it may be the case that the program cannot be ported if the
11413 target compiler does not support the required functionality.  The best
11414 approach in writing portable code is to avoid file sharing (and hence
11415 the use of the @samp{shared=@var{xxx}} parameter in the form string)
11416 completely.
11418 One common use of file sharing in Ada 83 is the use of instantiations of
11419 Sequential_IO on the same file with different types, to achieve
11420 heterogeneous input-output.  Although this approach will work in GNAT if
11421 @samp{shared=yes} is specified, it is preferable in Ada 95 to use Stream_IO
11422 for this purpose (using the stream attributes)
11424 @node Open Modes
11425 @section Open Modes
11427 @noindent
11428 @code{Open} and @code{Create} calls result in a call to @code{fopen}
11429 using the mode shown in the following table:
11431 @sp 2
11432 @center @code{Open} and @code{Create} Call Modes
11433 @smallexample
11434                                @b{OPEN }           @b{CREATE}
11435 Append_File                    "r+"             "w+"
11436 In_File                        "r"              "w+"
11437 Out_File (Direct_IO)           "r+"             "w"
11438 Out_File (all other cases)     "w"              "w"
11439 Inout_File                     "r+"             "w+"
11440 @end smallexample
11442 @noindent
11443 If text file translation is required, then either @samp{b} or @samp{t}
11444 is added to the mode, depending on the setting of Text.  Text file
11445 translation refers to the mapping of CR/LF sequences in an external file
11446 to LF characters internally.  This mapping only occurs in DOS and
11447 DOS-like systems, and is not relevant to other systems.
11449 A special case occurs with Stream_IO@.  As shown in the above table, the
11450 file is initially opened in @samp{r} or @samp{w} mode for the
11451 @code{In_File} and @code{Out_File} cases.  If a @code{Set_Mode} operation
11452 subsequently requires switching from reading to writing or vice-versa,
11453 then the file is reopened in @samp{r+} mode to permit the required operation.
11455 @node Operations on C Streams
11456 @section Operations on C Streams
11457 The package @code{Interfaces.C_Streams} provides an Ada program with direct
11458 access to the C library functions for operations on C streams:
11460 @smallexample @c adanocomment
11461 package Interfaces.C_Streams is
11462   -- Note: the reason we do not use the types that are in
11463   -- Interfaces.C is that we want to avoid dragging in the
11464   -- code in this unit if possible.
11465   subtype chars is System.Address;
11466   -- Pointer to null-terminated array of characters
11467   subtype FILEs is System.Address;
11468   -- Corresponds to the C type FILE*
11469   subtype voids is System.Address;
11470   -- Corresponds to the C type void*
11471   subtype int is Integer;
11472   subtype long is Long_Integer;
11473   -- Note: the above types are subtypes deliberately, and it
11474   -- is part of this spec that the above correspondences are
11475   -- guaranteed.  This means that it is legitimate to, for
11476   -- example, use Integer instead of int.  We provide these
11477   -- synonyms for clarity, but in some cases it may be
11478   -- convenient to use the underlying types (for example to
11479   -- avoid an unnecessary dependency of a spec on the spec
11480   -- of this unit).
11481   type size_t is mod 2 ** Standard'Address_Size;
11482   NULL_Stream : constant FILEs;
11483   -- Value returned (NULL in C) to indicate an
11484   -- fdopen/fopen/tmpfile error
11485   ----------------------------------
11486   -- Constants Defined in stdio.h --
11487   ----------------------------------
11488   EOF : constant int;
11489   -- Used by a number of routines to indicate error or
11490   -- end of file
11491   IOFBF : constant int;
11492   IOLBF : constant int;
11493   IONBF : constant int;
11494   -- Used to indicate buffering mode for setvbuf call
11495   SEEK_CUR : constant int;
11496   SEEK_END : constant int;
11497   SEEK_SET : constant int;
11498   -- Used to indicate origin for fseek call
11499   function stdin return FILEs;
11500   function stdout return FILEs;
11501   function stderr return FILEs;
11502   -- Streams associated with standard files
11503   --------------------------
11504   -- Standard C functions --
11505   --------------------------
11506   -- The functions selected below are ones that are
11507   -- available in DOS, OS/2, UNIX and Xenix (but not
11508   -- necessarily in ANSI C).  These are very thin interfaces
11509   -- which copy exactly the C headers.  For more
11510   -- documentation on these functions, see the Microsoft C
11511   -- "Run-Time Library Reference" (Microsoft Press, 1990,
11512   -- ISBN 1-55615-225-6), which includes useful information
11513   -- on system compatibility.
11514   procedure clearerr (stream : FILEs);
11515   function fclose (stream : FILEs) return int;
11516   function fdopen (handle : int; mode : chars) return FILEs;
11517   function feof (stream : FILEs) return int;
11518   function ferror (stream : FILEs) return int;
11519   function fflush (stream : FILEs) return int;
11520   function fgetc (stream : FILEs) return int;
11521   function fgets (strng : chars; n : int; stream : FILEs)
11522       return chars;
11523   function fileno (stream : FILEs) return int;
11524   function fopen (filename : chars; Mode : chars)
11525       return FILEs;
11526   -- Note: to maintain target independence, use
11527   -- text_translation_required, a boolean variable defined in
11528   -- a-sysdep.c to deal with the target dependent text
11529   -- translation requirement.  If this variable is set,
11530   -- then  b/t should be appended to the standard mode
11531   -- argument to set the text translation mode off or on
11532   -- as required.
11533   function fputc (C : int; stream : FILEs) return int;
11534   function fputs (Strng : chars; Stream : FILEs) return int;
11535   function fread
11536      (buffer : voids;
11537       size : size_t;
11538       count : size_t;
11539       stream : FILEs)
11540       return size_t;
11541   function freopen
11542      (filename : chars;
11543       mode : chars;
11544       stream : FILEs)
11545       return FILEs;
11546   function fseek
11547      (stream : FILEs;
11548       offset : long;
11549       origin : int)
11550       return int;
11551   function ftell (stream : FILEs) return long;
11552   function fwrite
11553      (buffer : voids;
11554       size : size_t;
11555       count : size_t;
11556       stream : FILEs)
11557       return size_t;
11558   function isatty (handle : int) return int;
11559   procedure mktemp (template : chars);
11560   -- The return value (which is just a pointer to template)
11561   -- is discarded
11562   procedure rewind (stream : FILEs);
11563   function rmtmp return int;
11564   function setvbuf
11565      (stream : FILEs;
11566       buffer : chars;
11567       mode : int;
11568       size : size_t)
11569       return int;
11571   function tmpfile return FILEs;
11572   function ungetc (c : int; stream : FILEs) return int;
11573   function unlink (filename : chars) return int;
11574   ---------------------
11575   -- Extra functions --
11576   ---------------------
11577   -- These functions supply slightly thicker bindings than
11578   -- those above.  They are derived from functions in the
11579   -- C Run-Time Library, but may do a bit more work than
11580   -- just directly calling one of the Library functions.
11581   function is_regular_file (handle : int) return int;
11582   -- Tests if given handle is for a regular file (result 1)
11583   -- or for a non-regular file (pipe or device, result 0).
11584   ---------------------------------
11585   -- Control of Text/Binary Mode --
11586   ---------------------------------
11587   -- If text_translation_required is true, then the following
11588   -- functions may be used to dynamically switch a file from
11589   -- binary to text mode or vice versa.  These functions have
11590   -- no effect if text_translation_required is false (i.e.  in
11591   -- normal UNIX mode).  Use fileno to get a stream handle.
11592   procedure set_binary_mode (handle : int);
11593   procedure set_text_mode (handle : int);
11594   ----------------------------
11595   -- Full Path Name support --
11596   ----------------------------
11597   procedure full_name (nam : chars; buffer : chars);
11598   -- Given a NUL terminated string representing a file
11599   -- name, returns in buffer a NUL terminated string
11600   -- representing the full path name for the file name.
11601   -- On systems where it is relevant the   drive is also
11602   -- part of the full path name.  It is the responsibility
11603   -- of the caller to pass an actual parameter for buffer
11604   -- that is big enough for any full path name.  Use
11605   -- max_path_len given below as the size of buffer.
11606   max_path_len : integer;
11607   -- Maximum length of an allowable full path name on the
11608   -- system, including a terminating NUL character.
11609 end Interfaces.C_Streams;
11610 @end smallexample
11612 @node Interfacing to C Streams
11613 @section Interfacing to C Streams
11615 @noindent
11616 The packages in this section permit interfacing Ada files to C Stream
11617 operations.
11619 @smallexample @c ada
11620  with Interfaces.C_Streams;
11621  package Ada.Sequential_IO.C_Streams is
11622     function C_Stream (F : File_Type)
11623        return Interfaces.C_Streams.FILEs;
11624     procedure Open
11625       (File : in out File_Type;
11626        Mode : in File_Mode;
11627        C_Stream : in Interfaces.C_Streams.FILEs;
11628        Form : in String := "");
11629  end Ada.Sequential_IO.C_Streams;
11631   with Interfaces.C_Streams;
11632   package Ada.Direct_IO.C_Streams is
11633      function C_Stream (F : File_Type)
11634         return Interfaces.C_Streams.FILEs;
11635      procedure Open
11636        (File : in out File_Type;
11637         Mode : in File_Mode;
11638         C_Stream : in Interfaces.C_Streams.FILEs;
11639         Form : in String := "");
11640   end Ada.Direct_IO.C_Streams;
11642   with Interfaces.C_Streams;
11643   package Ada.Text_IO.C_Streams is
11644      function C_Stream (F : File_Type)
11645         return Interfaces.C_Streams.FILEs;
11646      procedure Open
11647        (File : in out File_Type;
11648         Mode : in File_Mode;
11649         C_Stream : in Interfaces.C_Streams.FILEs;
11650         Form : in String := "");
11651   end Ada.Text_IO.C_Streams;
11653   with Interfaces.C_Streams;
11654   package Ada.Wide_Text_IO.C_Streams is
11655      function C_Stream (F : File_Type)
11656         return Interfaces.C_Streams.FILEs;
11657      procedure Open
11658        (File : in out File_Type;
11659         Mode : in File_Mode;
11660         C_Stream : in Interfaces.C_Streams.FILEs;
11661         Form : in String := "");
11662  end Ada.Wide_Text_IO.C_Streams;
11664   with Interfaces.C_Streams;
11665   package Ada.Wide_Wide_Text_IO.C_Streams is
11666      function C_Stream (F : File_Type)
11667         return Interfaces.C_Streams.FILEs;
11668      procedure Open
11669        (File : in out File_Type;
11670         Mode : in File_Mode;
11671         C_Stream : in Interfaces.C_Streams.FILEs;
11672         Form : in String := "");
11673  end Ada.Wide_Wide_Text_IO.C_Streams;
11675  with Interfaces.C_Streams;
11676  package Ada.Stream_IO.C_Streams is
11677     function C_Stream (F : File_Type)
11678        return Interfaces.C_Streams.FILEs;
11679     procedure Open
11680       (File : in out File_Type;
11681        Mode : in File_Mode;
11682        C_Stream : in Interfaces.C_Streams.FILEs;
11683        Form : in String := "");
11684  end Ada.Stream_IO.C_Streams;
11685 @end smallexample
11687 @noindent
11688 In each of these six packages, the @code{C_Stream} function obtains the
11689 @code{FILE} pointer from a currently opened Ada file.  It is then
11690 possible to use the @code{Interfaces.C_Streams} package to operate on
11691 this stream, or the stream can be passed to a C program which can
11692 operate on it directly.  Of course the program is responsible for
11693 ensuring that only appropriate sequences of operations are executed.
11695 One particular use of relevance to an Ada program is that the
11696 @code{setvbuf} function can be used to control the buffering of the
11697 stream used by an Ada file.  In the absence of such a call the standard
11698 default buffering is used.
11700 The @code{Open} procedures in these packages open a file giving an
11701 existing C Stream instead of a file name.  Typically this stream is
11702 imported from a C program, allowing an Ada file to operate on an
11703 existing C file.
11705 @node The GNAT Library
11706 @chapter The GNAT Library
11708 @noindent
11709 The GNAT library contains a number of general and special purpose packages.
11710 It represents functionality that the GNAT developers have found useful, and
11711 which is made available to GNAT users.  The packages described here are fully
11712 supported, and upwards compatibility will be maintained in future releases,
11713 so you can use these facilities with the confidence that the same functionality
11714 will be available in future releases.
11716 The chapter here simply gives a brief summary of the facilities available.
11717 The full documentation is found in the spec file for the package.  The full
11718 sources of these library packages, including both spec and body, are provided
11719 with all GNAT releases.  For example, to find out the full specifications of
11720 the SPITBOL pattern matching capability, including a full tutorial and
11721 extensive examples, look in the @file{g-spipat.ads} file in the library.
11723 For each entry here, the package name (as it would appear in a @code{with}
11724 clause) is given, followed by the name of the corresponding spec file in
11725 parentheses.  The packages are children in four hierarchies, @code{Ada},
11726 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
11727 GNAT-specific hierarchy.
11729 Note that an application program should only use packages in one of these
11730 four hierarchies if the package is defined in the Ada Reference Manual,
11731 or is listed in this section of the GNAT Programmers Reference Manual.
11732 All other units should be considered internal implementation units and
11733 should not be directly @code{with}'ed by application code.  The use of
11734 a @code{with} statement that references one of these internal implementation
11735 units makes an application potentially dependent on changes in versions
11736 of GNAT, and will generate a warning message.
11738 @menu
11739 * Ada.Characters.Latin_9 (a-chlat9.ads)::
11740 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
11741 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
11742 * Ada.Characters.Wide_Wide_Latin_1 (a-czila1.ads)::
11743 * Ada.Characters.Wide_Wide_Latin_9 (a-czila9.ads)::
11744 * Ada.Command_Line.Remove (a-colire.ads)::
11745 * Ada.Command_Line.Environment (a-colien.ads)::
11746 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
11747 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
11748 * Ada.Exceptions.Traceback (a-exctra.ads)::
11749 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
11750 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
11751 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
11752 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
11753 * Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)::
11754 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
11755 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
11756 * Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)::
11757 * GNAT.Array_Split (g-arrspl.ads)::
11758 * GNAT.AWK (g-awk.ads)::
11759 * GNAT.Bounded_Buffers (g-boubuf.ads)::
11760 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
11761 * GNAT.Bubble_Sort (g-bubsor.ads)::
11762 * GNAT.Bubble_Sort_A (g-busora.ads)::
11763 * GNAT.Bubble_Sort_G (g-busorg.ads)::
11764 * GNAT.Calendar (g-calend.ads)::
11765 * GNAT.Calendar.Time_IO (g-catiio.ads)::
11766 * GNAT.CRC32 (g-crc32.ads)::
11767 * GNAT.Case_Util (g-casuti.ads)::
11768 * GNAT.CGI (g-cgi.ads)::
11769 * GNAT.CGI.Cookie (g-cgicoo.ads)::
11770 * GNAT.CGI.Debug (g-cgideb.ads)::
11771 * GNAT.Command_Line (g-comlin.ads)::
11772 * GNAT.Compiler_Version (g-comver.ads)::
11773 * GNAT.Ctrl_C (g-ctrl_c.ads)::
11774 * GNAT.Current_Exception (g-curexc.ads)::
11775 * GNAT.Debug_Pools (g-debpoo.ads)::
11776 * GNAT.Debug_Utilities (g-debuti.ads)::
11777 * GNAT.Directory_Operations (g-dirope.ads)::
11778 * GNAT.Dynamic_HTables (g-dynhta.ads)::
11779 * GNAT.Dynamic_Tables (g-dyntab.ads)::
11780 * GNAT.Exception_Actions (g-excact.ads)::
11781 * GNAT.Exception_Traces (g-exctra.ads)::
11782 * GNAT.Exceptions (g-except.ads)::
11783 * GNAT.Expect (g-expect.ads)::
11784 * GNAT.Float_Control (g-flocon.ads)::
11785 * GNAT.Heap_Sort (g-heasor.ads)::
11786 * GNAT.Heap_Sort_A (g-hesora.ads)::
11787 * GNAT.Heap_Sort_G (g-hesorg.ads)::
11788 * GNAT.HTable (g-htable.ads)::
11789 * GNAT.IO (g-io.ads)::
11790 * GNAT.IO_Aux (g-io_aux.ads)::
11791 * GNAT.Lock_Files (g-locfil.ads)::
11792 * GNAT.MD5 (g-md5.ads)::
11793 * GNAT.Memory_Dump (g-memdum.ads)::
11794 * GNAT.Most_Recent_Exception (g-moreex.ads)::
11795 * GNAT.OS_Lib (g-os_lib.ads)::
11796 * GNAT.Perfect_Hash_Generators (g-pehage.ads)::
11797 * GNAT.Regexp (g-regexp.ads)::
11798 * GNAT.Registry (g-regist.ads)::
11799 * GNAT.Regpat (g-regpat.ads)::
11800 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
11801 * GNAT.Semaphores (g-semaph.ads)::
11802 * GNAT.Signals (g-signal.ads)::
11803 * GNAT.Sockets (g-socket.ads)::
11804 * GNAT.Source_Info (g-souinf.ads)::
11805 * GNAT.Spell_Checker (g-speche.ads)::
11806 * GNAT.Spitbol.Patterns (g-spipat.ads)::
11807 * GNAT.Spitbol (g-spitbo.ads)::
11808 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
11809 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
11810 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
11811 * GNAT.Strings (g-string.ads)::
11812 * GNAT.String_Split (g-strspl.ads)::
11813 * GNAT.Table (g-table.ads)::
11814 * GNAT.Task_Lock (g-tasloc.ads)::
11815 * GNAT.Threads (g-thread.ads)::
11816 * GNAT.Traceback (g-traceb.ads)::
11817 * GNAT.Traceback.Symbolic (g-trasym.ads)::
11818 * GNAT.Wide_String_Split (g-wistsp.ads)::
11819 * GNAT.Wide_Wide_String_Split (g-zistsp.ads)::
11820 * Interfaces.C.Extensions (i-cexten.ads)::
11821 * Interfaces.C.Streams (i-cstrea.ads)::
11822 * Interfaces.CPP (i-cpp.ads)::
11823 * Interfaces.Os2lib (i-os2lib.ads)::
11824 * Interfaces.Os2lib.Errors (i-os2err.ads)::
11825 * Interfaces.Os2lib.Synchronization (i-os2syn.ads)::
11826 * Interfaces.Os2lib.Threads (i-os2thr.ads)::
11827 * Interfaces.Packed_Decimal (i-pacdec.ads)::
11828 * Interfaces.VxWorks (i-vxwork.ads)::
11829 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
11830 * System.Address_Image (s-addima.ads)::
11831 * System.Assertions (s-assert.ads)::
11832 * System.Memory (s-memory.ads)::
11833 * System.Partition_Interface (s-parint.ads)::
11834 * System.Restrictions (s-restri.ads)::
11835 * System.Rident (s-rident.ads)::
11836 * System.Task_Info (s-tasinf.ads)::
11837 * System.Wch_Cnv (s-wchcnv.ads)::
11838 * System.Wch_Con (s-wchcon.ads)::
11839 @end menu
11841 @node Ada.Characters.Latin_9 (a-chlat9.ads)
11842 @section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
11843 @cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
11844 @cindex Latin_9 constants for Character
11846 @noindent
11847 This child of @code{Ada.Characters}
11848 provides a set of definitions corresponding to those in the
11849 RM-defined package @code{Ada.Characters.Latin_1} but with the
11850 few modifications required for @code{Latin-9}
11851 The provision of such a package
11852 is specifically authorized by the Ada Reference Manual
11853 (RM A.3(27)).
11855 @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
11856 @section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
11857 @cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
11858 @cindex Latin_1 constants for Wide_Character
11860 @noindent
11861 This child of @code{Ada.Characters}
11862 provides a set of definitions corresponding to those in the
11863 RM-defined package @code{Ada.Characters.Latin_1} but with the
11864 types of the constants being @code{Wide_Character}
11865 instead of @code{Character}.  The provision of such a package
11866 is specifically authorized by the Ada Reference Manual
11867 (RM A.3(27)).
11869 @node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
11870 @section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
11871 @cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
11872 @cindex Latin_9 constants for Wide_Character
11874 @noindent
11875 This child of @code{Ada.Characters}
11876 provides a set of definitions corresponding to those in the
11877 GNAT defined package @code{Ada.Characters.Latin_9} but with the
11878 types of the constants being @code{Wide_Character}
11879 instead of @code{Character}.  The provision of such a package
11880 is specifically authorized by the Ada Reference Manual
11881 (RM A.3(27)).
11883 @node Ada.Characters.Wide_Wide_Latin_1 (a-czila1.ads)
11884 @section @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-czila1.ads})
11885 @cindex @code{Ada.Characters.Wide_Wide_Latin_1} (@file{a-czila1.ads})
11886 @cindex Latin_1 constants for Wide_Wide_Character
11888 @noindent
11889 This child of @code{Ada.Characters}
11890 provides a set of definitions corresponding to those in the
11891 RM-defined package @code{Ada.Characters.Latin_1} but with the
11892 types of the constants being @code{Wide_Wide_Character}
11893 instead of @code{Character}.  The provision of such a package
11894 is specifically authorized by the Ada Reference Manual
11895 (RM A.3(27)).
11897 @node Ada.Characters.Wide_Wide_Latin_9 (a-czila9.ads)
11898 @section @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-czila9.ads})
11899 @cindex @code{Ada.Characters.Wide_Wide_Latin_9} (@file{a-czila9.ads})
11900 @cindex Latin_9 constants for Wide_Wide_Character
11902 @noindent
11903 This child of @code{Ada.Characters}
11904 provides a set of definitions corresponding to those in the
11905 GNAT defined package @code{Ada.Characters.Latin_9} but with the
11906 types of the constants being @code{Wide_Wide_Character}
11907 instead of @code{Character}.  The provision of such a package
11908 is specifically authorized by the Ada Reference Manual
11909 (RM A.3(27)).
11911 @node Ada.Command_Line.Remove (a-colire.ads)
11912 @section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
11913 @cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
11914 @cindex Removing command line arguments
11915 @cindex Command line, argument removal
11917 @noindent
11918 This child of @code{Ada.Command_Line}
11919 provides a mechanism for logically removing
11920 arguments from the argument list.  Once removed, an argument is not visible
11921 to further calls on the subprograms in @code{Ada.Command_Line} will not
11922 see the removed argument.
11924 @node Ada.Command_Line.Environment (a-colien.ads)
11925 @section @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
11926 @cindex @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
11927 @cindex Environment entries
11929 @noindent
11930 This child of @code{Ada.Command_Line}
11931 provides a mechanism for obtaining environment values on systems
11932 where this concept makes sense.
11934 @node Ada.Direct_IO.C_Streams (a-diocst.ads)
11935 @section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
11936 @cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
11937 @cindex C Streams, Interfacing with Direct_IO
11939 @noindent
11940 This package provides subprograms that allow interfacing between
11941 C streams and @code{Direct_IO}.  The stream identifier can be
11942 extracted from a file opened on the Ada side, and an Ada file
11943 can be constructed from a stream opened on the C side.
11945 @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
11946 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
11947 @cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
11948 @cindex Null_Occurrence, testing for
11950 @noindent
11951 This child subprogram provides a way of testing for the null
11952 exception occurrence (@code{Null_Occurrence}) without raising
11953 an exception.
11955 @node Ada.Exceptions.Traceback (a-exctra.ads)
11956 @section @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
11957 @cindex @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
11958 @cindex Traceback for Exception Occurrence
11960 @noindent
11961 This child package provides the subprogram (@code{Tracebacks}) to
11962 give a traceback array of addresses based on an exception
11963 occurrence.
11965 @node Ada.Sequential_IO.C_Streams (a-siocst.ads)
11966 @section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
11967 @cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
11968 @cindex C Streams, Interfacing with Sequential_IO
11970 @noindent
11971 This package provides subprograms that allow interfacing between
11972 C streams and @code{Sequential_IO}.  The stream identifier can be
11973 extracted from a file opened on the Ada side, and an Ada file
11974 can be constructed from a stream opened on the C side.
11976 @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
11977 @section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
11978 @cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
11979 @cindex C Streams, Interfacing with Stream_IO
11981 @noindent
11982 This package provides subprograms that allow interfacing between
11983 C streams and @code{Stream_IO}.  The stream identifier can be
11984 extracted from a file opened on the Ada side, and an Ada file
11985 can be constructed from a stream opened on the C side.
11987 @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
11988 @section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
11989 @cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
11990 @cindex @code{Unbounded_String}, IO support
11991 @cindex @code{Text_IO}, extensions for unbounded strings
11993 @noindent
11994 This package provides subprograms for Text_IO for unbounded
11995 strings, avoiding the necessity for an intermediate operation
11996 with ordinary strings.
11998 @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
11999 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
12000 @cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
12001 @cindex @code{Unbounded_Wide_String}, IO support
12002 @cindex @code{Text_IO}, extensions for unbounded wide strings
12004 @noindent
12005 This package provides subprograms for Text_IO for unbounded
12006 wide strings, avoiding the necessity for an intermediate operation
12007 with ordinary wide strings.
12009 @node Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO (a-szuzti.ads)
12010 @section @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
12011 @cindex @code{Ada.Strings.Wide_Wide_Unbounded.Wide_Wide_Text_IO} (@file{a-szuzti.ads})
12012 @cindex @code{Unbounded_Wide_Wide_String}, IO support
12013 @cindex @code{Text_IO}, extensions for unbounded wide wide strings
12015 @noindent
12016 This package provides subprograms for Text_IO for unbounded
12017 wide wide strings, avoiding the necessity for an intermediate operation
12018 with ordinary wide wide strings.
12020 @node Ada.Text_IO.C_Streams (a-tiocst.ads)
12021 @section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
12022 @cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
12023 @cindex C Streams, Interfacing with @code{Text_IO}
12025 @noindent
12026 This package provides subprograms that allow interfacing between
12027 C streams and @code{Text_IO}.  The stream identifier can be
12028 extracted from a file opened on the Ada side, and an Ada file
12029 can be constructed from a stream opened on the C side.
12031 @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
12032 @section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
12033 @cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
12034 @cindex C Streams, Interfacing with @code{Wide_Text_IO}
12036 @noindent
12037 This package provides subprograms that allow interfacing between
12038 C streams and @code{Wide_Text_IO}.  The stream identifier can be
12039 extracted from a file opened on the Ada side, and an Ada file
12040 can be constructed from a stream opened on the C side.
12042 @node Ada.Wide_Wide_Text_IO.C_Streams (a-ztcstr.ads)
12043 @section @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
12044 @cindex @code{Ada.Wide_Wide_Text_IO.C_Streams} (@file{a-ztcstr.ads})
12045 @cindex C Streams, Interfacing with @code{Wide_Wide_Text_IO}
12047 @noindent
12048 This package provides subprograms that allow interfacing between
12049 C streams and @code{Wide_Wide_Text_IO}.  The stream identifier can be
12050 extracted from a file opened on the Ada side, and an Ada file
12051 can be constructed from a stream opened on the C side.
12054 @node GNAT.Array_Split (g-arrspl.ads)
12055 @section @code{GNAT.Array_Split} (@file{g-arrspl.ads})
12056 @cindex @code{GNAT.Array_Split} (@file{g-arrspl.ads})
12057 @cindex Array splitter
12059 @noindent
12060 Useful array-manipulation routines: given a set of separators, split
12061 an array wherever the separators appear, and provide direct access
12062 to the resulting slices.
12064 @node GNAT.AWK (g-awk.ads)
12065 @section @code{GNAT.AWK} (@file{g-awk.ads})
12066 @cindex @code{GNAT.AWK} (@file{g-awk.ads})
12067 @cindex Parsing
12068 @cindex AWK
12070 @noindent
12071 Provides AWK-like parsing functions, with an easy interface for parsing one
12072 or more files containing formatted data.  The file is viewed as a database
12073 where each record is a line and a field is a data element in this line.
12075 @node GNAT.Bounded_Buffers (g-boubuf.ads)
12076 @section @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
12077 @cindex @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
12078 @cindex Parsing
12079 @cindex Bounded Buffers
12081 @noindent
12082 Provides a concurrent generic bounded buffer abstraction.  Instances are
12083 useful directly or as parts of the implementations of other abstractions,
12084 such as mailboxes.
12086 @node GNAT.Bounded_Mailboxes (g-boumai.ads)
12087 @section @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
12088 @cindex @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
12089 @cindex Parsing
12090 @cindex Mailboxes
12092 @noindent
12093 Provides a thread-safe asynchronous intertask mailbox communication facility.
12095 @node GNAT.Bubble_Sort (g-bubsor.ads)
12096 @section @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
12097 @cindex @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
12098 @cindex Sorting
12099 @cindex Bubble sort
12101 @noindent
12102 Provides a general implementation of bubble sort usable for sorting arbitrary
12103 data items.  Exchange and comparison procedures are provided by passing
12104 access-to-procedure values.
12106 @node GNAT.Bubble_Sort_A (g-busora.ads)
12107 @section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
12108 @cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
12109 @cindex Sorting
12110 @cindex Bubble sort
12112 @noindent
12113 Provides a general implementation of bubble sort usable for sorting arbitrary
12114 data items.  Move and comparison procedures are provided by passing
12115 access-to-procedure values. This is an older version, retained for
12116 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
12118 @node GNAT.Bubble_Sort_G (g-busorg.ads)
12119 @section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
12120 @cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
12121 @cindex Sorting
12122 @cindex Bubble sort
12124 @noindent
12125 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
12126 are provided as generic parameters, this improves efficiency, especially
12127 if the procedures can be inlined, at the expense of duplicating code for
12128 multiple instantiations.
12130 @node GNAT.Calendar (g-calend.ads)
12131 @section @code{GNAT.Calendar} (@file{g-calend.ads})
12132 @cindex @code{GNAT.Calendar} (@file{g-calend.ads})
12133 @cindex @code{Calendar}
12135 @noindent
12136 Extends the facilities provided by @code{Ada.Calendar} to include handling
12137 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
12138 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
12139 C @code{timeval} format.
12141 @node GNAT.Calendar.Time_IO (g-catiio.ads)
12142 @section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
12143 @cindex @code{Calendar}
12144 @cindex Time
12145 @cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
12147 @node GNAT.CRC32 (g-crc32.ads)
12148 @section @code{GNAT.CRC32} (@file{g-crc32.ads})
12149 @cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
12150 @cindex CRC32
12151 @cindex Cyclic Redundancy Check
12153 @noindent
12154 This package implements the CRC-32 algorithm.  For a full description
12155 of this algorithm see
12156 ``Computation of Cyclic Redundancy Checks via Table Look-Up'',
12157 @cite{Communications of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013,
12158 Aug.@: 1988.  Sarwate, D.V@.
12160 @noindent
12161 Provides an extended capability for formatted output of time values with
12162 full user control over the format.  Modeled on the GNU Date specification.
12164 @node GNAT.Case_Util (g-casuti.ads)
12165 @section @code{GNAT.Case_Util} (@file{g-casuti.ads})
12166 @cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
12167 @cindex Casing utilities
12168 @cindex Character handling (@code{GNAT.Case_Util})
12170 @noindent
12171 A set of simple routines for handling upper and lower casing of strings
12172 without the overhead of the full casing tables
12173 in @code{Ada.Characters.Handling}.
12175 @node GNAT.CGI (g-cgi.ads)
12176 @section @code{GNAT.CGI} (@file{g-cgi.ads})
12177 @cindex @code{GNAT.CGI} (@file{g-cgi.ads})
12178 @cindex CGI (Common Gateway Interface)
12180 @noindent
12181 This is a package for interfacing a GNAT program with a Web server via the
12182 Common Gateway Interface (CGI)@.  Basically this package parses the CGI
12183 parameters, which are a set of key/value pairs sent by the Web server.  It
12184 builds a table whose index is the key and provides some services to deal
12185 with this table.
12187 @node GNAT.CGI.Cookie (g-cgicoo.ads)
12188 @section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
12189 @cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
12190 @cindex CGI (Common Gateway Interface) cookie support
12191 @cindex Cookie support in CGI
12193 @noindent
12194 This is a package to interface a GNAT program with a Web server via the
12195 Common Gateway Interface (CGI).  It exports services to deal with Web
12196 cookies (piece of information kept in the Web client software).
12198 @node GNAT.CGI.Debug (g-cgideb.ads)
12199 @section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
12200 @cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
12201 @cindex CGI (Common Gateway Interface) debugging
12203 @noindent
12204 This is a package to help debugging CGI (Common Gateway Interface)
12205 programs written in Ada.
12207 @node GNAT.Command_Line (g-comlin.ads)
12208 @section @code{GNAT.Command_Line} (@file{g-comlin.ads})
12209 @cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
12210 @cindex Command line
12212 @noindent
12213 Provides a high level interface to @code{Ada.Command_Line} facilities,
12214 including the ability to scan for named switches with optional parameters
12215 and expand file names using wild card notations.
12217 @node GNAT.Compiler_Version (g-comver.ads)
12218 @section @code{GNAT.Compiler_Version} (@file{g-comver.ads})
12219 @cindex @code{GNAT.Compiler_Version} (@file{g-comver.ads})
12220 @cindex Compiler Version
12221 @cindex Version, of compiler
12223 @noindent
12224 Provides a routine for obtaining the version of the compiler used to
12225 compile the program. More accurately this is the version of the binder
12226 used to bind the program (this will normally be the same as the version
12227 of the compiler if a consistent tool set is used to compile all units
12228 of a partition).
12230 @node GNAT.Ctrl_C (g-ctrl_c.ads)
12231 @section @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
12232 @cindex @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
12233 @cindex Interrupt
12235 @noindent
12236 Provides a simple interface to handle Ctrl-C keyboard events.
12238 @node GNAT.Current_Exception (g-curexc.ads)
12239 @section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
12240 @cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
12241 @cindex Current exception
12242 @cindex Exception retrieval
12244 @noindent
12245 Provides access to information on the current exception that has been raised
12246 without the need for using the Ada-95 exception choice parameter specification
12247 syntax.  This is particularly useful in simulating typical facilities for
12248 obtaining information about exceptions provided by Ada 83 compilers.
12250 @node GNAT.Debug_Pools (g-debpoo.ads)
12251 @section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
12252 @cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
12253 @cindex Debugging
12254 @cindex Debug pools
12255 @cindex Memory corruption debugging
12257 @noindent
12258 Provide a debugging storage pools that helps tracking memory corruption
12259 problems.  See section ``Finding memory problems with GNAT Debug Pool'' in
12260 the @cite{GNAT User's Guide}.
12262 @node GNAT.Debug_Utilities (g-debuti.ads)
12263 @section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
12264 @cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
12265 @cindex Debugging
12267 @noindent
12268 Provides a few useful utilities for debugging purposes, including conversion
12269 to and from string images of address values. Supports both C and Ada formats
12270 for hexadecimal literals.
12272 @node GNAT.Directory_Operations (g-dirope.ads)
12273 @section @code{GNAT.Directory_Operations} (g-dirope.ads)
12274 @cindex @code{GNAT.Directory_Operations} (g-dirope.ads)
12275 @cindex Directory operations
12277 @noindent
12278 Provides a set of routines for manipulating directories, including changing
12279 the current directory, making new directories, and scanning the files in a
12280 directory.
12282 @node GNAT.Dynamic_HTables (g-dynhta.ads)
12283 @section @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
12284 @cindex @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
12285 @cindex Hash tables
12287 @noindent
12288 A generic implementation of hash tables that can be used to hash arbitrary
12289 data.  Provided in two forms, a simple form with built in hash functions,
12290 and a more complex form in which the hash function is supplied.
12292 @noindent
12293 This package provides a facility similar to that of @code{GNAT.HTable},
12294 except that this package declares a type that can be used to define
12295 dynamic instances of the hash table, while an instantiation of
12296 @code{GNAT.HTable} creates a single instance of the hash table.
12298 @node GNAT.Dynamic_Tables (g-dyntab.ads)
12299 @section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
12300 @cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
12301 @cindex Table implementation
12302 @cindex Arrays, extendable
12304 @noindent
12305 A generic package providing a single dimension array abstraction where the
12306 length of the array can be dynamically modified.
12308 @noindent
12309 This package provides a facility similar to that of @code{GNAT.Table},
12310 except that this package declares a type that can be used to define
12311 dynamic instances of the table, while an instantiation of
12312 @code{GNAT.Table} creates a single instance of the table type.
12314 @node GNAT.Exception_Actions (g-excact.ads)
12315 @section @code{GNAT.Exception_Actions} (@file{g-excact.ads})
12316 @cindex @code{GNAT.Exception_Actions} (@file{g-excact.ads})
12317 @cindex Exception actions
12319 @noindent
12320 Provides callbacks when an exception is raised. Callbacks can be registered
12321 for specific exceptions, or when any exception is raised. This
12322 can be used for instance to force a core dump to ease debugging.
12324 @node GNAT.Exception_Traces (g-exctra.ads)
12325 @section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
12326 @cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
12327 @cindex Exception traces
12328 @cindex Debugging
12330 @noindent
12331 Provides an interface allowing to control automatic output upon exception
12332 occurrences.
12334 @node GNAT.Exceptions (g-except.ads)
12335 @section @code{GNAT.Exceptions} (@file{g-expect.ads})
12336 @cindex @code{GNAT.Exceptions} (@file{g-expect.ads})
12337 @cindex Exceptions, Pure
12338 @cindex Pure packages, exceptions
12340 @noindent
12341 Normally it is not possible to raise an exception with
12342 a message from a subprogram in a pure package, since the
12343 necessary types and subprograms are in @code{Ada.Exceptions}
12344 which is not a pure unit. @code{GNAT.Exceptions} provides a
12345 facility for getting around this limitation for a few
12346 predefined exceptions, and for example allow raising
12347 @code{Constraint_Error} with a message from a pure subprogram.
12349 @node GNAT.Expect (g-expect.ads)
12350 @section @code{GNAT.Expect} (@file{g-expect.ads})
12351 @cindex @code{GNAT.Expect} (@file{g-expect.ads})
12353 @noindent
12354 Provides a set of subprograms similar to what is available
12355 with the standard Tcl Expect tool.
12356 It allows you to easily spawn and communicate with an external process.
12357 You can send commands or inputs to the process, and compare the output
12358 with some expected regular expression. Currently @code{GNAT.Expect}
12359 is implemented on all native GNAT ports except for OpenVMS@.
12360 It is not implemented for cross ports, and in particular is not
12361 implemented for VxWorks or LynxOS@.
12363 @node GNAT.Float_Control (g-flocon.ads)
12364 @section @code{GNAT.Float_Control} (@file{g-flocon.ads})
12365 @cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
12366 @cindex Floating-Point Processor
12368 @noindent
12369 Provides an interface for resetting the floating-point processor into the
12370 mode required for correct semantic operation in Ada.  Some third party
12371 library calls may cause this mode to be modified, and the Reset procedure
12372 in this package can be used to reestablish the required mode.
12374 @node GNAT.Heap_Sort (g-heasor.ads)
12375 @section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
12376 @cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
12377 @cindex Sorting
12379 @noindent
12380 Provides a general implementation of heap sort usable for sorting arbitrary
12381 data items. Exchange and comparison procedures are provided by passing
12382 access-to-procedure values.  The algorithm used is a modified heap sort
12383 that performs approximately N*log(N) comparisons in the worst case.
12385 @node GNAT.Heap_Sort_A (g-hesora.ads)
12386 @section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
12387 @cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
12388 @cindex Sorting
12390 @noindent
12391 Provides a general implementation of heap sort usable for sorting arbitrary
12392 data items. Move and comparison procedures are provided by passing
12393 access-to-procedure values.  The algorithm used is a modified heap sort
12394 that performs approximately N*log(N) comparisons in the worst case.
12395 This differs from @code{GNAT.Heap_Sort} in having a less convenient
12396 interface, but may be slightly more efficient.
12398 @node GNAT.Heap_Sort_G (g-hesorg.ads)
12399 @section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
12400 @cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
12401 @cindex Sorting
12403 @noindent
12404 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
12405 are provided as generic parameters, this improves efficiency, especially
12406 if the procedures can be inlined, at the expense of duplicating code for
12407 multiple instantiations.
12409 @node GNAT.HTable (g-htable.ads)
12410 @section @code{GNAT.HTable} (@file{g-htable.ads})
12411 @cindex @code{GNAT.HTable} (@file{g-htable.ads})
12412 @cindex Hash tables
12414 @noindent
12415 A generic implementation of hash tables that can be used to hash arbitrary
12416 data.  Provides two approaches, one a simple static approach, and the other
12417 allowing arbitrary dynamic hash tables.
12419 @node GNAT.IO (g-io.ads)
12420 @section @code{GNAT.IO} (@file{g-io.ads})
12421 @cindex @code{GNAT.IO} (@file{g-io.ads})
12422 @cindex Simple I/O
12423 @cindex Input/Output facilities
12425 @noindent
12426 A simple preelaborable input-output package that provides a subset of
12427 simple Text_IO functions for reading characters and strings from
12428 Standard_Input, and writing characters, strings and integers to either
12429 Standard_Output or Standard_Error.
12431 @node GNAT.IO_Aux (g-io_aux.ads)
12432 @section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
12433 @cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
12434 @cindex Text_IO
12435 @cindex Input/Output facilities
12437 Provides some auxiliary functions for use with Text_IO, including a test
12438 for whether a file exists, and functions for reading a line of text.
12440 @node GNAT.Lock_Files (g-locfil.ads)
12441 @section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
12442 @cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
12443 @cindex File locking
12444 @cindex Locking using files
12446 @noindent
12447 Provides a general interface for using files as locks.  Can be used for
12448 providing program level synchronization.
12450 @node GNAT.MD5 (g-md5.ads)
12451 @section @code{GNAT.MD5} (@file{g-md5.ads})
12452 @cindex @code{GNAT.MD5} (@file{g-md5.ads})
12453 @cindex Message Digest MD5
12455 @noindent
12456 Implements the MD5 Message-Digest Algorithm as described in RFC 1321.
12458 @node GNAT.Memory_Dump (g-memdum.ads)
12459 @section @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
12460 @cindex @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
12461 @cindex Dump Memory
12463 @noindent
12464 Provides a convenient routine for dumping raw memory to either the
12465 standard output or standard error files. Uses GNAT.IO for actual
12466 output.
12468 @node GNAT.Most_Recent_Exception (g-moreex.ads)
12469 @section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
12470 @cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
12471 @cindex Exception, obtaining most recent
12473 @noindent
12474 Provides access to the most recently raised exception.  Can be used for
12475 various logging purposes, including duplicating functionality of some
12476 Ada 83 implementation dependent extensions.
12478 @node GNAT.OS_Lib (g-os_lib.ads)
12479 @section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
12480 @cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
12481 @cindex Operating System interface
12482 @cindex Spawn capability
12484 @noindent
12485 Provides a range of target independent operating system interface functions,
12486 including time/date management, file operations, subprocess management,
12487 including a portable spawn procedure, and access to environment variables
12488 and error return codes.
12490 @node GNAT.Perfect_Hash_Generators (g-pehage.ads)
12491 @section @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
12492 @cindex @code{GNAT.Perfect_Hash_Generators} (@file{g-pehage.ads})
12493 @cindex Hash functions
12495 @noindent
12496 Provides a generator of static minimal perfect hash functions. No
12497 collisions occur and each item can be retrieved from the table in one
12498 probe (perfect property). The hash table size corresponds to the exact
12499 size of the key set and no larger (minimal property). The key set has to
12500 be know in advance (static property). The hash functions are also order
12501 preservering. If w2 is inserted after w1 in the generator, their
12502 hashcode are in the same order. These hashing functions are very
12503 convenient for use with realtime applications.
12505 @node GNAT.Regexp (g-regexp.ads)
12506 @section @code{GNAT.Regexp} (@file{g-regexp.ads})
12507 @cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
12508 @cindex Regular expressions
12509 @cindex Pattern matching
12511 @noindent
12512 A simple implementation of regular expressions, using a subset of regular
12513 expression syntax copied from familiar Unix style utilities.  This is the
12514 simples of the three pattern matching packages provided, and is particularly
12515 suitable for ``file globbing'' applications.
12517 @node GNAT.Registry (g-regist.ads)
12518 @section @code{GNAT.Registry} (@file{g-regist.ads})
12519 @cindex @code{GNAT.Registry} (@file{g-regist.ads})
12520 @cindex Windows Registry
12522 @noindent
12523 This is a high level binding to the Windows registry.  It is possible to
12524 do simple things like reading a key value, creating a new key.  For full
12525 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
12526 package provided with the Win32Ada binding
12528 @node GNAT.Regpat (g-regpat.ads)
12529 @section @code{GNAT.Regpat} (@file{g-regpat.ads})
12530 @cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
12531 @cindex Regular expressions
12532 @cindex Pattern matching
12534 @noindent
12535 A complete implementation of Unix-style regular expression matching, copied
12536 from the original V7 style regular expression library written in C by
12537 Henry Spencer (and binary compatible with this C library).
12539 @node GNAT.Secondary_Stack_Info (g-sestin.ads)
12540 @section @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
12541 @cindex @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
12542 @cindex Secondary Stack Info
12544 @noindent
12545 Provide the capability to query the high water mark of the current task's
12546 secondary stack.
12548 @node GNAT.Semaphores (g-semaph.ads)
12549 @section @code{GNAT.Semaphores} (@file{g-semaph.ads})
12550 @cindex @code{GNAT.Semaphores} (@file{g-semaph.ads})
12551 @cindex Semaphores
12553 @noindent
12554 Provides classic counting and binary semaphores using protected types.
12556 @node GNAT.Signals (g-signal.ads)
12557 @section @code{GNAT.Signals} (@file{g-signal.ads})
12558 @cindex @code{GNAT.Signals} (@file{g-signal.ads})
12559 @cindex Signals
12561 @noindent
12562 Provides the ability to manipulate the blocked status of signals on supported
12563 targets.
12565 @node GNAT.Sockets (g-socket.ads)
12566 @section @code{GNAT.Sockets} (@file{g-socket.ads})
12567 @cindex @code{GNAT.Sockets} (@file{g-socket.ads})
12568 @cindex Sockets
12570 @noindent
12571 A high level and portable interface to develop sockets based applications.
12572 This package is based on the sockets thin binding found in
12573 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
12574 on all native GNAT ports except for OpenVMS@.  It is not implemented
12575 for the LynxOS@ cross port.
12577 @node GNAT.Source_Info (g-souinf.ads)
12578 @section @code{GNAT.Source_Info} (@file{g-souinf.ads})
12579 @cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
12580 @cindex Source Information
12582 @noindent
12583 Provides subprograms that give access to source code information known at
12584 compile time, such as the current file name and line number.
12586 @node GNAT.Spell_Checker (g-speche.ads)
12587 @section @code{GNAT.Spell_Checker} (@file{g-speche.ads})
12588 @cindex @code{GNAT.Spell_Checker} (@file{g-speche.ads})
12589 @cindex Spell checking
12591 @noindent
12592 Provides a function for determining whether one string is a plausible
12593 near misspelling of another string.
12595 @node GNAT.Spitbol.Patterns (g-spipat.ads)
12596 @section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
12597 @cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
12598 @cindex SPITBOL pattern matching
12599 @cindex Pattern matching
12601 @noindent
12602 A complete implementation of SNOBOL4 style pattern matching.  This is the
12603 most elaborate of the pattern matching packages provided.  It fully duplicates
12604 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
12605 efficient algorithm developed by Robert Dewar for the SPITBOL system.
12607 @node GNAT.Spitbol (g-spitbo.ads)
12608 @section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
12609 @cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
12610 @cindex SPITBOL interface
12612 @noindent
12613 The top level package of the collection of SPITBOL-style functionality, this
12614 package provides basic SNOBOL4 string manipulation functions, such as
12615 Pad, Reverse, Trim, Substr capability, as well as a generic table function
12616 useful for constructing arbitrary mappings from strings in the style of
12617 the SNOBOL4 TABLE function.
12619 @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
12620 @section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
12621 @cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
12622 @cindex Sets of strings
12623 @cindex SPITBOL Tables
12625 @noindent
12626 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
12627 for type @code{Standard.Boolean}, giving an implementation of sets of
12628 string values.
12630 @node GNAT.Spitbol.Table_Integer (g-sptain.ads)
12631 @section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
12632 @cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
12633 @cindex Integer maps
12634 @cindex Maps
12635 @cindex SPITBOL Tables
12637 @noindent
12638 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
12639 for type @code{Standard.Integer}, giving an implementation of maps
12640 from string to integer values.
12642 @node GNAT.Spitbol.Table_VString (g-sptavs.ads)
12643 @section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
12644 @cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
12645 @cindex String maps
12646 @cindex Maps
12647 @cindex SPITBOL Tables
12649 @noindent
12650 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
12651 a variable length string type, giving an implementation of general
12652 maps from strings to strings.
12654 @node GNAT.Strings (g-string.ads)
12655 @section @code{GNAT.Strings} (@file{g-string.ads})
12656 @cindex @code{GNAT.Strings} (@file{g-string.ads})
12658 @noindent
12659 Common String access types and related subprograms. Basically it
12660 defines a string access and an array of string access types.
12662 @node GNAT.String_Split (g-strspl.ads)
12663 @section @code{GNAT.String_Split} (@file{g-strspl.ads})
12664 @cindex @code{GNAT.String_Split} (@file{g-strspl.ads})
12665 @cindex String splitter
12667 @noindent
12668 Useful string manipulation routines: given a set of separators, split
12669 a string wherever the separators appear, and provide direct access
12670 to the resulting slices. This package is instantiated from
12671 @code{GNAT.Array_Split}.
12673 @node GNAT.Table (g-table.ads)
12674 @section @code{GNAT.Table} (@file{g-table.ads})
12675 @cindex @code{GNAT.Table} (@file{g-table.ads})
12676 @cindex Table implementation
12677 @cindex Arrays, extendable
12679 @noindent
12680 A generic package providing a single dimension array abstraction where the
12681 length of the array can be dynamically modified.
12683 @noindent
12684 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
12685 except that this package declares a single instance of the table type,
12686 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
12687 used to define dynamic instances of the table.
12689 @node GNAT.Task_Lock (g-tasloc.ads)
12690 @section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
12691 @cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
12692 @cindex Task synchronization
12693 @cindex Task locking
12694 @cindex Locking
12696 @noindent
12697 A very simple facility for locking and unlocking sections of code using a
12698 single global task lock.  Appropriate for use in situations where contention
12699 between tasks is very rarely expected.
12701 @node GNAT.Threads (g-thread.ads)
12702 @section @code{GNAT.Threads} (@file{g-thread.ads})
12703 @cindex @code{GNAT.Threads} (@file{g-thread.ads})
12704 @cindex Foreign threads
12705 @cindex Threads, foreign
12707 @noindent
12708 Provides facilities for creating and destroying threads with explicit calls.
12709 These threads are known to the GNAT run-time system.  These subprograms are
12710 exported C-convention procedures intended to be called from foreign code.
12711 By using these primitives rather than directly calling operating systems
12712 routines, compatibility with the Ada tasking runt-time is provided.
12714 @node GNAT.Traceback (g-traceb.ads)
12715 @section @code{GNAT.Traceback} (@file{g-traceb.ads})
12716 @cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
12717 @cindex Trace back facilities
12719 @noindent
12720 Provides a facility for obtaining non-symbolic traceback information, useful
12721 in various debugging situations.
12723 @node GNAT.Traceback.Symbolic (g-trasym.ads)
12724 @section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
12725 @cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
12726 @cindex Trace back facilities
12728 @noindent
12729 Provides symbolic traceback information that includes the subprogram
12730 name and line number information.
12732 @node GNAT.Wide_String_Split (g-wistsp.ads)
12733 @section @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
12734 @cindex @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
12735 @cindex Wide_String splitter
12737 @noindent
12738 Useful wide string manipulation routines: given a set of separators, split
12739 a wide string wherever the separators appear, and provide direct access
12740 to the resulting slices. This package is instantiated from
12741 @code{GNAT.Array_Split}.
12743 @node GNAT.Wide_Wide_String_Split (g-zistsp.ads)
12744 @section @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
12745 @cindex @code{GNAT.Wide_Wide_String_Split} (@file{g-zistsp.ads})
12746 @cindex Wide_Wide_String splitter
12748 @noindent
12749 Useful wide wide string manipulation routines: given a set of separators, split
12750 a wide wide string wherever the separators appear, and provide direct access
12751 to the resulting slices. This package is instantiated from
12752 @code{GNAT.Array_Split}.
12754 @node Interfaces.C.Extensions (i-cexten.ads)
12755 @section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
12756 @cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
12758 @noindent
12759 This package contains additional C-related definitions, intended
12760 for use with either manually or automatically generated bindings
12761 to C libraries.
12763 @node Interfaces.C.Streams (i-cstrea.ads)
12764 @section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
12765 @cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
12766 @cindex  C streams, interfacing
12768 @noindent
12769 This package is a binding for the most commonly used operations
12770 on C streams.
12772 @node Interfaces.CPP (i-cpp.ads)
12773 @section @code{Interfaces.CPP} (@file{i-cpp.ads})
12774 @cindex @code{Interfaces.CPP} (@file{i-cpp.ads})
12775 @cindex  C++ interfacing
12776 @cindex  Interfacing, to C++
12778 @noindent
12779 This package provides facilities for use in interfacing to C++.  It
12780 is primarily intended to be used in connection with automated tools
12781 for the generation of C++ interfaces.
12783 @node Interfaces.Os2lib (i-os2lib.ads)
12784 @section @code{Interfaces.Os2lib} (@file{i-os2lib.ads})
12785 @cindex @code{Interfaces.Os2lib} (@file{i-os2lib.ads})
12786 @cindex Interfacing, to OS/2
12787 @cindex OS/2 interfacing
12789 @noindent
12790 This package provides interface definitions to the OS/2 library.
12791 It is a thin binding which is a direct translation of the
12792 various @file{<bse@.h>} files.
12794 @node Interfaces.Os2lib.Errors (i-os2err.ads)
12795 @section @code{Interfaces.Os2lib.Errors} (@file{i-os2err.ads})
12796 @cindex @code{Interfaces.Os2lib.Errors} (@file{i-os2err.ads})
12797 @cindex OS/2 Error codes
12798 @cindex Interfacing, to OS/2
12799 @cindex OS/2 interfacing
12801 @noindent
12802 This package provides definitions of the OS/2 error codes.
12804 @node Interfaces.Os2lib.Synchronization (i-os2syn.ads)
12805 @section @code{Interfaces.Os2lib.Synchronization} (@file{i-os2syn.ads})
12806 @cindex @code{Interfaces.Os2lib.Synchronization} (@file{i-os2syn.ads})
12807 @cindex Interfacing, to OS/2
12808 @cindex Synchronization, OS/2
12809 @cindex OS/2 synchronization primitives
12811 @noindent
12812 This is a child package that provides definitions for interfacing
12813 to the @code{OS/2} synchronization primitives.
12815 @node Interfaces.Os2lib.Threads (i-os2thr.ads)
12816 @section @code{Interfaces.Os2lib.Threads} (@file{i-os2thr.ads})
12817 @cindex @code{Interfaces.Os2lib.Threads} (@file{i-os2thr.ads})
12818 @cindex Interfacing, to OS/2
12819 @cindex Thread control, OS/2
12820 @cindex OS/2 thread interfacing
12822 @noindent
12823 This is a child package that provides definitions for interfacing
12824 to the @code{OS/2} thread primitives.
12826 @node Interfaces.Packed_Decimal (i-pacdec.ads)
12827 @section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
12828 @cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
12829 @cindex  IBM Packed Format
12830 @cindex  Packed Decimal
12832 @noindent
12833 This package provides a set of routines for conversions to and
12834 from a packed decimal format compatible with that used on IBM
12835 mainframes.
12837 @node Interfaces.VxWorks (i-vxwork.ads)
12838 @section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
12839 @cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
12840 @cindex Interfacing to VxWorks
12841 @cindex VxWorks, interfacing
12843 @noindent
12844 This package provides a limited binding to the VxWorks API.
12845 In particular, it interfaces with the
12846 VxWorks hardware interrupt facilities.
12848 @node Interfaces.VxWorks.IO (i-vxwoio.ads)
12849 @section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
12850 @cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
12851 @cindex Interfacing to VxWorks' I/O
12852 @cindex VxWorks, I/O interfacing
12853 @cindex VxWorks, Get_Immediate
12854 @cindex Get_Immediate, VxWorks
12856 @noindent
12857 This package provides a binding to the ioctl (IO/Control)
12858 function of VxWorks, defining a set of option values and
12859 function codes. A particular use of this package is
12860 to enable the use of Get_Immediate under VxWorks.
12862 @node System.Address_Image (s-addima.ads)
12863 @section @code{System.Address_Image} (@file{s-addima.ads})
12864 @cindex @code{System.Address_Image} (@file{s-addima.ads})
12865 @cindex Address image
12866 @cindex Image, of an address
12868 @noindent
12869 This function provides a useful debugging
12870 function that gives an (implementation dependent)
12871 string which identifies an address.
12873 @node System.Assertions (s-assert.ads)
12874 @section @code{System.Assertions} (@file{s-assert.ads})
12875 @cindex @code{System.Assertions} (@file{s-assert.ads})
12876 @cindex Assertions
12877 @cindex Assert_Failure, exception
12879 @noindent
12880 This package provides the declaration of the exception raised
12881 by an run-time assertion failure, as well as the routine that
12882 is used internally to raise this assertion.
12884 @node System.Memory (s-memory.ads)
12885 @section @code{System.Memory} (@file{s-memory.ads})
12886 @cindex @code{System.Memory} (@file{s-memory.ads})
12887 @cindex Memory allocation
12889 @noindent
12890 This package provides the interface to the low level routines used
12891 by the generated code for allocation and freeing storage for the
12892 default storage pool (analogous to the C routines malloc and free.
12893 It also provides a reallocation interface analogous to the C routine
12894 realloc. The body of this unit may be modified to provide alternative
12895 allocation mechanisms for the default pool, and in addition, direct
12896 calls to this unit may be made for low level allocation uses (for
12897 example see the body of @code{GNAT.Tables}).
12899 @node System.Partition_Interface (s-parint.ads)
12900 @section @code{System.Partition_Interface} (@file{s-parint.ads})
12901 @cindex @code{System.Partition_Interface} (@file{s-parint.ads})
12902 @cindex Partition intefacing functions
12904 @noindent
12905 This package provides facilities for partition interfacing.  It
12906 is used primarily in a distribution context when using Annex E
12907 with @code{GLADE}.
12909 @node System.Restrictions (s-restri.ads)
12910 @section @code{System.Restrictions} (@file{s-restri.ads})
12911 @cindex @code{System.Restrictions} (@file{s-restri.ads})
12912 @cindex Run-time restrictions access
12914 @noindent
12915 This package provides facilities for accessing at run-time
12916 the status of restrictions specified at compile time for
12917 the partition. Information is available both with regard
12918 to actual restrictions specified, and with regard to
12919 compiler determined information on which restrictions
12920 are violated by one or more packages in the partition.
12922 @node System.Rident (s-rident.ads)
12923 @section @code{System.Rident} (@file{s-rident.ads})
12924 @cindex @code{System.Rident} (@file{s-rident.ads})
12925 @cindex Restrictions definitions
12927 @noindent
12928 This package provides definitions of the restrictions
12929 identifiers supported by GNAT, and also the format of
12930 the restrictions provided in package System.Restrictions.
12931 It is not normally necessary to @code{with} this generic package
12932 since the necessary instantiation is included in
12933 package System.Restrictions.
12935 @node System.Task_Info (s-tasinf.ads)
12936 @section @code{System.Task_Info} (@file{s-tasinf.ads})
12937 @cindex @code{System.Task_Info} (@file{s-tasinf.ads})
12938 @cindex Task_Info pragma
12940 @noindent
12941 This package provides target dependent functionality that is used
12942 to support the @code{Task_Info} pragma
12944 @node System.Wch_Cnv (s-wchcnv.ads)
12945 @section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
12946 @cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
12947 @cindex Wide Character, Representation
12948 @cindex Wide String, Conversion
12949 @cindex Representation of wide characters
12951 @noindent
12952 This package provides routines for converting between
12953 wide and wide wide characters and a representation as a value of type
12954 @code{Standard.String}, using a specified wide character
12955 encoding method.  It uses definitions in
12956 package @code{System.Wch_Con}.
12958 @node System.Wch_Con (s-wchcon.ads)
12959 @section @code{System.Wch_Con} (@file{s-wchcon.ads})
12960 @cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
12962 @noindent
12963 This package provides definitions and descriptions of
12964 the various methods used for encoding wide characters
12965 in ordinary strings.  These definitions are used by
12966 the package @code{System.Wch_Cnv}.
12968 @node Interfacing to Other Languages
12969 @chapter Interfacing to Other Languages
12970 @noindent
12971 The facilities in annex B of the Ada 95 Reference Manual are fully
12972 implemented in GNAT, and in addition, a full interface to C++ is
12973 provided.
12975 @menu
12976 * Interfacing to C::
12977 * Interfacing to C++::
12978 * Interfacing to COBOL::
12979 * Interfacing to Fortran::
12980 * Interfacing to non-GNAT Ada code::
12981 @end menu
12983 @node Interfacing to C
12984 @section Interfacing to C
12986 @noindent
12987 Interfacing to C with GNAT can use one of two approaches:
12989 @itemize @bullet
12990 @item
12991 The types in the package @code{Interfaces.C} may be used.
12992 @item
12993 Standard Ada types may be used directly.  This may be less portable to
12994 other compilers, but will work on all GNAT compilers, which guarantee
12995 correspondence between the C and Ada types.
12996 @end itemize
12998 @noindent
12999 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
13000 effect, since this is the default.  The following table shows the
13001 correspondence between Ada scalar types and the corresponding C types.
13003 @table @code
13004 @item Integer
13005 @code{int}
13006 @item Short_Integer
13007 @code{short}
13008 @item Short_Short_Integer
13009 @code{signed char}
13010 @item Long_Integer
13011 @code{long}
13012 @item Long_Long_Integer
13013 @code{long long}
13014 @item Short_Float
13015 @code{float}
13016 @item Float
13017 @code{float}
13018 @item Long_Float
13019 @code{double}
13020 @item Long_Long_Float
13021 This is the longest floating-point type supported by the hardware.
13022 @end table
13024 @noindent
13025 Additionally, there are the following general correspondences between Ada
13026 and C types:
13027 @itemize @bullet
13028 @item
13029 Ada enumeration types map to C enumeration types directly if pragma
13030 @code{Convention C} is specified, which causes them to have int
13031 length.  Without pragma @code{Convention C}, Ada enumeration types map to
13032 8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short},
13033 @code{int}, respectively) depending on the number of values passed.
13034 This is the only case in which pragma @code{Convention C} affects the
13035 representation of an Ada type.
13037 @item
13038 Ada access types map to C pointers, except for the case of pointers to
13039 unconstrained types in Ada, which have no direct C equivalent.
13041 @item
13042 Ada arrays map directly to C arrays.
13044 @item
13045 Ada records map directly to C structures.
13047 @item
13048 Packed Ada records map to C structures where all members are bit fields
13049 of the length corresponding to the @code{@var{type}'Size} value in Ada.
13050 @end itemize
13052 @node Interfacing to C++
13053 @section Interfacing to C++
13055 @noindent
13056 The interface to C++ makes use of the following pragmas, which are
13057 primarily intended to be constructed automatically using a binding generator
13058 tool, although it is possible to construct them by hand.  No suitable binding
13059 generator tool is supplied with GNAT though.
13061 Using these pragmas it is possible to achieve complete
13062 inter-operability between Ada tagged types and C class definitions.
13063 See @ref{Implementation Defined Pragmas}, for more details.
13065 @table @code
13066 @item pragma CPP_Class ([Entity =>] @var{local_name})
13067 The argument denotes an entity in the current declarative region that is
13068 declared as a tagged or untagged record type.  It indicates that the type
13069 corresponds to an externally declared C++ class type, and is to be laid
13070 out the same way that C++ would lay out the type.
13072 @item pragma CPP_Constructor ([Entity =>] @var{local_name})
13073 This pragma identifies an imported function (imported in the usual way
13074 with pragma @code{Import}) as corresponding to a C++ constructor.
13076 @item pragma CPP_Vtable @dots{}
13077 One @code{CPP_Vtable} pragma can be present for each component of type
13078 @code{CPP.Interfaces.Vtable_Ptr} in a record to which pragma @code{CPP_Class}
13079 applies.
13080 @end table
13082 @node Interfacing to COBOL
13083 @section Interfacing to COBOL
13085 @noindent
13086 Interfacing to COBOL is achieved as described in section B.4 of
13087 the Ada 95 reference manual.
13089 @node Interfacing to Fortran
13090 @section Interfacing to Fortran
13092 @noindent
13093 Interfacing to Fortran is achieved as described in section B.5 of the
13094 reference manual.  The pragma @code{Convention Fortran}, applied to a
13095 multi-dimensional array causes the array to be stored in column-major
13096 order as required for convenient interface to Fortran.
13098 @node Interfacing to non-GNAT Ada code
13099 @section Interfacing to non-GNAT Ada code
13101 It is possible to specify the convention @code{Ada} in a pragma
13102 @code{Import} or pragma @code{Export}.  However this refers to
13103 the calling conventions used by GNAT, which may or may not be
13104 similar enough to those used by some other Ada 83 or Ada 95
13105 compiler to allow interoperation.
13107 If arguments types are kept simple, and if the foreign compiler generally
13108 follows system calling conventions, then it may be possible to integrate
13109 files compiled by other Ada compilers, provided that the elaboration
13110 issues are adequately addressed (for example by eliminating the
13111 need for any load time elaboration).
13113 In particular, GNAT running on VMS is designed to
13114 be highly compatible with the DEC Ada 83 compiler, so this is one
13115 case in which it is possible to import foreign units of this type,
13116 provided that the data items passed are restricted to simple scalar
13117 values or simple record types without variants, or simple array
13118 types with fixed bounds.
13120 @node Specialized Needs Annexes
13121 @chapter Specialized Needs Annexes
13123 @noindent
13124 Ada 95 defines a number of specialized needs annexes, which are not
13125 required in all implementations.  However, as described in this chapter,
13126 GNAT implements all of these special needs annexes:
13128 @table @asis
13129 @item Systems Programming (Annex C)
13130 The Systems Programming Annex is fully implemented.
13132 @item Real-Time Systems (Annex D)
13133 The Real-Time Systems Annex is fully implemented.
13135 @item Distributed Systems (Annex E)
13136 Stub generation is fully implemented in the GNAT compiler.  In addition,
13137 a complete compatible PCS is available as part of the GLADE system,
13138 a separate product.  When the two
13139 products are used in conjunction, this annex is fully implemented.
13141 @item Information Systems (Annex F)
13142 The Information Systems annex is fully implemented.
13144 @item Numerics (Annex G)
13145 The Numerics Annex is fully implemented.
13147 @item Safety and Security (Annex H)
13148 The Safety and Security annex is fully implemented.
13149 @end table
13151 @node Implementation of Specific Ada Features
13152 @chapter Implementation of Specific Ada Features
13154 @noindent
13155 This chapter describes the GNAT implementation of several Ada language
13156 facilities.
13158 @menu
13159 * Machine Code Insertions::
13160 * GNAT Implementation of Tasking::
13161 * GNAT Implementation of Shared Passive Packages::
13162 * Code Generation for Array Aggregates::
13163 * The Size of Discriminated Records with Default Discriminants::
13164 @end menu
13166 @node Machine Code Insertions
13167 @section Machine Code Insertions
13169 @noindent
13170 Package @code{Machine_Code} provides machine code support as described
13171 in the Ada 95 Reference Manual in two separate forms:
13172 @itemize @bullet
13173 @item
13174 Machine code statements, consisting of qualified expressions that
13175 fit the requirements of RM section 13.8.
13176 @item
13177 An intrinsic callable procedure, providing an alternative mechanism of
13178 including machine instructions in a subprogram.
13179 @end itemize
13181 @noindent
13182 The two features are similar, and both are closely related to the mechanism
13183 provided by the asm instruction in the GNU C compiler.  Full understanding
13184 and use of the facilities in this package requires understanding the asm
13185 instruction as described in @cite{Using the GNU Compiler Collection (GCC)}
13186 by Richard Stallman. The relevant section is titled ``Extensions to the C
13187 Language Family'' -> ``Assembler Instructions with C Expression Operands''.
13189 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
13190 semantic restrictions and effects as described below.  Both are provided so
13191 that the procedure call can be used as a statement, and the function call
13192 can be used to form a code_statement.
13194 The first example given in the GCC documentation is the C @code{asm}
13195 instruction:
13196 @smallexample
13197    asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
13198 @end smallexample
13200 @noindent
13201 The equivalent can be written for GNAT as:
13203 @smallexample @c ada
13204 Asm ("fsinx %1 %0",
13205      My_Float'Asm_Output ("=f", result),
13206      My_Float'Asm_Input  ("f",  angle));
13207 @end smallexample
13209 @noindent
13210 The first argument to @code{Asm} is the assembler template, and is
13211 identical to what is used in GNU C@.  This string must be a static
13212 expression.  The second argument is the output operand list.  It is
13213 either a single @code{Asm_Output} attribute reference, or a list of such
13214 references enclosed in parentheses (technically an array aggregate of
13215 such references).
13217 The @code{Asm_Output} attribute denotes a function that takes two
13218 parameters.  The first is a string, the second is the name of a variable
13219 of the type designated by the attribute prefix.  The first (string)
13220 argument is required to be a static expression and designates the
13221 constraint for the parameter (e.g.@: what kind of register is
13222 required).  The second argument is the variable to be updated with the
13223 result.  The possible values for constraint are the same as those used in
13224 the RTL, and are dependent on the configuration file used to build the
13225 GCC back end.  If there are no output operands, then this argument may
13226 either be omitted, or explicitly given as @code{No_Output_Operands}.
13228 The second argument of @code{@var{my_float}'Asm_Output} functions as
13229 though it were an @code{out} parameter, which is a little curious, but
13230 all names have the form of expressions, so there is no syntactic
13231 irregularity, even though normally functions would not be permitted
13232 @code{out} parameters.  The third argument is the list of input
13233 operands.  It is either a single @code{Asm_Input} attribute reference, or
13234 a list of such references enclosed in parentheses (technically an array
13235 aggregate of such references).
13237 The @code{Asm_Input} attribute denotes a function that takes two
13238 parameters.  The first is a string, the second is an expression of the
13239 type designated by the prefix.  The first (string) argument is required
13240 to be a static expression, and is the constraint for the parameter,
13241 (e.g.@: what kind of register is required).  The second argument is the
13242 value to be used as the input argument.  The possible values for the
13243 constant are the same as those used in the RTL, and are dependent on
13244 the configuration file used to built the GCC back end.
13246 If there are no input operands, this argument may either be omitted, or
13247 explicitly given as @code{No_Input_Operands}.  The fourth argument, not
13248 present in the above example, is a list of register names, called the
13249 @dfn{clobber} argument.  This argument, if given, must be a static string
13250 expression, and is a space or comma separated list of names of registers
13251 that must be considered destroyed as a result of the @code{Asm} call.  If
13252 this argument is the null string (the default value), then the code
13253 generator assumes that no additional registers are destroyed.
13255 The fifth argument, not present in the above example, called the
13256 @dfn{volatile} argument, is by default @code{False}.  It can be set to
13257 the literal value @code{True} to indicate to the code generator that all
13258 optimizations with respect to the instruction specified should be
13259 suppressed, and that in particular, for an instruction that has outputs,
13260 the instruction will still be generated, even if none of the outputs are
13261 used.  See the full description in the GCC manual for further details.
13263 The @code{Asm} subprograms may be used in two ways.  First the procedure
13264 forms can be used anywhere a procedure call would be valid, and
13265 correspond to what the RM calls ``intrinsic'' routines.  Such calls can
13266 be used to intersperse machine instructions with other Ada statements.
13267 Second, the function forms, which return a dummy value of the limited
13268 private type @code{Asm_Insn}, can be used in code statements, and indeed
13269 this is the only context where such calls are allowed.  Code statements
13270 appear as aggregates of the form:
13272 @smallexample @c ada
13273 Asm_Insn'(Asm (@dots{}));
13274 Asm_Insn'(Asm_Volatile (@dots{}));
13275 @end smallexample
13277 @noindent
13278 In accordance with RM rules, such code statements are allowed only
13279 within subprograms whose entire body consists of such statements.  It is
13280 not permissible to intermix such statements with other Ada statements.
13282 Typically the form using intrinsic procedure calls is more convenient
13283 and more flexible.  The code statement form is provided to meet the RM
13284 suggestion that such a facility should be made available.  The following
13285 is the exact syntax of the call to @code{Asm}. As usual, if named notation
13286 is used, the arguments may be given in arbitrary order, following the
13287 normal rules for use of positional and named arguments)
13289 @smallexample
13290 ASM_CALL ::= Asm (
13291                  [Template =>] static_string_EXPRESSION
13292                [,[Outputs  =>] OUTPUT_OPERAND_LIST      ]
13293                [,[Inputs   =>] INPUT_OPERAND_LIST       ]
13294                [,[Clobber  =>] static_string_EXPRESSION ]
13295                [,[Volatile =>] static_boolean_EXPRESSION] )
13297 OUTPUT_OPERAND_LIST ::=
13298   [PREFIX.]No_Output_Operands
13299 | OUTPUT_OPERAND_ATTRIBUTE
13300 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
13302 OUTPUT_OPERAND_ATTRIBUTE ::=
13303   SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
13305 INPUT_OPERAND_LIST ::=
13306   [PREFIX.]No_Input_Operands
13307 | INPUT_OPERAND_ATTRIBUTE
13308 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
13310 INPUT_OPERAND_ATTRIBUTE ::=
13311   SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
13312 @end smallexample
13314 @noindent
13315 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
13316 are declared in the package @code{Machine_Code} and must be referenced
13317 according to normal visibility rules. In particular if there is no
13318 @code{use} clause for this package, then appropriate package name
13319 qualification is required.
13321 @node GNAT Implementation of Tasking
13322 @section GNAT Implementation of Tasking
13324 @noindent
13325 This chapter outlines the basic GNAT approach to tasking (in particular,
13326 a multi-layered library for portability) and discusses issues related
13327 to compliance with the Real-Time Systems Annex.
13329 @menu
13330 * Mapping Ada Tasks onto the Underlying Kernel Threads::
13331 * Ensuring Compliance with the Real-Time Annex::
13332 @end menu
13334 @node Mapping Ada Tasks onto the Underlying Kernel Threads
13335 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
13337 @noindent
13338 GNAT's run-time support comprises two layers:
13340 @itemize @bullet
13341 @item GNARL (GNAT Run-time Layer)
13342 @item GNULL (GNAT Low-level Library)
13343 @end itemize
13345 @noindent
13346 In GNAT, Ada's tasking services rely on a platform and OS independent
13347 layer known as GNARL@.  This code is responsible for implementing the
13348 correct semantics of Ada's task creation, rendezvous, protected
13349 operations etc.
13351 GNARL decomposes Ada's tasking semantics into simpler lower level
13352 operations such as create a thread, set the priority of a thread,
13353 yield, create a lock, lock/unlock, etc.  The spec for these low-level
13354 operations constitutes GNULLI, the GNULL Interface.  This interface is
13355 directly inspired from the POSIX real-time API@.
13357 If the underlying executive or OS implements the POSIX standard
13358 faithfully, the GNULL Interface maps as is to the services offered by
13359 the underlying kernel.  Otherwise, some target dependent glue code maps
13360 the services offered by the underlying kernel to the semantics expected
13361 by GNARL@.
13363 Whatever the underlying OS (VxWorks, UNIX, OS/2, Windows NT, etc.) the
13364 key point is that each Ada task is mapped on a thread in the underlying
13365 kernel.  For example, in the case of VxWorks, one Ada task = one VxWorks task.
13367 In addition Ada task priorities map onto the underlying thread priorities.
13368 Mapping Ada tasks onto the underlying kernel threads has several advantages:
13370 @itemize @bullet
13371 @item
13372 The underlying scheduler is used to schedule the Ada tasks.  This
13373 makes Ada tasks as efficient as kernel threads from a scheduling
13374 standpoint.
13376 @item
13377 Interaction with code written in C containing threads is eased
13378 since at the lowest level Ada tasks and C threads map onto the same
13379 underlying kernel concept.
13381 @item
13382 When an Ada task is blocked during I/O the remaining Ada tasks are
13383 able to proceed.
13385 @item
13386 On multiprocessor systems Ada tasks can execute in parallel.
13387 @end itemize
13389 @noindent
13390 Some threads libraries offer a mechanism to fork a new process, with the
13391 child process duplicating the threads from the parent.
13392 GNAT does not
13393 support this functionality when the parent contains more than one task.
13394 @cindex Forking a new process
13396 @node Ensuring Compliance with the Real-Time Annex
13397 @subsection Ensuring Compliance with the Real-Time Annex
13398 @cindex Real-Time Systems Annex compliance
13400 @noindent
13401 Although mapping Ada tasks onto
13402 the underlying threads has significant advantages, it does create some
13403 complications when it comes to respecting the scheduling semantics
13404 specified in the real-time annex (Annex D).
13406 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
13407 scheduling policy states:
13409 @quotation
13410 @emph{When the active priority of a ready task that is not running
13411 changes, or the setting of its base priority takes effect, the
13412 task is removed from the ready queue for its old active priority
13413 and is added at the tail of the ready queue for its new active
13414 priority, except in the case where the active priority is lowered
13415 due to the loss of inherited priority, in which case the task is
13416 added at the head of the ready queue for its new active priority.}
13417 @end quotation
13419 @noindent
13420 While most kernels do put tasks at the end of the priority queue when
13421 a task changes its priority, (which respects the main
13422 FIFO_Within_Priorities requirement), almost none keep a thread at the
13423 beginning of its priority queue when its priority drops from the loss
13424 of inherited priority.
13426 As a result most vendors have provided incomplete Annex D implementations.
13428 The GNAT run-time, has a nice cooperative solution to this problem
13429 which ensures that accurate FIFO_Within_Priorities semantics are
13430 respected.
13432 The principle is as follows.  When an Ada task T is about to start
13433 running, it checks whether some other Ada task R with the same
13434 priority as T has been suspended due to the loss of priority
13435 inheritance.  If this is the case, T yields and is placed at the end of
13436 its priority queue.  When R arrives at the front of the queue it
13437 executes.
13439 Note that this simple scheme preserves the relative order of the tasks
13440 that were ready to execute in the priority queue where R has been
13441 placed at the end.
13443 @node GNAT Implementation of Shared Passive Packages
13444 @section GNAT Implementation of Shared Passive Packages
13445 @cindex Shared passive packages
13447 @noindent
13448 GNAT fully implements the pragma @code{Shared_Passive} for
13449 @cindex pragma @code{Shared_Passive}
13450 the purpose of designating shared passive packages.
13451 This allows the use of passive partitions in the
13452 context described in the Ada Reference Manual; i.e. for communication
13453 between separate partitions of a distributed application using the
13454 features in Annex E.
13455 @cindex Annex E
13456 @cindex Distribution Systems Annex
13458 However, the implementation approach used by GNAT provides for more
13459 extensive usage as follows:
13461 @table @emph
13462 @item Communication between separate programs
13464 This allows separate programs to access the data in passive
13465 partitions, using protected objects for synchronization where
13466 needed. The only requirement is that the two programs have a
13467 common shared file system. It is even possible for programs
13468 running on different machines with different architectures
13469 (e.g. different endianness) to communicate via the data in
13470 a passive partition.
13472 @item Persistence between program runs
13474 The data in a passive package can persist from one run of a
13475 program to another, so that a later program sees the final
13476 values stored by a previous run of the same program.
13478 @end table
13480 @noindent
13481 The implementation approach used is to store the data in files. A
13482 separate stream file is created for each object in the package, and
13483 an access to an object causes the corresponding file to be read or
13484 written.
13486 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
13487 @cindex @code{SHARED_MEMORY_DIRECTORY} environment variable
13488 set to the directory to be used for these files.
13489 The files in this directory
13490 have names that correspond to their fully qualified names. For
13491 example, if we have the package
13493 @smallexample @c ada
13494 package X is
13495   pragma Shared_Passive (X);
13496   Y : Integer;
13497   Z : Float;
13498 end X;
13499 @end smallexample
13501 @noindent
13502 and the environment variable is set to @code{/stemp/}, then the files created
13503 will have the names:
13505 @smallexample
13506 /stemp/x.y
13507 /stemp/x.z
13508 @end smallexample
13510 @noindent
13511 These files are created when a value is initially written to the object, and
13512 the files are retained until manually deleted. This provides the persistence
13513 semantics. If no file exists, it means that no partition has assigned a value
13514 to the variable; in this case the initial value declared in the package
13515 will be used. This model ensures that there are no issues in synchronizing
13516 the elaboration process, since elaboration of passive packages elaborates the
13517 initial values, but does not create the files.
13519 The files are written using normal @code{Stream_IO} access.
13520 If you want to be able
13521 to communicate between programs or partitions running on different
13522 architectures, then you should use the XDR versions of the stream attribute
13523 routines, since these are architecture independent.
13525 If active synchronization is required for access to the variables in the
13526 shared passive package, then as described in the Ada Reference Manual, the
13527 package may contain protected objects used for this purpose. In this case
13528 a lock file (whose name is @file{___lock} (three underscores)
13529 is created in the shared memory directory.
13530 @cindex @file{___lock} file (for shared passive packages)
13531 This is used to provide the required locking
13532 semantics for proper protected object synchronization.
13534 As of January 2003, GNAT supports shared passive packages on all platforms
13535 except for OpenVMS.
13537 @node Code Generation for Array Aggregates
13538 @section Code Generation for Array Aggregates
13540 @menu
13541 * Static constant aggregates with static bounds::
13542 * Constant aggregates with an unconstrained nominal types::
13543 * Aggregates with static bounds::
13544 * Aggregates with non-static bounds::
13545 * Aggregates in assignment statements::
13546 @end menu
13548 @noindent
13549 Aggregate have a rich syntax and allow the user to specify the values of
13550 complex data structures by means of a single construct.  As a result, the
13551 code generated for aggregates can be quite complex and involve loops, case
13552 statements and multiple assignments.  In the simplest cases, however, the
13553 compiler will recognize aggregates whose components and constraints are
13554 fully static, and in those cases the compiler will generate little or no
13555 executable code.  The following is an outline of the code that GNAT generates
13556 for various aggregate constructs.  For further details, the user will find it
13557 useful to examine the output produced by the -gnatG flag to see the expanded
13558 source that is input to the code generator.  The user will also want to examine
13559 the assembly code generated at various levels of optimization.
13561 The code generated for aggregates depends on the context, the component values,
13562 and the type.  In the context of an object declaration the code generated is
13563 generally simpler than in the case of an assignment.  As a general rule, static
13564 component values and static subtypes also lead to simpler code.
13566 @node Static constant aggregates with static bounds
13567 @subsection Static constant aggregates with static bounds
13569 @noindent
13570 For the declarations:
13571 @smallexample @c ada
13572     type One_Dim is array (1..10) of integer;
13573     ar0 : constant One_Dim := ( 1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
13574 @end smallexample
13576 @noindent
13577 GNAT generates no executable code: the constant ar0 is placed in static memory.
13578 The same is true for constant aggregates with named associations:
13580 @smallexample @c ada
13581     Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1=> 1);
13582     Cr3 : constant One_Dim := (others => 7777);
13583 @end smallexample
13585 @noindent
13586 The same is true for multidimensional constant arrays such as:
13588 @smallexample @c ada
13589     type two_dim is array (1..3, 1..3) of integer;
13590     Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
13591 @end smallexample
13593 @noindent
13594 The same is true for arrays of one-dimensional arrays: the following are
13595 static:
13597 @smallexample @c ada
13598 type ar1b  is array (1..3) of boolean;
13599 type ar_ar is array (1..3) of ar1b;
13600 None  : constant ar1b := (others => false);     --  fully static
13601 None2 : constant ar_ar := (1..3 => None);       --  fully static
13602 @end smallexample
13604 @noindent
13605 However, for multidimensional aggregates with named associations, GNAT will
13606 generate assignments and loops, even if all associations are static.  The
13607 following two declarations generate a loop for the first dimension, and
13608 individual component assignments for the second dimension:
13610 @smallexample @c ada
13611 Zero1: constant two_dim := (1..3 => (1..3 => 0));
13612 Zero2: constant two_dim := (others => (others => 0));
13613 @end smallexample
13615 @node Constant aggregates with an unconstrained nominal types
13616 @subsection Constant aggregates with an unconstrained nominal types
13618 @noindent
13619 In such cases the aggregate itself establishes the subtype, so that
13620 associations with @code{others} cannot be used.  GNAT determines the
13621 bounds for the actual subtype of the aggregate, and allocates the
13622 aggregate statically as well.  No code is generated for the following:
13624 @smallexample @c ada
13625     type One_Unc is array (natural range <>) of integer;
13626     Cr_Unc : constant One_Unc := (12,24,36);
13627 @end smallexample
13629 @node Aggregates with static bounds
13630 @subsection Aggregates with static bounds
13632 @noindent
13633 In all previous examples the aggregate was the initial (and immutable) value
13634 of a constant.  If the aggregate initializes a variable, then code is generated
13635 for it as a combination of individual assignments and loops over the target
13636 object.  The declarations
13638 @smallexample @c ada
13639        Cr_Var1 : One_Dim := (2, 5, 7, 11);
13640        Cr_Var2 : One_Dim := (others > -1);
13641 @end smallexample
13643 @noindent
13644 generate the equivalent of
13646 @smallexample @c ada
13647        Cr_Var1 (1) := 2;
13648        Cr_Var1 (2) := 3;
13649        Cr_Var1 (3) := 5;
13650        Cr_Var1 (4) := 11;
13652        for I in Cr_Var2'range loop
13653           Cr_Var2 (I) := =-1;
13654        end loop;
13655 @end smallexample
13657 @node Aggregates with non-static bounds
13658 @subsection Aggregates with non-static bounds
13660 @noindent
13661 If the bounds of the aggregate are not statically compatible with the bounds
13662 of the nominal subtype  of the target, then constraint checks have to be
13663 generated on the bounds.  For a multidimensional array, constraint checks may
13664 have to be applied to sub-arrays individually, if they do not have statically
13665 compatible subtypes.
13667 @node Aggregates in assignment statements
13668 @subsection Aggregates in assignment statements
13670 @noindent
13671 In general, aggregate assignment requires the construction of a temporary,
13672 and a copy from the temporary to the target of the assignment.  This is because
13673 it is not always possible to convert the assignment into a series of individual
13674 component assignments.  For example, consider the simple case:
13676 @smallexample @c ada
13677         A := (A(2), A(1));
13678 @end smallexample
13680 @noindent
13681 This cannot be converted into:
13683 @smallexample @c ada
13684         A(1) := A(2);
13685         A(2) := A(1);
13686 @end smallexample
13688 @noindent
13689 So the aggregate has to be built first in a separate location, and then
13690 copied into the target.  GNAT recognizes simple cases where this intermediate
13691 step is not required, and the assignments can be performed in place, directly
13692 into the target.  The following sufficient criteria are applied:
13694 @itemize @bullet
13695 @item
13696 The bounds of the aggregate are static, and the associations are static.
13697 @item
13698 The components of the aggregate are static constants, names of
13699 simple variables that are not renamings, or expressions not involving
13700 indexed components whose operands obey these rules.
13701 @end itemize
13703 @noindent
13704 If any of these conditions are violated, the aggregate will be built in
13705 a temporary (created either by the front-end or the code generator) and then
13706 that temporary will be copied onto the target.
13709 @node The Size of Discriminated Records with Default Discriminants
13710 @section The Size of Discriminated Records with Default Discriminants
13712 @noindent
13713 If a discriminated type @code{T} has discriminants with default values, it is
13714 possible to declare an object of this type without providing an explicit
13715 constraint:
13717 @smallexample @c ada
13718 @group
13719 type Size is range 1..100;
13721 type Rec (D : Size := 15) is record
13722    Name : String (1..D);
13723 end T;
13725 Word : Rec;
13726 @end group
13727 @end smallexample
13729 @noindent
13730 Such an object is said to be @emph{unconstrained}.
13731 The discriminant of the object
13732 can be modified by a full assignment to the object, as long as it preserves the
13733 relation between the value of the discriminant, and the value of the components
13734 that depend on it:
13736 @smallexample @c ada
13737 @group
13738 Word := (3, "yes");
13740 Word := (5, "maybe");
13742 Word := (5, "no"); -- raises Constraint_Error
13743 @end group
13744 @end smallexample
13746 @noindent
13747 In order to support this behavior efficiently, an unconstrained object is
13748 given the maximum size that any value of the type requires. In the case
13749 above, @code{Word} has storage for the discriminant and for
13750 a @code{String} of length 100.
13751 It is important to note that unconstrained objects do not require dynamic
13752 allocation. It would be an improper implementation to place on the heap those
13753 components whose size depends on discriminants. (This improper implementation
13754 was used by some Ada83 compilers, where the @code{Name} component above
13755 would have
13756 been stored as a pointer to a dynamic string). Following the principle that
13757 dynamic storage management should never be introduced implicitly,
13758 an Ada95 compiler should reserve the full size for an unconstrained declared
13759 object, and place it on the stack.
13761 This maximum size approach
13762 has been a source of surprise to some users, who expect the default
13763 values of the discriminants to determine the size reserved for an
13764 unconstrained object: ``If the default is 15, why should the object occupy
13765 a larger size?''
13766 The answer, of course, is that the discriminant may be later modified,
13767 and its full range of values must be taken into account. This is why the
13768 declaration:
13770 @smallexample
13771 @group
13772 type Rec (D : Positive := 15) is record
13773    Name : String (1..D);
13774 end record;
13776 Too_Large : Rec;
13777 @end group
13778 @end smallexample
13780 @noindent
13781 is flagged by the compiler with a warning:
13782 an attempt to create @code{Too_Large} will raise @code{Storage_Error},
13783 because the required size includes @code{Positive'Last}
13784 bytes. As the first example indicates, the proper approach is to declare an
13785 index type of ``reasonable'' range so that unconstrained objects are not too
13786 large.
13788 One final wrinkle: if the object is declared to be @code{aliased}, or if it is
13789 created in the heap by means of an allocator, then it is @emph{not}
13790 unconstrained:
13791 it is constrained by the default values of the discriminants, and those values
13792 cannot be modified by full assignment. This is because in the presence of
13793 aliasing all views of the object (which may be manipulated by different tasks,
13794 say) must be consistent, so it is imperative that the object, once created,
13795 remain invariant.
13800 @node Project File Reference
13801 @chapter Project File Reference
13803 @noindent
13804 This chapter describes the syntax and semantics of project files.
13805 Project files specify the options to be used when building a system.
13806 Project files can specify global settings for all tools,
13807 as well as tool-specific settings.
13808 See the chapter on project files in the GNAT Users guide for examples of use.
13810 @menu
13811 * Reserved Words::
13812 * Lexical Elements::
13813 * Declarations::
13814 * Empty declarations::
13815 * Typed string declarations::
13816 * Variables::
13817 * Expressions::
13818 * Attributes::
13819 * Project Attributes::
13820 * Attribute References::
13821 * External Values::
13822 * Case Construction::
13823 * Packages::
13824 * Package Renamings::
13825 * Projects::
13826 * Project Extensions::
13827 * Project File Elaboration::
13828 @end menu
13830 @node Reserved Words
13831 @section Reserved Words
13833 @noindent
13834 All Ada95 reserved words are reserved in project files, and cannot be used
13835 as variable names or project names. In addition, the following are
13836 also reserved in project files:
13838 @itemize
13839 @item @code{extends}
13841 @item @code{external}
13843 @item @code{project}
13845 @end itemize
13847 @node Lexical Elements
13848 @section Lexical Elements
13850 @noindent
13851 Rules for identifiers are the same as in Ada95. Identifiers
13852 are case-insensitive.  Strings are case sensitive, except where noted.
13853 Comments have the same form as in Ada95.
13855 @noindent
13856 Syntax:
13858 @smallexample
13859 simple_name ::=
13860   identifier
13862 name ::=
13863   simple_name @{. simple_name@}
13864 @end smallexample
13866 @node Declarations
13867 @section Declarations
13869 @noindent
13870 Declarations introduce new entities that denote types, variables, attributes,
13871 and packages. Some declarations can only appear immediately within a project
13872 declaration. Others can appear within a project or within a package.
13874 Syntax:
13875 @smallexample
13876 declarative_item ::=
13877   simple_declarative_item |
13878   typed_string_declaration |
13879   package_declaration
13881 simple_declarative_item ::=
13882   variable_declaration |
13883   typed_variable_declaration |
13884   attribute_declaration |
13885   case_construction |
13886   empty_declaration
13887 @end smallexample
13889 @node Empty declarations
13890 @section Empty declarations
13892 @smallexample
13893 empty_declaration ::=
13894   @b{null} ;
13895 @end smallexample
13897 An empty declaration is allowed anywhere a declaration is allowed.
13898 It has no effect.
13900 @node Typed string declarations
13901 @section Typed string declarations
13903 @noindent
13904 Typed strings are sequences of string literals. Typed strings are the only
13905 named types in project files. They are used in case constructions, where they
13906 provide support for conditional attribute definitions.
13908 Syntax:
13909 @smallexample
13910 typed_string_declaration ::=
13911   @b{type} <typed_string_>_simple_name @b{is}
13912    ( string_literal @{, string_literal@} );
13913 @end smallexample
13915 @noindent
13916 A typed string declaration can only appear immediately within a project
13917 declaration.
13919 All the string literals in a typed string declaration must be distinct.
13921 @node Variables
13922 @section Variables
13924 @noindent
13925 Variables denote values, and appear as constituents of expressions.
13927 @smallexample
13928 typed_variable_declaration ::=
13929   <typed_variable_>simple_name : <typed_string_>name :=  string_expression ;
13931 variable_declaration ::=
13932   <variable_>simple_name := expression;
13933 @end smallexample
13935 @noindent
13936 The elaboration of a variable declaration introduces the variable and
13937 assigns to it the value of the expression. The name of the variable is
13938 available after the assignment symbol.
13940 @noindent
13941 A typed_variable can only be declare once.
13943 @noindent
13944 a non typed variable can be declared multiple times.
13946 @noindent
13947 Before the completion of its first declaration, the value of variable
13948 is the null string.
13950 @node Expressions
13951 @section Expressions
13953 @noindent
13954 An expression is a formula that defines a computation or retrieval of a value.
13955 In a project file the value of an expression is either a string or a list
13956 of strings. A string value in an expression is either a literal, the current
13957 value of a variable, an external value, an attribute reference, or a
13958 concatenation operation.
13960 Syntax:
13962 @smallexample
13963 expression ::=
13964   term @{& term@}
13966 term ::=
13967   string_literal |
13968   string_list |
13969   <variable_>name |
13970   external_value |
13971   attribute_reference
13973 string_literal ::=
13974   (same as Ada)
13976 string_list ::=
13977   ( <string_>expression @{ , <string_>expression @} )
13978 @end smallexample
13980 @subsection Concatenation
13981 @noindent
13982 The following concatenation functions are defined:
13984 @smallexample @c ada
13985   function "&" (X : String;      Y : String)      return String;
13986   function "&" (X : String_List; Y : String)      return String_List;
13987   function "&" (X : String_List; Y : String_List) return String_List;
13988 @end smallexample
13990 @node Attributes
13991 @section Attributes
13993 @noindent
13994 An attribute declaration defines a property of a project or package. This
13995 property can later be queried by means of an attribute reference.
13996 Attribute values are strings or string lists.
13998 Some attributes are associative arrays. These attributes are mappings whose
13999 domain is a set of strings. These attributes are declared one association
14000 at a time, by specifying a point in the domain and the corresponding image
14001 of the attribute. They may also be declared as a full associative array,
14002 getting the same associations as the corresponding attribute in an imported
14003 or extended project.
14005 Attributes that are not associative arrays are called simple attributes.
14007 Syntax:
14008 @smallexample
14009 attribute_declaration ::=
14010   full_associative_array_declaration |
14011   @b{for} attribute_designator @b{use} expression ;
14013 full_associative_array_declaration ::=
14014   @b{for} <associative_array_attribute_>simple_name @b{use}
14015   <project_>simple_name [ . <package_>simple_Name ] ' <attribute_>simple_name ;
14017 attribute_designator ::=
14018   <simple_attribute_>simple_name |
14019   <associative_array_attribute_>simple_name ( string_literal )
14020 @end smallexample
14022 @noindent
14023 Some attributes are project-specific, and can only appear immediately within
14024 a project declaration. Others are package-specific, and can only appear within
14025 the proper package.
14027 The expression in an attribute definition must be a string or a string_list.
14028 The string literal appearing in the attribute_designator of an associative
14029 array attribute is case-insensitive.
14031 @node Project Attributes
14032 @section Project Attributes
14034 @noindent
14035 The following attributes apply to a project. All of them are simple
14036 attributes.
14038 @table @code
14039 @item   Object_Dir
14040 Expression must be a path name. The attribute defines the
14041 directory in which the object files created by the build are to be placed. If
14042 not specified, object files are placed in the project directory.
14044 @item   Exec_Dir
14045 Expression must be a path name. The attribute defines the
14046 directory in which the executables created by the build are to be placed.
14047 If not specified, executables are placed in the object directory.
14049 @item  Source_Dirs
14050 Expression must be a list of path names. The attribute
14051 defines the directories in which the source files for the project are to be
14052 found. If not specified, source files are found in the project directory.
14054 @item  Source_Files
14055 Expression must be a list of file names. The attribute
14056 defines the individual files, in the project directory, which are to be used
14057 as sources for the project. File names are path_names that contain no directory
14058 information. If the project has no sources the attribute must be declared
14059 explicitly with an empty list.
14061 @item  Source_List_File
14062 Expression must a single path name. The attribute
14063 defines a text file that contains a list of source file names to be used
14064 as sources for the project
14066 @item  Library_Dir
14067 Expression must be a path name. The attribute defines the
14068 directory in which a  library is to be built.  The directory must exist, must
14069 be distinct from the project's object directory, and must be writable.
14071 @item  Library_Name
14072 Expression must be a string that is a legal file name,
14073 without extension. The attribute defines a string that is used to generate
14074 the name of the library to be built by the project.
14076 @item  Library_Kind
14077 Argument must be a string value that must be one of the
14078 following @code{"static"}, @code{"dynamic"} or @code{"relocatable"}. This
14079 string is case-insensitive. If this attribute is not specified, the library is
14080 a static library. Otherwise, the library may be dynamic or relocatable. This
14081 distinction is operating-system dependent.
14083 @item  Library_Version
14084 Expression must be a string value whose interpretation
14085 is platform dependent. On UNIX, it is used only for dynamic/relocatable
14086 libraries as the internal name of the library (the @code{"soname"}). If the
14087 library file name (built from the @code{Library_Name}) is different from the
14088 @code{Library_Version}, then the library file will be a symbolic link to the
14089 actual file whose name will be @code{Library_Version}.
14091 @item Library_Interface
14092 Expression must be a string list. Each element of the string list
14093 must designate a unit of the project.
14094 If this attribute is present in a Library Project File, then the project
14095 file is a Stand-alone Library_Project_File.
14097 @item Library_Auto_Init
14098 Expression must be a single string "true" or "false", case-insensitive.
14099 If this attribute is present in a Stand-alone Library Project File,
14100 it indicates if initialization is automatic when the dynamic library
14101 is loaded.
14103 @item Library_Options
14104 Expression must be a string list. Indicates additional switches that
14105 are to be used when building a shared library.
14107 @item Library_GCC
14108 Expression must be a single string. Designates an alternative to "gcc"
14109 for building shared libraries.
14111 @item  Library_Src_Dir
14112 Expression must be a path name. The attribute defines the
14113 directory in which the sources of the interfaces of a Stand-alone Library will
14114 be copied.  The directory must exist, must be distinct from the project's
14115 object directory and source directories, and must be writable.
14117 @item  Main
14118 Expression must be a list of strings that are legal file names.
14119 These file names designate existing compilation units in the source directory
14120 that are legal main subprograms.
14122 When a project file is elaborated, as part of the execution of a gnatmake
14123 command, one or several executables are built and placed in the Exec_Dir.
14124 If the gnatmake command does not include explicit file names, the executables
14125 that are built correspond to the files specified by this attribute.
14127 @item Main_Language
14128 This is a simple attribute. Its value is a string that specifies the
14129 language of the main program.
14131 @item  Languages
14132 Expression must be a string list. Each string designates
14133 a programming language that is known to GNAT. The strings are case-insensitive.
14135 @item  Locally_Removed_Files
14136 This attribute is legal only in a project file that extends another.
14137 Expression must be a list of strings that are legal file names.
14138 Each file name must designate a source that would normally be inherited
14139 by the current project file. It cannot designate an immediate source that is
14140 not inherited. Each of the source files in the list are not considered to
14141 be sources of the project file: they are not inherited.
14142 @end table
14144 @node Attribute References
14145 @section Attribute References
14147 @noindent
14148 Attribute references are used to retrieve the value of previously defined
14149 attribute for a package or project.
14150 Syntax:
14151 @smallexample
14152 attribute_reference ::=
14153   attribute_prefix ' <simple_attribute_>simple_name [ ( string_literal ) ]
14155 attribute_prefix ::=
14156   @b{project} |
14157   <project_simple_name | package_identifier |
14158   <project_>simple_name . package_identifier
14159 @end smallexample
14161 @noindent
14162 If an attribute has not been specified for a given package or project, its
14163 value is the null string or the empty list.
14165 @node External Values
14166 @section External Values
14168 @noindent
14169 An external value is an expression whose value is obtained from the command
14170 that invoked the processing of the current project file (typically a
14171 gnatmake command).
14173 Syntax:
14174 @smallexample
14175 external_value ::=
14176   @b{external} ( string_literal [, string_literal] )
14177 @end smallexample
14179 @noindent
14180 The first string_literal is the string to be used on the command line or
14181 in the environment to specify the external value. The second string_literal,
14182 if present, is the default to use if there is no specification for this
14183 external value either on the command line or in the environment.
14185 @node Case Construction
14186 @section Case Construction
14188 @noindent
14189 A case construction supports attribute declarations that depend on the value of
14190 a previously declared variable.
14192 Syntax:
14193 @smallexample
14194 case_construction ::=
14195   @b{case} <typed_variable_>name @b{is}
14196     @{case_item@}
14197   @b{end case} ;
14199 case_item ::=
14200   @b{when} discrete_choice_list =>
14201     @{case_construction | attribute_declaration | empty_declaration@}
14203 discrete_choice_list ::=
14204   string_literal @{| string_literal@} |
14205     @b{others}
14206 @end smallexample
14208 @noindent
14209 All choices in a choice list must be distinct. The choice lists of two
14210 distinct alternatives must be disjoint. Unlike Ada, the choice lists of all
14211 alternatives do not need to include all values of the type. An @code{others}
14212 choice must appear last in the list of alternatives.
14214 @node Packages
14215 @section Packages
14217 @noindent
14218 A package provides a grouping of variable declarations and attribute
14219 declarations to be used when invoking various GNAT tools. The name of
14220 the package indicates the tool(s) to which it applies.
14221 Syntax:
14223 @smallexample
14224 package_declaration ::=
14225   package_specification | package_renaming
14227 package_specification ::=
14228   @b{package} package_identifier @b{is}
14229     @{simple_declarative_item@}
14230   @b{end} package_identifier ;
14232 package_identifier ::=
14233   @code{Naming} | @code{Builder} | @code{Compiler} | @code{Binder} |
14234   @code{Linker} | @code{Finder}  | @code{Cross_Reference} |
14235   @code{gnatls} | @code{IDE}     | @code{Pretty_Printer}
14236 @end smallexample
14238 @subsection Package Naming
14240 @noindent
14241 The attributes of a @code{Naming} package specifies the naming conventions
14242 that apply to the source files in a project. When invoking other GNAT tools,
14243 they will use the sources in the source directories that satisfy these
14244 naming conventions.
14246 The following attributes apply to a @code{Naming} package:
14248 @table @code
14249 @item Casing
14250 This is a simple attribute whose value is a string. Legal values of this
14251 string are @code{"lowercase"}, @code{"uppercase"} or @code{"mixedcase"}.
14252 These strings are themselves case insensitive.
14254 @noindent
14255 If @code{Casing} is not specified, then the default is @code{"lowercase"}.
14257 @item Dot_Replacement
14258 This is a simple attribute whose string value satisfies the following
14259 requirements:
14261 @itemize @bullet
14262 @item It must not be empty
14263 @item It cannot start or end with an alphanumeric character
14264 @item It cannot be a single underscore
14265 @item It cannot start with an underscore followed by an alphanumeric
14266 @item It cannot contain a dot @code{'.'} if longer than one character
14267 @end itemize
14269 @noindent
14270 If @code{Dot_Replacement} is not specified, then the default is @code{"-"}.
14272 @item Spec_Suffix
14273 This is an associative array attribute, defined on language names,
14274 whose image is a string that must satisfy the following
14275 conditions:
14277 @itemize @bullet
14278 @item It must not be empty
14279 @item It cannot start with an alphanumeric character
14280 @item It cannot start with an underscore followed by an alphanumeric character
14281 @end itemize
14283 @noindent
14284 For Ada, the attribute denotes the suffix used in file names that contain
14285 library unit declarations, that is to say units that are package and
14286 subprogram declarations. If @code{Spec_Suffix ("Ada")} is not
14287 specified, then the default is @code{".ads"}.
14289 For C and C++, the attribute denotes the suffix used in file names that
14290 contain prototypes.
14292 @item Body_Suffix
14293 This is an associative array attribute defined on language names,
14294 whose image is a string that must satisfy the following
14295 conditions:
14297 @itemize @bullet
14298 @item It must not be empty
14299 @item It cannot start with an alphanumeric character
14300 @item It cannot start with an underscore followed by an alphanumeric character
14301 @item It cannot be a suffix of @code{Spec_Suffix}
14302 @end itemize
14304 @noindent
14305 For Ada, the attribute denotes the suffix used in file names that contain
14306 library bodies, that is to say units that are package and subprogram bodies.
14307 If @code{Body_Suffix ("Ada")} is not specified, then the default is
14308 @code{".adb"}.
14310 For C and C++, the attribute denotes the suffix used in file names that contain
14311 source code.
14313 @item Separate_Suffix
14314 This is a simple attribute whose value satisfies the same conditions as
14315 @code{Body_Suffix}.
14317 This attribute is specific to Ada. It denotes the suffix used in file names
14318 that contain separate bodies. If it is not specified, then it defaults to same
14319 value as @code{Body_Suffix ("Ada")}.
14321 @item Spec
14322 This is an associative array attribute, specific to Ada, defined over
14323 compilation unit names. The image is a string that is the name of the file
14324 that contains that library unit. The file name is case sensitive if the
14325 conventions of the host operating system require it.
14327 @item Body
14328 This is an associative array attribute, specific to Ada, defined over
14329 compilation unit names. The image is a string that is the name of the file
14330 that contains the library unit body for the named unit. The file name is case
14331 sensitive if the conventions of the host operating system require it.
14333 @item Specification_Exceptions
14334 This is an associative array attribute defined on language names,
14335 whose value is a list of strings.
14337 This attribute is not significant for Ada.
14339 For C and C++, each string in the list denotes the name of a file that
14340 contains prototypes, but whose suffix is not necessarily the
14341 @code{Spec_Suffix} for the language.
14343 @item Implementation_Exceptions
14344 This is an associative array attribute defined on language names,
14345 whose value is a list of strings.
14347 This attribute is not significant for Ada.
14349 For C and C++, each string in the list denotes the name of a file that
14350 contains source code, but whose suffix is not necessarily the
14351 @code{Body_Suffix} for the language.
14352 @end table
14354 The following attributes of package @code{Naming} are obsolescent. They are
14355 kept as synonyms of other attributes for compatibility with previous versions
14356 of the Project Manager.
14358 @table @code
14359 @item Specification_Suffix
14360 This is a synonym of @code{Spec_Suffix}.
14362 @item Implementation_Suffix
14363 This is a synonym of @code{Body_Suffix}.
14365 @item Specification
14366 This is a synonym of @code{Spec}.
14368 @item Implementation
14369 This is a synonym of @code{Body}.
14370 @end table
14372 @subsection package Compiler
14374 @noindent
14375 The attributes of the @code{Compiler} package specify the compilation options
14376 to be used by the underlying compiler.
14378 @table @code
14379 @item  Default_Switches
14380 This is an associative array attribute. Its
14381 domain is a set of language names. Its range is a string list that
14382 specifies the compilation options to be used when compiling a component
14383 written in that language, for which no file-specific switches have been
14384 specified..
14386 @item  Switches
14387 This is an associative array attribute. Its domain is
14388 a set of file names. Its range is a string list that specifies the
14389 compilation options to be used when compiling the named file. If a file
14390 is not specified in the Switches attribute, it is compiled with the
14391 settings specified by Default_Switches.
14393 @item  Local_Configuration_Pragmas.
14394 This is a simple attribute, whose
14395 value is a path name that designates a file containing configuration pragmas
14396 to be used for all invocations of the compiler for immediate sources of the
14397 project.
14399 @item Executable
14400 This is an associative array attribute. Its domain is
14401 a set of main source file names. Its range is a simple string that specifies
14402 the executable file name to be used when linking the specified main source.
14403 If a main source is not specified in the Executable attribute, the executable
14404 file name is deducted from the main source file name.
14405 @end table
14407 @subsection package Builder
14409 @noindent
14410 The attributes of package @code{Builder} specify the compilation, binding, and
14411 linking options to be used when building an executable for a project. The
14412 following attributes apply to package @code{Builder}:
14414 @table @code
14415 @item Default_Switches
14416 As above.
14418 @item Switches
14419 As above.
14421 @item Global_Configuration_Pragmas
14422 This is a simple attribute, whose
14423 value is a path name that designates a file that contains configuration pragmas
14424 to be used in every build of an executable. If both local and global
14425 configuration pragmas are specified, a compilation makes use of both sets.
14427 @item Executable
14428 This is an associative array attribute, defined over
14429 compilation unit names. The image is a string that is the name of the
14430 executable file corresponding to the main source file index.
14431 This attribute has no effect if its value is the empty string.
14433 @item Executable_Suffix
14434 This is a simple attribute whose value is a suffix to be added to
14435 the executables that don't have an attribute Executable specified.
14436 @end table
14438 @subsection package Gnatls
14440 @noindent
14441 The attributes of package @code{Gnatls} specify the tool options to be used
14442 when invoking the library browser @command{gnatls}.
14443 The following attributes apply to package @code{Gnatls}:
14445 @table @code
14446 @item Switches
14447 As above.
14448 @end table
14450 @subsection package Binder
14452 @noindent
14453 The attributes of package @code{Binder} specify the options to be used
14454 when invoking the binder in the construction of an executable.
14455 The following attributes apply to package @code{Binder}:
14457 @table @code
14458 @item     Default_Switches
14459 As above.
14460 @item     Switches
14461 As above.
14462 @end table
14464 @subsection package Linker
14466 @noindent
14467 The attributes of package @code{Linker} specify the options to be used when
14468 invoking the linker in the construction of an executable.
14469 The following attributes apply to package @code{Linker}:
14471 @table @code
14472 @item     Default_Switches
14473 As above
14474 @item     Switches
14475 As above.
14476 @end table
14478 @subsection package Cross_Reference
14480 @noindent
14481 The attributes of package @code{Cross_Reference} specify the tool options
14482 to be used
14483 when invoking the library tool @command{gnatxref}.
14484 The following attributes apply to package @code{Cross_Reference}:
14486 @table @code
14487 @item     Default_Switches
14488 As above.
14489 @item     Switches
14490 As above.
14491 @end table
14493 @subsection package   Finder
14495 @noindent
14496 The attributes of package @code{Finder} specify the tool options to be used
14497 when invoking the search tool @command{gnatfind}.
14498 The following attributes apply to package @code{Finder}:
14500 @table @code
14501 @item     Default_Switches
14502 As above.
14503 @item     Switches
14504 As above.
14505 @end table
14507 @subsection package Pretty_Printer
14509 @noindent
14510 The attributes of package @code{Pretty_Printer}
14511 specify the tool options to be used
14512 when invoking the formatting tool @command{gnatpp}.
14513 The following attributes apply to package @code{Pretty_Printer}:
14515 @table @code
14516 @item     Default_switches
14517 As above.
14518 @item     Switches
14519 As above.
14520 @end table
14522 @subsection  package IDE
14524 @noindent
14525 The attributes of package @code{IDE} specify the options to be used when using
14526 an Integrated Development Environment such as @command{GPS}.
14528 @table @code
14529 @item Remote_Host
14530 This is a simple attribute. Its value is a string that designates the remote
14531 host in a cross-compilation environment, to be used for remote compilation and
14532 debugging. This field should not be specified when running on the local
14533 machine.
14535 @item Program_Host
14536 This is a simple attribute. Its value is a string that specifies the
14537 name of IP address of the embedded target in a cross-compilation environment,
14538 on which the program should execute.
14540 @item Communication_Protocol
14541 This is a simple string attribute. Its value is the name of the protocol
14542 to use to communicate with the target in a cross-compilation environment,
14543 e.g. @code{"wtx"} or @code{"vxworks"}.
14545 @item Compiler_Command
14546 This is an associative array attribute, whose domain is a language name. Its
14547 value is  string that denotes the command to be used to invoke the compiler.
14548 The value of @code{Compiler_Command ("Ada")} is expected to be compatible with
14549 gnatmake, in particular in the handling of switches.
14551 @item Debugger_Command
14552 This is simple attribute, Its value is a string that specifies the name of
14553 the debugger to be used, such as gdb, powerpc-wrs-vxworks-gdb or gdb-4.
14555 @item Default_Switches
14556 This is an associative array attribute. Its indexes are the name of the
14557 external tools that the GNAT Programming System (GPS) is supporting. Its
14558 value is a list of switches to use when invoking that tool.
14560 @item  Gnatlist
14561 This is a simple attribute.  Its value is a string that specifies the name
14562 of the @command{gnatls} utility to be used to retrieve information about the
14563 predefined path; e.g., @code{"gnatls"}, @code{"powerpc-wrs-vxworks-gnatls"}.
14565 @item VCS_Kind
14566 This is a simple atribute. Is value is a string used to specify the
14567 Version Control System (VCS) to be used for this project, e.g CVS, RCS
14568 ClearCase or Perforce.
14570 @item VCS_File_Check
14571 This is a simple attribute. Its value is a string that specifies the
14572 command used by the VCS to check the validity of a file, either
14573 when the user explicitly asks for a check, or as a sanity check before
14574 doing the check-in.
14576 @item VCS_Log_Check
14577 This is a simple attribute. Its value is a string that specifies
14578 the command used by the VCS to check the validity of a log file.
14580 @end table
14582 @node Package Renamings
14583 @section Package Renamings
14585 @noindent
14586 A package can be defined by a renaming declaration. The new package renames
14587 a package declared in a different project file, and has the same attributes
14588 as the package it renames.
14589 Syntax:
14590 @smallexample
14591 package_renaming ::==
14592   @b{package} package_identifier @b{renames}
14593        <project_>simple_name.package_identifier ;
14594 @end smallexample
14596 @noindent
14597 The package_identifier of the renamed package must be the same as the
14598 package_identifier. The project whose name is the prefix of the renamed
14599 package must contain a package declaration with this name. This project
14600 must appear in the context_clause of the enclosing project declaration,
14601 or be the parent project of the enclosing child project.
14603 @node Projects
14604 @section Projects
14606 @noindent
14607 A project file specifies a set of rules for constructing a software system.
14608 A project file can be self-contained, or depend on other project files.
14609 Dependencies are expressed through a context clause that names other projects.
14611 Syntax:
14613 @smallexample
14614 project ::=
14615   context_clause project_declaration
14617 project_declaration ::=
14618   simple_project_declaration | project_extension
14620 simple_project_declaration ::=
14621   @b{project} <project_>simple_name @b{is}
14622     @{declarative_item@}
14623   @b{end} <project_>simple_name;
14625 context_clause ::=
14626   @{with_clause@}
14628 with_clause ::=
14629   [@b{limited}] @b{with} path_name @{ , path_name @} ;
14631 path_name ::=
14632    string_literal
14633 @end smallexample
14635 @noindent
14636 A path name denotes a project file. A path name can be absolute or relative.
14637 An absolute path name includes a sequence of directories, in the syntax of
14638 the host operating system, that identifies uniquely the project file in the
14639 file system. A relative path name identifies the project file, relative
14640 to the directory that contains the current project, or relative to a
14641 directory listed in the environment variable ADA_PROJECT_PATH.
14642 Path names are case sensitive if file names in the host operating system
14643 are case sensitive.
14645 The syntax of the environment variable ADA_PROJECT_PATH is a list of
14646 directory names separated by colons (semicolons on Windows).
14648 A given project name can appear only once in a context_clause.
14650 It is illegal for a project imported by a context clause to refer, directly
14651 or indirectly, to the project in which this context clause appears (the
14652 dependency graph cannot contain cycles), except when one of the with_clause
14653 in the cycle is a @code{limited with}.
14655 @node Project Extensions
14656 @section Project Extensions
14658 @noindent
14659 A project extension introduces a new project, which inherits the declarations
14660 of another project.
14661 Syntax:
14662 @smallexample
14664 project_extension ::=
14665   @b{project} <project_>simple_name  @b{extends} path_name @b{is}
14666     @{declarative_item@}
14667   @b{end} <project_>simple_name;
14668 @end smallexample
14670 @noindent
14671 The project extension declares a child project. The child project inherits
14672 all the declarations and all the files of the parent project, These inherited
14673 declaration can be overridden in the child project, by means of suitable
14674 declarations.
14676 @node Project File Elaboration
14677 @section Project File Elaboration
14679 @noindent
14680 A project file is processed as part of the invocation of a gnat tool that
14681 uses the project option. Elaboration of the process file consists in the
14682 sequential elaboration of all its declarations. The computed values of
14683 attributes and variables in the project are then used to establish the
14684 environment in which the gnat tool will execute.
14686 @node Obsolescent Features
14687 @chapter Obsolescent Features
14689 @noindent
14690 This chapter describes features that are provided by GNAT, but are
14691 considered obsolescent since there are preferred ways of achieving
14692 the same effect. These features are provided solely for historical
14693 compatibility purposes.
14695 @menu
14696 * pragma No_Run_Time::
14697 * pragma Ravenscar::
14698 * pragma Restricted_Run_Time::
14699 @end menu
14701 @node pragma No_Run_Time
14702 @section pragma No_Run_Time
14704 The pragma @code{No_Run_Time} is used to achieve an affect similar
14705 to the use of the "Zero Foot Print" configurable run time, but without
14706 requiring a specially configured run time. The result of using this
14707 pragma, which must be used for all units in a partition, is to restrict
14708 the use of any language features requiring run-time support code. The
14709 preferred usage is to use an appropriately configured run-time that
14710 includes just those features that are to be made accessible.
14712 @node pragma Ravenscar
14713 @section pragma Ravenscar
14715 The pragma @code{Ravenscar} has exactly the same effect as pragma
14716 @code{Profile (Ravenscar)}. The latter usage is preferred since it
14717 is part of the new Ada 2005 standard.
14719 @node pragma Restricted_Run_Time
14720 @section pragma Restricted_Run_Time
14722 The pragma @code{Restricted_Run_Time} has exactly the same effect as
14723 pragma @code{Profile (Restricted)}. The latter usage is
14724 preferred since the Ada 2005 pragma @code{Profile} is intended for
14725 this kind of implementation dependent addition.
14727 @include fdl.texi
14728 @c GNU Free Documentation License
14730 @node Index,,GNU Free Documentation License, Top
14731 @unnumbered Index
14733 @printindex cp
14735 @contents
14737 @bye