OSDN Git Service

2004-05-27 Vincent Celier <celier@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_Discriminants::
206 * Img::
207 * Integer_Value::
208 * Large::
209 * Machine_Size::
210 * Mantissa::
211 * Max_Interrupt_Priority::
212 * Max_Priority::
213 * Maximum_Alignment::
214 * Mechanism_Code::
215 * Null_Parameter::
216 * Object_Size::
217 * Passed_By_Reference::
218 * Range_Length::
219 * Safe_Emax::
220 * Safe_Large::
221 * Small::
222 * Storage_Unit::
223 * Target_Name::
224 * Tick::
225 * To_Address::
226 * Type_Class::
227 * UET_Address::
228 * Unconstrained_Array::
229 * Universal_Literal_String::
230 * Unrestricted_Access::
231 * VADS_Size::
232 * Value_Size::
233 * Wchar_T_Size::
234 * Word_Size::
235
236 The Implementation of Standard I/O
237
238 * Standard I/O Packages::
239 * FORM Strings::
240 * Direct_IO::
241 * Sequential_IO::
242 * Text_IO::
243 * Wide_Text_IO::
244 * Stream_IO::
245 * Shared Files::
246 * Open Modes::
247 * Operations on C Streams::
248 * Interfacing to C Streams::
249
250 The GNAT Library
251
252 * Ada.Characters.Latin_9 (a-chlat9.ads)::
253 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
254 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
255 * Ada.Command_Line.Remove (a-colire.ads)::
256 * Ada.Command_Line.Environment (a-colien.ads)::
257 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
258 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
259 * Ada.Exceptions.Traceback (a-exctra.ads)::
260 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
261 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
262 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
263 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
264 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
265 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
266 * GNAT.Array_Split (g-arrspl.ads)::
267 * GNAT.AWK (g-awk.ads)::
268 * GNAT.Bounded_Buffers (g-boubuf.ads)::
269 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
270 * GNAT.Bubble_Sort (g-bubsor.ads)::
271 * GNAT.Bubble_Sort_A (g-busora.ads)::
272 * GNAT.Bubble_Sort_G (g-busorg.ads)::
273 * GNAT.Calendar (g-calend.ads)::
274 * GNAT.Calendar.Time_IO (g-catiio.ads)::
275 * GNAT.Case_Util (g-casuti.ads)::
276 * GNAT.CGI (g-cgi.ads)::
277 * GNAT.CGI.Cookie (g-cgicoo.ads)::
278 * GNAT.CGI.Debug (g-cgideb.ads)::
279 * GNAT.Command_Line (g-comlin.ads)::
280 * GNAT.Compiler_Version (g-comver.ads)::
281 * GNAT.Ctrl_C (g-ctrl_c.ads)::
282 * GNAT.CRC32 (g-crc32.ads)::
283 * GNAT.Current_Exception (g-curexc.ads)::
284 * GNAT.Debug_Pools (g-debpoo.ads)::
285 * GNAT.Debug_Utilities (g-debuti.ads)::
286 * GNAT.Directory_Operations (g-dirope.ads)::
287 * GNAT.Dynamic_HTables (g-dynhta.ads)::
288 * GNAT.Dynamic_Tables (g-dyntab.ads)::
289 * GNAT.Exception_Actions (g-excact.ads)::
290 * GNAT.Exception_Traces (g-exctra.ads)::
291 * GNAT.Exceptions (g-except.ads)::
292 * GNAT.Expect (g-expect.ads)::
293 * GNAT.Float_Control (g-flocon.ads)::
294 * GNAT.Heap_Sort (g-heasor.ads)::
295 * GNAT.Heap_Sort_A (g-hesora.ads)::
296 * GNAT.Heap_Sort_G (g-hesorg.ads)::
297 * GNAT.HTable (g-htable.ads)::
298 * GNAT.IO (g-io.ads)::
299 * GNAT.IO_Aux (g-io_aux.ads)::
300 * GNAT.Lock_Files (g-locfil.ads)::
301 * GNAT.MD5 (g-md5.ads)::
302 * GNAT.Memory_Dump (g-memdum.ads)::
303 * GNAT.Most_Recent_Exception (g-moreex.ads)::
304 * GNAT.OS_Lib (g-os_lib.ads)::
305 * GNAT.Perfect_Hash.Generators (g-pehage.ads)::
306 * GNAT.Regexp (g-regexp.ads)::
307 * GNAT.Registry (g-regist.ads)::
308 * GNAT.Regpat (g-regpat.ads)::
309 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
310 * GNAT.Semaphores (g-semaph.ads)::
311 * GNAT.Signals (g-signal.ads)::
312 * GNAT.Sockets (g-socket.ads)::
313 * GNAT.Source_Info (g-souinf.ads)::
314 * GNAT.Spell_Checker (g-speche.ads)::
315 * GNAT.Spitbol.Patterns (g-spipat.ads)::
316 * GNAT.Spitbol (g-spitbo.ads)::
317 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
318 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
319 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
320 * GNAT.Strings (g-string.ads)::
321 * GNAT.String_Split (g-strspl.ads)::
322 * GNAT.Table (g-table.ads)::
323 * GNAT.Task_Lock (g-tasloc.ads)::
324 * GNAT.Threads (g-thread.ads)::
325 * GNAT.Traceback (g-traceb.ads)::
326 * GNAT.Traceback.Symbolic (g-trasym.ads)::
327 * GNAT.Wide_String_Split (g-wistsp.ads)::
328 * Interfaces.C.Extensions (i-cexten.ads)::
329 * Interfaces.C.Streams (i-cstrea.ads)::
330 * Interfaces.CPP (i-cpp.ads)::
331 * Interfaces.Os2lib (i-os2lib.ads)::
332 * Interfaces.Os2lib.Errors (i-os2err.ads)::
333 * Interfaces.Os2lib.Synchronization (i-os2syn.ads)::
334 * Interfaces.Os2lib.Threads (i-os2thr.ads)::
335 * Interfaces.Packed_Decimal (i-pacdec.ads)::
336 * Interfaces.VxWorks (i-vxwork.ads)::
337 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
338 * System.Address_Image (s-addima.ads)::
339 * System.Assertions (s-assert.ads)::
340 * System.Memory (s-memory.ads)::
341 * System.Partition_Interface (s-parint.ads)::
342 * System.Restrictions (s-restri.ads)::
343 * System.Rident (s-rident.ads)::
344 * System.Task_Info (s-tasinf.ads)::
345 * System.Wch_Cnv (s-wchcnv.ads)::
346 * System.Wch_Con (s-wchcon.ads)::
347
348 Text_IO
349
350 * Text_IO Stream Pointer Positioning::
351 * Text_IO Reading and Writing Non-Regular Files::
352 * Get_Immediate::
353 * Treating Text_IO Files as Streams::
354 * Text_IO Extensions::
355 * Text_IO Facilities for Unbounded Strings::
356
357 Wide_Text_IO
358
359 * Wide_Text_IO Stream Pointer Positioning::
360 * Wide_Text_IO Reading and Writing Non-Regular Files::
361
362 Interfacing to Other Languages
363
364 * Interfacing to C::
365 * Interfacing to C++::
366 * Interfacing to COBOL::
367 * Interfacing to Fortran::
368 * Interfacing to non-GNAT Ada code::
369
370 Specialized Needs Annexes
371
372 Implementation of Specific Ada Features
373 * Machine Code Insertions::
374 * GNAT Implementation of Tasking::
375 * GNAT Implementation of Shared Passive Packages::
376 * Code Generation for Array Aggregates::
377
378 Project File Reference
379
380 GNU Free Documentation License
381
382 Index
383 @end menu
384
385 @end ifnottex
386
387 @node About This Guide
388 @unnumbered About This Guide
389
390 @noindent
391 This manual contains useful information in writing programs using the
392 GNAT compiler.  It includes information on implementation dependent
393 characteristics of GNAT, including all the information required by Annex
394 M of the standard.
395
396 Ada 95 is designed to be highly portable.
397 In general, a program will have the same effect even when compiled by
398 different compilers on different platforms.
399 However, since Ada 95 is designed to be used in a
400 wide variety of applications, it also contains a number of system
401 dependent features to be used in interfacing to the external world.
402 @cindex Implementation-dependent features
403 @cindex Portability
404
405 Note: Any program that makes use of implementation-dependent features
406 may be non-portable.  You should follow good programming practice and
407 isolate and clearly document any sections of your program that make use
408 of these features in a non-portable manner.
409
410 @menu
411 * What This Reference Manual Contains::
412 * Conventions::
413 * Related Information::
414 @end menu
415
416 @node What This Reference Manual Contains
417 @unnumberedsec What This Reference Manual Contains
418
419 @noindent
420 This reference manual contains the following chapters:
421
422 @itemize @bullet
423 @item
424 @ref{Implementation Defined Pragmas}, lists GNAT implementation-dependent
425 pragmas, which can be used to extend and enhance the functionality of the
426 compiler.
427
428 @item
429 @ref{Implementation Defined Attributes}, lists GNAT
430 implementation-dependent attributes which can be used to extend and
431 enhance the functionality of the compiler.
432
433 @item
434 @ref{Implementation Advice}, provides information on generally
435 desirable behavior which are not requirements that all compilers must
436 follow since it cannot be provided on all systems, or which may be
437 undesirable on some systems.
438
439 @item
440 @ref{Implementation Defined Characteristics}, provides a guide to
441 minimizing implementation dependent features.
442
443 @item
444 @ref{Intrinsic Subprograms}, describes the intrinsic subprograms
445 implemented by GNAT, and how they can be imported into user
446 application programs.
447
448 @item
449 @ref{Representation Clauses and Pragmas}, describes in detail the
450 way that GNAT represents data, and in particular the exact set
451 of representation clauses and pragmas that is accepted.
452
453 @item
454 @ref{Standard Library Routines}, provides a listing of packages and a
455 brief description of the functionality that is provided by Ada's
456 extensive set of standard library routines as implemented by GNAT@.
457
458 @item
459 @ref{The Implementation of Standard I/O}, details how the GNAT
460 implementation of the input-output facilities.
461
462 @item
463 @ref{The GNAT Library}, is a catalog of packages that complement
464 the Ada predefined library.
465
466 @item
467 @ref{Interfacing to Other Languages}, describes how programs
468 written in Ada using GNAT can be interfaced to other programming
469 languages.
470
471 @ref{Specialized Needs Annexes}, describes the GNAT implementation of all
472 of the specialized needs annexes.
473
474 @item
475 @ref{Implementation of Specific Ada Features}, discusses issues related
476 to GNAT's implementation of machine code insertions, tasking, and several
477 other features.
478
479 @item
480 @ref{Project File Reference}, presents the syntax and semantics
481 of project files.
482
483 @end itemize
484
485 @cindex Ada 95 ISO/ANSI Standard
486 @noindent
487 This reference manual assumes that you are familiar with Ada 95
488 language, as described in the International Standard
489 ANSI/ISO/IEC-8652:1995, Jan 1995.
490
491 @node Conventions
492 @unnumberedsec Conventions
493 @cindex Conventions, typographical
494 @cindex Typographical conventions
495
496 @noindent
497 Following are examples of the typographical and graphic conventions used
498 in this guide:
499
500 @itemize @bullet
501 @item
502 @code{Functions}, @code{utility program names}, @code{standard names},
503 and @code{classes}.
504
505 @item
506 @code{Option flags}
507
508 @item
509 @file{File Names}, @samp{button names}, and @samp{field names}.
510
511 @item
512 @code{Variables}.
513
514 @item
515 @emph{Emphasis}.
516
517 @item
518 [optional information or parameters]
519
520 @item
521 Examples are described by text
522 @smallexample
523 and then shown this way.
524 @end smallexample
525 @end itemize
526
527 @noindent
528 Commands that are entered by the user are preceded in this manual by the
529 characters @samp{$ } (dollar sign followed by space).  If your system uses this
530 sequence as a prompt, then the commands will appear exactly as you see them
531 in the manual.  If your system uses some other prompt, then the command will
532 appear with the @samp{$} replaced by whatever prompt character you are using.
533
534 @node Related Information
535 @unnumberedsec Related Information
536 @noindent
537 See the following documents for further information on GNAT:
538
539 @itemize @bullet
540 @item
541 @cite{GNAT User's Guide}, which provides information on how to use
542 the GNAT compiler system.
543
544 @item
545 @cite{Ada 95 Reference Manual}, which contains all reference
546 material for the Ada 95 programming language.
547
548 @item
549 @cite{Ada 95 Annotated Reference Manual}, which is an annotated version
550 of the standard reference manual cited above.  The annotations describe
551 detailed aspects of the design decision, and in particular contain useful
552 sections on Ada 83 compatibility.
553
554 @item
555 @cite{DEC Ada, Technical Overview and Comparison on DIGITAL Platforms},
556 which contains specific information on compatibility between GNAT and
557 DEC Ada 83 systems.
558
559 @item
560 @cite{DEC Ada, Language Reference Manual, part number AA-PYZAB-TK} which
561 describes in detail the pragmas and attributes provided by the DEC Ada 83
562 compiler system.
563
564 @end itemize
565
566 @node Implementation Defined Pragmas
567 @chapter Implementation Defined Pragmas
568
569 @noindent
570 Ada 95 defines a set of pragmas that can be used to supply additional
571 information to the compiler.  These language defined pragmas are
572 implemented in GNAT and work as described in the Ada 95 Reference
573 Manual.
574
575 In addition, Ada 95 allows implementations to define additional pragmas
576 whose meaning is defined by the implementation.  GNAT provides a number
577 of these implementation-dependent pragmas which can be used to extend
578 and enhance the functionality of the compiler.  This section of the GNAT
579 Reference Manual describes these additional pragmas.
580
581 Note that any program using these pragmas may not be portable to other
582 compilers (although GNAT implements this set of pragmas on all
583 platforms).  Therefore if portability to other compilers is an important
584 consideration, the use of these pragmas should be minimized.
585
586 @menu
587 * Pragma Abort_Defer::
588 * Pragma Ada_83::
589 * Pragma Ada_95::
590 * Pragma Annotate::
591 * Pragma Assert::
592 * Pragma Ast_Entry::
593 * Pragma C_Pass_By_Copy::
594 * Pragma Comment::
595 * Pragma Common_Object::
596 * Pragma Compile_Time_Warning::
597 * Pragma Complex_Representation::
598 * Pragma Component_Alignment::
599 * Pragma Convention_Identifier::
600 * Pragma CPP_Class::
601 * Pragma CPP_Constructor::
602 * Pragma CPP_Virtual::
603 * Pragma CPP_Vtable::
604 * Pragma Debug::
605 * Pragma Elaboration_Checks::
606 * Pragma Eliminate::
607 * Pragma Export_Exception::
608 * Pragma Export_Function::
609 * Pragma Export_Object::
610 * Pragma Export_Procedure::
611 * Pragma Export_Value::
612 * Pragma Export_Valued_Procedure::
613 * Pragma Extend_System::
614 * Pragma External::
615 * Pragma External_Name_Casing::
616 * Pragma Finalize_Storage_Only::
617 * Pragma Float_Representation::
618 * Pragma Ident::
619 * Pragma Import_Exception::
620 * Pragma Import_Function::
621 * Pragma Import_Object::
622 * Pragma Import_Procedure::
623 * Pragma Import_Valued_Procedure::
624 * Pragma Initialize_Scalars::
625 * Pragma Inline_Always::
626 * Pragma Inline_Generic::
627 * Pragma Interface::
628 * Pragma Interface_Name::
629 * Pragma Interrupt_Handler::
630 * Pragma Interrupt_State::
631 * Pragma Keep_Names::
632 * Pragma License::
633 * Pragma Link_With::
634 * Pragma Linker_Alias::
635 * Pragma Linker_Section::
636 * Pragma Long_Float::
637 * Pragma Machine_Attribute::
638 * Pragma Main_Storage::
639 * Pragma No_Return::
640 * Pragma Normalize_Scalars::
641 * Pragma Obsolescent::
642 * Pragma Passive::
643 * Pragma Polling::
644 * Pragma Profile (Ravenscar)::
645 * Pragma Propagate_Exceptions::
646 * Pragma Psect_Object::
647 * Pragma Pure_Function::
648 * Pragma Restricted_Run_Time::
649 * Pragma Restriction_Warnings::
650 * Pragma Source_File_Name::
651 * Pragma Source_File_Name_Project::
652 * Pragma Source_Reference::
653 * Pragma Stream_Convert::
654 * Pragma Style_Checks::
655 * Pragma Subtitle::
656 * Pragma Suppress_All::
657 * Pragma Suppress_Exception_Locations::
658 * Pragma Suppress_Initialization::
659 * Pragma Task_Info::
660 * Pragma Task_Name::
661 * Pragma Task_Storage::
662 * Pragma Thread_Body::
663 * Pragma Time_Slice::
664 * Pragma Title::
665 * Pragma Unchecked_Union::
666 * Pragma Unimplemented_Unit::
667 * Pragma Universal_Data::
668 * Pragma Unreferenced::
669 * Pragma Unreserve_All_Interrupts::
670 * Pragma Unsuppress::
671 * Pragma Use_VADS_Size::
672 * Pragma Validity_Checks::
673 * Pragma Volatile::
674 * Pragma Warnings::
675 * Pragma Weak_External::
676 @end menu
677
678 @node Pragma Abort_Defer
679 @unnumberedsec Pragma Abort_Defer
680 @findex Abort_Defer
681 @cindex Deferring aborts
682 @noindent
683 Syntax:
684 @smallexample
685 pragma Abort_Defer;
686 @end smallexample
687
688 @noindent
689 This pragma must appear at the start of the statement sequence of a
690 handled sequence of statements (right after the @code{begin}).  It has
691 the effect of deferring aborts for the sequence of statements (but not
692 for the declarations or handlers, if any, associated with this statement
693 sequence).
694
695 @node Pragma Ada_83
696 @unnumberedsec Pragma Ada_83
697 @findex Ada_83
698 @noindent
699 Syntax:
700 @smallexample @c ada
701 pragma Ada_83;
702 @end smallexample
703
704 @noindent
705 A configuration pragma that establishes Ada 83 mode for the unit to
706 which it applies, regardless of the mode set by the command line
707 switches.  In Ada 83 mode, GNAT attempts to be as compatible with
708 the syntax and semantics of Ada 83, as defined in the original Ada
709 83 Reference Manual as possible.  In particular, the new Ada 95
710 keywords are not recognized, optional package bodies are allowed,
711 and generics may name types with unknown discriminants without using
712 the @code{(<>)} notation.  In addition, some but not all of the additional
713 restrictions of Ada 83 are enforced.
714
715 Ada 83 mode is intended for two purposes.  Firstly, it allows existing
716 legacy Ada 83 code to be compiled and adapted to GNAT with less effort.
717 Secondly, it aids in keeping code backwards compatible with Ada 83.
718 However, there is no guarantee that code that is processed correctly
719 by GNAT in Ada 83 mode will in fact compile and execute with an Ada
720 83 compiler, since GNAT does not enforce all the additional checks
721 required by Ada 83.
722
723 @node Pragma Ada_95
724 @unnumberedsec Pragma Ada_95
725 @findex Ada_95
726 @noindent
727 Syntax:
728 @smallexample @c ada
729 pragma Ada_95;
730 @end smallexample
731
732 @noindent
733 A configuration pragma that establishes Ada 95 mode for the unit to which
734 it applies, regardless of the mode set by the command line switches.
735 This mode is set automatically for the @code{Ada} and @code{System}
736 packages and their children, so you need not specify it in these
737 contexts.  This pragma is useful when writing a reusable component that
738 itself uses Ada 95 features, but which is intended to be usable from
739 either Ada 83 or Ada 95 programs.
740
741 @node Pragma Annotate
742 @unnumberedsec Pragma Annotate
743 @findex Annotate
744 @noindent
745 Syntax:
746 @smallexample @c ada
747 pragma Annotate (IDENTIFIER @{, ARG@});
748
749 ARG ::= NAME | EXPRESSION
750 @end smallexample
751
752 @noindent
753 This pragma is used to annotate programs.  @var{identifier} identifies
754 the type of annotation.  GNAT verifies this is an identifier, but does
755 not otherwise analyze it.  The @var{arg} argument
756 can be either a string literal or an
757 expression.  String literals are assumed to be of type
758 @code{Standard.String}.  Names of entities are simply analyzed as entity
759 names.  All other expressions are analyzed as expressions, and must be
760 unambiguous.
761
762 The analyzed pragma is retained in the tree, but not otherwise processed
763 by any part of the GNAT compiler.  This pragma is intended for use by
764 external tools, including ASIS@.
765
766 @node Pragma Assert
767 @unnumberedsec Pragma Assert
768 @findex Assert
769 @noindent
770 Syntax:
771 @smallexample @c ada
772 pragma Assert (
773   boolean_EXPRESSION
774   [, static_string_EXPRESSION]);
775 @end smallexample
776
777 @noindent
778 The effect of this pragma depends on whether the corresponding command
779 line switch is set to activate assertions.  The pragma expands into code
780 equivalent to the following:
781
782 @smallexample @c ada
783 if assertions-enabled then
784    if not boolean_EXPRESSION then
785       System.Assertions.Raise_Assert_Failure
786         (string_EXPRESSION);
787    end if;
788 end if;
789 @end smallexample
790
791 @noindent
792 The string argument, if given, is the message that will be associated
793 with the exception occurrence if the exception is raised.  If no second
794 argument is given, the default message is @samp{@var{file}:@var{nnn}},
795 where @var{file} is the name of the source file containing the assert,
796 and @var{nnn} is the line number of the assert.  A pragma is not a
797 statement, so if a statement sequence contains nothing but a pragma
798 assert, then a null statement is required in addition, as in:
799
800 @smallexample @c ada
801 @dots{}
802 if J > 3 then
803    pragma Assert (K > 3, "Bad value for K");
804    null;
805 end if;
806 @end smallexample
807
808 @noindent
809 Note that, as with the @code{if} statement to which it is equivalent, the
810 type of the expression is either @code{Standard.Boolean}, or any type derived
811 from this standard type.
812
813 If assertions are disabled (switch @code{-gnata} not used), then there
814 is no effect (and in particular, any side effects from the expression
815 are suppressed).  More precisely it is not quite true that the pragma
816 has no effect, since the expression is analyzed, and may cause types
817 to be frozen if they are mentioned here for the first time.
818
819 If assertions are enabled, then the given expression is tested, and if
820 it is @code{False} then @code{System.Assertions.Raise_Assert_Failure} is called
821 which results in the raising of @code{Assert_Failure} with the given message.
822
823 If the boolean expression has side effects, these side effects will turn
824 on and off with the setting of the assertions mode, resulting in
825 assertions that have an effect on the program.  You should generally
826 avoid side effects in the expression arguments of this pragma.  However,
827 the expressions are analyzed for semantic correctness whether or not
828 assertions are enabled, so turning assertions on and off cannot affect
829 the legality of a program.
830
831 @node Pragma Ast_Entry
832 @unnumberedsec Pragma Ast_Entry
833 @cindex OpenVMS
834 @findex Ast_Entry
835 @noindent
836 Syntax:
837 @smallexample @c ada
838 pragma AST_Entry (entry_IDENTIFIER);
839 @end smallexample
840
841 @noindent
842 This pragma is implemented only in the OpenVMS implementation of GNAT@.  The
843 argument is the simple name of a single entry; at most one @code{AST_Entry}
844 pragma is allowed for any given entry.  This pragma must be used in
845 conjunction with the @code{AST_Entry} attribute, and is only allowed after
846 the entry declaration and in the same task type specification or single task
847 as the entry to which it applies.  This pragma specifies that the given entry
848 may be used to handle an OpenVMS asynchronous system trap (@code{AST})
849 resulting from an OpenVMS system service call.  The pragma does not affect
850 normal use of the entry.  For further details on this pragma, see the
851 DEC Ada Language Reference Manual, section 9.12a.
852
853 @node Pragma C_Pass_By_Copy
854 @unnumberedsec Pragma C_Pass_By_Copy
855 @cindex Passing by copy
856 @findex C_Pass_By_Copy
857 @noindent
858 Syntax:
859 @smallexample @c ada
860 pragma C_Pass_By_Copy
861   ([Max_Size =>] static_integer_EXPRESSION);
862 @end smallexample
863
864 @noindent
865 Normally the default mechanism for passing C convention records to C
866 convention subprograms is to pass them by reference, as suggested by RM
867 B.3(69).  Use the configuration pragma @code{C_Pass_By_Copy} to change
868 this default, by requiring that record formal parameters be passed by
869 copy if all of the following conditions are met:
870
871 @itemize @bullet
872 @item
873 The size of the record type does not exceed@*@var{static_integer_expression}.
874 @item
875 The record type has @code{Convention C}.
876 @item
877 The formal parameter has this record type, and the subprogram has a
878 foreign (non-Ada) convention.
879 @end itemize
880
881 @noindent
882 If these conditions are met the argument is passed by copy, i.e.@: in a
883 manner consistent with what C expects if the corresponding formal in the
884 C prototype is a struct (rather than a pointer to a struct).
885
886 You can also pass records by copy by specifying the convention
887 @code{C_Pass_By_Copy} for the record type, or by using the extended
888 @code{Import} and @code{Export} pragmas, which allow specification of
889 passing mechanisms on a parameter by parameter basis.
890
891 @node Pragma Comment
892 @unnumberedsec Pragma Comment
893 @findex Comment
894 @noindent
895 Syntax:
896
897 @smallexample @c ada
898 pragma Comment (static_string_EXPRESSION);
899 @end smallexample
900
901 @noindent
902 This is almost identical in effect to pragma @code{Ident}.  It allows the
903 placement of a comment into the object file and hence into the
904 executable file if the operating system permits such usage.  The
905 difference is that @code{Comment}, unlike @code{Ident}, has
906 no limitations on placement of the pragma (it can be placed
907 anywhere in the main source unit), and if more than one pragma
908 is used, all comments are retained.
909
910 @node Pragma Common_Object
911 @unnumberedsec Pragma Common_Object
912 @findex Common_Object
913 @noindent
914 Syntax:
915
916 @smallexample @c ada
917 pragma Common_Object (
918      [Internal =>] LOCAL_NAME,
919   [, [External =>] EXTERNAL_SYMBOL]
920   [, [Size     =>] EXTERNAL_SYMBOL] );
921
922 EXTERNAL_SYMBOL ::=
923   IDENTIFIER
924 | static_string_EXPRESSION
925 @end smallexample
926
927 @noindent
928 This pragma enables the shared use of variables stored in overlaid
929 linker areas corresponding to the use of @code{COMMON}
930 in Fortran.  The single
931 object @var{local_name} is assigned to the area designated by
932 the @var{External} argument.
933 You may define a record to correspond to a series
934 of fields.  The @var{size} argument
935 is syntax checked in GNAT, but otherwise ignored.
936
937 @code{Common_Object} is not supported on all platforms.  If no
938 support is available, then the code generator will issue a message
939 indicating that the necessary attribute for implementation of this
940 pragma is not available.
941
942 @node Pragma Compile_Time_Warning
943 @unnumberedsec Pragma Compile_Time_Warning
944 @findex Compile_Time_Warning
945 @noindent
946 Syntax:
947
948 @smallexample @c ada
949 pragma Compile_Time_Warning
950          (boolean_EXPRESSION, static_string_EXPRESSION);
951 @end smallexample
952
953 @noindent
954 This pragma can be used to generate additional compile time warnings. It
955 is particularly useful in generics, where warnings can be issued for
956 specific problematic instantiations. The first parameter is a boolean
957 expression. The pragma is effective only if the value of this expression
958 is known at compile time, and has the value True. The set of expressions
959 whose values are known at compile time includes all static boolean
960 expressions, and also other values which the compiler can determine
961 at compile time (e.g. the size of a record type set by an explicit
962 size representation clause, or the value of a variable which was
963 initialized to a constant and is known not to have been modified).
964 If these conditions are met, a warning message is generated using
965 the value given as the second argument. This string value may contain
966 embedded ASCII.LF characters to break the message into multiple lines.
967
968 @node Pragma Complex_Representation
969 @unnumberedsec Pragma Complex_Representation
970 @findex Complex_Representation
971 @noindent
972 Syntax:
973
974 @smallexample @c ada
975 pragma Complex_Representation
976         ([Entity =>] LOCAL_NAME);
977 @end smallexample
978
979 @noindent
980 The @var{Entity} argument must be the name of a record type which has
981 two fields of the same floating-point type.  The effect of this pragma is
982 to force gcc to use the special internal complex representation form for
983 this record, which may be more efficient.  Note that this may result in
984 the code for this type not conforming to standard ABI (application
985 binary interface) requirements for the handling of record types.  For
986 example, in some environments, there is a requirement for passing
987 records by pointer, and the use of this pragma may result in passing
988 this type in floating-point registers.
989
990 @node Pragma Component_Alignment
991 @unnumberedsec Pragma Component_Alignment
992 @cindex Alignments of components
993 @findex Component_Alignment
994 @noindent
995 Syntax:
996
997 @smallexample @c ada
998 pragma Component_Alignment (
999      [Form =>] ALIGNMENT_CHOICE
1000   [, [Name =>] type_LOCAL_NAME]);
1001
1002 ALIGNMENT_CHOICE ::=
1003   Component_Size
1004 | Component_Size_4
1005 | Storage_Unit
1006 | Default
1007 @end smallexample
1008
1009 @noindent
1010 Specifies the alignment of components in array or record types.
1011 The meaning of the @var{Form} argument is as follows:
1012
1013 @table @code
1014 @findex Component_Size
1015 @item Component_Size
1016 Aligns scalar components and subcomponents of the array or record type
1017 on boundaries appropriate to their inherent size (naturally
1018 aligned).  For example, 1-byte components are aligned on byte boundaries,
1019 2-byte integer components are aligned on 2-byte boundaries, 4-byte
1020 integer components are aligned on 4-byte boundaries and so on.  These
1021 alignment rules correspond to the normal rules for C compilers on all
1022 machines except the VAX@.
1023
1024 @findex Component_Size_4
1025 @item Component_Size_4
1026 Naturally aligns components with a size of four or fewer
1027 bytes.  Components that are larger than 4 bytes are placed on the next
1028 4-byte boundary.
1029
1030 @findex Storage_Unit
1031 @item Storage_Unit
1032 Specifies that array or record components are byte aligned, i.e.@:
1033 aligned on boundaries determined by the value of the constant
1034 @code{System.Storage_Unit}.
1035
1036 @cindex OpenVMS
1037 @item Default
1038 Specifies that array or record components are aligned on default
1039 boundaries, appropriate to the underlying hardware or operating system or
1040 both.  For OpenVMS VAX systems, the @code{Default} choice is the same as
1041 the @code{Storage_Unit} choice (byte alignment).  For all other systems,
1042 the @code{Default} choice is the same as @code{Component_Size} (natural
1043 alignment).
1044 @end table
1045
1046 @noindent
1047 If the @code{Name} parameter is present, @var{type_local_name} must
1048 refer to a local record or array type, and the specified alignment
1049 choice applies to the specified type.  The use of
1050 @code{Component_Alignment} together with a pragma @code{Pack} causes the
1051 @code{Component_Alignment} pragma to be ignored.  The use of
1052 @code{Component_Alignment} together with a record representation clause
1053 is only effective for fields not specified by the representation clause.
1054
1055 If the @code{Name} parameter is absent, the pragma can be used as either
1056 a configuration pragma, in which case it applies to one or more units in
1057 accordance with the normal rules for configuration pragmas, or it can be
1058 used within a declarative part, in which case it applies to types that
1059 are declared within this declarative part, or within any nested scope
1060 within this declarative part.  In either case it specifies the alignment
1061 to be applied to any record or array type which has otherwise standard
1062 representation.
1063
1064 If the alignment for a record or array type is not specified (using
1065 pragma @code{Pack}, pragma @code{Component_Alignment}, or a record rep
1066 clause), the GNAT uses the default alignment as described previously.
1067
1068 @node Pragma Convention_Identifier
1069 @unnumberedsec Pragma Convention_Identifier
1070 @findex Convention_Identifier
1071 @cindex Conventions, synonyms
1072 @noindent
1073 Syntax:
1074
1075 @smallexample @c ada
1076 pragma Convention_Identifier (
1077          [Name =>]       IDENTIFIER,
1078          [Convention =>] convention_IDENTIFIER);
1079 @end smallexample
1080
1081 @noindent
1082 This pragma provides a mechanism for supplying synonyms for existing
1083 convention identifiers. The @code{Name} identifier can subsequently
1084 be used as a synonym for the given convention in other pragmas (including
1085 for example pragma @code{Import} or another @code{Convention_Identifier}
1086 pragma). As an example of the use of this, suppose you had legacy code
1087 which used Fortran77 as the identifier for Fortran. Then the pragma:
1088
1089 @smallexample @c ada
1090 pragma Convention_Identifier (Fortran77, Fortran);
1091 @end smallexample
1092
1093 @noindent
1094 would allow the use of the convention identifier @code{Fortran77} in
1095 subsequent code, avoiding the need to modify the sources. As another
1096 example, you could use this to parametrize convention requirements
1097 according to systems. Suppose you needed to use @code{Stdcall} on
1098 windows systems, and @code{C} on some other system, then you could
1099 define a convention identifier @code{Library} and use a single
1100 @code{Convention_Identifier} pragma to specify which convention
1101 would be used system-wide.
1102
1103 @node Pragma CPP_Class
1104 @unnumberedsec Pragma CPP_Class
1105 @findex CPP_Class
1106 @cindex Interfacing with C++
1107 @noindent
1108 Syntax:
1109
1110 @smallexample @c ada
1111 pragma CPP_Class ([Entity =>] LOCAL_NAME);
1112 @end smallexample
1113
1114 @noindent
1115 The argument denotes an entity in the current declarative region
1116 that is declared as a tagged or untagged record type.  It indicates that
1117 the type corresponds to an externally declared C++ class type, and is to
1118 be laid out the same way that C++ would lay out the type.
1119
1120 If (and only if) the type is tagged, at least one component in the
1121 record must be of type @code{Interfaces.CPP.Vtable_Ptr}, corresponding
1122 to the C++ Vtable (or Vtables in the case of multiple inheritance) used
1123 for dispatching.
1124
1125 Types for which @code{CPP_Class} is specified do not have assignment or
1126 equality operators defined (such operations can be imported or declared
1127 as subprograms as required).  Initialization is allowed only by
1128 constructor functions (see pragma @code{CPP_Constructor}).
1129
1130 Pragma @code{CPP_Class} is intended primarily for automatic generation
1131 using an automatic binding generator tool.
1132 See @ref{Interfacing to C++} for related information.
1133
1134 @node Pragma CPP_Constructor
1135 @unnumberedsec Pragma CPP_Constructor
1136 @cindex Interfacing with C++
1137 @findex CPP_Constructor
1138 @noindent
1139 Syntax:
1140
1141 @smallexample @c ada
1142 pragma CPP_Constructor ([Entity =>] LOCAL_NAME);
1143 @end smallexample
1144
1145 @noindent
1146 This pragma identifies an imported function (imported in the usual way
1147 with pragma @code{Import}) as corresponding to a C++
1148 constructor.  The argument is a name that must have been
1149 previously mentioned in a pragma @code{Import}
1150 with @code{Convention} = @code{CPP}, and must be of one of the following
1151 forms:
1152
1153 @itemize @bullet
1154 @item
1155 @code{function @var{Fname} return @var{T}'Class}
1156
1157 @item
1158 @code{function @var{Fname} (@dots{}) return @var{T}'Class}
1159 @end itemize
1160
1161 @noindent
1162 where @var{T} is a tagged type to which the pragma @code{CPP_Class} applies.
1163
1164 The first form is the default constructor, used when an object of type
1165 @var{T} is created on the Ada side with no explicit constructor.  Other
1166 constructors (including the copy constructor, which is simply a special
1167 case of the second form in which the one and only argument is of type
1168 @var{T}), can only appear in two contexts:
1169
1170 @itemize @bullet
1171 @item
1172 On the right side of an initialization of an object of type @var{T}.
1173 @item
1174 In an extension aggregate for an object of a type derived from @var{T}.
1175 @end itemize
1176
1177 @noindent
1178 Although the constructor is described as a function that returns a value
1179 on the Ada side, it is typically a procedure with an extra implicit
1180 argument (the object being initialized) at the implementation
1181 level.  GNAT issues the appropriate call, whatever it is, to get the
1182 object properly initialized.
1183
1184 In the case of derived objects, you may use one of two possible forms
1185 for declaring and creating an object:
1186
1187 @itemize @bullet
1188 @item @code{New_Object : Derived_T}
1189 @item @code{New_Object : Derived_T := (@var{constructor-call with} @dots{})}
1190 @end itemize
1191
1192 @noindent
1193 In the first case the default constructor is called and extension fields
1194 if any are initialized according to the default initialization
1195 expressions in the Ada declaration.  In the second case, the given
1196 constructor is called and the extension aggregate indicates the explicit
1197 values of the extension fields.
1198
1199 If no constructors are imported, it is impossible to create any objects
1200 on the Ada side.  If no default constructor is imported, only the
1201 initialization forms using an explicit call to a constructor are
1202 permitted.
1203
1204 Pragma @code{CPP_Constructor} is intended primarily for automatic generation
1205 using an automatic binding generator tool.
1206 See @ref{Interfacing to C++} for more related information.
1207
1208 @node Pragma CPP_Virtual
1209 @unnumberedsec Pragma CPP_Virtual
1210 @cindex Interfacing to C++
1211 @findex CPP_Virtual
1212 @noindent
1213 Syntax:
1214
1215 @smallexample @c ada
1216 pragma CPP_Virtual
1217      [Entity     =>] ENTITY,
1218   [, [Vtable_Ptr =>] vtable_ENTITY,]
1219   [, [Position   =>] static_integer_EXPRESSION]);
1220 @end smallexample
1221
1222 @noindent
1223 This pragma serves the same function as pragma @code{Import} in that
1224 case of a virtual function imported from C++.  The @var{Entity} argument
1225 must be a
1226 primitive subprogram of a tagged type to which pragma @code{CPP_Class}
1227 applies.  The @var{Vtable_Ptr} argument specifies
1228 the Vtable_Ptr component which contains the
1229 entry for this virtual function.  The @var{Position} argument
1230 is the sequential number
1231 counting virtual functions for this Vtable starting at 1.
1232
1233 The @code{Vtable_Ptr} and @code{Position} arguments may be omitted if
1234 there is one Vtable_Ptr present (single inheritance case) and all
1235 virtual functions are imported.  In that case the compiler can deduce both
1236 these values.
1237
1238 No @code{External_Name} or @code{Link_Name} arguments are required for a
1239 virtual function, since it is always accessed indirectly via the
1240 appropriate Vtable entry.
1241
1242 Pragma @code{CPP_Virtual} is intended primarily for automatic generation
1243 using an automatic binding generator tool.
1244 See @ref{Interfacing to C++} for related information.
1245
1246 @node Pragma CPP_Vtable
1247 @unnumberedsec Pragma CPP_Vtable
1248 @cindex Interfacing with C++
1249 @findex CPP_Vtable
1250 @noindent
1251 Syntax:
1252
1253 @smallexample @c ada
1254 pragma CPP_Vtable (
1255   [Entity      =>] ENTITY,
1256   [Vtable_Ptr  =>] vtable_ENTITY,
1257   [Entry_Count =>] static_integer_EXPRESSION);
1258 @end smallexample
1259
1260 @noindent
1261 Given a record to which the pragma @code{CPP_Class} applies,
1262 this pragma can be specified for each component of type
1263 @code{CPP.Interfaces.Vtable_Ptr}.
1264 @var{Entity} is the tagged type, @var{Vtable_Ptr}
1265 is the record field of type @code{Vtable_Ptr}, and @var{Entry_Count} is
1266 the number of virtual functions on the C++ side.  Not all of these
1267 functions need to be imported on the Ada side.
1268
1269 You may omit the @code{CPP_Vtable} pragma if there is only one
1270 @code{Vtable_Ptr} component in the record and all virtual functions are
1271 imported on the Ada side (the default value for the entry count in this
1272 case is simply the total number of virtual functions).
1273
1274 Pragma @code{CPP_Vtable} is intended primarily for automatic generation
1275 using an automatic binding generator tool.
1276 See @ref{Interfacing to C++} for related information.
1277
1278 @node Pragma Debug
1279 @unnumberedsec Pragma Debug
1280 @findex Debug
1281 @noindent
1282 Syntax:
1283
1284 @smallexample @c ada
1285 pragma Debug (PROCEDURE_CALL_WITHOUT_SEMICOLON);
1286
1287 PROCEDURE_CALL_WITHOUT_SEMICOLON ::=
1288   PROCEDURE_NAME
1289 | PROCEDURE_PREFIX ACTUAL_PARAMETER_PART
1290 @end smallexample
1291
1292 @noindent
1293 The argument has the syntactic form of an expression, meeting the
1294 syntactic requirements for pragmas.
1295
1296 If assertions are not enabled on the command line, this pragma has no
1297 effect.  If asserts are enabled, the semantics of the pragma is exactly
1298 equivalent to the procedure call statement corresponding to the argument
1299 with a terminating semicolon.  Pragmas are permitted in sequences of
1300 declarations, so you can use pragma @code{Debug} to intersperse calls to
1301 debug procedures in the middle of declarations.
1302
1303 @node Pragma Elaboration_Checks
1304 @unnumberedsec Pragma Elaboration_Checks
1305 @cindex Elaboration control
1306 @findex Elaboration_Checks
1307 @noindent
1308 Syntax:
1309
1310 @smallexample @c ada
1311 pragma Elaboration_Checks (Dynamic | Static);
1312 @end smallexample
1313
1314 @noindent
1315 This is a configuration pragma that provides control over the
1316 elaboration model used by the compilation affected by the
1317 pragma.  If the parameter is @code{Dynamic},
1318 then the dynamic elaboration
1319 model described in the Ada Reference Manual is used, as though
1320 the @code{-gnatE} switch had been specified on the command
1321 line.  If the parameter is @code{Static}, then the default GNAT static
1322 model is used.  This configuration pragma overrides the setting
1323 of the command line.  For full details on the elaboration models
1324 used by the GNAT compiler, see section ``Elaboration Order
1325 Handling in GNAT'' in the @cite{GNAT User's Guide}.
1326
1327 @node Pragma Eliminate
1328 @unnumberedsec Pragma Eliminate
1329 @cindex Elimination of unused subprograms
1330 @findex Eliminate
1331 @noindent
1332 Syntax:
1333
1334 @smallexample @c ada
1335 pragma Eliminate (
1336     [Unit_Name =>] IDENTIFIER |
1337                    SELECTED_COMPONENT);
1338
1339 pragma Eliminate (
1340     [Unit_Name       =>]  IDENTIFIER |
1341                           SELECTED_COMPONENT,
1342     [Entity          =>]  IDENTIFIER |
1343                           SELECTED_COMPONENT |
1344                           STRING_LITERAL
1345     [,OVERLOADING_RESOLUTION]);
1346
1347 OVERLOADING_RESOLUTION ::= PARAMETER_AND_RESULT_TYPE_PROFILE |
1348                            SOURCE_LOCATION
1349
1350 PARAMETER_AND_RESULT_TYPE_PROFILE ::= PROCEDURE_PROFILE |
1351                                       FUNCTION_PROFILE
1352
1353 PROCEDURE_PROFILE ::= Parameter_Types => PARAMETER_TYPES
1354
1355 FUNCTION_PROFILE ::= [Parameter_Types => PARAMETER_TYPES,]
1356                       Result_Type => result_SUBTYPE_NAME]
1357
1358 PARAMETER_TYPES ::= (SUBTYPE_NAME @{, SUBTYPE_NAME@})
1359 SUBTYPE_NAME    ::= STRING_VALUE
1360
1361 SOURCE_LOCATION ::= Source_Location => SOURCE_TRACE
1362 SOURCE_TRACE    ::= STRING_VALUE
1363
1364 STRING_VALUE ::= STRING_LITERAL @{& STRING_LITERAL@}
1365 @end smallexample
1366
1367 @noindent
1368 This pragma indicates that the given entity is not used outside the
1369 compilation unit it is defined in. The entity must be an explicitly declared
1370 subprogram; this includes  generic subprogram instances and
1371 subprograms declared in generic package instances.
1372
1373 If the entity to be eliminated is a library level subprogram, then
1374 the first form of pragma @code{Eliminate} is used with only a single argument.
1375 In this form, the @code{Unit_Name} argument specifies the name of the
1376 library  level unit to be eliminated.
1377
1378 In all other cases, both @code{Unit_Name} and @code{Entity} arguments
1379 are required. If item is an entity of a library package, then the first
1380 argument specifies the unit name, and the second argument specifies
1381 the particular entity.  If the second argument is in string form, it must
1382 correspond to the internal manner in which GNAT stores entity names (see
1383 compilation unit Namet in the compiler sources for details).
1384
1385 The remaining parameters (OVERLOADING_RESOLUTION) are optionally used
1386 to distinguish between overloaded subprograms. If a pragma does not contain
1387 the OVERLOADING_RESOLUTION parameter(s), it is applied to all the overloaded
1388 subprograms denoted by the first two parameters.
1389
1390 Use PARAMETER_AND_RESULT_TYPE_PROFILE to specify the profile of the subprogram
1391 to be eliminated in a manner similar to that used for the extended
1392 @code{Import} and @code{Export} pragmas, except that the subtype names are
1393 always given as strings. At the moment, this form of distinguishing
1394 overloaded subprograms is implemented only partially, so we do not recommend
1395 using it for practical subprogram elimination.
1396
1397 Note, that in case of a parameterless procedure its profile is represented
1398 as @code{Parameter_Types => ("")}
1399
1400 Alternatively, the @code{Source_Location} parameter is used to specify
1401 which overloaded alternative is to be eliminated by pointing to the
1402 location of the DEFINING_PROGRAM_UNIT_NAME of this subprogram in the
1403 source text. The string literal (or concatenation of string literals)
1404 given as SOURCE_TRACE must have the following format:
1405
1406 @smallexample @c ada
1407 SOURCE_TRACE ::= SOURCE_LOCATION@{LBRACKET SOURCE_LOCATION RBRACKET@}
1408
1409 LBRACKET ::= [
1410 RBRACKET ::= ]
1411
1412 SOURCE_LOCATION ::= FILE_NAME:LINE_NUMBER
1413 FILE_NAME       ::= STRING_LITERAL
1414 LINE_NUMBER     ::= DIGIT @{DIGIT@}
1415 @end smallexample
1416
1417 SOURCE_TRACE should be the short name of the source file (with no directory
1418 information), and LINE_NUMBER is supposed to point to the line where the
1419 defining name of the subprogram is located.
1420
1421 For the subprograms that are not a part of generic instantiations, only one
1422 SOURCE_LOCATION is used. If a subprogram is declared in a package
1423 instantiation, SOURCE_TRACE contains two SOURCE_LOCATIONs, the first one is
1424 the location of the (DEFINING_PROGRAM_UNIT_NAME of the) instantiation, and the
1425 second one denotes the declaration of the corresponding subprogram in the
1426 generic package. This approach is recursively used to create SOURCE_LOCATIONs
1427 in case of nested instantiations.
1428
1429 The effect of the pragma is to allow the compiler to eliminate
1430 the code or data associated with the named entity.  Any reference to
1431 an eliminated entity outside the compilation unit it is defined in,
1432 causes a compile time or link time error.
1433
1434 The intention of pragma @code{Eliminate} is to allow a program to be compiled
1435 in a system independent manner, with unused entities eliminated, without
1436 the requirement of modifying the source text.  Normally the required set
1437 of @code{Eliminate} pragmas is constructed automatically using the gnatelim
1438 tool. Elimination of unused entities local to a compilation unit is
1439 automatic, without requiring the use of pragma @code{Eliminate}.
1440
1441 Note that the reason this pragma takes string literals where names might
1442 be expected is that a pragma @code{Eliminate} can appear in a context where the
1443 relevant names are not visible.
1444
1445 Note that any change in the source files that includes removing, splitting of
1446 adding lines may make the set of Eliminate pragmas using SOURCE_LOCATION
1447 parameter illegal.
1448
1449 @node Pragma Export_Exception
1450 @unnumberedsec Pragma Export_Exception
1451 @cindex OpenVMS
1452 @findex Export_Exception
1453 @noindent
1454 Syntax:
1455
1456 @smallexample @c ada
1457 pragma Export_Exception (
1458      [Internal =>] LOCAL_NAME,
1459   [, [External =>] EXTERNAL_SYMBOL,]
1460   [, [Form     =>] Ada | VMS]
1461   [, [Code     =>] static_integer_EXPRESSION]);
1462
1463 EXTERNAL_SYMBOL ::=
1464   IDENTIFIER
1465 | static_string_EXPRESSION
1466 @end smallexample
1467
1468 @noindent
1469 This pragma is implemented only in the OpenVMS implementation of GNAT@.  It
1470 causes the specified exception to be propagated outside of the Ada program,
1471 so that it can be handled by programs written in other OpenVMS languages.
1472 This pragma establishes an external name for an Ada exception and makes the
1473 name available to the OpenVMS Linker as a global symbol.  For further details
1474 on this pragma, see the
1475 DEC Ada Language Reference Manual, section 13.9a3.2.
1476
1477 @node Pragma Export_Function
1478 @unnumberedsec Pragma Export_Function
1479 @cindex Argument passing mechanisms
1480 @findex Export_Function
1481
1482 @noindent
1483 Syntax:
1484
1485 @smallexample @c ada
1486 pragma Export_Function (
1487      [Internal         =>] LOCAL_NAME,
1488   [, [External         =>] EXTERNAL_SYMBOL]
1489   [, [Parameter_Types  =>] PARAMETER_TYPES]
1490   [, [Result_Type      =>] result_SUBTYPE_MARK]
1491   [, [Mechanism        =>] MECHANISM]
1492   [, [Result_Mechanism =>] MECHANISM_NAME]);
1493
1494 EXTERNAL_SYMBOL ::=
1495   IDENTIFIER
1496 | static_string_EXPRESSION
1497 | ""
1498
1499 PARAMETER_TYPES ::=
1500   null
1501 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1502
1503 TYPE_DESIGNATOR ::=
1504   subtype_NAME
1505 | subtype_Name ' Access
1506
1507 MECHANISM ::=
1508   MECHANISM_NAME
1509 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1510
1511 MECHANISM_ASSOCIATION ::=
1512   [formal_parameter_NAME =>] MECHANISM_NAME
1513
1514 MECHANISM_NAME ::=
1515   Value
1516 | Reference
1517 @end smallexample
1518
1519 @noindent
1520 Use this pragma to make a function externally callable and optionally
1521 provide information on mechanisms to be used for passing parameter and
1522 result values.  We recommend, for the purposes of improving portability,
1523 this pragma always be used in conjunction with a separate pragma
1524 @code{Export}, which must precede the pragma @code{Export_Function}.
1525 GNAT does not require a separate pragma @code{Export}, but if none is
1526 present, @code{Convention Ada} is assumed, which is usually
1527 not what is wanted, so it is usually appropriate to use this
1528 pragma in conjunction with a @code{Export} or @code{Convention}
1529 pragma that specifies the desired foreign convention.
1530 Pragma @code{Export_Function}
1531 (and @code{Export}, if present) must appear in the same declarative
1532 region as the function to which they apply.
1533
1534 @var{internal_name} must uniquely designate the function to which the
1535 pragma applies.  If more than one function name exists of this name in
1536 the declarative part you must use the @code{Parameter_Types} and
1537 @code{Result_Type} parameters is mandatory to achieve the required
1538 unique designation.  @var{subtype_ mark}s in these parameters must
1539 exactly match the subtypes in the corresponding function specification,
1540 using positional notation to match parameters with subtype marks.
1541 The form with an @code{'Access} attribute can be used to match an
1542 anonymous access parameter.
1543
1544 @cindex OpenVMS
1545 @cindex Passing by descriptor
1546 Note that passing by descriptor is not supported, even on the OpenVMS
1547 ports of GNAT@.
1548
1549 @cindex Suppressing external name
1550 Special treatment is given if the EXTERNAL is an explicit null
1551 string or a static string expressions that evaluates to the null
1552 string. In this case, no external name is generated. This form
1553 still allows the specification of parameter mechanisms.
1554
1555 @node Pragma Export_Object
1556 @unnumberedsec Pragma Export_Object
1557 @findex Export_Object
1558 @noindent
1559 Syntax:
1560
1561 @smallexample @c ada
1562 pragma Export_Object
1563       [Internal =>] LOCAL_NAME,
1564    [, [External =>] EXTERNAL_SYMBOL]
1565    [, [Size     =>] EXTERNAL_SYMBOL]
1566
1567 EXTERNAL_SYMBOL ::=
1568   IDENTIFIER
1569 | static_string_EXPRESSION
1570 @end smallexample
1571
1572 @noindent
1573 This pragma designates an object as exported, and apart from the
1574 extended rules for external symbols, is identical in effect to the use of
1575 the normal @code{Export} pragma applied to an object.  You may use a
1576 separate Export pragma (and you probably should from the point of view
1577 of portability), but it is not required.  @var{Size} is syntax checked,
1578 but otherwise ignored by GNAT@.
1579
1580 @node Pragma Export_Procedure
1581 @unnumberedsec Pragma Export_Procedure
1582 @findex Export_Procedure
1583 @noindent
1584 Syntax:
1585
1586 @smallexample @c ada
1587 pragma Export_Procedure (
1588      [Internal        =>] LOCAL_NAME
1589   [, [External        =>] EXTERNAL_SYMBOL]
1590   [, [Parameter_Types =>] PARAMETER_TYPES]
1591   [, [Mechanism       =>] MECHANISM]);
1592
1593 EXTERNAL_SYMBOL ::=
1594   IDENTIFIER
1595 | static_string_EXPRESSION
1596 | ""
1597
1598 PARAMETER_TYPES ::=
1599   null
1600 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1601
1602 TYPE_DESIGNATOR ::=
1603   subtype_NAME
1604 | subtype_Name ' Access
1605
1606 MECHANISM ::=
1607   MECHANISM_NAME
1608 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1609
1610 MECHANISM_ASSOCIATION ::=
1611   [formal_parameter_NAME =>] MECHANISM_NAME
1612
1613 MECHANISM_NAME ::=
1614   Value
1615 | Reference
1616 @end smallexample
1617
1618 @noindent
1619 This pragma is identical to @code{Export_Function} except that it
1620 applies to a procedure rather than a function and the parameters
1621 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
1622 GNAT does not require a separate pragma @code{Export}, but if none is
1623 present, @code{Convention Ada} is assumed, which is usually
1624 not what is wanted, so it is usually appropriate to use this
1625 pragma in conjunction with a @code{Export} or @code{Convention}
1626 pragma that specifies the desired foreign convention.
1627
1628 @cindex OpenVMS
1629 @cindex Passing by descriptor
1630 Note that passing by descriptor is not supported, even on the OpenVMS
1631 ports of GNAT@.
1632
1633 @cindex Suppressing external name
1634 Special treatment is given if the EXTERNAL is an explicit null
1635 string or a static string expressions that evaluates to the null
1636 string. In this case, no external name is generated. This form
1637 still allows the specification of parameter mechanisms.
1638
1639 @node Pragma Export_Value
1640 @unnumberedsec Pragma Export_Value
1641 @findex Export_Value
1642 @noindent
1643 Syntax:
1644
1645 @smallexample @c ada
1646 pragma Export_Value (
1647   [Value     =>] static_integer_EXPRESSION,
1648   [Link_Name =>] static_string_EXPRESSION);
1649 @end smallexample
1650
1651 @noindent
1652 This pragma serves to export a static integer value for external use.
1653 The first argument specifies the value to be exported. The Link_Name
1654 argument specifies the symbolic name to be associated with the integer
1655 value. This pragma is useful for defining a named static value in Ada
1656 that can be referenced in assembly language units to be linked with
1657 the application. This pragma is currently supported only for the
1658 AAMP target and is ignored for other targets.
1659
1660 @node Pragma Export_Valued_Procedure
1661 @unnumberedsec Pragma Export_Valued_Procedure
1662 @findex Export_Valued_Procedure
1663 @noindent
1664 Syntax:
1665
1666 @smallexample @c ada
1667 pragma Export_Valued_Procedure (
1668      [Internal        =>] LOCAL_NAME
1669   [, [External        =>] EXTERNAL_SYMBOL]
1670   [, [Parameter_Types =>] PARAMETER_TYPES]
1671   [, [Mechanism       =>] MECHANISM]);
1672
1673 EXTERNAL_SYMBOL ::=
1674   IDENTIFIER
1675 | static_string_EXPRESSION
1676 | ""
1677
1678 PARAMETER_TYPES ::=
1679   null
1680 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1681
1682 TYPE_DESIGNATOR ::=
1683   subtype_NAME
1684 | subtype_Name ' Access
1685
1686 MECHANISM ::=
1687   MECHANISM_NAME
1688 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1689
1690 MECHANISM_ASSOCIATION ::=
1691   [formal_parameter_NAME =>] MECHANISM_NAME
1692
1693 MECHANISM_NAME ::=
1694   Value
1695 | Reference
1696 @end smallexample
1697
1698 @noindent
1699 This pragma is identical to @code{Export_Procedure} except that the
1700 first parameter of @var{local_name}, which must be present, must be of
1701 mode @code{OUT}, and externally the subprogram is treated as a function
1702 with this parameter as the result of the function.  GNAT provides for
1703 this capability to allow the use of @code{OUT} and @code{IN OUT}
1704 parameters in interfacing to external functions (which are not permitted
1705 in Ada functions).
1706 GNAT does not require a separate pragma @code{Export}, but if none is
1707 present, @code{Convention Ada} is assumed, which is almost certainly
1708 not what is wanted since the whole point of this pragma is to interface
1709 with foreign language functions, so it is usually appropriate to use this
1710 pragma in conjunction with a @code{Export} or @code{Convention}
1711 pragma that specifies the desired foreign convention.
1712
1713 @cindex OpenVMS
1714 @cindex Passing by descriptor
1715 Note that passing by descriptor is not supported, even on the OpenVMS
1716 ports of GNAT@.
1717
1718 @cindex Suppressing external name
1719 Special treatment is given if the EXTERNAL is an explicit null
1720 string or a static string expressions that evaluates to the null
1721 string. In this case, no external name is generated. This form
1722 still allows the specification of parameter mechanisms.
1723
1724 @node Pragma Extend_System
1725 @unnumberedsec Pragma Extend_System
1726 @cindex @code{system}, extending
1727 @cindex Dec Ada 83
1728 @findex Extend_System
1729 @noindent
1730 Syntax:
1731
1732 @smallexample @c ada
1733 pragma Extend_System ([Name =>] IDENTIFIER);
1734 @end smallexample
1735
1736 @noindent
1737 This pragma is used to provide backwards compatibility with other
1738 implementations that extend the facilities of package @code{System}.  In
1739 GNAT, @code{System} contains only the definitions that are present in
1740 the Ada 95 RM@.  However, other implementations, notably the DEC Ada 83
1741 implementation, provide many extensions to package @code{System}.
1742
1743 For each such implementation accommodated by this pragma, GNAT provides a
1744 package @code{Aux_@var{xxx}}, e.g.@: @code{Aux_DEC} for the DEC Ada 83
1745 implementation, which provides the required additional definitions.  You
1746 can use this package in two ways.  You can @code{with} it in the normal
1747 way and access entities either by selection or using a @code{use}
1748 clause.  In this case no special processing is required.
1749
1750 However, if existing code contains references such as
1751 @code{System.@var{xxx}} where @var{xxx} is an entity in the extended
1752 definitions provided in package @code{System}, you may use this pragma
1753 to extend visibility in @code{System} in a non-standard way that
1754 provides greater compatibility with the existing code.  Pragma
1755 @code{Extend_System} is a configuration pragma whose single argument is
1756 the name of the package containing the extended definition
1757 (e.g.@: @code{Aux_DEC} for the DEC Ada case).  A unit compiled under
1758 control of this pragma will be processed using special visibility
1759 processing that looks in package @code{System.Aux_@var{xxx}} where
1760 @code{Aux_@var{xxx}} is the pragma argument for any entity referenced in
1761 package @code{System}, but not found in package @code{System}.
1762
1763 You can use this pragma either to access a predefined @code{System}
1764 extension supplied with the compiler, for example @code{Aux_DEC} or
1765 you can construct your own extension unit following the above
1766 definition.  Note that such a package is a child of @code{System}
1767 and thus is considered part of the implementation.  To compile
1768 it you will have to use the appropriate switch for compiling
1769 system units.  See the GNAT User's Guide for details.
1770
1771 @node Pragma External
1772 @unnumberedsec Pragma External
1773 @findex External
1774 @noindent
1775 Syntax:
1776
1777 @smallexample @c ada
1778 pragma External (
1779   [   Convention    =>] convention_IDENTIFIER,
1780   [   Entity        =>] local_NAME
1781   [, [External_Name =>] static_string_EXPRESSION ]
1782   [, [Link_Name     =>] static_string_EXPRESSION ]);
1783 @end smallexample
1784
1785 @noindent
1786 This pragma is identical in syntax and semantics to pragma
1787 @code{Export} as defined in the Ada Reference Manual.  It is
1788 provided for compatibility with some Ada 83 compilers that
1789 used this pragma for exactly the same purposes as pragma
1790 @code{Export} before the latter was standardized.
1791
1792 @node Pragma External_Name_Casing
1793 @unnumberedsec Pragma External_Name_Casing
1794 @cindex Dec Ada 83 casing compatibility
1795 @cindex External Names, casing
1796 @cindex Casing of External names
1797 @findex External_Name_Casing
1798 @noindent
1799 Syntax:
1800
1801 @smallexample @c ada
1802 pragma External_Name_Casing (
1803   Uppercase | Lowercase
1804   [, Uppercase | Lowercase | As_Is]);
1805 @end smallexample
1806
1807 @noindent
1808 This pragma provides control over the casing of external names associated
1809 with Import and Export pragmas.  There are two cases to consider:
1810
1811 @table @asis
1812 @item Implicit external names
1813 Implicit external names are derived from identifiers.  The most common case
1814 arises when a standard Ada 95 Import or Export pragma is used with only two
1815 arguments, as in:
1816
1817 @smallexample @c ada
1818    pragma Import (C, C_Routine);
1819 @end smallexample
1820
1821 @noindent
1822 Since Ada is a case insensitive language, the spelling of the identifier in
1823 the Ada source program does not provide any information on the desired
1824 casing of the external name, and so a convention is needed.  In GNAT the
1825 default treatment is that such names are converted to all lower case
1826 letters.  This corresponds to the normal C style in many environments.
1827 The first argument of pragma @code{External_Name_Casing} can be used to
1828 control this treatment.  If @code{Uppercase} is specified, then the name
1829 will be forced to all uppercase letters.  If @code{Lowercase} is specified,
1830 then the normal default of all lower case letters will be used.
1831
1832 This same implicit treatment is also used in the case of extended DEC Ada 83
1833 compatible Import and Export pragmas where an external name is explicitly
1834 specified using an identifier rather than a string.
1835
1836 @item Explicit external names
1837 Explicit external names are given as string literals.  The most common case
1838 arises when a standard Ada 95 Import or Export pragma is used with three
1839 arguments, as in:
1840
1841 @smallexample @c ada
1842 pragma Import (C, C_Routine, "C_routine");
1843 @end smallexample
1844
1845 @noindent
1846 In this case, the string literal normally provides the exact casing required
1847 for the external name.  The second argument of pragma
1848 @code{External_Name_Casing} may be used to modify this behavior.
1849 If @code{Uppercase} is specified, then the name
1850 will be forced to all uppercase letters.  If @code{Lowercase} is specified,
1851 then the name will be forced to all lowercase letters.  A specification of
1852 @code{As_Is} provides the normal default behavior in which the casing is
1853 taken from the string provided.
1854 @end table
1855
1856 @noindent
1857 This pragma may appear anywhere that a pragma is valid.  In particular, it
1858 can be used as a configuration pragma in the @file{gnat.adc} file, in which
1859 case it applies to all subsequent compilations, or it can be used as a program
1860 unit pragma, in which case it only applies to the current unit, or it can
1861 be used more locally to control individual Import/Export pragmas.
1862
1863 It is primarily intended for use with OpenVMS systems, where many
1864 compilers convert all symbols to upper case by default.  For interfacing to
1865 such compilers (e.g.@: the DEC C compiler), it may be convenient to use
1866 the pragma:
1867
1868 @smallexample @c ada
1869 pragma External_Name_Casing (Uppercase, Uppercase);
1870 @end smallexample
1871
1872 @noindent
1873 to enforce the upper casing of all external symbols.
1874
1875 @node Pragma Finalize_Storage_Only
1876 @unnumberedsec Pragma Finalize_Storage_Only
1877 @findex Finalize_Storage_Only
1878 @noindent
1879 Syntax:
1880
1881 @smallexample @c ada
1882 pragma Finalize_Storage_Only (first_subtype_LOCAL_NAME);
1883 @end smallexample
1884
1885 @noindent
1886 This pragma allows the compiler not to emit a Finalize call for objects
1887 defined at the library level.  This is mostly useful for types where
1888 finalization is only used to deal with storage reclamation since in most
1889 environments it is not necessary to reclaim memory just before terminating
1890 execution, hence the name.
1891
1892 @node Pragma Float_Representation
1893 @unnumberedsec Pragma Float_Representation
1894 @cindex OpenVMS
1895 @findex Float_Representation
1896 @noindent
1897 Syntax:
1898
1899 @smallexample @c ada
1900 pragma Float_Representation (FLOAT_REP);
1901
1902 FLOAT_REP ::= VAX_Float | IEEE_Float
1903 @end smallexample
1904
1905 @noindent
1906 This pragma
1907 allows control over the internal representation chosen for the predefined
1908 floating point types declared in the packages @code{Standard} and
1909 @code{System}. On all systems other than OpenVMS, the argument must
1910 be @code{IEEE_Float} and the pragma has no effect. On OpenVMS, the
1911 argument may be @code{VAX_Float} to specify the use of the VAX float
1912 format for the floating-point types in Standard. This requires that
1913 the standard runtime libraries be recompiled. See the
1914 description of the @code{GNAT LIBRARY} command in the OpenVMS version
1915 of the GNAT Users Guide for details on the use of this command.
1916
1917 @node Pragma Ident
1918 @unnumberedsec Pragma Ident
1919 @findex Ident
1920 @noindent
1921 Syntax:
1922
1923 @smallexample @c ada
1924 pragma Ident (static_string_EXPRESSION);
1925 @end smallexample
1926
1927 @noindent
1928 This pragma provides a string identification in the generated object file,
1929 if the system supports the concept of this kind of identification string.
1930 This pragma is allowed only in the outermost declarative part or
1931 declarative items of a compilation unit. If more than one @code{Ident}
1932 pragma is given, only the last one processed is effective.
1933 @cindex OpenVMS
1934 On OpenVMS systems, the effect of the pragma is identical to the effect of
1935 the DEC Ada 83 pragma of the same name. Note that in DEC Ada 83, the
1936 maximum allowed length is 31 characters, so if it is important to
1937 maintain compatibility with this compiler, you should obey this length
1938 limit.
1939
1940 @node Pragma Import_Exception
1941 @unnumberedsec Pragma Import_Exception
1942 @cindex OpenVMS
1943 @findex Import_Exception
1944 @noindent
1945 Syntax:
1946
1947 @smallexample @c ada
1948 pragma Import_Exception (
1949      [Internal =>] LOCAL_NAME,
1950   [, [External =>] EXTERNAL_SYMBOL,]
1951   [, [Form     =>] Ada | VMS]
1952   [, [Code     =>] static_integer_EXPRESSION]);
1953
1954 EXTERNAL_SYMBOL ::=
1955   IDENTIFIER
1956 | static_string_EXPRESSION
1957 @end smallexample
1958
1959 @noindent
1960 This pragma is implemented only in the OpenVMS implementation of GNAT@.
1961 It allows OpenVMS conditions (for example, from OpenVMS system services or
1962 other OpenVMS languages) to be propagated to Ada programs as Ada exceptions.
1963 The pragma specifies that the exception associated with an exception
1964 declaration in an Ada program be defined externally (in non-Ada code).
1965 For further details on this pragma, see the
1966 DEC Ada Language Reference Manual, section 13.9a.3.1.
1967
1968 @node Pragma Import_Function
1969 @unnumberedsec Pragma Import_Function
1970 @findex Import_Function
1971 @noindent
1972 Syntax:
1973
1974 @smallexample @c ada
1975 pragma Import_Function (
1976      [Internal                 =>] LOCAL_NAME,
1977   [, [External                 =>] EXTERNAL_SYMBOL]
1978   [, [Parameter_Types          =>] PARAMETER_TYPES]
1979   [, [Result_Type              =>] SUBTYPE_MARK]
1980   [, [Mechanism                =>] MECHANISM]
1981   [, [Result_Mechanism         =>] MECHANISM_NAME]
1982   [, [First_Optional_Parameter =>] IDENTIFIER]);
1983
1984 EXTERNAL_SYMBOL ::=
1985   IDENTIFIER
1986 | static_string_EXPRESSION
1987
1988 PARAMETER_TYPES ::=
1989   null
1990 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
1991
1992 TYPE_DESIGNATOR ::=
1993   subtype_NAME
1994 | subtype_Name ' Access
1995
1996 MECHANISM ::=
1997   MECHANISM_NAME
1998 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
1999
2000 MECHANISM_ASSOCIATION ::=
2001   [formal_parameter_NAME =>] MECHANISM_NAME
2002
2003 MECHANISM_NAME ::=
2004   Value
2005 | Reference
2006 | Descriptor [([Class =>] CLASS_NAME)]
2007
2008 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2009 @end smallexample
2010
2011 @noindent
2012 This pragma is used in conjunction with a pragma @code{Import} to
2013 specify additional information for an imported function.  The pragma
2014 @code{Import} (or equivalent pragma @code{Interface}) must precede the
2015 @code{Import_Function} pragma and both must appear in the same
2016 declarative part as the function specification.
2017
2018 The @var{Internal} argument must uniquely designate
2019 the function to which the
2020 pragma applies.  If more than one function name exists of this name in
2021 the declarative part you must use the @code{Parameter_Types} and
2022 @var{Result_Type} parameters to achieve the required unique
2023 designation.  Subtype marks in these parameters must exactly match the
2024 subtypes in the corresponding function specification, using positional
2025 notation to match parameters with subtype marks.
2026 The form with an @code{'Access} attribute can be used to match an
2027 anonymous access parameter.
2028
2029 You may optionally use the @var{Mechanism} and @var{Result_Mechanism}
2030 parameters to specify passing mechanisms for the
2031 parameters and result.  If you specify a single mechanism name, it
2032 applies to all parameters.  Otherwise you may specify a mechanism on a
2033 parameter by parameter basis using either positional or named
2034 notation.  If the mechanism is not specified, the default mechanism
2035 is used.
2036
2037 @cindex OpenVMS
2038 @cindex Passing by descriptor
2039 Passing by descriptor is supported only on the OpenVMS ports of GNAT@.
2040
2041 @code{First_Optional_Parameter} applies only to OpenVMS ports of GNAT@.
2042 It specifies that the designated parameter and all following parameters
2043 are optional, meaning that they are not passed at the generated code
2044 level (this is distinct from the notion of optional parameters in Ada
2045 where the parameters are passed anyway with the designated optional
2046 parameters).  All optional parameters must be of mode @code{IN} and have
2047 default parameter values that are either known at compile time
2048 expressions, or uses of the @code{'Null_Parameter} attribute.
2049
2050 @node Pragma Import_Object
2051 @unnumberedsec Pragma Import_Object
2052 @findex Import_Object
2053 @noindent
2054 Syntax:
2055
2056 @smallexample @c ada
2057 pragma Import_Object
2058      [Internal =>] LOCAL_NAME,
2059   [, [External =>] EXTERNAL_SYMBOL],
2060   [, [Size     =>] EXTERNAL_SYMBOL]);
2061
2062 EXTERNAL_SYMBOL ::=
2063   IDENTIFIER
2064 | static_string_EXPRESSION
2065 @end smallexample
2066
2067 @noindent
2068 This pragma designates an object as imported, and apart from the
2069 extended rules for external symbols, is identical in effect to the use of
2070 the normal @code{Import} pragma applied to an object.  Unlike the
2071 subprogram case, you need not use a separate @code{Import} pragma,
2072 although you may do so (and probably should do so from a portability
2073 point of view).  @var{size} is syntax checked, but otherwise ignored by
2074 GNAT@.
2075
2076 @node Pragma Import_Procedure
2077 @unnumberedsec Pragma Import_Procedure
2078 @findex Import_Procedure
2079 @noindent
2080 Syntax:
2081
2082 @smallexample @c ada
2083 pragma Import_Procedure (
2084      [Internal                 =>] LOCAL_NAME,
2085   [, [External                 =>] EXTERNAL_SYMBOL]
2086   [, [Parameter_Types          =>] PARAMETER_TYPES]
2087   [, [Mechanism                =>] MECHANISM]
2088   [, [First_Optional_Parameter =>] IDENTIFIER]);
2089
2090 EXTERNAL_SYMBOL ::=
2091   IDENTIFIER
2092 | static_string_EXPRESSION
2093
2094 PARAMETER_TYPES ::=
2095   null
2096 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2097
2098 TYPE_DESIGNATOR ::=
2099   subtype_NAME
2100 | subtype_Name ' Access
2101
2102 MECHANISM ::=
2103   MECHANISM_NAME
2104 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2105
2106 MECHANISM_ASSOCIATION ::=
2107   [formal_parameter_NAME =>] MECHANISM_NAME
2108
2109 MECHANISM_NAME ::=
2110   Value
2111 | Reference
2112 | Descriptor [([Class =>] CLASS_NAME)]
2113
2114 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2115 @end smallexample
2116
2117 @noindent
2118 This pragma is identical to @code{Import_Function} except that it
2119 applies to a procedure rather than a function and the parameters
2120 @code{Result_Type} and @code{Result_Mechanism} are not permitted.
2121
2122 @node Pragma Import_Valued_Procedure
2123 @unnumberedsec Pragma Import_Valued_Procedure
2124 @findex Import_Valued_Procedure
2125 @noindent
2126 Syntax:
2127
2128 @smallexample @c ada
2129 pragma Import_Valued_Procedure (
2130      [Internal                 =>] LOCAL_NAME,
2131   [, [External                 =>] EXTERNAL_SYMBOL]
2132   [, [Parameter_Types          =>] PARAMETER_TYPES]
2133   [, [Mechanism                =>] MECHANISM]
2134   [, [First_Optional_Parameter =>] IDENTIFIER]);
2135
2136 EXTERNAL_SYMBOL ::=
2137   IDENTIFIER
2138 | static_string_EXPRESSION
2139
2140 PARAMETER_TYPES ::=
2141   null
2142 | TYPE_DESIGNATOR @{, TYPE_DESIGNATOR@}
2143
2144 TYPE_DESIGNATOR ::=
2145   subtype_NAME
2146 | subtype_Name ' Access
2147
2148 MECHANISM ::=
2149   MECHANISM_NAME
2150 | (MECHANISM_ASSOCIATION @{, MECHANISM_ASSOCIATION@})
2151
2152 MECHANISM_ASSOCIATION ::=
2153   [formal_parameter_NAME =>] MECHANISM_NAME
2154
2155 MECHANISM_NAME ::=
2156   Value
2157 | Reference
2158 | Descriptor [([Class =>] CLASS_NAME)]
2159
2160 CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca
2161 @end smallexample
2162
2163 @noindent
2164 This pragma is identical to @code{Import_Procedure} except that the
2165 first parameter of @var{local_name}, which must be present, must be of
2166 mode @code{OUT}, and externally the subprogram is treated as a function
2167 with this parameter as the result of the function.  The purpose of this
2168 capability is to allow the use of @code{OUT} and @code{IN OUT}
2169 parameters in interfacing to external functions (which are not permitted
2170 in Ada functions).  You may optionally use the @code{Mechanism}
2171 parameters to specify passing mechanisms for the parameters.
2172 If you specify a single mechanism name, it applies to all parameters.
2173 Otherwise you may specify a mechanism on a parameter by parameter
2174 basis using either positional or named notation.  If the mechanism is not
2175 specified, the default mechanism is used.
2176
2177 Note that it is important to use this pragma in conjunction with a separate
2178 pragma Import that specifies the desired convention, since otherwise the
2179 default convention is Ada, which is almost certainly not what is required.
2180
2181 @node Pragma Initialize_Scalars
2182 @unnumberedsec Pragma Initialize_Scalars
2183 @findex Initialize_Scalars
2184 @cindex debugging with Initialize_Scalars
2185 @noindent
2186 Syntax:
2187
2188 @smallexample @c ada
2189 pragma Initialize_Scalars;
2190 @end smallexample
2191
2192 @noindent
2193 This pragma is similar to @code{Normalize_Scalars} conceptually but has
2194 two important differences.  First, there is no requirement for the pragma
2195 to be used uniformly in all units of a partition, in particular, it is fine
2196 to use this just for some or all of the application units of a partition,
2197 without needing to recompile the run-time library.
2198
2199 In the case where some units are compiled with the pragma, and some without,
2200 then a declaration of a variable where the type is defined in package
2201 Standard or is locally declared will always be subject to initialization,
2202 as will any declaration of a scalar variable.  For composite variables,
2203 whether the variable is initialized may also depend on whether the package
2204 in which the type of the variable is declared is compiled with the pragma.
2205
2206 The other important difference is that there is control over the value used
2207 for initializing scalar objects.  At bind time, you can select whether to
2208 initialize with invalid values (like Normalize_Scalars), or with high or
2209 low values, or with a specified bit pattern.  See the users guide for binder
2210 options for specifying these cases.
2211
2212 This means that you can compile a program, and then without having to
2213 recompile the program, you can run it with different values being used
2214 for initializing otherwise uninitialized values, to test if your program
2215 behavior depends on the choice.  Of course the behavior should not change,
2216 and if it does, then most likely you have an erroneous reference to an
2217 uninitialized value.
2218
2219 Note that pragma @code{Initialize_Scalars} is particularly useful in
2220 conjunction with the enhanced validity checking that is now provided
2221 in GNAT, which checks for invalid values under more conditions.
2222 Using this feature (see description of the @code{-gnatV} flag in the
2223 users guide) in conjunction with pragma @code{Initialize_Scalars}
2224 provides a powerful new tool to assist in the detection of problems
2225 caused by uninitialized variables.
2226
2227 @node Pragma Inline_Always
2228 @unnumberedsec Pragma Inline_Always
2229 @findex Inline_Always
2230 @noindent
2231 Syntax:
2232
2233 @smallexample @c ada
2234 pragma Inline_Always (NAME [, NAME]);
2235 @end smallexample
2236
2237 @noindent
2238 Similar to pragma @code{Inline} except that inlining is not subject to
2239 the use of option @code{-gnatn} and the inlining happens regardless of
2240 whether this option is used.
2241
2242 @node Pragma Inline_Generic
2243 @unnumberedsec Pragma Inline_Generic
2244 @findex Inline_Generic
2245 @noindent
2246 Syntax:
2247
2248 @smallexample @c ada
2249 pragma Inline_Generic (generic_package_NAME);
2250 @end smallexample
2251
2252 @noindent
2253 This is implemented for compatibility with DEC Ada 83 and is recognized,
2254 but otherwise ignored, by GNAT@.  All generic instantiations are inlined
2255 by default when using GNAT@.
2256
2257 @node Pragma Interface
2258 @unnumberedsec Pragma Interface
2259 @findex Interface
2260 @noindent
2261 Syntax:
2262
2263 @smallexample @c ada
2264 pragma Interface (
2265      [Convention    =>] convention_identifier,
2266      [Entity =>] local_name
2267   [, [External_Name =>] static_string_expression],
2268   [, [Link_Name     =>] static_string_expression]);
2269 @end smallexample
2270
2271 @noindent
2272 This pragma is identical in syntax and semantics to
2273 the standard Ada 95 pragma @code{Import}.  It is provided for compatibility
2274 with Ada 83.  The definition is upwards compatible both with pragma
2275 @code{Interface} as defined in the Ada 83 Reference Manual, and also
2276 with some extended implementations of this pragma in certain Ada 83
2277 implementations.
2278
2279 @node Pragma Interface_Name
2280 @unnumberedsec Pragma Interface_Name
2281 @findex Interface_Name
2282 @noindent
2283 Syntax:
2284
2285 @smallexample @c ada
2286 pragma Interface_Name (
2287      [Entity        =>] LOCAL_NAME
2288   [, [External_Name =>] static_string_EXPRESSION]
2289   [, [Link_Name     =>] static_string_EXPRESSION]);
2290 @end smallexample
2291
2292 @noindent
2293 This pragma provides an alternative way of specifying the interface name
2294 for an interfaced subprogram, and is provided for compatibility with Ada
2295 83 compilers that use the pragma for this purpose.  You must provide at
2296 least one of @var{External_Name} or @var{Link_Name}.
2297
2298 @node Pragma Interrupt_Handler
2299 @unnumberedsec Pragma Interrupt_Handler
2300 @findex Interrupt_Handler
2301 @noindent
2302 Syntax:
2303
2304 @smallexample @c ada
2305 pragma Interrupt_Handler (procedure_LOCAL_NAME);
2306 @end smallexample
2307
2308 @noindent
2309 This program unit pragma is supported for parameterless protected procedures
2310 as described in Annex C of the Ada Reference Manual. On the AAMP target
2311 the pragma can also be specified for nonprotected parameterless procedures
2312 that are declared at the library level (which includes procedures
2313 declared at the top level of a library package). In the case of AAMP,
2314 when this pragma is applied to a nonprotected procedure, the instruction
2315 @code{IERET} is generated for returns from the procedure, enabling
2316 maskable interrupts, in place of the normal return instruction.
2317
2318 @node Pragma Interrupt_State
2319 @unnumberedsec Pragma Interrupt_State
2320 @findex Interrupt_State
2321 @noindent
2322 Syntax:
2323
2324 @smallexample @c ada
2325 pragma Interrupt_State (Name => value, State => SYSTEM | RUNTIME | USER);
2326 @end smallexample
2327
2328 @noindent
2329 Normally certain interrupts are reserved to the implementation.  Any attempt
2330 to attach an interrupt causes Program_Error to be raised, as described in
2331 RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
2332 many systems for an @kbd{Ctrl-C} interrupt.  Normally this interrupt is
2333 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
2334 interrupt execution.  Additionally, signals such as @code{SIGSEGV},
2335 @code{SIGABRT}, @code{SIGFPE} and @code{SIGILL} are often mapped to specific
2336 Ada exceptions, or used to implement run-time functions such as the
2337 @code{abort} statement and stack overflow checking.
2338
2339 Pragma @code{Interrupt_State} provides a general mechanism for overriding
2340 such uses of interrupts.  It subsumes the functionality of pragma
2341 @code{Unreserve_All_Interrupts}.  Pragma @code{Interrupt_State} is not
2342 available on OS/2, Windows or VMS.  On all other platforms than VxWorks,
2343 it applies to signals; on VxWorks, it applies to vectored hardware interrupts
2344 and may be used to mark interrupts required by the board support package
2345 as reserved.
2346
2347 Interrupts can be in one of three states:
2348 @itemize @bullet
2349 @item System
2350
2351 The interrupt is reserved (no Ada handler can be installed), and the
2352 Ada run-time may not install a handler. As a result you are guaranteed
2353 standard system default action if this interrupt is raised.
2354
2355 @item Runtime
2356
2357 The interrupt is reserved (no Ada handler can be installed). The run time
2358 is allowed to install a handler for internal control purposes, but is
2359 not required to do so.
2360
2361 @item User
2362
2363 The interrupt is unreserved.  The user may install a handler to provide
2364 some other action.
2365 @end itemize
2366
2367 @noindent
2368 These states are the allowed values of the @code{State} parameter of the
2369 pragma.  The @code{Name} parameter is a value of the type
2370 @code{Ada.Interrupts.Interrupt_ID}.  Typically, it is a name declared in
2371 @code{Ada.Interrupts.Names}.
2372
2373 This is a configuration pragma, and the binder will check that there
2374 are no inconsistencies between different units in a partition in how a
2375 given interrupt is specified. It may appear anywhere a pragma is legal.
2376
2377 The effect is to move the interrupt to the specified state.
2378
2379 By declaring interrupts to be SYSTEM, you guarantee the standard system
2380 action, such as a core dump.
2381
2382 By declaring interrupts to be USER, you guarantee that you can install
2383 a handler.
2384
2385 Note that certain signals on many operating systems cannot be caught and
2386 handled by applications.  In such cases, the pragma is ignored.  See the
2387 operating system documentation, or the value of the array @code{Reserved}
2388 declared in the specification of package @code{System.OS_Interface}.
2389
2390 Overriding the default state of signals used by the Ada runtime may interfere
2391 with an application's runtime behavior in the cases of the synchronous signals,
2392 and in the case of the signal used to implement the @code{abort} statement.
2393
2394 @node Pragma Keep_Names
2395 @unnumberedsec Pragma Keep_Names
2396 @findex Keep_Names
2397 @noindent
2398 Syntax:
2399
2400 @smallexample @c ada
2401 pragma Keep_Names ([On =>] enumeration_first_subtype_LOCAL_NAME);
2402 @end smallexample
2403
2404 @noindent
2405 The @var{LOCAL_NAME} argument
2406 must refer to an enumeration first subtype
2407 in the current declarative part. The effect is to retain the enumeration
2408 literal names for use by @code{Image} and @code{Value} even if a global
2409 @code{Discard_Names} pragma applies. This is useful when you want to
2410 generally suppress enumeration literal names and for example you therefore
2411 use a @code{Discard_Names} pragma in the @file{gnat.adc} file, but you
2412 want to retain the names for specific enumeration types.
2413
2414 @node Pragma License
2415 @unnumberedsec Pragma License
2416 @findex License
2417 @cindex License checking
2418 @noindent
2419 Syntax:
2420
2421 @smallexample @c ada
2422 pragma License (Unrestricted | GPL | Modified_GPL | Restricted);
2423 @end smallexample
2424
2425 @noindent
2426 This pragma is provided to allow automated checking for appropriate license
2427 conditions with respect to the standard and modified GPL@.  A pragma
2428 @code{License}, which is a configuration pragma that typically appears at
2429 the start of a source file or in a separate @file{gnat.adc} file, specifies
2430 the licensing conditions of a unit as follows:
2431
2432 @itemize @bullet
2433 @item Unrestricted
2434 This is used for a unit that can be freely used with no license restrictions.
2435 Examples of such units are public domain units, and units from the Ada
2436 Reference Manual.
2437
2438 @item GPL
2439 This is used for a unit that is licensed under the unmodified GPL, and which
2440 therefore cannot be @code{with}'ed by a restricted unit.
2441
2442 @item Modified_GPL
2443 This is used for a unit licensed under the GNAT modified GPL that includes
2444 a special exception paragraph that specifically permits the inclusion of
2445 the unit in programs without requiring the entire program to be released
2446 under the GPL@.  This is the license used for the GNAT run-time which ensures
2447 that the run-time can be used freely in any program without GPL concerns.
2448
2449 @item Restricted
2450 This is used for a unit that is restricted in that it is not permitted to
2451 depend on units that are licensed under the GPL@.  Typical examples are
2452 proprietary code that is to be released under more restrictive license
2453 conditions.  Note that restricted units are permitted to @code{with} units
2454 which are licensed under the modified GPL (this is the whole point of the
2455 modified GPL).
2456
2457 @end itemize
2458
2459 @noindent
2460 Normally a unit with no @code{License} pragma is considered to have an
2461 unknown license, and no checking is done.  However, standard GNAT headers
2462 are recognized, and license information is derived from them as follows.
2463
2464 @itemize @bullet
2465
2466 A GNAT license header starts with a line containing 78 hyphens.  The following
2467 comment text is searched for the appearance of any of the following strings.
2468
2469 If the string ``GNU General Public License'' is found, then the unit is assumed
2470 to have GPL license, unless the string ``As a special exception'' follows, in
2471 which case the license is assumed to be modified GPL@.
2472
2473 If one of the strings
2474 ``This specification is adapted from the Ada Semantic Interface'' or
2475 ``This specification is derived from the Ada Reference Manual'' is found
2476 then the unit is assumed to be unrestricted.
2477 @end itemize
2478
2479 @noindent
2480 These default actions means that a program with a restricted license pragma
2481 will automatically get warnings if a GPL unit is inappropriately
2482 @code{with}'ed.  For example, the program:
2483
2484 @smallexample @c ada
2485 with Sem_Ch3;
2486 with GNAT.Sockets;
2487 procedure Secret_Stuff is
2488   @dots{}
2489 end Secret_Stuff
2490 @end smallexample
2491
2492 @noindent
2493 if compiled with pragma @code{License} (@code{Restricted}) in a
2494 @file{gnat.adc} file will generate the warning:
2495
2496 @smallexample
2497 1.  with Sem_Ch3;
2498         |
2499    >>> license of withed unit "Sem_Ch3" is incompatible
2500
2501 2.  with GNAT.Sockets;
2502 3.  procedure Secret_Stuff is
2503 @end smallexample
2504
2505 @noindent
2506 Here we get a warning on @code{Sem_Ch3} since it is part of the GNAT
2507 compiler and is licensed under the
2508 GPL, but no warning for @code{GNAT.Sockets} which is part of the GNAT
2509 run time, and is therefore licensed under the modified GPL@.
2510
2511 @node Pragma Link_With
2512 @unnumberedsec Pragma Link_With
2513 @findex Link_With
2514 @noindent
2515 Syntax:
2516
2517 @smallexample @c ada
2518 pragma Link_With (static_string_EXPRESSION @{,static_string_EXPRESSION@});
2519 @end smallexample
2520
2521 @noindent
2522 This pragma is provided for compatibility with certain Ada 83 compilers.
2523 It has exactly the same effect as pragma @code{Linker_Options} except
2524 that spaces occurring within one of the string expressions are treated
2525 as separators. For example, in the following case:
2526
2527 @smallexample @c ada
2528 pragma Link_With ("-labc -ldef");
2529 @end smallexample
2530
2531 @noindent
2532 results in passing the strings @code{-labc} and @code{-ldef} as two
2533 separate arguments to the linker. In addition pragma Link_With allows
2534 multiple arguments, with the same effect as successive pragmas.
2535
2536 @node Pragma Linker_Alias
2537 @unnumberedsec Pragma Linker_Alias
2538 @findex Linker_Alias
2539 @noindent
2540 Syntax:
2541
2542 @smallexample @c ada
2543 pragma Linker_Alias (
2544   [Entity =>] LOCAL_NAME
2545   [Alias  =>] static_string_EXPRESSION);
2546 @end smallexample
2547
2548 @noindent
2549 This pragma establishes a linker alias for the given named entity.  For
2550 further details on the exact effect, consult the GCC manual.
2551
2552 @node Pragma Linker_Section
2553 @unnumberedsec Pragma Linker_Section
2554 @findex Linker_Section
2555 @noindent
2556 Syntax:
2557
2558 @smallexample @c ada
2559 pragma Linker_Section (
2560   [Entity  =>] LOCAL_NAME
2561   [Section =>] static_string_EXPRESSION);
2562 @end smallexample
2563
2564 @noindent
2565 This pragma specifies the name of the linker section for the given entity.
2566 For further details on the exact effect, consult the GCC manual.
2567
2568 @node Pragma Long_Float
2569 @unnumberedsec Pragma Long_Float
2570 @cindex OpenVMS
2571 @findex Long_Float
2572 @noindent
2573 Syntax:
2574
2575 @smallexample @c ada
2576 pragma Long_Float (FLOAT_FORMAT);
2577
2578 FLOAT_FORMAT ::= D_Float | G_Float
2579 @end smallexample
2580
2581 @noindent
2582 This pragma is implemented only in the OpenVMS implementation of GNAT@.
2583 It allows control over the internal representation chosen for the predefined
2584 type @code{Long_Float} and for floating point type representations with
2585 @code{digits} specified in the range 7 through 15.
2586 For further details on this pragma, see the
2587 @cite{DEC Ada Language Reference Manual}, section 3.5.7b.  Note that to use
2588 this pragma, the standard runtime libraries must be recompiled.  See the
2589 description of the @code{GNAT LIBRARY} command in the OpenVMS version
2590 of the GNAT User's Guide for details on the use of this command.
2591
2592 @node Pragma Machine_Attribute
2593 @unnumberedsec Pragma Machine_Attribute
2594 @findex Machine_Attribute
2595 @noindent
2596 Syntax:
2597
2598 @smallexample @c ada
2599 pragma Machine_Attribute (
2600   [Attribute_Name =>] string_EXPRESSION,
2601   [Entity         =>] LOCAL_NAME);
2602 @end smallexample
2603
2604 @noindent
2605 Machine dependent attributes can be specified for types and/or
2606 declarations.  Currently only subprogram entities are supported.  This
2607 pragma is semantically equivalent to
2608 @code{__attribute__((@var{string_expression}))} in GNU C,
2609 where @code{@var{string_expression}} is
2610 recognized by the GNU C macros @code{VALID_MACHINE_TYPE_ATTRIBUTE} and
2611 @code{VALID_MACHINE_DECL_ATTRIBUTE} which are defined in the
2612 configuration header file @file{tm.h} for each machine.  See the GCC
2613 manual for further information.
2614
2615 @node Pragma Main_Storage
2616 @unnumberedsec Pragma Main_Storage
2617 @cindex OpenVMS
2618 @findex Main_Storage
2619 @noindent
2620 Syntax:
2621
2622 @smallexample @c ada
2623 pragma Main_Storage
2624   (MAIN_STORAGE_OPTION [, MAIN_STORAGE_OPTION]);
2625
2626 MAIN_STORAGE_OPTION ::=
2627   [WORKING_STORAGE =>] static_SIMPLE_EXPRESSION
2628 | [TOP_GUARD       =>] static_SIMPLE_EXPRESSION
2629
2630 @end smallexample
2631
2632 @noindent
2633 This pragma is provided for compatibility with OpenVMS VAX Systems.  It has
2634 no effect in GNAT, other than being syntax checked.  Note that the pragma
2635 also has no effect in DEC Ada 83 for OpenVMS Alpha Systems.
2636
2637 @node Pragma No_Return
2638 @unnumberedsec Pragma No_Return
2639 @findex No_Return
2640 @noindent
2641 Syntax:
2642
2643 @smallexample @c ada
2644 pragma No_Return (procedure_LOCAL_NAME);
2645 @end smallexample
2646
2647 @noindent
2648 @var{procedure_local_NAME} must refer to one or more procedure
2649 declarations in the current declarative part.  A procedure to which this
2650 pragma is applied may not contain any explicit @code{return} statements,
2651 and also may not contain any implicit return statements from falling off
2652 the end of a statement sequence.  One use of this pragma is to identify
2653 procedures whose only purpose is to raise an exception.
2654
2655 Another use of this pragma is to suppress incorrect warnings about
2656 missing returns in functions, where the last statement of a function
2657 statement sequence is a call to such a procedure.
2658
2659 @node Pragma Normalize_Scalars
2660 @unnumberedsec Pragma Normalize_Scalars
2661 @findex Normalize_Scalars
2662 @noindent
2663 Syntax:
2664
2665 @smallexample @c ada
2666 pragma Normalize_Scalars;
2667 @end smallexample
2668
2669 @noindent
2670 This is a language defined pragma which is fully implemented in GNAT@.  The
2671 effect is to cause all scalar objects that are not otherwise initialized
2672 to be initialized.  The initial values are implementation dependent and
2673 are as follows:
2674
2675 @table @code
2676 @item Standard.Character
2677 @noindent
2678 Objects whose root type is Standard.Character are initialized to
2679 Character'Last.  This will be out of range of the subtype only if
2680 the subtype range excludes this value.
2681
2682 @item Standard.Wide_Character
2683 @noindent
2684 Objects whose root type is Standard.Wide_Character are initialized to
2685 Wide_Character'Last.  This will be out of range of the subtype only if
2686 the subtype range excludes this value.
2687
2688 @item Integer types
2689 @noindent
2690 Objects of an integer type are initialized to base_type'First, where
2691 base_type is the base type of the object type.  This will be out of range
2692 of the subtype only if the subtype range excludes this value.  For example,
2693 if you declare the subtype:
2694
2695 @smallexample @c ada
2696 subtype Ityp is integer range 1 .. 10;
2697 @end smallexample
2698
2699 @noindent
2700 then objects of type x will be initialized to Integer'First, a negative
2701 number that is certainly outside the range of subtype @code{Ityp}.
2702
2703 @item Real types
2704 Objects of all real types (fixed and floating) are initialized to
2705 base_type'First, where base_Type is the base type of the object type.
2706 This will be out of range of the subtype only if the subtype range
2707 excludes this value.
2708
2709 @item Modular types
2710 Objects of a modular type are initialized to typ'Last.  This will be out
2711 of range of the subtype only if the subtype excludes this value.
2712
2713 @item Enumeration types
2714 Objects of an enumeration type are initialized to all one-bits, i.e.@: to
2715 the value @code{2 ** typ'Size - 1}.  This will be out of range of the
2716 enumeration subtype in all cases except where the subtype contains
2717 exactly 2**8, 2**16, or 2**32 elements.
2718
2719 @end table
2720
2721 @node Pragma Obsolescent
2722 @unnumberedsec Pragma Obsolescent
2723 @findex Obsolescent
2724 @noindent
2725 Syntax:
2726
2727 @smallexample @c ada
2728 pragma Obsolescent [(static_string_EXPRESSION)];
2729 @end smallexample
2730
2731 @noindent
2732 This pragma must occur immediately following a subprogram
2733 declaration. It indicates that the associated function or procedure
2734 is considered obsolescent and should not be used. Typically this is
2735 used when an API must be modified by eventually removing or modifying
2736 existing subprograms. The pragma can be used at an intermediate stage
2737 when the subprogram is still present, but will be removed later.
2738
2739 The effect of this pragma is to output a warning message that the
2740 subprogram is obsolescent if the appropriate warning option in the
2741 compiler is activated. If a parameter is present, then a second
2742 warning message is given containing this text.
2743
2744 @node Pragma Passive
2745 @unnumberedsec Pragma Passive
2746 @findex Passive
2747 @noindent
2748 Syntax:
2749
2750 @smallexample @c ada
2751 pragma Passive ([Semaphore | No]);
2752 @end smallexample
2753
2754 @noindent
2755 Syntax checked, but otherwise ignored by GNAT@.  This is recognized for
2756 compatibility with DEC Ada 83 implementations, where it is used within a
2757 task definition to request that a task be made passive.  If the argument
2758 @code{Semaphore} is present, or the argument is omitted, then DEC Ada 83
2759 treats the pragma as an assertion that the containing task is passive
2760 and that optimization of context switch with this task is permitted and
2761 desired.  If the argument @code{No} is present, the task must not be
2762 optimized.  GNAT does not attempt to optimize any tasks in this manner
2763 (since protected objects are available in place of passive tasks).
2764
2765 @node Pragma Polling
2766 @unnumberedsec Pragma Polling
2767 @findex Polling
2768 @noindent
2769 Syntax:
2770
2771 @smallexample @c ada
2772 pragma Polling (ON | OFF);
2773 @end smallexample
2774
2775 @noindent
2776 This pragma controls the generation of polling code.  This is normally off.
2777 If @code{pragma Polling (ON)} is used then periodic calls are generated to
2778 the routine @code{Ada.Exceptions.Poll}.  This routine is a separate unit in the
2779 runtime library, and can be found in file @file{a-excpol.adb}.
2780
2781 Pragma @code{Polling} can appear as a configuration pragma (for example it
2782 can be placed in the @file{gnat.adc} file) to enable polling globally, or it
2783 can be used in the statement or declaration sequence to control polling
2784 more locally.
2785
2786 A call to the polling routine is generated at the start of every loop and
2787 at the start of every subprogram call.  This guarantees that the @code{Poll}
2788 routine is called frequently, and places an upper bound (determined by
2789 the complexity of the code) on the period between two @code{Poll} calls.
2790
2791 The primary purpose of the polling interface is to enable asynchronous
2792 aborts on targets that cannot otherwise support it (for example Windows
2793 NT), but it may be used for any other purpose requiring periodic polling.
2794 The standard version is null, and can be replaced by a user program.  This
2795 will require re-compilation of the @code{Ada.Exceptions} package that can
2796 be found in files @file{a-except.ads} and @file{a-except.adb}.
2797
2798 A standard alternative unit (in file @file{4wexcpol.adb} in the standard GNAT
2799 distribution) is used to enable the asynchronous abort capability on
2800 targets that do not normally support the capability.  The version of
2801 @code{Poll} in this file makes a call to the appropriate runtime routine
2802 to test for an abort condition.
2803
2804 Note that polling can also be enabled by use of the @code{-gnatP} switch.  See
2805 the @cite{GNAT User's Guide} for details.
2806
2807 @node Pragma Profile (Ravenscar)
2808 @unnumberedsec Pragma Profile (Ravenscar)
2809 @findex Ravenscar
2810 @noindent
2811 Syntax:
2812
2813 @smallexample @c ada
2814 pragma Profile (Ravenscar);
2815 @end smallexample
2816
2817 @noindent
2818 A configuration pragma that establishes the following set of configuration
2819 pragmas:
2820
2821 @table @code
2822 @item Task_Dispatching_Policy (FIFO_Within_Priorities)
2823 [RM D.2.2] Tasks are dispatched following a preemptive
2824 priority-ordered scheduling policy.
2825
2826 @item Locking_Policy (Ceiling_Locking)
2827 [RM D.3] While tasks and interrupts execute a protected action, they inherit
2828 the ceiling priority of the corresponding protected object.
2829 @c
2830 @c @item Detect_Blocking
2831 @c This pragma forces the detection of potentially blocking operations within a
2832 @c protected operation, and to raise Program_Error if that happens.
2833 @end table
2834 @noindent
2835
2836 plus the following set of restrictions:
2837
2838 @table @code
2839 @item Max_Entry_Queue_Length = 1
2840 Defines the maximum number of calls that are queued on a (protected) entry.
2841 Note that this restrictions is checked at run time. Violation of this
2842 restriction results in the raising of Program_Error exception at the point of
2843 the call. For the Profile (Ravenscar) the value of Max_Entry_Queue_Length is
2844 always 1 and hence no task can be queued on a protected entry.
2845
2846 @item Max_Protected_Entries = 1
2847 [RM D.7] Specifies the maximum number of entries per protected type. The
2848 bounds of every entry family of a protected unit shall be static, or shall be
2849 defined by a discriminant of a subtype whose corresponding bound is static.
2850 For the Profile (Ravenscar) the value of Max_Protected_Entries is always 1.
2851
2852 @item Max_Task_Entries = 0
2853 [RM D.7] Specifies the maximum number of entries
2854 per task.  The bounds of every entry family
2855 of a task unit shall be static, or shall be
2856 defined by a discriminant of a subtype whose
2857 corresponding bound is static.  A value of zero
2858 indicates that no rendezvous are possible.  For
2859 the Profile (Ravenscar), the value of Max_Task_Entries is always
2860 0 (zero).
2861
2862 @item No_Abort_Statements
2863 [RM D.7] There are no abort_statements, and there are
2864 no calls to Task_Identification.Abort_Task.
2865
2866 @item No_Asynchronous_Control
2867 [RM D.7] There are no semantic dependences on the package
2868 Asynchronous_Task_Control.
2869
2870 @item No_Calendar
2871 There are no semantic dependencies on the package Ada.Calendar.
2872
2873 @item No_Dynamic_Attachment
2874 There is no call to any of the operations defined in package Ada.Interrupts
2875 (Is_Reserved, Is_Attached, Current_Handler, Attach_Handler, Exchange_Handler,
2876 Detach_Handler, and Reference).
2877
2878 @item No_Dynamic_Priorities
2879 [RM D.7] There are no semantic dependencies on the package Dynamic_Priorities.
2880
2881 @item No_Implicit_Heap_Allocations
2882 [RM D.7] No constructs are allowed to cause implicit heap allocation.
2883
2884 @item No_Local_Protected_Objects
2885 Protected objects and access types that designate
2886 such objects shall be declared only at library level.
2887
2888 @item No_Protected_Type_Allocators
2889 There are no allocators for protected types or
2890 types containing protected subcomponents.
2891
2892 @item No_Relative_Delay
2893 There are no delay_relative statements.
2894
2895 @item No_Requeue_Statements
2896 Requeue statements are not allowed.
2897
2898 @item No_Select_Statements
2899 There are no select_statements.
2900
2901 @item No_Task_Allocators
2902 [RM D.7] There are no allocators for task types
2903 or types containing task subcomponents.
2904
2905 @item No_Task_Attributes_Package
2906 There are no semantic dependencies on the Ada.Task_Attributes package.
2907
2908 @item No_Task_Hierarchy
2909 [RM D.7] All (non-environment) tasks depend
2910 directly on the environment task of the partition.
2911
2912 @item No_Task_Termination
2913 Tasks which terminate are erroneous.
2914
2915 @item Simple_Barriers
2916 Entry barrier condition expressions shall be either static
2917 boolean expressions or boolean objects which are declared in
2918 the protected type which contains the entry.
2919 @end table
2920
2921 @noindent
2922 This set of configuration pragmas and restrictions correspond to the
2923 definition of the ``Ravenscar Profile'' for limited tasking, devised and
2924 published by the @cite{International Real-Time Ada Workshop}, 1997,
2925 and whose most recent description is available at
2926 @url{ftp://ftp.openravenscar.org/openravenscar/ravenscar00.pdf}.
2927
2928 The original definition of the profile was revised at subsequent IRTAW
2929 meetings. It has been included in the ISO
2930 @cite{Guide for the Use of the Ada Programming Language in High
2931 Integrity Systems}, and has been approved by ISO/IEC/SC22/WG9 for inclusion in
2932 the next revision of the standard. The formal definition given by
2933 the Ada Rapporteur Group (ARG) can be found in two Ada Issues (AI-249 and
2934 AI-305) available at
2935 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00249.TXT} and
2936 @url{http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00305.TXT}
2937 respectively.
2938
2939 The above set is a superset of the restrictions provided by pragma
2940 @code{Restricted_Run_Time}, it includes six additional restrictions
2941 (@code{Simple_Barriers}, @code{No_Select_Statements},
2942 @code{No_Calendar}, @code{No_Implicit_Heap_Allocations},
2943 @code{No_Relative_Delay} and @code{No_Task_Termination}).  This means
2944 that pragma @code{Profile (Ravenscar)}, like the pragma
2945 @code{Restricted_Run_Time}, automatically causes the use of a simplified,
2946 more efficient version of the tasking run-time system.
2947
2948 @node Pragma Propagate_Exceptions
2949 @unnumberedsec Pragma Propagate_Exceptions
2950 @findex Propagate_Exceptions
2951 @cindex Zero Cost Exceptions
2952 @noindent
2953 Syntax:
2954
2955 @smallexample @c ada
2956 pragma Propagate_Exceptions (subprogram_LOCAL_NAME);
2957 @end smallexample
2958
2959 @noindent
2960 This pragma indicates that the given entity, which is the name of an
2961 imported foreign-language subprogram may receive an Ada exception,
2962 and that the exception should be propagated.  It is relevant only if
2963 zero cost exception handling is in use, and is thus never needed if
2964 the alternative @code{longjmp} / @code{setjmp} implementation of
2965 exceptions is used (although it is harmless to use it in such cases).
2966
2967 The implementation of fast exceptions always properly propagates
2968 exceptions through Ada code, as described in the Ada Reference Manual.
2969 However, this manual is silent about the propagation of exceptions
2970 through foreign code.  For example, consider the
2971 situation where @code{P1} calls
2972 @code{P2}, and @code{P2} calls @code{P3}, where
2973 @code{P1} and @code{P3} are in Ada, but @code{P2} is in C@.
2974 @code{P3} raises an Ada exception.  The question is whether or not
2975 it will be propagated through @code{P2} and can be handled in
2976 @code{P1}.
2977
2978 For the @code{longjmp} / @code{setjmp} implementation of exceptions,
2979 the answer is always yes.  For some targets on which zero cost exception
2980 handling is implemented, the answer is also always yes.  However, there
2981 are some targets, notably in the current version all x86 architecture
2982 targets, in which the answer is that such propagation does not
2983 happen automatically.  If such propagation is required on these
2984 targets, it is mandatory to use @code{Propagate_Exceptions} to
2985 name all foreign language routines through which Ada exceptions
2986 may be propagated.
2987
2988 @node Pragma Psect_Object
2989 @unnumberedsec Pragma Psect_Object
2990 @findex Psect_Object
2991 @noindent
2992 Syntax:
2993
2994 @smallexample @c ada
2995 pragma Psect_Object (
2996      [Internal =>] LOCAL_NAME,
2997   [, [External =>] EXTERNAL_SYMBOL]
2998   [, [Size     =>] EXTERNAL_SYMBOL]);
2999
3000 EXTERNAL_SYMBOL ::=
3001   IDENTIFIER
3002 | static_string_EXPRESSION
3003 @end smallexample
3004
3005 @noindent
3006 This pragma is identical in effect to pragma @code{Common_Object}.
3007
3008 @node Pragma Pure_Function
3009 @unnumberedsec Pragma Pure_Function
3010 @findex Pure_Function
3011 @noindent
3012 Syntax:
3013
3014 @smallexample @c ada
3015 pragma Pure_Function ([Entity =>] function_LOCAL_NAME);
3016 @end smallexample
3017
3018 @noindent
3019 This pragma appears in the same declarative part as a function
3020 declaration (or a set of function declarations if more than one
3021 overloaded declaration exists, in which case the pragma applies
3022 to all entities).  It specifies that the function @code{Entity} is
3023 to be considered pure for the purposes of code generation.  This means
3024 that the compiler can assume that there are no side effects, and
3025 in particular that two calls with identical arguments produce the
3026 same result.  It also means that the function can be used in an
3027 address clause.
3028
3029 Note that, quite deliberately, there are no static checks to try
3030 to ensure that this promise is met, so @code{Pure_Function} can be used
3031 with functions that are conceptually pure, even if they do modify
3032 global variables.  For example, a square root function that is
3033 instrumented to count the number of times it is called is still
3034 conceptually pure, and can still be optimized, even though it
3035 modifies a global variable (the count).  Memo functions are another
3036 example (where a table of previous calls is kept and consulted to
3037 avoid re-computation).
3038
3039 @findex Pure
3040 Note: Most functions in a @code{Pure} package are automatically pure, and
3041 there is no need to use pragma @code{Pure_Function} for such functions.  One
3042 exception is any function that has at least one formal of type
3043 @code{System.Address} or a type derived from it.  Such functions are not
3044 considered pure by default, since the compiler assumes that the
3045 @code{Address} parameter may be functioning as a pointer and that the
3046 referenced data may change even if the address value does not.
3047 Similarly, imported functions are not considered to be pure by default,
3048 since there is no way of checking that they are in fact pure.  The use
3049 of pragma @code{Pure_Function} for such a function will override these default
3050 assumption, and cause the compiler to treat a designated subprogram as pure
3051 in these cases.
3052
3053 Note: If pragma @code{Pure_Function} is applied to a renamed function, it
3054 applies to the underlying renamed function.  This can be used to
3055 disambiguate cases of overloading where some but not all functions
3056 in a set of overloaded functions are to be designated as pure.
3057
3058 @node Pragma Restricted_Run_Time
3059 @unnumberedsec Pragma Restricted_Run_Time
3060 @findex Restricted_Run_Time
3061 @noindent
3062 Syntax:
3063
3064 @smallexample @c ada
3065 pragma Restricted_Run_Time;
3066 @end smallexample
3067
3068 @noindent
3069 A configuration pragma that establishes the following set of restrictions:
3070
3071 @itemize @bullet
3072 @item No_Abort_Statements
3073 @item No_Entry_Queue
3074 @item No_Task_Hierarchy
3075 @item No_Task_Allocators
3076 @item No_Dynamic_Priorities
3077 @item No_Terminate_Alternatives
3078 @item No_Dynamic_Attachment
3079 @item No_Protected_Type_Allocators
3080 @item No_Local_Protected_Objects
3081 @item No_Requeue_Statements
3082 @item No_Task_Attributes_Package
3083 @item Max_Asynchronous_Select_Nesting =  0
3084 @item Max_Task_Entries =  0
3085 @item Max_Protected_Entries = 1
3086 @item Max_Select_Alternatives = 0
3087 @end itemize
3088
3089 @noindent
3090 This set of restrictions causes the automatic selection of a simplified
3091 version of the run time that provides improved performance for the
3092 limited set of tasking functionality permitted by this set of restrictions.
3093
3094 @node Pragma Restriction_Warnings
3095 @unnumberedsec Pragma Restriction_Warnings
3096 @findex Restriction_Warnings
3097 @noindent
3098 Syntax:
3099
3100 @smallexample @c ada
3101 pragma Restriction_Warnings
3102   (restriction_IDENTIFIER @{, restriction_IDENTIFIER@});
3103 @end smallexample
3104
3105 @noindent
3106 This pragma allows a series of restriction identifiers to be
3107 specified (the list of allowed identifiers is the same as for
3108 pragma @code{Restrictions}). For each of these identifiers
3109 the compiler checks for violations of the restriction, but
3110 generates a warning message rather than an error message
3111 if the restriction is violated.
3112
3113 @node Pragma Source_File_Name
3114 @unnumberedsec Pragma Source_File_Name
3115 @findex Source_File_Name
3116 @noindent
3117 Syntax:
3118
3119 @smallexample @c ada
3120 pragma Source_File_Name (
3121   [Unit_Name   =>] unit_NAME,
3122   Spec_File_Name =>  STRING_LITERAL);
3123
3124 pragma Source_File_Name (
3125   [Unit_Name   =>] unit_NAME,
3126   Body_File_Name =>  STRING_LITERAL);
3127 @end smallexample
3128
3129 @noindent
3130 Use this to override the normal naming convention.  It is a configuration
3131 pragma, and so has the usual applicability of configuration pragmas
3132 (i.e.@: it applies to either an entire partition, or to all units in a
3133 compilation, or to a single unit, depending on how it is used.
3134 @var{unit_name} is mapped to @var{file_name_literal}.  The identifier for
3135 the second argument is required, and indicates whether this is the file
3136 name for the spec or for the body.
3137
3138 Another form of the @code{Source_File_Name} pragma allows
3139 the specification of patterns defining alternative file naming schemes
3140 to apply to all files.
3141
3142 @smallexample @c ada
3143 pragma Source_File_Name
3144   (Spec_File_Name => STRING_LITERAL
3145    [,Casing => CASING_SPEC]
3146    [,Dot_Replacement => STRING_LITERAL]);
3147
3148 pragma Source_File_Name
3149   (Body_File_Name => STRING_LITERAL
3150    [,Casing => CASING_SPEC]
3151    [,Dot_Replacement => STRING_LITERAL]);
3152
3153 pragma Source_File_Name
3154   (Subunit_File_Name => STRING_LITERAL
3155    [,Casing => CASING_SPEC]
3156    [,Dot_Replacement => STRING_LITERAL]);
3157
3158 CASING_SPEC ::= Lowercase | Uppercase | Mixedcase
3159 @end smallexample
3160
3161 @noindent
3162 The first argument is a pattern that contains a single asterisk indicating
3163 the point at which the unit name is to be inserted in the pattern string
3164 to form the file name.  The second argument is optional.  If present it
3165 specifies the casing of the unit name in the resulting file name string.
3166 The default is lower case.  Finally the third argument allows for systematic
3167 replacement of any dots in the unit name by the specified string literal.
3168
3169 A pragma Source_File_Name cannot appear after a
3170 @ref{Pragma Source_File_Name_Project}.
3171
3172 For more details on the use of the @code{Source_File_Name} pragma,
3173 see the sections ``Using Other File Names'' and
3174 ``Alternative File Naming Schemes'' in the @cite{GNAT User's Guide}.
3175
3176 @node Pragma Source_File_Name_Project
3177 @unnumberedsec Pragma Source_File_Name_Project
3178 @findex Source_File_Name_Project
3179 @noindent
3180
3181 This pragma has the same syntax and semantics as pragma Source_File_Name.
3182 It is only allowed as a stand alone configuration pragma.
3183 It cannot appear after a @ref{Pragma Source_File_Name}, and
3184 most importantly, once pragma Source_File_Name_Project appears,
3185 no further Source_File_Name pragmas are allowed.
3186
3187 The intention is that Source_File_Name_Project pragmas are always
3188 generated by the Project Manager in a manner consistent with the naming
3189 specified in a project file, and when naming is controlled in this manner,
3190 it is not permissible to attempt to modify this naming scheme using
3191 Source_File_Name pragmas (which would not be known to the project manager).
3192
3193 @node Pragma Source_Reference
3194 @unnumberedsec Pragma Source_Reference
3195 @findex Source_Reference
3196 @noindent
3197 Syntax:
3198
3199 @smallexample @c ada
3200 pragma Source_Reference (INTEGER_LITERAL, STRING_LITERAL);
3201 @end smallexample
3202
3203 @noindent
3204 This pragma must appear as the first line of a source file.
3205 @var{integer_literal} is the logical line number of the line following
3206 the pragma line (for use in error messages and debugging
3207 information).  @var{string_literal} is a static string constant that
3208 specifies the file name to be used in error messages and debugging
3209 information.  This is most notably used for the output of @code{gnatchop}
3210 with the @code{-r} switch, to make sure that the original unchopped
3211 source file is the one referred to.
3212
3213 The second argument must be a string literal, it cannot be a static
3214 string expression other than a string literal.  This is because its value
3215 is needed for error messages issued by all phases of the compiler.
3216
3217 @node Pragma Stream_Convert
3218 @unnumberedsec Pragma Stream_Convert
3219 @findex Stream_Convert
3220 @noindent
3221 Syntax:
3222
3223 @smallexample @c ada
3224 pragma Stream_Convert (
3225   [Entity =>] type_LOCAL_NAME,
3226   [Read   =>] function_NAME,
3227   [Write  =>] function_NAME);
3228 @end smallexample
3229
3230 @noindent
3231 This pragma provides an efficient way of providing stream functions for
3232 types defined in packages.  Not only is it simpler to use than declaring
3233 the necessary functions with attribute representation clauses, but more
3234 significantly, it allows the declaration to made in such a way that the
3235 stream packages are not loaded unless they are needed.  The use of
3236 the Stream_Convert pragma adds no overhead at all, unless the stream
3237 attributes are actually used on the designated type.
3238
3239 The first argument specifies the type for which stream functions are
3240 provided.  The second parameter provides a function used to read values
3241 of this type.  It must name a function whose argument type may be any
3242 subtype, and whose returned type must be the type given as the first
3243 argument to the pragma.
3244
3245 The meaning of the @var{Read}
3246 parameter is that if a stream attribute directly
3247 or indirectly specifies reading of the type given as the first parameter,
3248 then a value of the type given as the argument to the Read function is
3249 read from the stream, and then the Read function is used to convert this
3250 to the required target type.
3251
3252 Similarly the @var{Write} parameter specifies how to treat write attributes
3253 that directly or indirectly apply to the type given as the first parameter.
3254 It must have an input parameter of the type specified by the first parameter,
3255 and the return type must be the same as the input type of the Read function.
3256 The effect is to first call the Write function to convert to the given stream
3257 type, and then write the result type to the stream.
3258
3259 The Read and Write functions must not be overloaded subprograms.  If necessary
3260 renamings can be supplied to meet this requirement.
3261 The usage of this attribute is best illustrated by a simple example, taken
3262 from the GNAT implementation of package Ada.Strings.Unbounded:
3263
3264 @smallexample @c ada
3265 function To_Unbounded (S : String)
3266            return Unbounded_String
3267   renames To_Unbounded_String;
3268
3269 pragma Stream_Convert
3270   (Unbounded_String, To_Unbounded, To_String);
3271 @end smallexample
3272
3273 @noindent
3274 The specifications of the referenced functions, as given in the Ada 95
3275 Reference Manual are:
3276
3277 @smallexample @c ada
3278 function To_Unbounded_String (Source : String)
3279   return Unbounded_String;
3280
3281 function To_String (Source : Unbounded_String)
3282   return String;
3283 @end smallexample
3284
3285 @noindent
3286 The effect is that if the value of an unbounded string is written to a
3287 stream, then the representation of the item in the stream is in the same
3288 format used for @code{Standard.String}, and this same representation is
3289 expected when a value of this type is read from the stream.
3290
3291 @node Pragma Style_Checks
3292 @unnumberedsec Pragma Style_Checks
3293 @findex Style_Checks
3294 @noindent
3295 Syntax:
3296
3297 @smallexample @c ada
3298 pragma Style_Checks (string_LITERAL | ALL_CHECKS |
3299                      On | Off [, LOCAL_NAME]);
3300 @end smallexample
3301
3302 @noindent
3303 This pragma is used in conjunction with compiler switches to control the
3304 built in style checking provided by GNAT@.  The compiler switches, if set,
3305 provide an initial setting for the switches, and this pragma may be used
3306 to modify these settings, or the settings may be provided entirely by
3307 the use of the pragma.  This pragma can be used anywhere that a pragma
3308 is legal, including use as a configuration pragma (including use in
3309 the @file{gnat.adc} file).
3310
3311 The form with a string literal specifies which style options are to be
3312 activated.  These are additive, so they apply in addition to any previously
3313 set style check options.  The codes for the options are the same as those
3314 used in the @code{-gnaty} switch to @code{gcc} or @code{gnatmake}.
3315 For example the following two methods can be used to enable
3316 layout checking:
3317
3318 @itemize @bullet
3319 @item
3320 @smallexample @c ada
3321 pragma Style_Checks ("l");
3322 @end smallexample
3323
3324 @item
3325 @smallexample
3326 gcc -c -gnatyl @dots{}
3327 @end smallexample
3328 @end itemize
3329
3330 @noindent
3331 The form ALL_CHECKS activates all standard checks (its use is equivalent
3332 to the use of the @code{gnaty} switch with no options.  See GNAT User's
3333 Guide for details.
3334
3335 The forms with @code{Off} and @code{On}
3336 can be used to temporarily disable style checks
3337 as shown in the following example:
3338
3339 @smallexample @c ada
3340 @iftex
3341 @leftskip=0cm
3342 @end iftex
3343 pragma Style_Checks ("k"); -- requires keywords in lower case
3344 pragma Style_Checks (Off); -- turn off style checks
3345 NULL;                      -- this will not generate an error message
3346 pragma Style_Checks (On);  -- turn style checks back on
3347 NULL;                      -- this will generate an error message
3348 @end smallexample
3349
3350 @noindent
3351 Finally the two argument form is allowed only if the first argument is
3352 @code{On} or @code{Off}.  The effect is to turn of semantic style checks
3353 for the specified entity, as shown in the following example:
3354
3355 @smallexample @c ada
3356 @iftex
3357 @leftskip=0cm
3358 @end iftex
3359 pragma Style_Checks ("r"); -- require consistency of identifier casing
3360 Arg : Integer;
3361 Rf1 : Integer := ARG;      -- incorrect, wrong case
3362 pragma Style_Checks (Off, Arg);
3363 Rf2 : Integer := ARG;      -- OK, no error
3364 @end smallexample
3365
3366 @node Pragma Subtitle
3367 @unnumberedsec Pragma Subtitle
3368 @findex Subtitle
3369 @noindent
3370 Syntax:
3371
3372 @smallexample @c ada
3373 pragma Subtitle ([Subtitle =>] STRING_LITERAL);
3374 @end smallexample
3375
3376 @noindent
3377 This pragma is recognized for compatibility with other Ada compilers
3378 but is ignored by GNAT@.
3379
3380 @node Pragma Suppress_All
3381 @unnumberedsec Pragma Suppress_All
3382 @findex Suppress_All
3383 @noindent
3384 Syntax:
3385
3386 @smallexample @c ada
3387 pragma Suppress_All;
3388 @end smallexample
3389
3390 @noindent
3391 This pragma can only appear immediately following a compilation
3392 unit.  The effect is to apply @code{Suppress (All_Checks)} to the unit
3393 which it follows.  This pragma is implemented for compatibility with DEC
3394 Ada 83 usage.  The use of pragma @code{Suppress (All_Checks)} as a normal
3395 configuration pragma is the preferred usage in GNAT@.
3396
3397 @node Pragma Suppress_Exception_Locations
3398 @unnumberedsec Pragma Suppress_Exception_Locations
3399 @findex Suppress_Exception_Locations
3400 @noindent
3401 Syntax:
3402
3403 @smallexample @c ada
3404 pragma Suppress_Exception_Locations;
3405 @end smallexample
3406
3407 @noindent
3408 In normal mode, a raise statement for an exception by default generates
3409 an exception message giving the file name and line number for the location
3410 of the raise. This is useful for debugging and logging purposes, but this
3411 entails extra space for the strings for the messages. The configuration
3412 pragma @code{Suppress_Exception_Locations} can be used to suppress the
3413 generation of these strings, with the result that space is saved, but the
3414 exception message for such raises is null. This configuration pragma may
3415 appear in a global configuration pragma file, or in a specific unit as
3416 usual. It is not required that this pragma be used consistently within
3417 a partition, so it is fine to have some units within a partition compiled
3418 with this pragma and others compiled in normal mode without it.
3419
3420 @node Pragma Suppress_Initialization
3421 @unnumberedsec Pragma Suppress_Initialization
3422 @findex Suppress_Initialization
3423 @cindex Suppressing initialization
3424 @cindex Initialization, suppression of
3425 @noindent
3426 Syntax:
3427
3428 @smallexample @c ada
3429 pragma Suppress_Initialization ([Entity =>] type_Name);
3430 @end smallexample
3431
3432 @noindent
3433 This pragma suppresses any implicit or explicit initialization
3434 associated with the given type name for all variables of this type.
3435
3436 @node Pragma Task_Info
3437 @unnumberedsec Pragma Task_Info
3438 @findex Task_Info
3439 @noindent
3440 Syntax
3441
3442 @smallexample @c ada
3443 pragma Task_Info (EXPRESSION);
3444 @end smallexample
3445
3446 @noindent
3447 This pragma appears within a task definition (like pragma
3448 @code{Priority}) and applies to the task in which it appears.  The
3449 argument must be of type @code{System.Task_Info.Task_Info_Type}.
3450 The @code{Task_Info} pragma provides system dependent control over
3451 aspects of tasking implementation, for example, the ability to map
3452 tasks to specific processors.  For details on the facilities available
3453 for the version of GNAT that you are using, see the documentation
3454 in the specification of package System.Task_Info in the runtime
3455 library.
3456
3457 @node Pragma Task_Name
3458 @unnumberedsec Pragma Task_Name
3459 @findex Task_Name
3460 @noindent
3461 Syntax
3462
3463 @smallexample @c ada
3464 pragma Task_Name (string_EXPRESSION);
3465 @end smallexample
3466
3467 @noindent
3468 This pragma appears within a task definition (like pragma
3469 @code{Priority}) and applies to the task in which it appears.  The
3470 argument must be of type String, and provides a name to be used for
3471 the task instance when the task is created.  Note that this expression
3472 is not required to be static, and in particular, it can contain
3473 references to task discriminants.  This facility can be used to
3474 provide different names for different tasks as they are created,
3475 as illustrated in the example below.
3476
3477 The task name is recorded internally in the run-time structures
3478 and is accessible to tools like the debugger.  In addition the
3479 routine @code{Ada.Task_Identification.Image} will return this
3480 string, with a unique task address appended.
3481
3482 @smallexample @c ada
3483 --  Example of the use of pragma Task_Name
3484
3485 with Ada.Task_Identification;
3486 use Ada.Task_Identification;
3487 with Text_IO; use Text_IO;
3488 procedure t3 is
3489
3490    type Astring is access String;
3491
3492    task type Task_Typ (Name : access String) is
3493       pragma Task_Name (Name.all);
3494    end Task_Typ;
3495
3496    task body Task_Typ is
3497       Nam : constant String := Image (Current_Task);
3498    begin
3499       Put_Line ("-->" & Nam (1 .. 14) & "<--");
3500    end Task_Typ;
3501
3502    type Ptr_Task is access Task_Typ;
3503    Task_Var : Ptr_Task;
3504
3505 begin
3506    Task_Var :=
3507      new Task_Typ (new String'("This is task 1"));
3508    Task_Var :=
3509      new Task_Typ (new String'("This is task 2"));
3510 end;
3511 @end smallexample
3512
3513 @node Pragma Task_Storage
3514 @unnumberedsec Pragma Task_Storage
3515 @findex Task_Storage
3516 Syntax:
3517
3518 @smallexample @c ada
3519 pragma Task_Storage (
3520   [Task_Type =>] LOCAL_NAME,
3521   [Top_Guard =>] static_integer_EXPRESSION);
3522 @end smallexample
3523
3524 @noindent
3525 This pragma specifies the length of the guard area for tasks.  The guard
3526 area is an additional storage area allocated to a task.  A value of zero
3527 means that either no guard area is created or a minimal guard area is
3528 created, depending on the target.  This pragma can appear anywhere a
3529 @code{Storage_Size} attribute definition clause is allowed for a task
3530 type.
3531
3532 @node Pragma Thread_Body
3533 @unnumberedsec Pragma Thread_Body
3534 @findex Thread_Body
3535 Syntax:
3536
3537 @smallexample @c ada
3538 pragma Thread_Body (
3539   [Entity =>] LOCAL_NAME,
3540  [[Secondary_Stack_Size =>] static_integer_EXPRESSION)];
3541 @end smallexample
3542
3543 @noindent
3544 This pragma specifies that the subprogram whose name is given as the
3545 @code{Entity} argument is a thread body, which will be activated
3546 by being called via its Address from foreign code. The purpose is
3547 to allow execution and registration of the foreign thread within the
3548 Ada run-time system.
3549
3550 See the library unit @code{System.Threads} for details on the expansion of
3551 a thread body subprogram, including the calls made to subprograms
3552 within System.Threads to register the task.  This unit also lists the
3553 targets and runtime systems for which this pragma is supported.
3554
3555 A thread body subprogram may not be called directly from Ada code, and
3556 it is not permitted to apply the Access (or Unrestricted_Access) attributes
3557 to such a subprogram. The only legitimate way of calling such a subprogram
3558 is to pass its Address to foreign code and then make the call from the
3559 foreign code.
3560
3561 A thread body subprogram may have any parameters, and it may be a function
3562 returning a result. The convention of the thread body subprogram may be
3563 set in the usual manner using @code{pragma Convention}.
3564
3565 The secondary stack size parameter, if given, is used to set the size
3566 of secondary stack for the thread. The secondary stack is allocated as
3567 a local variable of the expanded thread body subprogram, and thus is
3568 allocated out of the main thread stack size. If no secondary stack
3569 size parameter is present, the default size (from the declaration in
3570 @code{System.Secondary_Stack} is used.
3571
3572 @node Pragma Time_Slice
3573 @unnumberedsec Pragma Time_Slice
3574 @findex Time_Slice
3575 @noindent
3576 Syntax:
3577
3578 @smallexample @c ada
3579 pragma Time_Slice (static_duration_EXPRESSION);
3580 @end smallexample
3581
3582 @noindent
3583 For implementations of GNAT on operating systems where it is possible
3584 to supply a time slice value, this pragma may be used for this purpose.
3585 It is ignored if it is used in a system that does not allow this control,
3586 or if it appears in other than the main program unit.
3587 @cindex OpenVMS
3588 Note that the effect of this pragma is identical to the effect of the
3589 DEC Ada 83 pragma of the same name when operating under OpenVMS systems.
3590
3591 @node Pragma Title
3592 @unnumberedsec Pragma Title
3593 @findex Title
3594 @noindent
3595 Syntax:
3596
3597 @smallexample @c ada
3598 pragma Title (TITLING_OPTION [, TITLING OPTION]);
3599
3600 TITLING_OPTION ::=
3601   [Title    =>] STRING_LITERAL,
3602 | [Subtitle =>] STRING_LITERAL
3603 @end smallexample
3604
3605 @noindent
3606 Syntax checked but otherwise ignored by GNAT@.  This is a listing control
3607 pragma used in DEC Ada 83 implementations to provide a title and/or
3608 subtitle for the program listing.  The program listing generated by GNAT
3609 does not have titles or subtitles.
3610
3611 Unlike other pragmas, the full flexibility of named notation is allowed
3612 for this pragma, i.e.@: the parameters may be given in any order if named
3613 notation is used, and named and positional notation can be mixed
3614 following the normal rules for procedure calls in Ada.
3615
3616 @node Pragma Unchecked_Union
3617 @unnumberedsec Pragma Unchecked_Union
3618 @cindex Unions in C
3619 @findex Unchecked_Union
3620 @noindent
3621 Syntax:
3622
3623 @smallexample @c ada
3624 pragma Unchecked_Union (first_subtype_LOCAL_NAME);
3625 @end smallexample
3626
3627 @noindent
3628 This pragma is used to declare that the specified type should be represented
3629 in a manner
3630 equivalent to a C union type, and is intended only for use in
3631 interfacing with C code that uses union types.  In Ada terms, the named
3632 type must obey the following rules:
3633
3634 @itemize @bullet
3635 @item
3636 It is a non-tagged non-limited record type.
3637 @item
3638 It has a single discrete discriminant with a default value.
3639 @item
3640 The component list consists of a single variant part.
3641 @item
3642 Each variant has a component list with a single component.
3643 @item
3644 No nested variants are allowed.
3645 @item
3646 No component has an explicit default value.
3647 @item
3648 No component has a non-static constraint.
3649 @end itemize
3650
3651 @noindent
3652 In addition, given a type that meets the above requirements, the
3653 following restrictions apply to its use throughout the program:
3654
3655 @itemize @bullet
3656 @item
3657 The discriminant name can be mentioned only in an aggregate.
3658 @item
3659 No subtypes may be created of this type.
3660 @item
3661 The type may not be constrained by giving a discriminant value.
3662 @item
3663 The type cannot be passed as the actual for a generic formal with a
3664 discriminant.
3665 @end itemize
3666
3667 @noindent
3668 Equality and inequality operations on @code{unchecked_unions} are not
3669 available, since there is no discriminant to compare and the compiler
3670 does not even know how many bits to compare.  It is implementation
3671 dependent whether this is detected at compile time as an illegality or
3672 whether it is undetected and considered to be an erroneous construct.  In
3673 GNAT, a direct comparison is illegal, but GNAT does not attempt to catch
3674 the composite case (where two composites are compared that contain an
3675 unchecked union component), so such comparisons are simply considered
3676 erroneous.
3677
3678 The layout of the resulting type corresponds exactly to a C union, where
3679 each branch of the union corresponds to a single variant in the Ada
3680 record.  The semantics of the Ada program is not changed in any way by
3681 the pragma, i.e.@: provided the above restrictions are followed, and no
3682 erroneous incorrect references to fields or erroneous comparisons occur,
3683 the semantics is exactly as described by the Ada reference manual.
3684 Pragma @code{Suppress (Discriminant_Check)} applies implicitly to the
3685 type and the default convention is C.
3686
3687 @node Pragma Unimplemented_Unit
3688 @unnumberedsec Pragma Unimplemented_Unit
3689 @findex Unimplemented_Unit
3690 @noindent
3691 Syntax:
3692
3693 @smallexample @c ada
3694 pragma Unimplemented_Unit;
3695 @end smallexample
3696
3697 @noindent
3698 If this pragma occurs in a unit that is processed by the compiler, GNAT
3699 aborts with the message @samp{@var{xxx} not implemented}, where
3700 @var{xxx} is the name of the current compilation unit.  This pragma is
3701 intended to allow the compiler to handle unimplemented library units in
3702 a clean manner.
3703
3704 The abort only happens if code is being generated.  Thus you can use
3705 specs of unimplemented packages in syntax or semantic checking mode.
3706
3707 @node Pragma Universal_Data
3708 @unnumberedsec Pragma Universal_Data
3709 @findex Universal_Data
3710 @noindent
3711 Syntax:
3712
3713 @smallexample @c ada
3714 pragma Universal_Data [(library_unit_Name)];
3715 @end smallexample
3716
3717 @noindent
3718 This pragma is supported only for the AAMP target and is ignored for
3719 other targets. The pragma specifies that all library-level objects
3720 (Counter 0 data) associated with the library unit are to be accessed
3721 and updated using universal addressing (24-bit addresses for AAMP5)
3722 rather than the default of 16-bit Data Environment (DENV) addressing.
3723 Use of this pragma will generally result in less efficient code for
3724 references to global data associated with the library unit, but
3725 allows such data to be located anywhere in memory. This pragma is
3726 a library unit pragma, but can also be used as a configuration pragma
3727 (including use in the @file{gnat.adc} file). The functionality
3728 of this pragma is also available by applying the -univ switch on the
3729 compilations of units where universal addressing of the data is desired.
3730
3731 @node Pragma Unreferenced
3732 @unnumberedsec Pragma Unreferenced
3733 @findex Unreferenced
3734 @cindex Warnings, unreferenced
3735 @noindent
3736 Syntax:
3737
3738 @smallexample @c ada
3739 pragma Unreferenced (local_Name @{, local_Name@});
3740 @end smallexample
3741
3742 @noindent
3743 This pragma signals that the entities whose names are listed are
3744 deliberately not referenced in the current source unit. This
3745 suppresses warnings about the
3746 entities being unreferenced, and in addition a warning will be
3747 generated if one of these entities is in fact referenced in the
3748 same unit as the pragma (or in the corresponding body, or one
3749 of its subunits).
3750
3751 This is particularly useful for clearly signaling that a particular
3752 parameter is not referenced in some particular subprogram implementation
3753 and that this is deliberate. It can also be useful in the case of
3754 objects declared only for their initialization or finalization side
3755 effects.
3756
3757 If @code{local_Name} identifies more than one matching homonym in the
3758 current scope, then the entity most recently declared is the one to which
3759 the pragma applies.
3760
3761 The left hand side of an assignment does not count as a reference for the
3762 purpose of this pragma. Thus it is fine to assign to an entity for which
3763 pragma Unreferenced is given.
3764
3765 @node Pragma Unreserve_All_Interrupts
3766 @unnumberedsec Pragma Unreserve_All_Interrupts
3767 @findex Unreserve_All_Interrupts
3768 @noindent
3769 Syntax:
3770
3771 @smallexample @c ada
3772 pragma Unreserve_All_Interrupts;
3773 @end smallexample
3774
3775 @noindent
3776 Normally certain interrupts are reserved to the implementation.  Any attempt
3777 to attach an interrupt causes Program_Error to be raised, as described in
3778 RM C.3.2(22).  A typical example is the @code{SIGINT} interrupt used in
3779 many systems for a @kbd{Ctrl-C} interrupt.  Normally this interrupt is
3780 reserved to the implementation, so that @kbd{Ctrl-C} can be used to
3781 interrupt execution.
3782
3783 If the pragma @code{Unreserve_All_Interrupts} appears anywhere in any unit in
3784 a program, then all such interrupts are unreserved.  This allows the
3785 program to handle these interrupts, but disables their standard
3786 functions.  For example, if this pragma is used, then pressing
3787 @kbd{Ctrl-C} will not automatically interrupt execution.  However,
3788 a program can then handle the @code{SIGINT} interrupt as it chooses.
3789
3790 For a full list of the interrupts handled in a specific implementation,
3791 see the source code for the specification of @code{Ada.Interrupts.Names} in
3792 file @file{a-intnam.ads}.  This is a target dependent file that contains the
3793 list of interrupts recognized for a given target.  The documentation in
3794 this file also specifies what interrupts are affected by the use of
3795 the @code{Unreserve_All_Interrupts} pragma.
3796
3797 For a more general facility for controlling what interrupts can be
3798 handled, see pragma @code{Interrupt_State}, which subsumes the functionality
3799 of the @code{Unreserve_All_Interrupts} pragma.
3800
3801 @node Pragma Unsuppress
3802 @unnumberedsec Pragma Unsuppress
3803 @findex Unsuppress
3804 @noindent
3805 Syntax:
3806
3807 @smallexample @c ada
3808 pragma Unsuppress (IDENTIFIER [, [On =>] NAME]);
3809 @end smallexample
3810
3811 @noindent
3812 This pragma undoes the effect of a previous pragma @code{Suppress}.  If
3813 there is no corresponding pragma @code{Suppress} in effect, it has no
3814 effect.  The range of the effect is the same as for pragma
3815 @code{Suppress}.  The meaning of the arguments is identical to that used
3816 in pragma @code{Suppress}.
3817
3818 One important application is to ensure that checks are on in cases where
3819 code depends on the checks for its correct functioning, so that the code
3820 will compile correctly even if the compiler switches are set to suppress
3821 checks.
3822
3823 @node Pragma Use_VADS_Size
3824 @unnumberedsec Pragma Use_VADS_Size
3825 @cindex @code{Size}, VADS compatibility
3826 @findex Use_VADS_Size
3827 @noindent
3828 Syntax:
3829
3830 @smallexample @c ada
3831 pragma Use_VADS_Size;
3832 @end smallexample
3833
3834 @noindent
3835 This is a configuration pragma.  In a unit to which it applies, any use
3836 of the 'Size attribute is automatically interpreted as a use of the
3837 'VADS_Size attribute.  Note that this may result in incorrect semantic
3838 processing of valid Ada 95 programs.  This is intended to aid in the
3839 handling of legacy code which depends on the interpretation of Size
3840 as implemented in the VADS compiler.  See description of the VADS_Size
3841 attribute for further details.
3842
3843 @node Pragma Validity_Checks
3844 @unnumberedsec Pragma Validity_Checks
3845 @findex Validity_Checks
3846 @noindent
3847 Syntax:
3848
3849 @smallexample @c ada
3850 pragma Validity_Checks (string_LITERAL | ALL_CHECKS | On | Off);
3851 @end smallexample
3852
3853 @noindent
3854 This pragma is used in conjunction with compiler switches to control the
3855 built-in validity checking provided by GNAT@.  The compiler switches, if set
3856 provide an initial setting for the switches, and this pragma may be used
3857 to modify these settings, or the settings may be provided entirely by
3858 the use of the pragma.  This pragma can be used anywhere that a pragma
3859 is legal, including use as a configuration pragma (including use in
3860 the @file{gnat.adc} file).
3861
3862 The form with a string literal specifies which validity options are to be
3863 activated.  The validity checks are first set to include only the default
3864 reference manual settings, and then a string of letters in the string
3865 specifies the exact set of options required.  The form of this string
3866 is exactly as described for the @code{-gnatVx} compiler switch (see the
3867 GNAT users guide for details).  For example the following two methods
3868 can be used to enable validity checking for mode @code{in} and
3869 @code{in out} subprogram parameters:
3870
3871 @itemize @bullet
3872 @item
3873 @smallexample @c ada
3874 pragma Validity_Checks ("im");
3875 @end smallexample
3876
3877 @item
3878 @smallexample
3879 gcc -c -gnatVim @dots{}
3880 @end smallexample
3881 @end itemize
3882
3883 @noindent
3884 The form ALL_CHECKS activates all standard checks (its use is equivalent
3885 to the use of the @code{gnatva} switch.
3886
3887 The forms with @code{Off} and @code{On}
3888 can be used to temporarily disable validity checks
3889 as shown in the following example:
3890
3891 @smallexample @c ada
3892 @iftex
3893 @leftskip=0cm
3894 @end iftex
3895 pragma Validity_Checks ("c"); -- validity checks for copies
3896 pragma Validity_Checks (Off); -- turn off validity checks
3897 A := B;                       -- B will not be validity checked
3898 pragma Validity_Checks (On);  -- turn validity checks back on
3899 A := C;                       -- C will be validity checked
3900 @end smallexample
3901
3902 @node Pragma Volatile
3903 @unnumberedsec Pragma Volatile
3904 @findex Volatile
3905 @noindent
3906 Syntax:
3907
3908 @smallexample @c ada
3909 pragma Volatile (local_NAME);
3910 @end smallexample
3911
3912 @noindent
3913 This pragma is defined by the Ada 95 Reference Manual, and the GNAT
3914 implementation is fully conformant with this definition.  The reason it
3915 is mentioned in this section is that a pragma of the same name was supplied
3916 in some Ada 83 compilers, including DEC Ada 83.  The Ada 95 implementation
3917 of pragma Volatile is upwards compatible with the implementation in
3918 Dec Ada 83.
3919
3920 @node Pragma Warnings
3921 @unnumberedsec Pragma Warnings
3922 @findex Warnings
3923 @noindent
3924 Syntax:
3925
3926 @smallexample @c ada
3927 pragma Warnings (On | Off [, LOCAL_NAME]);
3928 @end smallexample
3929
3930 @noindent
3931 Normally warnings are enabled, with the output being controlled by
3932 the command line switch.  Warnings (@code{Off}) turns off generation of
3933 warnings until a Warnings (@code{On}) is encountered or the end of the
3934 current unit.  If generation of warnings is turned off using this
3935 pragma, then no warning messages are output, regardless of the
3936 setting of the command line switches.
3937
3938 The form with a single argument is a configuration pragma.
3939
3940 If the @var{local_name} parameter is present, warnings are suppressed for
3941 the specified entity.  This suppression is effective from the point where
3942 it occurs till the end of the extended scope of the variable (similar to
3943 the scope of @code{Suppress}).
3944
3945 @node Pragma Weak_External
3946 @unnumberedsec Pragma Weak_External
3947 @findex Weak_External
3948 @noindent
3949 Syntax:
3950
3951 @smallexample @c ada
3952 pragma Weak_External ([Entity =>] LOCAL_NAME);
3953 @end smallexample
3954
3955 @noindent
3956 This pragma specifies that the given entity should be marked as a weak
3957 external (one that does not have to be resolved) for the linker.  For
3958 further details, consult the GCC manual.
3959
3960 @node Implementation Defined Attributes
3961 @chapter Implementation Defined Attributes
3962 Ada 95 defines (throughout the Ada 95 reference manual,
3963 summarized in annex K),
3964 a set of attributes that provide useful additional functionality in all
3965 areas of the language.  These language defined attributes are implemented
3966 in GNAT and work as described in the Ada 95 Reference Manual.
3967
3968 In addition, Ada 95 allows implementations to define additional
3969 attributes whose meaning is defined by the implementation.  GNAT provides
3970 a number of these implementation-dependent attributes which can be used
3971 to extend and enhance the functionality of the compiler.  This section of
3972 the GNAT reference manual describes these additional attributes.
3973
3974 Note that any program using these attributes may not be portable to
3975 other compilers (although GNAT implements this set of attributes on all
3976 platforms).  Therefore if portability to other compilers is an important
3977 consideration, you should minimize the use of these attributes.
3978
3979 @menu
3980 * Abort_Signal::
3981 * Address_Size::
3982 * Asm_Input::
3983 * Asm_Output::
3984 * AST_Entry::
3985 * Bit::
3986 * Bit_Position::
3987 * Code_Address::
3988 * Default_Bit_Order::
3989 * Elaborated::
3990 * Elab_Body::
3991 * Elab_Spec::
3992 * Emax::
3993 * Enum_Rep::
3994 * Epsilon::
3995 * Fixed_Value::
3996 * Has_Discriminants::
3997 * Img::
3998 * Integer_Value::
3999 * Large::
4000 * Machine_Size::
4001 * Mantissa::
4002 * Max_Interrupt_Priority::
4003 * Max_Priority::
4004 * Maximum_Alignment::
4005 * Mechanism_Code::
4006 * Null_Parameter::
4007 * Object_Size::
4008 * Passed_By_Reference::
4009 * Range_Length::
4010 * Safe_Emax::
4011 * Safe_Large::
4012 * Small::
4013 * Storage_Unit::
4014 * Target_Name::
4015 * Tick::
4016 * To_Address::
4017 * Type_Class::
4018 * UET_Address::
4019 * Unconstrained_Array::
4020 * Universal_Literal_String::
4021 * Unrestricted_Access::
4022 * VADS_Size::
4023 * Value_Size::
4024 * Wchar_T_Size::
4025 * Word_Size::
4026 @end menu
4027
4028 @node Abort_Signal
4029 @unnumberedsec Abort_Signal
4030 @findex Abort_Signal
4031 @noindent
4032 @code{Standard'Abort_Signal} (@code{Standard} is the only allowed
4033 prefix) provides the entity for the special exception used to signal
4034 task abort or asynchronous transfer of control.  Normally this attribute
4035 should only be used in the tasking runtime (it is highly peculiar, and
4036 completely outside the normal semantics of Ada, for a user program to
4037 intercept the abort exception).
4038
4039 @node Address_Size
4040 @unnumberedsec Address_Size
4041 @cindex Size of @code{Address}
4042 @findex Address_Size
4043 @noindent
4044 @code{Standard'Address_Size} (@code{Standard} is the only allowed
4045 prefix) is a static constant giving the number of bits in an
4046 @code{Address}. It is the same value as System.Address'Size,
4047 but has the advantage of being static, while a direct
4048 reference to System.Address'Size is non-static because Address
4049 is a private type.
4050
4051 @node Asm_Input
4052 @unnumberedsec Asm_Input
4053 @findex Asm_Input
4054 @noindent
4055 The @code{Asm_Input} attribute denotes a function that takes two
4056 parameters.  The first is a string, the second is an expression of the
4057 type designated by the prefix.  The first (string) argument is required
4058 to be a static expression, and is the constraint for the parameter,
4059 (e.g.@: what kind of register is required).  The second argument is the
4060 value to be used as the input argument.  The possible values for the
4061 constant are the same as those used in the RTL, and are dependent on
4062 the configuration file used to built the GCC back end.
4063 @ref{Machine Code Insertions}
4064
4065 @node Asm_Output
4066 @unnumberedsec Asm_Output
4067 @findex Asm_Output
4068 @noindent
4069 The @code{Asm_Output} attribute denotes a function that takes two
4070 parameters.  The first is a string, the second is the name of a variable
4071 of the type designated by the attribute prefix.  The first (string)
4072 argument is required to be a static expression and designates the
4073 constraint for the parameter (e.g.@: what kind of register is
4074 required).  The second argument is the variable to be updated with the
4075 result.  The possible values for constraint are the same as those used in
4076 the RTL, and are dependent on the configuration file used to build the
4077 GCC back end.  If there are no output operands, then this argument may
4078 either be omitted, or explicitly given as @code{No_Output_Operands}.
4079 @ref{Machine Code Insertions}
4080
4081 @node AST_Entry
4082 @unnumberedsec AST_Entry
4083 @cindex OpenVMS
4084 @findex AST_Entry
4085 @noindent
4086 This attribute is implemented only in OpenVMS versions of GNAT@.  Applied to
4087 the name of an entry, it yields a value of the predefined type AST_Handler
4088 (declared in the predefined package System, as extended by the use of
4089 pragma @code{Extend_System (Aux_DEC)}).  This value enables the given entry to
4090 be called when an AST occurs.  For further details, refer to the @cite{DEC Ada
4091 Language Reference Manual}, section 9.12a.
4092
4093 @node Bit
4094 @unnumberedsec Bit
4095 @findex Bit
4096 @code{@var{obj}'Bit}, where @var{obj} is any object, yields the bit
4097 offset within the storage unit (byte) that contains the first bit of
4098 storage allocated for the object.  The value of this attribute is of the
4099 type @code{Universal_Integer}, and is always a non-negative number not
4100 exceeding the value of @code{System.Storage_Unit}.
4101
4102 For an object that is a variable or a constant allocated in a register,
4103 the value is zero.  (The use of this attribute does not force the
4104 allocation of a variable to memory).
4105
4106 For an object that is a formal parameter, this attribute applies
4107 to either the matching actual parameter or to a copy of the
4108 matching actual parameter.
4109
4110 For an access object the value is zero.  Note that
4111 @code{@var{obj}.all'Bit} is subject to an @code{Access_Check} for the
4112 designated object.  Similarly for a record component
4113 @code{@var{X}.@var{C}'Bit} is subject to a discriminant check and
4114 @code{@var{X}(@var{I}).Bit} and @code{@var{X}(@var{I1}..@var{I2})'Bit}
4115 are subject to index checks.
4116
4117 This attribute is designed to be compatible with the DEC Ada 83 definition
4118 and implementation of the @code{Bit} attribute.
4119
4120 @node Bit_Position
4121 @unnumberedsec Bit_Position
4122 @findex Bit_Position
4123 @noindent
4124 @code{@var{R.C}'Bit}, where @var{R} is a record object and C is one
4125 of the fields of the record type, yields the bit
4126 offset within the record contains the first bit of
4127 storage allocated for the object.  The value of this attribute is of the
4128 type @code{Universal_Integer}.  The value depends only on the field
4129 @var{C} and is independent of the alignment of
4130 the containing record @var{R}.
4131
4132 @node Code_Address
4133 @unnumberedsec Code_Address
4134 @findex Code_Address
4135 @cindex Subprogram address
4136 @cindex Address of subprogram code
4137 @noindent
4138 The @code{'Address}
4139 attribute may be applied to subprograms in Ada 95, but the
4140 intended effect from the Ada 95 reference manual seems to be to provide
4141 an address value which can be used to call the subprogram by means of
4142 an address clause as in the following example:
4143
4144 @smallexample @c ada
4145 procedure K is @dots{}
4146
4147 procedure L;
4148 for L'Address use K'Address;
4149 pragma Import (Ada, L);
4150 @end smallexample
4151
4152 @noindent
4153 A call to @code{L} is then expected to result in a call to @code{K}@.
4154 In Ada 83, where there were no access-to-subprogram values, this was
4155 a common work around for getting the effect of an indirect call.
4156 GNAT implements the above use of @code{Address} and the technique
4157 illustrated by the example code works correctly.
4158
4159 However, for some purposes, it is useful to have the address of the start
4160 of the generated code for the subprogram.  On some architectures, this is
4161 not necessarily the same as the @code{Address} value described above.
4162 For example, the @code{Address} value may reference a subprogram
4163 descriptor rather than the subprogram itself.
4164
4165 The @code{'Code_Address} attribute, which can only be applied to
4166 subprogram entities, always returns the address of the start of the
4167 generated code of the specified subprogram, which may or may not be
4168 the same value as is returned by the corresponding @code{'Address}
4169 attribute.
4170
4171 @node Default_Bit_Order
4172 @unnumberedsec Default_Bit_Order
4173 @cindex Big endian
4174 @cindex Little endian
4175 @findex Default_Bit_Order
4176 @noindent
4177 @code{Standard'Default_Bit_Order} (@code{Standard} is the only
4178 permissible prefix), provides the value @code{System.Default_Bit_Order}
4179 as a @code{Pos} value (0 for @code{High_Order_First}, 1 for
4180 @code{Low_Order_First}).  This is used to construct the definition of
4181 @code{Default_Bit_Order} in package @code{System}.
4182
4183 @node Elaborated
4184 @unnumberedsec Elaborated
4185 @findex Elaborated
4186 @noindent
4187 The prefix of the @code{'Elaborated} attribute must be a unit name.  The
4188 value is a Boolean which indicates whether or not the given unit has been
4189 elaborated.  This attribute is primarily intended for internal use by the
4190 generated code for dynamic elaboration checking, but it can also be used
4191 in user programs.  The value will always be True once elaboration of all
4192 units has been completed.  An exception is for units which need no
4193 elaboration, the value is always False for such units.
4194
4195 @node Elab_Body
4196 @unnumberedsec Elab_Body
4197 @findex Elab_Body
4198 @noindent
4199 This attribute can only be applied to a program unit name.  It returns
4200 the entity for the corresponding elaboration procedure for elaborating
4201 the body of the referenced unit.  This is used in the main generated
4202 elaboration procedure by the binder and is not normally used in any
4203 other context.  However, there may be specialized situations in which it
4204 is useful to be able to call this elaboration procedure from Ada code,
4205 e.g.@: if it is necessary to do selective re-elaboration to fix some
4206 error.
4207
4208 @node Elab_Spec
4209 @unnumberedsec Elab_Spec
4210 @findex Elab_Spec
4211 @noindent
4212 This attribute can only be applied to a program unit name.  It returns
4213 the entity for the corresponding elaboration procedure for elaborating
4214 the specification of the referenced unit.  This is used in the main
4215 generated elaboration procedure by the binder and is not normally used
4216 in any other context.  However, there may be specialized situations in
4217 which it is useful to be able to call this elaboration procedure from
4218 Ada code, e.g.@: if it is necessary to do selective re-elaboration to fix
4219 some error.
4220
4221 @node Emax
4222 @unnumberedsec Emax
4223 @cindex Ada 83 attributes
4224 @findex Emax
4225 @noindent
4226 The @code{Emax} attribute is provided for compatibility with Ada 83.  See
4227 the Ada 83 reference manual for an exact description of the semantics of
4228 this attribute.
4229
4230 @node Enum_Rep
4231 @unnumberedsec Enum_Rep
4232 @cindex Representation of enums
4233 @findex Enum_Rep
4234 @noindent
4235 For every enumeration subtype @var{S}, @code{@var{S}'Enum_Rep} denotes a
4236 function with the following spec:
4237
4238 @smallexample @c ada
4239 function @var{S}'Enum_Rep (Arg : @var{S}'Base)
4240   return @i{Universal_Integer};
4241 @end smallexample
4242
4243 @noindent
4244 It is also allowable to apply @code{Enum_Rep} directly to an object of an
4245 enumeration type or to a non-overloaded enumeration
4246 literal.  In this case @code{@var{S}'Enum_Rep} is equivalent to
4247 @code{@var{typ}'Enum_Rep(@var{S})} where @var{typ} is the type of the
4248 enumeration literal or object.
4249
4250 The function returns the representation value for the given enumeration
4251 value.  This will be equal to value of the @code{Pos} attribute in the
4252 absence of an enumeration representation clause.  This is a static
4253 attribute (i.e.@: the result is static if the argument is static).
4254
4255 @code{@var{S}'Enum_Rep} can also be used with integer types and objects,
4256 in which case it simply returns the integer value.  The reason for this
4257 is to allow it to be used for @code{(<>)} discrete formal arguments in
4258 a generic unit that can be instantiated with either enumeration types
4259 or integer types.  Note that if @code{Enum_Rep} is used on a modular
4260 type whose upper bound exceeds the upper bound of the largest signed
4261 integer type, and the argument is a variable, so that the universal
4262 integer calculation is done at run-time, then the call to @code{Enum_Rep}
4263 may raise @code{Constraint_Error}.
4264
4265 @node Epsilon
4266 @unnumberedsec Epsilon
4267 @cindex Ada 83 attributes
4268 @findex Epsilon
4269 @noindent
4270 The @code{Epsilon} attribute is provided for compatibility with Ada 83.  See
4271 the Ada 83 reference manual for an exact description of the semantics of
4272 this attribute.
4273
4274 @node Fixed_Value
4275 @unnumberedsec Fixed_Value
4276 @findex Fixed_Value
4277 @noindent
4278 For every fixed-point type @var{S}, @code{@var{S}'Fixed_Value} denotes a
4279 function with the following specification:
4280
4281 @smallexample @c ada
4282 function @var{S}'Fixed_Value (Arg : @i{Universal_Integer})
4283   return @var{S};
4284 @end smallexample
4285
4286 @noindent
4287 The value returned is the fixed-point value @var{V} such that
4288
4289 @smallexample @c ada
4290 @var{V} = Arg * @var{S}'Small
4291 @end smallexample
4292
4293 @noindent
4294 The effect is thus similar to first converting the argument to the
4295 integer type used to represent @var{S}, and then doing an unchecked
4296 conversion to the fixed-point type.  The difference is
4297 that there are full range checks, to ensure that the result is in range.
4298 This attribute is primarily intended for use in implementation of the
4299 input-output functions for fixed-point values.
4300
4301 @node Has_Discriminants
4302 @unnumberedsec Has_Discriminants
4303 @cindex Discriminants, testing for
4304 @findex Has_Discriminants
4305 @noindent
4306 The prefix of the @code{Has_Discriminants} attribute is a type.  The result
4307 is a Boolean value which is True if the type has discriminants, and False
4308 otherwise.  The intended use of this attribute is in conjunction with generic
4309 definitions.  If the attribute is applied to a generic private type, it
4310 indicates whether or not the corresponding actual type has discriminants.
4311
4312 @node Img
4313 @unnumberedsec Img
4314 @findex Img
4315 @noindent
4316 The @code{Img} attribute differs from @code{Image} in that it may be
4317 applied to objects as well as types, in which case it gives the
4318 @code{Image} for the subtype of the object.  This is convenient for
4319 debugging:
4320
4321 @smallexample @c ada
4322 Put_Line ("X = " & X'Img);
4323 @end smallexample
4324
4325 @noindent
4326 has the same meaning as the more verbose:
4327
4328 @smallexample @c ada
4329 Put_Line ("X = " & @var{T}'Image (X));
4330 @end smallexample
4331
4332 @noindent
4333 where @var{T} is the (sub)type of the object @code{X}.
4334
4335 @node Integer_Value
4336 @unnumberedsec Integer_Value
4337 @findex Integer_Value
4338 @noindent
4339 For every integer type @var{S}, @code{@var{S}'Integer_Value} denotes a
4340 function with the following spec:
4341
4342 @smallexample @c ada
4343 function @var{S}'Integer_Value (Arg : @i{Universal_Fixed})
4344   return @var{S};
4345 @end smallexample
4346
4347 @noindent
4348 The value returned is the integer value @var{V}, such that
4349
4350 @smallexample @c ada
4351 Arg = @var{V} * @var{T}'Small
4352 @end smallexample
4353
4354 @noindent
4355 where @var{T} is the type of @code{Arg}.
4356 The effect is thus similar to first doing an unchecked conversion from
4357 the fixed-point type to its corresponding implementation type, and then
4358 converting the result to the target integer type.  The difference is
4359 that there are full range checks, to ensure that the result is in range.
4360 This attribute is primarily intended for use in implementation of the
4361 standard input-output functions for fixed-point values.
4362
4363 @node Large
4364 @unnumberedsec Large
4365 @cindex Ada 83 attributes
4366 @findex Large
4367 @noindent
4368 The @code{Large} attribute is provided for compatibility with Ada 83.  See
4369 the Ada 83 reference manual for an exact description of the semantics of
4370 this attribute.
4371
4372 @node Machine_Size
4373 @unnumberedsec Machine_Size
4374 @findex Machine_Size
4375 @noindent
4376 This attribute is identical to the @code{Object_Size} attribute.  It is
4377 provided for compatibility with the DEC Ada 83 attribute of this name.
4378
4379 @node Mantissa
4380 @unnumberedsec Mantissa
4381 @cindex Ada 83 attributes
4382 @findex Mantissa
4383 @noindent
4384 The @code{Mantissa} attribute is provided for compatibility with Ada 83.  See
4385 the Ada 83 reference manual for an exact description of the semantics of
4386 this attribute.
4387
4388 @node Max_Interrupt_Priority
4389 @unnumberedsec Max_Interrupt_Priority
4390 @cindex Interrupt priority, maximum
4391 @findex Max_Interrupt_Priority
4392 @noindent
4393 @code{Standard'Max_Interrupt_Priority} (@code{Standard} is the only
4394 permissible prefix), provides the same value as
4395 @code{System.Max_Interrupt_Priority}.
4396
4397 @node Max_Priority
4398 @unnumberedsec Max_Priority
4399 @cindex Priority, maximum
4400 @findex Max_Priority
4401 @noindent
4402 @code{Standard'Max_Priority} (@code{Standard} is the only permissible
4403 prefix) provides the same value as @code{System.Max_Priority}.
4404
4405 @node Maximum_Alignment
4406 @unnumberedsec Maximum_Alignment
4407 @cindex Alignment, maximum
4408 @findex Maximum_Alignment
4409 @noindent
4410 @code{Standard'Maximum_Alignment} (@code{Standard} is the only
4411 permissible prefix) provides the maximum useful alignment value for the
4412 target.  This is a static value that can be used to specify the alignment
4413 for an object, guaranteeing that it is properly aligned in all
4414 cases.
4415
4416 @node Mechanism_Code
4417 @unnumberedsec Mechanism_Code
4418 @cindex Return values, passing mechanism
4419 @cindex Parameters, passing mechanism
4420 @findex Mechanism_Code
4421 @noindent
4422 @code{@var{function}'Mechanism_Code} yields an integer code for the
4423 mechanism used for the result of function, and
4424 @code{@var{subprogram}'Mechanism_Code (@var{n})} yields the mechanism
4425 used for formal parameter number @var{n} (a static integer value with 1
4426 meaning the first parameter) of @var{subprogram}.  The code returned is:
4427
4428 @table @asis
4429 @item 1
4430 by copy (value)
4431 @item 2
4432 by reference
4433 @item 3
4434 by descriptor (default descriptor class)
4435 @item 4
4436 by descriptor (UBS: unaligned bit string)
4437 @item 5
4438 by descriptor (UBSB: aligned bit string with arbitrary bounds)
4439 @item 6
4440 by descriptor (UBA: unaligned bit array)
4441 @item 7
4442 by descriptor (S: string, also scalar access type parameter)
4443 @item 8
4444 by descriptor (SB: string with arbitrary bounds)
4445 @item 9
4446 by descriptor (A: contiguous array)
4447 @item 10
4448 by descriptor (NCA: non-contiguous array)
4449 @end table
4450
4451 @noindent
4452 Values from 3 through 10 are only relevant to Digital OpenVMS implementations.
4453 @cindex OpenVMS
4454
4455 @node Null_Parameter
4456 @unnumberedsec Null_Parameter
4457 @cindex Zero address, passing
4458 @findex Null_Parameter
4459 @noindent
4460 A reference @code{@var{T}'Null_Parameter} denotes an imaginary object of
4461 type or subtype @var{T} allocated at machine address zero.  The attribute
4462 is allowed only as the default expression of a formal parameter, or as
4463 an actual expression of a subprogram call.  In either case, the
4464 subprogram must be imported.
4465
4466 The identity of the object is represented by the address zero in the
4467 argument list, independent of the passing mechanism (explicit or
4468 default).
4469
4470 This capability is needed to specify that a zero address should be
4471 passed for a record or other composite object passed by reference.
4472 There is no way of indicating this without the @code{Null_Parameter}
4473 attribute.
4474
4475 @node Object_Size
4476 @unnumberedsec Object_Size
4477 @cindex Size, used for objects
4478 @findex Object_Size
4479 @noindent
4480 The size of an object is not necessarily the same as the size of the type
4481 of an object.  This is because by default object sizes are increased to be
4482 a multiple of the alignment of the object.  For example,
4483 @code{Natural'Size} is
4484 31, but by default objects of type @code{Natural} will have a size of 32 bits.
4485 Similarly, a record containing an integer and a character:
4486
4487 @smallexample @c ada
4488 type Rec is record
4489    I : Integer;
4490    C : Character;
4491 end record;
4492 @end smallexample
4493
4494 @noindent
4495 will have a size of 40 (that is @code{Rec'Size} will be 40.  The
4496 alignment will be 4, because of the
4497 integer field, and so the default size of record objects for this type
4498 will be 64 (8 bytes).
4499
4500 The @code{@var{type}'Object_Size} attribute
4501 has been added to GNAT to allow the
4502 default object size of a type to be easily determined.  For example,
4503 @code{Natural'Object_Size} is 32, and
4504 @code{Rec'Object_Size} (for the record type in the above example) will be
4505 64.  Note also that, unlike the situation with the
4506 @code{Size} attribute as defined in the Ada RM, the
4507 @code{Object_Size} attribute can be specified individually
4508 for different subtypes.  For example:
4509
4510 @smallexample @c ada
4511 type R is new Integer;
4512 subtype R1 is R range 1 .. 10;
4513 subtype R2 is R range 1 .. 10;
4514 for R2'Object_Size use 8;
4515 @end smallexample
4516
4517 @noindent
4518 In this example, @code{R'Object_Size} and @code{R1'Object_Size} are both
4519 32 since the default object size for a subtype is the same as the object size
4520 for the parent subtype.  This means that objects of type @code{R}
4521 or @code{R1} will
4522 by default be 32 bits (four bytes).  But objects of type
4523 @code{R2} will be only
4524 8 bits (one byte), since @code{R2'Object_Size} has been set to 8.
4525
4526 @node Passed_By_Reference
4527 @unnumberedsec Passed_By_Reference
4528 @cindex Parameters, when passed by reference
4529 @findex Passed_By_Reference
4530 @noindent
4531 @code{@var{type}'Passed_By_Reference} for any subtype @var{type} returns
4532 a value of type @code{Boolean} value that is @code{True} if the type is
4533 normally passed by reference and @code{False} if the type is normally
4534 passed by copy in calls.  For scalar types, the result is always @code{False}
4535 and is static.  For non-scalar types, the result is non-static.
4536
4537 @node Range_Length
4538 @unnumberedsec Range_Length
4539 @findex Range_Length
4540 @noindent
4541 @code{@var{type}'Range_Length} for any discrete type @var{type} yields
4542 the number of values represented by the subtype (zero for a null
4543 range).  The result is static for static subtypes.  @code{Range_Length}
4544 applied to the index subtype of a one dimensional array always gives the
4545 same result as @code{Range} applied to the array itself.
4546
4547 @node Safe_Emax
4548 @unnumberedsec Safe_Emax
4549 @cindex Ada 83 attributes
4550 @findex Safe_Emax
4551 @noindent
4552 The @code{Safe_Emax} attribute is provided for compatibility with Ada 83.  See
4553 the Ada 83 reference manual for an exact description of the semantics of
4554 this attribute.
4555
4556 @node Safe_Large
4557 @unnumberedsec Safe_Large
4558 @cindex Ada 83 attributes
4559 @findex Safe_Large
4560 @noindent
4561 The @code{Safe_Large} attribute is provided for compatibility with Ada 83.  See
4562 the Ada 83 reference manual for an exact description of the semantics of
4563 this attribute.
4564
4565 @node Small
4566 @unnumberedsec Small
4567 @cindex Ada 83 attributes
4568 @findex Small
4569 @noindent
4570 The @code{Small} attribute is defined in Ada 95 only for fixed-point types.
4571 GNAT also allows this attribute to be applied to floating-point types
4572 for compatibility with Ada 83.  See
4573 the Ada 83 reference manual for an exact description of the semantics of
4574 this attribute when applied to floating-point types.
4575
4576 @node Storage_Unit
4577 @unnumberedsec Storage_Unit
4578 @findex Storage_Unit
4579 @noindent
4580 @code{Standard'Storage_Unit} (@code{Standard} is the only permissible
4581 prefix) provides the same value as @code{System.Storage_Unit}.
4582
4583 @node Target_Name
4584 @unnumberedsec Target_Name
4585 @findex Target_Name
4586 @noindent
4587 @code{Standard'Target_Name} (@code{Standard} is the only permissible
4588 prefix) provides a static string value that identifies the target
4589 for the current compilation. For GCC implementations, this is the
4590 standard gcc target name without the terminating slash (for
4591 example, GNAT 5.0 on windows yields "i586-pc-mingw32msv").
4592
4593 @node Tick
4594 @unnumberedsec Tick
4595 @findex Tick
4596 @noindent
4597 @code{Standard'Tick} (@code{Standard} is the only permissible prefix)
4598 provides the same value as @code{System.Tick},
4599
4600 @node To_Address
4601 @unnumberedsec To_Address
4602 @findex To_Address
4603 @noindent
4604 The @code{System'To_Address}
4605 (@code{System} is the only permissible prefix)
4606 denotes a function identical to
4607 @code{System.Storage_Elements.To_Address} except that
4608 it is a static attribute.  This means that if its argument is
4609 a static expression, then the result of the attribute is a
4610 static expression.  The result is that such an expression can be
4611 used in contexts (e.g.@: preelaborable packages) which require a
4612 static expression and where the function call could not be used
4613 (since the function call is always non-static, even if its
4614 argument is static).
4615
4616 @node Type_Class
4617 @unnumberedsec Type_Class
4618 @findex Type_Class
4619 @noindent
4620 @code{@var{type}'Type_Class} for any type or subtype @var{type} yields
4621 the value of the type class for the full type of @var{type}.  If
4622 @var{type} is a generic formal type, the value is the value for the
4623 corresponding actual subtype.  The value of this attribute is of type
4624 @code{System.Aux_DEC.Type_Class}, which has the following definition:
4625
4626 @smallexample @c ada
4627   type Type_Class is
4628     (Type_Class_Enumeration,
4629      Type_Class_Integer,
4630      Type_Class_Fixed_Point,
4631      Type_Class_Floating_Point,
4632      Type_Class_Array,
4633      Type_Class_Record,
4634      Type_Class_Access,
4635      Type_Class_Task,
4636      Type_Class_Address);
4637 @end smallexample
4638
4639 @noindent
4640 Protected types yield the value @code{Type_Class_Task}, which thus
4641 applies to all concurrent types.  This attribute is designed to
4642 be compatible with the DEC Ada 83 attribute of the same name.
4643
4644 @node UET_Address
4645 @unnumberedsec UET_Address
4646 @findex UET_Address
4647 @noindent
4648 The @code{UET_Address} attribute can only be used for a prefix which
4649 denotes a library package.  It yields the address of the unit exception
4650 table when zero cost exception handling is used.  This attribute is
4651 intended only for use within the GNAT implementation.  See the unit
4652 @code{Ada.Exceptions} in files @file{a-except.ads} and @file{a-except.adb}
4653 for details on how this attribute is used in the implementation.
4654
4655 @node Unconstrained_Array
4656 @unnumberedsec Unconstrained_Array
4657 @findex Unconstrained_Array
4658 @noindent
4659 The @code{Unconstrained_Array} attribute can be used with a prefix that
4660 denotes any type or subtype. It is a static attribute that yields
4661 @code{True} if the prefix designates an unconstrained array,
4662 and @code{False} otherwise. In a generic instance, the result is
4663 still static, and yields the result of applying this test to the
4664 generic actual.
4665
4666 @node Universal_Literal_String
4667 @unnumberedsec Universal_Literal_String
4668 @cindex Named numbers, representation of
4669 @findex Universal_Literal_String
4670 @noindent
4671 The prefix of @code{Universal_Literal_String} must be a named
4672 number.  The static result is the string consisting of the characters of
4673 the number as defined in the original source.  This allows the user
4674 program to access the actual text of named numbers without intermediate
4675 conversions and without the need to enclose the strings in quotes (which
4676 would preclude their use as numbers).  This is used internally for the
4677 construction of values of the floating-point attributes from the file
4678 @file{ttypef.ads}, but may also be used by user programs.
4679
4680 @node Unrestricted_Access
4681 @unnumberedsec Unrestricted_Access
4682 @cindex @code{Access}, unrestricted
4683 @findex Unrestricted_Access
4684 @noindent
4685 The @code{Unrestricted_Access} attribute is similar to @code{Access}
4686 except that all accessibility and aliased view checks are omitted.  This
4687 is a user-beware attribute.  It is similar to
4688 @code{Address}, for which it is a desirable replacement where the value
4689 desired is an access type.  In other words, its effect is identical to
4690 first applying the @code{Address} attribute and then doing an unchecked
4691 conversion to a desired access type.  In GNAT, but not necessarily in
4692 other implementations, the use of static chains for inner level
4693 subprograms means that @code{Unrestricted_Access} applied to a
4694 subprogram yields a value that can be called as long as the subprogram
4695 is in scope (normal Ada 95 accessibility rules restrict this usage).
4696
4697 It is possible to use @code{Unrestricted_Access} for any type, but care
4698 must be excercised if it is used to create pointers to unconstrained
4699 objects. In this case, the resulting pointer has the same scope as the
4700 context of the attribute, and may not be returned to some enclosing
4701 scope. For instance, a function cannot use @code{Unrestricted_Access}
4702 to create a unconstrained pointer and then return that value to the
4703 caller.
4704
4705 @node VADS_Size
4706 @unnumberedsec VADS_Size
4707 @cindex @code{Size}, VADS compatibility
4708 @findex VADS_Size
4709 @noindent
4710 The @code{'VADS_Size} attribute is intended to make it easier to port
4711 legacy code which relies on the semantics of @code{'Size} as implemented
4712 by the VADS Ada 83 compiler.  GNAT makes a best effort at duplicating the
4713 same semantic interpretation.  In particular, @code{'VADS_Size} applied
4714 to a predefined or other primitive type with no Size clause yields the
4715 Object_Size (for example, @code{Natural'Size} is 32 rather than 31 on
4716 typical machines).  In addition @code{'VADS_Size} applied to an object
4717 gives the result that would be obtained by applying the attribute to
4718 the corresponding type.
4719
4720 @node Value_Size
4721 @unnumberedsec Value_Size
4722 @cindex @code{Size}, setting for not-first subtype
4723 @findex Value_Size
4724 @code{@var{type}'Value_Size} is the number of bits required to represent
4725 a value of the given subtype.  It is the same as @code{@var{type}'Size},
4726 but, unlike @code{Size}, may be set for non-first subtypes.
4727
4728 @node Wchar_T_Size
4729 @unnumberedsec Wchar_T_Size
4730 @findex Wchar_T_Size
4731 @code{Standard'Wchar_T_Size} (@code{Standard} is the only permissible
4732 prefix) provides the size in bits of the C @code{wchar_t} type
4733 primarily for constructing the definition of this type in
4734 package @code{Interfaces.C}.
4735
4736 @node Word_Size
4737 @unnumberedsec Word_Size
4738 @findex Word_Size
4739 @code{Standard'Word_Size} (@code{Standard} is the only permissible
4740 prefix) provides the value @code{System.Word_Size}.
4741
4742 @c ------------------------
4743 @node Implementation Advice
4744 @chapter Implementation Advice
4745 @noindent
4746 The main text of the Ada 95 Reference Manual describes the required
4747 behavior of all Ada 95 compilers, and the GNAT compiler conforms to
4748 these requirements.
4749
4750 In addition, there are sections throughout the Ada 95
4751 reference manual headed
4752 by the phrase ``implementation advice''.  These sections are not normative,
4753 i.e.@: they do not specify requirements that all compilers must
4754 follow.  Rather they provide advice on generally desirable behavior.  You
4755 may wonder why they are not requirements.  The most typical answer is
4756 that they describe behavior that seems generally desirable, but cannot
4757 be provided on all systems, or which may be undesirable on some systems.
4758
4759 As far as practical, GNAT follows the implementation advice sections in
4760 the Ada 95 Reference Manual.  This chapter contains a table giving the
4761 reference manual section number, paragraph number and several keywords
4762 for each advice.  Each entry consists of the text of the advice followed
4763 by the GNAT interpretation of this advice.  Most often, this simply says
4764 ``followed'', which means that GNAT follows the advice.  However, in a
4765 number of cases, GNAT deliberately deviates from this advice, in which
4766 case the text describes what GNAT does and why.
4767
4768 @cindex Error detection
4769 @unnumberedsec 1.1.3(20): Error Detection
4770 @sp 1
4771 @cartouche
4772 If an implementation detects the use of an unsupported Specialized Needs
4773 Annex feature at run time, it should raise @code{Program_Error} if
4774 feasible.
4775 @end cartouche
4776 Not relevant.  All specialized needs annex features are either supported,
4777 or diagnosed at compile time.
4778
4779 @cindex Child Units
4780 @unnumberedsec 1.1.3(31): Child Units
4781 @sp 1
4782 @cartouche
4783 If an implementation wishes to provide implementation-defined
4784 extensions to the functionality of a language-defined library unit, it
4785 should normally do so by adding children to the library unit.
4786 @end cartouche
4787 Followed.
4788
4789 @cindex Bounded errors
4790 @unnumberedsec 1.1.5(12): Bounded Errors
4791 @sp 1
4792 @cartouche
4793 If an implementation detects a bounded error or erroneous
4794 execution, it should raise @code{Program_Error}.
4795 @end cartouche
4796 Followed in all cases in which the implementation detects a bounded
4797 error or erroneous execution.  Not all such situations are detected at
4798 runtime.
4799
4800 @cindex Pragmas
4801 @unnumberedsec 2.8(16): Pragmas
4802 @sp 1
4803 @cartouche
4804 Normally, implementation-defined pragmas should have no semantic effect
4805 for error-free programs; that is, if the implementation-defined pragmas
4806 are removed from a working program, the program should still be legal,
4807 and should still have the same semantics.
4808 @end cartouche
4809 The following implementation defined pragmas are exceptions to this
4810 rule:
4811
4812 @table @code
4813 @item Abort_Defer
4814 Affects semantics
4815 @item Ada_83
4816 Affects legality
4817 @item Assert
4818 Affects semantics
4819 @item CPP_Class
4820 Affects semantics
4821 @item CPP_Constructor
4822 Affects semantics
4823 @item CPP_Virtual
4824 Affects semantics
4825 @item CPP_Vtable
4826 Affects semantics
4827 @item Debug
4828 Affects semantics
4829 @item Interface_Name
4830 Affects semantics
4831 @item Machine_Attribute
4832 Affects semantics
4833 @item Unimplemented_Unit
4834 Affects legality
4835 @item Unchecked_Union
4836 Affects semantics
4837 @end table
4838
4839 @noindent
4840 In each of the above cases, it is essential to the purpose of the pragma
4841 that this advice not be followed.  For details see the separate section
4842 on implementation defined pragmas.
4843
4844 @unnumberedsec 2.8(17-19): Pragmas
4845 @sp 1
4846 @cartouche
4847 Normally, an implementation should not define pragmas that can
4848 make an illegal program legal, except as follows:
4849 @end cartouche
4850 @sp 1
4851 @cartouche
4852 A pragma used to complete a declaration, such as a pragma @code{Import};
4853 @end cartouche
4854 @sp 1
4855 @cartouche
4856 A pragma used to configure the environment by adding, removing, or
4857 replacing @code{library_items}.
4858 @end cartouche
4859 See response to paragraph 16 of this same section.
4860
4861 @cindex Character Sets
4862 @cindex Alternative Character Sets
4863 @unnumberedsec 3.5.2(5): Alternative Character Sets
4864 @sp 1
4865 @cartouche
4866 If an implementation supports a mode with alternative interpretations
4867 for @code{Character} and @code{Wide_Character}, the set of graphic
4868 characters of @code{Character} should nevertheless remain a proper
4869 subset of the set of graphic characters of @code{Wide_Character}.  Any
4870 character set ``localizations'' should be reflected in the results of
4871 the subprograms defined in the language-defined package
4872 @code{Characters.Handling} (see A.3) available in such a mode.  In a mode with
4873 an alternative interpretation of @code{Character}, the implementation should
4874 also support a corresponding change in what is a legal
4875 @code{identifier_letter}.
4876 @end cartouche
4877 Not all wide character modes follow this advice, in particular the JIS
4878 and IEC modes reflect standard usage in Japan, and in these encoding,
4879 the upper half of the Latin-1 set is not part of the wide-character
4880 subset, since the most significant bit is used for wide character
4881 encoding.  However, this only applies to the external forms.  Internally
4882 there is no such restriction.
4883
4884 @cindex Integer types
4885 @unnumberedsec 3.5.4(28): Integer Types
4886
4887 @sp 1
4888 @cartouche
4889 An implementation should support @code{Long_Integer} in addition to
4890 @code{Integer} if the target machine supports 32-bit (or longer)
4891 arithmetic.  No other named integer subtypes are recommended for package
4892 @code{Standard}.  Instead, appropriate named integer subtypes should be
4893 provided in the library package @code{Interfaces} (see B.2).
4894 @end cartouche
4895 @code{Long_Integer} is supported.  Other standard integer types are supported
4896 so this advice is not fully followed.  These types
4897 are supported for convenient interface to C, and so that all hardware
4898 types of the machine are easily available.
4899 @unnumberedsec 3.5.4(29): Integer Types
4900
4901 @sp 1
4902 @cartouche
4903 An implementation for a two's complement machine should support
4904 modular types with a binary modulus up to @code{System.Max_Int*2+2}.  An
4905 implementation should support a non-binary modules up to @code{Integer'Last}.
4906 @end cartouche
4907 Followed.
4908
4909 @cindex Enumeration values
4910 @unnumberedsec 3.5.5(8): Enumeration Values
4911 @sp 1
4912 @cartouche
4913 For the evaluation of a call on @code{@var{S}'Pos} for an enumeration
4914 subtype, if the value of the operand does not correspond to the internal
4915 code for any enumeration literal of its type (perhaps due to an
4916 un-initialized variable), then the implementation should raise
4917 @code{Program_Error}.  This is particularly important for enumeration
4918 types with noncontiguous internal codes specified by an
4919 enumeration_representation_clause.
4920 @end cartouche
4921 Followed.
4922
4923 @cindex Float types
4924 @unnumberedsec 3.5.7(17): Float Types
4925 @sp 1
4926 @cartouche
4927 An implementation should support @code{Long_Float} in addition to
4928 @code{Float} if the target machine supports 11 or more digits of
4929 precision.  No other named floating point subtypes are recommended for
4930 package @code{Standard}.  Instead, appropriate named floating point subtypes
4931 should be provided in the library package @code{Interfaces} (see B.2).
4932 @end cartouche
4933 @code{Short_Float} and @code{Long_Long_Float} are also provided.  The
4934 former provides improved compatibility with other implementations
4935 supporting this type.  The latter corresponds to the highest precision
4936 floating-point type supported by the hardware.  On most machines, this
4937 will be the same as @code{Long_Float}, but on some machines, it will
4938 correspond to the IEEE extended form.  The notable case is all ia32
4939 (x86) implementations, where @code{Long_Long_Float} corresponds to
4940 the 80-bit extended precision format supported in hardware on this
4941 processor.  Note that the 128-bit format on SPARC is not supported,
4942 since this is a software rather than a hardware format.
4943
4944 @cindex Multidimensional arrays
4945 @cindex Arrays, multidimensional
4946 @unnumberedsec 3.6.2(11): Multidimensional Arrays
4947 @sp 1
4948 @cartouche
4949 An implementation should normally represent multidimensional arrays in
4950 row-major order, consistent with the notation used for multidimensional
4951 array aggregates (see 4.3.3).  However, if a pragma @code{Convention}
4952 (@code{Fortran}, @dots{}) applies to a multidimensional array type, then
4953 column-major order should be used instead (see B.5, ``Interfacing with
4954 Fortran'').
4955 @end cartouche
4956 Followed.
4957
4958 @findex Duration'Small
4959 @unnumberedsec 9.6(30-31): Duration'Small
4960 @sp 1
4961 @cartouche
4962 Whenever possible in an implementation, the value of @code{Duration'Small}
4963 should be no greater than 100 microseconds.
4964 @end cartouche
4965 Followed.  (@code{Duration'Small} = 10**(@minus{}9)).
4966
4967 @sp 1
4968 @cartouche
4969 The time base for @code{delay_relative_statements} should be monotonic;
4970 it need not be the same time base as used for @code{Calendar.Clock}.
4971 @end cartouche
4972 Followed.
4973
4974 @unnumberedsec 10.2.1(12): Consistent Representation
4975 @sp 1
4976 @cartouche
4977 In an implementation, a type declared in a pre-elaborated package should
4978 have the same representation in every elaboration of a given version of
4979 the package, whether the elaborations occur in distinct executions of
4980 the same program, or in executions of distinct programs or partitions
4981 that include the given version.
4982 @end cartouche
4983 Followed, except in the case of tagged types.  Tagged types involve
4984 implicit pointers to a local copy of a dispatch table, and these pointers
4985 have representations which thus depend on a particular elaboration of the
4986 package.  It is not easy to see how it would be possible to follow this
4987 advice without severely impacting efficiency of execution.
4988
4989 @cindex Exception information
4990 @unnumberedsec 11.4.1(19): Exception Information
4991 @sp 1
4992 @cartouche
4993 @code{Exception_Message} by default and @code{Exception_Information}
4994 should produce information useful for
4995 debugging.  @code{Exception_Message} should be short, about one
4996 line.  @code{Exception_Information} can be long.  @code{Exception_Message}
4997 should not include the
4998 @code{Exception_Name}.  @code{Exception_Information} should include both
4999 the @code{Exception_Name} and the @code{Exception_Message}.
5000 @end cartouche
5001 Followed.  For each exception that doesn't have a specified
5002 @code{Exception_Message}, the compiler generates one containing the location
5003 of the raise statement.  This location has the form ``file:line'', where
5004 file is the short file name (without path information) and line is the line
5005 number in the file.  Note that in the case of the Zero Cost Exception
5006 mechanism, these messages become redundant with the Exception_Information that
5007 contains a full backtrace of the calling sequence, so they are disabled.
5008 To disable explicitly the generation of the source location message, use the
5009 Pragma @code{Discard_Names}.
5010
5011 @cindex Suppression of checks
5012 @cindex Checks, suppression of
5013 @unnumberedsec 11.5(28): Suppression of Checks
5014 @sp 1
5015 @cartouche
5016 The implementation should minimize the code executed for checks that
5017 have been suppressed.
5018 @end cartouche
5019 Followed.
5020
5021 @cindex Representation clauses
5022 @unnumberedsec 13.1 (21-24): Representation Clauses
5023 @sp 1
5024 @cartouche
5025 The recommended level of support for all representation items is
5026 qualified as follows:
5027 @end cartouche
5028 @sp 1
5029 @cartouche
5030 An implementation need not support representation items containing
5031 non-static expressions, except that an implementation should support a
5032 representation item for a given entity if each non-static expression in
5033 the representation item is a name that statically denotes a constant
5034 declared before the entity.
5035 @end cartouche
5036 Followed.  GNAT does not support non-static expressions in representation
5037 clauses unless they are constants declared before the entity.  For
5038 example:
5039
5040 @smallexample @c ada
5041 X : Some_Type;
5042 for X'Address use To_address (16#2000#);
5043 @end smallexample
5044
5045 @noindent
5046 will be rejected, since the To_Address expression is non-static.  Instead
5047 write:
5048
5049 @smallexample @c ada
5050 X_Address : constant Address : = To_Address (16#2000#);
5051 X         : Some_Type;
5052 for X'Address use X_Address;
5053 @end smallexample
5054
5055 @sp 1
5056 @cartouche
5057 An implementation need not support a specification for the @code{Size}
5058 for a given composite subtype, nor the size or storage place for an
5059 object (including a component) of a given composite subtype, unless the
5060 constraints on the subtype and its composite subcomponents (if any) are
5061 all static constraints.
5062 @end cartouche
5063 Followed.  Size Clauses are not permitted on non-static components, as
5064 described above.
5065
5066 @sp 1
5067 @cartouche
5068 An aliased component, or a component whose type is by-reference, should
5069 always be allocated at an addressable location.
5070 @end cartouche
5071 Followed.
5072
5073 @cindex Packed types
5074 @unnumberedsec 13.2(6-8): Packed Types
5075 @sp 1
5076 @cartouche
5077 If a type is packed, then the implementation should try to minimize
5078 storage allocated to objects of the type, possibly at the expense of
5079 speed of accessing components, subject to reasonable complexity in
5080 addressing calculations.
5081 @end cartouche
5082 @sp 1
5083 @cartouche
5084 The recommended level of support pragma @code{Pack} is:
5085
5086 For a packed record type, the components should be packed as tightly as
5087 possible subject to the Sizes of the component subtypes, and subject to
5088 any @code{record_representation_clause} that applies to the type; the
5089 implementation may, but need not, reorder components or cross aligned
5090 word boundaries to improve the packing.  A component whose @code{Size} is
5091 greater than the word size may be allocated an integral number of words.
5092 @end cartouche
5093 Followed.  Tight packing of arrays is supported for all component sizes
5094 up to 64-bits. If the array component size is 1 (that is to say, if
5095 the component is a boolean type or an enumeration type with two values)
5096 then values of the type are implicitly initialized to zero. This
5097 happens both for objects of the packed type, and for objects that have a
5098 subcomponent of the packed type.
5099
5100 @sp 1
5101 @cartouche
5102 An implementation should support Address clauses for imported
5103 subprograms.
5104 @end cartouche
5105 Followed.
5106 @cindex @code{Address} clauses
5107 @unnumberedsec 13.3(14-19): Address Clauses
5108
5109 @sp 1
5110 @cartouche
5111 For an array @var{X}, @code{@var{X}'Address} should point at the first
5112 component of the array, and not at the array bounds.
5113 @end cartouche
5114 Followed.
5115
5116 @sp 1
5117 @cartouche
5118 The recommended level of support for the @code{Address} attribute is:
5119
5120 @code{@var{X}'Address} should produce a useful result if @var{X} is an
5121 object that is aliased or of a by-reference type, or is an entity whose
5122 @code{Address} has been specified.
5123 @end cartouche
5124 Followed.  A valid address will be produced even if none of those
5125 conditions have been met.  If necessary, the object is forced into
5126 memory to ensure the address is valid.
5127
5128 @sp 1
5129 @cartouche
5130 An implementation should support @code{Address} clauses for imported
5131 subprograms.
5132 @end cartouche
5133 Followed.
5134
5135 @sp 1
5136 @cartouche
5137 Objects (including subcomponents) that are aliased or of a by-reference
5138 type should be allocated on storage element boundaries.
5139 @end cartouche
5140 Followed.
5141
5142 @sp 1
5143 @cartouche
5144 If the @code{Address} of an object is specified, or it is imported or exported,
5145 then the implementation should not perform optimizations based on
5146 assumptions of no aliases.
5147 @end cartouche
5148 Followed.
5149
5150 @cindex @code{Alignment} clauses
5151 @unnumberedsec 13.3(29-35): Alignment Clauses
5152 @sp 1
5153 @cartouche
5154 The recommended level of support for the @code{Alignment} attribute for
5155 subtypes is:
5156
5157 An implementation should support specified Alignments that are factors
5158 and multiples of the number of storage elements per word, subject to the
5159 following:
5160 @end cartouche
5161 Followed.
5162
5163 @sp 1
5164 @cartouche
5165 An implementation need not support specified @code{Alignment}s for
5166 combinations of @code{Size}s and @code{Alignment}s that cannot be easily
5167 loaded and stored by available machine instructions.
5168 @end cartouche
5169 Followed.
5170
5171 @sp 1
5172 @cartouche
5173 An implementation need not support specified @code{Alignment}s that are
5174 greater than the maximum @code{Alignment} the implementation ever returns by
5175 default.
5176 @end cartouche
5177 Followed.
5178
5179 @sp 1
5180 @cartouche
5181 The recommended level of support for the @code{Alignment} attribute for
5182 objects is:
5183
5184 Same as above, for subtypes, but in addition:
5185 @end cartouche
5186 Followed.
5187
5188 @sp 1
5189 @cartouche
5190 For stand-alone library-level objects of statically constrained
5191 subtypes, the implementation should support all @code{Alignment}s
5192 supported by the target linker.  For example, page alignment is likely to
5193 be supported for such objects, but not for subtypes.
5194 @end cartouche
5195 Followed.
5196
5197 @cindex @code{Size} clauses
5198 @unnumberedsec 13.3(42-43): Size Clauses
5199 @sp 1
5200 @cartouche
5201 The recommended level of support for the @code{Size} attribute of
5202 objects is:
5203
5204 A @code{Size} clause should be supported for an object if the specified
5205 @code{Size} is at least as large as its subtype's @code{Size}, and
5206 corresponds to a size in storage elements that is a multiple of the
5207 object's @code{Alignment} (if the @code{Alignment} is nonzero).
5208 @end cartouche
5209 Followed.
5210
5211 @unnumberedsec 13.3(50-56): Size Clauses
5212 @sp 1
5213 @cartouche
5214 If the @code{Size} of a subtype is specified, and allows for efficient
5215 independent addressability (see 9.10) on the target architecture, then
5216 the @code{Size} of the following objects of the subtype should equal the
5217 @code{Size} of the subtype:
5218
5219 Aliased objects (including components).
5220 @end cartouche
5221 Followed.
5222
5223 @sp 1
5224 @cartouche
5225 @code{Size} clause on a composite subtype should not affect the
5226 internal layout of components.
5227 @end cartouche
5228 Followed.
5229
5230 @sp 1
5231 @cartouche
5232 The recommended level of support for the @code{Size} attribute of subtypes is:
5233 @end cartouche
5234 @sp 1
5235 @cartouche
5236 The @code{Size} (if not specified) of a static discrete or fixed point
5237 subtype should be the number of bits needed to represent each value
5238 belonging to the subtype using an unbiased representation, leaving space
5239 for a sign bit only if the subtype contains negative values.  If such a
5240 subtype is a first subtype, then an implementation should support a
5241 specified @code{Size} for it that reflects this representation.
5242 @end cartouche
5243 Followed.
5244
5245 @sp 1
5246 @cartouche
5247 For a subtype implemented with levels of indirection, the @code{Size}
5248 should include the size of the pointers, but not the size of what they
5249 point at.
5250 @end cartouche
5251 Followed.
5252
5253 @cindex @code{Component_Size} clauses
5254 @unnumberedsec 13.3(71-73): Component Size Clauses
5255 @sp 1
5256 @cartouche
5257 The recommended level of support for the @code{Component_Size}
5258 attribute is:
5259 @end cartouche
5260 @sp 1
5261 @cartouche
5262 An implementation need not support specified @code{Component_Sizes} that are
5263 less than the @code{Size} of the component subtype.
5264 @end cartouche
5265 Followed.
5266
5267 @sp 1
5268 @cartouche
5269 An implementation should support specified @code{Component_Size}s that
5270 are factors and multiples of the word size.  For such
5271 @code{Component_Size}s, the array should contain no gaps between
5272 components.  For other @code{Component_Size}s (if supported), the array
5273 should contain no gaps between components when packing is also
5274 specified; the implementation should forbid this combination in cases
5275 where it cannot support a no-gaps representation.
5276 @end cartouche
5277 Followed.
5278
5279 @cindex Enumeration representation clauses
5280 @cindex Representation clauses, enumeration
5281 @unnumberedsec 13.4(9-10): Enumeration Representation Clauses
5282 @sp 1
5283 @cartouche
5284 The recommended level of support for enumeration representation clauses
5285 is:
5286
5287 An implementation need not support enumeration representation clauses
5288 for boolean types, but should at minimum support the internal codes in
5289 the range @code{System.Min_Int.System.Max_Int}.
5290 @end cartouche
5291 Followed.
5292
5293 @cindex Record representation clauses
5294 @cindex Representation clauses, records
5295 @unnumberedsec 13.5.1(17-22): Record Representation Clauses
5296 @sp 1
5297 @cartouche
5298 The recommended level of support for
5299 @*@code{record_representation_clauses} is:
5300
5301 An implementation should support storage places that can be extracted
5302 with a load, mask, shift sequence of machine code, and set with a load,
5303 shift, mask, store sequence, given the available machine instructions
5304 and run-time model.
5305 @end cartouche
5306 Followed.
5307
5308 @sp 1
5309 @cartouche
5310 A storage place should be supported if its size is equal to the
5311 @code{Size} of the component subtype, and it starts and ends on a
5312 boundary that obeys the @code{Alignment} of the component subtype.
5313 @end cartouche
5314 Followed.
5315
5316 @sp 1
5317 @cartouche
5318 If the default bit ordering applies to the declaration of a given type,
5319 then for a component whose subtype's @code{Size} is less than the word
5320 size, any storage place that does not cross an aligned word boundary
5321 should be supported.
5322 @end cartouche
5323 Followed.
5324
5325 @sp 1
5326 @cartouche
5327 An implementation may reserve a storage place for the tag field of a
5328 tagged type, and disallow other components from overlapping that place.
5329 @end cartouche
5330 Followed.  The storage place for the tag field is the beginning of the tagged
5331 record, and its size is Address'Size.  GNAT will reject an explicit component
5332 clause for the tag field.
5333
5334 @sp 1
5335 @cartouche
5336 An implementation need not support a @code{component_clause} for a
5337 component of an extension part if the storage place is not after the
5338 storage places of all components of the parent type, whether or not
5339 those storage places had been specified.
5340 @end cartouche
5341 Followed.  The above advice on record representation clauses is followed,
5342 and all mentioned features are implemented.
5343
5344 @cindex Storage place attributes
5345 @unnumberedsec 13.5.2(5): Storage Place Attributes
5346 @sp 1
5347 @cartouche
5348 If a component is represented using some form of pointer (such as an
5349 offset) to the actual data of the component, and this data is contiguous
5350 with the rest of the object, then the storage place attributes should
5351 reflect the place of the actual data, not the pointer.  If a component is
5352 allocated discontinuously from the rest of the object, then a warning
5353 should be generated upon reference to one of its storage place
5354 attributes.
5355 @end cartouche
5356 Followed.  There are no such components in GNAT@.
5357
5358 @cindex Bit ordering
5359 @unnumberedsec 13.5.3(7-8): Bit Ordering
5360 @sp 1
5361 @cartouche
5362 The recommended level of support for the non-default bit ordering is:
5363 @end cartouche
5364 @sp 1
5365 @cartouche
5366 If @code{Word_Size} = @code{Storage_Unit}, then the implementation
5367 should support the non-default bit ordering in addition to the default
5368 bit ordering.
5369 @end cartouche
5370 Followed.  Word size does not equal storage size in this implementation.
5371 Thus non-default bit ordering is not supported.
5372
5373 @cindex @code{Address}, as private type
5374 @unnumberedsec 13.7(37): Address as Private
5375 @sp 1
5376 @cartouche
5377 @code{Address} should be of a private type.
5378 @end cartouche
5379 Followed.
5380
5381 @cindex Operations, on @code{Address}
5382 @cindex @code{Address}, operations of
5383 @unnumberedsec 13.7.1(16): Address Operations
5384 @sp 1
5385 @cartouche
5386 Operations in @code{System} and its children should reflect the target
5387 environment semantics as closely as is reasonable.  For example, on most
5388 machines, it makes sense for address arithmetic to ``wrap around''.
5389 Operations that do not make sense should raise @code{Program_Error}.
5390 @end cartouche
5391 Followed.  Address arithmetic is modular arithmetic that wraps around.  No
5392 operation raises @code{Program_Error}, since all operations make sense.
5393
5394 @cindex Unchecked conversion
5395 @unnumberedsec 13.9(14-17): Unchecked Conversion
5396 @sp 1
5397 @cartouche
5398 The @code{Size} of an array object should not include its bounds; hence,
5399 the bounds should not be part of the converted data.
5400 @end cartouche
5401 Followed.
5402
5403 @sp 1
5404 @cartouche
5405 The implementation should not generate unnecessary run-time checks to
5406 ensure that the representation of @var{S} is a representation of the
5407 target type.  It should take advantage of the permission to return by
5408 reference when possible.  Restrictions on unchecked conversions should be
5409 avoided unless required by the target environment.
5410 @end cartouche
5411 Followed.  There are no restrictions on unchecked conversion.  A warning is
5412 generated if the source and target types do not have the same size since
5413 the semantics in this case may be target dependent.
5414
5415 @sp 1
5416 @cartouche
5417 The recommended level of support for unchecked conversions is:
5418 @end cartouche
5419 @sp 1
5420 @cartouche
5421 Unchecked conversions should be supported and should be reversible in
5422 the cases where this clause defines the result.  To enable meaningful use
5423 of unchecked conversion, a contiguous representation should be used for
5424 elementary subtypes, for statically constrained array subtypes whose
5425 component subtype is one of the subtypes described in this paragraph,
5426 and for record subtypes without discriminants whose component subtypes
5427 are described in this paragraph.
5428 @end cartouche
5429 Followed.
5430
5431 @cindex Heap usage, implicit
5432 @unnumberedsec 13.11(23-25): Implicit Heap Usage
5433 @sp 1
5434 @cartouche
5435 An implementation should document any cases in which it dynamically
5436 allocates heap storage for a purpose other than the evaluation of an
5437 allocator.
5438 @end cartouche
5439 Followed, the only other points at which heap storage is dynamically
5440 allocated are as follows:
5441
5442 @itemize @bullet
5443 @item
5444 At initial elaboration time, to allocate dynamically sized global
5445 objects.
5446
5447 @item
5448 To allocate space for a task when a task is created.
5449
5450 @item
5451 To extend the secondary stack dynamically when needed.  The secondary
5452 stack is used for returning variable length results.
5453 @end itemize
5454
5455 @sp 1
5456 @cartouche
5457 A default (implementation-provided) storage pool for an
5458 access-to-constant type should not have overhead to support deallocation of
5459 individual objects.
5460 @end cartouche
5461 Followed.
5462
5463 @sp 1
5464 @cartouche
5465 A storage pool for an anonymous access type should be created at the
5466 point of an allocator for the type, and be reclaimed when the designated
5467 object becomes inaccessible.
5468 @end cartouche
5469 Followed.
5470
5471 @cindex Unchecked deallocation
5472 @unnumberedsec 13.11.2(17): Unchecked De-allocation
5473 @sp 1
5474 @cartouche
5475 For a standard storage pool, @code{Free} should actually reclaim the
5476 storage.
5477 @end cartouche
5478 Followed.
5479
5480 @cindex Stream oriented attributes
5481 @unnumberedsec 13.13.2(17): Stream Oriented Attributes
5482 @sp 1
5483 @cartouche
5484 If a stream element is the same size as a storage element, then the
5485 normal in-memory representation should be used by @code{Read} and
5486 @code{Write} for scalar objects.  Otherwise, @code{Read} and @code{Write}
5487 should use the smallest number of stream elements needed to represent
5488 all values in the base range of the scalar type.
5489 @end cartouche
5490
5491 Followed.  By default, GNAT uses the interpretation suggested by AI-195,
5492 which specifies using the size of the first subtype.
5493 However, such an implementation is based on direct binary
5494 representations and is therefore target- and endianness-dependent.
5495 To address this issue, GNAT also supplies an alternate implementation
5496 of the stream attributes @code{Read} and @code{Write},
5497 which uses the target-independent XDR standard representation
5498 for scalar types.
5499 @cindex XDR representation
5500 @cindex @code{Read} attribute
5501 @cindex @code{Write} attribute
5502 @cindex Stream oriented attributes
5503 The XDR implementation is provided as an alternative body of the
5504 @code{System.Stream_Attributes} package, in the file
5505 @file{s-strxdr.adb} in the GNAT library.
5506 There is no @file{s-strxdr.ads} file.
5507 In order to install the XDR implementation, do the following:
5508 @enumerate
5509 @item Replace the default implementation of the
5510 @code{System.Stream_Attributes} package with the XDR implementation.
5511 For example on a Unix platform issue the commands:
5512 @smallexample
5513 $ mv s-stratt.adb s-strold.adb
5514 $ mv s-strxdr.adb s-stratt.adb
5515 @end smallexample
5516
5517 @item
5518 Rebuild the GNAT run-time library as documented in the
5519 @cite{GNAT User's Guide}
5520 @end enumerate
5521
5522 @unnumberedsec A.1(52): Names of Predefined Numeric Types
5523 @sp 1
5524 @cartouche
5525 If an implementation provides additional named predefined integer types,
5526 then the names should end with @samp{Integer} as in
5527 @samp{Long_Integer}.  If an implementation provides additional named
5528 predefined floating point types, then the names should end with
5529 @samp{Float} as in @samp{Long_Float}.
5530 @end cartouche
5531 Followed.
5532
5533 @findex Ada.Characters.Handling
5534 @unnumberedsec A.3.2(49): @code{Ada.Characters.Handling}
5535 @sp 1
5536 @cartouche
5537 If an implementation provides a localized definition of @code{Character}
5538 or @code{Wide_Character}, then the effects of the subprograms in
5539 @code{Characters.Handling} should reflect the localizations.  See also
5540 3.5.2.
5541 @end cartouche
5542 Followed.  GNAT provides no such localized definitions.
5543
5544 @cindex Bounded-length strings
5545 @unnumberedsec A.4.4(106): Bounded-Length String Handling
5546 @sp 1
5547 @cartouche
5548 Bounded string objects should not be implemented by implicit pointers
5549 and dynamic allocation.
5550 @end cartouche
5551 Followed.  No implicit pointers or dynamic allocation are used.
5552
5553 @cindex Random number generation
5554 @unnumberedsec A.5.2(46-47): Random Number Generation
5555 @sp 1
5556 @cartouche
5557 Any storage associated with an object of type @code{Generator} should be
5558 reclaimed on exit from the scope of the object.
5559 @end cartouche
5560 Followed.
5561
5562 @sp 1
5563 @cartouche
5564 If the generator period is sufficiently long in relation to the number
5565 of distinct initiator values, then each possible value of
5566 @code{Initiator} passed to @code{Reset} should initiate a sequence of
5567 random numbers that does not, in a practical sense, overlap the sequence
5568 initiated by any other value.  If this is not possible, then the mapping
5569 between initiator values and generator states should be a rapidly
5570 varying function of the initiator value.
5571 @end cartouche
5572 Followed.  The generator period is sufficiently long for the first
5573 condition here to hold true.
5574
5575 @findex Get_Immediate
5576 @unnumberedsec A.10.7(23): @code{Get_Immediate}
5577 @sp 1
5578 @cartouche
5579 The @code{Get_Immediate} procedures should be implemented with
5580 unbuffered input.  For a device such as a keyboard, input should be
5581 @dfn{available} if a key has already been typed, whereas for a disk
5582 file, input should always be available except at end of file.  For a file
5583 associated with a keyboard-like device, any line-editing features of the
5584 underlying operating system should be disabled during the execution of
5585 @code{Get_Immediate}.
5586 @end cartouche
5587 Followed on all targets except VxWorks. For VxWorks, there is no way to
5588 provide this functionality that does not result in the input buffer being
5589 flushed before the @code{Get_Immediate} call. A special unit
5590 @code{Interfaces.Vxworks.IO} is provided that contains routines to enable
5591 this functionality.
5592
5593 @findex Export
5594 @unnumberedsec B.1(39-41): Pragma @code{Export}
5595 @sp 1
5596 @cartouche
5597 If an implementation supports pragma @code{Export} to a given language,
5598 then it should also allow the main subprogram to be written in that
5599 language.  It should support some mechanism for invoking the elaboration
5600 of the Ada library units included in the system, and for invoking the
5601 finalization of the environment task.  On typical systems, the
5602 recommended mechanism is to provide two subprograms whose link names are
5603 @code{adainit} and @code{adafinal}.  @code{adainit} should contain the
5604 elaboration code for library units.  @code{adafinal} should contain the
5605 finalization code.  These subprograms should have no effect the second
5606 and subsequent time they are called.
5607 @end cartouche
5608 Followed.
5609
5610 @sp 1
5611 @cartouche
5612 Automatic elaboration of pre-elaborated packages should be
5613 provided when pragma @code{Export} is supported.
5614 @end cartouche
5615 Followed when the main program is in Ada.  If the main program is in a
5616 foreign language, then
5617 @code{adainit} must be called to elaborate pre-elaborated
5618 packages.
5619
5620 @sp 1
5621 @cartouche
5622 For each supported convention @var{L} other than @code{Intrinsic}, an
5623 implementation should support @code{Import} and @code{Export} pragmas
5624 for objects of @var{L}-compatible types and for subprograms, and pragma
5625 @code{Convention} for @var{L}-eligible types and for subprograms,
5626 presuming the other language has corresponding features.  Pragma
5627 @code{Convention} need not be supported for scalar types.
5628 @end cartouche
5629 Followed.
5630
5631 @cindex Package @code{Interfaces}
5632 @findex Interfaces
5633 @unnumberedsec B.2(12-13): Package @code{Interfaces}
5634 @sp 1
5635 @cartouche
5636 For each implementation-defined convention identifier, there should be a
5637 child package of package Interfaces with the corresponding name.  This
5638 package should contain any declarations that would be useful for
5639 interfacing to the language (implementation) represented by the
5640 convention.  Any declarations useful for interfacing to any language on
5641 the given hardware architecture should be provided directly in
5642 @code{Interfaces}.
5643 @end cartouche
5644 Followed.  An additional package not defined
5645 in the Ada 95 Reference Manual is @code{Interfaces.CPP}, used
5646 for interfacing to C++.
5647
5648 @sp 1
5649 @cartouche
5650 An implementation supporting an interface to C, COBOL, or Fortran should
5651 provide the corresponding package or packages described in the following
5652 clauses.
5653 @end cartouche
5654 Followed.  GNAT provides all the packages described in this section.
5655
5656 @cindex C, interfacing with
5657 @unnumberedsec B.3(63-71): Interfacing with C
5658 @sp 1
5659 @cartouche
5660 An implementation should support the following interface correspondences
5661 between Ada and C@.
5662 @end cartouche
5663 Followed.
5664
5665 @sp 1
5666 @cartouche
5667 An Ada procedure corresponds to a void-returning C function.
5668 @end cartouche
5669 Followed.
5670
5671 @sp 1
5672 @cartouche
5673 An Ada function corresponds to a non-void C function.
5674 @end cartouche
5675 Followed.
5676
5677 @sp 1
5678 @cartouche
5679 An Ada @code{in} scalar parameter is passed as a scalar argument to a C
5680 function.
5681 @end cartouche
5682 Followed.
5683
5684 @sp 1
5685 @cartouche
5686 An Ada @code{in} parameter of an access-to-object type with designated
5687 type @var{T} is passed as a @code{@var{t}*} argument to a C function,
5688 where @var{t} is the C type corresponding to the Ada type @var{T}.
5689 @end cartouche
5690 Followed.
5691
5692 @sp 1
5693 @cartouche
5694 An Ada access @var{T} parameter, or an Ada @code{out} or @code{in out}
5695 parameter of an elementary type @var{T}, is passed as a @code{@var{t}*}
5696 argument to a C function, where @var{t} is the C type corresponding to
5697 the Ada type @var{T}.  In the case of an elementary @code{out} or
5698 @code{in out} parameter, a pointer to a temporary copy is used to
5699 preserve by-copy semantics.
5700 @end cartouche
5701 Followed.
5702
5703 @sp 1
5704 @cartouche
5705 An Ada parameter of a record type @var{T}, of any mode, is passed as a
5706 @code{@var{t}*} argument to a C function, where @var{t} is the C
5707 structure corresponding to the Ada type @var{T}.
5708 @end cartouche
5709 Followed.  This convention may be overridden by the use of the C_Pass_By_Copy
5710 pragma, or Convention, or by explicitly specifying the mechanism for a given
5711 call using an extended import or export pragma.
5712
5713 @sp 1
5714 @cartouche
5715 An Ada parameter of an array type with component type @var{T}, of any
5716 mode, is passed as a @code{@var{t}*} argument to a C function, where
5717 @var{t} is the C type corresponding to the Ada type @var{T}.
5718 @end cartouche
5719 Followed.
5720
5721 @sp 1
5722 @cartouche
5723 An Ada parameter of an access-to-subprogram type is passed as a pointer
5724 to a C function whose prototype corresponds to the designated
5725 subprogram's specification.
5726 @end cartouche
5727 Followed.
5728
5729 @cindex COBOL, interfacing with
5730 @unnumberedsec B.4(95-98): Interfacing with COBOL
5731 @sp 1
5732 @cartouche
5733 An Ada implementation should support the following interface
5734 correspondences between Ada and COBOL@.
5735 @end cartouche
5736 Followed.
5737
5738 @sp 1
5739 @cartouche
5740 An Ada access @var{T} parameter is passed as a @samp{BY REFERENCE} data item of
5741 the COBOL type corresponding to @var{T}.
5742 @end cartouche
5743 Followed.
5744
5745 @sp 1
5746 @cartouche
5747 An Ada in scalar parameter is passed as a @samp{BY CONTENT} data item of
5748 the corresponding COBOL type.
5749 @end cartouche
5750 Followed.
5751
5752 @sp 1
5753 @cartouche
5754 Any other Ada parameter is passed as a @samp{BY REFERENCE} data item of the
5755 COBOL type corresponding to the Ada parameter type; for scalars, a local
5756 copy is used if necessary to ensure by-copy semantics.
5757 @end cartouche
5758 Followed.
5759
5760 @cindex Fortran, interfacing with
5761 @unnumberedsec B.5(22-26): Interfacing with Fortran
5762 @sp 1
5763 @cartouche
5764 An Ada implementation should support the following interface
5765 correspondences between Ada and Fortran:
5766 @end cartouche
5767 Followed.
5768
5769 @sp 1
5770 @cartouche
5771 An Ada procedure corresponds to a Fortran subroutine.
5772 @end cartouche
5773 Followed.
5774
5775 @sp 1
5776 @cartouche
5777 An Ada function corresponds to a Fortran function.
5778 @end cartouche
5779 Followed.
5780
5781 @sp 1
5782 @cartouche
5783 An Ada parameter of an elementary, array, or record type @var{T} is
5784 passed as a @var{T} argument to a Fortran procedure, where @var{T} is
5785 the Fortran type corresponding to the Ada type @var{T}, and where the
5786 INTENT attribute of the corresponding dummy argument matches the Ada
5787 formal parameter mode; the Fortran implementation's parameter passing
5788 conventions are used.  For elementary types, a local copy is used if
5789 necessary to ensure by-copy semantics.
5790 @end cartouche
5791 Followed.
5792
5793 @sp 1
5794 @cartouche
5795 An Ada parameter of an access-to-subprogram type is passed as a
5796 reference to a Fortran procedure whose interface corresponds to the
5797 designated subprogram's specification.
5798 @end cartouche
5799 Followed.
5800
5801 @cindex Machine operations
5802 @unnumberedsec C.1(3-5): Access to Machine Operations
5803 @sp 1
5804 @cartouche
5805 The machine code or intrinsic support should allow access to all
5806 operations normally available to assembly language programmers for the
5807 target environment, including privileged instructions, if any.
5808 @end cartouche
5809 Followed.
5810
5811 @sp 1
5812 @cartouche
5813 The interfacing pragmas (see Annex B) should support interface to
5814 assembler; the default assembler should be associated with the
5815 convention identifier @code{Assembler}.
5816 @end cartouche
5817 Followed.
5818
5819 @sp 1
5820 @cartouche
5821 If an entity is exported to assembly language, then the implementation
5822 should allocate it at an addressable location, and should ensure that it
5823 is retained by the linking process, even if not otherwise referenced
5824 from the Ada code.  The implementation should assume that any call to a
5825 machine code or assembler subprogram is allowed to read or update every
5826 object that is specified as exported.
5827 @end cartouche
5828 Followed.
5829
5830 @unnumberedsec C.1(10-16): Access to Machine Operations
5831 @sp 1
5832 @cartouche
5833 The implementation should ensure that little or no overhead is
5834 associated with calling intrinsic and machine-code subprograms.
5835 @end cartouche
5836 Followed for both intrinsics and machine-code subprograms.
5837
5838 @sp 1
5839 @cartouche
5840 It is recommended that intrinsic subprograms be provided for convenient
5841 access to any machine operations that provide special capabilities or
5842 efficiency and that are not otherwise available through the language
5843 constructs.
5844 @end cartouche
5845 Followed.  A full set of machine operation intrinsic subprograms is provided.
5846
5847 @sp 1
5848 @cartouche
5849 Atomic read-modify-write operations---e.g.@:, test and set, compare and
5850 swap, decrement and test, enqueue/dequeue.
5851 @end cartouche
5852 Followed on any target supporting such operations.
5853
5854 @sp 1
5855 @cartouche
5856 Standard numeric functions---e.g.@:, sin, log.
5857 @end cartouche
5858 Followed on any target supporting such operations.
5859
5860 @sp 1
5861 @cartouche
5862 String manipulation operations---e.g.@:, translate and test.
5863 @end cartouche
5864 Followed on any target supporting such operations.
5865
5866 @sp 1
5867 @cartouche
5868 Vector operations---e.g.@:, compare vector against thresholds.
5869 @end cartouche
5870 Followed on any target supporting such operations.
5871
5872 @sp 1
5873 @cartouche
5874 Direct operations on I/O ports.
5875 @end cartouche
5876 Followed on any target supporting such operations.
5877
5878 @cindex Interrupt support
5879 @unnumberedsec C.3(28): Interrupt Support
5880 @sp 1
5881 @cartouche
5882 If the @code{Ceiling_Locking} policy is not in effect, the
5883 implementation should provide means for the application to specify which
5884 interrupts are to be blocked during protected actions, if the underlying
5885 system allows for a finer-grain control of interrupt blocking.
5886 @end cartouche
5887 Followed.  The underlying system does not allow for finer-grain control
5888 of interrupt blocking.
5889
5890 @cindex Protected procedure handlers
5891 @unnumberedsec C.3.1(20-21): Protected Procedure Handlers
5892 @sp 1
5893 @cartouche
5894 Whenever possible, the implementation should allow interrupt handlers to
5895 be called directly by the hardware.
5896 @end cartouche
5897 @c SGI info:
5898 @ignore
5899 This is never possible under IRIX, so this is followed by default.
5900 @end ignore
5901 Followed on any target where the underlying operating system permits
5902 such direct calls.
5903
5904 @sp 1
5905 @cartouche
5906 Whenever practical, violations of any
5907 implementation-defined restrictions should be detected before run time.
5908 @end cartouche
5909 Followed.  Compile time warnings are given when possible.
5910
5911 @cindex Package @code{Interrupts}
5912 @findex Interrupts
5913 @unnumberedsec C.3.2(25): Package @code{Interrupts}
5914
5915 @sp 1
5916 @cartouche
5917 If implementation-defined forms of interrupt handler procedures are
5918 supported, such as protected procedures with parameters, then for each
5919 such form of a handler, a type analogous to @code{Parameterless_Handler}
5920 should be specified in a child package of @code{Interrupts}, with the
5921 same operations as in the predefined package Interrupts.
5922 @end cartouche
5923 Followed.
5924
5925 @cindex Pre-elaboration requirements
5926 @unnumberedsec C.4(14): Pre-elaboration Requirements
5927 @sp 1
5928 @cartouche
5929 It is recommended that pre-elaborated packages be implemented in such a
5930 way that there should be little or no code executed at run time for the
5931 elaboration of entities not already covered by the Implementation
5932 Requirements.
5933 @end cartouche
5934 Followed.  Executable code is generated in some cases, e.g.@: loops
5935 to initialize large arrays.
5936
5937 @unnumberedsec C.5(8): Pragma @code{Discard_Names}
5938
5939 @sp 1
5940 @cartouche
5941 If the pragma applies to an entity, then the implementation should
5942 reduce the amount of storage used for storing names associated with that
5943 entity.
5944 @end cartouche
5945 Followed.
5946
5947 @cindex Package @code{Task_Attributes}
5948 @findex Task_Attributes
5949 @unnumberedsec C.7.2(30): The Package Task_Attributes
5950 @sp 1
5951 @cartouche
5952 Some implementations are targeted to domains in which memory use at run
5953 time must be completely deterministic.  For such implementations, it is
5954 recommended that the storage for task attributes will be pre-allocated
5955 statically and not from the heap.  This can be accomplished by either
5956 placing restrictions on the number and the size of the task's
5957 attributes, or by using the pre-allocated storage for the first @var{N}
5958 attribute objects, and the heap for the others.  In the latter case,
5959 @var{N} should be documented.
5960 @end cartouche
5961 Not followed.  This implementation is not targeted to such a domain.
5962
5963 @cindex Locking Policies
5964 @unnumberedsec D.3(17): Locking Policies
5965
5966 @sp 1
5967 @cartouche
5968 The implementation should use names that end with @samp{_Locking} for
5969 locking policies defined by the implementation.
5970 @end cartouche
5971 Followed.  A single implementation-defined locking policy is defined,
5972 whose name (@code{Inheritance_Locking}) follows this suggestion.
5973
5974 @cindex Entry queuing policies
5975 @unnumberedsec D.4(16): Entry Queuing Policies
5976 @sp 1
5977 @cartouche
5978 Names that end with @samp{_Queuing} should be used
5979 for all implementation-defined queuing policies.
5980 @end cartouche
5981 Followed.  No such implementation-defined queuing policies exist.
5982
5983 @cindex Preemptive abort
5984 @unnumberedsec D.6(9-10): Preemptive Abort
5985 @sp 1
5986 @cartouche
5987 Even though the @code{abort_statement} is included in the list of
5988 potentially blocking operations (see 9.5.1), it is recommended that this
5989 statement be implemented in a way that never requires the task executing
5990 the @code{abort_statement} to block.
5991 @end cartouche
5992 Followed.
5993
5994 @sp 1
5995 @cartouche
5996 On a multi-processor, the delay associated with aborting a task on
5997 another processor should be bounded; the implementation should use
5998 periodic polling, if necessary, to achieve this.
5999 @end cartouche
6000 Followed.
6001
6002 @cindex Tasking restrictions
6003 @unnumberedsec D.7(21): Tasking Restrictions
6004 @sp 1
6005 @cartouche
6006 When feasible, the implementation should take advantage of the specified
6007 restrictions to produce a more efficient implementation.
6008 @end cartouche
6009 GNAT currently takes advantage of these restrictions by providing an optimized
6010 run time when the Ravenscar profile and the GNAT restricted run time set
6011 of restrictions are specified.  See pragma @code{Profile (Ravenscar)} and
6012 pragma @code{Restricted_Run_Time} for more details.
6013
6014 @cindex Time, monotonic
6015 @unnumberedsec D.8(47-49): Monotonic Time
6016 @sp 1
6017 @cartouche
6018 When appropriate, implementations should provide configuration
6019 mechanisms to change the value of @code{Tick}.
6020 @end cartouche
6021 Such configuration mechanisms are not appropriate to this implementation
6022 and are thus not supported.
6023
6024 @sp 1
6025 @cartouche
6026 It is recommended that @code{Calendar.Clock} and @code{Real_Time.Clock}
6027 be implemented as transformations of the same time base.
6028 @end cartouche
6029 Followed.
6030
6031 @sp 1
6032 @cartouche
6033 It is recommended that the @dfn{best} time base which exists in
6034 the underlying system be available to the application through
6035 @code{Clock}.  @dfn{Best} may mean highest accuracy or largest range.
6036 @end cartouche
6037 Followed.
6038
6039 @cindex Partition communication subsystem
6040 @cindex PCS
6041 @unnumberedsec E.5(28-29): Partition Communication Subsystem
6042 @sp 1
6043 @cartouche
6044 Whenever possible, the PCS on the called partition should allow for
6045 multiple tasks to call the RPC-receiver with different messages and
6046 should allow them to block until the corresponding subprogram body
6047 returns.
6048 @end cartouche
6049 Followed by GLADE, a separately supplied PCS that can be used with
6050 GNAT.
6051
6052 @sp 1
6053 @cartouche
6054 The @code{Write} operation on a stream of type @code{Params_Stream_Type}
6055 should raise @code{Storage_Error} if it runs out of space trying to
6056 write the @code{Item} into the stream.
6057 @end cartouche
6058 Followed by GLADE, a separately supplied PCS that can be used with
6059 GNAT@.
6060
6061 @cindex COBOL support
6062 @unnumberedsec F(7): COBOL Support
6063 @sp 1
6064 @cartouche
6065 If COBOL (respectively, C) is widely supported in the target
6066 environment, implementations supporting the Information Systems Annex
6067 should provide the child package @code{Interfaces.COBOL} (respectively,
6068 @code{Interfaces.C}) specified in Annex B and should support a
6069 @code{convention_identifier} of COBOL (respectively, C) in the interfacing
6070 pragmas (see Annex B), thus allowing Ada programs to interface with
6071 programs written in that language.
6072 @end cartouche
6073 Followed.
6074
6075 @cindex Decimal radix support
6076 @unnumberedsec F.1(2): Decimal Radix Support
6077 @sp 1
6078 @cartouche
6079 Packed decimal should be used as the internal representation for objects
6080 of subtype @var{S} when @var{S}'Machine_Radix = 10.
6081 @end cartouche
6082 Not followed.  GNAT ignores @var{S}'Machine_Radix and always uses binary
6083 representations.
6084
6085 @cindex Numerics
6086 @unnumberedsec G: Numerics
6087 @sp 2
6088 @cartouche
6089 If Fortran (respectively, C) is widely supported in the target
6090 environment, implementations supporting the Numerics Annex
6091 should provide the child package @code{Interfaces.Fortran} (respectively,
6092 @code{Interfaces.C}) specified in Annex B and should support a
6093 @code{convention_identifier} of Fortran (respectively, C) in the interfacing
6094 pragmas (see Annex B), thus allowing Ada programs to interface with
6095 programs written in that language.
6096 @end cartouche
6097 Followed.
6098
6099 @cindex Complex types
6100 @unnumberedsec G.1.1(56-58): Complex Types
6101 @sp 2
6102 @cartouche
6103 Because the usual mathematical meaning of multiplication of a complex
6104 operand and a real operand is that of the scaling of both components of
6105 the former by the latter, an implementation should not perform this
6106 operation by first promoting the real operand to complex type and then
6107 performing a full complex multiplication.  In systems that, in the
6108 future, support an Ada binding to IEC 559:1989, the latter technique
6109 will not generate the required result when one of the components of the
6110 complex operand is infinite.  (Explicit multiplication of the infinite
6111 component by the zero component obtained during promotion yields a NaN
6112 that propagates into the final result.) Analogous advice applies in the
6113 case of multiplication of a complex operand and a pure-imaginary
6114 operand, and in the case of division of a complex operand by a real or
6115 pure-imaginary operand.
6116 @end cartouche
6117 Not followed.
6118
6119 @sp 1
6120 @cartouche
6121 Similarly, because the usual mathematical meaning of addition of a
6122 complex operand and a real operand is that the imaginary operand remains
6123 unchanged, an implementation should not perform this operation by first
6124 promoting the real operand to complex type and then performing a full
6125 complex addition.  In implementations in which the @code{Signed_Zeros}
6126 attribute of the component type is @code{True} (and which therefore
6127 conform to IEC 559:1989 in regard to the handling of the sign of zero in
6128 predefined arithmetic operations), the latter technique will not
6129 generate the required result when the imaginary component of the complex
6130 operand is a negatively signed zero.  (Explicit addition of the negative
6131 zero to the zero obtained during promotion yields a positive zero.)
6132 Analogous advice applies in the case of addition of a complex operand
6133 and a pure-imaginary operand, and in the case of subtraction of a
6134 complex operand and a real or pure-imaginary operand.
6135 @end cartouche
6136 Not followed.
6137
6138 @sp 1
6139 @cartouche
6140 Implementations in which @code{Real'Signed_Zeros} is @code{True} should
6141 attempt to provide a rational treatment of the signs of zero results and
6142 result components.  As one example, the result of the @code{Argument}
6143 function should have the sign of the imaginary component of the
6144 parameter @code{X} when the point represented by that parameter lies on
6145 the positive real axis; as another, the sign of the imaginary component
6146 of the @code{Compose_From_Polar} function should be the same as
6147 (respectively, the opposite of) that of the @code{Argument} parameter when that
6148 parameter has a value of zero and the @code{Modulus} parameter has a
6149 nonnegative (respectively, negative) value.
6150 @end cartouche
6151 Followed.
6152
6153 @cindex Complex elementary functions
6154 @unnumberedsec G.1.2(49): Complex Elementary Functions
6155 @sp 1
6156 @cartouche
6157 Implementations in which @code{Complex_Types.Real'Signed_Zeros} is
6158 @code{True} should attempt to provide a rational treatment of the signs
6159 of zero results and result components.  For example, many of the complex
6160 elementary functions have components that are odd functions of one of
6161 the parameter components; in these cases, the result component should
6162 have the sign of the parameter component at the origin.  Other complex
6163 elementary functions have zero components whose sign is opposite that of
6164 a parameter component at the origin, or is always positive or always
6165 negative.
6166 @end cartouche
6167 Followed.
6168
6169 @cindex Accuracy requirements
6170 @unnumberedsec G.2.4(19): Accuracy Requirements
6171 @sp 1
6172 @cartouche
6173 The versions of the forward trigonometric functions without a
6174 @code{Cycle} parameter should not be implemented by calling the
6175 corresponding version with a @code{Cycle} parameter of
6176 @code{2.0*Numerics.Pi}, since this will not provide the required
6177 accuracy in some portions of the domain.  For the same reason, the
6178 version of @code{Log} without a @code{Base} parameter should not be
6179 implemented by calling the corresponding version with a @code{Base}
6180 parameter of @code{Numerics.e}.
6181 @end cartouche
6182 Followed.
6183
6184 @cindex Complex arithmetic accuracy
6185 @cindex Accuracy, complex arithmetic
6186 @unnumberedsec G.2.6(15): Complex Arithmetic Accuracy
6187
6188 @sp 1
6189 @cartouche
6190 The version of the @code{Compose_From_Polar} function without a
6191 @code{Cycle} parameter should not be implemented by calling the
6192 corresponding version with a @code{Cycle} parameter of
6193 @code{2.0*Numerics.Pi}, since this will not provide the required
6194 accuracy in some portions of the domain.
6195 @end cartouche
6196 Followed.
6197
6198 @c -----------------------------------------
6199 @node Implementation Defined Characteristics
6200 @chapter Implementation Defined Characteristics
6201
6202 @noindent
6203 In addition to the implementation dependent pragmas and attributes, and
6204 the implementation advice, there are a number of other features of Ada
6205 95 that are potentially implementation dependent.  These are mentioned
6206 throughout the Ada 95 Reference Manual, and are summarized in annex M@.
6207
6208 A requirement for conforming Ada compilers is that they provide
6209 documentation describing how the implementation deals with each of these
6210 issues.  In this chapter, you will find each point in annex M listed
6211 followed by a description in italic font of how GNAT
6212 @c SGI info:
6213 @ignore
6214 in the ProDev Ada
6215 implementation on IRIX 5.3 operating system or greater
6216 @end ignore
6217 handles the implementation dependence.
6218
6219 You can use this chapter as a guide to minimizing implementation
6220 dependent features in your programs if portability to other compilers
6221 and other operating systems is an important consideration.  The numbers
6222 in each section below correspond to the paragraph number in the Ada 95
6223 Reference Manual.
6224
6225 @sp 1
6226 @cartouche
6227 @noindent
6228 @strong{2}.  Whether or not each recommendation given in Implementation
6229 Advice is followed.  See 1.1.2(37).
6230 @end cartouche
6231 @noindent
6232 @xref{Implementation Advice}.
6233
6234 @sp 1
6235 @cartouche
6236 @noindent
6237 @strong{3}.  Capacity limitations of the implementation.  See 1.1.3(3).
6238 @end cartouche
6239 @noindent
6240 The complexity of programs that can be processed is limited only by the
6241 total amount of available virtual memory, and disk space for the
6242 generated object files.
6243
6244 @sp 1
6245 @cartouche
6246 @noindent
6247 @strong{4}.  Variations from the standard that are impractical to avoid
6248 given the implementation's execution environment.  See 1.1.3(6).
6249 @end cartouche
6250 @noindent
6251 There are no variations from the standard.
6252
6253 @sp 1
6254 @cartouche
6255 @noindent
6256 @strong{5}.  Which @code{code_statement}s cause external
6257 interactions.  See 1.1.3(10).
6258 @end cartouche
6259 @noindent
6260 Any @code{code_statement} can potentially cause external interactions.
6261
6262 @sp 1
6263 @cartouche
6264 @noindent
6265 @strong{6}.  The coded representation for the text of an Ada
6266 program.  See 2.1(4).
6267 @end cartouche
6268 @noindent
6269 See separate section on source representation.
6270
6271 @sp 1
6272 @cartouche
6273 @noindent
6274 @strong{7}.  The control functions allowed in comments.  See 2.1(14).
6275 @end cartouche
6276 @noindent
6277 See separate section on source representation.
6278
6279 @sp 1
6280 @cartouche
6281 @noindent
6282 @strong{8}.  The representation for an end of line.  See 2.2(2).
6283 @end cartouche
6284 @noindent
6285 See separate section on source representation.
6286
6287 @sp 1
6288 @cartouche
6289 @noindent
6290 @strong{9}.  Maximum supported line length and lexical element
6291 length.  See 2.2(15).
6292 @end cartouche
6293 @noindent
6294 The maximum line length is 255 characters an the maximum length of a
6295 lexical element is also 255 characters.
6296
6297 @sp 1
6298 @cartouche
6299 @noindent
6300 @strong{10}.  Implementation defined pragmas.  See 2.8(14).
6301 @end cartouche
6302 @noindent
6303
6304 @xref{Implementation Defined Pragmas}.
6305
6306 @sp 1
6307 @cartouche
6308 @noindent
6309 @strong{11}.  Effect of pragma @code{Optimize}.  See 2.8(27).
6310 @end cartouche
6311 @noindent
6312 Pragma @code{Optimize}, if given with a @code{Time} or @code{Space}
6313 parameter, checks that the optimization flag is set, and aborts if it is
6314 not.
6315
6316 @sp 1
6317 @cartouche
6318 @noindent
6319 @strong{12}.  The sequence of characters of the value returned by
6320 @code{@var{S}'Image} when some of the graphic characters of
6321 @code{@var{S}'Wide_Image} are not defined in @code{Character}.  See
6322 3.5(37).
6323 @end cartouche
6324 @noindent
6325 The sequence of characters is as defined by the wide character encoding
6326 method used for the source.  See section on source representation for
6327 further details.
6328
6329 @sp 1
6330 @cartouche
6331 @noindent
6332 @strong{13}.  The predefined integer types declared in
6333 @code{Standard}.  See 3.5.4(25).
6334 @end cartouche
6335 @noindent
6336 @table @code
6337 @item Short_Short_Integer
6338 8 bit signed
6339 @item Short_Integer
6340 (Short) 16 bit signed
6341 @item Integer
6342 32 bit signed
6343 @item Long_Integer
6344 64 bit signed (Alpha OpenVMS only)
6345 32 bit signed (all other targets)
6346 @item Long_Long_Integer
6347 64 bit signed
6348 @end table
6349
6350 @sp 1
6351 @cartouche
6352 @noindent
6353 @strong{14}.  Any nonstandard integer types and the operators defined
6354 for them.  See 3.5.4(26).
6355 @end cartouche
6356 @noindent
6357 There are no nonstandard integer types.
6358
6359 @sp 1
6360 @cartouche
6361 @noindent
6362 @strong{15}.  Any nonstandard real types and the operators defined for
6363 them.  See 3.5.6(8).
6364 @end cartouche
6365 @noindent
6366 There are no nonstandard real types.
6367
6368 @sp 1
6369 @cartouche
6370 @noindent
6371 @strong{16}.  What combinations of requested decimal precision and range
6372 are supported for floating point types.  See 3.5.7(7).
6373 @end cartouche
6374 @noindent
6375 The precision and range is as defined by the IEEE standard.
6376
6377 @sp 1
6378 @cartouche
6379 @noindent
6380 @strong{17}.  The predefined floating point types declared in
6381 @code{Standard}.  See 3.5.7(16).
6382 @end cartouche
6383 @noindent
6384 @table @code
6385 @item Short_Float
6386 32 bit IEEE short
6387 @item Float
6388 (Short) 32 bit IEEE short
6389 @item Long_Float
6390 64 bit IEEE long
6391 @item Long_Long_Float
6392 64 bit IEEE long (80 bit IEEE long on x86 processors)
6393 @end table
6394
6395 @sp 1
6396 @cartouche
6397 @noindent
6398 @strong{18}.  The small of an ordinary fixed point type.  See 3.5.9(8).
6399 @end cartouche
6400 @noindent
6401 @code{Fine_Delta} is 2**(@minus{}63)
6402
6403 @sp 1
6404 @cartouche
6405 @noindent
6406 @strong{19}.  What combinations of small, range, and digits are
6407 supported for fixed point types.  See 3.5.9(10).
6408 @end cartouche
6409 @noindent
6410 Any combinations are permitted that do not result in a small less than
6411 @code{Fine_Delta} and do not result in a mantissa larger than 63 bits.
6412 If the mantissa is larger than 53 bits on machines where Long_Long_Float
6413 is 64 bits (true of all architectures except ia32), then the output from
6414 Text_IO is accurate to only 53 bits, rather than the full mantissa.  This
6415 is because floating-point conversions are used to convert fixed point.
6416
6417 @sp 1
6418 @cartouche
6419 @noindent
6420 @strong{20}.  The result of @code{Tags.Expanded_Name} for types declared
6421 within an unnamed @code{block_statement}.  See 3.9(10).
6422 @end cartouche
6423 @noindent
6424 Block numbers of the form @code{B@var{nnn}}, where @var{nnn} is a
6425 decimal integer are allocated.
6426
6427 @sp 1
6428 @cartouche
6429 @noindent
6430 @strong{21}.  Implementation-defined attributes.  See 4.1.4(12).
6431 @end cartouche
6432 @noindent
6433 @xref{Implementation Defined Attributes}.
6434
6435 @sp 1
6436 @cartouche
6437 @noindent
6438 @strong{22}.  Any implementation-defined time types.  See 9.6(6).
6439 @end cartouche
6440 @noindent
6441 There are no implementation-defined time types.
6442
6443 @sp 1
6444 @cartouche
6445 @noindent
6446 @strong{23}.  The time base associated with relative delays.
6447 @end cartouche
6448 @noindent
6449 See 9.6(20).  The time base used is that provided by the C library
6450 function @code{gettimeofday}.
6451
6452 @sp 1
6453 @cartouche
6454 @noindent
6455 @strong{24}.  The time base of the type @code{Calendar.Time}.  See
6456 9.6(23).
6457 @end cartouche
6458 @noindent
6459 The time base used is that provided by the C library function
6460 @code{gettimeofday}.
6461
6462 @sp 1
6463 @cartouche
6464 @noindent
6465 @strong{25}.  The time zone used for package @code{Calendar}
6466 operations.  See 9.6(24).
6467 @end cartouche
6468 @noindent
6469 The time zone used by package @code{Calendar} is the current system time zone
6470 setting for local time, as accessed by the C library function
6471 @code{localtime}.
6472
6473 @sp 1
6474 @cartouche
6475 @noindent
6476 @strong{26}.  Any limit on @code{delay_until_statements} of
6477 @code{select_statements}.  See 9.6(29).
6478 @end cartouche
6479 @noindent
6480 There are no such limits.
6481
6482 @sp 1
6483 @cartouche
6484 @noindent
6485 @strong{27}.  Whether or not two non overlapping parts of a composite
6486 object are independently addressable, in the case where packing, record
6487 layout, or @code{Component_Size} is specified for the object.  See
6488 9.10(1).
6489 @end cartouche
6490 @noindent
6491 Separate components are independently addressable if they do not share
6492 overlapping storage units.
6493
6494 @sp 1
6495 @cartouche
6496 @noindent
6497 @strong{28}.  The representation for a compilation.  See 10.1(2).
6498 @end cartouche
6499 @noindent
6500 A compilation is represented by a sequence of files presented to the
6501 compiler in a single invocation of the @code{gcc} command.
6502
6503 @sp 1
6504 @cartouche
6505 @noindent
6506 @strong{29}.  Any restrictions on compilations that contain multiple
6507 compilation_units.  See 10.1(4).
6508 @end cartouche
6509 @noindent
6510 No single file can contain more than one compilation unit, but any
6511 sequence of files can be presented to the compiler as a single
6512 compilation.
6513
6514 @sp 1
6515 @cartouche
6516 @noindent
6517 @strong{30}.  The mechanisms for creating an environment and for adding
6518 and replacing compilation units.  See 10.1.4(3).
6519 @end cartouche
6520 @noindent
6521 See separate section on compilation model.
6522
6523 @sp 1
6524 @cartouche
6525 @noindent
6526 @strong{31}.  The manner of explicitly assigning library units to a
6527 partition.  See 10.2(2).
6528 @end cartouche
6529 @noindent
6530 If a unit contains an Ada main program, then the Ada units for the partition
6531 are determined by recursive application of the rules in the Ada Reference
6532 Manual section 10.2(2-6).  In other words, the Ada units will be those that
6533 are needed by the main program, and then this definition of need is applied
6534 recursively to those units, and the partition contains the transitive
6535 closure determined by this relationship.  In short, all the necessary units
6536 are included, with no need to explicitly specify the list.  If additional
6537 units are required, e.g.@: by foreign language units, then all units must be
6538 mentioned in the context clause of one of the needed Ada units.
6539
6540 If the partition contains no main program, or if the main program is in
6541 a language other than Ada, then GNAT
6542 provides the binder options @code{-z} and @code{-n} respectively, and in
6543 this case a list of units can be explicitly supplied to the binder for
6544 inclusion in the partition (all units needed by these units will also
6545 be included automatically).  For full details on the use of these
6546 options, refer to the @cite{GNAT User's Guide} sections on Binding
6547 and Linking.
6548
6549 @sp 1
6550 @cartouche
6551 @noindent
6552 @strong{32}.  The implementation-defined means, if any, of specifying
6553 which compilation units are needed by a given compilation unit.  See
6554 10.2(2).
6555 @end cartouche
6556 @noindent
6557 The units needed by a given compilation unit are as defined in
6558 the Ada Reference Manual section 10.2(2-6).  There are no
6559 implementation-defined pragmas or other implementation-defined
6560 means for specifying needed units.
6561
6562 @sp 1
6563 @cartouche
6564 @noindent
6565 @strong{33}.  The manner of designating the main subprogram of a
6566 partition.  See 10.2(7).
6567 @end cartouche
6568 @noindent
6569 The main program is designated by providing the name of the
6570 corresponding @file{ALI} file as the input parameter to the binder.
6571
6572 @sp 1
6573 @cartouche
6574 @noindent
6575 @strong{34}.  The order of elaboration of @code{library_items}.  See
6576 10.2(18).
6577 @end cartouche
6578 @noindent
6579 The first constraint on ordering is that it meets the requirements of
6580 chapter 10 of the Ada 95 Reference Manual.  This still leaves some
6581 implementation dependent choices, which are resolved by first
6582 elaborating bodies as early as possible (i.e.@: in preference to specs
6583 where there is a choice), and second by evaluating the immediate with
6584 clauses of a unit to determine the probably best choice, and
6585 third by elaborating in alphabetical order of unit names
6586 where a choice still remains.
6587
6588 @sp 1
6589 @cartouche
6590 @noindent
6591 @strong{35}.  Parameter passing and function return for the main
6592 subprogram.  See 10.2(21).
6593 @end cartouche
6594 @noindent
6595 The main program has no parameters.  It may be a procedure, or a function
6596 returning an integer type.  In the latter case, the returned integer
6597 value is the return code of the program (overriding any value that
6598 may have been set by a call to @code{Ada.Command_Line.Set_Exit_Status}).
6599
6600 @sp 1
6601 @cartouche
6602 @noindent
6603 @strong{36}.  The mechanisms for building and running partitions.  See
6604 10.2(24).
6605 @end cartouche
6606 @noindent
6607 GNAT itself supports programs with only a single partition.  The GNATDIST
6608 tool provided with the GLADE package (which also includes an implementation
6609 of the PCS) provides a completely flexible method for building and running
6610 programs consisting of multiple partitions.  See the separate GLADE manual
6611 for details.
6612
6613 @sp 1
6614 @cartouche
6615 @noindent
6616 @strong{37}.  The details of program execution, including program
6617 termination.  See 10.2(25).
6618 @end cartouche
6619 @noindent
6620 See separate section on compilation model.
6621
6622 @sp 1
6623 @cartouche
6624 @noindent
6625 @strong{38}.  The semantics of any non-active partitions supported by the
6626 implementation.  See 10.2(28).
6627 @end cartouche
6628 @noindent
6629 Passive partitions are supported on targets where shared memory is
6630 provided by the operating system.  See the GLADE reference manual for
6631 further details.
6632
6633 @sp 1
6634 @cartouche
6635 @noindent
6636 @strong{39}.  The information returned by @code{Exception_Message}.  See
6637 11.4.1(10).
6638 @end cartouche
6639 @noindent
6640 Exception message returns the null string unless a specific message has
6641 been passed by the program.
6642
6643 @sp 1
6644 @cartouche
6645 @noindent
6646 @strong{40}.  The result of @code{Exceptions.Exception_Name} for types
6647 declared within an unnamed @code{block_statement}.  See 11.4.1(12).
6648 @end cartouche
6649 @noindent
6650 Blocks have implementation defined names of the form @code{B@var{nnn}}
6651 where @var{nnn} is an integer.
6652
6653 @sp 1
6654 @cartouche
6655 @noindent
6656 @strong{41}.  The information returned by
6657 @code{Exception_Information}.  See 11.4.1(13).
6658 @end cartouche
6659 @noindent
6660 @code{Exception_Information} returns a string in the following format:
6661
6662 @smallexample
6663 @emph{Exception_Name:} nnnnn
6664 @emph{Message:} mmmmm
6665 @emph{PID:} ppp
6666 @emph{Call stack traceback locations:}
6667 0xhhhh 0xhhhh 0xhhhh ... 0xhhh
6668 @end smallexample
6669
6670 @noindent
6671 where
6672
6673 @itemize @bullet
6674 @item
6675 @code{nnnn} is the fully qualified name of the exception in all upper
6676 case letters. This line is always present.
6677
6678 @item
6679 @code{mmmm} is the message (this line present only if message is non-null)
6680
6681 @item
6682 @code{ppp} is the Process Id value as a decimal integer (this line is
6683 present only if the Process Id is non-zero). Currently we are
6684 not making use of this field.
6685
6686 @item
6687 The Call stack traceback locations line and the following values
6688 are present only if at least one traceback location was recorded.
6689 The values are given in C style format, with lower case letters
6690 for a-f, and only as many digits present as are necessary.
6691 @end itemize
6692
6693 @noindent
6694 The line terminator sequence at the end of each line, including
6695 the last line is a single @code{LF} character (@code{16#0A#}).
6696
6697 @sp 1
6698 @cartouche
6699 @noindent
6700 @strong{42}.  Implementation-defined check names.  See 11.5(27).
6701 @end cartouche
6702 @noindent
6703 No implementation-defined check names are supported.
6704
6705 @sp 1
6706 @cartouche
6707 @noindent
6708 @strong{43}.  The interpretation of each aspect of representation.  See
6709 13.1(20).
6710 @end cartouche
6711 @noindent
6712 See separate section on data representations.
6713
6714 @sp 1
6715 @cartouche
6716 @noindent
6717 @strong{44}.  Any restrictions placed upon representation items.  See
6718 13.1(20).
6719 @end cartouche
6720 @noindent
6721 See separate section on data representations.
6722
6723 @sp 1
6724 @cartouche
6725 @noindent
6726 @strong{45}.  The meaning of @code{Size} for indefinite subtypes.  See
6727 13.3(48).
6728 @end cartouche
6729 @noindent
6730 Size for an indefinite subtype is the maximum possible size, except that
6731 for the case of a subprogram parameter, the size of the parameter object
6732 is the actual size.
6733
6734 @sp 1
6735 @cartouche
6736 @noindent
6737 @strong{46}.  The default external representation for a type tag.  See
6738 13.3(75).
6739 @end cartouche
6740 @noindent
6741 The default external representation for a type tag is the fully expanded
6742 name of the type in upper case letters.
6743
6744 @sp 1
6745 @cartouche
6746 @noindent
6747 @strong{47}.  What determines whether a compilation unit is the same in
6748 two different partitions.  See 13.3(76).
6749 @end cartouche
6750 @noindent
6751 A compilation unit is the same in two different partitions if and only
6752 if it derives from the same source file.
6753
6754 @sp 1
6755 @cartouche
6756 @noindent
6757 @strong{48}.  Implementation-defined components.  See 13.5.1(15).
6758 @end cartouche
6759 @noindent
6760 The only implementation defined component is the tag for a tagged type,
6761 which contains a pointer to the dispatching table.
6762
6763 @sp 1
6764 @cartouche
6765 @noindent
6766 @strong{49}.  If @code{Word_Size} = @code{Storage_Unit}, the default bit
6767 ordering.  See 13.5.3(5).
6768 @end cartouche
6769 @noindent
6770 @code{Word_Size} (32) is not the same as @code{Storage_Unit} (8) for this
6771 implementation, so no non-default bit ordering is supported.  The default
6772 bit ordering corresponds to the natural endianness of the target architecture.
6773
6774 @sp 1
6775 @cartouche
6776 @noindent
6777 @strong{50}.  The contents of the visible part of package @code{System}
6778 and its language-defined children.  See 13.7(2).
6779 @end cartouche
6780 @noindent
6781 See the definition of these packages in files @file{system.ads} and
6782 @file{s-stoele.ads}.
6783
6784 @sp 1
6785 @cartouche
6786 @noindent
6787 @strong{51}.  The contents of the visible part of package
6788 @code{System.Machine_Code}, and the meaning of
6789 @code{code_statements}.  See 13.8(7).
6790 @end cartouche
6791 @noindent
6792 See the definition and documentation in file @file{s-maccod.ads}.
6793
6794 @sp 1
6795 @cartouche
6796 @noindent
6797 @strong{52}.  The effect of unchecked conversion.  See 13.9(11).
6798 @end cartouche
6799 @noindent
6800 Unchecked conversion between types of the same size
6801 and results in an uninterpreted transmission of the bits from one type
6802 to the other.  If the types are of unequal sizes, then in the case of
6803 discrete types, a shorter source is first zero or sign extended as
6804 necessary, and a shorter target is simply truncated on the left.
6805 For all non-discrete types, the source is first copied if necessary
6806 to ensure that the alignment requirements of the target are met, then
6807 a pointer is constructed to the source value, and the result is obtained
6808 by dereferencing this pointer after converting it to be a pointer to the
6809 target type.
6810
6811 @sp 1
6812 @cartouche
6813 @noindent
6814 @strong{53}.  The manner of choosing a storage pool for an access type
6815 when @code{Storage_Pool} is not specified for the type.  See 13.11(17).
6816 @end cartouche
6817 @noindent
6818 There are 3 different standard pools used by the compiler when
6819 @code{Storage_Pool} is not specified depending whether the type is local
6820 to a subprogram or defined at the library level and whether
6821 @code{Storage_Size}is specified or not.  See documentation in the runtime
6822 library units @code{System.Pool_Global}, @code{System.Pool_Size} and
6823 @code{System.Pool_Local} in files @file{s-poosiz.ads},
6824 @file{s-pooglo.ads} and @file{s-pooloc.ads} for full details on the
6825 default pools used.
6826
6827 @sp 1
6828 @cartouche
6829 @noindent
6830 @strong{54}.  Whether or not the implementation provides user-accessible
6831 names for the standard pool type(s).  See 13.11(17).
6832 @end cartouche
6833 @noindent
6834
6835 See documentation in the sources of the run time mentioned in paragraph
6836 @strong{53} .  All these pools are accessible by means of @code{with}'ing
6837 these units.
6838
6839 @sp 1
6840 @cartouche
6841 @noindent
6842 @strong{55}.  The meaning of @code{Storage_Size}.  See 13.11(18).
6843 @end cartouche
6844 @noindent
6845 @code{Storage_Size} is measured in storage units, and refers to the
6846 total space available for an access type collection, or to the primary
6847 stack space for a task.
6848
6849 @sp 1
6850 @cartouche
6851 @noindent
6852 @strong{56}.  Implementation-defined aspects of storage pools.  See
6853 13.11(22).
6854 @end cartouche
6855 @noindent
6856 See documentation in the sources of the run time mentioned in paragraph
6857 @strong{53} for details on GNAT-defined aspects of storage pools.
6858
6859 @sp 1
6860 @cartouche
6861 @noindent
6862 @strong{57}.  The set of restrictions allowed in a pragma
6863 @code{Restrictions}.  See 13.12(7).
6864 @end cartouche
6865 @noindent
6866 All RM defined Restriction identifiers are implemented.  The following
6867 additional restriction identifiers are provided.  There are two separate
6868 lists of implementation dependent restriction identifiers.  The first
6869 set requires consistency throughout a partition (in other words, if the
6870 restriction identifier is used for any compilation unit in the partition,
6871 then all compilation units in the partition must obey the restriction.
6872
6873 @table @code
6874
6875 @item Simple_Barriers
6876 @findex Simple_Barriers
6877 This restriction ensures at compile time that barriers in entry declarations
6878 for protected types are restricted to either static boolean expressions or
6879 references to simple boolean variables defined in the private part of the
6880 protected type.  No other form of entry barriers is permitted.  This is one
6881 of the restrictions of the Ravenscar profile for limited tasking (see also
6882 pragma @code{Profile (Ravenscar)}).
6883
6884 @item Max_Entry_Queue_Length => Expr
6885 @findex Max_Entry_Queue_Length
6886 This restriction is a declaration that any protected entry compiled in
6887 the scope of the restriction has at most the specified number of
6888 tasks waiting on the entry
6889 at any one time, and so no queue is required.  This restriction is not
6890 checked at compile time.  A program execution is erroneous if an attempt
6891 is made to queue more than the specified number of tasks on such an entry.
6892
6893 @item No_Calendar
6894 @findex No_Calendar
6895 This restriction ensures at compile time that there is no implicit or
6896 explicit dependence on the package @code{Ada.Calendar}.
6897
6898 @item No_Direct_Boolean_Operators
6899 @findex No_Direct_Boolean_Operators
6900 This restriction ensures that no logical (and/or/xor) or comparison
6901 operators are used on operands of type Boolean (or any type derived
6902 from Boolean). This is intended for use in safety critical programs
6903 where the certification protocol requires the use of short-circuit
6904 (and then, or else) forms for all composite boolean operations.
6905
6906 @item No_Dynamic_Attachment
6907 @findex No_Dynamic_Attachment
6908 This restriction ensures that there is no call to any of the operations
6909 defined in package Ada.Interrupts.
6910
6911 @item No_Enumeration_Maps
6912 @findex No_Enumeration_Maps
6913 This restriction ensures at compile time that no operations requiring
6914 enumeration maps are used (that is Image and Value attributes applied
6915 to enumeration types).
6916
6917 @item No_Entry_Calls_In_Elaboration_Code
6918 @findex No_Entry_Calls_In_Elaboration_Code
6919 This restriction ensures at compile time that no task or protected entry
6920 calls are made during elaboration code.  As a result of the use of this
6921 restriction, the compiler can assume that no code past an accept statement
6922 in a task can be executed at elaboration time.
6923
6924 @item No_Exception_Handlers
6925 @findex No_Exception_Handlers
6926 This restriction ensures at compile time that there are no explicit
6927 exception handlers. It also indicates that no exception propagation will
6928 be provided. In this mode, exceptions may be raised but will result in
6929 an immediate call to the last chance handler, a routine that the user
6930 must define with the following profile:
6931
6932    procedure Last_Chance_Handler
6933      (Source_Location : System.Address; Line : Integer);
6934    pragma Export (C, Last_Chance_Handler,
6935                   "__gnat_last_chance_handler");
6936
6937    The parameter is a C null-terminated string representing a message to be
6938    associated with the exception (typically the source location of the raise
6939    statement generated by the compiler). The Line parameter when non-zero
6940    represents the line number in the source program where the raise occurs.
6941
6942 @item No_Exception_Streams
6943 @findex No_Exception_Streams
6944 This restriction ensures at compile time that no stream operations for
6945 types Exception_Id or Exception_Occurrence are used. This also makes it
6946 impossible to pass exceptions to or from a partition with this restriction
6947 in a distributed environment. If this exception is active, then the generated
6948 code is simplified by omitting the otherwise-required global registration
6949 of exceptions when they are declared.
6950
6951 @item No_Implicit_Conditionals
6952 @findex No_Implicit_Conditionals
6953 This restriction ensures that the generated code does not contain any
6954 implicit conditionals, either by modifying the generated code where possible,
6955 or by rejecting any construct that would otherwise generate an implicit
6956 conditional.
6957
6958 @item No_Implicit_Dynamic_Code
6959 @findex No_Implicit_Dynamic_Code
6960 This restriction prevents the compiler from building ``trampolines''.
6961 This is a structure that is built on the stack and contains dynamic
6962 code to be executed at run time. A trampoline is needed to indirectly
6963 address a nested subprogram (that is a subprogram that is not at the
6964 library level). The restriction prevents the use of any of the
6965 attributes @code{Address}, @code{Access} or @code{Unrestricted_Access}
6966 being applied to a subprogram that is not at the library level.
6967
6968 @item No_Implicit_Loops
6969 @findex No_Implicit_Loops
6970 This restriction ensures that the generated code does not contain any
6971 implicit @code{for} loops, either by modifying
6972 the generated code where possible,
6973 or by rejecting any construct that would otherwise generate an implicit
6974 @code{for} loop.
6975
6976 @item No_Initialize_Scalars
6977 @findex No_Initialize_Scalars
6978 This restriction ensures that no unit in the partition is compiled with
6979 pragma Initialize_Scalars. This allows the generation of more efficient
6980 code, and in particular eliminates dummy null initialization routines that
6981 are otherwise generated for some record and array types.
6982
6983 @item No_Local_Protected_Objects
6984 @findex No_Local_Protected_Objects
6985 This restriction ensures at compile time that protected objects are
6986 only declared at the library level.
6987
6988 @item No_Protected_Type_Allocators
6989 @findex No_Protected_Type_Allocators
6990 This restriction ensures at compile time that there are no allocator
6991 expressions that attempt to allocate protected objects.
6992
6993 @item No_Secondary_Stack
6994 @findex No_Secondary_Stack
6995 This restriction ensures at compile time that the generated code does not
6996 contain any reference to the secondary stack.  The secondary stack is used
6997 to implement functions returning unconstrained objects (arrays or records)
6998 on some targets.
6999
7000 @item No_Select_Statements
7001 @findex No_Select_Statements
7002 This restriction ensures at compile time no select statements of any kind
7003 are permitted, that is the keyword @code{select} may not appear.
7004 This is one of the restrictions of the Ravenscar
7005 profile for limited tasking (see also pragma @code{Profile (Ravenscar)}).
7006
7007 @item No_Standard_Storage_Pools
7008 @findex No_Standard_Storage_Pools
7009 This restriction ensures at compile time that no access types
7010 use the standard default storage pool.  Any access type declared must
7011 have an explicit Storage_Pool attribute defined specifying a
7012 user-defined storage pool.
7013
7014 @item No_Streams
7015 @findex No_Streams
7016 This restriction ensures at compile time that there are no implicit or
7017 explicit dependencies on the package @code{Ada.Streams}.
7018
7019 @item No_Task_Attributes_Package
7020 @findex No_Task_Attributes_Package
7021 This restriction ensures at compile time that there are no implicit or
7022 explicit dependencies on the package @code{Ada.Task_Attributes}.
7023
7024 @item No_Task_Termination
7025 @findex No_Task_Termination
7026 This restriction ensures at compile time that no terminate alternatives
7027 appear in any task body.
7028
7029 @item No_Tasking
7030 @findex No_Tasking
7031 This restriction prevents the declaration of tasks or task types throughout
7032 the partition.  It is similar in effect to the use of @code{Max_Tasks => 0}
7033 except that violations are caught at compile time and cause an error message
7034 to be output either by the compiler or binder.
7035
7036 @item No_Wide_Characters
7037 @findex No_Wide_Characters
7038 This restriction ensures at compile time that no uses of the types
7039 @code{Wide_Character} or @code{Wide_String}
7040 appear, and that no wide character literals
7041 appear in the program (that is literals representing characters not in
7042 type @code{Character}.
7043
7044 @item Static_Priorities
7045 @findex Static_Priorities
7046 This restriction ensures at compile time that all priority expressions
7047 are static, and that there are no dependencies on the package
7048 @code{Ada.Dynamic_Priorities}.
7049
7050 @item Static_Storage_Size
7051 @findex Static_Storage_Size
7052 This restriction ensures at compile time that any expression appearing
7053 in a Storage_Size pragma or attribute definition clause is static.
7054
7055 @end table
7056
7057 @noindent
7058 The second set of implementation dependent restriction identifiers
7059 does not require partition-wide consistency.
7060 The restriction may be enforced for a single
7061 compilation unit without any effect on any of the
7062 other compilation units in the partition.
7063
7064 @table @code
7065
7066 @item No_Elaboration_Code
7067 @findex No_Elaboration_Code
7068 This restriction ensures at compile time that no elaboration code is
7069 generated.  Note that this is not the same condition as is enforced
7070 by pragma @code{Preelaborate}.  There are cases in which pragma
7071 @code{Preelaborate} still permits code to be generated (e.g.@: code
7072 to initialize a large array to all zeroes), and there are cases of units
7073 which do not meet the requirements for pragma @code{Preelaborate},
7074 but for which no elaboration code is generated.  Generally, it is
7075 the case that preelaborable units will meet the restrictions, with
7076 the exception of large aggregates initialized with an others_clause,
7077 and exception declarations (which generate calls to a run-time
7078 registry procedure).  Note that this restriction is enforced on
7079 a unit by unit basis, it need not be obeyed consistently
7080 throughout a partition.
7081
7082 @item No_Entry_Queue
7083 @findex No_Entry_Queue
7084 This restriction is a declaration that any protected entry compiled in
7085 the scope of the restriction has at most one task waiting on the entry
7086 at any one time, and so no queue is required.  This restriction is not
7087 checked at compile time.  A program execution is erroneous if an attempt
7088 is made to queue a second task on such an entry.
7089
7090 @item No_Implementation_Attributes
7091 @findex No_Implementation_Attributes
7092 This restriction checks at compile time that no GNAT-defined attributes
7093 are present.  With this restriction, the only attributes that can be used
7094 are those defined in the Ada 95 Reference Manual.
7095
7096 @item No_Implementation_Pragmas
7097 @findex No_Implementation_Pragmas
7098 This restriction checks at compile time that no GNAT-defined pragmas
7099 are present.  With this restriction, the only pragmas that can be used
7100 are those defined in the Ada 95 Reference Manual.
7101
7102 @item No_Implementation_Restrictions
7103 @findex No_Implementation_Restrictions
7104 This restriction checks at compile time that no GNAT-defined restriction
7105 identifiers (other than @code{No_Implementation_Restrictions} itself)
7106 are present.  With this restriction, the only other restriction identifiers
7107 that can be used are those defined in the Ada 95 Reference Manual.
7108
7109 @end table
7110
7111 @sp 1
7112 @cartouche
7113 @noindent
7114 @strong{58}.  The consequences of violating limitations on
7115 @code{Restrictions} pragmas.  See 13.12(9).
7116 @end cartouche
7117 @noindent
7118 Restrictions that can be checked at compile time result in illegalities
7119 if violated.  Currently there are no other consequences of violating
7120 restrictions.
7121
7122 @sp 1
7123 @cartouche
7124 @noindent
7125 @strong{59}.  The representation used by the @code{Read} and
7126 @code{Write} attributes of elementary types in terms of stream
7127 elements.  See 13.13.2(9).
7128 @end cartouche
7129 @noindent
7130 The representation is the in-memory representation of the base type of
7131 the type, using the number of bits corresponding to the
7132 @code{@var{type}'Size} value, and the natural ordering of the machine.
7133
7134 @sp 1
7135 @cartouche
7136 @noindent
7137 @strong{60}.  The names and characteristics of the numeric subtypes
7138 declared in the visible part of package @code{Standard}.  See A.1(3).
7139 @end cartouche
7140 @noindent
7141 See items describing the integer and floating-point types supported.
7142
7143 @sp 1
7144 @cartouche
7145 @noindent
7146 @strong{61}.  The accuracy actually achieved by the elementary
7147 functions.  See A.5.1(1).
7148 @end cartouche
7149 @noindent
7150 The elementary functions correspond to the functions available in the C
7151 library.  Only fast math mode is implemented.
7152
7153 @sp 1
7154 @cartouche
7155 @noindent
7156 @strong{62}.  The sign of a zero result from some of the operators or
7157 functions in @code{Numerics.Generic_Elementary_Functions}, when
7158 @code{Float_Type'Signed_Zeros} is @code{True}.  See A.5.1(46).
7159 @end cartouche
7160 @noindent
7161 The sign of zeroes follows the requirements of the IEEE 754 standard on
7162 floating-point.
7163
7164 @sp 1
7165 @cartouche
7166 @noindent
7167 @strong{63}.  The value of
7168 @code{Numerics.Float_Random.Max_Image_Width}.  See A.5.2(27).
7169 @end cartouche
7170 @noindent
7171 Maximum image width is 649, see library file @file{a-numran.ads}.
7172
7173 @sp 1
7174 @cartouche
7175 @noindent
7176 @strong{64}.  The value of
7177 @code{Numerics.Discrete_Random.Max_Image_Width}.  See A.5.2(27).
7178 @end cartouche
7179 @noindent
7180 Maximum image width is 80, see library file @file{a-nudira.ads}.
7181
7182 @sp 1
7183 @cartouche
7184 @noindent
7185 @strong{65}.  The algorithms for random number generation.  See
7186 A.5.2(32).
7187 @end cartouche
7188 @noindent
7189 The algorithm is documented in the source files @file{a-numran.ads} and
7190 @file{a-numran.adb}.
7191
7192 @sp 1
7193 @cartouche
7194 @noindent
7195 @strong{66}.  The string representation of a random number generator's
7196 state.  See A.5.2(38).
7197 @end cartouche
7198 @noindent
7199 See the documentation contained in the file @file{a-numran.adb}.
7200
7201 @sp 1
7202 @cartouche
7203 @noindent
7204 @strong{67}.  The minimum time interval between calls to the
7205 time-dependent Reset procedure that are guaranteed to initiate different
7206 random number sequences.  See A.5.2(45).
7207 @end cartouche
7208 @noindent
7209 The minimum period between reset calls to guarantee distinct series of
7210 random numbers is one microsecond.
7211
7212 @sp 1
7213 @cartouche
7214 @noindent
7215 @strong{68}.  The values of the @code{Model_Mantissa},
7216 @code{Model_Emin}, @code{Model_Epsilon}, @code{Model},
7217 @code{Safe_First}, and @code{Safe_Last} attributes, if the Numerics
7218 Annex is not supported.  See A.5.3(72).
7219 @end cartouche
7220 @noindent
7221 See the source file @file{ttypef.ads} for the values of all numeric
7222 attributes.
7223
7224 @sp 1
7225 @cartouche
7226 @noindent
7227 @strong{69}.  Any implementation-defined characteristics of the
7228 input-output packages.  See A.7(14).
7229 @end cartouche
7230 @noindent
7231 There are no special implementation defined characteristics for these
7232 packages.
7233
7234 @sp 1
7235 @cartouche
7236 @noindent
7237 @strong{70}.  The value of @code{Buffer_Size} in @code{Storage_IO}.  See
7238 A.9(10).
7239 @end cartouche
7240 @noindent
7241 All type representations are contiguous, and the @code{Buffer_Size} is
7242 the value of @code{@var{type}'Size} rounded up to the next storage unit
7243 boundary.
7244
7245 @sp 1
7246 @cartouche
7247 @noindent
7248 @strong{71}.  External files for standard input, standard output, and
7249 standard error See A.10(5).
7250 @end cartouche
7251 @noindent
7252 These files are mapped onto the files provided by the C streams
7253 libraries.  See source file @file{i-cstrea.ads} for further details.
7254
7255 @sp 1
7256 @cartouche
7257 @noindent
7258 @strong{72}.  The accuracy of the value produced by @code{Put}.  See
7259 A.10.9(36).
7260 @end cartouche
7261 @noindent
7262 If more digits are requested in the output than are represented by the
7263 precision of the value, zeroes are output in the corresponding least
7264 significant digit positions.
7265
7266 @sp 1
7267 @cartouche
7268 @noindent
7269 @strong{73}.  The meaning of @code{Argument_Count}, @code{Argument}, and
7270 @code{Command_Name}.  See A.15(1).
7271 @end cartouche
7272 @noindent
7273 These are mapped onto the @code{argv} and @code{argc} parameters of the
7274 main program in the natural manner.
7275
7276 @sp 1
7277 @cartouche
7278 @noindent
7279 @strong{74}.  Implementation-defined convention names.  See B.1(11).
7280 @end cartouche
7281 @noindent
7282 The following convention names are supported
7283
7284 @table @code
7285 @item  Ada
7286 Ada
7287 @item Assembler
7288 Assembly language
7289 @item Asm
7290 Synonym for Assembler
7291 @item Assembly
7292 Synonym for Assembler
7293 @item C
7294 C
7295 @item C_Pass_By_Copy
7296 Allowed only for record types, like C, but also notes that record
7297 is to be passed by copy rather than reference.
7298 @item COBOL
7299 COBOL
7300 @item CPP
7301 C++
7302 @item Default
7303 Treated the same as C
7304 @item External
7305 Treated the same as C
7306 @item Fortran
7307 Fortran
7308 @item Intrinsic
7309 For support of pragma @code{Import} with convention Intrinsic, see
7310 separate section on Intrinsic Subprograms.
7311 @item Stdcall
7312 Stdcall (used for Windows implementations only).  This convention correspond
7313 to the WINAPI (previously called Pascal convention) C/C++ convention under
7314 Windows.  A function with this convention cleans the stack before exit.
7315 @item DLL
7316 Synonym for Stdcall
7317 @item Win32
7318 Synonym for Stdcall
7319 @item Stubbed
7320 Stubbed is a special convention used to indicate that the body of the
7321 subprogram will be entirely ignored.  Any call to the subprogram
7322 is converted into a raise of the @code{Program_Error} exception.  If a
7323 pragma @code{Import} specifies convention @code{stubbed} then no body need
7324 be present at all.  This convention is useful during development for the
7325 inclusion of subprograms whose body has not yet been written.
7326
7327 @end table
7328 @noindent
7329 In addition, all otherwise unrecognized convention names are also
7330 treated as being synonymous with convention C@.  In all implementations
7331 except for VMS, use of such other names results in a warning.  In VMS
7332 implementations, these names are accepted silently.
7333
7334 @sp 1
7335 @cartouche
7336 @noindent
7337 @strong{75}.  The meaning of link names.  See B.1(36).
7338 @end cartouche
7339 @noindent
7340 Link names are the actual names used by the linker.
7341
7342 @sp 1
7343 @cartouche
7344 @noindent
7345 @strong{76}.  The manner of choosing link names when neither the link
7346 name nor the address of an imported or exported entity is specified.  See
7347 B.1(36).
7348 @end cartouche
7349 @noindent
7350 The default linker name is that which would be assigned by the relevant
7351 external language, interpreting the Ada name as being in all lower case
7352 letters.
7353
7354 @sp 1
7355 @cartouche
7356 @noindent
7357 @strong{77}.  The effect of pragma @code{Linker_Options}.  See B.1(37).
7358 @end cartouche
7359 @noindent
7360 The string passed to @code{Linker_Options} is presented uninterpreted as
7361 an argument to the link command, unless it contains Ascii.NUL characters.
7362 NUL characters if they appear act as argument separators, so for example
7363
7364 @smallexample @c ada
7365 pragma Linker_Options ("-labc" & ASCII.Nul & "-ldef");
7366 @end smallexample
7367
7368 @noindent
7369 causes two separate arguments @code{-labc} and @code{-ldef} to be passed to the
7370 linker. The order of linker options is preserved for a given unit. The final
7371 list of options passed to the linker is in reverse order of the elaboration
7372 order. For example, linker options fo a body always appear before the options
7373 from the corresponding package spec.
7374
7375 @sp 1
7376 @cartouche
7377 @noindent
7378 @strong{78}.  The contents of the visible part of package
7379 @code{Interfaces} and its language-defined descendants.  See B.2(1).
7380 @end cartouche
7381 @noindent
7382 See files with prefix @file{i-} in the distributed library.
7383
7384 @sp 1
7385 @cartouche
7386 @noindent
7387 @strong{79}.  Implementation-defined children of package
7388 @code{Interfaces}.  The contents of the visible part of package
7389 @code{Interfaces}.  See B.2(11).
7390 @end cartouche
7391 @noindent
7392 See files with prefix @file{i-} in the distributed library.
7393
7394 @sp 1
7395 @cartouche
7396 @noindent
7397 @strong{80}.  The types @code{Floating}, @code{Long_Floating},
7398 @code{Binary}, @code{Long_Binary}, @code{Decimal_ Element}, and
7399 @code{COBOL_Character}; and the initialization of the variables
7400 @code{Ada_To_COBOL} and @code{COBOL_To_Ada}, in
7401 @code{Interfaces.COBOL}.  See B.4(50).
7402 @end cartouche
7403 @noindent
7404 @table @code
7405 @item Floating
7406 Float
7407 @item Long_Floating
7408 (Floating) Long_Float
7409 @item Binary
7410 Integer
7411 @item Long_Binary
7412 Long_Long_Integer
7413 @item Decimal_Element
7414 Character
7415 @item COBOL_Character
7416 Character
7417 @end table
7418
7419 @noindent
7420 For initialization, see the file @file{i-cobol.ads} in the distributed library.
7421
7422 @sp 1
7423 @cartouche
7424 @noindent
7425 @strong{81}.  Support for access to machine instructions.  See C.1(1).
7426 @end cartouche
7427 @noindent
7428 See documentation in file @file{s-maccod.ads} in the distributed library.
7429
7430 @sp 1
7431 @cartouche
7432 @noindent
7433 @strong{82}.  Implementation-defined aspects of access to machine
7434 operations.  See C.1(9).
7435 @end cartouche
7436 @noindent
7437 See documentation in file @file{s-maccod.ads} in the distributed library.
7438
7439 @sp 1
7440 @cartouche
7441 @noindent
7442 @strong{83}.  Implementation-defined aspects of interrupts.  See C.3(2).
7443 @end cartouche
7444 @noindent
7445 Interrupts are mapped to signals or conditions as appropriate.  See
7446 definition of unit
7447 @code{Ada.Interrupt_Names} in source file @file{a-intnam.ads} for details
7448 on the interrupts supported on a particular target.
7449
7450 @sp 1
7451 @cartouche
7452 @noindent
7453 @strong{84}.  Implementation-defined aspects of pre-elaboration.  See
7454 C.4(13).
7455 @end cartouche
7456 @noindent
7457 GNAT does not permit a partition to be restarted without reloading,
7458 except under control of the debugger.
7459
7460 @sp 1
7461 @cartouche
7462 @noindent
7463 @strong{85}.  The semantics of pragma @code{Discard_Names}.  See C.5(7).
7464 @end cartouche
7465 @noindent
7466 Pragma @code{Discard_Names} causes names of enumeration literals to
7467 be suppressed.  In the presence of this pragma, the Image attribute
7468 provides the image of the Pos of the literal, and Value accepts
7469 Pos values.
7470
7471 @sp 1
7472 @cartouche
7473 @noindent
7474 @strong{86}.  The result of the @code{Task_Identification.Image}
7475 attribute.  See C.7.1(7).
7476 @end cartouche
7477 @noindent
7478 The result of this attribute is an 8-digit hexadecimal string
7479 representing the virtual address of the task control block.
7480
7481 @sp 1
7482 @cartouche
7483 @noindent
7484 @strong{87}.  The value of @code{Current_Task} when in a protected entry
7485 or interrupt handler.  See C.7.1(17).
7486 @end cartouche
7487 @noindent
7488 Protected entries or interrupt handlers can be executed by any
7489 convenient thread, so the value of @code{Current_Task} is undefined.
7490
7491 @sp 1
7492 @cartouche
7493 @noindent
7494 @strong{88}.  The effect of calling @code{Current_Task} from an entry
7495 body or interrupt handler.  See C.7.1(19).
7496 @end cartouche
7497 @noindent
7498 The effect of calling @code{Current_Task} from an entry body or
7499 interrupt handler is to return the identification of the task currently
7500 executing the code.
7501
7502 @sp 1
7503 @cartouche
7504 @noindent
7505 @strong{89}.  Implementation-defined aspects of
7506 @code{Task_Attributes}.  See C.7.2(19).
7507 @end cartouche
7508 @noindent
7509 There are no implementation-defined aspects of @code{Task_Attributes}.
7510
7511 @sp 1
7512 @cartouche
7513 @noindent
7514 @strong{90}.  Values of all @code{Metrics}.  See D(2).
7515 @end cartouche
7516 @noindent
7517 The metrics information for GNAT depends on the performance of the
7518 underlying operating system.  The sources of the run-time for tasking
7519 implementation, together with the output from @code{-gnatG} can be
7520 used to determine the exact sequence of operating systems calls made
7521 to implement various tasking constructs.  Together with appropriate
7522 information on the performance of the underlying operating system,
7523 on the exact target in use, this information can be used to determine
7524 the required metrics.
7525
7526 @sp 1
7527 @cartouche
7528 @noindent
7529 @strong{91}.  The declarations of @code{Any_Priority} and
7530 @code{Priority}.  See D.1(11).
7531 @end cartouche
7532 @noindent
7533 See declarations in file @file{system.ads}.
7534
7535 @sp 1
7536 @cartouche
7537 @noindent
7538 @strong{92}.  Implementation-defined execution resources.  See D.1(15).
7539 @end cartouche
7540 @noindent
7541 There are no implementation-defined execution resources.
7542
7543 @sp 1
7544 @cartouche
7545 @noindent
7546 @strong{93}.  Whether, on a multiprocessor, a task that is waiting for
7547 access to a protected object keeps its processor busy.  See D.2.1(3).
7548 @end cartouche
7549 @noindent
7550 On a multi-processor, a task that is waiting for access to a protected
7551 object does not keep its processor busy.
7552
7553 @sp 1
7554 @cartouche
7555 @noindent
7556 @strong{94}.  The affect of implementation defined execution resources
7557 on task dispatching.  See D.2.1(9).
7558 @end cartouche
7559 @noindent
7560 @c SGI info
7561 @ignore
7562 Tasks map to IRIX threads, and the dispatching policy is as defined by
7563 the IRIX implementation of threads.
7564 @end ignore
7565 Tasks map to threads in the threads package used by GNAT@.  Where possible
7566 and appropriate, these threads correspond to native threads of the
7567 underlying operating system.
7568
7569 @sp 1
7570 @cartouche
7571 @noindent
7572 @strong{95}.  Implementation-defined @code{policy_identifiers} allowed
7573 in a pragma @code{Task_Dispatching_Policy}.  See D.2.2(3).
7574 @end cartouche
7575 @noindent
7576 There are no implementation-defined policy-identifiers allowed in this
7577 pragma.
7578
7579 @sp 1
7580 @cartouche
7581 @noindent
7582 @strong{96}.  Implementation-defined aspects of priority inversion.  See
7583 D.2.2(16).
7584 @end cartouche
7585 @noindent
7586 Execution of a task cannot be preempted by the implementation processing
7587 of delay expirations for lower priority tasks.
7588
7589 @sp 1
7590 @cartouche
7591 @noindent
7592 @strong{97}.  Implementation defined task dispatching.  See D.2.2(18).
7593 @end cartouche
7594 @noindent
7595 @c SGI info:
7596 @ignore
7597 Tasks map to IRIX threads, and the dispatching policy is as defied by
7598 the IRIX implementation of threads.
7599 @end ignore
7600 The policy is the same as that of the underlying threads implementation.
7601
7602 @sp 1
7603 @cartouche
7604 @noindent
7605 @strong{98}.  Implementation-defined @code{policy_identifiers} allowed
7606 in a pragma @code{Locking_Policy}.  See D.3(4).
7607 @end cartouche
7608 @noindent
7609 The only implementation defined policy permitted in GNAT is
7610 @code{Inheritance_Locking}.  On targets that support this policy, locking
7611 is implemented by inheritance, i.e.@: the task owning the lock operates
7612 at a priority equal to the highest priority of any task currently
7613 requesting the lock.
7614
7615 @sp 1
7616 @cartouche
7617 @noindent
7618 @strong{99}.  Default ceiling priorities.  See D.3(10).
7619 @end cartouche
7620 @noindent
7621 The ceiling priority of protected objects of the type
7622 @code{System.Interrupt_Priority'Last} as described in the Ada 95
7623 Reference Manual D.3(10),
7624
7625 @sp 1
7626 @cartouche
7627 @noindent
7628 @strong{100}.  The ceiling of any protected object used internally by
7629 the implementation.  See D.3(16).
7630 @end cartouche
7631 @noindent
7632 The ceiling priority of internal protected objects is
7633 @code{System.Priority'Last}.
7634
7635 @sp 1
7636 @cartouche
7637 @noindent
7638 @strong{101}.  Implementation-defined queuing policies.  See D.4(1).
7639 @end cartouche
7640 @noindent
7641 There are no implementation-defined queueing policies.
7642
7643 @sp 1
7644 @cartouche
7645 @noindent
7646 @strong{102}.  On a multiprocessor, any conditions that cause the
7647 completion of an aborted construct to be delayed later than what is
7648 specified for a single processor.  See D.6(3).
7649 @end cartouche
7650 @noindent
7651 The semantics for abort on a multi-processor is the same as on a single
7652 processor, there are no further delays.
7653
7654 @sp 1
7655 @cartouche
7656 @noindent
7657 @strong{103}.  Any operations that implicitly require heap storage
7658 allocation.  See D.7(8).
7659 @end cartouche
7660 @noindent
7661 The only operation that implicitly requires heap storage allocation is
7662 task creation.
7663
7664 @sp 1
7665 @cartouche
7666 @noindent
7667 @strong{104}.  Implementation-defined aspects of pragma
7668 @code{Restrictions}.  See D.7(20).
7669 @end cartouche
7670 @noindent
7671 There are no such implementation-defined aspects.
7672
7673 @sp 1
7674 @cartouche
7675 @noindent
7676 @strong{105}.  Implementation-defined aspects of package
7677 @code{Real_Time}.  See D.8(17).
7678 @end cartouche
7679 @noindent
7680 There are no implementation defined aspects of package @code{Real_Time}.
7681
7682 @sp 1
7683 @cartouche
7684 @noindent
7685 @strong{106}.  Implementation-defined aspects of
7686 @code{delay_statements}.  See D.9(8).
7687 @end cartouche
7688 @noindent
7689 Any difference greater than one microsecond will cause the task to be
7690 delayed (see D.9(7)).
7691
7692 @sp 1
7693 @cartouche
7694 @noindent
7695 @strong{107}.  The upper bound on the duration of interrupt blocking
7696 caused by the implementation.  See D.12(5).
7697 @end cartouche
7698 @noindent
7699 The upper bound is determined by the underlying operating system.  In
7700 no cases is it more than 10 milliseconds.
7701
7702 @sp 1
7703 @cartouche
7704 @noindent
7705 @strong{108}.  The means for creating and executing distributed
7706 programs.  See E(5).
7707 @end cartouche
7708 @noindent
7709 The GLADE package provides a utility GNATDIST for creating and executing
7710 distributed programs.  See the GLADE reference manual for further details.
7711
7712 @sp 1
7713 @cartouche
7714 @noindent
7715 @strong{109}.  Any events that can result in a partition becoming
7716 inaccessible.  See E.1(7).
7717 @end cartouche
7718 @noindent
7719 See the GLADE reference manual for full details on such events.
7720
7721 @sp 1
7722 @cartouche
7723 @noindent
7724 @strong{110}.  The scheduling policies, treatment of priorities, and
7725 management of shared resources between partitions in certain cases.  See
7726 E.1(11).
7727 @end cartouche
7728 @noindent
7729 See the GLADE reference manual for full details on these aspects of
7730 multi-partition execution.
7731
7732 @sp 1
7733 @cartouche
7734 @noindent
7735 @strong{111}.  Events that cause the version of a compilation unit to
7736 change.  See E.3(5).
7737 @end cartouche
7738 @noindent
7739 Editing the source file of a compilation unit, or the source files of
7740 any units on which it is dependent in a significant way cause the version
7741 to change.  No other actions cause the version number to change.  All changes
7742 are significant except those which affect only layout, capitalization or
7743 comments.
7744
7745 @sp 1
7746 @cartouche
7747 @noindent
7748 @strong{112}.  Whether the execution of the remote subprogram is
7749 immediately aborted as a result of cancellation.  See E.4(13).
7750 @end cartouche
7751 @noindent
7752 See the GLADE reference manual for details on the effect of abort in
7753 a distributed application.
7754
7755 @sp 1
7756 @cartouche
7757 @noindent
7758 @strong{113}.  Implementation-defined aspects of the PCS@.  See E.5(25).
7759 @end cartouche
7760 @noindent
7761 See the GLADE reference manual for a full description of all implementation
7762 defined aspects of the PCS@.
7763
7764 @sp 1
7765 @cartouche
7766 @noindent
7767 @strong{114}.  Implementation-defined interfaces in the PCS@.  See
7768 E.5(26).
7769 @end cartouche
7770 @noindent
7771 See the GLADE reference manual for a full description of all
7772 implementation defined interfaces.
7773
7774 @sp 1
7775 @cartouche
7776 @noindent
7777 @strong{115}.  The values of named numbers in the package
7778 @code{Decimal}.  See F.2(7).
7779 @end cartouche
7780 @noindent
7781 @table @code
7782 @item Max_Scale
7783 +18
7784 @item Min_Scale
7785 -18
7786 @item Min_Delta
7787 1.0E-18
7788 @item Max_Delta
7789 1.0E+18
7790 @item Max_Decimal_Digits
7791 18
7792 @end table
7793
7794 @sp 1
7795 @cartouche
7796 @noindent
7797 @strong{116}.  The value of @code{Max_Picture_Length} in the package
7798 @code{Text_IO.Editing}.  See F.3.3(16).
7799 @end cartouche
7800 @noindent
7801 64
7802
7803 @sp 1
7804 @cartouche
7805 @noindent
7806 @strong{117}.  The value of @code{Max_Picture_Length} in the package
7807 @code{Wide_Text_IO.Editing}.  See F.3.4(5).
7808 @end cartouche
7809 @noindent
7810 64
7811
7812 @sp 1
7813 @cartouche
7814 @noindent
7815 @strong{118}.  The accuracy actually achieved by the complex elementary
7816 functions and by other complex arithmetic operations.  See G.1(1).
7817 @end cartouche
7818 @noindent
7819 Standard library functions are used for the complex arithmetic
7820 operations.  Only fast math mode is currently supported.
7821
7822 @sp 1
7823 @cartouche
7824 @noindent
7825 @strong{119}.  The sign of a zero result (or a component thereof) from
7826 any operator or function in @code{Numerics.Generic_Complex_Types}, when
7827 @code{Real'Signed_Zeros} is True.  See G.1.1(53).
7828 @end cartouche
7829 @noindent
7830 The signs of zero values are as recommended by the relevant
7831 implementation advice.
7832
7833 @sp 1
7834 @cartouche
7835 @noindent
7836 @strong{120}.  The sign of a zero result (or a component thereof) from
7837 any operator or function in
7838 @code{Numerics.Generic_Complex_Elementary_Functions}, when
7839 @code{Real'Signed_Zeros} is @code{True}.  See G.1.2(45).
7840 @end cartouche
7841 @noindent
7842 The signs of zero values are as recommended by the relevant
7843 implementation advice.
7844
7845 @sp 1
7846 @cartouche
7847 @noindent
7848 @strong{121}.  Whether the strict mode or the relaxed mode is the
7849 default.  See G.2(2).
7850 @end cartouche
7851 @noindent
7852 The strict mode is the default.  There is no separate relaxed mode.  GNAT
7853 provides a highly efficient implementation of strict mode.
7854
7855 @sp 1
7856 @cartouche
7857 @noindent
7858 @strong{122}.  The result interval in certain cases of fixed-to-float
7859 conversion.  See G.2.1(10).
7860 @end cartouche
7861 @noindent
7862 For cases where the result interval is implementation dependent, the
7863 accuracy is that provided by performing all operations in 64-bit IEEE
7864 floating-point format.
7865
7866 @sp 1
7867 @cartouche
7868 @noindent
7869 @strong{123}.  The result of a floating point arithmetic operation in
7870 overflow situations, when the @code{Machine_Overflows} attribute of the
7871 result type is @code{False}.  See G.2.1(13).
7872 @end cartouche
7873 @noindent
7874 Infinite and Nan values are produced as dictated by the IEEE
7875 floating-point standard.
7876
7877 @sp 1
7878 @cartouche
7879 @noindent
7880 @strong{124}.  The result interval for division (or exponentiation by a
7881 negative exponent), when the floating point hardware implements division
7882 as multiplication by a reciprocal.  See G.2.1(16).
7883 @end cartouche
7884 @noindent
7885 Not relevant, division is IEEE exact.
7886
7887 @sp 1
7888 @cartouche
7889 @noindent
7890 @strong{125}.  The definition of close result set, which determines the
7891 accuracy of certain fixed point multiplications and divisions.  See
7892 G.2.3(5).
7893 @end cartouche
7894 @noindent
7895 Operations in the close result set are performed using IEEE long format
7896 floating-point arithmetic.  The input operands are converted to
7897 floating-point, the operation is done in floating-point, and the result
7898 is converted to the target type.
7899
7900 @sp 1
7901 @cartouche
7902 @noindent
7903 @strong{126}.  Conditions on a @code{universal_real} operand of a fixed
7904 point multiplication or division for which the result shall be in the
7905 perfect result set.  See G.2.3(22).
7906 @end cartouche
7907 @noindent
7908 The result is only defined to be in the perfect result set if the result
7909 can be computed by a single scaling operation involving a scale factor
7910 representable in 64-bits.
7911
7912 @sp 1
7913 @cartouche
7914 @noindent
7915 @strong{127}.  The result of a fixed point arithmetic operation in
7916 overflow situations, when the @code{Machine_Overflows} attribute of the
7917 result type is @code{False}.  See G.2.3(27).
7918 @end cartouche
7919 @noindent
7920 Not relevant, @code{Machine_Overflows} is @code{True} for fixed-point
7921 types.
7922
7923 @sp 1
7924 @cartouche
7925 @noindent
7926 @strong{128}.  The result of an elementary function reference in
7927 overflow situations, when the @code{Machine_Overflows} attribute of the
7928 result type is @code{False}.  See G.2.4(4).
7929 @end cartouche
7930 @noindent
7931 IEEE infinite and Nan values are produced as appropriate.
7932
7933 @sp 1
7934 @cartouche
7935 @noindent
7936 @strong{129}.  The value of the angle threshold, within which certain
7937 elementary functions, complex arithmetic operations, and complex
7938 elementary functions yield results conforming to a maximum relative
7939 error bound.  See G.2.4(10).
7940 @end cartouche
7941 @noindent
7942 Information on this subject is not yet available.
7943
7944 @sp 1
7945 @cartouche
7946 @noindent
7947 @strong{130}.  The accuracy of certain elementary functions for
7948 parameters beyond the angle threshold.  See G.2.4(10).
7949 @end cartouche
7950 @noindent
7951 Information on this subject is not yet available.
7952
7953 @sp 1
7954 @cartouche
7955 @noindent
7956 @strong{131}.  The result of a complex arithmetic operation or complex
7957 elementary function reference in overflow situations, when the
7958 @code{Machine_Overflows} attribute of the corresponding real type is
7959 @code{False}.  See G.2.6(5).
7960 @end cartouche
7961 @noindent
7962 IEEE infinite and Nan values are produced as appropriate.
7963
7964 @sp 1
7965 @cartouche
7966 @noindent
7967 @strong{132}.  The accuracy of certain complex arithmetic operations and
7968 certain complex elementary functions for parameters (or components
7969 thereof) beyond the angle threshold.  See G.2.6(8).
7970 @end cartouche
7971 @noindent
7972 Information on those subjects is not yet available.
7973
7974 @sp 1
7975 @cartouche
7976 @noindent
7977 @strong{133}.  Information regarding bounded errors and erroneous
7978 execution.  See H.2(1).
7979 @end cartouche
7980 @noindent
7981 Information on this subject is not yet available.
7982
7983 @sp 1
7984 @cartouche
7985 @noindent
7986 @strong{134}.  Implementation-defined aspects of pragma
7987 @code{Inspection_Point}.  See H.3.2(8).
7988 @end cartouche
7989 @noindent
7990 Pragma @code{Inspection_Point} ensures that the variable is live and can
7991 be examined by the debugger at the inspection point.
7992
7993 @sp 1
7994 @cartouche
7995 @noindent
7996 @strong{135}.  Implementation-defined aspects of pragma
7997 @code{Restrictions}.  See H.4(25).
7998 @end cartouche
7999 @noindent
8000 There are no implementation-defined aspects of pragma @code{Restrictions}.  The
8001 use of pragma @code{Restrictions [No_Exceptions]} has no effect on the
8002 generated code.  Checks must suppressed by use of pragma @code{Suppress}.
8003
8004 @sp 1
8005 @cartouche
8006 @noindent
8007 @strong{136}.  Any restrictions on pragma @code{Restrictions}.  See
8008 H.4(27).
8009 @end cartouche
8010 @noindent
8011 There are no restrictions on pragma @code{Restrictions}.
8012
8013 @node Intrinsic Subprograms
8014 @chapter Intrinsic Subprograms
8015 @cindex Intrinsic Subprograms
8016
8017 @menu
8018 * Intrinsic Operators::
8019 * Enclosing_Entity::
8020 * Exception_Information::
8021 * Exception_Message::
8022 * Exception_Name::
8023 * File::
8024 * Line::
8025 * Rotate_Left::
8026 * Rotate_Right::
8027 * Shift_Left::
8028 * Shift_Right::
8029 * Shift_Right_Arithmetic::
8030 * Source_Location::
8031 @end menu
8032
8033 @noindent
8034 GNAT allows a user application program to write the declaration:
8035
8036 @smallexample @c ada
8037    pragma Import (Intrinsic, name);
8038 @end smallexample
8039
8040 @noindent
8041 providing that the name corresponds to one of the implemented intrinsic
8042 subprograms in GNAT, and that the parameter profile of the referenced
8043 subprogram meets the requirements.  This chapter describes the set of
8044 implemented intrinsic subprograms, and the requirements on parameter profiles.
8045 Note that no body is supplied; as with other uses of pragma Import, the
8046 body is supplied elsewhere (in this case by the compiler itself).  Note
8047 that any use of this feature is potentially non-portable, since the
8048 Ada standard does not require Ada compilers to implement this feature.
8049
8050 @node Intrinsic Operators
8051 @section Intrinsic Operators
8052 @cindex Intrinsic operator
8053
8054 @noindent
8055 All the predefined numeric operators in package Standard
8056 in @code{pragma Import (Intrinsic,..)}
8057 declarations.  In the binary operator case, the operands must have the same
8058 size.  The operand or operands must also be appropriate for
8059 the operator.  For example, for addition, the operands must
8060 both be floating-point or both be fixed-point, and the
8061 right operand for @code{"**"} must have a root type of
8062 @code{Standard.Integer'Base}.
8063 You can use an intrinsic operator declaration as in the following example:
8064
8065 @smallexample @c ada
8066    type Int1 is new Integer;
8067    type Int2 is new Integer;
8068
8069    function "+" (X1 : Int1; X2 : Int2) return Int1;
8070    function "+" (X1 : Int1; X2 : Int2) return Int2;
8071    pragma Import (Intrinsic, "+");
8072 @end smallexample
8073
8074 @noindent
8075 This declaration would permit ``mixed mode'' arithmetic on items
8076 of the differing types @code{Int1} and @code{Int2}.
8077 It is also possible to specify such operators for private types, if the
8078 full views are appropriate arithmetic types.
8079
8080 @node Enclosing_Entity
8081 @section Enclosing_Entity
8082 @cindex Enclosing_Entity
8083 @noindent
8084 This intrinsic subprogram is used in the implementation of the
8085 library routine @code{GNAT.Source_Info}.  The only useful use of the
8086 intrinsic import in this case is the one in this unit, so an
8087 application program should simply call the function
8088 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
8089 the current subprogram, package, task, entry, or protected subprogram.
8090
8091 @node Exception_Information
8092 @section Exception_Information
8093 @cindex Exception_Information'
8094 @noindent
8095 This intrinsic subprogram is used in the implementation of the
8096 library routine @code{GNAT.Current_Exception}.  The only useful
8097 use of the intrinsic import in this case is the one in this unit,
8098 so an application program should simply call the function
8099 @code{GNAT.Current_Exception.Exception_Information} to obtain
8100 the exception information associated with the current exception.
8101
8102 @node Exception_Message
8103 @section Exception_Message
8104 @cindex Exception_Message
8105 @noindent
8106 This intrinsic subprogram is used in the implementation of the
8107 library routine @code{GNAT.Current_Exception}.  The only useful
8108 use of the intrinsic import in this case is the one in this unit,
8109 so an application program should simply call the function
8110 @code{GNAT.Current_Exception.Exception_Message} to obtain
8111 the message associated with the current exception.
8112
8113 @node Exception_Name
8114 @section Exception_Name
8115 @cindex Exception_Name
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_Name} to obtain
8122 the name of the current exception.
8123
8124 @node File
8125 @section File
8126 @cindex File
8127 @noindent
8128 This intrinsic subprogram is used in the implementation of the
8129 library routine @code{GNAT.Source_Info}.  The only useful use of the
8130 intrinsic import in this case is the one in this unit, so an
8131 application program should simply call the function
8132 @code{GNAT.Source_Info.File} to obtain the name of the current
8133 file.
8134
8135 @node Line
8136 @section Line
8137 @cindex Line
8138 @noindent
8139 This intrinsic subprogram is used in the implementation of the
8140 library routine @code{GNAT.Source_Info}.  The only useful use of the
8141 intrinsic import in this case is the one in this unit, so an
8142 application program should simply call the function
8143 @code{GNAT.Source_Info.Line} to obtain the number of the current
8144 source line.
8145
8146 @node Rotate_Left
8147 @section Rotate_Left
8148 @cindex Rotate_Left
8149 @noindent
8150 In standard Ada 95, the @code{Rotate_Left} function is available only
8151 for the predefined modular types in package @code{Interfaces}.  However, in
8152 GNAT it is possible to define a Rotate_Left function for a user
8153 defined modular type or any signed integer type as in this example:
8154
8155 @smallexample @c ada
8156    function Shift_Left
8157      (Value  : My_Modular_Type;
8158       Amount : Natural)
8159       return   My_Modular_Type;
8160 @end smallexample
8161
8162 @noindent
8163 The requirements are that the profile be exactly as in the example
8164 above.  The only modifications allowed are in the formal parameter
8165 names, and in the type of @code{Value} and the return type, which
8166 must be the same, and must be either a signed integer type, or
8167 a modular integer type with a binary modulus, and the size must
8168 be 8.  16, 32 or 64 bits.
8169
8170 @node Rotate_Right
8171 @section Rotate_Right
8172 @cindex Rotate_Right
8173 @noindent
8174 A @code{Rotate_Right} function can be defined for any user defined
8175 binary modular integer type, or signed integer type, as described
8176 above for @code{Rotate_Left}.
8177
8178 @node Shift_Left
8179 @section Shift_Left
8180 @cindex Shift_Left
8181 @noindent
8182 A @code{Shift_Left} function can be defined for any user defined
8183 binary modular integer type, or signed integer type, as described
8184 above for @code{Rotate_Left}.
8185
8186 @node Shift_Right
8187 @section Shift_Right
8188 @cindex Shift_Right
8189 @noindent
8190 A @code{Shift_Right} function can be defined for any user defined
8191 binary modular integer type, or signed integer type, as described
8192 above for @code{Rotate_Left}.
8193
8194 @node Shift_Right_Arithmetic
8195 @section Shift_Right_Arithmetic
8196 @cindex Shift_Right_Arithmetic
8197 @noindent
8198 A @code{Shift_Right_Arithmetic} function can be defined for any user
8199 defined binary modular integer type, or signed integer type, as described
8200 above for @code{Rotate_Left}.
8201
8202 @node Source_Location
8203 @section Source_Location
8204 @cindex Source_Location
8205 @noindent
8206 This intrinsic subprogram is used in the implementation of the
8207 library routine @code{GNAT.Source_Info}.  The only useful use of the
8208 intrinsic import in this case is the one in this unit, so an
8209 application program should simply call the function
8210 @code{GNAT.Source_Info.Source_Location} to obtain the current
8211 source file location.
8212
8213 @node Representation Clauses and Pragmas
8214 @chapter Representation Clauses and Pragmas
8215 @cindex Representation Clauses
8216
8217 @menu
8218 * Alignment Clauses::
8219 * Size Clauses::
8220 * Storage_Size Clauses::
8221 * Size of Variant Record Objects::
8222 * Biased Representation ::
8223 * Value_Size and Object_Size Clauses::
8224 * Component_Size Clauses::
8225 * Bit_Order Clauses::
8226 * Effect of Bit_Order on Byte Ordering::
8227 * Pragma Pack for Arrays::
8228 * Pragma Pack for Records::
8229 * Record Representation Clauses::
8230 * Enumeration Clauses::
8231 * Address Clauses::
8232 * Effect of Convention on Representation::
8233 * Determining the Representations chosen by GNAT::
8234 @end menu
8235
8236 @noindent
8237 @cindex Representation Clause
8238 @cindex Representation Pragma
8239 @cindex Pragma, representation
8240 This section describes the representation clauses accepted by GNAT, and
8241 their effect on the representation of corresponding data objects.
8242
8243 GNAT fully implements Annex C (Systems Programming).  This means that all
8244 the implementation advice sections in chapter 13 are fully implemented.
8245 However, these sections only require a minimal level of support for
8246 representation clauses.  GNAT provides much more extensive capabilities,
8247 and this section describes the additional capabilities provided.
8248
8249 @node Alignment Clauses
8250 @section Alignment Clauses
8251 @cindex Alignment Clause
8252
8253 @noindent
8254 GNAT requires that all alignment clauses specify a power of 2, and all
8255 default alignments are always a power of 2.  The default alignment
8256 values are as follows:
8257
8258 @itemize @bullet
8259 @item @emph{Primitive Types}.
8260 For primitive types, the alignment is the minimum of the actual size of
8261 objects of the type divided by @code{Storage_Unit},
8262 and the maximum alignment supported by the target.
8263 (This maximum alignment is given by the GNAT-specific attribute
8264 @code{Standard'Maximum_Alignment}; see @ref{Maximum_Alignment}.)
8265 @cindex @code{Maximum_Alignment} attribute
8266 For example, for type @code{Long_Float}, the object size is 8 bytes, and the
8267 default alignment will be 8 on any target that supports alignments
8268 this large, but on some targets, the maximum alignment may be smaller
8269 than 8, in which case objects of type @code{Long_Float} will be maximally
8270 aligned.
8271
8272 @item @emph{Arrays}.
8273 For arrays, the alignment is equal to the alignment of the component type
8274 for the normal case where no packing or component size is given.  If the
8275 array is packed, and the packing is effective (see separate section on
8276 packed arrays), then the alignment will be one for long packed arrays,
8277 or arrays whose length is not known at compile time.  For short packed
8278 arrays, which are handled internally as modular types, the alignment
8279 will be as described for primitive types, e.g.@: a packed array of length
8280 31 bits will have an object size of four bytes, and an alignment of 4.
8281
8282 @item @emph{Records}.
8283 For the normal non-packed case, the alignment of a record is equal to
8284 the maximum alignment of any of its components.  For tagged records, this
8285 includes the implicit access type used for the tag.  If a pragma @code{Pack} is
8286 used and all fields are packable (see separate section on pragma @code{Pack}),
8287 then the resulting alignment is 1.
8288
8289 A special case is when:
8290 @itemize @bullet
8291 @item
8292 the size of the record is given explicitly, or a
8293 full record representation clause is given, and
8294 @item
8295 the size of the record is 2, 4, or 8 bytes.
8296 @end itemize
8297 @noindent
8298 In this case, an alignment is chosen to match the
8299 size of the record. For example, if we have:
8300
8301 @smallexample @c ada
8302    type Small is record
8303       A, B : Character;
8304    end record;
8305    for Small'Size use 16;
8306 @end smallexample
8307
8308 @noindent
8309 then the default alignment of the record type @code{Small} is 2, not 1. This
8310 leads to more efficient code when the record is treated as a unit, and also
8311 allows the type to specified as @code{Atomic} on architectures requiring
8312 strict alignment.
8313
8314 @end itemize
8315
8316 @noindent
8317 An alignment clause may
8318 always specify a larger alignment than the default value, up to some
8319 maximum value dependent on the target (obtainable by using the
8320 attribute reference @code{Standard'Maximum_Alignment}).
8321 The only case where
8322 it is permissible to specify a smaller alignment than the default value
8323 is for a record with a record representation clause.
8324 In this case, packable fields for which a component clause is
8325 given still result in a default alignment corresponding to the original
8326 type, but this may be overridden, since these components in fact only
8327 require an alignment of one byte.  For example, given
8328
8329 @smallexample @c ada
8330   type V is record
8331      A : Integer;
8332   end record;
8333
8334   for V use record
8335      A at 0  range 0 .. 31;
8336   end record;
8337
8338   for V'alignment use 1;
8339 @end smallexample
8340
8341 @noindent
8342 @cindex Alignment, default
8343 The default alignment for the type @code{V} is 4, as a result of the
8344 Integer field in the record, but since this field is placed with a
8345 component clause, it is permissible, as shown, to override the default
8346 alignment of the record with a smaller value.
8347
8348 @node Size Clauses
8349 @section Size Clauses
8350 @cindex Size Clause
8351
8352 @noindent
8353 The default size for a type @code{T} is obtainable through the
8354 language-defined attribute @code{T'Size} and also through the
8355 equivalent GNAT-defined attribute @code{T'Value_Size}.
8356 For objects of type @code{T}, GNAT will generally increase the type size
8357 so that the object size (obtainable through the GNAT-defined attribute
8358 @code{T'Object_Size})
8359 is a multiple of @code{T'Alignment * Storage_Unit}.
8360 For example
8361
8362 @smallexample @c ada
8363    type Smallint is range 1 .. 6;
8364
8365    type Rec is record
8366       Y1 : integer;
8367       Y2 : boolean;
8368    end record;
8369 @end smallexample
8370
8371 @noindent
8372 In this example, @code{Smallint'Size} = @code{Smallint'Value_Size} = 3,
8373 as specified by the RM rules,
8374 but objects of this type will have a size of 8
8375 (@code{Smallint'Object_Size} = 8),
8376 since objects by default occupy an integral number
8377 of storage units.  On some targets, notably older
8378 versions of the Digital Alpha, the size of stand
8379 alone objects of this type may be 32, reflecting
8380 the inability of the hardware to do byte load/stores.
8381
8382 Similarly, the size of type @code{Rec} is 40 bits
8383 (@code{Rec'Size} = @code{Rec'Value_Size} = 40), but
8384 the alignment is 4, so objects of this type will have
8385 their size increased to 64 bits so that it is a multiple
8386 of the alignment (in bits).  The reason for this decision, which is
8387 in accordance with the specific Implementation Advice in RM 13.3(43):
8388
8389 @quotation
8390 A @code{Size} clause should be supported for an object if the specified
8391 @code{Size} is at least as large as its subtype's @code{Size}, and corresponds
8392 to a size in storage elements that is a multiple of the object's
8393 @code{Alignment} (if the @code{Alignment} is nonzero).
8394 @end quotation
8395
8396 @noindent
8397 An explicit size clause may be used to override the default size by
8398 increasing it.  For example, if we have:
8399
8400 @smallexample @c ada
8401    type My_Boolean is new Boolean;
8402    for My_Boolean'Size use 32;
8403 @end smallexample
8404
8405 @noindent
8406 then values of this type will always be 32 bits long.  In the case of
8407 discrete types, the size can be increased up to 64 bits, with the effect
8408 that the entire specified field is used to hold the value, sign- or
8409 zero-extended as appropriate.  If more than 64 bits is specified, then
8410 padding space is allocated after the value, and a warning is issued that
8411 there are unused bits.
8412
8413 Similarly the size of records and arrays may be increased, and the effect
8414 is to add padding bits after the value.  This also causes a warning message
8415 to be generated.
8416
8417 The largest Size value permitted in GNAT is 2**31@minus{}1.  Since this is a
8418 Size in bits, this corresponds to an object of size 256 megabytes (minus
8419 one).  This limitation is true on all targets.  The reason for this
8420 limitation is that it improves the quality of the code in many cases
8421 if it is known that a Size value can be accommodated in an object of
8422 type Integer.
8423
8424 @node Storage_Size Clauses
8425 @section Storage_Size Clauses
8426 @cindex Storage_Size Clause
8427
8428 @noindent
8429 For tasks, the @code{Storage_Size} clause specifies the amount of space
8430 to be allocated for the task stack.  This cannot be extended, and if the
8431 stack is exhausted, then @code{Storage_Error} will be raised (if stack
8432 checking is enabled).  Use a @code{Storage_Size} attribute definition clause,
8433 or a @code{Storage_Size} pragma in the task definition to set the
8434 appropriate required size.  A useful technique is to include in every
8435 task definition a pragma of the form:
8436
8437 @smallexample @c ada
8438    pragma Storage_Size (Default_Stack_Size);
8439 @end smallexample
8440
8441 @noindent
8442 Then @code{Default_Stack_Size} can be defined in a global package, and
8443 modified as required.  Any tasks requiring stack sizes different from the
8444 default can have an appropriate alternative reference in the pragma.
8445
8446 For access types, the @code{Storage_Size} clause specifies the maximum
8447 space available for allocation of objects of the type.  If this space is
8448 exceeded then @code{Storage_Error} will be raised by an allocation attempt.
8449 In the case where the access type is declared local to a subprogram, the
8450 use of a @code{Storage_Size} clause triggers automatic use of a special
8451 predefined storage pool (@code{System.Pool_Size}) that ensures that all
8452 space for the pool is automatically reclaimed on exit from the scope in
8453 which the type is declared.
8454
8455 A special case recognized by the compiler is the specification of a
8456 @code{Storage_Size} of zero for an access type.  This means that no
8457 items can be allocated from the pool, and this is recognized at compile
8458 time, and all the overhead normally associated with maintaining a fixed
8459 size storage pool is eliminated.  Consider the following example:
8460
8461 @smallexample @c ada
8462    procedure p is
8463       type R is array (Natural) of Character;
8464       type P is access all R;
8465       for P'Storage_Size use 0;
8466       --  Above access type intended only for interfacing purposes
8467
8468       y : P;
8469
8470       procedure g (m : P);
8471       pragma Import (C, g);
8472
8473       --  @dots{}
8474
8475    begin
8476       --  @dots{}
8477       y := new R;
8478    end;
8479 @end smallexample
8480
8481 @noindent
8482 As indicated in this example, these dummy storage pools are often useful in
8483 connection with interfacing where no object will ever be allocated.  If you
8484 compile the above example, you get the warning:
8485
8486 @smallexample
8487    p.adb:16:09: warning: allocation from empty storage pool
8488    p.adb:16:09: warning: Storage_Error will be raised at run time
8489 @end smallexample
8490
8491 @noindent
8492 Of course in practice, there will not be any explicit allocators in the
8493 case of such an access declaration.
8494
8495 @node Size of Variant Record Objects
8496 @section Size of Variant Record Objects
8497 @cindex Size, variant record objects
8498 @cindex Variant record objects, size
8499
8500 @noindent
8501 In the case of variant record objects, there is a question whether Size gives
8502 information about a particular variant, or the maximum size required
8503 for any variant.  Consider the following program
8504
8505 @smallexample @c ada
8506 with Text_IO; use Text_IO;
8507 procedure q is
8508    type R1 (A : Boolean := False) is record
8509      case A is
8510        when True  => X : Character;
8511        when False => null;
8512      end case;
8513    end record;
8514
8515    V1 : R1 (False);
8516    V2 : R1;
8517
8518 begin
8519    Put_Line (Integer'Image (V1'Size));
8520    Put_Line (Integer'Image (V2'Size));
8521 end q;
8522 @end smallexample
8523
8524 @noindent
8525 Here we are dealing with a variant record, where the True variant
8526 requires 16 bits, and the False variant requires 8 bits.
8527 In the above example, both V1 and V2 contain the False variant,
8528 which is only 8 bits long.  However, the result of running the
8529 program is:
8530
8531 @smallexample
8532 8
8533 16
8534 @end smallexample
8535
8536 @noindent
8537 The reason for the difference here is that the discriminant value of
8538 V1 is fixed, and will always be False.  It is not possible to assign
8539 a True variant value to V1, therefore 8 bits is sufficient.  On the
8540 other hand, in the case of V2, the initial discriminant value is
8541 False (from the default), but it is possible to assign a True
8542 variant value to V2, therefore 16 bits must be allocated for V2
8543 in the general case, even fewer bits may be needed at any particular
8544 point during the program execution.
8545
8546 As can be seen from the output of this program, the @code{'Size}
8547 attribute applied to such an object in GNAT gives the actual allocated
8548 size of the variable, which is the largest size of any of the variants.
8549 The Ada Reference Manual is not completely clear on what choice should
8550 be made here, but the GNAT behavior seems most consistent with the
8551 language in the RM@.
8552
8553 In some cases, it may be desirable to obtain the size of the current
8554 variant, rather than the size of the largest variant.  This can be
8555 achieved in GNAT by making use of the fact that in the case of a
8556 subprogram parameter, GNAT does indeed return the size of the current
8557 variant (because a subprogram has no way of knowing how much space
8558 is actually allocated for the actual).
8559
8560 Consider the following modified version of the above program:
8561
8562 @smallexample @c ada
8563 with Text_IO; use Text_IO;
8564 procedure q is
8565    type R1 (A : Boolean := False) is record
8566      case A is
8567        when True  => X : Character;
8568        when False => null;
8569      end case;
8570    end record;
8571
8572    V2 : R1;
8573
8574    function Size (V : R1) return Integer is
8575    begin
8576       return V'Size;
8577    end Size;
8578
8579 begin
8580    Put_Line (Integer'Image (V2'Size));
8581    Put_Line (Integer'IMage (Size (V2)));
8582    V2 := (True, 'x');
8583    Put_Line (Integer'Image (V2'Size));
8584    Put_Line (Integer'IMage (Size (V2)));
8585 end q;
8586 @end smallexample
8587
8588 @noindent
8589 The output from this program is
8590
8591 @smallexample
8592 16
8593 8
8594 16
8595 16
8596 @end smallexample
8597
8598 @noindent
8599 Here we see that while the @code{'Size} attribute always returns
8600 the maximum size, regardless of the current variant value, the
8601 @code{Size} function does indeed return the size of the current
8602 variant value.
8603
8604 @node Biased Representation
8605 @section Biased Representation
8606 @cindex Size for biased representation
8607 @cindex Biased representation
8608
8609 @noindent
8610 In the case of scalars with a range starting at other than zero, it is
8611 possible in some cases to specify a size smaller than the default minimum
8612 value, and in such cases, GNAT uses an unsigned biased representation,
8613 in which zero is used to represent the lower bound, and successive values
8614 represent successive values of the type.
8615
8616 For example, suppose we have the declaration:
8617
8618 @smallexample @c ada
8619    type Small is range -7 .. -4;
8620    for Small'Size use 2;
8621 @end smallexample
8622
8623 @noindent
8624 Although the default size of type @code{Small} is 4, the @code{Size}
8625 clause is accepted by GNAT and results in the following representation
8626 scheme:
8627
8628 @smallexample
8629   -7 is represented as 2#00#
8630   -6 is represented as 2#01#
8631   -5 is represented as 2#10#
8632   -4 is represented as 2#11#
8633 @end smallexample
8634
8635 @noindent
8636 Biased representation is only used if the specified @code{Size} clause
8637 cannot be accepted in any other manner.  These reduced sizes that force
8638 biased representation can be used for all discrete types except for
8639 enumeration types for which a representation clause is given.
8640
8641 @node Value_Size and Object_Size Clauses
8642 @section Value_Size and Object_Size Clauses
8643 @findex Value_Size
8644 @findex Object_Size
8645 @cindex Size, of objects
8646
8647 @noindent
8648 In Ada 95, @code{T'Size} for a type @code{T} is the minimum number of bits
8649 required to hold values of type @code{T}.  Although this interpretation was
8650 allowed in Ada 83, it was not required, and this requirement in practice
8651 can cause some significant difficulties.  For example, in most Ada 83
8652 compilers, @code{Natural'Size} was 32.  However, in Ada 95,
8653 @code{Natural'Size} is
8654 typically 31.  This means that code may change in behavior when moving
8655 from Ada 83 to Ada 95.  For example, consider:
8656
8657 @smallexample @c ada
8658    type Rec is record;
8659       A : Natural;
8660       B : Natural;
8661    end record;
8662
8663    for Rec use record
8664       at 0  range 0 .. Natural'Size - 1;
8665       at 0  range Natural'Size .. 2 * Natural'Size - 1;
8666    end record;
8667 @end smallexample
8668
8669 @noindent
8670 In the above code, since the typical size of @code{Natural} objects
8671 is 32 bits and @code{Natural'Size} is 31, the above code can cause
8672 unexpected inefficient packing in Ada 95, and in general there are
8673 cases where the fact that the object size can exceed the
8674 size of the type causes surprises.
8675
8676 To help get around this problem GNAT provides two implementation
8677 defined attributes, @code{Value_Size} and @code{Object_Size}.  When
8678 applied to a type, these attributes yield the size of the type
8679 (corresponding to the RM defined size attribute), and the size of
8680 objects of the type respectively.
8681
8682 The @code{Object_Size} is used for determining the default size of
8683 objects and components.  This size value can be referred to using the
8684 @code{Object_Size} attribute.  The phrase ``is used'' here means that it is
8685 the basis of the determination of the size.  The backend is free to
8686 pad this up if necessary for efficiency, e.g.@: an 8-bit stand-alone
8687 character might be stored in 32 bits on a machine with no efficient
8688 byte access instructions such as the Alpha.
8689
8690 The default rules for the value of @code{Object_Size} for
8691 discrete types are as follows:
8692
8693 @itemize @bullet
8694 @item
8695 The @code{Object_Size} for base subtypes reflect the natural hardware
8696 size in bits (run the compiler with @option{-gnatS} to find those values
8697 for numeric types). Enumeration types and fixed-point base subtypes have
8698 8, 16, 32 or 64 bits for this size, depending on the range of values
8699 to be stored.
8700
8701 @item
8702 The @code{Object_Size} of a subtype is the same as the
8703 @code{Object_Size} of
8704 the type from which it is obtained.
8705
8706 @item
8707 The @code{Object_Size} of a derived base type is copied from the parent
8708 base type, and the @code{Object_Size} of a derived first subtype is copied
8709 from the parent first subtype.
8710 @end itemize
8711
8712 @noindent
8713 The @code{Value_Size} attribute
8714 is the (minimum) number of bits required to store a value
8715 of the type.
8716 This value is used to determine how tightly to pack
8717 records or arrays with components of this type, and also affects
8718 the semantics of unchecked conversion (unchecked conversions where
8719 the @code{Value_Size} values differ generate a warning, and are potentially
8720 target dependent).
8721
8722 The default rules for the value of @code{Value_Size} are as follows:
8723
8724 @itemize @bullet
8725 @item
8726 The @code{Value_Size} for a base subtype is the minimum number of bits
8727 required to store all values of the type (including the sign bit
8728 only if negative values are possible).
8729
8730 @item
8731 If a subtype statically matches the first subtype of a given type, then it has
8732 by default the same @code{Value_Size} as the first subtype.  This is a
8733 consequence of RM 13.1(14) (``if two subtypes statically match,
8734 then their subtype-specific aspects are the same''.)
8735
8736 @item
8737 All other subtypes have a @code{Value_Size} corresponding to the minimum
8738 number of bits required to store all values of the subtype.  For
8739 dynamic bounds, it is assumed that the value can range down or up
8740 to the corresponding bound of the ancestor
8741 @end itemize
8742
8743 @noindent
8744 The RM defined attribute @code{Size} corresponds to the
8745 @code{Value_Size} attribute.
8746
8747 The @code{Size} attribute may be defined for a first-named subtype.  This sets
8748 the @code{Value_Size} of
8749 the first-named subtype to the given value, and the
8750 @code{Object_Size} of this first-named subtype to the given value padded up
8751 to an appropriate boundary.  It is a consequence of the default rules
8752 above that this @code{Object_Size} will apply to all further subtypes.  On the
8753 other hand, @code{Value_Size} is affected only for the first subtype, any
8754 dynamic subtypes obtained from it directly, and any statically matching
8755 subtypes.  The @code{Value_Size} of any other static subtypes is not affected.
8756
8757 @code{Value_Size} and
8758 @code{Object_Size} may be explicitly set for any subtype using
8759 an attribute definition clause.  Note that the use of these attributes
8760 can cause the RM 13.1(14) rule to be violated.  If two access types
8761 reference aliased objects whose subtypes have differing @code{Object_Size}
8762 values as a result of explicit attribute definition clauses, then it
8763 is erroneous to convert from one access subtype to the other.
8764
8765 At the implementation level, Esize stores the Object_Size and the
8766 RM_Size field stores the @code{Value_Size} (and hence the value of the
8767 @code{Size} attribute,
8768 which, as noted above, is equivalent to @code{Value_Size}).
8769
8770 To get a feel for the difference, consider the following examples (note
8771 that in each case the base is @code{Short_Short_Integer} with a size of 8):
8772
8773 @smallexample
8774                                        Object_Size     Value_Size
8775
8776 type x1 is range 0 .. 5;                    8               3
8777
8778 type x2 is range 0 .. 5;
8779 for x2'size use 12;                        16              12
8780
8781 subtype x3 is x2 range 0 .. 3;             16               2
8782
8783 subtype x4 is x2'base range 0 .. 10;        8               4
8784
8785 subtype x5 is x2 range 0 .. dynamic;       16               3*
8786
8787 subtype x6 is x2'base range 0 .. dynamic;   8               3*
8788
8789 @end smallexample
8790
8791 @noindent
8792 Note: the entries marked ``3*'' are not actually specified by the Ada 95 RM,
8793 but it seems in the spirit of the RM rules to allocate the minimum number
8794 of bits (here 3, given the range for @code{x2})
8795 known to be large enough to hold the given range of values.
8796
8797 So far, so good, but GNAT has to obey the RM rules, so the question is
8798 under what conditions must the RM @code{Size} be used.
8799 The following is a list
8800 of the occasions on which the RM @code{Size} must be used:
8801
8802 @itemize @bullet
8803 @item
8804 Component size for packed arrays or records
8805
8806 @item
8807 Value of the attribute @code{Size} for a type
8808
8809 @item
8810 Warning about sizes not matching for unchecked conversion
8811 @end itemize
8812
8813 @noindent
8814 For record types, the @code{Object_Size} is always a multiple of the
8815 alignment of the type (this is true for all types). In some cases the
8816 @code{Value_Size} can be smaller. Consider:
8817
8818 @smallexample
8819    type R is record
8820      X : Integer;
8821      Y : Character;
8822    end record;
8823 @end smallexample
8824
8825 @noindent
8826 On a typical 32-bit architecture, the X component will be four bytes, and
8827 require four-byte alignment, and the Y component will be one byte. In this
8828 case @code{R'Value_Size} will be 40 (bits) since this is the minimum size
8829 required to store a value of this type, and for example, it is permissible
8830 to have a component of type R in an outer record whose component size is
8831 specified to be 48 bits. However, @code{R'Object_Size} will be 64 (bits),
8832 since it must be rounded up so that this value is a multiple of the
8833 alignment (4 bytes = 32 bits).
8834
8835 @noindent
8836 For all other types, the @code{Object_Size}
8837 and Value_Size are the same (and equivalent to the RM attribute @code{Size}).
8838 Only @code{Size} may be specified for such types.
8839
8840 @node Component_Size Clauses
8841 @section Component_Size Clauses
8842 @cindex Component_Size Clause
8843
8844 @noindent
8845 Normally, the value specified in a component clause must be consistent
8846 with the subtype of the array component with regard to size and alignment.
8847 In other words, the value specified must be at least equal to the size
8848 of this subtype, and must be a multiple of the alignment value.
8849
8850 In addition, component size clauses are allowed which cause the array
8851 to be packed, by specifying a smaller value.  The cases in which this
8852 is allowed are for component size values in the range 1 through 63.  The value
8853 specified must not be smaller than the Size of the subtype.  GNAT will
8854 accurately honor all packing requests in this range.  For example, if
8855 we have:
8856
8857 @smallexample @c ada
8858 type r is array (1 .. 8) of Natural;
8859 for r'Component_Size use 31;
8860 @end smallexample
8861
8862 @noindent
8863 then the resulting array has a length of 31 bytes (248 bits = 8 * 31).
8864 Of course access to the components of such an array is considerably
8865 less efficient than if the natural component size of 32 is used.
8866
8867 @node Bit_Order Clauses
8868 @section Bit_Order Clauses
8869 @cindex Bit_Order Clause
8870 @cindex bit ordering
8871 @cindex ordering, of bits
8872
8873 @noindent
8874 For record subtypes, GNAT permits the specification of the @code{Bit_Order}
8875 attribute.  The specification may either correspond to the default bit
8876 order for the target, in which case the specification has no effect and
8877 places no additional restrictions, or it may be for the non-standard
8878 setting (that is the opposite of the default).
8879
8880 In the case where the non-standard value is specified, the effect is
8881 to renumber bits within each byte, but the ordering of bytes is not
8882 affected.  There are certain
8883 restrictions placed on component clauses as follows:
8884
8885 @itemize @bullet
8886
8887 @item Components fitting within a single storage unit.
8888 @noindent
8889 These are unrestricted, and the effect is merely to renumber bits.  For
8890 example if we are on a little-endian machine with @code{Low_Order_First}
8891 being the default, then the following two declarations have exactly
8892 the same effect:
8893
8894 @smallexample @c ada
8895    type R1 is record
8896       A : Boolean;
8897       B : Integer range 1 .. 120;
8898    end record;
8899
8900    for R1 use record
8901       A at 0 range 0 .. 0;
8902       B at 0 range 1 .. 7;
8903    end record;
8904
8905    type R2 is record
8906       A : Boolean;
8907       B : Integer range 1 .. 120;
8908    end record;
8909
8910    for R2'Bit_Order use High_Order_First;
8911
8912    for R2 use record
8913       A at 0 range 7 .. 7;
8914       B at 0 range 0 .. 6;
8915    end record;
8916 @end smallexample
8917
8918 @noindent
8919 The useful application here is to write the second declaration with the
8920 @code{Bit_Order} attribute definition clause, and know that it will be treated
8921 the same, regardless of whether the target is little-endian or big-endian.
8922
8923 @item Components occupying an integral number of bytes.
8924 @noindent
8925 These are components that exactly fit in two or more bytes.  Such component
8926 declarations are allowed, but have no effect, since it is important to realize
8927 that the @code{Bit_Order} specification does not affect the ordering of bytes.
8928 In particular, the following attempt at getting an endian-independent integer
8929 does not work:
8930
8931 @smallexample @c ada
8932    type R2 is record
8933       A : Integer;
8934    end record;
8935
8936    for R2'Bit_Order use High_Order_First;
8937
8938    for R2 use record
8939       A at 0 range 0 .. 31;
8940    end record;
8941 @end smallexample
8942
8943 @noindent
8944 This declaration will result in a little-endian integer on a
8945 little-endian machine, and a big-endian integer on a big-endian machine.
8946 If byte flipping is required for interoperability between big- and
8947 little-endian machines, this must be explicitly programmed.  This capability
8948 is not provided by @code{Bit_Order}.
8949
8950 @item Components that are positioned across byte boundaries
8951 @noindent
8952 but do not occupy an integral number of bytes.  Given that bytes are not
8953 reordered, such fields would occupy a non-contiguous sequence of bits
8954 in memory, requiring non-trivial code to reassemble.  They are for this
8955 reason not permitted, and any component clause specifying such a layout
8956 will be flagged as illegal by GNAT@.
8957
8958 @end itemize
8959
8960 @noindent
8961 Since the misconception that Bit_Order automatically deals with all
8962 endian-related incompatibilities is a common one, the specification of
8963 a component field that is an integral number of bytes will always
8964 generate a warning.  This warning may be suppressed using
8965 @code{pragma Suppress} if desired.  The following section contains additional
8966 details regarding the issue of byte ordering.
8967
8968 @node Effect of Bit_Order on Byte Ordering
8969 @section Effect of Bit_Order on Byte Ordering
8970 @cindex byte ordering
8971 @cindex ordering, of bytes
8972
8973 @noindent
8974 In this section we will review the effect of the @code{Bit_Order} attribute
8975 definition clause on byte ordering.  Briefly, it has no effect at all, but
8976 a detailed example will be helpful.  Before giving this
8977 example, let us review the precise
8978 definition of the effect of defining @code{Bit_Order}.  The effect of a
8979 non-standard bit order is described in section 15.5.3 of the Ada
8980 Reference Manual:
8981
8982 @quotation
8983 2   A bit ordering is a method of interpreting the meaning of
8984 the storage place attributes.
8985 @end quotation
8986
8987 @noindent
8988 To understand the precise definition of storage place attributes in
8989 this context, we visit section 13.5.1 of the manual:
8990
8991 @quotation
8992 13   A record_representation_clause (without the mod_clause)
8993 specifies the layout.  The storage place attributes (see 13.5.2)
8994 are taken from the values of the position, first_bit, and last_bit
8995 expressions after normalizing those values so that first_bit is
8996 less than Storage_Unit.
8997 @end quotation
8998
8999 @noindent
9000 The critical point here is that storage places are taken from
9001 the values after normalization, not before.  So the @code{Bit_Order}
9002 interpretation applies to normalized values.  The interpretation
9003 is described in the later part of the 15.5.3 paragraph:
9004
9005 @quotation
9006 2   A bit ordering is a method of interpreting the meaning of
9007 the storage place attributes.  High_Order_First (known in the
9008 vernacular as ``big endian'') means that the first bit of a
9009 storage element (bit 0) is the most significant bit (interpreting
9010 the sequence of bits that represent a component as an unsigned
9011 integer value).  Low_Order_First (known in the vernacular as
9012 ``little endian'') means the opposite: the first bit is the
9013 least significant.
9014 @end quotation
9015
9016 @noindent
9017 Note that the numbering is with respect to the bits of a storage
9018 unit.  In other words, the specification affects only the numbering
9019 of bits within a single storage unit.
9020
9021 We can make the effect clearer by giving an example.
9022
9023 Suppose that we have an external device which presents two bytes, the first
9024 byte presented, which is the first (low addressed byte) of the two byte
9025 record is called Master, and the second byte is called Slave.
9026
9027 The left most (most significant bit is called Control for each byte, and
9028 the remaining 7 bits are called V1, V2, @dots{} V7, where V7 is the rightmost
9029 (least significant) bit.
9030
9031 On a big-endian machine, we can write the following representation clause
9032
9033 @smallexample @c ada
9034    type Data is record
9035       Master_Control : Bit;
9036       Master_V1      : Bit;
9037       Master_V2      : Bit;
9038       Master_V3      : Bit;
9039       Master_V4      : Bit;
9040       Master_V5      : Bit;
9041       Master_V6      : Bit;
9042       Master_V7      : Bit;
9043       Slave_Control  : Bit;
9044       Slave_V1       : Bit;
9045       Slave_V2       : Bit;
9046       Slave_V3       : Bit;
9047       Slave_V4       : Bit;
9048       Slave_V5       : Bit;
9049       Slave_V6       : Bit;
9050       Slave_V7       : Bit;
9051    end record;
9052
9053    for Data use record
9054       Master_Control at 0 range 0 .. 0;
9055       Master_V1      at 0 range 1 .. 1;
9056       Master_V2      at 0 range 2 .. 2;
9057       Master_V3      at 0 range 3 .. 3;
9058       Master_V4      at 0 range 4 .. 4;
9059       Master_V5      at 0 range 5 .. 5;
9060       Master_V6      at 0 range 6 .. 6;
9061       Master_V7      at 0 range 7 .. 7;
9062       Slave_Control  at 1 range 0 .. 0;
9063       Slave_V1       at 1 range 1 .. 1;
9064       Slave_V2       at 1 range 2 .. 2;
9065       Slave_V3       at 1 range 3 .. 3;
9066       Slave_V4       at 1 range 4 .. 4;
9067       Slave_V5       at 1 range 5 .. 5;
9068       Slave_V6       at 1 range 6 .. 6;
9069       Slave_V7       at 1 range 7 .. 7;
9070    end record;
9071 @end smallexample
9072
9073 @noindent
9074 Now if we move this to a little endian machine, then the bit ordering within
9075 the byte is backwards, so we have to rewrite the record rep clause as:
9076
9077 @smallexample @c ada
9078    for Data use record
9079       Master_Control at 0 range 7 .. 7;
9080       Master_V1      at 0 range 6 .. 6;
9081       Master_V2      at 0 range 5 .. 5;
9082       Master_V3      at 0 range 4 .. 4;
9083       Master_V4      at 0 range 3 .. 3;
9084       Master_V5      at 0 range 2 .. 2;
9085       Master_V6      at 0 range 1 .. 1;
9086       Master_V7      at 0 range 0 .. 0;
9087       Slave_Control  at 1 range 7 .. 7;
9088       Slave_V1       at 1 range 6 .. 6;
9089       Slave_V2       at 1 range 5 .. 5;
9090       Slave_V3       at 1 range 4 .. 4;
9091       Slave_V4       at 1 range 3 .. 3;
9092       Slave_V5       at 1 range 2 .. 2;
9093       Slave_V6       at 1 range 1 .. 1;
9094       Slave_V7       at 1 range 0 .. 0;
9095    end record;
9096 @end smallexample
9097
9098 @noindent
9099 It is a nuisance to have to rewrite the clause, especially if
9100 the code has to be maintained on both machines.  However,
9101 this is a case that we can handle with the
9102 @code{Bit_Order} attribute if it is implemented.
9103 Note that the implementation is not required on byte addressed
9104 machines, but it is indeed implemented in GNAT.
9105 This means that we can simply use the
9106 first record clause, together with the declaration
9107
9108 @smallexample @c ada
9109    for Data'Bit_Order use High_Order_First;
9110 @end smallexample
9111
9112 @noindent
9113 and the effect is what is desired, namely the layout is exactly the same,
9114 independent of whether the code is compiled on a big-endian or little-endian
9115 machine.
9116
9117 The important point to understand is that byte ordering is not affected.
9118 A @code{Bit_Order} attribute definition never affects which byte a field
9119 ends up in, only where it ends up in that byte.
9120 To make this clear, let us rewrite the record rep clause of the previous
9121 example as:
9122
9123 @smallexample @c ada
9124    for Data'Bit_Order use High_Order_First;
9125    for Data use record
9126       Master_Control at 0 range  0 .. 0;
9127       Master_V1      at 0 range  1 .. 1;
9128       Master_V2      at 0 range  2 .. 2;
9129       Master_V3      at 0 range  3 .. 3;
9130       Master_V4      at 0 range  4 .. 4;
9131       Master_V5      at 0 range  5 .. 5;
9132       Master_V6      at 0 range  6 .. 6;
9133       Master_V7      at 0 range  7 .. 7;
9134       Slave_Control  at 0 range  8 .. 8;
9135       Slave_V1       at 0 range  9 .. 9;
9136       Slave_V2       at 0 range 10 .. 10;
9137       Slave_V3       at 0 range 11 .. 11;
9138       Slave_V4       at 0 range 12 .. 12;
9139       Slave_V5       at 0 range 13 .. 13;
9140       Slave_V6       at 0 range 14 .. 14;
9141       Slave_V7       at 0 range 15 .. 15;
9142    end record;
9143 @end smallexample
9144
9145 @noindent
9146 This is exactly equivalent to saying (a repeat of the first example):
9147
9148 @smallexample @c ada
9149    for Data'Bit_Order use High_Order_First;
9150    for Data use record
9151       Master_Control at 0 range 0 .. 0;
9152       Master_V1      at 0 range 1 .. 1;
9153       Master_V2      at 0 range 2 .. 2;
9154       Master_V3      at 0 range 3 .. 3;
9155       Master_V4      at 0 range 4 .. 4;
9156       Master_V5      at 0 range 5 .. 5;
9157       Master_V6      at 0 range 6 .. 6;
9158       Master_V7      at 0 range 7 .. 7;
9159       Slave_Control  at 1 range 0 .. 0;
9160       Slave_V1       at 1 range 1 .. 1;
9161       Slave_V2       at 1 range 2 .. 2;
9162       Slave_V3       at 1 range 3 .. 3;
9163       Slave_V4       at 1 range 4 .. 4;
9164       Slave_V5       at 1 range 5 .. 5;
9165       Slave_V6       at 1 range 6 .. 6;
9166       Slave_V7       at 1 range 7 .. 7;
9167    end record;
9168 @end smallexample
9169
9170 @noindent
9171 Why are they equivalent? Well take a specific field, the @code{Slave_V2}
9172 field.  The storage place attributes are obtained by normalizing the
9173 values given so that the @code{First_Bit} value is less than 8.  After
9174 normalizing the values (0,10,10) we get (1,2,2) which is exactly what
9175 we specified in the other case.
9176
9177 Now one might expect that the @code{Bit_Order} attribute might affect
9178 bit numbering within the entire record component (two bytes in this
9179 case, thus affecting which byte fields end up in), but that is not
9180 the way this feature is defined, it only affects numbering of bits,
9181 not which byte they end up in.
9182
9183 Consequently it never makes sense to specify a starting bit number
9184 greater than 7 (for a byte addressable field) if an attribute
9185 definition for @code{Bit_Order} has been given, and indeed it
9186 may be actively confusing to specify such a value, so the compiler
9187 generates a warning for such usage.
9188
9189 If you do need to control byte ordering then appropriate conditional
9190 values must be used.  If in our example, the slave byte came first on
9191 some machines we might write:
9192
9193 @smallexample @c ada
9194    Master_Byte_First constant Boolean := @dots{};
9195
9196    Master_Byte : constant Natural :=
9197                    1 - Boolean'Pos (Master_Byte_First);
9198    Slave_Byte  : constant Natural :=
9199                    Boolean'Pos (Master_Byte_First);
9200
9201    for Data'Bit_Order use High_Order_First;
9202    for Data use record
9203       Master_Control at Master_Byte range 0 .. 0;
9204       Master_V1      at Master_Byte range 1 .. 1;
9205       Master_V2      at Master_Byte range 2 .. 2;
9206       Master_V3      at Master_Byte range 3 .. 3;
9207       Master_V4      at Master_Byte range 4 .. 4;
9208       Master_V5      at Master_Byte range 5 .. 5;
9209       Master_V6      at Master_Byte range 6 .. 6;
9210       Master_V7      at Master_Byte range 7 .. 7;
9211       Slave_Control  at Slave_Byte  range 0 .. 0;
9212       Slave_V1       at Slave_Byte  range 1 .. 1;
9213       Slave_V2       at Slave_Byte  range 2 .. 2;
9214       Slave_V3       at Slave_Byte  range 3 .. 3;
9215       Slave_V4       at Slave_Byte  range 4 .. 4;
9216       Slave_V5       at Slave_Byte  range 5 .. 5;
9217       Slave_V6       at Slave_Byte  range 6 .. 6;
9218       Slave_V7       at Slave_Byte  range 7 .. 7;
9219    end record;
9220 @end smallexample
9221
9222 @noindent
9223 Now to switch between machines, all that is necessary is
9224 to set the boolean constant @code{Master_Byte_First} in
9225 an appropriate manner.
9226
9227 @node Pragma Pack for Arrays
9228 @section Pragma Pack for Arrays
9229 @cindex Pragma Pack (for arrays)
9230
9231 @noindent
9232 Pragma @code{Pack} applied to an array has no effect unless the component type
9233 is packable.  For a component type to be packable, it must be one of the
9234 following cases:
9235
9236 @itemize @bullet
9237 @item
9238 Any scalar type
9239 @item
9240 Any type whose size is specified with a size clause
9241 @item
9242 Any packed array type with a static size
9243 @end itemize
9244
9245 @noindent
9246 For all these cases, if the component subtype size is in the range
9247 1 through 63, then the effect of the pragma @code{Pack} is exactly as though a
9248 component size were specified giving the component subtype size.
9249 For example if we have:
9250
9251 @smallexample @c ada
9252    type r is range 0 .. 17;
9253
9254    type ar is array (1 .. 8) of r;
9255    pragma Pack (ar);
9256 @end smallexample
9257
9258 @noindent
9259 Then the component size of @code{ar} will be set to 5 (i.e.@: to @code{r'size},
9260 and the size of the array @code{ar} will be exactly 40 bits.
9261
9262 Note that in some cases this rather fierce approach to packing can produce
9263 unexpected effects.  For example, in Ada 95, type Natural typically has a
9264 size of 31, meaning that if you pack an array of Natural, you get 31-bit
9265 close packing, which saves a few bits, but results in far less efficient
9266 access.  Since many other Ada compilers will ignore such a packing request,
9267 GNAT will generate a warning on some uses of pragma @code{Pack} that it guesses
9268 might not be what is intended.  You can easily remove this warning by
9269 using an explicit @code{Component_Size} setting instead, which never generates
9270 a warning, since the intention of the programmer is clear in this case.
9271
9272 GNAT treats packed arrays in one of two ways.  If the size of the array is
9273 known at compile time and is less than 64 bits, then internally the array
9274 is represented as a single modular type, of exactly the appropriate number
9275 of bits.  If the length is greater than 63 bits, or is not known at compile
9276 time, then the packed array is represented as an array of bytes, and the
9277 length is always a multiple of 8 bits.
9278
9279 Note that to represent a packed array as a modular type, the alignment must
9280 be suitable for the modular type involved. For example, on typical machines
9281 a 32-bit packed array will be represented by a 32-bit modular integer with
9282 an alignment of four bytes. If you explicitly override the default alignment
9283 with an alignment clause that is too small, the modular representation
9284 cannot be used. For example, consider the following set of declarations:
9285
9286 @smallexample @c ada
9287    type R is range 1 .. 3;
9288    type S is array (1 .. 31) of R;
9289    for S'Component_Size use 2;
9290    for S'Size use 62;
9291    for S'Alignment use 1;
9292 @end smallexample
9293
9294 @noindent
9295 If the alignment clause were not present, then a 62-bit modular
9296 representation would be chosen (typically with an alignment of 4 or 8
9297 bytes depending on the target). But the default alignment is overridden
9298 with the explicit alignment clause. This means that the modular
9299 representation cannot be used, and instead the array of bytes
9300 representation must be used, meaning that the length must be a multiple
9301 of 8. Thus the above set of declarations will result in a diagnostic
9302 rejecting the size clause and noting that the minimum size allowed is 64.
9303
9304 @cindex Pragma Pack (for type Natural)
9305 @cindex Pragma Pack warning
9306
9307 One special case that is worth noting occurs when the base type of the
9308 component size is 8/16/32 and the subtype is one bit less. Notably this
9309 occurs with subtype @code{Natural}. Consider:
9310
9311 @smallexample @c ada
9312    type Arr is array (1 .. 32) of Natural;
9313    pragma Pack (Arr);
9314 @end smallexample
9315
9316 @noindent
9317 In all commonly used Ada 83 compilers, this pragma Pack would be ignored,
9318 since typically @code{Natural'Size} is 32 in Ada 83, and in any case most
9319 Ada 83 compilers did not attempt 31 bit packing.
9320
9321 In Ada 95, @code{Natural'Size} is required to be 31. Furthermore, GNAT really
9322 does pack 31-bit subtype to 31 bits. This may result in a substantial
9323 unintended performance penalty when porting legacy Ada 83 code. To help
9324 prevent this, GNAT generates a warning in such cases. If you really want 31
9325 bit packing in a case like this, you can set the component size explicitly:
9326
9327 @smallexample @c ada
9328    type Arr is array (1 .. 32) of Natural;
9329    for Arr'Component_Size use 31;
9330 @end smallexample
9331
9332 @noindent
9333 Here 31-bit packing is achieved as required, and no warning is generated,
9334 since in this case the programmer intention is clear.
9335
9336 @node Pragma Pack for Records
9337 @section Pragma Pack for Records
9338 @cindex Pragma Pack (for records)
9339
9340 @noindent
9341 Pragma @code{Pack} applied to a record will pack the components to reduce
9342 wasted space from alignment gaps and by reducing the amount of space
9343 taken by components.  We distinguish between @emph{packable} components and
9344 @emph{non-packable} components.
9345 Components of the following types are considered packable:
9346 @itemize @bullet
9347 @item
9348 All primitive types are packable.
9349
9350 @item
9351 Small packed arrays, whose size does not exceed 64 bits, and where the
9352 size is statically known at compile time, are represented internally
9353 as modular integers, and so they are also packable.
9354
9355 @end itemize
9356
9357 @noindent
9358 All packable components occupy the exact number of bits corresponding to
9359 their @code{Size} value, and are packed with no padding bits, i.e.@: they
9360 can start on an arbitrary bit boundary.
9361
9362 All other types are non-packable, they occupy an integral number of
9363 storage units, and
9364 are placed at a boundary corresponding to their alignment requirements.
9365
9366 For example, consider the record
9367
9368 @smallexample @c ada
9369    type Rb1 is array (1 .. 13) of Boolean;
9370    pragma Pack (rb1);
9371
9372    type Rb2 is array (1 .. 65) of Boolean;
9373    pragma Pack (rb2);
9374
9375    type x2 is record
9376       l1 : Boolean;
9377       l2 : Duration;
9378       l3 : Float;
9379       l4 : Boolean;
9380       l5 : Rb1;
9381       l6 : Rb2;
9382    end record;
9383    pragma Pack (x2);
9384 @end smallexample
9385
9386 @noindent
9387 The representation for the record x2 is as follows:
9388
9389 @smallexample @c ada
9390 for x2'Size use 224;
9391 for x2 use record
9392    l1 at  0 range  0 .. 0;
9393    l2 at  0 range  1 .. 64;
9394    l3 at 12 range  0 .. 31;
9395    l4 at 16 range  0 .. 0;
9396    l5 at 16 range  1 .. 13;
9397    l6 at 18 range  0 .. 71;
9398 end record;
9399 @end smallexample
9400
9401 @noindent
9402 Studying this example, we see that the packable fields @code{l1}
9403 and @code{l2} are
9404 of length equal to their sizes, and placed at specific bit boundaries (and
9405 not byte boundaries) to
9406 eliminate padding.  But @code{l3} is of a non-packable float type, so
9407 it is on the next appropriate alignment boundary.
9408
9409 The next two fields are fully packable, so @code{l4} and @code{l5} are
9410 minimally packed with no gaps.  However, type @code{Rb2} is a packed
9411 array that is longer than 64 bits, so it is itself non-packable.  Thus
9412 the @code{l6} field is aligned to the next byte boundary, and takes an
9413 integral number of bytes, i.e.@: 72 bits.
9414
9415 @node Record Representation Clauses
9416 @section Record Representation Clauses
9417 @cindex Record Representation Clause
9418
9419 @noindent
9420 Record representation clauses may be given for all record types, including
9421 types obtained by record extension.  Component clauses are allowed for any
9422 static component.  The restrictions on component clauses depend on the type
9423 of the component.
9424
9425 @cindex Component Clause
9426 For all components of an elementary type, the only restriction on component
9427 clauses is that the size must be at least the 'Size value of the type
9428 (actually the Value_Size).  There are no restrictions due to alignment,
9429 and such components may freely cross storage boundaries.
9430
9431 Packed arrays with a size up to and including 64 bits are represented
9432 internally using a modular type with the appropriate number of bits, and
9433 thus the same lack of restriction applies.  For example, if you declare:
9434
9435 @smallexample @c ada
9436    type R is array (1 .. 49) of Boolean;
9437    pragma Pack (R);
9438    for R'Size use 49;
9439 @end smallexample
9440
9441 @noindent
9442 then a component clause for a component of type R may start on any
9443 specified bit boundary, and may specify a value of 49 bits or greater.
9444
9445 The rules for other types are different for GNAT 3 and GNAT 5 versions
9446 (based on GCC 2 and GCC 3 respectively). In GNAT 5, larger components
9447 may also be placed on arbitrary boundaries, so for example, the following
9448 is permitted:
9449
9450 @smallexample @c ada
9451    type R is array (1 .. 79) of Boolean;
9452    pragma Pack (R);
9453    for R'Size use 79;
9454
9455    type Q is record
9456       G, H : Boolean;
9457       L, M : R;
9458    end record;
9459
9460    for Q use record
9461       G at 0 range  0 ..   0;
9462       H at 0 range  1 ..   1;
9463       L at 0 range  2 ..  80;
9464       R at 0 range 81 .. 159;
9465    end record;
9466 @end smallexample
9467
9468 @noindent
9469 In GNAT 3, there are more severe restrictions on larger components.
9470 For non-primitive types, including packed arrays with a size greater than
9471 64 bits, component clauses must respect the alignment requirement of the
9472 type, in particular, always starting on a byte boundary, and the length
9473 must be a multiple of the storage unit.
9474
9475 The following rules regarding tagged types are enforced in both GNAT 3 and
9476 GNAT 5:
9477
9478 The tag field of a tagged type always occupies an address sized field at
9479 the start of the record.  No component clause may attempt to overlay this
9480 tag.
9481
9482 In the case of a record extension T1, of a type T, no component clause applied
9483 to the type T1 can specify a storage location that would overlap the first
9484 T'Size bytes of the record.
9485
9486 @node Enumeration Clauses
9487 @section Enumeration Clauses
9488
9489 The only restriction on enumeration clauses is that the range of values
9490 must be representable.  For the signed case, if one or more of the
9491 representation values are negative, all values must be in the range:
9492
9493 @smallexample @c ada
9494    System.Min_Int .. System.Max_Int
9495 @end smallexample
9496
9497 @noindent
9498 For the unsigned case, where all values are non negative, the values must
9499 be in the range:
9500
9501 @smallexample @c ada
9502    0 .. System.Max_Binary_Modulus;
9503 @end smallexample
9504
9505 @noindent
9506 A @emph{confirming} representation clause is one in which the values range
9507 from 0 in sequence, i.e.@: a clause that confirms the default representation
9508 for an enumeration type.
9509 Such a confirming representation
9510 is permitted by these rules, and is specially recognized by the compiler so
9511 that no extra overhead results from the use of such a clause.
9512
9513 If an array has an index type which is an enumeration type to which an
9514 enumeration clause has been applied, then the array is stored in a compact
9515 manner.  Consider the declarations:
9516
9517 @smallexample @c ada
9518    type r is (A, B, C);
9519    for r use (A => 1, B => 5, C => 10);
9520    type t is array (r) of Character;
9521 @end smallexample
9522
9523 @noindent
9524 The array type t corresponds to a vector with exactly three elements and
9525 has a default size equal to @code{3*Character'Size}.  This ensures efficient
9526 use of space, but means that accesses to elements of the array will incur
9527 the overhead of converting representation values to the corresponding
9528 positional values, (i.e.@: the value delivered by the @code{Pos} attribute).
9529
9530 @node Address Clauses
9531 @section Address Clauses
9532 @cindex Address Clause
9533
9534 The reference manual allows a general restriction on representation clauses,
9535 as found in RM 13.1(22):
9536
9537 @quotation
9538 An implementation need not support representation
9539 items containing nonstatic expressions, except that
9540 an implementation should support a representation item
9541 for a given entity if each nonstatic expression in the
9542 representation item is a name that statically denotes
9543 a constant declared before the entity.
9544 @end quotation
9545
9546 @noindent
9547 In practice this is applicable only to address clauses, since this is the
9548 only case in which a non-static expression is permitted by the syntax.  As
9549 the AARM notes in sections 13.1 (22.a-22.h):
9550
9551 @display
9552   22.a   Reason: This is to avoid the following sort of thing:
9553
9554   22.b        X : Integer := F(@dots{});
9555               Y : Address := G(@dots{});
9556               for X'Address use Y;
9557
9558   22.c   In the above, we have to evaluate the
9559          initialization expression for X before we
9560          know where to put the result.  This seems
9561          like an unreasonable implementation burden.
9562
9563   22.d   The above code should instead be written
9564          like this:
9565
9566   22.e        Y : constant Address := G(@dots{});
9567               X : Integer := F(@dots{});
9568               for X'Address use Y;
9569
9570   22.f   This allows the expression ``Y'' to be safely
9571          evaluated before X is created.
9572
9573   22.g   The constant could be a formal parameter of mode in.
9574
9575   22.h   An implementation can support other nonstatic
9576          expressions if it wants to.  Expressions of type
9577          Address are hardly ever static, but their value
9578          might be known at compile time anyway in many
9579          cases.
9580 @end display
9581
9582 @noindent
9583 GNAT does indeed permit many additional cases of non-static expressions.  In
9584 particular, if the type involved is elementary there are no restrictions
9585 (since in this case, holding a temporary copy of the initialization value,
9586 if one is present, is inexpensive).  In addition, if there is no implicit or
9587 explicit initialization, then there are no restrictions.  GNAT will reject
9588 only the case where all three of these conditions hold:
9589
9590 @itemize @bullet
9591
9592 @item
9593 The type of the item is non-elementary (e.g.@: a record or array).
9594
9595 @item
9596 There is explicit or implicit initialization required for the object.
9597 Note that access values are always implicitly initialized, and also
9598 in GNAT, certain bit-packed arrays (those having a dynamic length or
9599 a length greater than 64) will also be implicitly initialized to zero.
9600
9601 @item
9602 The address value is non-static.  Here GNAT is more permissive than the
9603 RM, and allows the address value to be the address of a previously declared
9604 stand-alone variable, as long as it does not itself have an address clause.
9605
9606 @smallexample @c ada
9607            Anchor  : Some_Initialized_Type;
9608            Overlay : Some_Initialized_Type;
9609            for Overlay'Address use Anchor'Address;
9610 @end smallexample
9611
9612 @noindent
9613 However, the prefix of the address clause cannot be an array component, or
9614 a component of a discriminated record.
9615
9616 @end itemize
9617
9618 @noindent
9619 As noted above in section 22.h, address values are typically non-static.  In
9620 particular the To_Address function, even if applied to a literal value, is
9621 a non-static function call.  To avoid this minor annoyance, GNAT provides
9622 the implementation defined attribute 'To_Address.  The following two
9623 expressions have identical values:
9624
9625 @findex Attribute
9626 @findex To_Address
9627 @smallexample @c ada
9628    To_Address (16#1234_0000#)
9629    System'To_Address (16#1234_0000#);
9630 @end smallexample
9631
9632 @noindent
9633 except that the second form is considered to be a static expression, and
9634 thus when used as an address clause value is always permitted.
9635
9636 @noindent
9637 Additionally, GNAT treats as static an address clause that is an
9638 unchecked_conversion of a static integer value.  This simplifies the porting
9639 of legacy code, and provides a portable equivalent to the GNAT attribute
9640 @code{To_Address}.
9641
9642 Another issue with address clauses is the interaction with alignment
9643 requirements.  When an address clause is given for an object, the address
9644 value must be consistent with the alignment of the object (which is usually
9645 the same as the alignment of the type of the object).  If an address clause
9646 is given that specifies an inappropriately aligned address value, then the
9647 program execution is erroneous.
9648
9649 Since this source of erroneous behavior can have unfortunate effects, GNAT
9650 checks (at compile time if possible, generating a warning, or at execution
9651 time with a run-time check) that the alignment is appropriate.  If the
9652 run-time check fails, then @code{Program_Error} is raised.  This run-time
9653 check is suppressed if range checks are suppressed, or if
9654 @code{pragma Restrictions (No_Elaboration_Code)} is in effect.
9655
9656 @findex Export
9657 An address clause cannot be given for an exported object.  More
9658 understandably the real restriction is that objects with an address
9659 clause cannot be exported.  This is because such variables are not
9660 defined by the Ada program, so there is no external object to export.
9661
9662 @findex Import
9663 It is permissible to give an address clause and a pragma Import for the
9664 same object.  In this case, the variable is not really defined by the
9665 Ada program, so there is no external symbol to be linked.  The link name
9666 and the external name are ignored in this case.  The reason that we allow this
9667 combination is that it provides a useful idiom to avoid unwanted
9668 initializations on objects with address clauses.
9669
9670 When an address clause is given for an object that has implicit or
9671 explicit initialization, then by default initialization takes place.  This
9672 means that the effect of the object declaration is to overwrite the
9673 memory at the specified address.  This is almost always not what the
9674 programmer wants, so GNAT will output a warning:
9675
9676 @smallexample
9677   with System;
9678   package G is
9679      type R is record
9680         M : Integer := 0;
9681      end record;
9682
9683      Ext : R;
9684      for Ext'Address use System'To_Address (16#1234_1234#);
9685          |
9686   >>> warning: implicit initialization of "Ext" may
9687       modify overlaid storage
9688   >>> warning: use pragma Import for "Ext" to suppress
9689       initialization (RM B(24))
9690
9691   end G;
9692 @end smallexample
9693
9694 @noindent
9695 As indicated by the warning message, the solution is to use a (dummy) pragma
9696 Import to suppress this initialization.  The pragma tell the compiler that the
9697 object is declared and initialized elsewhere.  The following package compiles
9698 without warnings (and the initialization is suppressed):
9699
9700 @smallexample @c ada
9701    with System;
9702    package G is
9703       type R is record
9704          M : Integer := 0;
9705       end record;
9706
9707       Ext : R;
9708       for Ext'Address use System'To_Address (16#1234_1234#);
9709       pragma Import (Ada, Ext);
9710    end G;
9711 @end smallexample
9712
9713 @noindent
9714 A final issue with address clauses involves their use for overlaying
9715 variables, as in the following example:
9716 @cindex Overlaying of objects
9717
9718 @smallexample @c ada
9719   A : Integer;
9720   B : Integer;
9721   for B'Address use A'Address;
9722 @end smallexample
9723
9724 @noindent
9725 or alternatively, using the form recommended by the RM:
9726
9727 @smallexample @c ada
9728   A    : Integer;
9729   Addr : constant Address := A'Address;
9730   B    : Integer;
9731   for B'Address use Addr;
9732 @end smallexample
9733
9734 @noindent
9735 In both of these cases, @code{A}
9736 and @code{B} become aliased to one another via the
9737 address clause. This use of address clauses to overlay
9738 variables, achieving an effect similar to unchecked
9739 conversion was erroneous in Ada 83, but in Ada 95
9740 the effect is implementation defined. Furthermore, the
9741 Ada 95 RM specifically recommends that in a situation
9742 like this, @code{B} should be subject to the following
9743 implementation advice (RM 13.3(19)):
9744
9745 @quotation
9746 19  If the Address of an object is specified, or it is imported
9747     or exported, then the implementation should not perform
9748     optimizations based on assumptions of no aliases.
9749 @end quotation
9750
9751 @noindent
9752 GNAT follows this recommendation, and goes further by also applying
9753 this recommendation to the overlaid variable (@code{A}
9754 in the above example) in this case. This means that the overlay
9755 works "as expected", in that a modification to one of the variables
9756 will affect the value of the other.
9757
9758 @node Effect of Convention on Representation
9759 @section Effect of Convention on Representation
9760 @cindex Convention, effect on representation
9761
9762 @noindent
9763 Normally the specification of a foreign language convention for a type or
9764 an object has no effect on the chosen representation.  In particular, the
9765 representation chosen for data in GNAT generally meets the standard system
9766 conventions, and for example records are laid out in a manner that is
9767 consistent with C@.  This means that specifying convention C (for example)
9768 has no effect.
9769
9770 There are three exceptions to this general rule:
9771
9772 @itemize @bullet
9773
9774 @item Convention Fortran and array subtypes
9775 If pragma Convention Fortran is specified for an array subtype, then in
9776 accordance with the implementation advice in section 3.6.2(11) of the
9777 Ada Reference Manual, the array will be stored in a Fortran-compatible
9778 column-major manner, instead of the normal default row-major order.
9779
9780 @item Convention C and enumeration types
9781 GNAT normally stores enumeration types in 8, 16, or 32 bits as required
9782 to accommodate all values of the type.  For example, for the enumeration
9783 type declared by:
9784
9785 @smallexample @c ada
9786    type Color is (Red, Green, Blue);
9787 @end smallexample
9788
9789 @noindent
9790 8 bits is sufficient to store all values of the type, so by default, objects
9791 of type @code{Color} will be represented using 8 bits.  However, normal C
9792 convention is to use 32 bits for all enum values in C, since enum values
9793 are essentially of type int.  If pragma @code{Convention C} is specified for an
9794 Ada enumeration type, then the size is modified as necessary (usually to
9795 32 bits) to be consistent with the C convention for enum values.
9796
9797 @item Convention C/Fortran and Boolean types
9798 In C, the usual convention for boolean values, that is values used for
9799 conditions, is that zero represents false, and nonzero values represent
9800 true.  In Ada, the normal convention is that two specific values, typically
9801 0/1, are used to represent false/true respectively.
9802
9803 Fortran has a similar convention for @code{LOGICAL} values (any nonzero
9804 value represents true).
9805
9806 To accommodate the Fortran and C conventions, if a pragma Convention specifies
9807 C or Fortran convention for a derived Boolean, as in the following example:
9808
9809 @smallexample @c ada
9810    type C_Switch is new Boolean;
9811    pragma Convention (C, C_Switch);
9812 @end smallexample
9813
9814 @noindent
9815 then the GNAT generated code will treat any nonzero value as true.  For truth
9816 values generated by GNAT, the conventional value 1 will be used for True, but
9817 when one of these values is read, any nonzero value is treated as True.
9818
9819 @end itemize
9820
9821 @node Determining the Representations chosen by GNAT
9822 @section Determining the Representations chosen by GNAT
9823 @cindex Representation, determination of
9824 @cindex @code{-gnatR} switch
9825
9826 @noindent
9827 Although the descriptions in this section are intended to be complete, it is
9828 often easier to simply experiment to see what GNAT accepts and what the
9829 effect is on the layout of types and objects.
9830
9831 As required by the Ada RM, if a representation clause is not accepted, then
9832 it must be rejected as illegal by the compiler.  However, when a
9833 representation clause or pragma is accepted, there can still be questions
9834 of what the compiler actually does.  For example, if a partial record
9835 representation clause specifies the location of some components and not
9836 others, then where are the non-specified components placed? Or if pragma
9837 @code{Pack} is used on a record, then exactly where are the resulting
9838 fields placed? The section on pragma @code{Pack} in this chapter can be
9839 used to answer the second question, but it is often easier to just see
9840 what the compiler does.
9841
9842 For this purpose, GNAT provides the option @code{-gnatR}.  If you compile
9843 with this option, then the compiler will output information on the actual
9844 representations chosen, in a format similar to source representation
9845 clauses.  For example, if we compile the package:
9846
9847 @smallexample @c ada
9848 package q is
9849    type r (x : boolean) is tagged record
9850       case x is
9851          when True => S : String (1 .. 100);
9852          when False => null;
9853       end case;
9854    end record;
9855
9856    type r2 is new r (false) with record
9857       y2 : integer;
9858    end record;
9859
9860    for r2 use record
9861       y2 at 16 range 0 .. 31;
9862    end record;
9863
9864    type x is record
9865       y : character;
9866    end record;
9867
9868    type x1 is array (1 .. 10) of x;
9869    for x1'component_size use 11;
9870
9871    type ia is access integer;
9872
9873    type Rb1 is array (1 .. 13) of Boolean;
9874    pragma Pack (rb1);
9875
9876    type Rb2 is array (1 .. 65) of Boolean;
9877    pragma Pack (rb2);
9878
9879    type x2 is record
9880       l1 : Boolean;
9881       l2 : Duration;
9882       l3 : Float;
9883       l4 : Boolean;
9884       l5 : Rb1;
9885       l6 : Rb2;
9886    end record;
9887    pragma Pack (x2);
9888 end q;
9889 @end smallexample
9890
9891 @noindent
9892 using the switch @code{-gnatR} we obtain the following output:
9893
9894 @smallexample
9895 Representation information for unit q
9896 -------------------------------------
9897
9898 for r'Size use ??;
9899 for r'Alignment use 4;
9900 for r use record
9901    x    at 4 range  0 .. 7;
9902    _tag at 0 range  0 .. 31;
9903    s    at 5 range  0 .. 799;
9904 end record;
9905
9906 for r2'Size use 160;
9907 for r2'Alignment use 4;
9908 for r2 use record
9909    x       at  4 range  0 .. 7;
9910    _tag    at  0 range  0 .. 31;
9911    _parent at  0 range  0 .. 63;
9912    y2      at 16 range  0 .. 31;
9913 end record;
9914
9915 for x'Size use 8;
9916 for x'Alignment use 1;
9917 for x use record
9918    y at 0 range  0 .. 7;
9919 end record;
9920
9921 for x1'Size use 112;
9922 for x1'Alignment use 1;
9923 for x1'Component_Size use 11;
9924
9925 for rb1'Size use 13;
9926 for rb1'Alignment use 2;
9927 for rb1'Component_Size use 1;
9928
9929 for rb2'Size use 72;
9930 for rb2'Alignment use 1;
9931 for rb2'Component_Size use 1;
9932
9933 for x2'Size use 224;
9934 for x2'Alignment use 4;
9935 for x2 use record
9936    l1 at  0 range  0 .. 0;
9937    l2 at  0 range  1 .. 64;
9938    l3 at 12 range  0 .. 31;
9939    l4 at 16 range  0 .. 0;
9940    l5 at 16 range  1 .. 13;
9941    l6 at 18 range  0 .. 71;
9942 end record;
9943 @end smallexample
9944
9945 @noindent
9946 The Size values are actually the Object_Size, i.e.@: the default size that
9947 will be allocated for objects of the type.
9948 The ?? size for type r indicates that we have a variant record, and the
9949 actual size of objects will depend on the discriminant value.
9950
9951 The Alignment values show the actual alignment chosen by the compiler
9952 for each record or array type.
9953
9954 The record representation clause for type r shows where all fields
9955 are placed, including the compiler generated tag field (whose location
9956 cannot be controlled by the programmer).
9957
9958 The record representation clause for the type extension r2 shows all the
9959 fields present, including the parent field, which is a copy of the fields
9960 of the parent type of r2, i.e.@: r1.
9961
9962 The component size and size clauses for types rb1 and rb2 show
9963 the exact effect of pragma @code{Pack} on these arrays, and the record
9964 representation clause for type x2 shows how pragma @code{Pack} affects
9965 this record type.
9966
9967 In some cases, it may be useful to cut and paste the representation clauses
9968 generated by the compiler into the original source to fix and guarantee
9969 the actual representation to be used.
9970
9971 @node Standard Library Routines
9972 @chapter Standard Library Routines
9973
9974 @noindent
9975 The Ada 95 Reference Manual contains in Annex A a full description of an
9976 extensive set of standard library routines that can be used in any Ada
9977 program, and which must be provided by all Ada compilers.  They are
9978 analogous to the standard C library used by C programs.
9979
9980 GNAT implements all of the facilities described in annex A, and for most
9981 purposes the description in the Ada 95
9982 reference manual, or appropriate Ada
9983 text book, will be sufficient for making use of these facilities.
9984
9985 In the case of the input-output facilities, @xref{The Implementation of
9986 Standard I/O}, gives details on exactly how GNAT interfaces to the
9987 file system.  For the remaining packages, the Ada 95 reference manual
9988 should be sufficient.  The following is a list of the packages included,
9989 together with a brief description of the functionality that is provided.
9990
9991 For completeness, references are included to other predefined library
9992 routines defined in other sections of the Ada 95 reference manual (these are
9993 cross-indexed from annex A).
9994
9995 @table @code
9996 @item Ada (A.2)
9997 This is a parent package for all the standard library packages.  It is
9998 usually included implicitly in your program, and itself contains no
9999 useful data or routines.
10000
10001 @item Ada.Calendar (9.6)
10002 @code{Calendar} provides time of day access, and routines for
10003 manipulating times and durations.
10004
10005 @item Ada.Characters (A.3.1)
10006 This is a dummy parent package that contains no useful entities
10007
10008 @item Ada.Characters.Handling (A.3.2)
10009 This package provides some basic character handling capabilities,
10010 including classification functions for classes of characters (e.g.@: test
10011 for letters, or digits).
10012
10013 @item Ada.Characters.Latin_1 (A.3.3)
10014 This package includes a complete set of definitions of the characters
10015 that appear in type CHARACTER@.  It is useful for writing programs that
10016 will run in international environments.  For example, if you want an
10017 upper case E with an acute accent in a string, it is often better to use
10018 the definition of @code{UC_E_Acute} in this package.  Then your program
10019 will print in an understandable manner even if your environment does not
10020 support these extended characters.
10021
10022 @item Ada.Command_Line (A.15)
10023 This package provides access to the command line parameters and the name
10024 of the current program (analogous to the use of @code{argc} and @code{argv}
10025 in C), and also allows the exit status for the program to be set in a
10026 system-independent manner.
10027
10028 @item Ada.Decimal (F.2)
10029 This package provides constants describing the range of decimal numbers
10030 implemented, and also a decimal divide routine (analogous to the COBOL
10031 verb DIVIDE .. GIVING .. REMAINDER ..)
10032
10033 @item Ada.Direct_IO (A.8.4)
10034 This package provides input-output using a model of a set of records of
10035 fixed-length, containing an arbitrary definite Ada type, indexed by an
10036 integer record number.
10037
10038 @item Ada.Dynamic_Priorities (D.5)
10039 This package allows the priorities of a task to be adjusted dynamically
10040 as the task is running.
10041
10042 @item Ada.Exceptions (11.4.1)
10043 This package provides additional information on exceptions, and also
10044 contains facilities for treating exceptions as data objects, and raising
10045 exceptions with associated messages.
10046
10047 @item Ada.Finalization (7.6)
10048 This package contains the declarations and subprograms to support the
10049 use of controlled types, providing for automatic initialization and
10050 finalization (analogous to the constructors and destructors of C++)
10051
10052 @item Ada.Interrupts (C.3.2)
10053 This package provides facilities for interfacing to interrupts, which
10054 includes the set of signals or conditions that can be raised and
10055 recognized as interrupts.
10056
10057 @item Ada.Interrupts.Names (C.3.2)
10058 This package provides the set of interrupt names (actually signal
10059 or condition names) that can be handled by GNAT@.
10060
10061 @item Ada.IO_Exceptions (A.13)
10062 This package defines the set of exceptions that can be raised by use of
10063 the standard IO packages.
10064
10065 @item Ada.Numerics
10066 This package contains some standard constants and exceptions used
10067 throughout the numerics packages.  Note that the constants pi and e are
10068 defined here, and it is better to use these definitions than rolling
10069 your own.
10070
10071 @item Ada.Numerics.Complex_Elementary_Functions
10072 Provides the implementation of standard elementary functions (such as
10073 log and trigonometric functions) operating on complex numbers using the
10074 standard @code{Float} and the @code{Complex} and @code{Imaginary} types
10075 created by the package @code{Numerics.Complex_Types}.
10076
10077 @item Ada.Numerics.Complex_Types
10078 This is a predefined instantiation of
10079 @code{Numerics.Generic_Complex_Types} using @code{Standard.Float} to
10080 build the type @code{Complex} and @code{Imaginary}.
10081
10082 @item Ada.Numerics.Discrete_Random
10083 This package provides a random number generator suitable for generating
10084 random integer values from a specified range.
10085
10086 @item Ada.Numerics.Float_Random
10087 This package provides a random number generator suitable for generating
10088 uniformly distributed floating point values.
10089
10090 @item Ada.Numerics.Generic_Complex_Elementary_Functions
10091 This is a generic version of the package that provides the
10092 implementation of standard elementary functions (such as log and
10093 trigonometric functions) for an arbitrary complex type.
10094
10095 The following predefined instantiations of this package are provided:
10096
10097 @table @code
10098 @item Short_Float
10099 @code{Ada.Numerics.Short_Complex_Elementary_Functions}
10100 @item Float
10101 @code{Ada.Numerics.Complex_Elementary_Functions}
10102 @item Long_Float
10103 @code{Ada.Numerics.
10104  Long_Complex_Elementary_Functions}
10105 @end table
10106
10107 @item Ada.Numerics.Generic_Complex_Types
10108 This is a generic package that allows the creation of complex types,
10109 with associated complex arithmetic operations.
10110
10111 The following predefined instantiations of this package exist
10112 @table @code
10113 @item Short_Float
10114 @code{Ada.Numerics.Short_Complex_Complex_Types}
10115 @item Float
10116 @code{Ada.Numerics.Complex_Complex_Types}
10117 @item Long_Float
10118 @code{Ada.Numerics.Long_Complex_Complex_Types}
10119 @end table
10120
10121 @item Ada.Numerics.Generic_Elementary_Functions
10122 This is a generic package that provides the implementation of standard
10123 elementary functions (such as log an trigonometric functions) for an
10124 arbitrary float type.
10125
10126 The following predefined instantiations of this package exist
10127
10128 @table @code
10129 @item Short_Float
10130 @code{Ada.Numerics.Short_Elementary_Functions}
10131 @item Float
10132 @code{Ada.Numerics.Elementary_Functions}
10133 @item Long_Float
10134 @code{Ada.Numerics.Long_Elementary_Functions}
10135 @end table
10136
10137 @item Ada.Real_Time (D.8)
10138 This package provides facilities similar to those of @code{Calendar}, but
10139 operating with a finer clock suitable for real time control. Note that
10140 annex D requires that there be no backward clock jumps, and GNAT generally
10141 guarantees this behavior, but of course if the external clock on which
10142 the GNAT runtime depends is deliberately reset by some external event,
10143 then such a backward jump may occur.
10144
10145 @item Ada.Sequential_IO (A.8.1)
10146 This package provides input-output facilities for sequential files,
10147 which can contain a sequence of values of a single type, which can be
10148 any Ada type, including indefinite (unconstrained) types.
10149
10150 @item Ada.Storage_IO (A.9)
10151 This package provides a facility for mapping arbitrary Ada types to and
10152 from a storage buffer.  It is primarily intended for the creation of new
10153 IO packages.
10154
10155 @item Ada.Streams (13.13.1)
10156 This is a generic package that provides the basic support for the
10157 concept of streams as used by the stream attributes (@code{Input},
10158 @code{Output}, @code{Read} and @code{Write}).
10159
10160 @item Ada.Streams.Stream_IO (A.12.1)
10161 This package is a specialization of the type @code{Streams} defined in
10162 package @code{Streams} together with a set of operations providing
10163 Stream_IO capability.  The Stream_IO model permits both random and
10164 sequential access to a file which can contain an arbitrary set of values
10165 of one or more Ada types.
10166
10167 @item Ada.Strings (A.4.1)
10168 This package provides some basic constants used by the string handling
10169 packages.
10170
10171 @item Ada.Strings.Bounded (A.4.4)
10172 This package provides facilities for handling variable length
10173 strings.  The bounded model requires a maximum length.  It is thus
10174 somewhat more limited than the unbounded model, but avoids the use of
10175 dynamic allocation or finalization.
10176
10177 @item Ada.Strings.Fixed (A.4.3)
10178 This package provides facilities for handling fixed length strings.
10179
10180 @item Ada.Strings.Maps (A.4.2)
10181 This package provides facilities for handling character mappings and
10182 arbitrarily defined subsets of characters.  For instance it is useful in
10183 defining specialized translation tables.
10184
10185 @item Ada.Strings.Maps.Constants (A.4.6)
10186 This package provides a standard set of predefined mappings and
10187 predefined character sets.  For example, the standard upper to lower case
10188 conversion table is found in this package.  Note that upper to lower case
10189 conversion is non-trivial if you want to take the entire set of
10190 characters, including extended characters like E with an acute accent,
10191 into account.  You should use the mappings in this package (rather than
10192 adding 32 yourself) to do case mappings.
10193
10194 @item Ada.Strings.Unbounded (A.4.5)
10195 This package provides facilities for handling variable length
10196 strings.  The unbounded model allows arbitrary length strings, but
10197 requires the use of dynamic allocation and finalization.
10198
10199 @item Ada.Strings.Wide_Bounded (A.4.7)
10200 @itemx Ada.Strings.Wide_Fixed (A.4.7)
10201 @itemx Ada.Strings.Wide_Maps (A.4.7)
10202 @itemx Ada.Strings.Wide_Maps.Constants (A.4.7)
10203 @itemx Ada.Strings.Wide_Unbounded (A.4.7)
10204 These packages provide analogous capabilities to the corresponding
10205 packages without @samp{Wide_} in the name, but operate with the types
10206 @code{Wide_String} and @code{Wide_Character} instead of @code{String}
10207 and @code{Character}.
10208
10209 @item Ada.Synchronous_Task_Control (D.10)
10210 This package provides some standard facilities for controlling task
10211 communication in a synchronous manner.
10212
10213 @item Ada.Tags
10214 This package contains definitions for manipulation of the tags of tagged
10215 values.
10216
10217 @item Ada.Task_Attributes
10218 This package provides the capability of associating arbitrary
10219 task-specific data with separate tasks.
10220
10221 @item Ada.Text_IO
10222 This package provides basic text input-output capabilities for
10223 character, string and numeric data.  The subpackages of this
10224 package are listed next.
10225
10226 @item Ada.Text_IO.Decimal_IO
10227 Provides input-output facilities for decimal fixed-point types
10228
10229 @item Ada.Text_IO.Enumeration_IO
10230 Provides input-output facilities for enumeration types.
10231
10232 @item Ada.Text_IO.Fixed_IO
10233 Provides input-output facilities for ordinary fixed-point types.
10234
10235 @item Ada.Text_IO.Float_IO
10236 Provides input-output facilities for float types.  The following
10237 predefined instantiations of this generic package are available:
10238
10239 @table @code
10240 @item Short_Float
10241 @code{Short_Float_Text_IO}
10242 @item Float
10243 @code{Float_Text_IO}
10244 @item Long_Float
10245 @code{Long_Float_Text_IO}
10246 @end table
10247
10248 @item Ada.Text_IO.Integer_IO
10249 Provides input-output facilities for integer types.  The following
10250 predefined instantiations of this generic package are available:
10251
10252 @table @code
10253 @item Short_Short_Integer
10254 @code{Ada.Short_Short_Integer_Text_IO}
10255 @item Short_Integer
10256 @code{Ada.Short_Integer_Text_IO}
10257 @item Integer
10258 @code{Ada.Integer_Text_IO}
10259 @item Long_Integer
10260 @code{Ada.Long_Integer_Text_IO}
10261 @item Long_Long_Integer
10262 @code{Ada.Long_Long_Integer_Text_IO}
10263 @end table
10264
10265 @item Ada.Text_IO.Modular_IO
10266 Provides input-output facilities for modular (unsigned) types
10267
10268 @item Ada.Text_IO.Complex_IO (G.1.3)
10269 This package provides basic text input-output capabilities for complex
10270 data.
10271
10272 @item Ada.Text_IO.Editing (F.3.3)
10273 This package contains routines for edited output, analogous to the use
10274 of pictures in COBOL@.  The picture formats used by this package are a
10275 close copy of the facility in COBOL@.
10276
10277 @item Ada.Text_IO.Text_Streams (A.12.2)
10278 This package provides a facility that allows Text_IO files to be treated
10279 as streams, so that the stream attributes can be used for writing
10280 arbitrary data, including binary data, to Text_IO files.
10281
10282 @item Ada.Unchecked_Conversion (13.9)
10283 This generic package allows arbitrary conversion from one type to
10284 another of the same size, providing for breaking the type safety in
10285 special circumstances.
10286
10287 If the types have the same Size (more accurately the same Value_Size),
10288 then the effect is simply to transfer the bits from the source to the
10289 target type without any modification.  This usage is well defined, and
10290 for simple types whose representation is typically the same across
10291 all implementations, gives a portable method of performing such
10292 conversions.
10293
10294 If the types do not have the same size, then the result is implementation
10295 defined, and thus may be non-portable.  The following describes how GNAT
10296 handles such unchecked conversion cases.
10297
10298 If the types are of different sizes, and are both discrete types, then
10299 the effect is of a normal type conversion without any constraint checking.
10300 In particular if the result type has a larger size, the result will be
10301 zero or sign extended.  If the result type has a smaller size, the result
10302 will be truncated by ignoring high order bits.
10303
10304 If the types are of different sizes, and are not both discrete types,
10305 then the conversion works as though pointers were created to the source
10306 and target, and the pointer value is converted.  The effect is that bits
10307 are copied from successive low order storage units and bits of the source
10308 up to the length of the target type.
10309
10310 A warning is issued if the lengths differ, since the effect in this
10311 case is implementation dependent, and the above behavior may not match
10312 that of some other compiler.
10313
10314 A pointer to one type may be converted to a pointer to another type using
10315 unchecked conversion.  The only case in which the effect is undefined is
10316 when one or both pointers are pointers to unconstrained array types.  In
10317 this case, the bounds information may get incorrectly transferred, and in
10318 particular, GNAT uses double size pointers for such types, and it is
10319 meaningless to convert between such pointer types.  GNAT will issue a
10320 warning if the alignment of the target designated type is more strict
10321 than the alignment of the source designated type (since the result may
10322 be unaligned in this case).
10323
10324 A pointer other than a pointer to an unconstrained array type may be
10325 converted to and from System.Address.  Such usage is common in Ada 83
10326 programs, but note that Ada.Address_To_Access_Conversions is the
10327 preferred method of performing such conversions in Ada 95.  Neither
10328 unchecked conversion nor Ada.Address_To_Access_Conversions should be
10329 used in conjunction with pointers to unconstrained objects, since
10330 the bounds information cannot be handled correctly in this case.
10331
10332 @item Ada.Unchecked_Deallocation (13.11.2)
10333 This generic package allows explicit freeing of storage previously
10334 allocated by use of an allocator.
10335
10336 @item Ada.Wide_Text_IO (A.11)
10337 This package is similar to @code{Ada.Text_IO}, except that the external
10338 file supports wide character representations, and the internal types are
10339 @code{Wide_Character} and @code{Wide_String} instead of @code{Character}
10340 and @code{String}.  It contains generic subpackages listed next.
10341
10342 @item Ada.Wide_Text_IO.Decimal_IO
10343 Provides input-output facilities for decimal fixed-point types
10344
10345 @item Ada.Wide_Text_IO.Enumeration_IO
10346 Provides input-output facilities for enumeration types.
10347
10348 @item Ada.Wide_Text_IO.Fixed_IO
10349 Provides input-output facilities for ordinary fixed-point types.
10350
10351 @item Ada.Wide_Text_IO.Float_IO
10352 Provides input-output facilities for float types.  The following
10353 predefined instantiations of this generic package are available:
10354
10355 @table @code
10356 @item Short_Float
10357 @code{Short_Float_Wide_Text_IO}
10358 @item Float
10359 @code{Float_Wide_Text_IO}
10360 @item Long_Float
10361 @code{Long_Float_Wide_Text_IO}
10362 @end table
10363
10364 @item Ada.Wide_Text_IO.Integer_IO
10365 Provides input-output facilities for integer types.  The following
10366 predefined instantiations of this generic package are available:
10367
10368 @table @code
10369 @item Short_Short_Integer
10370 @code{Ada.Short_Short_Integer_Wide_Text_IO}
10371 @item Short_Integer
10372 @code{Ada.Short_Integer_Wide_Text_IO}
10373 @item Integer
10374 @code{Ada.Integer_Wide_Text_IO}
10375 @item Long_Integer
10376 @code{Ada.Long_Integer_Wide_Text_IO}
10377 @item Long_Long_Integer
10378 @code{Ada.Long_Long_Integer_Wide_Text_IO}
10379 @end table
10380
10381 @item Ada.Wide_Text_IO.Modular_IO
10382 Provides input-output facilities for modular (unsigned) types
10383
10384 @item Ada.Wide_Text_IO.Complex_IO (G.1.3)
10385 This package is similar to @code{Ada.Text_IO.Complex_IO}, except that the
10386 external file supports wide character representations.
10387
10388 @item Ada.Wide_Text_IO.Editing (F.3.4)
10389 This package is similar to @code{Ada.Text_IO.Editing}, except that the
10390 types are @code{Wide_Character} and @code{Wide_String} instead of
10391 @code{Character} and @code{String}.
10392
10393 @item Ada.Wide_Text_IO.Streams (A.12.3)
10394 This package is similar to @code{Ada.Text_IO.Streams}, except that the
10395 types are @code{Wide_Character} and @code{Wide_String} instead of
10396 @code{Character} and @code{String}.
10397 @end table
10398
10399 @node The Implementation of Standard I/O
10400 @chapter The Implementation of Standard I/O
10401
10402 @noindent
10403 GNAT implements all the required input-output facilities described in
10404 A.6 through A.14.  These sections of the Ada 95 reference manual describe the
10405 required behavior of these packages from the Ada point of view, and if
10406 you are writing a portable Ada program that does not need to know the
10407 exact manner in which Ada maps to the outside world when it comes to
10408 reading or writing external files, then you do not need to read this
10409 chapter.  As long as your files are all regular files (not pipes or
10410 devices), and as long as you write and read the files only from Ada, the
10411 description in the Ada 95 reference manual is sufficient.
10412
10413 However, if you want to do input-output to pipes or other devices, such
10414 as the keyboard or screen, or if the files you are dealing with are
10415 either generated by some other language, or to be read by some other
10416 language, then you need to know more about the details of how the GNAT
10417 implementation of these input-output facilities behaves.
10418
10419 In this chapter we give a detailed description of exactly how GNAT
10420 interfaces to the file system.  As always, the sources of the system are
10421 available to you for answering questions at an even more detailed level,
10422 but for most purposes the information in this chapter will suffice.
10423
10424 Another reason that you may need to know more about how input-output is
10425 implemented arises when you have a program written in mixed languages
10426 where, for example, files are shared between the C and Ada sections of
10427 the same program.  GNAT provides some additional facilities, in the form
10428 of additional child library packages, that facilitate this sharing, and
10429 these additional facilities are also described in this chapter.
10430
10431 @menu
10432 * Standard I/O Packages::
10433 * FORM Strings::
10434 * Direct_IO::
10435 * Sequential_IO::
10436 * Text_IO::
10437 * Wide_Text_IO::
10438 * Stream_IO::
10439 * Shared Files::
10440 * Open Modes::
10441 * Operations on C Streams::
10442 * Interfacing to C Streams::
10443 @end menu
10444
10445 @node Standard I/O Packages
10446 @section Standard I/O Packages
10447
10448 @noindent
10449 The Standard I/O packages described in Annex A for
10450
10451 @itemize @bullet
10452 @item
10453 Ada.Text_IO
10454 @item
10455 Ada.Text_IO.Complex_IO
10456 @item
10457 Ada.Text_IO.Text_Streams,
10458 @item
10459 Ada.Wide_Text_IO
10460 @item
10461 Ada.Wide_Text_IO.Complex_IO,
10462 @item
10463 Ada.Wide_Text_IO.Text_Streams
10464 @item
10465 Ada.Stream_IO
10466 @item
10467 Ada.Sequential_IO
10468 @item
10469 Ada.Direct_IO
10470 @end itemize
10471
10472 @noindent
10473 are implemented using the C
10474 library streams facility; where
10475
10476 @itemize @bullet
10477 @item
10478 All files are opened using @code{fopen}.
10479 @item
10480 All input/output operations use @code{fread}/@code{fwrite}.
10481 @end itemize
10482
10483 @noindent
10484 There is no internal buffering of any kind at the Ada library level.  The
10485 only buffering is that provided at the system level in the
10486 implementation of the C library routines that support streams.  This
10487 facilitates shared use of these streams by mixed language programs.
10488
10489 @node FORM Strings
10490 @section FORM Strings
10491
10492 @noindent
10493 The format of a FORM string in GNAT is:
10494
10495 @smallexample
10496 "keyword=value,keyword=value,@dots{},keyword=value"
10497 @end smallexample
10498
10499 @noindent
10500 where letters may be in upper or lower case, and there are no spaces
10501 between values.  The order of the entries is not important.  Currently
10502 there are two keywords defined.
10503
10504 @smallexample
10505 SHARED=[YES|NO]
10506 WCEM=[n|h|u|s\e]
10507 @end smallexample
10508
10509 @noindent
10510 The use of these parameters is described later in this section.
10511
10512 @node Direct_IO
10513 @section Direct_IO
10514
10515 @noindent
10516 Direct_IO can only be instantiated for definite types.  This is a
10517 restriction of the Ada language, which means that the records are fixed
10518 length (the length being determined by @code{@var{type}'Size}, rounded
10519 up to the next storage unit boundary if necessary).
10520
10521 The records of a Direct_IO file are simply written to the file in index
10522 sequence, with the first record starting at offset zero, and subsequent
10523 records following.  There is no control information of any kind.  For
10524 example, if 32-bit integers are being written, each record takes
10525 4-bytes, so the record at index @var{K} starts at offset
10526 (@var{K}@minus{}1)*4.
10527
10528 There is no limit on the size of Direct_IO files, they are expanded as
10529 necessary to accommodate whatever records are written to the file.
10530
10531 @node Sequential_IO
10532 @section Sequential_IO
10533
10534 @noindent
10535 Sequential_IO may be instantiated with either a definite (constrained)
10536 or indefinite (unconstrained) type.
10537
10538 For the definite type case, the elements written to the file are simply
10539 the memory images of the data values with no control information of any
10540 kind.  The resulting file should be read using the same type, no validity
10541 checking is performed on input.
10542
10543 For the indefinite type case, the elements written consist of two
10544 parts.  First is the size of the data item, written as the memory image
10545 of a @code{Interfaces.C.size_t} value, followed by the memory image of
10546 the data value.  The resulting file can only be read using the same
10547 (unconstrained) type.  Normal assignment checks are performed on these
10548 read operations, and if these checks fail, @code{Data_Error} is
10549 raised.  In particular, in the array case, the lengths must match, and in
10550 the variant record case, if the variable for a particular read operation
10551 is constrained, the discriminants must match.
10552
10553 Note that it is not possible to use Sequential_IO to write variable
10554 length array items, and then read the data back into different length
10555 arrays.  For example, the following will raise @code{Data_Error}:
10556
10557 @smallexample @c ada
10558  package IO is new Sequential_IO (String);
10559  F : IO.File_Type;
10560  S : String (1..4);
10561  @dots{}
10562  IO.Create (F)
10563  IO.Write (F, "hello!")
10564  IO.Reset (F, Mode=>In_File);
10565  IO.Read (F, S);
10566  Put_Line (S);
10567
10568 @end smallexample
10569
10570 @noindent
10571 On some Ada implementations, this will print @code{hell}, but the program is
10572 clearly incorrect, since there is only one element in the file, and that
10573 element is the string @code{hello!}.
10574
10575 In Ada 95, this kind of behavior can be legitimately achieved using
10576 Stream_IO, and this is the preferred mechanism.  In particular, the above
10577 program fragment rewritten to use Stream_IO will work correctly.
10578
10579 @node Text_IO
10580 @section Text_IO
10581
10582 @noindent
10583 Text_IO files consist of a stream of characters containing the following
10584 special control characters:
10585
10586 @smallexample
10587 LF (line feed, 16#0A#) Line Mark
10588 FF (form feed, 16#0C#) Page Mark
10589 @end smallexample
10590
10591 @noindent
10592 A canonical Text_IO file is defined as one in which the following
10593 conditions are met:
10594
10595 @itemize @bullet
10596 @item
10597 The character @code{LF} is used only as a line mark, i.e.@: to mark the end
10598 of the line.
10599
10600 @item
10601 The character @code{FF} is used only as a page mark, i.e.@: to mark the
10602 end of a page and consequently can appear only immediately following a
10603 @code{LF} (line mark) character.
10604
10605 @item
10606 The file ends with either @code{LF} (line mark) or @code{LF}-@code{FF}
10607 (line mark, page mark).  In the former case, the page mark is implicitly
10608 assumed to be present.
10609 @end itemize
10610
10611 @noindent
10612 A file written using Text_IO will be in canonical form provided that no
10613 explicit @code{LF} or @code{FF} characters are written using @code{Put}
10614 or @code{Put_Line}.  There will be no @code{FF} character at the end of
10615 the file unless an explicit @code{New_Page} operation was performed
10616 before closing the file.
10617
10618 A canonical Text_IO file that is a regular file, i.e.@: not a device or a
10619 pipe, can be read using any of the routines in Text_IO@.  The
10620 semantics in this case will be exactly as defined in the Ada 95 reference
10621 manual and all the routines in Text_IO are fully implemented.
10622
10623 A text file that does not meet the requirements for a canonical Text_IO
10624 file has one of the following:
10625
10626 @itemize @bullet
10627 @item
10628 The file contains @code{FF} characters not immediately following a
10629 @code{LF} character.
10630
10631 @item
10632 The file contains @code{LF} or @code{FF} characters written by
10633 @code{Put} or @code{Put_Line}, which are not logically considered to be
10634 line marks or page marks.
10635
10636 @item
10637 The file ends in a character other than @code{LF} or @code{FF},
10638 i.e.@: there is no explicit line mark or page mark at the end of the file.
10639 @end itemize
10640
10641 @noindent
10642 Text_IO can be used to read such non-standard text files but subprograms
10643 to do with line or page numbers do not have defined meanings.  In
10644 particular, a @code{FF} character that does not follow a @code{LF}
10645 character may or may not be treated as a page mark from the point of
10646 view of page and line numbering.  Every @code{LF} character is considered
10647 to end a line, and there is an implied @code{LF} character at the end of
10648 the file.
10649
10650 @menu
10651 * Text_IO Stream Pointer Positioning::
10652 * Text_IO Reading and Writing Non-Regular Files::
10653 * Get_Immediate::
10654 * Treating Text_IO Files as Streams::
10655 * Text_IO Extensions::
10656 * Text_IO Facilities for Unbounded Strings::
10657 @end menu
10658
10659 @node Text_IO Stream Pointer Positioning
10660 @subsection Stream Pointer Positioning
10661
10662 @noindent
10663 @code{Ada.Text_IO} has a definition of current position for a file that
10664 is being read.  No internal buffering occurs in Text_IO, and usually the
10665 physical position in the stream used to implement the file corresponds
10666 to this logical position defined by Text_IO@.  There are two exceptions:
10667
10668 @itemize @bullet
10669 @item
10670 After a call to @code{End_Of_Page} that returns @code{True}, the stream
10671 is positioned past the @code{LF} (line mark) that precedes the page
10672 mark.  Text_IO maintains an internal flag so that subsequent read
10673 operations properly handle the logical position which is unchanged by
10674 the @code{End_Of_Page} call.
10675
10676 @item
10677 After a call to @code{End_Of_File} that returns @code{True}, if the
10678 Text_IO file was positioned before the line mark at the end of file
10679 before the call, then the logical position is unchanged, but the stream
10680 is physically positioned right at the end of file (past the line mark,
10681 and past a possible page mark following the line mark.  Again Text_IO
10682 maintains internal flags so that subsequent read operations properly
10683 handle the logical position.
10684 @end itemize
10685
10686 @noindent
10687 These discrepancies have no effect on the observable behavior of
10688 Text_IO, but if a single Ada stream is shared between a C program and
10689 Ada program, or shared (using @samp{shared=yes} in the form string)
10690 between two Ada files, then the difference may be observable in some
10691 situations.
10692
10693 @node Text_IO Reading and Writing Non-Regular Files
10694 @subsection Reading and Writing Non-Regular Files
10695
10696 @noindent
10697 A non-regular file is a device (such as a keyboard), or a pipe.  Text_IO
10698 can be used for reading and writing.  Writing is not affected and the
10699 sequence of characters output is identical to the normal file case, but
10700 for reading, the behavior of Text_IO is modified to avoid undesirable
10701 look-ahead as follows:
10702
10703 An input file that is not a regular file is considered to have no page
10704 marks.  Any @code{Ascii.FF} characters (the character normally used for a
10705 page mark) appearing in the file are considered to be data
10706 characters.  In particular:
10707
10708 @itemize @bullet
10709 @item
10710 @code{Get_Line} and @code{Skip_Line} do not test for a page mark
10711 following a line mark.  If a page mark appears, it will be treated as a
10712 data character.
10713
10714 @item
10715 This avoids the need to wait for an extra character to be typed or
10716 entered from the pipe to complete one of these operations.
10717
10718 @item
10719 @code{End_Of_Page} always returns @code{False}
10720
10721 @item
10722 @code{End_Of_File} will return @code{False} if there is a page mark at
10723 the end of the file.
10724 @end itemize
10725
10726 @noindent
10727 Output to non-regular files is the same as for regular files.  Page marks
10728 may be written to non-regular files using @code{New_Page}, but as noted
10729 above they will not be treated as page marks on input if the output is
10730 piped to another Ada program.
10731
10732 Another important discrepancy when reading non-regular files is that the end
10733 of file indication is not ``sticky''.  If an end of file is entered, e.g.@: by
10734 pressing the @key{EOT} key,
10735 then end of file
10736 is signaled once (i.e.@: the test @code{End_Of_File}
10737 will yield @code{True}, or a read will
10738 raise @code{End_Error}), but then reading can resume
10739 to read data past that end of
10740 file indication, until another end of file indication is entered.
10741
10742 @node Get_Immediate
10743 @subsection Get_Immediate
10744 @cindex Get_Immediate
10745
10746 @noindent
10747 Get_Immediate returns the next character (including control characters)
10748 from the input file.  In particular, Get_Immediate will return LF or FF
10749 characters used as line marks or page marks.  Such operations leave the
10750 file positioned past the control character, and it is thus not treated
10751 as having its normal function.  This means that page, line and column
10752 counts after this kind of Get_Immediate call are set as though the mark
10753 did not occur.  In the case where a Get_Immediate leaves the file
10754 positioned between the line mark and page mark (which is not normally
10755 possible), it is undefined whether the FF character will be treated as a
10756 page mark.
10757
10758 @node Treating Text_IO Files as Streams
10759 @subsection Treating Text_IO Files as Streams
10760 @cindex Stream files
10761
10762 @noindent
10763 The package @code{Text_IO.Streams} allows a Text_IO file to be treated
10764 as a stream.  Data written to a Text_IO file in this stream mode is
10765 binary data.  If this binary data contains bytes 16#0A# (@code{LF}) or
10766 16#0C# (@code{FF}), the resulting file may have non-standard
10767 format.  Similarly if read operations are used to read from a Text_IO
10768 file treated as a stream, then @code{LF} and @code{FF} characters may be
10769 skipped and the effect is similar to that described above for
10770 @code{Get_Immediate}.
10771
10772 @node Text_IO Extensions
10773 @subsection Text_IO Extensions
10774 @cindex Text_IO extensions
10775
10776 @noindent
10777 A package GNAT.IO_Aux in the GNAT library provides some useful extensions
10778 to the standard @code{Text_IO} package:
10779
10780 @itemize @bullet
10781 @item function File_Exists (Name : String) return Boolean;
10782 Determines if a file of the given name exists.
10783
10784 @item function Get_Line return String;
10785 Reads a string from the standard input file.  The value returned is exactly
10786 the length of the line that was read.
10787
10788 @item function Get_Line (File : Ada.Text_IO.File_Type) return String;
10789 Similar, except that the parameter File specifies the file from which
10790 the string is to be read.
10791
10792 @end itemize
10793
10794 @node Text_IO Facilities for Unbounded Strings
10795 @subsection Text_IO Facilities for Unbounded Strings
10796 @cindex Text_IO for unbounded strings
10797 @cindex Unbounded_String, Text_IO operations
10798
10799 @noindent
10800 The package @code{Ada.Strings.Unbounded.Text_IO}
10801 in library files @code{a-suteio.ads/adb} contains some GNAT-specific
10802 subprograms useful for Text_IO operations on unbounded strings:
10803
10804 @itemize @bullet
10805
10806 @item function Get_Line (File : File_Type) return Unbounded_String;
10807 Reads a line from the specified file
10808 and returns the result as an unbounded string.
10809
10810 @item procedure Put (File : File_Type; U : Unbounded_String);
10811 Writes the value of the given unbounded string to the specified file
10812 Similar to the effect of
10813 @code{Put (To_String (U))} except that an extra copy is avoided.
10814
10815 @item procedure Put_Line (File : File_Type; U : Unbounded_String);
10816 Writes the value of the given unbounded string to the specified file,
10817 followed by a @code{New_Line}.
10818 Similar to the effect of @code{Put_Line (To_String (U))} except
10819 that an extra copy is avoided.
10820 @end itemize
10821
10822 @noindent
10823 In the above procedures, @code{File} is of type @code{Ada.Text_IO.File_Type}
10824 and is optional.  If the parameter is omitted, then the standard input or
10825 output file is referenced as appropriate.
10826
10827 The package @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} in library
10828 files @file{a-swuwti.ads} and @file{a-swuwti.adb} provides similar extended
10829 @code{Wide_Text_IO} functionality for unbounded wide strings.
10830
10831 @node Wide_Text_IO
10832 @section Wide_Text_IO
10833
10834 @noindent
10835 @code{Wide_Text_IO} is similar in most respects to Text_IO, except that
10836 both input and output files may contain special sequences that represent
10837 wide character values.  The encoding scheme for a given file may be
10838 specified using a FORM parameter:
10839
10840 @smallexample
10841 WCEM=@var{x}
10842 @end smallexample
10843
10844 @noindent
10845 as part of the FORM string (WCEM = wide character encoding method),
10846 where @var{x} is one of the following characters
10847
10848 @table @samp
10849 @item h
10850 Hex ESC encoding
10851 @item u
10852 Upper half encoding
10853 @item s
10854 Shift-JIS encoding
10855 @item e
10856 EUC Encoding
10857 @item 8
10858 UTF-8 encoding
10859 @item b
10860 Brackets encoding
10861 @end table
10862
10863 @noindent
10864 The encoding methods match those that
10865 can be used in a source
10866 program, but there is no requirement that the encoding method used for
10867 the source program be the same as the encoding method used for files,
10868 and different files may use different encoding methods.
10869
10870 The default encoding method for the standard files, and for opened files
10871 for which no WCEM parameter is given in the FORM string matches the
10872 wide character encoding specified for the main program (the default
10873 being brackets encoding if no coding method was specified with -gnatW).
10874
10875 @table @asis
10876 @item Hex Coding
10877 In this encoding, a wide character is represented by a five character
10878 sequence:
10879
10880 @smallexample
10881 ESC a b c d
10882 @end smallexample
10883
10884 @noindent
10885 where @var{a}, @var{b}, @var{c}, @var{d} are the four hexadecimal
10886 characters (using upper case letters) of the wide character code.  For
10887 example, ESC A345 is used to represent the wide character with code
10888 16#A345#.  This scheme is compatible with use of the full
10889 @code{Wide_Character} set.
10890
10891 @item Upper Half Coding
10892 The wide character with encoding 16#abcd#, where the upper bit is on
10893 (i.e.@: a is in the range 8-F) is represented as two bytes 16#ab# and
10894 16#cd#.  The second byte may never be a format control character, but is
10895 not required to be in the upper half.  This method can be also used for
10896 shift-JIS or EUC where the internal coding matches the external coding.
10897
10898 @item Shift JIS Coding
10899 A wide character is represented by a two character sequence 16#ab# and
10900 16#cd#, with the restrictions described for upper half encoding as
10901 described above.  The internal character code is the corresponding JIS
10902 character according to the standard algorithm for Shift-JIS
10903 conversion.  Only characters defined in the JIS code set table can be
10904 used with this encoding method.
10905
10906 @item EUC Coding
10907 A wide character is represented by a two character sequence 16#ab# and
10908 16#cd#, with both characters being in the upper half.  The internal
10909 character code is the corresponding JIS character according to the EUC
10910 encoding algorithm.  Only characters defined in the JIS code set table
10911 can be used with this encoding method.
10912
10913 @item UTF-8 Coding
10914 A wide character is represented using
10915 UCS Transformation Format 8 (UTF-8) as defined in Annex R of ISO
10916 10646-1/Am.2.  Depending on the character value, the representation
10917 is a one, two, or three byte sequence:
10918
10919 @smallexample
10920 16#0000#-16#007f#: 2#0xxxxxxx#
10921 16#0080#-16#07ff#: 2#110xxxxx# 2#10xxxxxx#
10922 16#0800#-16#ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
10923 @end smallexample
10924
10925 @noindent
10926 where the xxx bits correspond to the left-padded bits of the
10927 16-bit character value.  Note that all lower half ASCII characters
10928 are represented as ASCII bytes and all upper half characters and
10929 other wide characters are represented as sequences of upper-half
10930 (The full UTF-8 scheme allows for encoding 31-bit characters as
10931 6-byte sequences, but in this implementation, all UTF-8 sequences
10932 of four or more bytes length will raise a Constraint_Error, as
10933 will all invalid UTF-8 sequences.)
10934
10935 @item Brackets Coding
10936 In this encoding, a wide character is represented by the following eight
10937 character sequence:
10938
10939 @smallexample
10940 [ " a b c d " ]
10941 @end smallexample
10942
10943 @noindent
10944 where @code{a}, @code{b}, @code{c}, @code{d} are the four hexadecimal
10945 characters (using uppercase letters) of the wide character code.  For
10946 example, @code{["A345"]} is used to represent the wide character with code
10947 @code{16#A345#}.
10948 This scheme is compatible with use of the full Wide_Character set.
10949 On input, brackets coding can also be used for upper half characters,
10950 e.g.@: @code{["C1"]} for lower case a.  However, on output, brackets notation
10951 is only used for wide characters with a code greater than @code{16#FF#}.
10952
10953 @end table
10954
10955 @noindent
10956 For the coding schemes other than Hex and Brackets encoding,
10957 not all wide character
10958 values can be represented.  An attempt to output a character that cannot
10959 be represented using the encoding scheme for the file causes
10960 Constraint_Error to be raised.  An invalid wide character sequence on
10961 input also causes Constraint_Error to be raised.
10962
10963 @menu
10964 * Wide_Text_IO Stream Pointer Positioning::
10965 * Wide_Text_IO Reading and Writing Non-Regular Files::
10966 @end menu
10967
10968 @node Wide_Text_IO Stream Pointer Positioning
10969 @subsection Stream Pointer Positioning
10970
10971 @noindent
10972 @code{Ada.Wide_Text_IO} is similar to @code{Ada.Text_IO} in its handling
10973 of stream pointer positioning (@pxref{Text_IO}).  There is one additional
10974 case:
10975
10976 If @code{Ada.Wide_Text_IO.Look_Ahead} reads a character outside the
10977 normal lower ASCII set (i.e.@: a character in the range:
10978
10979 @smallexample @c ada
10980 Wide_Character'Val (16#0080#) .. Wide_Character'Val (16#FFFF#)
10981 @end smallexample
10982
10983 @noindent
10984 then although the logical position of the file pointer is unchanged by
10985 the @code{Look_Ahead} call, the stream is physically positioned past the
10986 wide character sequence.  Again this is to avoid the need for buffering
10987 or backup, and all @code{Wide_Text_IO} routines check the internal
10988 indication that this situation has occurred so that this is not visible
10989 to a normal program using @code{Wide_Text_IO}.  However, this discrepancy
10990 can be observed if the wide text file shares a stream with another file.
10991
10992 @node Wide_Text_IO Reading and Writing Non-Regular Files
10993 @subsection Reading and Writing Non-Regular Files
10994
10995 @noindent
10996 As in the case of Text_IO, when a non-regular file is read, it is
10997 assumed that the file contains no page marks (any form characters are
10998 treated as data characters), and @code{End_Of_Page} always returns
10999 @code{False}.  Similarly, the end of file indication is not sticky, so
11000 it is possible to read beyond an end of file.
11001
11002 @node Stream_IO
11003 @section Stream_IO
11004
11005 @noindent
11006 A stream file is a sequence of bytes, where individual elements are
11007 written to the file as described in the Ada 95 reference manual.  The type
11008 @code{Stream_Element} is simply a byte.  There are two ways to read or
11009 write a stream file.
11010
11011 @itemize @bullet
11012 @item
11013 The operations @code{Read} and @code{Write} directly read or write a
11014 sequence of stream elements with no control information.
11015
11016 @item
11017 The stream attributes applied to a stream file transfer data in the
11018 manner described for stream attributes.
11019 @end itemize
11020
11021 @node Shared Files
11022 @section Shared Files
11023
11024 @noindent
11025 Section A.14 of the Ada 95 Reference Manual allows implementations to
11026 provide a wide variety of behavior if an attempt is made to access the
11027 same external file with two or more internal files.
11028
11029 To provide a full range of functionality, while at the same time
11030 minimizing the problems of portability caused by this implementation
11031 dependence, GNAT handles file sharing as follows:
11032
11033 @itemize @bullet
11034 @item
11035 In the absence of a @samp{shared=@var{xxx}} form parameter, an attempt
11036 to open two or more files with the same full name is considered an error
11037 and is not supported.  The exception @code{Use_Error} will be
11038 raised.  Note that a file that is not explicitly closed by the program
11039 remains open until the program terminates.
11040
11041 @item
11042 If the form parameter @samp{shared=no} appears in the form string, the
11043 file can be opened or created with its own separate stream identifier,
11044 regardless of whether other files sharing the same external file are
11045 opened.  The exact effect depends on how the C stream routines handle
11046 multiple accesses to the same external files using separate streams.
11047
11048 @item
11049 If the form parameter @samp{shared=yes} appears in the form string for
11050 each of two or more files opened using the same full name, the same
11051 stream is shared between these files, and the semantics are as described
11052 in Ada 95 Reference Manual, Section A.14.
11053 @end itemize
11054
11055 @noindent
11056 When a program that opens multiple files with the same name is ported
11057 from another Ada compiler to GNAT, the effect will be that
11058 @code{Use_Error} is raised.
11059
11060 The documentation of the original compiler and the documentation of the
11061 program should then be examined to determine if file sharing was
11062 expected, and @samp{shared=@var{xxx}} parameters added to @code{Open}
11063 and @code{Create} calls as required.
11064
11065 When a program is ported from GNAT to some other Ada compiler, no
11066 special attention is required unless the @samp{shared=@var{xxx}} form
11067 parameter is used in the program.  In this case, you must examine the
11068 documentation of the new compiler to see if it supports the required
11069 file sharing semantics, and form strings modified appropriately.  Of
11070 course it may be the case that the program cannot be ported if the
11071 target compiler does not support the required functionality.  The best
11072 approach in writing portable code is to avoid file sharing (and hence
11073 the use of the @samp{shared=@var{xxx}} parameter in the form string)
11074 completely.
11075
11076 One common use of file sharing in Ada 83 is the use of instantiations of
11077 Sequential_IO on the same file with different types, to achieve
11078 heterogeneous input-output.  Although this approach will work in GNAT if
11079 @samp{shared=yes} is specified, it is preferable in Ada 95 to use Stream_IO
11080 for this purpose (using the stream attributes)
11081
11082 @node Open Modes
11083 @section Open Modes
11084
11085 @noindent
11086 @code{Open} and @code{Create} calls result in a call to @code{fopen}
11087 using the mode shown in the following table:
11088
11089 @sp 2
11090 @center @code{Open} and @code{Create} Call Modes
11091 @smallexample
11092                                @b{OPEN }           @b{CREATE}
11093 Append_File                    "r+"             "w+"
11094 In_File                        "r"              "w+"
11095 Out_File (Direct_IO)           "r+"             "w"
11096 Out_File (all other cases)     "w"              "w"
11097 Inout_File                     "r+"             "w+"
11098 @end smallexample
11099
11100 @noindent
11101 If text file translation is required, then either @samp{b} or @samp{t}
11102 is added to the mode, depending on the setting of Text.  Text file
11103 translation refers to the mapping of CR/LF sequences in an external file
11104 to LF characters internally.  This mapping only occurs in DOS and
11105 DOS-like systems, and is not relevant to other systems.
11106
11107 A special case occurs with Stream_IO@.  As shown in the above table, the
11108 file is initially opened in @samp{r} or @samp{w} mode for the
11109 @code{In_File} and @code{Out_File} cases.  If a @code{Set_Mode} operation
11110 subsequently requires switching from reading to writing or vice-versa,
11111 then the file is reopened in @samp{r+} mode to permit the required operation.
11112
11113 @node Operations on C Streams
11114 @section Operations on C Streams
11115 The package @code{Interfaces.C_Streams} provides an Ada program with direct
11116 access to the C library functions for operations on C streams:
11117
11118 @smallexample @c adanocomment
11119 package Interfaces.C_Streams is
11120   -- Note: the reason we do not use the types that are in
11121   -- Interfaces.C is that we want to avoid dragging in the
11122   -- code in this unit if possible.
11123   subtype chars is System.Address;
11124   -- Pointer to null-terminated array of characters
11125   subtype FILEs is System.Address;
11126   -- Corresponds to the C type FILE*
11127   subtype voids is System.Address;
11128   -- Corresponds to the C type void*
11129   subtype int is Integer;
11130   subtype long is Long_Integer;
11131   -- Note: the above types are subtypes deliberately, and it
11132   -- is part of this spec that the above correspondences are
11133   -- guaranteed.  This means that it is legitimate to, for
11134   -- example, use Integer instead of int.  We provide these
11135   -- synonyms for clarity, but in some cases it may be
11136   -- convenient to use the underlying types (for example to
11137   -- avoid an unnecessary dependency of a spec on the spec
11138   -- of this unit).
11139   type size_t is mod 2 ** Standard'Address_Size;
11140   NULL_Stream : constant FILEs;
11141   -- Value returned (NULL in C) to indicate an
11142   -- fdopen/fopen/tmpfile error
11143   ----------------------------------
11144   -- Constants Defined in stdio.h --
11145   ----------------------------------
11146   EOF : constant int;
11147   -- Used by a number of routines to indicate error or
11148   -- end of file
11149   IOFBF : constant int;
11150   IOLBF : constant int;
11151   IONBF : constant int;
11152   -- Used to indicate buffering mode for setvbuf call
11153   SEEK_CUR : constant int;
11154   SEEK_END : constant int;
11155   SEEK_SET : constant int;
11156   -- Used to indicate origin for fseek call
11157   function stdin return FILEs;
11158   function stdout return FILEs;
11159   function stderr return FILEs;
11160   -- Streams associated with standard files
11161   --------------------------
11162   -- Standard C functions --
11163   --------------------------
11164   -- The functions selected below are ones that are
11165   -- available in DOS, OS/2, UNIX and Xenix (but not
11166   -- necessarily in ANSI C).  These are very thin interfaces
11167   -- which copy exactly the C headers.  For more
11168   -- documentation on these functions, see the Microsoft C
11169   -- "Run-Time Library Reference" (Microsoft Press, 1990,
11170   -- ISBN 1-55615-225-6), which includes useful information
11171   -- on system compatibility.
11172   procedure clearerr (stream : FILEs);
11173   function fclose (stream : FILEs) return int;
11174   function fdopen (handle : int; mode : chars) return FILEs;
11175   function feof (stream : FILEs) return int;
11176   function ferror (stream : FILEs) return int;
11177   function fflush (stream : FILEs) return int;
11178   function fgetc (stream : FILEs) return int;
11179   function fgets (strng : chars; n : int; stream : FILEs)
11180       return chars;
11181   function fileno (stream : FILEs) return int;
11182   function fopen (filename : chars; Mode : chars)
11183       return FILEs;
11184   -- Note: to maintain target independence, use
11185   -- text_translation_required, a boolean variable defined in
11186   -- a-sysdep.c to deal with the target dependent text
11187   -- translation requirement.  If this variable is set,
11188   -- then  b/t should be appended to the standard mode
11189   -- argument to set the text translation mode off or on
11190   -- as required.
11191   function fputc (C : int; stream : FILEs) return int;
11192   function fputs (Strng : chars; Stream : FILEs) return int;
11193   function fread
11194      (buffer : voids;
11195       size : size_t;
11196       count : size_t;
11197       stream : FILEs)
11198       return size_t;
11199   function freopen
11200      (filename : chars;
11201       mode : chars;
11202       stream : FILEs)
11203       return FILEs;
11204   function fseek
11205      (stream : FILEs;
11206       offset : long;
11207       origin : int)
11208       return int;
11209   function ftell (stream : FILEs) return long;
11210   function fwrite
11211      (buffer : voids;
11212       size : size_t;
11213       count : size_t;
11214       stream : FILEs)
11215       return size_t;
11216   function isatty (handle : int) return int;
11217   procedure mktemp (template : chars);
11218   -- The return value (which is just a pointer to template)
11219   -- is discarded
11220   procedure rewind (stream : FILEs);
11221   function rmtmp return int;
11222   function setvbuf
11223      (stream : FILEs;
11224       buffer : chars;
11225       mode : int;
11226       size : size_t)
11227       return int;
11228
11229   function tmpfile return FILEs;
11230   function ungetc (c : int; stream : FILEs) return int;
11231   function unlink (filename : chars) return int;
11232   ---------------------
11233   -- Extra functions --
11234   ---------------------
11235   -- These functions supply slightly thicker bindings than
11236   -- those above.  They are derived from functions in the
11237   -- C Run-Time Library, but may do a bit more work than
11238   -- just directly calling one of the Library functions.
11239   function is_regular_file (handle : int) return int;
11240   -- Tests if given handle is for a regular file (result 1)
11241   -- or for a non-regular file (pipe or device, result 0).
11242   ---------------------------------
11243   -- Control of Text/Binary Mode --
11244   ---------------------------------
11245   -- If text_translation_required is true, then the following
11246   -- functions may be used to dynamically switch a file from
11247   -- binary to text mode or vice versa.  These functions have
11248   -- no effect if text_translation_required is false (i.e.  in
11249   -- normal UNIX mode).  Use fileno to get a stream handle.
11250   procedure set_binary_mode (handle : int);
11251   procedure set_text_mode (handle : int);
11252   ----------------------------
11253   -- Full Path Name support --
11254   ----------------------------
11255   procedure full_name (nam : chars; buffer : chars);
11256   -- Given a NUL terminated string representing a file
11257   -- name, returns in buffer a NUL terminated string
11258   -- representing the full path name for the file name.
11259   -- On systems where it is relevant the   drive is also
11260   -- part of the full path name.  It is the responsibility
11261   -- of the caller to pass an actual parameter for buffer
11262   -- that is big enough for any full path name.  Use
11263   -- max_path_len given below as the size of buffer.
11264   max_path_len : integer;
11265   -- Maximum length of an allowable full path name on the
11266   -- system, including a terminating NUL character.
11267 end Interfaces.C_Streams;
11268 @end smallexample
11269
11270 @node Interfacing to C Streams
11271 @section Interfacing to C Streams
11272
11273 @noindent
11274 The packages in this section permit interfacing Ada files to C Stream
11275 operations.
11276
11277 @smallexample @c ada
11278  with Interfaces.C_Streams;
11279  package Ada.Sequential_IO.C_Streams is
11280     function C_Stream (F : File_Type)
11281        return Interfaces.C_Streams.FILEs;
11282     procedure Open
11283       (File : in out File_Type;
11284        Mode : in File_Mode;
11285        C_Stream : in Interfaces.C_Streams.FILEs;
11286        Form : in String := "");
11287  end Ada.Sequential_IO.C_Streams;
11288
11289   with Interfaces.C_Streams;
11290   package Ada.Direct_IO.C_Streams is
11291      function C_Stream (F : File_Type)
11292         return Interfaces.C_Streams.FILEs;
11293      procedure Open
11294        (File : in out File_Type;
11295         Mode : in File_Mode;
11296         C_Stream : in Interfaces.C_Streams.FILEs;
11297         Form : in String := "");
11298   end Ada.Direct_IO.C_Streams;
11299
11300   with Interfaces.C_Streams;
11301   package Ada.Text_IO.C_Streams is
11302      function C_Stream (F : File_Type)
11303         return Interfaces.C_Streams.FILEs;
11304      procedure Open
11305        (File : in out File_Type;
11306         Mode : in File_Mode;
11307         C_Stream : in Interfaces.C_Streams.FILEs;
11308         Form : in String := "");
11309   end Ada.Text_IO.C_Streams;
11310
11311   with Interfaces.C_Streams;
11312   package Ada.Wide_Text_IO.C_Streams is
11313      function C_Stream (F : File_Type)
11314         return Interfaces.C_Streams.FILEs;
11315      procedure Open
11316        (File : in out File_Type;
11317         Mode : in File_Mode;
11318         C_Stream : in Interfaces.C_Streams.FILEs;
11319         Form : in String := "");
11320  end Ada.Wide_Text_IO.C_Streams;
11321
11322  with Interfaces.C_Streams;
11323  package Ada.Stream_IO.C_Streams is
11324     function C_Stream (F : File_Type)
11325        return Interfaces.C_Streams.FILEs;
11326     procedure Open
11327       (File : in out File_Type;
11328        Mode : in File_Mode;
11329        C_Stream : in Interfaces.C_Streams.FILEs;
11330        Form : in String := "");
11331  end Ada.Stream_IO.C_Streams;
11332 @end smallexample
11333
11334 @noindent
11335 In each of these five packages, the @code{C_Stream} function obtains the
11336 @code{FILE} pointer from a currently opened Ada file.  It is then
11337 possible to use the @code{Interfaces.C_Streams} package to operate on
11338 this stream, or the stream can be passed to a C program which can
11339 operate on it directly.  Of course the program is responsible for
11340 ensuring that only appropriate sequences of operations are executed.
11341
11342 One particular use of relevance to an Ada program is that the
11343 @code{setvbuf} function can be used to control the buffering of the
11344 stream used by an Ada file.  In the absence of such a call the standard
11345 default buffering is used.
11346
11347 The @code{Open} procedures in these packages open a file giving an
11348 existing C Stream instead of a file name.  Typically this stream is
11349 imported from a C program, allowing an Ada file to operate on an
11350 existing C file.
11351
11352 @node The GNAT Library
11353 @chapter The GNAT Library
11354
11355 @noindent
11356 The GNAT library contains a number of general and special purpose packages.
11357 It represents functionality that the GNAT developers have found useful, and
11358 which is made available to GNAT users.  The packages described here are fully
11359 supported, and upwards compatibility will be maintained in future releases,
11360 so you can use these facilities with the confidence that the same functionality
11361 will be available in future releases.
11362
11363 The chapter here simply gives a brief summary of the facilities available.
11364 The full documentation is found in the spec file for the package.  The full
11365 sources of these library packages, including both spec and body, are provided
11366 with all GNAT releases.  For example, to find out the full specifications of
11367 the SPITBOL pattern matching capability, including a full tutorial and
11368 extensive examples, look in the @file{g-spipat.ads} file in the library.
11369
11370 For each entry here, the package name (as it would appear in a @code{with}
11371 clause) is given, followed by the name of the corresponding spec file in
11372 parentheses.  The packages are children in four hierarchies, @code{Ada},
11373 @code{Interfaces}, @code{System}, and @code{GNAT}, the latter being a
11374 GNAT-specific hierarchy.
11375
11376 Note that an application program should only use packages in one of these
11377 four hierarchies if the package is defined in the Ada Reference Manual,
11378 or is listed in this section of the GNAT Programmers Reference Manual.
11379 All other units should be considered internal implementation units and
11380 should not be directly @code{with}'ed by application code.  The use of
11381 a @code{with} statement that references one of these internal implementation
11382 units makes an application potentially dependent on changes in versions
11383 of GNAT, and will generate a warning message.
11384
11385 @menu
11386 * Ada.Characters.Latin_9 (a-chlat9.ads)::
11387 * Ada.Characters.Wide_Latin_1 (a-cwila1.ads)::
11388 * Ada.Characters.Wide_Latin_9 (a-cwila9.ads)::
11389 * Ada.Command_Line.Remove (a-colire.ads)::
11390 * Ada.Command_Line.Environment (a-colien.ads)::
11391 * Ada.Direct_IO.C_Streams (a-diocst.ads)::
11392 * Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)::
11393 * Ada.Exceptions.Traceback (a-exctra.ads)::
11394 * Ada.Sequential_IO.C_Streams (a-siocst.ads)::
11395 * Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)::
11396 * Ada.Strings.Unbounded.Text_IO (a-suteio.ads)::
11397 * Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)::
11398 * Ada.Text_IO.C_Streams (a-tiocst.ads)::
11399 * Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)::
11400 * GNAT.Array_Split (g-arrspl.ads)::
11401 * GNAT.AWK (g-awk.ads)::
11402 * GNAT.Bounded_Buffers (g-boubuf.ads)::
11403 * GNAT.Bounded_Mailboxes (g-boumai.ads)::
11404 * GNAT.Bubble_Sort (g-bubsor.ads)::
11405 * GNAT.Bubble_Sort_A (g-busora.ads)::
11406 * GNAT.Bubble_Sort_G (g-busorg.ads)::
11407 * GNAT.Calendar (g-calend.ads)::
11408 * GNAT.Calendar.Time_IO (g-catiio.ads)::
11409 * GNAT.CRC32 (g-crc32.ads)::
11410 * GNAT.Case_Util (g-casuti.ads)::
11411 * GNAT.CGI (g-cgi.ads)::
11412 * GNAT.CGI.Cookie (g-cgicoo.ads)::
11413 * GNAT.CGI.Debug (g-cgideb.ads)::
11414 * GNAT.Command_Line (g-comlin.ads)::
11415 * GNAT.Compiler_Version (g-comver.ads)::
11416 * GNAT.Ctrl_C (g-ctrl_c.ads)::
11417 * GNAT.Current_Exception (g-curexc.ads)::
11418 * GNAT.Debug_Pools (g-debpoo.ads)::
11419 * GNAT.Debug_Utilities (g-debuti.ads)::
11420 * GNAT.Directory_Operations (g-dirope.ads)::
11421 * GNAT.Dynamic_HTables (g-dynhta.ads)::
11422 * GNAT.Dynamic_Tables (g-dyntab.ads)::
11423 * GNAT.Exception_Actions (g-excact.ads)::
11424 * GNAT.Exception_Traces (g-exctra.ads)::
11425 * GNAT.Exceptions (g-except.ads)::
11426 * GNAT.Expect (g-expect.ads)::
11427 * GNAT.Float_Control (g-flocon.ads)::
11428 * GNAT.Heap_Sort (g-heasor.ads)::
11429 * GNAT.Heap_Sort_A (g-hesora.ads)::
11430 * GNAT.Heap_Sort_G (g-hesorg.ads)::
11431 * GNAT.HTable (g-htable.ads)::
11432 * GNAT.IO (g-io.ads)::
11433 * GNAT.IO_Aux (g-io_aux.ads)::
11434 * GNAT.Lock_Files (g-locfil.ads)::
11435 * GNAT.MD5 (g-md5.ads)::
11436 * GNAT.Memory_Dump (g-memdum.ads)::
11437 * GNAT.Most_Recent_Exception (g-moreex.ads)::
11438 * GNAT.OS_Lib (g-os_lib.ads)::
11439 * GNAT.Perfect_Hash.Generators (g-pehage.ads)::
11440 * GNAT.Regexp (g-regexp.ads)::
11441 * GNAT.Registry (g-regist.ads)::
11442 * GNAT.Regpat (g-regpat.ads)::
11443 * GNAT.Secondary_Stack_Info (g-sestin.ads)::
11444 * GNAT.Semaphores (g-semaph.ads)::
11445 * GNAT.Signals (g-signal.ads)::
11446 * GNAT.Sockets (g-socket.ads)::
11447 * GNAT.Source_Info (g-souinf.ads)::
11448 * GNAT.Spell_Checker (g-speche.ads)::
11449 * GNAT.Spitbol.Patterns (g-spipat.ads)::
11450 * GNAT.Spitbol (g-spitbo.ads)::
11451 * GNAT.Spitbol.Table_Boolean (g-sptabo.ads)::
11452 * GNAT.Spitbol.Table_Integer (g-sptain.ads)::
11453 * GNAT.Spitbol.Table_VString (g-sptavs.ads)::
11454 * GNAT.Strings (g-string.ads)::
11455 * GNAT.String_Split (g-strspl.ads)::
11456 * GNAT.Table (g-table.ads)::
11457 * GNAT.Task_Lock (g-tasloc.ads)::
11458 * GNAT.Threads (g-thread.ads)::
11459 * GNAT.Traceback (g-traceb.ads)::
11460 * GNAT.Traceback.Symbolic (g-trasym.ads)::
11461 * GNAT.Wide_String_Split (g-wistsp.ads)::
11462 * Interfaces.C.Extensions (i-cexten.ads)::
11463 * Interfaces.C.Streams (i-cstrea.ads)::
11464 * Interfaces.CPP (i-cpp.ads)::
11465 * Interfaces.Os2lib (i-os2lib.ads)::
11466 * Interfaces.Os2lib.Errors (i-os2err.ads)::
11467 * Interfaces.Os2lib.Synchronization (i-os2syn.ads)::
11468 * Interfaces.Os2lib.Threads (i-os2thr.ads)::
11469 * Interfaces.Packed_Decimal (i-pacdec.ads)::
11470 * Interfaces.VxWorks (i-vxwork.ads)::
11471 * Interfaces.VxWorks.IO (i-vxwoio.ads)::
11472 * System.Address_Image (s-addima.ads)::
11473 * System.Assertions (s-assert.ads)::
11474 * System.Memory (s-memory.ads)::
11475 * System.Partition_Interface (s-parint.ads)::
11476 * System.Restrictions (s-restri.ads)::
11477 * System.Rident (s-rident.ads)::
11478 * System.Task_Info (s-tasinf.ads)::
11479 * System.Wch_Cnv (s-wchcnv.ads)::
11480 * System.Wch_Con (s-wchcon.ads)::
11481 @end menu
11482
11483 @node Ada.Characters.Latin_9 (a-chlat9.ads)
11484 @section @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
11485 @cindex @code{Ada.Characters.Latin_9} (@file{a-chlat9.ads})
11486 @cindex Latin_9 constants for Character
11487
11488 @noindent
11489 This child of @code{Ada.Characters}
11490 provides a set of definitions corresponding to those in the
11491 RM-defined package @code{Ada.Characters.Latin_1} but with the
11492 few modifications required for @code{Latin-9}
11493 The provision of such a package
11494 is specifically authorized by the Ada Reference Manual
11495 (RM A.3(27)).
11496
11497 @node Ada.Characters.Wide_Latin_1 (a-cwila1.ads)
11498 @section @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
11499 @cindex @code{Ada.Characters.Wide_Latin_1} (@file{a-cwila1.ads})
11500 @cindex Latin_1 constants for Wide_Character
11501
11502 @noindent
11503 This child of @code{Ada.Characters}
11504 provides a set of definitions corresponding to those in the
11505 RM-defined package @code{Ada.Characters.Latin_1} but with the
11506 types of the constants being @code{Wide_Character}
11507 instead of @code{Character}.  The provision of such a package
11508 is specifically authorized by the Ada Reference Manual
11509 (RM A.3(27)).
11510
11511 @node Ada.Characters.Wide_Latin_9 (a-cwila9.ads)
11512 @section @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
11513 @cindex @code{Ada.Characters.Wide_Latin_9} (@file{a-cwila1.ads})
11514 @cindex Latin_9 constants for Wide_Character
11515
11516 @noindent
11517 This child of @code{Ada.Characters}
11518 provides a set of definitions corresponding to those in the
11519 GNAT defined package @code{Ada.Characters.Latin_9} but with the
11520 types of the constants being @code{Wide_Character}
11521 instead of @code{Character}.  The provision of such a package
11522 is specifically authorized by the Ada Reference Manual
11523 (RM A.3(27)).
11524
11525 @node Ada.Command_Line.Remove (a-colire.ads)
11526 @section @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
11527 @cindex @code{Ada.Command_Line.Remove} (@file{a-colire.ads})
11528 @cindex Removing command line arguments
11529 @cindex Command line, argument removal
11530
11531 @noindent
11532 This child of @code{Ada.Command_Line}
11533 provides a mechanism for logically removing
11534 arguments from the argument list.  Once removed, an argument is not visible
11535 to further calls on the subprograms in @code{Ada.Command_Line} will not
11536 see the removed argument.
11537
11538 @node Ada.Command_Line.Environment (a-colien.ads)
11539 @section @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
11540 @cindex @code{Ada.Command_Line.Environment} (@file{a-colien.ads})
11541 @cindex Environment entries
11542
11543 @noindent
11544 This child of @code{Ada.Command_Line}
11545 provides a mechanism for obtaining environment values on systems
11546 where this concept makes sense.
11547
11548 @node Ada.Direct_IO.C_Streams (a-diocst.ads)
11549 @section @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
11550 @cindex @code{Ada.Direct_IO.C_Streams} (@file{a-diocst.ads})
11551 @cindex C Streams, Interfacing with Direct_IO
11552
11553 @noindent
11554 This package provides subprograms that allow interfacing between
11555 C streams and @code{Direct_IO}.  The stream identifier can be
11556 extracted from a file opened on the Ada side, and an Ada file
11557 can be constructed from a stream opened on the C side.
11558
11559 @node Ada.Exceptions.Is_Null_Occurrence (a-einuoc.ads)
11560 @section @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
11561 @cindex @code{Ada.Exceptions.Is_Null_Occurrence} (@file{a-einuoc.ads})
11562 @cindex Null_Occurrence, testing for
11563
11564 @noindent
11565 This child subprogram provides a way of testing for the null
11566 exception occurrence (@code{Null_Occurrence}) without raising
11567 an exception.
11568
11569 @node Ada.Exceptions.Traceback (a-exctra.ads)
11570 @section @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
11571 @cindex @code{Ada.Exceptions.Traceback} (@file{a-exctra.ads})
11572 @cindex Traceback for Exception Occurrence
11573
11574 @noindent
11575 This child package provides the subprogram (@code{Tracebacks}) to
11576 give a traceback array of addresses based on an exception
11577 occurrence.
11578
11579 @node Ada.Sequential_IO.C_Streams (a-siocst.ads)
11580 @section @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
11581 @cindex @code{Ada.Sequential_IO.C_Streams} (@file{a-siocst.ads})
11582 @cindex C Streams, Interfacing with Sequential_IO
11583
11584 @noindent
11585 This package provides subprograms that allow interfacing between
11586 C streams and @code{Sequential_IO}.  The stream identifier can be
11587 extracted from a file opened on the Ada side, and an Ada file
11588 can be constructed from a stream opened on the C side.
11589
11590 @node Ada.Streams.Stream_IO.C_Streams (a-ssicst.ads)
11591 @section @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
11592 @cindex @code{Ada.Streams.Stream_IO.C_Streams} (@file{a-ssicst.ads})
11593 @cindex C Streams, Interfacing with Stream_IO
11594
11595 @noindent
11596 This package provides subprograms that allow interfacing between
11597 C streams and @code{Stream_IO}.  The stream identifier can be
11598 extracted from a file opened on the Ada side, and an Ada file
11599 can be constructed from a stream opened on the C side.
11600
11601 @node Ada.Strings.Unbounded.Text_IO (a-suteio.ads)
11602 @section @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
11603 @cindex @code{Ada.Strings.Unbounded.Text_IO} (@file{a-suteio.ads})
11604 @cindex @code{Unbounded_String}, IO support
11605 @cindex @code{Text_IO}, extensions for unbounded strings
11606
11607 @noindent
11608 This package provides subprograms for Text_IO for unbounded
11609 strings, avoiding the necessity for an intermediate operation
11610 with ordinary strings.
11611
11612 @node Ada.Strings.Wide_Unbounded.Wide_Text_IO (a-swuwti.ads)
11613 @section @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
11614 @cindex @code{Ada.Strings.Wide_Unbounded.Wide_Text_IO} (@file{a-swuwti.ads})
11615 @cindex @code{Unbounded_Wide_String}, IO support
11616 @cindex @code{Text_IO}, extensions for unbounded wide strings
11617
11618 @noindent
11619 This package provides subprograms for Text_IO for unbounded
11620 wide strings, avoiding the necessity for an intermediate operation
11621 with ordinary wide strings.
11622
11623 @node Ada.Text_IO.C_Streams (a-tiocst.ads)
11624 @section @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
11625 @cindex @code{Ada.Text_IO.C_Streams} (@file{a-tiocst.ads})
11626 @cindex C Streams, Interfacing with @code{Text_IO}
11627
11628 @noindent
11629 This package provides subprograms that allow interfacing between
11630 C streams and @code{Text_IO}.  The stream identifier can be
11631 extracted from a file opened on the Ada side, and an Ada file
11632 can be constructed from a stream opened on the C side.
11633
11634 @node Ada.Wide_Text_IO.C_Streams (a-wtcstr.ads)
11635 @section @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
11636 @cindex @code{Ada.Wide_Text_IO.C_Streams} (@file{a-wtcstr.ads})
11637 @cindex C Streams, Interfacing with @code{Wide_Text_IO}
11638
11639 @noindent
11640 This package provides subprograms that allow interfacing between
11641 C streams and @code{Wide_Text_IO}.  The stream identifier can be
11642 extracted from a file opened on the Ada side, and an Ada file
11643 can be constructed from a stream opened on the C side.
11644
11645 @node GNAT.Array_Split (g-arrspl.ads)
11646 @section @code{GNAT.Array_Split} (@file{g-arrspl.ads})
11647 @cindex @code{GNAT.Array_Split} (@file{g-arrspl.ads})
11648 @cindex Array splitter
11649
11650 @noindent
11651 Useful array-manipulation routines: given a set of separators, split
11652 an array wherever the separators appear, and provide direct access
11653 to the resulting slices.
11654
11655 @node GNAT.AWK (g-awk.ads)
11656 @section @code{GNAT.AWK} (@file{g-awk.ads})
11657 @cindex @code{GNAT.AWK} (@file{g-awk.ads})
11658 @cindex Parsing
11659 @cindex AWK
11660
11661 @noindent
11662 Provides AWK-like parsing functions, with an easy interface for parsing one
11663 or more files containing formatted data.  The file is viewed as a database
11664 where each record is a line and a field is a data element in this line.
11665
11666 @node GNAT.Bounded_Buffers (g-boubuf.ads)
11667 @section @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
11668 @cindex @code{GNAT.Bounded_Buffers} (@file{g-boubuf.ads})
11669 @cindex Parsing
11670 @cindex Bounded Buffers
11671
11672 @noindent
11673 Provides a concurrent generic bounded buffer abstraction.  Instances are
11674 useful directly or as parts of the implementations of other abstractions,
11675 such as mailboxes.
11676
11677 @node GNAT.Bounded_Mailboxes (g-boumai.ads)
11678 @section @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
11679 @cindex @code{GNAT.Bounded_Mailboxes} (@file{g-boumai.ads})
11680 @cindex Parsing
11681 @cindex Mailboxes
11682
11683 @noindent
11684 Provides a thread-safe asynchronous intertask mailbox communication facility.
11685
11686 @node GNAT.Bubble_Sort (g-bubsor.ads)
11687 @section @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
11688 @cindex @code{GNAT.Bubble_Sort} (@file{g-bubsor.ads})
11689 @cindex Sorting
11690 @cindex Bubble sort
11691
11692 @noindent
11693 Provides a general implementation of bubble sort usable for sorting arbitrary
11694 data items.  Exchange and comparison procedures are provided by passing
11695 access-to-procedure values.
11696
11697 @node GNAT.Bubble_Sort_A (g-busora.ads)
11698 @section @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
11699 @cindex @code{GNAT.Bubble_Sort_A} (@file{g-busora.ads})
11700 @cindex Sorting
11701 @cindex Bubble sort
11702
11703 @noindent
11704 Provides a general implementation of bubble sort usable for sorting arbitrary
11705 data items.  Move and comparison procedures are provided by passing
11706 access-to-procedure values. This is an older version, retained for
11707 compatibility. Usually @code{GNAT.Bubble_Sort} will be preferable.
11708
11709 @node GNAT.Bubble_Sort_G (g-busorg.ads)
11710 @section @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
11711 @cindex @code{GNAT.Bubble_Sort_G} (@file{g-busorg.ads})
11712 @cindex Sorting
11713 @cindex Bubble sort
11714
11715 @noindent
11716 Similar to @code{Bubble_Sort_A} except that the move and sorting procedures
11717 are provided as generic parameters, this improves efficiency, especially
11718 if the procedures can be inlined, at the expense of duplicating code for
11719 multiple instantiations.
11720
11721 @node GNAT.Calendar (g-calend.ads)
11722 @section @code{GNAT.Calendar} (@file{g-calend.ads})
11723 @cindex @code{GNAT.Calendar} (@file{g-calend.ads})
11724 @cindex @code{Calendar}
11725
11726 @noindent
11727 Extends the facilities provided by @code{Ada.Calendar} to include handling
11728 of days of the week, an extended @code{Split} and @code{Time_Of} capability.
11729 Also provides conversion of @code{Ada.Calendar.Time} values to and from the
11730 C @code{timeval} format.
11731
11732 @node GNAT.Calendar.Time_IO (g-catiio.ads)
11733 @section @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
11734 @cindex @code{Calendar}
11735 @cindex Time
11736 @cindex @code{GNAT.Calendar.Time_IO} (@file{g-catiio.ads})
11737
11738 @node GNAT.CRC32 (g-crc32.ads)
11739 @section @code{GNAT.CRC32} (@file{g-crc32.ads})
11740 @cindex @code{GNAT.CRC32} (@file{g-crc32.ads})
11741 @cindex CRC32
11742 @cindex Cyclic Redundancy Check
11743
11744 @noindent
11745 This package implements the CRC-32 algorithm.  For a full description
11746 of this algorithm see
11747 ``Computation of Cyclic Redundancy Checks via Table Look-Up'',
11748 @cite{Communications of the ACM}, Vol.@: 31 No.@: 8, pp.@: 1008-1013,
11749 Aug.@: 1988.  Sarwate, D.V@.
11750
11751 @noindent
11752 Provides an extended capability for formatted output of time values with
11753 full user control over the format.  Modeled on the GNU Date specification.
11754
11755 @node GNAT.Case_Util (g-casuti.ads)
11756 @section @code{GNAT.Case_Util} (@file{g-casuti.ads})
11757 @cindex @code{GNAT.Case_Util} (@file{g-casuti.ads})
11758 @cindex Casing utilities
11759 @cindex Character handling (@code{GNAT.Case_Util})
11760
11761 @noindent
11762 A set of simple routines for handling upper and lower casing of strings
11763 without the overhead of the full casing tables
11764 in @code{Ada.Characters.Handling}.
11765
11766 @node GNAT.CGI (g-cgi.ads)
11767 @section @code{GNAT.CGI} (@file{g-cgi.ads})
11768 @cindex @code{GNAT.CGI} (@file{g-cgi.ads})
11769 @cindex CGI (Common Gateway Interface)
11770
11771 @noindent
11772 This is a package for interfacing a GNAT program with a Web server via the
11773 Common Gateway Interface (CGI)@.  Basically this package parses the CGI
11774 parameters, which are a set of key/value pairs sent by the Web server.  It
11775 builds a table whose index is the key and provides some services to deal
11776 with this table.
11777
11778 @node GNAT.CGI.Cookie (g-cgicoo.ads)
11779 @section @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
11780 @cindex @code{GNAT.CGI.Cookie} (@file{g-cgicoo.ads})
11781 @cindex CGI (Common Gateway Interface) cookie support
11782 @cindex Cookie support in CGI
11783
11784 @noindent
11785 This is a package to interface a GNAT program with a Web server via the
11786 Common Gateway Interface (CGI).  It exports services to deal with Web
11787 cookies (piece of information kept in the Web client software).
11788
11789 @node GNAT.CGI.Debug (g-cgideb.ads)
11790 @section @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
11791 @cindex @code{GNAT.CGI.Debug} (@file{g-cgideb.ads})
11792 @cindex CGI (Common Gateway Interface) debugging
11793
11794 @noindent
11795 This is a package to help debugging CGI (Common Gateway Interface)
11796 programs written in Ada.
11797
11798 @node GNAT.Command_Line (g-comlin.ads)
11799 @section @code{GNAT.Command_Line} (@file{g-comlin.ads})
11800 @cindex @code{GNAT.Command_Line} (@file{g-comlin.ads})
11801 @cindex Command line
11802
11803 @noindent
11804 Provides a high level interface to @code{Ada.Command_Line} facilities,
11805 including the ability to scan for named switches with optional parameters
11806 and expand file names using wild card notations.
11807
11808 @node GNAT.Compiler_Version (g-comver.ads)
11809 @section @code{GNAT.Compiler_Version} (@file{g-comver.ads})
11810 @cindex @code{GNAT.Compiler_Version} (@file{g-comver.ads})
11811 @cindex Compiler Version
11812 @cindex Version, of compiler
11813
11814 @noindent
11815 Provides a routine for obtaining the version of the compiler used to
11816 compile the program. More accurately this is the version of the binder
11817 used to bind the program (this will normally be the same as the version
11818 of the compiler if a consistent tool set is used to compile all units
11819 of a partition).
11820
11821 @node GNAT.Ctrl_C (g-ctrl_c.ads)
11822 @section @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
11823 @cindex @code{GNAT.Ctrl_C} (@file{g-ctrl_c.ads})
11824 @cindex Interrupt
11825
11826 @noindent
11827 Provides a simple interface to handle Ctrl-C keyboard events.
11828
11829 @node GNAT.Current_Exception (g-curexc.ads)
11830 @section @code{GNAT.Current_Exception} (@file{g-curexc.ads})
11831 @cindex @code{GNAT.Current_Exception} (@file{g-curexc.ads})
11832 @cindex Current exception
11833 @cindex Exception retrieval
11834
11835 @noindent
11836 Provides access to information on the current exception that has been raised
11837 without the need for using the Ada-95 exception choice parameter specification
11838 syntax.  This is particularly useful in simulating typical facilities for
11839 obtaining information about exceptions provided by Ada 83 compilers.
11840
11841 @node GNAT.Debug_Pools (g-debpoo.ads)
11842 @section @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
11843 @cindex @code{GNAT.Debug_Pools} (@file{g-debpoo.ads})
11844 @cindex Debugging
11845 @cindex Debug pools
11846 @cindex Memory corruption debugging
11847
11848 @noindent
11849 Provide a debugging storage pools that helps tracking memory corruption
11850 problems.  See section ``Finding memory problems with GNAT Debug Pool'' in
11851 the @cite{GNAT User's Guide}.
11852
11853 @node GNAT.Debug_Utilities (g-debuti.ads)
11854 @section @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
11855 @cindex @code{GNAT.Debug_Utilities} (@file{g-debuti.ads})
11856 @cindex Debugging
11857
11858 @noindent
11859 Provides a few useful utilities for debugging purposes, including conversion
11860 to and from string images of address values. Supports both C and Ada formats
11861 for hexadecimal literals.
11862
11863 @node GNAT.Directory_Operations (g-dirope.ads)
11864 @section @code{GNAT.Directory_Operations} (g-dirope.ads)
11865 @cindex @code{GNAT.Directory_Operations} (g-dirope.ads)
11866 @cindex Directory operations
11867
11868 @noindent
11869 Provides a set of routines for manipulating directories, including changing
11870 the current directory, making new directories, and scanning the files in a
11871 directory.
11872
11873 @node GNAT.Dynamic_HTables (g-dynhta.ads)
11874 @section @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
11875 @cindex @code{GNAT.Dynamic_HTables} (@file{g-dynhta.ads})
11876 @cindex Hash tables
11877
11878 @noindent
11879 A generic implementation of hash tables that can be used to hash arbitrary
11880 data.  Provided in two forms, a simple form with built in hash functions,
11881 and a more complex form in which the hash function is supplied.
11882
11883 @noindent
11884 This package provides a facility similar to that of @code{GNAT.HTable},
11885 except that this package declares a type that can be used to define
11886 dynamic instances of the hash table, while an instantiation of
11887 @code{GNAT.HTable} creates a single instance of the hash table.
11888
11889 @node GNAT.Dynamic_Tables (g-dyntab.ads)
11890 @section @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
11891 @cindex @code{GNAT.Dynamic_Tables} (@file{g-dyntab.ads})
11892 @cindex Table implementation
11893 @cindex Arrays, extendable
11894
11895 @noindent
11896 A generic package providing a single dimension array abstraction where the
11897 length of the array can be dynamically modified.
11898
11899 @noindent
11900 This package provides a facility similar to that of @code{GNAT.Table},
11901 except that this package declares a type that can be used to define
11902 dynamic instances of the table, while an instantiation of
11903 @code{GNAT.Table} creates a single instance of the table type.
11904
11905 @node GNAT.Exception_Actions (g-excact.ads)
11906 @section @code{GNAT.Exception_Actions} (@file{g-excact.ads})
11907 @cindex @code{GNAT.Exception_Actions} (@file{g-excact.ads})
11908 @cindex Exception actions
11909
11910 @noindent
11911 Provides callbacks when an exception is raised. Callbacks can be registered
11912 for specific exceptions, or when any exception is raised. This
11913 can be used for instance to force a core dump to ease debugging.
11914
11915 @node GNAT.Exception_Traces (g-exctra.ads)
11916 @section @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
11917 @cindex @code{GNAT.Exception_Traces} (@file{g-exctra.ads})
11918 @cindex Exception traces
11919 @cindex Debugging
11920
11921 @noindent
11922 Provides an interface allowing to control automatic output upon exception
11923 occurrences.
11924
11925 @node GNAT.Exceptions (g-except.ads)
11926 @section @code{GNAT.Exceptions} (@file{g-expect.ads})
11927 @cindex @code{GNAT.Exceptions} (@file{g-expect.ads})
11928 @cindex Exceptions, Pure
11929 @cindex Pure packages, exceptions
11930
11931 @noindent
11932 Normally it is not possible to raise an exception with
11933 a message from a subprogram in a pure package, since the
11934 necessary types and subprograms are in @code{Ada.Exceptions}
11935 which is not a pure unit. @code{GNAT.Exceptions} provides a
11936 facility for getting around this limitation for a few
11937 predefined exceptions, and for example allow raising
11938 @code{Constraint_Error} with a message from a pure subprogram.
11939
11940 @node GNAT.Expect (g-expect.ads)
11941 @section @code{GNAT.Expect} (@file{g-expect.ads})
11942 @cindex @code{GNAT.Expect} (@file{g-expect.ads})
11943
11944 @noindent
11945 Provides a set of subprograms similar to what is available
11946 with the standard Tcl Expect tool.
11947 It allows you to easily spawn and communicate with an external process.
11948 You can send commands or inputs to the process, and compare the output
11949 with some expected regular expression. Currently @code{GNAT.Expect}
11950 is implemented on all native GNAT ports except for OpenVMS@.
11951 It is not implemented for cross ports, and in particular is not
11952 implemented for VxWorks or LynxOS@.
11953
11954 @node GNAT.Float_Control (g-flocon.ads)
11955 @section @code{GNAT.Float_Control} (@file{g-flocon.ads})
11956 @cindex @code{GNAT.Float_Control} (@file{g-flocon.ads})
11957 @cindex Floating-Point Processor
11958
11959 @noindent
11960 Provides an interface for resetting the floating-point processor into the
11961 mode required for correct semantic operation in Ada.  Some third party
11962 library calls may cause this mode to be modified, and the Reset procedure
11963 in this package can be used to reestablish the required mode.
11964
11965 @node GNAT.Heap_Sort (g-heasor.ads)
11966 @section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
11967 @cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
11968 @cindex Sorting
11969
11970 @noindent
11971 Provides a general implementation of heap sort usable for sorting arbitrary
11972 data items. Exchange and comparison procedures are provided by passing
11973 access-to-procedure values.  The algorithm used is a modified heap sort
11974 that performs approximately N*log(N) comparisons in the worst case.
11975
11976 @node GNAT.Heap_Sort_A (g-hesora.ads)
11977 @section @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
11978 @cindex @code{GNAT.Heap_Sort_A} (@file{g-hesora.ads})
11979 @cindex Sorting
11980
11981 @noindent
11982 Provides a general implementation of heap sort usable for sorting arbitrary
11983 data items. Move and comparison procedures are provided by passing
11984 access-to-procedure values.  The algorithm used is a modified heap sort
11985 that performs approximately N*log(N) comparisons in the worst case.
11986 This differs from @code{GNAT.Heap_Sort} in having a less convenient
11987 interface, but may be slightly more efficient.
11988
11989 @node GNAT.Heap_Sort_G (g-hesorg.ads)
11990 @section @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
11991 @cindex @code{GNAT.Heap_Sort_G} (@file{g-hesorg.ads})
11992 @cindex Sorting
11993
11994 @noindent
11995 Similar to @code{Heap_Sort_A} except that the move and sorting procedures
11996 are provided as generic parameters, this improves efficiency, especially
11997 if the procedures can be inlined, at the expense of duplicating code for
11998 multiple instantiations.
11999
12000 @node GNAT.HTable (g-htable.ads)
12001 @section @code{GNAT.HTable} (@file{g-htable.ads})
12002 @cindex @code{GNAT.HTable} (@file{g-htable.ads})
12003 @cindex Hash tables
12004
12005 @noindent
12006 A generic implementation of hash tables that can be used to hash arbitrary
12007 data.  Provides two approaches, one a simple static approach, and the other
12008 allowing arbitrary dynamic hash tables.
12009
12010 @node GNAT.IO (g-io.ads)
12011 @section @code{GNAT.IO} (@file{g-io.ads})
12012 @cindex @code{GNAT.IO} (@file{g-io.ads})
12013 @cindex Simple I/O
12014 @cindex Input/Output facilities
12015
12016 @noindent
12017 A simple preelaborable input-output package that provides a subset of
12018 simple Text_IO functions for reading characters and strings from
12019 Standard_Input, and writing characters, strings and integers to either
12020 Standard_Output or Standard_Error.
12021
12022 @node GNAT.IO_Aux (g-io_aux.ads)
12023 @section @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
12024 @cindex @code{GNAT.IO_Aux} (@file{g-io_aux.ads})
12025 @cindex Text_IO
12026 @cindex Input/Output facilities
12027
12028 Provides some auxiliary functions for use with Text_IO, including a test
12029 for whether a file exists, and functions for reading a line of text.
12030
12031 @node GNAT.Lock_Files (g-locfil.ads)
12032 @section @code{GNAT.Lock_Files} (@file{g-locfil.ads})
12033 @cindex @code{GNAT.Lock_Files} (@file{g-locfil.ads})
12034 @cindex File locking
12035 @cindex Locking using files
12036
12037 @noindent
12038 Provides a general interface for using files as locks.  Can be used for
12039 providing program level synchronization.
12040
12041 @node GNAT.MD5 (g-md5.ads)
12042 @section @code{GNAT.MD5} (@file{g-md5.ads})
12043 @cindex @code{GNAT.MD5} (@file{g-md5.ads})
12044 @cindex Message Digest MD5
12045
12046 @noindent
12047 Implements the MD5 Message-Digest Algorithm as described in RFC 1321.
12048
12049 @node GNAT.Memory_Dump (g-memdum.ads)
12050 @section @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
12051 @cindex @code{GNAT.Memory_Dump} (@file{g-memdum.ads})
12052 @cindex Dump Memory
12053
12054 @noindent
12055 Provides a convenient routine for dumping raw memory to either the
12056 standard output or standard error files. Uses GNAT.IO for actual
12057 output.
12058
12059 @node GNAT.Most_Recent_Exception (g-moreex.ads)
12060 @section @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
12061 @cindex @code{GNAT.Most_Recent_Exception} (@file{g-moreex.ads})
12062 @cindex Exception, obtaining most recent
12063
12064 @noindent
12065 Provides access to the most recently raised exception.  Can be used for
12066 various logging purposes, including duplicating functionality of some
12067 Ada 83 implementation dependent extensions.
12068
12069 @node GNAT.OS_Lib (g-os_lib.ads)
12070 @section @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
12071 @cindex @code{GNAT.OS_Lib} (@file{g-os_lib.ads})
12072 @cindex Operating System interface
12073 @cindex Spawn capability
12074
12075 @noindent
12076 Provides a range of target independent operating system interface functions,
12077 including time/date management, file operations, subprocess management,
12078 including a portable spawn procedure, and access to environment variables
12079 and error return codes.
12080
12081 @node GNAT.Perfect_Hash.Generators (g-pehage.ads)
12082 @section @code{GNAT.Perfect_Hash.Generators} (@file{g-pehage.ads})
12083 @cindex @code{GNAT.Perfect_Hash.Generators} (@file{g-pehage.ads})
12084 @cindex Hash functions
12085
12086 @noindent
12087 Provides a generator of static minimal perfect hash functions. No
12088 collisions occur and each item can be retrieved from the table in one
12089 probe (perfect property). The hash table size corresponds to the exact
12090 size of the key set and no larger (minimal property). The key set has to
12091 be know in advance (static property). The hash functions are also order
12092 preservering. If w2 is inserted after w1 in the generator, their
12093 hashcode are in the same order. These hashing functions are very
12094 convenient for use with realtime applications.
12095
12096 @node GNAT.Regexp (g-regexp.ads)
12097 @section @code{GNAT.Regexp} (@file{g-regexp.ads})
12098 @cindex @code{GNAT.Regexp} (@file{g-regexp.ads})
12099 @cindex Regular expressions
12100 @cindex Pattern matching
12101
12102 @noindent
12103 A simple implementation of regular expressions, using a subset of regular
12104 expression syntax copied from familiar Unix style utilities.  This is the
12105 simples of the three pattern matching packages provided, and is particularly
12106 suitable for ``file globbing'' applications.
12107
12108 @node GNAT.Registry (g-regist.ads)
12109 @section @code{GNAT.Registry} (@file{g-regist.ads})
12110 @cindex @code{GNAT.Registry} (@file{g-regist.ads})
12111 @cindex Windows Registry
12112
12113 @noindent
12114 This is a high level binding to the Windows registry.  It is possible to
12115 do simple things like reading a key value, creating a new key.  For full
12116 registry API, but at a lower level of abstraction, refer to the Win32.Winreg
12117 package provided with the Win32Ada binding
12118
12119 @node GNAT.Regpat (g-regpat.ads)
12120 @section @code{GNAT.Regpat} (@file{g-regpat.ads})
12121 @cindex @code{GNAT.Regpat} (@file{g-regpat.ads})
12122 @cindex Regular expressions
12123 @cindex Pattern matching
12124
12125 @noindent
12126 A complete implementation of Unix-style regular expression matching, copied
12127 from the original V7 style regular expression library written in C by
12128 Henry Spencer (and binary compatible with this C library).
12129
12130 @node GNAT.Secondary_Stack_Info (g-sestin.ads)
12131 @section @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
12132 @cindex @code{GNAT.Secondary_Stack_Info} (@file{g-sestin.ads})
12133 @cindex Secondary Stack Info
12134
12135 @noindent
12136 Provide the capability to query the high water mark of the current task's
12137 secondary stack.
12138
12139 @node GNAT.Semaphores (g-semaph.ads)
12140 @section @code{GNAT.Semaphores} (@file{g-semaph.ads})
12141 @cindex @code{GNAT.Semaphores} (@file{g-semaph.ads})
12142 @cindex Semaphores
12143
12144 @noindent
12145 Provides classic counting and binary semaphores using protected types.
12146
12147 @node GNAT.Signals (g-signal.ads)
12148 @section @code{GNAT.Signals} (@file{g-signal.ads})
12149 @cindex @code{GNAT.Signals} (@file{g-signal.ads})
12150 @cindex Signals
12151
12152 @noindent
12153 Provides the ability to manipulate the blocked status of signals on supported
12154 targets.
12155
12156 @node GNAT.Sockets (g-socket.ads)
12157 @section @code{GNAT.Sockets} (@file{g-socket.ads})
12158 @cindex @code{GNAT.Sockets} (@file{g-socket.ads})
12159 @cindex Sockets
12160
12161 @noindent
12162 A high level and portable interface to develop sockets based applications.
12163 This package is based on the sockets thin binding found in
12164 @code{GNAT.Sockets.Thin}. Currently @code{GNAT.Sockets} is implemented
12165 on all native GNAT ports except for OpenVMS@.  It is not implemented
12166 for the LynxOS@ cross port.
12167
12168 @node GNAT.Source_Info (g-souinf.ads)
12169 @section @code{GNAT.Source_Info} (@file{g-souinf.ads})
12170 @cindex @code{GNAT.Source_Info} (@file{g-souinf.ads})
12171 @cindex Source Information
12172
12173 @noindent
12174 Provides subprograms that give access to source code information known at
12175 compile time, such as the current file name and line number.
12176
12177 @node GNAT.Spell_Checker (g-speche.ads)
12178 @section @code{GNAT.Spell_Checker} (@file{g-speche.ads})
12179 @cindex @code{GNAT.Spell_Checker} (@file{g-speche.ads})
12180 @cindex Spell checking
12181
12182 @noindent
12183 Provides a function for determining whether one string is a plausible
12184 near misspelling of another string.
12185
12186 @node GNAT.Spitbol.Patterns (g-spipat.ads)
12187 @section @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
12188 @cindex @code{GNAT.Spitbol.Patterns} (@file{g-spipat.ads})
12189 @cindex SPITBOL pattern matching
12190 @cindex Pattern matching
12191
12192 @noindent
12193 A complete implementation of SNOBOL4 style pattern matching.  This is the
12194 most elaborate of the pattern matching packages provided.  It fully duplicates
12195 the SNOBOL4 dynamic pattern construction and matching capabilities, using the
12196 efficient algorithm developed by Robert Dewar for the SPITBOL system.
12197
12198 @node GNAT.Spitbol (g-spitbo.ads)
12199 @section @code{GNAT.Spitbol} (@file{g-spitbo.ads})
12200 @cindex @code{GNAT.Spitbol} (@file{g-spitbo.ads})
12201 @cindex SPITBOL interface
12202
12203 @noindent
12204 The top level package of the collection of SPITBOL-style functionality, this
12205 package provides basic SNOBOL4 string manipulation functions, such as
12206 Pad, Reverse, Trim, Substr capability, as well as a generic table function
12207 useful for constructing arbitrary mappings from strings in the style of
12208 the SNOBOL4 TABLE function.
12209
12210 @node GNAT.Spitbol.Table_Boolean (g-sptabo.ads)
12211 @section @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
12212 @cindex @code{GNAT.Spitbol.Table_Boolean} (@file{g-sptabo.ads})
12213 @cindex Sets of strings
12214 @cindex SPITBOL Tables
12215
12216 @noindent
12217 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
12218 for type @code{Standard.Boolean}, giving an implementation of sets of
12219 string values.
12220
12221 @node GNAT.Spitbol.Table_Integer (g-sptain.ads)
12222 @section @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
12223 @cindex @code{GNAT.Spitbol.Table_Integer} (@file{g-sptain.ads})
12224 @cindex Integer maps
12225 @cindex Maps
12226 @cindex SPITBOL Tables
12227
12228 @noindent
12229 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table}
12230 for type @code{Standard.Integer}, giving an implementation of maps
12231 from string to integer values.
12232
12233 @node GNAT.Spitbol.Table_VString (g-sptavs.ads)
12234 @section @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
12235 @cindex @code{GNAT.Spitbol.Table_VString} (@file{g-sptavs.ads})
12236 @cindex String maps
12237 @cindex Maps
12238 @cindex SPITBOL Tables
12239
12240 @noindent
12241 A library level of instantiation of @code{GNAT.Spitbol.Patterns.Table} for
12242 a variable length string type, giving an implementation of general
12243 maps from strings to strings.
12244
12245 @node GNAT.Strings (g-string.ads)
12246 @section @code{GNAT.Strings} (@file{g-string.ads})
12247 @cindex @code{GNAT.Strings} (@file{g-string.ads})
12248
12249 @noindent
12250 Common String access types and related subprograms. Basically it
12251 defines a string access and an array of string access types.
12252
12253 @node GNAT.String_Split (g-strspl.ads)
12254 @section @code{GNAT.String_Split} (@file{g-strspl.ads})
12255 @cindex @code{GNAT.String_Split} (@file{g-strspl.ads})
12256 @cindex String splitter
12257
12258 @noindent
12259 Useful string-manipulation routines: given a set of separators, split
12260 a string wherever the separators appear, and provide direct access
12261 to the resulting slices. This package is instantiated from
12262 @code{GNAT.Array_Split}.
12263
12264 @node GNAT.Table (g-table.ads)
12265 @section @code{GNAT.Table} (@file{g-table.ads})
12266 @cindex @code{GNAT.Table} (@file{g-table.ads})
12267 @cindex Table implementation
12268 @cindex Arrays, extendable
12269
12270 @noindent
12271 A generic package providing a single dimension array abstraction where the
12272 length of the array can be dynamically modified.
12273
12274 @noindent
12275 This package provides a facility similar to that of @code{GNAT.Dynamic_Tables},
12276 except that this package declares a single instance of the table type,
12277 while an instantiation of @code{GNAT.Dynamic_Tables} creates a type that can be
12278 used to define dynamic instances of the table.
12279
12280 @node GNAT.Task_Lock (g-tasloc.ads)
12281 @section @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
12282 @cindex @code{GNAT.Task_Lock} (@file{g-tasloc.ads})
12283 @cindex Task synchronization
12284 @cindex Task locking
12285 @cindex Locking
12286
12287 @noindent
12288 A very simple facility for locking and unlocking sections of code using a
12289 single global task lock.  Appropriate for use in situations where contention
12290 between tasks is very rarely expected.
12291
12292 @node GNAT.Threads (g-thread.ads)
12293 @section @code{GNAT.Threads} (@file{g-thread.ads})
12294 @cindex @code{GNAT.Threads} (@file{g-thread.ads})
12295 @cindex Foreign threads
12296 @cindex Threads, foreign
12297
12298 @noindent
12299 Provides facilities for creating and destroying threads with explicit calls.
12300 These threads are known to the GNAT run-time system.  These subprograms are
12301 exported C-convention procedures intended to be called from foreign code.
12302 By using these primitives rather than directly calling operating systems
12303 routines, compatibility with the Ada tasking runt-time is provided.
12304
12305 @node GNAT.Traceback (g-traceb.ads)
12306 @section @code{GNAT.Traceback} (@file{g-traceb.ads})
12307 @cindex @code{GNAT.Traceback} (@file{g-traceb.ads})
12308 @cindex Trace back facilities
12309
12310 @noindent
12311 Provides a facility for obtaining non-symbolic traceback information, useful
12312 in various debugging situations.
12313
12314 @node GNAT.Traceback.Symbolic (g-trasym.ads)
12315 @section @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
12316 @cindex @code{GNAT.Traceback.Symbolic} (@file{g-trasym.ads})
12317 @cindex Trace back facilities
12318
12319 @noindent
12320 Provides symbolic traceback information that includes the subprogram
12321 name and line number information.
12322
12323 @node GNAT.Wide_String_Split (g-wistsp.ads)
12324 @section @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
12325 @cindex @code{GNAT.Wide_String_Split} (@file{g-wistsp.ads})
12326 @cindex Wide_String splitter
12327
12328 @noindent
12329 Useful wide_string-manipulation routines: given a set of separators, split
12330 a wide_string wherever the separators appear, and provide direct access
12331 to the resulting slices. This package is instantiated from
12332 @code{GNAT.Array_Split}.
12333
12334 @node Interfaces.C.Extensions (i-cexten.ads)
12335 @section @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
12336 @cindex @code{Interfaces.C.Extensions} (@file{i-cexten.ads})
12337
12338 @noindent
12339 This package contains additional C-related definitions, intended
12340 for use with either manually or automatically generated bindings
12341 to C libraries.
12342
12343 @node Interfaces.C.Streams (i-cstrea.ads)
12344 @section @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
12345 @cindex @code{Interfaces.C.Streams} (@file{i-cstrea.ads})
12346 @cindex  C streams, interfacing
12347
12348 @noindent
12349 This package is a binding for the most commonly used operations
12350 on C streams.
12351
12352 @node Interfaces.CPP (i-cpp.ads)
12353 @section @code{Interfaces.CPP} (@file{i-cpp.ads})
12354 @cindex @code{Interfaces.CPP} (@file{i-cpp.ads})
12355 @cindex  C++ interfacing
12356 @cindex  Interfacing, to C++
12357
12358 @noindent
12359 This package provides facilities for use in interfacing to C++.  It
12360 is primarily intended to be used in connection with automated tools
12361 for the generation of C++ interfaces.
12362
12363 @node Interfaces.Os2lib (i-os2lib.ads)
12364 @section @code{Interfaces.Os2lib} (@file{i-os2lib.ads})
12365 @cindex @code{Interfaces.Os2lib} (@file{i-os2lib.ads})
12366 @cindex Interfacing, to OS/2
12367 @cindex OS/2 interfacing
12368
12369 @noindent
12370 This package provides interface definitions to the OS/2 library.
12371 It is a thin binding which is a direct translation of the
12372 various @file{<bse@.h>} files.
12373
12374 @node Interfaces.Os2lib.Errors (i-os2err.ads)
12375 @section @code{Interfaces.Os2lib.Errors} (@file{i-os2err.ads})
12376 @cindex @code{Interfaces.Os2lib.Errors} (@file{i-os2err.ads})
12377 @cindex OS/2 Error codes
12378 @cindex Interfacing, to OS/2
12379 @cindex OS/2 interfacing
12380
12381 @noindent
12382 This package provides definitions of the OS/2 error codes.
12383
12384 @node Interfaces.Os2lib.Synchronization (i-os2syn.ads)
12385 @section @code{Interfaces.Os2lib.Synchronization} (@file{i-os2syn.ads})
12386 @cindex @code{Interfaces.Os2lib.Synchronization} (@file{i-os2syn.ads})
12387 @cindex Interfacing, to OS/2
12388 @cindex Synchronization, OS/2
12389 @cindex OS/2 synchronization primitives
12390
12391 @noindent
12392 This is a child package that provides definitions for interfacing
12393 to the @code{OS/2} synchronization primitives.
12394
12395 @node Interfaces.Os2lib.Threads (i-os2thr.ads)
12396 @section @code{Interfaces.Os2lib.Threads} (@file{i-os2thr.ads})
12397 @cindex @code{Interfaces.Os2lib.Threads} (@file{i-os2thr.ads})
12398 @cindex Interfacing, to OS/2
12399 @cindex Thread control, OS/2
12400 @cindex OS/2 thread interfacing
12401
12402 @noindent
12403 This is a child package that provides definitions for interfacing
12404 to the @code{OS/2} thread primitives.
12405
12406 @node Interfaces.Packed_Decimal (i-pacdec.ads)
12407 @section @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
12408 @cindex @code{Interfaces.Packed_Decimal} (@file{i-pacdec.ads})
12409 @cindex  IBM Packed Format
12410 @cindex  Packed Decimal
12411
12412 @noindent
12413 This package provides a set of routines for conversions to and
12414 from a packed decimal format compatible with that used on IBM
12415 mainframes.
12416
12417 @node Interfaces.VxWorks (i-vxwork.ads)
12418 @section @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
12419 @cindex @code{Interfaces.VxWorks} (@file{i-vxwork.ads})
12420 @cindex Interfacing to VxWorks
12421 @cindex VxWorks, interfacing
12422
12423 @noindent
12424 This package provides a limited binding to the VxWorks API.
12425 In particular, it interfaces with the
12426 VxWorks hardware interrupt facilities.
12427
12428 @node Interfaces.VxWorks.IO (i-vxwoio.ads)
12429 @section @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
12430 @cindex @code{Interfaces.VxWorks.IO} (@file{i-vxwoio.ads})
12431 @cindex Interfacing to VxWorks' I/O
12432 @cindex VxWorks, I/O interfacing
12433 @cindex VxWorks, Get_Immediate
12434 @cindex Get_Immediate, VxWorks
12435
12436 @noindent
12437 This package provides a binding to the ioctl (IO/Control)
12438 function of VxWorks, defining a set of option values and
12439 function codes. A particular use of this package is
12440 to enable the use of Get_Immediate under VxWorks.
12441
12442 @node System.Address_Image (s-addima.ads)
12443 @section @code{System.Address_Image} (@file{s-addima.ads})
12444 @cindex @code{System.Address_Image} (@file{s-addima.ads})
12445 @cindex Address image
12446 @cindex Image, of an address
12447
12448 @noindent
12449 This function provides a useful debugging
12450 function that gives an (implementation dependent)
12451 string which identifies an address.
12452
12453 @node System.Assertions (s-assert.ads)
12454 @section @code{System.Assertions} (@file{s-assert.ads})
12455 @cindex @code{System.Assertions} (@file{s-assert.ads})
12456 @cindex Assertions
12457 @cindex Assert_Failure, exception
12458
12459 @noindent
12460 This package provides the declaration of the exception raised
12461 by an run-time assertion failure, as well as the routine that
12462 is used internally to raise this assertion.
12463
12464 @node System.Memory (s-memory.ads)
12465 @section @code{System.Memory} (@file{s-memory.ads})
12466 @cindex @code{System.Memory} (@file{s-memory.ads})
12467 @cindex Memory allocation
12468
12469 @noindent
12470 This package provides the interface to the low level routines used
12471 by the generated code for allocation and freeing storage for the
12472 default storage pool (analogous to the C routines malloc and free.
12473 It also provides a reallocation interface analogous to the C routine
12474 realloc. The body of this unit may be modified to provide alternative
12475 allocation mechanisms for the default pool, and in addition, direct
12476 calls to this unit may be made for low level allocation uses (for
12477 example see the body of @code{GNAT.Tables}).
12478
12479 @node System.Partition_Interface (s-parint.ads)
12480 @section @code{System.Partition_Interface} (@file{s-parint.ads})
12481 @cindex @code{System.Partition_Interface} (@file{s-parint.ads})
12482 @cindex Partition intefacing functions
12483
12484 @noindent
12485 This package provides facilities for partition interfacing.  It
12486 is used primarily in a distribution context when using Annex E
12487 with @code{GLADE}.
12488
12489 @node System.Restrictions (s-restri.ads)
12490 @section @code{System.Restrictions} (@file{s-restri.ads})
12491 @cindex @code{System.Restrictions} (@file{s-restri.ads})
12492 @cindex Run-time restrictions access
12493
12494 @noindent
12495 This package provides facilities for accessing at run-time
12496 the status of restrictions specified at compile time for
12497 the partition. Information is available both with regard
12498 to actual restrictions specified, and with regard to
12499 compiler determined information on which restrictions
12500 are violated by one or more packages in the partition.
12501
12502 @node System.Rident (s-rident.ads)
12503 @section @code{System.Rident} (@file{s-rident.ads})
12504 @cindex @code{System.Rident} (@file{s-rident.ads})
12505 @cindex Restrictions definitions
12506
12507 @noindent
12508 This package provides definitions of the restrictions
12509 identifiers supported by GNAT, and also the format of
12510 the restrictions provided in package System.Restrictions.
12511 It is not normally necessary to @code{with} this generic package
12512 since the necessary instantiation is included in
12513 package System.Restrictions.
12514
12515 @node System.Task_Info (s-tasinf.ads)
12516 @section @code{System.Task_Info} (@file{s-tasinf.ads})
12517 @cindex @code{System.Task_Info} (@file{s-tasinf.ads})
12518 @cindex Task_Info pragma
12519
12520 @noindent
12521 This package provides target dependent functionality that is used
12522 to support the @code{Task_Info} pragma
12523
12524 @node System.Wch_Cnv (s-wchcnv.ads)
12525 @section @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
12526 @cindex @code{System.Wch_Cnv} (@file{s-wchcnv.ads})
12527 @cindex Wide Character, Representation
12528 @cindex Wide String, Conversion
12529 @cindex Representation of wide characters
12530
12531 @noindent
12532 This package provides routines for converting between
12533 wide characters and a representation as a value of type
12534 @code{Standard.String}, using a specified wide character
12535 encoding method.  It uses definitions in
12536 package @code{System.Wch_Con}.
12537
12538 @node System.Wch_Con (s-wchcon.ads)
12539 @section @code{System.Wch_Con} (@file{s-wchcon.ads})
12540 @cindex @code{System.Wch_Con} (@file{s-wchcon.ads})
12541
12542 @noindent
12543 This package provides definitions and descriptions of
12544 the various methods used for encoding wide characters
12545 in ordinary strings.  These definitions are used by
12546 the package @code{System.Wch_Cnv}.
12547
12548 @node Interfacing to Other Languages
12549 @chapter Interfacing to Other Languages
12550 @noindent
12551 The facilities in annex B of the Ada 95 Reference Manual are fully
12552 implemented in GNAT, and in addition, a full interface to C++ is
12553 provided.
12554
12555 @menu
12556 * Interfacing to C::
12557 * Interfacing to C++::
12558 * Interfacing to COBOL::
12559 * Interfacing to Fortran::
12560 * Interfacing to non-GNAT Ada code::
12561 @end menu
12562
12563 @node Interfacing to C
12564 @section Interfacing to C
12565
12566 @noindent
12567 Interfacing to C with GNAT can use one of two approaches:
12568
12569 @itemize @bullet
12570 @item
12571 The types in the package @code{Interfaces.C} may be used.
12572 @item
12573 Standard Ada types may be used directly.  This may be less portable to
12574 other compilers, but will work on all GNAT compilers, which guarantee
12575 correspondence between the C and Ada types.
12576 @end itemize
12577
12578 @noindent
12579 Pragma @code{Convention C} may be applied to Ada types, but mostly has no
12580 effect, since this is the default.  The following table shows the
12581 correspondence between Ada scalar types and the corresponding C types.
12582
12583 @table @code
12584 @item Integer
12585 @code{int}
12586 @item Short_Integer
12587 @code{short}
12588 @item Short_Short_Integer
12589 @code{signed char}
12590 @item Long_Integer
12591 @code{long}
12592 @item Long_Long_Integer
12593 @code{long long}
12594 @item Short_Float
12595 @code{float}
12596 @item Float
12597 @code{float}
12598 @item Long_Float
12599 @code{double}
12600 @item Long_Long_Float
12601 This is the longest floating-point type supported by the hardware.
12602 @end table
12603
12604 @noindent
12605 Additionally, there are the following general correspondences between Ada
12606 and C types:
12607 @itemize @bullet
12608 @item
12609 Ada enumeration types map to C enumeration types directly if pragma
12610 @code{Convention C} is specified, which causes them to have int
12611 length.  Without pragma @code{Convention C}, Ada enumeration types map to
12612 8, 16, or 32 bits (i.e.@: C types @code{signed char}, @code{short},
12613 @code{int}, respectively) depending on the number of values passed.
12614 This is the only case in which pragma @code{Convention C} affects the
12615 representation of an Ada type.
12616
12617 @item
12618 Ada access types map to C pointers, except for the case of pointers to
12619 unconstrained types in Ada, which have no direct C equivalent.
12620
12621 @item
12622 Ada arrays map directly to C arrays.
12623
12624 @item
12625 Ada records map directly to C structures.
12626
12627 @item
12628 Packed Ada records map to C structures where all members are bit fields
12629 of the length corresponding to the @code{@var{type}'Size} value in Ada.
12630 @end itemize
12631
12632 @node Interfacing to C++
12633 @section Interfacing to C++
12634
12635 @noindent
12636 The interface to C++ makes use of the following pragmas, which are
12637 primarily intended to be constructed automatically using a binding generator
12638 tool, although it is possible to construct them by hand.  No suitable binding
12639 generator tool is supplied with GNAT though.
12640
12641 Using these pragmas it is possible to achieve complete
12642 inter-operability between Ada tagged types and C class definitions.
12643 See @ref{Implementation Defined Pragmas}, for more details.
12644
12645 @table @code
12646 @item pragma CPP_Class ([Entity =>] @var{local_name})
12647 The argument denotes an entity in the current declarative region that is
12648 declared as a tagged or untagged record type.  It indicates that the type
12649 corresponds to an externally declared C++ class type, and is to be laid
12650 out the same way that C++ would lay out the type.
12651
12652 @item pragma CPP_Constructor ([Entity =>] @var{local_name})
12653 This pragma identifies an imported function (imported in the usual way
12654 with pragma @code{Import}) as corresponding to a C++ constructor.
12655
12656 @item pragma CPP_Vtable @dots{}
12657 One @code{CPP_Vtable} pragma can be present for each component of type
12658 @code{CPP.Interfaces.Vtable_Ptr} in a record to which pragma @code{CPP_Class}
12659 applies.
12660 @end table
12661
12662 @node Interfacing to COBOL
12663 @section Interfacing to COBOL
12664
12665 @noindent
12666 Interfacing to COBOL is achieved as described in section B.4 of
12667 the Ada 95 reference manual.
12668
12669 @node Interfacing to Fortran
12670 @section Interfacing to Fortran
12671
12672 @noindent
12673 Interfacing to Fortran is achieved as described in section B.5 of the
12674 reference manual.  The pragma @code{Convention Fortran}, applied to a
12675 multi-dimensional array causes the array to be stored in column-major
12676 order as required for convenient interface to Fortran.
12677
12678 @node Interfacing to non-GNAT Ada code
12679 @section Interfacing to non-GNAT Ada code
12680
12681 It is possible to specify the convention @code{Ada} in a pragma
12682 @code{Import} or pragma @code{Export}.  However this refers to
12683 the calling conventions used by GNAT, which may or may not be
12684 similar enough to those used by some other Ada 83 or Ada 95
12685 compiler to allow interoperation.
12686
12687 If arguments types are kept simple, and if the foreign compiler generally
12688 follows system calling conventions, then it may be possible to integrate
12689 files compiled by other Ada compilers, provided that the elaboration
12690 issues are adequately addressed (for example by eliminating the
12691 need for any load time elaboration).
12692
12693 In particular, GNAT running on VMS is designed to
12694 be highly compatible with the DEC Ada 83 compiler, so this is one
12695 case in which it is possible to import foreign units of this type,
12696 provided that the data items passed are restricted to simple scalar
12697 values or simple record types without variants, or simple array
12698 types with fixed bounds.
12699
12700 @node Specialized Needs Annexes
12701 @chapter Specialized Needs Annexes
12702
12703 @noindent
12704 Ada 95 defines a number of specialized needs annexes, which are not
12705 required in all implementations.  However, as described in this chapter,
12706 GNAT implements all of these special needs annexes:
12707
12708 @table @asis
12709 @item Systems Programming (Annex C)
12710 The Systems Programming Annex is fully implemented.
12711
12712 @item Real-Time Systems (Annex D)
12713 The Real-Time Systems Annex is fully implemented.
12714
12715 @item Distributed Systems (Annex E)
12716 Stub generation is fully implemented in the GNAT compiler.  In addition,
12717 a complete compatible PCS is available as part of the GLADE system,
12718 a separate product.  When the two
12719 products are used in conjunction, this annex is fully implemented.
12720
12721 @item Information Systems (Annex F)
12722 The Information Systems annex is fully implemented.
12723
12724 @item Numerics (Annex G)
12725 The Numerics Annex is fully implemented.
12726
12727 @item Safety and Security (Annex H)
12728 The Safety and Security annex is fully implemented.
12729 @end table
12730
12731 @node Implementation of Specific Ada Features
12732 @chapter Implementation of Specific Ada Features
12733
12734 @noindent
12735 This chapter describes the GNAT implementation of several Ada language
12736 facilities.
12737
12738 @menu
12739 * Machine Code Insertions::
12740 * GNAT Implementation of Tasking::
12741 * GNAT Implementation of Shared Passive Packages::
12742 * Code Generation for Array Aggregates::
12743 @end menu
12744
12745 @node Machine Code Insertions
12746 @section Machine Code Insertions
12747
12748 @noindent
12749 Package @code{Machine_Code} provides machine code support as described
12750 in the Ada 95 Reference Manual in two separate forms:
12751 @itemize @bullet
12752 @item
12753 Machine code statements, consisting of qualified expressions that
12754 fit the requirements of RM section 13.8.
12755 @item
12756 An intrinsic callable procedure, providing an alternative mechanism of
12757 including machine instructions in a subprogram.
12758 @end itemize
12759
12760 @noindent
12761 The two features are similar, and both are closely related to the mechanism
12762 provided by the asm instruction in the GNU C compiler.  Full understanding
12763 and use of the facilities in this package requires understanding the asm
12764 instruction as described in @cite{Using the GNU Compiler Collection (GCC)}
12765 by Richard Stallman. The relevant section is titled ``Extensions to the C
12766 Language Family'' -> ``Assembler Instructions with C Expression Operands''.
12767
12768 Calls to the function @code{Asm} and the procedure @code{Asm} have identical
12769 semantic restrictions and effects as described below.  Both are provided so
12770 that the procedure call can be used as a statement, and the function call
12771 can be used to form a code_statement.
12772
12773 The first example given in the GCC documentation is the C @code{asm}
12774 instruction:
12775 @smallexample
12776    asm ("fsinx %1 %0" : "=f" (result) : "f" (angle));
12777 @end smallexample
12778
12779 @noindent
12780 The equivalent can be written for GNAT as:
12781
12782 @smallexample @c ada
12783 Asm ("fsinx %1 %0",
12784      My_Float'Asm_Output ("=f", result),
12785      My_Float'Asm_Input  ("f",  angle));
12786 @end smallexample
12787
12788 @noindent
12789 The first argument to @code{Asm} is the assembler template, and is
12790 identical to what is used in GNU C@.  This string must be a static
12791 expression.  The second argument is the output operand list.  It is
12792 either a single @code{Asm_Output} attribute reference, or a list of such
12793 references enclosed in parentheses (technically an array aggregate of
12794 such references).
12795
12796 The @code{Asm_Output} attribute denotes a function that takes two
12797 parameters.  The first is a string, the second is the name of a variable
12798 of the type designated by the attribute prefix.  The first (string)
12799 argument is required to be a static expression and designates the
12800 constraint for the parameter (e.g.@: what kind of register is
12801 required).  The second argument is the variable to be updated with the
12802 result.  The possible values for constraint are the same as those used in
12803 the RTL, and are dependent on the configuration file used to build the
12804 GCC back end.  If there are no output operands, then this argument may
12805 either be omitted, or explicitly given as @code{No_Output_Operands}.
12806
12807 The second argument of @code{@var{my_float}'Asm_Output} functions as
12808 though it were an @code{out} parameter, which is a little curious, but
12809 all names have the form of expressions, so there is no syntactic
12810 irregularity, even though normally functions would not be permitted
12811 @code{out} parameters.  The third argument is the list of input
12812 operands.  It is either a single @code{Asm_Input} attribute reference, or
12813 a list of such references enclosed in parentheses (technically an array
12814 aggregate of such references).
12815
12816 The @code{Asm_Input} attribute denotes a function that takes two
12817 parameters.  The first is a string, the second is an expression of the
12818 type designated by the prefix.  The first (string) argument is required
12819 to be a static expression, and is the constraint for the parameter,
12820 (e.g.@: what kind of register is required).  The second argument is the
12821 value to be used as the input argument.  The possible values for the
12822 constant are the same as those used in the RTL, and are dependent on
12823 the configuration file used to built the GCC back end.
12824
12825 If there are no input operands, this argument may either be omitted, or
12826 explicitly given as @code{No_Input_Operands}.  The fourth argument, not
12827 present in the above example, is a list of register names, called the
12828 @dfn{clobber} argument.  This argument, if given, must be a static string
12829 expression, and is a space or comma separated list of names of registers
12830 that must be considered destroyed as a result of the @code{Asm} call.  If
12831 this argument is the null string (the default value), then the code
12832 generator assumes that no additional registers are destroyed.
12833
12834 The fifth argument, not present in the above example, called the
12835 @dfn{volatile} argument, is by default @code{False}.  It can be set to
12836 the literal value @code{True} to indicate to the code generator that all
12837 optimizations with respect to the instruction specified should be
12838 suppressed, and that in particular, for an instruction that has outputs,
12839 the instruction will still be generated, even if none of the outputs are
12840 used.  See the full description in the GCC manual for further details.
12841
12842 The @code{Asm} subprograms may be used in two ways.  First the procedure
12843 forms can be used anywhere a procedure call would be valid, and
12844 correspond to what the RM calls ``intrinsic'' routines.  Such calls can
12845 be used to intersperse machine instructions with other Ada statements.
12846 Second, the function forms, which return a dummy value of the limited
12847 private type @code{Asm_Insn}, can be used in code statements, and indeed
12848 this is the only context where such calls are allowed.  Code statements
12849 appear as aggregates of the form:
12850
12851 @smallexample @c ada
12852 Asm_Insn'(Asm (@dots{}));
12853 Asm_Insn'(Asm_Volatile (@dots{}));
12854 @end smallexample
12855
12856 @noindent
12857 In accordance with RM rules, such code statements are allowed only
12858 within subprograms whose entire body consists of such statements.  It is
12859 not permissible to intermix such statements with other Ada statements.
12860
12861 Typically the form using intrinsic procedure calls is more convenient
12862 and more flexible.  The code statement form is provided to meet the RM
12863 suggestion that such a facility should be made available.  The following
12864 is the exact syntax of the call to @code{Asm}. As usual, if named notation
12865 is used, the arguments may be given in arbitrary order, following the
12866 normal rules for use of positional and named arguments)
12867
12868 @smallexample
12869 ASM_CALL ::= Asm (
12870                  [Template =>] static_string_EXPRESSION
12871                [,[Outputs  =>] OUTPUT_OPERAND_LIST      ]
12872                [,[Inputs   =>] INPUT_OPERAND_LIST       ]
12873                [,[Clobber  =>] static_string_EXPRESSION ]
12874                [,[Volatile =>] static_boolean_EXPRESSION] )
12875
12876 OUTPUT_OPERAND_LIST ::=
12877   [PREFIX.]No_Output_Operands
12878 | OUTPUT_OPERAND_ATTRIBUTE
12879 | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
12880
12881 OUTPUT_OPERAND_ATTRIBUTE ::=
12882   SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
12883
12884 INPUT_OPERAND_LIST ::=
12885   [PREFIX.]No_Input_Operands
12886 | INPUT_OPERAND_ATTRIBUTE
12887 | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
12888
12889 INPUT_OPERAND_ATTRIBUTE ::=
12890   SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
12891 @end smallexample
12892
12893 @noindent
12894 The identifiers @code{No_Input_Operands} and @code{No_Output_Operands}
12895 are declared in the package @code{Machine_Code} and must be referenced
12896 according to normal visibility rules. In particular if there is no
12897 @code{use} clause for this package, then appropriate package name
12898 qualification is required.
12899
12900 @node GNAT Implementation of Tasking
12901 @section GNAT Implementation of Tasking
12902
12903 @noindent
12904 This chapter outlines the basic GNAT approach to tasking (in particular,
12905 a multi-layered library for portability) and discusses issues related
12906 to compliance with the Real-Time Systems Annex.
12907
12908 @menu
12909 * Mapping Ada Tasks onto the Underlying Kernel Threads::
12910 * Ensuring Compliance with the Real-Time Annex::
12911 @end menu
12912
12913 @node Mapping Ada Tasks onto the Underlying Kernel Threads
12914 @subsection Mapping Ada Tasks onto the Underlying Kernel Threads
12915
12916 @noindent
12917 GNAT's run-time support comprises two layers:
12918
12919 @itemize @bullet
12920 @item GNARL (GNAT Run-time Layer)
12921 @item GNULL (GNAT Low-level Library)
12922 @end itemize
12923
12924 @noindent
12925 In GNAT, Ada's tasking services rely on a platform and OS independent
12926 layer known as GNARL@.  This code is responsible for implementing the
12927 correct semantics of Ada's task creation, rendezvous, protected
12928 operations etc.
12929
12930 GNARL decomposes Ada's tasking semantics into simpler lower level
12931 operations such as create a thread, set the priority of a thread,
12932 yield, create a lock, lock/unlock, etc.  The spec for these low-level
12933 operations constitutes GNULLI, the GNULL Interface.  This interface is
12934 directly inspired from the POSIX real-time API@.
12935
12936 If the underlying executive or OS implements the POSIX standard
12937 faithfully, the GNULL Interface maps as is to the services offered by
12938 the underlying kernel.  Otherwise, some target dependent glue code maps
12939 the services offered by the underlying kernel to the semantics expected
12940 by GNARL@.
12941
12942 Whatever the underlying OS (VxWorks, UNIX, OS/2, Windows NT, etc.) the
12943 key point is that each Ada task is mapped on a thread in the underlying
12944 kernel.  For example, in the case of VxWorks, one Ada task = one VxWorks task.
12945
12946 In addition Ada task priorities map onto the underlying thread priorities.
12947 Mapping Ada tasks onto the underlying kernel threads has several advantages:
12948
12949 @itemize @bullet
12950 @item
12951 The underlying scheduler is used to schedule the Ada tasks.  This
12952 makes Ada tasks as efficient as kernel threads from a scheduling
12953 standpoint.
12954
12955 @item
12956 Interaction with code written in C containing threads is eased
12957 since at the lowest level Ada tasks and C threads map onto the same
12958 underlying kernel concept.
12959
12960 @item
12961 When an Ada task is blocked during I/O the remaining Ada tasks are
12962 able to proceed.
12963
12964 @item
12965 On multiprocessor systems Ada tasks can execute in parallel.
12966 @end itemize
12967
12968 @noindent
12969 Some threads libraries offer a mechanism to fork a new process, with the
12970 child process duplicating the threads from the parent.
12971 GNAT does not
12972 support this functionality when the parent contains more than one task.
12973 @cindex Forking a new process
12974
12975 @node Ensuring Compliance with the Real-Time Annex
12976 @subsection Ensuring Compliance with the Real-Time Annex
12977 @cindex Real-Time Systems Annex compliance
12978
12979 @noindent
12980 Although mapping Ada tasks onto
12981 the underlying threads has significant advantages, it does create some
12982 complications when it comes to respecting the scheduling semantics
12983 specified in the real-time annex (Annex D).
12984
12985 For instance the Annex D requirement for the @code{FIFO_Within_Priorities}
12986 scheduling policy states:
12987
12988 @quotation
12989 @emph{When the active priority of a ready task that is not running
12990 changes, or the setting of its base priority takes effect, the
12991 task is removed from the ready queue for its old active priority
12992 and is added at the tail of the ready queue for its new active
12993 priority, except in the case where the active priority is lowered
12994 due to the loss of inherited priority, in which case the task is
12995 added at the head of the ready queue for its new active priority.}
12996 @end quotation
12997
12998 @noindent
12999 While most kernels do put tasks at the end of the priority queue when
13000 a task changes its priority, (which respects the main
13001 FIFO_Within_Priorities requirement), almost none keep a thread at the
13002 beginning of its priority queue when its priority drops from the loss
13003 of inherited priority.
13004
13005 As a result most vendors have provided incomplete Annex D implementations.
13006
13007 The GNAT run-time, has a nice cooperative solution to this problem
13008 which ensures that accurate FIFO_Within_Priorities semantics are
13009 respected.
13010
13011 The principle is as follows.  When an Ada task T is about to start
13012 running, it checks whether some other Ada task R with the same
13013 priority as T has been suspended due to the loss of priority
13014 inheritance.  If this is the case, T yields and is placed at the end of
13015 its priority queue.  When R arrives at the front of the queue it
13016 executes.
13017
13018 Note that this simple scheme preserves the relative order of the tasks
13019 that were ready to execute in the priority queue where R has been
13020 placed at the end.
13021
13022 @node GNAT Implementation of Shared Passive Packages
13023 @section GNAT Implementation of Shared Passive Packages
13024 @cindex Shared passive packages
13025
13026 @noindent
13027 GNAT fully implements the pragma @code{Shared_Passive} for
13028 @cindex pragma @code{Shared_Passive}
13029 the purpose of designating shared passive packages.
13030 This allows the use of passive partitions in the
13031 context described in the Ada Reference Manual; i.e. for communication
13032 between separate partitions of a distributed application using the
13033 features in Annex E.
13034 @cindex Annex E
13035 @cindex Distribution Systems Annex
13036
13037 However, the implementation approach used by GNAT provides for more
13038 extensive usage as follows:
13039
13040 @table @emph
13041 @item Communication between separate programs
13042
13043 This allows separate programs to access the data in passive
13044 partitions, using protected objects for synchronization where
13045 needed. The only requirement is that the two programs have a
13046 common shared file system. It is even possible for programs
13047 running on different machines with different architectures
13048 (e.g. different endianness) to communicate via the data in
13049 a passive partition.
13050
13051 @item Persistence between program runs
13052
13053 The data in a passive package can persist from one run of a
13054 program to another, so that a later program sees the final
13055 values stored by a previous run of the same program.
13056
13057 @end table
13058
13059 @noindent
13060 The implementation approach used is to store the data in files. A
13061 separate stream file is created for each object in the package, and
13062 an access to an object causes the corresponding file to be read or
13063 written.
13064
13065 The environment variable @code{SHARED_MEMORY_DIRECTORY} should be
13066 @cindex @code{SHARED_MEMORY_DIRECTORY} environment variable
13067 set to the directory to be used for these files.
13068 The files in this directory
13069 have names that correspond to their fully qualified names. For
13070 example, if we have the package
13071
13072 @smallexample @c ada
13073 package X is
13074   pragma Shared_Passive (X);
13075   Y : Integer;
13076   Z : Float;
13077 end X;
13078 @end smallexample
13079
13080 @noindent
13081 and the environment variable is set to @code{/stemp/}, then the files created
13082 will have the names:
13083
13084 @smallexample
13085 /stemp/x.y
13086 /stemp/x.z
13087 @end smallexample
13088
13089 @noindent
13090 These files are created when a value is initially written to the object, and
13091 the files are retained until manually deleted. This provides the persistence
13092 semantics. If no file exists, it means that no partition has assigned a value
13093 to the variable; in this case the initial value declared in the package
13094 will be used. This model ensures that there are no issues in synchronizing
13095 the elaboration process, since elaboration of passive packages elaborates the
13096 initial values, but does not create the files.
13097
13098 The files are written using normal @code{Stream_IO} access.
13099 If you want to be able
13100 to communicate between programs or partitions running on different
13101 architectures, then you should use the XDR versions of the stream attribute
13102 routines, since these are architecture independent.
13103
13104 If active synchronization is required for access to the variables in the
13105 shared passive package, then as described in the Ada Reference Manual, the
13106 package may contain protected objects used for this purpose. In this case
13107 a lock file (whose name is @file{___lock} (three underscores)
13108 is created in the shared memory directory.
13109 @cindex @file{___lock} file (for shared passive packages)
13110 This is used to provide the required locking
13111 semantics for proper protected object synchronization.
13112
13113 As of January 2003, GNAT supports shared passive packages on all platforms
13114 except for OpenVMS.
13115
13116 @node Code Generation for Array Aggregates
13117 @section Code Generation for Array Aggregates
13118
13119 @menu
13120 * Static constant aggregates with static bounds::
13121 * Constant aggregates with an unconstrained nominal types::
13122 * Aggregates with static bounds::
13123 * Aggregates with non-static bounds::
13124 * Aggregates in assignment statements::
13125 @end menu
13126
13127 @noindent
13128 Aggregate have a rich syntax and allow the user to specify the values of
13129 complex data structures by means of a single construct.  As a result, the
13130 code generated for aggregates can be quite complex and involve loops, case
13131 statements and multiple assignments.  In the simplest cases, however, the
13132 compiler will recognize aggregates whose components and constraints are
13133 fully static, and in those cases the compiler will generate little or no
13134 executable code.  The following is an outline of the code that GNAT generates
13135 for various aggregate constructs.  For further details, the user will find it
13136 useful to examine the output produced by the -gnatG flag to see the expanded
13137 source that is input to the code generator.  The user will also want to examine
13138 the assembly code generated at various levels of optimization.
13139
13140 The code generated for aggregates depends on the context, the component values,
13141 and the type.  In the context of an object declaration the code generated is
13142 generally simpler than in the case of an assignment.  As a general rule, static
13143 component values and static subtypes also lead to simpler code.
13144
13145 @node Static constant aggregates with static bounds
13146 @subsection Static constant aggregates with static bounds
13147
13148 @noindent
13149 For the declarations:
13150 @smallexample @c ada
13151     type One_Dim is array (1..10) of integer;
13152     ar0 : constant One_Dim := ( 1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
13153 @end smallexample
13154
13155 @noindent
13156 GNAT generates no executable code: the constant ar0 is placed in static memory.
13157 The same is true for constant aggregates with named associations:
13158
13159 @smallexample @c ada
13160     Cr1 : constant One_Dim := (4 => 16, 2 => 4, 3 => 9, 1=> 1);
13161     Cr3 : constant One_Dim := (others => 7777);
13162 @end smallexample
13163
13164 @noindent
13165 The same is true for multidimensional constant arrays such as:
13166
13167 @smallexample @c ada
13168     type two_dim is array (1..3, 1..3) of integer;
13169     Unit : constant two_dim := ( (1,0,0), (0,1,0), (0,0,1));
13170 @end smallexample
13171
13172 @noindent
13173 The same is true for arrays of one-dimensional arrays: the following are
13174 static:
13175
13176 @smallexample @c ada
13177 type ar1b  is array (1..3) of boolean;
13178 type ar_ar is array (1..3) of ar1b;
13179 None  : constant ar1b := (others => false);     --  fully static
13180 None2 : constant ar_ar := (1..3 => None);       --  fully static
13181 @end smallexample
13182
13183 @noindent
13184 However, for multidimensional aggregates with named associations, GNAT will
13185 generate assignments and loops, even if all associations are static.  The
13186 following two declarations generate a loop for the first dimension, and
13187 individual component assignments for the second dimension:
13188
13189 @smallexample @c ada
13190 Zero1: constant two_dim := (1..3 => (1..3 => 0));
13191 Zero2: constant two_dim := (others => (others => 0));
13192 @end smallexample
13193
13194 @node Constant aggregates with an unconstrained nominal types
13195 @subsection Constant aggregates with an unconstrained nominal types
13196
13197 @noindent
13198 In such cases the aggregate itself establishes the subtype, so that
13199 associations with @code{others} cannot be used.  GNAT determines the
13200 bounds for the actual subtype of the aggregate, and allocates the
13201 aggregate statically as well.  No code is generated for the following:
13202
13203 @smallexample @c ada
13204     type One_Unc is array (natural range <>) of integer;
13205     Cr_Unc : constant One_Unc := (12,24,36);
13206 @end smallexample
13207
13208 @node Aggregates with static bounds
13209 @subsection Aggregates with static bounds
13210
13211 @noindent
13212 In all previous examples the aggregate was the initial (and immutable) value
13213 of a constant.  If the aggregate initializes a variable, then code is generated
13214 for it as a combination of individual assignments and loops over the target
13215 object.  The declarations
13216
13217 @smallexample @c ada
13218        Cr_Var1 : One_Dim := (2, 5, 7, 11);
13219        Cr_Var2 : One_Dim := (others > -1);
13220 @end smallexample
13221
13222 @noindent
13223 generate the equivalent of
13224
13225 @smallexample @c ada
13226        Cr_Var1 (1) := 2;
13227        Cr_Var1 (2) := 3;
13228        Cr_Var1 (3) := 5;
13229        Cr_Var1 (4) := 11;
13230
13231        for I in Cr_Var2'range loop
13232           Cr_Var2 (I) := =-1;
13233        end loop;
13234 @end smallexample
13235
13236 @node Aggregates with non-static bounds
13237 @subsection Aggregates with non-static bounds
13238
13239 @noindent
13240 If the bounds of the aggregate are not statically compatible with the bounds
13241 of the nominal subtype  of the target, then constraint checks have to be
13242 generated on the bounds.  For a multidimensional array, constraint checks may
13243 have to be applied to sub-arrays individually, if they do not have statically
13244 compatible subtypes.
13245
13246 @node Aggregates in assignment statements
13247 @subsection Aggregates in assignment statements
13248
13249 @noindent
13250 In general, aggregate assignment requires the construction of a temporary,
13251 and a copy from the temporary to the target of the assignment.  This is because
13252 it is not always possible to convert the assignment into a series of individual
13253 component assignments.  For example, consider the simple case:
13254
13255 @smallexample @c ada
13256         A := (A(2), A(1));
13257 @end smallexample
13258
13259 @noindent
13260 This cannot be converted into:
13261
13262 @smallexample @c ada
13263         A(1) := A(2);
13264         A(2) := A(1);
13265 @end smallexample
13266
13267 @noindent
13268 So the aggregate has to be built first in a separate location, and then
13269 copied into the target.  GNAT recognizes simple cases where this intermediate
13270 step is not required, and the assignments can be performed in place, directly
13271 into the target.  The following sufficient criteria are applied:
13272
13273 @itemize @bullet
13274 @item
13275 The bounds of the aggregate are static, and the associations are static.
13276 @item
13277 The components of the aggregate are static constants, names of
13278 simple variables that are not renamings, or expressions not involving
13279 indexed components whose operands obey these rules.
13280 @end itemize
13281
13282 @noindent
13283 If any of these conditions are violated, the aggregate will be built in
13284 a temporary (created either by the front-end or the code generator) and then
13285 that temporary will be copied onto the target.
13286
13287 @node Project File Reference
13288 @chapter Project File Reference
13289
13290 @noindent
13291 This chapter describes the syntax and semantics of project files.
13292 Project files specify the options to be used when building a system.
13293 Project files can specify global settings for all tools,
13294 as well as tool-specific settings.
13295 See the chapter on project files in the GNAT Users guide for examples of use.
13296
13297 @menu
13298 * Reserved Words::
13299 * Lexical Elements::
13300 * Declarations::
13301 * Typed string declarations::
13302 * Variables::
13303 * Expressions::
13304 * Attributes::
13305 * Project Attributes::
13306 * Attribute References::
13307 * External Values::
13308 * Case Construction::
13309 * Packages::
13310 * Package Renamings::
13311 * Projects::
13312 * Project Extensions::
13313 * Project File Elaboration::
13314 @end menu
13315
13316 @node Reserved Words
13317 @section Reserved Words
13318
13319 @noindent
13320 All Ada95 reserved words are reserved in project files, and cannot be used
13321 as variable names or project names. In addition, the following are
13322 also reserved in project files:
13323
13324 @itemize
13325 @item @code{extends}
13326
13327 @item @code{external}
13328
13329 @item @code{project}
13330
13331 @end itemize
13332
13333 @node Lexical Elements
13334 @section Lexical Elements
13335
13336 @noindent
13337 Rules for identifiers are the same as in Ada95. Identifiers
13338 are case-insensitive.  Strings are case sensitive, except where noted.
13339 Comments have the same form as in Ada95.
13340
13341 @noindent
13342 Syntax:
13343
13344 @smallexample
13345 simple_name ::=
13346   identifier
13347
13348 name ::=
13349   simple_name @{. simple_name@}
13350 @end smallexample
13351
13352 @node Declarations
13353 @section Declarations
13354
13355 @noindent
13356 Declarations introduce new entities that denote types, variables, attributes,
13357 and packages. Some declarations can only appear immediately within a project
13358 declaration. Others can appear within a project or within a package.
13359
13360 Syntax:
13361 @smallexample
13362 declarative_item ::=
13363   simple_declarative_item |
13364   typed_string_declaration |
13365   package_declaration
13366
13367 simple_declarative_item ::=
13368   variable_declaration |
13369   typed_variable_declaration |
13370   attribute_declaration |
13371   case_construction
13372 @end smallexample
13373
13374 @node Typed string declarations
13375 @section Typed string declarations
13376
13377 @noindent
13378 Typed strings are sequences of string literals. Typed strings are the only
13379 named types in project files. They are used in case constructions, where they
13380 provide support for conditional attribute definitions.
13381
13382 Syntax:
13383 @smallexample
13384 typed_string_declaration ::=
13385   @b{type} <typed_string_>_simple_name @b{is}
13386    ( string_literal @{, string_literal@} );
13387 @end smallexample
13388
13389 @noindent
13390 A typed string declaration can only appear immediately within a project
13391 declaration.
13392
13393 All the string literals in a typed string declaration must be distinct.
13394
13395 @node Variables
13396 @section Variables
13397
13398 @noindent
13399 Variables denote values, and appear as constituents of expressions.
13400
13401 @smallexample
13402 typed_variable_declaration ::=
13403   <typed_variable_>simple_name : <typed_string_>name :=  string_expression ;
13404
13405 variable_declaration ::=
13406   <variable_>simple_name := expression;
13407 @end smallexample
13408
13409 @noindent
13410 The elaboration of a variable declaration introduces the variable and
13411 assigns to it the value of the expression. The name of the variable is
13412 available after the assignment symbol.
13413
13414 @noindent
13415 A typed_variable can only be declare once.
13416
13417 @noindent
13418 a non typed variable can be declared multiple times.
13419
13420 @noindent
13421 Before the completion of its first declaration, the value of variable
13422 is the null string.
13423
13424 @node Expressions
13425 @section Expressions
13426
13427 @noindent
13428 An expression is a formula that defines a computation or retrieval of a value.
13429 In a project file the value of an expression is either a string or a list
13430 of strings. A string value in an expression is either a literal, the current
13431 value of a variable, an external value, an attribute reference, or a
13432 concatenation operation.
13433
13434 Syntax:
13435
13436 @smallexample
13437 expression ::=
13438   term @{& term@}
13439
13440 term ::=
13441   string_literal |
13442   string_list |
13443   <variable_>name |
13444   external_value |
13445   attribute_reference
13446
13447 string_literal ::=
13448   (same as Ada)
13449
13450 string_list ::=
13451   ( <string_>expression @{ , <string_>expression @} )
13452 @end smallexample
13453
13454 @subsection Concatenation
13455 @noindent
13456 The following concatenation functions are defined:
13457
13458 @smallexample @c ada
13459   function "&" (X : String;      Y : String)      return String;
13460   function "&" (X : String_List; Y : String)      return String_List;
13461   function "&" (X : String_List; Y : String_List) return String_List;
13462 @end smallexample
13463
13464 @node Attributes
13465 @section Attributes
13466
13467 @noindent
13468 An attribute declaration defines a property of a project or package. This
13469 property can later be queried by means of an attribute reference.
13470 Attribute values are strings or string lists.
13471
13472 Some attributes are associative arrays. These attributes are mappings whose
13473 domain is a set of strings. These attributes are declared one association
13474 at a time, by specifying a point in the domain and the corresponding image
13475 of the attribute. They may also be declared as a full associative array,
13476 getting the same associations as the corresponding attribute in an imported
13477 or extended project.
13478
13479 Attributes that are not associative arrays are called simple attributes.
13480
13481 Syntax:
13482 @smallexample
13483 attribute_declaration ::=
13484   full_associative_array_declaration |
13485   @b{for} attribute_designator @b{use} expression ;
13486
13487 full_associative_array_declaration ::=
13488   @b{for} <associative_array_attribute_>simple_name @b{use}
13489   <project_>simple_name [ . <package_>simple_Name ] ' <attribute_>simple_name ;
13490
13491 attribute_designator ::=
13492   <simple_attribute_>simple_name |
13493   <associative_array_attribute_>simple_name ( string_literal )
13494 @end smallexample
13495
13496 @noindent
13497 Some attributes are project-specific, and can only appear immediately within
13498 a project declaration. Others are package-specific, and can only appear within
13499 the proper package.
13500
13501 The expression in an attribute definition must be a string or a string_list.
13502 The string literal appearing in the attribute_designator of an associative
13503 array attribute is case-insensitive.
13504
13505 @node Project Attributes
13506 @section Project Attributes
13507
13508 @noindent
13509 The following attributes apply to a project. All of them are simple
13510 attributes.
13511
13512 @table @code
13513 @item   Object_Dir
13514 Expression must be a path name. The attribute defines the
13515 directory in which the object files created by the build are to be placed. If
13516 not specified, object files are placed in the project directory.
13517
13518 @item   Exec_Dir
13519 Expression must be a path name. The attribute defines the
13520 directory in which the executables created by the build are to be placed.
13521 If not specified, executables are placed in the object directory.
13522
13523 @item  Source_Dirs
13524 Expression must be a list of path names. The attribute
13525 defines the directories in which the source files for the project are to be
13526 found. If not specified, source files are found in the project directory.
13527
13528 @item  Source_Files
13529 Expression must be a list of file names. The attribute
13530 defines the individual files, in the project directory, which are to be used
13531 as sources for the project. File names are path_names that contain no directory
13532 information. If the project has no sources the attribute must be declared
13533 explicitly with an empty list.
13534
13535 @item  Source_List_File
13536 Expression must a single path name. The attribute
13537 defines a text file that contains a list of source file names to be used
13538 as sources for the project
13539
13540 @item  Library_Dir
13541 Expression must be a path name. The attribute defines the
13542 directory in which a  library is to be built.  The directory must exist, must
13543 be distinct from the project's object directory, and must be writable.
13544
13545 @item  Library_Name
13546 Expression must be a string that is a legal file name,
13547 without extension. The attribute defines a string that is used to generate
13548 the name of the library to be built by the project.
13549
13550 @item  Library_Kind
13551 Argument must be a string value that must be one of the
13552 following @code{"static"}, @code{"dynamic"} or @code{"relocatable"}. This
13553 string is case-insensitive. If this attribute is not specified, the library is
13554 a static library. Otherwise, the library may be dynamic or relocatable. This
13555 distinction is operating-system dependent.
13556
13557 @item  Library_Version
13558 Expression must be a string value whose interpretation
13559 is platform dependent. On UNIX, it is used only for dynamic/relocatable
13560 libraries as the internal name of the library (the @code{"soname"}). If the
13561 library file name (built from the @code{Library_Name}) is different from the
13562 @code{Library_Version}, then the library file will be a symbolic link to the
13563 actual file whose name will be @code{Library_Version}.
13564
13565 @item Library_Interface
13566 Expression must be a string list. Each element of the string list
13567 must designate a unit of the project.
13568 If this attribute is present in a Library Project File, then the project
13569 file is a Stand-alone Library_Project_File.
13570
13571 @item Library_Auto_Init
13572 Expression must be a single string "true" or "false", case-insensitive.
13573 If this attribute is present in a Stand-alone Library Project File,
13574 it indicates if initialization is automatic when the dynamic library
13575 is loaded.
13576
13577 @item Library_Options
13578 Expression must be a string list. Indicates additional switches that
13579 are to be used when building a shared library.
13580
13581 @item Library_GCC
13582 Expression must be a single string. Designates an alternative to "gcc"
13583 for building shared libraries.
13584
13585 @item  Library_Src_Dir
13586 Expression must be a path name. The attribute defines the
13587 directory in which the sources of the interfaces of a Stand-alone Library will
13588 be copied.  The directory must exist, must be distinct from the project's
13589 object directory and source directories, and must be writable.
13590
13591 @item  Main
13592 Expression must be a list of strings that are legal file names.
13593 These file names designate existing compilation units in the source directory
13594 that are legal main subprograms.
13595
13596 When a project file is elaborated, as part of the execution of a gnatmake
13597 command, one or several executables are built and placed in the Exec_Dir.
13598 If the gnatmake command does not include explicit file names, the executables
13599 that are built correspond to the files specified by this attribute.
13600
13601 @item Main_Language
13602 This is a simple attribute. Its value is a string that specifies the
13603 language of the main program.
13604
13605 @item  Languages
13606 Expression must be a string list. Each string designates
13607 a programming language that is known to GNAT. The strings are case-insensitive.
13608
13609 @item  Locally_Removed_Files
13610 This attribute is legal only in a project file that extends another.
13611 Expression must be a list of strings that are legal file names.
13612 Each file name must designate a source that would normally be inherited
13613 by the current project file. It cannot designate an immediate source that is
13614 not inherited. Each of the source files in the list are not considered to
13615 be sources of the project file: they are not inherited.
13616 @end table
13617
13618 @node Attribute References
13619 @section Attribute References
13620
13621 @noindent
13622 Attribute references are used to retrieve the value of previously defined
13623 attribute for a package or project.
13624 Syntax:
13625 @smallexample
13626 attribute_reference ::=
13627   attribute_prefix ' <simple_attribute_>simple_name [ ( string_literal ) ]
13628
13629 attribute_prefix ::=
13630   @b{project} |
13631   <project_simple_name | package_identifier |
13632   <project_>simple_name . package_identifier
13633 @end smallexample
13634
13635 @noindent
13636 If an attribute has not been specified for a given package or project, its
13637 value is the null string or the empty list.
13638
13639 @node External Values
13640 @section External Values
13641
13642 @noindent
13643 An external value is an expression whose value is obtained from the command
13644 that invoked the processing of the current project file (typically a
13645 gnatmake command).
13646
13647 Syntax:
13648 @smallexample
13649 external_value ::=
13650   @b{external} ( string_literal [, string_literal] )
13651 @end smallexample
13652
13653 @noindent
13654 The first string_literal is the string to be used on the command line or
13655 in the environment to specify the external value. The second string_literal,
13656 if present, is the default to use if there is no specification for this
13657 external value either on the command line or in the environment.
13658
13659 @node Case Construction
13660 @section Case Construction
13661
13662 @noindent
13663 A case construction supports attribute declarations that depend on the value of
13664 a previously declared variable.
13665
13666 Syntax:
13667 @smallexample
13668 case_construction ::=
13669   @b{case} <typed_variable_>name @b{is}
13670     @{case_item@}
13671   @b{end case} ;
13672
13673 case_item ::=
13674   @b{when} discrete_choice_list =>
13675     @{case_construction | attribute_declaration@}
13676
13677 discrete_choice_list ::=
13678   string_literal @{| string_literal@} |
13679     @b{others}
13680 @end smallexample
13681
13682 @noindent
13683 All choices in a choice list must be distinct. The choice lists of two
13684 distinct alternatives must be disjoint. Unlike Ada, the choice lists of all
13685 alternatives do not need to include all values of the type. An @code{others}
13686 choice must appear last in the list of alternatives.
13687
13688 @node Packages
13689 @section Packages
13690
13691 @noindent
13692 A package provides a grouping of variable declarations and attribute
13693 declarations to be used when invoking various GNAT tools. The name of
13694 the package indicates the tool(s) to which it applies.
13695 Syntax:
13696
13697 @smallexample
13698 package_declaration ::=
13699   package_specification | package_renaming
13700
13701 package_specification ::=
13702   @b{package} package_identifier @b{is}
13703     @{simple_declarative_item@}
13704   @b{end} package_identifier ;
13705
13706 package_identifier ::=
13707   @code{Naming} | @code{Builder} | @code{Compiler} | @code{Binder} |
13708   @code{Linker} | @code{Finder}  | @code{Cross_Reference} |
13709   @code{gnatls} | @code{IDE}     | @code{Pretty_Printer}
13710 @end smallexample
13711
13712 @subsection Package Naming
13713
13714 @noindent
13715 The attributes of a @code{Naming} package specifies the naming conventions
13716 that apply to the source files in a project. When invoking other GNAT tools,
13717 they will use the sources in the source directories that satisfy these
13718 naming conventions.
13719
13720 The following attributes apply to a @code{Naming} package:
13721
13722 @table @code
13723 @item Casing
13724 This is a simple attribute whose value is a string. Legal values of this
13725 string are @code{"lowercase"}, @code{"uppercase"} or @code{"mixedcase"}.
13726 These strings are themselves case insensitive.
13727
13728 @noindent
13729 If @code{Casing} is not specified, then the default is @code{"lowercase"}.
13730
13731 @item Dot_Replacement
13732 This is a simple attribute whose string value satisfies the following
13733 requirements:
13734
13735 @itemize @bullet
13736 @item It must not be empty
13737 @item It cannot start or end with an alphanumeric character
13738 @item It cannot be a single underscore
13739 @item It cannot start with an underscore followed by an alphanumeric
13740 @item It cannot contain a dot @code{'.'} if longer than one character
13741 @end itemize
13742
13743 @noindent
13744 If @code{Dot_Replacement} is not specified, then the default is @code{"-"}.
13745
13746 @item Spec_Suffix
13747 This is an associative array attribute, defined on language names,
13748 whose image is a string that must satisfy the following
13749 conditions:
13750
13751 @itemize @bullet
13752 @item It must not be empty
13753 @item It cannot start with an alphanumeric character
13754 @item It cannot start with an underscore followed by an alphanumeric character
13755 @end itemize
13756
13757 @noindent
13758 For Ada, the attribute denotes the suffix used in file names that contain
13759 library unit declarations, that is to say units that are package and
13760 subprogram declarations. If @code{Spec_Suffix ("Ada")} is not
13761 specified, then the default is @code{".ads"}.
13762
13763 For C and C++, the attribute denotes the suffix used in file names that
13764 contain prototypes.
13765
13766 @item Body_Suffix
13767 This is an associative array attribute defined on language names,
13768 whose image is a string that must satisfy the following
13769 conditions:
13770
13771 @itemize @bullet
13772 @item It must not be empty
13773 @item It cannot start with an alphanumeric character
13774 @item It cannot start with an underscore followed by an alphanumeric character
13775 @item It cannot be a suffix of @code{Spec_Suffix}
13776 @end itemize
13777
13778 @noindent
13779 For Ada, the attribute denotes the suffix used in file names that contain
13780 library bodies, that is to say units that are package and subprogram bodies.
13781 If @code{Body_Suffix ("Ada")} is not specified, then the default is
13782 @code{".adb"}.
13783
13784 For C and C++, the attribute denotes the suffix used in file names that contain
13785 source code.
13786
13787 @item Separate_Suffix
13788 This is a simple attribute whose value satisfies the same conditions as
13789 @code{Body_Suffix}.
13790
13791 This attribute is specific to Ada. It denotes the suffix used in file names
13792 that contain separate bodies. If it is not specified, then it defaults to same
13793 value as @code{Body_Suffix ("Ada")}.
13794
13795 @item Spec
13796 This is an associative array attribute, specific to Ada, defined over
13797 compilation unit names. The image is a string that is the name of the file
13798 that contains that library unit. The file name is case sensitive if the
13799 conventions of the host operating system require it.
13800
13801 @item Body
13802 This is an associative array attribute, specific to Ada, defined over
13803 compilation unit names. The image is a string that is the name of the file
13804 that contains the library unit body for the named unit. The file name is case
13805 sensitive if the conventions of the host operating system require it.
13806
13807 @item Specification_Exceptions
13808 This is an associative array attribute defined on language names,
13809 whose value is a list of strings.
13810
13811 This attribute is not significant for Ada.
13812
13813 For C and C++, each string in the list denotes the name of a file that
13814 contains prototypes, but whose suffix is not necessarily the
13815 @code{Spec_Suffix} for the language.
13816
13817 @item Implementation_Exceptions
13818 This is an associative array attribute defined on language names,
13819 whose value is a list of strings.
13820
13821 This attribute is not significant for Ada.
13822
13823 For C and C++, each string in the list denotes the name of a file that
13824 contains source code, but whose suffix is not necessarily the
13825 @code{Body_Suffix} for the language.
13826 @end table
13827
13828 The following attributes of package @code{Naming} are obsolescent. They are
13829 kept as synonyms of other attributes for compatibility with previous versions
13830 of the Project Manager.
13831
13832 @table @code
13833 @item Specification_Suffix
13834 This is a synonym of @code{Spec_Suffix}.
13835
13836 @item Implementation_Suffix
13837 This is a synonym of @code{Body_Suffix}.
13838
13839 @item Specification
13840 This is a synonym of @code{Spec}.
13841
13842 @item Implementation
13843 This is a synonym of @code{Body}.
13844 @end table
13845
13846 @subsection package Compiler
13847
13848 @noindent
13849 The attributes of the @code{Compiler} package specify the compilation options
13850 to be used by the underlying compiler.
13851
13852 @table @code
13853 @item  Default_Switches
13854 This is an associative array attribute. Its
13855 domain is a set of language names. Its range is a string list that
13856 specifies the compilation options to be used when compiling a component
13857 written in that language, for which no file-specific switches have been
13858 specified..
13859
13860 @item  Switches
13861 This is an associative array attribute. Its domain is
13862 a set of file names. Its range is a string list that specifies the
13863 compilation options to be used when compiling the named file. If a file
13864 is not specified in the Switches attribute, it is compiled with the
13865 settings specified by Default_Switches.
13866
13867 @item  Local_Configuration_Pragmas.
13868 This is a simple attribute, whose
13869 value is a path name that designates a file containing configuration pragmas
13870 to be used for all invocations of the compiler for immediate sources of the
13871 project.
13872
13873 @item Executable
13874 This is an associative array attribute. Its domain is
13875 a set of main source file names. Its range is a simple string that specifies
13876 the executable file name to be used when linking the specified main source.
13877 If a main source is not specified in the Executable attribute, the executable
13878 file name is deducted from the main source file name.
13879 @end table
13880
13881 @subsection package Builder
13882
13883 @noindent
13884 The attributes of package @code{Builder} specify the compilation, binding, and
13885 linking options to be used when building an executable for a project. The
13886 following attributes apply to package @code{Builder}:
13887
13888 @table @code
13889 @item Default_Switches
13890 As above.
13891
13892 @item Switches
13893 As above.
13894
13895 @item Global_Configuration_Pragmas
13896 This is a simple attribute, whose
13897 value is a path name that designates a file that contains configuration pragmas
13898 to be used in every build of an executable. If both local and global
13899 configuration pragmas are specified, a compilation makes use of both sets.
13900
13901 @item Executable
13902 This is an associative array attribute, defined over
13903 compilation unit names. The image is a string that is the name of the
13904 executable file corresponding to the main source file index.
13905 This attribute has no effect if its value is the empty string.
13906
13907 @item Executable_Suffix
13908 This is a simple attribute whose value is a suffix to be added to
13909 the executables that don't have an attribute Executable specified.
13910 @end table
13911
13912 @subsection package Gnatls
13913
13914 @noindent
13915 The attributes of package @code{Gnatls} specify the tool options to be used
13916 when invoking the library browser @command{gnatls}.
13917 The following attributes apply to package @code{Gnatls}:
13918
13919 @table @code
13920 @item Switches
13921 As above.
13922 @end table
13923
13924 @subsection package Binder
13925
13926 @noindent
13927 The attributes of package @code{Binder} specify the options to be used
13928 when invoking the binder in the construction of an executable.
13929 The following attributes apply to package @code{Binder}:
13930
13931 @table @code
13932 @item     Default_Switches
13933 As above.
13934 @item     Switches
13935 As above.
13936 @end table
13937
13938 @subsection package Linker
13939
13940 @noindent
13941 The attributes of package @code{Linker} specify the options to be used when
13942 invoking the linker in the construction of an executable.
13943 The following attributes apply to package @code{Linker}:
13944
13945 @table @code
13946 @item     Default_Switches
13947 As above
13948 @item     Switches
13949 As above.
13950 @end table
13951
13952 @subsection package Cross_Reference
13953
13954 @noindent
13955 The attributes of package @code{Cross_Reference} specify the tool options
13956 to be used
13957 when invoking the library tool @command{gnatxref}.
13958 The following attributes apply to package @code{Cross_Reference}:
13959
13960 @table @code
13961 @item     Default_Switches
13962 As above.
13963 @item     Switches
13964 As above.
13965 @end table
13966
13967 @subsection package   Finder
13968
13969 @noindent
13970 The attributes of package @code{Finder} specify the tool options to be used
13971 when invoking the search tool @command{gnatfind}.
13972 The following attributes apply to package @code{Finder}:
13973
13974 @table @code
13975 @item     Default_Switches
13976 As above.
13977 @item     Switches
13978 As above.
13979 @end table
13980
13981 @subsection package Pretty_Printer
13982
13983 @noindent
13984 The attributes of package @code{Pretty_Printer}
13985 specify the tool options to be used
13986 when invoking the formatting tool @command{gnatpp}.
13987 The following attributes apply to package @code{Pretty_Printer}:
13988
13989 @table @code
13990 @item     Default_switches
13991 As above.
13992 @item     Switches
13993 As above.
13994 @end table
13995
13996 @subsection  package IDE
13997
13998 @noindent
13999 The attributes of package @code{IDE} specify the options to be used when using
14000 an Integrated Development Environment such as @command{GPS}.
14001
14002 @table @code
14003 @item Remote_Host
14004 This is a simple attribute. Its value is a string that designates the remote
14005 host in a cross-compilation environment, to be used for remote compilation and
14006 debugging. This field should not be specified when running on the local
14007 machine.
14008
14009 @item Program_Host
14010 This is a simple attribute. Its value is a string that specifies the
14011 name of IP address of the embedded target in a cross-compilation environment,
14012 on which the program should execute.
14013
14014 @item Communication_Protocol
14015 This is a simple string attribute. Its value is the name of the protocol
14016 to use to communicate with the target in a cross-compilation environment,
14017 e.g. @code{"wtx"} or @code{"vxworks"}.
14018
14019 @item Compiler_Command
14020 This is an associative array attribute, whose domain is a language name. Its
14021 value is  string that denotes the command to be used to invoke the compiler.
14022 The value of @code{Compiler_Command ("Ada")} is expected to be compatible with
14023 gnatmake, in particular in the handling of switches.
14024
14025 @item Debugger_Command
14026 This is simple attribute, Its value is a string that specifies the name of
14027 the debugger to be used, such as gdb, powerpc-wrs-vxworks-gdb or gdb-4.
14028
14029 @item Default_Switches
14030 This is an associative array attribute. Its indexes are the name of the
14031 external tools that the GNAT Programming System (GPS) is supporting. Its
14032 value is a list of switches to use when invoking that tool.
14033
14034 @item  Gnatlist
14035 This is a simple attribute.  Its value is a string that specifies the name
14036 of the @command{gnatls} utility to be used to retrieve information about the
14037 predefined path; e.g., @code{"gnatls"}, @code{"powerpc-wrs-vxworks-gnatls"}.
14038
14039 @item VCS_Kind
14040 This is a simple atribute. Is value is a string used to specify the
14041 Version Control System (VCS) to be used for this project, e.g CVS, RCS
14042 ClearCase or Perforce.
14043
14044 @item VCS_File_Check
14045 This is a simple attribute. Its value is a string that specifies the
14046 command used by the VCS to check the validity of a file, either
14047 when the user explicitly asks for a check, or as a sanity check before
14048 doing the check-in.
14049
14050 @item VCS_Log_Check
14051 This is a simple attribute. Its value is a string that specifies
14052 the command used by the VCS to check the validity of a log file.
14053
14054 @end table
14055
14056 @node Package Renamings
14057 @section Package Renamings
14058
14059 @noindent
14060 A package can be defined by a renaming declaration. The new package renames
14061 a package declared in a different project file, and has the same attributes
14062 as the package it renames.
14063 Syntax:
14064 @smallexample
14065 package_renaming ::==
14066   @b{package} package_identifier @b{renames}
14067        <project_>simple_name.package_identifier ;
14068 @end smallexample
14069
14070 @noindent
14071 The package_identifier of the renamed package must be the same as the
14072 package_identifier. The project whose name is the prefix of the renamed
14073 package must contain a package declaration with this name. This project
14074 must appear in the context_clause of the enclosing project declaration,
14075 or be the parent project of the enclosing child project.
14076
14077 @node Projects
14078 @section Projects
14079
14080 @noindent
14081 A project file specifies a set of rules for constructing a software system.
14082 A project file can be self-contained, or depend on other project files.
14083 Dependencies are expressed through a context clause that names other projects.
14084
14085 Syntax:
14086
14087 @smallexample
14088 project ::=
14089   context_clause project_declaration
14090
14091 project_declaration ::=
14092   simple_project_declaration | project_extension
14093
14094 simple_project_declaration ::=
14095   @b{project} <project_>simple_name @b{is}
14096     @{declarative_item@}
14097   @b{end} <project_>simple_name;
14098
14099 context_clause ::=
14100   @{with_clause@}
14101
14102 with_clause ::=
14103   [@b{limited}] @b{with} path_name @{ , path_name @} ;
14104
14105 path_name ::=
14106    string_literal
14107 @end smallexample
14108
14109 @noindent
14110 A path name denotes a project file. A path name can be absolute or relative.
14111 An absolute path name includes a sequence of directories, in the syntax of
14112 the host operating system, that identifies uniquely the project file in the
14113 file system. A relative path name identifies the project file, relative
14114 to the directory that contains the current project, or relative to a
14115 directory listed in the environment variable ADA_PROJECT_PATH.
14116 Path names are case sensitive if file names in the host operating system
14117 are case sensitive.
14118
14119 The syntax of the environment variable ADA_PROJECT_PATH is a list of
14120 directory names separated by colons (semicolons on Windows).
14121
14122 A given project name can appear only once in a context_clause.
14123
14124 It is illegal for a project imported by a context clause to refer, directly
14125 or indirectly, to the project in which this context clause appears (the
14126 dependency graph cannot contain cycles), except when one of the with_clause
14127 in the cycle is a @code{limited with}.
14128
14129 @node Project Extensions
14130 @section Project Extensions
14131
14132 @noindent
14133 A project extension introduces a new project, which inherits the declarations
14134 of another project.
14135 Syntax:
14136 @smallexample
14137
14138 project_extension ::=
14139   @b{project} <project_>simple_name  @b{extends} path_name @b{is}
14140     @{declarative_item@}
14141   @b{end} <project_>simple_name;
14142 @end smallexample
14143
14144 @noindent
14145 The project extension declares a child project. The child project inherits
14146 all the declarations and all the files of the parent project, These inherited
14147 declaration can be overridden in the child project, by means of suitable
14148 declarations.
14149
14150 @node Project File Elaboration
14151 @section Project File Elaboration
14152
14153 @noindent
14154 A project file is processed as part of the invocation of a gnat tool that
14155 uses the project option. Elaboration of the process file consists in the
14156 sequential elaboration of all its declarations. The computed values of
14157 attributes and variables in the project are then used to establish the
14158 environment in which the gnat tool will execute.
14159
14160 @include fdl.texi
14161 @c GNU Free Documentation License
14162
14163 @node Index,,GNU Free Documentation License, Top
14164 @unnumbered Index
14165
14166 @printindex cp
14167
14168 @contents
14169
14170 @bye