OSDN Git Service

* gnat-style.texi, gnat_rm.texi, gnat_ugn.texi: Remove RCS tags.
[pf3gnuchains/gcc-fork.git] / gcc / ada / gnat_rm.texi
1 \input texinfo   @c -*-texinfo-*-
2
3 @c %**start of header
4
5 @c oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
6 @c                                                                            o
7 @c                           GNAT DOCUMENTATION                               o
8 @c                                                                            o
9 @c                              G N A T _ RM                                  o
10 @c                                                                            o
11 @c              Copyright (C) 1995-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
17
18 @setfilename gnat_rm.info
19 @settitle GNAT Reference Manual
20 @setchapternewpage odd
21 @syncodeindex fn cp
22
23 @include gcc-common.texi
24
25 @dircategory GNU Ada tools
26 @direntry
27 * GNAT Reference Manual: (gnat_rm).  Reference Manual for GNU Ada tools.
28 @end direntry
29
30 @copying
31 Copyright @copyright{} 1995-2004, Free Software Foundation
32
33 Permission is granted to copy, distribute and/or modify this document
34 under the terms of the GNU Free Documentation License, Version 1.2
35 or any later version published by the Free Software Foundation;
36 with the Invariant Sections being ``GNU Free Documentation License'',
37 with the Front-Cover Texts being ``GNAT Reference Manual'', and with
38 no Back-Cover Texts. A copy of the license is included in the section
39 entitled ``GNU Free Documentation License''.
40 @end copying
41
42 @titlepage
43
44 @title GNAT Reference Manual
45 @subtitle GNAT, The GNU Ada 95 Compiler
46 @subtitle GCC version @value{version-GCC}
47 @author Ada Core Technologies, Inc.
48
49 @page
50 @vskip 0pt plus 1filll
51
52 @insertcopying
53
54 @end titlepage
55
56 @ifnottex
57 @node Top, About This Guide, (dir), (dir)
58 @top GNAT Reference Manual
59
60 @noindent
61 GNAT Reference Manual
62
63 @noindent
64 GNAT, The GNU Ada 95 Compiler@*
65 Version for GCC @value{version-GCC}@*
66
67 @noindent
68 Ada Core Technologies, Inc.
69
70 @menu
71 * About This Guide::
72 * Implementation Defined Pragmas::
73 * Implementation Defined Attributes::
74 * Implementation Advice::
75 * Implementation Defined Characteristics::
76 * Intrinsic Subprograms::
77 * Representation Clauses and Pragmas::
78 * Standard Library Routines::
79 * The Implementation of Standard I/O::
80 * The GNAT Library::
81 * Interfacing to Other Languages::
82 * Specialized Needs Annexes::
83 * Implementation of Specific Ada Features::
84 * Project File Reference::
85 * GNU Free Documentation License::
86 * Index::
87
88  --- The Detailed Node Listing ---
89
90 About This Guide
91
92 * What This Reference Manual Contains::
93 * Related Information::
94
95 Implementation Defined Pragmas
96
97 * Pragma Abort_Defer::
98 * Pragma Ada_83::
99 * Pragma Ada_95::
100 * Pragma Annotate::
101 * Pragma Assert::
102 * Pragma Ast_Entry::
103 * Pragma C_Pass_By_Copy::
104 * Pragma Comment::
105 * Pragma Common_Object::
106 * Pragma Compile_Time_Warning::
107 * Pragma Complex_Representation::
108 * Pragma Component_Alignment::
109 * Pragma Convention_Identifier::
110 * Pragma CPP_Class::
111 * Pragma CPP_Constructor::
112 * Pragma CPP_Virtual::
113 * Pragma CPP_Vtable::
114 * Pragma Debug::
115 * Pragma Elaboration_Checks::
116 * Pragma Eliminate::
117 * Pragma Export_Exception::
118 * Pragma Export_Function::
119 * Pragma Export_Object::
120 * Pragma Export_Procedure::
121 * Pragma Export_Value::
122 * Pragma Export_Valued_Procedure::
123 * Pragma Extend_System::
124 * Pragma External::
125 * Pragma External_Name_Casing::
126 * Pragma Finalize_Storage_Only::
127 * Pragma Float_Representation::
128 * Pragma Ident::
129 * Pragma Import_Exception::
130 * Pragma Import_Function::
131 * Pragma Import_Object::
132 * Pragma Import_Procedure::
133 * Pragma Import_Valued_Procedure::
134 * Pragma Initialize_Scalars::
135 * Pragma Inline_Always::
136 * Pragma Inline_Generic::
137 * Pragma Interface::
138 * Pragma Interface_Name::
139 * Pragma Interrupt_Handler::
140 * Pragma Interrupt_State::
141 * Pragma Keep_Names::
142 * Pragma License::
143 * Pragma Link_With::
144 * Pragma Linker_Alias::
145 * Pragma Linker_Section::
146 * Pragma Long_Float::
147 * Pragma Machine_Attribute::
148 * Pragma Main_Storage::
149 * Pragma No_Return::
150 * Pragma Normalize_Scalars::
151 * Pragma Obsolescent::
152 * Pragma Passive::
153 * Pragma Polling::
154 * Pragma Propagate_Exceptions::
155 * Pragma Psect_Object::
156 * Pragma Pure_Function::
157 * Pragma Ravenscar::
158 * Pragma Restricted_Run_Time::
159 * Pragma Restriction_Warnings::
160 * Pragma Source_File_Name::
161 * Pragma Source_File_Name_Project::
162 * Pragma Source_Reference::
163 * Pragma Stream_Convert::
164 * Pragma Style_Checks::
165 * Pragma Subtitle::
166 * Pragma Suppress_All::
167 * Pragma Suppress_Exception_Locations::
168 * Pragma Suppress_Initialization::
169 * Pragma Task_Info::
170 * Pragma Task_Name::
171 * Pragma Task_Storage::
172 * Pragma Thread_Body::
173 * Pragma Time_Slice::
174 * Pragma Title::
175 * Pragma Unchecked_Union::
176 * Pragma Unimplemented_Unit::
177 * Pragma Universal_Data::
178 * Pragma Unreferenced::
179 * Pragma Unreserve_All_Interrupts::
180 * Pragma Unsuppress::
181 * Pragma Use_VADS_Size::
182 * Pragma Validity_Checks::
183 * Pragma Volatile::
184 * Pragma Warnings::
185 * Pragma Weak_External::
186
187 Implementation Defined Attributes
188
189 * Abort_Signal::
190 * Address_Size::
191 * Asm_Input::
192 * Asm_Output::
193 * AST_Entry::
194 * Bit::
195 * Bit_Position::
196 * Code_Address::
197 * Default_Bit_Order::
198 * Elaborated::
199 * Elab_Body::
200 * Elab_Spec::
201 * Emax::
202 * Enum_Rep::
203 * Epsilon::
204 * Fixed_Value::
205 * Has_Discriminants::
206 * Img::
207 * Integer_Value::
208 * Large::
209 * Machine_Size::
210 * Mantissa::
211 * Max_Interrupt_Priority::
212 * Max_Priority::
213 * Maximum_Alignment::
214 * Mechanism_Code::
215 * Null_Parameter::
216 * Object_Size::
217 * Passed_By_Reference::
218 * Range_Length::
219 * Safe_Emax::
220 * Safe_Large::
221 * Small::
222 * Storage_Unit::
223 * Target_Name::
224 * Tick::
225 * To_Address::
226 * Type_Class::
227 * UET_Address::
228 * Unconstrained_Array::
229 * Universal_Literal_String::
230 * Unrestricted_Access::
231 * VADS_Size::
232 * Value_Size::
233 * Wchar_T_Size::
234 * Word_Size::
235
236 The Implementation of Standard I/O
237
238 * Standard I/O Packages::
239 * FORM Strings::
240 * Direct_IO::
241 * Sequential_IO::
242 * Text_IO::
243 * Wide_Text_IO::
244 * Stream_IO::
245 * Shared Files::
246 * Open Modes::
247 * Operations on C Streams::
248 * Interfacing to C Streams::
249
250 The GNAT Library
251
252 * Ada.Characters.Latin_9 (a-chlat9.ads)::
253 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
254 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
255 * Ada.Command_Line.Remove (a-colire.ads)::
256 * Ada.Command_Line.Environment (a-colien.ads)::
257 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
258 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
259 * Ada.Exceptions.Traceback (a-exctra.ads)::
260 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
261 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
262 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
263 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
264 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
265 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
266 * GNAT.Array_Split (g-arrspl.ads)::
267 * GNAT.AWK (g-awk.ads)::
268 * GNAT.Bounded_Buffers (g-boubuf.ads)::
269 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
270 * GNAT.Bubble_Sort (g-bubsor.ads)::
271 * GNAT.Bubble_Sort_A (g-busora.ads)::
272 * GNAT.Bubble_Sort_G (g-busorg.ads)::
273 * GNAT.Calendar (g-calend.ads)::
274 * GNAT.Calendar.Time_IO (g-catiio.ads)::
275 * GNAT.Case_Util (g-casuti.ads)::
276 * GNAT.CGI (g-cgi.ads)::
277 * GNAT.CGI.Cookie (g-cgicoo.ads)::
278 * GNAT.CGI.Debug (g-cgideb.ads)::
279 * GNAT.Command_Line (g-comlin.ads)::
280 * GNAT.Compiler_Version (g-comver.ads)::
281 * GNAT.Ctrl_C (g-ctrl_c.ads)::
282 * GNAT.CRC32 (g-crc32.ads)::
283 * GNAT.Current_Exception (g-curexc.ads)::
284 * GNAT.Debug_Pools (g-debpoo.ads)::
285 * GNAT.Debug_Utilities (g-debuti.ads)::
286 * GNAT.Directory_Operations (g-dirope.ads)::
287 * GNAT.Dynamic_HTables (g-dynhta.ads)::
288 * GNAT.Dynamic_Tables (g-dyntab.ads)::
289 * GNAT.Exception_Actions (g-excact.ads)::
290 * GNAT.Exception_Traces (g-exctra.ads)::
291 * GNAT.Exceptions (g-except.ads)::
292 * GNAT.Expect (g-expect.ads)::
293 * GNAT.Float_Control (g-flocon.ads)::
294 * GNAT.Heap_Sort (g-heasor.ads)::
295 * GNAT.Heap_Sort_A (g-hesora.ads)::
296 * GNAT.Heap_Sort_G (g-hesorg.ads)::
297 * GNAT.HTable (g-htable.ads)::
298 * GNAT.IO (g-io.ads)::
299 * GNAT.IO_Aux (g-io_aux.ads)::
300 * GNAT.Lock_Files (g-locfil.ads)::
301 * GNAT.MD5 (g-md5.ads)::
302 * GNAT.Memory_Dump (g-memdum.ads)::
303 * GNAT.Most_Recent_Exception (g-moreex.ads)::
304 * GNAT.OS_Lib (g-os_lib.ads)::
305 * GNAT.Perfect_Hash.Generators (g-pehage.ads)::
306 * GNAT.Regexp (g-regexp.ads)::
307 * GNAT.Registry (g-regist.ads)::
308 * GNAT.Regpat (g-regpat.ads)::
309 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
310 * GNAT.Semaphores (g-semaph.ads)::
311 * GNAT.Signals (g-signal.ads)::
312 * GNAT.Sockets (g-socket.ads)::
313 * GNAT.Source_Info (g-souinf.ads)::
314 * GNAT.Spell_Checker (g-speche.ads)::
315 * GNAT.Spitbol.Patterns (g-spipat.ads)::
316 * GNAT.Spitbol (g-spitbo.ads)::
317 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
318 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
319 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
320 * GNAT.Strings (g-string.ads)::
321 * GNAT.String_Split (g-strspl.ads)::
322 * GNAT.Table (g-table.ads)::
323 * GNAT.Task_Lock (g-tasloc.ads)::
324 * GNAT.Threads (g-thread.ads)::
325 * GNAT.Traceback (g-traceb.ads)::
326 * GNAT.Traceback.Symbolic (g-trasym.ads)::
327 * GNAT.Wide_String_Split (g-wistsp.ads)::
328 * Interfaces.C.Extensions (i-cexten.ads)::
329 * Interfaces.C.Streams (i-cstrea.ads)::
330 * Interfaces.CPP (i-cpp.ads)::
331 * Interfaces.Os2lib (i-os2lib.ads)::
332 * Interfaces.Os2lib.Errors (i-os2err.ads)::
333 * Interfaces.Os2lib.Synchronization (i-os2syn.ads)::
334 * Interfaces.Os2lib.Threads (i-os2thr.ads)::
335 * Interfaces.Packed_Decimal (i-pacdec.ads)::
336 * Interfaces.VxWorks (i-vxwork.ads)::
337 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
338 * System.Address_Image (s-addima.ads)::
339 * System.Assertions (s-assert.ads)::
340 * System.Memory (s-memory.ads)::
341 * System.Partition_Interface (s-parint.ads)::
342 * System.Restrictions (s-restri.ads)::
343 * System.Rident (s-rident.ads)::
344 * System.Task_Info (s-tasinf.ads)::
345 * System.Wch_Cnv (s-wchcnv.ads)::
346 * System.Wch_Con (s-wchcon.ads)::
347
348 Text_IO
349
350 * Text_IO Stream Pointer Positioning::
351 * Text_IO Reading and Writing Non-Regular Files::
352 * Get_Immediate::
353 * Treating Text_IO Files as Streams::
354 * Text_IO Extensions::
355 * Text_IO Facilities for Unbounded Strings::
356
357 Wide_Text_IO
358
359 * Wide_Text_IO Stream Pointer Positioning::
360 * Wide_Text_IO Reading and Writing Non-Regular Files::
361
362 Interfacing to Other Languages
363
364 * Interfacing to C::
365 * Interfacing to C++::
366 * Interfacing to COBOL::
367 * Interfacing to Fortran::
368 * Interfacing to non-GNAT Ada code::
369
370 Specialized Needs Annexes
371
372 Implementation of Specific Ada Features
373 * Machine Code Insertions::
374 * GNAT Implementation of Tasking::
375 * GNAT Implementation of Shared Passive Packages::
376 * Code Generation for Array Aggregates::
377
378 Project File Reference
379
380 GNU Free Documentation License
381
382 Index
383 @end menu
384
385 @end ifnottex
386
387 @node About This Guide
388 @unnumbered About This Guide
389
390 @noindent
391 This manual contains useful information in writing programs using the
392 GNAT compiler.  It includes information on implementation dependent
393 characteristics of GNAT, including all the information required by Annex
394 M of the standard.
395
396 Ada 95 is designed to be highly portable.
397 In general, a program will have the same effect even when compiled by
398 different compilers on different platforms.
399 However, since Ada 95 is designed to be used in a
400 wide variety of applications, it also contains a number of system
401 dependent features to be used in interfacing to the external world.
402 @cindex Implementation-dependent features
403 @cindex Portability
404
405 Note: Any program that makes use of implementation-dependent features
406 may be non-portable.  You should follow good programming practice and
407 isolate and clearly document any sections of your program that make use
408 of these features in a non-portable manner.
409
410 @menu
411 * What This Reference Manual Contains::
412 * Conventions::
413 * Related Information::
414 @end menu
415
416 @node What This Reference Manual Contains
417 @unnumberedsec What This Reference Manual Contains
418
419 @noindent
420 This reference manual contains the following chapters:
421
422 @itemize @bullet
423 @item
424 @ref{Implementation Defined Pragmas}, lists GNAT implementation-dependent
425 pragmas, which can be used to extend and enhance the functionality of the
426 compiler.
427
428 @item
429 @ref{Implementation Defined Attributes}, lists GNAT
430 implementation-dependent attributes which can be used to extend and
431 enhance the functionality of the compiler.
432
433 @item
434 @ref{Implementation Advice}, provides information on generally
435 desirable behavior which are not requirements that all compilers must
436 follow since it cannot be provided on all systems, or which may be
437 undesirable on some systems.
438
439 @item
440 @ref{Implementation Defined Characteristics}, provides a guide to
441 minimizing implementation dependent features.
442
443 @item
444 @ref{Intrinsic Subprograms}, describes the intrinsic subprograms
445 implemented by GNAT, and how they can be imported into user
446 application programs.
447
448 @item
449 @ref{Representation Clauses and Pragmas}, describes in detail the
450 way that GNAT represents data, and in particular the exact set
451 of representation clauses and pragmas that is accepted.
452
453 @item
454 @ref{Standard Library Routines}, provides a listing of packages and a
455 brief description of the functionality that is provided by Ada's
456 extensive set of standard library routines as implemented by GNAT@.
457
458 @item
459 @ref{The Implementation of Standard I/O}, details how the GNAT
460 implementation of the input-output facilities.
461
462 @item
463 @ref{The GNAT Library}, is a catalog of packages that complement
464 the Ada predefined library.
465
466 @item
467 @ref{Interfacing to Other Languages}, describes how programs
468 written in Ada using GNAT can be interfaced to other programming
469 languages.
470
471 @ref{Specialized Needs Annexes}, describes the GNAT implementation of all
472 of the specialized needs annexes.
473
474 @item
475 @ref{Implementation of Specific Ada Features}, discusses issues related
476 to GNAT's implementation of machine code insertions, tasking, and several
477 other features.
478
479 @item
480 @ref{Project File Reference}, presents the syntax and semantics
481 of project files.
482
483 @end itemize
484
485 @cindex Ada 95 ISO/ANSI Standard
486 @noindent
487 This reference manual assumes that you are familiar with Ada 95
488 language, as described in the International Standard
489 ANSI/ISO/IEC-8652:1995, Jan 1995.
490
491 @node Conventions
492 @unnumberedsec Conventions
493 @cindex Conventions, typographical
494 @cindex Typographical conventions
495
496 @noindent
497 Following are examples of the typographical and graphic conventions used
498 in this guide:
499
500 @itemize @bullet
501 @item
502 @code{Functions}, @code{utility program names}, @code{standard names},
503 and @code{classes}.
504
505 @item
506 @code{Option flags}
507
508 @item
509 @file{File Names}, @samp{button names}, and @samp{field names}.
510
511 @item
512 @code{Variables}.
513
514 @item
515 @emph{Emphasis}.
516
517 @item
518 [optional information or parameters]
519
520 @item
521 Examples are described by text
522 @smallexample
523 and then shown this way.
524 @end smallexample
525 @end itemize
526
527 @noindent
528 Commands that are entered by the user are preceded in this manual by the
529 characters @samp{$ } (dollar sign followed by space).  If your system uses this
530 sequence as a prompt, then the commands will appear exactly as you see them
531 in the manual.  If your system uses some other prompt, then the command will
532 appear with the @samp{$} replaced by whatever prompt character you are using.
533
534 @node Related Information
535 @unnumberedsec Related Information
536 @noindent
537 See the following documents for further information on GNAT:
538
539 @itemize @bullet
540 @item
541 @cite{GNAT User's Guide}, which provides information on how to use
542 the GNAT compiler system.
543
544 @item
545 @cite{Ada 95 Reference Manual}, which contains all reference
546 material for the Ada 95 programming language.
547
548 @item
549 @cite{Ada 95 Annotated Reference Manual}, which is an annotated version
550 of the standard reference manual cited above.  The annotations describe
551 detailed aspects of the design decision, and in particular contain useful
552 sections on Ada 83 compatibility.
553
554 @item
555 @cite{DEC Ada, Technical Overview and Comparison on DIGITAL Platforms},
556 which contains specific information on compatibility between GNAT and
557 DEC Ada 83 systems.
558
559 @item
560 @cite{DEC Ada, Language Reference Manual, part number AA-PYZAB-TK} which
561 describes in detail the pragmas and attributes provided by the DEC Ada 83
562 compiler system.
563
564 @end itemize
565
566 @node Implementation Defined Pragmas
567 @chapter Implementation Defined Pragmas
568
569 @noindent
570 Ada 95 defines a set of pragmas that can be used to supply additional
571 information to the compiler.  These language defined pragmas are
572 implemented in GNAT and work as described in the Ada 95 Reference
573 Manual.
574
575 In addition, Ada 95 allows implementations to define additional pragmas
576 whose meaning is defined by the implementation.  GNAT provides a number
577 of these implementation-dependent pragmas which can be used to extend
578 and enhance the functionality of the compiler.  This section of the GNAT
579 Reference Manual describes these additional pragmas.
580
581 Note that any program using these pragmas may not be portable to other
582 compilers (although GNAT implements this set of pragmas on all
583 platforms).  Therefore if portability to other compilers is an important
584 consideration, the use of these pragmas should be minimized.
585
586 @menu
587 * Pragma Abort_Defer::
588 * Pragma Ada_83::
589 * Pragma Ada_95::
590 * Pragma Annotate::
591 * Pragma Assert::
592 * Pragma Ast_Entry::
593 * Pragma C_Pass_By_Copy::
594 * Pragma Comment::
595 * Pragma Common_Object::
596 * Pragma Compile_Time_Warning::
597 * Pragma Complex_Representation::
598 * Pragma Component_Alignment::
599 * Pragma Convention_Identifier::
600 * Pragma CPP_Class::
601 * Pragma CPP_Constructor::
602 * Pragma CPP_Virtual::
603 * Pragma CPP_Vtable::
604 * Pragma Debug::
605 * Pragma Elaboration_Checks::
606 * Pragma Eliminate::
607 * Pragma Export_Exception::
608 * Pragma Export_Function::
609 * Pragma Export_Object::
610 * Pragma Export_Procedure::
611 * Pragma Export_Value::
612 * Pragma Export_Valued_Procedure::
613 * Pragma Extend_System::
614 * Pragma External::
615 * Pragma External_Name_Casing::
616 * Pragma Finalize_Storage_Only::
617 * Pragma Float_Representation::
618 * Pragma Ident::
619 * Pragma Import_Exception::
620 * Pragma Import_Function::
621 * Pragma Import_Object::
622 * Pragma Import_Procedure::
623 * Pragma Import_Valued_Procedure::
624 * Pragma Initialize_Scalars::
625 * Pragma Inline_Always::
626 * Pragma Inline_Generic::
627 * Pragma Interface::
628 * Pragma Interface_Name::
629 * Pragma Interrupt_Handler::
630 * Pragma Interrupt_State::
631 * Pragma Keep_Names::
632 * Pragma License::
633 * Pragma Link_With::
634 * Pragma Linker_Alias::
635 * Pragma Linker_Section::
636 * Pragma Long_Float::
637 * Pragma Machine_Attribute::
638 * Pragma Main_Storage::
639 * Pragma No_Return::
640 * Pragma Normalize_Scalars::
641 * Pragma Obsolescent::
642 * Pragma Passive::
643 * Pragma Polling::
644 * Pragma Propagate_Exceptions::
645 * Pragma Psect_Object::
646 * Pragma Pure_Function::
647 * Pragma Ravenscar::
648 * Pragma Restricted_Run_Time::
649 * Pragma Restriction_Warnings::
650 * Pragma Source_File_Name::
651 * Pragma Source_File_Name_Project::
652 * Pragma Source_Reference::
653 * Pragma Stream_Convert::
654 * Pragma Style_Checks::
655 * Pragma Subtitle::
656 * Pragma Suppress_All::
657 * Pragma Suppress_Exception_Locations::
658 * Pragma Suppress_Initialization::
659 * Pragma Task_Info::
660 * Pragma Task_Name::
661 * Pragma Task_Storage::
662 * Pragma Thread_Body::
663 * Pragma Time_Slice::
664 * Pragma Title::
665 * Pragma Unchecked_Union::
666 * Pragma Unimplemented_Unit::
667 * Pragma Universal_Data::
668 * Pragma Unreferenced::
669 * Pragma Unreserve_All_Interrupts::
670 * Pragma Unsuppress::
671 * Pragma Use_VADS_Size::
672 * Pragma Validity_Checks::
673 * Pragma Volatile::
674 * Pragma Warnings::
675 * Pragma Weak_External::
676 @end menu
677
678 @node Pragma Abort_Defer
679 @unnumberedsec Pragma Abort_Defer
680 @findex Abort_Defer
681 @cindex Deferring aborts
682 @noindent
683 Syntax:
684 @smallexample
685 pragma Abort_Defer;
686 @end smallexample
687
688 @noindent
689 This pragma must appear at the start of the statement sequence of a
690 handled sequence of statements (right after the @code{begin}).  It has
691 the effect of deferring aborts for the sequence of statements (but not
692 for the declarations or handlers, if any, associated with this statement
693 sequence).
694
695 @node Pragma Ada_83
696 @unnumberedsec Pragma Ada_83
697 @findex Ada_83
698 @noindent
699 Syntax:
700 @smallexample @c ada
701 pragma Ada_83;
702 @end smallexample
703
704 @noindent
705 A configuration pragma that establishes Ada 83 mode for the unit to
706 which it applies, regardless of the mode set by the command line
707 switches.  In Ada 83 mode, GNAT attempts to be as compatible with
708 the syntax and semantics of Ada 83, as defined in the original Ada
709 83 Reference Manual as possible.  In particular, the new Ada 95
710 keywords are not recognized, optional package bodies are allowed,
711 and generics may name types with unknown discriminants without using
712 the @code{(<>)} notation.  In addition, some but not all of the additional
713 restrictions of Ada 83 are enforced.
714
715 Ada 83 mode is intended for two purposes.  Firstly, it allows existing
716 legacy Ada 83 code to be compiled and adapted to GNAT with less effort.
717 Secondly, it aids in keeping code backwards compatible with Ada 83.
718 However, there is no guarantee that code that is processed correctly
719 by GNAT in Ada 83 mode will in fact compile and execute with an Ada
720 83 compiler, since GNAT does not enforce all the additional checks
721 required by Ada 83.
722
723 @node Pragma Ada_95
724 @unnumberedsec Pragma Ada_95
725 @findex Ada_95
726 @noindent
727 Syntax:
728 @smallexample @c ada
729 pragma Ada_95;
730 @end smallexample
731
732 @noindent
733 A configuration pragma that establishes Ada 95 mode for the unit to which
734 it applies, regardless of the mode set by the command line switches.
735 This mode is set automatically for the @code{Ada} and @code{System}
736 packages and their children, so you need not specify it in these
737 contexts.  This pragma is useful when writing a reusable component that
738 itself uses Ada 95 features, but which is intended to be usable from
739 either Ada 83 or Ada 95 programs.
740
741 @node Pragma Annotate
742 @unnumberedsec Pragma Annotate
743 @findex Annotate
744 @noindent
745 Syntax:
746 @smallexample @c ada
747 pragma Annotate (IDENTIFIER @{, ARG@});
748
749 ARG ::= NAME | EXPRESSION
750 @end smallexample
751
752 @noindent
753 This pragma is used to annotate programs.  @var{identifier} identifies
754 the type of annotation.  GNAT verifies this is an identifier, but does
755 not otherwise analyze it.  The @var{arg} argument
756 can be either a string literal or an
757 expression.  String literals are assumed to be of type
758 @code{Standard.String}.  Names of entities are simply analyzed as entity
759 names.  All other expressions are analyzed as expressions, and must be
760 unambiguous.
761
762 The analyzed pragma is retained in the tree, but not otherwise processed
763 by any part of the GNAT compiler.  This pragma is intended for use by
764 external tools, including ASIS@.
765
766 @node Pragma Assert
767 @unnumberedsec Pragma Assert
768 @findex Assert
769 @noindent
770 Syntax:
771 @smallexample @c ada
772 pragma Assert (
773   boolean_EXPRESSION
774   [, static_string_EXPRESSION]);
775 @end smallexample
776
777 @noindent
778 The effect of this pragma depends on whether the corresponding command
779 line switch is set to activate assertions.  The pragma expands into code
780 equivalent to the following:
781
782 @smallexample @c ada
783 if assertions-enabled then
784    if not boolean_EXPRESSION then
785       System.Assertions.Raise_Assert_Failure
786         (string_EXPRESSION);
787    end if;
788 end if;
789 @end smallexample
790
791 @noindent
792 The string argument, if given, is the message that will be associated
793 with the exception occurrence if the exception is raised.  If no second
794 argument is given, the default message is @samp{@var{file}:@var{nnn}},
795 where @var{file} is the name of the source file containing the assert,
796 and @var{nnn} is the line number of the assert.  A pragma is not a
797 statement, so if a statement sequence contains nothing but a pragma
798 assert, then a null statement is required in addition, as in:
799
800 @smallexample @c ada
801 @dots{}
802 if J > 3 then
803    pragma Assert (K > 3, "Bad value for K");
804    null;
805 end if;
806 @end smallexample
807
808 @noindent
809 Note that, as with the @code{if} statement to which it is equivalent, the
810 type of the expression is either @code{Standard.Boolean}, or any type derived
811 from this standard type.
812
813 If assertions are disabled (switch @code{-gnata} not used), then there
814 is no effect (and in particular, any side effects from the expression
815 are suppressed).  More precisely it is not quite true that the pragma
816 has no effect, since the expression is analyzed, and may cause types
817 to be frozen if they are mentioned here for the first time.
818
819 If assertions are enabled, then the given expression is tested, and if
820 it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
821 which results in the raising of @code{Assert_Failure} with the given message.
822
823 If the boolean expression has side effects, these side effects will turn
824 on and off with the setting of the assertions mode, resulting in
825 assertions that have an effect on the program.  You should generally
826 avoid side effects in the expression arguments of this pragma.  However,
827 the expressions are analyzed for semantic correctness whether or not
828 assertions are enabled, so turning assertions on and off cannot affect
829 the legality of a program.
830
831 @node Pragma Ast_Entry
832 @unnumberedsec Pragma Ast_Entry
833 @cindex OpenVMS
834 @findex Ast_Entry
835 @noindent
836 Syntax:
837 @smallexample @c ada
838 pragma AST_Entry (entry_IDENTIFIER);
839 @end smallexample
840
841 @noindent
842 This pragma is implemented only in the OpenVMS implementation of GNAT@.  The
843 argument is the simple name of a single entry; at most one @code{AST_Entry}
844 pragma is allowed for any given entry.  This pragma must be used in
845 conjunction with the @code{AST_Entry} attribute, and is only allowed after
846 the entry declaration and in the same task type specification or single task
847 as the entry to which it applies.  This pragma specifies that the given entry
848 may be used to handle an OpenVMS asynchronous system trap (@code{AST})
849 resulting from an OpenVMS system service call.  The pragma does not affect
850 normal use of the entry.  For further details on this pragma, see the
851 DEC Ada Language Reference Manual, section 9.12a.
852
853 @node Pragma C_Pass_By_Copy
854 @unnumberedsec Pragma C_Pass_By_Copy
855 @cindex Passing by copy
856 @findex C_Pass_By_Copy
857 @noindent
858 Syntax:
859 @smallexample @c ada
860 pragma C_Pass_By_Copy
861   ([Max_Size =>] static_integer_EXPRESSION);
862 @end smallexample
863
864 @noindent
865 Normally the default mechanism for passing C convention records to C
866 convention subprograms is to pass them by reference, as suggested by RM
867 B.3(69).  Use the configuration pragma @code{C_Pass_By_Copy} to change
868 this default, by requiring that record formal parameters be passed by
869 copy if all of the following conditions are met:
870
871 @itemize @bullet
872 @item
873 The size of the record type does not exceed@*@var{static_integer_expression}.
874 @item
875 The record type has @code{Convention C}.
876 @item
877 The formal parameter has this record type, and the subprogram has a
878 foreign (non-Ada) convention.
879 @end itemize
880
881 @noindent
882 If these conditions are met the argument is passed by copy, i.e.@: in a
883 manner consistent with what C expects if the corresponding formal in the
884 C prototype is a struct (rather than a pointer to a struct).
885
886 You can also pass records by copy by specifying the convention
887 @code{C_Pass_By_Copy} for the record type, or by using the extended
888 @code{Import} and @code{Export} pragmas, which allow specification of
889 passing mechanisms on a parameter by parameter basis.
890
891 @node Pragma Comment
892 @unnumberedsec Pragma Comment
893 @findex Comment
894 @noindent
895 Syntax:
896
897 @smallexample @c ada
898 pragma Comment (static_string_EXPRESSION);
899 @end smallexample
900
901 @noindent
902 This is almost identical in effect to pragma @code{Ident}.  It allows the
903 placement of a comment into the object file and hence into the
904 executable file if the operating system permits such usage.  The
905 difference is that @code{Comment}, unlike @code{Ident}, has
906 no limitations on placement of the pragma (it can be placed
907 anywhere in the main source unit), and if more than one pragma
908 is used, all comments are retained.
909
910 @node Pragma Common_Object
911 @unnumberedsec Pragma Common_Object
912 @findex Common_Object
913 @noindent
914 Syntax:
915
916 @smallexample @c ada
917 pragma Common_Object (
918      [Internal =>] LOCAL_NAME,
919   [, [External =>] EXTERNAL_SYMBOL]
920   [, [Size     =>] EXTERNAL_SYMBOL] );
921
922 EXTERNAL_SYMBOL ::=
923   IDENTIFIER
924 | static_string_EXPRESSION
925 @end smallexample
926
927 @noindent
928 This pragma enables the shared use of variables stored in overlaid
929 linker areas corresponding to the use of @code{COMMON}
930 in Fortran.  The single
931 object @var{local_name} is assigned to the area designated by
932 the @var{External} argument.
933 You may define a record to correspond to a series
934 of fields.  The @var{size} argument
935 is syntax checked in GNAT, but otherwise ignored.
936
937 @code{Common_Object} is not supported on all platforms.  If no
938 support is available, then the code generator will issue a message
939 indicating that the necessary attribute for implementation of this
940 pragma is not available.
941
942 @node Pragma Compile_Time_Warning
943 @unnumberedsec Pragma Compile_Time_Warning
944 @findex Compile_Time_Warning
945 @noindent
946 Syntax:
947
948 @smallexample @c ada
949 pragma Compile_Time_Warning
950          (boolean_EXPRESSION, static_string_EXPRESSION);
951 @end smallexample
952
953 @noindent
954 This pragma can be used to generate additional compile time warnings. It
955 is particularly useful in generics, where warnings can be issued for
956 specific problematic instantiations. The first parameter is a boolean
957 expression. The pragma is effective only if the value of this expression
958 is known at compile time, and has the value True. The set of expressions
959 whose values are known at compile time includes all static boolean
960 expressions, and also other values which the compiler can determine
961 at compile time (e.g. the size of a record type set by an explicit
962 size representation clause, or the value of a variable which was
963 initialized to a constant and is known not to have been modified).
964 If these conditions are met, a warning message is generated using
965 the value given as the second argument. This string value may contain
966 embedded ASCII.LF characters to break the message into multiple lines.
967
968 @node Pragma Complex_Representation
969 @unnumberedsec Pragma Complex_Representation
970 @findex Complex_Representation
971 @noindent
972 Syntax:
973
974 @smallexample @c ada
975 pragma Complex_Representation
976         ([Entity =>] LOCAL_NAME);
977 @end smallexample
978
979 @noindent
980 The @var{Entity} argument must be the name of a record type which has
981 two fields of the same floating-point type.  The effect of this pragma is
982 to force gcc to use the special internal complex representation form for
983 this record, which may be more efficient.  Note that this may result in
984 the code for this type not conforming to standard ABI (application
985 binary interface) requirements for the handling of record types.  For
986 example, in some environments, there is a requirement for passing
987 records by pointer, and the use of this pragma may result in passing
988 this type in floating-point registers.
989
990 @node Pragma Component_Alignment
991 @unnumberedsec Pragma Component_Alignment
992 @cindex Alignments of components
993 @findex Component_Alignment
994 @noindent
995 Syntax:
996
997 @smallexample @c ada
998 pragma Component_Alignment (
999      [Form =>] ALIGNMENT_CHOICE
1000   [, [Name =>] type_LOCAL_NAME]);
1001
1002 ALIGNMENT_CHOICE ::=
1003   Component_Size
1004 | Component_Size_4
1005 | Storage_Unit
1006 | Default
1007 @end smallexample
1008
1009 @noindent
1010 Specifies the alignment of components in array or record types.
1011 The meaning of the @var{Form} argument is as follows:
1012
1013 @table @code
1014 @findex Component_Size
1015 @item Component_Size
1016 Aligns scalar components and subcomponents of the array or record type
1017 on boundaries appropriate to their inherent size (naturally
1018 aligned).  For example, 1-byte components are aligned on byte boundaries,
1019 2-byte integer components are aligned on 2-byte boundaries, 4-byte
1020 integer components are aligned on 4-byte boundaries and so on.  These
1021 alignment rules correspond to the normal rules for C compilers on all
1022 machines except the VAX@.
1023
1024 @findex Component_Size_4
1025 @item Component_Size_4
1026 Naturally aligns components with a size of four or fewer
1027 bytes.  Components that are larger than 4 bytes are placed on the next
1028 4-byte boundary.
1029
1030 @findex Storage_Unit
1031 @item Storage_Unit
1032 Specifies that array or record components are byte aligned, i.e.@:
1033 aligned on boundaries determined by the value of the constant
1034 @code{System.Storage_Unit}.
1035
1036 @cindex OpenVMS
1037 @item Default
1038 Specifies that array or record components are aligned on default
1039 boundaries, appropriate to the underlying hardware or operating system or
1040 both.  For OpenVMS VAX systems, the @code{Default} choice is the same as
1041 the @code{Storage_Unit} choice (byte alignment).  For all other systems,
1042 the @code{Default} choice is the same as @code{Component_Size} (natural
1043 alignment).
1044 @end table
1045
1046 @noindent
1047 If the @code{Name} parameter is present, @var{type_local_name} must
1048 refer to a local record or array type, and the specified alignment
1049 choice applies to the specified type.  The use of
1050 @code{Component_Alignment} together with a pragma @code{Pack} causes the
1051 @code{Component_Alignment} pragma to be ignored.  The use of
1052 @code{Component_Alignment} together with a record representation clause
1053 is only effective for fields not specified by the representation clause.
1054
1055 If the @code{Name} parameter is absent, the pragma can be used as either
1056 a configuration pragma, in which case it applies to one or more units in
1057 accordance with the normal rules for configuration pragmas, or it can be
1058 used within a declarative part, in which case it applies to types that
1059 are declared within this declarative part, or within any nested scope
1060 within this declarative part.  In either case it specifies the alignment
1061 to be applied to any record or array type which has otherwise standard
1062 representation.
1063
1064 If the alignment for a record or array type is not specified (using
1065 pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
1066 clause), the GNAT uses the default alignment as described previously.
1067
1068 @node Pragma Convention_Identifier
1069 @unnumberedsec Pragma Convention_Identifier
1070 @findex Convention_Identifier
1071 @cindex Conventions, synonyms
1072 @noindent
1073 Syntax:
1074
1075 @smallexample @c ada
1076 pragma Convention_Identifier (
1077          [Name =>]       IDENTIFIER,
1078          [Convention =>] convention_IDENTIFIER);
1079 @end smallexample
1080
1081 @noindent
1082 This pragma provides a mechanism for supplying synonyms for existing
1083 convention identifiers. The @code{Name} identifier can subsequently
1084 be used as a synonym for the given convention in other pragmas (including
1085 for example pragma @code{Import} or another @code{Convention_Identifier}
1086 pragma). As an example of the use of this, suppose you had legacy code
1087 which used Fortran77 as the identifier for Fortran. Then the pragma:
1088
1089 @smallexample @c ada
1090 pragma Convention_Identifier (Fortran77, Fortran);
1091 @end smallexample
1092
1093 @noindent
1094 would allow the use of the convention identifier @code{Fortran77} in
1095 subsequent code, avoiding the need to modify the sources. As another
1096 example, you could use this to parametrize convention requirements
1097 according to systems. Suppose you needed to use @code{Stdcall} on
1098 windows systems, and @code{C} on some other system, then you could
1099 define a convention identifier @code{Library} and use a single
1100 @code{Convention_Identifier} pragma to specify which convention
1101 would be used system-wide.
1102
1103 @node Pragma CPP_Class
1104 @unnumberedsec Pragma CPP_Class
1105 @findex CPP_Class
1106 @cindex Interfacing with C++
1107 @noindent
1108 Syntax:
1109
1110 @smallexample @c ada
1111 pragma CPP_Class ([Entity =>] LOCAL_NAME);
1112 @end smallexample
1113
1114 @noindent
1115 The argument denotes an entity in the current declarative region
1116 that is declared as a tagged or untagged record type.  It indicates that
1117 the type corresponds to an externally declared C++ class type, and is to
1118 be laid out the same way that C++ would lay out the type.
1119
1120 If (and only if) the type is tagged, at least one component in the
1121 record must be of type @code{Interfaces.CPP.Vtable_Ptr}, corresponding
1122 to the C++ Vtable (or Vtables in the case of multiple inheritance) used
1123 for dispatching.
1124
1125 Types for which @code{CPP_Class} is specified do not have assignment or
1126 equality operators defined (such operations can be imported or declared
1127 as subprograms as required).  Initialization is allowed only by
1128 constructor functions (see pragma @code{CPP_Constructor}).
1129
1130 Pragma @code{CPP_Class} is intended primarily for automatic generation
1131 using an automatic binding generator tool.
1132 See @ref{Interfacing to C++} for related information.
1133
1134 @node Pragma CPP_Constructor
1135 @unnumberedsec Pragma CPP_Constructor
1136 @cindex Interfacing with C++
1137 @findex CPP_Constructor
1138 @noindent
1139 Syntax:
1140
1141 @smallexample @c ada
1142 pragma CPP_Constructor ([Entity =>] LOCAL_NAME);
1143 @end smallexample
1144
1145 @noindent
1146 This pragma identifies an imported function (imported in the usual way
1147 with pragma @code{Import}) as corresponding to a C++
1148 constructor.  The argument is a name that must have been
1149 previously mentioned in a pragma @code{Import}
1150 with @code{Convention} = @code{CPP}, and must be of one of the following
1151 forms:
1152
1153 @itemize @bullet
1154 @item
1155 @code{function @var{Fname} return @var{T}'Class}
1156
1157 @item
1158 @code{function @var{Fname} (@dots{}) return @var{T}'Class}
1159 @end itemize
1160
1161 @noindent
1162 where @var{T} is a tagged type to which the pragma @code{CPP_Class} applies.
1163
1164 The first form is the default constructor, used when an object of type
1165 @var{T} is created on the Ada side with no explicit constructor.  Other
1166 constructors (including the copy constructor, which is simply a special
1167 case of the second form in which the one and only argument is of type
1168 @var{T}), can only appear in two contexts:
1169
1170 @itemize @bullet
1171 @item
1172 On the right side of an initialization of an object of type @var{T}.
1173 @item
1174 In an extension aggregate for an object of a type derived from @var{T}.
1175 @end itemize
1176
1177 @noindent
1178 Although the constructor is described as a function that returns a value
1179 on the Ada side, it is typically a procedure with an extra implicit
1180 argument (the object being initialized) at the implementation
1181 level.  GNAT issues the appropriate call, whatever it is, to get the
1182 object properly initialized.
1183
1184 In the case of derived objects, you may use one of two possible forms
1185 for declaring and creating an object:
1186
1187 @itemize @bullet
1188 @item @code{New_Object : Derived_T}
1189 @item @code{New_Object : Derived_T := (@var{constructor-call with} @dots{})}
1190 @end itemize
1191
1192 @noindent
1193 In the first case the default constructor is called and extension fields
1194 if any are initialized according to the default initialization
1195 expressions in the Ada declaration.  In the second case, the given
1196 constructor is called and the extension aggregate indicates the explicit
1197 values of the extension fields.
1198
1199 If no constructors are imported, it is impossible to create any objects
1200 on the Ada side.  If no default constructor is imported, only the
1201 initialization forms using an explicit call to a constructor are
1202 permitted.
1203
1204 Pragma @code{CPP_Constructor} is intended primarily for automatic generation
1205 using an automatic binding generator tool.
1206 See @ref{Interfacing to C++} for more related information.
1207
1208 @node Pragma CPP_Virtual
1209 @unnumberedsec Pragma CPP_Virtual
1210 @cindex Interfacing to C++
1211 @findex CPP_Virtual
1212 @noindent
1213 Syntax:
1214
1215 @smallexample @c ada
1216 pragma CPP_Virtual
1217      [Entity     =>] ENTITY,
1218   [, [Vtable_Ptr =>] vtable_ENTITY,]
1219   [, [Position   =>] static_integer_EXPRESSION]);
1220 @end smallexample
1221
1222 @noindent
1223 This pragma serves the same function as pragma @code{Import} in that
1224 case of a virtual function imported from C++.  The @var{Entity} argument
1225 must be a
1226 primitive subprogram of a tagged type to which pragma @code{CPP_Class}
1227 applies.  The @var{Vtable_Ptr} argument specifies
1228 the Vtable_Ptr component which contains the
1229 entry for this virtual function.  The @var{Position} argument
1230 is the sequential number
1231 counting virtual functions for this Vtable starting at 1.
1232
1233 The @code{Vtable_Ptr} and @code{Position} arguments may be omitted if
1234 there is one Vtable_Ptr present (single inheritance case) and all
1235 virtual functions are imported.  In that case the compiler can deduce both
1236 these values.
1237
1238 No @code{External_Name} or @code{Link_Name} arguments are required for a
1239 virtual function, since it is always accessed indirectly via the
1240 appropriate Vtable entry.
1241
1242 Pragma @code{CPP_Virtual} is intended primarily for automatic generation
1243 using an automatic binding generator tool.
1244 See @ref{Interfacing to C++} for related information.
1245
1246 @node Pragma CPP_Vtable
1247 @unnumberedsec Pragma CPP_Vtable
1248 @cindex Interfacing with C++
1249 @findex CPP_Vtable
1250 @noindent
1251 Syntax:
1252
1253 @smallexample @c ada
1254 pragma CPP_Vtable (
1255   [Entity      =>] ENTITY,
1256   [Vtable_Ptr  =>] vtable_ENTITY,
1257   [Entry_Count =>] static_integer_EXPRESSION);
1258 @end smallexample
1259
1260 @noindent
1261 Given a record to which the pragma @code{CPP_Class} applies,
1262 this pragma can be specified for each component of type
1263 @code{CPP.Interfaces.Vtable_Ptr}.
1264 @var{Entity} is the tagged type, @var{Vtable_Ptr}
1265 is the record field of type @code{Vtable_Ptr}, and @var{Entry_Count} is
1266 the number of virtual functions on the C++ side.  Not all of these
1267 functions need to be imported on the Ada side.
1268
1269 You may omit the @code{CPP_Vtable} pragma if there is only one
1270 @code{Vtable_Ptr} component in the record and all virtual functions are
1271 imported on the Ada side (the default value for the entry count in this
1272 case is simply the total number of virtual functions).
1273
1274 Pragma @code{CPP_Vtable} is intended primarily for automatic generation
1275 using an automatic binding generator tool.
1276 See @ref{Interfacing to C++} for related information.
1277
1278 @node Pragma Debug
1279 @unnumberedsec Pragma Debug
1280 @findex Debug
1281 @noindent
1282 Syntax:
1283
1284 @smallexample @c ada
1285 pragma Debug (PROCEDURE_CALL_WITHOUT_SEMICOLON);
1286
1287 PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
1288   PROCEDURE_NAME
1289 | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
1290 @end smallexample
1291
1292 @noindent
1293 The argument has the syntactic form of an expression, meeting the
1294 syntactic requirements for pragmas.
1295
1296 If assertions are not enabled on the command line, this pragma has no
1297 effect.  If asserts are enabled, the semantics of the pragma is exactly
1298 equivalent to the procedure call statement corresponding to the argument
1299 with a terminating semicolon.  Pragmas are permitted in sequences of
1300 declarations, so you can use pragma @code{Debug} to intersperse calls to
1301 debug procedures in the middle of declarations.
1302
1303 @node Pragma Elaboration_Checks
1304 @unnumberedsec Pragma Elaboration_Checks
1305 @cindex Elaboration control
1306 @findex Elaboration_Checks
1307 @noindent
1308 Syntax:
1309
1310 @smallexample @c ada
1311 pragma Elaboration_Checks (RM | Static);
1312 @end smallexample
1313
1314 @noindent
1315 This is a configuration pragma that provides control over the
1316 elaboration model used by the compilation affected by the
1317 pragma.  If the parameter is RM, then the dynamic elaboration
1318 model described in the Ada Reference Manual is used, as though
1319 the @code{-gnatE} switch had been specified on the command
1320 line.  If the parameter is Static, then the default GNAT static
1321 model is used.  This configuration pragma overrides the setting
1322 of the command line.  For full details on the elaboration models
1323 used by the GNAT compiler, see section ``Elaboration Order
1324 Handling in GNAT'' in the @cite{GNAT User's Guide}.
1325
1326 @node Pragma Eliminate
1327 @unnumberedsec Pragma Eliminate
1328 @cindex Elimination of unused subprograms
1329 @findex Eliminate
1330 @noindent
1331 Syntax:
1332
1333 @smallexample @c ada
1334 pragma Eliminate (
1335     [Unit_Name =>] IDENTIFIER |
1336                    SELECTED_COMPONENT);
1337
1338 pragma Eliminate (
1339     [Unit_Name       =>]  IDENTIFIER |
1340                           SELECTED_COMPONENT,
1341     [Entity          =>]  IDENTIFIER |
1342                           SELECTED_COMPONENT |
1343                           STRING_LITERAL
1344   [,[Parameter_Types =>]  PARAMETER_TYPES]
1345   [,[Result_Type     =>]  result_SUBTYPE_NAME]
1346   [,[Homonym_Number  =>]  INTEGER_LITERAL]);
1347
1348 PARAMETER_TYPES ::= (SUBTYPE_NAME @{, SUBTYPE_NAME@})
1349 SUBTYPE_NAME    ::= STRING_LITERAL
1350 @end smallexample
1351
1352 @noindent
1353 This pragma indicates that the given entity is not used outside the
1354 compilation unit it is defined in.  The entity may be either a subprogram
1355 or a variable.
1356
1357 If the entity to be eliminated is a library level subprogram, then
1358 the first form of pragma @code{Eliminate} is used with only a single argument.
1359 In this form, the @code{Unit_Name} argument specifies the name of the
1360 library  level unit to be eliminated.
1361
1362 In all other cases, both @code{Unit_Name} and @code{Entity} arguments
1363 are required. If item is an entity of a library package, then the first
1364 argument specifies the unit name, and the second argument specifies
1365 the particular entity.  If the second argument is in string form, it must
1366 correspond to the internal manner in which GNAT stores entity names (see
1367 compilation unit Namet in the compiler sources for details).
1368
1369 The remaining parameters are optionally used to distinguish
1370 between overloaded subprograms.  There are two ways of doing this.
1371
1372 Use @code{Parameter_Types} and @code{Result_Type} to specify the
1373 profile of the subprogram to be eliminated in a manner similar to that
1374 used for
1375 the extended @code{Import} and @code{Export} pragmas, except that the
1376 subtype names are always given as string literals, again corresponding
1377 to the internal manner in which GNAT stores entity names.
1378
1379 Alternatively, the @code{Homonym_Number} parameter is used to specify
1380 which overloaded alternative is to be eliminated.  A value of 1 indicates
1381 the first subprogram (in lexical order), 2 indicates the second etc.
1382
1383 The effect of the pragma is to allow the compiler to eliminate
1384 the code or data associated with the named entity.  Any reference to
1385 an eliminated entity outside the compilation unit it is defined in,
1386 causes a compile time or link time error.
1387
1388 The parameters of this pragma may be given in any order, as long as
1389 the usual rules for use of named parameters and position parameters
1390 are used.
1391
1392 The intention of pragma @code{Eliminate} is to allow a program to be compiled
1393 in a system independent manner, with unused entities eliminated, without
1394 the requirement of modifying the source text.  Normally the required set
1395 of @code{Eliminate} pragmas is constructed automatically using the gnatelim
1396 tool. Elimination of unused entities local to a compilation unit is
1397 automatic, without requiring the use of pragma @code{Eliminate}.
1398
1399 Note that the reason this pragma takes string literals where names might
1400 be expected is that a pragma @code{Eliminate} can appear in a context where the
1401 relevant names are not visible.
1402
1403 @node Pragma Export_Exception
1404 @unnumberedsec Pragma Export_Exception
1405 @cindex OpenVMS
1406 @findex Export_Exception
1407 @noindent
1408 Syntax:
1409
1410 @smallexample @c ada
1411 pragma Export_Exception (
1412      [Internal =>] LOCAL_NAME,
1413   [, [External =>] EXTERNAL_SYMBOL,]
1414   [, [Form     =>] Ada | VMS]
1415   [, [Code     =>] static_integer_EXPRESSION]);
1416
1417 EXTERNAL_SYMBOL ::=
1418   IDENTIFIER
1419 | static_string_EXPRESSION
1420 @end smallexample
1421
1422 @noindent
1423 This pragma is implemented only in the OpenVMS implementation of GNAT@.  It
1424 causes the specified exception to be propagated outside of the Ada program,
1425 so that it can be handled by programs written in other OpenVMS languages.
1426 This pragma establishes an external name for an Ada exception and makes the
1427 name available to the OpenVMS Linker as a global symbol.  For further details
1428 on this pragma, see the
1429 DEC Ada Language Reference Manual, section 13.9a3.2.
1430
1431 @node Pragma Export_Function
1432 @unnumberedsec Pragma Export_Function
1433 @cindex Argument passing mechanisms
1434 @findex Export_Function
1435
1436 @noindent
1437 Syntax:
1438
1439 @smallexample @c ada
1440 pragma Export_Function (
1441      [Internal         =>] LOCAL_NAME,
1442   [, [External         =>] EXTERNAL_SYMBOL]
1443   [, [Parameter_Types  =>] PARAMETER_TYPES]
1444   [, [Result_Type      =>] result_SUBTYPE_MARK]
1445   [, [Mechanism        =>] MECHANISM]
1446   [, [Result_Mechanism =>] MECHANISM_NAME]);
1447
1448 EXTERNAL_SYMBOL ::=
1449   IDENTIFIER
1450 | static_string_EXPRESSION
1451 | ""
1452
1453 PARAMETER_TYPES ::=
1454   null
1455 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1456
1457 TYPE_DESIGNATOR ::=
1458   subtype_NAME
1459 | subtype_Name ' Access
1460
1461 MECHANISM ::=
1462   MECHANISM_NAME
1463 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1464
1465 MECHANISM_ASSOCIATION ::=
1466   [formal_parameter_NAME =>] MECHANISM_NAME
1467
1468 MECHANISM_NAME ::=
1469   Value
1470 | Reference
1471 @end smallexample
1472
1473 @noindent
1474 Use this pragma to make a function externally callable and optionally
1475 provide information on mechanisms to be used for passing parameter and
1476 result values.  We recommend, for the purposes of improving portability,
1477 this pragma always be used in conjunction with a separate pragma
1478 @code{Export}, which must precede the pragma @code{Export_Function}.
1479 GNAT does not require a separate pragma @code{Export}, but if none is
1480 present, @code{Convention Ada} is assumed, which is usually
1481 not what is wanted, so it is usually appropriate to use this
1482 pragma in conjunction with a @code{Export} or @code{Convention}
1483 pragma that specifies the desired foreign convention.
1484 Pragma @code{Export_Function}
1485 (and @code{Export}, if present) must appear in the same declarative
1486 region as the function to which they apply.
1487
1488 @var{internal_name} must uniquely designate the function to which the
1489 pragma applies.  If more than one function name exists of this name in
1490 the declarative part you must use the @code{Parameter_Types} and
1491 @code{Result_Type} parameters is mandatory to achieve the required
1492 unique designation.  @var{subtype_ mark}s in these parameters must
1493 exactly match the subtypes in the corresponding function specification,
1494 using positional notation to match parameters with subtype marks.
1495 The form with an @code{'Access} attribute can be used to match an
1496 anonymous access parameter.
1497
1498 @cindex OpenVMS
1499 @cindex Passing by descriptor
1500 Note that passing by descriptor is not supported, even on the OpenVMS
1501 ports of GNAT@.
1502
1503 @cindex Suppressing external name
1504 Special treatment is given if the EXTERNAL is an explicit null
1505 string or a static string expressions that evaluates to the null
1506 string. In this case, no external name is generated. This form
1507 still allows the specification of parameter mechanisms.
1508
1509 @node Pragma Export_Object
1510 @unnumberedsec Pragma Export_Object
1511 @findex Export_Object
1512 @noindent
1513 Syntax:
1514
1515 @smallexample @c ada
1516 pragma Export_Object
1517       [Internal =>] LOCAL_NAME,
1518    [, [External =>] EXTERNAL_SYMBOL]
1519    [, [Size     =>] EXTERNAL_SYMBOL]
1520
1521 EXTERNAL_SYMBOL ::=
1522   IDENTIFIER
1523 | static_string_EXPRESSION
1524 @end smallexample
1525
1526 @noindent
1527 This pragma designates an object as exported, and apart from the
1528 extended rules for external symbols, is identical in effect to the use of
1529 the normal @code{Export} pragma applied to an object.  You may use a
1530 separate Export pragma (and you probably should from the point of view
1531 of portability), but it is not required.  @var{Size} is syntax checked,
1532 but otherwise ignored by GNAT@.
1533
1534 @node Pragma Export_Procedure
1535 @unnumberedsec Pragma Export_Procedure
1536 @findex Export_Procedure
1537 @noindent
1538 Syntax:
1539
1540 @smallexample @c ada
1541 pragma Export_Procedure (
1542      [Internal        =>] LOCAL_NAME
1543   [, [External        =>] EXTERNAL_SYMBOL]
1544   [, [Parameter_Types =>] PARAMETER_TYPES]
1545   [, [Mechanism       =>] MECHANISM]);
1546
1547 EXTERNAL_SYMBOL ::=
1548   IDENTIFIER
1549 | static_string_EXPRESSION
1550 | ""
1551
1552 PARAMETER_TYPES ::=
1553   null
1554 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1555
1556 TYPE_DESIGNATOR ::=
1557   subtype_NAME
1558 | subtype_Name ' Access
1559
1560 MECHANISM ::=
1561   MECHANISM_NAME
1562 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1563
1564 MECHANISM_ASSOCIATION ::=
1565   [formal_parameter_NAME =>] MECHANISM_NAME
1566
1567 MECHANISM_NAME ::=
1568   Value
1569 | Reference
1570 @end smallexample
1571
1572 @noindent
1573 This pragma is identical to @code{Export_Function} except that it
1574 applies to a procedure rather than a function and the parameters
1575 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
1576 GNAT does not require a separate pragma @code{Export}, but if none is
1577 present, @code{Convention Ada} is assumed, which is usually
1578 not what is wanted, so it is usually appropriate to use this
1579 pragma in conjunction with a @code{Export} or @code{Convention}
1580 pragma that specifies the desired foreign convention.
1581
1582 @cindex OpenVMS
1583 @cindex Passing by descriptor
1584 Note that passing by descriptor is not supported, even on the OpenVMS
1585 ports of GNAT@.
1586
1587 @cindex Suppressing external name
1588 Special treatment is given if the EXTERNAL is an explicit null
1589 string or a static string expressions that evaluates to the null
1590 string. In this case, no external name is generated. This form
1591 still allows the specification of parameter mechanisms.
1592
1593 @node Pragma Export_Value
1594 @unnumberedsec Pragma Export_Value
1595 @findex Export_Value
1596 @noindent
1597 Syntax:
1598
1599 @smallexample @c ada
1600 pragma Export_Value (
1601   [Value     =>] static_integer_EXPRESSION,
1602   [Link_Name =>] static_string_EXPRESSION);
1603 @end smallexample
1604
1605 @noindent
1606 This pragma serves to export a static integer value for external use.
1607 The first argument specifies the value to be exported. The Link_Name
1608 argument specifies the symbolic name to be associated with the integer
1609 value. This pragma is useful for defining a named static value in Ada
1610 that can be referenced in assembly language units to be linked with
1611 the application. This pragma is currently supported only for the
1612 AAMP target and is ignored for other targets.
1613
1614 @node Pragma Export_Valued_Procedure
1615 @unnumberedsec Pragma Export_Valued_Procedure
1616 @findex Export_Valued_Procedure
1617 @noindent
1618 Syntax:
1619
1620 @smallexample @c ada
1621 pragma Export_Valued_Procedure (
1622      [Internal        =>] LOCAL_NAME
1623   [, [External        =>] EXTERNAL_SYMBOL]
1624   [, [Parameter_Types =>] PARAMETER_TYPES]
1625   [, [Mechanism       =>] MECHANISM]);
1626
1627 EXTERNAL_SYMBOL ::=
1628   IDENTIFIER
1629 | static_string_EXPRESSION
1630 | ""
1631
1632 PARAMETER_TYPES ::=
1633   null
1634 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1635
1636 TYPE_DESIGNATOR ::=
1637   subtype_NAME
1638 | subtype_Name ' Access
1639
1640 MECHANISM ::=
1641   MECHANISM_NAME
1642 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1643
1644 MECHANISM_ASSOCIATION ::=
1645   [formal_parameter_NAME =>] MECHANISM_NAME
1646
1647 MECHANISM_NAME ::=
1648   Value
1649 | Reference
1650 @end smallexample
1651
1652 @noindent
1653 This pragma is identical to @code{Export_Procedure} except that the
1654 first parameter of @var{local_name}, which must be present, must be of
1655 mode @code{OUT}, and externally the subprogram is treated as a function
1656 with this parameter as the result of the function.  GNAT provides for
1657 this capability to allow the use of @code{OUT} and @code{IN OUT}
1658 parameters in interfacing to external functions (which are not permitted
1659 in Ada functions).
1660 GNAT does not require a separate pragma @code{Export}, but if none is
1661 present, @code{Convention Ada} is assumed, which is almost certainly
1662 not what is wanted since the whole point of this pragma is to interface
1663 with foreign language functions, so it is usually appropriate to use this
1664 pragma in conjunction with a @code{Export} or @code{Convention}
1665 pragma that specifies the desired foreign convention.
1666
1667 @cindex OpenVMS
1668 @cindex Passing by descriptor
1669 Note that passing by descriptor is not supported, even on the OpenVMS
1670 ports of GNAT@.
1671
1672 @cindex Suppressing external name
1673 Special treatment is given if the EXTERNAL is an explicit null
1674 string or a static string expressions that evaluates to the null
1675 string. In this case, no external name is generated. This form
1676 still allows the specification of parameter mechanisms.
1677
1678 @node Pragma Extend_System
1679 @unnumberedsec Pragma Extend_System
1680 @cindex @code{system}, extending
1681 @cindex Dec Ada 83
1682 @findex Extend_System
1683 @noindent
1684 Syntax:
1685
1686 @smallexample @c ada
1687 pragma Extend_System ([Name =>] IDENTIFIER);
1688 @end smallexample
1689
1690 @noindent
1691 This pragma is used to provide backwards compatibility with other
1692 implementations that extend the facilities of package @code{System}.  In
1693 GNAT, @code{System} contains only the definitions that are present in
1694 the Ada 95 RM@.  However, other implementations, notably the DEC Ada 83
1695 implementation, provide many extensions to package @code{System}.
1696
1697 For each such implementation accommodated by this pragma, GNAT provides a
1698 package @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83
1699 implementation, which provides the required additional definitions.  You
1700 can use this package in two ways.  You can @code{with} it in the normal
1701 way and access entities either by selection or using a @code{use}
1702 clause.  In this case no special processing is required.
1703
1704 However, if existing code contains references such as
1705 @code{System.@var{xxx}} where @var{xxx} is an entity in the extended
1706 definitions provided in package @code{System}, you may use this pragma
1707 to extend visibility in @code{System} in a non-standard way that
1708 provides greater compatibility with the existing code.  Pragma
1709 @code{Extend_System} is a configuration pragma whose single argument is
1710 the name of the package containing the extended definition
1711 (e.g.@: @code{Aux_DEC} for the DEC Ada case).  A unit compiled under
1712 control of this pragma will be processed using special visibility
1713 processing that looks in package @code{System.Aux_@var{xxx}} where
1714 @code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
1715 package @code{System}, but not found in package @code{System}.
1716
1717 You can use this pragma either to access a predefined @code{System}
1718 extension supplied with the compiler, for example @code{Aux_DEC} or
1719 you can construct your own extension unit following the above
1720 definition.  Note that such a package is a child of @code{System}
1721 and thus is considered part of the implementation.  To compile
1722 it you will have to use the appropriate switch for compiling
1723 system units.  See the GNAT User's Guide for details.
1724
1725 @node Pragma External
1726 @unnumberedsec Pragma External
1727 @findex External
1728 @noindent
1729 Syntax:
1730
1731 @smallexample @c ada
1732 pragma External (
1733   [   Convention    =>] convention_IDENTIFIER,
1734   [   Entity        =>] local_NAME
1735   [, [External_Name =>] static_string_EXPRESSION ]
1736   [, [Link_Name     =>] static_string_EXPRESSION ]);
1737 @end smallexample
1738
1739 @noindent
1740 This pragma is identical in syntax and semantics to pragma
1741 @code{Export} as defined in the Ada Reference Manual.  It is
1742 provided for compatibility with some Ada 83 compilers that
1743 used this pragma for exactly the same purposes as pragma
1744 @code{Export} before the latter was standardized.
1745
1746 @node Pragma External_Name_Casing
1747 @unnumberedsec Pragma External_Name_Casing
1748 @cindex Dec Ada 83 casing compatibility
1749 @cindex External Names, casing
1750 @cindex Casing of External names
1751 @findex External_Name_Casing
1752 @noindent
1753 Syntax:
1754
1755 @smallexample @c ada
1756 pragma External_Name_Casing (
1757   Uppercase | Lowercase
1758   [, Uppercase | Lowercase | As_Is]);
1759 @end smallexample
1760
1761 @noindent
1762 This pragma provides control over the casing of external names associated
1763 with Import and Export pragmas.  There are two cases to consider:
1764
1765 @table @asis
1766 @item Implicit external names
1767 Implicit external names are derived from identifiers.  The most common case
1768 arises when a standard Ada 95 Import or Export pragma is used with only two
1769 arguments, as in:
1770
1771 @smallexample @c ada
1772    pragma Import (C, C_Routine);
1773 @end smallexample
1774
1775 @noindent
1776 Since Ada is a case insensitive language, the spelling of the identifier in
1777 the Ada source program does not provide any information on the desired
1778 casing of the external name, and so a convention is needed.  In GNAT the
1779 default treatment is that such names are converted to all lower case
1780 letters.  This corresponds to the normal C style in many environments.
1781 The first argument of pragma @code{External_Name_Casing} can be used to
1782 control this treatment.  If @code{Uppercase} is specified, then the name
1783 will be forced to all uppercase letters.  If @code{Lowercase} is specified,
1784 then the normal default of all lower case letters will be used.
1785
1786 This same implicit treatment is also used in the case of extended DEC Ada 83
1787 compatible Import and Export pragmas where an external name is explicitly
1788 specified using an identifier rather than a string.
1789
1790 @item Explicit external names
1791 Explicit external names are given as string literals.  The most common case
1792 arises when a standard Ada 95 Import or Export pragma is used with three
1793 arguments, as in:
1794
1795 @smallexample @c ada
1796 pragma Import (C, C_Routine, "C_routine");
1797 @end smallexample
1798
1799 @noindent
1800 In this case, the string literal normally provides the exact casing required
1801 for the external name.  The second argument of pragma
1802 @code{External_Name_Casing} may be used to modify this behavior.
1803 If @code{Uppercase} is specified, then the name
1804 will be forced to all uppercase letters.  If @code{Lowercase} is specified,
1805 then the name will be forced to all lowercase letters.  A specification of
1806 @code{As_Is} provides the normal default behavior in which the casing is
1807 taken from the string provided.
1808 @end table
1809
1810 @noindent
1811 This pragma may appear anywhere that a pragma is valid.  In particular, it
1812 can be used as a configuration pragma in the @file{gnat.adc} file, in which
1813 case it applies to all subsequent compilations, or it can be used as a program
1814 unit pragma, in which case it only applies to the current unit, or it can
1815 be used more locally to control individual Import/Export pragmas.
1816
1817 It is primarily intended for use with OpenVMS systems, where many
1818 compilers convert all symbols to upper case by default.  For interfacing to
1819 such compilers (e.g.@: the DEC C compiler), it may be convenient to use
1820 the pragma:
1821
1822 @smallexample @c ada
1823 pragma External_Name_Casing (Uppercase, Uppercase);
1824 @end smallexample
1825
1826 @noindent
1827 to enforce the upper casing of all external symbols.
1828
1829 @node Pragma Finalize_Storage_Only
1830 @unnumberedsec Pragma Finalize_Storage_Only
1831 @findex Finalize_Storage_Only
1832 @noindent
1833 Syntax:
1834
1835 @smallexample @c ada
1836 pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
1837 @end smallexample
1838
1839 @noindent
1840 This pragma allows the compiler not to emit a Finalize call for objects
1841 defined at the library level.  This is mostly useful for types where
1842 finalization is only used to deal with storage reclamation since in most
1843 environments it is not necessary to reclaim memory just before terminating
1844 execution, hence the name.
1845
1846 @node Pragma Float_Representation
1847 @unnumberedsec Pragma Float_Representation
1848 @cindex OpenVMS
1849 @findex Float_Representation
1850 @noindent
1851 Syntax:
1852
1853 @smallexample @c ada
1854 pragma Float_Representation (FLOAT_REP);
1855
1856 FLOAT_REP ::= VAX_Float | IEEE_Float
1857 @end smallexample
1858
1859 @noindent
1860 This pragma
1861 allows control over the internal representation chosen for the predefined
1862 floating point types declared in the packages @code{Standard} and
1863 @code{System}. On all systems other than OpenVMS, the argument must
1864 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
1865 argument may be @code{VAX_Float} to specify the use of the VAX float
1866 format for the floating-point types in Standard. This requires that
1867 the standard runtime libraries be recompiled. See the
1868 description of the @code{GNAT LIBRARY} command in the OpenVMS version
1869 of the GNAT Users Guide for details on the use of this command.
1870
1871 @node Pragma Ident
1872 @unnumberedsec Pragma Ident
1873 @findex Ident
1874 @noindent
1875 Syntax:
1876
1877 @smallexample @c ada
1878 pragma Ident (static_string_EXPRESSION);
1879 @end smallexample
1880
1881 @noindent
1882 This pragma provides a string identification in the generated object file,
1883 if the system supports the concept of this kind of identification string.
1884 This pragma is allowed only in the outermost declarative part or
1885 declarative items of a compilation unit. If more than one @code{Ident}
1886 pragma is given, only the last one processed is effective.
1887 @cindex OpenVMS
1888 On OpenVMS systems, the effect of the pragma is identical to the effect of
1889 the DEC Ada 83 pragma of the same name. Note that in DEC Ada 83, the
1890 maximum allowed length is 31 characters, so if it is important to
1891 maintain compatibility with this compiler, you should obey this length
1892 limit.
1893
1894 @node Pragma Import_Exception
1895 @unnumberedsec Pragma Import_Exception
1896 @cindex OpenVMS
1897 @findex Import_Exception
1898 @noindent
1899 Syntax:
1900
1901 @smallexample @c ada
1902 pragma Import_Exception (
1903      [Internal =>] LOCAL_NAME,
1904   [, [External =>] EXTERNAL_SYMBOL,]
1905   [, [Form     =>] Ada | VMS]
1906   [, [Code     =>] static_integer_EXPRESSION]);
1907
1908 EXTERNAL_SYMBOL ::=
1909   IDENTIFIER
1910 | static_string_EXPRESSION
1911 @end smallexample
1912
1913 @noindent
1914 This pragma is implemented only in the OpenVMS implementation of GNAT@.
1915 It allows OpenVMS conditions (for example, from OpenVMS system services or
1916 other OpenVMS languages) to be propagated to Ada programs as Ada exceptions.
1917 The pragma specifies that the exception associated with an exception
1918 declaration in an Ada program be defined externally (in non-Ada code).
1919 For further details on this pragma, see the
1920 DEC Ada Language Reference Manual, section 13.9a.3.1.
1921
1922 @node Pragma Import_Function
1923 @unnumberedsec Pragma Import_Function
1924 @findex Import_Function
1925 @noindent
1926 Syntax:
1927
1928 @smallexample @c ada
1929 pragma Import_Function (
1930      [Internal                 =>] LOCAL_NAME,
1931   [, [External                 =>] EXTERNAL_SYMBOL]
1932   [, [Parameter_Types          =>] PARAMETER_TYPES]
1933   [, [Result_Type              =>] SUBTYPE_MARK]
1934   [, [Mechanism                =>] MECHANISM]
1935   [, [Result_Mechanism         =>] MECHANISM_NAME]
1936   [, [First_Optional_Parameter =>] IDENTIFIER]);
1937
1938 EXTERNAL_SYMBOL ::=
1939   IDENTIFIER
1940 | static_string_EXPRESSION
1941
1942 PARAMETER_TYPES ::=
1943   null
1944 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1945
1946 TYPE_DESIGNATOR ::=
1947   subtype_NAME
1948 | subtype_Name ' Access
1949
1950 MECHANISM ::=
1951   MECHANISM_NAME
1952 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1953
1954 MECHANISM_ASSOCIATION ::=
1955   [formal_parameter_NAME =>] MECHANISM_NAME
1956
1957 MECHANISM_NAME ::=
1958   Value
1959 | Reference
1960 | Descriptor [([Class =>] CLASS_NAME)]
1961
1962 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
1963 @end smallexample
1964
1965 @noindent
1966 This pragma is used in conjunction with a pragma @code{Import} to
1967 specify additional information for an imported function.  The pragma
1968 @code{Import} (or equivalent pragma @code{Interface}) must precede the
1969 @code{Import_Function} pragma and both must appear in the same
1970 declarative part as the function specification.
1971
1972 The @var{Internal} argument must uniquely designate
1973 the function to which the
1974 pragma applies.  If more than one function name exists of this name in
1975 the declarative part you must use the @code{Parameter_Types} and
1976 @var{Result_Type} parameters to achieve the required unique
1977 designation.  Subtype marks in these parameters must exactly match the
1978 subtypes in the corresponding function specification, using positional
1979 notation to match parameters with subtype marks.
1980 The form with an @code{'Access} attribute can be used to match an
1981 anonymous access parameter.
1982
1983 You may optionally use the @var{Mechanism} and @var{Result_Mechanism}
1984 parameters to specify passing mechanisms for the
1985 parameters and result.  If you specify a single mechanism name, it
1986 applies to all parameters.  Otherwise you may specify a mechanism on a
1987 parameter by parameter basis using either positional or named
1988 notation.  If the mechanism is not specified, the default mechanism
1989 is used.
1990
1991 @cindex OpenVMS
1992 @cindex Passing by descriptor
1993 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
1994
1995 @code{First_Optional_Parameter} applies only to OpenVMS ports of GNAT@.
1996 It specifies that the designated parameter and all following parameters
1997 are optional, meaning that they are not passed at the generated code
1998 level (this is distinct from the notion of optional parameters in Ada
1999 where the parameters are passed anyway with the designated optional
2000 parameters).  All optional parameters must be of mode @code{IN} and have
2001 default parameter values that are either known at compile time
2002 expressions, or uses of the @code{'Null_Parameter} attribute.
2003
2004 @node Pragma Import_Object
2005 @unnumberedsec Pragma Import_Object
2006 @findex Import_Object
2007 @noindent
2008 Syntax:
2009
2010 @smallexample @c ada
2011 pragma Import_Object
2012      [Internal =>] LOCAL_NAME,
2013   [, [External =>] EXTERNAL_SYMBOL],
2014   [, [Size     =>] EXTERNAL_SYMBOL]);
2015
2016 EXTERNAL_SYMBOL ::=
2017   IDENTIFIER
2018 | static_string_EXPRESSION
2019 @end smallexample
2020
2021 @noindent
2022 This pragma designates an object as imported, and apart from the
2023 extended rules for external symbols, is identical in effect to the use of
2024 the normal @code{Import} pragma applied to an object.  Unlike the
2025 subprogram case, you need not use a separate @code{Import} pragma,
2026 although you may do so (and probably should do so from a portability
2027 point of view).  @var{size} is syntax checked, but otherwise ignored by
2028 GNAT@.
2029
2030 @node Pragma Import_Procedure
2031 @unnumberedsec Pragma Import_Procedure
2032 @findex Import_Procedure
2033 @noindent
2034 Syntax:
2035
2036 @smallexample @c ada
2037 pragma Import_Procedure (
2038      [Internal                 =>] LOCAL_NAME,
2039   [, [External                 =>] EXTERNAL_SYMBOL]
2040   [, [Parameter_Types          =>] PARAMETER_TYPES]
2041   [, [Mechanism                =>] MECHANISM]
2042   [, [First_Optional_Parameter =>] IDENTIFIER]);
2043
2044 EXTERNAL_SYMBOL ::=
2045   IDENTIFIER
2046 | static_string_EXPRESSION
2047
2048 PARAMETER_TYPES ::=
2049   null
2050 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2051
2052 TYPE_DESIGNATOR ::=
2053   subtype_NAME
2054 | subtype_Name ' Access
2055
2056 MECHANISM ::=
2057   MECHANISM_NAME
2058 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2059
2060 MECHANISM_ASSOCIATION ::=
2061   [formal_parameter_NAME =>] MECHANISM_NAME
2062
2063 MECHANISM_NAME ::=
2064   Value
2065 | Reference
2066 | Descriptor [([Class =>] CLASS_NAME)]
2067
2068 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2069 @end smallexample
2070
2071 @noindent
2072 This pragma is identical to @code{Import_Function} except that it
2073 applies to a procedure rather than a function and the parameters
2074 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2075
2076 @node Pragma Import_Valued_Procedure
2077 @unnumberedsec Pragma Import_Valued_Procedure
2078 @findex Import_Valued_Procedure
2079 @noindent
2080 Syntax:
2081
2082 @smallexample @c ada
2083 pragma Import_Valued_Procedure (
2084      [Internal                 =>] LOCAL_NAME,
2085   [, [External                 =>] EXTERNAL_SYMBOL]
2086   [, [Parameter_Types          =>] PARAMETER_TYPES]
2087   [, [Mechanism                =>] MECHANISM]
2088   [, [First_Optional_Parameter =>] IDENTIFIER]);
2089
2090 EXTERNAL_SYMBOL ::=
2091   IDENTIFIER
2092 | static_string_EXPRESSION
2093
2094 PARAMETER_TYPES ::=
2095   null
2096 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2097
2098 TYPE_DESIGNATOR ::=
2099   subtype_NAME
2100 | subtype_Name ' Access
2101
2102 MECHANISM ::=
2103   MECHANISM_NAME
2104 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2105
2106 MECHANISM_ASSOCIATION ::=
2107   [formal_parameter_NAME =>] MECHANISM_NAME
2108
2109 MECHANISM_NAME ::=
2110   Value
2111 | Reference
2112 | Descriptor [([Class =>] CLASS_NAME)]
2113
2114 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2115 @end smallexample
2116
2117 @noindent
2118 This pragma is identical to @code{Import_Procedure} except that the
2119 first parameter of @var{local_name}, which must be present, must be of
2120 mode @code{OUT}, and externally the subprogram is treated as a function
2121 with this parameter as the result of the function.  The purpose of this
2122 capability is to allow the use of @code{OUT} and @code{IN OUT}
2123 parameters in interfacing to external functions (which are not permitted
2124 in Ada functions).  You may optionally use the @code{Mechanism}
2125 parameters to specify passing mechanisms for the parameters.
2126 If you specify a single mechanism name, it applies to all parameters.
2127 Otherwise you may specify a mechanism on a parameter by parameter
2128 basis using either positional or named notation.  If the mechanism is not
2129 specified, the default mechanism is used.
2130
2131 Note that it is important to use this pragma in conjunction with a separate
2132 pragma Import that specifies the desired convention, since otherwise the
2133 default convention is Ada, which is almost certainly not what is required.
2134
2135 @node Pragma Initialize_Scalars
2136 @unnumberedsec Pragma Initialize_Scalars
2137 @findex Initialize_Scalars
2138 @cindex debugging with Initialize_Scalars
2139 @noindent
2140 Syntax:
2141
2142 @smallexample @c ada
2143 pragma Initialize_Scalars;
2144 @end smallexample
2145
2146 @noindent
2147 This pragma is similar to @code{Normalize_Scalars} conceptually but has
2148 two important differences.  First, there is no requirement for the pragma
2149 to be used uniformly in all units of a partition, in particular, it is fine
2150 to use this just for some or all of the application units of a partition,
2151 without needing to recompile the run-time library.
2152
2153 In the case where some units are compiled with the pragma, and some without,
2154 then a declaration of a variable where the type is defined in package
2155 Standard or is locally declared will always be subject to initialization,
2156 as will any declaration of a scalar variable.  For composite variables,
2157 whether the variable is initialized may also depend on whether the package
2158 in which the type of the variable is declared is compiled with the pragma.
2159
2160 The other important difference is that there is control over the value used
2161 for initializing scalar objects.  At bind time, you can select whether to
2162 initialize with invalid values (like Normalize_Scalars), or with high or
2163 low values, or with a specified bit pattern.  See the users guide for binder
2164 options for specifying these cases.
2165
2166 This means that you can compile a program, and then without having to
2167 recompile the program, you can run it with different values being used
2168 for initializing otherwise uninitialized values, to test if your program
2169 behavior depends on the choice.  Of course the behavior should not change,
2170 and if it does, then most likely you have an erroneous reference to an
2171 uninitialized value.
2172
2173 Note that pragma @code{Initialize_Scalars} is particularly useful in
2174 conjunction with the enhanced validity checking that is now provided
2175 in GNAT, which checks for invalid values under more conditions.
2176 Using this feature (see description of the @code{-gnatV} flag in the
2177 users guide) in conjunction with pragma @code{Initialize_Scalars}
2178 provides a powerful new tool to assist in the detection of problems
2179 caused by uninitialized variables.
2180
2181 @node Pragma Inline_Always
2182 @unnumberedsec Pragma Inline_Always
2183 @findex Inline_Always
2184 @noindent
2185 Syntax:
2186
2187 @smallexample @c ada
2188 pragma Inline_Always (NAME [, NAME]);
2189 @end smallexample
2190
2191 @noindent
2192 Similar to pragma @code{Inline} except that inlining is not subject to
2193 the use of option @code{-gnatn} and the inlining happens regardless of
2194 whether this option is used.
2195
2196 @node Pragma Inline_Generic
2197 @unnumberedsec Pragma Inline_Generic
2198 @findex Inline_Generic
2199 @noindent
2200 Syntax:
2201
2202 @smallexample @c ada
2203 pragma Inline_Generic (generic_package_NAME);
2204 @end smallexample
2205
2206 @noindent
2207 This is implemented for compatibility with DEC Ada 83 and is recognized,
2208 but otherwise ignored, by GNAT@.  All generic instantiations are inlined
2209 by default when using GNAT@.
2210
2211 @node Pragma Interface
2212 @unnumberedsec Pragma Interface
2213 @findex Interface
2214 @noindent
2215 Syntax:
2216
2217 @smallexample @c ada
2218 pragma Interface (
2219      [Convention    =>] convention_identifier,
2220      [Entity =>] local_name
2221   [, [External_Name =>] static_string_expression],
2222   [, [Link_Name     =>] static_string_expression]);
2223 @end smallexample
2224
2225 @noindent
2226 This pragma is identical in syntax and semantics to
2227 the standard Ada 95 pragma @code{Import}.  It is provided for compatibility
2228 with Ada 83.  The definition is upwards compatible both with pragma
2229 @code{Interface} as defined in the Ada 83 Reference Manual, and also
2230 with some extended implementations of this pragma in certain Ada 83
2231 implementations.
2232
2233 @node Pragma Interface_Name
2234 @unnumberedsec Pragma Interface_Name
2235 @findex Interface_Name
2236 @noindent
2237 Syntax:
2238
2239 @smallexample @c ada
2240 pragma Interface_Name (
2241      [Entity        =>] LOCAL_NAME
2242   [, [External_Name =>] static_string_EXPRESSION]
2243   [, [Link_Name     =>] static_string_EXPRESSION]);
2244 @end smallexample
2245
2246 @noindent
2247 This pragma provides an alternative way of specifying the interface name
2248 for an interfaced subprogram, and is provided for compatibility with Ada
2249 83 compilers that use the pragma for this purpose.  You must provide at
2250 least one of @var{External_Name} or @var{Link_Name}.
2251
2252 @node Pragma Interrupt_Handler
2253 @unnumberedsec Pragma Interrupt_Handler
2254 @findex Interrupt_Handler
2255 @noindent
2256 Syntax:
2257
2258 @smallexample @c ada
2259 pragma Interrupt_Handler (procedure_LOCAL_NAME);
2260 @end smallexample
2261
2262 @noindent
2263 This program unit pragma is supported for parameterless protected procedures
2264 as described in Annex C of the Ada Reference Manual. On the AAMP target
2265 the pragma can also be specified for nonprotected parameterless procedures
2266 that are declared at the library level (which includes procedures
2267 declared at the top level of a library package). In the case of AAMP,
2268 when this pragma is applied to a nonprotected procedure, the instruction
2269 @code{IERET} is generated for returns from the procedure, enabling
2270 maskable interrupts, in place of the normal return instruction.
2271
2272 @node Pragma Interrupt_State
2273 @unnumberedsec Pragma Interrupt_State
2274 @findex Interrupt_State
2275 @noindent
2276 Syntax:
2277
2278 @smallexample @c ada
2279 pragma Interrupt_State (Name => value, State => SYSTEM | RUNTIME | USER);
2280 @end smallexample
2281
2282 @noindent
2283 Normally certain interrupts are reserved to the implementation.  Any attempt
2284 to attach an interrupt causes Program_Error to be raised, as described in
2285 RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
2286 many systems for an @kbd{Ctrl-C} interrupt.  Normally this interrupt is
2287 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
2288 interrupt execution.  Additionally, signals such as @code{SIGSEGV},
2289 @code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
2290 Ada exceptions, or used to implement run-time functions such as the
2291 @code{abort} statement and stack overflow checking.
2292
2293 Pragma @code{Interrupt_State} provides a general mechanism for overriding
2294 such uses of interrupts.  It subsumes the functionality of pragma
2295 @code{Unreserve_All_Interrupts}.  Pragma @code{Interrupt_State} is not
2296 available on OS/2, Windows or VMS.  On all other platforms than VxWorks,
2297 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
2298 and may be used to mark interrupts required by the board support package
2299 as reserved.
2300
2301 Interrupts can be in one of three states:
2302 @itemize @bullet
2303 @item System
2304
2305 The interrupt is reserved (no Ada handler can be installed), and the
2306 Ada run-time may not install a handler. As a result you are guaranteed
2307 standard system default action if this interrupt is raised.
2308
2309 @item Runtime
2310
2311 The interrupt is reserved (no Ada handler can be installed). The run time
2312 is allowed to install a handler for internal control purposes, but is
2313 not required to do so.
2314
2315 @item User
2316
2317 The interrupt is unreserved.  The user may install a handler to provide
2318 some other action.
2319 @end itemize
2320
2321 @noindent
2322 These states are the allowed values of the @code{State} parameter of the
2323 pragma.  The @code{Name} parameter is a value of the type
2324 @code{Ada.Interrupts.Interrupt_ID}.  Typically, it is a name declared in
2325 @code{Ada.Interrupts.Names}.
2326
2327 This is a configuration pragma, and the binder will check that there
2328 are no inconsistencies between different units in a partition in how a
2329 given interrupt is specified. It may appear anywhere a pragma is legal.
2330
2331 The effect is to move the interrupt to the specified state.
2332
2333 By declaring interrupts to be SYSTEM, you guarantee the standard system
2334 action, such as a core dump.
2335
2336 By declaring interrupts to be USER, you guarantee that you can install
2337 a handler.
2338
2339 Note that certain signals on many operating systems cannot be caught and
2340 handled by applications.  In such cases, the pragma is ignored.  See the
2341 operating system documentation, or the value of the array @code{Reserved}
2342 declared in the specification of package @code{System.OS_Interface}.
2343
2344 Overriding the default state of signals used by the Ada runtime may interfere
2345 with an application's runtime behavior in the cases of the synchronous signals,
2346 and in the case of the signal used to implement the @code{abort} statement.
2347
2348 @node Pragma Keep_Names
2349 @unnumberedsec Pragma Keep_Names
2350 @findex Keep_Names
2351 @noindent
2352 Syntax:
2353
2354 @smallexample @c ada
2355 pragma Keep_Names ([On =>] enumeration_first_subtype_LOCAL_NAME);
2356 @end smallexample
2357
2358 @noindent
2359 The @var{LOCAL_NAME} argument
2360 must refer to an enumeration first subtype
2361 in the current declarative part. The effect is to retain the enumeration
2362 literal names for use by @code{Image} and @code{Value} even if a global
2363 @code{Discard_Names} pragma applies. This is useful when you want to
2364 generally suppress enumeration literal names and for example you therefore
2365 use a @code{Discard_Names} pragma in the @file{gnat.adc} file, but you
2366 want to retain the names for specific enumeration types.
2367
2368 @node Pragma License
2369 @unnumberedsec Pragma License
2370 @findex License
2371 @cindex License checking
2372 @noindent
2373 Syntax:
2374
2375 @smallexample @c ada
2376 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
2377 @end smallexample
2378
2379 @noindent
2380 This pragma is provided to allow automated checking for appropriate license
2381 conditions with respect to the standard and modified GPL@.  A pragma
2382 @code{License}, which is a configuration pragma that typically appears at
2383 the start of a source file or in a separate @file{gnat.adc} file, specifies
2384 the licensing conditions of a unit as follows:
2385
2386 @itemize @bullet
2387 @item Unrestricted
2388 This is used for a unit that can be freely used with no license restrictions.
2389 Examples of such units are public domain units, and units from the Ada
2390 Reference Manual.
2391
2392 @item GPL
2393 This is used for a unit that is licensed under the unmodified GPL, and which
2394 therefore cannot be @code{with}'ed by a restricted unit.
2395
2396 @item Modified_GPL
2397 This is used for a unit licensed under the GNAT modified GPL that includes
2398 a special exception paragraph that specifically permits the inclusion of
2399 the unit in programs without requiring the entire program to be released
2400 under the GPL@.  This is the license used for the GNAT run-time which ensures
2401 that the run-time can be used freely in any program without GPL concerns.
2402
2403 @item Restricted
2404 This is used for a unit that is restricted in that it is not permitted to
2405 depend on units that are licensed under the GPL@.  Typical examples are
2406 proprietary code that is to be released under more restrictive license
2407 conditions.  Note that restricted units are permitted to @code{with} units
2408 which are licensed under the modified GPL (this is the whole point of the
2409 modified GPL).
2410
2411 @end itemize
2412
2413 @noindent
2414 Normally a unit with no @code{License} pragma is considered to have an
2415 unknown license, and no checking is done.  However, standard GNAT headers
2416 are recognized, and license information is derived from them as follows.
2417
2418 @itemize @bullet
2419
2420 A GNAT license header starts with a line containing 78 hyphens.  The following
2421 comment text is searched for the appearance of any of the following strings.
2422
2423 If the string ``GNU General Public License'' is found, then the unit is assumed
2424 to have GPL license, unless the string ``As a special exception'' follows, in
2425 which case the license is assumed to be modified GPL@.
2426
2427 If one of the strings
2428 ``This specification is adapted from the Ada Semantic Interface'' or
2429 ``This specification is derived from the Ada Reference Manual'' is found
2430 then the unit is assumed to be unrestricted.
2431 @end itemize
2432
2433 @noindent
2434 These default actions means that a program with a restricted license pragma
2435 will automatically get warnings if a GPL unit is inappropriately
2436 @code{with}'ed.  For example, the program:
2437
2438 @smallexample @c ada
2439 with Sem_Ch3;
2440 with GNAT.Sockets;
2441 procedure Secret_Stuff is
2442   @dots{}
2443 end Secret_Stuff
2444 @end smallexample
2445
2446 @noindent
2447 if compiled with pragma @code{License} (@code{Restricted}) in a
2448 @file{gnat.adc} file will generate the warning:
2449
2450 @smallexample
2451 1.  with Sem_Ch3;
2452         |
2453    >>> license of withed unit "Sem_Ch3" is incompatible
2454
2455 2.  with GNAT.Sockets;
2456 3.  procedure Secret_Stuff is
2457 @end smallexample
2458
2459 @noindent
2460 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
2461 compiler and is licensed under the
2462 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
2463 run time, and is therefore licensed under the modified GPL@.
2464
2465 @node Pragma Link_With
2466 @unnumberedsec Pragma Link_With
2467 @findex Link_With
2468 @noindent
2469 Syntax:
2470
2471 @smallexample @c ada
2472 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
2473 @end smallexample
2474
2475 @noindent
2476 This pragma is provided for compatibility with certain Ada 83 compilers.
2477 It has exactly the same effect as pragma @code{Linker_Options} except
2478 that spaces occurring within one of the string expressions are treated
2479 as separators. For example, in the following case:
2480
2481 @smallexample @c ada
2482 pragma Link_With ("-labc -ldef");
2483 @end smallexample
2484
2485 @noindent
2486 results in passing the strings @code{-labc} and @code{-ldef} as two
2487 separate arguments to the linker. In addition pragma Link_With allows
2488 multiple arguments, with the same effect as successive pragmas.
2489
2490 @node Pragma Linker_Alias
2491 @unnumberedsec Pragma Linker_Alias
2492 @findex Linker_Alias
2493 @noindent
2494 Syntax:
2495
2496 @smallexample @c ada
2497 pragma Linker_Alias (
2498   [Entity =>] LOCAL_NAME
2499   [Alias  =>] static_string_EXPRESSION);
2500 @end smallexample
2501
2502 @noindent
2503 This pragma establishes a linker alias for the given named entity.  For
2504 further details on the exact effect, consult the GCC manual.
2505
2506 @node Pragma Linker_Section
2507 @unnumberedsec Pragma Linker_Section
2508 @findex Linker_Section
2509 @noindent
2510 Syntax:
2511
2512 @smallexample @c ada
2513 pragma Linker_Section (
2514   [Entity  =>] LOCAL_NAME
2515   [Section =>] static_string_EXPRESSION);
2516 @end smallexample
2517
2518 @noindent
2519 This pragma specifies the name of the linker section for the given entity.
2520 For further details on the exact effect, consult the GCC manual.
2521
2522 @node Pragma Long_Float
2523 @unnumberedsec Pragma Long_Float
2524 @cindex OpenVMS
2525 @findex Long_Float
2526 @noindent
2527 Syntax:
2528
2529 @smallexample @c ada
2530 pragma Long_Float (FLOAT_FORMAT);
2531
2532 FLOAT_FORMAT ::= D_Float | G_Float
2533 @end smallexample
2534
2535 @noindent
2536 This pragma is implemented only in the OpenVMS implementation of GNAT@.
2537 It allows control over the internal representation chosen for the predefined
2538 type @code{Long_Float} and for floating point type representations with
2539 @code{digits} specified in the range 7 through 15.
2540 For further details on this pragma, see the
2541 @cite{DEC Ada Language Reference Manual}, section 3.5.7b.  Note that to use
2542 this pragma, the standard runtime libraries must be recompiled.  See the
2543 description of the @code{GNAT LIBRARY} command in the OpenVMS version
2544 of the GNAT User's Guide for details on the use of this command.
2545
2546 @node Pragma Machine_Attribute
2547 @unnumberedsec Pragma Machine_Attribute
2548 @findex Machine_Attribute
2549 @noindent
2550 Syntax:
2551
2552 @smallexample @c ada
2553 pragma Machine_Attribute (
2554   [Attribute_Name =>] string_EXPRESSION,
2555   [Entity         =>] LOCAL_NAME);
2556 @end smallexample
2557
2558 @noindent
2559 Machine dependent attributes can be specified for types and/or
2560 declarations.  Currently only subprogram entities are supported.  This
2561 pragma is semantically equivalent to
2562 @code{__attribute__((@var{string_expression}))} in GNU C,
2563 where @code{@var{string_expression}} is
2564 recognized by the GNU C macros @code{VALID_MACHINE_TYPE_ATTRIBUTE} and
2565 @code{VALID_MACHINE_DECL_ATTRIBUTE} which are defined in the
2566 configuration header file @file{tm.h} for each machine.  See the GCC
2567 manual for further information.
2568
2569 @node Pragma Main_Storage
2570 @unnumberedsec Pragma Main_Storage
2571 @cindex OpenVMS
2572 @findex Main_Storage
2573 @noindent
2574 Syntax:
2575
2576 @smallexample @c ada
2577 pragma Main_Storage
2578   (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
2579
2580 MAIN_STORAGE_OPTION ::=
2581   [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
2582 | [TOP_GUARD       =>] static_SIMPLE_EXPRESSION
2583
2584 @end smallexample
2585
2586 @noindent
2587 This pragma is provided for compatibility with OpenVMS VAX Systems.  It has
2588 no effect in GNAT, other than being syntax checked.  Note that the pragma
2589 also has no effect in DEC Ada 83 for OpenVMS Alpha Systems.
2590
2591 @node Pragma No_Return
2592 @unnumberedsec Pragma No_Return
2593 @findex No_Return
2594 @noindent
2595 Syntax:
2596
2597 @smallexample @c ada
2598 pragma No_Return (procedure_LOCAL_NAME);
2599 @end smallexample
2600
2601 @noindent
2602 @var{procedure_local_NAME} must refer to one or more procedure
2603 declarations in the current declarative part.  A procedure to which this
2604 pragma is applied may not contain any explicit @code{return} statements,
2605 and also may not contain any implicit return statements from falling off
2606 the end of a statement sequence.  One use of this pragma is to identify
2607 procedures whose only purpose is to raise an exception.
2608
2609 Another use of this pragma is to suppress incorrect warnings about
2610 missing returns in functions, where the last statement of a function
2611 statement sequence is a call to such a procedure.
2612
2613 @node Pragma Normalize_Scalars
2614 @unnumberedsec Pragma Normalize_Scalars
2615 @findex Normalize_Scalars
2616 @noindent
2617 Syntax:
2618
2619 @smallexample @c ada
2620 pragma Normalize_Scalars;
2621 @end smallexample
2622
2623 @noindent
2624 This is a language defined pragma which is fully implemented in GNAT@.  The
2625 effect is to cause all scalar objects that are not otherwise initialized
2626 to be initialized.  The initial values are implementation dependent and
2627 are as follows:
2628
2629 @table @code
2630 @item Standard.Character
2631 @noindent
2632 Objects whose root type is Standard.Character are initialized to
2633 Character'Last.  This will be out of range of the subtype only if
2634 the subtype range excludes this value.
2635
2636 @item Standard.Wide_Character
2637 @noindent
2638 Objects whose root type is Standard.Wide_Character are initialized to
2639 Wide_Character'Last.  This will be out of range of the subtype only if
2640 the subtype range excludes this value.
2641
2642 @item Integer types
2643 @noindent
2644 Objects of an integer type are initialized to base_type'First, where
2645 base_type is the base type of the object type.  This will be out of range
2646 of the subtype only if the subtype range excludes this value.  For example,
2647 if you declare the subtype:
2648
2649 @smallexample @c ada
2650 subtype Ityp is integer range 1 .. 10;
2651 @end smallexample
2652
2653 @noindent
2654 then objects of type x will be initialized to Integer'First, a negative
2655 number that is certainly outside the range of subtype @code{Ityp}.
2656
2657 @item Real types
2658 Objects of all real types (fixed and floating) are initialized to
2659 base_type'First, where base_Type is the base type of the object type.
2660 This will be out of range of the subtype only if the subtype range
2661 excludes this value.
2662
2663 @item Modular types
2664 Objects of a modular type are initialized to typ'Last.  This will be out
2665 of range of the subtype only if the subtype excludes this value.
2666
2667 @item Enumeration types
2668 Objects of an enumeration type are initialized to all one-bits, i.e.@: to
2669 the value @code{2 ** typ'Size - 1}.  This will be out of range of the
2670 enumeration subtype in all cases except where the subtype contains
2671 exactly 2**8, 2**16, or 2**32 elements.
2672
2673 @end table
2674
2675 @node Pragma Obsolescent
2676 @unnumberedsec Pragma Obsolescent
2677 @findex Obsolescent
2678 @noindent
2679 Syntax:
2680
2681 @smallexample @c ada
2682 pragma Obsolescent [(static_string_EXPRESSION)];
2683 @end smallexample
2684
2685 @noindent
2686 This pragma must occur immediately following a subprogram
2687 declaration. It indicates that the associated function or procedure
2688 is considered obsolescent and should not be used. Typically this is
2689 used when an API must be modified by eventually removing or modifying
2690 existing subprograms. The pragma can be used at an intermediate stage
2691 when the subprogram is still present, but will be removed later.
2692
2693 The effect of this pragma is to output a warning message that the
2694 subprogram is obsolescent if the appropriate warning option in the
2695 compiler is activated. If a parameter is present, then a second
2696 warning message is given containing this text.
2697
2698 @node Pragma Passive
2699 @unnumberedsec Pragma Passive
2700 @findex Passive
2701 @noindent
2702 Syntax:
2703
2704 @smallexample @c ada
2705 pragma Passive ([Semaphore | No]);
2706 @end smallexample
2707
2708 @noindent
2709 Syntax checked, but otherwise ignored by GNAT@.  This is recognized for
2710 compatibility with DEC Ada 83 implementations, where it is used within a
2711 task definition to request that a task be made passive.  If the argument
2712 @code{Semaphore} is present, or the argument is omitted, then DEC Ada 83
2713 treats the pragma as an assertion that the containing task is passive
2714 and that optimization of context switch with this task is permitted and
2715 desired.  If the argument @code{No} is present, the task must not be
2716 optimized.  GNAT does not attempt to optimize any tasks in this manner
2717 (since protected objects are available in place of passive tasks).
2718
2719 @node Pragma Polling
2720 @unnumberedsec Pragma Polling
2721 @findex Polling
2722 @noindent
2723 Syntax:
2724
2725 @smallexample @c ada
2726 pragma Polling (ON | OFF);
2727 @end smallexample
2728
2729 @noindent
2730 This pragma controls the generation of polling code.  This is normally off.
2731 If @code{pragma Polling (ON)} is used then periodic calls are generated to
2732 the routine @code{Ada.Exceptions.Poll}.  This routine is a separate unit in the
2733 runtime library, and can be found in file @file{a-excpol.adb}.
2734
2735 Pragma @code{Polling} can appear as a configuration pragma (for example it
2736 can be placed in the @file{gnat.adc} file) to enable polling globally, or it
2737 can be used in the statement or declaration sequence to control polling
2738 more locally.
2739
2740 A call to the polling routine is generated at the start of every loop and
2741 at the start of every subprogram call.  This guarantees that the @code{Poll}
2742 routine is called frequently, and places an upper bound (determined by
2743 the complexity of the code) on the period between two @code{Poll} calls.
2744
2745 The primary purpose of the polling interface is to enable asynchronous
2746 aborts on targets that cannot otherwise support it (for example Windows
2747 NT), but it may be used for any other purpose requiring periodic polling.
2748 The standard version is null, and can be replaced by a user program.  This
2749 will require re-compilation of the @code{Ada.Exceptions} package that can
2750 be found in files @file{a-except.ads} and @file{a-except.adb}.
2751
2752 A standard alternative unit (in file @file{4wexcpol.adb} in the standard GNAT
2753 distribution) is used to enable the asynchronous abort capability on
2754 targets that do not normally support the capability.  The version of
2755 @code{Poll} in this file makes a call to the appropriate runtime routine
2756 to test for an abort condition.
2757
2758 Note that polling can also be enabled by use of the @code{-gnatP} switch.  See
2759 the @cite{GNAT User's Guide} for details.
2760
2761 @node Pragma Propagate_Exceptions
2762 @unnumberedsec Pragma Propagate_Exceptions
2763 @findex Propagate_Exceptions
2764 @cindex Zero Cost Exceptions
2765 @noindent
2766 Syntax:
2767
2768 @smallexample @c ada
2769 pragma Propagate_Exceptions (subprogram_LOCAL_NAME);
2770 @end smallexample
2771
2772 @noindent
2773 This pragma indicates that the given entity, which is the name of an
2774 imported foreign-language subprogram may receive an Ada exception,
2775 and that the exception should be propagated.  It is relevant only if
2776 zero cost exception handling is in use, and is thus never needed if
2777 the alternative @code{longjmp} / @code{setjmp} implementation of
2778 exceptions is used (although it is harmless to use it in such cases).
2779
2780 The implementation of fast exceptions always properly propagates
2781 exceptions through Ada code, as described in the Ada Reference Manual.
2782 However, this manual is silent about the propagation of exceptions
2783 through foreign code.  For example, consider the
2784 situation where @code{P1} calls
2785 @code{P2}, and @code{P2} calls @code{P3}, where
2786 @code{P1} and @code{P3} are in Ada, but @code{P2} is in C@.
2787 @code{P3} raises an Ada exception.  The question is whether or not
2788 it will be propagated through @code{P2} and can be handled in
2789 @code{P1}.
2790
2791 For the @code{longjmp} / @code{setjmp} implementation of exceptions,
2792 the answer is always yes.  For some targets on which zero cost exception
2793 handling is implemented, the answer is also always yes.  However, there
2794 are some targets, notably in the current version all x86 architecture
2795 targets, in which the answer is that such propagation does not
2796 happen automatically.  If such propagation is required on these
2797 targets, it is mandatory to use @code{Propagate_Exceptions} to
2798 name all foreign language routines through which Ada exceptions
2799 may be propagated.
2800
2801 @node Pragma Psect_Object
2802 @unnumberedsec Pragma Psect_Object
2803 @findex Psect_Object
2804 @noindent
2805 Syntax:
2806
2807 @smallexample @c ada
2808 pragma Psect_Object (
2809      [Internal =>] LOCAL_NAME,
2810   [, [External =>] EXTERNAL_SYMBOL]
2811   [, [Size     =>] EXTERNAL_SYMBOL]);
2812
2813 EXTERNAL_SYMBOL ::=
2814   IDENTIFIER
2815 | static_string_EXPRESSION
2816 @end smallexample
2817
2818 @noindent
2819 This pragma is identical in effect to pragma @code{Common_Object}.
2820
2821 @node Pragma Pure_Function
2822 @unnumberedsec Pragma Pure_Function
2823 @findex Pure_Function
2824 @noindent
2825 Syntax:
2826
2827 @smallexample @c ada
2828 pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
2829 @end smallexample
2830
2831 @noindent
2832 This pragma appears in the same declarative part as a function
2833 declaration (or a set of function declarations if more than one
2834 overloaded declaration exists, in which case the pragma applies
2835 to all entities).  It specifies that the function @code{Entity} is
2836 to be considered pure for the purposes of code generation.  This means
2837 that the compiler can assume that there are no side effects, and
2838 in particular that two calls with identical arguments produce the
2839 same result.  It also means that the function can be used in an
2840 address clause.
2841
2842 Note that, quite deliberately, there are no static checks to try
2843 to ensure that this promise is met, so @code{Pure_Function} can be used
2844 with functions that are conceptually pure, even if they do modify
2845 global variables.  For example, a square root function that is
2846 instrumented to count the number of times it is called is still
2847 conceptually pure, and can still be optimized, even though it
2848 modifies a global variable (the count).  Memo functions are another
2849 example (where a table of previous calls is kept and consulted to
2850 avoid re-computation).
2851
2852 @findex Pure
2853 Note: Most functions in a @code{Pure} package are automatically pure, and
2854 there is no need to use pragma @code{Pure_Function} for such functions.  One
2855 exception is any function that has at least one formal of type
2856 @code{System.Address} or a type derived from it.  Such functions are not
2857 considered pure by default, since the compiler assumes that the
2858 @code{Address} parameter may be functioning as a pointer and that the
2859 referenced data may change even if the address value does not.
2860 Similarly, imported functions are not considered to be pure by default,
2861 since there is no way of checking that they are in fact pure.  The use
2862 of pragma @code{Pure_Function} for such a function will override these default
2863 assumption, and cause the compiler to treat a designated subprogram as pure
2864 in these cases.
2865
2866 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
2867 applies to the underlying renamed function.  This can be used to
2868 disambiguate cases of overloading where some but not all functions
2869 in a set of overloaded functions are to be designated as pure.
2870
2871 @node Pragma Ravenscar
2872 @unnumberedsec Pragma Ravenscar
2873 @findex Ravenscar
2874 @noindent
2875 Syntax:
2876
2877 @smallexample @c ada
2878 pragma Ravenscar;
2879 @end smallexample
2880
2881 @noindent
2882 A configuration pragma that establishes the following set of restrictions:
2883
2884 @table @code
2885 @item No_Abort_Statements
2886 [RM D.7] There are no abort_statements, and there are
2887 no calls to Task_Identification.Abort_Task.
2888
2889 @item No_Select_Statements
2890 There are no select_statements.
2891
2892 @item No_Task_Hierarchy
2893 [RM D.7] All (non-environment) tasks depend
2894 directly on the environment task of the partition.
2895
2896 @item No_Task_Allocators
2897 [RM D.7] There are no allocators for task types
2898 or types containing task subcomponents.
2899
2900 @item No_Dynamic_Priorities
2901 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
2902
2903 @item No_Terminate_Alternatives
2904 [RM D.7] There are no selective_accepts with terminate_alternatives
2905
2906 @item No_Dynamic_Interrupts
2907 There are no semantic dependencies on Ada.Interrupts.
2908
2909 @item No_Implicit_Heap_Allocations
2910 [RM D.7] No constructs are allowed to cause implicit heap allocation
2911
2912 @item No_Protected_Type_Allocators
2913 There are no allocators for protected types or
2914 types containing protected subcomponents.
2915
2916 @item No_Local_Protected_Objects
2917 Protected objects and access types that designate
2918 such objects shall be declared only at library level.
2919
2920 @item No_Requeue_Statements
2921 Requeue statements are not allowed.
2922
2923 @item No_Calendar
2924 There are no semantic dependencies on the package Ada.Calendar.
2925
2926 @item No_Relative_Delay
2927 There are no delay_relative_statements.
2928
2929 @item No_Task_Attributes
2930 There are no semantic dependencies on the Ada.Task_Attributes package and
2931 there are no references to the attributes Callable and Terminated [RM 9.9].
2932
2933 @item Boolean_Entry_Barriers
2934 Entry barrier condition expressions shall be boolean
2935 objects which are declared in the protected type
2936 which contains the entry.
2937
2938 @item Max_Asynchronous_Select_Nesting = 0
2939 [RM D.7] Specifies the maximum dynamic nesting level of asynchronous_selects.
2940 A value of zero prevents the use of any asynchronous_select.
2941
2942 @item Max_Task_Entries = 0
2943 [RM D.7] Specifies the maximum number of entries
2944 per task.  The bounds of every entry family
2945 of a task unit shall be static, or shall be
2946 defined by a discriminant of a subtype whose
2947 corresponding bound is static.  A value of zero
2948 indicates that no rendezvous are possible.  For
2949 the Ravenscar pragma, the value of Max_Task_Entries is always
2950 0 (zero).
2951
2952 @item Max_Protected_Entries = 1
2953 [RM D.7] Specifies the maximum number of entries per
2954 protected type.  The bounds of every entry family of
2955 a protected unit shall be static, or shall be defined
2956 by a discriminant of a subtype whose corresponding
2957 bound is static.  For the Ravenscar pragma the value of
2958 Max_Protected_Entries is always 1.
2959
2960 @item Max_Select_Alternatives = 0
2961 [RM D.7] Specifies the maximum number of alternatives in a selective_accept.
2962 For the Ravenscar pragma the value is always 0.
2963
2964 @item No_Task_Termination
2965 Tasks which terminate are erroneous.
2966
2967 @item No_Entry_Queue
2968 No task can be queued on a protected entry.  Note that this restrictions is
2969 checked at run time.  The violation of this restriction generates a
2970 Program_Error exception.
2971 @end table
2972
2973 @noindent
2974 This set of restrictions corresponds to the definition of the ``Ravenscar
2975 Profile'' for limited tasking, devised and published by the
2976 @cite{International Real-Time Ada Workshop}, 1997,
2977 and whose most recent description is available at
2978 @url{ftp://ftp.openravenscar.org/openravenscar/ravenscar00.pdf}.
2979
2980 The above set is a superset of the restrictions provided by pragma
2981 @code{Restricted_Run_Time}, it includes five additional restrictions
2982 (@code{Boolean_Entry_Barriers}, @code{No_Select_Statements},
2983 @code{No_Calendar},
2984 @code{No_Relative_Delay} and @code{No_Task_Termination}).  This means
2985 that pragma @code{Ravenscar}, like the pragma @code{Restricted_Run_Time},
2986 automatically causes the use of a simplified, more efficient version
2987 of the tasking run-time system.
2988
2989 @node Pragma Restricted_Run_Time
2990 @unnumberedsec Pragma Restricted_Run_Time
2991 @findex Restricted_Run_Time
2992 @noindent
2993 Syntax:
2994
2995 @smallexample @c ada
2996 pragma Restricted_Run_Time;
2997 @end smallexample
2998
2999 @noindent
3000 A configuration pragma that establishes the following set of restrictions:
3001
3002 @itemize @bullet
3003 @item No_Abort_Statements
3004 @item No_Entry_Queue
3005 @item No_Task_Hierarchy
3006 @item No_Task_Allocators
3007 @item No_Dynamic_Priorities
3008 @item No_Terminate_Alternatives
3009 @item No_Dynamic_Interrupts
3010 @item No_Protected_Type_Allocators
3011 @item No_Local_Protected_Objects
3012 @item No_Requeue_Statements
3013 @item No_Task_Attributes
3014 @item Max_Asynchronous_Select_Nesting =  0
3015 @item Max_Task_Entries =  0
3016 @item Max_Protected_Entries = 1
3017 @item Max_Select_Alternatives = 0
3018 @end itemize
3019
3020 @noindent
3021 This set of restrictions causes the automatic selection of a simplified
3022 version of the run time that provides improved performance for the
3023 limited set of tasking functionality permitted by this set of restrictions.
3024
3025 @node Pragma Restriction_Warnings
3026 @unnumberedsec Pragma Restriction_Warnings
3027 @findex Restriction_Warnings
3028 @noindent
3029 Syntax:
3030
3031 @smallexample @c ada
3032 pragma Restriction_Warnings
3033   (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
3034 @end smallexample
3035
3036 @noindent
3037 This pragma allows a series of restriction identifiers to be
3038 specified (the list of allowed identifiers is the same as for
3039 pragma @code{Restrictions}). For each of these identifiers
3040 the compiler checks for violations of the restriction, but
3041 generates a warning message rather than an error message
3042 if the restriction is violated.
3043
3044 @node Pragma Source_File_Name
3045 @unnumberedsec Pragma Source_File_Name
3046 @findex Source_File_Name
3047 @noindent
3048 Syntax:
3049
3050 @smallexample @c ada
3051 pragma Source_File_Name (
3052   [Unit_Name   =>] unit_NAME,
3053   Spec_File_Name =>  STRING_LITERAL);
3054
3055 pragma Source_File_Name (
3056   [Unit_Name   =>] unit_NAME,
3057   Body_File_Name =>  STRING_LITERAL);
3058 @end smallexample
3059
3060 @noindent
3061 Use this to override the normal naming convention.  It is a configuration
3062 pragma, and so has the usual applicability of configuration pragmas
3063 (i.e.@: it applies to either an entire partition, or to all units in a
3064 compilation, or to a single unit, depending on how it is used.
3065 @var{unit_name} is mapped to @var{file_name_literal}.  The identifier for
3066 the second argument is required, and indicates whether this is the file
3067 name for the spec or for the body.
3068
3069 Another form of the @code{Source_File_Name} pragma allows
3070 the specification of patterns defining alternative file naming schemes
3071 to apply to all files.
3072
3073 @smallexample @c ada
3074 pragma Source_File_Name
3075   (Spec_File_Name => STRING_LITERAL
3076    [,Casing => CASING_SPEC]
3077    [,Dot_Replacement => STRING_LITERAL]);
3078
3079 pragma Source_File_Name
3080   (Body_File_Name => STRING_LITERAL
3081    [,Casing => CASING_SPEC]
3082    [,Dot_Replacement => STRING_LITERAL]);
3083
3084 pragma Source_File_Name
3085   (Subunit_File_Name => STRING_LITERAL
3086    [,Casing => CASING_SPEC]
3087    [,Dot_Replacement => STRING_LITERAL]);
3088
3089 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
3090 @end smallexample
3091
3092 @noindent
3093 The first argument is a pattern that contains a single asterisk indicating
3094 the point at which the unit name is to be inserted in the pattern string
3095 to form the file name.  The second argument is optional.  If present it
3096 specifies the casing of the unit name in the resulting file name string.
3097 The default is lower case.  Finally the third argument allows for systematic
3098 replacement of any dots in the unit name by the specified string literal.
3099
3100 A pragma Source_File_Name cannot appear after a
3101 @ref{Pragma Source_File_Name_Project}.
3102
3103 For more details on the use of the @code{Source_File_Name} pragma,
3104 see the sections ``Using Other File Names'' and
3105 ``Alternative File Naming Schemes'' in the @cite{GNAT User's Guide}.
3106
3107 @node Pragma Source_File_Name_Project
3108 @unnumberedsec Pragma Source_File_Name_Project
3109 @findex Source_File_Name_Project
3110 @noindent
3111
3112 This pragma has the same syntax and semantics as pragma Source_File_Name.
3113 It is only allowed as a stand alone configuration pragma.
3114 It cannot appear after a @ref{Pragma Source_File_Name}, and
3115 most importantly, once pragma Source_File_Name_Project appears,
3116 no further Source_File_Name pragmas are allowed.
3117
3118 The intention is that Source_File_Name_Project pragmas are always
3119 generated by the Project Manager in a manner consistent with the naming
3120 specified in a project file, and when naming is controlled in this manner,
3121 it is not permissible to attempt to modify this naming scheme using
3122 Source_File_Name pragmas (which would not be known to the project manager).
3123
3124 @node Pragma Source_Reference
3125 @unnumberedsec Pragma Source_Reference
3126 @findex Source_Reference
3127 @noindent
3128 Syntax:
3129
3130 @smallexample @c ada
3131 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
3132 @end smallexample
3133
3134 @noindent
3135 This pragma must appear as the first line of a source file.
3136 @var{integer_literal} is the logical line number of the line following
3137 the pragma line (for use in error messages and debugging
3138 information).  @var{string_literal} is a static string constant that
3139 specifies the file name to be used in error messages and debugging
3140 information.  This is most notably used for the output of @code{gnatchop}
3141 with the @code{-r} switch, to make sure that the original unchopped
3142 source file is the one referred to.
3143
3144 The second argument must be a string literal, it cannot be a static
3145 string expression other than a string literal.  This is because its value
3146 is needed for error messages issued by all phases of the compiler.
3147
3148 @node Pragma Stream_Convert
3149 @unnumberedsec Pragma Stream_Convert
3150 @findex Stream_Convert
3151 @noindent
3152 Syntax:
3153
3154 @smallexample @c ada
3155 pragma Stream_Convert (
3156   [Entity =>] type_LOCAL_NAME,
3157   [Read   =>] function_NAME,
3158   [Write  =>] function_NAME);
3159 @end smallexample
3160
3161 @noindent
3162 This pragma provides an efficient way of providing stream functions for
3163 types defined in packages.  Not only is it simpler to use than declaring
3164 the necessary functions with attribute representation clauses, but more
3165 significantly, it allows the declaration to made in such a way that the
3166 stream packages are not loaded unless they are needed.  The use of
3167 the Stream_Convert pragma adds no overhead at all, unless the stream
3168 attributes are actually used on the designated type.
3169
3170 The first argument specifies the type for which stream functions are
3171 provided.  The second parameter provides a function used to read values
3172 of this type.  It must name a function whose argument type may be any
3173 subtype, and whose returned type must be the type given as the first
3174 argument to the pragma.
3175
3176 The meaning of the @var{Read}
3177 parameter is that if a stream attribute directly
3178 or indirectly specifies reading of the type given as the first parameter,
3179 then a value of the type given as the argument to the Read function is
3180 read from the stream, and then the Read function is used to convert this
3181 to the required target type.
3182
3183 Similarly the @var{Write} parameter specifies how to treat write attributes
3184 that directly or indirectly apply to the type given as the first parameter.
3185 It must have an input parameter of the type specified by the first parameter,
3186 and the return type must be the same as the input type of the Read function.
3187 The effect is to first call the Write function to convert to the given stream
3188 type, and then write the result type to the stream.
3189
3190 The Read and Write functions must not be overloaded subprograms.  If necessary
3191 renamings can be supplied to meet this requirement.
3192 The usage of this attribute is best illustrated by a simple example, taken
3193 from the GNAT implementation of package Ada.Strings.Unbounded:
3194
3195 @smallexample @c ada
3196 function To_Unbounded (S : String)
3197            return Unbounded_String
3198   renames To_Unbounded_String;
3199
3200 pragma Stream_Convert
3201   (Unbounded_String, To_Unbounded, To_String);
3202 @end smallexample
3203
3204 @noindent
3205 The specifications of the referenced functions, as given in the Ada 95
3206 Reference Manual are:
3207
3208 @smallexample @c ada
3209 function To_Unbounded_String (Source : String)
3210   return Unbounded_String;
3211
3212 function To_String (Source : Unbounded_String)
3213   return String;
3214 @end smallexample
3215
3216 @noindent
3217 The effect is that if the value of an unbounded string is written to a
3218 stream, then the representation of the item in the stream is in the same
3219 format used for @code{Standard.String}, and this same representation is
3220 expected when a value of this type is read from the stream.
3221
3222 @node Pragma Style_Checks
3223 @unnumberedsec Pragma Style_Checks
3224 @findex Style_Checks
3225 @noindent
3226 Syntax:
3227
3228 @smallexample @c ada
3229 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
3230                      On | Off [, LOCAL_NAME]);
3231 @end smallexample
3232
3233 @noindent
3234 This pragma is used in conjunction with compiler switches to control the
3235 built in style checking provided by GNAT@.  The compiler switches, if set,
3236 provide an initial setting for the switches, and this pragma may be used
3237 to modify these settings, or the settings may be provided entirely by
3238 the use of the pragma.  This pragma can be used anywhere that a pragma
3239 is legal, including use as a configuration pragma (including use in
3240 the @file{gnat.adc} file).
3241
3242 The form with a string literal specifies which style options are to be
3243 activated.  These are additive, so they apply in addition to any previously
3244 set style check options.  The codes for the options are the same as those
3245 used in the @code{-gnaty} switch to @code{gcc} or @code{gnatmake}.
3246 For example the following two methods can be used to enable
3247 layout checking:
3248
3249 @itemize @bullet
3250 @item
3251 @smallexample @c ada
3252 pragma Style_Checks ("l");
3253 @end smallexample
3254
3255 @item
3256 @smallexample
3257 gcc -c -gnatyl @dots{}
3258 @end smallexample
3259 @end itemize
3260
3261 @noindent
3262 The form ALL_CHECKS activates all standard checks (its use is equivalent
3263 to the use of the @code{gnaty} switch with no options.  See GNAT User's
3264 Guide for details.
3265
3266 The forms with @code{Off} and @code{On}
3267 can be used to temporarily disable style checks
3268 as shown in the following example:
3269
3270 @smallexample @c ada
3271 @iftex
3272 @leftskip=0cm
3273 @end iftex
3274 pragma Style_Checks ("k"); -- requires keywords in lower case
3275 pragma Style_Checks (Off); -- turn off style checks
3276 NULL;                      -- this will not generate an error message
3277 pragma Style_Checks (On);  -- turn style checks back on
3278 NULL;                      -- this will generate an error message
3279 @end smallexample
3280
3281 @noindent
3282 Finally the two argument form is allowed only if the first argument is
3283 @code{On} or @code{Off}.  The effect is to turn of semantic style checks
3284 for the specified entity, as shown in the following example:
3285
3286 @smallexample @c ada
3287 @iftex
3288 @leftskip=0cm
3289 @end iftex
3290 pragma Style_Checks ("r"); -- require consistency of identifier casing
3291 Arg : Integer;
3292 Rf1 : Integer := ARG;      -- incorrect, wrong case
3293 pragma Style_Checks (Off, Arg);
3294 Rf2 : Integer := ARG;      -- OK, no error
3295 @end smallexample
3296
3297 @node Pragma Subtitle
3298 @unnumberedsec Pragma Subtitle
3299 @findex Subtitle
3300 @noindent
3301 Syntax:
3302
3303 @smallexample @c ada
3304 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
3305 @end smallexample
3306
3307 @noindent
3308 This pragma is recognized for compatibility with other Ada compilers
3309 but is ignored by GNAT@.
3310
3311 @node Pragma Suppress_All
3312 @unnumberedsec Pragma Suppress_All
3313 @findex Suppress_All
3314 @noindent
3315 Syntax:
3316
3317 @smallexample @c ada
3318 pragma Suppress_All;
3319 @end smallexample
3320
3321 @noindent
3322 This pragma can only appear immediately following a compilation
3323 unit.  The effect is to apply @code{Suppress (All_Checks)} to the unit
3324 which it follows.  This pragma is implemented for compatibility with DEC
3325 Ada 83 usage.  The use of pragma @code{Suppress (All_Checks)} as a normal
3326 configuration pragma is the preferred usage in GNAT@.
3327
3328 @node Pragma Suppress_Exception_Locations
3329 @unnumberedsec Pragma Suppress_Exception_Locations
3330 @findex Suppress_Exception_Locations
3331 @noindent
3332 Syntax:
3333
3334 @smallexample @c ada
3335 pragma Suppress_Exception_Locations;
3336 @end smallexample
3337
3338 @noindent
3339 In normal mode, a raise statement for an exception by default generates
3340 an exception message giving the file name and line number for the location
3341 of the raise. This is useful for debugging and logging purposes, but this
3342 entails extra space for the strings for the messages. The configuration
3343 pragma @code{Suppress_Exception_Locations} can be used to suppress the
3344 generation of these strings, with the result that space is saved, but the
3345 exception message for such raises is null. This configuration pragma may
3346 appear in a global configuration pragma file, or in a specific unit as
3347 usual. It is not required that this pragma be used consistently within
3348 a partition, so it is fine to have some units within a partition compiled
3349 with this pragma and others compiled in normal mode without it.
3350
3351 @node Pragma Suppress_Initialization
3352 @unnumberedsec Pragma Suppress_Initialization
3353 @findex Suppress_Initialization
3354 @cindex Suppressing initialization
3355 @cindex Initialization, suppression of
3356 @noindent
3357 Syntax:
3358
3359 @smallexample @c ada
3360 pragma Suppress_Initialization ([Entity =>] type_Name);
3361 @end smallexample
3362
3363 @noindent
3364 This pragma suppresses any implicit or explicit initialization
3365 associated with the given type name for all variables of this type.
3366
3367 @node Pragma Task_Info
3368 @unnumberedsec Pragma Task_Info
3369 @findex Task_Info
3370 @noindent
3371 Syntax
3372
3373 @smallexample @c ada
3374 pragma Task_Info (EXPRESSION);
3375 @end smallexample
3376
3377 @noindent
3378 This pragma appears within a task definition (like pragma
3379 @code{Priority}) and applies to the task in which it appears.  The
3380 argument must be of type @code{System.Task_Info.Task_Info_Type}.
3381 The @code{Task_Info} pragma provides system dependent control over
3382 aspects of tasking implementation, for example, the ability to map
3383 tasks to specific processors.  For details on the facilities available
3384 for the version of GNAT that you are using, see the documentation
3385 in the specification of package System.Task_Info in the runtime
3386 library.
3387
3388 @node Pragma Task_Name
3389 @unnumberedsec Pragma Task_Name
3390 @findex Task_Name
3391 @noindent
3392 Syntax
3393
3394 @smallexample @c ada
3395 pragma Task_Name (string_EXPRESSION);
3396 @end smallexample
3397
3398 @noindent
3399 This pragma appears within a task definition (like pragma
3400 @code{Priority}) and applies to the task in which it appears.  The
3401 argument must be of type String, and provides a name to be used for
3402 the task instance when the task is created.  Note that this expression
3403 is not required to be static, and in particular, it can contain
3404 references to task discriminants.  This facility can be used to
3405 provide different names for different tasks as they are created,
3406 as illustrated in the example below.
3407
3408 The task name is recorded internally in the run-time structures
3409 and is accessible to tools like the debugger.  In addition the
3410 routine @code{Ada.Task_Identification.Image} will return this
3411 string, with a unique task address appended.
3412
3413 @smallexample @c ada
3414 --  Example of the use of pragma Task_Name
3415
3416 with Ada.Task_Identification;
3417 use Ada.Task_Identification;
3418 with Text_IO; use Text_IO;
3419 procedure t3 is
3420
3421    type Astring is access String;
3422
3423    task type Task_Typ (Name : access String) is
3424       pragma Task_Name (Name.all);
3425    end Task_Typ;
3426
3427    task body Task_Typ is
3428       Nam : constant String := Image (Current_Task);
3429    begin
3430       Put_Line ("-->" & Nam (1 .. 14) & "<--");
3431    end Task_Typ;
3432
3433    type Ptr_Task is access Task_Typ;
3434    Task_Var : Ptr_Task;
3435
3436 begin
3437    Task_Var :=
3438      new Task_Typ (new String'("This is task 1"));
3439    Task_Var :=
3440      new Task_Typ (new String'("This is task 2"));
3441 end;
3442 @end smallexample
3443
3444 @node Pragma Task_Storage
3445 @unnumberedsec Pragma Task_Storage
3446 @findex Task_Storage
3447 Syntax:
3448
3449 @smallexample @c ada
3450 pragma Task_Storage (
3451   [Task_Type =>] LOCAL_NAME,
3452   [Top_Guard =>] static_integer_EXPRESSION);
3453 @end smallexample
3454
3455 @noindent
3456 This pragma specifies the length of the guard area for tasks.  The guard
3457 area is an additional storage area allocated to a task.  A value of zero
3458 means that either no guard area is created or a minimal guard area is
3459 created, depending on the target.  This pragma can appear anywhere a
3460 @code{Storage_Size} attribute definition clause is allowed for a task
3461 type.
3462
3463 @node Pragma Thread_Body
3464 @unnumberedsec Pragma Thread_Body
3465 @findex Thread_Body
3466 Syntax:
3467
3468 @smallexample @c ada
3469 pragma Thread_Body (
3470   [Entity =>] LOCAL_NAME,
3471  [[Secondary_Stack_Size =>] static_integer_EXPRESSION)];
3472 @end smallexample
3473
3474 @noindent
3475 This pragma specifies that the subprogram whose name is given as the
3476 @code{Entity} argument is a thread body, which will be activated
3477 by being called via its Address from foreign code. The purpose is
3478 to allow execution and registration of the foreign thread within the
3479 Ada run-time system.
3480
3481 See the library unit @code{System.Threads} for details on the expansion of
3482 a thread body subprogram, including the calls made to subprograms
3483 within System.Threads to register the task.  This unit also lists the
3484 targets and runtime systems for which this pragma is supported.
3485
3486 A thread body subprogram may not be called directly from Ada code, and
3487 it is not permitted to apply the Access (or Unrestricted_Access) attributes
3488 to such a subprogram. The only legitimate way of calling such a subprogram
3489 is to pass its Address to foreign code and then make the call from the
3490 foreign code.
3491
3492 A thread body subprogram may have any parameters, and it may be a function
3493 returning a result. The convention of the thread body subprogram may be
3494 set in the usual manner using @code{pragma Convention}.
3495
3496 The secondary stack size parameter, if given, is used to set the size
3497 of secondary stack for the thread. The secondary stack is allocated as
3498 a local variable of the expanded thread body subprogram, and thus is
3499 allocated out of the main thread stack size. If no secondary stack
3500 size parameter is present, the default size (from the declaration in
3501 @code{System.Secondary_Stack} is used.
3502
3503 @node Pragma Time_Slice
3504 @unnumberedsec Pragma Time_Slice
3505 @findex Time_Slice
3506 @noindent
3507 Syntax:
3508
3509 @smallexample @c ada
3510 pragma Time_Slice (static_duration_EXPRESSION);
3511 @end smallexample
3512
3513 @noindent
3514 For implementations of GNAT on operating systems where it is possible
3515 to supply a time slice value, this pragma may be used for this purpose.
3516 It is ignored if it is used in a system that does not allow this control,
3517 or if it appears in other than the main program unit.
3518 @cindex OpenVMS
3519 Note that the effect of this pragma is identical to the effect of the
3520 DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
3521
3522 @node Pragma Title
3523 @unnumberedsec Pragma Title
3524 @findex Title
3525 @noindent
3526 Syntax:
3527
3528 @smallexample @c ada
3529 pragma Title (TITLING_OPTION [, TITLING OPTION]);
3530
3531 TITLING_OPTION ::=
3532   [Title    =>] STRING_LITERAL,
3533 | [Subtitle =>] STRING_LITERAL
3534 @end smallexample
3535
3536 @noindent
3537 Syntax checked but otherwise ignored by GNAT@.  This is a listing control
3538 pragma used in DEC Ada 83 implementations to provide a title and/or
3539 subtitle for the program listing.  The program listing generated by GNAT
3540 does not have titles or subtitles.
3541
3542 Unlike other pragmas, the full flexibility of named notation is allowed
3543 for this pragma, i.e.@: the parameters may be given in any order if named
3544 notation is used, and named and positional notation can be mixed
3545 following the normal rules for procedure calls in Ada.
3546
3547 @node Pragma Unchecked_Union
3548 @unnumberedsec Pragma Unchecked_Union
3549 @cindex Unions in C
3550 @findex Unchecked_Union
3551 @noindent
3552 Syntax:
3553
3554 @smallexample @c ada
3555 pragma Unchecked_Union (first_subtype_LOCAL_NAME);
3556 @end smallexample
3557
3558 @noindent
3559 This pragma is used to declare that the specified type should be represented
3560 in a manner
3561 equivalent to a C union type, and is intended only for use in
3562 interfacing with C code that uses union types.  In Ada terms, the named
3563 type must obey the following rules:
3564
3565 @itemize @bullet
3566 @item
3567 It is a non-tagged non-limited record type.
3568 @item
3569 It has a single discrete discriminant with a default value.
3570 @item
3571 The component list consists of a single variant part.
3572 @item
3573 Each variant has a component list with a single component.
3574 @item
3575 No nested variants are allowed.
3576 @item
3577 No component has an explicit default value.
3578 @item
3579 No component has a non-static constraint.
3580 @end itemize
3581
3582 @noindent
3583 In addition, given a type that meets the above requirements, the
3584 following restrictions apply to its use throughout the program:
3585
3586 @itemize @bullet
3587 @item
3588 The discriminant name can be mentioned only in an aggregate.
3589 @item
3590 No subtypes may be created of this type.
3591 @item
3592 The type may not be constrained by giving a discriminant value.
3593 @item
3594 The type cannot be passed as the actual for a generic formal with a
3595 discriminant.
3596 @end itemize
3597
3598 @noindent
3599 Equality and inequality operations on @code{unchecked_unions} are not
3600 available, since there is no discriminant to compare and the compiler
3601 does not even know how many bits to compare.  It is implementation
3602 dependent whether this is detected at compile time as an illegality or
3603 whether it is undetected and considered to be an erroneous construct.  In
3604 GNAT, a direct comparison is illegal, but GNAT does not attempt to catch
3605 the composite case (where two composites are compared that contain an
3606 unchecked union component), so such comparisons are simply considered
3607 erroneous.
3608
3609 The layout of the resulting type corresponds exactly to a C union, where
3610 each branch of the union corresponds to a single variant in the Ada
3611 record.  The semantics of the Ada program is not changed in any way by
3612 the pragma, i.e.@: provided the above restrictions are followed, and no
3613 erroneous incorrect references to fields or erroneous comparisons occur,
3614 the semantics is exactly as described by the Ada reference manual.
3615 Pragma @code{Suppress (Discriminant_Check)} applies implicitly to the
3616 type and the default convention is C.
3617
3618 @node Pragma Unimplemented_Unit
3619 @unnumberedsec Pragma Unimplemented_Unit
3620 @findex Unimplemented_Unit
3621 @noindent
3622 Syntax:
3623
3624 @smallexample @c ada
3625 pragma Unimplemented_Unit;
3626 @end smallexample
3627
3628 @noindent
3629 If this pragma occurs in a unit that is processed by the compiler, GNAT
3630 aborts with the message @samp{@var{xxx} not implemented}, where
3631 @var{xxx} is the name of the current compilation unit.  This pragma is
3632 intended to allow the compiler to handle unimplemented library units in
3633 a clean manner.
3634
3635 The abort only happens if code is being generated.  Thus you can use
3636 specs of unimplemented packages in syntax or semantic checking mode.
3637
3638 @node Pragma Universal_Data
3639 @unnumberedsec Pragma Universal_Data
3640 @findex Universal_Data
3641 @noindent
3642 Syntax:
3643
3644 @smallexample @c ada
3645 pragma Universal_Data [(library_unit_Name)];
3646 @end smallexample
3647
3648 @noindent
3649 This pragma is supported only for the AAMP target and is ignored for
3650 other targets. The pragma specifies that all library-level objects
3651 (Counter 0 data) associated with the library unit are to be accessed
3652 and updated using universal addressing (24-bit addresses for AAMP5)
3653 rather than the default of 16-bit Data Environment (DENV) addressing.
3654 Use of this pragma will generally result in less efficient code for
3655 references to global data associated with the library unit, but
3656 allows such data to be located anywhere in memory. This pragma is
3657 a library unit pragma, but can also be used as a configuration pragma
3658 (including use in the @file{gnat.adc} file). The functionality
3659 of this pragma is also available by applying the -univ switch on the
3660 compilations of units where universal addressing of the data is desired.
3661
3662 @node Pragma Unreferenced
3663 @unnumberedsec Pragma Unreferenced
3664 @findex Unreferenced
3665 @cindex Warnings, unreferenced
3666 @noindent
3667 Syntax:
3668
3669 @smallexample @c ada
3670 pragma Unreferenced (local_Name @{, local_Name@});
3671 @end smallexample
3672
3673 @noindent
3674 This pragma signals that the entities whose names are listed are
3675 deliberately not referenced in the current source unit. This
3676 suppresses warnings about the
3677 entities being unreferenced, and in addition a warning will be
3678 generated if one of these entities is in fact referenced in the
3679 same unit as the pragma (or in the corresponding body, or one
3680 of its subunits).
3681
3682 This is particularly useful for clearly signaling that a particular
3683 parameter is not referenced in some particular subprogram implementation
3684 and that this is deliberate. It can also be useful in the case of
3685 objects declared only for their initialization or finalization side
3686 effects.
3687
3688 If @code{local_Name} identifies more than one matching homonym in the
3689 current scope, then the entity most recently declared is the one to which
3690 the pragma applies.
3691
3692 The left hand side of an assignment does not count as a reference for the
3693 purpose of this pragma. Thus it is fine to assign to an entity for which
3694 pragma Unreferenced is given.
3695
3696 @node Pragma Unreserve_All_Interrupts
3697 @unnumberedsec Pragma Unreserve_All_Interrupts
3698 @findex Unreserve_All_Interrupts
3699 @noindent
3700 Syntax:
3701
3702 @smallexample @c ada
3703 pragma Unreserve_All_Interrupts;
3704 @end smallexample
3705
3706 @noindent
3707 Normally certain interrupts are reserved to the implementation.  Any attempt
3708 to attach an interrupt causes Program_Error to be raised, as described in
3709 RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
3710 many systems for a @kbd{Ctrl-C} interrupt.  Normally this interrupt is
3711 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
3712 interrupt execution.
3713
3714 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
3715 a program, then all such interrupts are unreserved.  This allows the
3716 program to handle these interrupts, but disables their standard
3717 functions.  For example, if this pragma is used, then pressing
3718 @kbd{Ctrl-C} will not automatically interrupt execution.  However,
3719 a program can then handle the @code{SIGINT} interrupt as it chooses.
3720
3721 For a full list of the interrupts handled in a specific implementation,
3722 see the source code for the specification of @code{Ada.Interrupts.Names} in
3723 file @file{a-intnam.ads}.  This is a target dependent file that contains the
3724 list of interrupts recognized for a given target.  The documentation in
3725 this file also specifies what interrupts are affected by the use of
3726 the @code{Unreserve_All_Interrupts} pragma.
3727
3728 For a more general facility for controlling what interrupts can be
3729 handled, see pragma @code{Interrupt_State}, which subsumes the functionality
3730 of the @code{Unreserve_All_Interrupts} pragma.
3731
3732 @node Pragma Unsuppress
3733 @unnumberedsec Pragma Unsuppress
3734 @findex Unsuppress
3735 @noindent
3736 Syntax:
3737
3738 @smallexample @c ada
3739 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
3740 @end smallexample
3741
3742 @noindent
3743 This pragma undoes the effect of a previous pragma @code{Suppress}.  If
3744 there is no corresponding pragma @code{Suppress} in effect, it has no
3745 effect.  The range of the effect is the same as for pragma
3746 @code{Suppress}.  The meaning of the arguments is identical to that used
3747 in pragma @code{Suppress}.
3748
3749 One important application is to ensure that checks are on in cases where
3750 code depends on the checks for its correct functioning, so that the code
3751 will compile correctly even if the compiler switches are set to suppress
3752 checks.
3753
3754 @node Pragma Use_VADS_Size
3755 @unnumberedsec Pragma Use_VADS_Size
3756 @cindex @code{Size}, VADS compatibility
3757 @findex Use_VADS_Size
3758 @noindent
3759 Syntax:
3760
3761 @smallexample @c ada
3762 pragma Use_VADS_Size;
3763 @end smallexample
3764
3765 @noindent
3766 This is a configuration pragma.  In a unit to which it applies, any use
3767 of the 'Size attribute is automatically interpreted as a use of the
3768 'VADS_Size attribute.  Note that this may result in incorrect semantic
3769 processing of valid Ada 95 programs.  This is intended to aid in the
3770 handling of legacy code which depends on the interpretation of Size
3771 as implemented in the VADS compiler.  See description of the VADS_Size
3772 attribute for further details.
3773
3774 @node Pragma Validity_Checks
3775 @unnumberedsec Pragma Validity_Checks
3776 @findex Validity_Checks
3777 @noindent
3778 Syntax:
3779
3780 @smallexample @c ada
3781 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
3782 @end smallexample
3783
3784 @noindent
3785 This pragma is used in conjunction with compiler switches to control the
3786 built-in validity checking provided by GNAT@.  The compiler switches, if set
3787 provide an initial setting for the switches, and this pragma may be used
3788 to modify these settings, or the settings may be provided entirely by
3789 the use of the pragma.  This pragma can be used anywhere that a pragma
3790 is legal, including use as a configuration pragma (including use in
3791 the @file{gnat.adc} file).
3792
3793 The form with a string literal specifies which validity options are to be
3794 activated.  The validity checks are first set to include only the default
3795 reference manual settings, and then a string of letters in the string
3796 specifies the exact set of options required.  The form of this string
3797 is exactly as described for the @code{-gnatVx} compiler switch (see the
3798 GNAT users guide for details).  For example the following two methods
3799 can be used to enable validity checking for mode @code{in} and
3800 @code{in out} subprogram parameters:
3801
3802 @itemize @bullet
3803 @item
3804 @smallexample @c ada
3805 pragma Validity_Checks ("im");
3806 @end smallexample
3807
3808 @item
3809 @smallexample
3810 gcc -c -gnatVim @dots{}
3811 @end smallexample
3812 @end itemize
3813
3814 @noindent
3815 The form ALL_CHECKS activates all standard checks (its use is equivalent
3816 to the use of the @code{gnatva} switch.
3817
3818 The forms with @code{Off} and @code{On}
3819 can be used to temporarily disable validity checks
3820 as shown in the following example:
3821
3822 @smallexample @c ada
3823 @iftex
3824 @leftskip=0cm
3825 @end iftex
3826 pragma Validity_Checks ("c"); -- validity checks for copies
3827 pragma Validity_Checks (Off); -- turn off validity checks
3828 A := B;                       -- B will not be validity checked
3829 pragma Validity_Checks (On);  -- turn validity checks back on
3830 A := C;                       -- C will be validity checked
3831 @end smallexample
3832
3833 @node Pragma Volatile
3834 @unnumberedsec Pragma Volatile
3835 @findex Volatile
3836 @noindent
3837 Syntax:
3838
3839 @smallexample @c ada
3840 pragma Volatile (local_NAME);
3841 @end smallexample
3842
3843 @noindent
3844 This pragma is defined by the Ada 95 Reference Manual, and the GNAT
3845 implementation is fully conformant with this definition.  The reason it
3846 is mentioned in this section is that a pragma of the same name was supplied
3847 in some Ada 83 compilers, including DEC Ada 83.  The Ada 95 implementation
3848 of pragma Volatile is upwards compatible with the implementation in
3849 Dec Ada 83.
3850
3851 @node Pragma Warnings
3852 @unnumberedsec Pragma Warnings
3853 @findex Warnings
3854 @noindent
3855 Syntax:
3856
3857 @smallexample @c ada
3858 pragma Warnings (On | Off [, LOCAL_NAME]);
3859 @end smallexample
3860
3861 @noindent
3862 Normally warnings are enabled, with the output being controlled by
3863 the command line switch.  Warnings (@code{Off}) turns off generation of
3864 warnings until a Warnings (@code{On}) is encountered or the end of the
3865 current unit.  If generation of warnings is turned off using this
3866 pragma, then no warning messages are output, regardless of the
3867 setting of the command line switches.
3868
3869 The form with a single argument is a configuration pragma.
3870
3871 If the @var{local_name} parameter is present, warnings are suppressed for
3872 the specified entity.  This suppression is effective from the point where
3873 it occurs till the end of the extended scope of the variable (similar to
3874 the scope of @code{Suppress}).
3875
3876 @node Pragma Weak_External
3877 @unnumberedsec Pragma Weak_External
3878 @findex Weak_External
3879 @noindent
3880 Syntax:
3881
3882 @smallexample @c ada
3883 pragma Weak_External ([Entity =>] LOCAL_NAME);
3884 @end smallexample
3885
3886 @noindent
3887 This pragma specifies that the given entity should be marked as a weak
3888 external (one that does not have to be resolved) for the linker.  For
3889 further details, consult the GCC manual.
3890
3891 @node Implementation Defined Attributes
3892 @chapter Implementation Defined Attributes
3893 Ada 95 defines (throughout the Ada 95 reference manual,
3894 summarized in annex K),
3895 a set of attributes that provide useful additional functionality in all
3896 areas of the language.  These language defined attributes are implemented
3897 in GNAT and work as described in the Ada 95 Reference Manual.
3898
3899 In addition, Ada 95 allows implementations to define additional
3900 attributes whose meaning is defined by the implementation.  GNAT provides
3901 a number of these implementation-dependent attributes which can be used
3902 to extend and enhance the functionality of the compiler.  This section of
3903 the GNAT reference manual describes these additional attributes.
3904
3905 Note that any program using these attributes may not be portable to
3906 other compilers (although GNAT implements this set of attributes on all
3907 platforms).  Therefore if portability to other compilers is an important
3908 consideration, you should minimize the use of these attributes.
3909
3910 @menu
3911 * Abort_Signal::
3912 * Address_Size::
3913 * Asm_Input::
3914 * Asm_Output::
3915 * AST_Entry::
3916 * Bit::
3917 * Bit_Position::
3918 * Code_Address::
3919 * Default_Bit_Order::
3920 * Elaborated::
3921 * Elab_Body::
3922 * Elab_Spec::
3923 * Emax::
3924 * Enum_Rep::
3925 * Epsilon::
3926 * Fixed_Value::
3927 * Has_Discriminants::
3928 * Img::
3929 * Integer_Value::
3930 * Large::
3931 * Machine_Size::
3932 * Mantissa::
3933 * Max_Interrupt_Priority::
3934 * Max_Priority::
3935 * Maximum_Alignment::
3936 * Mechanism_Code::
3937 * Null_Parameter::
3938 * Object_Size::
3939 * Passed_By_Reference::
3940 * Range_Length::
3941 * Safe_Emax::
3942 * Safe_Large::
3943 * Small::
3944 * Storage_Unit::
3945 * Target_Name::
3946 * Tick::
3947 * To_Address::
3948 * Type_Class::
3949 * UET_Address::
3950 * Unconstrained_Array::
3951 * Universal_Literal_String::
3952 * Unrestricted_Access::
3953 * VADS_Size::
3954 * Value_Size::
3955 * Wchar_T_Size::
3956 * Word_Size::
3957 @end menu
3958
3959 @node Abort_Signal
3960 @unnumberedsec Abort_Signal
3961 @findex Abort_Signal
3962 @noindent
3963 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
3964 prefix) provides the entity for the special exception used to signal
3965 task abort or asynchronous transfer of control.  Normally this attribute
3966 should only be used in the tasking runtime (it is highly peculiar, and
3967 completely outside the normal semantics of Ada, for a user program to
3968 intercept the abort exception).
3969
3970 @node Address_Size
3971 @unnumberedsec Address_Size
3972 @cindex Size of @code{Address}
3973 @findex Address_Size
3974 @noindent
3975 @code{Standard'Address_Size} (@code{Standard} is the only allowed
3976 prefix) is a static constant giving the number of bits in an
3977 @code{Address}. It is the same value as System.Address'Size,
3978 but has the advantage of being static, while a direct
3979 reference to System.Address'Size is non-static because Address
3980 is a private type.
3981
3982 @node Asm_Input
3983 @unnumberedsec Asm_Input
3984 @findex Asm_Input
3985 @noindent
3986 The @code{Asm_Input} attribute denotes a function that takes two
3987 parameters.  The first is a string, the second is an expression of the
3988 type designated by the prefix.  The first (string) argument is required
3989 to be a static expression, and is the constraint for the parameter,
3990 (e.g.@: what kind of register is required).  The second argument is the
3991 value to be used as the input argument.  The possible values for the
3992 constant are the same as those used in the RTL, and are dependent on
3993 the configuration file used to built the GCC back end.
3994 @ref{Machine Code Insertions}
3995
3996 @node Asm_Output
3997 @unnumberedsec Asm_Output
3998 @findex Asm_Output
3999 @noindent
4000 The @code{Asm_Output} attribute denotes a function that takes two
4001 parameters.  The first is a string, the second is the name of a variable
4002 of the type designated by the attribute prefix.  The first (string)
4003 argument is required to be a static expression and designates the
4004 constraint for the parameter (e.g.@: what kind of register is
4005 required).  The second argument is the variable to be updated with the
4006 result.  The possible values for constraint are the same as those used in
4007 the RTL, and are dependent on the configuration file used to build the
4008 GCC back end.  If there are no output operands, then this argument may
4009 either be omitted, or explicitly given as @code{No_Output_Operands}.
4010 @ref{Machine Code Insertions}
4011
4012 @node AST_Entry
4013 @unnumberedsec AST_Entry
4014 @cindex OpenVMS
4015 @findex AST_Entry
4016 @noindent
4017 This attribute is implemented only in OpenVMS versions of GNAT@.  Applied to
4018 the name of an entry, it yields a value of the predefined type AST_Handler
4019 (declared in the predefined package System, as extended by the use of
4020 pragma @code{Extend_System (Aux_DEC)}).  This value enables the given entry to
4021 be called when an AST occurs.  For further details, refer to the @cite{DEC Ada
4022 Language Reference Manual}, section 9.12a.
4023
4024 @node Bit
4025 @unnumberedsec Bit
4026 @findex Bit
4027 @code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
4028 offset within the storage unit (byte) that contains the first bit of
4029 storage allocated for the object.  The value of this attribute is of the
4030 type @code{Universal_Integer}, and is always a non-negative number not
4031 exceeding the value of @code{System.Storage_Unit}.
4032
4033 For an object that is a variable or a constant allocated in a register,
4034 the value is zero.  (The use of this attribute does not force the
4035 allocation of a variable to memory).
4036
4037 For an object that is a formal parameter, this attribute applies
4038 to either the matching actual parameter or to a copy of the
4039 matching actual parameter.
4040
4041 For an access object the value is zero.  Note that
4042 @code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
4043 designated object.  Similarly for a record component
4044 @code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
4045 @code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
4046 are subject to index checks.
4047
4048 This attribute is designed to be compatible with the DEC Ada 83 definition
4049 and implementation of the @code{Bit} attribute.
4050
4051 @node Bit_Position
4052 @unnumberedsec Bit_Position
4053 @findex Bit_Position
4054 @noindent
4055 @code{@var{R.C}'Bit}, where @var{R} is a record object and C is one
4056 of the fields of the record type, yields the bit
4057 offset within the record contains the first bit of
4058 storage allocated for the object.  The value of this attribute is of the
4059 type @code{Universal_Integer}.  The value depends only on the field
4060 @var{C} and is independent of the alignment of
4061 the containing record @var{R}.
4062
4063 @node Code_Address
4064 @unnumberedsec Code_Address
4065 @findex Code_Address
4066 @cindex Subprogram address
4067 @cindex Address of subprogram code
4068 @noindent
4069 The @code{'Address}
4070 attribute may be applied to subprograms in Ada 95, but the
4071 intended effect from the Ada 95 reference manual seems to be to provide
4072 an address value which can be used to call the subprogram by means of
4073 an address clause as in the following example:
4074
4075 @smallexample @c ada
4076 procedure K is @dots{}
4077
4078 procedure L;
4079 for L'Address use K'Address;
4080 pragma Import (Ada, L);
4081 @end smallexample
4082
4083 @noindent
4084 A call to @code{L} is then expected to result in a call to @code{K}@.
4085 In Ada 83, where there were no access-to-subprogram values, this was
4086 a common work around for getting the effect of an indirect call.
4087 GNAT implements the above use of @code{Address} and the technique
4088 illustrated by the example code works correctly.
4089
4090 However, for some purposes, it is useful to have the address of the start
4091 of the generated code for the subprogram.  On some architectures, this is
4092 not necessarily the same as the @code{Address} value described above.
4093 For example, the @code{Address} value may reference a subprogram
4094 descriptor rather than the subprogram itself.
4095
4096 The @code{'Code_Address} attribute, which can only be applied to
4097 subprogram entities, always returns the address of the start of the
4098 generated code of the specified subprogram, which may or may not be
4099 the same value as is returned by the corresponding @code{'Address}
4100 attribute.
4101
4102 @node Default_Bit_Order
4103 @unnumberedsec Default_Bit_Order
4104 @cindex Big endian
4105 @cindex Little endian
4106 @findex Default_Bit_Order
4107 @noindent
4108 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
4109 permissible prefix), provides the value @code{System.Default_Bit_Order}
4110 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
4111 @code{Low_Order_First}).  This is used to construct the definition of
4112 @code{Default_Bit_Order} in package @code{System}.
4113
4114 @node Elaborated
4115 @unnumberedsec Elaborated
4116 @findex Elaborated
4117 @noindent
4118 The prefix of the @code{'Elaborated} attribute must be a unit name.  The
4119 value is a Boolean which indicates whether or not the given unit has been
4120 elaborated.  This attribute is primarily intended for internal use by the
4121 generated code for dynamic elaboration checking, but it can also be used
4122 in user programs.  The value will always be True once elaboration of all
4123 units has been completed.  An exception is for units which need no
4124 elaboration, the value is always False for such units.
4125
4126 @node Elab_Body
4127 @unnumberedsec Elab_Body
4128 @findex Elab_Body
4129 @noindent
4130 This attribute can only be applied to a program unit name.  It returns
4131 the entity for the corresponding elaboration procedure for elaborating
4132 the body of the referenced unit.  This is used in the main generated
4133 elaboration procedure by the binder and is not normally used in any
4134 other context.  However, there may be specialized situations in which it
4135 is useful to be able to call this elaboration procedure from Ada code,
4136 e.g.@: if it is necessary to do selective re-elaboration to fix some
4137 error.
4138
4139 @node Elab_Spec
4140 @unnumberedsec Elab_Spec
4141 @findex Elab_Spec
4142 @noindent
4143 This attribute can only be applied to a program unit name.  It returns
4144 the entity for the corresponding elaboration procedure for elaborating
4145 the specification of the referenced unit.  This is used in the main
4146 generated elaboration procedure by the binder and is not normally used
4147 in any other context.  However, there may be specialized situations in
4148 which it is useful to be able to call this elaboration procedure from
4149 Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
4150 some error.
4151
4152 @node Emax
4153 @unnumberedsec Emax
4154 @cindex Ada 83 attributes
4155 @findex Emax
4156 @noindent
4157 The @code{Emax} attribute is provided for compatibility with Ada 83.  See
4158 the Ada 83 reference manual for an exact description of the semantics of
4159 this attribute.
4160
4161 @node Enum_Rep
4162 @unnumberedsec Enum_Rep
4163 @cindex Representation of enums
4164 @findex Enum_Rep
4165 @noindent
4166 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
4167 function with the following spec:
4168
4169 @smallexample @c ada
4170 function @var{S}'Enum_Rep (Arg : @var{S}'Base)
4171   return @i{Universal_Integer};
4172 @end smallexample
4173
4174 @noindent
4175 It is also allowable to apply @code{Enum_Rep} directly to an object of an
4176 enumeration type or to a non-overloaded enumeration
4177 literal.  In this case @code{@var{S}'Enum_Rep} is equivalent to
4178 @code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
4179 enumeration literal or object.
4180
4181 The function returns the representation value for the given enumeration
4182 value.  This will be equal to value of the @code{Pos} attribute in the
4183 absence of an enumeration representation clause.  This is a static
4184 attribute (i.e.@: the result is static if the argument is static).
4185
4186 @code{@var{S}'Enum_Rep} can also be used with integer types and objects,
4187 in which case it simply returns the integer value.  The reason for this
4188 is to allow it to be used for @code{(<>)} discrete formal arguments in
4189 a generic unit that can be instantiated with either enumeration types
4190 or integer types.  Note that if @code{Enum_Rep} is used on a modular
4191 type whose upper bound exceeds the upper bound of the largest signed
4192 integer type, and the argument is a variable, so that the universal
4193 integer calculation is done at run-time, then the call to @code{Enum_Rep}
4194 may raise @code{Constraint_Error}.
4195
4196 @node Epsilon
4197 @unnumberedsec Epsilon
4198 @cindex Ada 83 attributes
4199 @findex Epsilon
4200 @noindent
4201 The @code{Epsilon} attribute is provided for compatibility with Ada 83.  See
4202 the Ada 83 reference manual for an exact description of the semantics of
4203 this attribute.
4204
4205 @node Fixed_Value
4206 @unnumberedsec Fixed_Value
4207 @findex Fixed_Value
4208 @noindent
4209 For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
4210 function with the following specification:
4211
4212 @smallexample @c ada
4213 function @var{S}'Fixed_Value (Arg : @i{Universal_Integer})
4214   return @var{S};
4215 @end smallexample
4216
4217 @noindent
4218 The value returned is the fixed-point value @var{V} such that
4219
4220 @smallexample @c ada
4221 @var{V} = Arg * @var{S}'Small
4222 @end smallexample
4223
4224 @noindent
4225 The effect is thus similar to first converting the argument to the
4226 integer type used to represent @var{S}, and then doing an unchecked
4227 conversion to the fixed-point type.  The difference is
4228 that there are full range checks, to ensure that the result is in range.
4229 This attribute is primarily intended for use in implementation of the
4230 input-output functions for fixed-point values.
4231
4232 @node Has_Discriminants
4233 @unnumberedsec Has_Discriminants
4234 @cindex Discriminants, testing for
4235 @findex Has_Discriminants
4236 @noindent
4237 The prefix of the @code{Has_Discriminants} attribute is a type.  The result
4238 is a Boolean value which is True if the type has discriminants, and False
4239 otherwise.  The intended use of this attribute is in conjunction with generic
4240 definitions.  If the attribute is applied to a generic private type, it
4241 indicates whether or not the corresponding actual type has discriminants.
4242
4243 @node Img
4244 @unnumberedsec Img
4245 @findex Img
4246 @noindent
4247 The @code{Img} attribute differs from @code{Image} in that it may be
4248 applied to objects as well as types, in which case it gives the
4249 @code{Image} for the subtype of the object.  This is convenient for
4250 debugging:
4251
4252 @smallexample @c ada
4253 Put_Line ("X = " & X'Img);
4254 @end smallexample
4255
4256 @noindent
4257 has the same meaning as the more verbose:
4258
4259 @smallexample @c ada
4260 Put_Line ("X = " & @var{T}'Image (X));
4261 @end smallexample
4262
4263 @noindent
4264 where @var{T} is the (sub)type of the object @code{X}.
4265
4266 @node Integer_Value
4267 @unnumberedsec Integer_Value
4268 @findex Integer_Value
4269 @noindent
4270 For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
4271 function with the following spec:
4272
4273 @smallexample @c ada
4274 function @var{S}'Integer_Value (Arg : @i{Universal_Fixed})
4275   return @var{S};
4276 @end smallexample
4277
4278 @noindent
4279 The value returned is the integer value @var{V}, such that
4280
4281 @smallexample @c ada
4282 Arg = @var{V} * @var{T}'Small
4283 @end smallexample
4284
4285 @noindent
4286 where @var{T} is the type of @code{Arg}.
4287 The effect is thus similar to first doing an unchecked conversion from
4288 the fixed-point type to its corresponding implementation type, and then
4289 converting the result to the target integer type.  The difference is
4290 that there are full range checks, to ensure that the result is in range.
4291 This attribute is primarily intended for use in implementation of the
4292 standard input-output functions for fixed-point values.
4293
4294 @node Large
4295 @unnumberedsec Large
4296 @cindex Ada 83 attributes
4297 @findex Large
4298 @noindent
4299 The @code{Large} attribute is provided for compatibility with Ada 83.  See
4300 the Ada 83 reference manual for an exact description of the semantics of
4301 this attribute.
4302
4303 @node Machine_Size
4304 @unnumberedsec Machine_Size
4305 @findex Machine_Size
4306 @noindent
4307 This attribute is identical to the @code{Object_Size} attribute.  It is
4308 provided for compatibility with the DEC Ada 83 attribute of this name.
4309
4310 @node Mantissa
4311 @unnumberedsec Mantissa
4312 @cindex Ada 83 attributes
4313 @findex Mantissa
4314 @noindent
4315 The @code{Mantissa} attribute is provided for compatibility with Ada 83.  See
4316 the Ada 83 reference manual for an exact description of the semantics of
4317 this attribute.
4318
4319 @node Max_Interrupt_Priority
4320 @unnumberedsec Max_Interrupt_Priority
4321 @cindex Interrupt priority, maximum
4322 @findex Max_Interrupt_Priority
4323 @noindent
4324 @code{Standard'Max_Interrupt_Priority} (@code{Standard} is the only
4325 permissible prefix), provides the same value as
4326 @code{System.Max_Interrupt_Priority}.
4327
4328 @node Max_Priority
4329 @unnumberedsec Max_Priority
4330 @cindex Priority, maximum
4331 @findex Max_Priority
4332 @noindent
4333 @code{Standard'Max_Priority} (@code{Standard} is the only permissible
4334 prefix) provides the same value as @code{System.Max_Priority}.
4335
4336 @node Maximum_Alignment
4337 @unnumberedsec Maximum_Alignment
4338 @cindex Alignment, maximum
4339 @findex Maximum_Alignment
4340 @noindent
4341 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
4342 permissible prefix) provides the maximum useful alignment value for the
4343 target.  This is a static value that can be used to specify the alignment
4344 for an object, guaranteeing that it is properly aligned in all
4345 cases.
4346
4347 @node Mechanism_Code
4348 @unnumberedsec Mechanism_Code
4349 @cindex Return values, passing mechanism
4350 @cindex Parameters, passing mechanism
4351 @findex Mechanism_Code
4352 @noindent
4353 @code{@var{function}'Mechanism_Code} yields an integer code for the
4354 mechanism used for the result of function, and
4355 @code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
4356 used for formal parameter number @var{n} (a static integer value with 1
4357 meaning the first parameter) of @var{subprogram}.  The code returned is:
4358
4359 @table @asis
4360 @item 1
4361 by copy (value)
4362 @item 2
4363 by reference
4364 @item 3
4365 by descriptor (default descriptor class)
4366 @item 4
4367 by descriptor (UBS: unaligned bit string)
4368 @item 5
4369 by descriptor (UBSB: aligned bit string with arbitrary bounds)
4370 @item 6
4371 by descriptor (UBA: unaligned bit array)
4372 @item 7
4373 by descriptor (S: string, also scalar access type parameter)
4374 @item 8
4375 by descriptor (SB: string with arbitrary bounds)
4376 @item 9
4377 by descriptor (A: contiguous array)
4378 @item 10
4379 by descriptor (NCA: non-contiguous array)
4380 @end table
4381
4382 @noindent
4383 Values from 3 through 10 are only relevant to Digital OpenVMS implementations.
4384 @cindex OpenVMS
4385
4386 @node Null_Parameter
4387 @unnumberedsec Null_Parameter
4388 @cindex Zero address, passing
4389 @findex Null_Parameter
4390 @noindent
4391 A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
4392 type or subtype @var{T} allocated at machine address zero.  The attribute
4393 is allowed only as the default expression of a formal parameter, or as
4394 an actual expression of a subprogram call.  In either case, the
4395 subprogram must be imported.
4396
4397 The identity of the object is represented by the address zero in the
4398 argument list, independent of the passing mechanism (explicit or
4399 default).
4400
4401 This capability is needed to specify that a zero address should be
4402 passed for a record or other composite object passed by reference.
4403 There is no way of indicating this without the @code{Null_Parameter}
4404 attribute.
4405
4406 @node Object_Size
4407 @unnumberedsec Object_Size
4408 @cindex Size, used for objects
4409 @findex Object_Size
4410 @noindent
4411 The size of an object is not necessarily the same as the size of the type
4412 of an object.  This is because by default object sizes are increased to be
4413 a multiple of the alignment of the object.  For example,
4414 @code{Natural'Size} is
4415 31, but by default objects of type @code{Natural} will have a size of 32 bits.
4416 Similarly, a record containing an integer and a character:
4417
4418 @smallexample @c ada
4419 type Rec is record
4420    I : Integer;
4421    C : Character;
4422 end record;
4423 @end smallexample
4424
4425 @noindent
4426 will have a size of 40 (that is @code{Rec'Size} will be 40.  The
4427 alignment will be 4, because of the
4428 integer field, and so the default size of record objects for this type
4429 will be 64 (8 bytes).
4430
4431 The @code{@var{type}'Object_Size} attribute
4432 has been added to GNAT to allow the
4433 default object size of a type to be easily determined.  For example,
4434 @code{Natural'Object_Size} is 32, and
4435 @code{Rec'Object_Size} (for the record type in the above example) will be
4436 64.  Note also that, unlike the situation with the
4437 @code{Size} attribute as defined in the Ada RM, the
4438 @code{Object_Size} attribute can be specified individually
4439 for different subtypes.  For example:
4440
4441 @smallexample @c ada
4442 type R is new Integer;
4443 subtype R1 is R range 1 .. 10;
4444 subtype R2 is R range 1 .. 10;
4445 for R2'Object_Size use 8;
4446 @end smallexample
4447
4448 @noindent
4449 In this example, @code{R'Object_Size} and @code{R1'Object_Size} are both
4450 32 since the default object size for a subtype is the same as the object size
4451 for the parent subtype.  This means that objects of type @code{R}
4452 or @code{R1} will
4453 by default be 32 bits (four bytes).  But objects of type
4454 @code{R2} will be only
4455 8 bits (one byte), since @code{R2'Object_Size} has been set to 8.
4456
4457 @node Passed_By_Reference
4458 @unnumberedsec Passed_By_Reference
4459 @cindex Parameters, when passed by reference
4460 @findex Passed_By_Reference
4461 @noindent
4462 @code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
4463 a value of type @code{Boolean} value that is @code{True} if the type is
4464 normally passed by reference and @code{False} if the type is normally
4465 passed by copy in calls.  For scalar types, the result is always @code{False}
4466 and is static.  For non-scalar types, the result is non-static.
4467
4468 @node Range_Length
4469 @unnumberedsec Range_Length
4470 @findex Range_Length
4471 @noindent
4472 @code{@var{type}'Range_Length} for any discrete type @var{type} yields
4473 the number of values represented by the subtype (zero for a null
4474 range).  The result is static for static subtypes.  @code{Range_Length}
4475 applied to the index subtype of a one dimensional array always gives the
4476 same result as @code{Range} applied to the array itself.
4477
4478 @node Safe_Emax
4479 @unnumberedsec Safe_Emax
4480 @cindex Ada 83 attributes
4481 @findex Safe_Emax
4482 @noindent
4483 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83.  See
4484 the Ada 83 reference manual for an exact description of the semantics of
4485 this attribute.
4486
4487 @node Safe_Large
4488 @unnumberedsec Safe_Large
4489 @cindex Ada 83 attributes
4490 @findex Safe_Large
4491 @noindent
4492 The @code{Safe_Large} attribute is provided for compatibility with Ada 83.  See
4493 the Ada 83 reference manual for an exact description of the semantics of
4494 this attribute.
4495
4496 @node Small
4497 @unnumberedsec Small
4498 @cindex Ada 83 attributes
4499 @findex Small
4500 @noindent
4501 The @code{Small} attribute is defined in Ada 95 only for fixed-point types.
4502 GNAT also allows this attribute to be applied to floating-point types
4503 for compatibility with Ada 83.  See
4504 the Ada 83 reference manual for an exact description of the semantics of
4505 this attribute when applied to floating-point types.
4506
4507 @node Storage_Unit
4508 @unnumberedsec Storage_Unit
4509 @findex Storage_Unit
4510 @noindent
4511 @code{Standard'Storage_Unit} (@code{Standard} is the only permissible
4512 prefix) provides the same value as @code{System.Storage_Unit}.
4513
4514 @node Target_Name
4515 @unnumberedsec Target_Name
4516 @findex Target_Name
4517 @noindent
4518 @code{Standard'Target_Name} (@code{Standard} is the only permissible
4519 prefix) provides a static string value that identifies the target
4520 for the current compilation. For GCC implementations, this is the
4521 standard gcc target name without the terminating slash (for
4522 example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
4523
4524 @node Tick
4525 @unnumberedsec Tick
4526 @findex Tick
4527 @noindent
4528 @code{Standard'Tick} (@code{Standard} is the only permissible prefix)
4529 provides the same value as @code{System.Tick},
4530
4531 @node To_Address
4532 @unnumberedsec To_Address
4533 @findex To_Address
4534 @noindent
4535 The @code{System'To_Address}
4536 (@code{System} is the only permissible prefix)
4537 denotes a function identical to
4538 @code{System.Storage_Elements.To_Address} except that
4539 it is a static attribute.  This means that if its argument is
4540 a static expression, then the result of the attribute is a
4541 static expression.  The result is that such an expression can be
4542 used in contexts (e.g.@: preelaborable packages) which require a
4543 static expression and where the function call could not be used
4544 (since the function call is always non-static, even if its
4545 argument is static).
4546
4547 @node Type_Class
4548 @unnumberedsec Type_Class
4549 @findex Type_Class
4550 @noindent
4551 @code{@var{type}'Type_Class} for any type or subtype @var{type} yields
4552 the value of the type class for the full type of @var{type}.  If
4553 @var{type} is a generic formal type, the value is the value for the
4554 corresponding actual subtype.  The value of this attribute is of type
4555 @code{System.Aux_DEC.Type_Class}, which has the following definition:
4556
4557 @smallexample @c ada
4558   type Type_Class is
4559     (Type_Class_Enumeration,
4560      Type_Class_Integer,
4561      Type_Class_Fixed_Point,
4562      Type_Class_Floating_Point,
4563      Type_Class_Array,
4564      Type_Class_Record,
4565      Type_Class_Access,
4566      Type_Class_Task,
4567      Type_Class_Address);
4568 @end smallexample
4569
4570 @noindent
4571 Protected types yield the value @code{Type_Class_Task}, which thus
4572 applies to all concurrent types.  This attribute is designed to
4573 be compatible with the DEC Ada 83 attribute of the same name.
4574
4575 @node UET_Address
4576 @unnumberedsec UET_Address
4577 @findex UET_Address
4578 @noindent
4579 The @code{UET_Address} attribute can only be used for a prefix which
4580 denotes a library package.  It yields the address of the unit exception
4581 table when zero cost exception handling is used.  This attribute is
4582 intended only for use within the GNAT implementation.  See the unit
4583 @code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb}
4584 for details on how this attribute is used in the implementation.
4585
4586 @node Unconstrained_Array
4587 @unnumberedsec Unconstrained_Array
4588 @findex Unconstrained_Array
4589 @noindent
4590 The @code{Unconstrained_Array} attribute can be used with a prefix that
4591 denotes any type or subtype. It is a static attribute that yields
4592 @code{True} if the prefix designates an unconstrained array,
4593 and @code{False} otherwise. In a generic instance, the result is
4594 still static, and yields the result of applying this test to the
4595 generic actual.
4596
4597 @node Universal_Literal_String
4598 @unnumberedsec Universal_Literal_String
4599 @cindex Named numbers, representation of
4600 @findex Universal_Literal_String
4601 @noindent
4602 The prefix of @code{Universal_Literal_String} must be a named
4603 number.  The static result is the string consisting of the characters of
4604 the number as defined in the original source.  This allows the user
4605 program to access the actual text of named numbers without intermediate
4606 conversions and without the need to enclose the strings in quotes (which
4607 would preclude their use as numbers).  This is used internally for the
4608 construction of values of the floating-point attributes from the file
4609 @file{ttypef.ads}, but may also be used by user programs.
4610
4611 @node Unrestricted_Access
4612 @unnumberedsec Unrestricted_Access
4613 @cindex @code{Access}, unrestricted
4614 @findex Unrestricted_Access
4615 @noindent
4616 The @code{Unrestricted_Access} attribute is similar to @code{Access}
4617 except that all accessibility and aliased view checks are omitted.  This
4618 is a user-beware attribute.  It is similar to
4619 @code{Address}, for which it is a desirable replacement where the value
4620 desired is an access type.  In other words, its effect is identical to
4621 first applying the @code{Address} attribute and then doing an unchecked
4622 conversion to a desired access type.  In GNAT, but not necessarily in
4623 other implementations, the use of static chains for inner level
4624 subprograms means that @code{Unrestricted_Access} applied to a
4625 subprogram yields a value that can be called as long as the subprogram
4626 is in scope (normal Ada 95 accessibility rules restrict this usage).
4627
4628 It is possible to use @code{Unrestricted_Access} for any type, but care
4629 must be excercised if it is used to create pointers to unconstrained
4630 objects. In this case, the resulting pointer has the same scope as the
4631 context of the attribute, and may not be returned to some enclosing
4632 scope. For instance, a function cannot use @code{Unrestricted_Access}
4633 to create a unconstrained pointer and then return that value to the
4634 caller.
4635
4636 @node VADS_Size
4637 @unnumberedsec VADS_Size
4638 @cindex @code{Size}, VADS compatibility
4639 @findex VADS_Size
4640 @noindent
4641 The @code{'VADS_Size} attribute is intended to make it easier to port
4642 legacy code which relies on the semantics of @code{'Size} as implemented
4643 by the VADS Ada 83 compiler.  GNAT makes a best effort at duplicating the
4644 same semantic interpretation.  In particular, @code{'VADS_Size} applied
4645 to a predefined or other primitive type with no Size clause yields the
4646 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
4647 typical machines).  In addition @code{'VADS_Size} applied to an object
4648 gives the result that would be obtained by applying the attribute to
4649 the corresponding type.
4650
4651 @node Value_Size
4652 @unnumberedsec Value_Size
4653 @cindex @code{Size}, setting for not-first subtype
4654 @findex Value_Size
4655 @code{@var{type}'Value_Size} is the number of bits required to represent
4656 a value of the given subtype.  It is the same as @code{@var{type}'Size},
4657 but, unlike @code{Size}, may be set for non-first subtypes.
4658
4659 @node Wchar_T_Size
4660 @unnumberedsec Wchar_T_Size
4661 @findex Wchar_T_Size
4662 @code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
4663 prefix) provides the size in bits of the C @code{wchar_t} type
4664 primarily for constructing the definition of this type in
4665 package @code{Interfaces.C}.
4666
4667 @node Word_Size
4668 @unnumberedsec Word_Size
4669 @findex Word_Size
4670 @code{Standard'Word_Size} (@code{Standard} is the only permissible
4671 prefix) provides the value @code{System.Word_Size}.
4672
4673 @c ------------------------
4674 @node Implementation Advice
4675 @chapter Implementation Advice
4676 @noindent
4677 The main text of the Ada 95 Reference Manual describes the required
4678 behavior of all Ada 95 compilers, and the GNAT compiler conforms to
4679 these requirements.
4680
4681 In addition, there are sections throughout the Ada 95
4682 reference manual headed
4683 by the phrase ``implementation advice''.  These sections are not normative,
4684 i.e.@: they do not specify requirements that all compilers must
4685 follow.  Rather they provide advice on generally desirable behavior.  You
4686 may wonder why they are not requirements.  The most typical answer is
4687 that they describe behavior that seems generally desirable, but cannot
4688 be provided on all systems, or which may be undesirable on some systems.
4689
4690 As far as practical, GNAT follows the implementation advice sections in
4691 the Ada 95 Reference Manual.  This chapter contains a table giving the
4692 reference manual section number, paragraph number and several keywords
4693 for each advice.  Each entry consists of the text of the advice followed
4694 by the GNAT interpretation of this advice.  Most often, this simply says
4695 ``followed'', which means that GNAT follows the advice.  However, in a
4696 number of cases, GNAT deliberately deviates from this advice, in which
4697 case the text describes what GNAT does and why.
4698
4699 @cindex Error detection
4700 @unnumberedsec 1.1.3(20): Error Detection
4701 @sp 1
4702 @cartouche
4703 If an implementation detects the use of an unsupported Specialized Needs
4704 Annex feature at run time, it should raise @code{Program_Error} if
4705 feasible.
4706 @end cartouche
4707 Not relevant.  All specialized needs annex features are either supported,
4708 or diagnosed at compile time.
4709
4710 @cindex Child Units
4711 @unnumberedsec 1.1.3(31): Child Units
4712 @sp 1
4713 @cartouche
4714 If an implementation wishes to provide implementation-defined
4715 extensions to the functionality of a language-defined library unit, it
4716 should normally do so by adding children to the library unit.
4717 @end cartouche
4718 Followed.
4719
4720 @cindex Bounded errors
4721 @unnumberedsec 1.1.5(12): Bounded Errors
4722 @sp 1
4723 @cartouche
4724 If an implementation detects a bounded error or erroneous
4725 execution, it should raise @code{Program_Error}.
4726 @end cartouche
4727 Followed in all cases in which the implementation detects a bounded
4728 error or erroneous execution.  Not all such situations are detected at
4729 runtime.
4730
4731 @cindex Pragmas
4732 @unnumberedsec 2.8(16): Pragmas
4733 @sp 1
4734 @cartouche
4735 Normally, implementation-defined pragmas should have no semantic effect
4736 for error-free programs; that is, if the implementation-defined pragmas
4737 are removed from a working program, the program should still be legal,
4738 and should still have the same semantics.
4739 @end cartouche
4740 The following implementation defined pragmas are exceptions to this
4741 rule:
4742
4743 @table @code
4744 @item Abort_Defer
4745 Affects semantics
4746 @item Ada_83
4747 Affects legality
4748 @item Assert
4749 Affects semantics
4750 @item CPP_Class
4751 Affects semantics
4752 @item CPP_Constructor
4753 Affects semantics
4754 @item CPP_Virtual
4755 Affects semantics
4756 @item CPP_Vtable
4757 Affects semantics
4758 @item Debug
4759 Affects semantics
4760 @item Interface_Name
4761 Affects semantics
4762 @item Machine_Attribute
4763 Affects semantics
4764 @item Unimplemented_Unit
4765 Affects legality
4766 @item Unchecked_Union
4767 Affects semantics
4768 @end table
4769
4770 @noindent
4771 In each of the above cases, it is essential to the purpose of the pragma
4772 that this advice not be followed.  For details see the separate section
4773 on implementation defined pragmas.
4774
4775 @unnumberedsec 2.8(17-19): Pragmas
4776 @sp 1
4777 @cartouche
4778 Normally, an implementation should not define pragmas that can
4779 make an illegal program legal, except as follows:
4780 @end cartouche
4781 @sp 1
4782 @cartouche
4783 A pragma used to complete a declaration, such as a pragma @code{Import};
4784 @end cartouche
4785 @sp 1
4786 @cartouche
4787 A pragma used to configure the environment by adding, removing, or
4788 replacing @code{library_items}.
4789 @end cartouche
4790 See response to paragraph 16 of this same section.
4791
4792 @cindex Character Sets
4793 @cindex Alternative Character Sets
4794 @unnumberedsec 3.5.2(5): Alternative Character Sets
4795 @sp 1
4796 @cartouche
4797 If an implementation supports a mode with alternative interpretations
4798 for @code{Character} and @code{Wide_Character}, the set of graphic
4799 characters of @code{Character} should nevertheless remain a proper
4800 subset of the set of graphic characters of @code{Wide_Character}.  Any
4801 character set ``localizations'' should be reflected in the results of
4802 the subprograms defined in the language-defined package
4803 @code{Characters.Handling} (see A.3) available in such a mode.  In a mode with
4804 an alternative interpretation of @code{Character}, the implementation should
4805 also support a corresponding change in what is a legal
4806 @code{identifier_letter}.
4807 @end cartouche
4808 Not all wide character modes follow this advice, in particular the JIS
4809 and IEC modes reflect standard usage in Japan, and in these encoding,
4810 the upper half of the Latin-1 set is not part of the wide-character
4811 subset, since the most significant bit is used for wide character
4812 encoding.  However, this only applies to the external forms.  Internally
4813 there is no such restriction.
4814
4815 @cindex Integer types
4816 @unnumberedsec 3.5.4(28): Integer Types
4817
4818 @sp 1
4819 @cartouche
4820 An implementation should support @code{Long_Integer} in addition to
4821 @code{Integer} if the target machine supports 32-bit (or longer)
4822 arithmetic.  No other named integer subtypes are recommended for package
4823 @code{Standard}.  Instead, appropriate named integer subtypes should be
4824 provided in the library package @code{Interfaces} (see B.2).
4825 @end cartouche
4826 @code{Long_Integer} is supported.  Other standard integer types are supported
4827 so this advice is not fully followed.  These types
4828 are supported for convenient interface to C, and so that all hardware
4829 types of the machine are easily available.
4830 @unnumberedsec 3.5.4(29): Integer Types
4831
4832 @sp 1
4833 @cartouche
4834 An implementation for a two's complement machine should support
4835 modular types with a binary modulus up to @code{System.Max_Int*2+2}.  An
4836 implementation should support a non-binary modules up to @code{Integer'Last}.
4837 @end cartouche
4838 Followed.
4839
4840 @cindex Enumeration values
4841 @unnumberedsec 3.5.5(8): Enumeration Values
4842 @sp 1
4843 @cartouche
4844 For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
4845 subtype, if the value of the operand does not correspond to the internal
4846 code for any enumeration literal of its type (perhaps due to an
4847 un-initialized variable), then the implementation should raise
4848 @code{Program_Error}.  This is particularly important for enumeration
4849 types with noncontiguous internal codes specified by an
4850 enumeration_representation_clause.
4851 @end cartouche
4852 Followed.
4853
4854 @cindex Float types
4855 @unnumberedsec 3.5.7(17): Float Types
4856 @sp 1
4857 @cartouche
4858 An implementation should support @code{Long_Float} in addition to
4859 @code{Float} if the target machine supports 11 or more digits of
4860 precision.  No other named floating point subtypes are recommended for
4861 package @code{Standard}.  Instead, appropriate named floating point subtypes
4862 should be provided in the library package @code{Interfaces} (see B.2).
4863 @end cartouche
4864 @code{Short_Float} and @code{Long_Long_Float} are also provided.  The
4865 former provides improved compatibility with other implementations
4866 supporting this type.  The latter corresponds to the highest precision
4867 floating-point type supported by the hardware.  On most machines, this
4868 will be the same as @code{Long_Float}, but on some machines, it will
4869 correspond to the IEEE extended form.  The notable case is all ia32
4870 (x86) implementations, where @code{Long_Long_Float} corresponds to
4871 the 80-bit extended precision format supported in hardware on this
4872 processor.  Note that the 128-bit format on SPARC is not supported,
4873 since this is a software rather than a hardware format.
4874
4875 @cindex Multidimensional arrays
4876 @cindex Arrays, multidimensional
4877 @unnumberedsec 3.6.2(11): Multidimensional Arrays
4878 @sp 1
4879 @cartouche
4880 An implementation should normally represent multidimensional arrays in
4881 row-major order, consistent with the notation used for multidimensional
4882 array aggregates (see 4.3.3).  However, if a pragma @code{Convention}
4883 (@code{Fortran}, @dots{}) applies to a multidimensional array type, then
4884 column-major order should be used instead (see B.5, ``Interfacing with
4885 Fortran'').
4886 @end cartouche
4887 Followed.
4888
4889 @findex Duration'Small
4890 @unnumberedsec 9.6(30-31): Duration'Small
4891 @sp 1
4892 @cartouche
4893 Whenever possible in an implementation, the value of @code{Duration'Small}
4894 should be no greater than 100 microseconds.
4895 @end cartouche
4896 Followed.  (@code{Duration'Small} = 10**(@minus{}9)).
4897
4898 @sp 1
4899 @cartouche
4900 The time base for @code{delay_relative_statements} should be monotonic;
4901 it need not be the same time base as used for @code{Calendar.Clock}.
4902 @end cartouche
4903 Followed.
4904
4905 @unnumberedsec 10.2.1(12): Consistent Representation
4906 @sp 1
4907 @cartouche
4908 In an implementation, a type declared in a pre-elaborated package should
4909 have the same representation in every elaboration of a given version of
4910 the package, whether the elaborations occur in distinct executions of
4911 the same program, or in executions of distinct programs or partitions
4912 that include the given version.
4913 @end cartouche
4914 Followed, except in the case of tagged types.  Tagged types involve
4915 implicit pointers to a local copy of a dispatch table, and these pointers
4916 have representations which thus depend on a particular elaboration of the
4917 package.  It is not easy to see how it would be possible to follow this
4918 advice without severely impacting efficiency of execution.
4919
4920 @cindex Exception information
4921 @unnumberedsec 11.4.1(19): Exception Information
4922 @sp 1
4923 @cartouche
4924 @code{Exception_Message} by default and @code{Exception_Information}
4925 should produce information useful for
4926 debugging.  @code{Exception_Message} should be short, about one
4927 line.  @code{Exception_Information} can be long.  @code{Exception_Message}
4928 should not include the
4929 @code{Exception_Name}.  @code{Exception_Information} should include both
4930 the @code{Exception_Name} and the @code{Exception_Message}.
4931 @end cartouche
4932 Followed.  For each exception that doesn't have a specified
4933 @code{Exception_Message}, the compiler generates one containing the location
4934 of the raise statement.  This location has the form ``file:line'', where
4935 file is the short file name (without path information) and line is the line
4936 number in the file.  Note that in the case of the Zero Cost Exception
4937 mechanism, these messages become redundant with the Exception_Information that
4938 contains a full backtrace of the calling sequence, so they are disabled.
4939 To disable explicitly the generation of the source location message, use the
4940 Pragma @code{Discard_Names}.
4941
4942 @cindex Suppression of checks
4943 @cindex Checks, suppression of
4944 @unnumberedsec 11.5(28): Suppression of Checks
4945 @sp 1
4946 @cartouche
4947 The implementation should minimize the code executed for checks that
4948 have been suppressed.
4949 @end cartouche
4950 Followed.
4951
4952 @cindex Representation clauses
4953 @unnumberedsec 13.1 (21-24): Representation Clauses
4954 @sp 1
4955 @cartouche
4956 The recommended level of support for all representation items is
4957 qualified as follows:
4958 @end cartouche
4959 @sp 1
4960 @cartouche
4961 An implementation need not support representation items containing
4962 non-static expressions, except that an implementation should support a
4963 representation item for a given entity if each non-static expression in
4964 the representation item is a name that statically denotes a constant
4965 declared before the entity.
4966 @end cartouche
4967 Followed.  GNAT does not support non-static expressions in representation
4968 clauses unless they are constants declared before the entity.  For
4969 example:
4970
4971 @smallexample @c ada
4972 X : Some_Type;
4973 for X'Address use To_address (16#2000#);
4974 @end smallexample
4975
4976 @noindent
4977 will be rejected, since the To_Address expression is non-static.  Instead
4978 write:
4979
4980 @smallexample @c ada
4981 X_Address : constant Address : = To_Address (16#2000#);
4982 X         : Some_Type;
4983 for X'Address use X_Address;
4984 @end smallexample
4985
4986 @sp 1
4987 @cartouche
4988 An implementation need not support a specification for the @code{Size}
4989 for a given composite subtype, nor the size or storage place for an
4990 object (including a component) of a given composite subtype, unless the
4991 constraints on the subtype and its composite subcomponents (if any) are
4992 all static constraints.
4993 @end cartouche
4994 Followed.  Size Clauses are not permitted on non-static components, as
4995 described above.
4996
4997 @sp 1
4998 @cartouche
4999 An aliased component, or a component whose type is by-reference, should
5000 always be allocated at an addressable location.
5001 @end cartouche
5002 Followed.
5003
5004 @cindex Packed types
5005 @unnumberedsec 13.2(6-8): Packed Types
5006 @sp 1
5007 @cartouche
5008 If a type is packed, then the implementation should try to minimize
5009 storage allocated to objects of the type, possibly at the expense of
5010 speed of accessing components, subject to reasonable complexity in
5011 addressing calculations.
5012 @end cartouche
5013 @sp 1
5014 @cartouche
5015 The recommended level of support pragma @code{Pack} is:
5016
5017 For a packed record type, the components should be packed as tightly as
5018 possible subject to the Sizes of the component subtypes, and subject to
5019 any @code{record_representation_clause} that applies to the type; the
5020 implementation may, but need not, reorder components or cross aligned
5021 word boundaries to improve the packing.  A component whose @code{Size} is
5022 greater than the word size may be allocated an integral number of words.
5023 @end cartouche
5024 Followed.  Tight packing of arrays is supported for all component sizes
5025 up to 64-bits. If the array component size is 1 (that is to say, if
5026 the component is a boolean type or an enumeration type with two values)
5027 then values of the type are implicitly initialized to zero. This
5028 happens both for objects of the packed type, and for objects that have a
5029 subcomponent of the packed type.
5030
5031 @sp 1
5032 @cartouche
5033 An implementation should support Address clauses for imported
5034 subprograms.
5035 @end cartouche
5036 Followed.
5037 @cindex @code{Address} clauses
5038 @unnumberedsec 13.3(14-19): Address Clauses
5039
5040 @sp 1
5041 @cartouche
5042 For an array @var{X}, @code{@var{X}'Address} should point at the first
5043 component of the array, and not at the array bounds.
5044 @end cartouche
5045 Followed.
5046
5047 @sp 1
5048 @cartouche
5049 The recommended level of support for the @code{Address} attribute is:
5050
5051 @code{@var{X}'Address} should produce a useful result if @var{X} is an
5052 object that is aliased or of a by-reference type, or is an entity whose
5053 @code{Address} has been specified.
5054 @end cartouche
5055 Followed.  A valid address will be produced even if none of those
5056 conditions have been met.  If necessary, the object is forced into
5057 memory to ensure the address is valid.
5058
5059 @sp 1
5060 @cartouche
5061 An implementation should support @code{Address} clauses for imported
5062 subprograms.
5063 @end cartouche
5064 Followed.
5065
5066 @sp 1
5067 @cartouche
5068 Objects (including subcomponents) that are aliased or of a by-reference
5069 type should be allocated on storage element boundaries.
5070 @end cartouche
5071 Followed.
5072
5073 @sp 1
5074 @cartouche
5075 If the @code{Address} of an object is specified, or it is imported or exported,
5076 then the implementation should not perform optimizations based on
5077 assumptions of no aliases.
5078 @end cartouche
5079 Followed.
5080
5081 @cindex @code{Alignment} clauses
5082 @unnumberedsec 13.3(29-35): Alignment Clauses
5083 @sp 1
5084 @cartouche
5085 The recommended level of support for the @code{Alignment} attribute for
5086 subtypes is:
5087
5088 An implementation should support specified Alignments that are factors
5089 and multiples of the number of storage elements per word, subject to the
5090 following:
5091 @end cartouche
5092 Followed.
5093
5094 @sp 1
5095 @cartouche
5096 An implementation need not support specified @code{Alignment}s for
5097 combinations of @code{Size}s and @code{Alignment}s that cannot be easily
5098 loaded and stored by available machine instructions.
5099 @end cartouche
5100 Followed.
5101
5102 @sp 1
5103 @cartouche
5104 An implementation need not support specified @code{Alignment}s that are
5105 greater than the maximum @code{Alignment} the implementation ever returns by
5106 default.
5107 @end cartouche
5108 Followed.
5109
5110 @sp 1
5111 @cartouche
5112 The recommended level of support for the @code{Alignment} attribute for
5113 objects is:
5114
5115 Same as above, for subtypes, but in addition:
5116 @end cartouche
5117 Followed.
5118
5119 @sp 1
5120 @cartouche
5121 For stand-alone library-level objects of statically constrained
5122 subtypes, the implementation should support all @code{Alignment}s
5123 supported by the target linker.  For example, page alignment is likely to
5124 be supported for such objects, but not for subtypes.
5125 @end cartouche
5126 Followed.
5127
5128 @cindex @code{Size} clauses
5129 @unnumberedsec 13.3(42-43): Size Clauses
5130 @sp 1
5131 @cartouche
5132 The recommended level of support for the @code{Size} attribute of
5133 objects is:
5134
5135 A @code{Size} clause should be supported for an object if the specified
5136 @code{Size} is at least as large as its subtype's @code{Size}, and
5137 corresponds to a size in storage elements that is a multiple of the
5138 object's @code{Alignment} (if the @code{Alignment} is nonzero).
5139 @end cartouche
5140 Followed.
5141
5142 @unnumberedsec 13.3(50-56): Size Clauses
5143 @sp 1
5144 @cartouche
5145 If the @code{Size} of a subtype is specified, and allows for efficient
5146 independent addressability (see 9.10) on the target architecture, then
5147 the @code{Size} of the following objects of the subtype should equal the
5148 @code{Size} of the subtype:
5149
5150 Aliased objects (including components).
5151 @end cartouche
5152 Followed.
5153
5154 @sp 1
5155 @cartouche
5156 @code{Size} clause on a composite subtype should not affect the
5157 internal layout of components.
5158 @end cartouche
5159 Followed.
5160
5161 @sp 1
5162 @cartouche
5163 The recommended level of support for the @code{Size} attribute of subtypes is:
5164 @end cartouche
5165 @sp 1
5166 @cartouche
5167 The @code{Size} (if not specified) of a static discrete or fixed point
5168 subtype should be the number of bits needed to represent each value
5169 belonging to the subtype using an unbiased representation, leaving space
5170 for a sign bit only if the subtype contains negative values.  If such a
5171 subtype is a first subtype, then an implementation should support a
5172 specified @code{Size} for it that reflects this representation.
5173 @end cartouche
5174 Followed.
5175
5176 @sp 1
5177 @cartouche
5178 For a subtype implemented with levels of indirection, the @code{Size}
5179 should include the size of the pointers, but not the size of what they
5180 point at.
5181 @end cartouche
5182 Followed.
5183
5184 @cindex @code{Component_Size} clauses
5185 @unnumberedsec 13.3(71-73): Component Size Clauses
5186 @sp 1
5187 @cartouche
5188 The recommended level of support for the @code{Component_Size}
5189 attribute is:
5190 @end cartouche
5191 @sp 1
5192 @cartouche
5193 An implementation need not support specified @code{Component_Sizes} that are
5194 less than the @code{Size} of the component subtype.
5195 @end cartouche
5196 Followed.
5197
5198 @sp 1
5199 @cartouche
5200 An implementation should support specified @code{Component_Size}s that
5201 are factors and multiples of the word size.  For such
5202 @code{Component_Size}s, the array should contain no gaps between
5203 components.  For other @code{Component_Size}s (if supported), the array
5204 should contain no gaps between components when packing is also
5205 specified; the implementation should forbid this combination in cases
5206 where it cannot support a no-gaps representation.
5207 @end cartouche
5208 Followed.
5209
5210 @cindex Enumeration representation clauses
5211 @cindex Representation clauses, enumeration
5212 @unnumberedsec 13.4(9-10): Enumeration Representation Clauses
5213 @sp 1
5214 @cartouche
5215 The recommended level of support for enumeration representation clauses
5216 is:
5217
5218 An implementation need not support enumeration representation clauses
5219 for boolean types, but should at minimum support the internal codes in
5220 the range @code{System.Min_Int.System.Max_Int}.
5221 @end cartouche
5222 Followed.
5223
5224 @cindex Record representation clauses
5225 @cindex Representation clauses, records
5226 @unnumberedsec 13.5.1(17-22): Record Representation Clauses
5227 @sp 1
5228 @cartouche
5229 The recommended level of support for
5230 @*@code{record_representation_clauses} is:
5231
5232 An implementation should support storage places that can be extracted
5233 with a load, mask, shift sequence of machine code, and set with a load,
5234 shift, mask, store sequence, given the available machine instructions
5235 and run-time model.
5236 @end cartouche
5237 Followed.
5238
5239 @sp 1
5240 @cartouche
5241 A storage place should be supported if its size is equal to the
5242 @code{Size} of the component subtype, and it starts and ends on a
5243 boundary that obeys the @code{Alignment} of the component subtype.
5244 @end cartouche
5245 Followed.
5246
5247 @sp 1
5248 @cartouche
5249 If the default bit ordering applies to the declaration of a given type,
5250 then for a component whose subtype's @code{Size} is less than the word
5251 size, any storage place that does not cross an aligned word boundary
5252 should be supported.
5253 @end cartouche
5254 Followed.
5255
5256 @sp 1
5257 @cartouche
5258 An implementation may reserve a storage place for the tag field of a
5259 tagged type, and disallow other components from overlapping that place.
5260 @end cartouche
5261 Followed.  The storage place for the tag field is the beginning of the tagged
5262 record, and its size is Address'Size.  GNAT will reject an explicit component
5263 clause for the tag field.
5264
5265 @sp 1
5266 @cartouche
5267 An implementation need not support a @code{component_clause} for a
5268 component of an extension part if the storage place is not after the
5269 storage places of all components of the parent type, whether or not
5270 those storage places had been specified.
5271 @end cartouche
5272 Followed.  The above advice on record representation clauses is followed,
5273 and all mentioned features are implemented.
5274
5275 @cindex Storage place attributes
5276 @unnumberedsec 13.5.2(5): Storage Place Attributes
5277 @sp 1
5278 @cartouche
5279 If a component is represented using some form of pointer (such as an
5280 offset) to the actual data of the component, and this data is contiguous
5281 with the rest of the object, then the storage place attributes should
5282 reflect the place of the actual data, not the pointer.  If a component is
5283 allocated discontinuously from the rest of the object, then a warning
5284 should be generated upon reference to one of its storage place
5285 attributes.
5286 @end cartouche
5287 Followed.  There are no such components in GNAT@.
5288
5289 @cindex Bit ordering
5290 @unnumberedsec 13.5.3(7-8): Bit Ordering
5291 @sp 1
5292 @cartouche
5293 The recommended level of support for the non-default bit ordering is:
5294 @end cartouche
5295 @sp 1
5296 @cartouche
5297 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
5298 should support the non-default bit ordering in addition to the default
5299 bit ordering.
5300 @end cartouche
5301 Followed.  Word size does not equal storage size in this implementation.
5302 Thus non-default bit ordering is not supported.
5303
5304 @cindex @code{Address}, as private type
5305 @unnumberedsec 13.7(37): Address as Private
5306 @sp 1
5307 @cartouche
5308 @code{Address} should be of a private type.
5309 @end cartouche
5310 Followed.
5311
5312 @cindex Operations, on @code{Address}
5313 @cindex @code{Address}, operations of
5314 @unnumberedsec 13.7.1(16): Address Operations
5315 @sp 1
5316 @cartouche
5317 Operations in @code{System} and its children should reflect the target
5318 environment semantics as closely as is reasonable.  For example, on most
5319 machines, it makes sense for address arithmetic to ``wrap around''.
5320 Operations that do not make sense should raise @code{Program_Error}.
5321 @end cartouche
5322 Followed.  Address arithmetic is modular arithmetic that wraps around.  No
5323 operation raises @code{Program_Error}, since all operations make sense.
5324
5325 @cindex Unchecked conversion
5326 @unnumberedsec 13.9(14-17): Unchecked Conversion
5327 @sp 1
5328 @cartouche
5329 The @code{Size} of an array object should not include its bounds; hence,
5330 the bounds should not be part of the converted data.
5331 @end cartouche
5332 Followed.
5333
5334 @sp 1
5335 @cartouche
5336 The implementation should not generate unnecessary run-time checks to
5337 ensure that the representation of @var{S} is a representation of the
5338 target type.  It should take advantage of the permission to return by
5339 reference when possible.  Restrictions on unchecked conversions should be
5340 avoided unless required by the target environment.
5341 @end cartouche
5342 Followed.  There are no restrictions on unchecked conversion.  A warning is
5343 generated if the source and target types do not have the same size since
5344 the semantics in this case may be target dependent.
5345
5346 @sp 1
5347 @cartouche
5348 The recommended level of support for unchecked conversions is:
5349 @end cartouche
5350 @sp 1
5351 @cartouche
5352 Unchecked conversions should be supported and should be reversible in
5353 the cases where this clause defines the result.  To enable meaningful use
5354 of unchecked conversion, a contiguous representation should be used for
5355 elementary subtypes, for statically constrained array subtypes whose
5356 component subtype is one of the subtypes described in this paragraph,
5357 and for record subtypes without discriminants whose component subtypes
5358 are described in this paragraph.
5359 @end cartouche
5360 Followed.
5361
5362 @cindex Heap usage, implicit
5363 @unnumberedsec 13.11(23-25): Implicit Heap Usage
5364 @sp 1
5365 @cartouche
5366 An implementation should document any cases in which it dynamically
5367 allocates heap storage for a purpose other than the evaluation of an
5368 allocator.
5369 @end cartouche
5370 Followed, the only other points at which heap storage is dynamically
5371 allocated are as follows:
5372
5373 @itemize @bullet
5374 @item
5375 At initial elaboration time, to allocate dynamically sized global
5376 objects.
5377
5378 @item
5379 To allocate space for a task when a task is created.
5380
5381 @item
5382 To extend the secondary stack dynamically when needed.  The secondary
5383 stack is used for returning variable length results.
5384 @end itemize
5385
5386 @sp 1
5387 @cartouche
5388 A default (implementation-provided) storage pool for an
5389 access-to-constant type should not have overhead to support deallocation of
5390 individual objects.
5391 @end cartouche
5392 Followed.
5393
5394 @sp 1
5395 @cartouche
5396 A storage pool for an anonymous access type should be created at the
5397 point of an allocator for the type, and be reclaimed when the designated
5398 object becomes inaccessible.
5399 @end cartouche
5400 Followed.
5401
5402 @cindex Unchecked deallocation
5403 @unnumberedsec 13.11.2(17): Unchecked De-allocation
5404 @sp 1
5405 @cartouche
5406 For a standard storage pool, @code{Free} should actually reclaim the
5407 storage.
5408 @end cartouche
5409 Followed.
5410
5411 @cindex Stream oriented attributes
5412 @unnumberedsec 13.13.2(17): Stream Oriented Attributes
5413 @sp 1
5414 @cartouche
5415 If a stream element is the same size as a storage element, then the
5416 normal in-memory representation should be used by @code{Read} and
5417 @code{Write} for scalar objects.  Otherwise, @code{Read} and @code{Write}
5418 should use the smallest number of stream elements needed to represent
5419 all values in the base range of the scalar type.
5420 @end cartouche
5421
5422 Followed.  By default, GNAT uses the interpretation suggested by AI-195,
5423 which specifies using the size of the first subtype.
5424 However, such an implementation is based on direct binary
5425 representations and is therefore target- and endianness-dependent.
5426 To address this issue, GNAT also supplies an alternate implementation
5427 of the stream attributes @code{Read} and @code{Write},
5428 which uses the target-independent XDR standard representation
5429 for scalar types.
5430 @cindex XDR representation
5431 @cindex @code{Read} attribute
5432 @cindex @code{Write} attribute
5433 @cindex Stream oriented attributes
5434 The XDR implementation is provided as an alternative body of the
5435 @code{System.Stream_Attributes} package, in the file
5436 @file{s-strxdr.adb} in the GNAT library.
5437 There is no @file{s-strxdr.ads} file.
5438 In order to install the XDR implementation, do the following:
5439 @enumerate
5440 @item Replace the default implementation of the
5441 @code{System.Stream_Attributes} package with the XDR implementation.
5442 For example on a Unix platform issue the commands:
5443 @smallexample
5444 $ mv s-stratt.adb s-strold.adb
5445 $ mv s-strxdr.adb s-stratt.adb
5446 @end smallexample
5447
5448 @item
5449 Rebuild the GNAT run-time library as documented in the
5450 @cite{GNAT User's Guide}
5451 @end enumerate
5452
5453 @unnumberedsec A.1(52): Names of Predefined Numeric Types
5454 @sp 1
5455 @cartouche
5456 If an implementation provides additional named predefined integer types,
5457 then the names should end with @samp{Integer} as in
5458 @samp{Long_Integer}.  If an implementation provides additional named
5459 predefined floating point types, then the names should end with
5460 @samp{Float} as in @samp{Long_Float}.
5461 @end cartouche
5462 Followed.
5463
5464 @findex Ada.Characters.Handling
5465 @unnumberedsec A.3.2(49): @code{Ada.Characters.Handling}
5466 @sp 1
5467 @cartouche
5468 If an implementation provides a localized definition of @code{Character}
5469 or @code{Wide_Character}, then the effects of the subprograms in
5470 @code{Characters.Handling} should reflect the localizations.  See also
5471 3.5.2.
5472 @end cartouche
5473 Followed.  GNAT provides no such localized definitions.
5474
5475 @cindex Bounded-length strings
5476 @unnumberedsec A.4.4(106): Bounded-Length String Handling
5477 @sp 1
5478 @cartouche
5479 Bounded string objects should not be implemented by implicit pointers
5480 and dynamic allocation.
5481 @end cartouche
5482 Followed.  No implicit pointers or dynamic allocation are used.
5483
5484 @cindex Random number generation
5485 @unnumberedsec A.5.2(46-47): Random Number Generation
5486 @sp 1
5487 @cartouche
5488 Any storage associated with an object of type @code{Generator} should be
5489 reclaimed on exit from the scope of the object.
5490 @end cartouche
5491 Followed.
5492
5493 @sp 1
5494 @cartouche
5495 If the generator period is sufficiently long in relation to the number
5496 of distinct initiator values, then each possible value of
5497 @code{Initiator} passed to @code{Reset} should initiate a sequence of
5498 random numbers that does not, in a practical sense, overlap the sequence
5499 initiated by any other value.  If this is not possible, then the mapping
5500 between initiator values and generator states should be a rapidly
5501 varying function of the initiator value.
5502 @end cartouche
5503 Followed.  The generator period is sufficiently long for the first
5504 condition here to hold true.
5505
5506 @findex Get_Immediate
5507 @unnumberedsec A.10.7(23): @code{Get_Immediate}
5508 @sp 1
5509 @cartouche
5510 The @code{Get_Immediate} procedures should be implemented with
5511 unbuffered input.  For a device such as a keyboard, input should be
5512 @dfn{available} if a key has already been typed, whereas for a disk
5513 file, input should always be available except at end of file.  For a file
5514 associated with a keyboard-like device, any line-editing features of the
5515 underlying operating system should be disabled during the execution of
5516 @code{Get_Immediate}.
5517 @end cartouche
5518 Followed on all targets except VxWorks. For VxWorks, there is no way to
5519 provide this functionality that does not result in the input buffer being
5520 flushed before the @code{Get_Immediate} call. A special unit
5521 @code{Interfaces.Vxworks.IO} is provided that contains routines to enable
5522 this functionality.
5523
5524 @findex Export
5525 @unnumberedsec B.1(39-41): Pragma @code{Export}
5526 @sp 1
5527 @cartouche
5528 If an implementation supports pragma @code{Export} to a given language,
5529 then it should also allow the main subprogram to be written in that
5530 language.  It should support some mechanism for invoking the elaboration
5531 of the Ada library units included in the system, and for invoking the
5532 finalization of the environment task.  On typical systems, the
5533 recommended mechanism is to provide two subprograms whose link names are
5534 @code{adainit} and @code{adafinal}.  @code{adainit} should contain the
5535 elaboration code for library units.  @code{adafinal} should contain the
5536 finalization code.  These subprograms should have no effect the second
5537 and subsequent time they are called.
5538 @end cartouche
5539 Followed.
5540
5541 @sp 1
5542 @cartouche
5543 Automatic elaboration of pre-elaborated packages should be
5544 provided when pragma @code{Export} is supported.
5545 @end cartouche
5546 Followed when the main program is in Ada.  If the main program is in a
5547 foreign language, then
5548 @code{adainit} must be called to elaborate pre-elaborated
5549 packages.
5550
5551 @sp 1
5552 @cartouche
5553 For each supported convention @var{L} other than @code{Intrinsic}, an
5554 implementation should support @code{Import} and @code{Export} pragmas
5555 for objects of @var{L}-compatible types and for subprograms, and pragma
5556 @code{Convention} for @var{L}-eligible types and for subprograms,
5557 presuming the other language has corresponding features.  Pragma
5558 @code{Convention} need not be supported for scalar types.
5559 @end cartouche
5560 Followed.
5561
5562 @cindex Package @code{Interfaces}
5563 @findex Interfaces
5564 @unnumberedsec B.2(12-13): Package @code{Interfaces}
5565 @sp 1
5566 @cartouche
5567 For each implementation-defined convention identifier, there should be a
5568 child package of package Interfaces with the corresponding name.  This
5569 package should contain any declarations that would be useful for
5570 interfacing to the language (implementation) represented by the
5571 convention.  Any declarations useful for interfacing to any language on
5572 the given hardware architecture should be provided directly in
5573 @code{Interfaces}.
5574 @end cartouche
5575 Followed.  An additional package not defined
5576 in the Ada 95 Reference Manual is @code{Interfaces.CPP}, used
5577 for interfacing to C++.
5578
5579 @sp 1
5580 @cartouche
5581 An implementation supporting an interface to C, COBOL, or Fortran should
5582 provide the corresponding package or packages described in the following
5583 clauses.
5584 @end cartouche
5585 Followed.  GNAT provides all the packages described in this section.
5586
5587 @cindex C, interfacing with
5588 @unnumberedsec B.3(63-71): Interfacing with C
5589 @sp 1
5590 @cartouche
5591 An implementation should support the following interface correspondences
5592 between Ada and C@.
5593 @end cartouche
5594 Followed.
5595
5596 @sp 1
5597 @cartouche
5598 An Ada procedure corresponds to a void-returning C function.
5599 @end cartouche
5600 Followed.
5601
5602 @sp 1
5603 @cartouche
5604 An Ada function corresponds to a non-void C function.
5605 @end cartouche
5606 Followed.
5607
5608 @sp 1
5609 @cartouche
5610 An Ada @code{in} scalar parameter is passed as a scalar argument to a C
5611 function.
5612 @end cartouche
5613 Followed.
5614
5615 @sp 1
5616 @cartouche
5617 An Ada @code{in} parameter of an access-to-object type with designated
5618 type @var{T} is passed as a @code{@var{t}*} argument to a C function,
5619 where @var{t} is the C type corresponding to the Ada type @var{T}.
5620 @end cartouche
5621 Followed.
5622
5623 @sp 1
5624 @cartouche
5625 An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
5626 parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
5627 argument to a C function, where @var{t} is the C type corresponding to
5628 the Ada type @var{T}.  In the case of an elementary @code{out} or
5629 @code{in out} parameter, a pointer to a temporary copy is used to
5630 preserve by-copy semantics.
5631 @end cartouche
5632 Followed.
5633
5634 @sp 1
5635 @cartouche
5636 An Ada parameter of a record type @var{T}, of any mode, is passed as a
5637 @code{@var{t}*} argument to a C function, where @var{t} is the C
5638 structure corresponding to the Ada type @var{T}.
5639 @end cartouche
5640 Followed.  This convention may be overridden by the use of the C_Pass_By_Copy
5641 pragma, or Convention, or by explicitly specifying the mechanism for a given
5642 call using an extended import or export pragma.
5643
5644 @sp 1
5645 @cartouche
5646 An Ada parameter of an array type with component type @var{T}, of any
5647 mode, is passed as a @code{@var{t}*} argument to a C function, where
5648 @var{t} is the C type corresponding to the Ada type @var{T}.
5649 @end cartouche
5650 Followed.
5651
5652 @sp 1
5653 @cartouche
5654 An Ada parameter of an access-to-subprogram type is passed as a pointer
5655 to a C function whose prototype corresponds to the designated
5656 subprogram's specification.
5657 @end cartouche
5658 Followed.
5659
5660 @cindex COBOL, interfacing with
5661 @unnumberedsec B.4(95-98): Interfacing with COBOL
5662 @sp 1
5663 @cartouche
5664 An Ada implementation should support the following interface
5665 correspondences between Ada and COBOL@.
5666 @end cartouche
5667 Followed.
5668
5669 @sp 1
5670 @cartouche
5671 An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of
5672 the COBOL type corresponding to @var{T}.
5673 @end cartouche
5674 Followed.
5675
5676 @sp 1
5677 @cartouche
5678 An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of
5679 the corresponding COBOL type.
5680 @end cartouche
5681 Followed.
5682
5683 @sp 1
5684 @cartouche
5685 Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the
5686 COBOL type corresponding to the Ada parameter type; for scalars, a local
5687 copy is used if necessary to ensure by-copy semantics.
5688 @end cartouche
5689 Followed.
5690
5691 @cindex Fortran, interfacing with
5692 @unnumberedsec B.5(22-26): Interfacing with Fortran
5693 @sp 1
5694 @cartouche
5695 An Ada implementation should support the following interface
5696 correspondences between Ada and Fortran:
5697 @end cartouche
5698 Followed.
5699
5700 @sp 1
5701 @cartouche
5702 An Ada procedure corresponds to a Fortran subroutine.
5703 @end cartouche
5704 Followed.
5705
5706 @sp 1
5707 @cartouche
5708 An Ada function corresponds to a Fortran function.
5709 @end cartouche
5710 Followed.
5711
5712 @sp 1
5713 @cartouche
5714 An Ada parameter of an elementary, array, or record type @var{T} is
5715 passed as a @var{T} argument to a Fortran procedure, where @var{T} is
5716 the Fortran type corresponding to the Ada type @var{T}, and where the
5717 INTENT attribute of the corresponding dummy argument matches the Ada
5718 formal parameter mode; the Fortran implementation's parameter passing
5719 conventions are used.  For elementary types, a local copy is used if
5720 necessary to ensure by-copy semantics.
5721 @end cartouche
5722 Followed.
5723
5724 @sp 1
5725 @cartouche
5726 An Ada parameter of an access-to-subprogram type is passed as a
5727 reference to a Fortran procedure whose interface corresponds to the
5728 designated subprogram's specification.
5729 @end cartouche
5730 Followed.
5731
5732 @cindex Machine operations
5733 @unnumberedsec C.1(3-5): Access to Machine Operations
5734 @sp 1
5735 @cartouche
5736 The machine code or intrinsic support should allow access to all
5737 operations normally available to assembly language programmers for the
5738 target environment, including privileged instructions, if any.
5739 @end cartouche
5740 Followed.
5741
5742 @sp 1
5743 @cartouche
5744 The interfacing pragmas (see Annex B) should support interface to
5745 assembler; the default assembler should be associated with the
5746 convention identifier @code{Assembler}.
5747 @end cartouche
5748 Followed.
5749
5750 @sp 1
5751 @cartouche
5752 If an entity is exported to assembly language, then the implementation
5753 should allocate it at an addressable location, and should ensure that it
5754 is retained by the linking process, even if not otherwise referenced
5755 from the Ada code.  The implementation should assume that any call to a
5756 machine code or assembler subprogram is allowed to read or update every
5757 object that is specified as exported.
5758 @end cartouche
5759 Followed.
5760
5761 @unnumberedsec C.1(10-16): Access to Machine Operations
5762 @sp 1
5763 @cartouche
5764 The implementation should ensure that little or no overhead is
5765 associated with calling intrinsic and machine-code subprograms.
5766 @end cartouche
5767 Followed for both intrinsics and machine-code subprograms.
5768
5769 @sp 1
5770 @cartouche
5771 It is recommended that intrinsic subprograms be provided for convenient
5772 access to any machine operations that provide special capabilities or
5773 efficiency and that are not otherwise available through the language
5774 constructs.
5775 @end cartouche
5776 Followed.  A full set of machine operation intrinsic subprograms is provided.
5777
5778 @sp 1
5779 @cartouche
5780 Atomic read-modify-write operations---e.g.@:, test and set, compare and
5781 swap, decrement and test, enqueue/dequeue.
5782 @end cartouche
5783 Followed on any target supporting such operations.
5784
5785 @sp 1
5786 @cartouche
5787 Standard numeric functions---e.g.@:, sin, log.
5788 @end cartouche
5789 Followed on any target supporting such operations.
5790
5791 @sp 1
5792 @cartouche
5793 String manipulation operations---e.g.@:, translate and test.
5794 @end cartouche
5795 Followed on any target supporting such operations.
5796
5797 @sp 1
5798 @cartouche
5799 Vector operations---e.g.@:, compare vector against thresholds.
5800 @end cartouche
5801 Followed on any target supporting such operations.
5802
5803 @sp 1
5804 @cartouche
5805 Direct operations on I/O ports.
5806 @end cartouche
5807 Followed on any target supporting such operations.
5808
5809 @cindex Interrupt support
5810 @unnumberedsec C.3(28): Interrupt Support
5811 @sp 1
5812 @cartouche
5813 If the @code{Ceiling_Locking} policy is not in effect, the
5814 implementation should provide means for the application to specify which
5815 interrupts are to be blocked during protected actions, if the underlying
5816 system allows for a finer-grain control of interrupt blocking.
5817 @end cartouche
5818 Followed.  The underlying system does not allow for finer-grain control
5819 of interrupt blocking.
5820
5821 @cindex Protected procedure handlers
5822 @unnumberedsec C.3.1(20-21): Protected Procedure Handlers
5823 @sp 1
5824 @cartouche
5825 Whenever possible, the implementation should allow interrupt handlers to
5826 be called directly by the hardware.
5827 @end cartouche
5828 @c SGI info:
5829 @ignore
5830 This is never possible under IRIX, so this is followed by default.
5831 @end ignore
5832 Followed on any target where the underlying operating system permits
5833 such direct calls.
5834
5835 @sp 1
5836 @cartouche
5837 Whenever practical, violations of any
5838 implementation-defined restrictions should be detected before run time.
5839 @end cartouche
5840 Followed.  Compile time warnings are given when possible.
5841
5842 @cindex Package @code{Interrupts}
5843 @findex Interrupts
5844 @unnumberedsec C.3.2(25): Package @code{Interrupts}
5845
5846 @sp 1
5847 @cartouche
5848 If implementation-defined forms of interrupt handler procedures are
5849 supported, such as protected procedures with parameters, then for each
5850 such form of a handler, a type analogous to @code{Parameterless_Handler}
5851 should be specified in a child package of @code{Interrupts}, with the
5852 same operations as in the predefined package Interrupts.
5853 @end cartouche
5854 Followed.
5855
5856 @cindex Pre-elaboration requirements
5857 @unnumberedsec C.4(14): Pre-elaboration Requirements
5858 @sp 1
5859 @cartouche
5860 It is recommended that pre-elaborated packages be implemented in such a
5861 way that there should be little or no code executed at run time for the
5862 elaboration of entities not already covered by the Implementation
5863 Requirements.
5864 @end cartouche
5865 Followed.  Executable code is generated in some cases, e.g.@: loops
5866 to initialize large arrays.
5867
5868 @unnumberedsec C.5(8): Pragma @code{Discard_Names}
5869
5870 @sp 1
5871 @cartouche
5872 If the pragma applies to an entity, then the implementation should
5873 reduce the amount of storage used for storing names associated with that
5874 entity.
5875 @end cartouche
5876 Followed.
5877
5878 @cindex Package @code{Task_Attributes}
5879 @findex Task_Attributes
5880 @unnumberedsec C.7.2(30): The Package Task_Attributes
5881 @sp 1
5882 @cartouche
5883 Some implementations are targeted to domains in which memory use at run
5884 time must be completely deterministic.  For such implementations, it is
5885 recommended that the storage for task attributes will be pre-allocated
5886 statically and not from the heap.  This can be accomplished by either
5887 placing restrictions on the number and the size of the task's
5888 attributes, or by using the pre-allocated storage for the first @var{N}
5889 attribute objects, and the heap for the others.  In the latter case,
5890 @var{N} should be documented.
5891 @end cartouche
5892 Not followed.  This implementation is not targeted to such a domain.
5893
5894 @cindex Locking Policies
5895 @unnumberedsec D.3(17): Locking Policies
5896
5897 @sp 1
5898 @cartouche
5899 The implementation should use names that end with @samp{_Locking} for
5900 locking policies defined by the implementation.
5901 @end cartouche
5902 Followed.  A single implementation-defined locking policy is defined,
5903 whose name (@code{Inheritance_Locking}) follows this suggestion.
5904
5905 @cindex Entry queuing policies
5906 @unnumberedsec D.4(16): Entry Queuing Policies
5907 @sp 1
5908 @cartouche
5909 Names that end with @samp{_Queuing} should be used
5910 for all implementation-defined queuing policies.
5911 @end cartouche
5912 Followed.  No such implementation-defined queuing policies exist.
5913
5914 @cindex Preemptive abort
5915 @unnumberedsec D.6(9-10): Preemptive Abort
5916 @sp 1
5917 @cartouche
5918 Even though the @code{abort_statement} is included in the list of
5919 potentially blocking operations (see 9.5.1), it is recommended that this
5920 statement be implemented in a way that never requires the task executing
5921 the @code{abort_statement} to block.
5922 @end cartouche
5923 Followed.
5924
5925 @sp 1
5926 @cartouche
5927 On a multi-processor, the delay associated with aborting a task on
5928 another processor should be bounded; the implementation should use
5929 periodic polling, if necessary, to achieve this.
5930 @end cartouche
5931 Followed.
5932
5933 @cindex Tasking restrictions
5934 @unnumberedsec D.7(21): Tasking Restrictions
5935 @sp 1
5936 @cartouche
5937 When feasible, the implementation should take advantage of the specified
5938 restrictions to produce a more efficient implementation.
5939 @end cartouche
5940 GNAT currently takes advantage of these restrictions by providing an optimized
5941 run time when the Ravenscar profile and the GNAT restricted run time set
5942 of restrictions are specified.  See pragma @code{Ravenscar} and pragma
5943 @code{Restricted_Run_Time} for more details.
5944
5945 @cindex Time, monotonic
5946 @unnumberedsec D.8(47-49): Monotonic Time
5947 @sp 1
5948 @cartouche
5949 When appropriate, implementations should provide configuration
5950 mechanisms to change the value of @code{Tick}.
5951 @end cartouche
5952 Such configuration mechanisms are not appropriate to this implementation
5953 and are thus not supported.
5954
5955 @sp 1
5956 @cartouche
5957 It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
5958 be implemented as transformations of the same time base.
5959 @end cartouche
5960 Followed.
5961
5962 @sp 1
5963 @cartouche
5964 It is recommended that the @dfn{best} time base which exists in
5965 the underlying system be available to the application through
5966 @code{Clock}.  @dfn{Best} may mean highest accuracy or largest range.
5967 @end cartouche
5968 Followed.
5969
5970 @cindex Partition communication subsystem
5971 @cindex PCS
5972 @unnumberedsec E.5(28-29): Partition Communication Subsystem
5973 @sp 1
5974 @cartouche
5975 Whenever possible, the PCS on the called partition should allow for
5976 multiple tasks to call the RPC-receiver with different messages and
5977 should allow them to block until the corresponding subprogram body
5978 returns.
5979 @end cartouche
5980 Followed by GLADE, a separately supplied PCS that can be used with
5981 GNAT.
5982
5983 @sp 1
5984 @cartouche
5985 The @code{Write} operation on a stream of type @code{Params_Stream_Type}
5986 should raise @code{Storage_Error} if it runs out of space trying to
5987 write the @code{Item} into the stream.
5988 @end cartouche
5989 Followed by GLADE, a separately supplied PCS that can be used with
5990 GNAT@.
5991
5992 @cindex COBOL support
5993 @unnumberedsec F(7): COBOL Support
5994 @sp 1
5995 @cartouche
5996 If COBOL (respectively, C) is widely supported in the target
5997 environment, implementations supporting the Information Systems Annex
5998 should provide the child package @code{Interfaces.COBOL} (respectively,
5999 @code{Interfaces.C}) specified in Annex B and should support a
6000 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
6001 pragmas (see Annex B), thus allowing Ada programs to interface with
6002 programs written in that language.
6003 @end cartouche
6004 Followed.
6005
6006 @cindex Decimal radix support
6007 @unnumberedsec F.1(2): Decimal Radix Support
6008 @sp 1
6009 @cartouche
6010 Packed decimal should be used as the internal representation for objects
6011 of subtype @var{S} when @var{S}'Machine_Radix = 10.
6012 @end cartouche
6013 Not followed.  GNAT ignores @var{S}'Machine_Radix and always uses binary
6014 representations.
6015
6016 @cindex Numerics
6017 @unnumberedsec G: Numerics
6018 @sp 2
6019 @cartouche
6020 If Fortran (respectively, C) is widely supported in the target
6021 environment, implementations supporting the Numerics Annex
6022 should provide the child package @code{Interfaces.Fortran} (respectively,
6023 @code{Interfaces.C}) specified in Annex B and should support a
6024 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
6025 pragmas (see Annex B), thus allowing Ada programs to interface with
6026 programs written in that language.
6027 @end cartouche
6028 Followed.
6029
6030 @cindex Complex types
6031 @unnumberedsec G.1.1(56-58): Complex Types
6032 @sp 2
6033 @cartouche
6034 Because the usual mathematical meaning of multiplication of a complex
6035 operand and a real operand is that of the scaling of both components of
6036 the former by the latter, an implementation should not perform this
6037 operation by first promoting the real operand to complex type and then
6038 performing a full complex multiplication.  In systems that, in the
6039 future, support an Ada binding to IEC 559:1989, the latter technique
6040 will not generate the required result when one of the components of the
6041 complex operand is infinite.  (Explicit multiplication of the infinite
6042 component by the zero component obtained during promotion yields a NaN
6043 that propagates into the final result.) Analogous advice applies in the
6044 case of multiplication of a complex operand and a pure-imaginary
6045 operand, and in the case of division of a complex operand by a real or
6046 pure-imaginary operand.
6047 @end cartouche
6048 Not followed.
6049
6050 @sp 1
6051 @cartouche
6052 Similarly, because the usual mathematical meaning of addition of a
6053 complex operand and a real operand is that the imaginary operand remains
6054 unchanged, an implementation should not perform this operation by first
6055 promoting the real operand to complex type and then performing a full
6056 complex addition.  In implementations in which the @code{Signed_Zeros}
6057 attribute of the component type is @code{True} (and which therefore
6058 conform to IEC 559:1989 in regard to the handling of the sign of zero in
6059 predefined arithmetic operations), the latter technique will not
6060 generate the required result when the imaginary component of the complex
6061 operand is a negatively signed zero.  (Explicit addition of the negative
6062 zero to the zero obtained during promotion yields a positive zero.)
6063 Analogous advice applies in the case of addition of a complex operand
6064 and a pure-imaginary operand, and in the case of subtraction of a
6065 complex operand and a real or pure-imaginary operand.
6066 @end cartouche
6067 Not followed.
6068
6069 @sp 1
6070 @cartouche
6071 Implementations in which @code{Real'Signed_Zeros} is @code{True} should
6072 attempt to provide a rational treatment of the signs of zero results and
6073 result components.  As one example, the result of the @code{Argument}
6074 function should have the sign of the imaginary component of the
6075 parameter @code{X} when the point represented by that parameter lies on
6076 the positive real axis; as another, the sign of the imaginary component
6077 of the @code{Compose_From_Polar} function should be the same as
6078 (respectively, the opposite of) that of the @code{Argument} parameter when that
6079 parameter has a value of zero and the @code{Modulus} parameter has a
6080 nonnegative (respectively, negative) value.
6081 @end cartouche
6082 Followed.
6083
6084 @cindex Complex elementary functions
6085 @unnumberedsec G.1.2(49): Complex Elementary Functions
6086 @sp 1
6087 @cartouche
6088 Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
6089 @code{True} should attempt to provide a rational treatment of the signs
6090 of zero results and result components.  For example, many of the complex
6091 elementary functions have components that are odd functions of one of
6092 the parameter components; in these cases, the result component should
6093 have the sign of the parameter component at the origin.  Other complex
6094 elementary functions have zero components whose sign is opposite that of
6095 a parameter component at the origin, or is always positive or always
6096 negative.
6097 @end cartouche
6098 Followed.
6099
6100 @cindex Accuracy requirements
6101 @unnumberedsec G.2.4(19): Accuracy Requirements
6102 @sp 1
6103 @cartouche
6104 The versions of the forward trigonometric functions without a
6105 @code{Cycle} parameter should not be implemented by calling the
6106 corresponding version with a @code{Cycle} parameter of
6107 @code{2.0*Numerics.Pi}, since this will not provide the required
6108 accuracy in some portions of the domain.  For the same reason, the
6109 version of @code{Log} without a @code{Base} parameter should not be
6110 implemented by calling the corresponding version with a @code{Base}
6111 parameter of @code{Numerics.e}.
6112 @end cartouche
6113 Followed.
6114
6115 @cindex Complex arithmetic accuracy
6116 @cindex Accuracy, complex arithmetic
6117 @unnumberedsec G.2.6(15): Complex Arithmetic Accuracy
6118
6119 @sp 1
6120 @cartouche
6121 The version of the @code{Compose_From_Polar} function without a
6122 @code{Cycle} parameter should not be implemented by calling the
6123 corresponding version with a @code{Cycle} parameter of
6124 @code{2.0*Numerics.Pi}, since this will not provide the required
6125 accuracy in some portions of the domain.
6126 @end cartouche
6127 Followed.
6128
6129 @c -----------------------------------------
6130 @node Implementation Defined Characteristics
6131 @chapter Implementation Defined Characteristics
6132
6133 @noindent
6134 In addition to the implementation dependent pragmas and attributes, and
6135 the implementation advice, there are a number of other features of Ada
6136 95 that are potentially implementation dependent.  These are mentioned
6137 throughout the Ada 95 Reference Manual, and are summarized in annex M@.
6138
6139 A requirement for conforming Ada compilers is that they provide
6140 documentation describing how the implementation deals with each of these
6141 issues.  In this chapter, you will find each point in annex M listed
6142 followed by a description in italic font of how GNAT
6143 @c SGI info:
6144 @ignore
6145 in the ProDev Ada
6146 implementation on IRIX 5.3 operating system or greater
6147 @end ignore
6148 handles the implementation dependence.
6149
6150 You can use this chapter as a guide to minimizing implementation
6151 dependent features in your programs if portability to other compilers
6152 and other operating systems is an important consideration.  The numbers
6153 in each section below correspond to the paragraph number in the Ada 95
6154 Reference Manual.
6155
6156 @sp 1
6157 @cartouche
6158 @noindent
6159 @strong{2}.  Whether or not each recommendation given in Implementation
6160 Advice is followed.  See 1.1.2(37).
6161 @end cartouche
6162 @noindent
6163 @xref{Implementation Advice}.
6164
6165 @sp 1
6166 @cartouche
6167 @noindent
6168 @strong{3}.  Capacity limitations of the implementation.  See 1.1.3(3).
6169 @end cartouche
6170 @noindent
6171 The complexity of programs that can be processed is limited only by the
6172 total amount of available virtual memory, and disk space for the
6173 generated object files.
6174
6175 @sp 1
6176 @cartouche
6177 @noindent
6178 @strong{4}.  Variations from the standard that are impractical to avoid
6179 given the implementation's execution environment.  See 1.1.3(6).
6180 @end cartouche
6181 @noindent
6182 There are no variations from the standard.
6183
6184 @sp 1
6185 @cartouche
6186 @noindent
6187 @strong{5}.  Which @code{code_statement}s cause external
6188 interactions.  See 1.1.3(10).
6189 @end cartouche
6190 @noindent
6191 Any @code{code_statement} can potentially cause external interactions.
6192
6193 @sp 1
6194 @cartouche
6195 @noindent
6196 @strong{6}.  The coded representation for the text of an Ada
6197 program.  See 2.1(4).
6198 @end cartouche
6199 @noindent
6200 See separate section on source representation.
6201
6202 @sp 1
6203 @cartouche
6204 @noindent
6205 @strong{7}.  The control functions allowed in comments.  See 2.1(14).
6206 @end cartouche
6207 @noindent
6208 See separate section on source representation.
6209
6210 @sp 1
6211 @cartouche
6212 @noindent
6213 @strong{8}.  The representation for an end of line.  See 2.2(2).
6214 @end cartouche
6215 @noindent
6216 See separate section on source representation.
6217
6218 @sp 1
6219 @cartouche
6220 @noindent
6221 @strong{9}.  Maximum supported line length and lexical element
6222 length.  See 2.2(15).
6223 @end cartouche
6224 @noindent
6225 The maximum line length is 255 characters an the maximum length of a
6226 lexical element is also 255 characters.
6227
6228 @sp 1
6229 @cartouche
6230 @noindent
6231 @strong{10}.  Implementation defined pragmas.  See 2.8(14).
6232 @end cartouche
6233 @noindent
6234
6235 @xref{Implementation Defined Pragmas}.
6236
6237 @sp 1
6238 @cartouche
6239 @noindent
6240 @strong{11}.  Effect of pragma @code{Optimize}.  See 2.8(27).
6241 @end cartouche
6242 @noindent
6243 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
6244 parameter, checks that the optimization flag is set, and aborts if it is
6245 not.
6246
6247 @sp 1
6248 @cartouche
6249 @noindent
6250 @strong{12}.  The sequence of characters of the value returned by
6251 @code{@var{S}'Image} when some of the graphic characters of
6252 @code{@var{S}'Wide_Image} are not defined in @code{Character}.  See
6253 3.5(37).
6254 @end cartouche
6255 @noindent
6256 The sequence of characters is as defined by the wide character encoding
6257 method used for the source.  See section on source representation for
6258 further details.
6259
6260 @sp 1
6261 @cartouche
6262 @noindent
6263 @strong{13}.  The predefined integer types declared in
6264 @code{Standard}.  See 3.5.4(25).
6265 @end cartouche
6266 @noindent
6267 @table @code
6268 @item Short_Short_Integer
6269 8 bit signed
6270 @item Short_Integer
6271 (Short) 16 bit signed
6272 @item Integer
6273 32 bit signed
6274 @item Long_Integer
6275 64 bit signed (Alpha OpenVMS only)
6276 32 bit signed (all other targets)
6277 @item Long_Long_Integer
6278 64 bit signed
6279 @end table
6280
6281 @sp 1
6282 @cartouche
6283 @noindent
6284 @strong{14}.  Any nonstandard integer types and the operators defined
6285 for them.  See 3.5.4(26).
6286 @end cartouche
6287 @noindent
6288 There are no nonstandard integer types.
6289
6290 @sp 1
6291 @cartouche
6292 @noindent
6293 @strong{15}.  Any nonstandard real types and the operators defined for
6294 them.  See 3.5.6(8).
6295 @end cartouche
6296 @noindent
6297 There are no nonstandard real types.
6298
6299 @sp 1
6300 @cartouche
6301 @noindent
6302 @strong{16}.  What combinations of requested decimal precision and range
6303 are supported for floating point types.  See 3.5.7(7).
6304 @end cartouche
6305 @noindent
6306 The precision and range is as defined by the IEEE standard.
6307
6308 @sp 1
6309 @cartouche
6310 @noindent
6311 @strong{17}.  The predefined floating point types declared in
6312 @code{Standard}.  See 3.5.7(16).
6313 @end cartouche
6314 @noindent
6315 @table @code
6316 @item Short_Float
6317 32 bit IEEE short
6318 @item Float
6319 (Short) 32 bit IEEE short
6320 @item Long_Float
6321 64 bit IEEE long
6322 @item Long_Long_Float
6323 64 bit IEEE long (80 bit IEEE long on x86 processors)
6324 @end table
6325
6326 @sp 1
6327 @cartouche
6328 @noindent
6329 @strong{18}.  The small of an ordinary fixed point type.  See 3.5.9(8).
6330 @end cartouche
6331 @noindent
6332 @code{Fine_Delta} is 2**(@minus{}63)
6333
6334 @sp 1
6335 @cartouche
6336 @noindent
6337 @strong{19}.  What combinations of small, range, and digits are
6338 supported for fixed point types.  See 3.5.9(10).
6339 @end cartouche
6340 @noindent
6341 Any combinations are permitted that do not result in a small less than
6342 @code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
6343 If the mantissa is larger than 53 bits on machines where Long_Long_Float
6344 is 64 bits (true of all architectures except ia32), then the output from
6345 Text_IO is accurate to only 53 bits, rather than the full mantissa.  This
6346 is because floating-point conversions are used to convert fixed point.
6347
6348 @sp 1
6349 @cartouche
6350 @noindent
6351 @strong{20}.  The result of @code{Tags.Expanded_Name} for types declared
6352 within an unnamed @code{block_statement}.  See 3.9(10).
6353 @end cartouche
6354 @noindent
6355 Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
6356 decimal integer are allocated.
6357
6358 @sp 1
6359 @cartouche
6360 @noindent
6361 @strong{21}.  Implementation-defined attributes.  See 4.1.4(12).
6362 @end cartouche
6363 @noindent
6364 @xref{Implementation Defined Attributes}.
6365
6366 @sp 1
6367 @cartouche
6368 @noindent
6369 @strong{22}.  Any implementation-defined time types.  See 9.6(6).
6370 @end cartouche
6371 @noindent
6372 There are no implementation-defined time types.
6373
6374 @sp 1
6375 @cartouche
6376 @noindent
6377 @strong{23}.  The time base associated with relative delays.
6378 @end cartouche
6379 @noindent
6380 See 9.6(20).  The time base used is that provided by the C library
6381 function @code{gettimeofday}.
6382
6383 @sp 1
6384 @cartouche
6385 @noindent
6386 @strong{24}.  The time base of the type @code{Calendar.Time}.  See
6387 9.6(23).
6388 @end cartouche
6389 @noindent
6390 The time base used is that provided by the C library function
6391 @code{gettimeofday}.
6392
6393 @sp 1
6394 @cartouche
6395 @noindent
6396 @strong{25}.  The time zone used for package @code{Calendar}
6397 operations.  See 9.6(24).
6398 @end cartouche
6399 @noindent
6400 The time zone used by package @code{Calendar} is the current system time zone
6401 setting for local time, as accessed by the C library function
6402 @code{localtime}.
6403
6404 @sp 1
6405 @cartouche
6406 @noindent
6407 @strong{26}.  Any limit on @code{delay_until_statements} of
6408 @code{select_statements}.  See 9.6(29).
6409 @end cartouche
6410 @noindent
6411 There are no such limits.
6412
6413 @sp 1
6414 @cartouche
6415 @noindent
6416 @strong{27}.  Whether or not two non overlapping parts of a composite
6417 object are independently addressable, in the case where packing, record
6418 layout, or @code{Component_Size} is specified for the object.  See
6419 9.10(1).
6420 @end cartouche
6421 @noindent
6422 Separate components are independently addressable if they do not share
6423 overlapping storage units.
6424
6425 @sp 1
6426 @cartouche
6427 @noindent
6428 @strong{28}.  The representation for a compilation.  See 10.1(2).
6429 @end cartouche
6430 @noindent
6431 A compilation is represented by a sequence of files presented to the
6432 compiler in a single invocation of the @code{gcc} command.
6433
6434 @sp 1
6435 @cartouche
6436 @noindent
6437 @strong{29}.  Any restrictions on compilations that contain multiple
6438 compilation_units.  See 10.1(4).
6439 @end cartouche
6440 @noindent
6441 No single file can contain more than one compilation unit, but any
6442 sequence of files can be presented to the compiler as a single
6443 compilation.
6444
6445 @sp 1
6446 @cartouche
6447 @noindent
6448 @strong{30}.  The mechanisms for creating an environment and for adding
6449 and replacing compilation units.  See 10.1.4(3).
6450 @end cartouche
6451 @noindent
6452 See separate section on compilation model.
6453
6454 @sp 1
6455 @cartouche
6456 @noindent
6457 @strong{31}.  The manner of explicitly assigning library units to a
6458 partition.  See 10.2(2).
6459 @end cartouche
6460 @noindent
6461 If a unit contains an Ada main program, then the Ada units for the partition
6462 are determined by recursive application of the rules in the Ada Reference
6463 Manual section 10.2(2-6).  In other words, the Ada units will be those that
6464 are needed by the main program, and then this definition of need is applied
6465 recursively to those units, and the partition contains the transitive
6466 closure determined by this relationship.  In short, all the necessary units
6467 are included, with no need to explicitly specify the list.  If additional
6468 units are required, e.g.@: by foreign language units, then all units must be
6469 mentioned in the context clause of one of the needed Ada units.
6470
6471 If the partition contains no main program, or if the main program is in
6472 a language other than Ada, then GNAT
6473 provides the binder options @code{-z} and @code{-n} respectively, and in
6474 this case a list of units can be explicitly supplied to the binder for
6475 inclusion in the partition (all units needed by these units will also
6476 be included automatically).  For full details on the use of these
6477 options, refer to the @cite{GNAT User's Guide} sections on Binding
6478 and Linking.
6479
6480 @sp 1
6481 @cartouche
6482 @noindent
6483 @strong{32}.  The implementation-defined means, if any, of specifying
6484 which compilation units are needed by a given compilation unit.  See
6485 10.2(2).
6486 @end cartouche
6487 @noindent
6488 The units needed by a given compilation unit are as defined in
6489 the Ada Reference Manual section 10.2(2-6).  There are no
6490 implementation-defined pragmas or other implementation-defined
6491 means for specifying needed units.
6492
6493 @sp 1
6494 @cartouche
6495 @noindent
6496 @strong{33}.  The manner of designating the main subprogram of a
6497 partition.  See 10.2(7).
6498 @end cartouche
6499 @noindent
6500 The main program is designated by providing the name of the
6501 corresponding @file{ALI} file as the input parameter to the binder.
6502
6503 @sp 1
6504 @cartouche
6505 @noindent
6506 @strong{34}.  The order of elaboration of @code{library_items}.  See
6507 10.2(18).
6508 @end cartouche
6509 @noindent
6510 The first constraint on ordering is that it meets the requirements of
6511 chapter 10 of the Ada 95 Reference Manual.  This still leaves some
6512 implementation dependent choices, which are resolved by first
6513 elaborating bodies as early as possible (i.e.@: in preference to specs
6514 where there is a choice), and second by evaluating the immediate with
6515 clauses of a unit to determine the probably best choice, and
6516 third by elaborating in alphabetical order of unit names
6517 where a choice still remains.
6518
6519 @sp 1
6520 @cartouche
6521 @noindent
6522 @strong{35}.  Parameter passing and function return for the main
6523 subprogram.  See 10.2(21).
6524 @end cartouche
6525 @noindent
6526 The main program has no parameters.  It may be a procedure, or a function
6527 returning an integer type.  In the latter case, the returned integer
6528 value is the return code of the program (overriding any value that
6529 may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
6530
6531 @sp 1
6532 @cartouche
6533 @noindent
6534 @strong{36}.  The mechanisms for building and running partitions.  See
6535 10.2(24).
6536 @end cartouche
6537 @noindent
6538 GNAT itself supports programs with only a single partition.  The GNATDIST
6539 tool provided with the GLADE package (which also includes an implementation
6540 of the PCS) provides a completely flexible method for building and running
6541 programs consisting of multiple partitions.  See the separate GLADE manual
6542 for details.
6543
6544 @sp 1
6545 @cartouche
6546 @noindent
6547 @strong{37}.  The details of program execution, including program
6548 termination.  See 10.2(25).
6549 @end cartouche
6550 @noindent
6551 See separate section on compilation model.
6552
6553 @sp 1
6554 @cartouche
6555 @noindent
6556 @strong{38}.  The semantics of any non-active partitions supported by the
6557 implementation.  See 10.2(28).
6558 @end cartouche
6559 @noindent
6560 Passive partitions are supported on targets where shared memory is
6561 provided by the operating system.  See the GLADE reference manual for
6562 further details.
6563
6564 @sp 1
6565 @cartouche
6566 @noindent
6567 @strong{39}.  The information returned by @code{Exception_Message}.  See
6568 11.4.1(10).
6569 @end cartouche
6570 @noindent
6571 Exception message returns the null string unless a specific message has
6572 been passed by the program.
6573
6574 @sp 1
6575 @cartouche
6576 @noindent
6577 @strong{40}.  The result of @code{Exceptions.Exception_Name} for types
6578 declared within an unnamed @code{block_statement}.  See 11.4.1(12).
6579 @end cartouche
6580 @noindent
6581 Blocks have implementation defined names of the form @code{B@var{nnn}}
6582 where @var{nnn} is an integer.
6583
6584 @sp 1
6585 @cartouche
6586 @noindent
6587 @strong{41}.  The information returned by
6588 @code{Exception_Information}.  See 11.4.1(13).
6589 @end cartouche
6590 @noindent
6591 @code{Exception_Information} returns a string in the following format:
6592
6593 @smallexample
6594 @emph{Exception_Name:} nnnnn
6595 @emph{Message:} mmmmm
6596 @emph{PID:} ppp
6597 @emph{Call stack traceback locations:}
6598 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
6599 @end smallexample
6600
6601 @noindent
6602 where
6603
6604 @itemize @bullet
6605 @item
6606 @code{nnnn} is the fully qualified name of the exception in all upper
6607 case letters. This line is always present.
6608
6609 @item
6610 @code{mmmm} is the message (this line present only if message is non-null)
6611
6612 @item
6613 @code{ppp} is the Process Id value as a decimal integer (this line is
6614 present only if the Process Id is non-zero). Currently we are
6615 not making use of this field.
6616
6617 @item
6618 The Call stack traceback locations line and the following values
6619 are present only if at least one traceback location was recorded.
6620 The values are given in C style format, with lower case letters
6621 for a-f, and only as many digits present as are necessary.
6622 @end itemize
6623
6624 @noindent
6625 The line terminator sequence at the end of each line, including
6626 the last line is a single @code{LF} character (@code{16#0A#}).
6627
6628 @sp 1
6629 @cartouche
6630 @noindent
6631 @strong{42}.  Implementation-defined check names.  See 11.5(27).
6632 @end cartouche
6633 @noindent
6634 No implementation-defined check names are supported.
6635
6636 @sp 1
6637 @cartouche
6638 @noindent
6639 @strong{43}.  The interpretation of each aspect of representation.  See
6640 13.1(20).
6641 @end cartouche
6642 @noindent
6643 See separate section on data representations.
6644
6645 @sp 1
6646 @cartouche
6647 @noindent
6648 @strong{44}.  Any restrictions placed upon representation items.  See
6649 13.1(20).
6650 @end cartouche
6651 @noindent
6652 See separate section on data representations.
6653
6654 @sp 1
6655 @cartouche
6656 @noindent
6657 @strong{45}.  The meaning of @code{Size} for indefinite subtypes.  See
6658 13.3(48).
6659 @end cartouche
6660 @noindent
6661 Size for an indefinite subtype is the maximum possible size, except that
6662 for the case of a subprogram parameter, the size of the parameter object
6663 is the actual size.
6664
6665 @sp 1
6666 @cartouche
6667 @noindent
6668 @strong{46}.  The default external representation for a type tag.  See
6669 13.3(75).
6670 @end cartouche
6671 @noindent
6672 The default external representation for a type tag is the fully expanded
6673 name of the type in upper case letters.
6674
6675 @sp 1
6676 @cartouche
6677 @noindent
6678 @strong{47}.  What determines whether a compilation unit is the same in
6679 two different partitions.  See 13.3(76).
6680 @end cartouche
6681 @noindent
6682 A compilation unit is the same in two different partitions if and only
6683 if it derives from the same source file.
6684
6685 @sp 1
6686 @cartouche
6687 @noindent
6688 @strong{48}.  Implementation-defined components.  See 13.5.1(15).
6689 @end cartouche
6690 @noindent
6691 The only implementation defined component is the tag for a tagged type,
6692 which contains a pointer to the dispatching table.
6693
6694 @sp 1
6695 @cartouche
6696 @noindent
6697 @strong{49}.  If @code{Word_Size} = @code{Storage_Unit}, the default bit
6698 ordering.  See 13.5.3(5).
6699 @end cartouche
6700 @noindent
6701 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
6702 implementation, so no non-default bit ordering is supported.  The default
6703 bit ordering corresponds to the natural endianness of the target architecture.
6704
6705 @sp 1
6706 @cartouche
6707 @noindent
6708 @strong{50}.  The contents of the visible part of package @code{System}
6709 and its language-defined children.  See 13.7(2).
6710 @end cartouche
6711 @noindent
6712 See the definition of these packages in files @file{system.ads} and
6713 @file{s-stoele.ads}.
6714
6715 @sp 1
6716 @cartouche
6717 @noindent
6718 @strong{51}.  The contents of the visible part of package
6719 @code{System.Machine_Code}, and the meaning of
6720 @code{code_statements}.  See 13.8(7).
6721 @end cartouche
6722 @noindent
6723 See the definition and documentation in file @file{s-maccod.ads}.
6724
6725 @sp 1
6726 @cartouche
6727 @noindent
6728 @strong{52}.  The effect of unchecked conversion.  See 13.9(11).
6729 @end cartouche
6730 @noindent
6731 Unchecked conversion between types of the same size
6732 and results in an uninterpreted transmission of the bits from one type
6733 to the other.  If the types are of unequal sizes, then in the case of
6734 discrete types, a shorter source is first zero or sign extended as
6735 necessary, and a shorter target is simply truncated on the left.
6736 For all non-discrete types, the source is first copied if necessary
6737 to ensure that the alignment requirements of the target are met, then
6738 a pointer is constructed to the source value, and the result is obtained
6739 by dereferencing this pointer after converting it to be a pointer to the
6740 target type.
6741
6742 @sp 1
6743 @cartouche
6744 @noindent
6745 @strong{53}.  The manner of choosing a storage pool for an access type
6746 when @code{Storage_Pool} is not specified for the type.  See 13.11(17).
6747 @end cartouche
6748 @noindent
6749 There are 3 different standard pools used by the compiler when
6750 @code{Storage_Pool} is not specified depending whether the type is local
6751 to a subprogram or defined at the library level and whether
6752 @code{Storage_Size}is specified or not.  See documentation in the runtime
6753 library units @code{System.Pool_Global}, @code{System.Pool_Size} and
6754 @code{System.Pool_Local} in files @file{s-poosiz.ads},
6755 @file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
6756 default pools used.
6757
6758 @sp 1
6759 @cartouche
6760 @noindent
6761 @strong{54}.  Whether or not the implementation provides user-accessible
6762 names for the standard pool type(s).  See 13.11(17).
6763 @end cartouche
6764 @noindent
6765
6766 See documentation in the sources of the run time mentioned in paragraph
6767 @strong{53} .  All these pools are accessible by means of @code{with}'ing
6768 these units.
6769
6770 @sp 1
6771 @cartouche
6772 @noindent
6773 @strong{55}.  The meaning of @code{Storage_Size}.  See 13.11(18).
6774 @end cartouche
6775 @noindent
6776 @code{Storage_Size} is measured in storage units, and refers to the
6777 total space available for an access type collection, or to the primary
6778 stack space for a task.
6779
6780 @sp 1
6781 @cartouche
6782 @noindent
6783 @strong{56}.  Implementation-defined aspects of storage pools.  See
6784 13.11(22).
6785 @end cartouche
6786 @noindent
6787 See documentation in the sources of the run time mentioned in paragraph
6788 @strong{53} for details on GNAT-defined aspects of storage pools.
6789
6790 @sp 1
6791 @cartouche
6792 @noindent
6793 @strong{57}.  The set of restrictions allowed in a pragma
6794 @code{Restrictions}.  See 13.12(7).
6795 @end cartouche
6796 @noindent
6797 All RM defined Restriction identifiers are implemented.  The following
6798 additional restriction identifiers are provided.  There are two separate
6799 lists of implementation dependent restriction identifiers.  The first
6800 set requires consistency throughout a partition (in other words, if the
6801 restriction identifier is used for any compilation unit in the partition,
6802 then all compilation units in the partition must obey the restriction.
6803
6804 @table @code
6805
6806 @item Boolean_Entry_Barriers
6807 @findex Boolean_Entry_Barriers
6808 This restriction ensures at compile time that barriers in entry declarations
6809 for protected types are restricted to references to simple boolean variables
6810 defined in the private part of the protected type.  No other form of entry
6811 barriers is permitted.  This is one of the restrictions of the Ravenscar
6812 profile for limited tasking (see also pragma @code{Ravenscar}).
6813
6814 @item Max_Entry_Queue_Depth => Expr
6815 @findex Max_Entry_Queue_Depth
6816 This restriction is a declaration that any protected entry compiled in
6817 the scope of the restriction has at most the specified number of
6818 tasks waiting on the entry
6819 at any one time, and so no queue is required.  This restriction is not
6820 checked at compile time.  A program execution is erroneous if an attempt
6821 is made to queue more than the specified number of tasks on such an entry.
6822
6823 @item No_Calendar
6824 @findex No_Calendar
6825 This restriction ensures at compile time that there is no implicit or
6826 explicit dependence on the package @code{Ada.Calendar}.
6827
6828 @item No_Direct_Boolean_Operators
6829 @findex No_Direct_Boolean_Operators
6830 This restriction ensures that no logical (and/or/xor) or comparison
6831 operators are used on operands of type Boolean (or any type derived
6832 from Boolean). This is intended for use in safety critical programs
6833 where the certification protocol requires the use of short-circuit
6834 (and then, or else) forms for all composite boolean operations.
6835
6836 @item No_Dynamic_Interrupts
6837 @findex No_Dynamic_Interrupts
6838 This restriction ensures at compile time that there is no attempt to
6839 dynamically associate interrupts.  Only static association is allowed.
6840
6841 @item No_Enumeration_Maps
6842 @findex No_Enumeration_Maps
6843 This restriction ensures at compile time that no operations requiring
6844 enumeration maps are used (that is Image and Value attributes applied
6845 to enumeration types).
6846
6847 @item No_Entry_Calls_In_Elaboration_Code
6848 @findex No_Entry_Calls_In_Elaboration_Code
6849 This restriction ensures at compile time that no task or protected entry
6850 calls are made during elaboration code.  As a result of the use of this
6851 restriction, the compiler can assume that no code past an accept statement
6852 in a task can be executed at elaboration time.
6853
6854 @item No_Exception_Handlers
6855 @findex No_Exception_Handlers
6856 This restriction ensures at compile time that there are no explicit
6857 exception handlers. It also indicates that no exception propagation will
6858 be provided. In this mode, exceptions may be raised but will result in
6859 an immediate call to the last chance handler, a routine that the user
6860 must define with the following profile:
6861
6862    procedure Last_Chance_Handler
6863      (Source_Location : System.Address; Line : Integer);
6864    pragma Export (C, Last_Chance_Handler,
6865                   "__gnat_last_chance_handler");
6866
6867    The parameter is a C null-terminated string representing a message to be
6868    associated with the exception (typically the source location of the raise
6869    statement generated by the compiler). The Line parameter when non-zero
6870    represents the line number in the source program where the raise occurs.
6871
6872 @item No_Exception_Streams
6873 @findex No_Exception_Streams
6874 This restriction ensures at compile time that no stream operations for
6875 types Exception_Id or Exception_Occurrence are used. This also makes it
6876 impossible to pass exceptions to or from a partition with this restriction
6877 in a distributed environment. If this exception is active, then the generated
6878 code is simplified by omitting the otherwise-required global registration
6879 of exceptions when they are declared.
6880
6881 @item No_Implicit_Conditionals
6882 @findex No_Implicit_Conditionals
6883 This restriction ensures that the generated code does not contain any
6884 implicit conditionals, either by modifying the generated code where possible,
6885 or by rejecting any construct that would otherwise generate an implicit
6886 conditional.
6887
6888 @item No_Implicit_Dynamic_Code
6889 @findex No_Implicit_Dynamic_Code
6890 This restriction prevents the compiler from building ``trampolines''.
6891 This is a structure that is built on the stack and contains dynamic
6892 code to be executed at run time. A trampoline is needed to indirectly
6893 address a nested subprogram (that is a subprogram that is not at the
6894 library level). The restriction prevents the use of any of the
6895 attributes @code{Address}, @code{Access} or @code{Unrestricted_Access}
6896 being applied to a subprogram that is not at the library level.
6897
6898 @item No_Implicit_Loops
6899 @findex No_Implicit_Loops
6900 This restriction ensures that the generated code does not contain any
6901 implicit @code{for} loops, either by modifying
6902 the generated code where possible,
6903 or by rejecting any construct that would otherwise generate an implicit
6904 @code{for} loop.
6905
6906 @item No_Initialize_Scalars
6907 @findex No_Initialize_Scalars
6908 This restriction ensures that no unit in the partition is compiled with
6909 pragma Initialize_Scalars. This allows the generation of more efficient
6910 code, and in particular eliminates dummy null initialization routines that
6911 are otherwise generated for some record and array types.
6912
6913 @item No_Local_Protected_Objects
6914 @findex No_Local_Protected_Objects
6915 This restriction ensures at compile time that protected objects are
6916 only declared at the library level.
6917
6918 @item No_Protected_Type_Allocators
6919 @findex No_Protected_Type_Allocators
6920 This restriction ensures at compile time that there are no allocator
6921 expressions that attempt to allocate protected objects.
6922
6923 @item No_Secondary_Stack
6924 @findex No_Secondary_Stack
6925 This restriction ensures at compile time that the generated code does not
6926 contain any reference to the secondary stack.  The secondary stack is used
6927 to implement functions returning unconstrained objects (arrays or records)
6928 on some targets.
6929
6930 @item No_Select_Statements
6931 @findex No_Select_Statements
6932 This restriction ensures at compile time no select statements of any kind
6933 are permitted, that is the keyword @code{select} may not appear.
6934 This is one of the restrictions of the Ravenscar
6935 profile for limited tasking (see also pragma @code{Ravenscar}).
6936
6937 @item No_Standard_Storage_Pools
6938 @findex No_Standard_Storage_Pools
6939 This restriction ensures at compile time that no access types
6940 use the standard default storage pool.  Any access type declared must
6941 have an explicit Storage_Pool attribute defined specifying a
6942 user-defined storage pool.
6943
6944 @item No_Streams
6945 @findex No_Streams
6946 This restriction ensures at compile time that there are no implicit or
6947 explicit dependencies on the package @code{Ada.Streams}.
6948
6949 @item No_Task_Attributes
6950 @findex No_Task_Attributes
6951 This restriction ensures at compile time that there are no implicit or
6952 explicit dependencies on the package @code{Ada.Task_Attributes}.
6953
6954 @item No_Task_Termination
6955 @findex No_Task_Termination
6956 This restriction ensures at compile time that no terminate alternatives
6957 appear in any task body.
6958
6959 @item No_Tasking
6960 @findex No_Tasking
6961 This restriction prevents the declaration of tasks or task types throughout
6962 the partition.  It is similar in effect to the use of @code{Max_Tasks => 0}
6963 except that violations are caught at compile time and cause an error message
6964 to be output either by the compiler or binder.
6965
6966 @item No_Wide_Characters
6967 @findex No_Wide_Characters
6968 This restriction ensures at compile time that no uses of the types
6969 @code{Wide_Character} or @code{Wide_String}
6970 appear, and that no wide character literals
6971 appear in the program (that is literals representing characters not in
6972 type @code{Character}.
6973
6974 @item Static_Priorities
6975 @findex Static_Priorities
6976 This restriction ensures at compile time that all priority expressions
6977 are static, and that there are no dependencies on the package
6978 @code{Ada.Dynamic_Priorities}.
6979
6980 @item Static_Storage_Size
6981 @findex Static_Storage_Size
6982 This restriction ensures at compile time that any expression appearing
6983 in a Storage_Size pragma or attribute definition clause is static.
6984
6985 @end table
6986
6987 @noindent
6988 The second set of implementation dependent restriction identifiers
6989 does not require partition-wide consistency.
6990 The restriction may be enforced for a single
6991 compilation unit without any effect on any of the
6992 other compilation units in the partition.
6993
6994 @table @code
6995
6996 @item No_Elaboration_Code
6997 @findex No_Elaboration_Code
6998 This restriction ensures at compile time that no elaboration code is
6999 generated.  Note that this is not the same condition as is enforced
7000 by pragma @code{Preelaborate}.  There are cases in which pragma
7001 @code{Preelaborate} still permits code to be generated (e.g.@: code
7002 to initialize a large array to all zeroes), and there are cases of units
7003 which do not meet the requirements for pragma @code{Preelaborate},
7004 but for which no elaboration code is generated.  Generally, it is
7005 the case that preelaborable units will meet the restrictions, with
7006 the exception of large aggregates initialized with an others_clause,
7007 and exception declarations (which generate calls to a run-time
7008 registry procedure).  Note that this restriction is enforced on
7009 a unit by unit basis, it need not be obeyed consistently
7010 throughout a partition.
7011
7012 @item No_Entry_Queue
7013 @findex No_Entry_Queue
7014 This restriction is a declaration that any protected entry compiled in
7015 the scope of the restriction has at most one task waiting on the entry
7016 at any one time, and so no queue is required.  This restriction is not
7017 checked at compile time.  A program execution is erroneous if an attempt
7018 is made to queue a second task on such an entry.
7019
7020 @item No_Implementation_Attributes
7021 @findex No_Implementation_Attributes
7022 This restriction checks at compile time that no GNAT-defined attributes
7023 are present.  With this restriction, the only attributes that can be used
7024 are those defined in the Ada 95 Reference Manual.
7025
7026 @item No_Implementation_Pragmas
7027 @findex No_Implementation_Pragmas
7028 This restriction checks at compile time that no GNAT-defined pragmas
7029 are present.  With this restriction, the only pragmas that can be used
7030 are those defined in the Ada 95 Reference Manual.
7031
7032 @item No_Implementation_Restrictions
7033 @findex No_Implementation_Restrictions
7034 This restriction checks at compile time that no GNAT-defined restriction
7035 identifiers (other than @code{No_Implementation_Restrictions} itself)
7036 are present.  With this restriction, the only other restriction identifiers
7037 that can be used are those defined in the Ada 95 Reference Manual.
7038
7039 @end table
7040
7041 @sp 1
7042 @cartouche
7043 @noindent
7044 @strong{58}.  The consequences of violating limitations on
7045 @code{Restrictions} pragmas.  See 13.12(9).
7046 @end cartouche
7047 @noindent
7048 Restrictions that can be checked at compile time result in illegalities
7049 if violated.  Currently there are no other consequences of violating
7050 restrictions.
7051
7052 @sp 1
7053 @cartouche
7054 @noindent
7055 @strong{59}.  The representation used by the @code{Read} and
7056 @code{Write} attributes of elementary types in terms of stream
7057 elements.  See 13.13.2(9).
7058 @end cartouche
7059 @noindent
7060 The representation is the in-memory representation of the base type of
7061 the type, using the number of bits corresponding to the
7062 @code{@var{type}'Size} value, and the natural ordering of the machine.
7063
7064 @sp 1
7065 @cartouche
7066 @noindent
7067 @strong{60}.  The names and characteristics of the numeric subtypes
7068 declared in the visible part of package @code{Standard}.  See A.1(3).
7069 @end cartouche
7070 @noindent
7071 See items describing the integer and floating-point types supported.
7072
7073 @sp 1
7074 @cartouche
7075 @noindent
7076 @strong{61}.  The accuracy actually achieved by the elementary
7077 functions.  See A.5.1(1).
7078 @end cartouche
7079 @noindent
7080 The elementary functions correspond to the functions available in the C
7081 library.  Only fast math mode is implemented.
7082
7083 @sp 1
7084 @cartouche
7085 @noindent
7086 @strong{62}.  The sign of a zero result from some of the operators or
7087 functions in @code{Numerics.Generic_Elementary_Functions}, when
7088 @code{Float_Type'Signed_Zeros} is @code{True}.  See A.5.1(46).
7089 @end cartouche
7090 @noindent
7091 The sign of zeroes follows the requirements of the IEEE 754 standard on
7092 floating-point.
7093
7094 @sp 1
7095 @cartouche
7096 @noindent
7097 @strong{63}.  The value of
7098 @code{Numerics.Float_Random.Max_Image_Width}.  See A.5.2(27).
7099 @end cartouche
7100 @noindent
7101 Maximum image width is 649, see library file @file{a-numran.ads}.
7102
7103 @sp 1
7104 @cartouche
7105 @noindent
7106 @strong{64}.  The value of
7107 @code{Numerics.Discrete_Random.Max_Image_Width}.  See A.5.2(27).
7108 @end cartouche
7109 @noindent
7110 Maximum image width is 80, see library file @file{a-nudira.ads}.
7111
7112 @sp 1
7113 @cartouche
7114 @noindent
7115 @strong{65}.  The algorithms for random number generation.  See
7116 A.5.2(32).
7117 @end cartouche
7118 @noindent
7119 The algorithm is documented in the source files @file{a-numran.ads} and
7120 @file{a-numran.adb}.
7121
7122 @sp 1
7123 @cartouche
7124 @noindent
7125 @strong{66}.  The string representation of a random number generator's
7126 state.  See A.5.2(38).
7127 @end cartouche
7128 @noindent
7129 See the documentation contained in the file @file{a-numran.adb}.
7130
7131 @sp 1
7132 @cartouche
7133 @noindent
7134 @strong{67}.  The minimum time interval between calls to the
7135 time-dependent Reset procedure that are guaranteed to initiate different
7136 random number sequences.  See A.5.2(45).
7137 @end cartouche
7138 @noindent
7139 The minimum period between reset calls to guarantee distinct series of
7140 random numbers is one microsecond.
7141
7142 @sp 1
7143 @cartouche
7144 @noindent
7145 @strong{68}.  The values of the @code{Model_Mantissa},
7146 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
7147 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
7148 Annex is not supported.  See A.5.3(72).
7149 @end cartouche
7150 @noindent
7151 See the source file @file{ttypef.ads} for the values of all numeric
7152 attributes.
7153
7154 @sp 1
7155 @cartouche
7156 @noindent
7157 @strong{69}.  Any implementation-defined characteristics of the
7158 input-output packages.  See A.7(14).
7159 @end cartouche
7160 @noindent
7161 There are no special implementation defined characteristics for these
7162 packages.
7163
7164 @sp 1
7165 @cartouche
7166 @noindent
7167 @strong{70}.  The value of @code{Buffer_Size} in @code{Storage_IO}.  See
7168 A.9(10).
7169 @end cartouche
7170 @noindent
7171 All type representations are contiguous, and the @code{Buffer_Size} is
7172 the value of @code{@var{type}'Size} rounded up to the next storage unit
7173 boundary.
7174
7175 @sp 1
7176 @cartouche
7177 @noindent
7178 @strong{71}.  External files for standard input, standard output, and
7179 standard error See A.10(5).
7180 @end cartouche
7181 @noindent
7182 These files are mapped onto the files provided by the C streams
7183 libraries.  See source file @file{i-cstrea.ads} for further details.
7184
7185 @sp 1
7186 @cartouche
7187 @noindent
7188 @strong{72}.  The accuracy of the value produced by @code{Put}.  See
7189 A.10.9(36).
7190 @end cartouche
7191 @noindent
7192 If more digits are requested in the output than are represented by the
7193 precision of the value, zeroes are output in the corresponding least
7194 significant digit positions.
7195
7196 @sp 1
7197 @cartouche
7198 @noindent
7199 @strong{73}.  The meaning of @code{Argument_Count}, @code{Argument}, and
7200 @code{Command_Name}.  See A.15(1).
7201 @end cartouche
7202 @noindent
7203 These are mapped onto the @code{argv} and @code{argc} parameters of the
7204 main program in the natural manner.
7205
7206 @sp 1
7207 @cartouche
7208 @noindent
7209 @strong{74}.  Implementation-defined convention names.  See B.1(11).
7210 @end cartouche
7211 @noindent
7212 The following convention names are supported
7213
7214 @table @code
7215 @item  Ada
7216 Ada
7217 @item Assembler
7218 Assembly language
7219 @item Asm
7220 Synonym for Assembler
7221 @item Assembly
7222 Synonym for Assembler
7223 @item C
7224 C
7225 @item C_Pass_By_Copy
7226 Allowed only for record types, like C, but also notes that record
7227 is to be passed by copy rather than reference.
7228 @item COBOL
7229 COBOL
7230 @item CPP
7231 C++
7232 @item Default
7233 Treated the same as C
7234 @item External
7235 Treated the same as C
7236 @item Fortran
7237 Fortran
7238 @item Intrinsic
7239 For support of pragma @code{Import} with convention Intrinsic, see
7240 separate section on Intrinsic Subprograms.
7241 @item Stdcall
7242 Stdcall (used for Windows implementations only).  This convention correspond
7243 to the WINAPI (previously called Pascal convention) C/C++ convention under
7244 Windows.  A function with this convention cleans the stack before exit.
7245 @item DLL
7246 Synonym for Stdcall
7247 @item Win32
7248 Synonym for Stdcall
7249 @item Stubbed
7250 Stubbed is a special convention used to indicate that the body of the
7251 subprogram will be entirely ignored.  Any call to the subprogram
7252 is converted into a raise of the @code{Program_Error} exception.  If a
7253 pragma @code{Import} specifies convention @code{stubbed} then no body need
7254 be present at all.  This convention is useful during development for the
7255 inclusion of subprograms whose body has not yet been written.
7256
7257 @end table
7258 @noindent
7259 In addition, all otherwise unrecognized convention names are also
7260 treated as being synonymous with convention C@.  In all implementations
7261 except for VMS, use of such other names results in a warning.  In VMS
7262 implementations, these names are accepted silently.
7263
7264 @sp 1
7265 @cartouche
7266 @noindent
7267 @strong{75}.  The meaning of link names.  See B.1(36).
7268 @end cartouche
7269 @noindent
7270 Link names are the actual names used by the linker.
7271
7272 @sp 1
7273 @cartouche
7274 @noindent
7275 @strong{76}.  The manner of choosing link names when neither the link
7276 name nor the address of an imported or exported entity is specified.  See
7277 B.1(36).
7278 @end cartouche
7279 @noindent
7280 The default linker name is that which would be assigned by the relevant
7281 external language, interpreting the Ada name as being in all lower case
7282 letters.
7283
7284 @sp 1
7285 @cartouche
7286 @noindent
7287 @strong{77}.  The effect of pragma @code{Linker_Options}.  See B.1(37).
7288 @end cartouche
7289 @noindent
7290 The string passed to @code{Linker_Options} is presented uninterpreted as
7291 an argument to the link command, unless it contains Ascii.NUL characters.
7292 NUL characters if they appear act as argument separators, so for example
7293
7294 @smallexample @c ada
7295 pragma Linker_Options ("-labc" & ASCII.Nul & "-ldef");
7296 @end smallexample
7297
7298 @noindent
7299 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
7300 linker. The order of linker options is preserved for a given unit. The final
7301 list of options passed to the linker is in reverse order of the elaboration
7302 order. For example, linker options fo a body always appear before the options
7303 from the corresponding package spec.
7304
7305 @sp 1
7306 @cartouche
7307 @noindent
7308 @strong{78}.  The contents of the visible part of package
7309 @code{Interfaces} and its language-defined descendants.  See B.2(1).
7310 @end cartouche
7311 @noindent
7312 See files with prefix @file{i-} in the distributed library.
7313
7314 @sp 1
7315 @cartouche
7316 @noindent
7317 @strong{79}.  Implementation-defined children of package
7318 @code{Interfaces}.  The contents of the visible part of package
7319 @code{Interfaces}.  See B.2(11).
7320 @end cartouche
7321 @noindent
7322 See files with prefix @file{i-} in the distributed library.
7323
7324 @sp 1
7325 @cartouche
7326 @noindent
7327 @strong{80}.  The types @code{Floating}, @code{Long_Floating},
7328 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
7329 @code{COBOL_Character}; and the initialization of the variables
7330 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
7331 @code{Interfaces.COBOL}.  See B.4(50).
7332 @end cartouche
7333 @noindent
7334 @table @code
7335 @item Floating
7336 Float
7337 @item Long_Floating
7338 (Floating) Long_Float
7339 @item Binary
7340 Integer
7341 @item Long_Binary
7342 Long_Long_Integer
7343 @item Decimal_Element
7344 Character
7345 @item COBOL_Character
7346 Character
7347 @end table
7348
7349 @noindent
7350 For initialization, see the file @file{i-cobol.ads} in the distributed library.
7351
7352 @sp 1
7353 @cartouche
7354 @noindent
7355 @strong{81}.  Support for access to machine instructions.  See C.1(1).
7356 @end cartouche
7357 @noindent
7358 See documentation in file @file{s-maccod.ads} in the distributed library.
7359
7360 @sp 1
7361 @cartouche
7362 @noindent
7363 @strong{82}.  Implementation-defined aspects of access to machine
7364 operations.  See C.1(9).
7365 @end cartouche
7366 @noindent
7367 See documentation in file @file{s-maccod.ads} in the distributed library.
7368
7369 @sp 1
7370 @cartouche
7371 @noindent
7372 @strong{83}.  Implementation-defined aspects of interrupts.  See C.3(2).
7373 @end cartouche
7374 @noindent
7375 Interrupts are mapped to signals or conditions as appropriate.  See
7376 definition of unit
7377 @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
7378 on the interrupts supported on a particular target.
7379
7380 @sp 1
7381 @cartouche
7382 @noindent
7383 @strong{84}.  Implementation-defined aspects of pre-elaboration.  See
7384 C.4(13).
7385 @end cartouche
7386 @noindent
7387 GNAT does not permit a partition to be restarted without reloading,
7388 except under control of the debugger.
7389
7390 @sp 1
7391 @cartouche
7392 @noindent
7393 @strong{85}.  The semantics of pragma @code{Discard_Names}.  See C.5(7).
7394 @end cartouche
7395 @noindent
7396 Pragma @code{Discard_Names} causes names of enumeration literals to
7397 be suppressed.  In the presence of this pragma, the Image attribute
7398 provides the image of the Pos of the literal, and Value accepts
7399 Pos values.
7400
7401 @sp 1
7402 @cartouche
7403 @noindent
7404 @strong{86}.  The result of the @code{Task_Identification.Image}
7405 attribute.  See C.7.1(7).
7406 @end cartouche
7407 @noindent
7408 The result of this attribute is an 8-digit hexadecimal string
7409 representing the virtual address of the task control block.
7410
7411 @sp 1
7412 @cartouche
7413 @noindent
7414 @strong{87}.  The value of @code{Current_Task} when in a protected entry
7415 or interrupt handler.  See C.7.1(17).
7416 @end cartouche
7417 @noindent
7418 Protected entries or interrupt handlers can be executed by any
7419 convenient thread, so the value of @code{Current_Task} is undefined.
7420
7421 @sp 1
7422 @cartouche
7423 @noindent
7424 @strong{88}.  The effect of calling @code{Current_Task} from an entry
7425 body or interrupt handler.  See C.7.1(19).
7426 @end cartouche
7427 @noindent
7428 The effect of calling @code{Current_Task} from an entry body or
7429 interrupt handler is to return the identification of the task currently
7430 executing the code.
7431
7432 @sp 1
7433 @cartouche
7434 @noindent
7435 @strong{89}.  Implementation-defined aspects of
7436 @code{Task_Attributes}.  See C.7.2(19).
7437 @end cartouche
7438 @noindent
7439 There are no implementation-defined aspects of @code{Task_Attributes}.
7440
7441 @sp 1
7442 @cartouche
7443 @noindent
7444 @strong{90}.  Values of all @code{Metrics}.  See D(2).
7445 @end cartouche
7446 @noindent
7447 The metrics information for GNAT depends on the performance of the
7448 underlying operating system.  The sources of the run-time for tasking
7449 implementation, together with the output from @code{-gnatG} can be
7450 used to determine the exact sequence of operating systems calls made
7451 to implement various tasking constructs.  Together with appropriate
7452 information on the performance of the underlying operating system,
7453 on the exact target in use, this information can be used to determine
7454 the required metrics.
7455
7456 @sp 1
7457 @cartouche
7458 @noindent
7459 @strong{91}.  The declarations of @code{Any_Priority} and
7460 @code{Priority}.  See D.1(11).
7461 @end cartouche
7462 @noindent
7463 See declarations in file @file{system.ads}.
7464
7465 @sp 1
7466 @cartouche
7467 @noindent
7468 @strong{92}.  Implementation-defined execution resources.  See D.1(15).
7469 @end cartouche
7470 @noindent
7471 There are no implementation-defined execution resources.
7472
7473 @sp 1
7474 @cartouche
7475 @noindent
7476 @strong{93}.  Whether, on a multiprocessor, a task that is waiting for
7477 access to a protected object keeps its processor busy.  See D.2.1(3).
7478 @end cartouche
7479 @noindent
7480 On a multi-processor, a task that is waiting for access to a protected
7481 object does not keep its processor busy.
7482
7483 @sp 1
7484 @cartouche
7485 @noindent
7486 @strong{94}.  The affect of implementation defined execution resources
7487 on task dispatching.  See D.2.1(9).
7488 @end cartouche
7489 @noindent
7490 @c SGI info
7491 @ignore
7492 Tasks map to IRIX threads, and the dispatching policy is as defined by
7493 the IRIX implementation of threads.
7494 @end ignore
7495 Tasks map to threads in the threads package used by GNAT@.  Where possible
7496 and appropriate, these threads correspond to native threads of the
7497 underlying operating system.
7498
7499 @sp 1
7500 @cartouche
7501 @noindent
7502 @strong{95}.  Implementation-defined @code{policy_identifiers} allowed
7503 in a pragma @code{Task_Dispatching_Policy}.  See D.2.2(3).
7504 @end cartouche
7505 @noindent
7506 There are no implementation-defined policy-identifiers allowed in this
7507 pragma.
7508
7509 @sp 1
7510 @cartouche
7511 @noindent
7512 @strong{96}.  Implementation-defined aspects of priority inversion.  See
7513 D.2.2(16).
7514 @end cartouche
7515 @noindent
7516 Execution of a task cannot be preempted by the implementation processing
7517 of delay expirations for lower priority tasks.
7518
7519 @sp 1
7520 @cartouche
7521 @noindent
7522 @strong{97}.  Implementation defined task dispatching.  See D.2.2(18).
7523 @end cartouche
7524 @noindent
7525 @c SGI info:
7526 @ignore
7527 Tasks map to IRIX threads, and the dispatching policy is as defied by
7528 the IRIX implementation of threads.
7529 @end ignore
7530 The policy is the same as that of the underlying threads implementation.
7531
7532 @sp 1
7533 @cartouche
7534 @noindent
7535 @strong{98}.  Implementation-defined @code{policy_identifiers} allowed
7536 in a pragma @code{Locking_Policy}.  See D.3(4).
7537 @end cartouche
7538 @noindent
7539 The only implementation defined policy permitted in GNAT is
7540 @code{Inheritance_Locking}.  On targets that support this policy, locking
7541 is implemented by inheritance, i.e.@: the task owning the lock operates
7542 at a priority equal to the highest priority of any task currently
7543 requesting the lock.
7544
7545 @sp 1
7546 @cartouche
7547 @noindent
7548 @strong{99}.  Default ceiling priorities.  See D.3(10).
7549 @end cartouche
7550 @noindent
7551 The ceiling priority of protected objects of the type
7552 @code{System.Interrupt_Priority'Last} as described in the Ada 95
7553 Reference Manual D.3(10),
7554
7555 @sp 1
7556 @cartouche
7557 @noindent
7558 @strong{100}.  The ceiling of any protected object used internally by
7559 the implementation.  See D.3(16).
7560 @end cartouche
7561 @noindent
7562 The ceiling priority of internal protected objects is
7563 @code{System.Priority'Last}.
7564
7565 @sp 1
7566 @cartouche
7567 @noindent
7568 @strong{101}.  Implementation-defined queuing policies.  See D.4(1).
7569 @end cartouche
7570 @noindent
7571 There are no implementation-defined queueing policies.
7572
7573 @sp 1
7574 @cartouche
7575 @noindent
7576 @strong{102}.  On a multiprocessor, any conditions that cause the
7577 completion of an aborted construct to be delayed later than what is
7578 specified for a single processor.  See D.6(3).
7579 @end cartouche
7580 @noindent
7581 The semantics for abort on a multi-processor is the same as on a single
7582 processor, there are no further delays.
7583
7584 @sp 1
7585 @cartouche
7586 @noindent
7587 @strong{103}.  Any operations that implicitly require heap storage
7588 allocation.  See D.7(8).
7589 @end cartouche
7590 @noindent
7591 The only operation that implicitly requires heap storage allocation is
7592 task creation.
7593
7594 @sp 1
7595 @cartouche
7596 @noindent
7597 @strong{104}.  Implementation-defined aspects of pragma
7598 @code{Restrictions}.  See D.7(20).
7599 @end cartouche
7600 @noindent
7601 There are no such implementation-defined aspects.
7602
7603 @sp 1
7604 @cartouche
7605 @noindent
7606 @strong{105}.  Implementation-defined aspects of package
7607 @code{Real_Time}.  See D.8(17).
7608 @end cartouche
7609 @noindent
7610 There are no implementation defined aspects of package @code{Real_Time}.
7611
7612 @sp 1
7613 @cartouche
7614 @noindent
7615 @strong{106}.  Implementation-defined aspects of
7616 @code{delay_statements}.  See D.9(8).
7617 @end cartouche
7618 @noindent
7619 Any difference greater than one microsecond will cause the task to be
7620 delayed (see D.9(7)).
7621
7622 @sp 1
7623 @cartouche
7624 @noindent
7625 @strong{107}.  The upper bound on the duration of interrupt blocking
7626 caused by the implementation.  See D.12(5).
7627 @end cartouche
7628 @noindent
7629 The upper bound is determined by the underlying operating system.  In
7630 no cases is it more than 10 milliseconds.
7631
7632 @sp 1
7633 @cartouche
7634 @noindent
7635 @strong{108}.  The means for creating and executing distributed
7636 programs.  See E(5).
7637 @end cartouche
7638 @noindent
7639 The GLADE package provides a utility GNATDIST for creating and executing
7640 distributed programs.  See the GLADE reference manual for further details.
7641
7642 @sp 1
7643 @cartouche
7644 @noindent
7645 @strong{109}.  Any events that can result in a partition becoming
7646 inaccessible.  See E.1(7).
7647 @end cartouche
7648 @noindent
7649 See the GLADE reference manual for full details on such events.
7650
7651 @sp 1
7652 @cartouche
7653 @noindent
7654 @strong{110}.  The scheduling policies, treatment of priorities, and
7655 management of shared resources between partitions in certain cases.  See
7656 E.1(11).
7657 @end cartouche
7658 @noindent
7659 See the GLADE reference manual for full details on these aspects of
7660 multi-partition execution.
7661
7662 @sp 1
7663 @cartouche
7664 @noindent
7665 @strong{111}.  Events that cause the version of a compilation unit to
7666 change.  See E.3(5).
7667 @end cartouche
7668 @noindent
7669 Editing the source file of a compilation unit, or the source files of
7670 any units on which it is dependent in a significant way cause the version
7671 to change.  No other actions cause the version number to change.  All changes
7672 are significant except those which affect only layout, capitalization or
7673 comments.
7674
7675 @sp 1
7676 @cartouche
7677 @noindent
7678 @strong{112}.  Whether the execution of the remote subprogram is
7679 immediately aborted as a result of cancellation.  See E.4(13).
7680 @end cartouche
7681 @noindent
7682 See the GLADE reference manual for details on the effect of abort in
7683 a distributed application.
7684
7685 @sp 1
7686 @cartouche
7687 @noindent
7688 @strong{113}.  Implementation-defined aspects of the PCS@.  See E.5(25).
7689 @end cartouche
7690 @noindent
7691 See the GLADE reference manual for a full description of all implementation
7692 defined aspects of the PCS@.
7693
7694 @sp 1
7695 @cartouche
7696 @noindent
7697 @strong{114}.  Implementation-defined interfaces in the PCS@.  See
7698 E.5(26).
7699 @end cartouche
7700 @noindent
7701 See the GLADE reference manual for a full description of all
7702 implementation defined interfaces.
7703
7704 @sp 1
7705 @cartouche
7706 @noindent
7707 @strong{115}.  The values of named numbers in the package
7708 @code{Decimal}.  See F.2(7).
7709 @end cartouche
7710 @noindent
7711 @table @code
7712 @item Max_Scale
7713 +18
7714 @item Min_Scale
7715 -18
7716 @item Min_Delta
7717 1.0E-18
7718 @item Max_Delta
7719 1.0E+18
7720 @item Max_Decimal_Digits
7721 18
7722 @end table
7723
7724 @sp 1
7725 @cartouche
7726 @noindent
7727 @strong{116}.  The value of @code{Max_Picture_Length} in the package
7728 @code{Text_IO.Editing}.  See F.3.3(16).
7729 @end cartouche
7730 @noindent
7731 64
7732
7733 @sp 1
7734 @cartouche
7735 @noindent
7736 @strong{117}.  The value of @code{Max_Picture_Length} in the package
7737 @code{Wide_Text_IO.Editing}.  See F.3.4(5).
7738 @end cartouche
7739 @noindent
7740 64
7741
7742 @sp 1
7743 @cartouche
7744 @noindent
7745 @strong{118}.  The accuracy actually achieved by the complex elementary
7746 functions and by other complex arithmetic operations.  See G.1(1).
7747 @end cartouche
7748 @noindent
7749 Standard library functions are used for the complex arithmetic
7750 operations.  Only fast math mode is currently supported.
7751
7752 @sp 1
7753 @cartouche
7754 @noindent
7755 @strong{119}.  The sign of a zero result (or a component thereof) from
7756 any operator or function in @code{Numerics.Generic_Complex_Types}, when
7757 @code{Real'Signed_Zeros} is True.  See G.1.1(53).
7758 @end cartouche
7759 @noindent
7760 The signs of zero values are as recommended by the relevant
7761 implementation advice.
7762
7763 @sp 1
7764 @cartouche
7765 @noindent
7766 @strong{120}.  The sign of a zero result (or a component thereof) from
7767 any operator or function in
7768 @code{Numerics.Generic_Complex_Elementary_Functions}, when
7769 @code{Real'Signed_Zeros} is @code{True}.  See G.1.2(45).
7770 @end cartouche
7771 @noindent
7772 The signs of zero values are as recommended by the relevant
7773 implementation advice.
7774
7775 @sp 1
7776 @cartouche
7777 @noindent
7778 @strong{121}.  Whether the strict mode or the relaxed mode is the
7779 default.  See G.2(2).
7780 @end cartouche
7781 @noindent
7782 The strict mode is the default.  There is no separate relaxed mode.  GNAT
7783 provides a highly efficient implementation of strict mode.
7784
7785 @sp 1
7786 @cartouche
7787 @noindent
7788 @strong{122}.  The result interval in certain cases of fixed-to-float
7789 conversion.  See G.2.1(10).
7790 @end cartouche
7791 @noindent
7792 For cases where the result interval is implementation dependent, the
7793 accuracy is that provided by performing all operations in 64-bit IEEE
7794 floating-point format.
7795
7796 @sp 1
7797 @cartouche
7798 @noindent
7799 @strong{123}.  The result of a floating point arithmetic operation in
7800 overflow situations, when the @code{Machine_Overflows} attribute of the
7801 result type is @code{False}.  See G.2.1(13).
7802 @end cartouche
7803 @noindent
7804 Infinite and Nan values are produced as dictated by the IEEE
7805 floating-point standard.
7806
7807 @sp 1
7808 @cartouche
7809 @noindent
7810 @strong{124}.  The result interval for division (or exponentiation by a
7811 negative exponent), when the floating point hardware implements division
7812 as multiplication by a reciprocal.  See G.2.1(16).
7813 @end cartouche
7814 @noindent
7815 Not relevant, division is IEEE exact.
7816
7817 @sp 1
7818 @cartouche
7819 @noindent
7820 @strong{125}.  The definition of close result set, which determines the
7821 accuracy of certain fixed point multiplications and divisions.  See
7822 G.2.3(5).
7823 @end cartouche
7824 @noindent
7825 Operations in the close result set are performed using IEEE long format
7826 floating-point arithmetic.  The input operands are converted to
7827 floating-point, the operation is done in floating-point, and the result
7828 is converted to the target type.
7829
7830 @sp 1
7831 @cartouche
7832 @noindent
7833 @strong{126}.  Conditions on a @code{universal_real} operand of a fixed
7834 point multiplication or division for which the result shall be in the
7835 perfect result set.  See G.2.3(22).
7836 @end cartouche
7837 @noindent
7838 The result is only defined to be in the perfect result set if the result
7839 can be computed by a single scaling operation involving a scale factor
7840 representable in 64-bits.
7841
7842 @sp 1
7843 @cartouche
7844 @noindent
7845 @strong{127}.  The result of a fixed point arithmetic operation in
7846 overflow situations, when the @code{Machine_Overflows} attribute of the
7847 result type is @code{False}.  See G.2.3(27).
7848 @end cartouche
7849 @noindent
7850 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
7851 types.
7852
7853 @sp 1
7854 @cartouche
7855 @noindent
7856 @strong{128}.  The result of an elementary function reference in
7857 overflow situations, when the @code{Machine_Overflows} attribute of the
7858 result type is @code{False}.  See G.2.4(4).
7859 @end cartouche
7860 @noindent
7861 IEEE infinite and Nan values are produced as appropriate.
7862
7863 @sp 1
7864 @cartouche
7865 @noindent
7866 @strong{129}.  The value of the angle threshold, within which certain
7867 elementary functions, complex arithmetic operations, and complex
7868 elementary functions yield results conforming to a maximum relative
7869 error bound.  See G.2.4(10).
7870 @end cartouche
7871 @noindent
7872 Information on this subject is not yet available.
7873
7874 @sp 1
7875 @cartouche
7876 @noindent
7877 @strong{130}.  The accuracy of certain elementary functions for
7878 parameters beyond the angle threshold.  See G.2.4(10).
7879 @end cartouche
7880 @noindent
7881 Information on this subject is not yet available.
7882
7883 @sp 1
7884 @cartouche
7885 @noindent
7886 @strong{131}.  The result of a complex arithmetic operation or complex
7887 elementary function reference in overflow situations, when the
7888 @code{Machine_Overflows} attribute of the corresponding real type is
7889 @code{False}.  See G.2.6(5).
7890 @end cartouche
7891 @noindent
7892 IEEE infinite and Nan values are produced as appropriate.
7893
7894 @sp 1
7895 @cartouche
7896 @noindent
7897 @strong{132}.  The accuracy of certain complex arithmetic operations and
7898 certain complex elementary functions for parameters (or components
7899 thereof) beyond the angle threshold.  See G.2.6(8).
7900 @end cartouche
7901 @noindent
7902 Information on those subjects is not yet available.
7903
7904 @sp 1
7905 @cartouche
7906 @noindent
7907 @strong{133}.  Information regarding bounded errors and erroneous
7908 execution.  See H.2(1).
7909 @end cartouche
7910 @noindent
7911 Information on this subject is not yet available.
7912
7913 @sp 1
7914 @cartouche
7915 @noindent
7916 @strong{134}.  Implementation-defined aspects of pragma
7917 @code{Inspection_Point}.  See H.3.2(8).
7918 @end cartouche
7919 @noindent
7920 Pragma @code{Inspection_Point} ensures that the variable is live and can
7921 be examined by the debugger at the inspection point.
7922
7923 @sp 1
7924 @cartouche
7925 @noindent
7926 @strong{135}.  Implementation-defined aspects of pragma
7927 @code{Restrictions}.  See H.4(25).
7928 @end cartouche
7929 @noindent
7930 There are no implementation-defined aspects of pragma @code{Restrictions}.  The
7931 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
7932 generated code.  Checks must suppressed by use of pragma @code{Suppress}.
7933
7934 @sp 1
7935 @cartouche
7936 @noindent
7937 @strong{136}.  Any restrictions on pragma @code{Restrictions}.  See
7938 H.4(27).
7939 @end cartouche
7940 @noindent
7941 There are no restrictions on pragma @code{Restrictions}.
7942
7943 @node Intrinsic Subprograms
7944 @chapter Intrinsic Subprograms
7945 @cindex Intrinsic Subprograms
7946
7947 @menu
7948 * Intrinsic Operators::
7949 * Enclosing_Entity::
7950 * Exception_Information::
7951 * Exception_Message::
7952 * Exception_Name::
7953 * File::
7954 * Line::
7955 * Rotate_Left::
7956 * Rotate_Right::
7957 * Shift_Left::
7958 * Shift_Right::
7959 * Shift_Right_Arithmetic::
7960 * Source_Location::
7961 @end menu
7962
7963 @noindent
7964 GNAT allows a user application program to write the declaration:
7965
7966 @smallexample @c ada
7967    pragma Import (Intrinsic, name);
7968 @end smallexample
7969
7970 @noindent
7971 providing that the name corresponds to one of the implemented intrinsic
7972 subprograms in GNAT, and that the parameter profile of the referenced
7973 subprogram meets the requirements.  This chapter describes the set of
7974 implemented intrinsic subprograms, and the requirements on parameter profiles.
7975 Note that no body is supplied; as with other uses of pragma Import, the
7976 body is supplied elsewhere (in this case by the compiler itself).  Note
7977 that any use of this feature is potentially non-portable, since the
7978 Ada standard does not require Ada compilers to implement this feature.
7979
7980 @node Intrinsic Operators
7981 @section Intrinsic Operators
7982 @cindex Intrinsic operator
7983
7984 @noindent
7985 All the predefined numeric operators in package Standard
7986 in @code{pragma Import (Intrinsic,..)}
7987 declarations.  In the binary operator case, the operands must have the same
7988 size.  The operand or operands must also be appropriate for
7989 the operator.  For example, for addition, the operands must
7990 both be floating-point or both be fixed-point, and the
7991 right operand for @code{"**"} must have a root type of
7992 @code{Standard.Integer'Base}.
7993 You can use an intrinsic operator declaration as in the following example:
7994
7995 @smallexample @c ada
7996    type Int1 is new Integer;
7997    type Int2 is new Integer;
7998
7999    function "+" (X1 : Int1; X2 : Int2) return Int1;
8000    function "+" (X1 : Int1; X2 : Int2) return Int2;
8001    pragma Import (Intrinsic, "+");
8002 @end smallexample
8003
8004 @noindent
8005 This declaration would permit ``mixed mode'' arithmetic on items
8006 of the differing types @code{Int1} and @code{Int2}.
8007 It is also possible to specify such operators for private types, if the
8008 full views are appropriate arithmetic types.
8009
8010 @node Enclosing_Entity
8011 @section Enclosing_Entity
8012 @cindex Enclosing_Entity
8013 @noindent
8014 This intrinsic subprogram is used in the implementation of the
8015 library routine @code{GNAT.Source_Info}.  The only useful use of the
8016 intrinsic import in this case is the one in this unit, so an
8017 application program should simply call the function
8018 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
8019 the current subprogram, package, task, entry, or protected subprogram.
8020
8021 @node Exception_Information
8022 @section Exception_Information
8023 @cindex Exception_Information'
8024 @noindent
8025 This intrinsic subprogram is used in the implementation of the
8026 library routine @code{GNAT.Current_Exception}.  The only useful
8027 use of the intrinsic import in this case is the one in this unit,
8028 so an application program should simply call the function
8029 @code{GNAT.Current_Exception.Exception_Information} to obtain
8030 the exception information associated with the current exception.
8031
8032 @node Exception_Message
8033 @section Exception_Message
8034 @cindex Exception_Message
8035 @noindent
8036 This intrinsic subprogram is used in the implementation of the
8037 library routine @code{GNAT.Current_Exception}.  The only useful
8038 use of the intrinsic import in this case is the one in this unit,
8039 so an application program should simply call the function
8040 @code{GNAT.Current_Exception.Exception_Message} to obtain
8041 the message associated with the current exception.
8042
8043 @node Exception_Name
8044 @section Exception_Name
8045 @cindex Exception_Name
8046 @noindent
8047 This intrinsic subprogram is used in the implementation of the
8048 library routine @code{GNAT.Current_Exception}.  The only useful
8049 use of the intrinsic import in this case is the one in this unit,
8050 so an application program should simply call the function
8051 @code{GNAT.Current_Exception.Exception_Name} to obtain
8052 the name of the current exception.
8053
8054 @node File
8055 @section File
8056 @cindex File
8057 @noindent
8058 This intrinsic subprogram is used in the implementation of the
8059 library routine @code{GNAT.Source_Info}.  The only useful use of the
8060 intrinsic import in this case is the one in this unit, so an
8061 application program should simply call the function
8062 @code{GNAT.Source_Info.File} to obtain the name of the current
8063 file.
8064
8065 @node Line
8066 @section Line
8067 @cindex Line
8068 @noindent
8069 This intrinsic subprogram is used in the implementation of the
8070 library routine @code{GNAT.Source_Info}.  The only useful use of the
8071 intrinsic import in this case is the one in this unit, so an
8072 application program should simply call the function
8073 @code{GNAT.Source_Info.Line} to obtain the number of the current
8074 source line.
8075
8076 @node Rotate_Left
8077 @section Rotate_Left
8078 @cindex Rotate_Left
8079 @noindent
8080 In standard Ada 95, the @code{Rotate_Left} function is available only
8081 for the predefined modular types in package @code{Interfaces}.  However, in
8082 GNAT it is possible to define a Rotate_Left function for a user
8083 defined modular type or any signed integer type as in this example:
8084
8085 @smallexample @c ada
8086    function Shift_Left
8087      (Value  : My_Modular_Type;
8088       Amount : Natural)
8089       return   My_Modular_Type;
8090 @end smallexample
8091
8092 @noindent
8093 The requirements are that the profile be exactly as in the example
8094 above.  The only modifications allowed are in the formal parameter
8095 names, and in the type of @code{Value} and the return type, which
8096 must be the same, and must be either a signed integer type, or
8097 a modular integer type with a binary modulus, and the size must
8098 be 8.  16, 32 or 64 bits.
8099
8100 @node Rotate_Right
8101 @section Rotate_Right
8102 @cindex Rotate_Right
8103 @noindent
8104 A @code{Rotate_Right} function can be defined for any user defined
8105 binary modular integer type, or signed integer type, as described
8106 above for @code{Rotate_Left}.
8107
8108 @node Shift_Left
8109 @section Shift_Left
8110 @cindex Shift_Left
8111 @noindent
8112 A @code{Shift_Left} function can be defined for any user defined
8113 binary modular integer type, or signed integer type, as described
8114 above for @code{Rotate_Left}.
8115
8116 @node Shift_Right
8117 @section Shift_Right
8118 @cindex Shift_Right
8119 @noindent
8120 A @code{Shift_Right} function can be defined for any user defined
8121 binary modular integer type, or signed integer type, as described
8122 above for @code{Rotate_Left}.
8123
8124 @node Shift_Right_Arithmetic
8125 @section Shift_Right_Arithmetic
8126 @cindex Shift_Right_Arithmetic
8127 @noindent
8128 A @code{Shift_Right_Arithmetic} function can be defined for any user
8129 defined binary modular integer type, or signed integer type, as described
8130 above for @code{Rotate_Left}.
8131
8132 @node Source_Location
8133 @section Source_Location
8134 @cindex Source_Location
8135 @noindent
8136 This intrinsic subprogram is used in the implementation of the
8137 library routine @code{GNAT.Source_Info}.  The only useful use of the
8138 intrinsic import in this case is the one in this unit, so an
8139 application program should simply call the function
8140 @code{GNAT.Source_Info.Source_Location} to obtain the current
8141 source file location.
8142
8143 @node Representation Clauses and Pragmas
8144 @chapter Representation Clauses and Pragmas
8145 @cindex Representation Clauses
8146
8147 @menu
8148 * Alignment Clauses::
8149 * Size Clauses::
8150 * Storage_Size Clauses::
8151 * Size of Variant Record Objects::
8152 * Biased Representation ::
8153 * Value_Size and Object_Size Clauses::
8154 * Component_Size Clauses::
8155 * Bit_Order Clauses::
8156 * Effect of Bit_Order on Byte Ordering::
8157 * Pragma Pack for Arrays::
8158 * Pragma Pack for Records::
8159 * Record Representation Clauses::
8160 * Enumeration Clauses::
8161 * Address Clauses::
8162 * Effect of Convention on Representation::
8163 * Determining the Representations chosen by GNAT::
8164 @end menu
8165
8166 @noindent
8167 @cindex Representation Clause
8168 @cindex Representation Pragma
8169 @cindex Pragma, representation
8170 This section describes the representation clauses accepted by GNAT, and
8171 their effect on the representation of corresponding data objects.
8172
8173 GNAT fully implements Annex C (Systems Programming).  This means that all
8174 the implementation advice sections in chapter 13 are fully implemented.
8175 However, these sections only require a minimal level of support for
8176 representation clauses.  GNAT provides much more extensive capabilities,
8177 and this section describes the additional capabilities provided.
8178
8179 @node Alignment Clauses
8180 @section Alignment Clauses
8181 @cindex Alignment Clause
8182
8183 @noindent
8184 GNAT requires that all alignment clauses specify a power of 2, and all
8185 default alignments are always a power of 2.  The default alignment
8186 values are as follows:
8187
8188 @itemize @bullet
8189 @item @emph{Primitive Types}.
8190 For primitive types, the alignment is the minimum of the actual size of
8191 objects of the type divided by @code{Storage_Unit},
8192 and the maximum alignment supported by the target.
8193 (This maximum alignment is given by the GNAT-specific attribute
8194 @code{Standard'Maximum_Alignment}; see @ref{Maximum_Alignment}.)
8195 @cindex @code{Maximum_Alignment} attribute
8196 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
8197 default alignment will be 8 on any target that supports alignments
8198 this large, but on some targets, the maximum alignment may be smaller
8199 than 8, in which case objects of type @code{Long_Float} will be maximally
8200 aligned.
8201
8202 @item @emph{Arrays}.
8203 For arrays, the alignment is equal to the alignment of the component type
8204 for the normal case where no packing or component size is given.  If the
8205 array is packed, and the packing is effective (see separate section on
8206 packed arrays), then the alignment will be one for long packed arrays,
8207 or arrays whose length is not known at compile time.  For short packed
8208 arrays, which are handled internally as modular types, the alignment
8209 will be as described for primitive types, e.g.@: a packed array of length
8210 31 bits will have an object size of four bytes, and an alignment of 4.
8211
8212 @item @emph{Records}.
8213 For the normal non-packed case, the alignment of a record is equal to
8214 the maximum alignment of any of its components.  For tagged records, this
8215 includes the implicit access type used for the tag.  If a pragma @code{Pack} is
8216 used and all fields are packable (see separate section on pragma @code{Pack}),
8217 then the resulting alignment is 1.
8218
8219 A special case is when:
8220 @itemize @bullet
8221 @item
8222 the size of the record is given explicitly, or a
8223 full record representation clause is given, and
8224 @item
8225 the size of the record is 2, 4, or 8 bytes.
8226 @end itemize
8227 @noindent
8228 In this case, an alignment is chosen to match the
8229 size of the record. For example, if we have:
8230
8231 @smallexample @c ada
8232    type Small is record
8233       A, B : Character;
8234    end record;
8235    for Small'Size use 16;
8236 @end smallexample
8237
8238 @noindent
8239 then the default alignment of the record type @code{Small} is 2, not 1. This
8240 leads to more efficient code when the record is treated as a unit, and also
8241 allows the type to specified as @code{Atomic} on architectures requiring
8242 strict alignment.
8243
8244 @end itemize
8245
8246 @noindent
8247 An alignment clause may
8248 always specify a larger alignment than the default value, up to some
8249 maximum value dependent on the target (obtainable by using the
8250 attribute reference @code{Standard'Maximum_Alignment}).
8251 The only case where
8252 it is permissible to specify a smaller alignment than the default value
8253 is for a record with a record representation clause.
8254 In this case, packable fields for which a component clause is
8255 given still result in a default alignment corresponding to the original
8256 type, but this may be overridden, since these components in fact only
8257 require an alignment of one byte.  For example, given
8258
8259 @smallexample @c ada
8260   type V is record
8261      A : Integer;
8262   end record;
8263
8264   for V use record
8265      A at 0  range 0 .. 31;
8266   end record;
8267
8268   for V'alignment use 1;
8269 @end smallexample
8270
8271 @noindent
8272 @cindex Alignment, default
8273 The default alignment for the type @code{V} is 4, as a result of the
8274 Integer field in the record, but since this field is placed with a
8275 component clause, it is permissible, as shown, to override the default
8276 alignment of the record with a smaller value.
8277
8278 @node Size Clauses
8279 @section Size Clauses
8280 @cindex Size Clause
8281
8282 @noindent
8283 The default size for a type @code{T} is obtainable through the
8284 language-defined attribute @code{T'Size} and also through the
8285 equivalent GNAT-defined attribute @code{T'Value_Size}.
8286 For objects of type @code{T}, GNAT will generally increase the type size
8287 so that the object size (obtainable through the GNAT-defined attribute
8288 @code{T'Object_Size})
8289 is a multiple of @code{T'Alignment * Storage_Unit}.
8290 For example
8291
8292 @smallexample @c ada
8293    type Smallint is range 1 .. 6;
8294
8295    type Rec is record
8296       Y1 : integer;
8297       Y2 : boolean;
8298    end record;
8299 @end smallexample
8300
8301 @noindent
8302 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
8303 as specified by the RM rules,
8304 but objects of this type will have a size of 8
8305 (@code{Smallint'Object_Size} = 8),
8306 since objects by default occupy an integral number
8307 of storage units.  On some targets, notably older
8308 versions of the Digital Alpha, the size of stand
8309 alone objects of this type may be 32, reflecting
8310 the inability of the hardware to do byte load/stores.
8311
8312 Similarly, the size of type @code{Rec} is 40 bits
8313 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
8314 the alignment is 4, so objects of this type will have
8315 their size increased to 64 bits so that it is a multiple
8316 of the alignment (in bits).  The reason for this decision, which is
8317 in accordance with the specific Implementation Advice in RM 13.3(43):
8318
8319 @quotation
8320 A @code{Size} clause should be supported for an object if the specified
8321 @code{Size} is at least as large as its subtype's @code{Size}, and corresponds
8322 to a size in storage elements that is a multiple of the object's
8323 @code{Alignment} (if the @code{Alignment} is nonzero).
8324 @end quotation
8325
8326 @noindent
8327 An explicit size clause may be used to override the default size by
8328 increasing it.  For example, if we have:
8329
8330 @smallexample @c ada
8331    type My_Boolean is new Boolean;
8332    for My_Boolean'Size use 32;
8333 @end smallexample
8334
8335 @noindent
8336 then values of this type will always be 32 bits long.  In the case of
8337 discrete types, the size can be increased up to 64 bits, with the effect
8338 that the entire specified field is used to hold the value, sign- or
8339 zero-extended as appropriate.  If more than 64 bits is specified, then
8340 padding space is allocated after the value, and a warning is issued that
8341 there are unused bits.
8342
8343 Similarly the size of records and arrays may be increased, and the effect
8344 is to add padding bits after the value.  This also causes a warning message
8345 to be generated.
8346
8347 The largest Size value permitted in GNAT is 2**31@minus{}1.  Since this is a
8348 Size in bits, this corresponds to an object of size 256 megabytes (minus
8349 one).  This limitation is true on all targets.  The reason for this
8350 limitation is that it improves the quality of the code in many cases
8351 if it is known that a Size value can be accommodated in an object of
8352 type Integer.
8353
8354 @node Storage_Size Clauses
8355 @section Storage_Size Clauses
8356 @cindex Storage_Size Clause
8357
8358 @noindent
8359 For tasks, the @code{Storage_Size} clause specifies the amount of space
8360 to be allocated for the task stack.  This cannot be extended, and if the
8361 stack is exhausted, then @code{Storage_Error} will be raised (if stack
8362 checking is enabled).  Use a @code{Storage_Size} attribute definition clause,
8363 or a @code{Storage_Size} pragma in the task definition to set the
8364 appropriate required size.  A useful technique is to include in every
8365 task definition a pragma of the form:
8366
8367 @smallexample @c ada
8368    pragma Storage_Size (Default_Stack_Size);
8369 @end smallexample
8370
8371 @noindent
8372 Then @code{Default_Stack_Size} can be defined in a global package, and
8373 modified as required.  Any tasks requiring stack sizes different from the
8374 default can have an appropriate alternative reference in the pragma.
8375
8376 For access types, the @code{Storage_Size} clause specifies the maximum
8377 space available for allocation of objects of the type.  If this space is
8378 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
8379 In the case where the access type is declared local to a subprogram, the
8380 use of a @code{Storage_Size} clause triggers automatic use of a special
8381 predefined storage pool (@code{System.Pool_Size}) that ensures that all
8382 space for the pool is automatically reclaimed on exit from the scope in
8383 which the type is declared.
8384
8385 A special case recognized by the compiler is the specification of a
8386 @code{Storage_Size} of zero for an access type.  This means that no
8387 items can be allocated from the pool, and this is recognized at compile
8388 time, and all the overhead normally associated with maintaining a fixed
8389 size storage pool is eliminated.  Consider the following example:
8390
8391 @smallexample @c ada
8392    procedure p is
8393       type R is array (Natural) of Character;
8394       type P is access all R;
8395       for P'Storage_Size use 0;
8396       --  Above access type intended only for interfacing purposes
8397
8398       y : P;
8399
8400       procedure g (m : P);
8401       pragma Import (C, g);
8402
8403       --  @dots{}
8404
8405    begin
8406       --  @dots{}
8407       y := new R;
8408    end;
8409 @end smallexample
8410
8411 @noindent
8412 As indicated in this example, these dummy storage pools are often useful in
8413 connection with interfacing where no object will ever be allocated.  If you
8414 compile the above example, you get the warning:
8415
8416 @smallexample
8417    p.adb:16:09: warning: allocation from empty storage pool
8418    p.adb:16:09: warning: Storage_Error will be raised at run time
8419 @end smallexample
8420
8421 @noindent
8422 Of course in practice, there will not be any explicit allocators in the
8423 case of such an access declaration.
8424
8425 @node Size of Variant Record Objects
8426 @section Size of Variant Record Objects
8427 @cindex Size, variant record objects
8428 @cindex Variant record objects, size
8429
8430 @noindent
8431 In the case of variant record objects, there is a question whether Size gives
8432 information about a particular variant, or the maximum size required
8433 for any variant.  Consider the following program
8434
8435 @smallexample @c ada
8436 with Text_IO; use Text_IO;
8437 procedure q is
8438    type R1 (A : Boolean := False) is record
8439      case A is
8440        when True  => X : Character;
8441        when False => null;
8442      end case;
8443    end record;
8444
8445    V1 : R1 (False);
8446    V2 : R1;
8447
8448 begin
8449    Put_Line (Integer'Image (V1'Size));
8450    Put_Line (Integer'Image (V2'Size));
8451 end q;
8452 @end smallexample
8453
8454 @noindent
8455 Here we are dealing with a variant record, where the True variant
8456 requires 16 bits, and the False variant requires 8 bits.
8457 In the above example, both V1 and V2 contain the False variant,
8458 which is only 8 bits long.  However, the result of running the
8459 program is:
8460
8461 @smallexample
8462 8
8463 16
8464 @end smallexample
8465
8466 @noindent
8467 The reason for the difference here is that the discriminant value of
8468 V1 is fixed, and will always be False.  It is not possible to assign
8469 a True variant value to V1, therefore 8 bits is sufficient.  On the
8470 other hand, in the case of V2, the initial discriminant value is
8471 False (from the default), but it is possible to assign a True
8472 variant value to V2, therefore 16 bits must be allocated for V2
8473 in the general case, even fewer bits may be needed at any particular
8474 point during the program execution.
8475
8476 As can be seen from the output of this program, the @code{'Size}
8477 attribute applied to such an object in GNAT gives the actual allocated
8478 size of the variable, which is the largest size of any of the variants.
8479 The Ada Reference Manual is not completely clear on what choice should
8480 be made here, but the GNAT behavior seems most consistent with the
8481 language in the RM@.
8482
8483 In some cases, it may be desirable to obtain the size of the current
8484 variant, rather than the size of the largest variant.  This can be
8485 achieved in GNAT by making use of the fact that in the case of a
8486 subprogram parameter, GNAT does indeed return the size of the current
8487 variant (because a subprogram has no way of knowing how much space
8488 is actually allocated for the actual).
8489
8490 Consider the following modified version of the above program:
8491
8492 @smallexample @c ada
8493 with Text_IO; use Text_IO;
8494 procedure q is
8495    type R1 (A : Boolean := False) is record
8496      case A is
8497        when True  => X : Character;
8498        when False => null;
8499      end case;
8500    end record;
8501
8502    V2 : R1;
8503
8504    function Size (V : R1) return Integer is
8505    begin
8506       return V'Size;
8507    end Size;
8508
8509 begin
8510    Put_Line (Integer'Image (V2'Size));
8511    Put_Line (Integer'IMage (Size (V2)));
8512    V2 := (True, 'x');
8513    Put_Line (Integer'Image (V2'Size));
8514    Put_Line (Integer'IMage (Size (V2)));
8515 end q;
8516 @end smallexample
8517
8518 @noindent
8519 The output from this program is
8520
8521 @smallexample
8522 16
8523 8
8524 16
8525 16
8526 @end smallexample
8527
8528 @noindent
8529 Here we see that while the @code{'Size} attribute always returns
8530 the maximum size, regardless of the current variant value, the
8531 @code{Size} function does indeed return the size of the current
8532 variant value.
8533
8534 @node Biased Representation
8535 @section Biased Representation
8536 @cindex Size for biased representation
8537 @cindex Biased representation
8538
8539 @noindent
8540 In the case of scalars with a range starting at other than zero, it is
8541 possible in some cases to specify a size smaller than the default minimum
8542 value, and in such cases, GNAT uses an unsigned biased representation,
8543 in which zero is used to represent the lower bound, and successive values
8544 represent successive values of the type.
8545
8546 For example, suppose we have the declaration:
8547
8548 @smallexample @c ada
8549    type Small is range -7 .. -4;
8550    for Small'Size use 2;
8551 @end smallexample
8552
8553 @noindent
8554 Although the default size of type @code{Small} is 4, the @code{Size}
8555 clause is accepted by GNAT and results in the following representation
8556 scheme:
8557
8558 @smallexample
8559   -7 is represented as 2#00#
8560   -6 is represented as 2#01#
8561   -5 is represented as 2#10#
8562   -4 is represented as 2#11#
8563 @end smallexample
8564
8565 @noindent
8566 Biased representation is only used if the specified @code{Size} clause
8567 cannot be accepted in any other manner.  These reduced sizes that force
8568 biased representation can be used for all discrete types except for
8569 enumeration types for which a representation clause is given.
8570
8571 @node Value_Size and Object_Size Clauses
8572 @section Value_Size and Object_Size Clauses
8573 @findex Value_Size
8574 @findex Object_Size
8575 @cindex Size, of objects
8576
8577 @noindent
8578 In Ada 95, @code{T'Size} for a type @code{T} is the minimum number of bits
8579 required to hold values of type @code{T}.  Although this interpretation was
8580 allowed in Ada 83, it was not required, and this requirement in practice
8581 can cause some significant difficulties.  For example, in most Ada 83
8582 compilers, @code{Natural'Size} was 32.  However, in Ada 95,
8583 @code{Natural'Size} is
8584 typically 31.  This means that code may change in behavior when moving
8585 from Ada 83 to Ada 95.  For example, consider:
8586
8587 @smallexample @c ada
8588    type Rec is record;
8589       A : Natural;
8590       B : Natural;
8591    end record;
8592
8593    for Rec use record
8594       at 0  range 0 .. Natural'Size - 1;
8595       at 0  range Natural'Size .. 2 * Natural'Size - 1;
8596    end record;
8597 @end smallexample
8598
8599 @noindent
8600 In the above code, since the typical size of @code{Natural} objects
8601 is 32 bits and @code{Natural'Size} is 31, the above code can cause
8602 unexpected inefficient packing in Ada 95, and in general there are
8603 cases where the fact that the object size can exceed the
8604 size of the type causes surprises.
8605
8606 To help get around this problem GNAT provides two implementation
8607 defined attributes, @code{Value_Size} and @code{Object_Size}.  When
8608 applied to a type, these attributes yield the size of the type
8609 (corresponding to the RM defined size attribute), and the size of
8610 objects of the type respectively.
8611
8612 The @code{Object_Size} is used for determining the default size of
8613 objects and components.  This size value can be referred to using the
8614 @code{Object_Size} attribute.  The phrase ``is used'' here means that it is
8615 the basis of the determination of the size.  The backend is free to
8616 pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
8617 character might be stored in 32 bits on a machine with no efficient
8618 byte access instructions such as the Alpha.
8619
8620 The default rules for the value of @code{Object_Size} for
8621 discrete types are as follows:
8622
8623 @itemize @bullet
8624 @item
8625 The @code{Object_Size} for base subtypes reflect the natural hardware
8626 size in bits (run the compiler with @option{-gnatS} to find those values
8627 for numeric types). Enumeration types and fixed-point base subtypes have
8628 8, 16, 32 or 64 bits for this size, depending on the range of values
8629 to be stored.
8630
8631 @item
8632 The @code{Object_Size} of a subtype is the same as the
8633 @code{Object_Size} of
8634 the type from which it is obtained.
8635
8636 @item
8637 The @code{Object_Size} of a derived base type is copied from the parent
8638 base type, and the @code{Object_Size} of a derived first subtype is copied
8639 from the parent first subtype.
8640 @end itemize
8641
8642 @noindent
8643 The @code{Value_Size} attribute
8644 is the (minimum) number of bits required to store a value
8645 of the type.
8646 This value is used to determine how tightly to pack
8647 records or arrays with components of this type, and also affects
8648 the semantics of unchecked conversion (unchecked conversions where
8649 the @code{Value_Size} values differ generate a warning, and are potentially
8650 target dependent).
8651
8652 The default rules for the value of @code{Value_Size} are as follows:
8653
8654 @itemize @bullet
8655 @item
8656 The @code{Value_Size} for a base subtype is the minimum number of bits
8657 required to store all values of the type (including the sign bit
8658 only if negative values are possible).
8659
8660 @item
8661 If a subtype statically matches the first subtype of a given type, then it has
8662 by default the same @code{Value_Size} as the first subtype.  This is a
8663 consequence of RM 13.1(14) (``if two subtypes statically match,
8664 then their subtype-specific aspects are the same''.)
8665
8666 @item
8667 All other subtypes have a @code{Value_Size} corresponding to the minimum
8668 number of bits required to store all values of the subtype.  For
8669 dynamic bounds, it is assumed that the value can range down or up
8670 to the corresponding bound of the ancestor
8671 @end itemize
8672
8673 @noindent
8674 The RM defined attribute @code{Size} corresponds to the
8675 @code{Value_Size} attribute.
8676
8677 The @code{Size} attribute may be defined for a first-named subtype.  This sets
8678 the @code{Value_Size} of
8679 the first-named subtype to the given value, and the
8680 @code{Object_Size} of this first-named subtype to the given value padded up
8681 to an appropriate boundary.  It is a consequence of the default rules
8682 above that this @code{Object_Size} will apply to all further subtypes.  On the
8683 other hand, @code{Value_Size} is affected only for the first subtype, any
8684 dynamic subtypes obtained from it directly, and any statically matching
8685 subtypes.  The @code{Value_Size} of any other static subtypes is not affected.
8686
8687 @code{Value_Size} and
8688 @code{Object_Size} may be explicitly set for any subtype using
8689 an attribute definition clause.  Note that the use of these attributes
8690 can cause the RM 13.1(14) rule to be violated.  If two access types
8691 reference aliased objects whose subtypes have differing @code{Object_Size}
8692 values as a result of explicit attribute definition clauses, then it
8693 is erroneous to convert from one access subtype to the other.
8694
8695 At the implementation level, Esize stores the Object_Size and the
8696 RM_Size field stores the @code{Value_Size} (and hence the value of the
8697 @code{Size} attribute,
8698 which, as noted above, is equivalent to @code{Value_Size}).
8699
8700 To get a feel for the difference, consider the following examples (note
8701 that in each case the base is @code{Short_Short_Integer} with a size of 8):
8702
8703 @smallexample
8704                                        Object_Size     Value_Size
8705
8706 type x1 is range 0 .. 5;                    8               3
8707
8708 type x2 is range 0 .. 5;
8709 for x2'size use 12;                        16              12
8710
8711 subtype x3 is x2 range 0 .. 3;             16               2
8712
8713 subtype x4 is x2'base range 0 .. 10;        8               4
8714
8715 subtype x5 is x2 range 0 .. dynamic;       16               3*
8716
8717 subtype x6 is x2'base range 0 .. dynamic;   8               3*
8718
8719 @end smallexample
8720
8721 @noindent
8722 Note: the entries marked ``3*'' are not actually specified by the Ada 95 RM,
8723 but it seems in the spirit of the RM rules to allocate the minimum number
8724 of bits (here 3, given the range for @code{x2})
8725 known to be large enough to hold the given range of values.
8726
8727 So far, so good, but GNAT has to obey the RM rules, so the question is
8728 under what conditions must the RM @code{Size} be used.
8729 The following is a list
8730 of the occasions on which the RM @code{Size} must be used:
8731
8732 @itemize @bullet
8733 @item
8734 Component size for packed arrays or records
8735
8736 @item
8737 Value of the attribute @code{Size} for a type
8738
8739 @item
8740 Warning about sizes not matching for unchecked conversion
8741 @end itemize
8742
8743 @noindent
8744 For record types, the @code{Object_Size} is always a multiple of the
8745 alignment of the type (this is true for all types). In some cases the
8746 @code{Value_Size} can be smaller. Consider:
8747
8748 @smallexample
8749    type R is record
8750      X : Integer;
8751      Y : Character;
8752    end record;
8753 @end smallexample
8754
8755 @noindent
8756 On a typical 32-bit architecture, the X component will be four bytes, and
8757 require four-byte alignment, and the Y component will be one byte. In this
8758 case @code{R'Value_Size} will be 40 (bits) since this is the minimum size
8759 required to store a value of this type, and for example, it is permissible
8760 to have a component of type R in an outer record whose component size is
8761 specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits),
8762 since it must be rounded up so that this value is a multiple of the
8763 alignment (4 bytes = 32 bits).
8764
8765 @noindent
8766 For all other types, the @code{Object_Size}
8767 and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
8768 Only @code{Size} may be specified for such types.
8769
8770 @node Component_Size Clauses
8771 @section Component_Size Clauses
8772 @cindex Component_Size Clause
8773
8774 @noindent
8775 Normally, the value specified in a component clause must be consistent
8776 with the subtype of the array component with regard to size and alignment.
8777 In other words, the value specified must be at least equal to the size
8778 of this subtype, and must be a multiple of the alignment value.
8779
8780 In addition, component size clauses are allowed which cause the array
8781 to be packed, by specifying a smaller value.  The cases in which this
8782 is allowed are for component size values in the range 1 through 63.  The value
8783 specified must not be smaller than the Size of the subtype.  GNAT will
8784 accurately honor all packing requests in this range.  For example, if
8785 we have:
8786
8787 @smallexample @c ada
8788 type r is array (1 .. 8) of Natural;
8789 for r'Component_Size use 31;
8790 @end smallexample
8791
8792 @noindent
8793 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
8794 Of course access to the components of such an array is considerably
8795 less efficient than if the natural component size of 32 is used.
8796
8797 @node Bit_Order Clauses
8798 @section Bit_Order Clauses
8799 @cindex Bit_Order Clause
8800 @cindex bit ordering
8801 @cindex ordering, of bits
8802
8803 @noindent
8804 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
8805 attribute.  The specification may either correspond to the default bit
8806 order for the target, in which case the specification has no effect and
8807 places no additional restrictions, or it may be for the non-standard
8808 setting (that is the opposite of the default).
8809
8810 In the case where the non-standard value is specified, the effect is
8811 to renumber bits within each byte, but the ordering of bytes is not
8812 affected.  There are certain
8813 restrictions placed on component clauses as follows:
8814
8815 @itemize @bullet
8816
8817 @item Components fitting within a single storage unit.
8818 @noindent
8819 These are unrestricted, and the effect is merely to renumber bits.  For
8820 example if we are on a little-endian machine with @code{Low_Order_First}
8821 being the default, then the following two declarations have exactly
8822 the same effect:
8823
8824 @smallexample @c ada
8825    type R1 is record
8826       A : Boolean;
8827       B : Integer range 1 .. 120;
8828    end record;
8829
8830    for R1 use record
8831       A at 0 range 0 .. 0;
8832       B at 0 range 1 .. 7;
8833    end record;
8834
8835    type R2 is record
8836       A : Boolean;
8837       B : Integer range 1 .. 120;
8838    end record;
8839
8840    for R2'Bit_Order use High_Order_First;
8841
8842    for R2 use record
8843       A at 0 range 7 .. 7;
8844       B at 0 range 0 .. 6;
8845    end record;
8846 @end smallexample
8847
8848 @noindent
8849 The useful application here is to write the second declaration with the
8850 @code{Bit_Order} attribute definition clause, and know that it will be treated
8851 the same, regardless of whether the target is little-endian or big-endian.
8852
8853 @item Components occupying an integral number of bytes.
8854 @noindent
8855 These are components that exactly fit in two or more bytes.  Such component
8856 declarations are allowed, but have no effect, since it is important to realize
8857 that the @code{Bit_Order} specification does not affect the ordering of bytes.
8858 In particular, the following attempt at getting an endian-independent integer
8859 does not work:
8860
8861 @smallexample @c ada
8862    type R2 is record
8863       A : Integer;
8864    end record;
8865
8866    for R2'Bit_Order use High_Order_First;
8867
8868    for R2 use record
8869       A at 0 range 0 .. 31;
8870    end record;
8871 @end smallexample
8872
8873 @noindent
8874 This declaration will result in a little-endian integer on a
8875 little-endian machine, and a big-endian integer on a big-endian machine.
8876 If byte flipping is required for interoperability between big- and
8877 little-endian machines, this must be explicitly programmed.  This capability
8878 is not provided by @code{Bit_Order}.
8879
8880 @item Components that are positioned across byte boundaries
8881 @noindent
8882 but do not occupy an integral number of bytes.  Given that bytes are not
8883 reordered, such fields would occupy a non-contiguous sequence of bits
8884 in memory, requiring non-trivial code to reassemble.  They are for this
8885 reason not permitted, and any component clause specifying such a layout
8886 will be flagged as illegal by GNAT@.
8887
8888 @end itemize
8889
8890 @noindent
8891 Since the misconception that Bit_Order automatically deals with all
8892 endian-related incompatibilities is a common one, the specification of
8893 a component field that is an integral number of bytes will always
8894 generate a warning.  This warning may be suppressed using
8895 @code{pragma Suppress} if desired.  The following section contains additional
8896 details regarding the issue of byte ordering.
8897
8898 @node Effect of Bit_Order on Byte Ordering
8899 @section Effect of Bit_Order on Byte Ordering
8900 @cindex byte ordering
8901 @cindex ordering, of bytes
8902
8903 @noindent
8904 In this section we will review the effect of the @code{Bit_Order} attribute
8905 definition clause on byte ordering.  Briefly, it has no effect at all, but
8906 a detailed example will be helpful.  Before giving this
8907 example, let us review the precise
8908 definition of the effect of defining @code{Bit_Order}.  The effect of a
8909 non-standard bit order is described in section 15.5.3 of the Ada
8910 Reference Manual:
8911
8912 @quotation
8913 2   A bit ordering is a method of interpreting the meaning of
8914 the storage place attributes.
8915 @end quotation
8916
8917 @noindent
8918 To understand the precise definition of storage place attributes in
8919 this context, we visit section 13.5.1 of the manual:
8920
8921 @quotation
8922 13   A record_representation_clause (without the mod_clause)
8923 specifies the layout.  The storage place attributes (see 13.5.2)
8924 are taken from the values of the position, first_bit, and last_bit
8925 expressions after normalizing those values so that first_bit is
8926 less than Storage_Unit.
8927 @end quotation
8928
8929 @noindent
8930 The critical point here is that storage places are taken from
8931 the values after normalization, not before.  So the @code{Bit_Order}
8932 interpretation applies to normalized values.  The interpretation
8933 is described in the later part of the 15.5.3 paragraph:
8934
8935 @quotation
8936 2   A bit ordering is a method of interpreting the meaning of
8937 the storage place attributes.  High_Order_First (known in the
8938 vernacular as ``big endian'') means that the first bit of a
8939 storage element (bit 0) is the most significant bit (interpreting
8940 the sequence of bits that represent a component as an unsigned
8941 integer value).  Low_Order_First (known in the vernacular as
8942 ``little endian'') means the opposite: the first bit is the
8943 least significant.
8944 @end quotation
8945
8946 @noindent
8947 Note that the numbering is with respect to the bits of a storage
8948 unit.  In other words, the specification affects only the numbering
8949 of bits within a single storage unit.
8950
8951 We can make the effect clearer by giving an example.
8952
8953 Suppose that we have an external device which presents two bytes, the first
8954 byte presented, which is the first (low addressed byte) of the two byte
8955 record is called Master, and the second byte is called Slave.
8956
8957 The left most (most significant bit is called Control for each byte, and
8958 the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
8959 (least significant) bit.
8960
8961 On a big-endian machine, we can write the following representation clause
8962
8963 @smallexample @c ada
8964    type Data is record
8965       Master_Control : Bit;
8966       Master_V1      : Bit;
8967       Master_V2      : Bit;
8968       Master_V3      : Bit;
8969       Master_V4      : Bit;
8970       Master_V5      : Bit;
8971       Master_V6      : Bit;
8972       Master_V7      : Bit;
8973       Slave_Control  : Bit;
8974       Slave_V1       : Bit;
8975       Slave_V2       : Bit;
8976       Slave_V3       : Bit;
8977       Slave_V4       : Bit;
8978       Slave_V5       : Bit;
8979       Slave_V6       : Bit;
8980       Slave_V7       : Bit;
8981    end record;
8982
8983    for Data use record
8984       Master_Control at 0 range 0 .. 0;
8985       Master_V1      at 0 range 1 .. 1;
8986       Master_V2      at 0 range 2 .. 2;
8987       Master_V3      at 0 range 3 .. 3;
8988       Master_V4      at 0 range 4 .. 4;
8989       Master_V5      at 0 range 5 .. 5;
8990       Master_V6      at 0 range 6 .. 6;
8991       Master_V7      at 0 range 7 .. 7;
8992       Slave_Control  at 1 range 0 .. 0;
8993       Slave_V1       at 1 range 1 .. 1;
8994       Slave_V2       at 1 range 2 .. 2;
8995       Slave_V3       at 1 range 3 .. 3;
8996       Slave_V4       at 1 range 4 .. 4;
8997       Slave_V5       at 1 range 5 .. 5;
8998       Slave_V6       at 1 range 6 .. 6;
8999       Slave_V7       at 1 range 7 .. 7;
9000    end record;
9001 @end smallexample
9002
9003 @noindent
9004 Now if we move this to a little endian machine, then the bit ordering within
9005 the byte is backwards, so we have to rewrite the record rep clause as:
9006
9007 @smallexample @c ada
9008    for Data use record
9009       Master_Control at 0 range 7 .. 7;
9010       Master_V1      at 0 range 6 .. 6;
9011       Master_V2      at 0 range 5 .. 5;
9012       Master_V3      at 0 range 4 .. 4;
9013       Master_V4      at 0 range 3 .. 3;
9014       Master_V5      at 0 range 2 .. 2;
9015       Master_V6      at 0 range 1 .. 1;
9016       Master_V7      at 0 range 0 .. 0;
9017       Slave_Control  at 1 range 7 .. 7;
9018       Slave_V1       at 1 range 6 .. 6;
9019       Slave_V2       at 1 range 5 .. 5;
9020       Slave_V3       at 1 range 4 .. 4;
9021       Slave_V4       at 1 range 3 .. 3;
9022       Slave_V5       at 1 range 2 .. 2;
9023       Slave_V6       at 1 range 1 .. 1;
9024       Slave_V7       at 1 range 0 .. 0;
9025    end record;
9026 @end smallexample
9027
9028 @noindent
9029 It is a nuisance to have to rewrite the clause, especially if
9030 the code has to be maintained on both machines.  However,
9031 this is a case that we can handle with the
9032 @code{Bit_Order} attribute if it is implemented.
9033 Note that the implementation is not required on byte addressed
9034 machines, but it is indeed implemented in GNAT.
9035 This means that we can simply use the
9036 first record clause, together with the declaration
9037
9038 @smallexample @c ada
9039    for Data'Bit_Order use High_Order_First;
9040 @end smallexample
9041
9042 @noindent
9043 and the effect is what is desired, namely the layout is exactly the same,
9044 independent of whether the code is compiled on a big-endian or little-endian
9045 machine.
9046
9047 The important point to understand is that byte ordering is not affected.
9048 A @code{Bit_Order} attribute definition never affects which byte a field
9049 ends up in, only where it ends up in that byte.
9050 To make this clear, let us rewrite the record rep clause of the previous
9051 example as:
9052
9053 @smallexample @c ada
9054    for Data'Bit_Order use High_Order_First;
9055    for Data use record
9056       Master_Control at 0 range  0 .. 0;
9057       Master_V1      at 0 range  1 .. 1;
9058       Master_V2      at 0 range  2 .. 2;
9059       Master_V3      at 0 range  3 .. 3;
9060       Master_V4      at 0 range  4 .. 4;
9061       Master_V5      at 0 range  5 .. 5;
9062       Master_V6      at 0 range  6 .. 6;
9063       Master_V7      at 0 range  7 .. 7;
9064       Slave_Control  at 0 range  8 .. 8;
9065       Slave_V1       at 0 range  9 .. 9;
9066       Slave_V2       at 0 range 10 .. 10;
9067       Slave_V3       at 0 range 11 .. 11;
9068       Slave_V4       at 0 range 12 .. 12;
9069       Slave_V5       at 0 range 13 .. 13;
9070       Slave_V6       at 0 range 14 .. 14;
9071       Slave_V7       at 0 range 15 .. 15;
9072    end record;
9073 @end smallexample
9074
9075 @noindent
9076 This is exactly equivalent to saying (a repeat of the first example):
9077
9078 @smallexample @c ada
9079    for Data'Bit_Order use High_Order_First;
9080    for Data use record
9081       Master_Control at 0 range 0 .. 0;
9082       Master_V1      at 0 range 1 .. 1;
9083       Master_V2      at 0 range 2 .. 2;
9084       Master_V3      at 0 range 3 .. 3;
9085       Master_V4      at 0 range 4 .. 4;
9086       Master_V5      at 0 range 5 .. 5;
9087       Master_V6      at 0 range 6 .. 6;
9088       Master_V7      at 0 range 7 .. 7;
9089       Slave_Control  at 1 range 0 .. 0;
9090       Slave_V1       at 1 range 1 .. 1;
9091       Slave_V2       at 1 range 2 .. 2;
9092       Slave_V3       at 1 range 3 .. 3;
9093       Slave_V4       at 1 range 4 .. 4;
9094       Slave_V5       at 1 range 5 .. 5;
9095       Slave_V6       at 1 range 6 .. 6;
9096       Slave_V7       at 1 range 7 .. 7;
9097    end record;
9098 @end smallexample
9099
9100 @noindent
9101 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
9102 field.  The storage place attributes are obtained by normalizing the
9103 values given so that the @code{First_Bit} value is less than 8.  After
9104 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
9105 we specified in the other case.
9106
9107 Now one might expect that the @code{Bit_Order} attribute might affect
9108 bit numbering within the entire record component (two bytes in this
9109 case, thus affecting which byte fields end up in), but that is not
9110 the way this feature is defined, it only affects numbering of bits,
9111 not which byte they end up in.
9112
9113 Consequently it never makes sense to specify a starting bit number
9114 greater than 7 (for a byte addressable field) if an attribute
9115 definition for @code{Bit_Order} has been given, and indeed it
9116 may be actively confusing to specify such a value, so the compiler
9117 generates a warning for such usage.
9118
9119 If you do need to control byte ordering then appropriate conditional
9120 values must be used.  If in our example, the slave byte came first on
9121 some machines we might write:
9122
9123 @smallexample @c ada
9124    Master_Byte_First constant Boolean := @dots{};
9125
9126    Master_Byte : constant Natural :=
9127                    1 - Boolean'Pos (Master_Byte_First);
9128    Slave_Byte  : constant Natural :=
9129                    Boolean'Pos (Master_Byte_First);
9130
9131    for Data'Bit_Order use High_Order_First;
9132    for Data use record
9133       Master_Control at Master_Byte range 0 .. 0;
9134       Master_V1      at Master_Byte range 1 .. 1;
9135       Master_V2      at Master_Byte range 2 .. 2;
9136       Master_V3      at Master_Byte range 3 .. 3;
9137       Master_V4      at Master_Byte range 4 .. 4;
9138       Master_V5      at Master_Byte range 5 .. 5;
9139       Master_V6      at Master_Byte range 6 .. 6;
9140       Master_V7      at Master_Byte range 7 .. 7;
9141       Slave_Control  at Slave_Byte  range 0 .. 0;
9142       Slave_V1       at Slave_Byte  range 1 .. 1;
9143       Slave_V2       at Slave_Byte  range 2 .. 2;
9144       Slave_V3       at Slave_Byte  range 3 .. 3;
9145       Slave_V4       at Slave_Byte  range 4 .. 4;
9146       Slave_V5       at Slave_Byte  range 5 .. 5;
9147       Slave_V6       at Slave_Byte  range 6 .. 6;
9148       Slave_V7       at Slave_Byte  range 7 .. 7;
9149    end record;
9150 @end smallexample
9151
9152 @noindent
9153 Now to switch between machines, all that is necessary is
9154 to set the boolean constant @code{Master_Byte_First} in
9155 an appropriate manner.
9156
9157 @node Pragma Pack for Arrays
9158 @section Pragma Pack for Arrays
9159 @cindex Pragma Pack (for arrays)
9160
9161 @noindent
9162 Pragma @code{Pack} applied to an array has no effect unless the component type
9163 is packable.  For a component type to be packable, it must be one of the
9164 following cases:
9165
9166 @itemize @bullet
9167 @item
9168 Any scalar type
9169 @item
9170 Any type whose size is specified with a size clause
9171 @item
9172 Any packed array type with a static size
9173 @end itemize
9174
9175 @noindent
9176 For all these cases, if the component subtype size is in the range
9177 1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
9178 component size were specified giving the component subtype size.
9179 For example if we have:
9180
9181 @smallexample @c ada
9182    type r is range 0 .. 17;
9183
9184    type ar is array (1 .. 8) of r;
9185    pragma Pack (ar);
9186 @end smallexample
9187
9188 @noindent
9189 Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
9190 and the size of the array @code{ar} will be exactly 40 bits.
9191
9192 Note that in some cases this rather fierce approach to packing can produce
9193 unexpected effects.  For example, in Ada 95, type Natural typically has a
9194 size of 31, meaning that if you pack an array of Natural, you get 31-bit
9195 close packing, which saves a few bits, but results in far less efficient
9196 access.  Since many other Ada compilers will ignore such a packing request,
9197 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
9198 might not be what is intended.  You can easily remove this warning by
9199 using an explicit @code{Component_Size} setting instead, which never generates
9200 a warning, since the intention of the programmer is clear in this case.
9201
9202 GNAT treats packed arrays in one of two ways.  If the size of the array is
9203 known at compile time and is less than 64 bits, then internally the array
9204 is represented as a single modular type, of exactly the appropriate number
9205 of bits.  If the length is greater than 63 bits, or is not known at compile
9206 time, then the packed array is represented as an array of bytes, and the
9207 length is always a multiple of 8 bits.
9208
9209 Note that to represent a packed array as a modular type, the alignment must
9210 be suitable for the modular type involved. For example, on typical machines
9211 a 32-bit packed array will be represented by a 32-bit modular integer with
9212 an alignment of four bytes. If you explicitly override the default alignment
9213 with an alignment clause that is too small, the modular representation
9214 cannot be used. For example, consider the following set of declarations:
9215
9216 @smallexample @c ada
9217    type R is range 1 .. 3;
9218    type S is array (1 .. 31) of R;
9219    for S'Component_Size use 2;
9220    for S'Size use 62;
9221    for S'Alignment use 1;
9222 @end smallexample
9223
9224 @noindent
9225 If the alignment clause were not present, then a 62-bit modular
9226 representation would be chosen (typically with an alignment of 4 or 8
9227 bytes depending on the target). But the default alignment is overridden
9228 with the explicit alignment clause. This means that the modular
9229 representation cannot be used, and instead the array of bytes
9230 representation must be used, meaning that the length must be a multiple
9231 of 8. Thus the above set of declarations will result in a diagnostic
9232 rejecting the size clause and noting that the minimum size allowed is 64.
9233
9234 @cindex Pragma Pack (for type Natural)
9235 @cindex Pragma Pack warning
9236
9237 One special case that is worth noting occurs when the base type of the
9238 component size is 8/16/32 and the subtype is one bit less. Notably this
9239 occurs with subtype @code{Natural}. Consider:
9240
9241 @smallexample @c ada
9242    type Arr is array (1 .. 32) of Natural;
9243    pragma Pack (Arr);
9244 @end smallexample
9245
9246 @noindent
9247 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
9248 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
9249 Ada 83 compilers did not attempt 31 bit packing.
9250
9251 In Ada 95, @code{Natural'Size} is required to be 31. Furthermore, GNAT really
9252 does pack 31-bit subtype to 31 bits. This may result in a substantial
9253 unintended performance penalty when porting legacy Ada 83 code. To help
9254 prevent this, GNAT generates a warning in such cases. If you really want 31
9255 bit packing in a case like this, you can set the component size explicitly:
9256
9257 @smallexample @c ada
9258    type Arr is array (1 .. 32) of Natural;
9259    for Arr'Component_Size use 31;
9260 @end smallexample
9261
9262 @noindent
9263 Here 31-bit packing is achieved as required, and no warning is generated,
9264 since in this case the programmer intention is clear.
9265
9266 @node Pragma Pack for Records
9267 @section Pragma Pack for Records
9268 @cindex Pragma Pack (for records)
9269
9270 @noindent
9271 Pragma @code{Pack} applied to a record will pack the components to reduce
9272 wasted space from alignment gaps and by reducing the amount of space
9273 taken by components.  We distinguish between @emph{packable} components and
9274 @emph{non-packable} components.
9275 Components of the following types are considered packable:
9276 @itemize @bullet
9277 @item
9278 All primitive types are packable.
9279
9280 @item
9281 Small packed arrays, whose size does not exceed 64 bits, and where the
9282 size is statically known at compile time, are represented internally
9283 as modular integers, and so they are also packable.
9284
9285 @end itemize
9286
9287 @noindent
9288 All packable components occupy the exact number of bits corresponding to
9289 their @code{Size} value, and are packed with no padding bits, i.e.@: they
9290 can start on an arbitrary bit boundary.
9291
9292 All other types are non-packable, they occupy an integral number of
9293 storage units, and
9294 are placed at a boundary corresponding to their alignment requirements.
9295
9296 For example, consider the record
9297
9298 @smallexample @c ada
9299    type Rb1 is array (1 .. 13) of Boolean;
9300    pragma Pack (rb1);
9301
9302    type Rb2 is array (1 .. 65) of Boolean;
9303    pragma Pack (rb2);
9304
9305    type x2 is record
9306       l1 : Boolean;
9307       l2 : Duration;
9308       l3 : Float;
9309       l4 : Boolean;
9310       l5 : Rb1;
9311       l6 : Rb2;
9312    end record;
9313    pragma Pack (x2);
9314 @end smallexample
9315
9316 @noindent
9317 The representation for the record x2 is as follows:
9318
9319 @smallexample @c ada
9320 for x2'Size use 224;
9321 for x2 use record
9322    l1 at  0 range  0 .. 0;
9323    l2 at  0 range  1 .. 64;
9324    l3 at 12 range  0 .. 31;
9325    l4 at 16 range  0 .. 0;
9326    l5 at 16 range  1 .. 13;
9327    l6 at 18 range  0 .. 71;
9328 end record;
9329 @end smallexample
9330
9331 @noindent
9332 Studying this example, we see that the packable fields @code{l1}
9333 and @code{l2} are
9334 of length equal to their sizes, and placed at specific bit boundaries (and
9335 not byte boundaries) to
9336 eliminate padding.  But @code{l3} is of a non-packable float type, so
9337 it is on the next appropriate alignment boundary.
9338
9339 The next two fields are fully packable, so @code{l4} and @code{l5} are
9340 minimally packed with no gaps.  However, type @code{Rb2} is a packed
9341 array that is longer than 64 bits, so it is itself non-packable.  Thus
9342 the @code{l6} field is aligned to the next byte boundary, and takes an
9343 integral number of bytes, i.e.@: 72 bits.
9344
9345 @node Record Representation Clauses
9346 @section Record Representation Clauses
9347 @cindex Record Representation Clause
9348
9349 @noindent
9350 Record representation clauses may be given for all record types, including
9351 types obtained by record extension.  Component clauses are allowed for any
9352 static component.  The restrictions on component clauses depend on the type
9353 of the component.
9354
9355 @cindex Component Clause
9356 For all components of an elementary type, the only restriction on component
9357 clauses is that the size must be at least the 'Size value of the type
9358 (actually the Value_Size).  There are no restrictions due to alignment,
9359 and such components may freely cross storage boundaries.
9360
9361 Packed arrays with a size up to and including 64 bits are represented
9362 internally using a modular type with the appropriate number of bits, and
9363 thus the same lack of restriction applies.  For example, if you declare:
9364
9365 @smallexample @c ada
9366    type R is array (1 .. 49) of Boolean;
9367    pragma Pack (R);
9368    for R'Size use 49;
9369 @end smallexample
9370
9371 @noindent
9372 then a component clause for a component of type R may start on any
9373 specified bit boundary, and may specify a value of 49 bits or greater.
9374
9375 The rules for other types are different for GNAT 3 and GNAT 5 versions
9376 (based on GCC 2 and GCC 3 respectively). In GNAT 5, larger components
9377 may also be placed on arbitrary boundaries, so for example, the following
9378 is permitted:
9379
9380 @smallexample @c ada
9381    type R is array (1 .. 79) of Boolean;
9382    pragma Pack (R);
9383    for R'Size use 79;
9384
9385    type Q is record
9386       G, H : Boolean;
9387       L, M : R;
9388    end record;
9389
9390    for Q use record
9391       G at 0 range  0 ..   0;
9392       H at 0 range  1 ..   1;
9393       L at 0 range  2 ..  80;
9394       R at 0 range 81 .. 159;
9395    end record;
9396 @end smallexample
9397
9398 @noindent
9399 In GNAT 3, there are more severe restrictions on larger components.
9400 For non-primitive types, including packed arrays with a size greater than
9401 64 bits, component clauses must respect the alignment requirement of the
9402 type, in particular, always starting on a byte boundary, and the length
9403 must be a multiple of the storage unit.
9404
9405 The following rules regarding tagged types are enforced in both GNAT 3 and
9406 GNAT 5:
9407
9408 The tag field of a tagged type always occupies an address sized field at
9409 the start of the record.  No component clause may attempt to overlay this
9410 tag.
9411
9412 In the case of a record extension T1, of a type T, no component clause applied
9413 to the type T1 can specify a storage location that would overlap the first
9414 T'Size bytes of the record.
9415
9416 @node Enumeration Clauses
9417 @section Enumeration Clauses
9418
9419 The only restriction on enumeration clauses is that the range of values
9420 must be representable.  For the signed case, if one or more of the
9421 representation values are negative, all values must be in the range:
9422
9423 @smallexample @c ada
9424    System.Min_Int .. System.Max_Int
9425 @end smallexample
9426
9427 @noindent
9428 For the unsigned case, where all values are non negative, the values must
9429 be in the range:
9430
9431 @smallexample @c ada
9432    0 .. System.Max_Binary_Modulus;
9433 @end smallexample
9434
9435 @noindent
9436 A @emph{confirming} representation clause is one in which the values range
9437 from 0 in sequence, i.e.@: a clause that confirms the default representation
9438 for an enumeration type.
9439 Such a confirming representation
9440 is permitted by these rules, and is specially recognized by the compiler so
9441 that no extra overhead results from the use of such a clause.
9442
9443 If an array has an index type which is an enumeration type to which an
9444 enumeration clause has been applied, then the array is stored in a compact
9445 manner.  Consider the declarations:
9446
9447 @smallexample @c ada
9448    type r is (A, B, C);
9449    for r use (A => 1, B => 5, C => 10);
9450    type t is array (r) of Character;
9451 @end smallexample
9452
9453 @noindent
9454 The array type t corresponds to a vector with exactly three elements and
9455 has a default size equal to @code{3*Character'Size}.  This ensures efficient
9456 use of space, but means that accesses to elements of the array will incur
9457 the overhead of converting representation values to the corresponding
9458 positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
9459
9460 @node Address Clauses
9461 @section Address Clauses
9462 @cindex Address Clause
9463
9464 The reference manual allows a general restriction on representation clauses,
9465 as found in RM 13.1(22):
9466
9467 @quotation
9468 An implementation need not support representation
9469 items containing nonstatic expressions, except that
9470 an implementation should support a representation item
9471 for a given entity if each nonstatic expression in the
9472 representation item is a name that statically denotes
9473 a constant declared before the entity.
9474 @end quotation
9475
9476 @noindent
9477 In practice this is applicable only to address clauses, since this is the
9478 only case in which a non-static expression is permitted by the syntax.  As
9479 the AARM notes in sections 13.1 (22.a-22.h):
9480
9481 @display
9482   22.a   Reason: This is to avoid the following sort of thing:
9483
9484   22.b        X : Integer := F(@dots{});
9485               Y : Address := G(@dots{});
9486               for X'Address use Y;
9487
9488   22.c   In the above, we have to evaluate the
9489          initialization expression for X before we
9490          know where to put the result.  This seems
9491          like an unreasonable implementation burden.
9492
9493   22.d   The above code should instead be written
9494          like this:
9495
9496   22.e        Y : constant Address := G(@dots{});
9497               X : Integer := F(@dots{});
9498               for X'Address use Y;
9499
9500   22.f   This allows the expression ``Y'' to be safely
9501          evaluated before X is created.
9502
9503   22.g   The constant could be a formal parameter of mode in.
9504
9505   22.h   An implementation can support other nonstatic
9506          expressions if it wants to.  Expressions of type
9507          Address are hardly ever static, but their value
9508          might be known at compile time anyway in many
9509          cases.
9510 @end display
9511
9512 @noindent
9513 GNAT does indeed permit many additional cases of non-static expressions.  In
9514 particular, if the type involved is elementary there are no restrictions
9515 (since in this case, holding a temporary copy of the initialization value,
9516 if one is present, is inexpensive).  In addition, if there is no implicit or
9517 explicit initialization, then there are no restrictions.  GNAT will reject
9518 only the case where all three of these conditions hold:
9519
9520 @itemize @bullet
9521
9522 @item
9523 The type of the item is non-elementary (e.g.@: a record or array).
9524
9525 @item
9526 There is explicit or implicit initialization required for the object.
9527 Note that access values are always implicitly initialized, and also
9528 in GNAT, certain bit-packed arrays (those having a dynamic length or
9529 a length greater than 64) will also be implicitly initialized to zero.
9530
9531 @item
9532 The address value is non-static.  Here GNAT is more permissive than the
9533 RM, and allows the address value to be the address of a previously declared
9534 stand-alone variable, as long as it does not itself have an address clause.
9535
9536 @smallexample @c ada
9537            Anchor  : Some_Initialized_Type;
9538            Overlay : Some_Initialized_Type;
9539            for Overlay'Address use Anchor'Address;
9540 @end smallexample
9541
9542 @noindent
9543 However, the prefix of the address clause cannot be an array component, or
9544 a component of a discriminated record.
9545
9546 @end itemize
9547
9548 @noindent
9549 As noted above in section 22.h, address values are typically non-static.  In
9550 particular the To_Address function, even if applied to a literal value, is
9551 a non-static function call.  To avoid this minor annoyance, GNAT provides
9552 the implementation defined attribute 'To_Address.  The following two
9553 expressions have identical values:
9554
9555 @findex Attribute
9556 @findex To_Address
9557 @smallexample @c ada
9558    To_Address (16#1234_0000#)
9559    System'To_Address (16#1234_0000#);
9560 @end smallexample
9561
9562 @noindent
9563 except that the second form is considered to be a static expression, and
9564 thus when used as an address clause value is always permitted.
9565
9566 @noindent
9567 Additionally, GNAT treats as static an address clause that is an
9568 unchecked_conversion of a static integer value.  This simplifies the porting
9569 of legacy code, and provides a portable equivalent to the GNAT attribute
9570 @code{To_Address}.
9571
9572 Another issue with address clauses is the interaction with alignment
9573 requirements.  When an address clause is given for an object, the address
9574 value must be consistent with the alignment of the object (which is usually
9575 the same as the alignment of the type of the object).  If an address clause
9576 is given that specifies an inappropriately aligned address value, then the
9577 program execution is erroneous.
9578
9579 Since this source of erroneous behavior can have unfortunate effects, GNAT
9580 checks (at compile time if possible, generating a warning, or at execution
9581 time with a run-time check) that the alignment is appropriate.  If the
9582 run-time check fails, then @code{Program_Error} is raised.  This run-time
9583 check is suppressed if range checks are suppressed, or if
9584 @code{pragma Restrictions (No_Elaboration_Code)} is in effect.
9585
9586 @findex Export
9587 An address clause cannot be given for an exported object.  More
9588 understandably the real restriction is that objects with an address
9589 clause cannot be exported.  This is because such variables are not
9590 defined by the Ada program, so there is no external object to export.
9591
9592 @findex Import
9593 It is permissible to give an address clause and a pragma Import for the
9594 same object.  In this case, the variable is not really defined by the
9595 Ada program, so there is no external symbol to be linked.  The link name
9596 and the external name are ignored in this case.  The reason that we allow this
9597 combination is that it provides a useful idiom to avoid unwanted
9598 initializations on objects with address clauses.
9599
9600 When an address clause is given for an object that has implicit or
9601 explicit initialization, then by default initialization takes place.  This
9602 means that the effect of the object declaration is to overwrite the
9603 memory at the specified address.  This is almost always not what the
9604 programmer wants, so GNAT will output a warning:
9605
9606 @smallexample
9607   with System;
9608   package G is
9609      type R is record
9610         M : Integer := 0;
9611      end record;
9612
9613      Ext : R;
9614      for Ext'Address use System'To_Address (16#1234_1234#);
9615          |
9616   >>> warning: implicit initialization of "Ext" may
9617       modify overlaid storage
9618   >>> warning: use pragma Import for "Ext" to suppress
9619       initialization (RM B(24))
9620
9621   end G;
9622 @end smallexample
9623
9624 @noindent
9625 As indicated by the warning message, the solution is to use a (dummy) pragma
9626 Import to suppress this initialization.  The pragma tell the compiler that the
9627 object is declared and initialized elsewhere.  The following package compiles
9628 without warnings (and the initialization is suppressed):
9629
9630 @smallexample @c ada
9631    with System;
9632    package G is
9633       type R is record
9634          M : Integer := 0;
9635       end record;
9636
9637       Ext : R;
9638       for Ext'Address use System'To_Address (16#1234_1234#);
9639       pragma Import (Ada, Ext);
9640    end G;
9641 @end smallexample
9642
9643 @noindent
9644 A final issue with address clauses involves their use for overlaying
9645 variables, as in the following example:
9646 @cindex Overlaying of objects
9647
9648 @smallexample @c ada
9649   A : Integer;
9650   B : Integer;
9651   for B'Address use A'Address;
9652 @end smallexample
9653
9654 @noindent
9655 or alternatively, using the form recommended by the RM:
9656
9657 @smallexample @c ada
9658   A    : Integer;
9659   Addr : constant Address := A'Address;
9660   B    : Integer;
9661   for B'Address use Addr;
9662 @end smallexample
9663
9664 @noindent
9665 In both of these cases, @code{A}
9666 and @code{B} become aliased to one another via the
9667 address clause. This use of address clauses to overlay
9668 variables, achieving an effect similar to unchecked
9669 conversion was erroneous in Ada 83, but in Ada 95
9670 the effect is implementation defined. Furthermore, the
9671 Ada 95 RM specifically recommends that in a situation
9672 like this, @code{B} should be subject to the following
9673 implementation advice (RM 13.3(19)):
9674
9675 @quotation
9676 19  If the Address of an object is specified, or it is imported
9677     or exported, then the implementation should not perform
9678     optimizations based on assumptions of no aliases.
9679 @end quotation
9680
9681 @noindent
9682 GNAT follows this recommendation, and goes further by also applying
9683 this recommendation to the overlaid variable (@code{A}
9684 in the above example) in this case. This means that the overlay
9685 works "as expected", in that a modification to one of the variables
9686 will affect the value of the other.
9687
9688 @node Effect of Convention on Representation
9689 @section Effect of Convention on Representation
9690 @cindex Convention, effect on representation
9691
9692 @noindent
9693 Normally the specification of a foreign language convention for a type or
9694 an object has no effect on the chosen representation.  In particular, the
9695 representation chosen for data in GNAT generally meets the standard system
9696 conventions, and for example records are laid out in a manner that is
9697 consistent with C@.  This means that specifying convention C (for example)
9698 has no effect.
9699
9700 There are three exceptions to this general rule:
9701
9702 @itemize @bullet
9703
9704 @item Convention Fortran and array subtypes
9705 If pragma Convention Fortran is specified for an array subtype, then in
9706 accordance with the implementation advice in section 3.6.2(11) of the
9707 Ada Reference Manual, the array will be stored in a Fortran-compatible
9708 column-major manner, instead of the normal default row-major order.
9709
9710 @item Convention C and enumeration types
9711 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
9712 to accommodate all values of the type.  For example, for the enumeration
9713 type declared by:
9714
9715 @smallexample @c ada
9716    type Color is (Red, Green, Blue);
9717 @end smallexample
9718
9719 @noindent
9720 8 bits is sufficient to store all values of the type, so by default, objects
9721 of type @code{Color} will be represented using 8 bits.  However, normal C
9722 convention is to use 32 bits for all enum values in C, since enum values
9723 are essentially of type int.  If pragma @code{Convention C} is specified for an
9724 Ada enumeration type, then the size is modified as necessary (usually to
9725 32 bits) to be consistent with the C convention for enum values.
9726
9727 @item Convention C/Fortran and Boolean types
9728 In C, the usual convention for boolean values, that is values used for
9729 conditions, is that zero represents false, and nonzero values represent
9730 true.  In Ada, the normal convention is that two specific values, typically
9731 0/1, are used to represent false/true respectively.
9732
9733 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
9734 value represents true).
9735
9736 To accommodate the Fortran and C conventions, if a pragma Convention specifies
9737 C or Fortran convention for a derived Boolean, as in the following example:
9738
9739 @smallexample @c ada
9740    type C_Switch is new Boolean;
9741    pragma Convention (C, C_Switch);
9742 @end smallexample
9743
9744 @noindent
9745 then the GNAT generated code will treat any nonzero value as true.  For truth
9746 values generated by GNAT, the conventional value 1 will be used for True, but
9747 when one of these values is read, any nonzero value is treated as True.
9748
9749 @end itemize
9750
9751 @node Determining the Representations chosen by GNAT
9752 @section Determining the Representations chosen by GNAT
9753 @cindex Representation, determination of
9754 @cindex @code{-gnatR} switch
9755
9756 @noindent
9757 Although the descriptions in this section are intended to be complete, it is
9758 often easier to simply experiment to see what GNAT accepts and what the
9759 effect is on the layout of types and objects.
9760
9761 As required by the Ada RM, if a representation clause is not accepted, then
9762 it must be rejected as illegal by the compiler.  However, when a
9763 representation clause or pragma is accepted, there can still be questions
9764 of what the compiler actually does.  For example, if a partial record
9765 representation clause specifies the location of some components and not
9766 others, then where are the non-specified components placed? Or if pragma
9767 @code{Pack} is used on a record, then exactly where are the resulting
9768 fields placed? The section on pragma @code{Pack} in this chapter can be
9769 used to answer the second question, but it is often easier to just see
9770 what the compiler does.
9771
9772 For this purpose, GNAT provides the option @code{-gnatR}.  If you compile
9773 with this option, then the compiler will output information on the actual
9774 representations chosen, in a format similar to source representation
9775 clauses.  For example, if we compile the package:
9776
9777 @smallexample @c ada
9778 package q is
9779    type r (x : boolean) is tagged record
9780       case x is
9781          when True => S : String (1 .. 100);
9782          when False => null;
9783       end case;
9784    end record;
9785
9786    type r2 is new r (false) with record
9787       y2 : integer;
9788    end record;
9789
9790    for r2 use record
9791       y2 at 16 range 0 .. 31;
9792    end record;
9793
9794    type x is record
9795       y : character;
9796    end record;
9797
9798    type x1 is array (1 .. 10) of x;
9799    for x1'component_size use 11;
9800
9801    type ia is access integer;
9802
9803    type Rb1 is array (1 .. 13) of Boolean;
9804    pragma Pack (rb1);
9805
9806    type Rb2 is array (1 .. 65) of Boolean;
9807    pragma Pack (rb2);
9808
9809    type x2 is record
9810       l1 : Boolean;
9811       l2 : Duration;
9812       l3 : Float;
9813       l4 : Boolean;
9814       l5 : Rb1;
9815       l6 : Rb2;
9816    end record;
9817    pragma Pack (x2);
9818 end q;
9819 @end smallexample
9820
9821 @noindent
9822 using the switch @code{-gnatR} we obtain the following output:
9823
9824 @smallexample
9825 Representation information for unit q
9826 -------------------------------------
9827
9828 for r'Size use ??;
9829 for r'Alignment use 4;
9830 for r use record
9831    x    at 4 range  0 .. 7;
9832    _tag at 0 range  0 .. 31;
9833    s    at 5 range  0 .. 799;
9834 end record;
9835
9836 for r2'Size use 160;
9837 for r2'Alignment use 4;
9838 for r2 use record
9839    x       at  4 range  0 .. 7;
9840    _tag    at  0 range  0 .. 31;
9841    _parent at  0 range  0 .. 63;
9842    y2      at 16 range  0 .. 31;
9843 end record;
9844
9845 for x'Size use 8;
9846 for x'Alignment use 1;
9847 for x use record
9848    y at 0 range  0 .. 7;
9849 end record;
9850
9851 for x1'Size use 112;
9852 for x1'Alignment use 1;
9853 for x1'Component_Size use 11;
9854
9855 for rb1'Size use 13;
9856 for rb1'Alignment use 2;
9857 for rb1'Component_Size use 1;
9858
9859 for rb2'Size use 72;
9860 for rb2'Alignment use 1;
9861 for rb2'Component_Size use 1;
9862
9863 for x2'Size use 224;
9864 for x2'Alignment use 4;
9865 for x2 use record
9866    l1 at  0 range  0 .. 0;
9867    l2 at  0 range  1 .. 64;
9868    l3 at 12 range  0 .. 31;
9869    l4 at 16 range  0 .. 0;
9870    l5 at 16 range  1 .. 13;
9871    l6 at 18 range  0 .. 71;
9872 end record;
9873 @end smallexample
9874
9875 @noindent
9876 The Size values are actually the Object_Size, i.e.@: the default size that
9877 will be allocated for objects of the type.
9878 The ?? size for type r indicates that we have a variant record, and the
9879 actual size of objects will depend on the discriminant value.
9880
9881 The Alignment values show the actual alignment chosen by the compiler
9882 for each record or array type.
9883
9884 The record representation clause for type r shows where all fields
9885 are placed, including the compiler generated tag field (whose location
9886 cannot be controlled by the programmer).
9887
9888 The record representation clause for the type extension r2 shows all the
9889 fields present, including the parent field, which is a copy of the fields
9890 of the parent type of r2, i.e.@: r1.
9891
9892 The component size and size clauses for types rb1 and rb2 show
9893 the exact effect of pragma @code{Pack} on these arrays, and the record
9894 representation clause for type x2 shows how pragma @code{Pack} affects
9895 this record type.
9896
9897 In some cases, it may be useful to cut and paste the representation clauses
9898 generated by the compiler into the original source to fix and guarantee
9899 the actual representation to be used.
9900
9901 @node Standard Library Routines
9902 @chapter Standard Library Routines
9903
9904 @noindent
9905 The Ada 95 Reference Manual contains in Annex A a full description of an
9906 extensive set of standard library routines that can be used in any Ada
9907 program, and which must be provided by all Ada compilers.  They are
9908 analogous to the standard C library used by C programs.
9909
9910 GNAT implements all of the facilities described in annex A, and for most
9911 purposes the description in the Ada 95
9912 reference manual, or appropriate Ada
9913 text book, will be sufficient for making use of these facilities.
9914
9915 In the case of the input-output facilities, @xref{The Implementation of
9916 Standard I/O}, gives details on exactly how GNAT interfaces to the
9917 file system.  For the remaining packages, the Ada 95 reference manual
9918 should be sufficient.  The following is a list of the packages included,
9919 together with a brief description of the functionality that is provided.
9920
9921 For completeness, references are included to other predefined library
9922 routines defined in other sections of the Ada 95 reference manual (these are
9923 cross-indexed from annex A).
9924
9925 @table @code
9926 @item Ada (A.2)
9927 This is a parent package for all the standard library packages.  It is
9928 usually included implicitly in your program, and itself contains no
9929 useful data or routines.
9930
9931 @item Ada.Calendar (9.6)
9932 @code{Calendar} provides time of day access, and routines for
9933 manipulating times and durations.
9934
9935 @item Ada.Characters (A.3.1)
9936 This is a dummy parent package that contains no useful entities
9937
9938 @item Ada.Characters.Handling (A.3.2)
9939 This package provides some basic character handling capabilities,
9940 including classification functions for classes of characters (e.g.@: test
9941 for letters, or digits).
9942
9943 @item Ada.Characters.Latin_1 (A.3.3)
9944 This package includes a complete set of definitions of the characters
9945 that appear in type CHARACTER@.  It is useful for writing programs that
9946 will run in international environments.  For example, if you want an
9947 upper case E with an acute accent in a string, it is often better to use
9948 the definition of @code{UC_E_Acute} in this package.  Then your program
9949 will print in an understandable manner even if your environment does not
9950 support these extended characters.
9951
9952 @item Ada.Command_Line (A.15)
9953 This package provides access to the command line parameters and the name
9954 of the current program (analogous to the use of @code{argc} and @code{argv}
9955 in C), and also allows the exit status for the program to be set in a
9956 system-independent manner.
9957
9958 @item Ada.Decimal (F.2)
9959 This package provides constants describing the range of decimal numbers
9960 implemented, and also a decimal divide routine (analogous to the COBOL
9961 verb DIVIDE .. GIVING .. REMAINDER ..)
9962
9963 @item Ada.Direct_IO (A.8.4)
9964 This package provides input-output using a model of a set of records of
9965 fixed-length, containing an arbitrary definite Ada type, indexed by an
9966 integer record number.
9967
9968 @item Ada.Dynamic_Priorities (D.5)
9969 This package allows the priorities of a task to be adjusted dynamically
9970 as the task is running.
9971
9972 @item Ada.Exceptions (11.4.1)
9973 This package provides additional information on exceptions, and also
9974 contains facilities for treating exceptions as data objects, and raising
9975 exceptions with associated messages.
9976
9977 @item Ada.Finalization (7.6)
9978 This package contains the declarations and subprograms to support the
9979 use of controlled types, providing for automatic initialization and
9980 finalization (analogous to the constructors and destructors of C++)
9981
9982 @item Ada.Interrupts (C.3.2)
9983 This package provides facilities for interfacing to interrupts, which
9984 includes the set of signals or conditions that can be raised and
9985 recognized as interrupts.
9986
9987 @item Ada.Interrupts.Names (C.3.2)
9988 This package provides the set of interrupt names (actually signal
9989 or condition names) that can be handled by GNAT@.
9990
9991 @item Ada.IO_Exceptions (A.13)
9992 This package defines the set of exceptions that can be raised by use of
9993 the standard IO packages.
9994
9995 @item Ada.Numerics
9996 This package contains some standard constants and exceptions used
9997 throughout the numerics packages.  Note that the constants pi and e are
9998 defined here, and it is better to use these definitions than rolling
9999 your own.
10000
10001 @item Ada.Numerics.Complex_Elementary_Functions
10002 Provides the implementation of standard elementary functions (such as
10003 log and trigonometric functions) operating on complex numbers using the
10004 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
10005 created by the package @code{Numerics.Complex_Types}.
10006
10007 @item Ada.Numerics.Complex_Types
10008 This is a predefined instantiation of
10009 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
10010 build the type @code{Complex} and @code{Imaginary}.
10011
10012 @item Ada.Numerics.Discrete_Random
10013 This package provides a random number generator suitable for generating
10014 random integer values from a specified range.
10015
10016 @item Ada.Numerics.Float_Random
10017 This package provides a random number generator suitable for generating
10018 uniformly distributed floating point values.
10019
10020 @item Ada.Numerics.Generic_Complex_Elementary_Functions
10021 This is a generic version of the package that provides the
10022 implementation of standard elementary functions (such as log and
10023 trigonometric functions) for an arbitrary complex type.
10024
10025 The following predefined instantiations of this package are provided:
10026
10027 @table @code
10028 @item Short_Float
10029 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
10030 @item Float
10031 @code{Ada.Numerics.Complex_Elementary_Functions}
10032 @item Long_Float
10033 @code{Ada.Numerics.
10034  Long_Complex_Elementary_Functions}
10035 @end table
10036
10037 @item Ada.Numerics.Generic_Complex_Types
10038 This is a generic package that allows the creation of complex types,
10039 with associated complex arithmetic operations.
10040
10041 The following predefined instantiations of this package exist
10042 @table @code
10043 @item Short_Float
10044 @code{Ada.Numerics.Short_Complex_Complex_Types}
10045 @item Float
10046 @code{Ada.Numerics.Complex_Complex_Types}
10047 @item Long_Float
10048 @code{Ada.Numerics.Long_Complex_Complex_Types}
10049 @end table
10050
10051 @item Ada.Numerics.Generic_Elementary_Functions
10052 This is a generic package that provides the implementation of standard
10053 elementary functions (such as log an trigonometric functions) for an
10054 arbitrary float type.
10055
10056 The following predefined instantiations of this package exist
10057
10058 @table @code
10059 @item Short_Float
10060 @code{Ada.Numerics.Short_Elementary_Functions}
10061 @item Float
10062 @code{Ada.Numerics.Elementary_Functions}
10063 @item Long_Float
10064 @code{Ada.Numerics.Long_Elementary_Functions}
10065 @end table
10066
10067 @item Ada.Real_Time (D.8)
10068 This package provides facilities similar to those of @code{Calendar}, but
10069 operating with a finer clock suitable for real time control. Note that
10070 annex D requires that there be no backward clock jumps, and GNAT generally
10071 guarantees this behavior, but of course if the external clock on which
10072 the GNAT runtime depends is deliberately reset by some external event,
10073 then such a backward jump may occur.
10074
10075 @item Ada.Sequential_IO (A.8.1)
10076 This package provides input-output facilities for sequential files,
10077 which can contain a sequence of values of a single type, which can be
10078 any Ada type, including indefinite (unconstrained) types.
10079
10080 @item Ada.Storage_IO (A.9)
10081 This package provides a facility for mapping arbitrary Ada types to and
10082 from a storage buffer.  It is primarily intended for the creation of new
10083 IO packages.
10084
10085 @item Ada.Streams (13.13.1)
10086 This is a generic package that provides the basic support for the
10087 concept of streams as used by the stream attributes (@code{Input},
10088 @code{Output}, @code{Read} and @code{Write}).
10089
10090 @item Ada.Streams.Stream_IO (A.12.1)
10091 This package is a specialization of the type @code{Streams} defined in
10092 package @code{Streams} together with a set of operations providing
10093 Stream_IO capability.  The Stream_IO model permits both random and
10094 sequential access to a file which can contain an arbitrary set of values
10095 of one or more Ada types.
10096
10097 @item Ada.Strings (A.4.1)
10098 This package provides some basic constants used by the string handling
10099 packages.
10100
10101 @item Ada.Strings.Bounded (A.4.4)
10102 This package provides facilities for handling variable length
10103 strings.  The bounded model requires a maximum length.  It is thus
10104 somewhat more limited than the unbounded model, but avoids the use of
10105 dynamic allocation or finalization.
10106
10107 @item Ada.Strings.Fixed (A.4.3)
10108 This package provides facilities for handling fixed length strings.
10109
10110 @item Ada.Strings.Maps (A.4.2)
10111 This package provides facilities for handling character mappings and
10112 arbitrarily defined subsets of characters.  For instance it is useful in
10113 defining specialized translation tables.
10114
10115 @item Ada.Strings.Maps.Constants (A.4.6)
10116 This package provides a standard set of predefined mappings and
10117 predefined character sets.  For example, the standard upper to lower case
10118 conversion table is found in this package.  Note that upper to lower case
10119 conversion is non-trivial if you want to take the entire set of
10120 characters, including extended characters like E with an acute accent,
10121 into account.  You should use the mappings in this package (rather than
10122 adding 32 yourself) to do case mappings.
10123
10124 @item Ada.Strings.Unbounded (A.4.5)
10125 This package provides facilities for handling variable length
10126 strings.  The unbounded model allows arbitrary length strings, but
10127 requires the use of dynamic allocation and finalization.
10128
10129 @item Ada.Strings.Wide_Bounded (A.4.7)
10130 @itemx Ada.Strings.Wide_Fixed (A.4.7)
10131 @itemx Ada.Strings.Wide_Maps (A.4.7)
10132 @itemx Ada.Strings.Wide_Maps.Constants (A.4.7)
10133 @itemx Ada.Strings.Wide_Unbounded (A.4.7)
10134 These packages provide analogous capabilities to the corresponding
10135 packages without @samp{Wide_} in the name, but operate with the types
10136 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
10137 and @code{Character}.
10138
10139 @item Ada.Synchronous_Task_Control (D.10)
10140 This package provides some standard facilities for controlling task
10141 communication in a synchronous manner.
10142
10143 @item Ada.Tags
10144 This package contains definitions for manipulation of the tags of tagged
10145 values.
10146
10147 @item Ada.Task_Attributes
10148 This package provides the capability of associating arbitrary
10149 task-specific data with separate tasks.
10150
10151 @item Ada.Text_IO
10152 This package provides basic text input-output capabilities for
10153 character, string and numeric data.  The subpackages of this
10154 package are listed next.
10155
10156 @item Ada.Text_IO.Decimal_IO
10157 Provides input-output facilities for decimal fixed-point types
10158
10159 @item Ada.Text_IO.Enumeration_IO
10160 Provides input-output facilities for enumeration types.
10161
10162 @item Ada.Text_IO.Fixed_IO
10163 Provides input-output facilities for ordinary fixed-point types.
10164
10165 @item Ada.Text_IO.Float_IO
10166 Provides input-output facilities for float types.  The following
10167 predefined instantiations of this generic package are available:
10168
10169 @table @code
10170 @item Short_Float
10171 @code{Short_Float_Text_IO}
10172 @item Float
10173 @code{Float_Text_IO}
10174 @item Long_Float
10175 @code{Long_Float_Text_IO}
10176 @end table
10177
10178 @item Ada.Text_IO.Integer_IO
10179 Provides input-output facilities for integer types.  The following
10180 predefined instantiations of this generic package are available:
10181
10182 @table @code
10183 @item Short_Short_Integer
10184 @code{Ada.Short_Short_Integer_Text_IO}
10185 @item Short_Integer
10186 @code{Ada.Short_Integer_Text_IO}
10187 @item Integer
10188 @code{Ada.Integer_Text_IO}
10189 @item Long_Integer
10190 @code{Ada.Long_Integer_Text_IO}
10191 @item Long_Long_Integer
10192 @code{Ada.Long_Long_Integer_Text_IO}
10193 @end table
10194
10195 @item Ada.Text_IO.Modular_IO
10196 Provides input-output facilities for modular (unsigned) types
10197
10198 @item Ada.Text_IO.Complex_IO (G.1.3)
10199 This package provides basic text input-output capabilities for complex
10200 data.
10201
10202 @item Ada.Text_IO.Editing (F.3.3)
10203 This package contains routines for edited output, analogous to the use
10204 of pictures in COBOL@.  The picture formats used by this package are a
10205 close copy of the facility in COBOL@.
10206
10207 @item Ada.Text_IO.Text_Streams (A.12.2)
10208 This package provides a facility that allows Text_IO files to be treated
10209 as streams, so that the stream attributes can be used for writing
10210 arbitrary data, including binary data, to Text_IO files.
10211
10212 @item Ada.Unchecked_Conversion (13.9)
10213 This generic package allows arbitrary conversion from one type to
10214 another of the same size, providing for breaking the type safety in
10215 special circumstances.
10216
10217 If the types have the same Size (more accurately the same Value_Size),
10218 then the effect is simply to transfer the bits from the source to the
10219 target type without any modification.  This usage is well defined, and
10220 for simple types whose representation is typically the same across
10221 all implementations, gives a portable method of performing such
10222 conversions.
10223
10224 If the types do not have the same size, then the result is implementation
10225 defined, and thus may be non-portable.  The following describes how GNAT
10226 handles such unchecked conversion cases.
10227
10228 If the types are of different sizes, and are both discrete types, then
10229 the effect is of a normal type conversion without any constraint checking.
10230 In particular if the result type has a larger size, the result will be
10231 zero or sign extended.  If the result type has a smaller size, the result
10232 will be truncated by ignoring high order bits.
10233
10234 If the types are of different sizes, and are not both discrete types,
10235 then the conversion works as though pointers were created to the source
10236 and target, and the pointer value is converted.  The effect is that bits
10237 are copied from successive low order storage units and bits of the source
10238 up to the length of the target type.
10239
10240 A warning is issued if the lengths differ, since the effect in this
10241 case is implementation dependent, and the above behavior may not match
10242 that of some other compiler.
10243
10244 A pointer to one type may be converted to a pointer to another type using
10245 unchecked conversion.  The only case in which the effect is undefined is
10246 when one or both pointers are pointers to unconstrained array types.  In
10247 this case, the bounds information may get incorrectly transferred, and in
10248 particular, GNAT uses double size pointers for such types, and it is
10249 meaningless to convert between such pointer types.  GNAT will issue a
10250 warning if the alignment of the target designated type is more strict
10251 than the alignment of the source designated type (since the result may
10252 be unaligned in this case).
10253
10254 A pointer other than a pointer to an unconstrained array type may be
10255 converted to and from System.Address.  Such usage is common in Ada 83
10256 programs, but note that Ada.Address_To_Access_Conversions is the
10257 preferred method of performing such conversions in Ada 95.  Neither
10258 unchecked conversion nor Ada.Address_To_Access_Conversions should be
10259 used in conjunction with pointers to unconstrained objects, since
10260 the bounds information cannot be handled correctly in this case.
10261
10262 @item Ada.Unchecked_Deallocation (13.11.2)
10263 This generic package allows explicit freeing of storage previously
10264 allocated by use of an allocator.
10265
10266 @item Ada.Wide_Text_IO (A.11)
10267 This package is similar to @code{Ada.Text_IO}, except that the external
10268 file supports wide character representations, and the internal types are
10269 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
10270 and @code{String}.  It contains generic subpackages listed next.
10271
10272 @item Ada.Wide_Text_IO.Decimal_IO
10273 Provides input-output facilities for decimal fixed-point types
10274
10275 @item Ada.Wide_Text_IO.Enumeration_IO
10276 Provides input-output facilities for enumeration types.
10277
10278 @item Ada.Wide_Text_IO.Fixed_IO
10279 Provides input-output facilities for ordinary fixed-point types.
10280
10281 @item Ada.Wide_Text_IO.Float_IO
10282 Provides input-output facilities for float types.  The following
10283 predefined instantiations of this generic package are available:
10284
10285 @table @code
10286 @item Short_Float
10287 @code{Short_Float_Wide_Text_IO}
10288 @item Float
10289 @code{Float_Wide_Text_IO}
10290 @item Long_Float
10291 @code{Long_Float_Wide_Text_IO}
10292 @end table
10293
10294 @item Ada.Wide_Text_IO.Integer_IO
10295 Provides input-output facilities for integer types.  The following
10296 predefined instantiations of this generic package are available:
10297
10298 @table @code
10299 @item Short_Short_Integer
10300 @code{Ada.Short_Short_Integer_Wide_Text_IO}
10301 @item Short_Integer
10302 @code{Ada.Short_Integer_Wide_Text_IO}
10303 @item Integer
10304 @code{Ada.Integer_Wide_Text_IO}
10305 @item Long_Integer
10306 @code{Ada.Long_Integer_Wide_Text_IO}
10307 @item Long_Long_Integer
10308 @code{Ada.Long_Long_Integer_Wide_Text_IO}
10309 @end table
10310
10311 @item Ada.Wide_Text_IO.Modular_IO
10312 Provides input-output facilities for modular (unsigned) types
10313
10314 @item Ada.Wide_Text_IO.Complex_IO (G.1.3)
10315 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
10316 external file supports wide character representations.
10317
10318 @item Ada.Wide_Text_IO.Editing (F.3.4)
10319 This package is similar to @code{Ada.Text_IO.Editing}, except that the
10320 types are @code{Wide_Character} and @code{Wide_String} instead of
10321 @code{Character} and @code{String}.
10322
10323 @item Ada.Wide_Text_IO.Streams (A.12.3)
10324 This package is similar to @code{Ada.Text_IO.Streams}, except that the
10325 types are @code{Wide_Character} and @code{Wide_String} instead of
10326 @code{Character} and @code{String}.
10327 @end table
10328
10329 @node The Implementation of Standard I/O
10330 @chapter The Implementation of Standard I/O
10331
10332 @noindent
10333 GNAT implements all the required input-output facilities described in
10334 A.6 through A.14.  These sections of the Ada 95 reference manual describe the
10335 required behavior of these packages from the Ada point of view, and if
10336 you are writing a portable Ada program that does not need to know the
10337 exact manner in which Ada maps to the outside world when it comes to
10338 reading or writing external files, then you do not need to read this
10339 chapter.  As long as your files are all regular files (not pipes or
10340 devices), and as long as you write and read the files only from Ada, the
10341 description in the Ada 95 reference manual is sufficient.
10342
10343 However, if you want to do input-output to pipes or other devices, such
10344 as the keyboard or screen, or if the files you are dealing with are
10345 either generated by some other language, or to be read by some other
10346 language, then you need to know more about the details of how the GNAT
10347 implementation of these input-output facilities behaves.
10348
10349 In this chapter we give a detailed description of exactly how GNAT
10350 interfaces to the file system.  As always, the sources of the system are
10351 available to you for answering questions at an even more detailed level,
10352 but for most purposes the information in this chapter will suffice.
10353
10354 Another reason that you may need to know more about how input-output is
10355 implemented arises when you have a program written in mixed languages
10356 where, for example, files are shared between the C and Ada sections of
10357 the same program.  GNAT provides some additional facilities, in the form
10358 of additional child library packages, that facilitate this sharing, and
10359 these additional facilities are also described in this chapter.
10360
10361 @menu
10362 * Standard I/O Packages::
10363 * FORM Strings::
10364 * Direct_IO::
10365 * Sequential_IO::
10366 * Text_IO::
10367 * Wide_Text_IO::
10368 * Stream_IO::
10369 * Shared Files::
10370 * Open Modes::
10371 * Operations on C Streams::
10372 * Interfacing to C Streams::
10373 @end menu
10374
10375 @node Standard I/O Packages
10376 @section Standard I/O Packages
10377
10378 @noindent
10379 The Standard I/O packages described in Annex A for
10380
10381 @itemize @bullet
10382 @item
10383 Ada.Text_IO
10384 @item
10385 Ada.Text_IO.Complex_IO
10386 @item
10387 Ada.Text_IO.Text_Streams,
10388 @item
10389 Ada.Wide_Text_IO
10390 @item
10391 Ada.Wide_Text_IO.Complex_IO,
10392 @item
10393 Ada.Wide_Text_IO.Text_Streams
10394 @item
10395 Ada.Stream_IO
10396 @item
10397 Ada.Sequential_IO
10398 @item
10399 Ada.Direct_IO
10400 @end itemize
10401
10402 @noindent
10403 are implemented using the C
10404 library streams facility; where
10405
10406 @itemize @bullet
10407 @item
10408 All files are opened using @code{fopen}.
10409 @item
10410 All input/output operations use @code{fread}/@code{fwrite}.
10411 @end itemize
10412
10413 @noindent
10414 There is no internal buffering of any kind at the Ada library level.  The
10415 only buffering is that provided at the system level in the
10416 implementation of the C library routines that support streams.  This
10417 facilitates shared use of these streams by mixed language programs.
10418
10419 @node FORM Strings
10420 @section FORM Strings
10421
10422 @noindent
10423 The format of a FORM string in GNAT is:
10424
10425 @smallexample
10426 "keyword=value,keyword=value,@dots{},keyword=value"
10427 @end smallexample
10428
10429 @noindent
10430 where letters may be in upper or lower case, and there are no spaces
10431 between values.  The order of the entries is not important.  Currently
10432 there are two keywords defined.
10433
10434 @smallexample
10435 SHARED=[YES|NO]
10436 WCEM=[n|h|u|s\e]
10437 @end smallexample
10438
10439 @noindent
10440 The use of these parameters is described later in this section.
10441
10442 @node Direct_IO
10443 @section Direct_IO
10444
10445 @noindent
10446 Direct_IO can only be instantiated for definite types.  This is a
10447 restriction of the Ada language, which means that the records are fixed
10448 length (the length being determined by @code{@var{type}'Size}, rounded
10449 up to the next storage unit boundary if necessary).
10450
10451 The records of a Direct_IO file are simply written to the file in index
10452 sequence, with the first record starting at offset zero, and subsequent
10453 records following.  There is no control information of any kind.  For
10454 example, if 32-bit integers are being written, each record takes
10455 4-bytes, so the record at index @var{K} starts at offset
10456 (@var{K}@minus{}1)*4.
10457
10458 There is no limit on the size of Direct_IO files, they are expanded as
10459 necessary to accommodate whatever records are written to the file.
10460
10461 @node Sequential_IO
10462 @section Sequential_IO
10463
10464 @noindent
10465 Sequential_IO may be instantiated with either a definite (constrained)
10466 or indefinite (unconstrained) type.
10467
10468 For the definite type case, the elements written to the file are simply
10469 the memory images of the data values with no control information of any
10470 kind.  The resulting file should be read using the same type, no validity
10471 checking is performed on input.
10472
10473 For the indefinite type case, the elements written consist of two
10474 parts.  First is the size of the data item, written as the memory image
10475 of a @code{Interfaces.C.size_t} value, followed by the memory image of
10476 the data value.  The resulting file can only be read using the same
10477 (unconstrained) type.  Normal assignment checks are performed on these
10478 read operations, and if these checks fail, @code{Data_Error} is
10479 raised.  In particular, in the array case, the lengths must match, and in
10480 the variant record case, if the variable for a particular read operation
10481 is constrained, the discriminants must match.
10482
10483 Note that it is not possible to use Sequential_IO to write variable
10484 length array items, and then read the data back into different length
10485 arrays.  For example, the following will raise @code{Data_Error}:
10486
10487 @smallexample @c ada
10488  package IO is new Sequential_IO (String);
10489  F : IO.File_Type;
10490  S : String (1..4);
10491  @dots{}
10492  IO.Create (F)
10493  IO.Write (F, "hello!")
10494  IO.Reset (F, Mode=>In_File);
10495  IO.Read (F, S);
10496  Put_Line (S);
10497
10498 @end smallexample
10499
10500 @noindent
10501 On some Ada implementations, this will print @code{hell}, but the program is
10502 clearly incorrect, since there is only one element in the file, and that
10503 element is the string @code{hello!}.
10504
10505 In Ada 95, this kind of behavior can be legitimately achieved using
10506 Stream_IO, and this is the preferred mechanism.  In particular, the above
10507 program fragment rewritten to use Stream_IO will work correctly.
10508
10509 @node Text_IO
10510 @section Text_IO
10511
10512 @noindent
10513 Text_IO files consist of a stream of characters containing the following
10514 special control characters:
10515
10516 @smallexample
10517 LF (line feed, 16#0A#) Line Mark
10518 FF (form feed, 16#0C#) Page Mark
10519 @end smallexample
10520
10521 @noindent
10522 A canonical Text_IO file is defined as one in which the following
10523 conditions are met:
10524
10525 @itemize @bullet
10526 @item
10527 The character @code{LF} is used only as a line mark, i.e.@: to mark the end
10528 of the line.
10529
10530 @item
10531 The character @code{FF} is used only as a page mark, i.e.@: to mark the
10532 end of a page and consequently can appear only immediately following a
10533 @code{LF} (line mark) character.
10534
10535 @item
10536 The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
10537 (line mark, page mark).  In the former case, the page mark is implicitly
10538 assumed to be present.
10539 @end itemize
10540
10541 @noindent
10542 A file written using Text_IO will be in canonical form provided that no
10543 explicit @code{LF} or @code{FF} characters are written using @code{Put}
10544 or @code{Put_Line}.  There will be no @code{FF} character at the end of
10545 the file unless an explicit @code{New_Page} operation was performed
10546 before closing the file.
10547
10548 A canonical Text_IO file that is a regular file, i.e.@: not a device or a
10549 pipe, can be read using any of the routines in Text_IO@.  The
10550 semantics in this case will be exactly as defined in the Ada 95 reference
10551 manual and all the routines in Text_IO are fully implemented.
10552
10553 A text file that does not meet the requirements for a canonical Text_IO
10554 file has one of the following:
10555
10556 @itemize @bullet
10557 @item
10558 The file contains @code{FF} characters not immediately following a
10559 @code{LF} character.
10560
10561 @item
10562 The file contains @code{LF} or @code{FF} characters written by
10563 @code{Put} or @code{Put_Line}, which are not logically considered to be
10564 line marks or page marks.
10565
10566 @item
10567 The file ends in a character other than @code{LF} or @code{FF},
10568 i.e.@: there is no explicit line mark or page mark at the end of the file.
10569 @end itemize
10570
10571 @noindent
10572 Text_IO can be used to read such non-standard text files but subprograms
10573 to do with line or page numbers do not have defined meanings.  In
10574 particular, a @code{FF} character that does not follow a @code{LF}
10575 character may or may not be treated as a page mark from the point of
10576 view of page and line numbering.  Every @code{LF} character is considered
10577 to end a line, and there is an implied @code{LF} character at the end of
10578 the file.
10579
10580 @menu
10581 * Text_IO Stream Pointer Positioning::
10582 * Text_IO Reading and Writing Non-Regular Files::
10583 * Get_Immediate::
10584 * Treating Text_IO Files as Streams::
10585 * Text_IO Extensions::
10586 * Text_IO Facilities for Unbounded Strings::
10587 @end menu
10588
10589 @node Text_IO Stream Pointer Positioning
10590 @subsection Stream Pointer Positioning
10591
10592 @noindent
10593 @code{Ada.Text_IO} has a definition of current position for a file that
10594 is being read.  No internal buffering occurs in Text_IO, and usually the
10595 physical position in the stream used to implement the file corresponds
10596 to this logical position defined by Text_IO@.  There are two exceptions:
10597
10598 @itemize @bullet
10599 @item
10600 After a call to @code{End_Of_Page} that returns @code{True}, the stream
10601 is positioned past the @code{LF} (line mark) that precedes the page
10602 mark.  Text_IO maintains an internal flag so that subsequent read
10603 operations properly handle the logical position which is unchanged by
10604 the @code{End_Of_Page} call.
10605
10606 @item
10607 After a call to @code{End_Of_File} that returns @code{True}, if the
10608 Text_IO file was positioned before the line mark at the end of file
10609 before the call, then the logical position is unchanged, but the stream
10610 is physically positioned right at the end of file (past the line mark,
10611 and past a possible page mark following the line mark.  Again Text_IO
10612 maintains internal flags so that subsequent read operations properly
10613 handle the logical position.
10614 @end itemize
10615
10616 @noindent
10617 These discrepancies have no effect on the observable behavior of
10618 Text_IO, but if a single Ada stream is shared between a C program and
10619 Ada program, or shared (using @samp{shared=yes} in the form string)
10620 between two Ada files, then the difference may be observable in some
10621 situations.
10622
10623 @node Text_IO Reading and Writing Non-Regular Files
10624 @subsection Reading and Writing Non-Regular Files
10625
10626 @noindent
10627 A non-regular file is a device (such as a keyboard), or a pipe.  Text_IO
10628 can be used for reading and writing.  Writing is not affected and the
10629 sequence of characters output is identical to the normal file case, but
10630 for reading, the behavior of Text_IO is modified to avoid undesirable
10631 look-ahead as follows:
10632
10633 An input file that is not a regular file is considered to have no page
10634 marks.  Any @code{Ascii.FF} characters (the character normally used for a
10635 page mark) appearing in the file are considered to be data
10636 characters.  In particular:
10637
10638 @itemize @bullet
10639 @item
10640 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
10641 following a line mark.  If a page mark appears, it will be treated as a
10642 data character.
10643
10644 @item
10645 This avoids the need to wait for an extra character to be typed or
10646 entered from the pipe to complete one of these operations.
10647
10648 @item
10649 @code{End_Of_Page} always returns @code{False}
10650
10651 @item
10652 @code{End_Of_File} will return @code{False} if there is a page mark at
10653 the end of the file.
10654 @end itemize
10655
10656 @noindent
10657 Output to non-regular files is the same as for regular files.  Page marks
10658 may be written to non-regular files using @code{New_Page}, but as noted
10659 above they will not be treated as page marks on input if the output is
10660 piped to another Ada program.
10661
10662 Another important discrepancy when reading non-regular files is that the end
10663 of file indication is not ``sticky''.  If an end of file is entered, e.g.@: by
10664 pressing the @key{EOT} key,
10665 then end of file
10666 is signaled once (i.e.@: the test @code{End_Of_File}
10667 will yield @code{True}, or a read will
10668 raise @code{End_Error}), but then reading can resume
10669 to read data past that end of
10670 file indication, until another end of file indication is entered.
10671
10672 @node Get_Immediate
10673 @subsection Get_Immediate
10674 @cindex Get_Immediate
10675
10676 @noindent
10677 Get_Immediate returns the next character (including control characters)
10678 from the input file.  In particular, Get_Immediate will return LF or FF
10679 characters used as line marks or page marks.  Such operations leave the
10680 file positioned past the control character, and it is thus not treated
10681 as having its normal function.  This means that page, line and column
10682 counts after this kind of Get_Immediate call are set as though the mark
10683 did not occur.  In the case where a Get_Immediate leaves the file
10684 positioned between the line mark and page mark (which is not normally
10685 possible), it is undefined whether the FF character will be treated as a
10686 page mark.
10687
10688 @node Treating Text_IO Files as Streams
10689 @subsection Treating Text_IO Files as Streams
10690 @cindex Stream files
10691
10692 @noindent
10693 The package @code{Text_IO.Streams} allows a Text_IO file to be treated
10694 as a stream.  Data written to a Text_IO file in this stream mode is
10695 binary data.  If this binary data contains bytes 16#0A# (@code{LF}) or
10696 16#0C# (@code{FF}), the resulting file may have non-standard
10697 format.  Similarly if read operations are used to read from a Text_IO
10698 file treated as a stream, then @code{LF} and @code{FF} characters may be
10699 skipped and the effect is similar to that described above for
10700 @code{Get_Immediate}.
10701
10702 @node Text_IO Extensions
10703 @subsection Text_IO Extensions
10704 @cindex Text_IO extensions
10705
10706 @noindent
10707 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
10708 to the standard @code{Text_IO} package:
10709
10710 @itemize @bullet
10711 @item function File_Exists (Name : String) return Boolean;
10712 Determines if a file of the given name exists.
10713
10714 @item function Get_Line return String;
10715 Reads a string from the standard input file.  The value returned is exactly
10716 the length of the line that was read.
10717
10718 @item function Get_Line (File : Ada.Text_IO.File_Type) return String;
10719 Similar, except that the parameter File specifies the file from which
10720 the string is to be read.
10721
10722 @end itemize
10723
10724 @node Text_IO Facilities for Unbounded Strings
10725 @subsection Text_IO Facilities for Unbounded Strings
10726 @cindex Text_IO for unbounded strings
10727 @cindex Unbounded_String, Text_IO operations
10728
10729 @noindent
10730 The package @code{Ada.Strings.Unbounded.Text_IO}
10731 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
10732 subprograms useful for Text_IO operations on unbounded strings:
10733
10734 @itemize @bullet
10735
10736 @item function Get_Line (File : File_Type) return Unbounded_String;
10737 Reads a line from the specified file
10738 and returns the result as an unbounded string.
10739
10740 @item procedure Put (File : File_Type; U : Unbounded_String);
10741 Writes the value of the given unbounded string to the specified file
10742 Similar to the effect of
10743 @code{Put (To_String (U))} except that an extra copy is avoided.
10744
10745 @item procedure Put_Line (File : File_Type; U : Unbounded_String);
10746 Writes the value of the given unbounded string to the specified file,
10747 followed by a @code{New_Line}.
10748 Similar to the effect of @code{Put_Line (To_String (U))} except
10749 that an extra copy is avoided.
10750 @end itemize
10751
10752 @noindent
10753 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
10754 and is optional.  If the parameter is omitted, then the standard input or
10755 output file is referenced as appropriate.
10756
10757 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
10758 files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended
10759 @code{Wide_Text_IO} functionality for unbounded wide strings.
10760
10761 @node Wide_Text_IO
10762 @section Wide_Text_IO
10763
10764 @noindent
10765 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
10766 both input and output files may contain special sequences that represent
10767 wide character values.  The encoding scheme for a given file may be
10768 specified using a FORM parameter:
10769
10770 @smallexample
10771 WCEM=@var{x}
10772 @end smallexample
10773
10774 @noindent
10775 as part of the FORM string (WCEM = wide character encoding method),
10776 where @var{x} is one of the following characters
10777
10778 @table @samp
10779 @item h
10780 Hex ESC encoding
10781 @item u
10782 Upper half encoding
10783 @item s
10784 Shift-JIS encoding
10785 @item e
10786 EUC Encoding
10787 @item 8
10788 UTF-8 encoding
10789 @item b
10790 Brackets encoding
10791 @end table
10792
10793 @noindent
10794 The encoding methods match those that
10795 can be used in a source
10796 program, but there is no requirement that the encoding method used for
10797 the source program be the same as the encoding method used for files,
10798 and different files may use different encoding methods.
10799
10800 The default encoding method for the standard files, and for opened files
10801 for which no WCEM parameter is given in the FORM string matches the
10802 wide character encoding specified for the main program (the default
10803 being brackets encoding if no coding method was specified with -gnatW).
10804
10805 @table @asis
10806 @item Hex Coding
10807 In this encoding, a wide character is represented by a five character
10808 sequence:
10809
10810 @smallexample
10811 ESC a b c d
10812 @end smallexample
10813
10814 @noindent
10815 where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
10816 characters (using upper case letters) of the wide character code.  For
10817 example, ESC A345 is used to represent the wide character with code
10818 16#A345#.  This scheme is compatible with use of the full
10819 @code{Wide_Character} set.
10820
10821 @item Upper Half Coding
10822 The wide character with encoding 16#abcd#, where the upper bit is on
10823 (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
10824 16#cd#.  The second byte may never be a format control character, but is
10825 not required to be in the upper half.  This method can be also used for
10826 shift-JIS or EUC where the internal coding matches the external coding.
10827
10828 @item Shift JIS Coding
10829 A wide character is represented by a two character sequence 16#ab# and
10830 16#cd#, with the restrictions described for upper half encoding as
10831 described above.  The internal character code is the corresponding JIS
10832 character according to the standard algorithm for Shift-JIS
10833 conversion.  Only characters defined in the JIS code set table can be
10834 used with this encoding method.
10835
10836 @item EUC Coding
10837 A wide character is represented by a two character sequence 16#ab# and
10838 16#cd#, with both characters being in the upper half.  The internal
10839 character code is the corresponding JIS character according to the EUC
10840 encoding algorithm.  Only characters defined in the JIS code set table
10841 can be used with this encoding method.
10842
10843 @item UTF-8 Coding
10844 A wide character is represented using
10845 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
10846 10646-1/Am.2.  Depending on the character value, the representation
10847 is a one, two, or three byte sequence:
10848
10849 @smallexample
10850 16#0000#-16#007f#: 2#0xxxxxxx#
10851 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
10852 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
10853 @end smallexample
10854
10855 @noindent
10856 where the xxx bits correspond to the left-padded bits of the
10857 16-bit character value.  Note that all lower half ASCII characters
10858 are represented as ASCII bytes and all upper half characters and
10859 other wide characters are represented as sequences of upper-half
10860 (The full UTF-8 scheme allows for encoding 31-bit characters as
10861 6-byte sequences, but in this implementation, all UTF-8 sequences
10862 of four or more bytes length will raise a Constraint_Error, as
10863 will all invalid UTF-8 sequences.)
10864
10865 @item Brackets Coding
10866 In this encoding, a wide character is represented by the following eight
10867 character sequence:
10868
10869 @smallexample
10870 [ " a b c d " ]
10871 @end smallexample
10872
10873 @noindent
10874 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
10875 characters (using uppercase letters) of the wide character code.  For
10876 example, @code{["A345"]} is used to represent the wide character with code
10877 @code{16#A345#}.
10878 This scheme is compatible with use of the full Wide_Character set.
10879 On input, brackets coding can also be used for upper half characters,
10880 e.g.@: @code{["C1"]} for lower case a.  However, on output, brackets notation
10881 is only used for wide characters with a code greater than @code{16#FF#}.
10882
10883 @end table
10884
10885 @noindent
10886 For the coding schemes other than Hex and Brackets encoding,
10887 not all wide character
10888 values can be represented.  An attempt to output a character that cannot
10889 be represented using the encoding scheme for the file causes
10890 Constraint_Error to be raised.  An invalid wide character sequence on
10891 input also causes Constraint_Error to be raised.
10892
10893 @menu
10894 * Wide_Text_IO Stream Pointer Positioning::
10895 * Wide_Text_IO Reading and Writing Non-Regular Files::
10896 @end menu
10897
10898 @node Wide_Text_IO Stream Pointer Positioning
10899 @subsection Stream Pointer Positioning
10900
10901 @noindent
10902 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
10903 of stream pointer positioning (@pxref{Text_IO}).  There is one additional
10904 case:
10905
10906 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
10907 normal lower ASCII set (i.e.@: a character in the range:
10908
10909 @smallexample @c ada
10910 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
10911 @end smallexample
10912
10913 @noindent
10914 then although the logical position of the file pointer is unchanged by
10915 the @code{Look_Ahead} call, the stream is physically positioned past the
10916 wide character sequence.  Again this is to avoid the need for buffering
10917 or backup, and all @code{Wide_Text_IO} routines check the internal
10918 indication that this situation has occurred so that this is not visible
10919 to a normal program using @code{Wide_Text_IO}.  However, this discrepancy
10920 can be observed if the wide text file shares a stream with another file.
10921
10922 @node Wide_Text_IO Reading and Writing Non-Regular Files
10923 @subsection Reading and Writing Non-Regular Files
10924
10925 @noindent
10926 As in the case of Text_IO, when a non-regular file is read, it is
10927 assumed that the file contains no page marks (any form characters are
10928 treated as data characters), and @code{End_Of_Page} always returns
10929 @code{False}.  Similarly, the end of file indication is not sticky, so
10930 it is possible to read beyond an end of file.
10931
10932 @node Stream_IO
10933 @section Stream_IO
10934
10935 @noindent
10936 A stream file is a sequence of bytes, where individual elements are
10937 written to the file as described in the Ada 95 reference manual.  The type
10938 @code{Stream_Element} is simply a byte.  There are two ways to read or
10939 write a stream file.
10940
10941 @itemize @bullet
10942 @item
10943 The operations @code{Read} and @code{Write} directly read or write a
10944 sequence of stream elements with no control information.
10945
10946 @item
10947 The stream attributes applied to a stream file transfer data in the
10948 manner described for stream attributes.
10949 @end itemize
10950
10951 @node Shared Files
10952 @section Shared Files
10953
10954 @noindent
10955 Section A.14 of the Ada 95 Reference Manual allows implementations to
10956 provide a wide variety of behavior if an attempt is made to access the
10957 same external file with two or more internal files.
10958
10959 To provide a full range of functionality, while at the same time
10960 minimizing the problems of portability caused by this implementation
10961 dependence, GNAT handles file sharing as follows:
10962
10963 @itemize @bullet
10964 @item
10965 In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
10966 to open two or more files with the same full name is considered an error
10967 and is not supported.  The exception @code{Use_Error} will be
10968 raised.  Note that a file that is not explicitly closed by the program
10969 remains open until the program terminates.
10970
10971 @item
10972 If the form parameter @samp{shared=no} appears in the form string, the
10973 file can be opened or created with its own separate stream identifier,
10974 regardless of whether other files sharing the same external file are
10975 opened.  The exact effect depends on how the C stream routines handle
10976 multiple accesses to the same external files using separate streams.
10977
10978 @item
10979 If the form parameter @samp{shared=yes} appears in the form string for
10980 each of two or more files opened using the same full name, the same
10981 stream is shared between these files, and the semantics are as described
10982 in Ada 95 Reference Manual, Section A.14.
10983 @end itemize
10984
10985 @noindent
10986 When a program that opens multiple files with the same name is ported
10987 from another Ada compiler to GNAT, the effect will be that
10988 @code{Use_Error} is raised.
10989
10990 The documentation of the original compiler and the documentation of the
10991 program should then be examined to determine if file sharing was
10992 expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
10993 and @code{Create} calls as required.
10994
10995 When a program is ported from GNAT to some other Ada compiler, no
10996 special attention is required unless the @samp{shared=@var{xxx}} form
10997 parameter is used in the program.  In this case, you must examine the
10998 documentation of the new compiler to see if it supports the required
10999 file sharing semantics, and form strings modified appropriately.  Of
11000 course it may be the case that the program cannot be ported if the
11001 target compiler does not support the required functionality.  The best
11002 approach in writing portable code is to avoid file sharing (and hence
11003 the use of the @samp{shared=@var{xxx}} parameter in the form string)
11004 completely.
11005
11006 One common use of file sharing in Ada 83 is the use of instantiations of
11007 Sequential_IO on the same file with different types, to achieve
11008 heterogeneous input-output.  Although this approach will work in GNAT if
11009 @samp{shared=yes} is specified, it is preferable in Ada 95 to use Stream_IO
11010 for this purpose (using the stream attributes)
11011
11012 @node Open Modes
11013 @section Open Modes
11014
11015 @noindent
11016 @code{Open} and @code{Create} calls result in a call to @code{fopen}
11017 using the mode shown in the following table:
11018
11019 @sp 2
11020 @center @code{Open} and @code{Create} Call Modes
11021 @smallexample
11022                                @b{OPEN }           @b{CREATE}
11023 Append_File                    "r+"             "w+"
11024 In_File                        "r"              "w+"
11025 Out_File (Direct_IO)           "r+"             "w"
11026 Out_File (all other cases)     "w"              "w"
11027 Inout_File                     "r+"             "w+"
11028 @end smallexample
11029
11030 @noindent
11031 If text file translation is required, then either @samp{b} or @samp{t}
11032 is added to the mode, depending on the setting of Text.  Text file
11033 translation refers to the mapping of CR/LF sequences in an external file
11034 to LF characters internally.  This mapping only occurs in DOS and
11035 DOS-like systems, and is not relevant to other systems.
11036
11037 A special case occurs with Stream_IO@.  As shown in the above table, the
11038 file is initially opened in @samp{r} or @samp{w} mode for the
11039 @code{In_File} and @code{Out_File} cases.  If a @code{Set_Mode} operation
11040 subsequently requires switching from reading to writing or vice-versa,
11041 then the file is reopened in @samp{r+} mode to permit the required operation.
11042
11043 @node Operations on C Streams
11044 @section Operations on C Streams
11045 The package @code{Interfaces.C_Streams} provides an Ada program with direct
11046 access to the C library functions for operations on C streams:
11047
11048 @smallexample @c adanocomment
11049 package Interfaces.C_Streams is
11050   -- Note: the reason we do not use the types that are in
11051   -- Interfaces.C is that we want to avoid dragging in the
11052   -- code in this unit if possible.
11053   subtype chars is System.Address;
11054   -- Pointer to null-terminated array of characters
11055   subtype FILEs is System.Address;
11056   -- Corresponds to the C type FILE*
11057   subtype voids is System.Address;
11058   -- Corresponds to the C type void*
11059   subtype int is Integer;
11060   subtype long is Long_Integer;
11061   -- Note: the above types are subtypes deliberately, and it
11062   -- is part of this spec that the above correspondences are
11063   -- guaranteed.  This means that it is legitimate to, for
11064   -- example, use Integer instead of int.  We provide these
11065   -- synonyms for clarity, but in some cases it may be
11066   -- convenient to use the underlying types (for example to
11067   -- avoid an unnecessary dependency of a spec on the spec
11068   -- of this unit).
11069   type size_t is mod 2 ** Standard'Address_Size;
11070   NULL_Stream : constant FILEs;
11071   -- Value returned (NULL in C) to indicate an
11072   -- fdopen/fopen/tmpfile error
11073   ----------------------------------
11074   -- Constants Defined in stdio.h --
11075   ----------------------------------
11076   EOF : constant int;
11077   -- Used by a number of routines to indicate error or
11078   -- end of file
11079   IOFBF : constant int;
11080   IOLBF : constant int;
11081   IONBF : constant int;
11082   -- Used to indicate buffering mode for setvbuf call
11083   SEEK_CUR : constant int;
11084   SEEK_END : constant int;
11085   SEEK_SET : constant int;
11086   -- Used to indicate origin for fseek call
11087   function stdin return FILEs;
11088   function stdout return FILEs;
11089   function stderr return FILEs;
11090   -- Streams associated with standard files
11091   --------------------------
11092   -- Standard C functions --
11093   --------------------------
11094   -- The functions selected below are ones that are
11095   -- available in DOS, OS/2, UNIX and Xenix (but not
11096   -- necessarily in ANSI C).  These are very thin interfaces
11097   -- which copy exactly the C headers.  For more
11098   -- documentation on these functions, see the Microsoft C
11099   -- "Run-Time Library Reference" (Microsoft Press, 1990,
11100   -- ISBN 1-55615-225-6), which includes useful information
11101   -- on system compatibility.
11102   procedure clearerr (stream : FILEs);
11103   function fclose (stream : FILEs) return int;
11104   function fdopen (handle : int; mode : chars) return FILEs;
11105   function feof (stream : FILEs) return int;
11106   function ferror (stream : FILEs) return int;
11107   function fflush (stream : FILEs) return int;
11108   function fgetc (stream : FILEs) return int;
11109   function fgets (strng : chars; n : int; stream : FILEs)
11110       return chars;
11111   function fileno (stream : FILEs) return int;
11112   function fopen (filename : chars; Mode : chars)
11113       return FILEs;
11114   -- Note: to maintain target independence, use
11115   -- text_translation_required, a boolean variable defined in
11116   -- a-sysdep.c to deal with the target dependent text
11117   -- translation requirement.  If this variable is set,
11118   -- then  b/t should be appended to the standard mode
11119   -- argument to set the text translation mode off or on
11120   -- as required.
11121   function fputc (C : int; stream : FILEs) return int;
11122   function fputs (Strng : chars; Stream : FILEs) return int;
11123   function fread
11124      (buffer : voids;
11125       size : size_t;
11126       count : size_t;
11127       stream : FILEs)
11128       return size_t;
11129   function freopen
11130      (filename : chars;
11131       mode : chars;
11132       stream : FILEs)
11133       return FILEs;
11134   function fseek
11135      (stream : FILEs;
11136       offset : long;
11137       origin : int)
11138       return int;
11139   function ftell (stream : FILEs) return long;
11140   function fwrite
11141      (buffer : voids;
11142       size : size_t;
11143       count : size_t;
11144       stream : FILEs)
11145       return size_t;
11146   function isatty (handle : int) return int;
11147   procedure mktemp (template : chars);
11148   -- The return value (which is just a pointer to template)
11149   -- is discarded
11150   procedure rewind (stream : FILEs);
11151   function rmtmp return int;
11152   function setvbuf
11153      (stream : FILEs;
11154       buffer : chars;
11155       mode : int;
11156       size : size_t)
11157       return int;
11158
11159   function tmpfile return FILEs;
11160   function ungetc (c : int; stream : FILEs) return int;
11161   function unlink (filename : chars) return int;
11162   ---------------------
11163   -- Extra functions --
11164   ---------------------
11165   -- These functions supply slightly thicker bindings than
11166   -- those above.  They are derived from functions in the
11167   -- C Run-Time Library, but may do a bit more work than
11168   -- just directly calling one of the Library functions.
11169   function is_regular_file (handle : int) return int;
11170   -- Tests if given handle is for a regular file (result 1)
11171   -- or for a non-regular file (pipe or device, result 0).
11172   ---------------------------------
11173   -- Control of Text/Binary Mode --
11174   ---------------------------------
11175   -- If text_translation_required is true, then the following
11176   -- functions may be used to dynamically switch a file from
11177   -- binary to text mode or vice versa.  These functions have
11178   -- no effect if text_translation_required is false (i.e.  in
11179   -- normal UNIX mode).  Use fileno to get a stream handle.
11180   procedure set_binary_mode (handle : int);
11181   procedure set_text_mode (handle : int);
11182   ----------------------------
11183   -- Full Path Name support --
11184   ----------------------------
11185   procedure full_name (nam : chars; buffer : chars);
11186   -- Given a NUL terminated string representing a file
11187   -- name, returns in buffer a NUL terminated string
11188   -- representing the full path name for the file name.
11189   -- On systems where it is relevant the   drive is also
11190   -- part of the full path name.  It is the responsibility
11191   -- of the caller to pass an actual parameter for buffer
11192   -- that is big enough for any full path name.  Use
11193   -- max_path_len given below as the size of buffer.
11194   max_path_len : integer;
11195   -- Maximum length of an allowable full path name on the
11196   -- system, including a terminating NUL character.
11197 end Interfaces.C_Streams;
11198 @end smallexample
11199
11200 @node Interfacing to C Streams
11201 @section Interfacing to C Streams
11202
11203 @noindent
11204 The packages in this section permit interfacing Ada files to C Stream
11205 operations.
11206
11207 @smallexample @c ada
11208  with Interfaces.C_Streams;
11209  package Ada.Sequential_IO.C_Streams is
11210     function C_Stream (F : File_Type)
11211        return Interfaces.C_Streams.FILEs;
11212     procedure Open
11213       (File : in out File_Type;
11214        Mode : in File_Mode;
11215        C_Stream : in Interfaces.C_Streams.FILEs;
11216        Form : in String := "");
11217  end Ada.Sequential_IO.C_Streams;
11218
11219   with Interfaces.C_Streams;
11220   package Ada.Direct_IO.C_Streams is
11221      function C_Stream (F : File_Type)
11222         return Interfaces.C_Streams.FILEs;
11223      procedure Open
11224        (File : in out File_Type;
11225         Mode : in File_Mode;
11226         C_Stream : in Interfaces.C_Streams.FILEs;
11227         Form : in String := "");
11228   end Ada.Direct_IO.C_Streams;
11229
11230   with Interfaces.C_Streams;
11231   package Ada.Text_IO.C_Streams is
11232      function C_Stream (F : File_Type)
11233         return Interfaces.C_Streams.FILEs;
11234      procedure Open
11235        (File : in out File_Type;
11236         Mode : in File_Mode;
11237         C_Stream : in Interfaces.C_Streams.FILEs;
11238         Form : in String := "");
11239   end Ada.Text_IO.C_Streams;
11240
11241   with Interfaces.C_Streams;
11242   package Ada.Wide_Text_IO.C_Streams is
11243      function C_Stream (F : File_Type)
11244         return Interfaces.C_Streams.FILEs;
11245      procedure Open
11246        (File : in out File_Type;
11247         Mode : in File_Mode;
11248         C_Stream : in Interfaces.C_Streams.FILEs;
11249         Form : in String := "");
11250  end Ada.Wide_Text_IO.C_Streams;
11251
11252  with Interfaces.C_Streams;
11253  package Ada.Stream_IO.C_Streams is
11254     function C_Stream (F : File_Type)
11255        return Interfaces.C_Streams.FILEs;
11256     procedure Open
11257       (File : in out File_Type;
11258        Mode : in File_Mode;
11259        C_Stream : in Interfaces.C_Streams.FILEs;
11260        Form : in String := "");
11261  end Ada.Stream_IO.C_Streams;
11262 @end smallexample
11263
11264 @noindent
11265 In each of these five packages, the @code{C_Stream} function obtains the
11266 @code{FILE} pointer from a currently opened Ada file.  It is then
11267 possible to use the @code{Interfaces.C_Streams} package to operate on
11268 this stream, or the stream can be passed to a C program which can
11269 operate on it directly.  Of course the program is responsible for
11270 ensuring that only appropriate sequences of operations are executed.
11271
11272 One particular use of relevance to an Ada program is that the
11273 @code{setvbuf} function can be used to control the buffering of the
11274 stream used by an Ada file.  In the absence of such a call the standard
11275 default buffering is used.
11276
11277 The @code{Open} procedures in these packages open a file giving an
11278 existing C Stream instead of a file name.  Typically this stream is
11279 imported from a C program, allowing an Ada file to operate on an
11280 existing C file.
11281
11282 @node The GNAT Library
11283 @chapter The GNAT Library
11284
11285 @noindent
11286 The GNAT library contains a number of general and special purpose packages.
11287 It represents functionality that the GNAT developers have found useful, and
11288 which is made available to GNAT users.  The packages described here are fully
11289 supported, and upwards compatibility will be maintained in future releases,
11290 so you can use these facilities with the confidence that the same functionality
11291 will be available in future releases.
11292
11293 The chapter here simply gives a brief summary of the facilities available.
11294 The full documentation is found in the spec file for the package.  The full
11295 sources of these library packages, including both spec and body, are provided
11296 with all GNAT releases.  For example, to find out the full specifications of
11297 the SPITBOL pattern matching capability, including a full tutorial and
11298 extensive examples, look in the @file{g-spipat.ads} file in the library.
11299
11300 For each entry here, the package name (as it would appear in a @code{with}
11301 clause) is given, followed by the name of the corresponding spec file in
11302 parentheses.  The packages are children in four hierarchies, @code{Ada},
11303 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
11304 GNAT-specific hierarchy.
11305
11306 Note that an application program should only use packages in one of these
11307 four hierarchies if the package is defined in the Ada Reference Manual,
11308 or is listed in this section of the GNAT Programmers Reference Manual.
11309 All other units should be considered internal implementation units and
11310 should not be directly @code{with}'ed by application code.  The use of
11311 a @code{with} statement that references one of these internal implementation
11312 units makes an application potentially dependent on changes in versions
11313 of GNAT, and will generate a warning message.
11314
11315 @menu
11316 * Ada.Characters.Latin_9 (a-chlat9.ads)::
11317 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
11318 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
11319 * Ada.Command_Line.Remove (a-colire.ads)::
11320 * Ada.Command_Line.Environment (a-colien.ads)::
11321 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
11322 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
11323 * Ada.Exceptions.Traceback (a-exctra.ads)::
11324 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
11325 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
11326 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
11327 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
11328 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
11329 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
11330 * GNAT.Array_Split (g-arrspl.ads)::
11331 * GNAT.AWK (g-awk.ads)::
11332 * GNAT.Bounded_Buffers (g-boubuf.ads)::
11333 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
11334 * GNAT.Bubble_Sort (g-bubsor.ads)::
11335 * GNAT.Bubble_Sort_A (g-busora.ads)::
11336 * GNAT.Bubble_Sort_G (g-busorg.ads)::
11337 * GNAT.Calendar (g-calend.ads)::
11338 * GNAT.Calendar.Time_IO (g-catiio.ads)::
11339 * GNAT.CRC32 (g-crc32.ads)::
11340 * GNAT.Case_Util (g-casuti.ads)::
11341 * GNAT.CGI (g-cgi.ads)::
11342 * GNAT.CGI.Cookie (g-cgicoo.ads)::
11343 * GNAT.CGI.Debug (g-cgideb.ads)::
11344 * GNAT.Command_Line (g-comlin.ads)::
11345 * GNAT.Compiler_Version (g-comver.ads)::
11346 * GNAT.Ctrl_C (g-ctrl_c.ads)::
11347 * GNAT.Current_Exception (g-curexc.ads)::
11348 * GNAT.Debug_Pools (g-debpoo.ads)::
11349 * GNAT.Debug_Utilities (g-debuti.ads)::
11350 * GNAT.Directory_Operations (g-dirope.ads)::
11351 * GNAT.Dynamic_HTables (g-dynhta.ads)::
11352 * GNAT.Dynamic_Tables (g-dyntab.ads)::
11353 * GNAT.Exception_Actions (g-excact.ads)::
11354 * GNAT.Exception_Traces (g-exctra.ads)::
11355 * GNAT.Exceptions (g-except.ads)::
11356 * GNAT.Expect (g-expect.ads)::
11357 * GNAT.Float_Control (g-flocon.ads)::
11358 * GNAT.Heap_Sort (g-heasor.ads)::
11359 * GNAT.Heap_Sort_A (g-hesora.ads)::
11360 * GNAT.Heap_Sort_G (g-hesorg.ads)::
11361 * GNAT.HTable (g-htable.ads)::
11362 * GNAT.IO (g-io.ads)::
11363 * GNAT.IO_Aux (g-io_aux.ads)::
11364 * GNAT.Lock_Files (g-locfil.ads)::
11365 * GNAT.MD5 (g-md5.ads)::
11366 * GNAT.Memory_Dump (g-memdum.ads)::
11367 * GNAT.Most_Recent_Exception (g-moreex.ads)::
11368 * GNAT.OS_Lib (g-os_lib.ads)::
11369 * GNAT.Perfect_Hash.Generators (g-pehage.ads)::
11370 * GNAT.Regexp (g-regexp.ads)::
11371 * GNAT.Registry (g-regist.ads)::
11372 * GNAT.Regpat (g-regpat.ads)::
11373 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
11374 * GNAT.Semaphores (g-semaph.ads)::
11375 * GNAT.Signals (g-signal.ads)::
11376 * GNAT.Sockets (g-socket.ads)::
11377 * GNAT.Source_Info (g-souinf.ads)::
11378 * GNAT.Spell_Checker (g-speche.ads)::
11379 * GNAT.Spitbol.Patterns (g-spipat.ads)::
11380 * GNAT.Spitbol (g-spitbo.ads)::
11381 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
11382 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
11383 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
11384 * GNAT.Strings (g-string.ads)::
11385 * GNAT.String_Split (g-strspl.ads)::
11386 * GNAT.Table (g-table.ads)::
11387 * GNAT.Task_Lock (g-tasloc.ads)::
11388 * GNAT.Threads (g-thread.ads)::
11389 * GNAT.Traceback (g-traceb.ads)::
11390 * GNAT.Traceback.Symbolic (g-trasym.ads)::
11391 * GNAT.Wide_String_Split (g-wistsp.ads)::
11392 * Interfaces.C.Extensions (i-cexten.ads)::
11393 * Interfaces.C.Streams (i-cstrea.ads)::
11394 * Interfaces.CPP (i-cpp.ads)::
11395 * Interfaces.Os2lib (i-os2lib.ads)::
11396 * Interfaces.Os2lib.Errors (i-os2err.ads)::
11397 * Interfaces.Os2lib.Synchronization (i-os2syn.ads)::
11398 * Interfaces.Os2lib.Threads (i-os2thr.ads)::
11399 * Interfaces.Packed_Decimal (i-pacdec.ads)::
11400 * Interfaces.VxWorks (i-vxwork.ads)::
11401 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
11402 * System.Address_Image (s-addima.ads)::
11403 * System.Assertions (s-assert.ads)::
11404 * System.Memory (s-memory.ads)::
11405 * System.Partition_Interface (s-parint.ads)::
11406 * System.Restrictions (s-restri.ads)::
11407 * System.Rident (s-rident.ads)::
11408 * System.Task_Info (s-tasinf.ads)::
11409 * System.Wch_Cnv (s-wchcnv.ads)::
11410 * System.Wch_Con (s-wchcon.ads)::
11411 @end menu
11412
11413 @node Ada.Characters.Latin_9 (a-chlat9.ads)
11414 @section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
11415 @cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
11416 @cindex Latin_9 constants for Character
11417
11418 @noindent
11419 This child of @code{Ada.Characters}
11420 provides a set of definitions corresponding to those in the
11421 RM-defined package @code{Ada.Characters.Latin_1} but with the
11422 few modifications required for @code{Latin-9}
11423 The provision of such a package
11424 is specifically authorized by the Ada Reference Manual
11425 (RM A.3(27)).
11426
11427 @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
11428 @section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
11429 @cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
11430 @cindex Latin_1 constants for Wide_Character
11431
11432 @noindent
11433 This child of @code{Ada.Characters}
11434 provides a set of definitions corresponding to those in the
11435 RM-defined package @code{Ada.Characters.Latin_1} but with the
11436 types of the constants being @code{Wide_Character}
11437 instead of @code{Character}.  The provision of such a package
11438 is specifically authorized by the Ada Reference Manual
11439 (RM A.3(27)).
11440
11441 @node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
11442 @section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
11443 @cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
11444 @cindex Latin_9 constants for Wide_Character
11445
11446 @noindent
11447 This child of @code{Ada.Characters}
11448 provides a set of definitions corresponding to those in the
11449 GNAT defined package @code{Ada.Characters.Latin_9} but with the
11450 types of the constants being @code{Wide_Character}
11451 instead of @code{Character}.  The provision of such a package
11452 is specifically authorized by the Ada Reference Manual
11453 (RM A.3(27)).
11454
11455 @node Ada.Command_Line.Remove (a-colire.ads)
11456 @section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
11457 @cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
11458 @cindex Removing command line arguments
11459 @cindex Command line, argument removal
11460
11461 @noindent
11462 This child of @code{Ada.Command_Line}
11463 provides a mechanism for logically removing
11464 arguments from the argument list.  Once removed, an argument is not visible
11465 to further calls on the subprograms in @code{Ada.Command_Line} will not
11466 see the removed argument.
11467
11468 @node Ada.Command_Line.Environment (a-colien.ads)
11469 @section @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
11470 @cindex @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
11471 @cindex Environment entries
11472
11473 @noindent
11474 This child of @code{Ada.Command_Line}
11475 provides a mechanism for obtaining environment values on systems
11476 where this concept makes sense.
11477
11478 @node Ada.Direct_IO.C_Streams (a-diocst.ads)
11479 @section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
11480 @cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
11481 @cindex C Streams, Interfacing with Direct_IO
11482
11483 @noindent
11484 This package provides subprograms that allow interfacing between
11485 C streams and @code{Direct_IO}.  The stream identifier can be
11486 extracted from a file opened on the Ada side, and an Ada file
11487 can be constructed from a stream opened on the C side.
11488
11489 @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
11490 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
11491 @cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
11492 @cindex Null_Occurrence, testing for
11493
11494 @noindent
11495 This child subprogram provides a way of testing for the null
11496 exception occurrence (@code{Null_Occurrence}) without raising
11497 an exception.
11498
11499 @node Ada.Exceptions.Traceback (a-exctra.ads)
11500 @section @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
11501 @cindex @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
11502 @cindex Traceback for Exception Occurrence
11503
11504 @noindent
11505 This child package provides the subprogram (@code{Tracebacks}) to
11506 give a traceback array of addresses based on an exception
11507 occurrence.
11508
11509 @node Ada.Sequential_IO.C_Streams (a-siocst.ads)
11510 @section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
11511 @cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
11512 @cindex C Streams, Interfacing with Sequential_IO
11513
11514 @noindent
11515 This package provides subprograms that allow interfacing between
11516 C streams and @code{Sequential_IO}.  The stream identifier can be
11517 extracted from a file opened on the Ada side, and an Ada file
11518 can be constructed from a stream opened on the C side.
11519
11520 @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
11521 @section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
11522 @cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
11523 @cindex C Streams, Interfacing with Stream_IO
11524
11525 @noindent
11526 This package provides subprograms that allow interfacing between
11527 C streams and @code{Stream_IO}.  The stream identifier can be
11528 extracted from a file opened on the Ada side, and an Ada file
11529 can be constructed from a stream opened on the C side.
11530
11531 @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
11532 @section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
11533 @cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
11534 @cindex @code{Unbounded_String}, IO support
11535 @cindex @code{Text_IO}, extensions for unbounded strings
11536
11537 @noindent
11538 This package provides subprograms for Text_IO for unbounded
11539 strings, avoiding the necessity for an intermediate operation
11540 with ordinary strings.
11541
11542 @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
11543 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
11544 @cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
11545 @cindex @code{Unbounded_Wide_String}, IO support
11546 @cindex @code{Text_IO}, extensions for unbounded wide strings
11547
11548 @noindent
11549 This package provides subprograms for Text_IO for unbounded
11550 wide strings, avoiding the necessity for an intermediate operation
11551 with ordinary wide strings.
11552
11553 @node Ada.Text_IO.C_Streams (a-tiocst.ads)
11554 @section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
11555 @cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
11556 @cindex C Streams, Interfacing with @code{Text_IO}
11557
11558 @noindent
11559 This package provides subprograms that allow interfacing between
11560 C streams and @code{Text_IO}.  The stream identifier can be
11561 extracted from a file opened on the Ada side, and an Ada file
11562 can be constructed from a stream opened on the C side.
11563
11564 @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
11565 @section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
11566 @cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
11567 @cindex C Streams, Interfacing with @code{Wide_Text_IO}
11568
11569 @noindent
11570 This package provides subprograms that allow interfacing between
11571 C streams and @code{Wide_Text_IO}.  The stream identifier can be
11572 extracted from a file opened on the Ada side, and an Ada file
11573 can be constructed from a stream opened on the C side.
11574
11575 @node GNAT.Array_Split (g-arrspl.ads)
11576 @section @code{GNAT.Array_Split} (@file{g-arrspl.ads})
11577 @cindex @code{GNAT.Array_Split} (@file{g-arrspl.ads})
11578 @cindex Array splitter
11579
11580 @noindent
11581 Useful array-manipulation routines: given a set of separators, split
11582 an array wherever the separators appear, and provide direct access
11583 to the resulting slices.
11584
11585 @node GNAT.AWK (g-awk.ads)
11586 @section @code{GNAT.AWK} (@file{g-awk.ads})
11587 @cindex @code{GNAT.AWK} (@file{g-awk.ads})
11588 @cindex Parsing
11589 @cindex AWK
11590
11591 @noindent
11592 Provides AWK-like parsing functions, with an easy interface for parsing one
11593 or more files containing formatted data.  The file is viewed as a database
11594 where each record is a line and a field is a data element in this line.
11595
11596 @node GNAT.Bounded_Buffers (g-boubuf.ads)
11597 @section @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
11598 @cindex @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
11599 @cindex Parsing
11600 @cindex Bounded Buffers
11601
11602 @noindent
11603 Provides a concurrent generic bounded buffer abstraction.  Instances are
11604 useful directly or as parts of the implementations of other abstractions,
11605 such as mailboxes.
11606
11607 @node GNAT.Bounded_Mailboxes (g-boumai.ads)
11608 @section @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
11609 @cindex @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
11610 @cindex Parsing
11611 @cindex Mailboxes
11612
11613 @noindent
11614 Provides a thread-safe asynchronous intertask mailbox communication facility.
11615
11616 @node GNAT.Bubble_Sort (g-bubsor.ads)
11617 @section @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
11618 @cindex @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
11619 @cindex Sorting
11620 @cindex Bubble sort
11621
11622 @noindent
11623 Provides a general implementation of bubble sort usable for sorting arbitrary
11624 data items.  Exchange and comparison procedures are provided by passing
11625 access-to-procedure values.
11626
11627 @node GNAT.Bubble_Sort_A (g-busora.ads)
11628 @section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
11629 @cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
11630 @cindex Sorting
11631 @cindex Bubble sort
11632
11633 @noindent
11634 Provides a general implementation of bubble sort usable for sorting arbitrary
11635 data items.  Move and comparison procedures are provided by passing
11636 access-to-procedure values. This is an older version, retained for
11637 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
11638
11639 @node GNAT.Bubble_Sort_G (g-busorg.ads)
11640 @section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
11641 @cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
11642 @cindex Sorting
11643 @cindex Bubble sort
11644
11645 @noindent
11646 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
11647 are provided as generic parameters, this improves efficiency, especially
11648 if the procedures can be inlined, at the expense of duplicating code for
11649 multiple instantiations.
11650
11651 @node GNAT.Calendar (g-calend.ads)
11652 @section @code{GNAT.Calendar} (@file{g-calend.ads})
11653 @cindex @code{GNAT.Calendar} (@file{g-calend.ads})
11654 @cindex @code{Calendar}
11655
11656 @noindent
11657 Extends the facilities provided by @code{Ada.Calendar} to include handling
11658 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
11659 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
11660 C @code{timeval} format.
11661
11662 @node GNAT.Calendar.Time_IO (g-catiio.ads)
11663 @section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
11664 @cindex @code{Calendar}
11665 @cindex Time
11666 @cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
11667
11668 @node GNAT.CRC32 (g-crc32.ads)
11669 @section @code{GNAT.CRC32} (@file{g-crc32.ads})
11670 @cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
11671 @cindex CRC32
11672 @cindex Cyclic Redundancy Check
11673
11674 @noindent
11675 This package implements the CRC-32 algorithm.  For a full description
11676 of this algorithm see
11677 ``Computation of Cyclic Redundancy Checks via Table Look-Up'',
11678 @cite{Communications of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013,
11679 Aug.@: 1988.  Sarwate, D.V@.
11680
11681 @noindent
11682 Provides an extended capability for formatted output of time values with
11683 full user control over the format.  Modeled on the GNU Date specification.
11684
11685 @node GNAT.Case_Util (g-casuti.ads)
11686 @section @code{GNAT.Case_Util} (@file{g-casuti.ads})
11687 @cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
11688 @cindex Casing utilities
11689 @cindex Character handling (@code{GNAT.Case_Util})
11690
11691 @noindent
11692 A set of simple routines for handling upper and lower casing of strings
11693 without the overhead of the full casing tables
11694 in @code{Ada.Characters.Handling}.
11695
11696 @node GNAT.CGI (g-cgi.ads)
11697 @section @code{GNAT.CGI} (@file{g-cgi.ads})
11698 @cindex @code{GNAT.CGI} (@file{g-cgi.ads})
11699 @cindex CGI (Common Gateway Interface)
11700
11701 @noindent
11702 This is a package for interfacing a GNAT program with a Web server via the
11703 Common Gateway Interface (CGI)@.  Basically this package parses the CGI
11704 parameters, which are a set of key/value pairs sent by the Web server.  It
11705 builds a table whose index is the key and provides some services to deal
11706 with this table.
11707
11708 @node GNAT.CGI.Cookie (g-cgicoo.ads)
11709 @section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
11710 @cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
11711 @cindex CGI (Common Gateway Interface) cookie support
11712 @cindex Cookie support in CGI
11713
11714 @noindent
11715 This is a package to interface a GNAT program with a Web server via the
11716 Common Gateway Interface (CGI).  It exports services to deal with Web
11717 cookies (piece of information kept in the Web client software).
11718
11719 @node GNAT.CGI.Debug (g-cgideb.ads)
11720 @section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
11721 @cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
11722 @cindex CGI (Common Gateway Interface) debugging
11723
11724 @noindent
11725 This is a package to help debugging CGI (Common Gateway Interface)
11726 programs written in Ada.
11727
11728 @node GNAT.Command_Line (g-comlin.ads)
11729 @section @code{GNAT.Command_Line} (@file{g-comlin.ads})
11730 @cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
11731 @cindex Command line
11732
11733 @noindent
11734 Provides a high level interface to @code{Ada.Command_Line} facilities,
11735 including the ability to scan for named switches with optional parameters
11736 and expand file names using wild card notations.
11737
11738 @node GNAT.Compiler_Version (g-comver.ads)
11739 @section @code{GNAT.Compiler_Version} (@file{g-comver.ads})
11740 @cindex @code{GNAT.Compiler_Version} (@file{g-comver.ads})
11741 @cindex Compiler Version
11742 @cindex Version, of compiler
11743
11744 @noindent
11745 Provides a routine for obtaining the version of the compiler used to
11746 compile the program. More accurately this is the version of the binder
11747 used to bind the program (this will normally be the same as the version
11748 of the compiler if a consistent tool set is used to compile all units
11749 of a partition).
11750
11751 @node GNAT.Ctrl_C (g-ctrl_c.ads)
11752 @section @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
11753 @cindex @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
11754 @cindex Interrupt
11755
11756 @noindent
11757 Provides a simple interface to handle Ctrl-C keyboard events.
11758
11759 @node GNAT.Current_Exception (g-curexc.ads)
11760 @section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
11761 @cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
11762 @cindex Current exception
11763 @cindex Exception retrieval
11764
11765 @noindent
11766 Provides access to information on the current exception that has been raised
11767 without the need for using the Ada-95 exception choice parameter specification
11768 syntax.  This is particularly useful in simulating typical facilities for
11769 obtaining information about exceptions provided by Ada 83 compilers.
11770
11771 @node GNAT.Debug_Pools (g-debpoo.ads)
11772 @section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
11773 @cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
11774 @cindex Debugging
11775 @cindex Debug pools
11776 @cindex Memory corruption debugging
11777
11778 @noindent
11779 Provide a debugging storage pools that helps tracking memory corruption
11780 problems.  See section ``Finding memory problems with GNAT Debug Pool'' in
11781 the @cite{GNAT User's Guide}.
11782
11783 @node GNAT.Debug_Utilities (g-debuti.ads)
11784 @section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
11785 @cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
11786 @cindex Debugging
11787
11788 @noindent
11789 Provides a few useful utilities for debugging purposes, including conversion
11790 to and from string images of address values. Supports both C and Ada formats
11791 for hexadecimal literals.
11792
11793 @node GNAT.Directory_Operations (g-dirope.ads)
11794 @section @code{GNAT.Directory_Operations} (g-dirope.ads)
11795 @cindex @code{GNAT.Directory_Operations} (g-dirope.ads)
11796 @cindex Directory operations
11797
11798 @noindent
11799 Provides a set of routines for manipulating directories, including changing
11800 the current directory, making new directories, and scanning the files in a
11801 directory.
11802
11803 @node GNAT.Dynamic_HTables (g-dynhta.ads)
11804 @section @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
11805 @cindex @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
11806 @cindex Hash tables
11807
11808 @noindent
11809 A generic implementation of hash tables that can be used to hash arbitrary
11810 data.  Provided in two forms, a simple form with built in hash functions,
11811 and a more complex form in which the hash function is supplied.
11812
11813 @noindent
11814 This package provides a facility similar to that of @code{GNAT.HTable},
11815 except that this package declares a type that can be used to define
11816 dynamic instances of the hash table, while an instantiation of
11817 @code{GNAT.HTable} creates a single instance of the hash table.
11818
11819 @node GNAT.Dynamic_Tables (g-dyntab.ads)
11820 @section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
11821 @cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
11822 @cindex Table implementation
11823 @cindex Arrays, extendable
11824
11825 @noindent
11826 A generic package providing a single dimension array abstraction where the
11827 length of the array can be dynamically modified.
11828
11829 @noindent
11830 This package provides a facility similar to that of @code{GNAT.Table},
11831 except that this package declares a type that can be used to define
11832 dynamic instances of the table, while an instantiation of
11833 @code{GNAT.Table} creates a single instance of the table type.
11834
11835 @node GNAT.Exception_Actions (g-excact.ads)
11836 @section @code{GNAT.Exception_Actions} (@file{g-excact.ads})
11837 @cindex @code{GNAT.Exception_Actions} (@file{g-excact.ads})
11838 @cindex Exception actions
11839
11840 @noindent
11841 Provides callbacks when an exception is raised. Callbacks can be registered
11842 for specific exceptions, or when any exception is raised. This
11843 can be used for instance to force a core dump to ease debugging.
11844
11845 @node GNAT.Exception_Traces (g-exctra.ads)
11846 @section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
11847 @cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
11848 @cindex Exception traces
11849 @cindex Debugging
11850
11851 @noindent
11852 Provides an interface allowing to control automatic output upon exception
11853 occurrences.
11854
11855 @node GNAT.Exceptions (g-except.ads)
11856 @section @code{GNAT.Exceptions} (@file{g-expect.ads})
11857 @cindex @code{GNAT.Exceptions} (@file{g-expect.ads})
11858 @cindex Exceptions, Pure
11859 @cindex Pure packages, exceptions
11860
11861 @noindent
11862 Normally it is not possible to raise an exception with
11863 a message from a subprogram in a pure package, since the
11864 necessary types and subprograms are in @code{Ada.Exceptions}
11865 which is not a pure unit. @code{GNAT.Exceptions} provides a
11866 facility for getting around this limitation for a few
11867 predefined exceptions, and for example allow raising
11868 @code{Constraint_Error} with a message from a pure subprogram.
11869
11870 @node GNAT.Expect (g-expect.ads)
11871 @section @code{GNAT.Expect} (@file{g-expect.ads})
11872 @cindex @code{GNAT.Expect} (@file{g-expect.ads})
11873
11874 @noindent
11875 Provides a set of subprograms similar to what is available
11876 with the standard Tcl Expect tool.
11877 It allows you to easily spawn and communicate with an external process.
11878 You can send commands or inputs to the process, and compare the output
11879 with some expected regular expression. Currently @code{GNAT.Expect}
11880 is implemented on all native GNAT ports except for OpenVMS@.
11881 It is not implemented for cross ports, and in particular is not
11882 implemented for VxWorks or LynxOS@.
11883
11884 @node GNAT.Float_Control (g-flocon.ads)
11885 @section @code{GNAT.Float_Control} (@file{g-flocon.ads})
11886 @cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
11887 @cindex Floating-Point Processor
11888
11889 @noindent
11890 Provides an interface for resetting the floating-point processor into the
11891 mode required for correct semantic operation in Ada.  Some third party
11892 library calls may cause this mode to be modified, and the Reset procedure
11893 in this package can be used to reestablish the required mode.
11894
11895 @node GNAT.Heap_Sort (g-heasor.ads)
11896 @section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
11897 @cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
11898 @cindex Sorting
11899
11900 @noindent
11901 Provides a general implementation of heap sort usable for sorting arbitrary
11902 data items. Exchange and comparison procedures are provided by passing
11903 access-to-procedure values.  The algorithm used is a modified heap sort
11904 that performs approximately N*log(N) comparisons in the worst case.
11905
11906 @node GNAT.Heap_Sort_A (g-hesora.ads)
11907 @section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
11908 @cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
11909 @cindex Sorting
11910
11911 @noindent
11912 Provides a general implementation of heap sort usable for sorting arbitrary
11913 data items. Move and comparison procedures are provided by passing
11914 access-to-procedure values.  The algorithm used is a modified heap sort
11915 that performs approximately N*log(N) comparisons in the worst case.
11916 This differs from @code{GNAT.Heap_Sort} in having a less convenient
11917 interface, but may be slightly more efficient.
11918
11919 @node GNAT.Heap_Sort_G (g-hesorg.ads)
11920 @section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
11921 @cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
11922 @cindex Sorting
11923
11924 @noindent
11925 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
11926 are provided as generic parameters, this improves efficiency, especially
11927 if the procedures can be inlined, at the expense of duplicating code for
11928 multiple instantiations.
11929
11930 @node GNAT.HTable (g-htable.ads)
11931 @section @code{GNAT.HTable} (@file{g-htable.ads})
11932 @cindex @code{GNAT.HTable} (@file{g-htable.ads})
11933 @cindex Hash tables
11934
11935 @noindent
11936 A generic implementation of hash tables that can be used to hash arbitrary
11937 data.  Provides two approaches, one a simple static approach, and the other
11938 allowing arbitrary dynamic hash tables.
11939
11940 @node GNAT.IO (g-io.ads)
11941 @section @code{GNAT.IO} (@file{g-io.ads})
11942 @cindex @code{GNAT.IO} (@file{g-io.ads})
11943 @cindex Simple I/O
11944 @cindex Input/Output facilities
11945
11946 @noindent
11947 A simple preelaborable input-output package that provides a subset of
11948 simple Text_IO functions for reading characters and strings from
11949 Standard_Input, and writing characters, strings and integers to either
11950 Standard_Output or Standard_Error.
11951
11952 @node GNAT.IO_Aux (g-io_aux.ads)
11953 @section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
11954 @cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
11955 @cindex Text_IO
11956 @cindex Input/Output facilities
11957
11958 Provides some auxiliary functions for use with Text_IO, including a test
11959 for whether a file exists, and functions for reading a line of text.
11960
11961 @node GNAT.Lock_Files (g-locfil.ads)
11962 @section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
11963 @cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
11964 @cindex File locking
11965 @cindex Locking using files
11966
11967 @noindent
11968 Provides a general interface for using files as locks.  Can be used for
11969 providing program level synchronization.
11970
11971 @node GNAT.MD5 (g-md5.ads)
11972 @section @code{GNAT.MD5} (@file{g-md5.ads})
11973 @cindex @code{GNAT.MD5} (@file{g-md5.ads})
11974 @cindex Message Digest MD5
11975
11976 @noindent
11977 Implements the MD5 Message-Digest Algorithm as described in RFC 1321.
11978
11979 @node GNAT.Memory_Dump (g-memdum.ads)
11980 @section @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
11981 @cindex @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
11982 @cindex Dump Memory
11983
11984 @noindent
11985 Provides a convenient routine for dumping raw memory to either the
11986 standard output or standard error files. Uses GNAT.IO for actual
11987 output.
11988
11989 @node GNAT.Most_Recent_Exception (g-moreex.ads)
11990 @section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
11991 @cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
11992 @cindex Exception, obtaining most recent
11993
11994 @noindent
11995 Provides access to the most recently raised exception.  Can be used for
11996 various logging purposes, including duplicating functionality of some
11997 Ada 83 implementation dependent extensions.
11998
11999 @node GNAT.OS_Lib (g-os_lib.ads)
12000 @section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
12001 @cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
12002 @cindex Operating System interface
12003 @cindex Spawn capability
12004
12005 @noindent
12006 Provides a range of target independent operating system interface functions,
12007 including time/date management, file operations, subprocess management,
12008 including a portable spawn procedure, and access to environment variables
12009 and error return codes.
12010
12011 @node GNAT.Perfect_Hash.Generators (g-pehage.ads)
12012 @section @code{GNAT.Perfect_Hash.Generators} (@file{g-pehage.ads})
12013 @cindex @code{GNAT.Perfect_Hash.Generators} (@file{g-pehage.ads})
12014 @cindex Hash functions
12015
12016 @noindent
12017 Provides a generator of static minimal perfect hash functions. No
12018 collisions occur and each item can be retrieved from the table in one
12019 probe (perfect property). The hash table size corresponds to the exact
12020 size of the key set and no larger (minimal property). The key set has to
12021 be know in advance (static property). The hash functions are also order
12022 preservering. If w2 is inserted after w1 in the generator, their
12023 hashcode are in the same order. These hashing functions are very
12024 convenient for use with realtime applications.
12025
12026 @node GNAT.Regexp (g-regexp.ads)
12027 @section @code{GNAT.Regexp} (@file{g-regexp.ads})
12028 @cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
12029 @cindex Regular expressions
12030 @cindex Pattern matching
12031
12032 @noindent
12033 A simple implementation of regular expressions, using a subset of regular
12034 expression syntax copied from familiar Unix style utilities.  This is the
12035 simples of the three pattern matching packages provided, and is particularly
12036 suitable for ``file globbing'' applications.
12037
12038 @node GNAT.Registry (g-regist.ads)
12039 @section @code{GNAT.Registry} (@file{g-regist.ads})
12040 @cindex @code{GNAT.Registry} (@file{g-regist.ads})
12041 @cindex Windows Registry
12042
12043 @noindent
12044 This is a high level binding to the Windows registry.  It is possible to
12045 do simple things like reading a key value, creating a new key.  For full
12046 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
12047 package provided with the Win32Ada binding
12048
12049 @node GNAT.Regpat (g-regpat.ads)
12050 @section @code{GNAT.Regpat} (@file{g-regpat.ads})
12051 @cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
12052 @cindex Regular expressions
12053 @cindex Pattern matching
12054
12055 @noindent
12056 A complete implementation of Unix-style regular expression matching, copied
12057 from the original V7 style regular expression library written in C by
12058 Henry Spencer (and binary compatible with this C library).
12059
12060 @node GNAT.Secondary_Stack_Info (g-sestin.ads)
12061 @section @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
12062 @cindex @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
12063 @cindex Secondary Stack Info
12064
12065 @noindent
12066 Provide the capability to query the high water mark of the current task's
12067 secondary stack.
12068
12069 @node GNAT.Semaphores (g-semaph.ads)
12070 @section @code{GNAT.Semaphores} (@file{g-semaph.ads})
12071 @cindex @code{GNAT.Semaphores} (@file{g-semaph.ads})
12072 @cindex Semaphores
12073
12074 @noindent
12075 Provides classic counting and binary semaphores using protected types.
12076
12077 @node GNAT.Signals (g-signal.ads)
12078 @section @code{GNAT.Signals} (@file{g-signal.ads})
12079 @cindex @code{GNAT.Signals} (@file{g-signal.ads})
12080 @cindex Signals
12081
12082 @noindent
12083 Provides the ability to manipulate the blocked status of signals on supported
12084 targets.
12085
12086 @node GNAT.Sockets (g-socket.ads)
12087 @section @code{GNAT.Sockets} (@file{g-socket.ads})
12088 @cindex @code{GNAT.Sockets} (@file{g-socket.ads})
12089 @cindex Sockets
12090
12091 @noindent
12092 A high level and portable interface to develop sockets based applications.
12093 This package is based on the sockets thin binding found in
12094 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
12095 on all native GNAT ports except for OpenVMS@.  It is not implemented
12096 for the LynxOS@ cross port.
12097
12098 @node GNAT.Source_Info (g-souinf.ads)
12099 @section @code{GNAT.Source_Info} (@file{g-souinf.ads})
12100 @cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
12101 @cindex Source Information
12102
12103 @noindent
12104 Provides subprograms that give access to source code information known at
12105 compile time, such as the current file name and line number.
12106
12107 @node GNAT.Spell_Checker (g-speche.ads)
12108 @section @code{GNAT.Spell_Checker} (@file{g-speche.ads})
12109 @cindex @code{GNAT.Spell_Checker} (@file{g-speche.ads})
12110 @cindex Spell checking
12111
12112 @noindent
12113 Provides a function for determining whether one string is a plausible
12114 near misspelling of another string.
12115
12116 @node GNAT.Spitbol.Patterns (g-spipat.ads)
12117 @section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
12118 @cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
12119 @cindex SPITBOL pattern matching
12120 @cindex Pattern matching
12121
12122 @noindent
12123 A complete implementation of SNOBOL4 style pattern matching.  This is the
12124 most elaborate of the pattern matching packages provided.  It fully duplicates
12125 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
12126 efficient algorithm developed by Robert Dewar for the SPITBOL system.
12127
12128 @node GNAT.Spitbol (g-spitbo.ads)
12129 @section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
12130 @cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
12131 @cindex SPITBOL interface
12132
12133 @noindent
12134 The top level package of the collection of SPITBOL-style functionality, this
12135 package provides basic SNOBOL4 string manipulation functions, such as
12136 Pad, Reverse, Trim, Substr capability, as well as a generic table function
12137 useful for constructing arbitrary mappings from strings in the style of
12138 the SNOBOL4 TABLE function.
12139
12140 @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
12141 @section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
12142 @cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
12143 @cindex Sets of strings
12144 @cindex SPITBOL Tables
12145
12146 @noindent
12147 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
12148 for type @code{Standard.Boolean}, giving an implementation of sets of
12149 string values.
12150
12151 @node GNAT.Spitbol.Table_Integer (g-sptain.ads)
12152 @section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
12153 @cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
12154 @cindex Integer maps
12155 @cindex Maps
12156 @cindex SPITBOL Tables
12157
12158 @noindent
12159 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
12160 for type @code{Standard.Integer}, giving an implementation of maps
12161 from string to integer values.
12162
12163 @node GNAT.Spitbol.Table_VString (g-sptavs.ads)
12164 @section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
12165 @cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
12166 @cindex String maps
12167 @cindex Maps
12168 @cindex SPITBOL Tables
12169
12170 @noindent
12171 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
12172 a variable length string type, giving an implementation of general
12173 maps from strings to strings.
12174
12175 @node GNAT.Strings (g-string.ads)
12176 @section @code{GNAT.Strings} (@file{g-string.ads})
12177 @cindex @code{GNAT.Strings} (@file{g-string.ads})
12178
12179 @noindent
12180 Common String access types and related subprograms. Basically it
12181 defines a string access and an array of string access types.
12182
12183 @node GNAT.String_Split (g-strspl.ads)
12184 @section @code{GNAT.String_Split} (@file{g-strspl.ads})
12185 @cindex @code{GNAT.String_Split} (@file{g-strspl.ads})
12186 @cindex String splitter
12187
12188 @noindent
12189 Useful string-manipulation routines: given a set of separators, split
12190 a string wherever the separators appear, and provide direct access
12191 to the resulting slices. This package is instantiated from
12192 @code{GNAT.Array_Split}.
12193
12194 @node GNAT.Table (g-table.ads)
12195 @section @code{GNAT.Table} (@file{g-table.ads})
12196 @cindex @code{GNAT.Table} (@file{g-table.ads})
12197 @cindex Table implementation
12198 @cindex Arrays, extendable
12199
12200 @noindent
12201 A generic package providing a single dimension array abstraction where the
12202 length of the array can be dynamically modified.
12203
12204 @noindent
12205 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
12206 except that this package declares a single instance of the table type,
12207 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
12208 used to define dynamic instances of the table.
12209
12210 @node GNAT.Task_Lock (g-tasloc.ads)
12211 @section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
12212 @cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
12213 @cindex Task synchronization
12214 @cindex Task locking
12215 @cindex Locking
12216
12217 @noindent
12218 A very simple facility for locking and unlocking sections of code using a
12219 single global task lock.  Appropriate for use in situations where contention
12220 between tasks is very rarely expected.
12221
12222 @node GNAT.Threads (g-thread.ads)
12223 @section @code{GNAT.Threads} (@file{g-thread.ads})
12224 @cindex @code{GNAT.Threads} (@file{g-thread.ads})
12225 @cindex Foreign threads
12226 @cindex Threads, foreign
12227
12228 @noindent
12229 Provides facilities for creating and destroying threads with explicit calls.
12230 These threads are known to the GNAT run-time system.  These subprograms are
12231 exported C-convention procedures intended to be called from foreign code.
12232 By using these primitives rather than directly calling operating systems
12233 routines, compatibility with the Ada tasking runt-time is provided.
12234
12235 @node GNAT.Traceback (g-traceb.ads)
12236 @section @code{GNAT.Traceback} (@file{g-traceb.ads})
12237 @cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
12238 @cindex Trace back facilities
12239
12240 @noindent
12241 Provides a facility for obtaining non-symbolic traceback information, useful
12242 in various debugging situations.
12243
12244 @node GNAT.Traceback.Symbolic (g-trasym.ads)
12245 @section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
12246 @cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
12247 @cindex Trace back facilities
12248
12249 @noindent
12250 Provides symbolic traceback information that includes the subprogram
12251 name and line number information.
12252
12253 @node GNAT.Wide_String_Split (g-wistsp.ads)
12254 @section @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
12255 @cindex @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
12256 @cindex Wide_String splitter
12257
12258 @noindent
12259 Useful wide_string-manipulation routines: given a set of separators, split
12260 a wide_string wherever the separators appear, and provide direct access
12261 to the resulting slices. This package is instantiated from
12262 @code{GNAT.Array_Split}.
12263
12264 @node Interfaces.C.Extensions (i-cexten.ads)
12265 @section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
12266 @cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
12267
12268 @noindent
12269 This package contains additional C-related definitions, intended
12270 for use with either manually or automatically generated bindings
12271 to C libraries.
12272
12273 @node Interfaces.C.Streams (i-cstrea.ads)
12274 @section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
12275 @cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
12276 @cindex  C streams, interfacing
12277
12278 @noindent
12279 This package is a binding for the most commonly used operations
12280 on C streams.
12281
12282 @node Interfaces.CPP (i-cpp.ads)
12283 @section @code{Interfaces.CPP} (@file{i-cpp.ads})
12284 @cindex @code{Interfaces.CPP} (@file{i-cpp.ads})
12285 @cindex  C++ interfacing
12286 @cindex  Interfacing, to C++
12287
12288 @noindent
12289 This package provides facilities for use in interfacing to C++.  It
12290 is primarily intended to be used in connection with automated tools
12291 for the generation of C++ interfaces.
12292
12293 @node Interfaces.Os2lib (i-os2lib.ads)
12294 @section @code{Interfaces.Os2lib} (@file{i-os2lib.ads})
12295 @cindex @code{Interfaces.Os2lib} (@file{i-os2lib.ads})
12296 @cindex Interfacing, to OS/2
12297 @cindex OS/2 interfacing
12298
12299 @noindent
12300 This package provides interface definitions to the OS/2 library.
12301 It is a thin binding which is a direct translation of the
12302 various @file{<bse@.h>} files.
12303
12304 @node Interfaces.Os2lib.Errors (i-os2err.ads)
12305 @section @code{Interfaces.Os2lib.Errors} (@file{i-os2err.ads})
12306 @cindex @code{Interfaces.Os2lib.Errors} (@file{i-os2err.ads})
12307 @cindex OS/2 Error codes
12308 @cindex Interfacing, to OS/2
12309 @cindex OS/2 interfacing
12310
12311 @noindent
12312 This package provides definitions of the OS/2 error codes.
12313
12314 @node Interfaces.Os2lib.Synchronization (i-os2syn.ads)
12315 @section @code{Interfaces.Os2lib.Synchronization} (@file{i-os2syn.ads})
12316 @cindex @code{Interfaces.Os2lib.Synchronization} (@file{i-os2syn.ads})
12317 @cindex Interfacing, to OS/2
12318 @cindex Synchronization, OS/2
12319 @cindex OS/2 synchronization primitives
12320
12321 @noindent
12322 This is a child package that provides definitions for interfacing
12323 to the @code{OS/2} synchronization primitives.
12324
12325 @node Interfaces.Os2lib.Threads (i-os2thr.ads)
12326 @section @code{Interfaces.Os2lib.Threads} (@file{i-os2thr.ads})
12327 @cindex @code{Interfaces.Os2lib.Threads} (@file{i-os2thr.ads})
12328 @cindex Interfacing, to OS/2
12329 @cindex Thread control, OS/2
12330 @cindex OS/2 thread interfacing
12331
12332 @noindent
12333 This is a child package that provides definitions for interfacing
12334 to the @code{OS/2} thread primitives.
12335
12336 @node Interfaces.Packed_Decimal (i-pacdec.ads)
12337 @section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
12338 @cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
12339 @cindex  IBM Packed Format
12340 @cindex  Packed Decimal
12341
12342 @noindent
12343 This package provides a set of routines for conversions to and
12344 from a packed decimal format compatible with that used on IBM
12345 mainframes.
12346
12347 @node Interfaces.VxWorks (i-vxwork.ads)
12348 @section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
12349 @cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
12350 @cindex Interfacing to VxWorks
12351 @cindex VxWorks, interfacing
12352
12353 @noindent
12354 This package provides a limited binding to the VxWorks API.
12355 In particular, it interfaces with the
12356 VxWorks hardware interrupt facilities.
12357
12358 @node Interfaces.VxWorks.IO (i-vxwoio.ads)
12359 @section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
12360 @cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
12361 @cindex Interfacing to VxWorks' I/O
12362 @cindex VxWorks, I/O interfacing
12363 @cindex VxWorks, Get_Immediate
12364 @cindex Get_Immediate, VxWorks
12365
12366 @noindent
12367 This package provides a binding to the ioctl (IO/Control)
12368 function of VxWorks, defining a set of option values and
12369 function codes. A particular use of this package is
12370 to enable the use of Get_Immediate under VxWorks.
12371
12372 @node System.Address_Image (s-addima.ads)
12373 @section @code{System.Address_Image} (@file{s-addima.ads})
12374 @cindex @code{System.Address_Image} (@file{s-addima.ads})
12375 @cindex Address image
12376 @cindex Image, of an address
12377
12378 @noindent
12379 This function provides a useful debugging
12380 function that gives an (implementation dependent)
12381 string which identifies an address.
12382
12383 @node System.Assertions (s-assert.ads)
12384 @section @code{System.Assertions} (@file{s-assert.ads})
12385 @cindex @code{System.Assertions} (@file{s-assert.ads})
12386 @cindex Assertions
12387 @cindex Assert_Failure, exception
12388
12389 @noindent
12390 This package provides the declaration of the exception raised
12391 by an run-time assertion failure, as well as the routine that
12392 is used internally to raise this assertion.
12393
12394 @node System.Memory (s-memory.ads)
12395 @section @code{System.Memory} (@file{s-memory.ads})
12396 @cindex @code{System.Memory} (@file{s-memory.ads})
12397 @cindex Memory allocation
12398
12399 @noindent
12400 This package provides the interface to the low level routines used
12401 by the generated code for allocation and freeing storage for the
12402 default storage pool (analogous to the C routines malloc and free.
12403 It also provides a reallocation interface analogous to the C routine
12404 realloc. The body of this unit may be modified to provide alternative
12405 allocation mechanisms for the default pool, and in addition, direct
12406 calls to this unit may be made for low level allocation uses (for
12407 example see the body of @code{GNAT.Tables}).
12408
12409 @node System.Partition_Interface (s-parint.ads)
12410 @section @code{System.Partition_Interface} (@file{s-parint.ads})
12411 @cindex @code{System.Partition_Interface} (@file{s-parint.ads})
12412 @cindex Partition intefacing functions
12413
12414 @noindent
12415 This package provides facilities for partition interfacing.  It
12416 is used primarily in a distribution context when using Annex E
12417 with @code{GLADE}.
12418
12419 @node System.Restrictions (s-restri.ads)
12420 @section @code{System.Restrictions} (@file{s-restri.ads})
12421 @cindex @code{System.Restrictions} (@file{s-restri.ads})
12422 @cindex Run-time restrictions access
12423
12424 @noindent
12425 This package provides facilities for accessing at run-time
12426 the status of restrictions specified at compile time for
12427 the partition. Information is available both with regard
12428 to actual restrictions specified, and with regard to
12429 compiler determined information on which restrictions
12430 are violated by one or more packages in the partition.
12431
12432 @node System.Rident (s-rident.ads)
12433 @section @code{System.Rident} (@file{s-rident.ads})
12434 @cindex @code{System.Rident} (@file{s-rident.ads})
12435 @cindex Restrictions definitions
12436
12437 @noindent
12438 This package provides definitions of the restrictions
12439 identifiers supported by GNAT, and also the format of
12440 the restrictions provided in package System.Restrictions.
12441 It is not normally necessary to @code{with} this generic package
12442 since the necessary instantiation is included in
12443 package System.Restrictions.
12444
12445 @node System.Task_Info (s-tasinf.ads)
12446 @section @code{System.Task_Info} (@file{s-tasinf.ads})
12447 @cindex @code{System.Task_Info} (@file{s-tasinf.ads})
12448 @cindex Task_Info pragma
12449
12450 @noindent
12451 This package provides target dependent functionality that is used
12452 to support the @code{Task_Info} pragma
12453
12454 @node System.Wch_Cnv (s-wchcnv.ads)
12455 @section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
12456 @cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
12457 @cindex Wide Character, Representation
12458 @cindex Wide String, Conversion
12459 @cindex Representation of wide characters
12460
12461 @noindent
12462 This package provides routines for converting between
12463 wide characters and a representation as a value of type
12464 @code{Standard.String}, using a specified wide character
12465 encoding method.  It uses definitions in
12466 package @code{System.Wch_Con}.
12467
12468 @node System.Wch_Con (s-wchcon.ads)
12469 @section @code{System.Wch_Con} (@file{s-wchcon.ads})
12470 @cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
12471
12472 @noindent
12473 This package provides definitions and descriptions of
12474 the various methods used for encoding wide characters
12475 in ordinary strings.  These definitions are used by
12476 the package @code{System.Wch_Cnv}.
12477
12478 @node Interfacing to Other Languages
12479 @chapter Interfacing to Other Languages
12480 @noindent
12481 The facilities in annex B of the Ada 95 Reference Manual are fully
12482 implemented in GNAT, and in addition, a full interface to C++ is
12483 provided.
12484
12485 @menu
12486 * Interfacing to C::
12487 * Interfacing to C++::
12488 * Interfacing to COBOL::
12489 * Interfacing to Fortran::
12490 * Interfacing to non-GNAT Ada code::
12491 @end menu
12492
12493 @node Interfacing to C
12494 @section Interfacing to C
12495
12496 @noindent
12497 Interfacing to C with GNAT can use one of two approaches:
12498
12499 @itemize @bullet
12500 @item
12501 The types in the package @code{Interfaces.C} may be used.
12502 @item
12503 Standard Ada types may be used directly.  This may be less portable to
12504 other compilers, but will work on all GNAT compilers, which guarantee
12505 correspondence between the C and Ada types.
12506 @end itemize
12507
12508 @noindent
12509 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
12510 effect, since this is the default.  The following table shows the
12511 correspondence between Ada scalar types and the corresponding C types.
12512
12513 @table @code
12514 @item Integer
12515 @code{int}
12516 @item Short_Integer
12517 @code{short}
12518 @item Short_Short_Integer
12519 @code{signed char}
12520 @item Long_Integer
12521 @code{long}
12522 @item Long_Long_Integer
12523 @code{long long}
12524 @item Short_Float
12525 @code{float}
12526 @item Float
12527 @code{float}
12528 @item Long_Float
12529 @code{double}
12530 @item Long_Long_Float
12531 This is the longest floating-point type supported by the hardware.
12532 @end table
12533
12534 @noindent
12535 Additionally, there are the following general correspondences between Ada
12536 and C types:
12537 @itemize @bullet
12538 @item
12539 Ada enumeration types map to C enumeration types directly if pragma
12540 @code{Convention C} is specified, which causes them to have int
12541 length.  Without pragma @code{Convention C}, Ada enumeration types map to
12542 8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short},
12543 @code{int}, respectively) depending on the number of values passed.
12544 This is the only case in which pragma @code{Convention C} affects the
12545 representation of an Ada type.
12546
12547 @item
12548 Ada access types map to C pointers, except for the case of pointers to
12549 unconstrained types in Ada, which have no direct C equivalent.
12550
12551 @item
12552 Ada arrays map directly to C arrays.
12553
12554 @item
12555 Ada records map directly to C structures.
12556
12557 @item
12558 Packed Ada records map to C structures where all members are bit fields
12559 of the length corresponding to the @code{@var{type}'Size} value in Ada.
12560 @end itemize
12561
12562 @node Interfacing to C++
12563 @section Interfacing to C++
12564
12565 @noindent
12566 The interface to C++ makes use of the following pragmas, which are
12567 primarily intended to be constructed automatically using a binding generator
12568 tool, although it is possible to construct them by hand.  Ada Core
12569 Technologies does not currently supply a suitable binding generator tool.
12570
12571 Using these pragmas it is possible to achieve complete
12572 inter-operability between Ada tagged types and C class definitions.
12573 See @ref{Implementation Defined Pragmas}, for more details.
12574
12575 @table @code
12576 @item pragma CPP_Class ([Entity =>] @var{local_name})
12577 The argument denotes an entity in the current declarative region that is
12578 declared as a tagged or untagged record type.  It indicates that the type
12579 corresponds to an externally declared C++ class type, and is to be laid
12580 out the same way that C++ would lay out the type.
12581
12582 @item pragma CPP_Constructor ([Entity =>] @var{local_name})
12583 This pragma identifies an imported function (imported in the usual way
12584 with pragma @code{Import}) as corresponding to a C++ constructor.
12585
12586 @item pragma CPP_Vtable @dots{}
12587 One @code{CPP_Vtable} pragma can be present for each component of type
12588 @code{CPP.Interfaces.Vtable_Ptr} in a record to which pragma @code{CPP_Class}
12589 applies.
12590 @end table
12591
12592 @node Interfacing to COBOL
12593 @section Interfacing to COBOL
12594
12595 @noindent
12596 Interfacing to COBOL is achieved as described in section B.4 of
12597 the Ada 95 reference manual.
12598
12599 @node Interfacing to Fortran
12600 @section Interfacing to Fortran
12601
12602 @noindent
12603 Interfacing to Fortran is achieved as described in section B.5 of the
12604 reference manual.  The pragma @code{Convention Fortran}, applied to a
12605 multi-dimensional array causes the array to be stored in column-major
12606 order as required for convenient interface to Fortran.
12607
12608 @node Interfacing to non-GNAT Ada code
12609 @section Interfacing to non-GNAT Ada code
12610
12611 It is possible to specify the convention @code{Ada} in a pragma
12612 @code{Import} or pragma @code{Export}.  However this refers to
12613 the calling conventions used by GNAT, which may or may not be
12614 similar enough to those used by some other Ada 83 or Ada 95
12615 compiler to allow interoperation.
12616
12617 If arguments types are kept simple, and if the foreign compiler generally
12618 follows system calling conventions, then it may be possible to integrate
12619 files compiled by other Ada compilers, provided that the elaboration
12620 issues are adequately addressed (for example by eliminating the
12621 need for any load time elaboration).
12622
12623 In particular, GNAT running on VMS is designed to
12624 be highly compatible with the DEC Ada 83 compiler, so this is one
12625 case in which it is possible to import foreign units of this type,
12626 provided that the data items passed are restricted to simple scalar
12627 values or simple record types without variants, or simple array
12628 types with fixed bounds.
12629
12630 @node Specialized Needs Annexes
12631 @chapter Specialized Needs Annexes
12632
12633 @noindent
12634 Ada 95 defines a number of specialized needs annexes, which are not
12635 required in all implementations.  However, as described in this chapter,
12636 GNAT implements all of these special needs annexes:
12637
12638 @table @asis
12639 @item Systems Programming (Annex C)
12640 The Systems Programming Annex is fully implemented.
12641
12642 @item Real-Time Systems (Annex D)
12643 The Real-Time Systems Annex is fully implemented.
12644
12645 @item Distributed Systems (Annex E)
12646 Stub generation is fully implemented in the GNAT compiler.  In addition,
12647 a complete compatible PCS is available as part of the GLADE system,
12648 a separate product.  When the two
12649 products are used in conjunction, this annex is fully implemented.
12650
12651 @item Information Systems (Annex F)
12652 The Information Systems annex is fully implemented.
12653
12654 @item Numerics (Annex G)
12655 The Numerics Annex is fully implemented.
12656
12657 @item Safety and Security (Annex H)
12658 The Safety and Security annex is fully implemented.
12659 @end table
12660
12661 @node Implementation of Specific Ada Features
12662 @chapter Implementation of Specific Ada Features
12663
12664 @noindent
12665 This chapter describes the GNAT implementation of several Ada language
12666 facilities.
12667
12668 @menu
12669 * Machine Code Insertions::
12670 * GNAT Implementation of Tasking::
12671 * GNAT Implementation of Shared Passive Packages::
12672 * Code Generation for Array Aggregates::
12673 @end menu
12674
12675 @node Machine Code Insertions
12676 @section Machine Code Insertions
12677
12678 @noindent
12679 Package @code{Machine_Code} provides machine code support as described
12680 in the Ada 95 Reference Manual in two separate forms:
12681 @itemize @bullet
12682 @item
12683 Machine code statements, consisting of qualified expressions that
12684 fit the requirements of RM section 13.8.
12685 @item
12686 An intrinsic callable procedure, providing an alternative mechanism of
12687 including machine instructions in a subprogram.
12688 @end itemize
12689
12690 @noindent
12691 The two features are similar, and both closely related to the mechanism
12692 provided by the asm instruction in the GNU C compiler.  Full understanding
12693 and use of the facilities in this package requires understanding the asm
12694 instruction as described in
12695 @cite{Using and Porting the GNU Compiler Collection (GCC)} by Richard
12696 Stallman.  Calls to the function @code{Asm} and the procedure @code{Asm}
12697 have identical semantic restrictions and effects as described below.
12698 Both are provided so that the procedure call can be used as a statement,
12699 and the function call can be used to form a code_statement.
12700
12701 The first example given in the GCC documentation is the C @code{asm}
12702 instruction:
12703 @smallexample
12704    asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
12705 @end smallexample
12706
12707 @noindent
12708 The equivalent can be written for GNAT as:
12709
12710 @smallexample @c ada
12711 Asm ("fsinx %1 %0",
12712      My_Float'Asm_Output ("=f", result),
12713      My_Float'Asm_Input  ("f",  angle));
12714 @end smallexample
12715
12716 @noindent
12717 The first argument to @code{Asm} is the assembler template, and is
12718 identical to what is used in GNU C@.  This string must be a static
12719 expression.  The second argument is the output operand list.  It is
12720 either a single @code{Asm_Output} attribute reference, or a list of such
12721 references enclosed in parentheses (technically an array aggregate of
12722 such references).
12723
12724 The @code{Asm_Output} attribute denotes a function that takes two
12725 parameters.  The first is a string, the second is the name of a variable
12726 of the type designated by the attribute prefix.  The first (string)
12727 argument is required to be a static expression and designates the
12728 constraint for the parameter (e.g.@: what kind of register is
12729 required).  The second argument is the variable to be updated with the
12730 result.  The possible values for constraint are the same as those used in
12731 the RTL, and are dependent on the configuration file used to build the
12732 GCC back end.  If there are no output operands, then this argument may
12733 either be omitted, or explicitly given as @code{No_Output_Operands}.
12734
12735 The second argument of @code{@var{my_float}'Asm_Output} functions as
12736 though it were an @code{out} parameter, which is a little curious, but
12737 all names have the form of expressions, so there is no syntactic
12738 irregularity, even though normally functions would not be permitted
12739 @code{out} parameters.  The third argument is the list of input
12740 operands.  It is either a single @code{Asm_Input} attribute reference, or
12741 a list of such references enclosed in parentheses (technically an array
12742 aggregate of such references).
12743
12744 The @code{Asm_Input} attribute denotes a function that takes two
12745 parameters.  The first is a string, the second is an expression of the
12746 type designated by the prefix.  The first (string) argument is required
12747 to be a static expression, and is the constraint for the parameter,
12748 (e.g.@: what kind of register is required).  The second argument is the
12749 value to be used as the input argument.  The possible values for the
12750 constant are the same as those used in the RTL, and are dependent on
12751 the configuration file used to built the GCC back end.
12752
12753 If there are no input operands, this argument may either be omitted, or
12754 explicitly given as @code{No_Input_Operands}.  The fourth argument, not
12755 present in the above example, is a list of register names, called the
12756 @dfn{clobber} argument.  This argument, if given, must be a static string
12757 expression, and is a space or comma separated list of names of registers
12758 that must be considered destroyed as a result of the @code{Asm} call.  If
12759 this argument is the null string (the default value), then the code
12760 generator assumes that no additional registers are destroyed.
12761
12762 The fifth argument, not present in the above example, called the
12763 @dfn{volatile} argument, is by default @code{False}.  It can be set to
12764 the literal value @code{True} to indicate to the code generator that all
12765 optimizations with respect to the instruction specified should be
12766 suppressed, and that in particular, for an instruction that has outputs,
12767 the instruction will still be generated, even if none of the outputs are
12768 used.  See the full description in the GCC manual for further details.
12769
12770 The @code{Asm} subprograms may be used in two ways.  First the procedure
12771 forms can be used anywhere a procedure call would be valid, and
12772 correspond to what the RM calls ``intrinsic'' routines.  Such calls can
12773 be used to intersperse machine instructions with other Ada statements.
12774 Second, the function forms, which return a dummy value of the limited
12775 private type @code{Asm_Insn}, can be used in code statements, and indeed
12776 this is the only context where such calls are allowed.  Code statements
12777 appear as aggregates of the form:
12778
12779 @smallexample @c ada
12780 Asm_Insn'(Asm (@dots{}));
12781 Asm_Insn'(Asm_Volatile (@dots{}));
12782 @end smallexample
12783
12784 @noindent
12785 In accordance with RM rules, such code statements are allowed only
12786 within subprograms whose entire body consists of such statements.  It is
12787 not permissible to intermix such statements with other Ada statements.
12788
12789 Typically the form using intrinsic procedure calls is more convenient
12790 and more flexible.  The code statement form is provided to meet the RM
12791 suggestion that such a facility should be made available.  The following
12792 is the exact syntax of the call to @code{Asm}. As usual, if named notation
12793 is used, the arguments may be given in arbitrary order, following the
12794 normal rules for use of positional and named arguments)
12795
12796 @smallexample
12797 ASM_CALL ::= Asm (
12798                  [Template =>] static_string_EXPRESSION
12799                [,[Outputs  =>] OUTPUT_OPERAND_LIST      ]
12800                [,[Inputs   =>] INPUT_OPERAND_LIST       ]
12801                [,[Clobber  =>] static_string_EXPRESSION ]
12802                [,[Volatile =>] static_boolean_EXPRESSION] )
12803
12804 OUTPUT_OPERAND_LIST ::=
12805   [PREFIX.]No_Output_Operands
12806 | OUTPUT_OPERAND_ATTRIBUTE
12807 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
12808
12809 OUTPUT_OPERAND_ATTRIBUTE ::=
12810   SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
12811
12812 INPUT_OPERAND_LIST ::=
12813   [PREFIX.]No_Input_Operands
12814 | INPUT_OPERAND_ATTRIBUTE
12815 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
12816
12817 INPUT_OPERAND_ATTRIBUTE ::=
12818   SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
12819 @end smallexample
12820
12821 @noindent
12822 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
12823 are declared in the package @code{Machine_Code} and must be referenced
12824 according to normal visibility rules. In particular if there is no
12825 @code{use} clause for this package, then appropriate package name
12826 qualification is required.
12827
12828 @node GNAT Implementation of Tasking
12829 @section GNAT Implementation of Tasking
12830
12831 @noindent
12832 This chapter outlines the basic GNAT approach to tasking (in particular,
12833 a multi-layered library for portability) and discusses issues related
12834 to compliance with the Real-Time Systems Annex.
12835
12836 @menu
12837 * Mapping Ada Tasks onto the Underlying Kernel Threads::
12838 * Ensuring Compliance with the Real-Time Annex::
12839 @end menu
12840
12841 @node Mapping Ada Tasks onto the Underlying Kernel Threads
12842 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
12843
12844 @noindent
12845 GNAT's run-time support comprises two layers:
12846
12847 @itemize @bullet
12848 @item GNARL (GNAT Run-time Layer)
12849 @item GNULL (GNAT Low-level Library)
12850 @end itemize
12851
12852 @noindent
12853 In GNAT, Ada's tasking services rely on a platform and OS independent
12854 layer known as GNARL@.  This code is responsible for implementing the
12855 correct semantics of Ada's task creation, rendezvous, protected
12856 operations etc.
12857
12858 GNARL decomposes Ada's tasking semantics into simpler lower level
12859 operations such as create a thread, set the priority of a thread,
12860 yield, create a lock, lock/unlock, etc.  The spec for these low-level
12861 operations constitutes GNULLI, the GNULL Interface.  This interface is
12862 directly inspired from the POSIX real-time API@.
12863
12864 If the underlying executive or OS implements the POSIX standard
12865 faithfully, the GNULL Interface maps as is to the services offered by
12866 the underlying kernel.  Otherwise, some target dependent glue code maps
12867 the services offered by the underlying kernel to the semantics expected
12868 by GNARL@.
12869
12870 Whatever the underlying OS (VxWorks, UNIX, OS/2, Windows NT, etc.) the
12871 key point is that each Ada task is mapped on a thread in the underlying
12872 kernel.  For example, in the case of VxWorks, one Ada task = one VxWorks task.
12873
12874 In addition Ada task priorities map onto the underlying thread priorities.
12875 Mapping Ada tasks onto the underlying kernel threads has several advantages:
12876
12877 @itemize @bullet
12878 @item
12879 The underlying scheduler is used to schedule the Ada tasks.  This
12880 makes Ada tasks as efficient as kernel threads from a scheduling
12881 standpoint.
12882
12883 @item
12884 Interaction with code written in C containing threads is eased
12885 since at the lowest level Ada tasks and C threads map onto the same
12886 underlying kernel concept.
12887
12888 @item
12889 When an Ada task is blocked during I/O the remaining Ada tasks are
12890 able to proceed.
12891
12892 @item
12893 On multiprocessor systems Ada tasks can execute in parallel.
12894 @end itemize
12895
12896 @noindent
12897 Some threads libraries offer a mechanism to fork a new process, with the
12898 child process duplicating the threads from the parent.
12899 GNAT does not
12900 support this functionality when the parent contains more than one task.
12901 @cindex Forking a new process
12902
12903 @node Ensuring Compliance with the Real-Time Annex
12904 @subsection Ensuring Compliance with the Real-Time Annex
12905 @cindex Real-Time Systems Annex compliance
12906
12907 @noindent
12908 Although mapping Ada tasks onto
12909 the underlying threads has significant advantages, it does create some
12910 complications when it comes to respecting the scheduling semantics
12911 specified in the real-time annex (Annex D).
12912
12913 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
12914 scheduling policy states:
12915
12916 @quotation
12917 @emph{When the active priority of a ready task that is not running
12918 changes, or the setting of its base priority takes effect, the
12919 task is removed from the ready queue for its old active priority
12920 and is added at the tail of the ready queue for its new active
12921 priority, except in the case where the active priority is lowered
12922 due to the loss of inherited priority, in which case the task is
12923 added at the head of the ready queue for its new active priority.}
12924 @end quotation
12925
12926 @noindent
12927 While most kernels do put tasks at the end of the priority queue when
12928 a task changes its priority, (which respects the main
12929 FIFO_Within_Priorities requirement), almost none keep a thread at the
12930 beginning of its priority queue when its priority drops from the loss
12931 of inherited priority.
12932
12933 As a result most vendors have provided incomplete Annex D implementations.
12934
12935 The GNAT run-time, has a nice cooperative solution to this problem
12936 which ensures that accurate FIFO_Within_Priorities semantics are
12937 respected.
12938
12939 The principle is as follows.  When an Ada task T is about to start
12940 running, it checks whether some other Ada task R with the same
12941 priority as T has been suspended due to the loss of priority
12942 inheritance.  If this is the case, T yields and is placed at the end of
12943 its priority queue.  When R arrives at the front of the queue it
12944 executes.
12945
12946 Note that this simple scheme preserves the relative order of the tasks
12947 that were ready to execute in the priority queue where R has been
12948 placed at the end.
12949
12950 @node GNAT Implementation of Shared Passive Packages
12951 @section GNAT Implementation of Shared Passive Packages
12952 @cindex Shared passive packages
12953
12954 @noindent
12955 GNAT fully implements the pragma @code{Shared_Passive} for
12956 @cindex pragma @code{Shared_Passive}
12957 the purpose of designating shared passive packages.
12958 This allows the use of passive partitions in the
12959 context described in the Ada Reference Manual; i.e. for communication
12960 between separate partitions of a distributed application using the
12961 features in Annex E.
12962 @cindex Annex E
12963 @cindex Distribution Systems Annex
12964
12965 However, the implementation approach used by GNAT provides for more
12966 extensive usage as follows:
12967
12968 @table @emph
12969 @item Communication between separate programs
12970
12971 This allows separate programs to access the data in passive
12972 partitions, using protected objects for synchronization where
12973 needed. The only requirement is that the two programs have a
12974 common shared file system. It is even possible for programs
12975 running on different machines with different architectures
12976 (e.g. different endianness) to communicate via the data in
12977 a passive partition.
12978
12979 @item Persistence between program runs
12980
12981 The data in a passive package can persist from one run of a
12982 program to another, so that a later program sees the final
12983 values stored by a previous run of the same program.
12984
12985 @end table
12986
12987 @noindent
12988 The implementation approach used is to store the data in files. A
12989 separate stream file is created for each object in the package, and
12990 an access to an object causes the corresponding file to be read or
12991 written.
12992
12993 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
12994 @cindex @code{SHARED_MEMORY_DIRECTORY} environment variable
12995 set to the directory to be used for these files.
12996 The files in this directory
12997 have names that correspond to their fully qualified names. For
12998 example, if we have the package
12999
13000 @smallexample @c ada
13001 package X is
13002   pragma Shared_Passive (X);
13003   Y : Integer;
13004   Z : Float;
13005 end X;
13006 @end smallexample
13007
13008 @noindent
13009 and the environment variable is set to @code{/stemp/}, then the files created
13010 will have the names:
13011
13012 @smallexample
13013 /stemp/x.y
13014 /stemp/x.z
13015 @end smallexample
13016
13017 @noindent
13018 These files are created when a value is initially written to the object, and
13019 the files are retained until manually deleted. This provides the persistence
13020 semantics. If no file exists, it means that no partition has assigned a value
13021 to the variable; in this case the initial value declared in the package
13022 will be used. This model ensures that there are no issues in synchronizing
13023 the elaboration process, since elaboration of passive packages elaborates the
13024 initial values, but does not create the files.
13025
13026 The files are written using normal @code{Stream_IO} access.
13027 If you want to be able
13028 to communicate between programs or partitions running on different
13029 architectures, then you should use the XDR versions of the stream attribute
13030 routines, since these are architecture independent.
13031
13032 If active synchronization is required for access to the variables in the
13033 shared passive package, then as described in the Ada Reference Manual, the
13034 package may contain protected objects used for this purpose. In this case
13035 a lock file (whose name is @file{___lock} (three underscores)
13036 is created in the shared memory directory.
13037 @cindex @file{___lock} file (for shared passive packages)
13038 This is used to provide the required locking
13039 semantics for proper protected object synchronization.
13040
13041 As of January 2003, GNAT supports shared passive packages on all platforms
13042 except for OpenVMS.
13043
13044 @node Code Generation for Array Aggregates
13045 @section Code Generation for Array Aggregates
13046
13047 @menu
13048 * Static constant aggregates with static bounds::
13049 * Constant aggregates with an unconstrained nominal types::
13050 * Aggregates with static bounds::
13051 * Aggregates with non-static bounds::
13052 * Aggregates in assignment statements::
13053 @end menu
13054
13055 @noindent
13056 Aggregate have a rich syntax and allow the user to specify the values of
13057 complex data structures by means of a single construct.  As a result, the
13058 code generated for aggregates can be quite complex and involve loops, case
13059 statements and multiple assignments.  In the simplest cases, however, the
13060 compiler will recognize aggregates whose components and constraints are
13061 fully static, and in those cases the compiler will generate little or no
13062 executable code.  The following is an outline of the code that GNAT generates
13063 for various aggregate constructs.  For further details, the user will find it
13064 useful to examine the output produced by the -gnatG flag to see the expanded
13065 source that is input to the code generator.  The user will also want to examine
13066 the assembly code generated at various levels of optimization.
13067
13068 The code generated for aggregates depends on the context, the component values,
13069 and the type.  In the context of an object declaration the code generated is
13070 generally simpler than in the case of an assignment.  As a general rule, static
13071 component values and static subtypes also lead to simpler code.
13072
13073 @node Static constant aggregates with static bounds
13074 @subsection Static constant aggregates with static bounds
13075
13076 @noindent
13077 For the declarations:
13078 @smallexample @c ada
13079     type One_Dim is array (1..10) of integer;
13080     ar0 : constant One_Dim := ( 1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
13081 @end smallexample
13082
13083 @noindent
13084 GNAT generates no executable code: the constant ar0 is placed in static memory.
13085 The same is true for constant aggregates with named associations:
13086
13087 @smallexample @c ada
13088     Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1=> 1);
13089     Cr3 : constant One_Dim := (others => 7777);
13090 @end smallexample
13091
13092 @noindent
13093 The same is true for multidimensional constant arrays such as:
13094
13095 @smallexample @c ada
13096     type two_dim is array (1..3, 1..3) of integer;
13097     Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
13098 @end smallexample
13099
13100 @noindent
13101 The same is true for arrays of one-dimensional arrays: the following are
13102 static:
13103
13104 @smallexample @c ada
13105 type ar1b  is array (1..3) of boolean;
13106 type ar_ar is array (1..3) of ar1b;
13107 None  : constant ar1b := (others => false);     --  fully static
13108 None2 : constant ar_ar := (1..3 => None);       --  fully static
13109 @end smallexample
13110
13111 @noindent
13112 However, for multidimensional aggregates with named associations, GNAT will
13113 generate assignments and loops, even if all associations are static.  The
13114 following two declarations generate a loop for the first dimension, and
13115 individual component assignments for the second dimension:
13116
13117 @smallexample @c ada
13118 Zero1: constant two_dim := (1..3 => (1..3 => 0));
13119 Zero2: constant two_dim := (others => (others => 0));
13120 @end smallexample
13121
13122 @node Constant aggregates with an unconstrained nominal types
13123 @subsection Constant aggregates with an unconstrained nominal types
13124
13125 @noindent
13126 In such cases the aggregate itself establishes the subtype, so that
13127 associations with @code{others} cannot be used.  GNAT determines the
13128 bounds for the actual subtype of the aggregate, and allocates the
13129 aggregate statically as well.  No code is generated for the following:
13130
13131 @smallexample @c ada
13132     type One_Unc is array (natural range <>) of integer;
13133     Cr_Unc : constant One_Unc := (12,24,36);
13134 @end smallexample
13135
13136 @node Aggregates with static bounds
13137 @subsection Aggregates with static bounds
13138
13139 @noindent
13140 In all previous examples the aggregate was the initial (and immutable) value
13141 of a constant.  If the aggregate initializes a variable, then code is generated
13142 for it as a combination of individual assignments and loops over the target
13143 object.  The declarations
13144
13145 @smallexample @c ada
13146        Cr_Var1 : One_Dim := (2, 5, 7, 11);
13147        Cr_Var2 : One_Dim := (others > -1);
13148 @end smallexample
13149
13150 @noindent
13151 generate the equivalent of
13152
13153 @smallexample @c ada
13154        Cr_Var1 (1) := 2;
13155        Cr_Var1 (2) := 3;
13156        Cr_Var1 (3) := 5;
13157        Cr_Var1 (4) := 11;
13158
13159        for I in Cr_Var2'range loop
13160           Cr_Var2 (I) := =-1;
13161        end loop;
13162 @end smallexample
13163
13164 @node Aggregates with non-static bounds
13165 @subsection Aggregates with non-static bounds
13166
13167 @noindent
13168 If the bounds of the aggregate are not statically compatible with the bounds
13169 of the nominal subtype  of the target, then constraint checks have to be
13170 generated on the bounds.  For a multidimensional array, constraint checks may
13171 have to be applied to sub-arrays individually, if they do not have statically
13172 compatible subtypes.
13173
13174 @node Aggregates in assignment statements
13175 @subsection Aggregates in assignment statements
13176
13177 @noindent
13178 In general, aggregate assignment requires the construction of a temporary,
13179 and a copy from the temporary to the target of the assignment.  This is because
13180 it is not always possible to convert the assignment into a series of individual
13181 component assignments.  For example, consider the simple case:
13182
13183 @smallexample @c ada
13184         A := (A(2), A(1));
13185 @end smallexample
13186
13187 @noindent
13188 This cannot be converted into:
13189
13190 @smallexample @c ada
13191         A(1) := A(2);
13192         A(2) := A(1);
13193 @end smallexample
13194
13195 @noindent
13196 So the aggregate has to be built first in a separate location, and then
13197 copied into the target.  GNAT recognizes simple cases where this intermediate
13198 step is not required, and the assignments can be performed in place, directly
13199 into the target.  The following sufficient criteria are applied:
13200
13201 @itemize @bullet
13202 @item
13203 The bounds of the aggregate are static, and the associations are static.
13204 @item
13205 The components of the aggregate are static constants, names of
13206 simple variables that are not renamings, or expressions not involving
13207 indexed components whose operands obey these rules.
13208 @end itemize
13209
13210 @noindent
13211 If any of these conditions are violated, the aggregate will be built in
13212 a temporary (created either by the front-end or the code generator) and then
13213 that temporary will be copied onto the target.
13214
13215 @node Project File Reference
13216 @chapter Project File Reference
13217
13218 @noindent
13219 This chapter describes the syntax and semantics of project files.
13220 Project files specify the options to be used when building a system.
13221 Project files can specify global settings for all tools,
13222 as well as tool-specific settings.
13223 See the chapter on project files in the GNAT Users guide for examples of use.
13224
13225 @menu
13226 * Reserved Words::
13227 * Lexical Elements::
13228 * Declarations::
13229 * Typed string declarations::
13230 * Variables::
13231 * Expressions::
13232 * Attributes::
13233 * Project Attributes::
13234 * Attribute References::
13235 * External Values::
13236 * Case Construction::
13237 * Packages::
13238 * Package Renamings::
13239 * Projects::
13240 * Project Extensions::
13241 * Project File Elaboration::
13242 @end menu
13243
13244 @node Reserved Words
13245 @section Reserved Words
13246
13247 @noindent
13248 All Ada95 reserved words are reserved in project files, and cannot be used
13249 as variable names or project names. In addition, the following are
13250 also reserved in project files:
13251
13252 @itemize
13253 @item @code{extends}
13254
13255 @item @code{external}
13256
13257 @item @code{project}
13258
13259 @end itemize
13260
13261 @node Lexical Elements
13262 @section Lexical Elements
13263
13264 @noindent
13265 Rules for identifiers are the same as in Ada95. Identifiers
13266 are case-insensitive.  Strings are case sensitive, except where noted.
13267 Comments have the same form as in Ada95.
13268
13269 @noindent
13270 Syntax:
13271
13272 @smallexample
13273 simple_name ::=
13274   identifier
13275
13276 name ::=
13277   simple_name @{. simple_name@}
13278 @end smallexample
13279
13280 @node Declarations
13281 @section Declarations
13282
13283 @noindent
13284 Declarations introduce new entities that denote types, variables, attributes,
13285 and packages. Some declarations can only appear immediately within a project
13286 declaration. Others can appear within a project or within a package.
13287
13288 Syntax:
13289 @smallexample
13290 declarative_item ::=
13291   simple_declarative_item |
13292   typed_string_declaration |
13293   package_declaration
13294
13295 simple_declarative_item ::=
13296   variable_declaration |
13297   typed_variable_declaration |
13298   attribute_declaration |
13299   case_construction
13300 @end smallexample
13301
13302 @node Typed string declarations
13303 @section Typed string declarations
13304
13305 @noindent
13306 Typed strings are sequences of string literals. Typed strings are the only
13307 named types in project files. They are used in case constructions, where they
13308 provide support for conditional attribute definitions.
13309
13310 Syntax:
13311 @smallexample
13312 typed_string_declaration ::=
13313   @b{type} <typed_string_>_simple_name @b{is}
13314    ( string_literal @{, string_literal@} );
13315 @end smallexample
13316
13317 @noindent
13318 A typed string declaration can only appear immediately within a project
13319 declaration.
13320
13321 All the string literals in a typed string declaration must be distinct.
13322
13323 @node Variables
13324 @section Variables
13325
13326 @noindent
13327 Variables denote values, and appear as constituents of expressions.
13328
13329 @smallexample
13330 typed_variable_declaration ::=
13331   <typed_variable_>simple_name : <typed_string_>name :=  string_expression ;
13332
13333 variable_declaration ::=
13334   <variable_>simple_name := expression;
13335 @end smallexample
13336
13337 @noindent
13338 The elaboration of a variable declaration introduces the variable and
13339 assigns to it the value of the expression. The name of the variable is
13340 available after the assignment symbol.
13341
13342 @noindent
13343 A typed_variable can only be declare once.
13344
13345 @noindent
13346 a non typed variable can be declared multiple times.
13347
13348 @noindent
13349 Before the completion of its first declaration, the value of variable
13350 is the null string.
13351
13352 @node Expressions
13353 @section Expressions
13354
13355 @noindent
13356 An expression is a formula that defines a computation or retrieval of a value.
13357 In a project file the value of an expression is either a string or a list
13358 of strings. A string value in an expression is either a literal, the current
13359 value of a variable, an external value, an attribute reference, or a
13360 concatenation operation.
13361
13362 Syntax:
13363
13364 @smallexample
13365 expression ::=
13366   term @{& term@}
13367
13368 term ::=
13369   string_literal |
13370   string_list |
13371   <variable_>name |
13372   external_value |
13373   attribute_reference
13374
13375 string_literal ::=
13376   (same as Ada)
13377
13378 string_list ::=
13379   ( <string_>expression @{ , <string_>expression @} )
13380 @end smallexample
13381
13382 @subsection Concatenation
13383 @noindent
13384 The following concatenation functions are defined:
13385
13386 @smallexample @c ada
13387   function "&" (X : String;      Y : String)      return String;
13388   function "&" (X : String_List; Y : String)      return String_List;
13389   function "&" (X : String_List; Y : String_List) return String_List;
13390 @end smallexample
13391
13392 @node Attributes
13393 @section Attributes
13394
13395 @noindent
13396 An attribute declaration defines a property of a project or package. This
13397 property can later be queried by means of an attribute reference.
13398 Attribute values are strings or string lists.
13399
13400 Some attributes are associative arrays. These attributes are mappings whose
13401 domain is a set of strings. These attributes are declared one association
13402 at a time, by specifying a point in the domain and the corresponding image
13403 of the attribute. They may also be declared as a full associative array,
13404 getting the same associations as the corresponding attribute in an imported
13405 or extended project.
13406
13407 Attributes that are not associative arrays are called simple attributes.
13408
13409 Syntax:
13410 @smallexample
13411 attribute_declaration ::=
13412   full_associative_array_declaration |
13413   @b{for} attribute_designator @b{use} expression ;
13414
13415 full_associative_array_declaration ::=
13416   @b{for} <associative_array_attribute_>simple_name @b{use}
13417   <project_>simple_name [ . <package_>simple_Name ] ' <attribute_>simple_name ;
13418
13419 attribute_designator ::=
13420   <simple_attribute_>simple_name |
13421   <associative_array_attribute_>simple_name ( string_literal )
13422 @end smallexample
13423
13424 @noindent
13425 Some attributes are project-specific, and can only appear immediately within
13426 a project declaration. Others are package-specific, and can only appear within
13427 the proper package.
13428
13429 The expression in an attribute definition must be a string or a string_list.
13430 The string literal appearing in the attribute_designator of an associative
13431 array attribute is case-insensitive.
13432
13433 @node Project Attributes
13434 @section Project Attributes
13435
13436 @noindent
13437 The following attributes apply to a project. All of them are simple
13438 attributes.
13439
13440 @table @code
13441 @item   Object_Dir
13442 Expression must be a path name. The attribute defines the
13443 directory in which the object files created by the build are to be placed. If
13444 not specified, object files are placed in the project directory.
13445
13446 @item   Exec_Dir
13447 Expression must be a path name. The attribute defines the
13448 directory in which the executables created by the build are to be placed.
13449 If not specified, executables are placed in the object directory.
13450
13451 @item  Source_Dirs
13452 Expression must be a list of path names. The attribute
13453 defines the directories in which the source files for the project are to be
13454 found. If not specified, source files are found in the project directory.
13455
13456 @item  Source_Files
13457 Expression must be a list of file names. The attribute
13458 defines the individual files, in the project directory, which are to be used
13459 as sources for the project. File names are path_names that contain no directory
13460 information. If the project has no sources the attribute must be declared
13461 explicitly with an empty list.
13462
13463 @item  Source_List_File
13464 Expression must a single path name. The attribute
13465 defines a text file that contains a list of source file names to be used
13466 as sources for the project
13467
13468 @item  Library_Dir
13469 Expression must be a path name. The attribute defines the
13470 directory in which a  library is to be built.  The directory must exist, must
13471 be distinct from the project's object directory, and must be writable.
13472
13473 @item  Library_Name
13474 Expression must be a string that is a legal file name,
13475 without extension. The attribute defines a string that is used to generate
13476 the name of the library to be built by the project.
13477
13478 @item  Library_Kind
13479 Argument must be a string value that must be one of the
13480 following @code{"static"}, @code{"dynamic"} or @code{"relocatable"}. This
13481 string is case-insensitive. If this attribute is not specified, the library is
13482 a static library. Otherwise, the library may be dynamic or relocatable. This
13483 distinction is operating-system dependent.
13484
13485 @item  Library_Version
13486 Expression must be a string value whose interpretation
13487 is platform dependent. On UNIX, it is used only for dynamic/relocatable
13488 libraries as the internal name of the library (the @code{"soname"}). If the
13489 library file name (built from the @code{Library_Name}) is different from the
13490 @code{Library_Version}, then the library file will be a symbolic link to the
13491 actual file whose name will be @code{Library_Version}.
13492
13493 @item Library_Interface
13494 Expression must be a string list. Each element of the string list
13495 must designate a unit of the project.
13496 If this attribute is present in a Library Project File, then the project
13497 file is a Stand-alone Library_Project_File.
13498
13499 @item Library_Auto_Init
13500 Expression must be a single string "true" or "false", case-insensitive.
13501 If this attribute is present in a Stand-alone Library Project File,
13502 it indicates if initialization is automatic when the dynamic library
13503 is loaded.
13504
13505 @item Library_Options
13506 Expression must be a string list. Indicates additional switches that
13507 are to be used when building a shared library.
13508
13509 @item Library_GCC
13510 Expression must be a single string. Designates an alternative to "gcc"
13511 for building shared libraries.
13512
13513 @item  Library_Src_Dir
13514 Expression must be a path name. The attribute defines the
13515 directory in which the sources of the interfaces of a Stand-alone Library will
13516 be copied.  The directory must exist, must be distinct from the project's
13517 object directory and source directories, and must be writable.
13518
13519 @item  Main
13520 Expression must be a list of strings that are legal file names.
13521 These file names designate existing compilation units in the source directory
13522 that are legal main subprograms.
13523
13524 When a project file is elaborated, as part of the execution of a gnatmake
13525 command, one or several executables are built and placed in the Exec_Dir.
13526 If the gnatmake command does not include explicit file names, the executables
13527 that are built correspond to the files specified by this attribute.
13528
13529 @item Main_Language
13530 This is a simple attribute. Its value is a string that specifies the
13531 language of the main program.
13532
13533 @item  Languages
13534 Expression must be a string list. Each string designates
13535 a programming language that is known to GNAT. The strings are case-insensitive.
13536
13537 @item  Locally_Removed_Files
13538 This attribute is legal only in a project file that extends another.
13539 Expression must be a list of strings that are legal file names.
13540 Each file name must designate a source that would normally be inherited
13541 by the current project file. It cannot designate an immediate source that is
13542 not inherited. Each of the source files in the list are not considered to
13543 be sources of the project file: they are not inherited.
13544 @end table
13545
13546 @node Attribute References
13547 @section Attribute References
13548
13549 @noindent
13550 Attribute references are used to retrieve the value of previously defined
13551 attribute for a package or project.
13552 Syntax:
13553 @smallexample
13554 attribute_reference ::=
13555   attribute_prefix ' <simple_attribute_>simple_name [ ( string_literal ) ]
13556
13557 attribute_prefix ::=
13558   @b{project} |
13559   <project_simple_name | package_identifier |
13560   <project_>simple_name . package_identifier
13561 @end smallexample
13562
13563 @noindent
13564 If an attribute has not been specified for a given package or project, its
13565 value is the null string or the empty list.
13566
13567 @node External Values
13568 @section External Values
13569
13570 @noindent
13571 An external value is an expression whose value is obtained from the command
13572 that invoked the processing of the current project file (typically a
13573 gnatmake command).
13574
13575 Syntax:
13576 @smallexample
13577 external_value ::=
13578   @b{external} ( string_literal [, string_literal] )
13579 @end smallexample
13580
13581 @noindent
13582 The first string_literal is the string to be used on the command line or
13583 in the environment to specify the external value. The second string_literal,
13584 if present, is the default to use if there is no specification for this
13585 external value either on the command line or in the environment.
13586
13587 @node Case Construction
13588 @section Case Construction
13589
13590 @noindent
13591 A case construction supports attribute declarations that depend on the value of
13592 a previously declared variable.
13593
13594 Syntax:
13595 @smallexample
13596 case_construction ::=
13597   @b{case} <typed_variable_>name @b{is}
13598     @{case_item@}
13599   @b{end case} ;
13600
13601 case_item ::=
13602   @b{when} discrete_choice_list =>
13603     @{case_construction | attribute_declaration@}
13604
13605 discrete_choice_list ::=
13606   string_literal @{| string_literal@} |
13607     @b{others}
13608 @end smallexample
13609
13610 @noindent
13611 All choices in a choice list must be distinct. The choice lists of two
13612 distinct alternatives must be disjoint. Unlike Ada, the choice lists of all
13613 alternatives do not need to include all values of the type. An @code{others}
13614 choice must appear last in the list of alternatives.
13615
13616 @node Packages
13617 @section Packages
13618
13619 @noindent
13620 A package provides a grouping of variable declarations and attribute
13621 declarations to be used when invoking various GNAT tools. The name of
13622 the package indicates the tool(s) to which it applies.
13623 Syntax:
13624
13625 @smallexample
13626 package_declaration ::=
13627   package_specification | package_renaming
13628
13629 package_specification ::=
13630   @b{package} package_identifier @b{is}
13631     @{simple_declarative_item@}
13632   @b{end} package_identifier ;
13633
13634 package_identifier ::=
13635   @code{Naming} | @code{Builder} | @code{Compiler} | @code{Binder} |
13636   @code{Linker} | @code{Finder}  | @code{Cross_Reference} |
13637   @code{gnatls} | @code{IDE}     | @code{Pretty_Printer}
13638 @end smallexample
13639
13640 @subsection Package Naming
13641
13642 @noindent
13643 The attributes of a @code{Naming} package specifies the naming conventions
13644 that apply to the source files in a project. When invoking other GNAT tools,
13645 they will use the sources in the source directories that satisfy these
13646 naming conventions.
13647
13648 The following attributes apply to a @code{Naming} package:
13649
13650 @table @code
13651 @item Casing
13652 This is a simple attribute whose value is a string. Legal values of this
13653 string are @code{"lowercase"}, @code{"uppercase"} or @code{"mixedcase"}.
13654 These strings are themselves case insensitive.
13655
13656 @noindent
13657 If @code{Casing} is not specified, then the default is @code{"lowercase"}.
13658
13659 @item Dot_Replacement
13660 This is a simple attribute whose string value satisfies the following
13661 requirements:
13662
13663 @itemize @bullet
13664 @item It must not be empty
13665 @item It cannot start or end with an alphanumeric character
13666 @item It cannot be a single underscore
13667 @item It cannot start with an underscore followed by an alphanumeric
13668 @item It cannot contain a dot @code{'.'} if longer than one character
13669 @end itemize
13670
13671 @noindent
13672 If @code{Dot_Replacement} is not specified, then the default is @code{"-"}.
13673
13674 @item Spec_Suffix
13675 This is an associative array attribute, defined on language names,
13676 whose image is a string that must satisfy the following
13677 conditions:
13678
13679 @itemize @bullet
13680 @item It must not be empty
13681 @item It cannot start with an alphanumeric character
13682 @item It cannot start with an underscore followed by an alphanumeric character
13683 @end itemize
13684
13685 @noindent
13686 For Ada, the attribute denotes the suffix used in file names that contain
13687 library unit declarations, that is to say units that are package and
13688 subprogram declarations. If @code{Spec_Suffix ("Ada")} is not
13689 specified, then the default is @code{".ads"}.
13690
13691 For C and C++, the attribute denotes the suffix used in file names that
13692 contain prototypes.
13693
13694 @item Body_Suffix
13695 This is an associative array attribute defined on language names,
13696 whose image is a string that must satisfy the following
13697 conditions:
13698
13699 @itemize @bullet
13700 @item It must not be empty
13701 @item It cannot start with an alphanumeric character
13702 @item It cannot start with an underscore followed by an alphanumeric character
13703 @item It cannot be a suffix of @code{Spec_Suffix}
13704 @end itemize
13705
13706 @noindent
13707 For Ada, the attribute denotes the suffix used in file names that contain
13708 library bodies, that is to say units that are package and subprogram bodies.
13709 If @code{Body_Suffix ("Ada")} is not specified, then the default is
13710 @code{".adb"}.
13711
13712 For C and C++, the attribute denotes the suffix used in file names that contain
13713 source code.
13714
13715 @item Separate_Suffix
13716 This is a simple attribute whose value satisfies the same conditions as
13717 @code{Body_Suffix}.
13718
13719 This attribute is specific to Ada. It denotes the suffix used in file names
13720 that contain separate bodies. If it is not specified, then it defaults to same
13721 value as @code{Body_Suffix ("Ada")}.
13722
13723 @item Spec
13724 This is an associative array attribute, specific to Ada, defined over
13725 compilation unit names. The image is a string that is the name of the file
13726 that contains that library unit. The file name is case sensitive if the
13727 conventions of the host operating system require it.
13728
13729 @item Body
13730 This is an associative array attribute, specific to Ada, defined over
13731 compilation unit names. The image is a string that is the name of the file
13732 that contains the library unit body for the named unit. The file name is case
13733 sensitive if the conventions of the host operating system require it.
13734
13735 @item Specification_Exceptions
13736 This is an associative array attribute defined on language names,
13737 whose value is a list of strings.
13738
13739 This attribute is not significant for Ada.
13740
13741 For C and C++, each string in the list denotes the name of a file that
13742 contains prototypes, but whose suffix is not necessarily the
13743 @code{Spec_Suffix} for the language.
13744
13745 @item Implementation_Exceptions
13746 This is an associative array attribute defined on language names,
13747 whose value is a list of strings.
13748
13749 This attribute is not significant for Ada.
13750
13751 For C and C++, each string in the list denotes the name of a file that
13752 contains source code, but whose suffix is not necessarily the
13753 @code{Body_Suffix} for the language.
13754 @end table
13755
13756 The following attributes of package @code{Naming} are obsolescent. They are
13757 kept as synonyms of other attributes for compatibility with previous versions
13758 of the Project Manager.
13759
13760 @table @code
13761 @item Specification_Suffix
13762 This is a synonym of @code{Spec_Suffix}.
13763
13764 @item Implementation_Suffix
13765 This is a synonym of @code{Body_Suffix}.
13766
13767 @item Specification
13768 This is a synonym of @code{Spec}.
13769
13770 @item Implementation
13771 This is a synonym of @code{Body}.
13772 @end table
13773
13774 @subsection package Compiler
13775
13776 @noindent
13777 The attributes of the @code{Compiler} package specify the compilation options
13778 to be used by the underlying compiler.
13779
13780 @table @code
13781 @item  Default_Switches
13782 This is an associative array attribute. Its
13783 domain is a set of language names. Its range is a string list that
13784 specifies the compilation options to be used when compiling a component
13785 written in that language, for which no file-specific switches have been
13786 specified..
13787
13788 @item  Switches
13789 This is an associative array attribute. Its domain is
13790 a set of file names. Its range is a string list that specifies the
13791 compilation options to be used when compiling the named file. If a file
13792 is not specified in the Switches attribute, it is compiled with the
13793 settings specified by Default_Switches.
13794
13795 @item  Local_Configuration_Pragmas.
13796 This is a simple attribute, whose
13797 value is a path name that designates a file containing configuration pragmas
13798 to be used for all invocations of the compiler for immediate sources of the
13799 project.
13800
13801 @item Executable
13802 This is an associative array attribute. Its domain is
13803 a set of main source file names. Its range is a simple string that specifies
13804 the executable file name to be used when linking the specified main source.
13805 If a main source is not specified in the Executable attribute, the executable
13806 file name is deducted from the main source file name.
13807 @end table
13808
13809 @subsection package Builder
13810
13811 @noindent
13812 The attributes of package @code{Builder} specify the compilation, binding, and
13813 linking options to be used when building an executable for a project. The
13814 following attributes apply to package @code{Builder}:
13815
13816 @table @code
13817 @item Default_Switches
13818 As above.
13819
13820 @item Switches
13821 As above.
13822
13823 @item Global_Configuration_Pragmas
13824 This is a simple attribute, whose
13825 value is a path name that designates a file that contains configuration pragmas
13826 to be used in every build of an executable. If both local and global
13827 configuration pragmas are specified, a compilation makes use of both sets.
13828
13829 @item Executable
13830 This is an associative array attribute, defined over
13831 compilation unit names. The image is a string that is the name of the
13832 executable file corresponding to the main source file index.
13833 This attribute has no effect if its value is the empty string.
13834
13835 @item Executable_Suffix
13836 This is a simple attribute whose value is a suffix to be added to
13837 the executables that don't have an attribute Executable specified.
13838 @end table
13839
13840 @subsection package Gnatls
13841
13842 @noindent
13843 The attributes of package @code{Gnatls} specify the tool options to be used
13844 when invoking the library browser @command{gnatls}.
13845 The following attributes apply to package @code{Gnatls}:
13846
13847 @table @code
13848 @item Switches
13849 As above.
13850 @end table
13851
13852 @subsection package Binder
13853
13854 @noindent
13855 The attributes of package @code{Binder} specify the options to be used
13856 when invoking the binder in the construction of an executable.
13857 The following attributes apply to package @code{Binder}:
13858
13859 @table @code
13860 @item     Default_Switches
13861 As above.
13862 @item     Switches
13863 As above.
13864 @end table
13865
13866 @subsection package Linker
13867
13868 @noindent
13869 The attributes of package @code{Linker} specify the options to be used when
13870 invoking the linker in the construction of an executable.
13871 The following attributes apply to package @code{Linker}:
13872
13873 @table @code
13874 @item     Default_Switches
13875 As above
13876 @item     Switches
13877 As above.
13878 @end table
13879
13880 @subsection package Cross_Reference
13881
13882 @noindent
13883 The attributes of package @code{Cross_Reference} specify the tool options
13884 to be used
13885 when invoking the library tool @command{gnatxref}.
13886 The following attributes apply to package @code{Cross_Reference}:
13887
13888 @table @code
13889 @item     Default_Switches
13890 As above.
13891 @item     Switches
13892 As above.
13893 @end table
13894
13895 @subsection package   Finder
13896
13897 @noindent
13898 The attributes of package @code{Finder} specify the tool options to be used
13899 when invoking the search tool @command{gnatfind}.
13900 The following attributes apply to package @code{Finder}:
13901
13902 @table @code
13903 @item     Default_Switches
13904 As above.
13905 @item     Switches
13906 As above.
13907 @end table
13908
13909 @subsection package Pretty_Printer
13910
13911 @noindent
13912 The attributes of package @code{Pretty_Printer}
13913 specify the tool options to be used
13914 when invoking the formatting tool @command{gnatpp}.
13915 The following attributes apply to package @code{Pretty_Printer}:
13916
13917 @table @code
13918 @item     Default_switches
13919 As above.
13920 @item     Switches
13921 As above.
13922 @end table
13923
13924 @subsection  package IDE
13925
13926 @noindent
13927 The attributes of package @code{IDE} specify the options to be used when using
13928 an Integrated Development Environment such as @command{GPS}.
13929
13930 @table @code
13931 @item Remote_Host
13932 This is a simple attribute. Its value is a string that designates the remote
13933 host in a cross-compilation environment, to be used for remote compilation and
13934 debugging. This field should not be specified when running on the local
13935 machine.
13936
13937 @item Program_Host
13938 This is a simple attribute. Its value is a string that specifies the
13939 name of IP address of the embedded target in a cross-compilation environment,
13940 on which the program should execute.
13941
13942 @item Communication_Protocol
13943 This is a simple string attribute. Its value is the name of the protocol
13944 to use to communicate with the target in a cross-compilation environment,
13945 e.g. @code{"wtx"} or @code{"vxworks"}.
13946
13947 @item Compiler_Command
13948 This is an associative array attribute, whose domain is a language name. Its
13949 value is  string that denotes the command to be used to invoke the compiler.
13950 The value of @code{Compiler_Command ("Ada")} is expected to be compatible with
13951 gnatmake, in particular in the handling of switches.
13952
13953 @item Debugger_Command
13954 This is simple attribute, Its value is a string that specifies the name of
13955 the debugger to be used, such as gdb, powerpc-wrs-vxworks-gdb or gdb-4.
13956
13957 @item Default_Switches
13958 This is an associative array attribute. Its indexes are the name of the
13959 external tools that the GNAT Programming System (GPS) is supporting. Its
13960 value is a list of switches to use when invoking that tool.
13961
13962 @item  Gnatlist
13963 This is a simple attribute.  Its value is a string that specifies the name
13964 of the @command{gnatls} utility to be used to retrieve information about the
13965 predefined path; e.g., @code{"gnatls"}, @code{"powerpc-wrs-vxworks-gnatls"}.
13966
13967 @item VCS_Kind
13968 This is a simple atribute. Is value is a string used to specify the
13969 Version Control System (VCS) to be used for this project, e.g CVS, RCS
13970 ClearCase or Perforce.
13971
13972 @item VCS_File_Check
13973 This is a simple attribute. Its value is a string that specifies the
13974 command used by the VCS to check the validity of a file, either
13975 when the user explicitly asks for a check, or as a sanity check before
13976 doing the check-in.
13977
13978 @item VCS_Log_Check
13979 This is a simple attribute. Its value is a string that specifies
13980 the command used by the VCS to check the validity of a log file.
13981
13982 @end table
13983
13984 @node Package Renamings
13985 @section Package Renamings
13986
13987 @noindent
13988 A package can be defined by a renaming declaration. The new package renames
13989 a package declared in a different project file, and has the same attributes
13990 as the package it renames.
13991 Syntax:
13992 @smallexample
13993 package_renaming ::==
13994   @b{package} package_identifier @b{renames}
13995        <project_>simple_name.package_identifier ;
13996 @end smallexample
13997
13998 @noindent
13999 The package_identifier of the renamed package must be the same as the
14000 package_identifier. The project whose name is the prefix of the renamed
14001 package must contain a package declaration with this name. This project
14002 must appear in the context_clause of the enclosing project declaration,
14003 or be the parent project of the enclosing child project.
14004
14005 @node Projects
14006 @section Projects
14007
14008 @noindent
14009 A project file specifies a set of rules for constructing a software system.
14010 A project file can be self-contained, or depend on other project files.
14011 Dependencies are expressed through a context clause that names other projects.
14012
14013 Syntax:
14014
14015 @smallexample
14016 project ::=
14017   context_clause project_declaration
14018
14019 project_declaration ::=
14020   simple_project_declaration | project_extension
14021
14022 simple_project_declaration ::=
14023   @b{project} <project_>simple_name @b{is}
14024     @{declarative_item@}
14025   @b{end} <project_>simple_name;
14026
14027 context_clause ::=
14028   @{with_clause@}
14029
14030 with_clause ::=
14031   [@b{limited}] @b{with} path_name @{ , path_name @} ;
14032
14033 path_name ::=
14034    string_literal
14035 @end smallexample
14036
14037 @noindent
14038 A path name denotes a project file. A path name can be absolute or relative.
14039 An absolute path name includes a sequence of directories, in the syntax of
14040 the host operating system, that identifies uniquely the project file in the
14041 file system. A relative path name identifies the project file, relative
14042 to the directory that contains the current project, or relative to a
14043 directory listed in the environment variable ADA_PROJECT_PATH.
14044 Path names are case sensitive if file names in the host operating system
14045 are case sensitive.
14046
14047 The syntax of the environment variable ADA_PROJECT_PATH is a list of
14048 directory names separated by colons (semicolons on Windows).
14049
14050 A given project name can appear only once in a context_clause.
14051
14052 It is illegal for a project imported by a context clause to refer, directly
14053 or indirectly, to the project in which this context clause appears (the
14054 dependency graph cannot contain cycles), except when one of the with_clause
14055 in the cycle is a @code{limited with}.
14056
14057 @node Project Extensions
14058 @section Project Extensions
14059
14060 @noindent
14061 A project extension introduces a new project, which inherits the declarations
14062 of another project.
14063 Syntax:
14064 @smallexample
14065
14066 project_extension ::=
14067   @b{project} <project_>simple_name  @b{extends} path_name @b{is}
14068     @{declarative_item@}
14069   @b{end} <project_>simple_name;
14070 @end smallexample
14071
14072 @noindent
14073 The project extension declares a child project. The child project inherits
14074 all the declarations and all the files of the parent project, These inherited
14075 declaration can be overridden in the child project, by means of suitable
14076 declarations.
14077
14078 @node Project File Elaboration
14079 @section Project File Elaboration
14080
14081 @noindent
14082 A project file is processed as part of the invocation of a gnat tool that
14083 uses the project option. Elaboration of the process file consists in the
14084 sequential elaboration of all its declarations. The computed values of
14085 attributes and variables in the project are then used to establish the
14086 environment in which the gnat tool will execute.
14087
14088 @include fdl.texi
14089 @c GNU Free Documentation License
14090
14091 @node Index,,GNU Free Documentation License, Top
14092 @unnumbered Index
14093
14094 @printindex cp
14095
14096 @contents
14097
14098 @bye