OSDN Git Service

2004-07-15 Robert Dewar <dewar@gnat.com>
[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 GCC version @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 Profile (Ravenscar)::
155 * Pragma Propagate_Exceptions::
156 * Pragma Psect_Object::
157 * Pragma Pure_Function::
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_Access_Values::
206 * Has_Discriminants::
207 * Img::
208 * Integer_Value::
209 * Large::
210 * Machine_Size::
211 * Mantissa::
212 * Max_Interrupt_Priority::
213 * Max_Priority::
214 * Maximum_Alignment::
215 * Mechanism_Code::
216 * Null_Parameter::
217 * Object_Size::
218 * Passed_By_Reference::
219 * Range_Length::
220 * Safe_Emax::
221 * Safe_Large::
222 * Small::
223 * Storage_Unit::
224 * Target_Name::
225 * Tick::
226 * To_Address::
227 * Type_Class::
228 * UET_Address::
229 * Unconstrained_Array::
230 * Universal_Literal_String::
231 * Unrestricted_Access::
232 * VADS_Size::
233 * Value_Size::
234 * Wchar_T_Size::
235 * Word_Size::
236
237 The Implementation of Standard I/O
238
239 * Standard I/O Packages::
240 * FORM Strings::
241 * Direct_IO::
242 * Sequential_IO::
243 * Text_IO::
244 * Wide_Text_IO::
245 * Stream_IO::
246 * Shared Files::
247 * Open Modes::
248 * Operations on C Streams::
249 * Interfacing to C Streams::
250
251 The GNAT Library
252
253 * Ada.Characters.Latin_9 (a-chlat9.ads)::
254 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
255 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
256 * Ada.Command_Line.Remove (a-colire.ads)::
257 * Ada.Command_Line.Environment (a-colien.ads)::
258 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
259 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
260 * Ada.Exceptions.Traceback (a-exctra.ads)::
261 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
262 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
263 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
264 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
265 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
266 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
267 * GNAT.Array_Split (g-arrspl.ads)::
268 * GNAT.AWK (g-awk.ads)::
269 * GNAT.Bounded_Buffers (g-boubuf.ads)::
270 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
271 * GNAT.Bubble_Sort (g-bubsor.ads)::
272 * GNAT.Bubble_Sort_A (g-busora.ads)::
273 * GNAT.Bubble_Sort_G (g-busorg.ads)::
274 * GNAT.Calendar (g-calend.ads)::
275 * GNAT.Calendar.Time_IO (g-catiio.ads)::
276 * GNAT.Case_Util (g-casuti.ads)::
277 * GNAT.CGI (g-cgi.ads)::
278 * GNAT.CGI.Cookie (g-cgicoo.ads)::
279 * GNAT.CGI.Debug (g-cgideb.ads)::
280 * GNAT.Command_Line (g-comlin.ads)::
281 * GNAT.Compiler_Version (g-comver.ads)::
282 * GNAT.Ctrl_C (g-ctrl_c.ads)::
283 * GNAT.CRC32 (g-crc32.ads)::
284 * GNAT.Current_Exception (g-curexc.ads)::
285 * GNAT.Debug_Pools (g-debpoo.ads)::
286 * GNAT.Debug_Utilities (g-debuti.ads)::
287 * GNAT.Directory_Operations (g-dirope.ads)::
288 * GNAT.Dynamic_HTables (g-dynhta.ads)::
289 * GNAT.Dynamic_Tables (g-dyntab.ads)::
290 * GNAT.Exception_Actions (g-excact.ads)::
291 * GNAT.Exception_Traces (g-exctra.ads)::
292 * GNAT.Exceptions (g-except.ads)::
293 * GNAT.Expect (g-expect.ads)::
294 * GNAT.Float_Control (g-flocon.ads)::
295 * GNAT.Heap_Sort (g-heasor.ads)::
296 * GNAT.Heap_Sort_A (g-hesora.ads)::
297 * GNAT.Heap_Sort_G (g-hesorg.ads)::
298 * GNAT.HTable (g-htable.ads)::
299 * GNAT.IO (g-io.ads)::
300 * GNAT.IO_Aux (g-io_aux.ads)::
301 * GNAT.Lock_Files (g-locfil.ads)::
302 * GNAT.MD5 (g-md5.ads)::
303 * GNAT.Memory_Dump (g-memdum.ads)::
304 * GNAT.Most_Recent_Exception (g-moreex.ads)::
305 * GNAT.OS_Lib (g-os_lib.ads)::
306 * GNAT.Perfect_Hash.Generators (g-pehage.ads)::
307 * GNAT.Regexp (g-regexp.ads)::
308 * GNAT.Registry (g-regist.ads)::
309 * GNAT.Regpat (g-regpat.ads)::
310 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
311 * GNAT.Semaphores (g-semaph.ads)::
312 * GNAT.Signals (g-signal.ads)::
313 * GNAT.Sockets (g-socket.ads)::
314 * GNAT.Source_Info (g-souinf.ads)::
315 * GNAT.Spell_Checker (g-speche.ads)::
316 * GNAT.Spitbol.Patterns (g-spipat.ads)::
317 * GNAT.Spitbol (g-spitbo.ads)::
318 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
319 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
320 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
321 * GNAT.Strings (g-string.ads)::
322 * GNAT.String_Split (g-strspl.ads)::
323 * GNAT.Table (g-table.ads)::
324 * GNAT.Task_Lock (g-tasloc.ads)::
325 * GNAT.Threads (g-thread.ads)::
326 * GNAT.Traceback (g-traceb.ads)::
327 * GNAT.Traceback.Symbolic (g-trasym.ads)::
328 * GNAT.Wide_String_Split (g-wistsp.ads)::
329 * Interfaces.C.Extensions (i-cexten.ads)::
330 * Interfaces.C.Streams (i-cstrea.ads)::
331 * Interfaces.CPP (i-cpp.ads)::
332 * Interfaces.Os2lib (i-os2lib.ads)::
333 * Interfaces.Os2lib.Errors (i-os2err.ads)::
334 * Interfaces.Os2lib.Synchronization (i-os2syn.ads)::
335 * Interfaces.Os2lib.Threads (i-os2thr.ads)::
336 * Interfaces.Packed_Decimal (i-pacdec.ads)::
337 * Interfaces.VxWorks (i-vxwork.ads)::
338 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
339 * System.Address_Image (s-addima.ads)::
340 * System.Assertions (s-assert.ads)::
341 * System.Memory (s-memory.ads)::
342 * System.Partition_Interface (s-parint.ads)::
343 * System.Restrictions (s-restri.ads)::
344 * System.Rident (s-rident.ads)::
345 * System.Task_Info (s-tasinf.ads)::
346 * System.Wch_Cnv (s-wchcnv.ads)::
347 * System.Wch_Con (s-wchcon.ads)::
348
349 Text_IO
350
351 * Text_IO Stream Pointer Positioning::
352 * Text_IO Reading and Writing Non-Regular Files::
353 * Get_Immediate::
354 * Treating Text_IO Files as Streams::
355 * Text_IO Extensions::
356 * Text_IO Facilities for Unbounded Strings::
357
358 Wide_Text_IO
359
360 * Wide_Text_IO Stream Pointer Positioning::
361 * Wide_Text_IO Reading and Writing Non-Regular Files::
362
363 Interfacing to Other Languages
364
365 * Interfacing to C::
366 * Interfacing to C++::
367 * Interfacing to COBOL::
368 * Interfacing to Fortran::
369 * Interfacing to non-GNAT Ada code::
370
371 Specialized Needs Annexes
372
373 Implementation of Specific Ada Features
374 * Machine Code Insertions::
375 * GNAT Implementation of Tasking::
376 * GNAT Implementation of Shared Passive Packages::
377 * Code Generation for Array Aggregates::
378
379 Project File Reference
380
381 GNU Free Documentation License
382
383 Index
384 @end menu
385
386 @end ifnottex
387
388 @node About This Guide
389 @unnumbered About This Guide
390
391 @noindent
392 This manual contains useful information in writing programs using the
393 GNAT compiler.  It includes information on implementation dependent
394 characteristics of GNAT, including all the information required by Annex
395 M of the standard.
396
397 Ada 95 is designed to be highly portable.
398 In general, a program will have the same effect even when compiled by
399 different compilers on different platforms.
400 However, since Ada 95 is designed to be used in a
401 wide variety of applications, it also contains a number of system
402 dependent features to be used in interfacing to the external world.
403 @cindex Implementation-dependent features
404 @cindex Portability
405
406 Note: Any program that makes use of implementation-dependent features
407 may be non-portable.  You should follow good programming practice and
408 isolate and clearly document any sections of your program that make use
409 of these features in a non-portable manner.
410
411 @menu
412 * What This Reference Manual Contains::
413 * Conventions::
414 * Related Information::
415 @end menu
416
417 @node What This Reference Manual Contains
418 @unnumberedsec What This Reference Manual Contains
419
420 @noindent
421 This reference manual contains the following chapters:
422
423 @itemize @bullet
424 @item
425 @ref{Implementation Defined Pragmas}, lists GNAT implementation-dependent
426 pragmas, which can be used to extend and enhance the functionality of the
427 compiler.
428
429 @item
430 @ref{Implementation Defined Attributes}, lists GNAT
431 implementation-dependent attributes which can be used to extend and
432 enhance the functionality of the compiler.
433
434 @item
435 @ref{Implementation Advice}, provides information on generally
436 desirable behavior which are not requirements that all compilers must
437 follow since it cannot be provided on all systems, or which may be
438 undesirable on some systems.
439
440 @item
441 @ref{Implementation Defined Characteristics}, provides a guide to
442 minimizing implementation dependent features.
443
444 @item
445 @ref{Intrinsic Subprograms}, describes the intrinsic subprograms
446 implemented by GNAT, and how they can be imported into user
447 application programs.
448
449 @item
450 @ref{Representation Clauses and Pragmas}, describes in detail the
451 way that GNAT represents data, and in particular the exact set
452 of representation clauses and pragmas that is accepted.
453
454 @item
455 @ref{Standard Library Routines}, provides a listing of packages and a
456 brief description of the functionality that is provided by Ada's
457 extensive set of standard library routines as implemented by GNAT@.
458
459 @item
460 @ref{The Implementation of Standard I/O}, details how the GNAT
461 implementation of the input-output facilities.
462
463 @item
464 @ref{The GNAT Library}, is a catalog of packages that complement
465 the Ada predefined library.
466
467 @item
468 @ref{Interfacing to Other Languages}, describes how programs
469 written in Ada using GNAT can be interfaced to other programming
470 languages.
471
472 @ref{Specialized Needs Annexes}, describes the GNAT implementation of all
473 of the specialized needs annexes.
474
475 @item
476 @ref{Implementation of Specific Ada Features}, discusses issues related
477 to GNAT's implementation of machine code insertions, tasking, and several
478 other features.
479
480 @item
481 @ref{Project File Reference}, presents the syntax and semantics
482 of project files.
483
484 @end itemize
485
486 @cindex Ada 95 ISO/ANSI Standard
487 @noindent
488 This reference manual assumes that you are familiar with Ada 95
489 language, as described in the International Standard
490 ANSI/ISO/IEC-8652:1995, Jan 1995.
491
492 @node Conventions
493 @unnumberedsec Conventions
494 @cindex Conventions, typographical
495 @cindex Typographical conventions
496
497 @noindent
498 Following are examples of the typographical and graphic conventions used
499 in this guide:
500
501 @itemize @bullet
502 @item
503 @code{Functions}, @code{utility program names}, @code{standard names},
504 and @code{classes}.
505
506 @item
507 @code{Option flags}
508
509 @item
510 @file{File Names}, @samp{button names}, and @samp{field names}.
511
512 @item
513 @code{Variables}.
514
515 @item
516 @emph{Emphasis}.
517
518 @item
519 [optional information or parameters]
520
521 @item
522 Examples are described by text
523 @smallexample
524 and then shown this way.
525 @end smallexample
526 @end itemize
527
528 @noindent
529 Commands that are entered by the user are preceded in this manual by the
530 characters @samp{$ } (dollar sign followed by space).  If your system uses this
531 sequence as a prompt, then the commands will appear exactly as you see them
532 in the manual.  If your system uses some other prompt, then the command will
533 appear with the @samp{$} replaced by whatever prompt character you are using.
534
535 @node Related Information
536 @unnumberedsec Related Information
537 @noindent
538 See the following documents for further information on GNAT:
539
540 @itemize @bullet
541 @item
542 @cite{GNAT User's Guide}, which provides information on how to use
543 the GNAT compiler system.
544
545 @item
546 @cite{Ada 95 Reference Manual}, which contains all reference
547 material for the Ada 95 programming language.
548
549 @item
550 @cite{Ada 95 Annotated Reference Manual}, which is an annotated version
551 of the standard reference manual cited above.  The annotations describe
552 detailed aspects of the design decision, and in particular contain useful
553 sections on Ada 83 compatibility.
554
555 @item
556 @cite{DEC Ada, Technical Overview and Comparison on DIGITAL Platforms},
557 which contains specific information on compatibility between GNAT and
558 DEC Ada 83 systems.
559
560 @item
561 @cite{DEC Ada, Language Reference Manual, part number AA-PYZAB-TK} which
562 describes in detail the pragmas and attributes provided by the DEC Ada 83
563 compiler system.
564
565 @end itemize
566
567 @node Implementation Defined Pragmas
568 @chapter Implementation Defined Pragmas
569
570 @noindent
571 Ada 95 defines a set of pragmas that can be used to supply additional
572 information to the compiler.  These language defined pragmas are
573 implemented in GNAT and work as described in the Ada 95 Reference
574 Manual.
575
576 In addition, Ada 95 allows implementations to define additional pragmas
577 whose meaning is defined by the implementation.  GNAT provides a number
578 of these implementation-dependent pragmas which can be used to extend
579 and enhance the functionality of the compiler.  This section of the GNAT
580 Reference Manual describes these additional pragmas.
581
582 Note that any program using these pragmas may not be portable to other
583 compilers (although GNAT implements this set of pragmas on all
584 platforms).  Therefore if portability to other compilers is an important
585 consideration, the use of these pragmas should be minimized.
586
587 @menu
588 * Pragma Abort_Defer::
589 * Pragma Ada_83::
590 * Pragma Ada_95::
591 * Pragma Annotate::
592 * Pragma Assert::
593 * Pragma Ast_Entry::
594 * Pragma C_Pass_By_Copy::
595 * Pragma Comment::
596 * Pragma Common_Object::
597 * Pragma Compile_Time_Warning::
598 * Pragma Complex_Representation::
599 * Pragma Component_Alignment::
600 * Pragma Convention_Identifier::
601 * Pragma CPP_Class::
602 * Pragma CPP_Constructor::
603 * Pragma CPP_Virtual::
604 * Pragma CPP_Vtable::
605 * Pragma Debug::
606 * Pragma Elaboration_Checks::
607 * Pragma Eliminate::
608 * Pragma Export_Exception::
609 * Pragma Export_Function::
610 * Pragma Export_Object::
611 * Pragma Export_Procedure::
612 * Pragma Export_Value::
613 * Pragma Export_Valued_Procedure::
614 * Pragma Extend_System::
615 * Pragma External::
616 * Pragma External_Name_Casing::
617 * Pragma Finalize_Storage_Only::
618 * Pragma Float_Representation::
619 * Pragma Ident::
620 * Pragma Import_Exception::
621 * Pragma Import_Function::
622 * Pragma Import_Object::
623 * Pragma Import_Procedure::
624 * Pragma Import_Valued_Procedure::
625 * Pragma Initialize_Scalars::
626 * Pragma Inline_Always::
627 * Pragma Inline_Generic::
628 * Pragma Interface::
629 * Pragma Interface_Name::
630 * Pragma Interrupt_Handler::
631 * Pragma Interrupt_State::
632 * Pragma Keep_Names::
633 * Pragma License::
634 * Pragma Link_With::
635 * Pragma Linker_Alias::
636 * Pragma Linker_Section::
637 * Pragma Long_Float::
638 * Pragma Machine_Attribute::
639 * Pragma Main_Storage::
640 * Pragma No_Return::
641 * Pragma Normalize_Scalars::
642 * Pragma Obsolescent::
643 * Pragma Passive::
644 * Pragma Polling::
645 * Pragma Profile (Ravenscar)::
646 * Pragma Propagate_Exceptions::
647 * Pragma Psect_Object::
648 * Pragma Pure_Function::
649 * Pragma Restricted_Run_Time::
650 * Pragma Restriction_Warnings::
651 * Pragma Source_File_Name::
652 * Pragma Source_File_Name_Project::
653 * Pragma Source_Reference::
654 * Pragma Stream_Convert::
655 * Pragma Style_Checks::
656 * Pragma Subtitle::
657 * Pragma Suppress_All::
658 * Pragma Suppress_Exception_Locations::
659 * Pragma Suppress_Initialization::
660 * Pragma Task_Info::
661 * Pragma Task_Name::
662 * Pragma Task_Storage::
663 * Pragma Thread_Body::
664 * Pragma Time_Slice::
665 * Pragma Title::
666 * Pragma Unchecked_Union::
667 * Pragma Unimplemented_Unit::
668 * Pragma Universal_Data::
669 * Pragma Unreferenced::
670 * Pragma Unreserve_All_Interrupts::
671 * Pragma Unsuppress::
672 * Pragma Use_VADS_Size::
673 * Pragma Validity_Checks::
674 * Pragma Volatile::
675 * Pragma Warnings::
676 * Pragma Weak_External::
677 @end menu
678
679 @node Pragma Abort_Defer
680 @unnumberedsec Pragma Abort_Defer
681 @findex Abort_Defer
682 @cindex Deferring aborts
683 @noindent
684 Syntax:
685 @smallexample
686 pragma Abort_Defer;
687 @end smallexample
688
689 @noindent
690 This pragma must appear at the start of the statement sequence of a
691 handled sequence of statements (right after the @code{begin}).  It has
692 the effect of deferring aborts for the sequence of statements (but not
693 for the declarations or handlers, if any, associated with this statement
694 sequence).
695
696 @node Pragma Ada_83
697 @unnumberedsec Pragma Ada_83
698 @findex Ada_83
699 @noindent
700 Syntax:
701 @smallexample @c ada
702 pragma Ada_83;
703 @end smallexample
704
705 @noindent
706 A configuration pragma that establishes Ada 83 mode for the unit to
707 which it applies, regardless of the mode set by the command line
708 switches.  In Ada 83 mode, GNAT attempts to be as compatible with
709 the syntax and semantics of Ada 83, as defined in the original Ada
710 83 Reference Manual as possible.  In particular, the new Ada 95
711 keywords are not recognized, optional package bodies are allowed,
712 and generics may name types with unknown discriminants without using
713 the @code{(<>)} notation.  In addition, some but not all of the additional
714 restrictions of Ada 83 are enforced.
715
716 Ada 83 mode is intended for two purposes.  Firstly, it allows existing
717 legacy Ada 83 code to be compiled and adapted to GNAT with less effort.
718 Secondly, it aids in keeping code backwards compatible with Ada 83.
719 However, there is no guarantee that code that is processed correctly
720 by GNAT in Ada 83 mode will in fact compile and execute with an Ada
721 83 compiler, since GNAT does not enforce all the additional checks
722 required by Ada 83.
723
724 @node Pragma Ada_95
725 @unnumberedsec Pragma Ada_95
726 @findex Ada_95
727 @noindent
728 Syntax:
729 @smallexample @c ada
730 pragma Ada_95;
731 @end smallexample
732
733 @noindent
734 A configuration pragma that establishes Ada 95 mode for the unit to which
735 it applies, regardless of the mode set by the command line switches.
736 This mode is set automatically for the @code{Ada} and @code{System}
737 packages and their children, so you need not specify it in these
738 contexts.  This pragma is useful when writing a reusable component that
739 itself uses Ada 95 features, but which is intended to be usable from
740 either Ada 83 or Ada 95 programs.
741
742 @node Pragma Annotate
743 @unnumberedsec Pragma Annotate
744 @findex Annotate
745 @noindent
746 Syntax:
747 @smallexample @c ada
748 pragma Annotate (IDENTIFIER @{, ARG@});
749
750 ARG ::= NAME | EXPRESSION
751 @end smallexample
752
753 @noindent
754 This pragma is used to annotate programs.  @var{identifier} identifies
755 the type of annotation.  GNAT verifies this is an identifier, but does
756 not otherwise analyze it.  The @var{arg} argument
757 can be either a string literal or an
758 expression.  String literals are assumed to be of type
759 @code{Standard.String}.  Names of entities are simply analyzed as entity
760 names.  All other expressions are analyzed as expressions, and must be
761 unambiguous.
762
763 The analyzed pragma is retained in the tree, but not otherwise processed
764 by any part of the GNAT compiler.  This pragma is intended for use by
765 external tools, including ASIS@.
766
767 @node Pragma Assert
768 @unnumberedsec Pragma Assert
769 @findex Assert
770 @noindent
771 Syntax:
772 @smallexample @c ada
773 pragma Assert (
774   boolean_EXPRESSION
775   [, static_string_EXPRESSION]);
776 @end smallexample
777
778 @noindent
779 The effect of this pragma depends on whether the corresponding command
780 line switch is set to activate assertions.  The pragma expands into code
781 equivalent to the following:
782
783 @smallexample @c ada
784 if assertions-enabled then
785    if not boolean_EXPRESSION then
786       System.Assertions.Raise_Assert_Failure
787         (string_EXPRESSION);
788    end if;
789 end if;
790 @end smallexample
791
792 @noindent
793 The string argument, if given, is the message that will be associated
794 with the exception occurrence if the exception is raised.  If no second
795 argument is given, the default message is @samp{@var{file}:@var{nnn}},
796 where @var{file} is the name of the source file containing the assert,
797 and @var{nnn} is the line number of the assert.  A pragma is not a
798 statement, so if a statement sequence contains nothing but a pragma
799 assert, then a null statement is required in addition, as in:
800
801 @smallexample @c ada
802 @dots{}
803 if J > 3 then
804    pragma Assert (K > 3, "Bad value for K");
805    null;
806 end if;
807 @end smallexample
808
809 @noindent
810 Note that, as with the @code{if} statement to which it is equivalent, the
811 type of the expression is either @code{Standard.Boolean}, or any type derived
812 from this standard type.
813
814 If assertions are disabled (switch @code{-gnata} not used), then there
815 is no effect (and in particular, any side effects from the expression
816 are suppressed).  More precisely it is not quite true that the pragma
817 has no effect, since the expression is analyzed, and may cause types
818 to be frozen if they are mentioned here for the first time.
819
820 If assertions are enabled, then the given expression is tested, and if
821 it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
822 which results in the raising of @code{Assert_Failure} with the given message.
823
824 If the boolean expression has side effects, these side effects will turn
825 on and off with the setting of the assertions mode, resulting in
826 assertions that have an effect on the program.  You should generally
827 avoid side effects in the expression arguments of this pragma.  However,
828 the expressions are analyzed for semantic correctness whether or not
829 assertions are enabled, so turning assertions on and off cannot affect
830 the legality of a program.
831
832 @node Pragma Ast_Entry
833 @unnumberedsec Pragma Ast_Entry
834 @cindex OpenVMS
835 @findex Ast_Entry
836 @noindent
837 Syntax:
838 @smallexample @c ada
839 pragma AST_Entry (entry_IDENTIFIER);
840 @end smallexample
841
842 @noindent
843 This pragma is implemented only in the OpenVMS implementation of GNAT@.  The
844 argument is the simple name of a single entry; at most one @code{AST_Entry}
845 pragma is allowed for any given entry.  This pragma must be used in
846 conjunction with the @code{AST_Entry} attribute, and is only allowed after
847 the entry declaration and in the same task type specification or single task
848 as the entry to which it applies.  This pragma specifies that the given entry
849 may be used to handle an OpenVMS asynchronous system trap (@code{AST})
850 resulting from an OpenVMS system service call.  The pragma does not affect
851 normal use of the entry.  For further details on this pragma, see the
852 DEC Ada Language Reference Manual, section 9.12a.
853
854 @node Pragma C_Pass_By_Copy
855 @unnumberedsec Pragma C_Pass_By_Copy
856 @cindex Passing by copy
857 @findex C_Pass_By_Copy
858 @noindent
859 Syntax:
860 @smallexample @c ada
861 pragma C_Pass_By_Copy
862   ([Max_Size =>] static_integer_EXPRESSION);
863 @end smallexample
864
865 @noindent
866 Normally the default mechanism for passing C convention records to C
867 convention subprograms is to pass them by reference, as suggested by RM
868 B.3(69).  Use the configuration pragma @code{C_Pass_By_Copy} to change
869 this default, by requiring that record formal parameters be passed by
870 copy if all of the following conditions are met:
871
872 @itemize @bullet
873 @item
874 The size of the record type does not exceed@*@var{static_integer_expression}.
875 @item
876 The record type has @code{Convention C}.
877 @item
878 The formal parameter has this record type, and the subprogram has a
879 foreign (non-Ada) convention.
880 @end itemize
881
882 @noindent
883 If these conditions are met the argument is passed by copy, i.e.@: in a
884 manner consistent with what C expects if the corresponding formal in the
885 C prototype is a struct (rather than a pointer to a struct).
886
887 You can also pass records by copy by specifying the convention
888 @code{C_Pass_By_Copy} for the record type, or by using the extended
889 @code{Import} and @code{Export} pragmas, which allow specification of
890 passing mechanisms on a parameter by parameter basis.
891
892 @node Pragma Comment
893 @unnumberedsec Pragma Comment
894 @findex Comment
895 @noindent
896 Syntax:
897
898 @smallexample @c ada
899 pragma Comment (static_string_EXPRESSION);
900 @end smallexample
901
902 @noindent
903 This is almost identical in effect to pragma @code{Ident}.  It allows the
904 placement of a comment into the object file and hence into the
905 executable file if the operating system permits such usage.  The
906 difference is that @code{Comment}, unlike @code{Ident}, has
907 no limitations on placement of the pragma (it can be placed
908 anywhere in the main source unit), and if more than one pragma
909 is used, all comments are retained.
910
911 @node Pragma Common_Object
912 @unnumberedsec Pragma Common_Object
913 @findex Common_Object
914 @noindent
915 Syntax:
916
917 @smallexample @c ada
918 pragma Common_Object (
919      [Internal =>] LOCAL_NAME,
920   [, [External =>] EXTERNAL_SYMBOL]
921   [, [Size     =>] EXTERNAL_SYMBOL] );
922
923 EXTERNAL_SYMBOL ::=
924   IDENTIFIER
925 | static_string_EXPRESSION
926 @end smallexample
927
928 @noindent
929 This pragma enables the shared use of variables stored in overlaid
930 linker areas corresponding to the use of @code{COMMON}
931 in Fortran.  The single
932 object @var{local_name} is assigned to the area designated by
933 the @var{External} argument.
934 You may define a record to correspond to a series
935 of fields.  The @var{size} argument
936 is syntax checked in GNAT, but otherwise ignored.
937
938 @code{Common_Object} is not supported on all platforms.  If no
939 support is available, then the code generator will issue a message
940 indicating that the necessary attribute for implementation of this
941 pragma is not available.
942
943 @node Pragma Compile_Time_Warning
944 @unnumberedsec Pragma Compile_Time_Warning
945 @findex Compile_Time_Warning
946 @noindent
947 Syntax:
948
949 @smallexample @c ada
950 pragma Compile_Time_Warning
951          (boolean_EXPRESSION, static_string_EXPRESSION);
952 @end smallexample
953
954 @noindent
955 This pragma can be used to generate additional compile time warnings. It
956 is particularly useful in generics, where warnings can be issued for
957 specific problematic instantiations. The first parameter is a boolean
958 expression. The pragma is effective only if the value of this expression
959 is known at compile time, and has the value True. The set of expressions
960 whose values are known at compile time includes all static boolean
961 expressions, and also other values which the compiler can determine
962 at compile time (e.g. the size of a record type set by an explicit
963 size representation clause, or the value of a variable which was
964 initialized to a constant and is known not to have been modified).
965 If these conditions are met, a warning message is generated using
966 the value given as the second argument. This string value may contain
967 embedded ASCII.LF characters to break the message into multiple lines.
968
969 @node Pragma Complex_Representation
970 @unnumberedsec Pragma Complex_Representation
971 @findex Complex_Representation
972 @noindent
973 Syntax:
974
975 @smallexample @c ada
976 pragma Complex_Representation
977         ([Entity =>] LOCAL_NAME);
978 @end smallexample
979
980 @noindent
981 The @var{Entity} argument must be the name of a record type which has
982 two fields of the same floating-point type.  The effect of this pragma is
983 to force gcc to use the special internal complex representation form for
984 this record, which may be more efficient.  Note that this may result in
985 the code for this type not conforming to standard ABI (application
986 binary interface) requirements for the handling of record types.  For
987 example, in some environments, there is a requirement for passing
988 records by pointer, and the use of this pragma may result in passing
989 this type in floating-point registers.
990
991 @node Pragma Component_Alignment
992 @unnumberedsec Pragma Component_Alignment
993 @cindex Alignments of components
994 @findex Component_Alignment
995 @noindent
996 Syntax:
997
998 @smallexample @c ada
999 pragma Component_Alignment (
1000      [Form =>] ALIGNMENT_CHOICE
1001   [, [Name =>] type_LOCAL_NAME]);
1002
1003 ALIGNMENT_CHOICE ::=
1004   Component_Size
1005 | Component_Size_4
1006 | Storage_Unit
1007 | Default
1008 @end smallexample
1009
1010 @noindent
1011 Specifies the alignment of components in array or record types.
1012 The meaning of the @var{Form} argument is as follows:
1013
1014 @table @code
1015 @findex Component_Size
1016 @item Component_Size
1017 Aligns scalar components and subcomponents of the array or record type
1018 on boundaries appropriate to their inherent size (naturally
1019 aligned).  For example, 1-byte components are aligned on byte boundaries,
1020 2-byte integer components are aligned on 2-byte boundaries, 4-byte
1021 integer components are aligned on 4-byte boundaries and so on.  These
1022 alignment rules correspond to the normal rules for C compilers on all
1023 machines except the VAX@.
1024
1025 @findex Component_Size_4
1026 @item Component_Size_4
1027 Naturally aligns components with a size of four or fewer
1028 bytes.  Components that are larger than 4 bytes are placed on the next
1029 4-byte boundary.
1030
1031 @findex Storage_Unit
1032 @item Storage_Unit
1033 Specifies that array or record components are byte aligned, i.e.@:
1034 aligned on boundaries determined by the value of the constant
1035 @code{System.Storage_Unit}.
1036
1037 @cindex OpenVMS
1038 @item Default
1039 Specifies that array or record components are aligned on default
1040 boundaries, appropriate to the underlying hardware or operating system or
1041 both.  For OpenVMS VAX systems, the @code{Default} choice is the same as
1042 the @code{Storage_Unit} choice (byte alignment).  For all other systems,
1043 the @code{Default} choice is the same as @code{Component_Size} (natural
1044 alignment).
1045 @end table
1046
1047 @noindent
1048 If the @code{Name} parameter is present, @var{type_local_name} must
1049 refer to a local record or array type, and the specified alignment
1050 choice applies to the specified type.  The use of
1051 @code{Component_Alignment} together with a pragma @code{Pack} causes the
1052 @code{Component_Alignment} pragma to be ignored.  The use of
1053 @code{Component_Alignment} together with a record representation clause
1054 is only effective for fields not specified by the representation clause.
1055
1056 If the @code{Name} parameter is absent, the pragma can be used as either
1057 a configuration pragma, in which case it applies to one or more units in
1058 accordance with the normal rules for configuration pragmas, or it can be
1059 used within a declarative part, in which case it applies to types that
1060 are declared within this declarative part, or within any nested scope
1061 within this declarative part.  In either case it specifies the alignment
1062 to be applied to any record or array type which has otherwise standard
1063 representation.
1064
1065 If the alignment for a record or array type is not specified (using
1066 pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
1067 clause), the GNAT uses the default alignment as described previously.
1068
1069 @node Pragma Convention_Identifier
1070 @unnumberedsec Pragma Convention_Identifier
1071 @findex Convention_Identifier
1072 @cindex Conventions, synonyms
1073 @noindent
1074 Syntax:
1075
1076 @smallexample @c ada
1077 pragma Convention_Identifier (
1078          [Name =>]       IDENTIFIER,
1079          [Convention =>] convention_IDENTIFIER);
1080 @end smallexample
1081
1082 @noindent
1083 This pragma provides a mechanism for supplying synonyms for existing
1084 convention identifiers. The @code{Name} identifier can subsequently
1085 be used as a synonym for the given convention in other pragmas (including
1086 for example pragma @code{Import} or another @code{Convention_Identifier}
1087 pragma). As an example of the use of this, suppose you had legacy code
1088 which used Fortran77 as the identifier for Fortran. Then the pragma:
1089
1090 @smallexample @c ada
1091 pragma Convention_Identifier (Fortran77, Fortran);
1092 @end smallexample
1093
1094 @noindent
1095 would allow the use of the convention identifier @code{Fortran77} in
1096 subsequent code, avoiding the need to modify the sources. As another
1097 example, you could use this to parametrize convention requirements
1098 according to systems. Suppose you needed to use @code{Stdcall} on
1099 windows systems, and @code{C} on some other system, then you could
1100 define a convention identifier @code{Library} and use a single
1101 @code{Convention_Identifier} pragma to specify which convention
1102 would be used system-wide.
1103
1104 @node Pragma CPP_Class
1105 @unnumberedsec Pragma CPP_Class
1106 @findex CPP_Class
1107 @cindex Interfacing with C++
1108 @noindent
1109 Syntax:
1110
1111 @smallexample @c ada
1112 pragma CPP_Class ([Entity =>] LOCAL_NAME);
1113 @end smallexample
1114
1115 @noindent
1116 The argument denotes an entity in the current declarative region
1117 that is declared as a tagged or untagged record type.  It indicates that
1118 the type corresponds to an externally declared C++ class type, and is to
1119 be laid out the same way that C++ would lay out the type.
1120
1121 If (and only if) the type is tagged, at least one component in the
1122 record must be of type @code{Interfaces.CPP.Vtable_Ptr}, corresponding
1123 to the C++ Vtable (or Vtables in the case of multiple inheritance) used
1124 for dispatching.
1125
1126 Types for which @code{CPP_Class} is specified do not have assignment or
1127 equality operators defined (such operations can be imported or declared
1128 as subprograms as required).  Initialization is allowed only by
1129 constructor functions (see pragma @code{CPP_Constructor}).
1130
1131 Pragma @code{CPP_Class} is intended primarily for automatic generation
1132 using an automatic binding generator tool.
1133 See @ref{Interfacing to C++} for related information.
1134
1135 @node Pragma CPP_Constructor
1136 @unnumberedsec Pragma CPP_Constructor
1137 @cindex Interfacing with C++
1138 @findex CPP_Constructor
1139 @noindent
1140 Syntax:
1141
1142 @smallexample @c ada
1143 pragma CPP_Constructor ([Entity =>] LOCAL_NAME);
1144 @end smallexample
1145
1146 @noindent
1147 This pragma identifies an imported function (imported in the usual way
1148 with pragma @code{Import}) as corresponding to a C++
1149 constructor.  The argument is a name that must have been
1150 previously mentioned in a pragma @code{Import}
1151 with @code{Convention} = @code{CPP}, and must be of one of the following
1152 forms:
1153
1154 @itemize @bullet
1155 @item
1156 @code{function @var{Fname} return @var{T}'Class}
1157
1158 @item
1159 @code{function @var{Fname} (@dots{}) return @var{T}'Class}
1160 @end itemize
1161
1162 @noindent
1163 where @var{T} is a tagged type to which the pragma @code{CPP_Class} applies.
1164
1165 The first form is the default constructor, used when an object of type
1166 @var{T} is created on the Ada side with no explicit constructor.  Other
1167 constructors (including the copy constructor, which is simply a special
1168 case of the second form in which the one and only argument is of type
1169 @var{T}), can only appear in two contexts:
1170
1171 @itemize @bullet
1172 @item
1173 On the right side of an initialization of an object of type @var{T}.
1174 @item
1175 In an extension aggregate for an object of a type derived from @var{T}.
1176 @end itemize
1177
1178 @noindent
1179 Although the constructor is described as a function that returns a value
1180 on the Ada side, it is typically a procedure with an extra implicit
1181 argument (the object being initialized) at the implementation
1182 level.  GNAT issues the appropriate call, whatever it is, to get the
1183 object properly initialized.
1184
1185 In the case of derived objects, you may use one of two possible forms
1186 for declaring and creating an object:
1187
1188 @itemize @bullet
1189 @item @code{New_Object : Derived_T}
1190 @item @code{New_Object : Derived_T := (@var{constructor-call with} @dots{})}
1191 @end itemize
1192
1193 @noindent
1194 In the first case the default constructor is called and extension fields
1195 if any are initialized according to the default initialization
1196 expressions in the Ada declaration.  In the second case, the given
1197 constructor is called and the extension aggregate indicates the explicit
1198 values of the extension fields.
1199
1200 If no constructors are imported, it is impossible to create any objects
1201 on the Ada side.  If no default constructor is imported, only the
1202 initialization forms using an explicit call to a constructor are
1203 permitted.
1204
1205 Pragma @code{CPP_Constructor} is intended primarily for automatic generation
1206 using an automatic binding generator tool.
1207 See @ref{Interfacing to C++} for more related information.
1208
1209 @node Pragma CPP_Virtual
1210 @unnumberedsec Pragma CPP_Virtual
1211 @cindex Interfacing to C++
1212 @findex CPP_Virtual
1213 @noindent
1214 Syntax:
1215
1216 @smallexample @c ada
1217 pragma CPP_Virtual
1218      [Entity     =>] ENTITY,
1219   [, [Vtable_Ptr =>] vtable_ENTITY,]
1220   [, [Position   =>] static_integer_EXPRESSION]);
1221 @end smallexample
1222
1223 @noindent
1224 This pragma serves the same function as pragma @code{Import} in that
1225 case of a virtual function imported from C++.  The @var{Entity} argument
1226 must be a
1227 primitive subprogram of a tagged type to which pragma @code{CPP_Class}
1228 applies.  The @var{Vtable_Ptr} argument specifies
1229 the Vtable_Ptr component which contains the
1230 entry for this virtual function.  The @var{Position} argument
1231 is the sequential number
1232 counting virtual functions for this Vtable starting at 1.
1233
1234 The @code{Vtable_Ptr} and @code{Position} arguments may be omitted if
1235 there is one Vtable_Ptr present (single inheritance case) and all
1236 virtual functions are imported.  In that case the compiler can deduce both
1237 these values.
1238
1239 No @code{External_Name} or @code{Link_Name} arguments are required for a
1240 virtual function, since it is always accessed indirectly via the
1241 appropriate Vtable entry.
1242
1243 Pragma @code{CPP_Virtual} is intended primarily for automatic generation
1244 using an automatic binding generator tool.
1245 See @ref{Interfacing to C++} for related information.
1246
1247 @node Pragma CPP_Vtable
1248 @unnumberedsec Pragma CPP_Vtable
1249 @cindex Interfacing with C++
1250 @findex CPP_Vtable
1251 @noindent
1252 Syntax:
1253
1254 @smallexample @c ada
1255 pragma CPP_Vtable (
1256   [Entity      =>] ENTITY,
1257   [Vtable_Ptr  =>] vtable_ENTITY,
1258   [Entry_Count =>] static_integer_EXPRESSION);
1259 @end smallexample
1260
1261 @noindent
1262 Given a record to which the pragma @code{CPP_Class} applies,
1263 this pragma can be specified for each component of type
1264 @code{CPP.Interfaces.Vtable_Ptr}.
1265 @var{Entity} is the tagged type, @var{Vtable_Ptr}
1266 is the record field of type @code{Vtable_Ptr}, and @var{Entry_Count} is
1267 the number of virtual functions on the C++ side.  Not all of these
1268 functions need to be imported on the Ada side.
1269
1270 You may omit the @code{CPP_Vtable} pragma if there is only one
1271 @code{Vtable_Ptr} component in the record and all virtual functions are
1272 imported on the Ada side (the default value for the entry count in this
1273 case is simply the total number of virtual functions).
1274
1275 Pragma @code{CPP_Vtable} is intended primarily for automatic generation
1276 using an automatic binding generator tool.
1277 See @ref{Interfacing to C++} for related information.
1278
1279 @node Pragma Debug
1280 @unnumberedsec Pragma Debug
1281 @findex Debug
1282 @noindent
1283 Syntax:
1284
1285 @smallexample @c ada
1286 pragma Debug (PROCEDURE_CALL_WITHOUT_SEMICOLON);
1287
1288 PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
1289   PROCEDURE_NAME
1290 | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
1291 @end smallexample
1292
1293 @noindent
1294 The argument has the syntactic form of an expression, meeting the
1295 syntactic requirements for pragmas.
1296
1297 If assertions are not enabled on the command line, this pragma has no
1298 effect.  If asserts are enabled, the semantics of the pragma is exactly
1299 equivalent to the procedure call statement corresponding to the argument
1300 with a terminating semicolon.  Pragmas are permitted in sequences of
1301 declarations, so you can use pragma @code{Debug} to intersperse calls to
1302 debug procedures in the middle of declarations.
1303
1304 @node Pragma Elaboration_Checks
1305 @unnumberedsec Pragma Elaboration_Checks
1306 @cindex Elaboration control
1307 @findex Elaboration_Checks
1308 @noindent
1309 Syntax:
1310
1311 @smallexample @c ada
1312 pragma Elaboration_Checks (Dynamic | Static);
1313 @end smallexample
1314
1315 @noindent
1316 This is a configuration pragma that provides control over the
1317 elaboration model used by the compilation affected by the
1318 pragma.  If the parameter is @code{Dynamic},
1319 then the dynamic elaboration
1320 model described in the Ada Reference Manual is used, as though
1321 the @code{-gnatE} switch had been specified on the command
1322 line.  If the parameter is @code{Static}, then the default GNAT static
1323 model is used.  This configuration pragma overrides the setting
1324 of the command line.  For full details on the elaboration models
1325 used by the GNAT compiler, see section ``Elaboration Order
1326 Handling in GNAT'' in the @cite{GNAT User's Guide}.
1327
1328 @node Pragma Eliminate
1329 @unnumberedsec Pragma Eliminate
1330 @cindex Elimination of unused subprograms
1331 @findex Eliminate
1332 @noindent
1333 Syntax:
1334
1335 @smallexample @c ada
1336 pragma Eliminate (
1337     [Unit_Name =>] IDENTIFIER |
1338                    SELECTED_COMPONENT);
1339
1340 pragma Eliminate (
1341     [Unit_Name       =>]  IDENTIFIER |
1342                           SELECTED_COMPONENT,
1343     [Entity          =>]  IDENTIFIER |
1344                           SELECTED_COMPONENT |
1345                           STRING_LITERAL
1346     [,OVERLOADING_RESOLUTION]);
1347
1348 OVERLOADING_RESOLUTION ::= PARAMETER_AND_RESULT_TYPE_PROFILE |
1349                            SOURCE_LOCATION
1350
1351 PARAMETER_AND_RESULT_TYPE_PROFILE ::= PROCEDURE_PROFILE |
1352                                       FUNCTION_PROFILE
1353
1354 PROCEDURE_PROFILE ::= Parameter_Types => PARAMETER_TYPES
1355
1356 FUNCTION_PROFILE ::= [Parameter_Types => PARAMETER_TYPES,]
1357                       Result_Type => result_SUBTYPE_NAME]
1358
1359 PARAMETER_TYPES ::= (SUBTYPE_NAME @{, SUBTYPE_NAME@})
1360 SUBTYPE_NAME    ::= STRING_VALUE
1361
1362 SOURCE_LOCATION ::= Source_Location => SOURCE_TRACE
1363 SOURCE_TRACE    ::= STRING_VALUE
1364
1365 STRING_VALUE ::= STRING_LITERAL @{& STRING_LITERAL@}
1366 @end smallexample
1367
1368 @noindent
1369 This pragma indicates that the given entity is not used outside the
1370 compilation unit it is defined in. The entity must be an explicitly declared
1371 subprogram; this includes  generic subprogram instances and
1372 subprograms declared in generic package instances.
1373
1374 If the entity to be eliminated is a library level subprogram, then
1375 the first form of pragma @code{Eliminate} is used with only a single argument.
1376 In this form, the @code{Unit_Name} argument specifies the name of the
1377 library  level unit to be eliminated.
1378
1379 In all other cases, both @code{Unit_Name} and @code{Entity} arguments
1380 are required. If item is an entity of a library package, then the first
1381 argument specifies the unit name, and the second argument specifies
1382 the particular entity.  If the second argument is in string form, it must
1383 correspond to the internal manner in which GNAT stores entity names (see
1384 compilation unit Namet in the compiler sources for details).
1385
1386 The remaining parameters (OVERLOADING_RESOLUTION) are optionally used
1387 to distinguish between overloaded subprograms. If a pragma does not contain
1388 the OVERLOADING_RESOLUTION parameter(s), it is applied to all the overloaded
1389 subprograms denoted by the first two parameters.
1390
1391 Use PARAMETER_AND_RESULT_TYPE_PROFILE to specify the profile of the subprogram
1392 to be eliminated in a manner similar to that used for the extended
1393 @code{Import} and @code{Export} pragmas, except that the subtype names are
1394 always given as strings. At the moment, this form of distinguishing
1395 overloaded subprograms is implemented only partially, so we do not recommend
1396 using it for practical subprogram elimination.
1397
1398 Note, that in case of a parameterless procedure its profile is represented
1399 as @code{Parameter_Types => ("")}
1400
1401 Alternatively, the @code{Source_Location} parameter is used to specify
1402 which overloaded alternative is to be eliminated by pointing to the
1403 location of the DEFINING_PROGRAM_UNIT_NAME of this subprogram in the
1404 source text. The string literal (or concatenation of string literals)
1405 given as SOURCE_TRACE must have the following format:
1406
1407 @smallexample @c ada
1408 SOURCE_TRACE ::= SOURCE_LOCATION@{LBRACKET SOURCE_LOCATION RBRACKET@}
1409
1410 LBRACKET ::= [
1411 RBRACKET ::= ]
1412
1413 SOURCE_LOCATION ::= FILE_NAME:LINE_NUMBER
1414 FILE_NAME       ::= STRING_LITERAL
1415 LINE_NUMBER     ::= DIGIT @{DIGIT@}
1416 @end smallexample
1417
1418 SOURCE_TRACE should be the short name of the source file (with no directory
1419 information), and LINE_NUMBER is supposed to point to the line where the
1420 defining name of the subprogram is located.
1421
1422 For the subprograms that are not a part of generic instantiations, only one
1423 SOURCE_LOCATION is used. If a subprogram is declared in a package
1424 instantiation, SOURCE_TRACE contains two SOURCE_LOCATIONs, the first one is
1425 the location of the (DEFINING_PROGRAM_UNIT_NAME of the) instantiation, and the
1426 second one denotes the declaration of the corresponding subprogram in the
1427 generic package. This approach is recursively used to create SOURCE_LOCATIONs
1428 in case of nested instantiations.
1429
1430 The effect of the pragma is to allow the compiler to eliminate
1431 the code or data associated with the named entity.  Any reference to
1432 an eliminated entity outside the compilation unit it is defined in,
1433 causes a compile time or link time error.
1434
1435 The intention of pragma @code{Eliminate} is to allow a program to be compiled
1436 in a system independent manner, with unused entities eliminated, without
1437 the requirement of modifying the source text.  Normally the required set
1438 of @code{Eliminate} pragmas is constructed automatically using the gnatelim
1439 tool. Elimination of unused entities local to a compilation unit is
1440 automatic, without requiring the use of pragma @code{Eliminate}.
1441
1442 Note that the reason this pragma takes string literals where names might
1443 be expected is that a pragma @code{Eliminate} can appear in a context where the
1444 relevant names are not visible.
1445
1446 Note that any change in the source files that includes removing, splitting of
1447 adding lines may make the set of Eliminate pragmas using SOURCE_LOCATION
1448 parameter illegal.
1449
1450 @node Pragma Export_Exception
1451 @unnumberedsec Pragma Export_Exception
1452 @cindex OpenVMS
1453 @findex Export_Exception
1454 @noindent
1455 Syntax:
1456
1457 @smallexample @c ada
1458 pragma Export_Exception (
1459      [Internal =>] LOCAL_NAME,
1460   [, [External =>] EXTERNAL_SYMBOL,]
1461   [, [Form     =>] Ada | VMS]
1462   [, [Code     =>] static_integer_EXPRESSION]);
1463
1464 EXTERNAL_SYMBOL ::=
1465   IDENTIFIER
1466 | static_string_EXPRESSION
1467 @end smallexample
1468
1469 @noindent
1470 This pragma is implemented only in the OpenVMS implementation of GNAT@.  It
1471 causes the specified exception to be propagated outside of the Ada program,
1472 so that it can be handled by programs written in other OpenVMS languages.
1473 This pragma establishes an external name for an Ada exception and makes the
1474 name available to the OpenVMS Linker as a global symbol.  For further details
1475 on this pragma, see the
1476 DEC Ada Language Reference Manual, section 13.9a3.2.
1477
1478 @node Pragma Export_Function
1479 @unnumberedsec Pragma Export_Function
1480 @cindex Argument passing mechanisms
1481 @findex Export_Function
1482
1483 @noindent
1484 Syntax:
1485
1486 @smallexample @c ada
1487 pragma Export_Function (
1488      [Internal         =>] LOCAL_NAME,
1489   [, [External         =>] EXTERNAL_SYMBOL]
1490   [, [Parameter_Types  =>] PARAMETER_TYPES]
1491   [, [Result_Type      =>] result_SUBTYPE_MARK]
1492   [, [Mechanism        =>] MECHANISM]
1493   [, [Result_Mechanism =>] MECHANISM_NAME]);
1494
1495 EXTERNAL_SYMBOL ::=
1496   IDENTIFIER
1497 | static_string_EXPRESSION
1498 | ""
1499
1500 PARAMETER_TYPES ::=
1501   null
1502 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1503
1504 TYPE_DESIGNATOR ::=
1505   subtype_NAME
1506 | subtype_Name ' Access
1507
1508 MECHANISM ::=
1509   MECHANISM_NAME
1510 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1511
1512 MECHANISM_ASSOCIATION ::=
1513   [formal_parameter_NAME =>] MECHANISM_NAME
1514
1515 MECHANISM_NAME ::=
1516   Value
1517 | Reference
1518 @end smallexample
1519
1520 @noindent
1521 Use this pragma to make a function externally callable and optionally
1522 provide information on mechanisms to be used for passing parameter and
1523 result values.  We recommend, for the purposes of improving portability,
1524 this pragma always be used in conjunction with a separate pragma
1525 @code{Export}, which must precede the pragma @code{Export_Function}.
1526 GNAT does not require a separate pragma @code{Export}, but if none is
1527 present, @code{Convention Ada} is assumed, which is usually
1528 not what is wanted, so it is usually appropriate to use this
1529 pragma in conjunction with a @code{Export} or @code{Convention}
1530 pragma that specifies the desired foreign convention.
1531 Pragma @code{Export_Function}
1532 (and @code{Export}, if present) must appear in the same declarative
1533 region as the function to which they apply.
1534
1535 @var{internal_name} must uniquely designate the function to which the
1536 pragma applies.  If more than one function name exists of this name in
1537 the declarative part you must use the @code{Parameter_Types} and
1538 @code{Result_Type} parameters is mandatory to achieve the required
1539 unique designation.  @var{subtype_ mark}s in these parameters must
1540 exactly match the subtypes in the corresponding function specification,
1541 using positional notation to match parameters with subtype marks.
1542 The form with an @code{'Access} attribute can be used to match an
1543 anonymous access parameter.
1544
1545 @cindex OpenVMS
1546 @cindex Passing by descriptor
1547 Note that passing by descriptor is not supported, even on the OpenVMS
1548 ports of GNAT@.
1549
1550 @cindex Suppressing external name
1551 Special treatment is given if the EXTERNAL is an explicit null
1552 string or a static string expressions that evaluates to the null
1553 string. In this case, no external name is generated. This form
1554 still allows the specification of parameter mechanisms.
1555
1556 @node Pragma Export_Object
1557 @unnumberedsec Pragma Export_Object
1558 @findex Export_Object
1559 @noindent
1560 Syntax:
1561
1562 @smallexample @c ada
1563 pragma Export_Object
1564       [Internal =>] LOCAL_NAME,
1565    [, [External =>] EXTERNAL_SYMBOL]
1566    [, [Size     =>] EXTERNAL_SYMBOL]
1567
1568 EXTERNAL_SYMBOL ::=
1569   IDENTIFIER
1570 | static_string_EXPRESSION
1571 @end smallexample
1572
1573 @noindent
1574 This pragma designates an object as exported, and apart from the
1575 extended rules for external symbols, is identical in effect to the use of
1576 the normal @code{Export} pragma applied to an object.  You may use a
1577 separate Export pragma (and you probably should from the point of view
1578 of portability), but it is not required.  @var{Size} is syntax checked,
1579 but otherwise ignored by GNAT@.
1580
1581 @node Pragma Export_Procedure
1582 @unnumberedsec Pragma Export_Procedure
1583 @findex Export_Procedure
1584 @noindent
1585 Syntax:
1586
1587 @smallexample @c ada
1588 pragma Export_Procedure (
1589      [Internal        =>] LOCAL_NAME
1590   [, [External        =>] EXTERNAL_SYMBOL]
1591   [, [Parameter_Types =>] PARAMETER_TYPES]
1592   [, [Mechanism       =>] MECHANISM]);
1593
1594 EXTERNAL_SYMBOL ::=
1595   IDENTIFIER
1596 | static_string_EXPRESSION
1597 | ""
1598
1599 PARAMETER_TYPES ::=
1600   null
1601 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1602
1603 TYPE_DESIGNATOR ::=
1604   subtype_NAME
1605 | subtype_Name ' Access
1606
1607 MECHANISM ::=
1608   MECHANISM_NAME
1609 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1610
1611 MECHANISM_ASSOCIATION ::=
1612   [formal_parameter_NAME =>] MECHANISM_NAME
1613
1614 MECHANISM_NAME ::=
1615   Value
1616 | Reference
1617 @end smallexample
1618
1619 @noindent
1620 This pragma is identical to @code{Export_Function} except that it
1621 applies to a procedure rather than a function and the parameters
1622 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
1623 GNAT does not require a separate pragma @code{Export}, but if none is
1624 present, @code{Convention Ada} is assumed, which is usually
1625 not what is wanted, so it is usually appropriate to use this
1626 pragma in conjunction with a @code{Export} or @code{Convention}
1627 pragma that specifies the desired foreign convention.
1628
1629 @cindex OpenVMS
1630 @cindex Passing by descriptor
1631 Note that passing by descriptor is not supported, even on the OpenVMS
1632 ports of GNAT@.
1633
1634 @cindex Suppressing external name
1635 Special treatment is given if the EXTERNAL is an explicit null
1636 string or a static string expressions that evaluates to the null
1637 string. In this case, no external name is generated. This form
1638 still allows the specification of parameter mechanisms.
1639
1640 @node Pragma Export_Value
1641 @unnumberedsec Pragma Export_Value
1642 @findex Export_Value
1643 @noindent
1644 Syntax:
1645
1646 @smallexample @c ada
1647 pragma Export_Value (
1648   [Value     =>] static_integer_EXPRESSION,
1649   [Link_Name =>] static_string_EXPRESSION);
1650 @end smallexample
1651
1652 @noindent
1653 This pragma serves to export a static integer value for external use.
1654 The first argument specifies the value to be exported. The Link_Name
1655 argument specifies the symbolic name to be associated with the integer
1656 value. This pragma is useful for defining a named static value in Ada
1657 that can be referenced in assembly language units to be linked with
1658 the application. This pragma is currently supported only for the
1659 AAMP target and is ignored for other targets.
1660
1661 @node Pragma Export_Valued_Procedure
1662 @unnumberedsec Pragma Export_Valued_Procedure
1663 @findex Export_Valued_Procedure
1664 @noindent
1665 Syntax:
1666
1667 @smallexample @c ada
1668 pragma Export_Valued_Procedure (
1669      [Internal        =>] LOCAL_NAME
1670   [, [External        =>] EXTERNAL_SYMBOL]
1671   [, [Parameter_Types =>] PARAMETER_TYPES]
1672   [, [Mechanism       =>] MECHANISM]);
1673
1674 EXTERNAL_SYMBOL ::=
1675   IDENTIFIER
1676 | static_string_EXPRESSION
1677 | ""
1678
1679 PARAMETER_TYPES ::=
1680   null
1681 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1682
1683 TYPE_DESIGNATOR ::=
1684   subtype_NAME
1685 | subtype_Name ' Access
1686
1687 MECHANISM ::=
1688   MECHANISM_NAME
1689 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1690
1691 MECHANISM_ASSOCIATION ::=
1692   [formal_parameter_NAME =>] MECHANISM_NAME
1693
1694 MECHANISM_NAME ::=
1695   Value
1696 | Reference
1697 @end smallexample
1698
1699 @noindent
1700 This pragma is identical to @code{Export_Procedure} except that the
1701 first parameter of @var{local_name}, which must be present, must be of
1702 mode @code{OUT}, and externally the subprogram is treated as a function
1703 with this parameter as the result of the function.  GNAT provides for
1704 this capability to allow the use of @code{OUT} and @code{IN OUT}
1705 parameters in interfacing to external functions (which are not permitted
1706 in Ada functions).
1707 GNAT does not require a separate pragma @code{Export}, but if none is
1708 present, @code{Convention Ada} is assumed, which is almost certainly
1709 not what is wanted since the whole point of this pragma is to interface
1710 with foreign language functions, so it is usually appropriate to use this
1711 pragma in conjunction with a @code{Export} or @code{Convention}
1712 pragma that specifies the desired foreign convention.
1713
1714 @cindex OpenVMS
1715 @cindex Passing by descriptor
1716 Note that passing by descriptor is not supported, even on the OpenVMS
1717 ports of GNAT@.
1718
1719 @cindex Suppressing external name
1720 Special treatment is given if the EXTERNAL is an explicit null
1721 string or a static string expressions that evaluates to the null
1722 string. In this case, no external name is generated. This form
1723 still allows the specification of parameter mechanisms.
1724
1725 @node Pragma Extend_System
1726 @unnumberedsec Pragma Extend_System
1727 @cindex @code{system}, extending
1728 @cindex Dec Ada 83
1729 @findex Extend_System
1730 @noindent
1731 Syntax:
1732
1733 @smallexample @c ada
1734 pragma Extend_System ([Name =>] IDENTIFIER);
1735 @end smallexample
1736
1737 @noindent
1738 This pragma is used to provide backwards compatibility with other
1739 implementations that extend the facilities of package @code{System}.  In
1740 GNAT, @code{System} contains only the definitions that are present in
1741 the Ada 95 RM@.  However, other implementations, notably the DEC Ada 83
1742 implementation, provide many extensions to package @code{System}.
1743
1744 For each such implementation accommodated by this pragma, GNAT provides a
1745 package @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83
1746 implementation, which provides the required additional definitions.  You
1747 can use this package in two ways.  You can @code{with} it in the normal
1748 way and access entities either by selection or using a @code{use}
1749 clause.  In this case no special processing is required.
1750
1751 However, if existing code contains references such as
1752 @code{System.@var{xxx}} where @var{xxx} is an entity in the extended
1753 definitions provided in package @code{System}, you may use this pragma
1754 to extend visibility in @code{System} in a non-standard way that
1755 provides greater compatibility with the existing code.  Pragma
1756 @code{Extend_System} is a configuration pragma whose single argument is
1757 the name of the package containing the extended definition
1758 (e.g.@: @code{Aux_DEC} for the DEC Ada case).  A unit compiled under
1759 control of this pragma will be processed using special visibility
1760 processing that looks in package @code{System.Aux_@var{xxx}} where
1761 @code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
1762 package @code{System}, but not found in package @code{System}.
1763
1764 You can use this pragma either to access a predefined @code{System}
1765 extension supplied with the compiler, for example @code{Aux_DEC} or
1766 you can construct your own extension unit following the above
1767 definition.  Note that such a package is a child of @code{System}
1768 and thus is considered part of the implementation.  To compile
1769 it you will have to use the appropriate switch for compiling
1770 system units.  See the GNAT User's Guide for details.
1771
1772 @node Pragma External
1773 @unnumberedsec Pragma External
1774 @findex External
1775 @noindent
1776 Syntax:
1777
1778 @smallexample @c ada
1779 pragma External (
1780   [   Convention    =>] convention_IDENTIFIER,
1781   [   Entity        =>] local_NAME
1782   [, [External_Name =>] static_string_EXPRESSION ]
1783   [, [Link_Name     =>] static_string_EXPRESSION ]);
1784 @end smallexample
1785
1786 @noindent
1787 This pragma is identical in syntax and semantics to pragma
1788 @code{Export} as defined in the Ada Reference Manual.  It is
1789 provided for compatibility with some Ada 83 compilers that
1790 used this pragma for exactly the same purposes as pragma
1791 @code{Export} before the latter was standardized.
1792
1793 @node Pragma External_Name_Casing
1794 @unnumberedsec Pragma External_Name_Casing
1795 @cindex Dec Ada 83 casing compatibility
1796 @cindex External Names, casing
1797 @cindex Casing of External names
1798 @findex External_Name_Casing
1799 @noindent
1800 Syntax:
1801
1802 @smallexample @c ada
1803 pragma External_Name_Casing (
1804   Uppercase | Lowercase
1805   [, Uppercase | Lowercase | As_Is]);
1806 @end smallexample
1807
1808 @noindent
1809 This pragma provides control over the casing of external names associated
1810 with Import and Export pragmas.  There are two cases to consider:
1811
1812 @table @asis
1813 @item Implicit external names
1814 Implicit external names are derived from identifiers.  The most common case
1815 arises when a standard Ada 95 Import or Export pragma is used with only two
1816 arguments, as in:
1817
1818 @smallexample @c ada
1819    pragma Import (C, C_Routine);
1820 @end smallexample
1821
1822 @noindent
1823 Since Ada is a case insensitive language, the spelling of the identifier in
1824 the Ada source program does not provide any information on the desired
1825 casing of the external name, and so a convention is needed.  In GNAT the
1826 default treatment is that such names are converted to all lower case
1827 letters.  This corresponds to the normal C style in many environments.
1828 The first argument of pragma @code{External_Name_Casing} can be used to
1829 control this treatment.  If @code{Uppercase} is specified, then the name
1830 will be forced to all uppercase letters.  If @code{Lowercase} is specified,
1831 then the normal default of all lower case letters will be used.
1832
1833 This same implicit treatment is also used in the case of extended DEC Ada 83
1834 compatible Import and Export pragmas where an external name is explicitly
1835 specified using an identifier rather than a string.
1836
1837 @item Explicit external names
1838 Explicit external names are given as string literals.  The most common case
1839 arises when a standard Ada 95 Import or Export pragma is used with three
1840 arguments, as in:
1841
1842 @smallexample @c ada
1843 pragma Import (C, C_Routine, "C_routine");
1844 @end smallexample
1845
1846 @noindent
1847 In this case, the string literal normally provides the exact casing required
1848 for the external name.  The second argument of pragma
1849 @code{External_Name_Casing} may be used to modify this behavior.
1850 If @code{Uppercase} is specified, then the name
1851 will be forced to all uppercase letters.  If @code{Lowercase} is specified,
1852 then the name will be forced to all lowercase letters.  A specification of
1853 @code{As_Is} provides the normal default behavior in which the casing is
1854 taken from the string provided.
1855 @end table
1856
1857 @noindent
1858 This pragma may appear anywhere that a pragma is valid.  In particular, it
1859 can be used as a configuration pragma in the @file{gnat.adc} file, in which
1860 case it applies to all subsequent compilations, or it can be used as a program
1861 unit pragma, in which case it only applies to the current unit, or it can
1862 be used more locally to control individual Import/Export pragmas.
1863
1864 It is primarily intended for use with OpenVMS systems, where many
1865 compilers convert all symbols to upper case by default.  For interfacing to
1866 such compilers (e.g.@: the DEC C compiler), it may be convenient to use
1867 the pragma:
1868
1869 @smallexample @c ada
1870 pragma External_Name_Casing (Uppercase, Uppercase);
1871 @end smallexample
1872
1873 @noindent
1874 to enforce the upper casing of all external symbols.
1875
1876 @node Pragma Finalize_Storage_Only
1877 @unnumberedsec Pragma Finalize_Storage_Only
1878 @findex Finalize_Storage_Only
1879 @noindent
1880 Syntax:
1881
1882 @smallexample @c ada
1883 pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
1884 @end smallexample
1885
1886 @noindent
1887 This pragma allows the compiler not to emit a Finalize call for objects
1888 defined at the library level.  This is mostly useful for types where
1889 finalization is only used to deal with storage reclamation since in most
1890 environments it is not necessary to reclaim memory just before terminating
1891 execution, hence the name.
1892
1893 @node Pragma Float_Representation
1894 @unnumberedsec Pragma Float_Representation
1895 @cindex OpenVMS
1896 @findex Float_Representation
1897 @noindent
1898 Syntax:
1899
1900 @smallexample @c ada
1901 pragma Float_Representation (FLOAT_REP);
1902
1903 FLOAT_REP ::= VAX_Float | IEEE_Float
1904 @end smallexample
1905
1906 @noindent
1907 This pragma
1908 allows control over the internal representation chosen for the predefined
1909 floating point types declared in the packages @code{Standard} and
1910 @code{System}. On all systems other than OpenVMS, the argument must
1911 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
1912 argument may be @code{VAX_Float} to specify the use of the VAX float
1913 format for the floating-point types in Standard. This requires that
1914 the standard runtime libraries be recompiled. See the
1915 description of the @code{GNAT LIBRARY} command in the OpenVMS version
1916 of the GNAT Users Guide for details on the use of this command.
1917
1918 @node Pragma Ident
1919 @unnumberedsec Pragma Ident
1920 @findex Ident
1921 @noindent
1922 Syntax:
1923
1924 @smallexample @c ada
1925 pragma Ident (static_string_EXPRESSION);
1926 @end smallexample
1927
1928 @noindent
1929 This pragma provides a string identification in the generated object file,
1930 if the system supports the concept of this kind of identification string.
1931 This pragma is allowed only in the outermost declarative part or
1932 declarative items of a compilation unit. If more than one @code{Ident}
1933 pragma is given, only the last one processed is effective.
1934 @cindex OpenVMS
1935 On OpenVMS systems, the effect of the pragma is identical to the effect of
1936 the DEC Ada 83 pragma of the same name. Note that in DEC Ada 83, the
1937 maximum allowed length is 31 characters, so if it is important to
1938 maintain compatibility with this compiler, you should obey this length
1939 limit.
1940
1941 @node Pragma Import_Exception
1942 @unnumberedsec Pragma Import_Exception
1943 @cindex OpenVMS
1944 @findex Import_Exception
1945 @noindent
1946 Syntax:
1947
1948 @smallexample @c ada
1949 pragma Import_Exception (
1950      [Internal =>] LOCAL_NAME,
1951   [, [External =>] EXTERNAL_SYMBOL,]
1952   [, [Form     =>] Ada | VMS]
1953   [, [Code     =>] static_integer_EXPRESSION]);
1954
1955 EXTERNAL_SYMBOL ::=
1956   IDENTIFIER
1957 | static_string_EXPRESSION
1958 @end smallexample
1959
1960 @noindent
1961 This pragma is implemented only in the OpenVMS implementation of GNAT@.
1962 It allows OpenVMS conditions (for example, from OpenVMS system services or
1963 other OpenVMS languages) to be propagated to Ada programs as Ada exceptions.
1964 The pragma specifies that the exception associated with an exception
1965 declaration in an Ada program be defined externally (in non-Ada code).
1966 For further details on this pragma, see the
1967 DEC Ada Language Reference Manual, section 13.9a.3.1.
1968
1969 @node Pragma Import_Function
1970 @unnumberedsec Pragma Import_Function
1971 @findex Import_Function
1972 @noindent
1973 Syntax:
1974
1975 @smallexample @c ada
1976 pragma Import_Function (
1977      [Internal                 =>] LOCAL_NAME,
1978   [, [External                 =>] EXTERNAL_SYMBOL]
1979   [, [Parameter_Types          =>] PARAMETER_TYPES]
1980   [, [Result_Type              =>] SUBTYPE_MARK]
1981   [, [Mechanism                =>] MECHANISM]
1982   [, [Result_Mechanism         =>] MECHANISM_NAME]
1983   [, [First_Optional_Parameter =>] IDENTIFIER]);
1984
1985 EXTERNAL_SYMBOL ::=
1986   IDENTIFIER
1987 | static_string_EXPRESSION
1988
1989 PARAMETER_TYPES ::=
1990   null
1991 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1992
1993 TYPE_DESIGNATOR ::=
1994   subtype_NAME
1995 | subtype_Name ' Access
1996
1997 MECHANISM ::=
1998   MECHANISM_NAME
1999 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2000
2001 MECHANISM_ASSOCIATION ::=
2002   [formal_parameter_NAME =>] MECHANISM_NAME
2003
2004 MECHANISM_NAME ::=
2005   Value
2006 | Reference
2007 | Descriptor [([Class =>] CLASS_NAME)]
2008
2009 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2010 @end smallexample
2011
2012 @noindent
2013 This pragma is used in conjunction with a pragma @code{Import} to
2014 specify additional information for an imported function.  The pragma
2015 @code{Import} (or equivalent pragma @code{Interface}) must precede the
2016 @code{Import_Function} pragma and both must appear in the same
2017 declarative part as the function specification.
2018
2019 The @var{Internal} argument must uniquely designate
2020 the function to which the
2021 pragma applies.  If more than one function name exists of this name in
2022 the declarative part you must use the @code{Parameter_Types} and
2023 @var{Result_Type} parameters to achieve the required unique
2024 designation.  Subtype marks in these parameters must exactly match the
2025 subtypes in the corresponding function specification, using positional
2026 notation to match parameters with subtype marks.
2027 The form with an @code{'Access} attribute can be used to match an
2028 anonymous access parameter.
2029
2030 You may optionally use the @var{Mechanism} and @var{Result_Mechanism}
2031 parameters to specify passing mechanisms for the
2032 parameters and result.  If you specify a single mechanism name, it
2033 applies to all parameters.  Otherwise you may specify a mechanism on a
2034 parameter by parameter basis using either positional or named
2035 notation.  If the mechanism is not specified, the default mechanism
2036 is used.
2037
2038 @cindex OpenVMS
2039 @cindex Passing by descriptor
2040 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2041
2042 @code{First_Optional_Parameter} applies only to OpenVMS ports of GNAT@.
2043 It specifies that the designated parameter and all following parameters
2044 are optional, meaning that they are not passed at the generated code
2045 level (this is distinct from the notion of optional parameters in Ada
2046 where the parameters are passed anyway with the designated optional
2047 parameters).  All optional parameters must be of mode @code{IN} and have
2048 default parameter values that are either known at compile time
2049 expressions, or uses of the @code{'Null_Parameter} attribute.
2050
2051 @node Pragma Import_Object
2052 @unnumberedsec Pragma Import_Object
2053 @findex Import_Object
2054 @noindent
2055 Syntax:
2056
2057 @smallexample @c ada
2058 pragma Import_Object
2059      [Internal =>] LOCAL_NAME,
2060   [, [External =>] EXTERNAL_SYMBOL],
2061   [, [Size     =>] EXTERNAL_SYMBOL]);
2062
2063 EXTERNAL_SYMBOL ::=
2064   IDENTIFIER
2065 | static_string_EXPRESSION
2066 @end smallexample
2067
2068 @noindent
2069 This pragma designates an object as imported, and apart from the
2070 extended rules for external symbols, is identical in effect to the use of
2071 the normal @code{Import} pragma applied to an object.  Unlike the
2072 subprogram case, you need not use a separate @code{Import} pragma,
2073 although you may do so (and probably should do so from a portability
2074 point of view).  @var{size} is syntax checked, but otherwise ignored by
2075 GNAT@.
2076
2077 @node Pragma Import_Procedure
2078 @unnumberedsec Pragma Import_Procedure
2079 @findex Import_Procedure
2080 @noindent
2081 Syntax:
2082
2083 @smallexample @c ada
2084 pragma Import_Procedure (
2085      [Internal                 =>] LOCAL_NAME,
2086   [, [External                 =>] EXTERNAL_SYMBOL]
2087   [, [Parameter_Types          =>] PARAMETER_TYPES]
2088   [, [Mechanism                =>] MECHANISM]
2089   [, [First_Optional_Parameter =>] IDENTIFIER]);
2090
2091 EXTERNAL_SYMBOL ::=
2092   IDENTIFIER
2093 | static_string_EXPRESSION
2094
2095 PARAMETER_TYPES ::=
2096   null
2097 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2098
2099 TYPE_DESIGNATOR ::=
2100   subtype_NAME
2101 | subtype_Name ' Access
2102
2103 MECHANISM ::=
2104   MECHANISM_NAME
2105 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2106
2107 MECHANISM_ASSOCIATION ::=
2108   [formal_parameter_NAME =>] MECHANISM_NAME
2109
2110 MECHANISM_NAME ::=
2111   Value
2112 | Reference
2113 | Descriptor [([Class =>] CLASS_NAME)]
2114
2115 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2116 @end smallexample
2117
2118 @noindent
2119 This pragma is identical to @code{Import_Function} except that it
2120 applies to a procedure rather than a function and the parameters
2121 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2122
2123 @node Pragma Import_Valued_Procedure
2124 @unnumberedsec Pragma Import_Valued_Procedure
2125 @findex Import_Valued_Procedure
2126 @noindent
2127 Syntax:
2128
2129 @smallexample @c ada
2130 pragma Import_Valued_Procedure (
2131      [Internal                 =>] LOCAL_NAME,
2132   [, [External                 =>] EXTERNAL_SYMBOL]
2133   [, [Parameter_Types          =>] PARAMETER_TYPES]
2134   [, [Mechanism                =>] MECHANISM]
2135   [, [First_Optional_Parameter =>] IDENTIFIER]);
2136
2137 EXTERNAL_SYMBOL ::=
2138   IDENTIFIER
2139 | static_string_EXPRESSION
2140
2141 PARAMETER_TYPES ::=
2142   null
2143 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2144
2145 TYPE_DESIGNATOR ::=
2146   subtype_NAME
2147 | subtype_Name ' Access
2148
2149 MECHANISM ::=
2150   MECHANISM_NAME
2151 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2152
2153 MECHANISM_ASSOCIATION ::=
2154   [formal_parameter_NAME =>] MECHANISM_NAME
2155
2156 MECHANISM_NAME ::=
2157   Value
2158 | Reference
2159 | Descriptor [([Class =>] CLASS_NAME)]
2160
2161 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2162 @end smallexample
2163
2164 @noindent
2165 This pragma is identical to @code{Import_Procedure} except that the
2166 first parameter of @var{local_name}, which must be present, must be of
2167 mode @code{OUT}, and externally the subprogram is treated as a function
2168 with this parameter as the result of the function.  The purpose of this
2169 capability is to allow the use of @code{OUT} and @code{IN OUT}
2170 parameters in interfacing to external functions (which are not permitted
2171 in Ada functions).  You may optionally use the @code{Mechanism}
2172 parameters to specify passing mechanisms for the parameters.
2173 If you specify a single mechanism name, it applies to all parameters.
2174 Otherwise you may specify a mechanism on a parameter by parameter
2175 basis using either positional or named notation.  If the mechanism is not
2176 specified, the default mechanism is used.
2177
2178 Note that it is important to use this pragma in conjunction with a separate
2179 pragma Import that specifies the desired convention, since otherwise the
2180 default convention is Ada, which is almost certainly not what is required.
2181
2182 @node Pragma Initialize_Scalars
2183 @unnumberedsec Pragma Initialize_Scalars
2184 @findex Initialize_Scalars
2185 @cindex debugging with Initialize_Scalars
2186 @noindent
2187 Syntax:
2188
2189 @smallexample @c ada
2190 pragma Initialize_Scalars;
2191 @end smallexample
2192
2193 @noindent
2194 This pragma is similar to @code{Normalize_Scalars} conceptually but has
2195 two important differences.  First, there is no requirement for the pragma
2196 to be used uniformly in all units of a partition, in particular, it is fine
2197 to use this just for some or all of the application units of a partition,
2198 without needing to recompile the run-time library.
2199
2200 In the case where some units are compiled with the pragma, and some without,
2201 then a declaration of a variable where the type is defined in package
2202 Standard or is locally declared will always be subject to initialization,
2203 as will any declaration of a scalar variable.  For composite variables,
2204 whether the variable is initialized may also depend on whether the package
2205 in which the type of the variable is declared is compiled with the pragma.
2206
2207 The other important difference is that there is control over the value used
2208 for initializing scalar objects.  At bind time, you can select whether to
2209 initialize with invalid values (like Normalize_Scalars), or with high or
2210 low values, or with a specified bit pattern.  See the users guide for binder
2211 options for specifying these cases.
2212
2213 This means that you can compile a program, and then without having to
2214 recompile the program, you can run it with different values being used
2215 for initializing otherwise uninitialized values, to test if your program
2216 behavior depends on the choice.  Of course the behavior should not change,
2217 and if it does, then most likely you have an erroneous reference to an
2218 uninitialized value.
2219
2220 Note that pragma @code{Initialize_Scalars} is particularly useful in
2221 conjunction with the enhanced validity checking that is now provided
2222 in GNAT, which checks for invalid values under more conditions.
2223 Using this feature (see description of the @code{-gnatV} flag in the
2224 users guide) in conjunction with pragma @code{Initialize_Scalars}
2225 provides a powerful new tool to assist in the detection of problems
2226 caused by uninitialized variables.
2227
2228 Note: the use of @code{Initialize_Scalars} has a fairly extensive
2229 effect on the generated code. This may cause your code to be
2230 substantially larger. It may also cause an increase in the amount
2231 of stack required, so it is probably a good idea to turn on stack
2232 checking (see description of stack checking in the GNAT users guide)
2233 when using this pragma.
2234
2235 @node Pragma Inline_Always
2236 @unnumberedsec Pragma Inline_Always
2237 @findex Inline_Always
2238 @noindent
2239 Syntax:
2240
2241 @smallexample @c ada
2242 pragma Inline_Always (NAME [, NAME]);
2243 @end smallexample
2244
2245 @noindent
2246 Similar to pragma @code{Inline} except that inlining is not subject to
2247 the use of option @code{-gnatn} and the inlining happens regardless of
2248 whether this option is used.
2249
2250 @node Pragma Inline_Generic
2251 @unnumberedsec Pragma Inline_Generic
2252 @findex Inline_Generic
2253 @noindent
2254 Syntax:
2255
2256 @smallexample @c ada
2257 pragma Inline_Generic (generic_package_NAME);
2258 @end smallexample
2259
2260 @noindent
2261 This is implemented for compatibility with DEC Ada 83 and is recognized,
2262 but otherwise ignored, by GNAT@.  All generic instantiations are inlined
2263 by default when using GNAT@.
2264
2265 @node Pragma Interface
2266 @unnumberedsec Pragma Interface
2267 @findex Interface
2268 @noindent
2269 Syntax:
2270
2271 @smallexample @c ada
2272 pragma Interface (
2273      [Convention    =>] convention_identifier,
2274      [Entity =>] local_name
2275   [, [External_Name =>] static_string_expression],
2276   [, [Link_Name     =>] static_string_expression]);
2277 @end smallexample
2278
2279 @noindent
2280 This pragma is identical in syntax and semantics to
2281 the standard Ada 95 pragma @code{Import}.  It is provided for compatibility
2282 with Ada 83.  The definition is upwards compatible both with pragma
2283 @code{Interface} as defined in the Ada 83 Reference Manual, and also
2284 with some extended implementations of this pragma in certain Ada 83
2285 implementations.
2286
2287 @node Pragma Interface_Name
2288 @unnumberedsec Pragma Interface_Name
2289 @findex Interface_Name
2290 @noindent
2291 Syntax:
2292
2293 @smallexample @c ada
2294 pragma Interface_Name (
2295      [Entity        =>] LOCAL_NAME
2296   [, [External_Name =>] static_string_EXPRESSION]
2297   [, [Link_Name     =>] static_string_EXPRESSION]);
2298 @end smallexample
2299
2300 @noindent
2301 This pragma provides an alternative way of specifying the interface name
2302 for an interfaced subprogram, and is provided for compatibility with Ada
2303 83 compilers that use the pragma for this purpose.  You must provide at
2304 least one of @var{External_Name} or @var{Link_Name}.
2305
2306 @node Pragma Interrupt_Handler
2307 @unnumberedsec Pragma Interrupt_Handler
2308 @findex Interrupt_Handler
2309 @noindent
2310 Syntax:
2311
2312 @smallexample @c ada
2313 pragma Interrupt_Handler (procedure_LOCAL_NAME);
2314 @end smallexample
2315
2316 @noindent
2317 This program unit pragma is supported for parameterless protected procedures
2318 as described in Annex C of the Ada Reference Manual. On the AAMP target
2319 the pragma can also be specified for nonprotected parameterless procedures
2320 that are declared at the library level (which includes procedures
2321 declared at the top level of a library package). In the case of AAMP,
2322 when this pragma is applied to a nonprotected procedure, the instruction
2323 @code{IERET} is generated for returns from the procedure, enabling
2324 maskable interrupts, in place of the normal return instruction.
2325
2326 @node Pragma Interrupt_State
2327 @unnumberedsec Pragma Interrupt_State
2328 @findex Interrupt_State
2329 @noindent
2330 Syntax:
2331
2332 @smallexample @c ada
2333 pragma Interrupt_State (Name => value, State => SYSTEM | RUNTIME | USER);
2334 @end smallexample
2335
2336 @noindent
2337 Normally certain interrupts are reserved to the implementation.  Any attempt
2338 to attach an interrupt causes Program_Error to be raised, as described in
2339 RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
2340 many systems for an @kbd{Ctrl-C} interrupt.  Normally this interrupt is
2341 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
2342 interrupt execution.  Additionally, signals such as @code{SIGSEGV},
2343 @code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
2344 Ada exceptions, or used to implement run-time functions such as the
2345 @code{abort} statement and stack overflow checking.
2346
2347 Pragma @code{Interrupt_State} provides a general mechanism for overriding
2348 such uses of interrupts.  It subsumes the functionality of pragma
2349 @code{Unreserve_All_Interrupts}.  Pragma @code{Interrupt_State} is not
2350 available on OS/2, Windows or VMS.  On all other platforms than VxWorks,
2351 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
2352 and may be used to mark interrupts required by the board support package
2353 as reserved.
2354
2355 Interrupts can be in one of three states:
2356 @itemize @bullet
2357 @item System
2358
2359 The interrupt is reserved (no Ada handler can be installed), and the
2360 Ada run-time may not install a handler. As a result you are guaranteed
2361 standard system default action if this interrupt is raised.
2362
2363 @item Runtime
2364
2365 The interrupt is reserved (no Ada handler can be installed). The run time
2366 is allowed to install a handler for internal control purposes, but is
2367 not required to do so.
2368
2369 @item User
2370
2371 The interrupt is unreserved.  The user may install a handler to provide
2372 some other action.
2373 @end itemize
2374
2375 @noindent
2376 These states are the allowed values of the @code{State} parameter of the
2377 pragma.  The @code{Name} parameter is a value of the type
2378 @code{Ada.Interrupts.Interrupt_ID}.  Typically, it is a name declared in
2379 @code{Ada.Interrupts.Names}.
2380
2381 This is a configuration pragma, and the binder will check that there
2382 are no inconsistencies between different units in a partition in how a
2383 given interrupt is specified. It may appear anywhere a pragma is legal.
2384
2385 The effect is to move the interrupt to the specified state.
2386
2387 By declaring interrupts to be SYSTEM, you guarantee the standard system
2388 action, such as a core dump.
2389
2390 By declaring interrupts to be USER, you guarantee that you can install
2391 a handler.
2392
2393 Note that certain signals on many operating systems cannot be caught and
2394 handled by applications.  In such cases, the pragma is ignored.  See the
2395 operating system documentation, or the value of the array @code{Reserved}
2396 declared in the specification of package @code{System.OS_Interface}.
2397
2398 Overriding the default state of signals used by the Ada runtime may interfere
2399 with an application's runtime behavior in the cases of the synchronous signals,
2400 and in the case of the signal used to implement the @code{abort} statement.
2401
2402 @node Pragma Keep_Names
2403 @unnumberedsec Pragma Keep_Names
2404 @findex Keep_Names
2405 @noindent
2406 Syntax:
2407
2408 @smallexample @c ada
2409 pragma Keep_Names ([On =>] enumeration_first_subtype_LOCAL_NAME);
2410 @end smallexample
2411
2412 @noindent
2413 The @var{LOCAL_NAME} argument
2414 must refer to an enumeration first subtype
2415 in the current declarative part. The effect is to retain the enumeration
2416 literal names for use by @code{Image} and @code{Value} even if a global
2417 @code{Discard_Names} pragma applies. This is useful when you want to
2418 generally suppress enumeration literal names and for example you therefore
2419 use a @code{Discard_Names} pragma in the @file{gnat.adc} file, but you
2420 want to retain the names for specific enumeration types.
2421
2422 @node Pragma License
2423 @unnumberedsec Pragma License
2424 @findex License
2425 @cindex License checking
2426 @noindent
2427 Syntax:
2428
2429 @smallexample @c ada
2430 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
2431 @end smallexample
2432
2433 @noindent
2434 This pragma is provided to allow automated checking for appropriate license
2435 conditions with respect to the standard and modified GPL@.  A pragma
2436 @code{License}, which is a configuration pragma that typically appears at
2437 the start of a source file or in a separate @file{gnat.adc} file, specifies
2438 the licensing conditions of a unit as follows:
2439
2440 @itemize @bullet
2441 @item Unrestricted
2442 This is used for a unit that can be freely used with no license restrictions.
2443 Examples of such units are public domain units, and units from the Ada
2444 Reference Manual.
2445
2446 @item GPL
2447 This is used for a unit that is licensed under the unmodified GPL, and which
2448 therefore cannot be @code{with}'ed by a restricted unit.
2449
2450 @item Modified_GPL
2451 This is used for a unit licensed under the GNAT modified GPL that includes
2452 a special exception paragraph that specifically permits the inclusion of
2453 the unit in programs without requiring the entire program to be released
2454 under the GPL@.  This is the license used for the GNAT run-time which ensures
2455 that the run-time can be used freely in any program without GPL concerns.
2456
2457 @item Restricted
2458 This is used for a unit that is restricted in that it is not permitted to
2459 depend on units that are licensed under the GPL@.  Typical examples are
2460 proprietary code that is to be released under more restrictive license
2461 conditions.  Note that restricted units are permitted to @code{with} units
2462 which are licensed under the modified GPL (this is the whole point of the
2463 modified GPL).
2464
2465 @end itemize
2466
2467 @noindent
2468 Normally a unit with no @code{License} pragma is considered to have an
2469 unknown license, and no checking is done.  However, standard GNAT headers
2470 are recognized, and license information is derived from them as follows.
2471
2472 @itemize @bullet
2473
2474 A GNAT license header starts with a line containing 78 hyphens.  The following
2475 comment text is searched for the appearance of any of the following strings.
2476
2477 If the string ``GNU General Public License'' is found, then the unit is assumed
2478 to have GPL license, unless the string ``As a special exception'' follows, in
2479 which case the license is assumed to be modified GPL@.
2480
2481 If one of the strings
2482 ``This specification is adapted from the Ada Semantic Interface'' or
2483 ``This specification is derived from the Ada Reference Manual'' is found
2484 then the unit is assumed to be unrestricted.
2485 @end itemize
2486
2487 @noindent
2488 These default actions means that a program with a restricted license pragma
2489 will automatically get warnings if a GPL unit is inappropriately
2490 @code{with}'ed.  For example, the program:
2491
2492 @smallexample @c ada
2493 with Sem_Ch3;
2494 with GNAT.Sockets;
2495 procedure Secret_Stuff is
2496   @dots{}
2497 end Secret_Stuff
2498 @end smallexample
2499
2500 @noindent
2501 if compiled with pragma @code{License} (@code{Restricted}) in a
2502 @file{gnat.adc} file will generate the warning:
2503
2504 @smallexample
2505 1.  with Sem_Ch3;
2506         |
2507    >>> license of withed unit "Sem_Ch3" is incompatible
2508
2509 2.  with GNAT.Sockets;
2510 3.  procedure Secret_Stuff is
2511 @end smallexample
2512
2513 @noindent
2514 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
2515 compiler and is licensed under the
2516 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
2517 run time, and is therefore licensed under the modified GPL@.
2518
2519 @node Pragma Link_With
2520 @unnumberedsec Pragma Link_With
2521 @findex Link_With
2522 @noindent
2523 Syntax:
2524
2525 @smallexample @c ada
2526 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
2527 @end smallexample
2528
2529 @noindent
2530 This pragma is provided for compatibility with certain Ada 83 compilers.
2531 It has exactly the same effect as pragma @code{Linker_Options} except
2532 that spaces occurring within one of the string expressions are treated
2533 as separators. For example, in the following case:
2534
2535 @smallexample @c ada
2536 pragma Link_With ("-labc -ldef");
2537 @end smallexample
2538
2539 @noindent
2540 results in passing the strings @code{-labc} and @code{-ldef} as two
2541 separate arguments to the linker. In addition pragma Link_With allows
2542 multiple arguments, with the same effect as successive pragmas.
2543
2544 @node Pragma Linker_Alias
2545 @unnumberedsec Pragma Linker_Alias
2546 @findex Linker_Alias
2547 @noindent
2548 Syntax:
2549
2550 @smallexample @c ada
2551 pragma Linker_Alias (
2552   [Entity =>] LOCAL_NAME
2553   [Alias  =>] static_string_EXPRESSION);
2554 @end smallexample
2555
2556 @noindent
2557 This pragma establishes a linker alias for the given named entity.  For
2558 further details on the exact effect, consult the GCC manual.
2559
2560 @node Pragma Linker_Section
2561 @unnumberedsec Pragma Linker_Section
2562 @findex Linker_Section
2563 @noindent
2564 Syntax:
2565
2566 @smallexample @c ada
2567 pragma Linker_Section (
2568   [Entity  =>] LOCAL_NAME
2569   [Section =>] static_string_EXPRESSION);
2570 @end smallexample
2571
2572 @noindent
2573 This pragma specifies the name of the linker section for the given entity.
2574 For further details on the exact effect, consult the GCC manual.
2575
2576 @node Pragma Long_Float
2577 @unnumberedsec Pragma Long_Float
2578 @cindex OpenVMS
2579 @findex Long_Float
2580 @noindent
2581 Syntax:
2582
2583 @smallexample @c ada
2584 pragma Long_Float (FLOAT_FORMAT);
2585
2586 FLOAT_FORMAT ::= D_Float | G_Float
2587 @end smallexample
2588
2589 @noindent
2590 This pragma is implemented only in the OpenVMS implementation of GNAT@.
2591 It allows control over the internal representation chosen for the predefined
2592 type @code{Long_Float} and for floating point type representations with
2593 @code{digits} specified in the range 7 through 15.
2594 For further details on this pragma, see the
2595 @cite{DEC Ada Language Reference Manual}, section 3.5.7b.  Note that to use
2596 this pragma, the standard runtime libraries must be recompiled.  See the
2597 description of the @code{GNAT LIBRARY} command in the OpenVMS version
2598 of the GNAT User's Guide for details on the use of this command.
2599
2600 @node Pragma Machine_Attribute
2601 @unnumberedsec Pragma Machine_Attribute
2602 @findex Machine_Attribute
2603 @noindent
2604 Syntax:
2605
2606 @smallexample @c ada
2607 pragma Machine_Attribute (
2608   [Attribute_Name =>] string_EXPRESSION,
2609   [Entity         =>] LOCAL_NAME);
2610 @end smallexample
2611
2612 @noindent
2613 Machine dependent attributes can be specified for types and/or
2614 declarations.  Currently only subprogram entities are supported.  This
2615 pragma is semantically equivalent to
2616 @code{__attribute__((@var{string_expression}))} in GNU C,
2617 where @code{@var{string_expression}} is
2618 recognized by the GNU C macros @code{VALID_MACHINE_TYPE_ATTRIBUTE} and
2619 @code{VALID_MACHINE_DECL_ATTRIBUTE} which are defined in the
2620 configuration header file @file{tm.h} for each machine.  See the GCC
2621 manual for further information.
2622
2623 @node Pragma Main_Storage
2624 @unnumberedsec Pragma Main_Storage
2625 @cindex OpenVMS
2626 @findex Main_Storage
2627 @noindent
2628 Syntax:
2629
2630 @smallexample @c ada
2631 pragma Main_Storage
2632   (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
2633
2634 MAIN_STORAGE_OPTION ::=
2635   [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
2636 | [TOP_GUARD       =>] static_SIMPLE_EXPRESSION
2637
2638 @end smallexample
2639
2640 @noindent
2641 This pragma is provided for compatibility with OpenVMS VAX Systems.  It has
2642 no effect in GNAT, other than being syntax checked.  Note that the pragma
2643 also has no effect in DEC Ada 83 for OpenVMS Alpha Systems.
2644
2645 @node Pragma No_Return
2646 @unnumberedsec Pragma No_Return
2647 @findex No_Return
2648 @noindent
2649 Syntax:
2650
2651 @smallexample @c ada
2652 pragma No_Return (procedure_LOCAL_NAME);
2653 @end smallexample
2654
2655 @noindent
2656 @var{procedure_local_NAME} must refer to one or more procedure
2657 declarations in the current declarative part.  A procedure to which this
2658 pragma is applied may not contain any explicit @code{return} statements,
2659 and also may not contain any implicit return statements from falling off
2660 the end of a statement sequence.  One use of this pragma is to identify
2661 procedures whose only purpose is to raise an exception.
2662
2663 Another use of this pragma is to suppress incorrect warnings about
2664 missing returns in functions, where the last statement of a function
2665 statement sequence is a call to such a procedure.
2666
2667 @node Pragma Normalize_Scalars
2668 @unnumberedsec Pragma Normalize_Scalars
2669 @findex Normalize_Scalars
2670 @noindent
2671 Syntax:
2672
2673 @smallexample @c ada
2674 pragma Normalize_Scalars;
2675 @end smallexample
2676
2677 @noindent
2678 This is a language defined pragma which is fully implemented in GNAT@.  The
2679 effect is to cause all scalar objects that are not otherwise initialized
2680 to be initialized.  The initial values are implementation dependent and
2681 are as follows:
2682
2683 @table @code
2684 @item Standard.Character
2685 @noindent
2686 Objects whose root type is Standard.Character are initialized to
2687 Character'Last.  This will be out of range of the subtype only if
2688 the subtype range excludes this value.
2689
2690 @item Standard.Wide_Character
2691 @noindent
2692 Objects whose root type is Standard.Wide_Character are initialized to
2693 Wide_Character'Last.  This will be out of range of the subtype only if
2694 the subtype range excludes this value.
2695
2696 @item Integer types
2697 @noindent
2698 Objects of an integer type are initialized to base_type'First, where
2699 base_type is the base type of the object type.  This will be out of range
2700 of the subtype only if the subtype range excludes this value.  For example,
2701 if you declare the subtype:
2702
2703 @smallexample @c ada
2704 subtype Ityp is integer range 1 .. 10;
2705 @end smallexample
2706
2707 @noindent
2708 then objects of type x will be initialized to Integer'First, a negative
2709 number that is certainly outside the range of subtype @code{Ityp}.
2710
2711 @item Real types
2712 Objects of all real types (fixed and floating) are initialized to
2713 base_type'First, where base_Type is the base type of the object type.
2714 This will be out of range of the subtype only if the subtype range
2715 excludes this value.
2716
2717 @item Modular types
2718 Objects of a modular type are initialized to typ'Last.  This will be out
2719 of range of the subtype only if the subtype excludes this value.
2720
2721 @item Enumeration types
2722 Objects of an enumeration type are initialized to all one-bits, i.e.@: to
2723 the value @code{2 ** typ'Size - 1}.  This will be out of range of the
2724 enumeration subtype in all cases except where the subtype contains
2725 exactly 2**8, 2**16, or 2**32 elements.
2726
2727 @end table
2728
2729 @node Pragma Obsolescent
2730 @unnumberedsec Pragma Obsolescent
2731 @findex Obsolescent
2732 @noindent
2733 Syntax:
2734
2735 @smallexample @c ada
2736 pragma Obsolescent [(static_string_EXPRESSION)];
2737 @end smallexample
2738
2739 @noindent
2740 This pragma must occur immediately following a subprogram
2741 declaration. It indicates that the associated function or procedure
2742 is considered obsolescent and should not be used. Typically this is
2743 used when an API must be modified by eventually removing or modifying
2744 existing subprograms. The pragma can be used at an intermediate stage
2745 when the subprogram is still present, but will be removed later.
2746
2747 The effect of this pragma is to output a warning message that the
2748 subprogram is obsolescent if the appropriate warning option in the
2749 compiler is activated. If a parameter is present, then a second
2750 warning message is given containing this text.
2751
2752 @node Pragma Passive
2753 @unnumberedsec Pragma Passive
2754 @findex Passive
2755 @noindent
2756 Syntax:
2757
2758 @smallexample @c ada
2759 pragma Passive ([Semaphore | No]);
2760 @end smallexample
2761
2762 @noindent
2763 Syntax checked, but otherwise ignored by GNAT@.  This is recognized for
2764 compatibility with DEC Ada 83 implementations, where it is used within a
2765 task definition to request that a task be made passive.  If the argument
2766 @code{Semaphore} is present, or the argument is omitted, then DEC Ada 83
2767 treats the pragma as an assertion that the containing task is passive
2768 and that optimization of context switch with this task is permitted and
2769 desired.  If the argument @code{No} is present, the task must not be
2770 optimized.  GNAT does not attempt to optimize any tasks in this manner
2771 (since protected objects are available in place of passive tasks).
2772
2773 @node Pragma Polling
2774 @unnumberedsec Pragma Polling
2775 @findex Polling
2776 @noindent
2777 Syntax:
2778
2779 @smallexample @c ada
2780 pragma Polling (ON | OFF);
2781 @end smallexample
2782
2783 @noindent
2784 This pragma controls the generation of polling code.  This is normally off.
2785 If @code{pragma Polling (ON)} is used then periodic calls are generated to
2786 the routine @code{Ada.Exceptions.Poll}.  This routine is a separate unit in the
2787 runtime library, and can be found in file @file{a-excpol.adb}.
2788
2789 Pragma @code{Polling} can appear as a configuration pragma (for example it
2790 can be placed in the @file{gnat.adc} file) to enable polling globally, or it
2791 can be used in the statement or declaration sequence to control polling
2792 more locally.
2793
2794 A call to the polling routine is generated at the start of every loop and
2795 at the start of every subprogram call.  This guarantees that the @code{Poll}
2796 routine is called frequently, and places an upper bound (determined by
2797 the complexity of the code) on the period between two @code{Poll} calls.
2798
2799 The primary purpose of the polling interface is to enable asynchronous
2800 aborts on targets that cannot otherwise support it (for example Windows
2801 NT), but it may be used for any other purpose requiring periodic polling.
2802 The standard version is null, and can be replaced by a user program.  This
2803 will require re-compilation of the @code{Ada.Exceptions} package that can
2804 be found in files @file{a-except.ads} and @file{a-except.adb}.
2805
2806 A standard alternative unit (in file @file{4wexcpol.adb} in the standard GNAT
2807 distribution) is used to enable the asynchronous abort capability on
2808 targets that do not normally support the capability.  The version of
2809 @code{Poll} in this file makes a call to the appropriate runtime routine
2810 to test for an abort condition.
2811
2812 Note that polling can also be enabled by use of the @code{-gnatP} switch.  See
2813 the @cite{GNAT User's Guide} for details.
2814
2815 @node Pragma Profile (Ravenscar)
2816 @unnumberedsec Pragma Profile (Ravenscar)
2817 @findex Ravenscar
2818 @noindent
2819 Syntax:
2820
2821 @smallexample @c ada
2822 pragma Profile (Ravenscar);
2823 @end smallexample
2824
2825 @noindent
2826 A configuration pragma that establishes the following set of configuration
2827 pragmas:
2828
2829 @table @code
2830 @item Task_Dispatching_Policy (FIFO_Within_Priorities)
2831 [RM D.2.2] Tasks are dispatched following a preemptive
2832 priority-ordered scheduling policy.
2833
2834 @item Locking_Policy (Ceiling_Locking)
2835 [RM D.3] While tasks and interrupts execute a protected action, they inherit
2836 the ceiling priority of the corresponding protected object.
2837 @c
2838 @c @item Detect_Blocking
2839 @c This pragma forces the detection of potentially blocking operations within a
2840 @c protected operation, and to raise Program_Error if that happens.
2841 @end table
2842 @noindent
2843
2844 plus the following set of restrictions:
2845
2846 @table @code
2847 @item Max_Entry_Queue_Length = 1
2848 Defines the maximum number of calls that are queued on a (protected) entry.
2849 Note that this restrictions is checked at run time. Violation of this
2850 restriction results in the raising of Program_Error exception at the point of
2851 the call. For the Profile (Ravenscar) the value of Max_Entry_Queue_Length is
2852 always 1 and hence no task can be queued on a protected entry.
2853
2854 @item Max_Protected_Entries = 1
2855 [RM D.7] Specifies the maximum number of entries per protected type. The
2856 bounds of every entry family of a protected unit shall be static, or shall be
2857 defined by a discriminant of a subtype whose corresponding bound is static.
2858 For the Profile (Ravenscar) the value of Max_Protected_Entries is always 1.
2859
2860 @item Max_Task_Entries = 0
2861 [RM D.7] Specifies the maximum number of entries
2862 per task.  The bounds of every entry family
2863 of a task unit shall be static, or shall be
2864 defined by a discriminant of a subtype whose
2865 corresponding bound is static.  A value of zero
2866 indicates that no rendezvous are possible.  For
2867 the Profile (Ravenscar), the value of Max_Task_Entries is always
2868 0 (zero).
2869
2870 @item No_Abort_Statements
2871 [RM D.7] There are no abort_statements, and there are
2872 no calls to Task_Identification.Abort_Task.
2873
2874 @item No_Asynchronous_Control
2875 [RM D.7] There are no semantic dependences on the package
2876 Asynchronous_Task_Control.
2877
2878 @item No_Calendar
2879 There are no semantic dependencies on the package Ada.Calendar.
2880
2881 @item No_Dynamic_Attachment
2882 There is no call to any of the operations defined in package Ada.Interrupts
2883 (Is_Reserved, Is_Attached, Current_Handler, Attach_Handler, Exchange_Handler,
2884 Detach_Handler, and Reference).
2885
2886 @item No_Dynamic_Priorities
2887 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
2888
2889 @item No_Implicit_Heap_Allocations
2890 [RM D.7] No constructs are allowed to cause implicit heap allocation.
2891
2892 @item No_Local_Protected_Objects
2893 Protected objects and access types that designate
2894 such objects shall be declared only at library level.
2895
2896 @item No_Protected_Type_Allocators
2897 There are no allocators for protected types or
2898 types containing protected subcomponents.
2899
2900 @item No_Relative_Delay
2901 There are no delay_relative statements.
2902
2903 @item No_Requeue_Statements
2904 Requeue statements are not allowed.
2905
2906 @item No_Select_Statements
2907 There are no select_statements.
2908
2909 @item No_Task_Allocators
2910 [RM D.7] There are no allocators for task types
2911 or types containing task subcomponents.
2912
2913 @item No_Task_Attributes_Package
2914 There are no semantic dependencies on the Ada.Task_Attributes package.
2915
2916 @item No_Task_Hierarchy
2917 [RM D.7] All (non-environment) tasks depend
2918 directly on the environment task of the partition.
2919
2920 @item No_Task_Termination
2921 Tasks which terminate are erroneous.
2922
2923 @item Simple_Barriers
2924 Entry barrier condition expressions shall be either static
2925 boolean expressions or boolean objects which are declared in
2926 the protected type which contains the entry.
2927 @end table
2928
2929 @noindent
2930 This set of configuration pragmas and restrictions correspond to the
2931 definition of the ``Ravenscar Profile'' for limited tasking, devised and
2932 published by the @cite{International Real-Time Ada Workshop}, 1997,
2933 and whose most recent description is available at
2934 @url{ftp://ftp.openravenscar.org/openravenscar/ravenscar00.pdf}.
2935
2936 The original definition of the profile was revised at subsequent IRTAW
2937 meetings. It has been included in the ISO
2938 @cite{Guide for the Use of the Ada Programming Language in High
2939 Integrity Systems}, and has been approved by ISO/IEC/SC22/WG9 for inclusion in
2940 the next revision of the standard. The formal definition given by
2941 the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
2942 AI-305) available at
2943 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00249.TXT} and
2944 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00305.TXT}
2945 respectively.
2946
2947 The above set is a superset of the restrictions provided by pragma
2948 @code{Restricted_Run_Time}, it includes six additional restrictions
2949 (@code{Simple_Barriers}, @code{No_Select_Statements},
2950 @code{No_Calendar}, @code{No_Implicit_Heap_Allocations},
2951 @code{No_Relative_Delay} and @code{No_Task_Termination}).  This means
2952 that pragma @code{Profile (Ravenscar)}, like the pragma
2953 @code{Restricted_Run_Time}, automatically causes the use of a simplified,
2954 more efficient version of the tasking run-time system.
2955
2956 @node Pragma Propagate_Exceptions
2957 @unnumberedsec Pragma Propagate_Exceptions
2958 @findex Propagate_Exceptions
2959 @cindex Zero Cost Exceptions
2960 @noindent
2961 Syntax:
2962
2963 @smallexample @c ada
2964 pragma Propagate_Exceptions (subprogram_LOCAL_NAME);
2965 @end smallexample
2966
2967 @noindent
2968 This pragma indicates that the given entity, which is the name of an
2969 imported foreign-language subprogram may receive an Ada exception,
2970 and that the exception should be propagated.  It is relevant only if
2971 zero cost exception handling is in use, and is thus never needed if
2972 the alternative @code{longjmp} / @code{setjmp} implementation of
2973 exceptions is used (although it is harmless to use it in such cases).
2974
2975 The implementation of fast exceptions always properly propagates
2976 exceptions through Ada code, as described in the Ada Reference Manual.
2977 However, this manual is silent about the propagation of exceptions
2978 through foreign code.  For example, consider the
2979 situation where @code{P1} calls
2980 @code{P2}, and @code{P2} calls @code{P3}, where
2981 @code{P1} and @code{P3} are in Ada, but @code{P2} is in C@.
2982 @code{P3} raises an Ada exception.  The question is whether or not
2983 it will be propagated through @code{P2} and can be handled in
2984 @code{P1}.
2985
2986 For the @code{longjmp} / @code{setjmp} implementation of exceptions,
2987 the answer is always yes.  For some targets on which zero cost exception
2988 handling is implemented, the answer is also always yes.  However, there
2989 are some targets, notably in the current version all x86 architecture
2990 targets, in which the answer is that such propagation does not
2991 happen automatically.  If such propagation is required on these
2992 targets, it is mandatory to use @code{Propagate_Exceptions} to
2993 name all foreign language routines through which Ada exceptions
2994 may be propagated.
2995
2996 @node Pragma Psect_Object
2997 @unnumberedsec Pragma Psect_Object
2998 @findex Psect_Object
2999 @noindent
3000 Syntax:
3001
3002 @smallexample @c ada
3003 pragma Psect_Object (
3004      [Internal =>] LOCAL_NAME,
3005   [, [External =>] EXTERNAL_SYMBOL]
3006   [, [Size     =>] EXTERNAL_SYMBOL]);
3007
3008 EXTERNAL_SYMBOL ::=
3009   IDENTIFIER
3010 | static_string_EXPRESSION
3011 @end smallexample
3012
3013 @noindent
3014 This pragma is identical in effect to pragma @code{Common_Object}.
3015
3016 @node Pragma Pure_Function
3017 @unnumberedsec Pragma Pure_Function
3018 @findex Pure_Function
3019 @noindent
3020 Syntax:
3021
3022 @smallexample @c ada
3023 pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
3024 @end smallexample
3025
3026 @noindent
3027 This pragma appears in the same declarative part as a function
3028 declaration (or a set of function declarations if more than one
3029 overloaded declaration exists, in which case the pragma applies
3030 to all entities).  It specifies that the function @code{Entity} is
3031 to be considered pure for the purposes of code generation.  This means
3032 that the compiler can assume that there are no side effects, and
3033 in particular that two calls with identical arguments produce the
3034 same result.  It also means that the function can be used in an
3035 address clause.
3036
3037 Note that, quite deliberately, there are no static checks to try
3038 to ensure that this promise is met, so @code{Pure_Function} can be used
3039 with functions that are conceptually pure, even if they do modify
3040 global variables.  For example, a square root function that is
3041 instrumented to count the number of times it is called is still
3042 conceptually pure, and can still be optimized, even though it
3043 modifies a global variable (the count).  Memo functions are another
3044 example (where a table of previous calls is kept and consulted to
3045 avoid re-computation).
3046
3047 @findex Pure
3048 Note: Most functions in a @code{Pure} package are automatically pure, and
3049 there is no need to use pragma @code{Pure_Function} for such functions.  One
3050 exception is any function that has at least one formal of type
3051 @code{System.Address} or a type derived from it.  Such functions are not
3052 considered pure by default, since the compiler assumes that the
3053 @code{Address} parameter may be functioning as a pointer and that the
3054 referenced data may change even if the address value does not.
3055 Similarly, imported functions are not considered to be pure by default,
3056 since there is no way of checking that they are in fact pure.  The use
3057 of pragma @code{Pure_Function} for such a function will override these default
3058 assumption, and cause the compiler to treat a designated subprogram as pure
3059 in these cases.
3060
3061 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
3062 applies to the underlying renamed function.  This can be used to
3063 disambiguate cases of overloading where some but not all functions
3064 in a set of overloaded functions are to be designated as pure.
3065
3066 @node Pragma Restricted_Run_Time
3067 @unnumberedsec Pragma Restricted_Run_Time
3068 @findex Restricted_Run_Time
3069 @noindent
3070 Syntax:
3071
3072 @smallexample @c ada
3073 pragma Restricted_Run_Time;
3074 @end smallexample
3075
3076 @noindent
3077 A configuration pragma that establishes the following set of restrictions:
3078
3079 @itemize @bullet
3080 @item No_Abort_Statements
3081 @item No_Entry_Queue
3082 @item No_Task_Hierarchy
3083 @item No_Task_Allocators
3084 @item No_Dynamic_Priorities
3085 @item No_Terminate_Alternatives
3086 @item No_Dynamic_Attachment
3087 @item No_Protected_Type_Allocators
3088 @item No_Local_Protected_Objects
3089 @item No_Requeue_Statements
3090 @item No_Task_Attributes_Package
3091 @item Max_Asynchronous_Select_Nesting =  0
3092 @item Max_Task_Entries =  0
3093 @item Max_Protected_Entries = 1
3094 @item Max_Select_Alternatives = 0
3095 @end itemize
3096
3097 @noindent
3098 This set of restrictions causes the automatic selection of a simplified
3099 version of the run time that provides improved performance for the
3100 limited set of tasking functionality permitted by this set of restrictions.
3101
3102 @node Pragma Restriction_Warnings
3103 @unnumberedsec Pragma Restriction_Warnings
3104 @findex Restriction_Warnings
3105 @noindent
3106 Syntax:
3107
3108 @smallexample @c ada
3109 pragma Restriction_Warnings
3110   (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
3111 @end smallexample
3112
3113 @noindent
3114 This pragma allows a series of restriction identifiers to be
3115 specified (the list of allowed identifiers is the same as for
3116 pragma @code{Restrictions}). For each of these identifiers
3117 the compiler checks for violations of the restriction, but
3118 generates a warning message rather than an error message
3119 if the restriction is violated.
3120
3121 @node Pragma Source_File_Name
3122 @unnumberedsec Pragma Source_File_Name
3123 @findex Source_File_Name
3124 @noindent
3125 Syntax:
3126
3127 @smallexample @c ada
3128 pragma Source_File_Name (
3129   [Unit_Name   =>] unit_NAME,
3130   Spec_File_Name =>  STRING_LITERAL);
3131
3132 pragma Source_File_Name (
3133   [Unit_Name   =>] unit_NAME,
3134   Body_File_Name =>  STRING_LITERAL);
3135 @end smallexample
3136
3137 @noindent
3138 Use this to override the normal naming convention.  It is a configuration
3139 pragma, and so has the usual applicability of configuration pragmas
3140 (i.e.@: it applies to either an entire partition, or to all units in a
3141 compilation, or to a single unit, depending on how it is used.
3142 @var{unit_name} is mapped to @var{file_name_literal}.  The identifier for
3143 the second argument is required, and indicates whether this is the file
3144 name for the spec or for the body.
3145
3146 Another form of the @code{Source_File_Name} pragma allows
3147 the specification of patterns defining alternative file naming schemes
3148 to apply to all files.
3149
3150 @smallexample @c ada
3151 pragma Source_File_Name
3152   (Spec_File_Name => STRING_LITERAL
3153    [,Casing => CASING_SPEC]
3154    [,Dot_Replacement => STRING_LITERAL]);
3155
3156 pragma Source_File_Name
3157   (Body_File_Name => STRING_LITERAL
3158    [,Casing => CASING_SPEC]
3159    [,Dot_Replacement => STRING_LITERAL]);
3160
3161 pragma Source_File_Name
3162   (Subunit_File_Name => STRING_LITERAL
3163    [,Casing => CASING_SPEC]
3164    [,Dot_Replacement => STRING_LITERAL]);
3165
3166 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
3167 @end smallexample
3168
3169 @noindent
3170 The first argument is a pattern that contains a single asterisk indicating
3171 the point at which the unit name is to be inserted in the pattern string
3172 to form the file name.  The second argument is optional.  If present it
3173 specifies the casing of the unit name in the resulting file name string.
3174 The default is lower case.  Finally the third argument allows for systematic
3175 replacement of any dots in the unit name by the specified string literal.
3176
3177 A pragma Source_File_Name cannot appear after a
3178 @ref{Pragma Source_File_Name_Project}.
3179
3180 For more details on the use of the @code{Source_File_Name} pragma,
3181 see the sections ``Using Other File Names'' and
3182 ``Alternative File Naming Schemes'' in the @cite{GNAT User's Guide}.
3183
3184 @node Pragma Source_File_Name_Project
3185 @unnumberedsec Pragma Source_File_Name_Project
3186 @findex Source_File_Name_Project
3187 @noindent
3188
3189 This pragma has the same syntax and semantics as pragma Source_File_Name.
3190 It is only allowed as a stand alone configuration pragma.
3191 It cannot appear after a @ref{Pragma Source_File_Name}, and
3192 most importantly, once pragma Source_File_Name_Project appears,
3193 no further Source_File_Name pragmas are allowed.
3194
3195 The intention is that Source_File_Name_Project pragmas are always
3196 generated by the Project Manager in a manner consistent with the naming
3197 specified in a project file, and when naming is controlled in this manner,
3198 it is not permissible to attempt to modify this naming scheme using
3199 Source_File_Name pragmas (which would not be known to the project manager).
3200
3201 @node Pragma Source_Reference
3202 @unnumberedsec Pragma Source_Reference
3203 @findex Source_Reference
3204 @noindent
3205 Syntax:
3206
3207 @smallexample @c ada
3208 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
3209 @end smallexample
3210
3211 @noindent
3212 This pragma must appear as the first line of a source file.
3213 @var{integer_literal} is the logical line number of the line following
3214 the pragma line (for use in error messages and debugging
3215 information).  @var{string_literal} is a static string constant that
3216 specifies the file name to be used in error messages and debugging
3217 information.  This is most notably used for the output of @code{gnatchop}
3218 with the @code{-r} switch, to make sure that the original unchopped
3219 source file is the one referred to.
3220
3221 The second argument must be a string literal, it cannot be a static
3222 string expression other than a string literal.  This is because its value
3223 is needed for error messages issued by all phases of the compiler.
3224
3225 @node Pragma Stream_Convert
3226 @unnumberedsec Pragma Stream_Convert
3227 @findex Stream_Convert
3228 @noindent
3229 Syntax:
3230
3231 @smallexample @c ada
3232 pragma Stream_Convert (
3233   [Entity =>] type_LOCAL_NAME,
3234   [Read   =>] function_NAME,
3235   [Write  =>] function_NAME);
3236 @end smallexample
3237
3238 @noindent
3239 This pragma provides an efficient way of providing stream functions for
3240 types defined in packages.  Not only is it simpler to use than declaring
3241 the necessary functions with attribute representation clauses, but more
3242 significantly, it allows the declaration to made in such a way that the
3243 stream packages are not loaded unless they are needed.  The use of
3244 the Stream_Convert pragma adds no overhead at all, unless the stream
3245 attributes are actually used on the designated type.
3246
3247 The first argument specifies the type for which stream functions are
3248 provided.  The second parameter provides a function used to read values
3249 of this type.  It must name a function whose argument type may be any
3250 subtype, and whose returned type must be the type given as the first
3251 argument to the pragma.
3252
3253 The meaning of the @var{Read}
3254 parameter is that if a stream attribute directly
3255 or indirectly specifies reading of the type given as the first parameter,
3256 then a value of the type given as the argument to the Read function is
3257 read from the stream, and then the Read function is used to convert this
3258 to the required target type.
3259
3260 Similarly the @var{Write} parameter specifies how to treat write attributes
3261 that directly or indirectly apply to the type given as the first parameter.
3262 It must have an input parameter of the type specified by the first parameter,
3263 and the return type must be the same as the input type of the Read function.
3264 The effect is to first call the Write function to convert to the given stream
3265 type, and then write the result type to the stream.
3266
3267 The Read and Write functions must not be overloaded subprograms.  If necessary
3268 renamings can be supplied to meet this requirement.
3269 The usage of this attribute is best illustrated by a simple example, taken
3270 from the GNAT implementation of package Ada.Strings.Unbounded:
3271
3272 @smallexample @c ada
3273 function To_Unbounded (S : String)
3274            return Unbounded_String
3275   renames To_Unbounded_String;
3276
3277 pragma Stream_Convert
3278   (Unbounded_String, To_Unbounded, To_String);
3279 @end smallexample
3280
3281 @noindent
3282 The specifications of the referenced functions, as given in the Ada 95
3283 Reference Manual are:
3284
3285 @smallexample @c ada
3286 function To_Unbounded_String (Source : String)
3287   return Unbounded_String;
3288
3289 function To_String (Source : Unbounded_String)
3290   return String;
3291 @end smallexample
3292
3293 @noindent
3294 The effect is that if the value of an unbounded string is written to a
3295 stream, then the representation of the item in the stream is in the same
3296 format used for @code{Standard.String}, and this same representation is
3297 expected when a value of this type is read from the stream.
3298
3299 @node Pragma Style_Checks
3300 @unnumberedsec Pragma Style_Checks
3301 @findex Style_Checks
3302 @noindent
3303 Syntax:
3304
3305 @smallexample @c ada
3306 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
3307                      On | Off [, LOCAL_NAME]);
3308 @end smallexample
3309
3310 @noindent
3311 This pragma is used in conjunction with compiler switches to control the
3312 built in style checking provided by GNAT@.  The compiler switches, if set,
3313 provide an initial setting for the switches, and this pragma may be used
3314 to modify these settings, or the settings may be provided entirely by
3315 the use of the pragma.  This pragma can be used anywhere that a pragma
3316 is legal, including use as a configuration pragma (including use in
3317 the @file{gnat.adc} file).
3318
3319 The form with a string literal specifies which style options are to be
3320 activated.  These are additive, so they apply in addition to any previously
3321 set style check options.  The codes for the options are the same as those
3322 used in the @code{-gnaty} switch to @code{gcc} or @code{gnatmake}.
3323 For example the following two methods can be used to enable
3324 layout checking:
3325
3326 @itemize @bullet
3327 @item
3328 @smallexample @c ada
3329 pragma Style_Checks ("l");
3330 @end smallexample
3331
3332 @item
3333 @smallexample
3334 gcc -c -gnatyl @dots{}
3335 @end smallexample
3336 @end itemize
3337
3338 @noindent
3339 The form ALL_CHECKS activates all standard checks (its use is equivalent
3340 to the use of the @code{gnaty} switch with no options.  See GNAT User's
3341 Guide for details.
3342
3343 The forms with @code{Off} and @code{On}
3344 can be used to temporarily disable style checks
3345 as shown in the following example:
3346
3347 @smallexample @c ada
3348 @iftex
3349 @leftskip=0cm
3350 @end iftex
3351 pragma Style_Checks ("k"); -- requires keywords in lower case
3352 pragma Style_Checks (Off); -- turn off style checks
3353 NULL;                      -- this will not generate an error message
3354 pragma Style_Checks (On);  -- turn style checks back on
3355 NULL;                      -- this will generate an error message
3356 @end smallexample
3357
3358 @noindent
3359 Finally the two argument form is allowed only if the first argument is
3360 @code{On} or @code{Off}.  The effect is to turn of semantic style checks
3361 for the specified entity, as shown in the following example:
3362
3363 @smallexample @c ada
3364 @iftex
3365 @leftskip=0cm
3366 @end iftex
3367 pragma Style_Checks ("r"); -- require consistency of identifier casing
3368 Arg : Integer;
3369 Rf1 : Integer := ARG;      -- incorrect, wrong case
3370 pragma Style_Checks (Off, Arg);
3371 Rf2 : Integer := ARG;      -- OK, no error
3372 @end smallexample
3373
3374 @node Pragma Subtitle
3375 @unnumberedsec Pragma Subtitle
3376 @findex Subtitle
3377 @noindent
3378 Syntax:
3379
3380 @smallexample @c ada
3381 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
3382 @end smallexample
3383
3384 @noindent
3385 This pragma is recognized for compatibility with other Ada compilers
3386 but is ignored by GNAT@.
3387
3388 @node Pragma Suppress_All
3389 @unnumberedsec Pragma Suppress_All
3390 @findex Suppress_All
3391 @noindent
3392 Syntax:
3393
3394 @smallexample @c ada
3395 pragma Suppress_All;
3396 @end smallexample
3397
3398 @noindent
3399 This pragma can only appear immediately following a compilation
3400 unit.  The effect is to apply @code{Suppress (All_Checks)} to the unit
3401 which it follows.  This pragma is implemented for compatibility with DEC
3402 Ada 83 usage.  The use of pragma @code{Suppress (All_Checks)} as a normal
3403 configuration pragma is the preferred usage in GNAT@.
3404
3405 @node Pragma Suppress_Exception_Locations
3406 @unnumberedsec Pragma Suppress_Exception_Locations
3407 @findex Suppress_Exception_Locations
3408 @noindent
3409 Syntax:
3410
3411 @smallexample @c ada
3412 pragma Suppress_Exception_Locations;
3413 @end smallexample
3414
3415 @noindent
3416 In normal mode, a raise statement for an exception by default generates
3417 an exception message giving the file name and line number for the location
3418 of the raise. This is useful for debugging and logging purposes, but this
3419 entails extra space for the strings for the messages. The configuration
3420 pragma @code{Suppress_Exception_Locations} can be used to suppress the
3421 generation of these strings, with the result that space is saved, but the
3422 exception message for such raises is null. This configuration pragma may
3423 appear in a global configuration pragma file, or in a specific unit as
3424 usual. It is not required that this pragma be used consistently within
3425 a partition, so it is fine to have some units within a partition compiled
3426 with this pragma and others compiled in normal mode without it.
3427
3428 @node Pragma Suppress_Initialization
3429 @unnumberedsec Pragma Suppress_Initialization
3430 @findex Suppress_Initialization
3431 @cindex Suppressing initialization
3432 @cindex Initialization, suppression of
3433 @noindent
3434 Syntax:
3435
3436 @smallexample @c ada
3437 pragma Suppress_Initialization ([Entity =>] type_Name);
3438 @end smallexample
3439
3440 @noindent
3441 This pragma suppresses any implicit or explicit initialization
3442 associated with the given type name for all variables of this type.
3443
3444 @node Pragma Task_Info
3445 @unnumberedsec Pragma Task_Info
3446 @findex Task_Info
3447 @noindent
3448 Syntax
3449
3450 @smallexample @c ada
3451 pragma Task_Info (EXPRESSION);
3452 @end smallexample
3453
3454 @noindent
3455 This pragma appears within a task definition (like pragma
3456 @code{Priority}) and applies to the task in which it appears.  The
3457 argument must be of type @code{System.Task_Info.Task_Info_Type}.
3458 The @code{Task_Info} pragma provides system dependent control over
3459 aspects of tasking implementation, for example, the ability to map
3460 tasks to specific processors.  For details on the facilities available
3461 for the version of GNAT that you are using, see the documentation
3462 in the specification of package System.Task_Info in the runtime
3463 library.
3464
3465 @node Pragma Task_Name
3466 @unnumberedsec Pragma Task_Name
3467 @findex Task_Name
3468 @noindent
3469 Syntax
3470
3471 @smallexample @c ada
3472 pragma Task_Name (string_EXPRESSION);
3473 @end smallexample
3474
3475 @noindent
3476 This pragma appears within a task definition (like pragma
3477 @code{Priority}) and applies to the task in which it appears.  The
3478 argument must be of type String, and provides a name to be used for
3479 the task instance when the task is created.  Note that this expression
3480 is not required to be static, and in particular, it can contain
3481 references to task discriminants.  This facility can be used to
3482 provide different names for different tasks as they are created,
3483 as illustrated in the example below.
3484
3485 The task name is recorded internally in the run-time structures
3486 and is accessible to tools like the debugger.  In addition the
3487 routine @code{Ada.Task_Identification.Image} will return this
3488 string, with a unique task address appended.
3489
3490 @smallexample @c ada
3491 --  Example of the use of pragma Task_Name
3492
3493 with Ada.Task_Identification;
3494 use Ada.Task_Identification;
3495 with Text_IO; use Text_IO;
3496 procedure t3 is
3497
3498    type Astring is access String;
3499
3500    task type Task_Typ (Name : access String) is
3501       pragma Task_Name (Name.all);
3502    end Task_Typ;
3503
3504    task body Task_Typ is
3505       Nam : constant String := Image (Current_Task);
3506    begin
3507       Put_Line ("-->" & Nam (1 .. 14) & "<--");
3508    end Task_Typ;
3509
3510    type Ptr_Task is access Task_Typ;
3511    Task_Var : Ptr_Task;
3512
3513 begin
3514    Task_Var :=
3515      new Task_Typ (new String'("This is task 1"));
3516    Task_Var :=
3517      new Task_Typ (new String'("This is task 2"));
3518 end;
3519 @end smallexample
3520
3521 @node Pragma Task_Storage
3522 @unnumberedsec Pragma Task_Storage
3523 @findex Task_Storage
3524 Syntax:
3525
3526 @smallexample @c ada
3527 pragma Task_Storage (
3528   [Task_Type =>] LOCAL_NAME,
3529   [Top_Guard =>] static_integer_EXPRESSION);
3530 @end smallexample
3531
3532 @noindent
3533 This pragma specifies the length of the guard area for tasks.  The guard
3534 area is an additional storage area allocated to a task.  A value of zero
3535 means that either no guard area is created or a minimal guard area is
3536 created, depending on the target.  This pragma can appear anywhere a
3537 @code{Storage_Size} attribute definition clause is allowed for a task
3538 type.
3539
3540 @node Pragma Thread_Body
3541 @unnumberedsec Pragma Thread_Body
3542 @findex Thread_Body
3543 Syntax:
3544
3545 @smallexample @c ada
3546 pragma Thread_Body (
3547   [Entity =>] LOCAL_NAME,
3548  [[Secondary_Stack_Size =>] static_integer_EXPRESSION)];
3549 @end smallexample
3550
3551 @noindent
3552 This pragma specifies that the subprogram whose name is given as the
3553 @code{Entity} argument is a thread body, which will be activated
3554 by being called via its Address from foreign code. The purpose is
3555 to allow execution and registration of the foreign thread within the
3556 Ada run-time system.
3557
3558 See the library unit @code{System.Threads} for details on the expansion of
3559 a thread body subprogram, including the calls made to subprograms
3560 within System.Threads to register the task.  This unit also lists the
3561 targets and runtime systems for which this pragma is supported.
3562
3563 A thread body subprogram may not be called directly from Ada code, and
3564 it is not permitted to apply the Access (or Unrestricted_Access) attributes
3565 to such a subprogram. The only legitimate way of calling such a subprogram
3566 is to pass its Address to foreign code and then make the call from the
3567 foreign code.
3568
3569 A thread body subprogram may have any parameters, and it may be a function
3570 returning a result. The convention of the thread body subprogram may be
3571 set in the usual manner using @code{pragma Convention}.
3572
3573 The secondary stack size parameter, if given, is used to set the size
3574 of secondary stack for the thread. The secondary stack is allocated as
3575 a local variable of the expanded thread body subprogram, and thus is
3576 allocated out of the main thread stack size. If no secondary stack
3577 size parameter is present, the default size (from the declaration in
3578 @code{System.Secondary_Stack} is used.
3579
3580 @node Pragma Time_Slice
3581 @unnumberedsec Pragma Time_Slice
3582 @findex Time_Slice
3583 @noindent
3584 Syntax:
3585
3586 @smallexample @c ada
3587 pragma Time_Slice (static_duration_EXPRESSION);
3588 @end smallexample
3589
3590 @noindent
3591 For implementations of GNAT on operating systems where it is possible
3592 to supply a time slice value, this pragma may be used for this purpose.
3593 It is ignored if it is used in a system that does not allow this control,
3594 or if it appears in other than the main program unit.
3595 @cindex OpenVMS
3596 Note that the effect of this pragma is identical to the effect of the
3597 DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
3598
3599 @node Pragma Title
3600 @unnumberedsec Pragma Title
3601 @findex Title
3602 @noindent
3603 Syntax:
3604
3605 @smallexample @c ada
3606 pragma Title (TITLING_OPTION [, TITLING OPTION]);
3607
3608 TITLING_OPTION ::=
3609   [Title    =>] STRING_LITERAL,
3610 | [Subtitle =>] STRING_LITERAL
3611 @end smallexample
3612
3613 @noindent
3614 Syntax checked but otherwise ignored by GNAT@.  This is a listing control
3615 pragma used in DEC Ada 83 implementations to provide a title and/or
3616 subtitle for the program listing.  The program listing generated by GNAT
3617 does not have titles or subtitles.
3618
3619 Unlike other pragmas, the full flexibility of named notation is allowed
3620 for this pragma, i.e.@: the parameters may be given in any order if named
3621 notation is used, and named and positional notation can be mixed
3622 following the normal rules for procedure calls in Ada.
3623
3624 @node Pragma Unchecked_Union
3625 @unnumberedsec Pragma Unchecked_Union
3626 @cindex Unions in C
3627 @findex Unchecked_Union
3628 @noindent
3629 Syntax:
3630
3631 @smallexample @c ada
3632 pragma Unchecked_Union (first_subtype_LOCAL_NAME);
3633 @end smallexample
3634
3635 @noindent
3636 This pragma is used to declare that the specified type should be represented
3637 in a manner
3638 equivalent to a C union type, and is intended only for use in
3639 interfacing with C code that uses union types.  In Ada terms, the named
3640 type must obey the following rules:
3641
3642 @itemize @bullet
3643 @item
3644 It is a non-tagged non-limited record type.
3645 @item
3646 It has a single discrete discriminant with a default value.
3647 @item
3648 The component list consists of a single variant part.
3649 @item
3650 Each variant has a component list with a single component.
3651 @item
3652 No nested variants are allowed.
3653 @item
3654 No component has an explicit default value.
3655 @item
3656 No component has a non-static constraint.
3657 @end itemize
3658
3659 @noindent
3660 In addition, given a type that meets the above requirements, the
3661 following restrictions apply to its use throughout the program:
3662
3663 @itemize @bullet
3664 @item
3665 The discriminant name can be mentioned only in an aggregate.
3666 @item
3667 No subtypes may be created of this type.
3668 @item
3669 The type may not be constrained by giving a discriminant value.
3670 @item
3671 The type cannot be passed as the actual for a generic formal with a
3672 discriminant.
3673 @end itemize
3674
3675 @noindent
3676 Equality and inequality operations on @code{unchecked_unions} are not
3677 available, since there is no discriminant to compare and the compiler
3678 does not even know how many bits to compare.  It is implementation
3679 dependent whether this is detected at compile time as an illegality or
3680 whether it is undetected and considered to be an erroneous construct.  In
3681 GNAT, a direct comparison is illegal, but GNAT does not attempt to catch
3682 the composite case (where two composites are compared that contain an
3683 unchecked union component), so such comparisons are simply considered
3684 erroneous.
3685
3686 The layout of the resulting type corresponds exactly to a C union, where
3687 each branch of the union corresponds to a single variant in the Ada
3688 record.  The semantics of the Ada program is not changed in any way by
3689 the pragma, i.e.@: provided the above restrictions are followed, and no
3690 erroneous incorrect references to fields or erroneous comparisons occur,
3691 the semantics is exactly as described by the Ada reference manual.
3692 Pragma @code{Suppress (Discriminant_Check)} applies implicitly to the
3693 type and the default convention is C.
3694
3695 @node Pragma Unimplemented_Unit
3696 @unnumberedsec Pragma Unimplemented_Unit
3697 @findex Unimplemented_Unit
3698 @noindent
3699 Syntax:
3700
3701 @smallexample @c ada
3702 pragma Unimplemented_Unit;
3703 @end smallexample
3704
3705 @noindent
3706 If this pragma occurs in a unit that is processed by the compiler, GNAT
3707 aborts with the message @samp{@var{xxx} not implemented}, where
3708 @var{xxx} is the name of the current compilation unit.  This pragma is
3709 intended to allow the compiler to handle unimplemented library units in
3710 a clean manner.
3711
3712 The abort only happens if code is being generated.  Thus you can use
3713 specs of unimplemented packages in syntax or semantic checking mode.
3714
3715 @node Pragma Universal_Data
3716 @unnumberedsec Pragma Universal_Data
3717 @findex Universal_Data
3718 @noindent
3719 Syntax:
3720
3721 @smallexample @c ada
3722 pragma Universal_Data [(library_unit_Name)];
3723 @end smallexample
3724
3725 @noindent
3726 This pragma is supported only for the AAMP target and is ignored for
3727 other targets. The pragma specifies that all library-level objects
3728 (Counter 0 data) associated with the library unit are to be accessed
3729 and updated using universal addressing (24-bit addresses for AAMP5)
3730 rather than the default of 16-bit Data Environment (DENV) addressing.
3731 Use of this pragma will generally result in less efficient code for
3732 references to global data associated with the library unit, but
3733 allows such data to be located anywhere in memory. This pragma is
3734 a library unit pragma, but can also be used as a configuration pragma
3735 (including use in the @file{gnat.adc} file). The functionality
3736 of this pragma is also available by applying the -univ switch on the
3737 compilations of units where universal addressing of the data is desired.
3738
3739 @node Pragma Unreferenced
3740 @unnumberedsec Pragma Unreferenced
3741 @findex Unreferenced
3742 @cindex Warnings, unreferenced
3743 @noindent
3744 Syntax:
3745
3746 @smallexample @c ada
3747 pragma Unreferenced (local_Name @{, local_Name@});
3748 @end smallexample
3749
3750 @noindent
3751 This pragma signals that the entities whose names are listed are
3752 deliberately not referenced in the current source unit. This
3753 suppresses warnings about the
3754 entities being unreferenced, and in addition a warning will be
3755 generated if one of these entities is in fact referenced in the
3756 same unit as the pragma (or in the corresponding body, or one
3757 of its subunits).
3758
3759 This is particularly useful for clearly signaling that a particular
3760 parameter is not referenced in some particular subprogram implementation
3761 and that this is deliberate. It can also be useful in the case of
3762 objects declared only for their initialization or finalization side
3763 effects.
3764
3765 If @code{local_Name} identifies more than one matching homonym in the
3766 current scope, then the entity most recently declared is the one to which
3767 the pragma applies.
3768
3769 The left hand side of an assignment does not count as a reference for the
3770 purpose of this pragma. Thus it is fine to assign to an entity for which
3771 pragma Unreferenced is given.
3772
3773 @node Pragma Unreserve_All_Interrupts
3774 @unnumberedsec Pragma Unreserve_All_Interrupts
3775 @findex Unreserve_All_Interrupts
3776 @noindent
3777 Syntax:
3778
3779 @smallexample @c ada
3780 pragma Unreserve_All_Interrupts;
3781 @end smallexample
3782
3783 @noindent
3784 Normally certain interrupts are reserved to the implementation.  Any attempt
3785 to attach an interrupt causes Program_Error to be raised, as described in
3786 RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
3787 many systems for a @kbd{Ctrl-C} interrupt.  Normally this interrupt is
3788 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
3789 interrupt execution.
3790
3791 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
3792 a program, then all such interrupts are unreserved.  This allows the
3793 program to handle these interrupts, but disables their standard
3794 functions.  For example, if this pragma is used, then pressing
3795 @kbd{Ctrl-C} will not automatically interrupt execution.  However,
3796 a program can then handle the @code{SIGINT} interrupt as it chooses.
3797
3798 For a full list of the interrupts handled in a specific implementation,
3799 see the source code for the specification of @code{Ada.Interrupts.Names} in
3800 file @file{a-intnam.ads}.  This is a target dependent file that contains the
3801 list of interrupts recognized for a given target.  The documentation in
3802 this file also specifies what interrupts are affected by the use of
3803 the @code{Unreserve_All_Interrupts} pragma.
3804
3805 For a more general facility for controlling what interrupts can be
3806 handled, see pragma @code{Interrupt_State}, which subsumes the functionality
3807 of the @code{Unreserve_All_Interrupts} pragma.
3808
3809 @node Pragma Unsuppress
3810 @unnumberedsec Pragma Unsuppress
3811 @findex Unsuppress
3812 @noindent
3813 Syntax:
3814
3815 @smallexample @c ada
3816 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
3817 @end smallexample
3818
3819 @noindent
3820 This pragma undoes the effect of a previous pragma @code{Suppress}.  If
3821 there is no corresponding pragma @code{Suppress} in effect, it has no
3822 effect.  The range of the effect is the same as for pragma
3823 @code{Suppress}.  The meaning of the arguments is identical to that used
3824 in pragma @code{Suppress}.
3825
3826 One important application is to ensure that checks are on in cases where
3827 code depends on the checks for its correct functioning, so that the code
3828 will compile correctly even if the compiler switches are set to suppress
3829 checks.
3830
3831 @node Pragma Use_VADS_Size
3832 @unnumberedsec Pragma Use_VADS_Size
3833 @cindex @code{Size}, VADS compatibility
3834 @findex Use_VADS_Size
3835 @noindent
3836 Syntax:
3837
3838 @smallexample @c ada
3839 pragma Use_VADS_Size;
3840 @end smallexample
3841
3842 @noindent
3843 This is a configuration pragma.  In a unit to which it applies, any use
3844 of the 'Size attribute is automatically interpreted as a use of the
3845 'VADS_Size attribute.  Note that this may result in incorrect semantic
3846 processing of valid Ada 95 programs.  This is intended to aid in the
3847 handling of legacy code which depends on the interpretation of Size
3848 as implemented in the VADS compiler.  See description of the VADS_Size
3849 attribute for further details.
3850
3851 @node Pragma Validity_Checks
3852 @unnumberedsec Pragma Validity_Checks
3853 @findex Validity_Checks
3854 @noindent
3855 Syntax:
3856
3857 @smallexample @c ada
3858 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
3859 @end smallexample
3860
3861 @noindent
3862 This pragma is used in conjunction with compiler switches to control the
3863 built-in validity checking provided by GNAT@.  The compiler switches, if set
3864 provide an initial setting for the switches, and this pragma may be used
3865 to modify these settings, or the settings may be provided entirely by
3866 the use of the pragma.  This pragma can be used anywhere that a pragma
3867 is legal, including use as a configuration pragma (including use in
3868 the @file{gnat.adc} file).
3869
3870 The form with a string literal specifies which validity options are to be
3871 activated.  The validity checks are first set to include only the default
3872 reference manual settings, and then a string of letters in the string
3873 specifies the exact set of options required.  The form of this string
3874 is exactly as described for the @code{-gnatVx} compiler switch (see the
3875 GNAT users guide for details).  For example the following two methods
3876 can be used to enable validity checking for mode @code{in} and
3877 @code{in out} subprogram parameters:
3878
3879 @itemize @bullet
3880 @item
3881 @smallexample @c ada
3882 pragma Validity_Checks ("im");
3883 @end smallexample
3884
3885 @item
3886 @smallexample
3887 gcc -c -gnatVim @dots{}
3888 @end smallexample
3889 @end itemize
3890
3891 @noindent
3892 The form ALL_CHECKS activates all standard checks (its use is equivalent
3893 to the use of the @code{gnatva} switch.
3894
3895 The forms with @code{Off} and @code{On}
3896 can be used to temporarily disable validity checks
3897 as shown in the following example:
3898
3899 @smallexample @c ada
3900 @iftex
3901 @leftskip=0cm
3902 @end iftex
3903 pragma Validity_Checks ("c"); -- validity checks for copies
3904 pragma Validity_Checks (Off); -- turn off validity checks
3905 A := B;                       -- B will not be validity checked
3906 pragma Validity_Checks (On);  -- turn validity checks back on
3907 A := C;                       -- C will be validity checked
3908 @end smallexample
3909
3910 @node Pragma Volatile
3911 @unnumberedsec Pragma Volatile
3912 @findex Volatile
3913 @noindent
3914 Syntax:
3915
3916 @smallexample @c ada
3917 pragma Volatile (local_NAME);
3918 @end smallexample
3919
3920 @noindent
3921 This pragma is defined by the Ada 95 Reference Manual, and the GNAT
3922 implementation is fully conformant with this definition.  The reason it
3923 is mentioned in this section is that a pragma of the same name was supplied
3924 in some Ada 83 compilers, including DEC Ada 83.  The Ada 95 implementation
3925 of pragma Volatile is upwards compatible with the implementation in
3926 Dec Ada 83.
3927
3928 @node Pragma Warnings
3929 @unnumberedsec Pragma Warnings
3930 @findex Warnings
3931 @noindent
3932 Syntax:
3933
3934 @smallexample @c ada
3935 pragma Warnings (On | Off [, LOCAL_NAME]);
3936 @end smallexample
3937
3938 @noindent
3939 Normally warnings are enabled, with the output being controlled by
3940 the command line switch.  Warnings (@code{Off}) turns off generation of
3941 warnings until a Warnings (@code{On}) is encountered or the end of the
3942 current unit.  If generation of warnings is turned off using this
3943 pragma, then no warning messages are output, regardless of the
3944 setting of the command line switches.
3945
3946 The form with a single argument is a configuration pragma.
3947
3948 If the @var{local_name} parameter is present, warnings are suppressed for
3949 the specified entity.  This suppression is effective from the point where
3950 it occurs till the end of the extended scope of the variable (similar to
3951 the scope of @code{Suppress}).
3952
3953 @node Pragma Weak_External
3954 @unnumberedsec Pragma Weak_External
3955 @findex Weak_External
3956 @noindent
3957 Syntax:
3958
3959 @smallexample @c ada
3960 pragma Weak_External ([Entity =>] LOCAL_NAME);
3961 @end smallexample
3962
3963 @noindent
3964 This pragma specifies that the given entity should be marked as a weak
3965 external (one that does not have to be resolved) for the linker.  For
3966 further details, consult the GCC manual.
3967
3968 @node Implementation Defined Attributes
3969 @chapter Implementation Defined Attributes
3970 Ada 95 defines (throughout the Ada 95 reference manual,
3971 summarized in annex K),
3972 a set of attributes that provide useful additional functionality in all
3973 areas of the language.  These language defined attributes are implemented
3974 in GNAT and work as described in the Ada 95 Reference Manual.
3975
3976 In addition, Ada 95 allows implementations to define additional
3977 attributes whose meaning is defined by the implementation.  GNAT provides
3978 a number of these implementation-dependent attributes which can be used
3979 to extend and enhance the functionality of the compiler.  This section of
3980 the GNAT reference manual describes these additional attributes.
3981
3982 Note that any program using these attributes may not be portable to
3983 other compilers (although GNAT implements this set of attributes on all
3984 platforms).  Therefore if portability to other compilers is an important
3985 consideration, you should minimize the use of these attributes.
3986
3987 @menu
3988 * Abort_Signal::
3989 * Address_Size::
3990 * Asm_Input::
3991 * Asm_Output::
3992 * AST_Entry::
3993 * Bit::
3994 * Bit_Position::
3995 * Code_Address::
3996 * Default_Bit_Order::
3997 * Elaborated::
3998 * Elab_Body::
3999 * Elab_Spec::
4000 * Emax::
4001 * Enum_Rep::
4002 * Epsilon::
4003 * Fixed_Value::
4004 * Has_Access_Values::
4005 * Has_Discriminants::
4006 * Img::
4007 * Integer_Value::
4008 * Large::
4009 * Machine_Size::
4010 * Mantissa::
4011 * Max_Interrupt_Priority::
4012 * Max_Priority::
4013 * Maximum_Alignment::
4014 * Mechanism_Code::
4015 * Null_Parameter::
4016 * Object_Size::
4017 * Passed_By_Reference::
4018 * Range_Length::
4019 * Safe_Emax::
4020 * Safe_Large::
4021 * Small::
4022 * Storage_Unit::
4023 * Target_Name::
4024 * Tick::
4025 * To_Address::
4026 * Type_Class::
4027 * UET_Address::
4028 * Unconstrained_Array::
4029 * Universal_Literal_String::
4030 * Unrestricted_Access::
4031 * VADS_Size::
4032 * Value_Size::
4033 * Wchar_T_Size::
4034 * Word_Size::
4035 @end menu
4036
4037 @node Abort_Signal
4038 @unnumberedsec Abort_Signal
4039 @findex Abort_Signal
4040 @noindent
4041 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
4042 prefix) provides the entity for the special exception used to signal
4043 task abort or asynchronous transfer of control.  Normally this attribute
4044 should only be used in the tasking runtime (it is highly peculiar, and
4045 completely outside the normal semantics of Ada, for a user program to
4046 intercept the abort exception).
4047
4048 @node Address_Size
4049 @unnumberedsec Address_Size
4050 @cindex Size of @code{Address}
4051 @findex Address_Size
4052 @noindent
4053 @code{Standard'Address_Size} (@code{Standard} is the only allowed
4054 prefix) is a static constant giving the number of bits in an
4055 @code{Address}. It is the same value as System.Address'Size,
4056 but has the advantage of being static, while a direct
4057 reference to System.Address'Size is non-static because Address
4058 is a private type.
4059
4060 @node Asm_Input
4061 @unnumberedsec Asm_Input
4062 @findex Asm_Input
4063 @noindent
4064 The @code{Asm_Input} attribute denotes a function that takes two
4065 parameters.  The first is a string, the second is an expression of the
4066 type designated by the prefix.  The first (string) argument is required
4067 to be a static expression, and is the constraint for the parameter,
4068 (e.g.@: what kind of register is required).  The second argument is the
4069 value to be used as the input argument.  The possible values for the
4070 constant are the same as those used in the RTL, and are dependent on
4071 the configuration file used to built the GCC back end.
4072 @ref{Machine Code Insertions}
4073
4074 @node Asm_Output
4075 @unnumberedsec Asm_Output
4076 @findex Asm_Output
4077 @noindent
4078 The @code{Asm_Output} attribute denotes a function that takes two
4079 parameters.  The first is a string, the second is the name of a variable
4080 of the type designated by the attribute prefix.  The first (string)
4081 argument is required to be a static expression and designates the
4082 constraint for the parameter (e.g.@: what kind of register is
4083 required).  The second argument is the variable to be updated with the
4084 result.  The possible values for constraint are the same as those used in
4085 the RTL, and are dependent on the configuration file used to build the
4086 GCC back end.  If there are no output operands, then this argument may
4087 either be omitted, or explicitly given as @code{No_Output_Operands}.
4088 @ref{Machine Code Insertions}
4089
4090 @node AST_Entry
4091 @unnumberedsec AST_Entry
4092 @cindex OpenVMS
4093 @findex AST_Entry
4094 @noindent
4095 This attribute is implemented only in OpenVMS versions of GNAT@.  Applied to
4096 the name of an entry, it yields a value of the predefined type AST_Handler
4097 (declared in the predefined package System, as extended by the use of
4098 pragma @code{Extend_System (Aux_DEC)}).  This value enables the given entry to
4099 be called when an AST occurs.  For further details, refer to the @cite{DEC Ada
4100 Language Reference Manual}, section 9.12a.
4101
4102 @node Bit
4103 @unnumberedsec Bit
4104 @findex Bit
4105 @code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
4106 offset within the storage unit (byte) that contains the first bit of
4107 storage allocated for the object.  The value of this attribute is of the
4108 type @code{Universal_Integer}, and is always a non-negative number not
4109 exceeding the value of @code{System.Storage_Unit}.
4110
4111 For an object that is a variable or a constant allocated in a register,
4112 the value is zero.  (The use of this attribute does not force the
4113 allocation of a variable to memory).
4114
4115 For an object that is a formal parameter, this attribute applies
4116 to either the matching actual parameter or to a copy of the
4117 matching actual parameter.
4118
4119 For an access object the value is zero.  Note that
4120 @code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
4121 designated object.  Similarly for a record component
4122 @code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
4123 @code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
4124 are subject to index checks.
4125
4126 This attribute is designed to be compatible with the DEC Ada 83 definition
4127 and implementation of the @code{Bit} attribute.
4128
4129 @node Bit_Position
4130 @unnumberedsec Bit_Position
4131 @findex Bit_Position
4132 @noindent
4133 @code{@var{R.C}'Bit}, where @var{R} is a record object and C is one
4134 of the fields of the record type, yields the bit
4135 offset within the record contains the first bit of
4136 storage allocated for the object.  The value of this attribute is of the
4137 type @code{Universal_Integer}.  The value depends only on the field
4138 @var{C} and is independent of the alignment of
4139 the containing record @var{R}.
4140
4141 @node Code_Address
4142 @unnumberedsec Code_Address
4143 @findex Code_Address
4144 @cindex Subprogram address
4145 @cindex Address of subprogram code
4146 @noindent
4147 The @code{'Address}
4148 attribute may be applied to subprograms in Ada 95, but the
4149 intended effect from the Ada 95 reference manual seems to be to provide
4150 an address value which can be used to call the subprogram by means of
4151 an address clause as in the following example:
4152
4153 @smallexample @c ada
4154 procedure K is @dots{}
4155
4156 procedure L;
4157 for L'Address use K'Address;
4158 pragma Import (Ada, L);
4159 @end smallexample
4160
4161 @noindent
4162 A call to @code{L} is then expected to result in a call to @code{K}@.
4163 In Ada 83, where there were no access-to-subprogram values, this was
4164 a common work around for getting the effect of an indirect call.
4165 GNAT implements the above use of @code{Address} and the technique
4166 illustrated by the example code works correctly.
4167
4168 However, for some purposes, it is useful to have the address of the start
4169 of the generated code for the subprogram.  On some architectures, this is
4170 not necessarily the same as the @code{Address} value described above.
4171 For example, the @code{Address} value may reference a subprogram
4172 descriptor rather than the subprogram itself.
4173
4174 The @code{'Code_Address} attribute, which can only be applied to
4175 subprogram entities, always returns the address of the start of the
4176 generated code of the specified subprogram, which may or may not be
4177 the same value as is returned by the corresponding @code{'Address}
4178 attribute.
4179
4180 @node Default_Bit_Order
4181 @unnumberedsec Default_Bit_Order
4182 @cindex Big endian
4183 @cindex Little endian
4184 @findex Default_Bit_Order
4185 @noindent
4186 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
4187 permissible prefix), provides the value @code{System.Default_Bit_Order}
4188 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
4189 @code{Low_Order_First}).  This is used to construct the definition of
4190 @code{Default_Bit_Order} in package @code{System}.
4191
4192 @node Elaborated
4193 @unnumberedsec Elaborated
4194 @findex Elaborated
4195 @noindent
4196 The prefix of the @code{'Elaborated} attribute must be a unit name.  The
4197 value is a Boolean which indicates whether or not the given unit has been
4198 elaborated.  This attribute is primarily intended for internal use by the
4199 generated code for dynamic elaboration checking, but it can also be used
4200 in user programs.  The value will always be True once elaboration of all
4201 units has been completed.  An exception is for units which need no
4202 elaboration, the value is always False for such units.
4203
4204 @node Elab_Body
4205 @unnumberedsec Elab_Body
4206 @findex Elab_Body
4207 @noindent
4208 This attribute can only be applied to a program unit name.  It returns
4209 the entity for the corresponding elaboration procedure for elaborating
4210 the body of the referenced unit.  This is used in the main generated
4211 elaboration procedure by the binder and is not normally used in any
4212 other context.  However, there may be specialized situations in which it
4213 is useful to be able to call this elaboration procedure from Ada code,
4214 e.g.@: if it is necessary to do selective re-elaboration to fix some
4215 error.
4216
4217 @node Elab_Spec
4218 @unnumberedsec Elab_Spec
4219 @findex Elab_Spec
4220 @noindent
4221 This attribute can only be applied to a program unit name.  It returns
4222 the entity for the corresponding elaboration procedure for elaborating
4223 the specification of the referenced unit.  This is used in the main
4224 generated elaboration procedure by the binder and is not normally used
4225 in any other context.  However, there may be specialized situations in
4226 which it is useful to be able to call this elaboration procedure from
4227 Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
4228 some error.
4229
4230 @node Emax
4231 @unnumberedsec Emax
4232 @cindex Ada 83 attributes
4233 @findex Emax
4234 @noindent
4235 The @code{Emax} attribute is provided for compatibility with Ada 83.  See
4236 the Ada 83 reference manual for an exact description of the semantics of
4237 this attribute.
4238
4239 @node Enum_Rep
4240 @unnumberedsec Enum_Rep
4241 @cindex Representation of enums
4242 @findex Enum_Rep
4243 @noindent
4244 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
4245 function with the following spec:
4246
4247 @smallexample @c ada
4248 function @var{S}'Enum_Rep (Arg : @var{S}'Base)
4249   return @i{Universal_Integer};
4250 @end smallexample
4251
4252 @noindent
4253 It is also allowable to apply @code{Enum_Rep} directly to an object of an
4254 enumeration type or to a non-overloaded enumeration
4255 literal.  In this case @code{@var{S}'Enum_Rep} is equivalent to
4256 @code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
4257 enumeration literal or object.
4258
4259 The function returns the representation value for the given enumeration
4260 value.  This will be equal to value of the @code{Pos} attribute in the
4261 absence of an enumeration representation clause.  This is a static
4262 attribute (i.e.@: the result is static if the argument is static).
4263
4264 @code{@var{S}'Enum_Rep} can also be used with integer types and objects,
4265 in which case it simply returns the integer value.  The reason for this
4266 is to allow it to be used for @code{(<>)} discrete formal arguments in
4267 a generic unit that can be instantiated with either enumeration types
4268 or integer types.  Note that if @code{Enum_Rep} is used on a modular
4269 type whose upper bound exceeds the upper bound of the largest signed
4270 integer type, and the argument is a variable, so that the universal
4271 integer calculation is done at run-time, then the call to @code{Enum_Rep}
4272 may raise @code{Constraint_Error}.
4273
4274 @node Epsilon
4275 @unnumberedsec Epsilon
4276 @cindex Ada 83 attributes
4277 @findex Epsilon
4278 @noindent
4279 The @code{Epsilon} attribute is provided for compatibility with Ada 83.  See
4280 the Ada 83 reference manual for an exact description of the semantics of
4281 this attribute.
4282
4283 @node Fixed_Value
4284 @unnumberedsec Fixed_Value
4285 @findex Fixed_Value
4286 @noindent
4287 For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
4288 function with the following specification:
4289
4290 @smallexample @c ada
4291 function @var{S}'Fixed_Value (Arg : @i{Universal_Integer})
4292   return @var{S};
4293 @end smallexample
4294
4295 @noindent
4296 The value returned is the fixed-point value @var{V} such that
4297
4298 @smallexample @c ada
4299 @var{V} = Arg * @var{S}'Small
4300 @end smallexample
4301
4302 @noindent
4303 The effect is thus similar to first converting the argument to the
4304 integer type used to represent @var{S}, and then doing an unchecked
4305 conversion to the fixed-point type.  The difference is
4306 that there are full range checks, to ensure that the result is in range.
4307 This attribute is primarily intended for use in implementation of the
4308 input-output functions for fixed-point values.
4309
4310 @node Has_Access_Values
4311 @unnumberedsec Has_Access_Values
4312 @cindex Access values, testing for
4313 @findex Has_Access_Values
4314 @noindent
4315 The prefix of the @code{Has_Access_Values} attribute is a type.  The result
4316 is a Boolean value which is True if the is an access type, or is a composite
4317 type with a component (at any nesting depth) that is an access type, and is
4318 False otherwise.
4319 The intended use of this attribute is in conjunction with generic
4320 definitions.  If the attribute is applied to a generic private type, it
4321 indicates whether or not the corresponding actual type has access values.
4322
4323 @node Has_Discriminants
4324 @unnumberedsec Has_Discriminants
4325 @cindex Discriminants, testing for
4326 @findex Has_Discriminants
4327 @noindent
4328 The prefix of the @code{Has_Discriminants} attribute is a type.  The result
4329 is a Boolean value which is True if the type has discriminants, and False
4330 otherwise.  The intended use of this attribute is in conjunction with generic
4331 definitions.  If the attribute is applied to a generic private type, it
4332 indicates whether or not the corresponding actual type has discriminants.
4333
4334 @node Img
4335 @unnumberedsec Img
4336 @findex Img
4337 @noindent
4338 The @code{Img} attribute differs from @code{Image} in that it may be
4339 applied to objects as well as types, in which case it gives the
4340 @code{Image} for the subtype of the object.  This is convenient for
4341 debugging:
4342
4343 @smallexample @c ada
4344 Put_Line ("X = " & X'Img);
4345 @end smallexample
4346
4347 @noindent
4348 has the same meaning as the more verbose:
4349
4350 @smallexample @c ada
4351 Put_Line ("X = " & @var{T}'Image (X));
4352 @end smallexample
4353
4354 @noindent
4355 where @var{T} is the (sub)type of the object @code{X}.
4356
4357 @node Integer_Value
4358 @unnumberedsec Integer_Value
4359 @findex Integer_Value
4360 @noindent
4361 For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
4362 function with the following spec:
4363
4364 @smallexample @c ada
4365 function @var{S}'Integer_Value (Arg : @i{Universal_Fixed})
4366   return @var{S};
4367 @end smallexample
4368
4369 @noindent
4370 The value returned is the integer value @var{V}, such that
4371
4372 @smallexample @c ada
4373 Arg = @var{V} * @var{T}'Small
4374 @end smallexample
4375
4376 @noindent
4377 where @var{T} is the type of @code{Arg}.
4378 The effect is thus similar to first doing an unchecked conversion from
4379 the fixed-point type to its corresponding implementation type, and then
4380 converting the result to the target integer type.  The difference is
4381 that there are full range checks, to ensure that the result is in range.
4382 This attribute is primarily intended for use in implementation of the
4383 standard input-output functions for fixed-point values.
4384
4385 @node Large
4386 @unnumberedsec Large
4387 @cindex Ada 83 attributes
4388 @findex Large
4389 @noindent
4390 The @code{Large} attribute is provided for compatibility with Ada 83.  See
4391 the Ada 83 reference manual for an exact description of the semantics of
4392 this attribute.
4393
4394 @node Machine_Size
4395 @unnumberedsec Machine_Size
4396 @findex Machine_Size
4397 @noindent
4398 This attribute is identical to the @code{Object_Size} attribute.  It is
4399 provided for compatibility with the DEC Ada 83 attribute of this name.
4400
4401 @node Mantissa
4402 @unnumberedsec Mantissa
4403 @cindex Ada 83 attributes
4404 @findex Mantissa
4405 @noindent
4406 The @code{Mantissa} attribute is provided for compatibility with Ada 83.  See
4407 the Ada 83 reference manual for an exact description of the semantics of
4408 this attribute.
4409
4410 @node Max_Interrupt_Priority
4411 @unnumberedsec Max_Interrupt_Priority
4412 @cindex Interrupt priority, maximum
4413 @findex Max_Interrupt_Priority
4414 @noindent
4415 @code{Standard'Max_Interrupt_Priority} (@code{Standard} is the only
4416 permissible prefix), provides the same value as
4417 @code{System.Max_Interrupt_Priority}.
4418
4419 @node Max_Priority
4420 @unnumberedsec Max_Priority
4421 @cindex Priority, maximum
4422 @findex Max_Priority
4423 @noindent
4424 @code{Standard'Max_Priority} (@code{Standard} is the only permissible
4425 prefix) provides the same value as @code{System.Max_Priority}.
4426
4427 @node Maximum_Alignment
4428 @unnumberedsec Maximum_Alignment
4429 @cindex Alignment, maximum
4430 @findex Maximum_Alignment
4431 @noindent
4432 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
4433 permissible prefix) provides the maximum useful alignment value for the
4434 target.  This is a static value that can be used to specify the alignment
4435 for an object, guaranteeing that it is properly aligned in all
4436 cases.
4437
4438 @node Mechanism_Code
4439 @unnumberedsec Mechanism_Code
4440 @cindex Return values, passing mechanism
4441 @cindex Parameters, passing mechanism
4442 @findex Mechanism_Code
4443 @noindent
4444 @code{@var{function}'Mechanism_Code} yields an integer code for the
4445 mechanism used for the result of function, and
4446 @code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
4447 used for formal parameter number @var{n} (a static integer value with 1
4448 meaning the first parameter) of @var{subprogram}.  The code returned is:
4449
4450 @table @asis
4451 @item 1
4452 by copy (value)
4453 @item 2
4454 by reference
4455 @item 3
4456 by descriptor (default descriptor class)
4457 @item 4
4458 by descriptor (UBS: unaligned bit string)
4459 @item 5
4460 by descriptor (UBSB: aligned bit string with arbitrary bounds)
4461 @item 6
4462 by descriptor (UBA: unaligned bit array)
4463 @item 7
4464 by descriptor (S: string, also scalar access type parameter)
4465 @item 8
4466 by descriptor (SB: string with arbitrary bounds)
4467 @item 9
4468 by descriptor (A: contiguous array)
4469 @item 10
4470 by descriptor (NCA: non-contiguous array)
4471 @end table
4472
4473 @noindent
4474 Values from 3 through 10 are only relevant to Digital OpenVMS implementations.
4475 @cindex OpenVMS
4476
4477 @node Null_Parameter
4478 @unnumberedsec Null_Parameter
4479 @cindex Zero address, passing
4480 @findex Null_Parameter
4481 @noindent
4482 A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
4483 type or subtype @var{T} allocated at machine address zero.  The attribute
4484 is allowed only as the default expression of a formal parameter, or as
4485 an actual expression of a subprogram call.  In either case, the
4486 subprogram must be imported.
4487
4488 The identity of the object is represented by the address zero in the
4489 argument list, independent of the passing mechanism (explicit or
4490 default).
4491
4492 This capability is needed to specify that a zero address should be
4493 passed for a record or other composite object passed by reference.
4494 There is no way of indicating this without the @code{Null_Parameter}
4495 attribute.
4496
4497 @node Object_Size
4498 @unnumberedsec Object_Size
4499 @cindex Size, used for objects
4500 @findex Object_Size
4501 @noindent
4502 The size of an object is not necessarily the same as the size of the type
4503 of an object.  This is because by default object sizes are increased to be
4504 a multiple of the alignment of the object.  For example,
4505 @code{Natural'Size} is
4506 31, but by default objects of type @code{Natural} will have a size of 32 bits.
4507 Similarly, a record containing an integer and a character:
4508
4509 @smallexample @c ada
4510 type Rec is record
4511    I : Integer;
4512    C : Character;
4513 end record;
4514 @end smallexample
4515
4516 @noindent
4517 will have a size of 40 (that is @code{Rec'Size} will be 40.  The
4518 alignment will be 4, because of the
4519 integer field, and so the default size of record objects for this type
4520 will be 64 (8 bytes).
4521
4522 The @code{@var{type}'Object_Size} attribute
4523 has been added to GNAT to allow the
4524 default object size of a type to be easily determined.  For example,
4525 @code{Natural'Object_Size} is 32, and
4526 @code{Rec'Object_Size} (for the record type in the above example) will be
4527 64.  Note also that, unlike the situation with the
4528 @code{Size} attribute as defined in the Ada RM, the
4529 @code{Object_Size} attribute can be specified individually
4530 for different subtypes.  For example:
4531
4532 @smallexample @c ada
4533 type R is new Integer;
4534 subtype R1 is R range 1 .. 10;
4535 subtype R2 is R range 1 .. 10;
4536 for R2'Object_Size use 8;
4537 @end smallexample
4538
4539 @noindent
4540 In this example, @code{R'Object_Size} and @code{R1'Object_Size} are both
4541 32 since the default object size for a subtype is the same as the object size
4542 for the parent subtype.  This means that objects of type @code{R}
4543 or @code{R1} will
4544 by default be 32 bits (four bytes).  But objects of type
4545 @code{R2} will be only
4546 8 bits (one byte), since @code{R2'Object_Size} has been set to 8.
4547
4548 @node Passed_By_Reference
4549 @unnumberedsec Passed_By_Reference
4550 @cindex Parameters, when passed by reference
4551 @findex Passed_By_Reference
4552 @noindent
4553 @code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
4554 a value of type @code{Boolean} value that is @code{True} if the type is
4555 normally passed by reference and @code{False} if the type is normally
4556 passed by copy in calls.  For scalar types, the result is always @code{False}
4557 and is static.  For non-scalar types, the result is non-static.
4558
4559 @node Range_Length
4560 @unnumberedsec Range_Length
4561 @findex Range_Length
4562 @noindent
4563 @code{@var{type}'Range_Length} for any discrete type @var{type} yields
4564 the number of values represented by the subtype (zero for a null
4565 range).  The result is static for static subtypes.  @code{Range_Length}
4566 applied to the index subtype of a one dimensional array always gives the
4567 same result as @code{Range} applied to the array itself.
4568
4569 @node Safe_Emax
4570 @unnumberedsec Safe_Emax
4571 @cindex Ada 83 attributes
4572 @findex Safe_Emax
4573 @noindent
4574 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83.  See
4575 the Ada 83 reference manual for an exact description of the semantics of
4576 this attribute.
4577
4578 @node Safe_Large
4579 @unnumberedsec Safe_Large
4580 @cindex Ada 83 attributes
4581 @findex Safe_Large
4582 @noindent
4583 The @code{Safe_Large} attribute is provided for compatibility with Ada 83.  See
4584 the Ada 83 reference manual for an exact description of the semantics of
4585 this attribute.
4586
4587 @node Small
4588 @unnumberedsec Small
4589 @cindex Ada 83 attributes
4590 @findex Small
4591 @noindent
4592 The @code{Small} attribute is defined in Ada 95 only for fixed-point types.
4593 GNAT also allows this attribute to be applied to floating-point types
4594 for compatibility with Ada 83.  See
4595 the Ada 83 reference manual for an exact description of the semantics of
4596 this attribute when applied to floating-point types.
4597
4598 @node Storage_Unit
4599 @unnumberedsec Storage_Unit
4600 @findex Storage_Unit
4601 @noindent
4602 @code{Standard'Storage_Unit} (@code{Standard} is the only permissible
4603 prefix) provides the same value as @code{System.Storage_Unit}.
4604
4605 @node Target_Name
4606 @unnumberedsec Target_Name
4607 @findex Target_Name
4608 @noindent
4609 @code{Standard'Target_Name} (@code{Standard} is the only permissible
4610 prefix) provides a static string value that identifies the target
4611 for the current compilation. For GCC implementations, this is the
4612 standard gcc target name without the terminating slash (for
4613 example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
4614
4615 @node Tick
4616 @unnumberedsec Tick
4617 @findex Tick
4618 @noindent
4619 @code{Standard'Tick} (@code{Standard} is the only permissible prefix)
4620 provides the same value as @code{System.Tick},
4621
4622 @node To_Address
4623 @unnumberedsec To_Address
4624 @findex To_Address
4625 @noindent
4626 The @code{System'To_Address}
4627 (@code{System} is the only permissible prefix)
4628 denotes a function identical to
4629 @code{System.Storage_Elements.To_Address} except that
4630 it is a static attribute.  This means that if its argument is
4631 a static expression, then the result of the attribute is a
4632 static expression.  The result is that such an expression can be
4633 used in contexts (e.g.@: preelaborable packages) which require a
4634 static expression and where the function call could not be used
4635 (since the function call is always non-static, even if its
4636 argument is static).
4637
4638 @node Type_Class
4639 @unnumberedsec Type_Class
4640 @findex Type_Class
4641 @noindent
4642 @code{@var{type}'Type_Class} for any type or subtype @var{type} yields
4643 the value of the type class for the full type of @var{type}.  If
4644 @var{type} is a generic formal type, the value is the value for the
4645 corresponding actual subtype.  The value of this attribute is of type
4646 @code{System.Aux_DEC.Type_Class}, which has the following definition:
4647
4648 @smallexample @c ada
4649   type Type_Class is
4650     (Type_Class_Enumeration,
4651      Type_Class_Integer,
4652      Type_Class_Fixed_Point,
4653      Type_Class_Floating_Point,
4654      Type_Class_Array,
4655      Type_Class_Record,
4656      Type_Class_Access,
4657      Type_Class_Task,
4658      Type_Class_Address);
4659 @end smallexample
4660
4661 @noindent
4662 Protected types yield the value @code{Type_Class_Task}, which thus
4663 applies to all concurrent types.  This attribute is designed to
4664 be compatible with the DEC Ada 83 attribute of the same name.
4665
4666 @node UET_Address
4667 @unnumberedsec UET_Address
4668 @findex UET_Address
4669 @noindent
4670 The @code{UET_Address} attribute can only be used for a prefix which
4671 denotes a library package.  It yields the address of the unit exception
4672 table when zero cost exception handling is used.  This attribute is
4673 intended only for use within the GNAT implementation.  See the unit
4674 @code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb}
4675 for details on how this attribute is used in the implementation.
4676
4677 @node Unconstrained_Array
4678 @unnumberedsec Unconstrained_Array
4679 @findex Unconstrained_Array
4680 @noindent
4681 The @code{Unconstrained_Array} attribute can be used with a prefix that
4682 denotes any type or subtype. It is a static attribute that yields
4683 @code{True} if the prefix designates an unconstrained array,
4684 and @code{False} otherwise. In a generic instance, the result is
4685 still static, and yields the result of applying this test to the
4686 generic actual.
4687
4688 @node Universal_Literal_String
4689 @unnumberedsec Universal_Literal_String
4690 @cindex Named numbers, representation of
4691 @findex Universal_Literal_String
4692 @noindent
4693 The prefix of @code{Universal_Literal_String} must be a named
4694 number.  The static result is the string consisting of the characters of
4695 the number as defined in the original source.  This allows the user
4696 program to access the actual text of named numbers without intermediate
4697 conversions and without the need to enclose the strings in quotes (which
4698 would preclude their use as numbers).  This is used internally for the
4699 construction of values of the floating-point attributes from the file
4700 @file{ttypef.ads}, but may also be used by user programs.
4701
4702 @node Unrestricted_Access
4703 @unnumberedsec Unrestricted_Access
4704 @cindex @code{Access}, unrestricted
4705 @findex Unrestricted_Access
4706 @noindent
4707 The @code{Unrestricted_Access} attribute is similar to @code{Access}
4708 except that all accessibility and aliased view checks are omitted.  This
4709 is a user-beware attribute.  It is similar to
4710 @code{Address}, for which it is a desirable replacement where the value
4711 desired is an access type.  In other words, its effect is identical to
4712 first applying the @code{Address} attribute and then doing an unchecked
4713 conversion to a desired access type.  In GNAT, but not necessarily in
4714 other implementations, the use of static chains for inner level
4715 subprograms means that @code{Unrestricted_Access} applied to a
4716 subprogram yields a value that can be called as long as the subprogram
4717 is in scope (normal Ada 95 accessibility rules restrict this usage).
4718
4719 It is possible to use @code{Unrestricted_Access} for any type, but care
4720 must be excercised if it is used to create pointers to unconstrained
4721 objects. In this case, the resulting pointer has the same scope as the
4722 context of the attribute, and may not be returned to some enclosing
4723 scope. For instance, a function cannot use @code{Unrestricted_Access}
4724 to create a unconstrained pointer and then return that value to the
4725 caller.
4726
4727 @node VADS_Size
4728 @unnumberedsec VADS_Size
4729 @cindex @code{Size}, VADS compatibility
4730 @findex VADS_Size
4731 @noindent
4732 The @code{'VADS_Size} attribute is intended to make it easier to port
4733 legacy code which relies on the semantics of @code{'Size} as implemented
4734 by the VADS Ada 83 compiler.  GNAT makes a best effort at duplicating the
4735 same semantic interpretation.  In particular, @code{'VADS_Size} applied
4736 to a predefined or other primitive type with no Size clause yields the
4737 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
4738 typical machines).  In addition @code{'VADS_Size} applied to an object
4739 gives the result that would be obtained by applying the attribute to
4740 the corresponding type.
4741
4742 @node Value_Size
4743 @unnumberedsec Value_Size
4744 @cindex @code{Size}, setting for not-first subtype
4745 @findex Value_Size
4746 @code{@var{type}'Value_Size} is the number of bits required to represent
4747 a value of the given subtype.  It is the same as @code{@var{type}'Size},
4748 but, unlike @code{Size}, may be set for non-first subtypes.
4749
4750 @node Wchar_T_Size
4751 @unnumberedsec Wchar_T_Size
4752 @findex Wchar_T_Size
4753 @code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
4754 prefix) provides the size in bits of the C @code{wchar_t} type
4755 primarily for constructing the definition of this type in
4756 package @code{Interfaces.C}.
4757
4758 @node Word_Size
4759 @unnumberedsec Word_Size
4760 @findex Word_Size
4761 @code{Standard'Word_Size} (@code{Standard} is the only permissible
4762 prefix) provides the value @code{System.Word_Size}.
4763
4764 @c ------------------------
4765 @node Implementation Advice
4766 @chapter Implementation Advice
4767 @noindent
4768 The main text of the Ada 95 Reference Manual describes the required
4769 behavior of all Ada 95 compilers, and the GNAT compiler conforms to
4770 these requirements.
4771
4772 In addition, there are sections throughout the Ada 95
4773 reference manual headed
4774 by the phrase ``implementation advice''.  These sections are not normative,
4775 i.e.@: they do not specify requirements that all compilers must
4776 follow.  Rather they provide advice on generally desirable behavior.  You
4777 may wonder why they are not requirements.  The most typical answer is
4778 that they describe behavior that seems generally desirable, but cannot
4779 be provided on all systems, or which may be undesirable on some systems.
4780
4781 As far as practical, GNAT follows the implementation advice sections in
4782 the Ada 95 Reference Manual.  This chapter contains a table giving the
4783 reference manual section number, paragraph number and several keywords
4784 for each advice.  Each entry consists of the text of the advice followed
4785 by the GNAT interpretation of this advice.  Most often, this simply says
4786 ``followed'', which means that GNAT follows the advice.  However, in a
4787 number of cases, GNAT deliberately deviates from this advice, in which
4788 case the text describes what GNAT does and why.
4789
4790 @cindex Error detection
4791 @unnumberedsec 1.1.3(20): Error Detection
4792 @sp 1
4793 @cartouche
4794 If an implementation detects the use of an unsupported Specialized Needs
4795 Annex feature at run time, it should raise @code{Program_Error} if
4796 feasible.
4797 @end cartouche
4798 Not relevant.  All specialized needs annex features are either supported,
4799 or diagnosed at compile time.
4800
4801 @cindex Child Units
4802 @unnumberedsec 1.1.3(31): Child Units
4803 @sp 1
4804 @cartouche
4805 If an implementation wishes to provide implementation-defined
4806 extensions to the functionality of a language-defined library unit, it
4807 should normally do so by adding children to the library unit.
4808 @end cartouche
4809 Followed.
4810
4811 @cindex Bounded errors
4812 @unnumberedsec 1.1.5(12): Bounded Errors
4813 @sp 1
4814 @cartouche
4815 If an implementation detects a bounded error or erroneous
4816 execution, it should raise @code{Program_Error}.
4817 @end cartouche
4818 Followed in all cases in which the implementation detects a bounded
4819 error or erroneous execution.  Not all such situations are detected at
4820 runtime.
4821
4822 @cindex Pragmas
4823 @unnumberedsec 2.8(16): Pragmas
4824 @sp 1
4825 @cartouche
4826 Normally, implementation-defined pragmas should have no semantic effect
4827 for error-free programs; that is, if the implementation-defined pragmas
4828 are removed from a working program, the program should still be legal,
4829 and should still have the same semantics.
4830 @end cartouche
4831 The following implementation defined pragmas are exceptions to this
4832 rule:
4833
4834 @table @code
4835 @item Abort_Defer
4836 Affects semantics
4837 @item Ada_83
4838 Affects legality
4839 @item Assert
4840 Affects semantics
4841 @item CPP_Class
4842 Affects semantics
4843 @item CPP_Constructor
4844 Affects semantics
4845 @item CPP_Virtual
4846 Affects semantics
4847 @item CPP_Vtable
4848 Affects semantics
4849 @item Debug
4850 Affects semantics
4851 @item Interface_Name
4852 Affects semantics
4853 @item Machine_Attribute
4854 Affects semantics
4855 @item Unimplemented_Unit
4856 Affects legality
4857 @item Unchecked_Union
4858 Affects semantics
4859 @end table
4860
4861 @noindent
4862 In each of the above cases, it is essential to the purpose of the pragma
4863 that this advice not be followed.  For details see the separate section
4864 on implementation defined pragmas.
4865
4866 @unnumberedsec 2.8(17-19): Pragmas
4867 @sp 1
4868 @cartouche
4869 Normally, an implementation should not define pragmas that can
4870 make an illegal program legal, except as follows:
4871 @end cartouche
4872 @sp 1
4873 @cartouche
4874 A pragma used to complete a declaration, such as a pragma @code{Import};
4875 @end cartouche
4876 @sp 1
4877 @cartouche
4878 A pragma used to configure the environment by adding, removing, or
4879 replacing @code{library_items}.
4880 @end cartouche
4881 See response to paragraph 16 of this same section.
4882
4883 @cindex Character Sets
4884 @cindex Alternative Character Sets
4885 @unnumberedsec 3.5.2(5): Alternative Character Sets
4886 @sp 1
4887 @cartouche
4888 If an implementation supports a mode with alternative interpretations
4889 for @code{Character} and @code{Wide_Character}, the set of graphic
4890 characters of @code{Character} should nevertheless remain a proper
4891 subset of the set of graphic characters of @code{Wide_Character}.  Any
4892 character set ``localizations'' should be reflected in the results of
4893 the subprograms defined in the language-defined package
4894 @code{Characters.Handling} (see A.3) available in such a mode.  In a mode with
4895 an alternative interpretation of @code{Character}, the implementation should
4896 also support a corresponding change in what is a legal
4897 @code{identifier_letter}.
4898 @end cartouche
4899 Not all wide character modes follow this advice, in particular the JIS
4900 and IEC modes reflect standard usage in Japan, and in these encoding,
4901 the upper half of the Latin-1 set is not part of the wide-character
4902 subset, since the most significant bit is used for wide character
4903 encoding.  However, this only applies to the external forms.  Internally
4904 there is no such restriction.
4905
4906 @cindex Integer types
4907 @unnumberedsec 3.5.4(28): Integer Types
4908
4909 @sp 1
4910 @cartouche
4911 An implementation should support @code{Long_Integer} in addition to
4912 @code{Integer} if the target machine supports 32-bit (or longer)
4913 arithmetic.  No other named integer subtypes are recommended for package
4914 @code{Standard}.  Instead, appropriate named integer subtypes should be
4915 provided in the library package @code{Interfaces} (see B.2).
4916 @end cartouche
4917 @code{Long_Integer} is supported.  Other standard integer types are supported
4918 so this advice is not fully followed.  These types
4919 are supported for convenient interface to C, and so that all hardware
4920 types of the machine are easily available.
4921 @unnumberedsec 3.5.4(29): Integer Types
4922
4923 @sp 1
4924 @cartouche
4925 An implementation for a two's complement machine should support
4926 modular types with a binary modulus up to @code{System.Max_Int*2+2}.  An
4927 implementation should support a non-binary modules up to @code{Integer'Last}.
4928 @end cartouche
4929 Followed.
4930
4931 @cindex Enumeration values
4932 @unnumberedsec 3.5.5(8): Enumeration Values
4933 @sp 1
4934 @cartouche
4935 For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
4936 subtype, if the value of the operand does not correspond to the internal
4937 code for any enumeration literal of its type (perhaps due to an
4938 un-initialized variable), then the implementation should raise
4939 @code{Program_Error}.  This is particularly important for enumeration
4940 types with noncontiguous internal codes specified by an
4941 enumeration_representation_clause.
4942 @end cartouche
4943 Followed.
4944
4945 @cindex Float types
4946 @unnumberedsec 3.5.7(17): Float Types
4947 @sp 1
4948 @cartouche
4949 An implementation should support @code{Long_Float} in addition to
4950 @code{Float} if the target machine supports 11 or more digits of
4951 precision.  No other named floating point subtypes are recommended for
4952 package @code{Standard}.  Instead, appropriate named floating point subtypes
4953 should be provided in the library package @code{Interfaces} (see B.2).
4954 @end cartouche
4955 @code{Short_Float} and @code{Long_Long_Float} are also provided.  The
4956 former provides improved compatibility with other implementations
4957 supporting this type.  The latter corresponds to the highest precision
4958 floating-point type supported by the hardware.  On most machines, this
4959 will be the same as @code{Long_Float}, but on some machines, it will
4960 correspond to the IEEE extended form.  The notable case is all ia32
4961 (x86) implementations, where @code{Long_Long_Float} corresponds to
4962 the 80-bit extended precision format supported in hardware on this
4963 processor.  Note that the 128-bit format on SPARC is not supported,
4964 since this is a software rather than a hardware format.
4965
4966 @cindex Multidimensional arrays
4967 @cindex Arrays, multidimensional
4968 @unnumberedsec 3.6.2(11): Multidimensional Arrays
4969 @sp 1
4970 @cartouche
4971 An implementation should normally represent multidimensional arrays in
4972 row-major order, consistent with the notation used for multidimensional
4973 array aggregates (see 4.3.3).  However, if a pragma @code{Convention}
4974 (@code{Fortran}, @dots{}) applies to a multidimensional array type, then
4975 column-major order should be used instead (see B.5, ``Interfacing with
4976 Fortran'').
4977 @end cartouche
4978 Followed.
4979
4980 @findex Duration'Small
4981 @unnumberedsec 9.6(30-31): Duration'Small
4982 @sp 1
4983 @cartouche
4984 Whenever possible in an implementation, the value of @code{Duration'Small}
4985 should be no greater than 100 microseconds.
4986 @end cartouche
4987 Followed.  (@code{Duration'Small} = 10**(@minus{}9)).
4988
4989 @sp 1
4990 @cartouche
4991 The time base for @code{delay_relative_statements} should be monotonic;
4992 it need not be the same time base as used for @code{Calendar.Clock}.
4993 @end cartouche
4994 Followed.
4995
4996 @unnumberedsec 10.2.1(12): Consistent Representation
4997 @sp 1
4998 @cartouche
4999 In an implementation, a type declared in a pre-elaborated package should
5000 have the same representation in every elaboration of a given version of
5001 the package, whether the elaborations occur in distinct executions of
5002 the same program, or in executions of distinct programs or partitions
5003 that include the given version.
5004 @end cartouche
5005 Followed, except in the case of tagged types.  Tagged types involve
5006 implicit pointers to a local copy of a dispatch table, and these pointers
5007 have representations which thus depend on a particular elaboration of the
5008 package.  It is not easy to see how it would be possible to follow this
5009 advice without severely impacting efficiency of execution.
5010
5011 @cindex Exception information
5012 @unnumberedsec 11.4.1(19): Exception Information
5013 @sp 1
5014 @cartouche
5015 @code{Exception_Message} by default and @code{Exception_Information}
5016 should produce information useful for
5017 debugging.  @code{Exception_Message} should be short, about one
5018 line.  @code{Exception_Information} can be long.  @code{Exception_Message}
5019 should not include the
5020 @code{Exception_Name}.  @code{Exception_Information} should include both
5021 the @code{Exception_Name} and the @code{Exception_Message}.
5022 @end cartouche
5023 Followed.  For each exception that doesn't have a specified
5024 @code{Exception_Message}, the compiler generates one containing the location
5025 of the raise statement.  This location has the form ``file:line'', where
5026 file is the short file name (without path information) and line is the line
5027 number in the file.  Note that in the case of the Zero Cost Exception
5028 mechanism, these messages become redundant with the Exception_Information that
5029 contains a full backtrace of the calling sequence, so they are disabled.
5030 To disable explicitly the generation of the source location message, use the
5031 Pragma @code{Discard_Names}.
5032
5033 @cindex Suppression of checks
5034 @cindex Checks, suppression of
5035 @unnumberedsec 11.5(28): Suppression of Checks
5036 @sp 1
5037 @cartouche
5038 The implementation should minimize the code executed for checks that
5039 have been suppressed.
5040 @end cartouche
5041 Followed.
5042
5043 @cindex Representation clauses
5044 @unnumberedsec 13.1 (21-24): Representation Clauses
5045 @sp 1
5046 @cartouche
5047 The recommended level of support for all representation items is
5048 qualified as follows:
5049 @end cartouche
5050 @sp 1
5051 @cartouche
5052 An implementation need not support representation items containing
5053 non-static expressions, except that an implementation should support a
5054 representation item for a given entity if each non-static expression in
5055 the representation item is a name that statically denotes a constant
5056 declared before the entity.
5057 @end cartouche
5058 Followed.  GNAT does not support non-static expressions in representation
5059 clauses unless they are constants declared before the entity.  For
5060 example:
5061
5062 @smallexample @c ada
5063 X : Some_Type;
5064 for X'Address use To_address (16#2000#);
5065 @end smallexample
5066
5067 @noindent
5068 will be rejected, since the To_Address expression is non-static.  Instead
5069 write:
5070
5071 @smallexample @c ada
5072 X_Address : constant Address : = To_Address (16#2000#);
5073 X         : Some_Type;
5074 for X'Address use X_Address;
5075 @end smallexample
5076
5077 @sp 1
5078 @cartouche
5079 An implementation need not support a specification for the @code{Size}
5080 for a given composite subtype, nor the size or storage place for an
5081 object (including a component) of a given composite subtype, unless the
5082 constraints on the subtype and its composite subcomponents (if any) are
5083 all static constraints.
5084 @end cartouche
5085 Followed.  Size Clauses are not permitted on non-static components, as
5086 described above.
5087
5088 @sp 1
5089 @cartouche
5090 An aliased component, or a component whose type is by-reference, should
5091 always be allocated at an addressable location.
5092 @end cartouche
5093 Followed.
5094
5095 @cindex Packed types
5096 @unnumberedsec 13.2(6-8): Packed Types
5097 @sp 1
5098 @cartouche
5099 If a type is packed, then the implementation should try to minimize
5100 storage allocated to objects of the type, possibly at the expense of
5101 speed of accessing components, subject to reasonable complexity in
5102 addressing calculations.
5103 @end cartouche
5104 @sp 1
5105 @cartouche
5106 The recommended level of support pragma @code{Pack} is:
5107
5108 For a packed record type, the components should be packed as tightly as
5109 possible subject to the Sizes of the component subtypes, and subject to
5110 any @code{record_representation_clause} that applies to the type; the
5111 implementation may, but need not, reorder components or cross aligned
5112 word boundaries to improve the packing.  A component whose @code{Size} is
5113 greater than the word size may be allocated an integral number of words.
5114 @end cartouche
5115 Followed.  Tight packing of arrays is supported for all component sizes
5116 up to 64-bits. If the array component size is 1 (that is to say, if
5117 the component is a boolean type or an enumeration type with two values)
5118 then values of the type are implicitly initialized to zero. This
5119 happens both for objects of the packed type, and for objects that have a
5120 subcomponent of the packed type.
5121
5122 @sp 1
5123 @cartouche
5124 An implementation should support Address clauses for imported
5125 subprograms.
5126 @end cartouche
5127 Followed.
5128 @cindex @code{Address} clauses
5129 @unnumberedsec 13.3(14-19): Address Clauses
5130
5131 @sp 1
5132 @cartouche
5133 For an array @var{X}, @code{@var{X}'Address} should point at the first
5134 component of the array, and not at the array bounds.
5135 @end cartouche
5136 Followed.
5137
5138 @sp 1
5139 @cartouche
5140 The recommended level of support for the @code{Address} attribute is:
5141
5142 @code{@var{X}'Address} should produce a useful result if @var{X} is an
5143 object that is aliased or of a by-reference type, or is an entity whose
5144 @code{Address} has been specified.
5145 @end cartouche
5146 Followed.  A valid address will be produced even if none of those
5147 conditions have been met.  If necessary, the object is forced into
5148 memory to ensure the address is valid.
5149
5150 @sp 1
5151 @cartouche
5152 An implementation should support @code{Address} clauses for imported
5153 subprograms.
5154 @end cartouche
5155 Followed.
5156
5157 @sp 1
5158 @cartouche
5159 Objects (including subcomponents) that are aliased or of a by-reference
5160 type should be allocated on storage element boundaries.
5161 @end cartouche
5162 Followed.
5163
5164 @sp 1
5165 @cartouche
5166 If the @code{Address} of an object is specified, or it is imported or exported,
5167 then the implementation should not perform optimizations based on
5168 assumptions of no aliases.
5169 @end cartouche
5170 Followed.
5171
5172 @cindex @code{Alignment} clauses
5173 @unnumberedsec 13.3(29-35): Alignment Clauses
5174 @sp 1
5175 @cartouche
5176 The recommended level of support for the @code{Alignment} attribute for
5177 subtypes is:
5178
5179 An implementation should support specified Alignments that are factors
5180 and multiples of the number of storage elements per word, subject to the
5181 following:
5182 @end cartouche
5183 Followed.
5184
5185 @sp 1
5186 @cartouche
5187 An implementation need not support specified @code{Alignment}s for
5188 combinations of @code{Size}s and @code{Alignment}s that cannot be easily
5189 loaded and stored by available machine instructions.
5190 @end cartouche
5191 Followed.
5192
5193 @sp 1
5194 @cartouche
5195 An implementation need not support specified @code{Alignment}s that are
5196 greater than the maximum @code{Alignment} the implementation ever returns by
5197 default.
5198 @end cartouche
5199 Followed.
5200
5201 @sp 1
5202 @cartouche
5203 The recommended level of support for the @code{Alignment} attribute for
5204 objects is:
5205
5206 Same as above, for subtypes, but in addition:
5207 @end cartouche
5208 Followed.
5209
5210 @sp 1
5211 @cartouche
5212 For stand-alone library-level objects of statically constrained
5213 subtypes, the implementation should support all @code{Alignment}s
5214 supported by the target linker.  For example, page alignment is likely to
5215 be supported for such objects, but not for subtypes.
5216 @end cartouche
5217 Followed.
5218
5219 @cindex @code{Size} clauses
5220 @unnumberedsec 13.3(42-43): Size Clauses
5221 @sp 1
5222 @cartouche
5223 The recommended level of support for the @code{Size} attribute of
5224 objects is:
5225
5226 A @code{Size} clause should be supported for an object if the specified
5227 @code{Size} is at least as large as its subtype's @code{Size}, and
5228 corresponds to a size in storage elements that is a multiple of the
5229 object's @code{Alignment} (if the @code{Alignment} is nonzero).
5230 @end cartouche
5231 Followed.
5232
5233 @unnumberedsec 13.3(50-56): Size Clauses
5234 @sp 1
5235 @cartouche
5236 If the @code{Size} of a subtype is specified, and allows for efficient
5237 independent addressability (see 9.10) on the target architecture, then
5238 the @code{Size} of the following objects of the subtype should equal the
5239 @code{Size} of the subtype:
5240
5241 Aliased objects (including components).
5242 @end cartouche
5243 Followed.
5244
5245 @sp 1
5246 @cartouche
5247 @code{Size} clause on a composite subtype should not affect the
5248 internal layout of components.
5249 @end cartouche
5250 Followed.
5251
5252 @sp 1
5253 @cartouche
5254 The recommended level of support for the @code{Size} attribute of subtypes is:
5255 @end cartouche
5256 @sp 1
5257 @cartouche
5258 The @code{Size} (if not specified) of a static discrete or fixed point
5259 subtype should be the number of bits needed to represent each value
5260 belonging to the subtype using an unbiased representation, leaving space
5261 for a sign bit only if the subtype contains negative values.  If such a
5262 subtype is a first subtype, then an implementation should support a
5263 specified @code{Size} for it that reflects this representation.
5264 @end cartouche
5265 Followed.
5266
5267 @sp 1
5268 @cartouche
5269 For a subtype implemented with levels of indirection, the @code{Size}
5270 should include the size of the pointers, but not the size of what they
5271 point at.
5272 @end cartouche
5273 Followed.
5274
5275 @cindex @code{Component_Size} clauses
5276 @unnumberedsec 13.3(71-73): Component Size Clauses
5277 @sp 1
5278 @cartouche
5279 The recommended level of support for the @code{Component_Size}
5280 attribute is:
5281 @end cartouche
5282 @sp 1
5283 @cartouche
5284 An implementation need not support specified @code{Component_Sizes} that are
5285 less than the @code{Size} of the component subtype.
5286 @end cartouche
5287 Followed.
5288
5289 @sp 1
5290 @cartouche
5291 An implementation should support specified @code{Component_Size}s that
5292 are factors and multiples of the word size.  For such
5293 @code{Component_Size}s, the array should contain no gaps between
5294 components.  For other @code{Component_Size}s (if supported), the array
5295 should contain no gaps between components when packing is also
5296 specified; the implementation should forbid this combination in cases
5297 where it cannot support a no-gaps representation.
5298 @end cartouche
5299 Followed.
5300
5301 @cindex Enumeration representation clauses
5302 @cindex Representation clauses, enumeration
5303 @unnumberedsec 13.4(9-10): Enumeration Representation Clauses
5304 @sp 1
5305 @cartouche
5306 The recommended level of support for enumeration representation clauses
5307 is:
5308
5309 An implementation need not support enumeration representation clauses
5310 for boolean types, but should at minimum support the internal codes in
5311 the range @code{System.Min_Int.System.Max_Int}.
5312 @end cartouche
5313 Followed.
5314
5315 @cindex Record representation clauses
5316 @cindex Representation clauses, records
5317 @unnumberedsec 13.5.1(17-22): Record Representation Clauses
5318 @sp 1
5319 @cartouche
5320 The recommended level of support for
5321 @*@code{record_representation_clauses} is:
5322
5323 An implementation should support storage places that can be extracted
5324 with a load, mask, shift sequence of machine code, and set with a load,
5325 shift, mask, store sequence, given the available machine instructions
5326 and run-time model.
5327 @end cartouche
5328 Followed.
5329
5330 @sp 1
5331 @cartouche
5332 A storage place should be supported if its size is equal to the
5333 @code{Size} of the component subtype, and it starts and ends on a
5334 boundary that obeys the @code{Alignment} of the component subtype.
5335 @end cartouche
5336 Followed.
5337
5338 @sp 1
5339 @cartouche
5340 If the default bit ordering applies to the declaration of a given type,
5341 then for a component whose subtype's @code{Size} is less than the word
5342 size, any storage place that does not cross an aligned word boundary
5343 should be supported.
5344 @end cartouche
5345 Followed.
5346
5347 @sp 1
5348 @cartouche
5349 An implementation may reserve a storage place for the tag field of a
5350 tagged type, and disallow other components from overlapping that place.
5351 @end cartouche
5352 Followed.  The storage place for the tag field is the beginning of the tagged
5353 record, and its size is Address'Size.  GNAT will reject an explicit component
5354 clause for the tag field.
5355
5356 @sp 1
5357 @cartouche
5358 An implementation need not support a @code{component_clause} for a
5359 component of an extension part if the storage place is not after the
5360 storage places of all components of the parent type, whether or not
5361 those storage places had been specified.
5362 @end cartouche
5363 Followed.  The above advice on record representation clauses is followed,
5364 and all mentioned features are implemented.
5365
5366 @cindex Storage place attributes
5367 @unnumberedsec 13.5.2(5): Storage Place Attributes
5368 @sp 1
5369 @cartouche
5370 If a component is represented using some form of pointer (such as an
5371 offset) to the actual data of the component, and this data is contiguous
5372 with the rest of the object, then the storage place attributes should
5373 reflect the place of the actual data, not the pointer.  If a component is
5374 allocated discontinuously from the rest of the object, then a warning
5375 should be generated upon reference to one of its storage place
5376 attributes.
5377 @end cartouche
5378 Followed.  There are no such components in GNAT@.
5379
5380 @cindex Bit ordering
5381 @unnumberedsec 13.5.3(7-8): Bit Ordering
5382 @sp 1
5383 @cartouche
5384 The recommended level of support for the non-default bit ordering is:
5385 @end cartouche
5386 @sp 1
5387 @cartouche
5388 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
5389 should support the non-default bit ordering in addition to the default
5390 bit ordering.
5391 @end cartouche
5392 Followed.  Word size does not equal storage size in this implementation.
5393 Thus non-default bit ordering is not supported.
5394
5395 @cindex @code{Address}, as private type
5396 @unnumberedsec 13.7(37): Address as Private
5397 @sp 1
5398 @cartouche
5399 @code{Address} should be of a private type.
5400 @end cartouche
5401 Followed.
5402
5403 @cindex Operations, on @code{Address}
5404 @cindex @code{Address}, operations of
5405 @unnumberedsec 13.7.1(16): Address Operations
5406 @sp 1
5407 @cartouche
5408 Operations in @code{System} and its children should reflect the target
5409 environment semantics as closely as is reasonable.  For example, on most
5410 machines, it makes sense for address arithmetic to ``wrap around''.
5411 Operations that do not make sense should raise @code{Program_Error}.
5412 @end cartouche
5413 Followed.  Address arithmetic is modular arithmetic that wraps around.  No
5414 operation raises @code{Program_Error}, since all operations make sense.
5415
5416 @cindex Unchecked conversion
5417 @unnumberedsec 13.9(14-17): Unchecked Conversion
5418 @sp 1
5419 @cartouche
5420 The @code{Size} of an array object should not include its bounds; hence,
5421 the bounds should not be part of the converted data.
5422 @end cartouche
5423 Followed.
5424
5425 @sp 1
5426 @cartouche
5427 The implementation should not generate unnecessary run-time checks to
5428 ensure that the representation of @var{S} is a representation of the
5429 target type.  It should take advantage of the permission to return by
5430 reference when possible.  Restrictions on unchecked conversions should be
5431 avoided unless required by the target environment.
5432 @end cartouche
5433 Followed.  There are no restrictions on unchecked conversion.  A warning is
5434 generated if the source and target types do not have the same size since
5435 the semantics in this case may be target dependent.
5436
5437 @sp 1
5438 @cartouche
5439 The recommended level of support for unchecked conversions is:
5440 @end cartouche
5441 @sp 1
5442 @cartouche
5443 Unchecked conversions should be supported and should be reversible in
5444 the cases where this clause defines the result.  To enable meaningful use
5445 of unchecked conversion, a contiguous representation should be used for
5446 elementary subtypes, for statically constrained array subtypes whose
5447 component subtype is one of the subtypes described in this paragraph,
5448 and for record subtypes without discriminants whose component subtypes
5449 are described in this paragraph.
5450 @end cartouche
5451 Followed.
5452
5453 @cindex Heap usage, implicit
5454 @unnumberedsec 13.11(23-25): Implicit Heap Usage
5455 @sp 1
5456 @cartouche
5457 An implementation should document any cases in which it dynamically
5458 allocates heap storage for a purpose other than the evaluation of an
5459 allocator.
5460 @end cartouche
5461 Followed, the only other points at which heap storage is dynamically
5462 allocated are as follows:
5463
5464 @itemize @bullet
5465 @item
5466 At initial elaboration time, to allocate dynamically sized global
5467 objects.
5468
5469 @item
5470 To allocate space for a task when a task is created.
5471
5472 @item
5473 To extend the secondary stack dynamically when needed.  The secondary
5474 stack is used for returning variable length results.
5475 @end itemize
5476
5477 @sp 1
5478 @cartouche
5479 A default (implementation-provided) storage pool for an
5480 access-to-constant type should not have overhead to support deallocation of
5481 individual objects.
5482 @end cartouche
5483 Followed.
5484
5485 @sp 1
5486 @cartouche
5487 A storage pool for an anonymous access type should be created at the
5488 point of an allocator for the type, and be reclaimed when the designated
5489 object becomes inaccessible.
5490 @end cartouche
5491 Followed.
5492
5493 @cindex Unchecked deallocation
5494 @unnumberedsec 13.11.2(17): Unchecked De-allocation
5495 @sp 1
5496 @cartouche
5497 For a standard storage pool, @code{Free} should actually reclaim the
5498 storage.
5499 @end cartouche
5500 Followed.
5501
5502 @cindex Stream oriented attributes
5503 @unnumberedsec 13.13.2(17): Stream Oriented Attributes
5504 @sp 1
5505 @cartouche
5506 If a stream element is the same size as a storage element, then the
5507 normal in-memory representation should be used by @code{Read} and
5508 @code{Write} for scalar objects.  Otherwise, @code{Read} and @code{Write}
5509 should use the smallest number of stream elements needed to represent
5510 all values in the base range of the scalar type.
5511 @end cartouche
5512
5513 Followed.  By default, GNAT uses the interpretation suggested by AI-195,
5514 which specifies using the size of the first subtype.
5515 However, such an implementation is based on direct binary
5516 representations and is therefore target- and endianness-dependent.
5517 To address this issue, GNAT also supplies an alternate implementation
5518 of the stream attributes @code{Read} and @code{Write},
5519 which uses the target-independent XDR standard representation
5520 for scalar types.
5521 @cindex XDR representation
5522 @cindex @code{Read} attribute
5523 @cindex @code{Write} attribute
5524 @cindex Stream oriented attributes
5525 The XDR implementation is provided as an alternative body of the
5526 @code{System.Stream_Attributes} package, in the file
5527 @file{s-strxdr.adb} in the GNAT library.
5528 There is no @file{s-strxdr.ads} file.
5529 In order to install the XDR implementation, do the following:
5530 @enumerate
5531 @item Replace the default implementation of the
5532 @code{System.Stream_Attributes} package with the XDR implementation.
5533 For example on a Unix platform issue the commands:
5534 @smallexample
5535 $ mv s-stratt.adb s-strold.adb
5536 $ mv s-strxdr.adb s-stratt.adb
5537 @end smallexample
5538
5539 @item
5540 Rebuild the GNAT run-time library as documented in the
5541 @cite{GNAT User's Guide}
5542 @end enumerate
5543
5544 @unnumberedsec A.1(52): Names of Predefined Numeric Types
5545 @sp 1
5546 @cartouche
5547 If an implementation provides additional named predefined integer types,
5548 then the names should end with @samp{Integer} as in
5549 @samp{Long_Integer}.  If an implementation provides additional named
5550 predefined floating point types, then the names should end with
5551 @samp{Float} as in @samp{Long_Float}.
5552 @end cartouche
5553 Followed.
5554
5555 @findex Ada.Characters.Handling
5556 @unnumberedsec A.3.2(49): @code{Ada.Characters.Handling}
5557 @sp 1
5558 @cartouche
5559 If an implementation provides a localized definition of @code{Character}
5560 or @code{Wide_Character}, then the effects of the subprograms in
5561 @code{Characters.Handling} should reflect the localizations.  See also
5562 3.5.2.
5563 @end cartouche
5564 Followed.  GNAT provides no such localized definitions.
5565
5566 @cindex Bounded-length strings
5567 @unnumberedsec A.4.4(106): Bounded-Length String Handling
5568 @sp 1
5569 @cartouche
5570 Bounded string objects should not be implemented by implicit pointers
5571 and dynamic allocation.
5572 @end cartouche
5573 Followed.  No implicit pointers or dynamic allocation are used.
5574
5575 @cindex Random number generation
5576 @unnumberedsec A.5.2(46-47): Random Number Generation
5577 @sp 1
5578 @cartouche
5579 Any storage associated with an object of type @code{Generator} should be
5580 reclaimed on exit from the scope of the object.
5581 @end cartouche
5582 Followed.
5583
5584 @sp 1
5585 @cartouche
5586 If the generator period is sufficiently long in relation to the number
5587 of distinct initiator values, then each possible value of
5588 @code{Initiator} passed to @code{Reset} should initiate a sequence of
5589 random numbers that does not, in a practical sense, overlap the sequence
5590 initiated by any other value.  If this is not possible, then the mapping
5591 between initiator values and generator states should be a rapidly
5592 varying function of the initiator value.
5593 @end cartouche
5594 Followed.  The generator period is sufficiently long for the first
5595 condition here to hold true.
5596
5597 @findex Get_Immediate
5598 @unnumberedsec A.10.7(23): @code{Get_Immediate}
5599 @sp 1
5600 @cartouche
5601 The @code{Get_Immediate} procedures should be implemented with
5602 unbuffered input.  For a device such as a keyboard, input should be
5603 @dfn{available} if a key has already been typed, whereas for a disk
5604 file, input should always be available except at end of file.  For a file
5605 associated with a keyboard-like device, any line-editing features of the
5606 underlying operating system should be disabled during the execution of
5607 @code{Get_Immediate}.
5608 @end cartouche
5609 Followed on all targets except VxWorks. For VxWorks, there is no way to
5610 provide this functionality that does not result in the input buffer being
5611 flushed before the @code{Get_Immediate} call. A special unit
5612 @code{Interfaces.Vxworks.IO} is provided that contains routines to enable
5613 this functionality.
5614
5615 @findex Export
5616 @unnumberedsec B.1(39-41): Pragma @code{Export}
5617 @sp 1
5618 @cartouche
5619 If an implementation supports pragma @code{Export} to a given language,
5620 then it should also allow the main subprogram to be written in that
5621 language.  It should support some mechanism for invoking the elaboration
5622 of the Ada library units included in the system, and for invoking the
5623 finalization of the environment task.  On typical systems, the
5624 recommended mechanism is to provide two subprograms whose link names are
5625 @code{adainit} and @code{adafinal}.  @code{adainit} should contain the
5626 elaboration code for library units.  @code{adafinal} should contain the
5627 finalization code.  These subprograms should have no effect the second
5628 and subsequent time they are called.
5629 @end cartouche
5630 Followed.
5631
5632 @sp 1
5633 @cartouche
5634 Automatic elaboration of pre-elaborated packages should be
5635 provided when pragma @code{Export} is supported.
5636 @end cartouche
5637 Followed when the main program is in Ada.  If the main program is in a
5638 foreign language, then
5639 @code{adainit} must be called to elaborate pre-elaborated
5640 packages.
5641
5642 @sp 1
5643 @cartouche
5644 For each supported convention @var{L} other than @code{Intrinsic}, an
5645 implementation should support @code{Import} and @code{Export} pragmas
5646 for objects of @var{L}-compatible types and for subprograms, and pragma
5647 @code{Convention} for @var{L}-eligible types and for subprograms,
5648 presuming the other language has corresponding features.  Pragma
5649 @code{Convention} need not be supported for scalar types.
5650 @end cartouche
5651 Followed.
5652
5653 @cindex Package @code{Interfaces}
5654 @findex Interfaces
5655 @unnumberedsec B.2(12-13): Package @code{Interfaces}
5656 @sp 1
5657 @cartouche
5658 For each implementation-defined convention identifier, there should be a
5659 child package of package Interfaces with the corresponding name.  This
5660 package should contain any declarations that would be useful for
5661 interfacing to the language (implementation) represented by the
5662 convention.  Any declarations useful for interfacing to any language on
5663 the given hardware architecture should be provided directly in
5664 @code{Interfaces}.
5665 @end cartouche
5666 Followed.  An additional package not defined
5667 in the Ada 95 Reference Manual is @code{Interfaces.CPP}, used
5668 for interfacing to C++.
5669
5670 @sp 1
5671 @cartouche
5672 An implementation supporting an interface to C, COBOL, or Fortran should
5673 provide the corresponding package or packages described in the following
5674 clauses.
5675 @end cartouche
5676 Followed.  GNAT provides all the packages described in this section.
5677
5678 @cindex C, interfacing with
5679 @unnumberedsec B.3(63-71): Interfacing with C
5680 @sp 1
5681 @cartouche
5682 An implementation should support the following interface correspondences
5683 between Ada and C@.
5684 @end cartouche
5685 Followed.
5686
5687 @sp 1
5688 @cartouche
5689 An Ada procedure corresponds to a void-returning C function.
5690 @end cartouche
5691 Followed.
5692
5693 @sp 1
5694 @cartouche
5695 An Ada function corresponds to a non-void C function.
5696 @end cartouche
5697 Followed.
5698
5699 @sp 1
5700 @cartouche
5701 An Ada @code{in} scalar parameter is passed as a scalar argument to a C
5702 function.
5703 @end cartouche
5704 Followed.
5705
5706 @sp 1
5707 @cartouche
5708 An Ada @code{in} parameter of an access-to-object type with designated
5709 type @var{T} is passed as a @code{@var{t}*} argument to a C function,
5710 where @var{t} is the C type corresponding to the Ada type @var{T}.
5711 @end cartouche
5712 Followed.
5713
5714 @sp 1
5715 @cartouche
5716 An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
5717 parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
5718 argument to a C function, where @var{t} is the C type corresponding to
5719 the Ada type @var{T}.  In the case of an elementary @code{out} or
5720 @code{in out} parameter, a pointer to a temporary copy is used to
5721 preserve by-copy semantics.
5722 @end cartouche
5723 Followed.
5724
5725 @sp 1
5726 @cartouche
5727 An Ada parameter of a record type @var{T}, of any mode, is passed as a
5728 @code{@var{t}*} argument to a C function, where @var{t} is the C
5729 structure corresponding to the Ada type @var{T}.
5730 @end cartouche
5731 Followed.  This convention may be overridden by the use of the C_Pass_By_Copy
5732 pragma, or Convention, or by explicitly specifying the mechanism for a given
5733 call using an extended import or export pragma.
5734
5735 @sp 1
5736 @cartouche
5737 An Ada parameter of an array type with component type @var{T}, of any
5738 mode, is passed as a @code{@var{t}*} argument to a C function, where
5739 @var{t} is the C type corresponding to the Ada type @var{T}.
5740 @end cartouche
5741 Followed.
5742
5743 @sp 1
5744 @cartouche
5745 An Ada parameter of an access-to-subprogram type is passed as a pointer
5746 to a C function whose prototype corresponds to the designated
5747 subprogram's specification.
5748 @end cartouche
5749 Followed.
5750
5751 @cindex COBOL, interfacing with
5752 @unnumberedsec B.4(95-98): Interfacing with COBOL
5753 @sp 1
5754 @cartouche
5755 An Ada implementation should support the following interface
5756 correspondences between Ada and COBOL@.
5757 @end cartouche
5758 Followed.
5759
5760 @sp 1
5761 @cartouche
5762 An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of
5763 the COBOL type corresponding to @var{T}.
5764 @end cartouche
5765 Followed.
5766
5767 @sp 1
5768 @cartouche
5769 An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of
5770 the corresponding COBOL type.
5771 @end cartouche
5772 Followed.
5773
5774 @sp 1
5775 @cartouche
5776 Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the
5777 COBOL type corresponding to the Ada parameter type; for scalars, a local
5778 copy is used if necessary to ensure by-copy semantics.
5779 @end cartouche
5780 Followed.
5781
5782 @cindex Fortran, interfacing with
5783 @unnumberedsec B.5(22-26): Interfacing with Fortran
5784 @sp 1
5785 @cartouche
5786 An Ada implementation should support the following interface
5787 correspondences between Ada and Fortran:
5788 @end cartouche
5789 Followed.
5790
5791 @sp 1
5792 @cartouche
5793 An Ada procedure corresponds to a Fortran subroutine.
5794 @end cartouche
5795 Followed.
5796
5797 @sp 1
5798 @cartouche
5799 An Ada function corresponds to a Fortran function.
5800 @end cartouche
5801 Followed.
5802
5803 @sp 1
5804 @cartouche
5805 An Ada parameter of an elementary, array, or record type @var{T} is
5806 passed as a @var{T} argument to a Fortran procedure, where @var{T} is
5807 the Fortran type corresponding to the Ada type @var{T}, and where the
5808 INTENT attribute of the corresponding dummy argument matches the Ada
5809 formal parameter mode; the Fortran implementation's parameter passing
5810 conventions are used.  For elementary types, a local copy is used if
5811 necessary to ensure by-copy semantics.
5812 @end cartouche
5813 Followed.
5814
5815 @sp 1
5816 @cartouche
5817 An Ada parameter of an access-to-subprogram type is passed as a
5818 reference to a Fortran procedure whose interface corresponds to the
5819 designated subprogram's specification.
5820 @end cartouche
5821 Followed.
5822
5823 @cindex Machine operations
5824 @unnumberedsec C.1(3-5): Access to Machine Operations
5825 @sp 1
5826 @cartouche
5827 The machine code or intrinsic support should allow access to all
5828 operations normally available to assembly language programmers for the
5829 target environment, including privileged instructions, if any.
5830 @end cartouche
5831 Followed.
5832
5833 @sp 1
5834 @cartouche
5835 The interfacing pragmas (see Annex B) should support interface to
5836 assembler; the default assembler should be associated with the
5837 convention identifier @code{Assembler}.
5838 @end cartouche
5839 Followed.
5840
5841 @sp 1
5842 @cartouche
5843 If an entity is exported to assembly language, then the implementation
5844 should allocate it at an addressable location, and should ensure that it
5845 is retained by the linking process, even if not otherwise referenced
5846 from the Ada code.  The implementation should assume that any call to a
5847 machine code or assembler subprogram is allowed to read or update every
5848 object that is specified as exported.
5849 @end cartouche
5850 Followed.
5851
5852 @unnumberedsec C.1(10-16): Access to Machine Operations
5853 @sp 1
5854 @cartouche
5855 The implementation should ensure that little or no overhead is
5856 associated with calling intrinsic and machine-code subprograms.
5857 @end cartouche
5858 Followed for both intrinsics and machine-code subprograms.
5859
5860 @sp 1
5861 @cartouche
5862 It is recommended that intrinsic subprograms be provided for convenient
5863 access to any machine operations that provide special capabilities or
5864 efficiency and that are not otherwise available through the language
5865 constructs.
5866 @end cartouche
5867 Followed.  A full set of machine operation intrinsic subprograms is provided.
5868
5869 @sp 1
5870 @cartouche
5871 Atomic read-modify-write operations---e.g.@:, test and set, compare and
5872 swap, decrement and test, enqueue/dequeue.
5873 @end cartouche
5874 Followed on any target supporting such operations.
5875
5876 @sp 1
5877 @cartouche
5878 Standard numeric functions---e.g.@:, sin, log.
5879 @end cartouche
5880 Followed on any target supporting such operations.
5881
5882 @sp 1
5883 @cartouche
5884 String manipulation operations---e.g.@:, translate and test.
5885 @end cartouche
5886 Followed on any target supporting such operations.
5887
5888 @sp 1
5889 @cartouche
5890 Vector operations---e.g.@:, compare vector against thresholds.
5891 @end cartouche
5892 Followed on any target supporting such operations.
5893
5894 @sp 1
5895 @cartouche
5896 Direct operations on I/O ports.
5897 @end cartouche
5898 Followed on any target supporting such operations.
5899
5900 @cindex Interrupt support
5901 @unnumberedsec C.3(28): Interrupt Support
5902 @sp 1
5903 @cartouche
5904 If the @code{Ceiling_Locking} policy is not in effect, the
5905 implementation should provide means for the application to specify which
5906 interrupts are to be blocked during protected actions, if the underlying
5907 system allows for a finer-grain control of interrupt blocking.
5908 @end cartouche
5909 Followed.  The underlying system does not allow for finer-grain control
5910 of interrupt blocking.
5911
5912 @cindex Protected procedure handlers
5913 @unnumberedsec C.3.1(20-21): Protected Procedure Handlers
5914 @sp 1
5915 @cartouche
5916 Whenever possible, the implementation should allow interrupt handlers to
5917 be called directly by the hardware.
5918 @end cartouche
5919 @c SGI info:
5920 @ignore
5921 This is never possible under IRIX, so this is followed by default.
5922 @end ignore
5923 Followed on any target where the underlying operating system permits
5924 such direct calls.
5925
5926 @sp 1
5927 @cartouche
5928 Whenever practical, violations of any
5929 implementation-defined restrictions should be detected before run time.
5930 @end cartouche
5931 Followed.  Compile time warnings are given when possible.
5932
5933 @cindex Package @code{Interrupts}
5934 @findex Interrupts
5935 @unnumberedsec C.3.2(25): Package @code{Interrupts}
5936
5937 @sp 1
5938 @cartouche
5939 If implementation-defined forms of interrupt handler procedures are
5940 supported, such as protected procedures with parameters, then for each
5941 such form of a handler, a type analogous to @code{Parameterless_Handler}
5942 should be specified in a child package of @code{Interrupts}, with the
5943 same operations as in the predefined package Interrupts.
5944 @end cartouche
5945 Followed.
5946
5947 @cindex Pre-elaboration requirements
5948 @unnumberedsec C.4(14): Pre-elaboration Requirements
5949 @sp 1
5950 @cartouche
5951 It is recommended that pre-elaborated packages be implemented in such a
5952 way that there should be little or no code executed at run time for the
5953 elaboration of entities not already covered by the Implementation
5954 Requirements.
5955 @end cartouche
5956 Followed.  Executable code is generated in some cases, e.g.@: loops
5957 to initialize large arrays.
5958
5959 @unnumberedsec C.5(8): Pragma @code{Discard_Names}
5960
5961 @sp 1
5962 @cartouche
5963 If the pragma applies to an entity, then the implementation should
5964 reduce the amount of storage used for storing names associated with that
5965 entity.
5966 @end cartouche
5967 Followed.
5968
5969 @cindex Package @code{Task_Attributes}
5970 @findex Task_Attributes
5971 @unnumberedsec C.7.2(30): The Package Task_Attributes
5972 @sp 1
5973 @cartouche
5974 Some implementations are targeted to domains in which memory use at run
5975 time must be completely deterministic.  For such implementations, it is
5976 recommended that the storage for task attributes will be pre-allocated
5977 statically and not from the heap.  This can be accomplished by either
5978 placing restrictions on the number and the size of the task's
5979 attributes, or by using the pre-allocated storage for the first @var{N}
5980 attribute objects, and the heap for the others.  In the latter case,
5981 @var{N} should be documented.
5982 @end cartouche
5983 Not followed.  This implementation is not targeted to such a domain.
5984
5985 @cindex Locking Policies
5986 @unnumberedsec D.3(17): Locking Policies
5987
5988 @sp 1
5989 @cartouche
5990 The implementation should use names that end with @samp{_Locking} for
5991 locking policies defined by the implementation.
5992 @end cartouche
5993 Followed.  A single implementation-defined locking policy is defined,
5994 whose name (@code{Inheritance_Locking}) follows this suggestion.
5995
5996 @cindex Entry queuing policies
5997 @unnumberedsec D.4(16): Entry Queuing Policies
5998 @sp 1
5999 @cartouche
6000 Names that end with @samp{_Queuing} should be used
6001 for all implementation-defined queuing policies.
6002 @end cartouche
6003 Followed.  No such implementation-defined queuing policies exist.
6004
6005 @cindex Preemptive abort
6006 @unnumberedsec D.6(9-10): Preemptive Abort
6007 @sp 1
6008 @cartouche
6009 Even though the @code{abort_statement} is included in the list of
6010 potentially blocking operations (see 9.5.1), it is recommended that this
6011 statement be implemented in a way that never requires the task executing
6012 the @code{abort_statement} to block.
6013 @end cartouche
6014 Followed.
6015
6016 @sp 1
6017 @cartouche
6018 On a multi-processor, the delay associated with aborting a task on
6019 another processor should be bounded; the implementation should use
6020 periodic polling, if necessary, to achieve this.
6021 @end cartouche
6022 Followed.
6023
6024 @cindex Tasking restrictions
6025 @unnumberedsec D.7(21): Tasking Restrictions
6026 @sp 1
6027 @cartouche
6028 When feasible, the implementation should take advantage of the specified
6029 restrictions to produce a more efficient implementation.
6030 @end cartouche
6031 GNAT currently takes advantage of these restrictions by providing an optimized
6032 run time when the Ravenscar profile and the GNAT restricted run time set
6033 of restrictions are specified.  See pragma @code{Profile (Ravenscar)} and
6034 pragma @code{Restricted_Run_Time} for more details.
6035
6036 @cindex Time, monotonic
6037 @unnumberedsec D.8(47-49): Monotonic Time
6038 @sp 1
6039 @cartouche
6040 When appropriate, implementations should provide configuration
6041 mechanisms to change the value of @code{Tick}.
6042 @end cartouche
6043 Such configuration mechanisms are not appropriate to this implementation
6044 and are thus not supported.
6045
6046 @sp 1
6047 @cartouche
6048 It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
6049 be implemented as transformations of the same time base.
6050 @end cartouche
6051 Followed.
6052
6053 @sp 1
6054 @cartouche
6055 It is recommended that the @dfn{best} time base which exists in
6056 the underlying system be available to the application through
6057 @code{Clock}.  @dfn{Best} may mean highest accuracy or largest range.
6058 @end cartouche
6059 Followed.
6060
6061 @cindex Partition communication subsystem
6062 @cindex PCS
6063 @unnumberedsec E.5(28-29): Partition Communication Subsystem
6064 @sp 1
6065 @cartouche
6066 Whenever possible, the PCS on the called partition should allow for
6067 multiple tasks to call the RPC-receiver with different messages and
6068 should allow them to block until the corresponding subprogram body
6069 returns.
6070 @end cartouche
6071 Followed by GLADE, a separately supplied PCS that can be used with
6072 GNAT.
6073
6074 @sp 1
6075 @cartouche
6076 The @code{Write} operation on a stream of type @code{Params_Stream_Type}
6077 should raise @code{Storage_Error} if it runs out of space trying to
6078 write the @code{Item} into the stream.
6079 @end cartouche
6080 Followed by GLADE, a separately supplied PCS that can be used with
6081 GNAT@.
6082
6083 @cindex COBOL support
6084 @unnumberedsec F(7): COBOL Support
6085 @sp 1
6086 @cartouche
6087 If COBOL (respectively, C) is widely supported in the target
6088 environment, implementations supporting the Information Systems Annex
6089 should provide the child package @code{Interfaces.COBOL} (respectively,
6090 @code{Interfaces.C}) specified in Annex B and should support a
6091 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
6092 pragmas (see Annex B), thus allowing Ada programs to interface with
6093 programs written in that language.
6094 @end cartouche
6095 Followed.
6096
6097 @cindex Decimal radix support
6098 @unnumberedsec F.1(2): Decimal Radix Support
6099 @sp 1
6100 @cartouche
6101 Packed decimal should be used as the internal representation for objects
6102 of subtype @var{S} when @var{S}'Machine_Radix = 10.
6103 @end cartouche
6104 Not followed.  GNAT ignores @var{S}'Machine_Radix and always uses binary
6105 representations.
6106
6107 @cindex Numerics
6108 @unnumberedsec G: Numerics
6109 @sp 2
6110 @cartouche
6111 If Fortran (respectively, C) is widely supported in the target
6112 environment, implementations supporting the Numerics Annex
6113 should provide the child package @code{Interfaces.Fortran} (respectively,
6114 @code{Interfaces.C}) specified in Annex B and should support a
6115 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
6116 pragmas (see Annex B), thus allowing Ada programs to interface with
6117 programs written in that language.
6118 @end cartouche
6119 Followed.
6120
6121 @cindex Complex types
6122 @unnumberedsec G.1.1(56-58): Complex Types
6123 @sp 2
6124 @cartouche
6125 Because the usual mathematical meaning of multiplication of a complex
6126 operand and a real operand is that of the scaling of both components of
6127 the former by the latter, an implementation should not perform this
6128 operation by first promoting the real operand to complex type and then
6129 performing a full complex multiplication.  In systems that, in the
6130 future, support an Ada binding to IEC 559:1989, the latter technique
6131 will not generate the required result when one of the components of the
6132 complex operand is infinite.  (Explicit multiplication of the infinite
6133 component by the zero component obtained during promotion yields a NaN
6134 that propagates into the final result.) Analogous advice applies in the
6135 case of multiplication of a complex operand and a pure-imaginary
6136 operand, and in the case of division of a complex operand by a real or
6137 pure-imaginary operand.
6138 @end cartouche
6139 Not followed.
6140
6141 @sp 1
6142 @cartouche
6143 Similarly, because the usual mathematical meaning of addition of a
6144 complex operand and a real operand is that the imaginary operand remains
6145 unchanged, an implementation should not perform this operation by first
6146 promoting the real operand to complex type and then performing a full
6147 complex addition.  In implementations in which the @code{Signed_Zeros}
6148 attribute of the component type is @code{True} (and which therefore
6149 conform to IEC 559:1989 in regard to the handling of the sign of zero in
6150 predefined arithmetic operations), the latter technique will not
6151 generate the required result when the imaginary component of the complex
6152 operand is a negatively signed zero.  (Explicit addition of the negative
6153 zero to the zero obtained during promotion yields a positive zero.)
6154 Analogous advice applies in the case of addition of a complex operand
6155 and a pure-imaginary operand, and in the case of subtraction of a
6156 complex operand and a real or pure-imaginary operand.
6157 @end cartouche
6158 Not followed.
6159
6160 @sp 1
6161 @cartouche
6162 Implementations in which @code{Real'Signed_Zeros} is @code{True} should
6163 attempt to provide a rational treatment of the signs of zero results and
6164 result components.  As one example, the result of the @code{Argument}
6165 function should have the sign of the imaginary component of the
6166 parameter @code{X} when the point represented by that parameter lies on
6167 the positive real axis; as another, the sign of the imaginary component
6168 of the @code{Compose_From_Polar} function should be the same as
6169 (respectively, the opposite of) that of the @code{Argument} parameter when that
6170 parameter has a value of zero and the @code{Modulus} parameter has a
6171 nonnegative (respectively, negative) value.
6172 @end cartouche
6173 Followed.
6174
6175 @cindex Complex elementary functions
6176 @unnumberedsec G.1.2(49): Complex Elementary Functions
6177 @sp 1
6178 @cartouche
6179 Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
6180 @code{True} should attempt to provide a rational treatment of the signs
6181 of zero results and result components.  For example, many of the complex
6182 elementary functions have components that are odd functions of one of
6183 the parameter components; in these cases, the result component should
6184 have the sign of the parameter component at the origin.  Other complex
6185 elementary functions have zero components whose sign is opposite that of
6186 a parameter component at the origin, or is always positive or always
6187 negative.
6188 @end cartouche
6189 Followed.
6190
6191 @cindex Accuracy requirements
6192 @unnumberedsec G.2.4(19): Accuracy Requirements
6193 @sp 1
6194 @cartouche
6195 The versions of the forward trigonometric functions without a
6196 @code{Cycle} parameter should not be implemented by calling the
6197 corresponding version with a @code{Cycle} parameter of
6198 @code{2.0*Numerics.Pi}, since this will not provide the required
6199 accuracy in some portions of the domain.  For the same reason, the
6200 version of @code{Log} without a @code{Base} parameter should not be
6201 implemented by calling the corresponding version with a @code{Base}
6202 parameter of @code{Numerics.e}.
6203 @end cartouche
6204 Followed.
6205
6206 @cindex Complex arithmetic accuracy
6207 @cindex Accuracy, complex arithmetic
6208 @unnumberedsec G.2.6(15): Complex Arithmetic Accuracy
6209
6210 @sp 1
6211 @cartouche
6212 The version of the @code{Compose_From_Polar} function without a
6213 @code{Cycle} parameter should not be implemented by calling the
6214 corresponding version with a @code{Cycle} parameter of
6215 @code{2.0*Numerics.Pi}, since this will not provide the required
6216 accuracy in some portions of the domain.
6217 @end cartouche
6218 Followed.
6219
6220 @c -----------------------------------------
6221 @node Implementation Defined Characteristics
6222 @chapter Implementation Defined Characteristics
6223
6224 @noindent
6225 In addition to the implementation dependent pragmas and attributes, and
6226 the implementation advice, there are a number of other features of Ada
6227 95 that are potentially implementation dependent.  These are mentioned
6228 throughout the Ada 95 Reference Manual, and are summarized in annex M@.
6229
6230 A requirement for conforming Ada compilers is that they provide
6231 documentation describing how the implementation deals with each of these
6232 issues.  In this chapter, you will find each point in annex M listed
6233 followed by a description in italic font of how GNAT
6234 @c SGI info:
6235 @ignore
6236 in the ProDev Ada
6237 implementation on IRIX 5.3 operating system or greater
6238 @end ignore
6239 handles the implementation dependence.
6240
6241 You can use this chapter as a guide to minimizing implementation
6242 dependent features in your programs if portability to other compilers
6243 and other operating systems is an important consideration.  The numbers
6244 in each section below correspond to the paragraph number in the Ada 95
6245 Reference Manual.
6246
6247 @sp 1
6248 @cartouche
6249 @noindent
6250 @strong{2}.  Whether or not each recommendation given in Implementation
6251 Advice is followed.  See 1.1.2(37).
6252 @end cartouche
6253 @noindent
6254 @xref{Implementation Advice}.
6255
6256 @sp 1
6257 @cartouche
6258 @noindent
6259 @strong{3}.  Capacity limitations of the implementation.  See 1.1.3(3).
6260 @end cartouche
6261 @noindent
6262 The complexity of programs that can be processed is limited only by the
6263 total amount of available virtual memory, and disk space for the
6264 generated object files.
6265
6266 @sp 1
6267 @cartouche
6268 @noindent
6269 @strong{4}.  Variations from the standard that are impractical to avoid
6270 given the implementation's execution environment.  See 1.1.3(6).
6271 @end cartouche
6272 @noindent
6273 There are no variations from the standard.
6274
6275 @sp 1
6276 @cartouche
6277 @noindent
6278 @strong{5}.  Which @code{code_statement}s cause external
6279 interactions.  See 1.1.3(10).
6280 @end cartouche
6281 @noindent
6282 Any @code{code_statement} can potentially cause external interactions.
6283
6284 @sp 1
6285 @cartouche
6286 @noindent
6287 @strong{6}.  The coded representation for the text of an Ada
6288 program.  See 2.1(4).
6289 @end cartouche
6290 @noindent
6291 See separate section on source representation.
6292
6293 @sp 1
6294 @cartouche
6295 @noindent
6296 @strong{7}.  The control functions allowed in comments.  See 2.1(14).
6297 @end cartouche
6298 @noindent
6299 See separate section on source representation.
6300
6301 @sp 1
6302 @cartouche
6303 @noindent
6304 @strong{8}.  The representation for an end of line.  See 2.2(2).
6305 @end cartouche
6306 @noindent
6307 See separate section on source representation.
6308
6309 @sp 1
6310 @cartouche
6311 @noindent
6312 @strong{9}.  Maximum supported line length and lexical element
6313 length.  See 2.2(15).
6314 @end cartouche
6315 @noindent
6316 The maximum line length is 255 characters an the maximum length of a
6317 lexical element is also 255 characters.
6318
6319 @sp 1
6320 @cartouche
6321 @noindent
6322 @strong{10}.  Implementation defined pragmas.  See 2.8(14).
6323 @end cartouche
6324 @noindent
6325
6326 @xref{Implementation Defined Pragmas}.
6327
6328 @sp 1
6329 @cartouche
6330 @noindent
6331 @strong{11}.  Effect of pragma @code{Optimize}.  See 2.8(27).
6332 @end cartouche
6333 @noindent
6334 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
6335 parameter, checks that the optimization flag is set, and aborts if it is
6336 not.
6337
6338 @sp 1
6339 @cartouche
6340 @noindent
6341 @strong{12}.  The sequence of characters of the value returned by
6342 @code{@var{S}'Image} when some of the graphic characters of
6343 @code{@var{S}'Wide_Image} are not defined in @code{Character}.  See
6344 3.5(37).
6345 @end cartouche
6346 @noindent
6347 The sequence of characters is as defined by the wide character encoding
6348 method used for the source.  See section on source representation for
6349 further details.
6350
6351 @sp 1
6352 @cartouche
6353 @noindent
6354 @strong{13}.  The predefined integer types declared in
6355 @code{Standard}.  See 3.5.4(25).
6356 @end cartouche
6357 @noindent
6358 @table @code
6359 @item Short_Short_Integer
6360 8 bit signed
6361 @item Short_Integer
6362 (Short) 16 bit signed
6363 @item Integer
6364 32 bit signed
6365 @item Long_Integer
6366 64 bit signed (Alpha OpenVMS only)
6367 32 bit signed (all other targets)
6368 @item Long_Long_Integer
6369 64 bit signed
6370 @end table
6371
6372 @sp 1
6373 @cartouche
6374 @noindent
6375 @strong{14}.  Any nonstandard integer types and the operators defined
6376 for them.  See 3.5.4(26).
6377 @end cartouche
6378 @noindent
6379 There are no nonstandard integer types.
6380
6381 @sp 1
6382 @cartouche
6383 @noindent
6384 @strong{15}.  Any nonstandard real types and the operators defined for
6385 them.  See 3.5.6(8).
6386 @end cartouche
6387 @noindent
6388 There are no nonstandard real types.
6389
6390 @sp 1
6391 @cartouche
6392 @noindent
6393 @strong{16}.  What combinations of requested decimal precision and range
6394 are supported for floating point types.  See 3.5.7(7).
6395 @end cartouche
6396 @noindent
6397 The precision and range is as defined by the IEEE standard.
6398
6399 @sp 1
6400 @cartouche
6401 @noindent
6402 @strong{17}.  The predefined floating point types declared in
6403 @code{Standard}.  See 3.5.7(16).
6404 @end cartouche
6405 @noindent
6406 @table @code
6407 @item Short_Float
6408 32 bit IEEE short
6409 @item Float
6410 (Short) 32 bit IEEE short
6411 @item Long_Float
6412 64 bit IEEE long
6413 @item Long_Long_Float
6414 64 bit IEEE long (80 bit IEEE long on x86 processors)
6415 @end table
6416
6417 @sp 1
6418 @cartouche
6419 @noindent
6420 @strong{18}.  The small of an ordinary fixed point type.  See 3.5.9(8).
6421 @end cartouche
6422 @noindent
6423 @code{Fine_Delta} is 2**(@minus{}63)
6424
6425 @sp 1
6426 @cartouche
6427 @noindent
6428 @strong{19}.  What combinations of small, range, and digits are
6429 supported for fixed point types.  See 3.5.9(10).
6430 @end cartouche
6431 @noindent
6432 Any combinations are permitted that do not result in a small less than
6433 @code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
6434 If the mantissa is larger than 53 bits on machines where Long_Long_Float
6435 is 64 bits (true of all architectures except ia32), then the output from
6436 Text_IO is accurate to only 53 bits, rather than the full mantissa.  This
6437 is because floating-point conversions are used to convert fixed point.
6438
6439 @sp 1
6440 @cartouche
6441 @noindent
6442 @strong{20}.  The result of @code{Tags.Expanded_Name} for types declared
6443 within an unnamed @code{block_statement}.  See 3.9(10).
6444 @end cartouche
6445 @noindent
6446 Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
6447 decimal integer are allocated.
6448
6449 @sp 1
6450 @cartouche
6451 @noindent
6452 @strong{21}.  Implementation-defined attributes.  See 4.1.4(12).
6453 @end cartouche
6454 @noindent
6455 @xref{Implementation Defined Attributes}.
6456
6457 @sp 1
6458 @cartouche
6459 @noindent
6460 @strong{22}.  Any implementation-defined time types.  See 9.6(6).
6461 @end cartouche
6462 @noindent
6463 There are no implementation-defined time types.
6464
6465 @sp 1
6466 @cartouche
6467 @noindent
6468 @strong{23}.  The time base associated with relative delays.
6469 @end cartouche
6470 @noindent
6471 See 9.6(20).  The time base used is that provided by the C library
6472 function @code{gettimeofday}.
6473
6474 @sp 1
6475 @cartouche
6476 @noindent
6477 @strong{24}.  The time base of the type @code{Calendar.Time}.  See
6478 9.6(23).
6479 @end cartouche
6480 @noindent
6481 The time base used is that provided by the C library function
6482 @code{gettimeofday}.
6483
6484 @sp 1
6485 @cartouche
6486 @noindent
6487 @strong{25}.  The time zone used for package @code{Calendar}
6488 operations.  See 9.6(24).
6489 @end cartouche
6490 @noindent
6491 The time zone used by package @code{Calendar} is the current system time zone
6492 setting for local time, as accessed by the C library function
6493 @code{localtime}.
6494
6495 @sp 1
6496 @cartouche
6497 @noindent
6498 @strong{26}.  Any limit on @code{delay_until_statements} of
6499 @code{select_statements}.  See 9.6(29).
6500 @end cartouche
6501 @noindent
6502 There are no such limits.
6503
6504 @sp 1
6505 @cartouche
6506 @noindent
6507 @strong{27}.  Whether or not two non overlapping parts of a composite
6508 object are independently addressable, in the case where packing, record
6509 layout, or @code{Component_Size} is specified for the object.  See
6510 9.10(1).
6511 @end cartouche
6512 @noindent
6513 Separate components are independently addressable if they do not share
6514 overlapping storage units.
6515
6516 @sp 1
6517 @cartouche
6518 @noindent
6519 @strong{28}.  The representation for a compilation.  See 10.1(2).
6520 @end cartouche
6521 @noindent
6522 A compilation is represented by a sequence of files presented to the
6523 compiler in a single invocation of the @code{gcc} command.
6524
6525 @sp 1
6526 @cartouche
6527 @noindent
6528 @strong{29}.  Any restrictions on compilations that contain multiple
6529 compilation_units.  See 10.1(4).
6530 @end cartouche
6531 @noindent
6532 No single file can contain more than one compilation unit, but any
6533 sequence of files can be presented to the compiler as a single
6534 compilation.
6535
6536 @sp 1
6537 @cartouche
6538 @noindent
6539 @strong{30}.  The mechanisms for creating an environment and for adding
6540 and replacing compilation units.  See 10.1.4(3).
6541 @end cartouche
6542 @noindent
6543 See separate section on compilation model.
6544
6545 @sp 1
6546 @cartouche
6547 @noindent
6548 @strong{31}.  The manner of explicitly assigning library units to a
6549 partition.  See 10.2(2).
6550 @end cartouche
6551 @noindent
6552 If a unit contains an Ada main program, then the Ada units for the partition
6553 are determined by recursive application of the rules in the Ada Reference
6554 Manual section 10.2(2-6).  In other words, the Ada units will be those that
6555 are needed by the main program, and then this definition of need is applied
6556 recursively to those units, and the partition contains the transitive
6557 closure determined by this relationship.  In short, all the necessary units
6558 are included, with no need to explicitly specify the list.  If additional
6559 units are required, e.g.@: by foreign language units, then all units must be
6560 mentioned in the context clause of one of the needed Ada units.
6561
6562 If the partition contains no main program, or if the main program is in
6563 a language other than Ada, then GNAT
6564 provides the binder options @code{-z} and @code{-n} respectively, and in
6565 this case a list of units can be explicitly supplied to the binder for
6566 inclusion in the partition (all units needed by these units will also
6567 be included automatically).  For full details on the use of these
6568 options, refer to the @cite{GNAT User's Guide} sections on Binding
6569 and Linking.
6570
6571 @sp 1
6572 @cartouche
6573 @noindent
6574 @strong{32}.  The implementation-defined means, if any, of specifying
6575 which compilation units are needed by a given compilation unit.  See
6576 10.2(2).
6577 @end cartouche
6578 @noindent
6579 The units needed by a given compilation unit are as defined in
6580 the Ada Reference Manual section 10.2(2-6).  There are no
6581 implementation-defined pragmas or other implementation-defined
6582 means for specifying needed units.
6583
6584 @sp 1
6585 @cartouche
6586 @noindent
6587 @strong{33}.  The manner of designating the main subprogram of a
6588 partition.  See 10.2(7).
6589 @end cartouche
6590 @noindent
6591 The main program is designated by providing the name of the
6592 corresponding @file{ALI} file as the input parameter to the binder.
6593
6594 @sp 1
6595 @cartouche
6596 @noindent
6597 @strong{34}.  The order of elaboration of @code{library_items}.  See
6598 10.2(18).
6599 @end cartouche
6600 @noindent
6601 The first constraint on ordering is that it meets the requirements of
6602 chapter 10 of the Ada 95 Reference Manual.  This still leaves some
6603 implementation dependent choices, which are resolved by first
6604 elaborating bodies as early as possible (i.e.@: in preference to specs
6605 where there is a choice), and second by evaluating the immediate with
6606 clauses of a unit to determine the probably best choice, and
6607 third by elaborating in alphabetical order of unit names
6608 where a choice still remains.
6609
6610 @sp 1
6611 @cartouche
6612 @noindent
6613 @strong{35}.  Parameter passing and function return for the main
6614 subprogram.  See 10.2(21).
6615 @end cartouche
6616 @noindent
6617 The main program has no parameters.  It may be a procedure, or a function
6618 returning an integer type.  In the latter case, the returned integer
6619 value is the return code of the program (overriding any value that
6620 may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
6621
6622 @sp 1
6623 @cartouche
6624 @noindent
6625 @strong{36}.  The mechanisms for building and running partitions.  See
6626 10.2(24).
6627 @end cartouche
6628 @noindent
6629 GNAT itself supports programs with only a single partition.  The GNATDIST
6630 tool provided with the GLADE package (which also includes an implementation
6631 of the PCS) provides a completely flexible method for building and running
6632 programs consisting of multiple partitions.  See the separate GLADE manual
6633 for details.
6634
6635 @sp 1
6636 @cartouche
6637 @noindent
6638 @strong{37}.  The details of program execution, including program
6639 termination.  See 10.2(25).
6640 @end cartouche
6641 @noindent
6642 See separate section on compilation model.
6643
6644 @sp 1
6645 @cartouche
6646 @noindent
6647 @strong{38}.  The semantics of any non-active partitions supported by the
6648 implementation.  See 10.2(28).
6649 @end cartouche
6650 @noindent
6651 Passive partitions are supported on targets where shared memory is
6652 provided by the operating system.  See the GLADE reference manual for
6653 further details.
6654
6655 @sp 1
6656 @cartouche
6657 @noindent
6658 @strong{39}.  The information returned by @code{Exception_Message}.  See
6659 11.4.1(10).
6660 @end cartouche
6661 @noindent
6662 Exception message returns the null string unless a specific message has
6663 been passed by the program.
6664
6665 @sp 1
6666 @cartouche
6667 @noindent
6668 @strong{40}.  The result of @code{Exceptions.Exception_Name} for types
6669 declared within an unnamed @code{block_statement}.  See 11.4.1(12).
6670 @end cartouche
6671 @noindent
6672 Blocks have implementation defined names of the form @code{B@var{nnn}}
6673 where @var{nnn} is an integer.
6674
6675 @sp 1
6676 @cartouche
6677 @noindent
6678 @strong{41}.  The information returned by
6679 @code{Exception_Information}.  See 11.4.1(13).
6680 @end cartouche
6681 @noindent
6682 @code{Exception_Information} returns a string in the following format:
6683
6684 @smallexample
6685 @emph{Exception_Name:} nnnnn
6686 @emph{Message:} mmmmm
6687 @emph{PID:} ppp
6688 @emph{Call stack traceback locations:}
6689 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
6690 @end smallexample
6691
6692 @noindent
6693 where
6694
6695 @itemize @bullet
6696 @item
6697 @code{nnnn} is the fully qualified name of the exception in all upper
6698 case letters. This line is always present.
6699
6700 @item
6701 @code{mmmm} is the message (this line present only if message is non-null)
6702
6703 @item
6704 @code{ppp} is the Process Id value as a decimal integer (this line is
6705 present only if the Process Id is non-zero). Currently we are
6706 not making use of this field.
6707
6708 @item
6709 The Call stack traceback locations line and the following values
6710 are present only if at least one traceback location was recorded.
6711 The values are given in C style format, with lower case letters
6712 for a-f, and only as many digits present as are necessary.
6713 @end itemize
6714
6715 @noindent
6716 The line terminator sequence at the end of each line, including
6717 the last line is a single @code{LF} character (@code{16#0A#}).
6718
6719 @sp 1
6720 @cartouche
6721 @noindent
6722 @strong{42}.  Implementation-defined check names.  See 11.5(27).
6723 @end cartouche
6724 @noindent
6725 No implementation-defined check names are supported.
6726
6727 @sp 1
6728 @cartouche
6729 @noindent
6730 @strong{43}.  The interpretation of each aspect of representation.  See
6731 13.1(20).
6732 @end cartouche
6733 @noindent
6734 See separate section on data representations.
6735
6736 @sp 1
6737 @cartouche
6738 @noindent
6739 @strong{44}.  Any restrictions placed upon representation items.  See
6740 13.1(20).
6741 @end cartouche
6742 @noindent
6743 See separate section on data representations.
6744
6745 @sp 1
6746 @cartouche
6747 @noindent
6748 @strong{45}.  The meaning of @code{Size} for indefinite subtypes.  See
6749 13.3(48).
6750 @end cartouche
6751 @noindent
6752 Size for an indefinite subtype is the maximum possible size, except that
6753 for the case of a subprogram parameter, the size of the parameter object
6754 is the actual size.
6755
6756 @sp 1
6757 @cartouche
6758 @noindent
6759 @strong{46}.  The default external representation for a type tag.  See
6760 13.3(75).
6761 @end cartouche
6762 @noindent
6763 The default external representation for a type tag is the fully expanded
6764 name of the type in upper case letters.
6765
6766 @sp 1
6767 @cartouche
6768 @noindent
6769 @strong{47}.  What determines whether a compilation unit is the same in
6770 two different partitions.  See 13.3(76).
6771 @end cartouche
6772 @noindent
6773 A compilation unit is the same in two different partitions if and only
6774 if it derives from the same source file.
6775
6776 @sp 1
6777 @cartouche
6778 @noindent
6779 @strong{48}.  Implementation-defined components.  See 13.5.1(15).
6780 @end cartouche
6781 @noindent
6782 The only implementation defined component is the tag for a tagged type,
6783 which contains a pointer to the dispatching table.
6784
6785 @sp 1
6786 @cartouche
6787 @noindent
6788 @strong{49}.  If @code{Word_Size} = @code{Storage_Unit}, the default bit
6789 ordering.  See 13.5.3(5).
6790 @end cartouche
6791 @noindent
6792 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
6793 implementation, so no non-default bit ordering is supported.  The default
6794 bit ordering corresponds to the natural endianness of the target architecture.
6795
6796 @sp 1
6797 @cartouche
6798 @noindent
6799 @strong{50}.  The contents of the visible part of package @code{System}
6800 and its language-defined children.  See 13.7(2).
6801 @end cartouche
6802 @noindent
6803 See the definition of these packages in files @file{system.ads} and
6804 @file{s-stoele.ads}.
6805
6806 @sp 1
6807 @cartouche
6808 @noindent
6809 @strong{51}.  The contents of the visible part of package
6810 @code{System.Machine_Code}, and the meaning of
6811 @code{code_statements}.  See 13.8(7).
6812 @end cartouche
6813 @noindent
6814 See the definition and documentation in file @file{s-maccod.ads}.
6815
6816 @sp 1
6817 @cartouche
6818 @noindent
6819 @strong{52}.  The effect of unchecked conversion.  See 13.9(11).
6820 @end cartouche
6821 @noindent
6822 Unchecked conversion between types of the same size
6823 and results in an uninterpreted transmission of the bits from one type
6824 to the other.  If the types are of unequal sizes, then in the case of
6825 discrete types, a shorter source is first zero or sign extended as
6826 necessary, and a shorter target is simply truncated on the left.
6827 For all non-discrete types, the source is first copied if necessary
6828 to ensure that the alignment requirements of the target are met, then
6829 a pointer is constructed to the source value, and the result is obtained
6830 by dereferencing this pointer after converting it to be a pointer to the
6831 target type.
6832
6833 @sp 1
6834 @cartouche
6835 @noindent
6836 @strong{53}.  The manner of choosing a storage pool for an access type
6837 when @code{Storage_Pool} is not specified for the type.  See 13.11(17).
6838 @end cartouche
6839 @noindent
6840 There are 3 different standard pools used by the compiler when
6841 @code{Storage_Pool} is not specified depending whether the type is local
6842 to a subprogram or defined at the library level and whether
6843 @code{Storage_Size}is specified or not.  See documentation in the runtime
6844 library units @code{System.Pool_Global}, @code{System.Pool_Size} and
6845 @code{System.Pool_Local} in files @file{s-poosiz.ads},
6846 @file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
6847 default pools used.
6848
6849 @sp 1
6850 @cartouche
6851 @noindent
6852 @strong{54}.  Whether or not the implementation provides user-accessible
6853 names for the standard pool type(s).  See 13.11(17).
6854 @end cartouche
6855 @noindent
6856
6857 See documentation in the sources of the run time mentioned in paragraph
6858 @strong{53} .  All these pools are accessible by means of @code{with}'ing
6859 these units.
6860
6861 @sp 1
6862 @cartouche
6863 @noindent
6864 @strong{55}.  The meaning of @code{Storage_Size}.  See 13.11(18).
6865 @end cartouche
6866 @noindent
6867 @code{Storage_Size} is measured in storage units, and refers to the
6868 total space available for an access type collection, or to the primary
6869 stack space for a task.
6870
6871 @sp 1
6872 @cartouche
6873 @noindent
6874 @strong{56}.  Implementation-defined aspects of storage pools.  See
6875 13.11(22).
6876 @end cartouche
6877 @noindent
6878 See documentation in the sources of the run time mentioned in paragraph
6879 @strong{53} for details on GNAT-defined aspects of storage pools.
6880
6881 @sp 1
6882 @cartouche
6883 @noindent
6884 @strong{57}.  The set of restrictions allowed in a pragma
6885 @code{Restrictions}.  See 13.12(7).
6886 @end cartouche
6887 @noindent
6888 All RM defined Restriction identifiers are implemented.  The following
6889 additional restriction identifiers are provided.  There are two separate
6890 lists of implementation dependent restriction identifiers.  The first
6891 set requires consistency throughout a partition (in other words, if the
6892 restriction identifier is used for any compilation unit in the partition,
6893 then all compilation units in the partition must obey the restriction.
6894
6895 @table @code
6896
6897 @item Simple_Barriers
6898 @findex Simple_Barriers
6899 This restriction ensures at compile time that barriers in entry declarations
6900 for protected types are restricted to either static boolean expressions or
6901 references to simple boolean variables defined in the private part of the
6902 protected type.  No other form of entry barriers is permitted.  This is one
6903 of the restrictions of the Ravenscar profile for limited tasking (see also
6904 pragma @code{Profile (Ravenscar)}).
6905
6906 @item Max_Entry_Queue_Length => Expr
6907 @findex Max_Entry_Queue_Length
6908 This restriction is a declaration that any protected entry compiled in
6909 the scope of the restriction has at most the specified number of
6910 tasks waiting on the entry
6911 at any one time, and so no queue is required.  This restriction is not
6912 checked at compile time.  A program execution is erroneous if an attempt
6913 is made to queue more than the specified number of tasks on such an entry.
6914
6915 @item No_Calendar
6916 @findex No_Calendar
6917 This restriction ensures at compile time that there is no implicit or
6918 explicit dependence on the package @code{Ada.Calendar}.
6919
6920 @item No_Direct_Boolean_Operators
6921 @findex No_Direct_Boolean_Operators
6922 This restriction ensures that no logical (and/or/xor) or comparison
6923 operators are used on operands of type Boolean (or any type derived
6924 from Boolean). This is intended for use in safety critical programs
6925 where the certification protocol requires the use of short-circuit
6926 (and then, or else) forms for all composite boolean operations.
6927
6928 @item No_Dynamic_Attachment
6929 @findex No_Dynamic_Attachment
6930 This restriction ensures that there is no call to any of the operations
6931 defined in package Ada.Interrupts.
6932
6933 @item No_Enumeration_Maps
6934 @findex No_Enumeration_Maps
6935 This restriction ensures at compile time that no operations requiring
6936 enumeration maps are used (that is Image and Value attributes applied
6937 to enumeration types).
6938
6939 @item No_Entry_Calls_In_Elaboration_Code
6940 @findex No_Entry_Calls_In_Elaboration_Code
6941 This restriction ensures at compile time that no task or protected entry
6942 calls are made during elaboration code.  As a result of the use of this
6943 restriction, the compiler can assume that no code past an accept statement
6944 in a task can be executed at elaboration time.
6945
6946 @item No_Exception_Handlers
6947 @findex No_Exception_Handlers
6948 This restriction ensures at compile time that there are no explicit
6949 exception handlers. It also indicates that no exception propagation will
6950 be provided. In this mode, exceptions may be raised but will result in
6951 an immediate call to the last chance handler, a routine that the user
6952 must define with the following profile:
6953
6954    procedure Last_Chance_Handler
6955      (Source_Location : System.Address; Line : Integer);
6956    pragma Export (C, Last_Chance_Handler,
6957                   "__gnat_last_chance_handler");
6958
6959    The parameter is a C null-terminated string representing a message to be
6960    associated with the exception (typically the source location of the raise
6961    statement generated by the compiler). The Line parameter when non-zero
6962    represents the line number in the source program where the raise occurs.
6963
6964 @item No_Exception_Streams
6965 @findex No_Exception_Streams
6966 This restriction ensures at compile time that no stream operations for
6967 types Exception_Id or Exception_Occurrence are used. This also makes it
6968 impossible to pass exceptions to or from a partition with this restriction
6969 in a distributed environment. If this exception is active, then the generated
6970 code is simplified by omitting the otherwise-required global registration
6971 of exceptions when they are declared.
6972
6973 @item No_Implicit_Conditionals
6974 @findex No_Implicit_Conditionals
6975 This restriction ensures that the generated code does not contain any
6976 implicit conditionals, either by modifying the generated code where possible,
6977 or by rejecting any construct that would otherwise generate an implicit
6978 conditional.
6979
6980 @item No_Implicit_Dynamic_Code
6981 @findex No_Implicit_Dynamic_Code
6982 This restriction prevents the compiler from building ``trampolines''.
6983 This is a structure that is built on the stack and contains dynamic
6984 code to be executed at run time. A trampoline is needed to indirectly
6985 address a nested subprogram (that is a subprogram that is not at the
6986 library level). The restriction prevents the use of any of the
6987 attributes @code{Address}, @code{Access} or @code{Unrestricted_Access}
6988 being applied to a subprogram that is not at the library level.
6989
6990 @item No_Implicit_Loops
6991 @findex No_Implicit_Loops
6992 This restriction ensures that the generated code does not contain any
6993 implicit @code{for} loops, either by modifying
6994 the generated code where possible,
6995 or by rejecting any construct that would otherwise generate an implicit
6996 @code{for} loop.
6997
6998 @item No_Initialize_Scalars
6999 @findex No_Initialize_Scalars
7000 This restriction ensures that no unit in the partition is compiled with
7001 pragma Initialize_Scalars. This allows the generation of more efficient
7002 code, and in particular eliminates dummy null initialization routines that
7003 are otherwise generated for some record and array types.
7004
7005 @item No_Local_Protected_Objects
7006 @findex No_Local_Protected_Objects
7007 This restriction ensures at compile time that protected objects are
7008 only declared at the library level.
7009
7010 @item No_Protected_Type_Allocators
7011 @findex No_Protected_Type_Allocators
7012 This restriction ensures at compile time that there are no allocator
7013 expressions that attempt to allocate protected objects.
7014
7015 @item No_Secondary_Stack
7016 @findex No_Secondary_Stack
7017 This restriction ensures at compile time that the generated code does not
7018 contain any reference to the secondary stack.  The secondary stack is used
7019 to implement functions returning unconstrained objects (arrays or records)
7020 on some targets.
7021
7022 @item No_Select_Statements
7023 @findex No_Select_Statements
7024 This restriction ensures at compile time no select statements of any kind
7025 are permitted, that is the keyword @code{select} may not appear.
7026 This is one of the restrictions of the Ravenscar
7027 profile for limited tasking (see also pragma @code{Profile (Ravenscar)}).
7028
7029 @item No_Standard_Storage_Pools
7030 @findex No_Standard_Storage_Pools
7031 This restriction ensures at compile time that no access types
7032 use the standard default storage pool.  Any access type declared must
7033 have an explicit Storage_Pool attribute defined specifying a
7034 user-defined storage pool.
7035
7036 @item No_Streams
7037 @findex No_Streams
7038 This restriction ensures at compile time that there are no implicit or
7039 explicit dependencies on the package @code{Ada.Streams}.
7040
7041 @item No_Task_Attributes_Package
7042 @findex No_Task_Attributes_Package
7043 This restriction ensures at compile time that there are no implicit or
7044 explicit dependencies on the package @code{Ada.Task_Attributes}.
7045
7046 @item No_Task_Termination
7047 @findex No_Task_Termination
7048 This restriction ensures at compile time that no terminate alternatives
7049 appear in any task body.
7050
7051 @item No_Tasking
7052 @findex No_Tasking
7053 This restriction prevents the declaration of tasks or task types throughout
7054 the partition.  It is similar in effect to the use of @code{Max_Tasks => 0}
7055 except that violations are caught at compile time and cause an error message
7056 to be output either by the compiler or binder.
7057
7058 @item No_Wide_Characters
7059 @findex No_Wide_Characters
7060 This restriction ensures at compile time that no uses of the types
7061 @code{Wide_Character} or @code{Wide_String}
7062 appear, and that no wide character literals
7063 appear in the program (that is literals representing characters not in
7064 type @code{Character}.
7065
7066 @item Static_Priorities
7067 @findex Static_Priorities
7068 This restriction ensures at compile time that all priority expressions
7069 are static, and that there are no dependencies on the package
7070 @code{Ada.Dynamic_Priorities}.
7071
7072 @item Static_Storage_Size
7073 @findex Static_Storage_Size
7074 This restriction ensures at compile time that any expression appearing
7075 in a Storage_Size pragma or attribute definition clause is static.
7076
7077 @end table
7078
7079 @noindent
7080 The second set of implementation dependent restriction identifiers
7081 does not require partition-wide consistency.
7082 The restriction may be enforced for a single
7083 compilation unit without any effect on any of the
7084 other compilation units in the partition.
7085
7086 @table @code
7087
7088 @item No_Elaboration_Code
7089 @findex No_Elaboration_Code
7090 This restriction ensures at compile time that no elaboration code is
7091 generated.  Note that this is not the same condition as is enforced
7092 by pragma @code{Preelaborate}.  There are cases in which pragma
7093 @code{Preelaborate} still permits code to be generated (e.g.@: code
7094 to initialize a large array to all zeroes), and there are cases of units
7095 which do not meet the requirements for pragma @code{Preelaborate},
7096 but for which no elaboration code is generated.  Generally, it is
7097 the case that preelaborable units will meet the restrictions, with
7098 the exception of large aggregates initialized with an others_clause,
7099 and exception declarations (which generate calls to a run-time
7100 registry procedure).  Note that this restriction is enforced on
7101 a unit by unit basis, it need not be obeyed consistently
7102 throughout a partition.
7103
7104 @item No_Entry_Queue
7105 @findex No_Entry_Queue
7106 This restriction is a declaration that any protected entry compiled in
7107 the scope of the restriction has at most one task waiting on the entry
7108 at any one time, and so no queue is required.  This restriction is not
7109 checked at compile time.  A program execution is erroneous if an attempt
7110 is made to queue a second task on such an entry.
7111
7112 @item No_Implementation_Attributes
7113 @findex No_Implementation_Attributes
7114 This restriction checks at compile time that no GNAT-defined attributes
7115 are present.  With this restriction, the only attributes that can be used
7116 are those defined in the Ada 95 Reference Manual.
7117
7118 @item No_Implementation_Pragmas
7119 @findex No_Implementation_Pragmas
7120 This restriction checks at compile time that no GNAT-defined pragmas
7121 are present.  With this restriction, the only pragmas that can be used
7122 are those defined in the Ada 95 Reference Manual.
7123
7124 @item No_Implementation_Restrictions
7125 @findex No_Implementation_Restrictions
7126 This restriction checks at compile time that no GNAT-defined restriction
7127 identifiers (other than @code{No_Implementation_Restrictions} itself)
7128 are present.  With this restriction, the only other restriction identifiers
7129 that can be used are those defined in the Ada 95 Reference Manual.
7130
7131 @end table
7132
7133 @sp 1
7134 @cartouche
7135 @noindent
7136 @strong{58}.  The consequences of violating limitations on
7137 @code{Restrictions} pragmas.  See 13.12(9).
7138 @end cartouche
7139 @noindent
7140 Restrictions that can be checked at compile time result in illegalities
7141 if violated.  Currently there are no other consequences of violating
7142 restrictions.
7143
7144 @sp 1
7145 @cartouche
7146 @noindent
7147 @strong{59}.  The representation used by the @code{Read} and
7148 @code{Write} attributes of elementary types in terms of stream
7149 elements.  See 13.13.2(9).
7150 @end cartouche
7151 @noindent
7152 The representation is the in-memory representation of the base type of
7153 the type, using the number of bits corresponding to the
7154 @code{@var{type}'Size} value, and the natural ordering of the machine.
7155
7156 @sp 1
7157 @cartouche
7158 @noindent
7159 @strong{60}.  The names and characteristics of the numeric subtypes
7160 declared in the visible part of package @code{Standard}.  See A.1(3).
7161 @end cartouche
7162 @noindent
7163 See items describing the integer and floating-point types supported.
7164
7165 @sp 1
7166 @cartouche
7167 @noindent
7168 @strong{61}.  The accuracy actually achieved by the elementary
7169 functions.  See A.5.1(1).
7170 @end cartouche
7171 @noindent
7172 The elementary functions correspond to the functions available in the C
7173 library.  Only fast math mode is implemented.
7174
7175 @sp 1
7176 @cartouche
7177 @noindent
7178 @strong{62}.  The sign of a zero result from some of the operators or
7179 functions in @code{Numerics.Generic_Elementary_Functions}, when
7180 @code{Float_Type'Signed_Zeros} is @code{True}.  See A.5.1(46).
7181 @end cartouche
7182 @noindent
7183 The sign of zeroes follows the requirements of the IEEE 754 standard on
7184 floating-point.
7185
7186 @sp 1
7187 @cartouche
7188 @noindent
7189 @strong{63}.  The value of
7190 @code{Numerics.Float_Random.Max_Image_Width}.  See A.5.2(27).
7191 @end cartouche
7192 @noindent
7193 Maximum image width is 649, see library file @file{a-numran.ads}.
7194
7195 @sp 1
7196 @cartouche
7197 @noindent
7198 @strong{64}.  The value of
7199 @code{Numerics.Discrete_Random.Max_Image_Width}.  See A.5.2(27).
7200 @end cartouche
7201 @noindent
7202 Maximum image width is 80, see library file @file{a-nudira.ads}.
7203
7204 @sp 1
7205 @cartouche
7206 @noindent
7207 @strong{65}.  The algorithms for random number generation.  See
7208 A.5.2(32).
7209 @end cartouche
7210 @noindent
7211 The algorithm is documented in the source files @file{a-numran.ads} and
7212 @file{a-numran.adb}.
7213
7214 @sp 1
7215 @cartouche
7216 @noindent
7217 @strong{66}.  The string representation of a random number generator's
7218 state.  See A.5.2(38).
7219 @end cartouche
7220 @noindent
7221 See the documentation contained in the file @file{a-numran.adb}.
7222
7223 @sp 1
7224 @cartouche
7225 @noindent
7226 @strong{67}.  The minimum time interval between calls to the
7227 time-dependent Reset procedure that are guaranteed to initiate different
7228 random number sequences.  See A.5.2(45).
7229 @end cartouche
7230 @noindent
7231 The minimum period between reset calls to guarantee distinct series of
7232 random numbers is one microsecond.
7233
7234 @sp 1
7235 @cartouche
7236 @noindent
7237 @strong{68}.  The values of the @code{Model_Mantissa},
7238 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
7239 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
7240 Annex is not supported.  See A.5.3(72).
7241 @end cartouche
7242 @noindent
7243 See the source file @file{ttypef.ads} for the values of all numeric
7244 attributes.
7245
7246 @sp 1
7247 @cartouche
7248 @noindent
7249 @strong{69}.  Any implementation-defined characteristics of the
7250 input-output packages.  See A.7(14).
7251 @end cartouche
7252 @noindent
7253 There are no special implementation defined characteristics for these
7254 packages.
7255
7256 @sp 1
7257 @cartouche
7258 @noindent
7259 @strong{70}.  The value of @code{Buffer_Size} in @code{Storage_IO}.  See
7260 A.9(10).
7261 @end cartouche
7262 @noindent
7263 All type representations are contiguous, and the @code{Buffer_Size} is
7264 the value of @code{@var{type}'Size} rounded up to the next storage unit
7265 boundary.
7266
7267 @sp 1
7268 @cartouche
7269 @noindent
7270 @strong{71}.  External files for standard input, standard output, and
7271 standard error See A.10(5).
7272 @end cartouche
7273 @noindent
7274 These files are mapped onto the files provided by the C streams
7275 libraries.  See source file @file{i-cstrea.ads} for further details.
7276
7277 @sp 1
7278 @cartouche
7279 @noindent
7280 @strong{72}.  The accuracy of the value produced by @code{Put}.  See
7281 A.10.9(36).
7282 @end cartouche
7283 @noindent
7284 If more digits are requested in the output than are represented by the
7285 precision of the value, zeroes are output in the corresponding least
7286 significant digit positions.
7287
7288 @sp 1
7289 @cartouche
7290 @noindent
7291 @strong{73}.  The meaning of @code{Argument_Count}, @code{Argument}, and
7292 @code{Command_Name}.  See A.15(1).
7293 @end cartouche
7294 @noindent
7295 These are mapped onto the @code{argv} and @code{argc} parameters of the
7296 main program in the natural manner.
7297
7298 @sp 1
7299 @cartouche
7300 @noindent
7301 @strong{74}.  Implementation-defined convention names.  See B.1(11).
7302 @end cartouche
7303 @noindent
7304 The following convention names are supported
7305
7306 @table @code
7307 @item  Ada
7308 Ada
7309 @item Assembler
7310 Assembly language
7311 @item Asm
7312 Synonym for Assembler
7313 @item Assembly
7314 Synonym for Assembler
7315 @item C
7316 C
7317 @item C_Pass_By_Copy
7318 Allowed only for record types, like C, but also notes that record
7319 is to be passed by copy rather than reference.
7320 @item COBOL
7321 COBOL
7322 @item CPP
7323 C++
7324 @item Default
7325 Treated the same as C
7326 @item External
7327 Treated the same as C
7328 @item Fortran
7329 Fortran
7330 @item Intrinsic
7331 For support of pragma @code{Import} with convention Intrinsic, see
7332 separate section on Intrinsic Subprograms.
7333 @item Stdcall
7334 Stdcall (used for Windows implementations only).  This convention correspond
7335 to the WINAPI (previously called Pascal convention) C/C++ convention under
7336 Windows.  A function with this convention cleans the stack before exit.
7337 @item DLL
7338 Synonym for Stdcall
7339 @item Win32
7340 Synonym for Stdcall
7341 @item Stubbed
7342 Stubbed is a special convention used to indicate that the body of the
7343 subprogram will be entirely ignored.  Any call to the subprogram
7344 is converted into a raise of the @code{Program_Error} exception.  If a
7345 pragma @code{Import} specifies convention @code{stubbed} then no body need
7346 be present at all.  This convention is useful during development for the
7347 inclusion of subprograms whose body has not yet been written.
7348
7349 @end table
7350 @noindent
7351 In addition, all otherwise unrecognized convention names are also
7352 treated as being synonymous with convention C@.  In all implementations
7353 except for VMS, use of such other names results in a warning.  In VMS
7354 implementations, these names are accepted silently.
7355
7356 @sp 1
7357 @cartouche
7358 @noindent
7359 @strong{75}.  The meaning of link names.  See B.1(36).
7360 @end cartouche
7361 @noindent
7362 Link names are the actual names used by the linker.
7363
7364 @sp 1
7365 @cartouche
7366 @noindent
7367 @strong{76}.  The manner of choosing link names when neither the link
7368 name nor the address of an imported or exported entity is specified.  See
7369 B.1(36).
7370 @end cartouche
7371 @noindent
7372 The default linker name is that which would be assigned by the relevant
7373 external language, interpreting the Ada name as being in all lower case
7374 letters.
7375
7376 @sp 1
7377 @cartouche
7378 @noindent
7379 @strong{77}.  The effect of pragma @code{Linker_Options}.  See B.1(37).
7380 @end cartouche
7381 @noindent
7382 The string passed to @code{Linker_Options} is presented uninterpreted as
7383 an argument to the link command, unless it contains Ascii.NUL characters.
7384 NUL characters if they appear act as argument separators, so for example
7385
7386 @smallexample @c ada
7387 pragma Linker_Options ("-labc" & ASCII.Nul & "-ldef");
7388 @end smallexample
7389
7390 @noindent
7391 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
7392 linker. The order of linker options is preserved for a given unit. The final
7393 list of options passed to the linker is in reverse order of the elaboration
7394 order. For example, linker options fo a body always appear before the options
7395 from the corresponding package spec.
7396
7397 @sp 1
7398 @cartouche
7399 @noindent
7400 @strong{78}.  The contents of the visible part of package
7401 @code{Interfaces} and its language-defined descendants.  See B.2(1).
7402 @end cartouche
7403 @noindent
7404 See files with prefix @file{i-} in the distributed library.
7405
7406 @sp 1
7407 @cartouche
7408 @noindent
7409 @strong{79}.  Implementation-defined children of package
7410 @code{Interfaces}.  The contents of the visible part of package
7411 @code{Interfaces}.  See B.2(11).
7412 @end cartouche
7413 @noindent
7414 See files with prefix @file{i-} in the distributed library.
7415
7416 @sp 1
7417 @cartouche
7418 @noindent
7419 @strong{80}.  The types @code{Floating}, @code{Long_Floating},
7420 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
7421 @code{COBOL_Character}; and the initialization of the variables
7422 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
7423 @code{Interfaces.COBOL}.  See B.4(50).
7424 @end cartouche
7425 @noindent
7426 @table @code
7427 @item Floating
7428 Float
7429 @item Long_Floating
7430 (Floating) Long_Float
7431 @item Binary
7432 Integer
7433 @item Long_Binary
7434 Long_Long_Integer
7435 @item Decimal_Element
7436 Character
7437 @item COBOL_Character
7438 Character
7439 @end table
7440
7441 @noindent
7442 For initialization, see the file @file{i-cobol.ads} in the distributed library.
7443
7444 @sp 1
7445 @cartouche
7446 @noindent
7447 @strong{81}.  Support for access to machine instructions.  See C.1(1).
7448 @end cartouche
7449 @noindent
7450 See documentation in file @file{s-maccod.ads} in the distributed library.
7451
7452 @sp 1
7453 @cartouche
7454 @noindent
7455 @strong{82}.  Implementation-defined aspects of access to machine
7456 operations.  See C.1(9).
7457 @end cartouche
7458 @noindent
7459 See documentation in file @file{s-maccod.ads} in the distributed library.
7460
7461 @sp 1
7462 @cartouche
7463 @noindent
7464 @strong{83}.  Implementation-defined aspects of interrupts.  See C.3(2).
7465 @end cartouche
7466 @noindent
7467 Interrupts are mapped to signals or conditions as appropriate.  See
7468 definition of unit
7469 @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
7470 on the interrupts supported on a particular target.
7471
7472 @sp 1
7473 @cartouche
7474 @noindent
7475 @strong{84}.  Implementation-defined aspects of pre-elaboration.  See
7476 C.4(13).
7477 @end cartouche
7478 @noindent
7479 GNAT does not permit a partition to be restarted without reloading,
7480 except under control of the debugger.
7481
7482 @sp 1
7483 @cartouche
7484 @noindent
7485 @strong{85}.  The semantics of pragma @code{Discard_Names}.  See C.5(7).
7486 @end cartouche
7487 @noindent
7488 Pragma @code{Discard_Names} causes names of enumeration literals to
7489 be suppressed.  In the presence of this pragma, the Image attribute
7490 provides the image of the Pos of the literal, and Value accepts
7491 Pos values.
7492
7493 @sp 1
7494 @cartouche
7495 @noindent
7496 @strong{86}.  The result of the @code{Task_Identification.Image}
7497 attribute.  See C.7.1(7).
7498 @end cartouche
7499 @noindent
7500 The result of this attribute is an 8-digit hexadecimal string
7501 representing the virtual address of the task control block.
7502
7503 @sp 1
7504 @cartouche
7505 @noindent
7506 @strong{87}.  The value of @code{Current_Task} when in a protected entry
7507 or interrupt handler.  See C.7.1(17).
7508 @end cartouche
7509 @noindent
7510 Protected entries or interrupt handlers can be executed by any
7511 convenient thread, so the value of @code{Current_Task} is undefined.
7512
7513 @sp 1
7514 @cartouche
7515 @noindent
7516 @strong{88}.  The effect of calling @code{Current_Task} from an entry
7517 body or interrupt handler.  See C.7.1(19).
7518 @end cartouche
7519 @noindent
7520 The effect of calling @code{Current_Task} from an entry body or
7521 interrupt handler is to return the identification of the task currently
7522 executing the code.
7523
7524 @sp 1
7525 @cartouche
7526 @noindent
7527 @strong{89}.  Implementation-defined aspects of
7528 @code{Task_Attributes}.  See C.7.2(19).
7529 @end cartouche
7530 @noindent
7531 There are no implementation-defined aspects of @code{Task_Attributes}.
7532
7533 @sp 1
7534 @cartouche
7535 @noindent
7536 @strong{90}.  Values of all @code{Metrics}.  See D(2).
7537 @end cartouche
7538 @noindent
7539 The metrics information for GNAT depends on the performance of the
7540 underlying operating system.  The sources of the run-time for tasking
7541 implementation, together with the output from @code{-gnatG} can be
7542 used to determine the exact sequence of operating systems calls made
7543 to implement various tasking constructs.  Together with appropriate
7544 information on the performance of the underlying operating system,
7545 on the exact target in use, this information can be used to determine
7546 the required metrics.
7547
7548 @sp 1
7549 @cartouche
7550 @noindent
7551 @strong{91}.  The declarations of @code{Any_Priority} and
7552 @code{Priority}.  See D.1(11).
7553 @end cartouche
7554 @noindent
7555 See declarations in file @file{system.ads}.
7556
7557 @sp 1
7558 @cartouche
7559 @noindent
7560 @strong{92}.  Implementation-defined execution resources.  See D.1(15).
7561 @end cartouche
7562 @noindent
7563 There are no implementation-defined execution resources.
7564
7565 @sp 1
7566 @cartouche
7567 @noindent
7568 @strong{93}.  Whether, on a multiprocessor, a task that is waiting for
7569 access to a protected object keeps its processor busy.  See D.2.1(3).
7570 @end cartouche
7571 @noindent
7572 On a multi-processor, a task that is waiting for access to a protected
7573 object does not keep its processor busy.
7574
7575 @sp 1
7576 @cartouche
7577 @noindent
7578 @strong{94}.  The affect of implementation defined execution resources
7579 on task dispatching.  See D.2.1(9).
7580 @end cartouche
7581 @noindent
7582 @c SGI info
7583 @ignore
7584 Tasks map to IRIX threads, and the dispatching policy is as defined by
7585 the IRIX implementation of threads.
7586 @end ignore
7587 Tasks map to threads in the threads package used by GNAT@.  Where possible
7588 and appropriate, these threads correspond to native threads of the
7589 underlying operating system.
7590
7591 @sp 1
7592 @cartouche
7593 @noindent
7594 @strong{95}.  Implementation-defined @code{policy_identifiers} allowed
7595 in a pragma @code{Task_Dispatching_Policy}.  See D.2.2(3).
7596 @end cartouche
7597 @noindent
7598 There are no implementation-defined policy-identifiers allowed in this
7599 pragma.
7600
7601 @sp 1
7602 @cartouche
7603 @noindent
7604 @strong{96}.  Implementation-defined aspects of priority inversion.  See
7605 D.2.2(16).
7606 @end cartouche
7607 @noindent
7608 Execution of a task cannot be preempted by the implementation processing
7609 of delay expirations for lower priority tasks.
7610
7611 @sp 1
7612 @cartouche
7613 @noindent
7614 @strong{97}.  Implementation defined task dispatching.  See D.2.2(18).
7615 @end cartouche
7616 @noindent
7617 @c SGI info:
7618 @ignore
7619 Tasks map to IRIX threads, and the dispatching policy is as defied by
7620 the IRIX implementation of threads.
7621 @end ignore
7622 The policy is the same as that of the underlying threads implementation.
7623
7624 @sp 1
7625 @cartouche
7626 @noindent
7627 @strong{98}.  Implementation-defined @code{policy_identifiers} allowed
7628 in a pragma @code{Locking_Policy}.  See D.3(4).
7629 @end cartouche
7630 @noindent
7631 The only implementation defined policy permitted in GNAT is
7632 @code{Inheritance_Locking}.  On targets that support this policy, locking
7633 is implemented by inheritance, i.e.@: the task owning the lock operates
7634 at a priority equal to the highest priority of any task currently
7635 requesting the lock.
7636
7637 @sp 1
7638 @cartouche
7639 @noindent
7640 @strong{99}.  Default ceiling priorities.  See D.3(10).
7641 @end cartouche
7642 @noindent
7643 The ceiling priority of protected objects of the type
7644 @code{System.Interrupt_Priority'Last} as described in the Ada 95
7645 Reference Manual D.3(10),
7646
7647 @sp 1
7648 @cartouche
7649 @noindent
7650 @strong{100}.  The ceiling of any protected object used internally by
7651 the implementation.  See D.3(16).
7652 @end cartouche
7653 @noindent
7654 The ceiling priority of internal protected objects is
7655 @code{System.Priority'Last}.
7656
7657 @sp 1
7658 @cartouche
7659 @noindent
7660 @strong{101}.  Implementation-defined queuing policies.  See D.4(1).
7661 @end cartouche
7662 @noindent
7663 There are no implementation-defined queueing policies.
7664
7665 @sp 1
7666 @cartouche
7667 @noindent
7668 @strong{102}.  On a multiprocessor, any conditions that cause the
7669 completion of an aborted construct to be delayed later than what is
7670 specified for a single processor.  See D.6(3).
7671 @end cartouche
7672 @noindent
7673 The semantics for abort on a multi-processor is the same as on a single
7674 processor, there are no further delays.
7675
7676 @sp 1
7677 @cartouche
7678 @noindent
7679 @strong{103}.  Any operations that implicitly require heap storage
7680 allocation.  See D.7(8).
7681 @end cartouche
7682 @noindent
7683 The only operation that implicitly requires heap storage allocation is
7684 task creation.
7685
7686 @sp 1
7687 @cartouche
7688 @noindent
7689 @strong{104}.  Implementation-defined aspects of pragma
7690 @code{Restrictions}.  See D.7(20).
7691 @end cartouche
7692 @noindent
7693 There are no such implementation-defined aspects.
7694
7695 @sp 1
7696 @cartouche
7697 @noindent
7698 @strong{105}.  Implementation-defined aspects of package
7699 @code{Real_Time}.  See D.8(17).
7700 @end cartouche
7701 @noindent
7702 There are no implementation defined aspects of package @code{Real_Time}.
7703
7704 @sp 1
7705 @cartouche
7706 @noindent
7707 @strong{106}.  Implementation-defined aspects of
7708 @code{delay_statements}.  See D.9(8).
7709 @end cartouche
7710 @noindent
7711 Any difference greater than one microsecond will cause the task to be
7712 delayed (see D.9(7)).
7713
7714 @sp 1
7715 @cartouche
7716 @noindent
7717 @strong{107}.  The upper bound on the duration of interrupt blocking
7718 caused by the implementation.  See D.12(5).
7719 @end cartouche
7720 @noindent
7721 The upper bound is determined by the underlying operating system.  In
7722 no cases is it more than 10 milliseconds.
7723
7724 @sp 1
7725 @cartouche
7726 @noindent
7727 @strong{108}.  The means for creating and executing distributed
7728 programs.  See E(5).
7729 @end cartouche
7730 @noindent
7731 The GLADE package provides a utility GNATDIST for creating and executing
7732 distributed programs.  See the GLADE reference manual for further details.
7733
7734 @sp 1
7735 @cartouche
7736 @noindent
7737 @strong{109}.  Any events that can result in a partition becoming
7738 inaccessible.  See E.1(7).
7739 @end cartouche
7740 @noindent
7741 See the GLADE reference manual for full details on such events.
7742
7743 @sp 1
7744 @cartouche
7745 @noindent
7746 @strong{110}.  The scheduling policies, treatment of priorities, and
7747 management of shared resources between partitions in certain cases.  See
7748 E.1(11).
7749 @end cartouche
7750 @noindent
7751 See the GLADE reference manual for full details on these aspects of
7752 multi-partition execution.
7753
7754 @sp 1
7755 @cartouche
7756 @noindent
7757 @strong{111}.  Events that cause the version of a compilation unit to
7758 change.  See E.3(5).
7759 @end cartouche
7760 @noindent
7761 Editing the source file of a compilation unit, or the source files of
7762 any units on which it is dependent in a significant way cause the version
7763 to change.  No other actions cause the version number to change.  All changes
7764 are significant except those which affect only layout, capitalization or
7765 comments.
7766
7767 @sp 1
7768 @cartouche
7769 @noindent
7770 @strong{112}.  Whether the execution of the remote subprogram is
7771 immediately aborted as a result of cancellation.  See E.4(13).
7772 @end cartouche
7773 @noindent
7774 See the GLADE reference manual for details on the effect of abort in
7775 a distributed application.
7776
7777 @sp 1
7778 @cartouche
7779 @noindent
7780 @strong{113}.  Implementation-defined aspects of the PCS@.  See E.5(25).
7781 @end cartouche
7782 @noindent
7783 See the GLADE reference manual for a full description of all implementation
7784 defined aspects of the PCS@.
7785
7786 @sp 1
7787 @cartouche
7788 @noindent
7789 @strong{114}.  Implementation-defined interfaces in the PCS@.  See
7790 E.5(26).
7791 @end cartouche
7792 @noindent
7793 See the GLADE reference manual for a full description of all
7794 implementation defined interfaces.
7795
7796 @sp 1
7797 @cartouche
7798 @noindent
7799 @strong{115}.  The values of named numbers in the package
7800 @code{Decimal}.  See F.2(7).
7801 @end cartouche
7802 @noindent
7803 @table @code
7804 @item Max_Scale
7805 +18
7806 @item Min_Scale
7807 -18
7808 @item Min_Delta
7809 1.0E-18
7810 @item Max_Delta
7811 1.0E+18
7812 @item Max_Decimal_Digits
7813 18
7814 @end table
7815
7816 @sp 1
7817 @cartouche
7818 @noindent
7819 @strong{116}.  The value of @code{Max_Picture_Length} in the package
7820 @code{Text_IO.Editing}.  See F.3.3(16).
7821 @end cartouche
7822 @noindent
7823 64
7824
7825 @sp 1
7826 @cartouche
7827 @noindent
7828 @strong{117}.  The value of @code{Max_Picture_Length} in the package
7829 @code{Wide_Text_IO.Editing}.  See F.3.4(5).
7830 @end cartouche
7831 @noindent
7832 64
7833
7834 @sp 1
7835 @cartouche
7836 @noindent
7837 @strong{118}.  The accuracy actually achieved by the complex elementary
7838 functions and by other complex arithmetic operations.  See G.1(1).
7839 @end cartouche
7840 @noindent
7841 Standard library functions are used for the complex arithmetic
7842 operations.  Only fast math mode is currently supported.
7843
7844 @sp 1
7845 @cartouche
7846 @noindent
7847 @strong{119}.  The sign of a zero result (or a component thereof) from
7848 any operator or function in @code{Numerics.Generic_Complex_Types}, when
7849 @code{Real'Signed_Zeros} is True.  See G.1.1(53).
7850 @end cartouche
7851 @noindent
7852 The signs of zero values are as recommended by the relevant
7853 implementation advice.
7854
7855 @sp 1
7856 @cartouche
7857 @noindent
7858 @strong{120}.  The sign of a zero result (or a component thereof) from
7859 any operator or function in
7860 @code{Numerics.Generic_Complex_Elementary_Functions}, when
7861 @code{Real'Signed_Zeros} is @code{True}.  See G.1.2(45).
7862 @end cartouche
7863 @noindent
7864 The signs of zero values are as recommended by the relevant
7865 implementation advice.
7866
7867 @sp 1
7868 @cartouche
7869 @noindent
7870 @strong{121}.  Whether the strict mode or the relaxed mode is the
7871 default.  See G.2(2).
7872 @end cartouche
7873 @noindent
7874 The strict mode is the default.  There is no separate relaxed mode.  GNAT
7875 provides a highly efficient implementation of strict mode.
7876
7877 @sp 1
7878 @cartouche
7879 @noindent
7880 @strong{122}.  The result interval in certain cases of fixed-to-float
7881 conversion.  See G.2.1(10).
7882 @end cartouche
7883 @noindent
7884 For cases where the result interval is implementation dependent, the
7885 accuracy is that provided by performing all operations in 64-bit IEEE
7886 floating-point format.
7887
7888 @sp 1
7889 @cartouche
7890 @noindent
7891 @strong{123}.  The result of a floating point arithmetic operation in
7892 overflow situations, when the @code{Machine_Overflows} attribute of the
7893 result type is @code{False}.  See G.2.1(13).
7894 @end cartouche
7895 @noindent
7896 Infinite and Nan values are produced as dictated by the IEEE
7897 floating-point standard.
7898
7899 @sp 1
7900 @cartouche
7901 @noindent
7902 @strong{124}.  The result interval for division (or exponentiation by a
7903 negative exponent), when the floating point hardware implements division
7904 as multiplication by a reciprocal.  See G.2.1(16).
7905 @end cartouche
7906 @noindent
7907 Not relevant, division is IEEE exact.
7908
7909 @sp 1
7910 @cartouche
7911 @noindent
7912 @strong{125}.  The definition of close result set, which determines the
7913 accuracy of certain fixed point multiplications and divisions.  See
7914 G.2.3(5).
7915 @end cartouche
7916 @noindent
7917 Operations in the close result set are performed using IEEE long format
7918 floating-point arithmetic.  The input operands are converted to
7919 floating-point, the operation is done in floating-point, and the result
7920 is converted to the target type.
7921
7922 @sp 1
7923 @cartouche
7924 @noindent
7925 @strong{126}.  Conditions on a @code{universal_real} operand of a fixed
7926 point multiplication or division for which the result shall be in the
7927 perfect result set.  See G.2.3(22).
7928 @end cartouche
7929 @noindent
7930 The result is only defined to be in the perfect result set if the result
7931 can be computed by a single scaling operation involving a scale factor
7932 representable in 64-bits.
7933
7934 @sp 1
7935 @cartouche
7936 @noindent
7937 @strong{127}.  The result of a fixed point arithmetic operation in
7938 overflow situations, when the @code{Machine_Overflows} attribute of the
7939 result type is @code{False}.  See G.2.3(27).
7940 @end cartouche
7941 @noindent
7942 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
7943 types.
7944
7945 @sp 1
7946 @cartouche
7947 @noindent
7948 @strong{128}.  The result of an elementary function reference in
7949 overflow situations, when the @code{Machine_Overflows} attribute of the
7950 result type is @code{False}.  See G.2.4(4).
7951 @end cartouche
7952 @noindent
7953 IEEE infinite and Nan values are produced as appropriate.
7954
7955 @sp 1
7956 @cartouche
7957 @noindent
7958 @strong{129}.  The value of the angle threshold, within which certain
7959 elementary functions, complex arithmetic operations, and complex
7960 elementary functions yield results conforming to a maximum relative
7961 error bound.  See G.2.4(10).
7962 @end cartouche
7963 @noindent
7964 Information on this subject is not yet available.
7965
7966 @sp 1
7967 @cartouche
7968 @noindent
7969 @strong{130}.  The accuracy of certain elementary functions for
7970 parameters beyond the angle threshold.  See G.2.4(10).
7971 @end cartouche
7972 @noindent
7973 Information on this subject is not yet available.
7974
7975 @sp 1
7976 @cartouche
7977 @noindent
7978 @strong{131}.  The result of a complex arithmetic operation or complex
7979 elementary function reference in overflow situations, when the
7980 @code{Machine_Overflows} attribute of the corresponding real type is
7981 @code{False}.  See G.2.6(5).
7982 @end cartouche
7983 @noindent
7984 IEEE infinite and Nan values are produced as appropriate.
7985
7986 @sp 1
7987 @cartouche
7988 @noindent
7989 @strong{132}.  The accuracy of certain complex arithmetic operations and
7990 certain complex elementary functions for parameters (or components
7991 thereof) beyond the angle threshold.  See G.2.6(8).
7992 @end cartouche
7993 @noindent
7994 Information on those subjects is not yet available.
7995
7996 @sp 1
7997 @cartouche
7998 @noindent
7999 @strong{133}.  Information regarding bounded errors and erroneous
8000 execution.  See H.2(1).
8001 @end cartouche
8002 @noindent
8003 Information on this subject is not yet available.
8004
8005 @sp 1
8006 @cartouche
8007 @noindent
8008 @strong{134}.  Implementation-defined aspects of pragma
8009 @code{Inspection_Point}.  See H.3.2(8).
8010 @end cartouche
8011 @noindent
8012 Pragma @code{Inspection_Point} ensures that the variable is live and can
8013 be examined by the debugger at the inspection point.
8014
8015 @sp 1
8016 @cartouche
8017 @noindent
8018 @strong{135}.  Implementation-defined aspects of pragma
8019 @code{Restrictions}.  See H.4(25).
8020 @end cartouche
8021 @noindent
8022 There are no implementation-defined aspects of pragma @code{Restrictions}.  The
8023 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
8024 generated code.  Checks must suppressed by use of pragma @code{Suppress}.
8025
8026 @sp 1
8027 @cartouche
8028 @noindent
8029 @strong{136}.  Any restrictions on pragma @code{Restrictions}.  See
8030 H.4(27).
8031 @end cartouche
8032 @noindent
8033 There are no restrictions on pragma @code{Restrictions}.
8034
8035 @node Intrinsic Subprograms
8036 @chapter Intrinsic Subprograms
8037 @cindex Intrinsic Subprograms
8038
8039 @menu
8040 * Intrinsic Operators::
8041 * Enclosing_Entity::
8042 * Exception_Information::
8043 * Exception_Message::
8044 * Exception_Name::
8045 * File::
8046 * Line::
8047 * Rotate_Left::
8048 * Rotate_Right::
8049 * Shift_Left::
8050 * Shift_Right::
8051 * Shift_Right_Arithmetic::
8052 * Source_Location::
8053 @end menu
8054
8055 @noindent
8056 GNAT allows a user application program to write the declaration:
8057
8058 @smallexample @c ada
8059    pragma Import (Intrinsic, name);
8060 @end smallexample
8061
8062 @noindent
8063 providing that the name corresponds to one of the implemented intrinsic
8064 subprograms in GNAT, and that the parameter profile of the referenced
8065 subprogram meets the requirements.  This chapter describes the set of
8066 implemented intrinsic subprograms, and the requirements on parameter profiles.
8067 Note that no body is supplied; as with other uses of pragma Import, the
8068 body is supplied elsewhere (in this case by the compiler itself).  Note
8069 that any use of this feature is potentially non-portable, since the
8070 Ada standard does not require Ada compilers to implement this feature.
8071
8072 @node Intrinsic Operators
8073 @section Intrinsic Operators
8074 @cindex Intrinsic operator
8075
8076 @noindent
8077 All the predefined numeric operators in package Standard
8078 in @code{pragma Import (Intrinsic,..)}
8079 declarations.  In the binary operator case, the operands must have the same
8080 size.  The operand or operands must also be appropriate for
8081 the operator.  For example, for addition, the operands must
8082 both be floating-point or both be fixed-point, and the
8083 right operand for @code{"**"} must have a root type of
8084 @code{Standard.Integer'Base}.
8085 You can use an intrinsic operator declaration as in the following example:
8086
8087 @smallexample @c ada
8088    type Int1 is new Integer;
8089    type Int2 is new Integer;
8090
8091    function "+" (X1 : Int1; X2 : Int2) return Int1;
8092    function "+" (X1 : Int1; X2 : Int2) return Int2;
8093    pragma Import (Intrinsic, "+");
8094 @end smallexample
8095
8096 @noindent
8097 This declaration would permit ``mixed mode'' arithmetic on items
8098 of the differing types @code{Int1} and @code{Int2}.
8099 It is also possible to specify such operators for private types, if the
8100 full views are appropriate arithmetic types.
8101
8102 @node Enclosing_Entity
8103 @section Enclosing_Entity
8104 @cindex Enclosing_Entity
8105 @noindent
8106 This intrinsic subprogram is used in the implementation of the
8107 library routine @code{GNAT.Source_Info}.  The only useful use of the
8108 intrinsic import in this case is the one in this unit, so an
8109 application program should simply call the function
8110 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
8111 the current subprogram, package, task, entry, or protected subprogram.
8112
8113 @node Exception_Information
8114 @section Exception_Information
8115 @cindex Exception_Information'
8116 @noindent
8117 This intrinsic subprogram is used in the implementation of the
8118 library routine @code{GNAT.Current_Exception}.  The only useful
8119 use of the intrinsic import in this case is the one in this unit,
8120 so an application program should simply call the function
8121 @code{GNAT.Current_Exception.Exception_Information} to obtain
8122 the exception information associated with the current exception.
8123
8124 @node Exception_Message
8125 @section Exception_Message
8126 @cindex Exception_Message
8127 @noindent
8128 This intrinsic subprogram is used in the implementation of the
8129 library routine @code{GNAT.Current_Exception}.  The only useful
8130 use of the intrinsic import in this case is the one in this unit,
8131 so an application program should simply call the function
8132 @code{GNAT.Current_Exception.Exception_Message} to obtain
8133 the message associated with the current exception.
8134
8135 @node Exception_Name
8136 @section Exception_Name
8137 @cindex Exception_Name
8138 @noindent
8139 This intrinsic subprogram is used in the implementation of the
8140 library routine @code{GNAT.Current_Exception}.  The only useful
8141 use of the intrinsic import in this case is the one in this unit,
8142 so an application program should simply call the function
8143 @code{GNAT.Current_Exception.Exception_Name} to obtain
8144 the name of the current exception.
8145
8146 @node File
8147 @section File
8148 @cindex File
8149 @noindent
8150 This intrinsic subprogram is used in the implementation of the
8151 library routine @code{GNAT.Source_Info}.  The only useful use of the
8152 intrinsic import in this case is the one in this unit, so an
8153 application program should simply call the function
8154 @code{GNAT.Source_Info.File} to obtain the name of the current
8155 file.
8156
8157 @node Line
8158 @section Line
8159 @cindex Line
8160 @noindent
8161 This intrinsic subprogram is used in the implementation of the
8162 library routine @code{GNAT.Source_Info}.  The only useful use of the
8163 intrinsic import in this case is the one in this unit, so an
8164 application program should simply call the function
8165 @code{GNAT.Source_Info.Line} to obtain the number of the current
8166 source line.
8167
8168 @node Rotate_Left
8169 @section Rotate_Left
8170 @cindex Rotate_Left
8171 @noindent
8172 In standard Ada 95, the @code{Rotate_Left} function is available only
8173 for the predefined modular types in package @code{Interfaces}.  However, in
8174 GNAT it is possible to define a Rotate_Left function for a user
8175 defined modular type or any signed integer type as in this example:
8176
8177 @smallexample @c ada
8178    function Shift_Left
8179      (Value  : My_Modular_Type;
8180       Amount : Natural)
8181       return   My_Modular_Type;
8182 @end smallexample
8183
8184 @noindent
8185 The requirements are that the profile be exactly as in the example
8186 above.  The only modifications allowed are in the formal parameter
8187 names, and in the type of @code{Value} and the return type, which
8188 must be the same, and must be either a signed integer type, or
8189 a modular integer type with a binary modulus, and the size must
8190 be 8.  16, 32 or 64 bits.
8191
8192 @node Rotate_Right
8193 @section Rotate_Right
8194 @cindex Rotate_Right
8195 @noindent
8196 A @code{Rotate_Right} function can be defined for any user defined
8197 binary modular integer type, or signed integer type, as described
8198 above for @code{Rotate_Left}.
8199
8200 @node Shift_Left
8201 @section Shift_Left
8202 @cindex Shift_Left
8203 @noindent
8204 A @code{Shift_Left} function can be defined for any user defined
8205 binary modular integer type, or signed integer type, as described
8206 above for @code{Rotate_Left}.
8207
8208 @node Shift_Right
8209 @section Shift_Right
8210 @cindex Shift_Right
8211 @noindent
8212 A @code{Shift_Right} function can be defined for any user defined
8213 binary modular integer type, or signed integer type, as described
8214 above for @code{Rotate_Left}.
8215
8216 @node Shift_Right_Arithmetic
8217 @section Shift_Right_Arithmetic
8218 @cindex Shift_Right_Arithmetic
8219 @noindent
8220 A @code{Shift_Right_Arithmetic} function can be defined for any user
8221 defined binary modular integer type, or signed integer type, as described
8222 above for @code{Rotate_Left}.
8223
8224 @node Source_Location
8225 @section Source_Location
8226 @cindex Source_Location
8227 @noindent
8228 This intrinsic subprogram is used in the implementation of the
8229 library routine @code{GNAT.Source_Info}.  The only useful use of the
8230 intrinsic import in this case is the one in this unit, so an
8231 application program should simply call the function
8232 @code{GNAT.Source_Info.Source_Location} to obtain the current
8233 source file location.
8234
8235 @node Representation Clauses and Pragmas
8236 @chapter Representation Clauses and Pragmas
8237 @cindex Representation Clauses
8238
8239 @menu
8240 * Alignment Clauses::
8241 * Size Clauses::
8242 * Storage_Size Clauses::
8243 * Size of Variant Record Objects::
8244 * Biased Representation ::
8245 * Value_Size and Object_Size Clauses::
8246 * Component_Size Clauses::
8247 * Bit_Order Clauses::
8248 * Effect of Bit_Order on Byte Ordering::
8249 * Pragma Pack for Arrays::
8250 * Pragma Pack for Records::
8251 * Record Representation Clauses::
8252 * Enumeration Clauses::
8253 * Address Clauses::
8254 * Effect of Convention on Representation::
8255 * Determining the Representations chosen by GNAT::
8256 @end menu
8257
8258 @noindent
8259 @cindex Representation Clause
8260 @cindex Representation Pragma
8261 @cindex Pragma, representation
8262 This section describes the representation clauses accepted by GNAT, and
8263 their effect on the representation of corresponding data objects.
8264
8265 GNAT fully implements Annex C (Systems Programming).  This means that all
8266 the implementation advice sections in chapter 13 are fully implemented.
8267 However, these sections only require a minimal level of support for
8268 representation clauses.  GNAT provides much more extensive capabilities,
8269 and this section describes the additional capabilities provided.
8270
8271 @node Alignment Clauses
8272 @section Alignment Clauses
8273 @cindex Alignment Clause
8274
8275 @noindent
8276 GNAT requires that all alignment clauses specify a power of 2, and all
8277 default alignments are always a power of 2.  The default alignment
8278 values are as follows:
8279
8280 @itemize @bullet
8281 @item @emph{Primitive Types}.
8282 For primitive types, the alignment is the minimum of the actual size of
8283 objects of the type divided by @code{Storage_Unit},
8284 and the maximum alignment supported by the target.
8285 (This maximum alignment is given by the GNAT-specific attribute
8286 @code{Standard'Maximum_Alignment}; see @ref{Maximum_Alignment}.)
8287 @cindex @code{Maximum_Alignment} attribute
8288 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
8289 default alignment will be 8 on any target that supports alignments
8290 this large, but on some targets, the maximum alignment may be smaller
8291 than 8, in which case objects of type @code{Long_Float} will be maximally
8292 aligned.
8293
8294 @item @emph{Arrays}.
8295 For arrays, the alignment is equal to the alignment of the component type
8296 for the normal case where no packing or component size is given.  If the
8297 array is packed, and the packing is effective (see separate section on
8298 packed arrays), then the alignment will be one for long packed arrays,
8299 or arrays whose length is not known at compile time.  For short packed
8300 arrays, which are handled internally as modular types, the alignment
8301 will be as described for primitive types, e.g.@: a packed array of length
8302 31 bits will have an object size of four bytes, and an alignment of 4.
8303
8304 @item @emph{Records}.
8305 For the normal non-packed case, the alignment of a record is equal to
8306 the maximum alignment of any of its components.  For tagged records, this
8307 includes the implicit access type used for the tag.  If a pragma @code{Pack} is
8308 used and all fields are packable (see separate section on pragma @code{Pack}),
8309 then the resulting alignment is 1.
8310
8311 A special case is when:
8312 @itemize @bullet
8313 @item
8314 the size of the record is given explicitly, or a
8315 full record representation clause is given, and
8316 @item
8317 the size of the record is 2, 4, or 8 bytes.
8318 @end itemize
8319 @noindent
8320 In this case, an alignment is chosen to match the
8321 size of the record. For example, if we have:
8322
8323 @smallexample @c ada
8324    type Small is record
8325       A, B : Character;
8326    end record;
8327    for Small'Size use 16;
8328 @end smallexample
8329
8330 @noindent
8331 then the default alignment of the record type @code{Small} is 2, not 1. This
8332 leads to more efficient code when the record is treated as a unit, and also
8333 allows the type to specified as @code{Atomic} on architectures requiring
8334 strict alignment.
8335
8336 @end itemize
8337
8338 @noindent
8339 An alignment clause may
8340 always specify a larger alignment than the default value, up to some
8341 maximum value dependent on the target (obtainable by using the
8342 attribute reference @code{Standard'Maximum_Alignment}).
8343 The only case where
8344 it is permissible to specify a smaller alignment than the default value
8345 is for a record with a record representation clause.
8346 In this case, packable fields for which a component clause is
8347 given still result in a default alignment corresponding to the original
8348 type, but this may be overridden, since these components in fact only
8349 require an alignment of one byte.  For example, given
8350
8351 @smallexample @c ada
8352   type V is record
8353      A : Integer;
8354   end record;
8355
8356   for V use record
8357      A at 0  range 0 .. 31;
8358   end record;
8359
8360   for V'alignment use 1;
8361 @end smallexample
8362
8363 @noindent
8364 @cindex Alignment, default
8365 The default alignment for the type @code{V} is 4, as a result of the
8366 Integer field in the record, but since this field is placed with a
8367 component clause, it is permissible, as shown, to override the default
8368 alignment of the record with a smaller value.
8369
8370 @node Size Clauses
8371 @section Size Clauses
8372 @cindex Size Clause
8373
8374 @noindent
8375 The default size for a type @code{T} is obtainable through the
8376 language-defined attribute @code{T'Size} and also through the
8377 equivalent GNAT-defined attribute @code{T'Value_Size}.
8378 For objects of type @code{T}, GNAT will generally increase the type size
8379 so that the object size (obtainable through the GNAT-defined attribute
8380 @code{T'Object_Size})
8381 is a multiple of @code{T'Alignment * Storage_Unit}.
8382 For example
8383
8384 @smallexample @c ada
8385    type Smallint is range 1 .. 6;
8386
8387    type Rec is record
8388       Y1 : integer;
8389       Y2 : boolean;
8390    end record;
8391 @end smallexample
8392
8393 @noindent
8394 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
8395 as specified by the RM rules,
8396 but objects of this type will have a size of 8
8397 (@code{Smallint'Object_Size} = 8),
8398 since objects by default occupy an integral number
8399 of storage units.  On some targets, notably older
8400 versions of the Digital Alpha, the size of stand
8401 alone objects of this type may be 32, reflecting
8402 the inability of the hardware to do byte load/stores.
8403
8404 Similarly, the size of type @code{Rec} is 40 bits
8405 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
8406 the alignment is 4, so objects of this type will have
8407 their size increased to 64 bits so that it is a multiple
8408 of the alignment (in bits).  This decision is
8409 in accordance with the specific Implementation Advice in RM 13.3(43):
8410
8411 @quotation
8412 A @code{Size} clause should be supported for an object if the specified
8413 @code{Size} is at least as large as its subtype's @code{Size}, and corresponds
8414 to a size in storage elements that is a multiple of the object's
8415 @code{Alignment} (if the @code{Alignment} is nonzero).
8416 @end quotation
8417
8418 @noindent
8419 An explicit size clause may be used to override the default size by
8420 increasing it.  For example, if we have:
8421
8422 @smallexample @c ada
8423    type My_Boolean is new Boolean;
8424    for My_Boolean'Size use 32;
8425 @end smallexample
8426
8427 @noindent
8428 then values of this type will always be 32 bits long.  In the case of
8429 discrete types, the size can be increased up to 64 bits, with the effect
8430 that the entire specified field is used to hold the value, sign- or
8431 zero-extended as appropriate.  If more than 64 bits is specified, then
8432 padding space is allocated after the value, and a warning is issued that
8433 there are unused bits.
8434
8435 Similarly the size of records and arrays may be increased, and the effect
8436 is to add padding bits after the value.  This also causes a warning message
8437 to be generated.
8438
8439 The largest Size value permitted in GNAT is 2**31@minus{}1.  Since this is a
8440 Size in bits, this corresponds to an object of size 256 megabytes (minus
8441 one).  This limitation is true on all targets.  The reason for this
8442 limitation is that it improves the quality of the code in many cases
8443 if it is known that a Size value can be accommodated in an object of
8444 type Integer.
8445
8446 @node Storage_Size Clauses
8447 @section Storage_Size Clauses
8448 @cindex Storage_Size Clause
8449
8450 @noindent
8451 For tasks, the @code{Storage_Size} clause specifies the amount of space
8452 to be allocated for the task stack.  This cannot be extended, and if the
8453 stack is exhausted, then @code{Storage_Error} will be raised (if stack
8454 checking is enabled).  Use a @code{Storage_Size} attribute definition clause,
8455 or a @code{Storage_Size} pragma in the task definition to set the
8456 appropriate required size.  A useful technique is to include in every
8457 task definition a pragma of the form:
8458
8459 @smallexample @c ada
8460    pragma Storage_Size (Default_Stack_Size);
8461 @end smallexample
8462
8463 @noindent
8464 Then @code{Default_Stack_Size} can be defined in a global package, and
8465 modified as required.  Any tasks requiring stack sizes different from the
8466 default can have an appropriate alternative reference in the pragma.
8467
8468 For access types, the @code{Storage_Size} clause specifies the maximum
8469 space available for allocation of objects of the type.  If this space is
8470 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
8471 In the case where the access type is declared local to a subprogram, the
8472 use of a @code{Storage_Size} clause triggers automatic use of a special
8473 predefined storage pool (@code{System.Pool_Size}) that ensures that all
8474 space for the pool is automatically reclaimed on exit from the scope in
8475 which the type is declared.
8476
8477 A special case recognized by the compiler is the specification of a
8478 @code{Storage_Size} of zero for an access type.  This means that no
8479 items can be allocated from the pool, and this is recognized at compile
8480 time, and all the overhead normally associated with maintaining a fixed
8481 size storage pool is eliminated.  Consider the following example:
8482
8483 @smallexample @c ada
8484    procedure p is
8485       type R is array (Natural) of Character;
8486       type P is access all R;
8487       for P'Storage_Size use 0;
8488       --  Above access type intended only for interfacing purposes
8489
8490       y : P;
8491
8492       procedure g (m : P);
8493       pragma Import (C, g);
8494
8495       --  @dots{}
8496
8497    begin
8498       --  @dots{}
8499       y := new R;
8500    end;
8501 @end smallexample
8502
8503 @noindent
8504 As indicated in this example, these dummy storage pools are often useful in
8505 connection with interfacing where no object will ever be allocated.  If you
8506 compile the above example, you get the warning:
8507
8508 @smallexample
8509    p.adb:16:09: warning: allocation from empty storage pool
8510    p.adb:16:09: warning: Storage_Error will be raised at run time
8511 @end smallexample
8512
8513 @noindent
8514 Of course in practice, there will not be any explicit allocators in the
8515 case of such an access declaration.
8516
8517 @node Size of Variant Record Objects
8518 @section Size of Variant Record Objects
8519 @cindex Size, variant record objects
8520 @cindex Variant record objects, size
8521
8522 @noindent
8523 In the case of variant record objects, there is a question whether Size gives
8524 information about a particular variant, or the maximum size required
8525 for any variant.  Consider the following program
8526
8527 @smallexample @c ada
8528 with Text_IO; use Text_IO;
8529 procedure q is
8530    type R1 (A : Boolean := False) is record
8531      case A is
8532        when True  => X : Character;
8533        when False => null;
8534      end case;
8535    end record;
8536
8537    V1 : R1 (False);
8538    V2 : R1;
8539
8540 begin
8541    Put_Line (Integer'Image (V1'Size));
8542    Put_Line (Integer'Image (V2'Size));
8543 end q;
8544 @end smallexample
8545
8546 @noindent
8547 Here we are dealing with a variant record, where the True variant
8548 requires 16 bits, and the False variant requires 8 bits.
8549 In the above example, both V1 and V2 contain the False variant,
8550 which is only 8 bits long.  However, the result of running the
8551 program is:
8552
8553 @smallexample
8554 8
8555 16
8556 @end smallexample
8557
8558 @noindent
8559 The reason for the difference here is that the discriminant value of
8560 V1 is fixed, and will always be False.  It is not possible to assign
8561 a True variant value to V1, therefore 8 bits is sufficient.  On the
8562 other hand, in the case of V2, the initial discriminant value is
8563 False (from the default), but it is possible to assign a True
8564 variant value to V2, therefore 16 bits must be allocated for V2
8565 in the general case, even fewer bits may be needed at any particular
8566 point during the program execution.
8567
8568 As can be seen from the output of this program, the @code{'Size}
8569 attribute applied to such an object in GNAT gives the actual allocated
8570 size of the variable, which is the largest size of any of the variants.
8571 The Ada Reference Manual is not completely clear on what choice should
8572 be made here, but the GNAT behavior seems most consistent with the
8573 language in the RM@.
8574
8575 In some cases, it may be desirable to obtain the size of the current
8576 variant, rather than the size of the largest variant.  This can be
8577 achieved in GNAT by making use of the fact that in the case of a
8578 subprogram parameter, GNAT does indeed return the size of the current
8579 variant (because a subprogram has no way of knowing how much space
8580 is actually allocated for the actual).
8581
8582 Consider the following modified version of the above program:
8583
8584 @smallexample @c ada
8585 with Text_IO; use Text_IO;
8586 procedure q is
8587    type R1 (A : Boolean := False) is record
8588      case A is
8589        when True  => X : Character;
8590        when False => null;
8591      end case;
8592    end record;
8593
8594    V2 : R1;
8595
8596    function Size (V : R1) return Integer is
8597    begin
8598       return V'Size;
8599    end Size;
8600
8601 begin
8602    Put_Line (Integer'Image (V2'Size));
8603    Put_Line (Integer'IMage (Size (V2)));
8604    V2 := (True, 'x');
8605    Put_Line (Integer'Image (V2'Size));
8606    Put_Line (Integer'IMage (Size (V2)));
8607 end q;
8608 @end smallexample
8609
8610 @noindent
8611 The output from this program is
8612
8613 @smallexample
8614 16
8615 8
8616 16
8617 16
8618 @end smallexample
8619
8620 @noindent
8621 Here we see that while the @code{'Size} attribute always returns
8622 the maximum size, regardless of the current variant value, the
8623 @code{Size} function does indeed return the size of the current
8624 variant value.
8625
8626 @node Biased Representation
8627 @section Biased Representation
8628 @cindex Size for biased representation
8629 @cindex Biased representation
8630
8631 @noindent
8632 In the case of scalars with a range starting at other than zero, it is
8633 possible in some cases to specify a size smaller than the default minimum
8634 value, and in such cases, GNAT uses an unsigned biased representation,
8635 in which zero is used to represent the lower bound, and successive values
8636 represent successive values of the type.
8637
8638 For example, suppose we have the declaration:
8639
8640 @smallexample @c ada
8641    type Small is range -7 .. -4;
8642    for Small'Size use 2;
8643 @end smallexample
8644
8645 @noindent
8646 Although the default size of type @code{Small} is 4, the @code{Size}
8647 clause is accepted by GNAT and results in the following representation
8648 scheme:
8649
8650 @smallexample
8651   -7 is represented as 2#00#
8652   -6 is represented as 2#01#
8653   -5 is represented as 2#10#
8654   -4 is represented as 2#11#
8655 @end smallexample
8656
8657 @noindent
8658 Biased representation is only used if the specified @code{Size} clause
8659 cannot be accepted in any other manner.  These reduced sizes that force
8660 biased representation can be used for all discrete types except for
8661 enumeration types for which a representation clause is given.
8662
8663 @node Value_Size and Object_Size Clauses
8664 @section Value_Size and Object_Size Clauses
8665 @findex Value_Size
8666 @findex Object_Size
8667 @cindex Size, of objects
8668
8669 @noindent
8670 In Ada 95, @code{T'Size} for a type @code{T} is the minimum number of bits
8671 required to hold values of type @code{T}.  Although this interpretation was
8672 allowed in Ada 83, it was not required, and this requirement in practice
8673 can cause some significant difficulties.  For example, in most Ada 83
8674 compilers, @code{Natural'Size} was 32.  However, in Ada 95,
8675 @code{Natural'Size} is
8676 typically 31.  This means that code may change in behavior when moving
8677 from Ada 83 to Ada 95.  For example, consider:
8678
8679 @smallexample @c ada
8680    type Rec is record;
8681       A : Natural;
8682       B : Natural;
8683    end record;
8684
8685    for Rec use record
8686       at 0  range 0 .. Natural'Size - 1;
8687       at 0  range Natural'Size .. 2 * Natural'Size - 1;
8688    end record;
8689 @end smallexample
8690
8691 @noindent
8692 In the above code, since the typical size of @code{Natural} objects
8693 is 32 bits and @code{Natural'Size} is 31, the above code can cause
8694 unexpected inefficient packing in Ada 95, and in general there are
8695 cases where the fact that the object size can exceed the
8696 size of the type causes surprises.
8697
8698 To help get around this problem GNAT provides two implementation
8699 defined attributes, @code{Value_Size} and @code{Object_Size}.  When
8700 applied to a type, these attributes yield the size of the type
8701 (corresponding to the RM defined size attribute), and the size of
8702 objects of the type respectively.
8703
8704 The @code{Object_Size} is used for determining the default size of
8705 objects and components.  This size value can be referred to using the
8706 @code{Object_Size} attribute.  The phrase ``is used'' here means that it is
8707 the basis of the determination of the size.  The backend is free to
8708 pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
8709 character might be stored in 32 bits on a machine with no efficient
8710 byte access instructions such as the Alpha.
8711
8712 The default rules for the value of @code{Object_Size} for
8713 discrete types are as follows:
8714
8715 @itemize @bullet
8716 @item
8717 The @code{Object_Size} for base subtypes reflect the natural hardware
8718 size in bits (run the compiler with @option{-gnatS} to find those values
8719 for numeric types). Enumeration types and fixed-point base subtypes have
8720 8, 16, 32 or 64 bits for this size, depending on the range of values
8721 to be stored.
8722
8723 @item
8724 The @code{Object_Size} of a subtype is the same as the
8725 @code{Object_Size} of
8726 the type from which it is obtained.
8727
8728 @item
8729 The @code{Object_Size} of a derived base type is copied from the parent
8730 base type, and the @code{Object_Size} of a derived first subtype is copied
8731 from the parent first subtype.
8732 @end itemize
8733
8734 @noindent
8735 The @code{Value_Size} attribute
8736 is the (minimum) number of bits required to store a value
8737 of the type.
8738 This value is used to determine how tightly to pack
8739 records or arrays with components of this type, and also affects
8740 the semantics of unchecked conversion (unchecked conversions where
8741 the @code{Value_Size} values differ generate a warning, and are potentially
8742 target dependent).
8743
8744 The default rules for the value of @code{Value_Size} are as follows:
8745
8746 @itemize @bullet
8747 @item
8748 The @code{Value_Size} for a base subtype is the minimum number of bits
8749 required to store all values of the type (including the sign bit
8750 only if negative values are possible).
8751
8752 @item
8753 If a subtype statically matches the first subtype of a given type, then it has
8754 by default the same @code{Value_Size} as the first subtype.  This is a
8755 consequence of RM 13.1(14) (``if two subtypes statically match,
8756 then their subtype-specific aspects are the same''.)
8757
8758 @item
8759 All other subtypes have a @code{Value_Size} corresponding to the minimum
8760 number of bits required to store all values of the subtype.  For
8761 dynamic bounds, it is assumed that the value can range down or up
8762 to the corresponding bound of the ancestor
8763 @end itemize
8764
8765 @noindent
8766 The RM defined attribute @code{Size} corresponds to the
8767 @code{Value_Size} attribute.
8768
8769 The @code{Size} attribute may be defined for a first-named subtype.  This sets
8770 the @code{Value_Size} of
8771 the first-named subtype to the given value, and the
8772 @code{Object_Size} of this first-named subtype to the given value padded up
8773 to an appropriate boundary.  It is a consequence of the default rules
8774 above that this @code{Object_Size} will apply to all further subtypes.  On the
8775 other hand, @code{Value_Size} is affected only for the first subtype, any
8776 dynamic subtypes obtained from it directly, and any statically matching
8777 subtypes.  The @code{Value_Size} of any other static subtypes is not affected.
8778
8779 @code{Value_Size} and
8780 @code{Object_Size} may be explicitly set for any subtype using
8781 an attribute definition clause.  Note that the use of these attributes
8782 can cause the RM 13.1(14) rule to be violated.  If two access types
8783 reference aliased objects whose subtypes have differing @code{Object_Size}
8784 values as a result of explicit attribute definition clauses, then it
8785 is erroneous to convert from one access subtype to the other.
8786
8787 At the implementation level, Esize stores the Object_Size and the
8788 RM_Size field stores the @code{Value_Size} (and hence the value of the
8789 @code{Size} attribute,
8790 which, as noted above, is equivalent to @code{Value_Size}).
8791
8792 To get a feel for the difference, consider the following examples (note
8793 that in each case the base is @code{Short_Short_Integer} with a size of 8):
8794
8795 @smallexample
8796                                        Object_Size     Value_Size
8797
8798 type x1 is range 0 .. 5;                    8               3
8799
8800 type x2 is range 0 .. 5;
8801 for x2'size use 12;                        16              12
8802
8803 subtype x3 is x2 range 0 .. 3;             16               2
8804
8805 subtype x4 is x2'base range 0 .. 10;        8               4
8806
8807 subtype x5 is x2 range 0 .. dynamic;       16               3*
8808
8809 subtype x6 is x2'base range 0 .. dynamic;   8               3*
8810
8811 @end smallexample
8812
8813 @noindent
8814 Note: the entries marked ``3*'' are not actually specified by the Ada 95 RM,
8815 but it seems in the spirit of the RM rules to allocate the minimum number
8816 of bits (here 3, given the range for @code{x2})
8817 known to be large enough to hold the given range of values.
8818
8819 So far, so good, but GNAT has to obey the RM rules, so the question is
8820 under what conditions must the RM @code{Size} be used.
8821 The following is a list
8822 of the occasions on which the RM @code{Size} must be used:
8823
8824 @itemize @bullet
8825 @item
8826 Component size for packed arrays or records
8827
8828 @item
8829 Value of the attribute @code{Size} for a type
8830
8831 @item
8832 Warning about sizes not matching for unchecked conversion
8833 @end itemize
8834
8835 @noindent
8836 For record types, the @code{Object_Size} is always a multiple of the
8837 alignment of the type (this is true for all types). In some cases the
8838 @code{Value_Size} can be smaller. Consider:
8839
8840 @smallexample
8841    type R is record
8842      X : Integer;
8843      Y : Character;
8844    end record;
8845 @end smallexample
8846
8847 @noindent
8848 On a typical 32-bit architecture, the X component will be four bytes, and
8849 require four-byte alignment, and the Y component will be one byte. In this
8850 case @code{R'Value_Size} will be 40 (bits) since this is the minimum size
8851 required to store a value of this type, and for example, it is permissible
8852 to have a component of type R in an outer record whose component size is
8853 specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits),
8854 since it must be rounded up so that this value is a multiple of the
8855 alignment (4 bytes = 32 bits).
8856
8857 @noindent
8858 For all other types, the @code{Object_Size}
8859 and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
8860 Only @code{Size} may be specified for such types.
8861
8862 @node Component_Size Clauses
8863 @section Component_Size Clauses
8864 @cindex Component_Size Clause
8865
8866 @noindent
8867 Normally, the value specified in a component clause must be consistent
8868 with the subtype of the array component with regard to size and alignment.
8869 In other words, the value specified must be at least equal to the size
8870 of this subtype, and must be a multiple of the alignment value.
8871
8872 In addition, component size clauses are allowed which cause the array
8873 to be packed, by specifying a smaller value.  The cases in which this
8874 is allowed are for component size values in the range 1 through 63.  The value
8875 specified must not be smaller than the Size of the subtype.  GNAT will
8876 accurately honor all packing requests in this range.  For example, if
8877 we have:
8878
8879 @smallexample @c ada
8880 type r is array (1 .. 8) of Natural;
8881 for r'Component_Size use 31;
8882 @end smallexample
8883
8884 @noindent
8885 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
8886 Of course access to the components of such an array is considerably
8887 less efficient than if the natural component size of 32 is used.
8888
8889 @node Bit_Order Clauses
8890 @section Bit_Order Clauses
8891 @cindex Bit_Order Clause
8892 @cindex bit ordering
8893 @cindex ordering, of bits
8894
8895 @noindent
8896 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
8897 attribute.  The specification may either correspond to the default bit
8898 order for the target, in which case the specification has no effect and
8899 places no additional restrictions, or it may be for the non-standard
8900 setting (that is the opposite of the default).
8901
8902 In the case where the non-standard value is specified, the effect is
8903 to renumber bits within each byte, but the ordering of bytes is not
8904 affected.  There are certain
8905 restrictions placed on component clauses as follows:
8906
8907 @itemize @bullet
8908
8909 @item Components fitting within a single storage unit.
8910 @noindent
8911 These are unrestricted, and the effect is merely to renumber bits.  For
8912 example if we are on a little-endian machine with @code{Low_Order_First}
8913 being the default, then the following two declarations have exactly
8914 the same effect:
8915
8916 @smallexample @c ada
8917    type R1 is record
8918       A : Boolean;
8919       B : Integer range 1 .. 120;
8920    end record;
8921
8922    for R1 use record
8923       A at 0 range 0 .. 0;
8924       B at 0 range 1 .. 7;
8925    end record;
8926
8927    type R2 is record
8928       A : Boolean;
8929       B : Integer range 1 .. 120;
8930    end record;
8931
8932    for R2'Bit_Order use High_Order_First;
8933
8934    for R2 use record
8935       A at 0 range 7 .. 7;
8936       B at 0 range 0 .. 6;
8937    end record;
8938 @end smallexample
8939
8940 @noindent
8941 The useful application here is to write the second declaration with the
8942 @code{Bit_Order} attribute definition clause, and know that it will be treated
8943 the same, regardless of whether the target is little-endian or big-endian.
8944
8945 @item Components occupying an integral number of bytes.
8946 @noindent
8947 These are components that exactly fit in two or more bytes.  Such component
8948 declarations are allowed, but have no effect, since it is important to realize
8949 that the @code{Bit_Order} specification does not affect the ordering of bytes.
8950 In particular, the following attempt at getting an endian-independent integer
8951 does not work:
8952
8953 @smallexample @c ada
8954    type R2 is record
8955       A : Integer;
8956    end record;
8957
8958    for R2'Bit_Order use High_Order_First;
8959
8960    for R2 use record
8961       A at 0 range 0 .. 31;
8962    end record;
8963 @end smallexample
8964
8965 @noindent
8966 This declaration will result in a little-endian integer on a
8967 little-endian machine, and a big-endian integer on a big-endian machine.
8968 If byte flipping is required for interoperability between big- and
8969 little-endian machines, this must be explicitly programmed.  This capability
8970 is not provided by @code{Bit_Order}.
8971
8972 @item Components that are positioned across byte boundaries
8973 @noindent
8974 but do not occupy an integral number of bytes.  Given that bytes are not
8975 reordered, such fields would occupy a non-contiguous sequence of bits
8976 in memory, requiring non-trivial code to reassemble.  They are for this
8977 reason not permitted, and any component clause specifying such a layout
8978 will be flagged as illegal by GNAT@.
8979
8980 @end itemize
8981
8982 @noindent
8983 Since the misconception that Bit_Order automatically deals with all
8984 endian-related incompatibilities is a common one, the specification of
8985 a component field that is an integral number of bytes will always
8986 generate a warning.  This warning may be suppressed using
8987 @code{pragma Suppress} if desired.  The following section contains additional
8988 details regarding the issue of byte ordering.
8989
8990 @node Effect of Bit_Order on Byte Ordering
8991 @section Effect of Bit_Order on Byte Ordering
8992 @cindex byte ordering
8993 @cindex ordering, of bytes
8994
8995 @noindent
8996 In this section we will review the effect of the @code{Bit_Order} attribute
8997 definition clause on byte ordering.  Briefly, it has no effect at all, but
8998 a detailed example will be helpful.  Before giving this
8999 example, let us review the precise
9000 definition of the effect of defining @code{Bit_Order}.  The effect of a
9001 non-standard bit order is described in section 15.5.3 of the Ada
9002 Reference Manual:
9003
9004 @quotation
9005 2   A bit ordering is a method of interpreting the meaning of
9006 the storage place attributes.
9007 @end quotation
9008
9009 @noindent
9010 To understand the precise definition of storage place attributes in
9011 this context, we visit section 13.5.1 of the manual:
9012
9013 @quotation
9014 13   A record_representation_clause (without the mod_clause)
9015 specifies the layout.  The storage place attributes (see 13.5.2)
9016 are taken from the values of the position, first_bit, and last_bit
9017 expressions after normalizing those values so that first_bit is
9018 less than Storage_Unit.
9019 @end quotation
9020
9021 @noindent
9022 The critical point here is that storage places are taken from
9023 the values after normalization, not before.  So the @code{Bit_Order}
9024 interpretation applies to normalized values.  The interpretation
9025 is described in the later part of the 15.5.3 paragraph:
9026
9027 @quotation
9028 2   A bit ordering is a method of interpreting the meaning of
9029 the storage place attributes.  High_Order_First (known in the
9030 vernacular as ``big endian'') means that the first bit of a
9031 storage element (bit 0) is the most significant bit (interpreting
9032 the sequence of bits that represent a component as an unsigned
9033 integer value).  Low_Order_First (known in the vernacular as
9034 ``little endian'') means the opposite: the first bit is the
9035 least significant.
9036 @end quotation
9037
9038 @noindent
9039 Note that the numbering is with respect to the bits of a storage
9040 unit.  In other words, the specification affects only the numbering
9041 of bits within a single storage unit.
9042
9043 We can make the effect clearer by giving an example.
9044
9045 Suppose that we have an external device which presents two bytes, the first
9046 byte presented, which is the first (low addressed byte) of the two byte
9047 record is called Master, and the second byte is called Slave.
9048
9049 The left most (most significant bit is called Control for each byte, and
9050 the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
9051 (least significant) bit.
9052
9053 On a big-endian machine, we can write the following representation clause
9054
9055 @smallexample @c ada
9056    type Data is record
9057       Master_Control : Bit;
9058       Master_V1      : Bit;
9059       Master_V2      : Bit;
9060       Master_V3      : Bit;
9061       Master_V4      : Bit;
9062       Master_V5      : Bit;
9063       Master_V6      : Bit;
9064       Master_V7      : Bit;
9065       Slave_Control  : Bit;
9066       Slave_V1       : Bit;
9067       Slave_V2       : Bit;
9068       Slave_V3       : Bit;
9069       Slave_V4       : Bit;
9070       Slave_V5       : Bit;
9071       Slave_V6       : Bit;
9072       Slave_V7       : Bit;
9073    end record;
9074
9075    for Data use record
9076       Master_Control at 0 range 0 .. 0;
9077       Master_V1      at 0 range 1 .. 1;
9078       Master_V2      at 0 range 2 .. 2;
9079       Master_V3      at 0 range 3 .. 3;
9080       Master_V4      at 0 range 4 .. 4;
9081       Master_V5      at 0 range 5 .. 5;
9082       Master_V6      at 0 range 6 .. 6;
9083       Master_V7      at 0 range 7 .. 7;
9084       Slave_Control  at 1 range 0 .. 0;
9085       Slave_V1       at 1 range 1 .. 1;
9086       Slave_V2       at 1 range 2 .. 2;
9087       Slave_V3       at 1 range 3 .. 3;
9088       Slave_V4       at 1 range 4 .. 4;
9089       Slave_V5       at 1 range 5 .. 5;
9090       Slave_V6       at 1 range 6 .. 6;
9091       Slave_V7       at 1 range 7 .. 7;
9092    end record;
9093 @end smallexample
9094
9095 @noindent
9096 Now if we move this to a little endian machine, then the bit ordering within
9097 the byte is backwards, so we have to rewrite the record rep clause as:
9098
9099 @smallexample @c ada
9100    for Data use record
9101       Master_Control at 0 range 7 .. 7;
9102       Master_V1      at 0 range 6 .. 6;
9103       Master_V2      at 0 range 5 .. 5;
9104       Master_V3      at 0 range 4 .. 4;
9105       Master_V4      at 0 range 3 .. 3;
9106       Master_V5      at 0 range 2 .. 2;
9107       Master_V6      at 0 range 1 .. 1;
9108       Master_V7      at 0 range 0 .. 0;
9109       Slave_Control  at 1 range 7 .. 7;
9110       Slave_V1       at 1 range 6 .. 6;
9111       Slave_V2       at 1 range 5 .. 5;
9112       Slave_V3       at 1 range 4 .. 4;
9113       Slave_V4       at 1 range 3 .. 3;
9114       Slave_V5       at 1 range 2 .. 2;
9115       Slave_V6       at 1 range 1 .. 1;
9116       Slave_V7       at 1 range 0 .. 0;
9117    end record;
9118 @end smallexample
9119
9120 @noindent
9121 It is a nuisance to have to rewrite the clause, especially if
9122 the code has to be maintained on both machines.  However,
9123 this is a case that we can handle with the
9124 @code{Bit_Order} attribute if it is implemented.
9125 Note that the implementation is not required on byte addressed
9126 machines, but it is indeed implemented in GNAT.
9127 This means that we can simply use the
9128 first record clause, together with the declaration
9129
9130 @smallexample @c ada
9131    for Data'Bit_Order use High_Order_First;
9132 @end smallexample
9133
9134 @noindent
9135 and the effect is what is desired, namely the layout is exactly the same,
9136 independent of whether the code is compiled on a big-endian or little-endian
9137 machine.
9138
9139 The important point to understand is that byte ordering is not affected.
9140 A @code{Bit_Order} attribute definition never affects which byte a field
9141 ends up in, only where it ends up in that byte.
9142 To make this clear, let us rewrite the record rep clause of the previous
9143 example as:
9144
9145 @smallexample @c ada
9146    for Data'Bit_Order use High_Order_First;
9147    for Data use record
9148       Master_Control at 0 range  0 .. 0;
9149       Master_V1      at 0 range  1 .. 1;
9150       Master_V2      at 0 range  2 .. 2;
9151       Master_V3      at 0 range  3 .. 3;
9152       Master_V4      at 0 range  4 .. 4;
9153       Master_V5      at 0 range  5 .. 5;
9154       Master_V6      at 0 range  6 .. 6;
9155       Master_V7      at 0 range  7 .. 7;
9156       Slave_Control  at 0 range  8 .. 8;
9157       Slave_V1       at 0 range  9 .. 9;
9158       Slave_V2       at 0 range 10 .. 10;
9159       Slave_V3       at 0 range 11 .. 11;
9160       Slave_V4       at 0 range 12 .. 12;
9161       Slave_V5       at 0 range 13 .. 13;
9162       Slave_V6       at 0 range 14 .. 14;
9163       Slave_V7       at 0 range 15 .. 15;
9164    end record;
9165 @end smallexample
9166
9167 @noindent
9168 This is exactly equivalent to saying (a repeat of the first example):
9169
9170 @smallexample @c ada
9171    for Data'Bit_Order use High_Order_First;
9172    for Data use record
9173       Master_Control at 0 range 0 .. 0;
9174       Master_V1      at 0 range 1 .. 1;
9175       Master_V2      at 0 range 2 .. 2;
9176       Master_V3      at 0 range 3 .. 3;
9177       Master_V4      at 0 range 4 .. 4;
9178       Master_V5      at 0 range 5 .. 5;
9179       Master_V6      at 0 range 6 .. 6;
9180       Master_V7      at 0 range 7 .. 7;
9181       Slave_Control  at 1 range 0 .. 0;
9182       Slave_V1       at 1 range 1 .. 1;
9183       Slave_V2       at 1 range 2 .. 2;
9184       Slave_V3       at 1 range 3 .. 3;
9185       Slave_V4       at 1 range 4 .. 4;
9186       Slave_V5       at 1 range 5 .. 5;
9187       Slave_V6       at 1 range 6 .. 6;
9188       Slave_V7       at 1 range 7 .. 7;
9189    end record;
9190 @end smallexample
9191
9192 @noindent
9193 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
9194 field.  The storage place attributes are obtained by normalizing the
9195 values given so that the @code{First_Bit} value is less than 8.  After
9196 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
9197 we specified in the other case.
9198
9199 Now one might expect that the @code{Bit_Order} attribute might affect
9200 bit numbering within the entire record component (two bytes in this
9201 case, thus affecting which byte fields end up in), but that is not
9202 the way this feature is defined, it only affects numbering of bits,
9203 not which byte they end up in.
9204
9205 Consequently it never makes sense to specify a starting bit number
9206 greater than 7 (for a byte addressable field) if an attribute
9207 definition for @code{Bit_Order} has been given, and indeed it
9208 may be actively confusing to specify such a value, so the compiler
9209 generates a warning for such usage.
9210
9211 If you do need to control byte ordering then appropriate conditional
9212 values must be used.  If in our example, the slave byte came first on
9213 some machines we might write:
9214
9215 @smallexample @c ada
9216    Master_Byte_First constant Boolean := @dots{};
9217
9218    Master_Byte : constant Natural :=
9219                    1 - Boolean'Pos (Master_Byte_First);
9220    Slave_Byte  : constant Natural :=
9221                    Boolean'Pos (Master_Byte_First);
9222
9223    for Data'Bit_Order use High_Order_First;
9224    for Data use record
9225       Master_Control at Master_Byte range 0 .. 0;
9226       Master_V1      at Master_Byte range 1 .. 1;
9227       Master_V2      at Master_Byte range 2 .. 2;
9228       Master_V3      at Master_Byte range 3 .. 3;
9229       Master_V4      at Master_Byte range 4 .. 4;
9230       Master_V5      at Master_Byte range 5 .. 5;
9231       Master_V6      at Master_Byte range 6 .. 6;
9232       Master_V7      at Master_Byte range 7 .. 7;
9233       Slave_Control  at Slave_Byte  range 0 .. 0;
9234       Slave_V1       at Slave_Byte  range 1 .. 1;
9235       Slave_V2       at Slave_Byte  range 2 .. 2;
9236       Slave_V3       at Slave_Byte  range 3 .. 3;
9237       Slave_V4       at Slave_Byte  range 4 .. 4;
9238       Slave_V5       at Slave_Byte  range 5 .. 5;
9239       Slave_V6       at Slave_Byte  range 6 .. 6;
9240       Slave_V7       at Slave_Byte  range 7 .. 7;
9241    end record;
9242 @end smallexample
9243
9244 @noindent
9245 Now to switch between machines, all that is necessary is
9246 to set the boolean constant @code{Master_Byte_First} in
9247 an appropriate manner.
9248
9249 @node Pragma Pack for Arrays
9250 @section Pragma Pack for Arrays
9251 @cindex Pragma Pack (for arrays)
9252
9253 @noindent
9254 Pragma @code{Pack} applied to an array has no effect unless the component type
9255 is packable.  For a component type to be packable, it must be one of the
9256 following cases:
9257
9258 @itemize @bullet
9259 @item
9260 Any scalar type
9261 @item
9262 Any type whose size is specified with a size clause
9263 @item
9264 Any packed array type with a static size
9265 @end itemize
9266
9267 @noindent
9268 For all these cases, if the component subtype size is in the range
9269 1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
9270 component size were specified giving the component subtype size.
9271 For example if we have:
9272
9273 @smallexample @c ada
9274    type r is range 0 .. 17;
9275
9276    type ar is array (1 .. 8) of r;
9277    pragma Pack (ar);
9278 @end smallexample
9279
9280 @noindent
9281 Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
9282 and the size of the array @code{ar} will be exactly 40 bits.
9283
9284 Note that in some cases this rather fierce approach to packing can produce
9285 unexpected effects.  For example, in Ada 95, type Natural typically has a
9286 size of 31, meaning that if you pack an array of Natural, you get 31-bit
9287 close packing, which saves a few bits, but results in far less efficient
9288 access.  Since many other Ada compilers will ignore such a packing request,
9289 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
9290 might not be what is intended.  You can easily remove this warning by
9291 using an explicit @code{Component_Size} setting instead, which never generates
9292 a warning, since the intention of the programmer is clear in this case.
9293
9294 GNAT treats packed arrays in one of two ways.  If the size of the array is
9295 known at compile time and is less than 64 bits, then internally the array
9296 is represented as a single modular type, of exactly the appropriate number
9297 of bits.  If the length is greater than 63 bits, or is not known at compile
9298 time, then the packed array is represented as an array of bytes, and the
9299 length is always a multiple of 8 bits.
9300
9301 Note that to represent a packed array as a modular type, the alignment must
9302 be suitable for the modular type involved. For example, on typical machines
9303 a 32-bit packed array will be represented by a 32-bit modular integer with
9304 an alignment of four bytes. If you explicitly override the default alignment
9305 with an alignment clause that is too small, the modular representation
9306 cannot be used. For example, consider the following set of declarations:
9307
9308 @smallexample @c ada
9309    type R is range 1 .. 3;
9310    type S is array (1 .. 31) of R;
9311    for S'Component_Size use 2;
9312    for S'Size use 62;
9313    for S'Alignment use 1;
9314 @end smallexample
9315
9316 @noindent
9317 If the alignment clause were not present, then a 62-bit modular
9318 representation would be chosen (typically with an alignment of 4 or 8
9319 bytes depending on the target). But the default alignment is overridden
9320 with the explicit alignment clause. This means that the modular
9321 representation cannot be used, and instead the array of bytes
9322 representation must be used, meaning that the length must be a multiple
9323 of 8. Thus the above set of declarations will result in a diagnostic
9324 rejecting the size clause and noting that the minimum size allowed is 64.
9325
9326 @cindex Pragma Pack (for type Natural)
9327 @cindex Pragma Pack warning
9328
9329 One special case that is worth noting occurs when the base type of the
9330 component size is 8/16/32 and the subtype is one bit less. Notably this
9331 occurs with subtype @code{Natural}. Consider:
9332
9333 @smallexample @c ada
9334    type Arr is array (1 .. 32) of Natural;
9335    pragma Pack (Arr);
9336 @end smallexample
9337
9338 @noindent
9339 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
9340 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
9341 Ada 83 compilers did not attempt 31 bit packing.
9342
9343 In Ada 95, @code{Natural'Size} is required to be 31. Furthermore, GNAT really
9344 does pack 31-bit subtype to 31 bits. This may result in a substantial
9345 unintended performance penalty when porting legacy Ada 83 code. To help
9346 prevent this, GNAT generates a warning in such cases. If you really want 31
9347 bit packing in a case like this, you can set the component size explicitly:
9348
9349 @smallexample @c ada
9350    type Arr is array (1 .. 32) of Natural;
9351    for Arr'Component_Size use 31;
9352 @end smallexample
9353
9354 @noindent
9355 Here 31-bit packing is achieved as required, and no warning is generated,
9356 since in this case the programmer intention is clear.
9357
9358 @node Pragma Pack for Records
9359 @section Pragma Pack for Records
9360 @cindex Pragma Pack (for records)
9361
9362 @noindent
9363 Pragma @code{Pack} applied to a record will pack the components to reduce
9364 wasted space from alignment gaps and by reducing the amount of space
9365 taken by components.  We distinguish between @emph{packable} components and
9366 @emph{non-packable} components.
9367 Components of the following types are considered packable:
9368 @itemize @bullet
9369 @item
9370 All primitive types are packable.
9371
9372 @item
9373 Small packed arrays, whose size does not exceed 64 bits, and where the
9374 size is statically known at compile time, are represented internally
9375 as modular integers, and so they are also packable.
9376
9377 @end itemize
9378
9379 @noindent
9380 All packable components occupy the exact number of bits corresponding to
9381 their @code{Size} value, and are packed with no padding bits, i.e.@: they
9382 can start on an arbitrary bit boundary.
9383
9384 All other types are non-packable, they occupy an integral number of
9385 storage units, and
9386 are placed at a boundary corresponding to their alignment requirements.
9387
9388 For example, consider the record
9389
9390 @smallexample @c ada
9391    type Rb1 is array (1 .. 13) of Boolean;
9392    pragma Pack (rb1);
9393
9394    type Rb2 is array (1 .. 65) of Boolean;
9395    pragma Pack (rb2);
9396
9397    type x2 is record
9398       l1 : Boolean;
9399       l2 : Duration;
9400       l3 : Float;
9401       l4 : Boolean;
9402       l5 : Rb1;
9403       l6 : Rb2;
9404    end record;
9405    pragma Pack (x2);
9406 @end smallexample
9407
9408 @noindent
9409 The representation for the record x2 is as follows:
9410
9411 @smallexample @c ada
9412 for x2'Size use 224;
9413 for x2 use record
9414    l1 at  0 range  0 .. 0;
9415    l2 at  0 range  1 .. 64;
9416    l3 at 12 range  0 .. 31;
9417    l4 at 16 range  0 .. 0;
9418    l5 at 16 range  1 .. 13;
9419    l6 at 18 range  0 .. 71;
9420 end record;
9421 @end smallexample
9422
9423 @noindent
9424 Studying this example, we see that the packable fields @code{l1}
9425 and @code{l2} are
9426 of length equal to their sizes, and placed at specific bit boundaries (and
9427 not byte boundaries) to
9428 eliminate padding.  But @code{l3} is of a non-packable float type, so
9429 it is on the next appropriate alignment boundary.
9430
9431 The next two fields are fully packable, so @code{l4} and @code{l5} are
9432 minimally packed with no gaps.  However, type @code{Rb2} is a packed
9433 array that is longer than 64 bits, so it is itself non-packable.  Thus
9434 the @code{l6} field is aligned to the next byte boundary, and takes an
9435 integral number of bytes, i.e.@: 72 bits.
9436
9437 @node Record Representation Clauses
9438 @section Record Representation Clauses
9439 @cindex Record Representation Clause
9440
9441 @noindent
9442 Record representation clauses may be given for all record types, including
9443 types obtained by record extension.  Component clauses are allowed for any
9444 static component.  The restrictions on component clauses depend on the type
9445 of the component.
9446
9447 @cindex Component Clause
9448 For all components of an elementary type, the only restriction on component
9449 clauses is that the size must be at least the 'Size value of the type
9450 (actually the Value_Size).  There are no restrictions due to alignment,
9451 and such components may freely cross storage boundaries.
9452
9453 Packed arrays with a size up to and including 64 bits are represented
9454 internally using a modular type with the appropriate number of bits, and
9455 thus the same lack of restriction applies.  For example, if you declare:
9456
9457 @smallexample @c ada
9458    type R is array (1 .. 49) of Boolean;
9459    pragma Pack (R);
9460    for R'Size use 49;
9461 @end smallexample
9462
9463 @noindent
9464 then a component clause for a component of type R may start on any
9465 specified bit boundary, and may specify a value of 49 bits or greater.
9466
9467 Packed bit arrays that are longer than 64 bits must always be placed
9468 on a storage unit (byte) boundary. Any component clause that does not
9469 meet this requirement will be rejected.
9470
9471 The rules for other types are different for GNAT 3 and GNAT 5 versions
9472 (based on GCC 2 and GCC 3 respectively). In GNAT 5, larger components
9473 (other than packed arrays)
9474 may also be placed on arbitrary boundaries, so for example, the following
9475 is permitted:
9476
9477 @smallexample @c ada
9478    type R is array (1 .. 10) of Boolean;
9479    for R'Size use 80;
9480
9481    type Q is record
9482       G, H : Boolean;
9483       L, M : R;
9484    end record;
9485
9486    for Q use record
9487       G at 0 range  0 ..   0;
9488       H at 0 range  1 ..   1;
9489       L at 0 range  2 ..  81;
9490       R at 0 range 82 .. 161;
9491    end record;
9492 @end smallexample
9493
9494 @noindent
9495 In GNAT 3, there are more severe restrictions on larger components.
9496 For non-primitive types, including packed arrays with a size greater than
9497 64 bits, component clauses must respect the alignment requirement of the
9498 type, in particular, always starting on a byte boundary, and the length
9499 must be a multiple of the storage unit.
9500
9501 The following rules regarding tagged types are enforced in both GNAT 3 and
9502 GNAT 5:
9503
9504 The tag field of a tagged type always occupies an address sized field at
9505 the start of the record.  No component clause may attempt to overlay this
9506 tag.
9507
9508 In the case of a record extension T1, of a type T, no component clause applied
9509 to the type T1 can specify a storage location that would overlap the first
9510 T'Size bytes of the record.
9511
9512 @node Enumeration Clauses
9513 @section Enumeration Clauses
9514
9515 The only restriction on enumeration clauses is that the range of values
9516 must be representable.  For the signed case, if one or more of the
9517 representation values are negative, all values must be in the range:
9518
9519 @smallexample @c ada
9520    System.Min_Int .. System.Max_Int
9521 @end smallexample
9522
9523 @noindent
9524 For the unsigned case, where all values are non negative, the values must
9525 be in the range:
9526
9527 @smallexample @c ada
9528    0 .. System.Max_Binary_Modulus;
9529 @end smallexample
9530
9531 @noindent
9532 A @emph{confirming} representation clause is one in which the values range
9533 from 0 in sequence, i.e.@: a clause that confirms the default representation
9534 for an enumeration type.
9535 Such a confirming representation
9536 is permitted by these rules, and is specially recognized by the compiler so
9537 that no extra overhead results from the use of such a clause.
9538
9539 If an array has an index type which is an enumeration type to which an
9540 enumeration clause has been applied, then the array is stored in a compact
9541 manner.  Consider the declarations:
9542
9543 @smallexample @c ada
9544    type r is (A, B, C);
9545    for r use (A => 1, B => 5, C => 10);
9546    type t is array (r) of Character;
9547 @end smallexample
9548
9549 @noindent
9550 The array type t corresponds to a vector with exactly three elements and
9551 has a default size equal to @code{3*Character'Size}.  This ensures efficient
9552 use of space, but means that accesses to elements of the array will incur
9553 the overhead of converting representation values to the corresponding
9554 positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
9555
9556 @node Address Clauses
9557 @section Address Clauses
9558 @cindex Address Clause
9559
9560 The reference manual allows a general restriction on representation clauses,
9561 as found in RM 13.1(22):
9562
9563 @quotation
9564 An implementation need not support representation
9565 items containing nonstatic expressions, except that
9566 an implementation should support a representation item
9567 for a given entity if each nonstatic expression in the
9568 representation item is a name that statically denotes
9569 a constant declared before the entity.
9570 @end quotation
9571
9572 @noindent
9573 In practice this is applicable only to address clauses, since this is the
9574 only case in which a non-static expression is permitted by the syntax.  As
9575 the AARM notes in sections 13.1 (22.a-22.h):
9576
9577 @display
9578   22.a   Reason: This is to avoid the following sort of thing:
9579
9580   22.b        X : Integer := F(@dots{});
9581               Y : Address := G(@dots{});
9582               for X'Address use Y;
9583
9584   22.c   In the above, we have to evaluate the
9585          initialization expression for X before we
9586          know where to put the result.  This seems
9587          like an unreasonable implementation burden.
9588
9589   22.d   The above code should instead be written
9590          like this:
9591
9592   22.e        Y : constant Address := G(@dots{});
9593               X : Integer := F(@dots{});
9594               for X'Address use Y;
9595
9596   22.f   This allows the expression ``Y'' to be safely
9597          evaluated before X is created.
9598
9599   22.g   The constant could be a formal parameter of mode in.
9600
9601   22.h   An implementation can support other nonstatic
9602          expressions if it wants to.  Expressions of type
9603          Address are hardly ever static, but their value
9604          might be known at compile time anyway in many
9605          cases.
9606 @end display
9607
9608 @noindent
9609 GNAT does indeed permit many additional cases of non-static expressions.  In
9610 particular, if the type involved is elementary there are no restrictions
9611 (since in this case, holding a temporary copy of the initialization value,
9612 if one is present, is inexpensive).  In addition, if there is no implicit or
9613 explicit initialization, then there are no restrictions.  GNAT will reject
9614 only the case where all three of these conditions hold:
9615
9616 @itemize @bullet
9617
9618 @item
9619 The type of the item is non-elementary (e.g.@: a record or array).
9620
9621 @item
9622 There is explicit or implicit initialization required for the object.
9623 Note that access values are always implicitly initialized, and also
9624 in GNAT, certain bit-packed arrays (those having a dynamic length or
9625 a length greater than 64) will also be implicitly initialized to zero.
9626
9627 @item
9628 The address value is non-static.  Here GNAT is more permissive than the
9629 RM, and allows the address value to be the address of a previously declared
9630 stand-alone variable, as long as it does not itself have an address clause.
9631
9632 @smallexample @c ada
9633            Anchor  : Some_Initialized_Type;
9634            Overlay : Some_Initialized_Type;
9635            for Overlay'Address use Anchor'Address;
9636 @end smallexample
9637
9638 @noindent
9639 However, the prefix of the address clause cannot be an array component, or
9640 a component of a discriminated record.
9641
9642 @end itemize
9643
9644 @noindent
9645 As noted above in section 22.h, address values are typically non-static.  In
9646 particular the To_Address function, even if applied to a literal value, is
9647 a non-static function call.  To avoid this minor annoyance, GNAT provides
9648 the implementation defined attribute 'To_Address.  The following two
9649 expressions have identical values:
9650
9651 @findex Attribute
9652 @findex To_Address
9653 @smallexample @c ada
9654    To_Address (16#1234_0000#)
9655    System'To_Address (16#1234_0000#);
9656 @end smallexample
9657
9658 @noindent
9659 except that the second form is considered to be a static expression, and
9660 thus when used as an address clause value is always permitted.
9661
9662 @noindent
9663 Additionally, GNAT treats as static an address clause that is an
9664 unchecked_conversion of a static integer value.  This simplifies the porting
9665 of legacy code, and provides a portable equivalent to the GNAT attribute
9666 @code{To_Address}.
9667
9668 Another issue with address clauses is the interaction with alignment
9669 requirements.  When an address clause is given for an object, the address
9670 value must be consistent with the alignment of the object (which is usually
9671 the same as the alignment of the type of the object).  If an address clause
9672 is given that specifies an inappropriately aligned address value, then the
9673 program execution is erroneous.
9674
9675 Since this source of erroneous behavior can have unfortunate effects, GNAT
9676 checks (at compile time if possible, generating a warning, or at execution
9677 time with a run-time check) that the alignment is appropriate.  If the
9678 run-time check fails, then @code{Program_Error} is raised.  This run-time
9679 check is suppressed if range checks are suppressed, or if
9680 @code{pragma Restrictions (No_Elaboration_Code)} is in effect.
9681
9682 @findex Export
9683 An address clause cannot be given for an exported object.  More
9684 understandably the real restriction is that objects with an address
9685 clause cannot be exported.  This is because such variables are not
9686 defined by the Ada program, so there is no external object to export.
9687
9688 @findex Import
9689 It is permissible to give an address clause and a pragma Import for the
9690 same object.  In this case, the variable is not really defined by the
9691 Ada program, so there is no external symbol to be linked.  The link name
9692 and the external name are ignored in this case.  The reason that we allow this
9693 combination is that it provides a useful idiom to avoid unwanted
9694 initializations on objects with address clauses.
9695
9696 When an address clause is given for an object that has implicit or
9697 explicit initialization, then by default initialization takes place.  This
9698 means that the effect of the object declaration is to overwrite the
9699 memory at the specified address.  This is almost always not what the
9700 programmer wants, so GNAT will output a warning:
9701
9702 @smallexample
9703   with System;
9704   package G is
9705      type R is record
9706         M : Integer := 0;
9707      end record;
9708
9709      Ext : R;
9710      for Ext'Address use System'To_Address (16#1234_1234#);
9711          |
9712   >>> warning: implicit initialization of "Ext" may
9713       modify overlaid storage
9714   >>> warning: use pragma Import for "Ext" to suppress
9715       initialization (RM B(24))
9716
9717   end G;
9718 @end smallexample
9719
9720 @noindent
9721 As indicated by the warning message, the solution is to use a (dummy) pragma
9722 Import to suppress this initialization.  The pragma tell the compiler that the
9723 object is declared and initialized elsewhere.  The following package compiles
9724 without warnings (and the initialization is suppressed):
9725
9726 @smallexample @c ada
9727    with System;
9728    package G is
9729       type R is record
9730          M : Integer := 0;
9731       end record;
9732
9733       Ext : R;
9734       for Ext'Address use System'To_Address (16#1234_1234#);
9735       pragma Import (Ada, Ext);
9736    end G;
9737 @end smallexample
9738
9739 @noindent
9740 A final issue with address clauses involves their use for overlaying
9741 variables, as in the following example:
9742 @cindex Overlaying of objects
9743
9744 @smallexample @c ada
9745   A : Integer;
9746   B : Integer;
9747   for B'Address use A'Address;
9748 @end smallexample
9749
9750 @noindent
9751 or alternatively, using the form recommended by the RM:
9752
9753 @smallexample @c ada
9754   A    : Integer;
9755   Addr : constant Address := A'Address;
9756   B    : Integer;
9757   for B'Address use Addr;
9758 @end smallexample
9759
9760 @noindent
9761 In both of these cases, @code{A}
9762 and @code{B} become aliased to one another via the
9763 address clause. This use of address clauses to overlay
9764 variables, achieving an effect similar to unchecked
9765 conversion was erroneous in Ada 83, but in Ada 95
9766 the effect is implementation defined. Furthermore, the
9767 Ada 95 RM specifically recommends that in a situation
9768 like this, @code{B} should be subject to the following
9769 implementation advice (RM 13.3(19)):
9770
9771 @quotation
9772 19  If the Address of an object is specified, or it is imported
9773     or exported, then the implementation should not perform
9774     optimizations based on assumptions of no aliases.
9775 @end quotation
9776
9777 @noindent
9778 GNAT follows this recommendation, and goes further by also applying
9779 this recommendation to the overlaid variable (@code{A}
9780 in the above example) in this case. This means that the overlay
9781 works "as expected", in that a modification to one of the variables
9782 will affect the value of the other.
9783
9784 @node Effect of Convention on Representation
9785 @section Effect of Convention on Representation
9786 @cindex Convention, effect on representation
9787
9788 @noindent
9789 Normally the specification of a foreign language convention for a type or
9790 an object has no effect on the chosen representation.  In particular, the
9791 representation chosen for data in GNAT generally meets the standard system
9792 conventions, and for example records are laid out in a manner that is
9793 consistent with C@.  This means that specifying convention C (for example)
9794 has no effect.
9795
9796 There are three exceptions to this general rule:
9797
9798 @itemize @bullet
9799
9800 @item Convention Fortran and array subtypes
9801 If pragma Convention Fortran is specified for an array subtype, then in
9802 accordance with the implementation advice in section 3.6.2(11) of the
9803 Ada Reference Manual, the array will be stored in a Fortran-compatible
9804 column-major manner, instead of the normal default row-major order.
9805
9806 @item Convention C and enumeration types
9807 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
9808 to accommodate all values of the type.  For example, for the enumeration
9809 type declared by:
9810
9811 @smallexample @c ada
9812    type Color is (Red, Green, Blue);
9813 @end smallexample
9814
9815 @noindent
9816 8 bits is sufficient to store all values of the type, so by default, objects
9817 of type @code{Color} will be represented using 8 bits.  However, normal C
9818 convention is to use 32 bits for all enum values in C, since enum values
9819 are essentially of type int.  If pragma @code{Convention C} is specified for an
9820 Ada enumeration type, then the size is modified as necessary (usually to
9821 32 bits) to be consistent with the C convention for enum values.
9822
9823 @item Convention C/Fortran and Boolean types
9824 In C, the usual convention for boolean values, that is values used for
9825 conditions, is that zero represents false, and nonzero values represent
9826 true.  In Ada, the normal convention is that two specific values, typically
9827 0/1, are used to represent false/true respectively.
9828
9829 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
9830 value represents true).
9831
9832 To accommodate the Fortran and C conventions, if a pragma Convention specifies
9833 C or Fortran convention for a derived Boolean, as in the following example:
9834
9835 @smallexample @c ada
9836    type C_Switch is new Boolean;
9837    pragma Convention (C, C_Switch);
9838 @end smallexample
9839
9840 @noindent
9841 then the GNAT generated code will treat any nonzero value as true.  For truth
9842 values generated by GNAT, the conventional value 1 will be used for True, but
9843 when one of these values is read, any nonzero value is treated as True.
9844
9845 @end itemize
9846
9847 @node Determining the Representations chosen by GNAT
9848 @section Determining the Representations chosen by GNAT
9849 @cindex Representation, determination of
9850 @cindex @code{-gnatR} switch
9851
9852 @noindent
9853 Although the descriptions in this section are intended to be complete, it is
9854 often easier to simply experiment to see what GNAT accepts and what the
9855 effect is on the layout of types and objects.
9856
9857 As required by the Ada RM, if a representation clause is not accepted, then
9858 it must be rejected as illegal by the compiler.  However, when a
9859 representation clause or pragma is accepted, there can still be questions
9860 of what the compiler actually does.  For example, if a partial record
9861 representation clause specifies the location of some components and not
9862 others, then where are the non-specified components placed? Or if pragma
9863 @code{Pack} is used on a record, then exactly where are the resulting
9864 fields placed? The section on pragma @code{Pack} in this chapter can be
9865 used to answer the second question, but it is often easier to just see
9866 what the compiler does.
9867
9868 For this purpose, GNAT provides the option @code{-gnatR}.  If you compile
9869 with this option, then the compiler will output information on the actual
9870 representations chosen, in a format similar to source representation
9871 clauses.  For example, if we compile the package:
9872
9873 @smallexample @c ada
9874 package q is
9875    type r (x : boolean) is tagged record
9876       case x is
9877          when True => S : String (1 .. 100);
9878          when False => null;
9879       end case;
9880    end record;
9881
9882    type r2 is new r (false) with record
9883       y2 : integer;
9884    end record;
9885
9886    for r2 use record
9887       y2 at 16 range 0 .. 31;
9888    end record;
9889
9890    type x is record
9891       y : character;
9892    end record;
9893
9894    type x1 is array (1 .. 10) of x;
9895    for x1'component_size use 11;
9896
9897    type ia is access integer;
9898
9899    type Rb1 is array (1 .. 13) of Boolean;
9900    pragma Pack (rb1);
9901
9902    type Rb2 is array (1 .. 65) of Boolean;
9903    pragma Pack (rb2);
9904
9905    type x2 is record
9906       l1 : Boolean;
9907       l2 : Duration;
9908       l3 : Float;
9909       l4 : Boolean;
9910       l5 : Rb1;
9911       l6 : Rb2;
9912    end record;
9913    pragma Pack (x2);
9914 end q;
9915 @end smallexample
9916
9917 @noindent
9918 using the switch @code{-gnatR} we obtain the following output:
9919
9920 @smallexample
9921 Representation information for unit q
9922 -------------------------------------
9923
9924 for r'Size use ??;
9925 for r'Alignment use 4;
9926 for r use record
9927    x    at 4 range  0 .. 7;
9928    _tag at 0 range  0 .. 31;
9929    s    at 5 range  0 .. 799;
9930 end record;
9931
9932 for r2'Size use 160;
9933 for r2'Alignment use 4;
9934 for r2 use record
9935    x       at  4 range  0 .. 7;
9936    _tag    at  0 range  0 .. 31;
9937    _parent at  0 range  0 .. 63;
9938    y2      at 16 range  0 .. 31;
9939 end record;
9940
9941 for x'Size use 8;
9942 for x'Alignment use 1;
9943 for x use record
9944    y at 0 range  0 .. 7;
9945 end record;
9946
9947 for x1'Size use 112;
9948 for x1'Alignment use 1;
9949 for x1'Component_Size use 11;
9950
9951 for rb1'Size use 13;
9952 for rb1'Alignment use 2;
9953 for rb1'Component_Size use 1;
9954
9955 for rb2'Size use 72;
9956 for rb2'Alignment use 1;
9957 for rb2'Component_Size use 1;
9958
9959 for x2'Size use 224;
9960 for x2'Alignment use 4;
9961 for x2 use record
9962    l1 at  0 range  0 .. 0;
9963    l2 at  0 range  1 .. 64;
9964    l3 at 12 range  0 .. 31;
9965    l4 at 16 range  0 .. 0;
9966    l5 at 16 range  1 .. 13;
9967    l6 at 18 range  0 .. 71;
9968 end record;
9969 @end smallexample
9970
9971 @noindent
9972 The Size values are actually the Object_Size, i.e.@: the default size that
9973 will be allocated for objects of the type.
9974 The ?? size for type r indicates that we have a variant record, and the
9975 actual size of objects will depend on the discriminant value.
9976
9977 The Alignment values show the actual alignment chosen by the compiler
9978 for each record or array type.
9979
9980 The record representation clause for type r shows where all fields
9981 are placed, including the compiler generated tag field (whose location
9982 cannot be controlled by the programmer).
9983
9984 The record representation clause for the type extension r2 shows all the
9985 fields present, including the parent field, which is a copy of the fields
9986 of the parent type of r2, i.e.@: r1.
9987
9988 The component size and size clauses for types rb1 and rb2 show
9989 the exact effect of pragma @code{Pack} on these arrays, and the record
9990 representation clause for type x2 shows how pragma @code{Pack} affects
9991 this record type.
9992
9993 In some cases, it may be useful to cut and paste the representation clauses
9994 generated by the compiler into the original source to fix and guarantee
9995 the actual representation to be used.
9996
9997 @node Standard Library Routines
9998 @chapter Standard Library Routines
9999
10000 @noindent
10001 The Ada 95 Reference Manual contains in Annex A a full description of an
10002 extensive set of standard library routines that can be used in any Ada
10003 program, and which must be provided by all Ada compilers.  They are
10004 analogous to the standard C library used by C programs.
10005
10006 GNAT implements all of the facilities described in annex A, and for most
10007 purposes the description in the Ada 95
10008 reference manual, or appropriate Ada
10009 text book, will be sufficient for making use of these facilities.
10010
10011 In the case of the input-output facilities, @xref{The Implementation of
10012 Standard I/O}, gives details on exactly how GNAT interfaces to the
10013 file system.  For the remaining packages, the Ada 95 reference manual
10014 should be sufficient.  The following is a list of the packages included,
10015 together with a brief description of the functionality that is provided.
10016
10017 For completeness, references are included to other predefined library
10018 routines defined in other sections of the Ada 95 reference manual (these are
10019 cross-indexed from annex A).
10020
10021 @table @code
10022 @item Ada (A.2)
10023 This is a parent package for all the standard library packages.  It is
10024 usually included implicitly in your program, and itself contains no
10025 useful data or routines.
10026
10027 @item Ada.Calendar (9.6)
10028 @code{Calendar} provides time of day access, and routines for
10029 manipulating times and durations.
10030
10031 @item Ada.Characters (A.3.1)
10032 This is a dummy parent package that contains no useful entities
10033
10034 @item Ada.Characters.Handling (A.3.2)
10035 This package provides some basic character handling capabilities,
10036 including classification functions for classes of characters (e.g.@: test
10037 for letters, or digits).
10038
10039 @item Ada.Characters.Latin_1 (A.3.3)
10040 This package includes a complete set of definitions of the characters
10041 that appear in type CHARACTER@.  It is useful for writing programs that
10042 will run in international environments.  For example, if you want an
10043 upper case E with an acute accent in a string, it is often better to use
10044 the definition of @code{UC_E_Acute} in this package.  Then your program
10045 will print in an understandable manner even if your environment does not
10046 support these extended characters.
10047
10048 @item Ada.Command_Line (A.15)
10049 This package provides access to the command line parameters and the name
10050 of the current program (analogous to the use of @code{argc} and @code{argv}
10051 in C), and also allows the exit status for the program to be set in a
10052 system-independent manner.
10053
10054 @item Ada.Decimal (F.2)
10055 This package provides constants describing the range of decimal numbers
10056 implemented, and also a decimal divide routine (analogous to the COBOL
10057 verb DIVIDE .. GIVING .. REMAINDER ..)
10058
10059 @item Ada.Direct_IO (A.8.4)
10060 This package provides input-output using a model of a set of records of
10061 fixed-length, containing an arbitrary definite Ada type, indexed by an
10062 integer record number.
10063
10064 @item Ada.Dynamic_Priorities (D.5)
10065 This package allows the priorities of a task to be adjusted dynamically
10066 as the task is running.
10067
10068 @item Ada.Exceptions (11.4.1)
10069 This package provides additional information on exceptions, and also
10070 contains facilities for treating exceptions as data objects, and raising
10071 exceptions with associated messages.
10072
10073 @item Ada.Finalization (7.6)
10074 This package contains the declarations and subprograms to support the
10075 use of controlled types, providing for automatic initialization and
10076 finalization (analogous to the constructors and destructors of C++)
10077
10078 @item Ada.Interrupts (C.3.2)
10079 This package provides facilities for interfacing to interrupts, which
10080 includes the set of signals or conditions that can be raised and
10081 recognized as interrupts.
10082
10083 @item Ada.Interrupts.Names (C.3.2)
10084 This package provides the set of interrupt names (actually signal
10085 or condition names) that can be handled by GNAT@.
10086
10087 @item Ada.IO_Exceptions (A.13)
10088 This package defines the set of exceptions that can be raised by use of
10089 the standard IO packages.
10090
10091 @item Ada.Numerics
10092 This package contains some standard constants and exceptions used
10093 throughout the numerics packages.  Note that the constants pi and e are
10094 defined here, and it is better to use these definitions than rolling
10095 your own.
10096
10097 @item Ada.Numerics.Complex_Elementary_Functions
10098 Provides the implementation of standard elementary functions (such as
10099 log and trigonometric functions) operating on complex numbers using the
10100 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
10101 created by the package @code{Numerics.Complex_Types}.
10102
10103 @item Ada.Numerics.Complex_Types
10104 This is a predefined instantiation of
10105 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
10106 build the type @code{Complex} and @code{Imaginary}.
10107
10108 @item Ada.Numerics.Discrete_Random
10109 This package provides a random number generator suitable for generating
10110 random integer values from a specified range.
10111
10112 @item Ada.Numerics.Float_Random
10113 This package provides a random number generator suitable for generating
10114 uniformly distributed floating point values.
10115
10116 @item Ada.Numerics.Generic_Complex_Elementary_Functions
10117 This is a generic version of the package that provides the
10118 implementation of standard elementary functions (such as log and
10119 trigonometric functions) for an arbitrary complex type.
10120
10121 The following predefined instantiations of this package are provided:
10122
10123 @table @code
10124 @item Short_Float
10125 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
10126 @item Float
10127 @code{Ada.Numerics.Complex_Elementary_Functions}
10128 @item Long_Float
10129 @code{Ada.Numerics.
10130  Long_Complex_Elementary_Functions}
10131 @end table
10132
10133 @item Ada.Numerics.Generic_Complex_Types
10134 This is a generic package that allows the creation of complex types,
10135 with associated complex arithmetic operations.
10136
10137 The following predefined instantiations of this package exist
10138 @table @code
10139 @item Short_Float
10140 @code{Ada.Numerics.Short_Complex_Complex_Types}
10141 @item Float
10142 @code{Ada.Numerics.Complex_Complex_Types}
10143 @item Long_Float
10144 @code{Ada.Numerics.Long_Complex_Complex_Types}
10145 @end table
10146
10147 @item Ada.Numerics.Generic_Elementary_Functions
10148 This is a generic package that provides the implementation of standard
10149 elementary functions (such as log an trigonometric functions) for an
10150 arbitrary float type.
10151
10152 The following predefined instantiations of this package exist
10153
10154 @table @code
10155 @item Short_Float
10156 @code{Ada.Numerics.Short_Elementary_Functions}
10157 @item Float
10158 @code{Ada.Numerics.Elementary_Functions}
10159 @item Long_Float
10160 @code{Ada.Numerics.Long_Elementary_Functions}
10161 @end table
10162
10163 @item Ada.Real_Time (D.8)
10164 This package provides facilities similar to those of @code{Calendar}, but
10165 operating with a finer clock suitable for real time control. Note that
10166 annex D requires that there be no backward clock jumps, and GNAT generally
10167 guarantees this behavior, but of course if the external clock on which
10168 the GNAT runtime depends is deliberately reset by some external event,
10169 then such a backward jump may occur.
10170
10171 @item Ada.Sequential_IO (A.8.1)
10172 This package provides input-output facilities for sequential files,
10173 which can contain a sequence of values of a single type, which can be
10174 any Ada type, including indefinite (unconstrained) types.
10175
10176 @item Ada.Storage_IO (A.9)
10177 This package provides a facility for mapping arbitrary Ada types to and
10178 from a storage buffer.  It is primarily intended for the creation of new
10179 IO packages.
10180
10181 @item Ada.Streams (13.13.1)
10182 This is a generic package that provides the basic support for the
10183 concept of streams as used by the stream attributes (@code{Input},
10184 @code{Output}, @code{Read} and @code{Write}).
10185
10186 @item Ada.Streams.Stream_IO (A.12.1)
10187 This package is a specialization of the type @code{Streams} defined in
10188 package @code{Streams} together with a set of operations providing
10189 Stream_IO capability.  The Stream_IO model permits both random and
10190 sequential access to a file which can contain an arbitrary set of values
10191 of one or more Ada types.
10192
10193 @item Ada.Strings (A.4.1)
10194 This package provides some basic constants used by the string handling
10195 packages.
10196
10197 @item Ada.Strings.Bounded (A.4.4)
10198 This package provides facilities for handling variable length
10199 strings.  The bounded model requires a maximum length.  It is thus
10200 somewhat more limited than the unbounded model, but avoids the use of
10201 dynamic allocation or finalization.
10202
10203 @item Ada.Strings.Fixed (A.4.3)
10204 This package provides facilities for handling fixed length strings.
10205
10206 @item Ada.Strings.Maps (A.4.2)
10207 This package provides facilities for handling character mappings and
10208 arbitrarily defined subsets of characters.  For instance it is useful in
10209 defining specialized translation tables.
10210
10211 @item Ada.Strings.Maps.Constants (A.4.6)
10212 This package provides a standard set of predefined mappings and
10213 predefined character sets.  For example, the standard upper to lower case
10214 conversion table is found in this package.  Note that upper to lower case
10215 conversion is non-trivial if you want to take the entire set of
10216 characters, including extended characters like E with an acute accent,
10217 into account.  You should use the mappings in this package (rather than
10218 adding 32 yourself) to do case mappings.
10219
10220 @item Ada.Strings.Unbounded (A.4.5)
10221 This package provides facilities for handling variable length
10222 strings.  The unbounded model allows arbitrary length strings, but
10223 requires the use of dynamic allocation and finalization.
10224
10225 @item Ada.Strings.Wide_Bounded (A.4.7)
10226 @itemx Ada.Strings.Wide_Fixed (A.4.7)
10227 @itemx Ada.Strings.Wide_Maps (A.4.7)
10228 @itemx Ada.Strings.Wide_Maps.Constants (A.4.7)
10229 @itemx Ada.Strings.Wide_Unbounded (A.4.7)
10230 These packages provide analogous capabilities to the corresponding
10231 packages without @samp{Wide_} in the name, but operate with the types
10232 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
10233 and @code{Character}.
10234
10235 @item Ada.Synchronous_Task_Control (D.10)
10236 This package provides some standard facilities for controlling task
10237 communication in a synchronous manner.
10238
10239 @item Ada.Tags
10240 This package contains definitions for manipulation of the tags of tagged
10241 values.
10242
10243 @item Ada.Task_Attributes
10244 This package provides the capability of associating arbitrary
10245 task-specific data with separate tasks.
10246
10247 @item Ada.Text_IO
10248 This package provides basic text input-output capabilities for
10249 character, string and numeric data.  The subpackages of this
10250 package are listed next.
10251
10252 @item Ada.Text_IO.Decimal_IO
10253 Provides input-output facilities for decimal fixed-point types
10254
10255 @item Ada.Text_IO.Enumeration_IO
10256 Provides input-output facilities for enumeration types.
10257
10258 @item Ada.Text_IO.Fixed_IO
10259 Provides input-output facilities for ordinary fixed-point types.
10260
10261 @item Ada.Text_IO.Float_IO
10262 Provides input-output facilities for float types.  The following
10263 predefined instantiations of this generic package are available:
10264
10265 @table @code
10266 @item Short_Float
10267 @code{Short_Float_Text_IO}
10268 @item Float
10269 @code{Float_Text_IO}
10270 @item Long_Float
10271 @code{Long_Float_Text_IO}
10272 @end table
10273
10274 @item Ada.Text_IO.Integer_IO
10275 Provides input-output facilities for integer types.  The following
10276 predefined instantiations of this generic package are available:
10277
10278 @table @code
10279 @item Short_Short_Integer
10280 @code{Ada.Short_Short_Integer_Text_IO}
10281 @item Short_Integer
10282 @code{Ada.Short_Integer_Text_IO}
10283 @item Integer
10284 @code{Ada.Integer_Text_IO}
10285 @item Long_Integer
10286 @code{Ada.Long_Integer_Text_IO}
10287 @item Long_Long_Integer
10288 @code{Ada.Long_Long_Integer_Text_IO}
10289 @end table
10290
10291 @item Ada.Text_IO.Modular_IO
10292 Provides input-output facilities for modular (unsigned) types
10293
10294 @item Ada.Text_IO.Complex_IO (G.1.3)
10295 This package provides basic text input-output capabilities for complex
10296 data.
10297
10298 @item Ada.Text_IO.Editing (F.3.3)
10299 This package contains routines for edited output, analogous to the use
10300 of pictures in COBOL@.  The picture formats used by this package are a
10301 close copy of the facility in COBOL@.
10302
10303 @item Ada.Text_IO.Text_Streams (A.12.2)
10304 This package provides a facility that allows Text_IO files to be treated
10305 as streams, so that the stream attributes can be used for writing
10306 arbitrary data, including binary data, to Text_IO files.
10307
10308 @item Ada.Unchecked_Conversion (13.9)
10309 This generic package allows arbitrary conversion from one type to
10310 another of the same size, providing for breaking the type safety in
10311 special circumstances.
10312
10313 If the types have the same Size (more accurately the same Value_Size),
10314 then the effect is simply to transfer the bits from the source to the
10315 target type without any modification.  This usage is well defined, and
10316 for simple types whose representation is typically the same across
10317 all implementations, gives a portable method of performing such
10318 conversions.
10319
10320 If the types do not have the same size, then the result is implementation
10321 defined, and thus may be non-portable.  The following describes how GNAT
10322 handles such unchecked conversion cases.
10323
10324 If the types are of different sizes, and are both discrete types, then
10325 the effect is of a normal type conversion without any constraint checking.
10326 In particular if the result type has a larger size, the result will be
10327 zero or sign extended.  If the result type has a smaller size, the result
10328 will be truncated by ignoring high order bits.
10329
10330 If the types are of different sizes, and are not both discrete types,
10331 then the conversion works as though pointers were created to the source
10332 and target, and the pointer value is converted.  The effect is that bits
10333 are copied from successive low order storage units and bits of the source
10334 up to the length of the target type.
10335
10336 A warning is issued if the lengths differ, since the effect in this
10337 case is implementation dependent, and the above behavior may not match
10338 that of some other compiler.
10339
10340 A pointer to one type may be converted to a pointer to another type using
10341 unchecked conversion.  The only case in which the effect is undefined is
10342 when one or both pointers are pointers to unconstrained array types.  In
10343 this case, the bounds information may get incorrectly transferred, and in
10344 particular, GNAT uses double size pointers for such types, and it is
10345 meaningless to convert between such pointer types.  GNAT will issue a
10346 warning if the alignment of the target designated type is more strict
10347 than the alignment of the source designated type (since the result may
10348 be unaligned in this case).
10349
10350 A pointer other than a pointer to an unconstrained array type may be
10351 converted to and from System.Address.  Such usage is common in Ada 83
10352 programs, but note that Ada.Address_To_Access_Conversions is the
10353 preferred method of performing such conversions in Ada 95.  Neither
10354 unchecked conversion nor Ada.Address_To_Access_Conversions should be
10355 used in conjunction with pointers to unconstrained objects, since
10356 the bounds information cannot be handled correctly in this case.
10357
10358 @item Ada.Unchecked_Deallocation (13.11.2)
10359 This generic package allows explicit freeing of storage previously
10360 allocated by use of an allocator.
10361
10362 @item Ada.Wide_Text_IO (A.11)
10363 This package is similar to @code{Ada.Text_IO}, except that the external
10364 file supports wide character representations, and the internal types are
10365 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
10366 and @code{String}.  It contains generic subpackages listed next.
10367
10368 @item Ada.Wide_Text_IO.Decimal_IO
10369 Provides input-output facilities for decimal fixed-point types
10370
10371 @item Ada.Wide_Text_IO.Enumeration_IO
10372 Provides input-output facilities for enumeration types.
10373
10374 @item Ada.Wide_Text_IO.Fixed_IO
10375 Provides input-output facilities for ordinary fixed-point types.
10376
10377 @item Ada.Wide_Text_IO.Float_IO
10378 Provides input-output facilities for float types.  The following
10379 predefined instantiations of this generic package are available:
10380
10381 @table @code
10382 @item Short_Float
10383 @code{Short_Float_Wide_Text_IO}
10384 @item Float
10385 @code{Float_Wide_Text_IO}
10386 @item Long_Float
10387 @code{Long_Float_Wide_Text_IO}
10388 @end table
10389
10390 @item Ada.Wide_Text_IO.Integer_IO
10391 Provides input-output facilities for integer types.  The following
10392 predefined instantiations of this generic package are available:
10393
10394 @table @code
10395 @item Short_Short_Integer
10396 @code{Ada.Short_Short_Integer_Wide_Text_IO}
10397 @item Short_Integer
10398 @code{Ada.Short_Integer_Wide_Text_IO}
10399 @item Integer
10400 @code{Ada.Integer_Wide_Text_IO}
10401 @item Long_Integer
10402 @code{Ada.Long_Integer_Wide_Text_IO}
10403 @item Long_Long_Integer
10404 @code{Ada.Long_Long_Integer_Wide_Text_IO}
10405 @end table
10406
10407 @item Ada.Wide_Text_IO.Modular_IO
10408 Provides input-output facilities for modular (unsigned) types
10409
10410 @item Ada.Wide_Text_IO.Complex_IO (G.1.3)
10411 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
10412 external file supports wide character representations.
10413
10414 @item Ada.Wide_Text_IO.Editing (F.3.4)
10415 This package is similar to @code{Ada.Text_IO.Editing}, except that the
10416 types are @code{Wide_Character} and @code{Wide_String} instead of
10417 @code{Character} and @code{String}.
10418
10419 @item Ada.Wide_Text_IO.Streams (A.12.3)
10420 This package is similar to @code{Ada.Text_IO.Streams}, except that the
10421 types are @code{Wide_Character} and @code{Wide_String} instead of
10422 @code{Character} and @code{String}.
10423 @end table
10424
10425 @node The Implementation of Standard I/O
10426 @chapter The Implementation of Standard I/O
10427
10428 @noindent
10429 GNAT implements all the required input-output facilities described in
10430 A.6 through A.14.  These sections of the Ada 95 reference manual describe the
10431 required behavior of these packages from the Ada point of view, and if
10432 you are writing a portable Ada program that does not need to know the
10433 exact manner in which Ada maps to the outside world when it comes to
10434 reading or writing external files, then you do not need to read this
10435 chapter.  As long as your files are all regular files (not pipes or
10436 devices), and as long as you write and read the files only from Ada, the
10437 description in the Ada 95 reference manual is sufficient.
10438
10439 However, if you want to do input-output to pipes or other devices, such
10440 as the keyboard or screen, or if the files you are dealing with are
10441 either generated by some other language, or to be read by some other
10442 language, then you need to know more about the details of how the GNAT
10443 implementation of these input-output facilities behaves.
10444
10445 In this chapter we give a detailed description of exactly how GNAT
10446 interfaces to the file system.  As always, the sources of the system are
10447 available to you for answering questions at an even more detailed level,
10448 but for most purposes the information in this chapter will suffice.
10449
10450 Another reason that you may need to know more about how input-output is
10451 implemented arises when you have a program written in mixed languages
10452 where, for example, files are shared between the C and Ada sections of
10453 the same program.  GNAT provides some additional facilities, in the form
10454 of additional child library packages, that facilitate this sharing, and
10455 these additional facilities are also described in this chapter.
10456
10457 @menu
10458 * Standard I/O Packages::
10459 * FORM Strings::
10460 * Direct_IO::
10461 * Sequential_IO::
10462 * Text_IO::
10463 * Wide_Text_IO::
10464 * Stream_IO::
10465 * Shared Files::
10466 * Open Modes::
10467 * Operations on C Streams::
10468 * Interfacing to C Streams::
10469 @end menu
10470
10471 @node Standard I/O Packages
10472 @section Standard I/O Packages
10473
10474 @noindent
10475 The Standard I/O packages described in Annex A for
10476
10477 @itemize @bullet
10478 @item
10479 Ada.Text_IO
10480 @item
10481 Ada.Text_IO.Complex_IO
10482 @item
10483 Ada.Text_IO.Text_Streams,
10484 @item
10485 Ada.Wide_Text_IO
10486 @item
10487 Ada.Wide_Text_IO.Complex_IO,
10488 @item
10489 Ada.Wide_Text_IO.Text_Streams
10490 @item
10491 Ada.Stream_IO
10492 @item
10493 Ada.Sequential_IO
10494 @item
10495 Ada.Direct_IO
10496 @end itemize
10497
10498 @noindent
10499 are implemented using the C
10500 library streams facility; where
10501
10502 @itemize @bullet
10503 @item
10504 All files are opened using @code{fopen}.
10505 @item
10506 All input/output operations use @code{fread}/@code{fwrite}.
10507 @end itemize
10508
10509 @noindent
10510 There is no internal buffering of any kind at the Ada library level.  The
10511 only buffering is that provided at the system level in the
10512 implementation of the C library routines that support streams.  This
10513 facilitates shared use of these streams by mixed language programs.
10514
10515 @node FORM Strings
10516 @section FORM Strings
10517
10518 @noindent
10519 The format of a FORM string in GNAT is:
10520
10521 @smallexample
10522 "keyword=value,keyword=value,@dots{},keyword=value"
10523 @end smallexample
10524
10525 @noindent
10526 where letters may be in upper or lower case, and there are no spaces
10527 between values.  The order of the entries is not important.  Currently
10528 there are two keywords defined.
10529
10530 @smallexample
10531 SHARED=[YES|NO]
10532 WCEM=[n|h|u|s\e]
10533 @end smallexample
10534
10535 @noindent
10536 The use of these parameters is described later in this section.
10537
10538 @node Direct_IO
10539 @section Direct_IO
10540
10541 @noindent
10542 Direct_IO can only be instantiated for definite types.  This is a
10543 restriction of the Ada language, which means that the records are fixed
10544 length (the length being determined by @code{@var{type}'Size}, rounded
10545 up to the next storage unit boundary if necessary).
10546
10547 The records of a Direct_IO file are simply written to the file in index
10548 sequence, with the first record starting at offset zero, and subsequent
10549 records following.  There is no control information of any kind.  For
10550 example, if 32-bit integers are being written, each record takes
10551 4-bytes, so the record at index @var{K} starts at offset
10552 (@var{K}@minus{}1)*4.
10553
10554 There is no limit on the size of Direct_IO files, they are expanded as
10555 necessary to accommodate whatever records are written to the file.
10556
10557 @node Sequential_IO
10558 @section Sequential_IO
10559
10560 @noindent
10561 Sequential_IO may be instantiated with either a definite (constrained)
10562 or indefinite (unconstrained) type.
10563
10564 For the definite type case, the elements written to the file are simply
10565 the memory images of the data values with no control information of any
10566 kind.  The resulting file should be read using the same type, no validity
10567 checking is performed on input.
10568
10569 For the indefinite type case, the elements written consist of two
10570 parts.  First is the size of the data item, written as the memory image
10571 of a @code{Interfaces.C.size_t} value, followed by the memory image of
10572 the data value.  The resulting file can only be read using the same
10573 (unconstrained) type.  Normal assignment checks are performed on these
10574 read operations, and if these checks fail, @code{Data_Error} is
10575 raised.  In particular, in the array case, the lengths must match, and in
10576 the variant record case, if the variable for a particular read operation
10577 is constrained, the discriminants must match.
10578
10579 Note that it is not possible to use Sequential_IO to write variable
10580 length array items, and then read the data back into different length
10581 arrays.  For example, the following will raise @code{Data_Error}:
10582
10583 @smallexample @c ada
10584  package IO is new Sequential_IO (String);
10585  F : IO.File_Type;
10586  S : String (1..4);
10587  @dots{}
10588  IO.Create (F)
10589  IO.Write (F, "hello!")
10590  IO.Reset (F, Mode=>In_File);
10591  IO.Read (F, S);
10592  Put_Line (S);
10593
10594 @end smallexample
10595
10596 @noindent
10597 On some Ada implementations, this will print @code{hell}, but the program is
10598 clearly incorrect, since there is only one element in the file, and that
10599 element is the string @code{hello!}.
10600
10601 In Ada 95, this kind of behavior can be legitimately achieved using
10602 Stream_IO, and this is the preferred mechanism.  In particular, the above
10603 program fragment rewritten to use Stream_IO will work correctly.
10604
10605 @node Text_IO
10606 @section Text_IO
10607
10608 @noindent
10609 Text_IO files consist of a stream of characters containing the following
10610 special control characters:
10611
10612 @smallexample
10613 LF (line feed, 16#0A#) Line Mark
10614 FF (form feed, 16#0C#) Page Mark
10615 @end smallexample
10616
10617 @noindent
10618 A canonical Text_IO file is defined as one in which the following
10619 conditions are met:
10620
10621 @itemize @bullet
10622 @item
10623 The character @code{LF} is used only as a line mark, i.e.@: to mark the end
10624 of the line.
10625
10626 @item
10627 The character @code{FF} is used only as a page mark, i.e.@: to mark the
10628 end of a page and consequently can appear only immediately following a
10629 @code{LF} (line mark) character.
10630
10631 @item
10632 The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
10633 (line mark, page mark).  In the former case, the page mark is implicitly
10634 assumed to be present.
10635 @end itemize
10636
10637 @noindent
10638 A file written using Text_IO will be in canonical form provided that no
10639 explicit @code{LF} or @code{FF} characters are written using @code{Put}
10640 or @code{Put_Line}.  There will be no @code{FF} character at the end of
10641 the file unless an explicit @code{New_Page} operation was performed
10642 before closing the file.
10643
10644 A canonical Text_IO file that is a regular file, i.e.@: not a device or a
10645 pipe, can be read using any of the routines in Text_IO@.  The
10646 semantics in this case will be exactly as defined in the Ada 95 reference
10647 manual and all the routines in Text_IO are fully implemented.
10648
10649 A text file that does not meet the requirements for a canonical Text_IO
10650 file has one of the following:
10651
10652 @itemize @bullet
10653 @item
10654 The file contains @code{FF} characters not immediately following a
10655 @code{LF} character.
10656
10657 @item
10658 The file contains @code{LF} or @code{FF} characters written by
10659 @code{Put} or @code{Put_Line}, which are not logically considered to be
10660 line marks or page marks.
10661
10662 @item
10663 The file ends in a character other than @code{LF} or @code{FF},
10664 i.e.@: there is no explicit line mark or page mark at the end of the file.
10665 @end itemize
10666
10667 @noindent
10668 Text_IO can be used to read such non-standard text files but subprograms
10669 to do with line or page numbers do not have defined meanings.  In
10670 particular, a @code{FF} character that does not follow a @code{LF}
10671 character may or may not be treated as a page mark from the point of
10672 view of page and line numbering.  Every @code{LF} character is considered
10673 to end a line, and there is an implied @code{LF} character at the end of
10674 the file.
10675
10676 @menu
10677 * Text_IO Stream Pointer Positioning::
10678 * Text_IO Reading and Writing Non-Regular Files::
10679 * Get_Immediate::
10680 * Treating Text_IO Files as Streams::
10681 * Text_IO Extensions::
10682 * Text_IO Facilities for Unbounded Strings::
10683 @end menu
10684
10685 @node Text_IO Stream Pointer Positioning
10686 @subsection Stream Pointer Positioning
10687
10688 @noindent
10689 @code{Ada.Text_IO} has a definition of current position for a file that
10690 is being read.  No internal buffering occurs in Text_IO, and usually the
10691 physical position in the stream used to implement the file corresponds
10692 to this logical position defined by Text_IO@.  There are two exceptions:
10693
10694 @itemize @bullet
10695 @item
10696 After a call to @code{End_Of_Page} that returns @code{True}, the stream
10697 is positioned past the @code{LF} (line mark) that precedes the page
10698 mark.  Text_IO maintains an internal flag so that subsequent read
10699 operations properly handle the logical position which is unchanged by
10700 the @code{End_Of_Page} call.
10701
10702 @item
10703 After a call to @code{End_Of_File} that returns @code{True}, if the
10704 Text_IO file was positioned before the line mark at the end of file
10705 before the call, then the logical position is unchanged, but the stream
10706 is physically positioned right at the end of file (past the line mark,
10707 and past a possible page mark following the line mark.  Again Text_IO
10708 maintains internal flags so that subsequent read operations properly
10709 handle the logical position.
10710 @end itemize
10711
10712 @noindent
10713 These discrepancies have no effect on the observable behavior of
10714 Text_IO, but if a single Ada stream is shared between a C program and
10715 Ada program, or shared (using @samp{shared=yes} in the form string)
10716 between two Ada files, then the difference may be observable in some
10717 situations.
10718
10719 @node Text_IO Reading and Writing Non-Regular Files
10720 @subsection Reading and Writing Non-Regular Files
10721
10722 @noindent
10723 A non-regular file is a device (such as a keyboard), or a pipe.  Text_IO
10724 can be used for reading and writing.  Writing is not affected and the
10725 sequence of characters output is identical to the normal file case, but
10726 for reading, the behavior of Text_IO is modified to avoid undesirable
10727 look-ahead as follows:
10728
10729 An input file that is not a regular file is considered to have no page
10730 marks.  Any @code{Ascii.FF} characters (the character normally used for a
10731 page mark) appearing in the file are considered to be data
10732 characters.  In particular:
10733
10734 @itemize @bullet
10735 @item
10736 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
10737 following a line mark.  If a page mark appears, it will be treated as a
10738 data character.
10739
10740 @item
10741 This avoids the need to wait for an extra character to be typed or
10742 entered from the pipe to complete one of these operations.
10743
10744 @item
10745 @code{End_Of_Page} always returns @code{False}
10746
10747 @item
10748 @code{End_Of_File} will return @code{False} if there is a page mark at
10749 the end of the file.
10750 @end itemize
10751
10752 @noindent
10753 Output to non-regular files is the same as for regular files.  Page marks
10754 may be written to non-regular files using @code{New_Page}, but as noted
10755 above they will not be treated as page marks on input if the output is
10756 piped to another Ada program.
10757
10758 Another important discrepancy when reading non-regular files is that the end
10759 of file indication is not ``sticky''.  If an end of file is entered, e.g.@: by
10760 pressing the @key{EOT} key,
10761 then end of file
10762 is signaled once (i.e.@: the test @code{End_Of_File}
10763 will yield @code{True}, or a read will
10764 raise @code{End_Error}), but then reading can resume
10765 to read data past that end of
10766 file indication, until another end of file indication is entered.
10767
10768 @node Get_Immediate
10769 @subsection Get_Immediate
10770 @cindex Get_Immediate
10771
10772 @noindent
10773 Get_Immediate returns the next character (including control characters)
10774 from the input file.  In particular, Get_Immediate will return LF or FF
10775 characters used as line marks or page marks.  Such operations leave the
10776 file positioned past the control character, and it is thus not treated
10777 as having its normal function.  This means that page, line and column
10778 counts after this kind of Get_Immediate call are set as though the mark
10779 did not occur.  In the case where a Get_Immediate leaves the file
10780 positioned between the line mark and page mark (which is not normally
10781 possible), it is undefined whether the FF character will be treated as a
10782 page mark.
10783
10784 @node Treating Text_IO Files as Streams
10785 @subsection Treating Text_IO Files as Streams
10786 @cindex Stream files
10787
10788 @noindent
10789 The package @code{Text_IO.Streams} allows a Text_IO file to be treated
10790 as a stream.  Data written to a Text_IO file in this stream mode is
10791 binary data.  If this binary data contains bytes 16#0A# (@code{LF}) or
10792 16#0C# (@code{FF}), the resulting file may have non-standard
10793 format.  Similarly if read operations are used to read from a Text_IO
10794 file treated as a stream, then @code{LF} and @code{FF} characters may be
10795 skipped and the effect is similar to that described above for
10796 @code{Get_Immediate}.
10797
10798 @node Text_IO Extensions
10799 @subsection Text_IO Extensions
10800 @cindex Text_IO extensions
10801
10802 @noindent
10803 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
10804 to the standard @code{Text_IO} package:
10805
10806 @itemize @bullet
10807 @item function File_Exists (Name : String) return Boolean;
10808 Determines if a file of the given name exists.
10809
10810 @item function Get_Line return String;
10811 Reads a string from the standard input file.  The value returned is exactly
10812 the length of the line that was read.
10813
10814 @item function Get_Line (File : Ada.Text_IO.File_Type) return String;
10815 Similar, except that the parameter File specifies the file from which
10816 the string is to be read.
10817
10818 @end itemize
10819
10820 @node Text_IO Facilities for Unbounded Strings
10821 @subsection Text_IO Facilities for Unbounded Strings
10822 @cindex Text_IO for unbounded strings
10823 @cindex Unbounded_String, Text_IO operations
10824
10825 @noindent
10826 The package @code{Ada.Strings.Unbounded.Text_IO}
10827 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
10828 subprograms useful for Text_IO operations on unbounded strings:
10829
10830 @itemize @bullet
10831
10832 @item function Get_Line (File : File_Type) return Unbounded_String;
10833 Reads a line from the specified file
10834 and returns the result as an unbounded string.
10835
10836 @item procedure Put (File : File_Type; U : Unbounded_String);
10837 Writes the value of the given unbounded string to the specified file
10838 Similar to the effect of
10839 @code{Put (To_String (U))} except that an extra copy is avoided.
10840
10841 @item procedure Put_Line (File : File_Type; U : Unbounded_String);
10842 Writes the value of the given unbounded string to the specified file,
10843 followed by a @code{New_Line}.
10844 Similar to the effect of @code{Put_Line (To_String (U))} except
10845 that an extra copy is avoided.
10846 @end itemize
10847
10848 @noindent
10849 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
10850 and is optional.  If the parameter is omitted, then the standard input or
10851 output file is referenced as appropriate.
10852
10853 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
10854 files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended
10855 @code{Wide_Text_IO} functionality for unbounded wide strings.
10856
10857 @node Wide_Text_IO
10858 @section Wide_Text_IO
10859
10860 @noindent
10861 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
10862 both input and output files may contain special sequences that represent
10863 wide character values.  The encoding scheme for a given file may be
10864 specified using a FORM parameter:
10865
10866 @smallexample
10867 WCEM=@var{x}
10868 @end smallexample
10869
10870 @noindent
10871 as part of the FORM string (WCEM = wide character encoding method),
10872 where @var{x} is one of the following characters
10873
10874 @table @samp
10875 @item h
10876 Hex ESC encoding
10877 @item u
10878 Upper half encoding
10879 @item s
10880 Shift-JIS encoding
10881 @item e
10882 EUC Encoding
10883 @item 8
10884 UTF-8 encoding
10885 @item b
10886 Brackets encoding
10887 @end table
10888
10889 @noindent
10890 The encoding methods match those that
10891 can be used in a source
10892 program, but there is no requirement that the encoding method used for
10893 the source program be the same as the encoding method used for files,
10894 and different files may use different encoding methods.
10895
10896 The default encoding method for the standard files, and for opened files
10897 for which no WCEM parameter is given in the FORM string matches the
10898 wide character encoding specified for the main program (the default
10899 being brackets encoding if no coding method was specified with -gnatW).
10900
10901 @table @asis
10902 @item Hex Coding
10903 In this encoding, a wide character is represented by a five character
10904 sequence:
10905
10906 @smallexample
10907 ESC a b c d
10908 @end smallexample
10909
10910 @noindent
10911 where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
10912 characters (using upper case letters) of the wide character code.  For
10913 example, ESC A345 is used to represent the wide character with code
10914 16#A345#.  This scheme is compatible with use of the full
10915 @code{Wide_Character} set.
10916
10917 @item Upper Half Coding
10918 The wide character with encoding 16#abcd#, where the upper bit is on
10919 (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
10920 16#cd#.  The second byte may never be a format control character, but is
10921 not required to be in the upper half.  This method can be also used for
10922 shift-JIS or EUC where the internal coding matches the external coding.
10923
10924 @item Shift JIS Coding
10925 A wide character is represented by a two character sequence 16#ab# and
10926 16#cd#, with the restrictions described for upper half encoding as
10927 described above.  The internal character code is the corresponding JIS
10928 character according to the standard algorithm for Shift-JIS
10929 conversion.  Only characters defined in the JIS code set table can be
10930 used with this encoding method.
10931
10932 @item EUC Coding
10933 A wide character is represented by a two character sequence 16#ab# and
10934 16#cd#, with both characters being in the upper half.  The internal
10935 character code is the corresponding JIS character according to the EUC
10936 encoding algorithm.  Only characters defined in the JIS code set table
10937 can be used with this encoding method.
10938
10939 @item UTF-8 Coding
10940 A wide character is represented using
10941 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
10942 10646-1/Am.2.  Depending on the character value, the representation
10943 is a one, two, or three byte sequence:
10944
10945 @smallexample
10946 16#0000#-16#007f#: 2#0xxxxxxx#
10947 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
10948 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
10949 @end smallexample
10950
10951 @noindent
10952 where the xxx bits correspond to the left-padded bits of the
10953 16-bit character value.  Note that all lower half ASCII characters
10954 are represented as ASCII bytes and all upper half characters and
10955 other wide characters are represented as sequences of upper-half
10956 (The full UTF-8 scheme allows for encoding 31-bit characters as
10957 6-byte sequences, but in this implementation, all UTF-8 sequences
10958 of four or more bytes length will raise a Constraint_Error, as
10959 will all invalid UTF-8 sequences.)
10960
10961 @item Brackets Coding
10962 In this encoding, a wide character is represented by the following eight
10963 character sequence:
10964
10965 @smallexample
10966 [ " a b c d " ]
10967 @end smallexample
10968
10969 @noindent
10970 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
10971 characters (using uppercase letters) of the wide character code.  For
10972 example, @code{["A345"]} is used to represent the wide character with code
10973 @code{16#A345#}.
10974 This scheme is compatible with use of the full Wide_Character set.
10975 On input, brackets coding can also be used for upper half characters,
10976 e.g.@: @code{["C1"]} for lower case a.  However, on output, brackets notation
10977 is only used for wide characters with a code greater than @code{16#FF#}.
10978
10979 @end table
10980
10981 @noindent
10982 For the coding schemes other than Hex and Brackets encoding,
10983 not all wide character
10984 values can be represented.  An attempt to output a character that cannot
10985 be represented using the encoding scheme for the file causes
10986 Constraint_Error to be raised.  An invalid wide character sequence on
10987 input also causes Constraint_Error to be raised.
10988
10989 @menu
10990 * Wide_Text_IO Stream Pointer Positioning::
10991 * Wide_Text_IO Reading and Writing Non-Regular Files::
10992 @end menu
10993
10994 @node Wide_Text_IO Stream Pointer Positioning
10995 @subsection Stream Pointer Positioning
10996
10997 @noindent
10998 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
10999 of stream pointer positioning (@pxref{Text_IO}).  There is one additional
11000 case:
11001
11002 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
11003 normal lower ASCII set (i.e.@: a character in the range:
11004
11005 @smallexample @c ada
11006 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
11007 @end smallexample
11008
11009 @noindent
11010 then although the logical position of the file pointer is unchanged by
11011 the @code{Look_Ahead} call, the stream is physically positioned past the
11012 wide character sequence.  Again this is to avoid the need for buffering
11013 or backup, and all @code{Wide_Text_IO} routines check the internal
11014 indication that this situation has occurred so that this is not visible
11015 to a normal program using @code{Wide_Text_IO}.  However, this discrepancy
11016 can be observed if the wide text file shares a stream with another file.
11017
11018 @node Wide_Text_IO Reading and Writing Non-Regular Files
11019 @subsection Reading and Writing Non-Regular Files
11020
11021 @noindent
11022 As in the case of Text_IO, when a non-regular file is read, it is
11023 assumed that the file contains no page marks (any form characters are
11024 treated as data characters), and @code{End_Of_Page} always returns
11025 @code{False}.  Similarly, the end of file indication is not sticky, so
11026 it is possible to read beyond an end of file.
11027
11028 @node Stream_IO
11029 @section Stream_IO
11030
11031 @noindent
11032 A stream file is a sequence of bytes, where individual elements are
11033 written to the file as described in the Ada 95 reference manual.  The type
11034 @code{Stream_Element} is simply a byte.  There are two ways to read or
11035 write a stream file.
11036
11037 @itemize @bullet
11038 @item
11039 The operations @code{Read} and @code{Write} directly read or write a
11040 sequence of stream elements with no control information.
11041
11042 @item
11043 The stream attributes applied to a stream file transfer data in the
11044 manner described for stream attributes.
11045 @end itemize
11046
11047 @node Shared Files
11048 @section Shared Files
11049
11050 @noindent
11051 Section A.14 of the Ada 95 Reference Manual allows implementations to
11052 provide a wide variety of behavior if an attempt is made to access the
11053 same external file with two or more internal files.
11054
11055 To provide a full range of functionality, while at the same time
11056 minimizing the problems of portability caused by this implementation
11057 dependence, GNAT handles file sharing as follows:
11058
11059 @itemize @bullet
11060 @item
11061 In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
11062 to open two or more files with the same full name is considered an error
11063 and is not supported.  The exception @code{Use_Error} will be
11064 raised.  Note that a file that is not explicitly closed by the program
11065 remains open until the program terminates.
11066
11067 @item
11068 If the form parameter @samp{shared=no} appears in the form string, the
11069 file can be opened or created with its own separate stream identifier,
11070 regardless of whether other files sharing the same external file are
11071 opened.  The exact effect depends on how the C stream routines handle
11072 multiple accesses to the same external files using separate streams.
11073
11074 @item
11075 If the form parameter @samp{shared=yes} appears in the form string for
11076 each of two or more files opened using the same full name, the same
11077 stream is shared between these files, and the semantics are as described
11078 in Ada 95 Reference Manual, Section A.14.
11079 @end itemize
11080
11081 @noindent
11082 When a program that opens multiple files with the same name is ported
11083 from another Ada compiler to GNAT, the effect will be that
11084 @code{Use_Error} is raised.
11085
11086 The documentation of the original compiler and the documentation of the
11087 program should then be examined to determine if file sharing was
11088 expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
11089 and @code{Create} calls as required.
11090
11091 When a program is ported from GNAT to some other Ada compiler, no
11092 special attention is required unless the @samp{shared=@var{xxx}} form
11093 parameter is used in the program.  In this case, you must examine the
11094 documentation of the new compiler to see if it supports the required
11095 file sharing semantics, and form strings modified appropriately.  Of
11096 course it may be the case that the program cannot be ported if the
11097 target compiler does not support the required functionality.  The best
11098 approach in writing portable code is to avoid file sharing (and hence
11099 the use of the @samp{shared=@var{xxx}} parameter in the form string)
11100 completely.
11101
11102 One common use of file sharing in Ada 83 is the use of instantiations of
11103 Sequential_IO on the same file with different types, to achieve
11104 heterogeneous input-output.  Although this approach will work in GNAT if
11105 @samp{shared=yes} is specified, it is preferable in Ada 95 to use Stream_IO
11106 for this purpose (using the stream attributes)
11107
11108 @node Open Modes
11109 @section Open Modes
11110
11111 @noindent
11112 @code{Open} and @code{Create} calls result in a call to @code{fopen}
11113 using the mode shown in the following table:
11114
11115 @sp 2
11116 @center @code{Open} and @code{Create} Call Modes
11117 @smallexample
11118                                @b{OPEN }           @b{CREATE}
11119 Append_File                    "r+"             "w+"
11120 In_File                        "r"              "w+"
11121 Out_File (Direct_IO)           "r+"             "w"
11122 Out_File (all other cases)     "w"              "w"
11123 Inout_File                     "r+"             "w+"
11124 @end smallexample
11125
11126 @noindent
11127 If text file translation is required, then either @samp{b} or @samp{t}
11128 is added to the mode, depending on the setting of Text.  Text file
11129 translation refers to the mapping of CR/LF sequences in an external file
11130 to LF characters internally.  This mapping only occurs in DOS and
11131 DOS-like systems, and is not relevant to other systems.
11132
11133 A special case occurs with Stream_IO@.  As shown in the above table, the
11134 file is initially opened in @samp{r} or @samp{w} mode for the
11135 @code{In_File} and @code{Out_File} cases.  If a @code{Set_Mode} operation
11136 subsequently requires switching from reading to writing or vice-versa,
11137 then the file is reopened in @samp{r+} mode to permit the required operation.
11138
11139 @node Operations on C Streams
11140 @section Operations on C Streams
11141 The package @code{Interfaces.C_Streams} provides an Ada program with direct
11142 access to the C library functions for operations on C streams:
11143
11144 @smallexample @c adanocomment
11145 package Interfaces.C_Streams is
11146   -- Note: the reason we do not use the types that are in
11147   -- Interfaces.C is that we want to avoid dragging in the
11148   -- code in this unit if possible.
11149   subtype chars is System.Address;
11150   -- Pointer to null-terminated array of characters
11151   subtype FILEs is System.Address;
11152   -- Corresponds to the C type FILE*
11153   subtype voids is System.Address;
11154   -- Corresponds to the C type void*
11155   subtype int is Integer;
11156   subtype long is Long_Integer;
11157   -- Note: the above types are subtypes deliberately, and it
11158   -- is part of this spec that the above correspondences are
11159   -- guaranteed.  This means that it is legitimate to, for
11160   -- example, use Integer instead of int.  We provide these
11161   -- synonyms for clarity, but in some cases it may be
11162   -- convenient to use the underlying types (for example to
11163   -- avoid an unnecessary dependency of a spec on the spec
11164   -- of this unit).
11165   type size_t is mod 2 ** Standard'Address_Size;
11166   NULL_Stream : constant FILEs;
11167   -- Value returned (NULL in C) to indicate an
11168   -- fdopen/fopen/tmpfile error
11169   ----------------------------------
11170   -- Constants Defined in stdio.h --
11171   ----------------------------------
11172   EOF : constant int;
11173   -- Used by a number of routines to indicate error or
11174   -- end of file
11175   IOFBF : constant int;
11176   IOLBF : constant int;
11177   IONBF : constant int;
11178   -- Used to indicate buffering mode for setvbuf call
11179   SEEK_CUR : constant int;
11180   SEEK_END : constant int;
11181   SEEK_SET : constant int;
11182   -- Used to indicate origin for fseek call
11183   function stdin return FILEs;
11184   function stdout return FILEs;
11185   function stderr return FILEs;
11186   -- Streams associated with standard files
11187   --------------------------
11188   -- Standard C functions --
11189   --------------------------
11190   -- The functions selected below are ones that are
11191   -- available in DOS, OS/2, UNIX and Xenix (but not
11192   -- necessarily in ANSI C).  These are very thin interfaces
11193   -- which copy exactly the C headers.  For more
11194   -- documentation on these functions, see the Microsoft C
11195   -- "Run-Time Library Reference" (Microsoft Press, 1990,
11196   -- ISBN 1-55615-225-6), which includes useful information
11197   -- on system compatibility.
11198   procedure clearerr (stream : FILEs);
11199   function fclose (stream : FILEs) return int;
11200   function fdopen (handle : int; mode : chars) return FILEs;
11201   function feof (stream : FILEs) return int;
11202   function ferror (stream : FILEs) return int;
11203   function fflush (stream : FILEs) return int;
11204   function fgetc (stream : FILEs) return int;
11205   function fgets (strng : chars; n : int; stream : FILEs)
11206       return chars;
11207   function fileno (stream : FILEs) return int;
11208   function fopen (filename : chars; Mode : chars)
11209       return FILEs;
11210   -- Note: to maintain target independence, use
11211   -- text_translation_required, a boolean variable defined in
11212   -- a-sysdep.c to deal with the target dependent text
11213   -- translation requirement.  If this variable is set,
11214   -- then  b/t should be appended to the standard mode
11215   -- argument to set the text translation mode off or on
11216   -- as required.
11217   function fputc (C : int; stream : FILEs) return int;
11218   function fputs (Strng : chars; Stream : FILEs) return int;
11219   function fread
11220      (buffer : voids;
11221       size : size_t;
11222       count : size_t;
11223       stream : FILEs)
11224       return size_t;
11225   function freopen
11226      (filename : chars;
11227       mode : chars;
11228       stream : FILEs)
11229       return FILEs;
11230   function fseek
11231      (stream : FILEs;
11232       offset : long;
11233       origin : int)
11234       return int;
11235   function ftell (stream : FILEs) return long;
11236   function fwrite
11237      (buffer : voids;
11238       size : size_t;
11239       count : size_t;
11240       stream : FILEs)
11241       return size_t;
11242   function isatty (handle : int) return int;
11243   procedure mktemp (template : chars);
11244   -- The return value (which is just a pointer to template)
11245   -- is discarded
11246   procedure rewind (stream : FILEs);
11247   function rmtmp return int;
11248   function setvbuf
11249      (stream : FILEs;
11250       buffer : chars;
11251       mode : int;
11252       size : size_t)
11253       return int;
11254
11255   function tmpfile return FILEs;
11256   function ungetc (c : int; stream : FILEs) return int;
11257   function unlink (filename : chars) return int;
11258   ---------------------
11259   -- Extra functions --
11260   ---------------------
11261   -- These functions supply slightly thicker bindings than
11262   -- those above.  They are derived from functions in the
11263   -- C Run-Time Library, but may do a bit more work than
11264   -- just directly calling one of the Library functions.
11265   function is_regular_file (handle : int) return int;
11266   -- Tests if given handle is for a regular file (result 1)
11267   -- or for a non-regular file (pipe or device, result 0).
11268   ---------------------------------
11269   -- Control of Text/Binary Mode --
11270   ---------------------------------
11271   -- If text_translation_required is true, then the following
11272   -- functions may be used to dynamically switch a file from
11273   -- binary to text mode or vice versa.  These functions have
11274   -- no effect if text_translation_required is false (i.e.  in
11275   -- normal UNIX mode).  Use fileno to get a stream handle.
11276   procedure set_binary_mode (handle : int);
11277   procedure set_text_mode (handle : int);
11278   ----------------------------
11279   -- Full Path Name support --
11280   ----------------------------
11281   procedure full_name (nam : chars; buffer : chars);
11282   -- Given a NUL terminated string representing a file
11283   -- name, returns in buffer a NUL terminated string
11284   -- representing the full path name for the file name.
11285   -- On systems where it is relevant the   drive is also
11286   -- part of the full path name.  It is the responsibility
11287   -- of the caller to pass an actual parameter for buffer
11288   -- that is big enough for any full path name.  Use
11289   -- max_path_len given below as the size of buffer.
11290   max_path_len : integer;
11291   -- Maximum length of an allowable full path name on the
11292   -- system, including a terminating NUL character.
11293 end Interfaces.C_Streams;
11294 @end smallexample
11295
11296 @node Interfacing to C Streams
11297 @section Interfacing to C Streams
11298
11299 @noindent
11300 The packages in this section permit interfacing Ada files to C Stream
11301 operations.
11302
11303 @smallexample @c ada
11304  with Interfaces.C_Streams;
11305  package Ada.Sequential_IO.C_Streams is
11306     function C_Stream (F : File_Type)
11307        return Interfaces.C_Streams.FILEs;
11308     procedure Open
11309       (File : in out File_Type;
11310        Mode : in File_Mode;
11311        C_Stream : in Interfaces.C_Streams.FILEs;
11312        Form : in String := "");
11313  end Ada.Sequential_IO.C_Streams;
11314
11315   with Interfaces.C_Streams;
11316   package Ada.Direct_IO.C_Streams is
11317      function C_Stream (F : File_Type)
11318         return Interfaces.C_Streams.FILEs;
11319      procedure Open
11320        (File : in out File_Type;
11321         Mode : in File_Mode;
11322         C_Stream : in Interfaces.C_Streams.FILEs;
11323         Form : in String := "");
11324   end Ada.Direct_IO.C_Streams;
11325
11326   with Interfaces.C_Streams;
11327   package Ada.Text_IO.C_Streams is
11328      function C_Stream (F : File_Type)
11329         return Interfaces.C_Streams.FILEs;
11330      procedure Open
11331        (File : in out File_Type;
11332         Mode : in File_Mode;
11333         C_Stream : in Interfaces.C_Streams.FILEs;
11334         Form : in String := "");
11335   end Ada.Text_IO.C_Streams;
11336
11337   with Interfaces.C_Streams;
11338   package Ada.Wide_Text_IO.C_Streams is
11339      function C_Stream (F : File_Type)
11340         return Interfaces.C_Streams.FILEs;
11341      procedure Open
11342        (File : in out File_Type;
11343         Mode : in File_Mode;
11344         C_Stream : in Interfaces.C_Streams.FILEs;
11345         Form : in String := "");
11346  end Ada.Wide_Text_IO.C_Streams;
11347
11348  with Interfaces.C_Streams;
11349  package Ada.Stream_IO.C_Streams is
11350     function C_Stream (F : File_Type)
11351        return Interfaces.C_Streams.FILEs;
11352     procedure Open
11353       (File : in out File_Type;
11354        Mode : in File_Mode;
11355        C_Stream : in Interfaces.C_Streams.FILEs;
11356        Form : in String := "");
11357  end Ada.Stream_IO.C_Streams;
11358 @end smallexample
11359
11360 @noindent
11361 In each of these five packages, the @code{C_Stream} function obtains the
11362 @code{FILE} pointer from a currently opened Ada file.  It is then
11363 possible to use the @code{Interfaces.C_Streams} package to operate on
11364 this stream, or the stream can be passed to a C program which can
11365 operate on it directly.  Of course the program is responsible for
11366 ensuring that only appropriate sequences of operations are executed.
11367
11368 One particular use of relevance to an Ada program is that the
11369 @code{setvbuf} function can be used to control the buffering of the
11370 stream used by an Ada file.  In the absence of such a call the standard
11371 default buffering is used.
11372
11373 The @code{Open} procedures in these packages open a file giving an
11374 existing C Stream instead of a file name.  Typically this stream is
11375 imported from a C program, allowing an Ada file to operate on an
11376 existing C file.
11377
11378 @node The GNAT Library
11379 @chapter The GNAT Library
11380
11381 @noindent
11382 The GNAT library contains a number of general and special purpose packages.
11383 It represents functionality that the GNAT developers have found useful, and
11384 which is made available to GNAT users.  The packages described here are fully
11385 supported, and upwards compatibility will be maintained in future releases,
11386 so you can use these facilities with the confidence that the same functionality
11387 will be available in future releases.
11388
11389 The chapter here simply gives a brief summary of the facilities available.
11390 The full documentation is found in the spec file for the package.  The full
11391 sources of these library packages, including both spec and body, are provided
11392 with all GNAT releases.  For example, to find out the full specifications of
11393 the SPITBOL pattern matching capability, including a full tutorial and
11394 extensive examples, look in the @file{g-spipat.ads} file in the library.
11395
11396 For each entry here, the package name (as it would appear in a @code{with}
11397 clause) is given, followed by the name of the corresponding spec file in
11398 parentheses.  The packages are children in four hierarchies, @code{Ada},
11399 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
11400 GNAT-specific hierarchy.
11401
11402 Note that an application program should only use packages in one of these
11403 four hierarchies if the package is defined in the Ada Reference Manual,
11404 or is listed in this section of the GNAT Programmers Reference Manual.
11405 All other units should be considered internal implementation units and
11406 should not be directly @code{with}'ed by application code.  The use of
11407 a @code{with} statement that references one of these internal implementation
11408 units makes an application potentially dependent on changes in versions
11409 of GNAT, and will generate a warning message.
11410
11411 @menu
11412 * Ada.Characters.Latin_9 (a-chlat9.ads)::
11413 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
11414 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
11415 * Ada.Command_Line.Remove (a-colire.ads)::
11416 * Ada.Command_Line.Environment (a-colien.ads)::
11417 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
11418 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
11419 * Ada.Exceptions.Traceback (a-exctra.ads)::
11420 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
11421 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
11422 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
11423 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
11424 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
11425 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
11426 * GNAT.Array_Split (g-arrspl.ads)::
11427 * GNAT.AWK (g-awk.ads)::
11428 * GNAT.Bounded_Buffers (g-boubuf.ads)::
11429 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
11430 * GNAT.Bubble_Sort (g-bubsor.ads)::
11431 * GNAT.Bubble_Sort_A (g-busora.ads)::
11432 * GNAT.Bubble_Sort_G (g-busorg.ads)::
11433 * GNAT.Calendar (g-calend.ads)::
11434 * GNAT.Calendar.Time_IO (g-catiio.ads)::
11435 * GNAT.CRC32 (g-crc32.ads)::
11436 * GNAT.Case_Util (g-casuti.ads)::
11437 * GNAT.CGI (g-cgi.ads)::
11438 * GNAT.CGI.Cookie (g-cgicoo.ads)::
11439 * GNAT.CGI.Debug (g-cgideb.ads)::
11440 * GNAT.Command_Line (g-comlin.ads)::
11441 * GNAT.Compiler_Version (g-comver.ads)::
11442 * GNAT.Ctrl_C (g-ctrl_c.ads)::
11443 * GNAT.Current_Exception (g-curexc.ads)::
11444 * GNAT.Debug_Pools (g-debpoo.ads)::
11445 * GNAT.Debug_Utilities (g-debuti.ads)::
11446 * GNAT.Directory_Operations (g-dirope.ads)::
11447 * GNAT.Dynamic_HTables (g-dynhta.ads)::
11448 * GNAT.Dynamic_Tables (g-dyntab.ads)::
11449 * GNAT.Exception_Actions (g-excact.ads)::
11450 * GNAT.Exception_Traces (g-exctra.ads)::
11451 * GNAT.Exceptions (g-except.ads)::
11452 * GNAT.Expect (g-expect.ads)::
11453 * GNAT.Float_Control (g-flocon.ads)::
11454 * GNAT.Heap_Sort (g-heasor.ads)::
11455 * GNAT.Heap_Sort_A (g-hesora.ads)::
11456 * GNAT.Heap_Sort_G (g-hesorg.ads)::
11457 * GNAT.HTable (g-htable.ads)::
11458 * GNAT.IO (g-io.ads)::
11459 * GNAT.IO_Aux (g-io_aux.ads)::
11460 * GNAT.Lock_Files (g-locfil.ads)::
11461 * GNAT.MD5 (g-md5.ads)::
11462 * GNAT.Memory_Dump (g-memdum.ads)::
11463 * GNAT.Most_Recent_Exception (g-moreex.ads)::
11464 * GNAT.OS_Lib (g-os_lib.ads)::
11465 * GNAT.Perfect_Hash.Generators (g-pehage.ads)::
11466 * GNAT.Regexp (g-regexp.ads)::
11467 * GNAT.Registry (g-regist.ads)::
11468 * GNAT.Regpat (g-regpat.ads)::
11469 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
11470 * GNAT.Semaphores (g-semaph.ads)::
11471 * GNAT.Signals (g-signal.ads)::
11472 * GNAT.Sockets (g-socket.ads)::
11473 * GNAT.Source_Info (g-souinf.ads)::
11474 * GNAT.Spell_Checker (g-speche.ads)::
11475 * GNAT.Spitbol.Patterns (g-spipat.ads)::
11476 * GNAT.Spitbol (g-spitbo.ads)::
11477 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
11478 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
11479 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
11480 * GNAT.Strings (g-string.ads)::
11481 * GNAT.String_Split (g-strspl.ads)::
11482 * GNAT.Table (g-table.ads)::
11483 * GNAT.Task_Lock (g-tasloc.ads)::
11484 * GNAT.Threads (g-thread.ads)::
11485 * GNAT.Traceback (g-traceb.ads)::
11486 * GNAT.Traceback.Symbolic (g-trasym.ads)::
11487 * GNAT.Wide_String_Split (g-wistsp.ads)::
11488 * Interfaces.C.Extensions (i-cexten.ads)::
11489 * Interfaces.C.Streams (i-cstrea.ads)::
11490 * Interfaces.CPP (i-cpp.ads)::
11491 * Interfaces.Os2lib (i-os2lib.ads)::
11492 * Interfaces.Os2lib.Errors (i-os2err.ads)::
11493 * Interfaces.Os2lib.Synchronization (i-os2syn.ads)::
11494 * Interfaces.Os2lib.Threads (i-os2thr.ads)::
11495 * Interfaces.Packed_Decimal (i-pacdec.ads)::
11496 * Interfaces.VxWorks (i-vxwork.ads)::
11497 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
11498 * System.Address_Image (s-addima.ads)::
11499 * System.Assertions (s-assert.ads)::
11500 * System.Memory (s-memory.ads)::
11501 * System.Partition_Interface (s-parint.ads)::
11502 * System.Restrictions (s-restri.ads)::
11503 * System.Rident (s-rident.ads)::
11504 * System.Task_Info (s-tasinf.ads)::
11505 * System.Wch_Cnv (s-wchcnv.ads)::
11506 * System.Wch_Con (s-wchcon.ads)::
11507 @end menu
11508
11509 @node Ada.Characters.Latin_9 (a-chlat9.ads)
11510 @section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
11511 @cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
11512 @cindex Latin_9 constants for Character
11513
11514 @noindent
11515 This child of @code{Ada.Characters}
11516 provides a set of definitions corresponding to those in the
11517 RM-defined package @code{Ada.Characters.Latin_1} but with the
11518 few modifications required for @code{Latin-9}
11519 The provision of such a package
11520 is specifically authorized by the Ada Reference Manual
11521 (RM A.3(27)).
11522
11523 @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
11524 @section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
11525 @cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
11526 @cindex Latin_1 constants for Wide_Character
11527
11528 @noindent
11529 This child of @code{Ada.Characters}
11530 provides a set of definitions corresponding to those in the
11531 RM-defined package @code{Ada.Characters.Latin_1} but with the
11532 types of the constants being @code{Wide_Character}
11533 instead of @code{Character}.  The provision of such a package
11534 is specifically authorized by the Ada Reference Manual
11535 (RM A.3(27)).
11536
11537 @node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
11538 @section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
11539 @cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
11540 @cindex Latin_9 constants for Wide_Character
11541
11542 @noindent
11543 This child of @code{Ada.Characters}
11544 provides a set of definitions corresponding to those in the
11545 GNAT defined package @code{Ada.Characters.Latin_9} but with the
11546 types of the constants being @code{Wide_Character}
11547 instead of @code{Character}.  The provision of such a package
11548 is specifically authorized by the Ada Reference Manual
11549 (RM A.3(27)).
11550
11551 @node Ada.Command_Line.Remove (a-colire.ads)
11552 @section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
11553 @cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
11554 @cindex Removing command line arguments
11555 @cindex Command line, argument removal
11556
11557 @noindent
11558 This child of @code{Ada.Command_Line}
11559 provides a mechanism for logically removing
11560 arguments from the argument list.  Once removed, an argument is not visible
11561 to further calls on the subprograms in @code{Ada.Command_Line} will not
11562 see the removed argument.
11563
11564 @node Ada.Command_Line.Environment (a-colien.ads)
11565 @section @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
11566 @cindex @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
11567 @cindex Environment entries
11568
11569 @noindent
11570 This child of @code{Ada.Command_Line}
11571 provides a mechanism for obtaining environment values on systems
11572 where this concept makes sense.
11573
11574 @node Ada.Direct_IO.C_Streams (a-diocst.ads)
11575 @section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
11576 @cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
11577 @cindex C Streams, Interfacing with Direct_IO
11578
11579 @noindent
11580 This package provides subprograms that allow interfacing between
11581 C streams and @code{Direct_IO}.  The stream identifier can be
11582 extracted from a file opened on the Ada side, and an Ada file
11583 can be constructed from a stream opened on the C side.
11584
11585 @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
11586 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
11587 @cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
11588 @cindex Null_Occurrence, testing for
11589
11590 @noindent
11591 This child subprogram provides a way of testing for the null
11592 exception occurrence (@code{Null_Occurrence}) without raising
11593 an exception.
11594
11595 @node Ada.Exceptions.Traceback (a-exctra.ads)
11596 @section @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
11597 @cindex @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
11598 @cindex Traceback for Exception Occurrence
11599
11600 @noindent
11601 This child package provides the subprogram (@code{Tracebacks}) to
11602 give a traceback array of addresses based on an exception
11603 occurrence.
11604
11605 @node Ada.Sequential_IO.C_Streams (a-siocst.ads)
11606 @section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
11607 @cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
11608 @cindex C Streams, Interfacing with Sequential_IO
11609
11610 @noindent
11611 This package provides subprograms that allow interfacing between
11612 C streams and @code{Sequential_IO}.  The stream identifier can be
11613 extracted from a file opened on the Ada side, and an Ada file
11614 can be constructed from a stream opened on the C side.
11615
11616 @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
11617 @section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
11618 @cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
11619 @cindex C Streams, Interfacing with Stream_IO
11620
11621 @noindent
11622 This package provides subprograms that allow interfacing between
11623 C streams and @code{Stream_IO}.  The stream identifier can be
11624 extracted from a file opened on the Ada side, and an Ada file
11625 can be constructed from a stream opened on the C side.
11626
11627 @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
11628 @section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
11629 @cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
11630 @cindex @code{Unbounded_String}, IO support
11631 @cindex @code{Text_IO}, extensions for unbounded strings
11632
11633 @noindent
11634 This package provides subprograms for Text_IO for unbounded
11635 strings, avoiding the necessity for an intermediate operation
11636 with ordinary strings.
11637
11638 @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
11639 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
11640 @cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
11641 @cindex @code{Unbounded_Wide_String}, IO support
11642 @cindex @code{Text_IO}, extensions for unbounded wide strings
11643
11644 @noindent
11645 This package provides subprograms for Text_IO for unbounded
11646 wide strings, avoiding the necessity for an intermediate operation
11647 with ordinary wide strings.
11648
11649 @node Ada.Text_IO.C_Streams (a-tiocst.ads)
11650 @section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
11651 @cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
11652 @cindex C Streams, Interfacing with @code{Text_IO}
11653
11654 @noindent
11655 This package provides subprograms that allow interfacing between
11656 C streams and @code{Text_IO}.  The stream identifier can be
11657 extracted from a file opened on the Ada side, and an Ada file
11658 can be constructed from a stream opened on the C side.
11659
11660 @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
11661 @section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
11662 @cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
11663 @cindex C Streams, Interfacing with @code{Wide_Text_IO}
11664
11665 @noindent
11666 This package provides subprograms that allow interfacing between
11667 C streams and @code{Wide_Text_IO}.  The stream identifier can be
11668 extracted from a file opened on the Ada side, and an Ada file
11669 can be constructed from a stream opened on the C side.
11670
11671 @node GNAT.Array_Split (g-arrspl.ads)
11672 @section @code{GNAT.Array_Split} (@file{g-arrspl.ads})
11673 @cindex @code{GNAT.Array_Split} (@file{g-arrspl.ads})
11674 @cindex Array splitter
11675
11676 @noindent
11677 Useful array-manipulation routines: given a set of separators, split
11678 an array wherever the separators appear, and provide direct access
11679 to the resulting slices.
11680
11681 @node GNAT.AWK (g-awk.ads)
11682 @section @code{GNAT.AWK} (@file{g-awk.ads})
11683 @cindex @code{GNAT.AWK} (@file{g-awk.ads})
11684 @cindex Parsing
11685 @cindex AWK
11686
11687 @noindent
11688 Provides AWK-like parsing functions, with an easy interface for parsing one
11689 or more files containing formatted data.  The file is viewed as a database
11690 where each record is a line and a field is a data element in this line.
11691
11692 @node GNAT.Bounded_Buffers (g-boubuf.ads)
11693 @section @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
11694 @cindex @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
11695 @cindex Parsing
11696 @cindex Bounded Buffers
11697
11698 @noindent
11699 Provides a concurrent generic bounded buffer abstraction.  Instances are
11700 useful directly or as parts of the implementations of other abstractions,
11701 such as mailboxes.
11702
11703 @node GNAT.Bounded_Mailboxes (g-boumai.ads)
11704 @section @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
11705 @cindex @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
11706 @cindex Parsing
11707 @cindex Mailboxes
11708
11709 @noindent
11710 Provides a thread-safe asynchronous intertask mailbox communication facility.
11711
11712 @node GNAT.Bubble_Sort (g-bubsor.ads)
11713 @section @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
11714 @cindex @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
11715 @cindex Sorting
11716 @cindex Bubble sort
11717
11718 @noindent
11719 Provides a general implementation of bubble sort usable for sorting arbitrary
11720 data items.  Exchange and comparison procedures are provided by passing
11721 access-to-procedure values.
11722
11723 @node GNAT.Bubble_Sort_A (g-busora.ads)
11724 @section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
11725 @cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
11726 @cindex Sorting
11727 @cindex Bubble sort
11728
11729 @noindent
11730 Provides a general implementation of bubble sort usable for sorting arbitrary
11731 data items.  Move and comparison procedures are provided by passing
11732 access-to-procedure values. This is an older version, retained for
11733 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
11734
11735 @node GNAT.Bubble_Sort_G (g-busorg.ads)
11736 @section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
11737 @cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
11738 @cindex Sorting
11739 @cindex Bubble sort
11740
11741 @noindent
11742 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
11743 are provided as generic parameters, this improves efficiency, especially
11744 if the procedures can be inlined, at the expense of duplicating code for
11745 multiple instantiations.
11746
11747 @node GNAT.Calendar (g-calend.ads)
11748 @section @code{GNAT.Calendar} (@file{g-calend.ads})
11749 @cindex @code{GNAT.Calendar} (@file{g-calend.ads})
11750 @cindex @code{Calendar}
11751
11752 @noindent
11753 Extends the facilities provided by @code{Ada.Calendar} to include handling
11754 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
11755 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
11756 C @code{timeval} format.
11757
11758 @node GNAT.Calendar.Time_IO (g-catiio.ads)
11759 @section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
11760 @cindex @code{Calendar}
11761 @cindex Time
11762 @cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
11763
11764 @node GNAT.CRC32 (g-crc32.ads)
11765 @section @code{GNAT.CRC32} (@file{g-crc32.ads})
11766 @cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
11767 @cindex CRC32
11768 @cindex Cyclic Redundancy Check
11769
11770 @noindent
11771 This package implements the CRC-32 algorithm.  For a full description
11772 of this algorithm see
11773 ``Computation of Cyclic Redundancy Checks via Table Look-Up'',
11774 @cite{Communications of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013,
11775 Aug.@: 1988.  Sarwate, D.V@.
11776
11777 @noindent
11778 Provides an extended capability for formatted output of time values with
11779 full user control over the format.  Modeled on the GNU Date specification.
11780
11781 @node GNAT.Case_Util (g-casuti.ads)
11782 @section @code{GNAT.Case_Util} (@file{g-casuti.ads})
11783 @cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
11784 @cindex Casing utilities
11785 @cindex Character handling (@code{GNAT.Case_Util})
11786
11787 @noindent
11788 A set of simple routines for handling upper and lower casing of strings
11789 without the overhead of the full casing tables
11790 in @code{Ada.Characters.Handling}.
11791
11792 @node GNAT.CGI (g-cgi.ads)
11793 @section @code{GNAT.CGI} (@file{g-cgi.ads})
11794 @cindex @code{GNAT.CGI} (@file{g-cgi.ads})
11795 @cindex CGI (Common Gateway Interface)
11796
11797 @noindent
11798 This is a package for interfacing a GNAT program with a Web server via the
11799 Common Gateway Interface (CGI)@.  Basically this package parses the CGI
11800 parameters, which are a set of key/value pairs sent by the Web server.  It
11801 builds a table whose index is the key and provides some services to deal
11802 with this table.
11803
11804 @node GNAT.CGI.Cookie (g-cgicoo.ads)
11805 @section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
11806 @cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
11807 @cindex CGI (Common Gateway Interface) cookie support
11808 @cindex Cookie support in CGI
11809
11810 @noindent
11811 This is a package to interface a GNAT program with a Web server via the
11812 Common Gateway Interface (CGI).  It exports services to deal with Web
11813 cookies (piece of information kept in the Web client software).
11814
11815 @node GNAT.CGI.Debug (g-cgideb.ads)
11816 @section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
11817 @cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
11818 @cindex CGI (Common Gateway Interface) debugging
11819
11820 @noindent
11821 This is a package to help debugging CGI (Common Gateway Interface)
11822 programs written in Ada.
11823
11824 @node GNAT.Command_Line (g-comlin.ads)
11825 @section @code{GNAT.Command_Line} (@file{g-comlin.ads})
11826 @cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
11827 @cindex Command line
11828
11829 @noindent
11830 Provides a high level interface to @code{Ada.Command_Line} facilities,
11831 including the ability to scan for named switches with optional parameters
11832 and expand file names using wild card notations.
11833
11834 @node GNAT.Compiler_Version (g-comver.ads)
11835 @section @code{GNAT.Compiler_Version} (@file{g-comver.ads})
11836 @cindex @code{GNAT.Compiler_Version} (@file{g-comver.ads})
11837 @cindex Compiler Version
11838 @cindex Version, of compiler
11839
11840 @noindent
11841 Provides a routine for obtaining the version of the compiler used to
11842 compile the program. More accurately this is the version of the binder
11843 used to bind the program (this will normally be the same as the version
11844 of the compiler if a consistent tool set is used to compile all units
11845 of a partition).
11846
11847 @node GNAT.Ctrl_C (g-ctrl_c.ads)
11848 @section @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
11849 @cindex @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
11850 @cindex Interrupt
11851
11852 @noindent
11853 Provides a simple interface to handle Ctrl-C keyboard events.
11854
11855 @node GNAT.Current_Exception (g-curexc.ads)
11856 @section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
11857 @cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
11858 @cindex Current exception
11859 @cindex Exception retrieval
11860
11861 @noindent
11862 Provides access to information on the current exception that has been raised
11863 without the need for using the Ada-95 exception choice parameter specification
11864 syntax.  This is particularly useful in simulating typical facilities for
11865 obtaining information about exceptions provided by Ada 83 compilers.
11866
11867 @node GNAT.Debug_Pools (g-debpoo.ads)
11868 @section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
11869 @cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
11870 @cindex Debugging
11871 @cindex Debug pools
11872 @cindex Memory corruption debugging
11873
11874 @noindent
11875 Provide a debugging storage pools that helps tracking memory corruption
11876 problems.  See section ``Finding memory problems with GNAT Debug Pool'' in
11877 the @cite{GNAT User's Guide}.
11878
11879 @node GNAT.Debug_Utilities (g-debuti.ads)
11880 @section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
11881 @cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
11882 @cindex Debugging
11883
11884 @noindent
11885 Provides a few useful utilities for debugging purposes, including conversion
11886 to and from string images of address values. Supports both C and Ada formats
11887 for hexadecimal literals.
11888
11889 @node GNAT.Directory_Operations (g-dirope.ads)
11890 @section @code{GNAT.Directory_Operations} (g-dirope.ads)
11891 @cindex @code{GNAT.Directory_Operations} (g-dirope.ads)
11892 @cindex Directory operations
11893
11894 @noindent
11895 Provides a set of routines for manipulating directories, including changing
11896 the current directory, making new directories, and scanning the files in a
11897 directory.
11898
11899 @node GNAT.Dynamic_HTables (g-dynhta.ads)
11900 @section @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
11901 @cindex @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
11902 @cindex Hash tables
11903
11904 @noindent
11905 A generic implementation of hash tables that can be used to hash arbitrary
11906 data.  Provided in two forms, a simple form with built in hash functions,
11907 and a more complex form in which the hash function is supplied.
11908
11909 @noindent
11910 This package provides a facility similar to that of @code{GNAT.HTable},
11911 except that this package declares a type that can be used to define
11912 dynamic instances of the hash table, while an instantiation of
11913 @code{GNAT.HTable} creates a single instance of the hash table.
11914
11915 @node GNAT.Dynamic_Tables (g-dyntab.ads)
11916 @section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
11917 @cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
11918 @cindex Table implementation
11919 @cindex Arrays, extendable
11920
11921 @noindent
11922 A generic package providing a single dimension array abstraction where the
11923 length of the array can be dynamically modified.
11924
11925 @noindent
11926 This package provides a facility similar to that of @code{GNAT.Table},
11927 except that this package declares a type that can be used to define
11928 dynamic instances of the table, while an instantiation of
11929 @code{GNAT.Table} creates a single instance of the table type.
11930
11931 @node GNAT.Exception_Actions (g-excact.ads)
11932 @section @code{GNAT.Exception_Actions} (@file{g-excact.ads})
11933 @cindex @code{GNAT.Exception_Actions} (@file{g-excact.ads})
11934 @cindex Exception actions
11935
11936 @noindent
11937 Provides callbacks when an exception is raised. Callbacks can be registered
11938 for specific exceptions, or when any exception is raised. This
11939 can be used for instance to force a core dump to ease debugging.
11940
11941 @node GNAT.Exception_Traces (g-exctra.ads)
11942 @section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
11943 @cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
11944 @cindex Exception traces
11945 @cindex Debugging
11946
11947 @noindent
11948 Provides an interface allowing to control automatic output upon exception
11949 occurrences.
11950
11951 @node GNAT.Exceptions (g-except.ads)
11952 @section @code{GNAT.Exceptions} (@file{g-expect.ads})
11953 @cindex @code{GNAT.Exceptions} (@file{g-expect.ads})
11954 @cindex Exceptions, Pure
11955 @cindex Pure packages, exceptions
11956
11957 @noindent
11958 Normally it is not possible to raise an exception with
11959 a message from a subprogram in a pure package, since the
11960 necessary types and subprograms are in @code{Ada.Exceptions}
11961 which is not a pure unit. @code{GNAT.Exceptions} provides a
11962 facility for getting around this limitation for a few
11963 predefined exceptions, and for example allow raising
11964 @code{Constraint_Error} with a message from a pure subprogram.
11965
11966 @node GNAT.Expect (g-expect.ads)
11967 @section @code{GNAT.Expect} (@file{g-expect.ads})
11968 @cindex @code{GNAT.Expect} (@file{g-expect.ads})
11969
11970 @noindent
11971 Provides a set of subprograms similar to what is available
11972 with the standard Tcl Expect tool.
11973 It allows you to easily spawn and communicate with an external process.
11974 You can send commands or inputs to the process, and compare the output
11975 with some expected regular expression. Currently @code{GNAT.Expect}
11976 is implemented on all native GNAT ports except for OpenVMS@.
11977 It is not implemented for cross ports, and in particular is not
11978 implemented for VxWorks or LynxOS@.
11979
11980 @node GNAT.Float_Control (g-flocon.ads)
11981 @section @code{GNAT.Float_Control} (@file{g-flocon.ads})
11982 @cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
11983 @cindex Floating-Point Processor
11984
11985 @noindent
11986 Provides an interface for resetting the floating-point processor into the
11987 mode required for correct semantic operation in Ada.  Some third party
11988 library calls may cause this mode to be modified, and the Reset procedure
11989 in this package can be used to reestablish the required mode.
11990
11991 @node GNAT.Heap_Sort (g-heasor.ads)
11992 @section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
11993 @cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
11994 @cindex Sorting
11995
11996 @noindent
11997 Provides a general implementation of heap sort usable for sorting arbitrary
11998 data items. Exchange and comparison procedures are provided by passing
11999 access-to-procedure values.  The algorithm used is a modified heap sort
12000 that performs approximately N*log(N) comparisons in the worst case.
12001
12002 @node GNAT.Heap_Sort_A (g-hesora.ads)
12003 @section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
12004 @cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
12005 @cindex Sorting
12006
12007 @noindent
12008 Provides a general implementation of heap sort usable for sorting arbitrary
12009 data items. Move and comparison procedures are provided by passing
12010 access-to-procedure values.  The algorithm used is a modified heap sort
12011 that performs approximately N*log(N) comparisons in the worst case.
12012 This differs from @code{GNAT.Heap_Sort} in having a less convenient
12013 interface, but may be slightly more efficient.
12014
12015 @node GNAT.Heap_Sort_G (g-hesorg.ads)
12016 @section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
12017 @cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
12018 @cindex Sorting
12019
12020 @noindent
12021 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
12022 are provided as generic parameters, this improves efficiency, especially
12023 if the procedures can be inlined, at the expense of duplicating code for
12024 multiple instantiations.
12025
12026 @node GNAT.HTable (g-htable.ads)
12027 @section @code{GNAT.HTable} (@file{g-htable.ads})
12028 @cindex @code{GNAT.HTable} (@file{g-htable.ads})
12029 @cindex Hash tables
12030
12031 @noindent
12032 A generic implementation of hash tables that can be used to hash arbitrary
12033 data.  Provides two approaches, one a simple static approach, and the other
12034 allowing arbitrary dynamic hash tables.
12035
12036 @node GNAT.IO (g-io.ads)
12037 @section @code{GNAT.IO} (@file{g-io.ads})
12038 @cindex @code{GNAT.IO} (@file{g-io.ads})
12039 @cindex Simple I/O
12040 @cindex Input/Output facilities
12041
12042 @noindent
12043 A simple preelaborable input-output package that provides a subset of
12044 simple Text_IO functions for reading characters and strings from
12045 Standard_Input, and writing characters, strings and integers to either
12046 Standard_Output or Standard_Error.
12047
12048 @node GNAT.IO_Aux (g-io_aux.ads)
12049 @section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
12050 @cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
12051 @cindex Text_IO
12052 @cindex Input/Output facilities
12053
12054 Provides some auxiliary functions for use with Text_IO, including a test
12055 for whether a file exists, and functions for reading a line of text.
12056
12057 @node GNAT.Lock_Files (g-locfil.ads)
12058 @section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
12059 @cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
12060 @cindex File locking
12061 @cindex Locking using files
12062
12063 @noindent
12064 Provides a general interface for using files as locks.  Can be used for
12065 providing program level synchronization.
12066
12067 @node GNAT.MD5 (g-md5.ads)
12068 @section @code{GNAT.MD5} (@file{g-md5.ads})
12069 @cindex @code{GNAT.MD5} (@file{g-md5.ads})
12070 @cindex Message Digest MD5
12071
12072 @noindent
12073 Implements the MD5 Message-Digest Algorithm as described in RFC 1321.
12074
12075 @node GNAT.Memory_Dump (g-memdum.ads)
12076 @section @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
12077 @cindex @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
12078 @cindex Dump Memory
12079
12080 @noindent
12081 Provides a convenient routine for dumping raw memory to either the
12082 standard output or standard error files. Uses GNAT.IO for actual
12083 output.
12084
12085 @node GNAT.Most_Recent_Exception (g-moreex.ads)
12086 @section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
12087 @cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
12088 @cindex Exception, obtaining most recent
12089
12090 @noindent
12091 Provides access to the most recently raised exception.  Can be used for
12092 various logging purposes, including duplicating functionality of some
12093 Ada 83 implementation dependent extensions.
12094
12095 @node GNAT.OS_Lib (g-os_lib.ads)
12096 @section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
12097 @cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
12098 @cindex Operating System interface
12099 @cindex Spawn capability
12100
12101 @noindent
12102 Provides a range of target independent operating system interface functions,
12103 including time/date management, file operations, subprocess management,
12104 including a portable spawn procedure, and access to environment variables
12105 and error return codes.
12106
12107 @node GNAT.Perfect_Hash.Generators (g-pehage.ads)
12108 @section @code{GNAT.Perfect_Hash.Generators} (@file{g-pehage.ads})
12109 @cindex @code{GNAT.Perfect_Hash.Generators} (@file{g-pehage.ads})
12110 @cindex Hash functions
12111
12112 @noindent
12113 Provides a generator of static minimal perfect hash functions. No
12114 collisions occur and each item can be retrieved from the table in one
12115 probe (perfect property). The hash table size corresponds to the exact
12116 size of the key set and no larger (minimal property). The key set has to
12117 be know in advance (static property). The hash functions are also order
12118 preservering. If w2 is inserted after w1 in the generator, their
12119 hashcode are in the same order. These hashing functions are very
12120 convenient for use with realtime applications.
12121
12122 @node GNAT.Regexp (g-regexp.ads)
12123 @section @code{GNAT.Regexp} (@file{g-regexp.ads})
12124 @cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
12125 @cindex Regular expressions
12126 @cindex Pattern matching
12127
12128 @noindent
12129 A simple implementation of regular expressions, using a subset of regular
12130 expression syntax copied from familiar Unix style utilities.  This is the
12131 simples of the three pattern matching packages provided, and is particularly
12132 suitable for ``file globbing'' applications.
12133
12134 @node GNAT.Registry (g-regist.ads)
12135 @section @code{GNAT.Registry} (@file{g-regist.ads})
12136 @cindex @code{GNAT.Registry} (@file{g-regist.ads})
12137 @cindex Windows Registry
12138
12139 @noindent
12140 This is a high level binding to the Windows registry.  It is possible to
12141 do simple things like reading a key value, creating a new key.  For full
12142 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
12143 package provided with the Win32Ada binding
12144
12145 @node GNAT.Regpat (g-regpat.ads)
12146 @section @code{GNAT.Regpat} (@file{g-regpat.ads})
12147 @cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
12148 @cindex Regular expressions
12149 @cindex Pattern matching
12150
12151 @noindent
12152 A complete implementation of Unix-style regular expression matching, copied
12153 from the original V7 style regular expression library written in C by
12154 Henry Spencer (and binary compatible with this C library).
12155
12156 @node GNAT.Secondary_Stack_Info (g-sestin.ads)
12157 @section @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
12158 @cindex @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
12159 @cindex Secondary Stack Info
12160
12161 @noindent
12162 Provide the capability to query the high water mark of the current task's
12163 secondary stack.
12164
12165 @node GNAT.Semaphores (g-semaph.ads)
12166 @section @code{GNAT.Semaphores} (@file{g-semaph.ads})
12167 @cindex @code{GNAT.Semaphores} (@file{g-semaph.ads})
12168 @cindex Semaphores
12169
12170 @noindent
12171 Provides classic counting and binary semaphores using protected types.
12172
12173 @node GNAT.Signals (g-signal.ads)
12174 @section @code{GNAT.Signals} (@file{g-signal.ads})
12175 @cindex @code{GNAT.Signals} (@file{g-signal.ads})
12176 @cindex Signals
12177
12178 @noindent
12179 Provides the ability to manipulate the blocked status of signals on supported
12180 targets.
12181
12182 @node GNAT.Sockets (g-socket.ads)
12183 @section @code{GNAT.Sockets} (@file{g-socket.ads})
12184 @cindex @code{GNAT.Sockets} (@file{g-socket.ads})
12185 @cindex Sockets
12186
12187 @noindent
12188 A high level and portable interface to develop sockets based applications.
12189 This package is based on the sockets thin binding found in
12190 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
12191 on all native GNAT ports except for OpenVMS@.  It is not implemented
12192 for the LynxOS@ cross port.
12193
12194 @node GNAT.Source_Info (g-souinf.ads)
12195 @section @code{GNAT.Source_Info} (@file{g-souinf.ads})
12196 @cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
12197 @cindex Source Information
12198
12199 @noindent
12200 Provides subprograms that give access to source code information known at
12201 compile time, such as the current file name and line number.
12202
12203 @node GNAT.Spell_Checker (g-speche.ads)
12204 @section @code{GNAT.Spell_Checker} (@file{g-speche.ads})
12205 @cindex @code{GNAT.Spell_Checker} (@file{g-speche.ads})
12206 @cindex Spell checking
12207
12208 @noindent
12209 Provides a function for determining whether one string is a plausible
12210 near misspelling of another string.
12211
12212 @node GNAT.Spitbol.Patterns (g-spipat.ads)
12213 @section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
12214 @cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
12215 @cindex SPITBOL pattern matching
12216 @cindex Pattern matching
12217
12218 @noindent
12219 A complete implementation of SNOBOL4 style pattern matching.  This is the
12220 most elaborate of the pattern matching packages provided.  It fully duplicates
12221 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
12222 efficient algorithm developed by Robert Dewar for the SPITBOL system.
12223
12224 @node GNAT.Spitbol (g-spitbo.ads)
12225 @section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
12226 @cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
12227 @cindex SPITBOL interface
12228
12229 @noindent
12230 The top level package of the collection of SPITBOL-style functionality, this
12231 package provides basic SNOBOL4 string manipulation functions, such as
12232 Pad, Reverse, Trim, Substr capability, as well as a generic table function
12233 useful for constructing arbitrary mappings from strings in the style of
12234 the SNOBOL4 TABLE function.
12235
12236 @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
12237 @section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
12238 @cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
12239 @cindex Sets of strings
12240 @cindex SPITBOL Tables
12241
12242 @noindent
12243 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
12244 for type @code{Standard.Boolean}, giving an implementation of sets of
12245 string values.
12246
12247 @node GNAT.Spitbol.Table_Integer (g-sptain.ads)
12248 @section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
12249 @cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
12250 @cindex Integer maps
12251 @cindex Maps
12252 @cindex SPITBOL Tables
12253
12254 @noindent
12255 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
12256 for type @code{Standard.Integer}, giving an implementation of maps
12257 from string to integer values.
12258
12259 @node GNAT.Spitbol.Table_VString (g-sptavs.ads)
12260 @section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
12261 @cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
12262 @cindex String maps
12263 @cindex Maps
12264 @cindex SPITBOL Tables
12265
12266 @noindent
12267 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
12268 a variable length string type, giving an implementation of general
12269 maps from strings to strings.
12270
12271 @node GNAT.Strings (g-string.ads)
12272 @section @code{GNAT.Strings} (@file{g-string.ads})
12273 @cindex @code{GNAT.Strings} (@file{g-string.ads})
12274
12275 @noindent
12276 Common String access types and related subprograms. Basically it
12277 defines a string access and an array of string access types.
12278
12279 @node GNAT.String_Split (g-strspl.ads)
12280 @section @code{GNAT.String_Split} (@file{g-strspl.ads})
12281 @cindex @code{GNAT.String_Split} (@file{g-strspl.ads})
12282 @cindex String splitter
12283
12284 @noindent
12285 Useful string-manipulation routines: given a set of separators, split
12286 a string wherever the separators appear, and provide direct access
12287 to the resulting slices. This package is instantiated from
12288 @code{GNAT.Array_Split}.
12289
12290 @node GNAT.Table (g-table.ads)
12291 @section @code{GNAT.Table} (@file{g-table.ads})
12292 @cindex @code{GNAT.Table} (@file{g-table.ads})
12293 @cindex Table implementation
12294 @cindex Arrays, extendable
12295
12296 @noindent
12297 A generic package providing a single dimension array abstraction where the
12298 length of the array can be dynamically modified.
12299
12300 @noindent
12301 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
12302 except that this package declares a single instance of the table type,
12303 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
12304 used to define dynamic instances of the table.
12305
12306 @node GNAT.Task_Lock (g-tasloc.ads)
12307 @section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
12308 @cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
12309 @cindex Task synchronization
12310 @cindex Task locking
12311 @cindex Locking
12312
12313 @noindent
12314 A very simple facility for locking and unlocking sections of code using a
12315 single global task lock.  Appropriate for use in situations where contention
12316 between tasks is very rarely expected.
12317
12318 @node GNAT.Threads (g-thread.ads)
12319 @section @code{GNAT.Threads} (@file{g-thread.ads})
12320 @cindex @code{GNAT.Threads} (@file{g-thread.ads})
12321 @cindex Foreign threads
12322 @cindex Threads, foreign
12323
12324 @noindent
12325 Provides facilities for creating and destroying threads with explicit calls.
12326 These threads are known to the GNAT run-time system.  These subprograms are
12327 exported C-convention procedures intended to be called from foreign code.
12328 By using these primitives rather than directly calling operating systems
12329 routines, compatibility with the Ada tasking runt-time is provided.
12330
12331 @node GNAT.Traceback (g-traceb.ads)
12332 @section @code{GNAT.Traceback} (@file{g-traceb.ads})
12333 @cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
12334 @cindex Trace back facilities
12335
12336 @noindent
12337 Provides a facility for obtaining non-symbolic traceback information, useful
12338 in various debugging situations.
12339
12340 @node GNAT.Traceback.Symbolic (g-trasym.ads)
12341 @section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
12342 @cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
12343 @cindex Trace back facilities
12344
12345 @noindent
12346 Provides symbolic traceback information that includes the subprogram
12347 name and line number information.
12348
12349 @node GNAT.Wide_String_Split (g-wistsp.ads)
12350 @section @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
12351 @cindex @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
12352 @cindex Wide_String splitter
12353
12354 @noindent
12355 Useful wide_string-manipulation routines: given a set of separators, split
12356 a wide_string wherever the separators appear, and provide direct access
12357 to the resulting slices. This package is instantiated from
12358 @code{GNAT.Array_Split}.
12359
12360 @node Interfaces.C.Extensions (i-cexten.ads)
12361 @section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
12362 @cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
12363
12364 @noindent
12365 This package contains additional C-related definitions, intended
12366 for use with either manually or automatically generated bindings
12367 to C libraries.
12368
12369 @node Interfaces.C.Streams (i-cstrea.ads)
12370 @section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
12371 @cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
12372 @cindex  C streams, interfacing
12373
12374 @noindent
12375 This package is a binding for the most commonly used operations
12376 on C streams.
12377
12378 @node Interfaces.CPP (i-cpp.ads)
12379 @section @code{Interfaces.CPP} (@file{i-cpp.ads})
12380 @cindex @code{Interfaces.CPP} (@file{i-cpp.ads})
12381 @cindex  C++ interfacing
12382 @cindex  Interfacing, to C++
12383
12384 @noindent
12385 This package provides facilities for use in interfacing to C++.  It
12386 is primarily intended to be used in connection with automated tools
12387 for the generation of C++ interfaces.
12388
12389 @node Interfaces.Os2lib (i-os2lib.ads)
12390 @section @code{Interfaces.Os2lib} (@file{i-os2lib.ads})
12391 @cindex @code{Interfaces.Os2lib} (@file{i-os2lib.ads})
12392 @cindex Interfacing, to OS/2
12393 @cindex OS/2 interfacing
12394
12395 @noindent
12396 This package provides interface definitions to the OS/2 library.
12397 It is a thin binding which is a direct translation of the
12398 various @file{<bse@.h>} files.
12399
12400 @node Interfaces.Os2lib.Errors (i-os2err.ads)
12401 @section @code{Interfaces.Os2lib.Errors} (@file{i-os2err.ads})
12402 @cindex @code{Interfaces.Os2lib.Errors} (@file{i-os2err.ads})
12403 @cindex OS/2 Error codes
12404 @cindex Interfacing, to OS/2
12405 @cindex OS/2 interfacing
12406
12407 @noindent
12408 This package provides definitions of the OS/2 error codes.
12409
12410 @node Interfaces.Os2lib.Synchronization (i-os2syn.ads)
12411 @section @code{Interfaces.Os2lib.Synchronization} (@file{i-os2syn.ads})
12412 @cindex @code{Interfaces.Os2lib.Synchronization} (@file{i-os2syn.ads})
12413 @cindex Interfacing, to OS/2
12414 @cindex Synchronization, OS/2
12415 @cindex OS/2 synchronization primitives
12416
12417 @noindent
12418 This is a child package that provides definitions for interfacing
12419 to the @code{OS/2} synchronization primitives.
12420
12421 @node Interfaces.Os2lib.Threads (i-os2thr.ads)
12422 @section @code{Interfaces.Os2lib.Threads} (@file{i-os2thr.ads})
12423 @cindex @code{Interfaces.Os2lib.Threads} (@file{i-os2thr.ads})
12424 @cindex Interfacing, to OS/2
12425 @cindex Thread control, OS/2
12426 @cindex OS/2 thread interfacing
12427
12428 @noindent
12429 This is a child package that provides definitions for interfacing
12430 to the @code{OS/2} thread primitives.
12431
12432 @node Interfaces.Packed_Decimal (i-pacdec.ads)
12433 @section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
12434 @cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
12435 @cindex  IBM Packed Format
12436 @cindex  Packed Decimal
12437
12438 @noindent
12439 This package provides a set of routines for conversions to and
12440 from a packed decimal format compatible with that used on IBM
12441 mainframes.
12442
12443 @node Interfaces.VxWorks (i-vxwork.ads)
12444 @section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
12445 @cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
12446 @cindex Interfacing to VxWorks
12447 @cindex VxWorks, interfacing
12448
12449 @noindent
12450 This package provides a limited binding to the VxWorks API.
12451 In particular, it interfaces with the
12452 VxWorks hardware interrupt facilities.
12453
12454 @node Interfaces.VxWorks.IO (i-vxwoio.ads)
12455 @section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
12456 @cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
12457 @cindex Interfacing to VxWorks' I/O
12458 @cindex VxWorks, I/O interfacing
12459 @cindex VxWorks, Get_Immediate
12460 @cindex Get_Immediate, VxWorks
12461
12462 @noindent
12463 This package provides a binding to the ioctl (IO/Control)
12464 function of VxWorks, defining a set of option values and
12465 function codes. A particular use of this package is
12466 to enable the use of Get_Immediate under VxWorks.
12467
12468 @node System.Address_Image (s-addima.ads)
12469 @section @code{System.Address_Image} (@file{s-addima.ads})
12470 @cindex @code{System.Address_Image} (@file{s-addima.ads})
12471 @cindex Address image
12472 @cindex Image, of an address
12473
12474 @noindent
12475 This function provides a useful debugging
12476 function that gives an (implementation dependent)
12477 string which identifies an address.
12478
12479 @node System.Assertions (s-assert.ads)
12480 @section @code{System.Assertions} (@file{s-assert.ads})
12481 @cindex @code{System.Assertions} (@file{s-assert.ads})
12482 @cindex Assertions
12483 @cindex Assert_Failure, exception
12484
12485 @noindent
12486 This package provides the declaration of the exception raised
12487 by an run-time assertion failure, as well as the routine that
12488 is used internally to raise this assertion.
12489
12490 @node System.Memory (s-memory.ads)
12491 @section @code{System.Memory} (@file{s-memory.ads})
12492 @cindex @code{System.Memory} (@file{s-memory.ads})
12493 @cindex Memory allocation
12494
12495 @noindent
12496 This package provides the interface to the low level routines used
12497 by the generated code for allocation and freeing storage for the
12498 default storage pool (analogous to the C routines malloc and free.
12499 It also provides a reallocation interface analogous to the C routine
12500 realloc. The body of this unit may be modified to provide alternative
12501 allocation mechanisms for the default pool, and in addition, direct
12502 calls to this unit may be made for low level allocation uses (for
12503 example see the body of @code{GNAT.Tables}).
12504
12505 @node System.Partition_Interface (s-parint.ads)
12506 @section @code{System.Partition_Interface} (@file{s-parint.ads})
12507 @cindex @code{System.Partition_Interface} (@file{s-parint.ads})
12508 @cindex Partition intefacing functions
12509
12510 @noindent
12511 This package provides facilities for partition interfacing.  It
12512 is used primarily in a distribution context when using Annex E
12513 with @code{GLADE}.
12514
12515 @node System.Restrictions (s-restri.ads)
12516 @section @code{System.Restrictions} (@file{s-restri.ads})
12517 @cindex @code{System.Restrictions} (@file{s-restri.ads})
12518 @cindex Run-time restrictions access
12519
12520 @noindent
12521 This package provides facilities for accessing at run-time
12522 the status of restrictions specified at compile time for
12523 the partition. Information is available both with regard
12524 to actual restrictions specified, and with regard to
12525 compiler determined information on which restrictions
12526 are violated by one or more packages in the partition.
12527
12528 @node System.Rident (s-rident.ads)
12529 @section @code{System.Rident} (@file{s-rident.ads})
12530 @cindex @code{System.Rident} (@file{s-rident.ads})
12531 @cindex Restrictions definitions
12532
12533 @noindent
12534 This package provides definitions of the restrictions
12535 identifiers supported by GNAT, and also the format of
12536 the restrictions provided in package System.Restrictions.
12537 It is not normally necessary to @code{with} this generic package
12538 since the necessary instantiation is included in
12539 package System.Restrictions.
12540
12541 @node System.Task_Info (s-tasinf.ads)
12542 @section @code{System.Task_Info} (@file{s-tasinf.ads})
12543 @cindex @code{System.Task_Info} (@file{s-tasinf.ads})
12544 @cindex Task_Info pragma
12545
12546 @noindent
12547 This package provides target dependent functionality that is used
12548 to support the @code{Task_Info} pragma
12549
12550 @node System.Wch_Cnv (s-wchcnv.ads)
12551 @section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
12552 @cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
12553 @cindex Wide Character, Representation
12554 @cindex Wide String, Conversion
12555 @cindex Representation of wide characters
12556
12557 @noindent
12558 This package provides routines for converting between
12559 wide characters and a representation as a value of type
12560 @code{Standard.String}, using a specified wide character
12561 encoding method.  It uses definitions in
12562 package @code{System.Wch_Con}.
12563
12564 @node System.Wch_Con (s-wchcon.ads)
12565 @section @code{System.Wch_Con} (@file{s-wchcon.ads})
12566 @cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
12567
12568 @noindent
12569 This package provides definitions and descriptions of
12570 the various methods used for encoding wide characters
12571 in ordinary strings.  These definitions are used by
12572 the package @code{System.Wch_Cnv}.
12573
12574 @node Interfacing to Other Languages
12575 @chapter Interfacing to Other Languages
12576 @noindent
12577 The facilities in annex B of the Ada 95 Reference Manual are fully
12578 implemented in GNAT, and in addition, a full interface to C++ is
12579 provided.
12580
12581 @menu
12582 * Interfacing to C::
12583 * Interfacing to C++::
12584 * Interfacing to COBOL::
12585 * Interfacing to Fortran::
12586 * Interfacing to non-GNAT Ada code::
12587 @end menu
12588
12589 @node Interfacing to C
12590 @section Interfacing to C
12591
12592 @noindent
12593 Interfacing to C with GNAT can use one of two approaches:
12594
12595 @itemize @bullet
12596 @item
12597 The types in the package @code{Interfaces.C} may be used.
12598 @item
12599 Standard Ada types may be used directly.  This may be less portable to
12600 other compilers, but will work on all GNAT compilers, which guarantee
12601 correspondence between the C and Ada types.
12602 @end itemize
12603
12604 @noindent
12605 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
12606 effect, since this is the default.  The following table shows the
12607 correspondence between Ada scalar types and the corresponding C types.
12608
12609 @table @code
12610 @item Integer
12611 @code{int}
12612 @item Short_Integer
12613 @code{short}
12614 @item Short_Short_Integer
12615 @code{signed char}
12616 @item Long_Integer
12617 @code{long}
12618 @item Long_Long_Integer
12619 @code{long long}
12620 @item Short_Float
12621 @code{float}
12622 @item Float
12623 @code{float}
12624 @item Long_Float
12625 @code{double}
12626 @item Long_Long_Float
12627 This is the longest floating-point type supported by the hardware.
12628 @end table
12629
12630 @noindent
12631 Additionally, there are the following general correspondences between Ada
12632 and C types:
12633 @itemize @bullet
12634 @item
12635 Ada enumeration types map to C enumeration types directly if pragma
12636 @code{Convention C} is specified, which causes them to have int
12637 length.  Without pragma @code{Convention C}, Ada enumeration types map to
12638 8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short},
12639 @code{int}, respectively) depending on the number of values passed.
12640 This is the only case in which pragma @code{Convention C} affects the
12641 representation of an Ada type.
12642
12643 @item
12644 Ada access types map to C pointers, except for the case of pointers to
12645 unconstrained types in Ada, which have no direct C equivalent.
12646
12647 @item
12648 Ada arrays map directly to C arrays.
12649
12650 @item
12651 Ada records map directly to C structures.
12652
12653 @item
12654 Packed Ada records map to C structures where all members are bit fields
12655 of the length corresponding to the @code{@var{type}'Size} value in Ada.
12656 @end itemize
12657
12658 @node Interfacing to C++
12659 @section Interfacing to C++
12660
12661 @noindent
12662 The interface to C++ makes use of the following pragmas, which are
12663 primarily intended to be constructed automatically using a binding generator
12664 tool, although it is possible to construct them by hand.  No suitable binding
12665 generator tool is supplied with GNAT though.
12666
12667 Using these pragmas it is possible to achieve complete
12668 inter-operability between Ada tagged types and C class definitions.
12669 See @ref{Implementation Defined Pragmas}, for more details.
12670
12671 @table @code
12672 @item pragma CPP_Class ([Entity =>] @var{local_name})
12673 The argument denotes an entity in the current declarative region that is
12674 declared as a tagged or untagged record type.  It indicates that the type
12675 corresponds to an externally declared C++ class type, and is to be laid
12676 out the same way that C++ would lay out the type.
12677
12678 @item pragma CPP_Constructor ([Entity =>] @var{local_name})
12679 This pragma identifies an imported function (imported in the usual way
12680 with pragma @code{Import}) as corresponding to a C++ constructor.
12681
12682 @item pragma CPP_Vtable @dots{}
12683 One @code{CPP_Vtable} pragma can be present for each component of type
12684 @code{CPP.Interfaces.Vtable_Ptr} in a record to which pragma @code{CPP_Class}
12685 applies.
12686 @end table
12687
12688 @node Interfacing to COBOL
12689 @section Interfacing to COBOL
12690
12691 @noindent
12692 Interfacing to COBOL is achieved as described in section B.4 of
12693 the Ada 95 reference manual.
12694
12695 @node Interfacing to Fortran
12696 @section Interfacing to Fortran
12697
12698 @noindent
12699 Interfacing to Fortran is achieved as described in section B.5 of the
12700 reference manual.  The pragma @code{Convention Fortran}, applied to a
12701 multi-dimensional array causes the array to be stored in column-major
12702 order as required for convenient interface to Fortran.
12703
12704 @node Interfacing to non-GNAT Ada code
12705 @section Interfacing to non-GNAT Ada code
12706
12707 It is possible to specify the convention @code{Ada} in a pragma
12708 @code{Import} or pragma @code{Export}.  However this refers to
12709 the calling conventions used by GNAT, which may or may not be
12710 similar enough to those used by some other Ada 83 or Ada 95
12711 compiler to allow interoperation.
12712
12713 If arguments types are kept simple, and if the foreign compiler generally
12714 follows system calling conventions, then it may be possible to integrate
12715 files compiled by other Ada compilers, provided that the elaboration
12716 issues are adequately addressed (for example by eliminating the
12717 need for any load time elaboration).
12718
12719 In particular, GNAT running on VMS is designed to
12720 be highly compatible with the DEC Ada 83 compiler, so this is one
12721 case in which it is possible to import foreign units of this type,
12722 provided that the data items passed are restricted to simple scalar
12723 values or simple record types without variants, or simple array
12724 types with fixed bounds.
12725
12726 @node Specialized Needs Annexes
12727 @chapter Specialized Needs Annexes
12728
12729 @noindent
12730 Ada 95 defines a number of specialized needs annexes, which are not
12731 required in all implementations.  However, as described in this chapter,
12732 GNAT implements all of these special needs annexes:
12733
12734 @table @asis
12735 @item Systems Programming (Annex C)
12736 The Systems Programming Annex is fully implemented.
12737
12738 @item Real-Time Systems (Annex D)
12739 The Real-Time Systems Annex is fully implemented.
12740
12741 @item Distributed Systems (Annex E)
12742 Stub generation is fully implemented in the GNAT compiler.  In addition,
12743 a complete compatible PCS is available as part of the GLADE system,
12744 a separate product.  When the two
12745 products are used in conjunction, this annex is fully implemented.
12746
12747 @item Information Systems (Annex F)
12748 The Information Systems annex is fully implemented.
12749
12750 @item Numerics (Annex G)
12751 The Numerics Annex is fully implemented.
12752
12753 @item Safety and Security (Annex H)
12754 The Safety and Security annex is fully implemented.
12755 @end table
12756
12757 @node Implementation of Specific Ada Features
12758 @chapter Implementation of Specific Ada Features
12759
12760 @noindent
12761 This chapter describes the GNAT implementation of several Ada language
12762 facilities.
12763
12764 @menu
12765 * Machine Code Insertions::
12766 * GNAT Implementation of Tasking::
12767 * GNAT Implementation of Shared Passive Packages::
12768 * Code Generation for Array Aggregates::
12769 @end menu
12770
12771 @node Machine Code Insertions
12772 @section Machine Code Insertions
12773
12774 @noindent
12775 Package @code{Machine_Code} provides machine code support as described
12776 in the Ada 95 Reference Manual in two separate forms:
12777 @itemize @bullet
12778 @item
12779 Machine code statements, consisting of qualified expressions that
12780 fit the requirements of RM section 13.8.
12781 @item
12782 An intrinsic callable procedure, providing an alternative mechanism of
12783 including machine instructions in a subprogram.
12784 @end itemize
12785
12786 @noindent
12787 The two features are similar, and both are closely related to the mechanism
12788 provided by the asm instruction in the GNU C compiler.  Full understanding
12789 and use of the facilities in this package requires understanding the asm
12790 instruction as described in @cite{Using the GNU Compiler Collection (GCC)}
12791 by Richard Stallman. The relevant section is titled ``Extensions to the C
12792 Language Family'' -> ``Assembler Instructions with C Expression Operands''.
12793
12794 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
12795 semantic restrictions and effects as described below.  Both are provided so
12796 that the procedure call can be used as a statement, and the function call
12797 can be used to form a code_statement.
12798
12799 The first example given in the GCC documentation is the C @code{asm}
12800 instruction:
12801 @smallexample
12802    asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
12803 @end smallexample
12804
12805 @noindent
12806 The equivalent can be written for GNAT as:
12807
12808 @smallexample @c ada
12809 Asm ("fsinx %1 %0",
12810      My_Float'Asm_Output ("=f", result),
12811      My_Float'Asm_Input  ("f",  angle));
12812 @end smallexample
12813
12814 @noindent
12815 The first argument to @code{Asm} is the assembler template, and is
12816 identical to what is used in GNU C@.  This string must be a static
12817 expression.  The second argument is the output operand list.  It is
12818 either a single @code{Asm_Output} attribute reference, or a list of such
12819 references enclosed in parentheses (technically an array aggregate of
12820 such references).
12821
12822 The @code{Asm_Output} attribute denotes a function that takes two
12823 parameters.  The first is a string, the second is the name of a variable
12824 of the type designated by the attribute prefix.  The first (string)
12825 argument is required to be a static expression and designates the
12826 constraint for the parameter (e.g.@: what kind of register is
12827 required).  The second argument is the variable to be updated with the
12828 result.  The possible values for constraint are the same as those used in
12829 the RTL, and are dependent on the configuration file used to build the
12830 GCC back end.  If there are no output operands, then this argument may
12831 either be omitted, or explicitly given as @code{No_Output_Operands}.
12832
12833 The second argument of @code{@var{my_float}'Asm_Output} functions as
12834 though it were an @code{out} parameter, which is a little curious, but
12835 all names have the form of expressions, so there is no syntactic
12836 irregularity, even though normally functions would not be permitted
12837 @code{out} parameters.  The third argument is the list of input
12838 operands.  It is either a single @code{Asm_Input} attribute reference, or
12839 a list of such references enclosed in parentheses (technically an array
12840 aggregate of such references).
12841
12842 The @code{Asm_Input} attribute denotes a function that takes two
12843 parameters.  The first is a string, the second is an expression of the
12844 type designated by the prefix.  The first (string) argument is required
12845 to be a static expression, and is the constraint for the parameter,
12846 (e.g.@: what kind of register is required).  The second argument is the
12847 value to be used as the input argument.  The possible values for the
12848 constant are the same as those used in the RTL, and are dependent on
12849 the configuration file used to built the GCC back end.
12850
12851 If there are no input operands, this argument may either be omitted, or
12852 explicitly given as @code{No_Input_Operands}.  The fourth argument, not
12853 present in the above example, is a list of register names, called the
12854 @dfn{clobber} argument.  This argument, if given, must be a static string
12855 expression, and is a space or comma separated list of names of registers
12856 that must be considered destroyed as a result of the @code{Asm} call.  If
12857 this argument is the null string (the default value), then the code
12858 generator assumes that no additional registers are destroyed.
12859
12860 The fifth argument, not present in the above example, called the
12861 @dfn{volatile} argument, is by default @code{False}.  It can be set to
12862 the literal value @code{True} to indicate to the code generator that all
12863 optimizations with respect to the instruction specified should be
12864 suppressed, and that in particular, for an instruction that has outputs,
12865 the instruction will still be generated, even if none of the outputs are
12866 used.  See the full description in the GCC manual for further details.
12867
12868 The @code{Asm} subprograms may be used in two ways.  First the procedure
12869 forms can be used anywhere a procedure call would be valid, and
12870 correspond to what the RM calls ``intrinsic'' routines.  Such calls can
12871 be used to intersperse machine instructions with other Ada statements.
12872 Second, the function forms, which return a dummy value of the limited
12873 private type @code{Asm_Insn}, can be used in code statements, and indeed
12874 this is the only context where such calls are allowed.  Code statements
12875 appear as aggregates of the form:
12876
12877 @smallexample @c ada
12878 Asm_Insn'(Asm (@dots{}));
12879 Asm_Insn'(Asm_Volatile (@dots{}));
12880 @end smallexample
12881
12882 @noindent
12883 In accordance with RM rules, such code statements are allowed only
12884 within subprograms whose entire body consists of such statements.  It is
12885 not permissible to intermix such statements with other Ada statements.
12886
12887 Typically the form using intrinsic procedure calls is more convenient
12888 and more flexible.  The code statement form is provided to meet the RM
12889 suggestion that such a facility should be made available.  The following
12890 is the exact syntax of the call to @code{Asm}. As usual, if named notation
12891 is used, the arguments may be given in arbitrary order, following the
12892 normal rules for use of positional and named arguments)
12893
12894 @smallexample
12895 ASM_CALL ::= Asm (
12896                  [Template =>] static_string_EXPRESSION
12897                [,[Outputs  =>] OUTPUT_OPERAND_LIST      ]
12898                [,[Inputs   =>] INPUT_OPERAND_LIST       ]
12899                [,[Clobber  =>] static_string_EXPRESSION ]
12900                [,[Volatile =>] static_boolean_EXPRESSION] )
12901
12902 OUTPUT_OPERAND_LIST ::=
12903   [PREFIX.]No_Output_Operands
12904 | OUTPUT_OPERAND_ATTRIBUTE
12905 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
12906
12907 OUTPUT_OPERAND_ATTRIBUTE ::=
12908   SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
12909
12910 INPUT_OPERAND_LIST ::=
12911   [PREFIX.]No_Input_Operands
12912 | INPUT_OPERAND_ATTRIBUTE
12913 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
12914
12915 INPUT_OPERAND_ATTRIBUTE ::=
12916   SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
12917 @end smallexample
12918
12919 @noindent
12920 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
12921 are declared in the package @code{Machine_Code} and must be referenced
12922 according to normal visibility rules. In particular if there is no
12923 @code{use} clause for this package, then appropriate package name
12924 qualification is required.
12925
12926 @node GNAT Implementation of Tasking
12927 @section GNAT Implementation of Tasking
12928
12929 @noindent
12930 This chapter outlines the basic GNAT approach to tasking (in particular,
12931 a multi-layered library for portability) and discusses issues related
12932 to compliance with the Real-Time Systems Annex.
12933
12934 @menu
12935 * Mapping Ada Tasks onto the Underlying Kernel Threads::
12936 * Ensuring Compliance with the Real-Time Annex::
12937 @end menu
12938
12939 @node Mapping Ada Tasks onto the Underlying Kernel Threads
12940 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
12941
12942 @noindent
12943 GNAT's run-time support comprises two layers:
12944
12945 @itemize @bullet
12946 @item GNARL (GNAT Run-time Layer)
12947 @item GNULL (GNAT Low-level Library)
12948 @end itemize
12949
12950 @noindent
12951 In GNAT, Ada's tasking services rely on a platform and OS independent
12952 layer known as GNARL@.  This code is responsible for implementing the
12953 correct semantics of Ada's task creation, rendezvous, protected
12954 operations etc.
12955
12956 GNARL decomposes Ada's tasking semantics into simpler lower level
12957 operations such as create a thread, set the priority of a thread,
12958 yield, create a lock, lock/unlock, etc.  The spec for these low-level
12959 operations constitutes GNULLI, the GNULL Interface.  This interface is
12960 directly inspired from the POSIX real-time API@.
12961
12962 If the underlying executive or OS implements the POSIX standard
12963 faithfully, the GNULL Interface maps as is to the services offered by
12964 the underlying kernel.  Otherwise, some target dependent glue code maps
12965 the services offered by the underlying kernel to the semantics expected
12966 by GNARL@.
12967
12968 Whatever the underlying OS (VxWorks, UNIX, OS/2, Windows NT, etc.) the
12969 key point is that each Ada task is mapped on a thread in the underlying
12970 kernel.  For example, in the case of VxWorks, one Ada task = one VxWorks task.
12971
12972 In addition Ada task priorities map onto the underlying thread priorities.
12973 Mapping Ada tasks onto the underlying kernel threads has several advantages:
12974
12975 @itemize @bullet
12976 @item
12977 The underlying scheduler is used to schedule the Ada tasks.  This
12978 makes Ada tasks as efficient as kernel threads from a scheduling
12979 standpoint.
12980
12981 @item
12982 Interaction with code written in C containing threads is eased
12983 since at the lowest level Ada tasks and C threads map onto the same
12984 underlying kernel concept.
12985
12986 @item
12987 When an Ada task is blocked during I/O the remaining Ada tasks are
12988 able to proceed.
12989
12990 @item
12991 On multiprocessor systems Ada tasks can execute in parallel.
12992 @end itemize
12993
12994 @noindent
12995 Some threads libraries offer a mechanism to fork a new process, with the
12996 child process duplicating the threads from the parent.
12997 GNAT does not
12998 support this functionality when the parent contains more than one task.
12999 @cindex Forking a new process
13000
13001 @node Ensuring Compliance with the Real-Time Annex
13002 @subsection Ensuring Compliance with the Real-Time Annex
13003 @cindex Real-Time Systems Annex compliance
13004
13005 @noindent
13006 Although mapping Ada tasks onto
13007 the underlying threads has significant advantages, it does create some
13008 complications when it comes to respecting the scheduling semantics
13009 specified in the real-time annex (Annex D).
13010
13011 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
13012 scheduling policy states:
13013
13014 @quotation
13015 @emph{When the active priority of a ready task that is not running
13016 changes, or the setting of its base priority takes effect, the
13017 task is removed from the ready queue for its old active priority
13018 and is added at the tail of the ready queue for its new active
13019 priority, except in the case where the active priority is lowered
13020 due to the loss of inherited priority, in which case the task is
13021 added at the head of the ready queue for its new active priority.}
13022 @end quotation
13023
13024 @noindent
13025 While most kernels do put tasks at the end of the priority queue when
13026 a task changes its priority, (which respects the main
13027 FIFO_Within_Priorities requirement), almost none keep a thread at the
13028 beginning of its priority queue when its priority drops from the loss
13029 of inherited priority.
13030
13031 As a result most vendors have provided incomplete Annex D implementations.
13032
13033 The GNAT run-time, has a nice cooperative solution to this problem
13034 which ensures that accurate FIFO_Within_Priorities semantics are
13035 respected.
13036
13037 The principle is as follows.  When an Ada task T is about to start
13038 running, it checks whether some other Ada task R with the same
13039 priority as T has been suspended due to the loss of priority
13040 inheritance.  If this is the case, T yields and is placed at the end of
13041 its priority queue.  When R arrives at the front of the queue it
13042 executes.
13043
13044 Note that this simple scheme preserves the relative order of the tasks
13045 that were ready to execute in the priority queue where R has been
13046 placed at the end.
13047
13048 @node GNAT Implementation of Shared Passive Packages
13049 @section GNAT Implementation of Shared Passive Packages
13050 @cindex Shared passive packages
13051
13052 @noindent
13053 GNAT fully implements the pragma @code{Shared_Passive} for
13054 @cindex pragma @code{Shared_Passive}
13055 the purpose of designating shared passive packages.
13056 This allows the use of passive partitions in the
13057 context described in the Ada Reference Manual; i.e. for communication
13058 between separate partitions of a distributed application using the
13059 features in Annex E.
13060 @cindex Annex E
13061 @cindex Distribution Systems Annex
13062
13063 However, the implementation approach used by GNAT provides for more
13064 extensive usage as follows:
13065
13066 @table @emph
13067 @item Communication between separate programs
13068
13069 This allows separate programs to access the data in passive
13070 partitions, using protected objects for synchronization where
13071 needed. The only requirement is that the two programs have a
13072 common shared file system. It is even possible for programs
13073 running on different machines with different architectures
13074 (e.g. different endianness) to communicate via the data in
13075 a passive partition.
13076
13077 @item Persistence between program runs
13078
13079 The data in a passive package can persist from one run of a
13080 program to another, so that a later program sees the final
13081 values stored by a previous run of the same program.
13082
13083 @end table
13084
13085 @noindent
13086 The implementation approach used is to store the data in files. A
13087 separate stream file is created for each object in the package, and
13088 an access to an object causes the corresponding file to be read or
13089 written.
13090
13091 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
13092 @cindex @code{SHARED_MEMORY_DIRECTORY} environment variable
13093 set to the directory to be used for these files.
13094 The files in this directory
13095 have names that correspond to their fully qualified names. For
13096 example, if we have the package
13097
13098 @smallexample @c ada
13099 package X is
13100   pragma Shared_Passive (X);
13101   Y : Integer;
13102   Z : Float;
13103 end X;
13104 @end smallexample
13105
13106 @noindent
13107 and the environment variable is set to @code{/stemp/}, then the files created
13108 will have the names:
13109
13110 @smallexample
13111 /stemp/x.y
13112 /stemp/x.z
13113 @end smallexample
13114
13115 @noindent
13116 These files are created when a value is initially written to the object, and
13117 the files are retained until manually deleted. This provides the persistence
13118 semantics. If no file exists, it means that no partition has assigned a value
13119 to the variable; in this case the initial value declared in the package
13120 will be used. This model ensures that there are no issues in synchronizing
13121 the elaboration process, since elaboration of passive packages elaborates the
13122 initial values, but does not create the files.
13123
13124 The files are written using normal @code{Stream_IO} access.
13125 If you want to be able
13126 to communicate between programs or partitions running on different
13127 architectures, then you should use the XDR versions of the stream attribute
13128 routines, since these are architecture independent.
13129
13130 If active synchronization is required for access to the variables in the
13131 shared passive package, then as described in the Ada Reference Manual, the
13132 package may contain protected objects used for this purpose. In this case
13133 a lock file (whose name is @file{___lock} (three underscores)
13134 is created in the shared memory directory.
13135 @cindex @file{___lock} file (for shared passive packages)
13136 This is used to provide the required locking
13137 semantics for proper protected object synchronization.
13138
13139 As of January 2003, GNAT supports shared passive packages on all platforms
13140 except for OpenVMS.
13141
13142 @node Code Generation for Array Aggregates
13143 @section Code Generation for Array Aggregates
13144
13145 @menu
13146 * Static constant aggregates with static bounds::
13147 * Constant aggregates with an unconstrained nominal types::
13148 * Aggregates with static bounds::
13149 * Aggregates with non-static bounds::
13150 * Aggregates in assignment statements::
13151 @end menu
13152
13153 @noindent
13154 Aggregate have a rich syntax and allow the user to specify the values of
13155 complex data structures by means of a single construct.  As a result, the
13156 code generated for aggregates can be quite complex and involve loops, case
13157 statements and multiple assignments.  In the simplest cases, however, the
13158 compiler will recognize aggregates whose components and constraints are
13159 fully static, and in those cases the compiler will generate little or no
13160 executable code.  The following is an outline of the code that GNAT generates
13161 for various aggregate constructs.  For further details, the user will find it
13162 useful to examine the output produced by the -gnatG flag to see the expanded
13163 source that is input to the code generator.  The user will also want to examine
13164 the assembly code generated at various levels of optimization.
13165
13166 The code generated for aggregates depends on the context, the component values,
13167 and the type.  In the context of an object declaration the code generated is
13168 generally simpler than in the case of an assignment.  As a general rule, static
13169 component values and static subtypes also lead to simpler code.
13170
13171 @node Static constant aggregates with static bounds
13172 @subsection Static constant aggregates with static bounds
13173
13174 @noindent
13175 For the declarations:
13176 @smallexample @c ada
13177     type One_Dim is array (1..10) of integer;
13178     ar0 : constant One_Dim := ( 1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
13179 @end smallexample
13180
13181 @noindent
13182 GNAT generates no executable code: the constant ar0 is placed in static memory.
13183 The same is true for constant aggregates with named associations:
13184
13185 @smallexample @c ada
13186     Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1=> 1);
13187     Cr3 : constant One_Dim := (others => 7777);
13188 @end smallexample
13189
13190 @noindent
13191 The same is true for multidimensional constant arrays such as:
13192
13193 @smallexample @c ada
13194     type two_dim is array (1..3, 1..3) of integer;
13195     Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
13196 @end smallexample
13197
13198 @noindent
13199 The same is true for arrays of one-dimensional arrays: the following are
13200 static:
13201
13202 @smallexample @c ada
13203 type ar1b  is array (1..3) of boolean;
13204 type ar_ar is array (1..3) of ar1b;
13205 None  : constant ar1b := (others => false);     --  fully static
13206 None2 : constant ar_ar := (1..3 => None);       --  fully static
13207 @end smallexample
13208
13209 @noindent
13210 However, for multidimensional aggregates with named associations, GNAT will
13211 generate assignments and loops, even if all associations are static.  The
13212 following two declarations generate a loop for the first dimension, and
13213 individual component assignments for the second dimension:
13214
13215 @smallexample @c ada
13216 Zero1: constant two_dim := (1..3 => (1..3 => 0));
13217 Zero2: constant two_dim := (others => (others => 0));
13218 @end smallexample
13219
13220 @node Constant aggregates with an unconstrained nominal types
13221 @subsection Constant aggregates with an unconstrained nominal types
13222
13223 @noindent
13224 In such cases the aggregate itself establishes the subtype, so that
13225 associations with @code{others} cannot be used.  GNAT determines the
13226 bounds for the actual subtype of the aggregate, and allocates the
13227 aggregate statically as well.  No code is generated for the following:
13228
13229 @smallexample @c ada
13230     type One_Unc is array (natural range <>) of integer;
13231     Cr_Unc : constant One_Unc := (12,24,36);
13232 @end smallexample
13233
13234 @node Aggregates with static bounds
13235 @subsection Aggregates with static bounds
13236
13237 @noindent
13238 In all previous examples the aggregate was the initial (and immutable) value
13239 of a constant.  If the aggregate initializes a variable, then code is generated
13240 for it as a combination of individual assignments and loops over the target
13241 object.  The declarations
13242
13243 @smallexample @c ada
13244        Cr_Var1 : One_Dim := (2, 5, 7, 11);
13245        Cr_Var2 : One_Dim := (others > -1);
13246 @end smallexample
13247
13248 @noindent
13249 generate the equivalent of
13250
13251 @smallexample @c ada
13252        Cr_Var1 (1) := 2;
13253        Cr_Var1 (2) := 3;
13254        Cr_Var1 (3) := 5;
13255        Cr_Var1 (4) := 11;
13256
13257        for I in Cr_Var2'range loop
13258           Cr_Var2 (I) := =-1;
13259        end loop;
13260 @end smallexample
13261
13262 @node Aggregates with non-static bounds
13263 @subsection Aggregates with non-static bounds
13264
13265 @noindent
13266 If the bounds of the aggregate are not statically compatible with the bounds
13267 of the nominal subtype  of the target, then constraint checks have to be
13268 generated on the bounds.  For a multidimensional array, constraint checks may
13269 have to be applied to sub-arrays individually, if they do not have statically
13270 compatible subtypes.
13271
13272 @node Aggregates in assignment statements
13273 @subsection Aggregates in assignment statements
13274
13275 @noindent
13276 In general, aggregate assignment requires the construction of a temporary,
13277 and a copy from the temporary to the target of the assignment.  This is because
13278 it is not always possible to convert the assignment into a series of individual
13279 component assignments.  For example, consider the simple case:
13280
13281 @smallexample @c ada
13282         A := (A(2), A(1));
13283 @end smallexample
13284
13285 @noindent
13286 This cannot be converted into:
13287
13288 @smallexample @c ada
13289         A(1) := A(2);
13290         A(2) := A(1);
13291 @end smallexample
13292
13293 @noindent
13294 So the aggregate has to be built first in a separate location, and then
13295 copied into the target.  GNAT recognizes simple cases where this intermediate
13296 step is not required, and the assignments can be performed in place, directly
13297 into the target.  The following sufficient criteria are applied:
13298
13299 @itemize @bullet
13300 @item
13301 The bounds of the aggregate are static, and the associations are static.
13302 @item
13303 The components of the aggregate are static constants, names of
13304 simple variables that are not renamings, or expressions not involving
13305 indexed components whose operands obey these rules.
13306 @end itemize
13307
13308 @noindent
13309 If any of these conditions are violated, the aggregate will be built in
13310 a temporary (created either by the front-end or the code generator) and then
13311 that temporary will be copied onto the target.
13312
13313 @node Project File Reference
13314 @chapter Project File Reference
13315
13316 @noindent
13317 This chapter describes the syntax and semantics of project files.
13318 Project files specify the options to be used when building a system.
13319 Project files can specify global settings for all tools,
13320 as well as tool-specific settings.
13321 See the chapter on project files in the GNAT Users guide for examples of use.
13322
13323 @menu
13324 * Reserved Words::
13325 * Lexical Elements::
13326 * Declarations::
13327 * Empty declarations::
13328 * Typed string declarations::
13329 * Variables::
13330 * Expressions::
13331 * Attributes::
13332 * Project Attributes::
13333 * Attribute References::
13334 * External Values::
13335 * Case Construction::
13336 * Packages::
13337 * Package Renamings::
13338 * Projects::
13339 * Project Extensions::
13340 * Project File Elaboration::
13341 @end menu
13342
13343 @node Reserved Words
13344 @section Reserved Words
13345
13346 @noindent
13347 All Ada95 reserved words are reserved in project files, and cannot be used
13348 as variable names or project names. In addition, the following are
13349 also reserved in project files:
13350
13351 @itemize
13352 @item @code{extends}
13353
13354 @item @code{external}
13355
13356 @item @code{project}
13357
13358 @end itemize
13359
13360 @node Lexical Elements
13361 @section Lexical Elements
13362
13363 @noindent
13364 Rules for identifiers are the same as in Ada95. Identifiers
13365 are case-insensitive.  Strings are case sensitive, except where noted.
13366 Comments have the same form as in Ada95.
13367
13368 @noindent
13369 Syntax:
13370
13371 @smallexample
13372 simple_name ::=
13373   identifier
13374
13375 name ::=
13376   simple_name @{. simple_name@}
13377 @end smallexample
13378
13379 @node Declarations
13380 @section Declarations
13381
13382 @noindent
13383 Declarations introduce new entities that denote types, variables, attributes,
13384 and packages. Some declarations can only appear immediately within a project
13385 declaration. Others can appear within a project or within a package.
13386
13387 Syntax:
13388 @smallexample
13389 declarative_item ::=
13390   simple_declarative_item |
13391   typed_string_declaration |
13392   package_declaration
13393
13394 simple_declarative_item ::=
13395   variable_declaration |
13396   typed_variable_declaration |
13397   attribute_declaration |
13398   case_construction |
13399   empty_declaration
13400 @end smallexample
13401
13402 @node Empty declarations
13403 @section Empty declarations
13404
13405 @smallexample
13406 empty_declaration ::=
13407   @b{null} ;
13408 @end smallexample
13409
13410 An empty declaration is allowed anywhere a declaration is allowed.
13411 It has no effect.
13412
13413 @node Typed string declarations
13414 @section Typed string declarations
13415
13416 @noindent
13417 Typed strings are sequences of string literals. Typed strings are the only
13418 named types in project files. They are used in case constructions, where they
13419 provide support for conditional attribute definitions.
13420
13421 Syntax:
13422 @smallexample
13423 typed_string_declaration ::=
13424   @b{type} <typed_string_>_simple_name @b{is}
13425    ( string_literal @{, string_literal@} );
13426 @end smallexample
13427
13428 @noindent
13429 A typed string declaration can only appear immediately within a project
13430 declaration.
13431
13432 All the string literals in a typed string declaration must be distinct.
13433
13434 @node Variables
13435 @section Variables
13436
13437 @noindent
13438 Variables denote values, and appear as constituents of expressions.
13439
13440 @smallexample
13441 typed_variable_declaration ::=
13442   <typed_variable_>simple_name : <typed_string_>name :=  string_expression ;
13443
13444 variable_declaration ::=
13445   <variable_>simple_name := expression;
13446 @end smallexample
13447
13448 @noindent
13449 The elaboration of a variable declaration introduces the variable and
13450 assigns to it the value of the expression. The name of the variable is
13451 available after the assignment symbol.
13452
13453 @noindent
13454 A typed_variable can only be declare once.
13455
13456 @noindent
13457 a non typed variable can be declared multiple times.
13458
13459 @noindent
13460 Before the completion of its first declaration, the value of variable
13461 is the null string.
13462
13463 @node Expressions
13464 @section Expressions
13465
13466 @noindent
13467 An expression is a formula that defines a computation or retrieval of a value.
13468 In a project file the value of an expression is either a string or a list
13469 of strings. A string value in an expression is either a literal, the current
13470 value of a variable, an external value, an attribute reference, or a
13471 concatenation operation.
13472
13473 Syntax:
13474
13475 @smallexample
13476 expression ::=
13477   term @{& term@}
13478
13479 term ::=
13480   string_literal |
13481   string_list |
13482   <variable_>name |
13483   external_value |
13484   attribute_reference
13485
13486 string_literal ::=
13487   (same as Ada)
13488
13489 string_list ::=
13490   ( <string_>expression @{ , <string_>expression @} )
13491 @end smallexample
13492
13493 @subsection Concatenation
13494 @noindent
13495 The following concatenation functions are defined:
13496
13497 @smallexample @c ada
13498   function "&" (X : String;      Y : String)      return String;
13499   function "&" (X : String_List; Y : String)      return String_List;
13500   function "&" (X : String_List; Y : String_List) return String_List;
13501 @end smallexample
13502
13503 @node Attributes
13504 @section Attributes
13505
13506 @noindent
13507 An attribute declaration defines a property of a project or package. This
13508 property can later be queried by means of an attribute reference.
13509 Attribute values are strings or string lists.
13510
13511 Some attributes are associative arrays. These attributes are mappings whose
13512 domain is a set of strings. These attributes are declared one association
13513 at a time, by specifying a point in the domain and the corresponding image
13514 of the attribute. They may also be declared as a full associative array,
13515 getting the same associations as the corresponding attribute in an imported
13516 or extended project.
13517
13518 Attributes that are not associative arrays are called simple attributes.
13519
13520 Syntax:
13521 @smallexample
13522 attribute_declaration ::=
13523   full_associative_array_declaration |
13524   @b{for} attribute_designator @b{use} expression ;
13525
13526 full_associative_array_declaration ::=
13527   @b{for} <associative_array_attribute_>simple_name @b{use}
13528   <project_>simple_name [ . <package_>simple_Name ] ' <attribute_>simple_name ;
13529
13530 attribute_designator ::=
13531   <simple_attribute_>simple_name |
13532   <associative_array_attribute_>simple_name ( string_literal )
13533 @end smallexample
13534
13535 @noindent
13536 Some attributes are project-specific, and can only appear immediately within
13537 a project declaration. Others are package-specific, and can only appear within
13538 the proper package.
13539
13540 The expression in an attribute definition must be a string or a string_list.
13541 The string literal appearing in the attribute_designator of an associative
13542 array attribute is case-insensitive.
13543
13544 @node Project Attributes
13545 @section Project Attributes
13546
13547 @noindent
13548 The following attributes apply to a project. All of them are simple
13549 attributes.
13550
13551 @table @code
13552 @item   Object_Dir
13553 Expression must be a path name. The attribute defines the
13554 directory in which the object files created by the build are to be placed. If
13555 not specified, object files are placed in the project directory.
13556
13557 @item   Exec_Dir
13558 Expression must be a path name. The attribute defines the
13559 directory in which the executables created by the build are to be placed.
13560 If not specified, executables are placed in the object directory.
13561
13562 @item  Source_Dirs
13563 Expression must be a list of path names. The attribute
13564 defines the directories in which the source files for the project are to be
13565 found. If not specified, source files are found in the project directory.
13566
13567 @item  Source_Files
13568 Expression must be a list of file names. The attribute
13569 defines the individual files, in the project directory, which are to be used
13570 as sources for the project. File names are path_names that contain no directory
13571 information. If the project has no sources the attribute must be declared
13572 explicitly with an empty list.
13573
13574 @item  Source_List_File
13575 Expression must a single path name. The attribute
13576 defines a text file that contains a list of source file names to be used
13577 as sources for the project
13578
13579 @item  Library_Dir
13580 Expression must be a path name. The attribute defines the
13581 directory in which a  library is to be built.  The directory must exist, must
13582 be distinct from the project's object directory, and must be writable.
13583
13584 @item  Library_Name
13585 Expression must be a string that is a legal file name,
13586 without extension. The attribute defines a string that is used to generate
13587 the name of the library to be built by the project.
13588
13589 @item  Library_Kind
13590 Argument must be a string value that must be one of the
13591 following @code{"static"}, @code{"dynamic"} or @code{"relocatable"}. This
13592 string is case-insensitive. If this attribute is not specified, the library is
13593 a static library. Otherwise, the library may be dynamic or relocatable. This
13594 distinction is operating-system dependent.
13595
13596 @item  Library_Version
13597 Expression must be a string value whose interpretation
13598 is platform dependent. On UNIX, it is used only for dynamic/relocatable
13599 libraries as the internal name of the library (the @code{"soname"}). If the
13600 library file name (built from the @code{Library_Name}) is different from the
13601 @code{Library_Version}, then the library file will be a symbolic link to the
13602 actual file whose name will be @code{Library_Version}.
13603
13604 @item Library_Interface
13605 Expression must be a string list. Each element of the string list
13606 must designate a unit of the project.
13607 If this attribute is present in a Library Project File, then the project
13608 file is a Stand-alone Library_Project_File.
13609
13610 @item Library_Auto_Init
13611 Expression must be a single string "true" or "false", case-insensitive.
13612 If this attribute is present in a Stand-alone Library Project File,
13613 it indicates if initialization is automatic when the dynamic library
13614 is loaded.
13615
13616 @item Library_Options
13617 Expression must be a string list. Indicates additional switches that
13618 are to be used when building a shared library.
13619
13620 @item Library_GCC
13621 Expression must be a single string. Designates an alternative to "gcc"
13622 for building shared libraries.
13623
13624 @item  Library_Src_Dir
13625 Expression must be a path name. The attribute defines the
13626 directory in which the sources of the interfaces of a Stand-alone Library will
13627 be copied.  The directory must exist, must be distinct from the project's
13628 object directory and source directories, and must be writable.
13629
13630 @item  Main
13631 Expression must be a list of strings that are legal file names.
13632 These file names designate existing compilation units in the source directory
13633 that are legal main subprograms.
13634
13635 When a project file is elaborated, as part of the execution of a gnatmake
13636 command, one or several executables are built and placed in the Exec_Dir.
13637 If the gnatmake command does not include explicit file names, the executables
13638 that are built correspond to the files specified by this attribute.
13639
13640 @item Main_Language
13641 This is a simple attribute. Its value is a string that specifies the
13642 language of the main program.
13643
13644 @item  Languages
13645 Expression must be a string list. Each string designates
13646 a programming language that is known to GNAT. The strings are case-insensitive.
13647
13648 @item  Locally_Removed_Files
13649 This attribute is legal only in a project file that extends another.
13650 Expression must be a list of strings that are legal file names.
13651 Each file name must designate a source that would normally be inherited
13652 by the current project file. It cannot designate an immediate source that is
13653 not inherited. Each of the source files in the list are not considered to
13654 be sources of the project file: they are not inherited.
13655 @end table
13656
13657 @node Attribute References
13658 @section Attribute References
13659
13660 @noindent
13661 Attribute references are used to retrieve the value of previously defined
13662 attribute for a package or project.
13663 Syntax:
13664 @smallexample
13665 attribute_reference ::=
13666   attribute_prefix ' <simple_attribute_>simple_name [ ( string_literal ) ]
13667
13668 attribute_prefix ::=
13669   @b{project} |
13670   <project_simple_name | package_identifier |
13671   <project_>simple_name . package_identifier
13672 @end smallexample
13673
13674 @noindent
13675 If an attribute has not been specified for a given package or project, its
13676 value is the null string or the empty list.
13677
13678 @node External Values
13679 @section External Values
13680
13681 @noindent
13682 An external value is an expression whose value is obtained from the command
13683 that invoked the processing of the current project file (typically a
13684 gnatmake command).
13685
13686 Syntax:
13687 @smallexample
13688 external_value ::=
13689   @b{external} ( string_literal [, string_literal] )
13690 @end smallexample
13691
13692 @noindent
13693 The first string_literal is the string to be used on the command line or
13694 in the environment to specify the external value. The second string_literal,
13695 if present, is the default to use if there is no specification for this
13696 external value either on the command line or in the environment.
13697
13698 @node Case Construction
13699 @section Case Construction
13700
13701 @noindent
13702 A case construction supports attribute declarations that depend on the value of
13703 a previously declared variable.
13704
13705 Syntax:
13706 @smallexample
13707 case_construction ::=
13708   @b{case} <typed_variable_>name @b{is}
13709     @{case_item@}
13710   @b{end case} ;
13711
13712 case_item ::=
13713   @b{when} discrete_choice_list =>
13714     @{case_construction | attribute_declaration | empty_declaration@}
13715
13716 discrete_choice_list ::=
13717   string_literal @{| string_literal@} |
13718     @b{others}
13719 @end smallexample
13720
13721 @noindent
13722 All choices in a choice list must be distinct. The choice lists of two
13723 distinct alternatives must be disjoint. Unlike Ada, the choice lists of all
13724 alternatives do not need to include all values of the type. An @code{others}
13725 choice must appear last in the list of alternatives.
13726
13727 @node Packages
13728 @section Packages
13729
13730 @noindent
13731 A package provides a grouping of variable declarations and attribute
13732 declarations to be used when invoking various GNAT tools. The name of
13733 the package indicates the tool(s) to which it applies.
13734 Syntax:
13735
13736 @smallexample
13737 package_declaration ::=
13738   package_specification | package_renaming
13739
13740 package_specification ::=
13741   @b{package} package_identifier @b{is}
13742     @{simple_declarative_item@}
13743   @b{end} package_identifier ;
13744
13745 package_identifier ::=
13746   @code{Naming} | @code{Builder} | @code{Compiler} | @code{Binder} |
13747   @code{Linker} | @code{Finder}  | @code{Cross_Reference} |
13748   @code{gnatls} | @code{IDE}     | @code{Pretty_Printer}
13749 @end smallexample
13750
13751 @subsection Package Naming
13752
13753 @noindent
13754 The attributes of a @code{Naming} package specifies the naming conventions
13755 that apply to the source files in a project. When invoking other GNAT tools,
13756 they will use the sources in the source directories that satisfy these
13757 naming conventions.
13758
13759 The following attributes apply to a @code{Naming} package:
13760
13761 @table @code
13762 @item Casing
13763 This is a simple attribute whose value is a string. Legal values of this
13764 string are @code{"lowercase"}, @code{"uppercase"} or @code{"mixedcase"}.
13765 These strings are themselves case insensitive.
13766
13767 @noindent
13768 If @code{Casing} is not specified, then the default is @code{"lowercase"}.
13769
13770 @item Dot_Replacement
13771 This is a simple attribute whose string value satisfies the following
13772 requirements:
13773
13774 @itemize @bullet
13775 @item It must not be empty
13776 @item It cannot start or end with an alphanumeric character
13777 @item It cannot be a single underscore
13778 @item It cannot start with an underscore followed by an alphanumeric
13779 @item It cannot contain a dot @code{'.'} if longer than one character
13780 @end itemize
13781
13782 @noindent
13783 If @code{Dot_Replacement} is not specified, then the default is @code{"-"}.
13784
13785 @item Spec_Suffix
13786 This is an associative array attribute, defined on language names,
13787 whose image is a string that must satisfy the following
13788 conditions:
13789
13790 @itemize @bullet
13791 @item It must not be empty
13792 @item It cannot start with an alphanumeric character
13793 @item It cannot start with an underscore followed by an alphanumeric character
13794 @end itemize
13795
13796 @noindent
13797 For Ada, the attribute denotes the suffix used in file names that contain
13798 library unit declarations, that is to say units that are package and
13799 subprogram declarations. If @code{Spec_Suffix ("Ada")} is not
13800 specified, then the default is @code{".ads"}.
13801
13802 For C and C++, the attribute denotes the suffix used in file names that
13803 contain prototypes.
13804
13805 @item Body_Suffix
13806 This is an associative array attribute defined on language names,
13807 whose image is a string that must satisfy the following
13808 conditions:
13809
13810 @itemize @bullet
13811 @item It must not be empty
13812 @item It cannot start with an alphanumeric character
13813 @item It cannot start with an underscore followed by an alphanumeric character
13814 @item It cannot be a suffix of @code{Spec_Suffix}
13815 @end itemize
13816
13817 @noindent
13818 For Ada, the attribute denotes the suffix used in file names that contain
13819 library bodies, that is to say units that are package and subprogram bodies.
13820 If @code{Body_Suffix ("Ada")} is not specified, then the default is
13821 @code{".adb"}.
13822
13823 For C and C++, the attribute denotes the suffix used in file names that contain
13824 source code.
13825
13826 @item Separate_Suffix
13827 This is a simple attribute whose value satisfies the same conditions as
13828 @code{Body_Suffix}.
13829
13830 This attribute is specific to Ada. It denotes the suffix used in file names
13831 that contain separate bodies. If it is not specified, then it defaults to same
13832 value as @code{Body_Suffix ("Ada")}.
13833
13834 @item Spec
13835 This is an associative array attribute, specific to Ada, defined over
13836 compilation unit names. The image is a string that is the name of the file
13837 that contains that library unit. The file name is case sensitive if the
13838 conventions of the host operating system require it.
13839
13840 @item Body
13841 This is an associative array attribute, specific to Ada, defined over
13842 compilation unit names. The image is a string that is the name of the file
13843 that contains the library unit body for the named unit. The file name is case
13844 sensitive if the conventions of the host operating system require it.
13845
13846 @item Specification_Exceptions
13847 This is an associative array attribute defined on language names,
13848 whose value is a list of strings.
13849
13850 This attribute is not significant for Ada.
13851
13852 For C and C++, each string in the list denotes the name of a file that
13853 contains prototypes, but whose suffix is not necessarily the
13854 @code{Spec_Suffix} for the language.
13855
13856 @item Implementation_Exceptions
13857 This is an associative array attribute defined on language names,
13858 whose value is a list of strings.
13859
13860 This attribute is not significant for Ada.
13861
13862 For C and C++, each string in the list denotes the name of a file that
13863 contains source code, but whose suffix is not necessarily the
13864 @code{Body_Suffix} for the language.
13865 @end table
13866
13867 The following attributes of package @code{Naming} are obsolescent. They are
13868 kept as synonyms of other attributes for compatibility with previous versions
13869 of the Project Manager.
13870
13871 @table @code
13872 @item Specification_Suffix
13873 This is a synonym of @code{Spec_Suffix}.
13874
13875 @item Implementation_Suffix
13876 This is a synonym of @code{Body_Suffix}.
13877
13878 @item Specification
13879 This is a synonym of @code{Spec}.
13880
13881 @item Implementation
13882 This is a synonym of @code{Body}.
13883 @end table
13884
13885 @subsection package Compiler
13886
13887 @noindent
13888 The attributes of the @code{Compiler} package specify the compilation options
13889 to be used by the underlying compiler.
13890
13891 @table @code
13892 @item  Default_Switches
13893 This is an associative array attribute. Its
13894 domain is a set of language names. Its range is a string list that
13895 specifies the compilation options to be used when compiling a component
13896 written in that language, for which no file-specific switches have been
13897 specified..
13898
13899 @item  Switches
13900 This is an associative array attribute. Its domain is
13901 a set of file names. Its range is a string list that specifies the
13902 compilation options to be used when compiling the named file. If a file
13903 is not specified in the Switches attribute, it is compiled with the
13904 settings specified by Default_Switches.
13905
13906 @item  Local_Configuration_Pragmas.
13907 This is a simple attribute, whose
13908 value is a path name that designates a file containing configuration pragmas
13909 to be used for all invocations of the compiler for immediate sources of the
13910 project.
13911
13912 @item Executable
13913 This is an associative array attribute. Its domain is
13914 a set of main source file names. Its range is a simple string that specifies
13915 the executable file name to be used when linking the specified main source.
13916 If a main source is not specified in the Executable attribute, the executable
13917 file name is deducted from the main source file name.
13918 @end table
13919
13920 @subsection package Builder
13921
13922 @noindent
13923 The attributes of package @code{Builder} specify the compilation, binding, and
13924 linking options to be used when building an executable for a project. The
13925 following attributes apply to package @code{Builder}:
13926
13927 @table @code
13928 @item Default_Switches
13929 As above.
13930
13931 @item Switches
13932 As above.
13933
13934 @item Global_Configuration_Pragmas
13935 This is a simple attribute, whose
13936 value is a path name that designates a file that contains configuration pragmas
13937 to be used in every build of an executable. If both local and global
13938 configuration pragmas are specified, a compilation makes use of both sets.
13939
13940 @item Executable
13941 This is an associative array attribute, defined over
13942 compilation unit names. The image is a string that is the name of the
13943 executable file corresponding to the main source file index.
13944 This attribute has no effect if its value is the empty string.
13945
13946 @item Executable_Suffix
13947 This is a simple attribute whose value is a suffix to be added to
13948 the executables that don't have an attribute Executable specified.
13949 @end table
13950
13951 @subsection package Gnatls
13952
13953 @noindent
13954 The attributes of package @code{Gnatls} specify the tool options to be used
13955 when invoking the library browser @command{gnatls}.
13956 The following attributes apply to package @code{Gnatls}:
13957
13958 @table @code
13959 @item Switches
13960 As above.
13961 @end table
13962
13963 @subsection package Binder
13964
13965 @noindent
13966 The attributes of package @code{Binder} specify the options to be used
13967 when invoking the binder in the construction of an executable.
13968 The following attributes apply to package @code{Binder}:
13969
13970 @table @code
13971 @item     Default_Switches
13972 As above.
13973 @item     Switches
13974 As above.
13975 @end table
13976
13977 @subsection package Linker
13978
13979 @noindent
13980 The attributes of package @code{Linker} specify the options to be used when
13981 invoking the linker in the construction of an executable.
13982 The following attributes apply to package @code{Linker}:
13983
13984 @table @code
13985 @item     Default_Switches
13986 As above
13987 @item     Switches
13988 As above.
13989 @end table
13990
13991 @subsection package Cross_Reference
13992
13993 @noindent
13994 The attributes of package @code{Cross_Reference} specify the tool options
13995 to be used
13996 when invoking the library tool @command{gnatxref}.
13997 The following attributes apply to package @code{Cross_Reference}:
13998
13999 @table @code
14000 @item     Default_Switches
14001 As above.
14002 @item     Switches
14003 As above.
14004 @end table
14005
14006 @subsection package   Finder
14007
14008 @noindent
14009 The attributes of package @code{Finder} specify the tool options to be used
14010 when invoking the search tool @command{gnatfind}.
14011 The following attributes apply to package @code{Finder}:
14012
14013 @table @code
14014 @item     Default_Switches
14015 As above.
14016 @item     Switches
14017 As above.
14018 @end table
14019
14020 @subsection package Pretty_Printer
14021
14022 @noindent
14023 The attributes of package @code{Pretty_Printer}
14024 specify the tool options to be used
14025 when invoking the formatting tool @command{gnatpp}.
14026 The following attributes apply to package @code{Pretty_Printer}:
14027
14028 @table @code
14029 @item     Default_switches
14030 As above.
14031 @item     Switches
14032 As above.
14033 @end table
14034
14035 @subsection  package IDE
14036
14037 @noindent
14038 The attributes of package @code{IDE} specify the options to be used when using
14039 an Integrated Development Environment such as @command{GPS}.
14040
14041 @table @code
14042 @item Remote_Host
14043 This is a simple attribute. Its value is a string that designates the remote
14044 host in a cross-compilation environment, to be used for remote compilation and
14045 debugging. This field should not be specified when running on the local
14046 machine.
14047
14048 @item Program_Host
14049 This is a simple attribute. Its value is a string that specifies the
14050 name of IP address of the embedded target in a cross-compilation environment,
14051 on which the program should execute.
14052
14053 @item Communication_Protocol
14054 This is a simple string attribute. Its value is the name of the protocol
14055 to use to communicate with the target in a cross-compilation environment,
14056 e.g. @code{"wtx"} or @code{"vxworks"}.
14057
14058 @item Compiler_Command
14059 This is an associative array attribute, whose domain is a language name. Its
14060 value is  string that denotes the command to be used to invoke the compiler.
14061 The value of @code{Compiler_Command ("Ada")} is expected to be compatible with
14062 gnatmake, in particular in the handling of switches.
14063
14064 @item Debugger_Command
14065 This is simple attribute, Its value is a string that specifies the name of
14066 the debugger to be used, such as gdb, powerpc-wrs-vxworks-gdb or gdb-4.
14067
14068 @item Default_Switches
14069 This is an associative array attribute. Its indexes are the name of the
14070 external tools that the GNAT Programming System (GPS) is supporting. Its
14071 value is a list of switches to use when invoking that tool.
14072
14073 @item  Gnatlist
14074 This is a simple attribute.  Its value is a string that specifies the name
14075 of the @command{gnatls} utility to be used to retrieve information about the
14076 predefined path; e.g., @code{"gnatls"}, @code{"powerpc-wrs-vxworks-gnatls"}.
14077
14078 @item VCS_Kind
14079 This is a simple atribute. Is value is a string used to specify the
14080 Version Control System (VCS) to be used for this project, e.g CVS, RCS
14081 ClearCase or Perforce.
14082
14083 @item VCS_File_Check
14084 This is a simple attribute. Its value is a string that specifies the
14085 command used by the VCS to check the validity of a file, either
14086 when the user explicitly asks for a check, or as a sanity check before
14087 doing the check-in.
14088
14089 @item VCS_Log_Check
14090 This is a simple attribute. Its value is a string that specifies
14091 the command used by the VCS to check the validity of a log file.
14092
14093 @end table
14094
14095 @node Package Renamings
14096 @section Package Renamings
14097
14098 @noindent
14099 A package can be defined by a renaming declaration. The new package renames
14100 a package declared in a different project file, and has the same attributes
14101 as the package it renames.
14102 Syntax:
14103 @smallexample
14104 package_renaming ::==
14105   @b{package} package_identifier @b{renames}
14106        <project_>simple_name.package_identifier ;
14107 @end smallexample
14108
14109 @noindent
14110 The package_identifier of the renamed package must be the same as the
14111 package_identifier. The project whose name is the prefix of the renamed
14112 package must contain a package declaration with this name. This project
14113 must appear in the context_clause of the enclosing project declaration,
14114 or be the parent project of the enclosing child project.
14115
14116 @node Projects
14117 @section Projects
14118
14119 @noindent
14120 A project file specifies a set of rules for constructing a software system.
14121 A project file can be self-contained, or depend on other project files.
14122 Dependencies are expressed through a context clause that names other projects.
14123
14124 Syntax:
14125
14126 @smallexample
14127 project ::=
14128   context_clause project_declaration
14129
14130 project_declaration ::=
14131   simple_project_declaration | project_extension
14132
14133 simple_project_declaration ::=
14134   @b{project} <project_>simple_name @b{is}
14135     @{declarative_item@}
14136   @b{end} <project_>simple_name;
14137
14138 context_clause ::=
14139   @{with_clause@}
14140
14141 with_clause ::=
14142   [@b{limited}] @b{with} path_name @{ , path_name @} ;
14143
14144 path_name ::=
14145    string_literal
14146 @end smallexample
14147
14148 @noindent
14149 A path name denotes a project file. A path name can be absolute or relative.
14150 An absolute path name includes a sequence of directories, in the syntax of
14151 the host operating system, that identifies uniquely the project file in the
14152 file system. A relative path name identifies the project file, relative
14153 to the directory that contains the current project, or relative to a
14154 directory listed in the environment variable ADA_PROJECT_PATH.
14155 Path names are case sensitive if file names in the host operating system
14156 are case sensitive.
14157
14158 The syntax of the environment variable ADA_PROJECT_PATH is a list of
14159 directory names separated by colons (semicolons on Windows).
14160
14161 A given project name can appear only once in a context_clause.
14162
14163 It is illegal for a project imported by a context clause to refer, directly
14164 or indirectly, to the project in which this context clause appears (the
14165 dependency graph cannot contain cycles), except when one of the with_clause
14166 in the cycle is a @code{limited with}.
14167
14168 @node Project Extensions
14169 @section Project Extensions
14170
14171 @noindent
14172 A project extension introduces a new project, which inherits the declarations
14173 of another project.
14174 Syntax:
14175 @smallexample
14176
14177 project_extension ::=
14178   @b{project} <project_>simple_name  @b{extends} path_name @b{is}
14179     @{declarative_item@}
14180   @b{end} <project_>simple_name;
14181 @end smallexample
14182
14183 @noindent
14184 The project extension declares a child project. The child project inherits
14185 all the declarations and all the files of the parent project, These inherited
14186 declaration can be overridden in the child project, by means of suitable
14187 declarations.
14188
14189 @node Project File Elaboration
14190 @section Project File Elaboration
14191
14192 @noindent
14193 A project file is processed as part of the invocation of a gnat tool that
14194 uses the project option. Elaboration of the process file consists in the
14195 sequential elaboration of all its declarations. The computed values of
14196 attributes and variables in the project are then used to establish the
14197 environment in which the gnat tool will execute.
14198
14199 @include fdl.texi
14200 @c GNU Free Documentation License
14201
14202 @node Index,,GNU Free Documentation License, Top
14203 @unnumbered Index
14204
14205 @printindex cp
14206
14207 @contents
14208
14209 @bye